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

feat(connector): [SANTANDER] Send back `idSolicRec` as `reference_id` in Payments Response & skip PixAutomaticoPush in AuthorizeSessionToken call (#11992)

Sayak Bhattacharyafdb9cfd5dca6
diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rs
index 1444f832d6..30a3299865 100644
--- a/crates/diesel_models/src/payment_attempt.rs
+++ b/crates/diesel_models/src/payment_attempt.rs
@@ -37,6 +37,9 @@ impl ConnectorMandateReferenceId {
pub fn is_connector_mandate_id_present(&self) -> bool {
self.connector_mandate_id.is_some()
}
+ pub fn get_connector_mandate_id(&self) -> Option<String> {
+ self.connector_mandate_id.clone()
+ }
}
common_utils::impl_to_sql_from_sql_json!(NetworkDetails);
#[derive(
diff --git a/crates/hyperswitch_connectors/src/connectors/santander.rs b/crates/hyperswitch_connectors/src/connectors/santander.rs
index 8d578ac737..f7f02e1e8d 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander.rs
@@ -1233,11 +1233,11 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for San
);
if is_journey_2_cit {
- let mandate_id = req.request.connector_reference_id.as_ref().ok_or(
- errors::ConnectorError::MissingRequiredField {
- field_name: "connector_reference_id for Journey 2 CIT",
- },
- )?;
+ let mandate_id = req
+ .request
+ .connector_mandate_id
+ .clone()
+ .ok_or(errors::ConnectorError::MissingConnectorMandateID)?;
// Journey 2 CIT flow
Ok(format!(
"{}api/v1/rec/{}",
@@ -1276,14 +1276,8 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for San
None => {
let mandate_id = req
.request
- .mandate_id
- .as_ref()
- .and_then(|ids| match &ids.mandate_reference_id {
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- connector_mandate_ids,
- )) => connector_mandate_ids.get_connector_mandate_id(),
- _ => None,
- })
+ .connector_mandate_id
+ .clone()
.ok_or(errors::ConnectorError::MissingConnectorMandateID)?;
Ok(format!(
"{}api/v1/rec/{}",
@@ -1297,7 +1291,7 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for San
Some(enums::PaymentMethodType::PixAutomaticoPush) => {
let mandate_id = req
.request
- .connector_reference_id
+ .connector_mandate_id
.clone()
.ok_or(errors::ConnectorError::MissingConnectorMandateID)?;
Ok(format!(
@@ -2104,8 +2098,13 @@ impl ConnectorSpecifications for Santander {
current_flow: Option<CurrentFlowInfo>,
) -> bool {
match current_flow {
- // Journey 1/2/3/4 CIT
- Some(CurrentFlowInfo::SetupMandate { .. }) => true,
+ // Journey 2/3/4 CIT
+ Some(CurrentFlowInfo::SetupMandate { request_data, .. }) => {
+ matches!(
+ request_data.payment_method_type,
+ Some(enums::PaymentMethodType::PixAutomaticoQr)
+ )
+ }
Some(CurrentFlowInfo::CompleteAuthorize { .. })
| Some(CurrentFlowInfo::Authorize { .. })
| Some(CurrentFlowInfo::Psync { .. })
diff --git a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
index c1f8f4a51e..d1659c18d2 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
@@ -159,12 +159,14 @@ impl
.unwrap_or(AttemptStatus::Pending);
let resource_id =
ResponseId::ConnectorTransactionId(item.data.connector_request_reference_id.clone());
- let connector_response_reference_id = Some(item.response.id_rec.clone().expose());
+ let connector_response_reference_id = Some(item.response.id_solic_rec.clone().expose());
let mandate_reference = Some(MandateReference {
connector_mandate_id: Some(item.response.id_rec.clone().expose()),
payment_method_id: None,
mandate_metadata: None,
- connector_mandate_request_reference_id: Some(item.response.id_solic_rec.expose()),
+ connector_mandate_request_reference_id: Some(
+ item.response.id_solic_rec.clone().expose(),
+ ),
});
Ok(Self {
@@ -232,7 +234,6 @@ impl
}));
let resource_id =
ResponseId::ConnectorTransactionId(item.data.connector_request_reference_id.clone());
- let connector_response_reference_id = Some(item.response.id_rec.clone().expose());
Ok(Self {
status,
@@ -242,7 +243,7 @@ impl
mandate_reference,
connector_metadata,
network_txn_id: None,
- connector_response_reference_id,
+ connector_response_reference_id: None,
incremental_authorization_allowed: None,
authentication_data: None,
charges: None,
@@ -1219,21 +1220,36 @@ impl<F, T> TryFrom<ResponseRouterData<F, SantanderPaymentsSyncResponse, T, Payme
.change_context(errors::ConnectorError::ParsingFailed)
})
.transpose()?;
- Ok(Self {
- status: AttemptStatus::from(pix_data.status),
- response: Ok(PaymentsResponseData::TransactionResponse {
+ // Preserve existing `TransactionResponse` fields and only update `resource_id` and `connector_metadata`
+ let response = match item.data.response.clone() {
+ Ok(PaymentsResponseData::TransactionResponse {
+ redirection_data,
+ mandate_reference,
+ network_txn_id,
+ connector_response_reference_id,
+ incremental_authorization_allowed,
+ authentication_data,
+ charges,
+ ..
+ }) => Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
pix_data.txid.clone(),
),
- redirection_data: Box::new(None),
- mandate_reference: Box::new(None),
+ redirection_data,
+ mandate_reference,
connector_metadata,
- network_txn_id: None,
- connector_response_reference_id: None,
- incremental_authorization_allowed: None,
- authentication_data: None,
- charges: None,
+ network_txn_id,
+ connector_response_reference_id,
+ incremental_authorization_allowed,
+ authentication_data,
+ charges,
}),
+ other => other,
+ };
+
+ Ok(Self {
+ status: AttemptStatus::from(pix_data.status),
+ response,
..item.data
})
}
@@ -1454,7 +1470,7 @@ impl<F, T> TryFrom<ResponseRouterData<F, SantanderPaymentsResponse, T, PaymentsR
})),
connector_metadata: None,
network_txn_id: None,
- connector_response_reference_id: Some(cobr_data.id_rec.clone().expose()),
+ connector_response_reference_id: None,
incremental_authorization_allowed: None,
authentication_data: None,
charges: None,
@@ -2278,12 +2294,6 @@ impl<F>
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
- if !matches!(router_env::env::which(), router_env::env::Env::Production) {
- router_env::logger::info!(
- "Santander Recurrence Id: {:?}",
- item.response.id_rec.clone().expose()
- );
- }
Ok(Self {
status: AttemptStatus::from(item.response.status.clone()),
response: Ok(PaymentsResponseData::TransactionResponse {
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index 68cf81d07c..62dfc67c1d 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -1120,6 +1120,7 @@ pub struct PaymentsSyncData {
pub connector_reference_id: Option<String>,
pub setup_future_usage: Option<storage_enums::FutureUsage>,
pub feature_metadata: Option<api_models::payments::FeatureMetadata>,
+ pub connector_mandate_id: Option<String>,
}
#[derive(Debug, Default, Clone, Serialize)]
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index ca3e9da7fd..2635e5ae20 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -997,6 +997,7 @@ pub async fn construct_router_data_for_psync<'a>(
connector_reference_id: attempt.connector_response_reference_id.clone(),
setup_future_usage: Some(payment_intent.setup_future_usage),
feature_metadata: None,
+ connector_mandate_id: None,
};
// TODO: evaluate the fields in router data, if they are required or not
@@ -5274,6 +5275,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncData
.setup_future_usage_applied
.or(payment_data.payment_intent.setup_future_usage),
feature_metadata,
+ connector_mandate_id: payment_data
+ .payment_attempt
+ .connector_mandate_detail
+ .as_ref()
+ .and_then(|d| d.get_connector_mandate_id()),
})
}
}
diff --git a/crates/router/src/core/relay/utils.rs b/crates/router/src/core/relay/utils.rs
index 9e79be82cd..1c38eff689 100644
--- a/crates/router/src/core/relay/utils.rs
+++ b/crates/router/src/core/relay/utils.rs
@@ -648,6 +648,7 @@ pub async fn construct_relay_payments_retrieve_router_data(
connector_reference_id: None,
setup_future_usage: None,
feature_metadata: None,
+ connector_mandate_id: None,
},
response: Err(ErrorResponse::default()),