Skip to content

Commit

Permalink
fix(core): Populate off_session based on payments request (#6855)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepanshu-iiitu authored Dec 17, 2024
1 parent b301d09 commit 107098c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
15 changes: 12 additions & 3 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2615,7 +2615,10 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
payment_method_data: (payment_method_data.get_required_value("payment_method_data")?),
setup_future_usage: payment_data.payment_intent.setup_future_usage,
mandate_id: payment_data.mandate_id.clone(),
off_session: payment_data.mandate_id.as_ref().map(|_| true),
off_session: payment_data
.mandate_id
.as_ref()
.and(payment_data.payment_intent.off_session),
setup_mandate_details: payment_data.setup_mandate.clone(),
confirm: payment_data.payment_attempt.confirm,
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
Expand Down Expand Up @@ -3218,7 +3221,10 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
.get_required_value("payment_method_data")?),
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
setup_future_usage: payment_data.payment_intent.setup_future_usage,
off_session: payment_data.mandate_id.as_ref().map(|_| true),
off_session: payment_data
.mandate_id
.as_ref()
.and(payment_data.payment_intent.off_session),
mandate_id: payment_data.mandate_id.clone(),
setup_mandate_details: payment_data.setup_mandate,
customer_acceptance: payment_data.customer_acceptance,
Expand Down Expand Up @@ -3333,7 +3339,10 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
Ok(Self {
setup_future_usage: payment_data.payment_intent.setup_future_usage,
mandate_id: payment_data.mandate_id.clone(),
off_session: payment_data.mandate_id.as_ref().map(|_| true),
off_session: payment_data
.mandate_id
.as_ref()
.and(payment_data.payment_intent.off_session),
setup_mandate_details: payment_data.setup_mandate.clone(),
confirm: payment_data.payment_attempt.confirm,
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
Expand Down
12 changes: 3 additions & 9 deletions cypress-tests/cypress/e2e/PaymentUtils/Stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,7 @@ export const connectorDetails = {
Response: {
status: 200,
body: {
error_code: "No error code",
error_message:
"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.",
status: "succeeded",
},
},
},
Expand All @@ -734,9 +732,7 @@ export const connectorDetails = {
Response: {
status: 200,
body: {
error_code: "No error code",
error_message:
"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.",
status: "requires_capture",
},
},
},
Expand All @@ -748,9 +744,7 @@ export const connectorDetails = {
Response: {
status: 200,
body: {
status: "failed",
error_message:
"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.",
status: "succeeded",
},
},
},
Expand Down

0 comments on commit 107098c

Please sign in to comment.