diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs index 1df1d25b106a..a1aa1fa9eb4c 100644 --- a/crates/router/src/core/mandate.rs +++ b/crates/router/src/core/mandate.rs @@ -207,6 +207,7 @@ where }; let mandate_ids = mandate_reference + .as_ref() .map(|md| { Encode::::encode_to_value(&md) .change_context( @@ -226,6 +227,7 @@ where mandate_ids, network_txn_id, get_insensitive_payment_method_data_if_exists(&resp), + mandate_reference, )? { let connector = new_mandate_data.connector.clone(); logger::debug!("{:?}", new_mandate_data); diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index d9c1d719c739..139a2fb68079 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -50,7 +50,7 @@ use crate::{ }, storage::{self, enums as storage_enums, ephemeral_key, CustomerUpdate::Update}, transformers::{ForeignFrom, ForeignTryFrom}, - ErrorResponse, RouterData, + ErrorResponse, MandateReference, RouterData, }, utils::{ self, @@ -2123,6 +2123,7 @@ pub fn generate_mandate( connector_mandate_id: Option, network_txn_id: Option, payment_method_data_option: Option, + mandate_reference: Option, ) -> CustomResult, errors::ApiErrorResponse> { match (setup_mandate_details, customer) { (Some(data), Some(cus)) => { @@ -2155,7 +2156,10 @@ pub fn generate_mandate( pii::SecretSerdeValue::new( serde_json::to_value(payment_method_data).unwrap_or_default(), ) - })); + })) + .set_connector_mandate_id( + mandate_reference.and_then(|reference| reference.connector_mandate_id), + ); Ok(Some( match data.mandate_type.get_required_value("mandate_type")? {