From fb149cb0ff750fbaadf22d263be0f7bfe1574e37 Mon Sep 17 00:00:00 2001 From: Kritik Modi <61862301+kritikmodi@users.noreply.github.com> Date: Mon, 17 Jul 2023 18:55:02 +0530 Subject: [PATCH] fix(payments): populate mandate_data in the response body of the PaymentsCreate endpoint (#1715) --- crates/api_models/src/payments.rs | 1 + crates/router/src/core/payments/transformers.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index e781dd6f5b..99452d9b62 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1433,6 +1433,7 @@ pub struct PaymentsResponse { pub mandate_id: Option, /// Provided mandate information for creating a mandate + #[auth_based] pub mandate_data: Option, /// Indicates that you intend to make future payments with this Payment’s payment method. Providing this parameter will attach the payment method to the Customer, if present, after the Payment is confirmed and any required actions from the user are complete. diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index b9d805a300..f7423ee60c 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -183,6 +183,7 @@ where &operation, payment_data.ephemeral_key, payment_data.sessions_token, + payment_data.setup_mandate, ) } } @@ -273,6 +274,7 @@ pub fn payments_to_payments_response( operation: &Op, ephemeral_key_option: Option, session_tokens: Vec, + mandate_data: Option, ) -> RouterResponse where Op: Debug, @@ -416,6 +418,10 @@ where .and_then(|cus| cus.phone.as_ref().map(|s| s.to_owned())), ) .set_mandate_id(mandate_id) + .set_mandate_data( + mandate_data.map(api::MandateData::from), + auth_flow == services::AuthFlow::Merchant, + ) .set_description(payment_intent.description) .set_refunds(refunds_response) // refunds.iter().map(refund_to_refund_response), .set_disputes(disputes_response)