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(mandates): give higher precedence to connector mandate id over network txn id in mandates (#4073)

Shanksd28e415dc289
diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs
index 2fd559680e..fb80c0a1c4 100644
--- a/crates/router/src/connector/cybersource/transformers.rs
+++ b/crates/router/src/connector/cybersource/transformers.rs
@@ -508,8 +508,15 @@ impl
.map_or(false, |future_usage| {
matches!(future_usage, FutureUsage::OffSession)
})
- && item.router_data.request.customer_acceptance.is_some()
- {
+ && (item.router_data.request.customer_acceptance.is_some()
+ || item
+ .router_data
+ .request
+ .setup_mandate_details
+ .clone()
+ .map_or(false, |mandate_details| {
+ mandate_details.customer_acceptance.is_some()
+ })) {
(
Some(vec![CybersourceActionsList::TokenCreate]),
Some(vec![CybersourceActionsTokenType::PaymentInstrument]),
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 6e185ea66d..5efbee0bc6 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -301,14 +301,6 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
mandate_obj.network_transaction_id,
mandate_obj.connector_mandate_ids,
) {
- (Some(network_tx_id), _) => Ok(api_models::payments::MandateIds {
- mandate_id: Some(mandate_obj.mandate_id),
- mandate_reference_id: Some(
- api_models::payments::MandateReferenceId::NetworkMandateId(
- network_tx_id,
- ),
- ),
- }),
(_, Some(connector_mandate_id)) => connector_mandate_id
.parse_value("ConnectorMandateId")
.change_context(errors::ApiErrorResponse::MandateNotFound)
@@ -324,6 +316,14 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
))
}
}),
+ (Some(network_tx_id), _) => Ok(api_models::payments::MandateIds {
+ mandate_id: Some(mandate_obj.mandate_id),
+ mandate_reference_id: Some(
+ api_models::payments::MandateReferenceId::NetworkMandateId(
+ network_tx_id,
+ ),
+ ),
+ }),
(_, _) => Ok(api_models::payments::MandateIds {
mandate_id: Some(mandate_obj.mandate_id),
mandate_reference_id: None,