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(core/connector): [SANTANDER] Implement PreAuthorizeVoid Flow for PixAutomatico MITs (#15107)

Sayak Bhattacharya995562f72585
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen.rs b/crates/hyperswitch_connectors/src/connectors/adyen.rs
index 40ef48f947..fbc183244b 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen.rs
@@ -3455,7 +3455,8 @@ impl ConnectorSpecifications for Adyen {
}
api::CurrentFlowInfo::Psync { .. } => false,
api::CurrentFlowInfo::UpdatePostConfirm { .. } => false,
- api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
+ api::CurrentFlowInfo::PreAuthorizeVoid { .. }
+ | api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
diff --git a/crates/hyperswitch_connectors/src/connectors/barclaycard.rs b/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
index 6d8decfb8c..c1c9b09e41 100644
--- a/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
+++ b/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
@@ -1555,6 +1555,7 @@ impl ConnectorSpecifications for Barclaycard {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -1579,6 +1580,7 @@ impl ConnectorSpecifications for Barclaycard {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -1603,6 +1605,7 @@ impl ConnectorSpecifications for Barclaycard {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource.rs b/crates/hyperswitch_connectors/src/connectors/cybersource.rs
index 6776574cdd..c5fae7d0ff 100644
--- a/crates/hyperswitch_connectors/src/connectors/cybersource.rs
+++ b/crates/hyperswitch_connectors/src/connectors/cybersource.rs
@@ -2417,6 +2417,7 @@ impl ConnectorSpecifications for Cybersource {
api::CurrentFlowInfo::SetupMandate { .. } => None,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => None,
}
}
@@ -2441,6 +2442,7 @@ impl ConnectorSpecifications for Cybersource {
api::CurrentFlowInfo::SetupMandate { .. } => None,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => None,
}
}
@@ -2456,6 +2458,7 @@ impl ConnectorSpecifications for Cybersource {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -2480,6 +2483,7 @@ impl ConnectorSpecifications for Cybersource {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -2504,6 +2508,7 @@ impl ConnectorSpecifications for Cybersource {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/elavon_pg.rs b/crates/hyperswitch_connectors/src/connectors/elavon_pg.rs
index a19adba3ae..8248b3bd4b 100644
--- a/crates/hyperswitch_connectors/src/connectors/elavon_pg.rs
+++ b/crates/hyperswitch_connectors/src/connectors/elavon_pg.rs
@@ -770,6 +770,7 @@ impl ConnectorSpecifications for ElavonPg {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -807,6 +808,7 @@ impl ConnectorSpecifications for ElavonPg {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/globalpayments_realex.rs b/crates/hyperswitch_connectors/src/connectors/globalpayments_realex.rs
index 8423f3d7f3..b35ffda84d 100644
--- a/crates/hyperswitch_connectors/src/connectors/globalpayments_realex.rs
+++ b/crates/hyperswitch_connectors/src/connectors/globalpayments_realex.rs
@@ -736,6 +736,7 @@ impl ConnectorSpecifications for GlobalpaymentsRealex {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -763,6 +764,7 @@ impl ConnectorSpecifications for GlobalpaymentsRealex {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -790,6 +792,7 @@ impl ConnectorSpecifications for GlobalpaymentsRealex {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/ilixium.rs b/crates/hyperswitch_connectors/src/connectors/ilixium.rs
index d574b3a5d6..71173e6d4c 100644
--- a/crates/hyperswitch_connectors/src/connectors/ilixium.rs
+++ b/crates/hyperswitch_connectors/src/connectors/ilixium.rs
@@ -683,6 +683,7 @@ impl ConnectorSpecifications for Ilixium {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/moneris.rs b/crates/hyperswitch_connectors/src/connectors/moneris.rs
index cea9d48f15..19f907da5d 100644
--- a/crates/hyperswitch_connectors/src/connectors/moneris.rs
+++ b/crates/hyperswitch_connectors/src/connectors/moneris.rs
@@ -929,6 +929,7 @@ impl ConnectorSpecifications for Moneris {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/nexixpay.rs b/crates/hyperswitch_connectors/src/connectors/nexixpay.rs
index 4a769388ce..4264473a2f 100644
--- a/crates/hyperswitch_connectors/src/connectors/nexixpay.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nexixpay.rs
@@ -1303,6 +1303,7 @@ impl ConnectorSpecifications for Nexixpay {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -1334,6 +1335,7 @@ impl ConnectorSpecifications for Nexixpay {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/nmi.rs b/crates/hyperswitch_connectors/src/connectors/nmi.rs
index 6ab9a3c3ac..2379ab22e3 100644
--- a/crates/hyperswitch_connectors/src/connectors/nmi.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nmi.rs
@@ -1154,6 +1154,7 @@ impl ConnectorSpecifications for Nmi {
} => auth_type.is_three_ds() && request_data.is_card(),
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/nordea.rs b/crates/hyperswitch_connectors/src/connectors/nordea.rs
index dd75f6f8e8..e9c4ce52c1 100644
--- a/crates/hyperswitch_connectors/src/connectors/nordea.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nordea.rs
@@ -1154,6 +1154,7 @@ impl ConnectorSpecifications for Nordea {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/nuvei.rs b/crates/hyperswitch_connectors/src/connectors/nuvei.rs
index 5416d80fb8..676118ada0 100644
--- a/crates/hyperswitch_connectors/src/connectors/nuvei.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nuvei.rs
@@ -1722,7 +1722,8 @@ impl ConnectorSpecifications for Nuvei {
} => auth_type.is_three_ds() && request_data.is_card(),
api::CurrentFlowInfo::Psync { .. } => false,
api::CurrentFlowInfo::UpdatePostConfirm { .. } => false,
- api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
+ api::CurrentFlowInfo::PreAuthorizeVoid { .. }
+ | api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/paydotcom.rs b/crates/hyperswitch_connectors/src/connectors/paydotcom.rs
index fb9cb9c52f..8c98d8e1c3 100644
--- a/crates/hyperswitch_connectors/src/connectors/paydotcom.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paydotcom.rs
@@ -304,6 +304,7 @@ impl api::ConnectorSpecifications for Paydotcom {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -331,6 +332,7 @@ impl api::ConnectorSpecifications for Paydotcom {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/payme.rs b/crates/hyperswitch_connectors/src/connectors/payme.rs
index e234048868..fc6aa819a9 100644
--- a/crates/hyperswitch_connectors/src/connectors/payme.rs
+++ b/crates/hyperswitch_connectors/src/connectors/payme.rs
@@ -1366,7 +1366,8 @@ impl ConnectorSpecifications for Payme {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. } => false,
api::CurrentFlowInfo::UpdatePostConfirm { .. } => false,
- api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
+ api::CurrentFlowInfo::PreAuthorizeVoid { .. }
+ | api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/paynearme.rs b/crates/hyperswitch_connectors/src/connectors/paynearme.rs
index d2373af8a1..a364d63230 100644
--- a/crates/hyperswitch_connectors/src/connectors/paynearme.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paynearme.rs
@@ -674,6 +674,7 @@ impl ConnectorSpecifications for Paynearme {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/paypal.rs b/crates/hyperswitch_connectors/src/connectors/paypal.rs
index 94ff083740..db2bd6fcbf 100644
--- a/crates/hyperswitch_connectors/src/connectors/paypal.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paypal.rs
@@ -2885,6 +2885,7 @@ impl ConnectorSpecifications for Paypal {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -2900,7 +2901,8 @@ impl ConnectorSpecifications for Paypal {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. } => false,
api::CurrentFlowInfo::UpdatePostConfirm { .. } => false,
- api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
+ api::CurrentFlowInfo::PreAuthorizeVoid { .. }
+ | api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/paysafe.rs b/crates/hyperswitch_connectors/src/connectors/paysafe.rs
index d04f9d1ee6..494ed0410f 100644
--- a/crates/hyperswitch_connectors/src/connectors/paysafe.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paysafe.rs
@@ -1257,6 +1257,7 @@ impl ConnectorSpecifications for Paysafe {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => None,
}
}
@@ -1272,6 +1273,7 @@ impl ConnectorSpecifications for Paysafe {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -1294,6 +1296,7 @@ impl ConnectorSpecifications for Paysafe {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/redsys.rs b/crates/hyperswitch_connectors/src/connectors/redsys.rs
index 644ad16962..0f594d6c81 100644
--- a/crates/hyperswitch_connectors/src/connectors/redsys.rs
+++ b/crates/hyperswitch_connectors/src/connectors/redsys.rs
@@ -1036,6 +1036,7 @@ impl ConnectorSpecifications for Redsys {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -1076,6 +1077,7 @@ impl ConnectorSpecifications for Redsys {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/saferpay.rs b/crates/hyperswitch_connectors/src/connectors/saferpay.rs
index 9f1790098d..d79087e330 100644
--- a/crates/hyperswitch_connectors/src/connectors/saferpay.rs
+++ b/crates/hyperswitch_connectors/src/connectors/saferpay.rs
@@ -367,6 +367,7 @@ impl ConnectorSpecifications for Saferpay {
| api::CurrentFlowInfo::SetupMandate { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/santander.rs b/crates/hyperswitch_connectors/src/connectors/santander.rs
index 589ea8a4c0..aa3f7d5993 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander.rs
@@ -89,7 +89,7 @@ use crate::{
SantanderPaymentsSyncResponse, SantanderPixAutomaticRecResponse,
SantanderPixAutomaticSolicitationResponse, SantanderPixAutomaticoRecWebhookBody,
SantanderPixQrWebhookBody, SantanderPixWebhookRegisterResponse,
- SantanderRefundResponse, SantanderUpdateResponse, SantanderVoidResponse,
+ SantanderPreAuthorizeVoidResponse, SantanderRefundResponse, SantanderUpdateResponse,
SantanderWebhookBody,
},
},
@@ -1735,6 +1735,17 @@ impl ConnectorIntegration<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, Paym
)),
}
}
+ Some(enums::PaymentMethodType::PixAutomaticoPush)
+ | Some(enums::PaymentMethodType::PixAutomaticoQr)
+ if req.recurring_mandate_payment_data.is_some() =>
+ {
+ Ok(format!(
+ "{}api/v1/cobr/{}",
+ self.base_url(connectors),
+ req.request.connector_transaction_id
+ ))
+ }
+ // TODO: else handler, recurrence revoke api to be called
_ => Err(errors::ConnectorError::NotSupported {
message: req.payment_method.to_string(),
connector: "Santander".into(),
@@ -1821,10 +1832,10 @@ impl ConnectorIntegration<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, Paym
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsPreAuthorizeCancelRouterData, errors::ConnectorError> {
- let response: SantanderVoidResponse =
- res.response
- .parse_struct("Santander VoidResponse")
- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ let response: SantanderPreAuthorizeVoidResponse = res
+ .response
+ .parse_struct("Santander VoidResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
@@ -2508,15 +2519,35 @@ impl ConnectorSpecifications for Santander {
Some(&SANTANDER_CONNECTOR_INFO)
}
- fn is_pre_authorize_cancel_supported(
- &self,
- payment_method_type: Option<enums::PaymentMethodType>,
- ) -> bool {
- // TODO: Add support for pre-authorize cancel for PixAutomaticoQr and PixAutomaticoPush PMT
- matches!(
- payment_method_type,
- Some(enums::PaymentMethodType::PixQr) | Some(enums::PaymentMethodType::Boleto)
- )
+ fn is_pre_authorize_cancel_supported(&self, current_flow: CurrentFlowInfo) -> bool {
+ match current_flow {
+ CurrentFlowInfo::PreAuthorizeVoid {
+ payment_method_type,
+ attempt_status,
+ is_mit_payment,
+ } => {
+ let supports_non_recurring_cancel = matches!(
+ payment_method_type,
+ Some(enums::PaymentMethodType::PixQr) | Some(enums::PaymentMethodType::Boleto)
+ );
+ let supports_recurring_mit_cancel = is_mit_payment
+ && matches!(
+ payment_method_type,
+ Some(enums::PaymentMethodType::PixAutomaticoQr)
+ | Some(enums::PaymentMethodType::PixAutomaticoPush)
+ );
+
+ match attempt_status {
+ enums::AttemptStatus::AuthenticationPending => {
+ supports_non_recurring_cancel || supports_recurring_mit_cancel
+ }
+ // A created recurring charge is tracked as Processing until Santander executes it.
+ enums::AttemptStatus::Pending => supports_recurring_mit_cancel,
+ _ => false,
+ }
+ }
+ _ => false,
+ }
}
fn should_call_connector_for_update_post_confirm(
@@ -2662,7 +2693,8 @@ impl ConnectorSpecifications for Santander {
| Some(CurrentFlowInfo::Psync { .. })
| Some(CurrentFlowInfo::UpdatePostConfirm { .. })
| None => false,
- Some(CurrentFlowInfo::ConnectorWebhookRegister { .. }) => false,
+ Some(CurrentFlowInfo::PreAuthorizeVoid { .. })
+ | Some(CurrentFlowInfo::ConnectorWebhookRegister { .. }) => false,
}
}
fn is_push_notification_flow_required(&self, current_flow: CurrentFlowInfo) -> bool {
@@ -2677,6 +2709,7 @@ impl ConnectorSpecifications for Santander {
| CurrentFlowInfo::CompleteAuthorize { .. }
| CurrentFlowInfo::Psync { .. }
| CurrentFlowInfo::UpdatePostConfirm { .. }
+ | CurrentFlowInfo::PreAuthorizeVoid { .. }
| CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
@@ -2692,6 +2725,7 @@ impl ConnectorSpecifications for Santander {
| CurrentFlowInfo::CompleteAuthorize { .. }
| CurrentFlowInfo::Psync { .. }
| CurrentFlowInfo::UpdatePostConfirm { .. }
+ | CurrentFlowInfo::PreAuthorizeVoid { .. }
| CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/santander/requests.rs b/crates/hyperswitch_connectors/src/connectors/santander/requests.rs
index a24b94d94f..4ee15c0f07 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander/requests.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander/requests.rs
@@ -232,10 +232,23 @@ pub struct SantanderPixCancelRequest {
pub status: Option<responses::SantanderVoidStatus>,
}
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum SantanderPixAutomaticoCobrCancelStatus {
+ Cancelada,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SantanderPixAutomaticoCobrCancelRequest {
+ pub status: SantanderPixAutomaticoCobrCancelStatus,
+}
+
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SantanderPaymentsCancelRequest {
PixQR(SantanderPixCancelRequest),
+ PixAutomaticoCobr(SantanderPixAutomaticoCobrCancelRequest),
Boleto(SantanderBoletoCancelRequest),
}
diff --git a/crates/hyperswitch_connectors/src/connectors/santander/responses.rs b/crates/hyperswitch_connectors/src/connectors/santander/responses.rs
index 7cd534f5a5..b1f1113721 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander/responses.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander/responses.rs
@@ -295,10 +295,57 @@ pub struct SantanderPixVoidResponse {
pub location: Option<String>,
}
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SantanderPixAutomaticoCobrReceiverResponse {
+ pub agencia: Option<Secret<String>>,
+ pub conta: Secret<String>,
+ #[serde(rename = "tipoConta", skip_serializing_if = "Option::is_none")]
+ pub tipo_conta: Option<requests::SantanderAccountType>,
+ pub cnpj: Secret<String>,
+ pub nome: Secret<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SantanderPixAutomaticoCobrDebtorResponse {
+ pub email: Option<Secret<String>>,
+ pub logradouro: Option<Secret<String>>,
+ pub cidade: Option<Secret<String>>,
+ pub uf: Option<Secret<String>>,
+ pub cep: Option<Secret<String>>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SantanderPixAutomaticoCobrVoidResponse {
+ pub id_rec: Secret<String>,
+ pub txid: String,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub info_adicional: Option<String>,
+ pub calendario: SantanderPixAutomaticoCobrCalendarResponse,
+ pub valor: requests::SantanderPixAutomaticoCobrValor,
+ pub ajuste_dia_util: bool,
+ pub recebedor: SantanderPixAutomaticoCobrReceiverResponse,
+ pub status: SantanderPixAutomaticoCobrStatus,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub politica_retentativa: Option<String>,
+ pub devedor: SantanderPixAutomaticoCobrDebtorResponse,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub pix: Option<Vec<SantanderCobrSyncPix>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub atualizacao: Option<Vec<SantanderCobrSyncStatusUpdate>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub tentativas: Option<Vec<SantanderCobrSyncTentativa>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub encerramento: Option<SantanderPixAutomaticoEncerramento>,
+}
+
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
-pub enum SantanderVoidResponse {
+pub enum SantanderPreAuthorizeVoidResponse {
Pix(Box<SantanderPixVoidResponse>),
+ PixAutomaticoCobr(Box<SantanderPixAutomaticoCobrVoidResponse>),
Boleto(Box<SantanderBoletoVoidResponse>),
}
diff --git a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
index 1a962a9cb8..9b435e44f4 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
@@ -57,6 +57,7 @@ use crate::{
SantanderMetadataPatch, SantanderPaymentRequest, SantanderPaymentsCancelRequest,
SantanderPixAutomaticCalendarRequest, SantanderPixAutomaticDestinationRequest,
SantanderPixAutomaticSolicitationRequest, SantanderPixAutomaticoCobrCalendario,
+ SantanderPixAutomaticoCobrCancelRequest, SantanderPixAutomaticoCobrCancelStatus,
SantanderPixAutomaticoCobrRequest, SantanderPixAutomaticoCobrValor,
SantanderPixAutomaticoRecebedor, SantanderPixCancelRequest,
SantanderPixDueDateCalendarRequest, SantanderPixImmediateCalendarRequest,
@@ -78,8 +79,9 @@ use crate::{
SantanderPixAutomaticoRecWebhookBody, SantanderPixAutomaticoRecWebhookEntry,
SantanderPixKeyType, SantanderPixQRCodePaymentsResponse,
SantanderPixQRCodeSyncResponse, SantanderPixWebhookRegisterResponse,
- SantanderRefundResponse, SantanderRefundStatus, SantanderSetupMandateResponse,
- SantanderUpdateResponse, SantanderVoidResponse, SantanderVoidStatus, WaitScreenData,
+ SantanderPreAuthorizeVoidResponse, SantanderRefundResponse, SantanderRefundStatus,
+ SantanderSetupMandateResponse, SantanderUpdateResponse, SantanderVoidStatus,
+ WaitScreenData,
},
},
types::{RefreshTokenRouterData, RefundsResponseRouterData, ResponseRouterData},
@@ -1958,16 +1960,17 @@ impl<F, T> TryFrom<ResponseRouterData<F, SantanderPaymentsResponse, T, PaymentsR
}
}
-impl<F, T> TryFrom<ResponseRouterData<F, SantanderVoidResponse, T, PaymentsResponseData>>
+impl<F, T>
+ TryFrom<ResponseRouterData<F, SantanderPreAuthorizeVoidResponse, T, PaymentsResponseData>>
for RouterData<F, T, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: ResponseRouterData<F, SantanderVoidResponse, T, PaymentsResponseData>,
+ item: ResponseRouterData<F, SantanderPreAuthorizeVoidResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
match item.response.clone() {
- SantanderVoidResponse::Pix(res) => Ok(Self {
+ SantanderPreAuthorizeVoidResponse::Pix(res) => Ok(Self {
status: AttemptStatus::from(res.status),
response: Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(res.txid.clone()),
@@ -1984,7 +1987,24 @@ impl<F, T> TryFrom<ResponseRouterData<F, SantanderVoidResponse, T, PaymentsRespo
}),
..item.data
}),
- SantanderVoidResponse::Boleto(_) => Ok(Self {
+ SantanderPreAuthorizeVoidResponse::PixAutomaticoCobr(res) => Ok(Self {
+ status: cobr_status_to_attempt_status(res.status.clone(), true),
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(res.txid.clone()),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ network_txn_link_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ authentication_data: None,
+ payment_account_reference: None,
+ }),
+ ..item.data
+ }),
+ SantanderPreAuthorizeVoidResponse::Boleto(_) => Ok(Self {
status: AttemptStatus::Voided,
response: item.data.response,
..item.data
@@ -2028,10 +2048,26 @@ impl TryFrom<&PaymentsPreAuthorizeCancelRouterData> for SantanderPaymentsCancelR
let santander_mca_metadata = SantanderMetadataObject::try_from(&item.connector_meta_data)?;
match item.payment_method {
- enums::PaymentMethod::BankTransfer => {
- let pix_req = SantanderPixCancelRequest::try_from(item)?;
- Ok(Self::PixQR(pix_req))
- }
+ enums::PaymentMethod::BankTransfer => match item.payment_method_type {
+ Some(enums::PaymentMethodType::PixQr) => {
+ let pix_req = SantanderPixCancelRequest::try_from(item)?;
+ Ok(Self::PixQR(pix_req))
+ }
+ Some(enums::PaymentMethodType::PixAutomaticoPush)
+ | Some(enums::PaymentMethodType::PixAutomaticoQr) => Ok(Self::PixAutomaticoCobr(
+ SantanderPixAutomaticoCobrCancelRequest {
+ status: SantanderPixAutomaticoCobrCancelStatus::Cancelada,
+ },
+ )),
+ _ => Err(errors::ConnectorError::NotSupported {
+ message: format!(
+ "Pre-authorization Cancel for Payment method {}",
+ item.payment_method
+ ),
+ connector: "Santander".into(),
+ }
+ .into()),
+ },
enums::PaymentMethod::Voucher => {
let boleto_req =
SantanderBoletoCancelRequest::try_from((item, santander_mca_metadata))?;
diff --git a/crates/hyperswitch_connectors/src/connectors/shift4.rs b/crates/hyperswitch_connectors/src/connectors/shift4.rs
index 09e78743f3..0c9d6c48bb 100644
--- a/crates/hyperswitch_connectors/src/connectors/shift4.rs
+++ b/crates/hyperswitch_connectors/src/connectors/shift4.rs
@@ -1015,6 +1015,7 @@ impl ConnectorSpecifications for Shift4 {
| api::CurrentFlowInfo::CompleteAuthorize { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/trustpay.rs b/crates/hyperswitch_connectors/src/connectors/trustpay.rs
index d1870660da..6bf465b644 100644
--- a/crates/hyperswitch_connectors/src/connectors/trustpay.rs
+++ b/crates/hyperswitch_connectors/src/connectors/trustpay.rs
@@ -1467,6 +1467,7 @@ impl ConnectorSpecifications for Trustpay {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs b/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs
index 2d97a27505..675bb71aa3 100644
--- a/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs
+++ b/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs
@@ -1638,7 +1638,8 @@ impl ConnectorSpecifications for Worldpayxml {
api::CurrentFlowInfo::SetupMandate { .. } => false,
api::CurrentFlowInfo::Psync { .. } => false,
api::CurrentFlowInfo::UpdatePostConfirm { .. } => false,
- api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
+ api::CurrentFlowInfo::PreAuthorizeVoid { .. }
+ | api::CurrentFlowInfo::ConnectorWebhookRegister { .. } => false,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/xendit.rs b/crates/hyperswitch_connectors/src/connectors/xendit.rs
index 0ec071f617..99932c7214 100644
--- a/crates/hyperswitch_connectors/src/connectors/xendit.rs
+++ b/crates/hyperswitch_connectors/src/connectors/xendit.rs
@@ -1095,7 +1095,8 @@ impl ConnectorSpecifications for Xendit {
| api::CurrentFlowInfo::CompleteAuthorize { .. }
| api::CurrentFlowInfo::Psync { .. }
| api::CurrentFlowInfo::ConnectorWebhookRegister { .. }
- | api::CurrentFlowInfo::UpdatePostConfirm { .. } => false,
+ | api::CurrentFlowInfo::UpdatePostConfirm { .. }
+ | api::CurrentFlowInfo::PreAuthorizeVoid { .. } => false,
}
}
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index e0d6854fca..e816d5f5b4 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -74,6 +74,15 @@ pub enum CurrentFlowInfo {
/// The payment update post confirm request data
request_data: Box<PaymentsUpdatePostConfirmData>,
},
+ /// Pre-authorize void flow information
+ PreAuthorizeVoid {
+ /// The payment method type used for the payment
+ payment_method_type: Option<common_enums::PaymentMethodType>,
+ /// The current payment attempt status
+ attempt_status: storage_enums::AttemptStatus,
+ /// Whether this is a merchant-initiated transaction
+ is_mit_payment: bool,
+ },
ConnectorWebhookRegister {
/// The payment setup mandate request data
request_data: Box<ConnectorWebhookRegisterRequest>,
@@ -88,6 +97,7 @@ impl CurrentFlowInfo {
Self::SetupMandate { .. } => None,
Self::Psync { request_data } => request_data.feature_metadata.clone(),
Self::UpdatePostConfirm { request_data } => request_data.feature_metadata.clone(),
+ Self::PreAuthorizeVoid { .. } => None,
Self::ConnectorWebhookRegister { .. } => None,
}
}
diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs
index 28a6a6a767..77148d90e3 100644
--- a/crates/hyperswitch_interfaces/src/api.rs
+++ b/crates/hyperswitch_interfaces/src/api.rs
@@ -489,10 +489,7 @@ pub trait ConnectorSpecifications {
false
}
/// Check if pre-authenticate cancel flow is supported
- fn is_pre_authorize_cancel_supported(
- &self,
- _payment_method_type: Option<PaymentMethodType>,
- ) -> bool {
+ fn is_pre_authorize_cancel_supported(&self, _current_flow: CurrentFlowInfo) -> bool {
false
}
/// Check if connector should be called for UpdatePostConfirm
diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
index 6be1225cfd..9ba585fac2 100644
--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
@@ -708,17 +708,10 @@ impl ConnectorSpecifications for ConnectorEnum {
}
/// Check if connector supports pre-authorize cancel
- fn is_pre_authorize_cancel_supported(
- &self,
- payment_method_type: Option<common_enums::PaymentMethodType>,
- ) -> bool {
+ fn is_pre_authorize_cancel_supported(&self, current_flow: CurrentFlowInfo) -> bool {
match self {
- Self::Old(connector) => {
- connector.is_pre_authorize_cancel_supported(payment_method_type)
- }
- Self::New(connector) => {
- connector.is_pre_authorize_cancel_supported(payment_method_type)
- }
+ Self::Old(connector) => connector.is_pre_authorize_cancel_supported(current_flow),
+ Self::New(connector) => connector.is_pre_authorize_cancel_supported(current_flow),
}
}
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 01383d6dd1..eb64cccd28 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -11578,6 +11578,7 @@ where
"PreAuthorizeVoid" => matches!(
payment_data.get_payment_intent().status,
storage_enums::IntentStatus::RequiresCustomerAction
+ | storage_enums::IntentStatus::Processing
),
_ => false,
}
diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs
index a4a8671959..470d0ff5cf 100644
--- a/crates/router/src/core/payments/operations/payment_cancel.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel.rs
@@ -5,6 +5,7 @@ use async_trait::async_trait;
use common_utils::ext_traits::AsyncExt;
use error_stack::ResultExt;
use hyperswitch_domain_models::payment_method_data::ApiPaymentMethodDataMandateIds;
+use hyperswitch_interfaces::api::ConnectorSpecifications;
use router_env::instrument;
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
@@ -73,19 +74,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
- helpers::validate_payment_status_against_not_allowed_statuses(
- payment_intent.status,
- &[
- enums::IntentStatus::Failed,
- enums::IntentStatus::Succeeded,
- enums::IntentStatus::Cancelled,
- enums::IntentStatus::Processing,
- enums::IntentStatus::RequiresMerchantAction,
- enums::IntentStatus::Review,
- ],
- "cancel",
- )?;
-
let mut payment_attempt = db
.find_payment_attempt_by_payment_id_processor_merchant_id_attempt_id(
&payment_intent.payment_id,
@@ -97,6 +85,47 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
+ let supports_processing_pre_authorize_void = payment_intent.status
+ == enums::IntentStatus::Processing
+ && payment_attempt.payment_method_id.is_some()
+ && payment_attempt
+ .connector
+ .as_ref()
+ .and_then(|connector_name| {
+ api::ConnectorData::get_connector_by_name(
+ &state.conf.connectors,
+ connector_name,
+ api::GetToken::Connector,
+ payment_attempt.merchant_connector_id.clone(),
+ )
+ .ok()
+ })
+ .is_some_and(|connector_data| {
+ connector_data.connector.is_pre_authorize_cancel_supported(
+ hyperswitch_interfaces::api::CurrentFlowInfo::PreAuthorizeVoid {
+ payment_method_type: payment_attempt.payment_method_type,
+ attempt_status: payment_attempt.status,
+ is_mit_payment: true,
+ },
+ )
+ });
+
+ let mut not_allowed_statuses = vec![
+ enums::IntentStatus::Failed,
+ enums::IntentStatus::Succeeded,
+ enums::IntentStatus::Cancelled,
+ enums::IntentStatus::RequiresMerchantAction,
+ enums::IntentStatus::Review,
+ ];
+ if !supports_processing_pre_authorize_void {
+ not_allowed_statuses.push(enums::IntentStatus::Processing);
+ }
+ helpers::validate_payment_status_against_not_allowed_statuses(
+ payment_intent.status,
+ &not_allowed_statuses,
+ "cancel",
+ )?;
+
let shipping_address = helpers::get_address_by_id(
state,
payment_intent.shipping_address_id.clone(),
@@ -178,6 +207,16 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
.clone()
.map(domain::PaymentMethodData::from));
+ let recurring_mandate_payment_data =
+ payment_attempt.payment_method_id.is_some().then(|| {
+ hyperswitch_domain_models::router_data::RecurringMandatePaymentData {
+ payment_method_type: payment_attempt.payment_method_type,
+ original_payment_authorized_amount: None,
+ original_payment_authorized_currency: None,
+ mandate_metadata: None,
+ }
+ });
+
let payment_data = PaymentData {
capture_feature_metadata: None,
flow: PhantomData,
@@ -215,7 +254,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
creds_identifier,
pm_token: None,
connector_customer_id: None,
- recurring_mandate_payment_data: None,
+ recurring_mandate_payment_data,
multiple_capture_data: None,
redirect_response: None,
surcharge_details: None,
diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs
index e281bb9ad7..d4ff299bbe 100644
--- a/crates/router/src/routes/payments.rs
+++ b/crates/router/src/routes/payments.rs
@@ -2060,7 +2060,7 @@ pub async fn payments_cancel(
}
};
- // Check if the payment status is RequiresCustomerAction and connector supports pre-authorize cancel
+ // Check whether the connector supports pre-authorize cancel for this payment attempt.
let supports_pre_authorize_cancel =
if let Some(ref connector_name_str) = payment_pre_fetched_info.payment_attempt.connector {
ConnectorData::get_connector_by_name(
@@ -2070,16 +2070,25 @@ pub async fn payments_cancel(
None,
)
.map(|connector_data| {
- connector_data.connector.is_pre_authorize_cancel_supported(payment_pre_fetched_info.payment_attempt.payment_method_type)
+ connector_data.connector.is_pre_authorize_cancel_supported(
+ hyperswitch_interfaces::api::CurrentFlowInfo::PreAuthorizeVoid {
+ payment_method_type: payment_pre_fetched_info
+ .payment_attempt
+ .payment_method_type,
+ attempt_status: payment_pre_fetched_info.payment_attempt.status,
+ is_mit_payment: payment_pre_fetched_info
+ .payment_attempt
+ .payment_method_id
+ .is_some(),
+ },
+ )
})
.unwrap_or(false)
} else {
false
};
- if payment_pre_fetched_info.payment_intent.status == api_enums::IntentStatus::RequiresCustomerAction
- && supports_pre_authorize_cancel
- {
+ if supports_pre_authorize_cancel {
Box::pin(payments::payments_core::<
api_types::PreAuthorizeVoid,
payment_types::PaymentsResponse,