From 2042f365aaa65f48a221471635cc589ffd993e56 Mon Sep 17 00:00:00 2001 From: Swangi Kumari <85639103+swangi-kumari@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:03:12 +0530 Subject: [PATCH] fix(connector): [STRIPE] fix stripe mandate (#6899) --- .../router/src/connector/stripe/transformers.rs | 15 ++++++++++++--- crates/router/src/core/payments/transformers.rs | 15 +++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 2f0b0e0316fd..d3a169870ea6 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1702,7 +1702,13 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntent }; let mut payment_method_options = None; - let (mut payment_data, payment_method, billing_address, payment_method_types) = { + let ( + mut payment_data, + payment_method, + billing_address, + payment_method_types, + setup_future_usage, + ) = { match item .request .mandate_id @@ -1716,6 +1722,7 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntent connector_mandate_ids.get_connector_mandate_id(), StripeBillingAddress::default(), get_payment_method_type_for_saved_payment_method_payment(item)?, + None, ), Some(api_models::payments::MandateReferenceId::NetworkMandateId( network_transaction_id, @@ -1781,9 +1788,10 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntent None, StripeBillingAddress::default(), None, + None, ) } - _ => { + Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_)) | None => { let (payment_method_data, payment_method_type, billing_address) = create_stripe_payment_method( &item.request.payment_method_data, @@ -1805,6 +1813,7 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntent None, billing_address, payment_method_type, + item.request.setup_future_usage, ) } } @@ -1968,7 +1977,7 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntent customer, setup_mandate_details, off_session: item.request.off_session, - setup_future_usage: item.request.setup_future_usage, + setup_future_usage, payment_method_types, expand: Some(ExpandableObjects::LatestCharge), browser_info, diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 85bc51a09a7f..48e931989f02 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -2615,10 +2615,7 @@ impl TryFrom> 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() - .and(payment_data.payment_intent.off_session), + off_session: payment_data.mandate_id.as_ref().map(|_| true), setup_mandate_details: payment_data.setup_mandate.clone(), confirm: payment_data.payment_attempt.confirm, statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix, @@ -3221,10 +3218,7 @@ impl TryFrom> 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() - .and(payment_data.payment_intent.off_session), + off_session: payment_data.mandate_id.as_ref().map(|_| true), mandate_id: payment_data.mandate_id.clone(), setup_mandate_details: payment_data.setup_mandate, customer_acceptance: payment_data.customer_acceptance, @@ -3339,10 +3333,7 @@ impl TryFrom> 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() - .and(payment_data.payment_intent.off_session), + off_session: payment_data.mandate_id.as_ref().map(|_| true), setup_mandate_details: payment_data.setup_mandate.clone(), confirm: payment_data.payment_attempt.confirm, statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,