fix(mandates): give higher precedence to connector mandate id over network txn id in mandates (#4073)

Co-authored-by: Samraat Bansal <samraat.bansal@juspay.in>
This commit is contained in:
Shanks
2024-03-13 20:02:17 +05:30
committed by GitHub
parent a21d6d5e16
commit d28e415dc2
2 changed files with 17 additions and 10 deletions

View File

@ -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]),

View File

@ -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,