Skip to content

Commit c595f10

Browse files
committed
add cypress test trigger skip for no3ds zero auth mandate config
1 parent 39a645b commit c595f10

File tree

6 files changed

+127
-19
lines changed

6 files changed

+127
-19
lines changed

crates/router/src/core/payments.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -6564,14 +6564,16 @@ pub async fn payment_external_authentication(
65646564
&payment_attempt.clone(),
65656565
payment_connector_name,
65666566
));
6567-
let merchant_connector_account_id = payment_attempt
6568-
.merchant_connector_id
6569-
.clone()
6570-
.get_required_value("merchant_connector_id")
6571-
.change_context(errors::ApiErrorResponse::InternalServerError)
6572-
.attach_printable("Merchant connector id is not present in payment_attempt")?;
6573-
let webhook_url =
6574-
helpers::create_webhook_url(&state.base_url, merchant_id, &merchant_connector_account_id);
6567+
let merchant_connector_account_id = merchant_connector_account
6568+
.get_mca_id()
6569+
.ok_or(errors::ApiErrorResponse::InternalServerError)
6570+
.attach_printable("Error while finding mca_id from merchant_connector_account")?;
6571+
6572+
let webhook_url = helpers::create_webhook_url(
6573+
&state.base_url,
6574+
merchant_id,
6575+
&merchant_connector_account_id.get_string_repr().to_string(),
6576+
);
65756577

65766578
let authentication_details = business_profile
65776579
.authentication_connector_details

