-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(connector): [Novalnet] Add zero auth mandate #6631
base: main
Are you sure you want to change the base?
Conversation
Changed Files
|
df85bb8
to
4fdf8c1
Compare
let enforce_3d = match item.auth_type { | ||
enums::AuthenticationType::ThreeDs => Some(1), | ||
enums::AuthenticationType::NoThreeDs => None, | ||
}; | ||
let test_mode = match item.test_mode { | ||
Some(true) => 1, | ||
Some(false) | None => 0, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider using constants or enums here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, sure
mobile: item.get_optional_billing_phone_number(), | ||
billing: Some(billing), | ||
// no_nc is used to indicate if minimal customer data is passed or not | ||
no_nc: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use constants here.
let custom = NovalnetCustom { lang }; | ||
let hook_url = item.request.get_webhook_url()?; | ||
let return_url = item.request.get_return_url()?; | ||
let create_token = Some(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
let webhook_url = Some(helpers::create_webhook_url( | ||
router_base_url, | ||
&attempt.merchant_id, | ||
connector_name, | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Narayanbhat166 @sai-harsha-vardhan Should we consider passing MerchantConnectorAccountId
here, instead of the connector name? Basically update the create_webhook_url()
function as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's always recommended to use MerchantConnectorAccountId
in webhook url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sai-harsha-vardhan @SanchithHegde I made a new fn create_webhook_url_using_mca_id
,but only used it in line 226 (crates/router/src/core/payments/transformers.rs:226) . In the other places where create_webhook_url()
is currently used the MerchantConnectorAccountId value is Optional
, so we cant replace connector name with simply MerchantConnectorAccountId.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will always have the merchant_connector_id
when constructing the router data. So if it is not found you can raise an internal server error.
I do not see any harm in updating the existing webhook function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the existing create_webhook_url fn
4fdf8c1
to
0b20c37
Compare
0b20c37
to
73667aa
Compare
0fd4b9a
to
64d9202
Compare
4c94106
4c94106
to
004a8b6
Compare
) -> String { | ||
format!( | ||
"{}/webhooks/{}/{}", | ||
"/webhooks/{}/{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the base url should be in the beginning, and there are only two params in the format string, whereas there are three parameters
@@ -2322,7 +2322,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz | |||
let payment_data = additional_data.payment_data.clone(); | |||
let router_base_url = &additional_data.router_base_url; | |||
let connector_name = &additional_data.connector_name; | |||
let attempt = &payment_data.payment_attempt; | |||
let attempt = &payment_data.payment_attempt.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we cloning the attempt here? clone the fields instead
004a8b6
to
9f96ab9
Compare
b94e6f7
to
6553eee
Compare
31be626
to
3053db8
Compare
#[serde(untagged)] | ||
pub enum NovalNetAmount { | ||
StringMinor(StringMinorUnit), | ||
Int(i64), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use MinorUnit
here right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I will take this up in a separate PR #6981
a3cf7e0
3053db8
to
a3cf7e0
Compare
@@ -2745,11 +2745,17 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz | |||
attempt, | |||
connector_name, | |||
)); | |||
|
|||
let merchant_connector_account_id = payment_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sahkal @sai-harsha-vardhan we will not have merchant_connector_id
in case of tunnel payments right? I think we need to provide a fallback to connector_name
if merchant connector id is not present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, correct! but again putting a fallback to fetch with connector_name
would also not work since tunnel merchant will never have a MCA in Hs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes that is a valid point, we cannot make merchant_connector_id
as mandatory is what my concern is, because it will not be present in case of creds_identifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added connector_name
as fallback
c595f10
a3cf7e0
to
c595f10
Compare
@@ -3569,6 +3578,19 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ | |||
.map(|customer| customer.clone().into_inner()) | |||
}); | |||
let amount = payment_data.payment_attempt.get_total_amount(); | |||
let merchant_connector_account_id = payment_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the fallback here as well
.payment_attempt | ||
.merchant_connector_id | ||
.clone() | ||
.get_required_value("merchant_connector_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide the fallback here as well
Type of Change
Description
create_webhook_url
fn can acceptmerchant_connector_account_id
instead ofconnector_name
Additional Changes
Motivation and Context
How did you test it?
Note:
Skipping no3ds test cases as it is not supported by novalnet cc: @Likhin Bopanna
Tested manually
https://docs.google.com/document/d/1i4SSX837Dh9ipfOz24bDwJF8osR_UPmfPLWUbLP3bh0/edit?usp=sharing
Webhooks working as expected for /payments. Tested locally.
Checklist
cargo +nightly fmt --all
cargo clippy