Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix: update connector_mandate_id column in generate mandate flow (#2472)

Arjun Karthik61288d541f65
diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs
index 1df1d25b10..a1aa1fa9eb 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::<types::MandateReference>::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 d9c1d719c7..139a2fb680 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<pii::SecretSerdeValue>,
network_txn_id: Option<String>,
payment_method_data_option: Option<api_models::payments::PaymentMethodData>,
+ mandate_reference: Option<MandateReference>,
) -> CustomResult<Option<storage::MandateNew>, 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")? {