crates/router/src/core/payments/helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1243,13 +1243,13 @@ pub fn create_authorize_url(
12431243
pub fn create_webhook_url(
12441244
router_base_url: &String,
12451245
merchant_id: &id_type::MerchantId,
1246-
merchant_connector_id: &id_type::MerchantConnectorAccountId,
1246+
merchant_connector_id_or_connector_name: &String,
12471247
) -> String {
12481248
format!(
12491249
"{}/webhooks/{}/{}",
12501250
router_base_url,
12511251
merchant_id.get_string_repr(),
1252-
merchant_connector_id.get_string_repr(),
1252+
merchant_connector_id_or_connector_name,
12531253
)
12541254
}
12551255

crates/router/src/core/payments/transformers.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
224224
let webhook_url = Some(helpers::create_webhook_url(
225225
router_base_url,
226226
&attempt.merchant_id,
227-
&merchant_connector_account.get_id(),
227+
&merchant_connector_account.get_id().get_string_repr().to_string(),
228228
));
229229

230230
let router_return_url = payment_data
@@ -2747,11 +2747,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
27472747
));
27482748
let merchant_connector_account_id = payment_data
27492749
.payment_attempt
2750-
.merchant_connector_id
27512750
.clone()
2752-
.get_required_value("merchant_connector_id")
2753-
.change_context(errors::ApiErrorResponse::InternalServerError)
2754-
.attach_printable("Merchant connector id is not present in payment_attempt")?;
2751+
.merchant_connector_id
2752+
.map(|mca_id| mca_id.get_string_repr().to_string())
2753+
.unwrap_or(connector_name.to_string());
2754+
27552755
let webhook_url = Some(helpers::create_webhook_url(
27562756
router_base_url,
27572757
&attempt.merchant_id,
@@ -3585,7 +3585,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
35853585
let webhook_url = Some(helpers::create_webhook_url(
35863586
router_base_url,
35873587
&attempt.merchant_id,
3588-
&merchant_connector_account_id,
3588+
&merchant_connector_account_id.get_string_repr().to_string(),
35893589
));
35903590

35913591
Ok(Self {
@@ -3794,7 +3794,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
37943794
let webhook_url = Some(helpers::create_webhook_url(
37953795
router_base_url,
37963796
&attempt.merchant_id,
3797-
&merchant_connector_account_id,
3797+
&merchant_connector_account_id.get_string_repr().to_string(),
37983798
));
37993799
let router_return_url = Some(helpers::create_redirect_url(
38003800
router_base_url,

crates/router/src/core/relay/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub async fn construct_relay_refund_router_data<'a, F>(
3232
let webhook_url = Some(payments::helpers::create_webhook_url(
3333
&state.base_url.clone(),
3434
merchant_id,
35-
connector_name,
35+
&connector_account.get_id().get_string_repr().to_string(),
3636
));
3737

3838
let supported_connector = &state

crates/router/src/core/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ pub async fn construct_refund_router_data<'a, F>(
294294
let webhook_url = Some(helpers::create_webhook_url(
295295
&state.base_url.clone(),
296296
merchant_account.get_id(),
297-
&merchant_connector_account_id,
297+
&merchant_connector_account_id.get_string_repr().to_string(),
298298
));
299299
let test_mode: Option<bool> = merchant_connector_account.is_test_mode_on();
300300

cypress-tests/cypress/e2e/PaymentUtils/Novalnet.js

+106
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ const successfulThreeDSTestCardDetails = {
66
card_cvc: "123",
77
};
88

9+
const successfulNo3DSCardDetails = {
10+
card_number: "4242424242424242",
11+
card_exp_month: "01",
12+
card_exp_year: "50",
13+
card_holder_name: "joseph Doe",
14+
card_cvc: "123",
15+
};
16+
17+
const singleUseMandateData = {
18+
customer_acceptance: {
19+
acceptance_type: "offline",
20+
accepted_at: "1963-05-03T04:07:52.723Z",
21+
online: {
22+
ip_address: "125.0.0.1",
23+
user_agent: "amet irure esse",
24+
},
25+
},
26+
mandate_type: {
27+
single_use: {
28+
amount: 8000,
29+
currency: "EUR",
30+
},
31+
},
32+
};
33+
934
export const connectorDetails = {
1035
card_pm: {
1136
PaymentIntent: {
@@ -206,5 +231,86 @@ export const connectorDetails = {
206231
},
207232
},
208233
},
234+
SaveCardConfirmAutoCaptureOffSession: {
235+
Request: {
236+
setup_future_usage: "off_session",
237+
},
238+
Response: {
239+
status: 200,
240+
trigger_skip: true,
241+
body: {
242+
status: "requires_customer_action",
243+
},
244+
},
245+
},
246+
PaymentIntentOffSession: {
247+
Request: {
248+
currency: "EUR",
249+
amount: 6500,
250+
authentication_type: "no_three_ds",
251+
customer_acceptance: null,
252+
setup_future_usage: "off_session",
253+
},
254+
Response: {
255+
status: 200,
256+
trigger_skip: true,
257+
body: {
258+
status: "requires_payment_method",
259+
setup_future_usage: "off_session",
260+
},
261+
},
262+
},
263+
ZeroAuthPaymentIntent: {
264+
Request: {
265+
amount: 0,
266+
setup_future_usage: "off_session",
267+
currency: "EUR",
268+
},
269+
Response: {
270+
status: 200,
271+
trigger_skip: true,
272+
body: {
273+
status: "requires_payment_method",
274+
setup_future_usage: "off_session",
275+
},
276+
},
277+
},
278+
ZeroAuthMandate: {
279+
Request: {
280+
payment_method: "card",
281+
payment_method_data: {
282+
card: successfulNo3DSCardDetails,
283+
},
284+
currency: "USD",
285+
mandate_data: singleUseMandateData,
286+
},
287+
Response: {
288+
status: 200,
289+
trigger_skip: true,
290+
body: {
291+
status: "succeeded",
292+
},
293+
},
294+
},
295+
ZeroAuthConfirmPayment: {
296+
Request: {
297+
payment_type: "setup_mandate",
298+
payment_method: "card",
299+
payment_method_type: "credit",
300+
payment_method_data: {
301+
card: successfulNo3DSCardDetails,
302+
},
303+
},
304+
Response: {
305+
status: 501,
306+
body: {
307+
error: {
308+
type: "invalid_request",
309+
message: "Setup Mandate flow for Novalnet is not implemented",
310+
code: "IR_00",
311+
},
312+
},
313+
},
314+
},
209315
},
210316
};

0 commit comments

Comments
 (0)