Skip to content

Commit

Permalink
add cypress test trigger skip for no3ds zero auth mandate config
Browse files Browse the repository at this point in the history
  • Loading branch information
cookieg13 committed Jan 3, 2025
1 parent 39a645b commit c595f10
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 19 deletions.
18 changes: 10 additions & 8 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6564,14 +6564,16 @@ pub async fn payment_external_authentication(
&payment_attempt.clone(),
payment_connector_name,
));
let merchant_connector_account_id = payment_attempt
.merchant_connector_id
.clone()
.get_required_value("merchant_connector_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Merchant connector id is not present in payment_attempt")?;
let webhook_url =
helpers::create_webhook_url(&state.base_url, merchant_id, &merchant_connector_account_id);
let merchant_connector_account_id = merchant_connector_account
.get_mca_id()
.ok_or(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while finding mca_id from merchant_connector_account")?;

let webhook_url = helpers::create_webhook_url(
&state.base_url,
merchant_id,
&merchant_connector_account_id.get_string_repr().to_string(),
);

let authentication_details = business_profile
.authentication_connector_details
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,13 +1243,13 @@ pub fn create_authorize_url(
pub fn create_webhook_url(
router_base_url: &String,
merchant_id: &id_type::MerchantId,
merchant_connector_id: &id_type::MerchantConnectorAccountId,
merchant_connector_id_or_connector_name: &String,
) -> String {
format!(
"{}/webhooks/{}/{}",
router_base_url,
merchant_id.get_string_repr(),
merchant_connector_id.get_string_repr(),
merchant_connector_id_or_connector_name,
)
}

Expand Down
14 changes: 7 additions & 7 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
let webhook_url = Some(helpers::create_webhook_url(
router_base_url,
&attempt.merchant_id,
&merchant_connector_account.get_id(),
&merchant_connector_account.get_id().get_string_repr().to_string(),
));

let router_return_url = payment_data
Expand Down Expand Up @@ -2747,11 +2747,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
));
let merchant_connector_account_id = payment_data
.payment_attempt
.merchant_connector_id
.clone()
.get_required_value("merchant_connector_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Merchant connector id is not present in payment_attempt")?;
.merchant_connector_id
.map(|mca_id| mca_id.get_string_repr().to_string())
.unwrap_or(connector_name.to_string());

let webhook_url = Some(helpers::create_webhook_url(
router_base_url,
&attempt.merchant_id,
Expand Down Expand Up @@ -3585,7 +3585,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
let webhook_url = Some(helpers::create_webhook_url(
router_base_url,
&attempt.merchant_id,
&merchant_connector_account_id,
&merchant_connector_account_id.get_string_repr().to_string(),
));

Ok(Self {
Expand Down Expand Up @@ -3794,7 +3794,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
let webhook_url = Some(helpers::create_webhook_url(
router_base_url,
&attempt.merchant_id,
&merchant_connector_account_id,
&merchant_connector_account_id.get_string_repr().to_string(),
));
let router_return_url = Some(helpers::create_redirect_url(
router_base_url,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/relay/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub async fn construct_relay_refund_router_data<'a, F>(
let webhook_url = Some(payments::helpers::create_webhook_url(
&state.base_url.clone(),
merchant_id,
connector_name,
&connector_account.get_id().get_string_repr().to_string(),
));

let supported_connector = &state
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ pub async fn construct_refund_router_data<'a, F>(
let webhook_url = Some(helpers::create_webhook_url(
&state.base_url.clone(),
merchant_account.get_id(),
&merchant_connector_account_id,
&merchant_connector_account_id.get_string_repr().to_string(),
));
let test_mode: Option<bool> = merchant_connector_account.is_test_mode_on();

Expand Down
106 changes: 106 additions & 0 deletions cypress-tests/cypress/e2e/PaymentUtils/Novalnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ const successfulThreeDSTestCardDetails = {
card_cvc: "123",
};

const successfulNo3DSCardDetails = {
card_number: "4242424242424242",
card_exp_month: "01",
card_exp_year: "50",
card_holder_name: "joseph Doe",
card_cvc: "123",
};

const singleUseMandateData = {
customer_acceptance: {
acceptance_type: "offline",
accepted_at: "1963-05-03T04:07:52.723Z",
online: {
ip_address: "125.0.0.1",
user_agent: "amet irure esse",
},
},
mandate_type: {
single_use: {
amount: 8000,
currency: "EUR",
},
},
};

export const connectorDetails = {
card_pm: {
PaymentIntent: {
Expand Down Expand Up @@ -206,5 +231,86 @@ export const connectorDetails = {
},
},
},
SaveCardConfirmAutoCaptureOffSession: {
Request: {
setup_future_usage: "off_session",
},
Response: {
status: 200,
trigger_skip: true,
body: {
status: "requires_customer_action",
},
},
},
PaymentIntentOffSession: {
Request: {
currency: "EUR",
amount: 6500,
authentication_type: "no_three_ds",
customer_acceptance: null,
setup_future_usage: "off_session",
},
Response: {
status: 200,
trigger_skip: true,
body: {
status: "requires_payment_method",
setup_future_usage: "off_session",
},
},
},
ZeroAuthPaymentIntent: {
Request: {
amount: 0,
setup_future_usage: "off_session",
currency: "EUR",
},
Response: {
status: 200,
trigger_skip: true,
body: {
status: "requires_payment_method",
setup_future_usage: "off_session",
},
},
},
ZeroAuthMandate: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "USD",
mandate_data: singleUseMandateData,
},
Response: {
status: 200,
trigger_skip: true,
body: {
status: "succeeded",
},
},
},
ZeroAuthConfirmPayment: {
Request: {
payment_type: "setup_mandate",
payment_method: "card",
payment_method_type: "credit",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
},
Response: {
status: 501,
body: {
error: {
type: "invalid_request",
message: "Setup Mandate flow for Novalnet is not implemented",
code: "IR_00",
},
},
},
},
},
};

0 comments on commit c595f10

Please sign in to comment.