Skip to content

Commit 107098c

Browse files
fix(core): Populate off_session based on payments request (#6855)
1 parent b301d09 commit 107098c

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -2615,7 +2615,10 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
26152615
payment_method_data: (payment_method_data.get_required_value("payment_method_data")?),
26162616
setup_future_usage: payment_data.payment_intent.setup_future_usage,
26172617
mandate_id: payment_data.mandate_id.clone(),
2618-
off_session: payment_data.mandate_id.as_ref().map(|_| true),
2618+
off_session: payment_data
2619+
.mandate_id
2620+
.as_ref()
2621+
.and(payment_data.payment_intent.off_session),
26192622
setup_mandate_details: payment_data.setup_mandate.clone(),
26202623
confirm: payment_data.payment_attempt.confirm,
26212624
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
@@ -3218,7 +3221,10 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
32183221
.get_required_value("payment_method_data")?),
32193222
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
32203223
setup_future_usage: payment_data.payment_intent.setup_future_usage,
3221-
off_session: payment_data.mandate_id.as_ref().map(|_| true),
3224+
off_session: payment_data
3225+
.mandate_id
3226+
.as_ref()
3227+
.and(payment_data.payment_intent.off_session),
32223228
mandate_id: payment_data.mandate_id.clone(),
32233229
setup_mandate_details: payment_data.setup_mandate,
32243230
customer_acceptance: payment_data.customer_acceptance,
@@ -3333,7 +3339,10 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
33333339
Ok(Self {
33343340
setup_future_usage: payment_data.payment_intent.setup_future_usage,
33353341
mandate_id: payment_data.mandate_id.clone(),
3336-
off_session: payment_data.mandate_id.as_ref().map(|_| true),
3342+
off_session: payment_data
3343+
.mandate_id
3344+
.as_ref()
3345+
.and(payment_data.payment_intent.off_session),
33373346
setup_mandate_details: payment_data.setup_mandate.clone(),
33383347
confirm: payment_data.payment_attempt.confirm,
33393348
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,7 @@ export const connectorDetails = {
721721
Response: {
722722
status: 200,
723723
body: {
724-
error_code: "No error code",
725-
error_message:
726-
"You cannot confirm with `off_session=true` when `setup_future_usage` is also set on the PaymentIntent. The customer needs to be on-session to perform the steps which may be required to set up the PaymentMethod for future usage. Please confirm this PaymentIntent with your customer on-session.",
724+
status: "succeeded",
727725
},
728726
},
729727
},
@@ -734,9 +732,7 @@ export const connectorDetails = {
734732
Response: {
735733
status: 200,
736734
body: {
737-
error_code: "No error code",
738-
error_message:
739-
"You cannot confirm with `off_session=true` when `setup_future_usage` is also set on the PaymentIntent. The customer needs to be on-session to perform the steps which may be required to set up the PaymentMethod for future usage. Please confirm this PaymentIntent with your customer on-session.",
735+
status: "requires_capture",
740736
},
741737
},
742738
},
@@ -748,9 +744,7 @@ export const connectorDetails = {
748744
Response: {
749745
status: 200,
750746
body: {
751-
status: "failed",
752-
error_message:
753-
"You cannot confirm with `off_session=true` when `setup_future_usage` is also set on the PaymentIntent. The customer needs to be on-session to perform the steps which may be required to set up the PaymentMethod for future usage. Please confirm this PaymentIntent with your customer on-session.",
747+
status: "succeeded",
754748
},
755749
},
756750
},

0 commit comments

Comments
 (0)