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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(core/connector): [SANTANDER] Add PreAuthorizeVoid Flow for Payments Cancel API (#12436)
Sayak Bhattacharyac2757eadeeb0
diff --git a/crates/hyperswitch_connectors/src/connectors/santander.rs b/crates/hyperswitch_connectors/src/connectors/santander.rsindex 1c8a0768d3..d6d77ba7eb 100644--- a/crates/hyperswitch_connectors/src/connectors/santander.rs+++ b/crates/hyperswitch_connectors/src/connectors/santander.rs@@ -17,8 +17,8 @@ use hyperswitch_domain_models::{router_flow_types::{access_token_auth::AccessTokenAuth,payments::{- Authorize, Capture, GenerateQr, PSync, PaymentMethodToken, PushNotification, Session,- SetupMandate, Void,+ Authorize, Capture, GenerateQr, PSync, PaymentMethodToken, PreAuthorizeVoid,+ PushNotification, Session, SetupMandate, Void,},refunds::{Execute, RSync},AuthorizeSessionToken, UpdateMetadata,@@ -26,8 +26,9 @@ use hyperswitch_domain_models::{router_request_types::{AccessTokenRequestData, AuthorizeSessionTokenData, GenerateQrRequestData,PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData,- PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, PaymentsUpdateMetadataData,- PushNotificationRequestData, RefundsData, ResponseId, SetupMandateRequestData,+ PaymentsCaptureData, PaymentsPreAuthorizeCancelData, PaymentsSessionData, PaymentsSyncData,+ PaymentsUpdateMetadataData, PushNotificationRequestData, RefundsData, ResponseId,+ SetupMandateRequestData,},router_response_types::{ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,@@ -36,8 +37,9 @@ use hyperswitch_domain_models::{types::{PaymentsAuthorizeRouterData, PaymentsAuthorizeSessionTokenRouterData,PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsGenerateQrRouterData,- PaymentsPushNotificationRouterData, PaymentsSyncRouterData,- PaymentsUpdateMetadataRouterData, RefundSyncRouterData, RefundsRouterData,+ PaymentsPreAuthorizeCancelRouterData, PaymentsPushNotificationRouterData,+ PaymentsSyncRouterData, PaymentsUpdateMetadataRouterData, RefundSyncRouterData,+ RefundsRouterData,},};use hyperswitch_interfaces::{@@ -58,8 +60,9 @@ use crate::{connectors::santander::{requests::{AccessTokenUrlPath, SantanderAuthRequest, SantanderAuthType, SantanderMetadataObject,- SantanderPaymentRequest, SantanderPixAutomaticSolicitationRequest,- SantanderRefundRequest, SantanderRouterData, SantanderSetupMandateRequest,+ SantanderPaymentRequest, SantanderPaymentsCancelRequest,+ SantanderPixAutomaticSolicitationRequest, SantanderRefundRequest, SantanderRouterData,+ SantanderSetupMandateRequest,},responses::{SanatanderAccessTokenResponse, SantanderCreatePixPayloadLocationResponse,@@ -111,6 +114,7 @@ impl api::PaymentToken for Santander {}impl api::PaymentUpdateMetadata for Santander {}impl api::PaymentsPushNotification for Santander {}impl api::PaymentsGenerateQr for Santander {}+impl api::PaymentPreAuthorizeVoid for Santander {}impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>for Santander@@ -1583,10 +1587,12 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo}}-impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Santander {+impl ConnectorIntegration<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, PaymentsResponseData>+ for Santander+{fn get_headers(&self,- req: &PaymentsCancelRouterData,+ req: &PaymentsPreAuthorizeCancelRouterData,connectors: &Connectors,) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {self.build_headers(req, connectors)@@ -1598,108 +1604,113 @@ impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Safn get_url(&self,- _req: &PaymentsCancelRouterData,- _connectors: &Connectors,+ req: &PaymentsPreAuthorizeCancelRouterData,+ connectors: &Connectors,) -> CustomResult<String, errors::ConnectorError> {- Err(errors::ConnectorError::NotImplemented("Santander".to_string()).into())- // let santander_mca_metadata = SantanderMetadataObject::try_from(&req.connector_meta_data)?;-- // match req.payment_method {- // enums::PaymentMethod::BankTransfer => match req.request.payment_method_type {- // Some(enums::PaymentMethodType::Pix) => {- // let santander_variant =- // transformers::get_qr_code_type(req.request.connector_meta.clone())?;-- // match santander_variant {- // ExpiryType::Immediate => Ok(format!(- // "{}api/v1/cob/{}",- // self.base_url(connectors),- // req.request.connector_transaction_id- // )),- // ExpiryType::Scheduled => Ok(format!(- // "{}api/v1/cobv/{}",- // self.base_url(connectors),- // req.request.connector_transaction_id- // )),- // }- // }- // _ => Err(errors::ConnectorError::NotSupported {- // message: req.payment_method.to_string(),- // connector: "Santander",- // }- // .into()),- // },- // enums::PaymentMethod::Voucher => match req.request.payment_method_type {- // Some(enums::PaymentMethodType::Boleto) => {- // let base_url = connectors- // .santander- // .secondary_base_url- // .clone()- // .ok_or(errors::ConnectorError::FailedToObtainIntegrationUrl)?;-- // let version = santander_constants::SANTANDER_VERSION;-- // let boleto_mca_metadata = santander_mca_metadata- // .boleto- // .ok_or(errors::ConnectorError::NoConnectorMetaData)?;-- // Ok(format!(- // "{base_url}collection_bill_management/{version}/workspaces/{}/bank_slips",- // boleto_mca_metadata.workspace_id.peek(),- // ))- // }- // _ => Err(errors::ConnectorError::NotSupported {- // message: req.payment_method.to_string(),- // connector: "Santander",- // }- // .into()),- // },- // _ => Err(errors::ConnectorError::NotSupported {- // message: req.payment_method.to_string(),- // connector: "Santander",- // }- // .into()),- // }+ let santander_mca_metadata = SantanderMetadataObject::try_from(&req.connector_meta_data)?;++ match req.payment_method {+ enums::PaymentMethod::BankTransfer => match req.payment_method_type {+ Some(enums::PaymentMethodType::PixEmv) => {+ let santander_variant = transformers::get_qr_code_type(+ req.request.connector_meta.clone(),+ )+ .ok_or(errors::ConnectorError::MissingRequiredField {+ field_name: "connector_meta",+ })?;++ match santander_variant {+ common_enums::ExpiryType::Immediate => Ok(format!(+ "{}api/v1/cob/{}",+ self.base_url(connectors),+ req.request.connector_transaction_id+ )),+ common_enums::ExpiryType::Scheduled => Ok(format!(+ "{}api/v1/cobv/{}",+ self.base_url(connectors),+ req.request.connector_transaction_id+ )),+ }+ }+ _ => Err(errors::ConnectorError::NotSupported {+ message: req.payment_method.to_string(),+ connector: "Santander",+ }+ .into()),+ },+ enums::PaymentMethod::Voucher => match req.payment_method_type {+ Some(enums::PaymentMethodType::Boleto) => {+ let base_url = connectors+ .santander+ .secondary_base_url+ .clone()+ .ok_or(errors::ConnectorError::FailedToObtainIntegrationUrl)?;++ let version = santander_constants::SANTANDER_VERSION;++ let boleto_mca_metadata = santander_mca_metadata+ .boleto+ .ok_or(errors::ConnectorError::NoConnectorMetaData)?;++ Ok(format!(+ "{base_url}collection_bill_management/{version}/workspaces/{}/bank_slips",+ boleto_mca_metadata.workspace_id.peek(),+ ))+ }+ _ => Err(errors::ConnectorError::NotSupported {+ message: req.payment_method.to_string(),+ connector: "Santander",+ }+ .into()),+ },+ _ => Err(errors::ConnectorError::NotSupported {+ message: req.payment_method.to_string(),+ connector: "Santander",+ }+ .into()),+ }}fn get_request_body(&self,- _req: &PaymentsCancelRouterData,+ req: &PaymentsPreAuthorizeCancelRouterData,_connectors: &Connectors,) -> CustomResult<RequestContent, errors::ConnectorError> {- Err(errors::ConnectorError::NotImplemented("Santander".to_string()).into())- // let connector_req = SantanderPaymentsCancelRequest::try_from(req)?;- // Ok(RequestContent::Json(Box::new(connector_req)))+ let connector_req = SantanderPaymentsCancelRequest::try_from(req)?;+ Ok(RequestContent::Json(Box::new(connector_req)))}fn build_request(&self,- _req: &PaymentsCancelRouterData,- _connectors: &Connectors,+ req: &PaymentsPreAuthorizeCancelRouterData,+ connectors: &Connectors,) -> CustomResult<Option<Request>, errors::ConnectorError> {- Err(errors::ConnectorError::NotImplemented("Santander".to_string()).into())- // let auth_details = SantanderAuthType::try_from(&req.connector_auth_type)?;- // Ok(Some(- // RequestBuilder::new()- // .method(Method::Patch)- // .url(&types::PaymentsVoidType::get_url(self, req, connectors)?)- // .add_certificate(Some(auth_details.client_id))- // .add_certificate_key(Some(auth_details.client_secret))- // .attach_default_headers()- // .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)- // .set_body(types::PaymentsVoidType::get_request_body(- // self, req, connectors,- // )?)- // .build(),- // ))+ let auth_details = SantanderAuthType::try_from(&req.connector_auth_type)?;+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Patch)+ .url(&types::PaymentsPreAuthorizeVoidType::get_url(+ self, req, connectors,+ )?)+ .add_certificate(Some(auth_details.client_id))+ .add_certificate_key(Some(auth_details.client_secret))+ .attach_default_headers()+ .headers(types::PaymentsPreAuthorizeVoidType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::PaymentsPreAuthorizeVoidType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))}fn handle_response(&self,- data: &PaymentsCancelRouterData,+ data: &PaymentsPreAuthorizeCancelRouterData,event_builder: Option<&mut ConnectorEvent>,res: Response,- ) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {+ ) -> CustomResult<PaymentsPreAuthorizeCancelRouterData, errors::ConnectorError> {let response: SantanderVoidResponse =res.response.parse_struct("Santander VoidResponse")@@ -1730,6 +1741,16 @@ impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Sa}}+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Santander {+ fn build_request(+ &self,+ _req: &PaymentsCancelRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("Santander".to_string()).into())+ }+}+impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Santander {fn get_headers(&self,@@ -2082,6 +2103,17 @@ 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::PixEmv) | Some(enums::PaymentMethodType::Boleto)+ )+ }+fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {Some(&*SANTANDER_SUPPORTED_PAYMENT_METHODS)}diff --git a/crates/hyperswitch_connectors/src/connectors/santander/responses.rs b/crates/hyperswitch_connectors/src/connectors/santander/responses.rsindex 74e3579b42..33d102f103 100644--- a/crates/hyperswitch_connectors/src/connectors/santander/responses.rs+++ b/crates/hyperswitch_connectors/src/connectors/santander/responses.rs@@ -270,7 +270,7 @@ pub struct SantanderPixVoidResponse {// Debtorpub devedor: Option<requests::SantanderDebtor>,// Recipient- pub recebedor: Recipient,+ pub recebedor: Option<Recipient>,// Statuspub status: SantanderPaymentStatus,// Value@@ -284,6 +284,8 @@ pub struct SantanderPixVoidResponse {// Additional Infopub info_adicionais: Option<Vec<SantanderAdditionalInfo>>,pub pix: Option<Vec<SantanderPix>>,+ // Location (for void response)+ pub location: Option<String>,}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -312,6 +314,8 @@ pub struct ValueResponse {pub juros: Option<Interest>,// Discount detailspub desconto: Option<DiscountResponse>,+ // Modal of alteration (for void response)+ pub modalidade_alteracao: Option<String>,}#[derive(Debug, Clone, Serialize, Deserialize)]diff --git a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rsindex f8ba538640..fa81182682 100644--- a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs@@ -24,7 +24,8 @@ use hyperswitch_domain_models::{},router_response_types::{MandateReference, PaymentsResponseData, RefundsResponseData},types::{- PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsPushNotificationRouterData,+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData,+ PaymentsPreAuthorizeCancelRouterData, PaymentsPushNotificationRouterData,PaymentsSyncRouterData, PaymentsUpdateMetadataRouterData, RefundsRouterData,},};@@ -1682,10 +1683,38 @@ impl<F, T> TryFrom<ResponseRouterData<F, SantanderVoidResponse, T, PaymentsRespo}}-impl TryFrom<&PaymentsCancelRouterData> for SantanderPaymentsCancelRequest {+impl TryFrom<(&PaymentsCancelRouterData, SantanderMetadataObject)>+ for SantanderBoletoCancelRequest+{type Error = Error;+ fn try_from(+ value: (&PaymentsCancelRouterData, SantanderMetadataObject),+ ) -> Result<Self, Self::Error> {+ let boleto_mca_metadata = value+ .1+ .boleto+ .ok_or(errors::ConnectorError::NoConnectorMetaData)?;+ Ok(Self {+ operation: SantanderBoletoCancelOperation::Baixar,+ covenant_code: boleto_mca_metadata.covenant_code.clone(),+ bank_number: value.0.connector_request_reference_id.clone(),+ })+ }+}- fn try_from(item: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {+impl TryFrom<&PaymentsCancelRouterData> for SantanderPixCancelRequest {+ type Error = Error;+ fn try_from(_value: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {+ Ok(Self {+ status: Some(SantanderVoidStatus::RemovidaPeloUsuarioRecebedor),+ })+ }+}++impl TryFrom<&PaymentsPreAuthorizeCancelRouterData> for SantanderPaymentsCancelRequest {+ type Error = Error;++ fn try_from(item: &PaymentsPreAuthorizeCancelRouterData) -> Result<Self, Self::Error> {let santander_mca_metadata = SantanderMetadataObject::try_from(&item.connector_meta_data)?;match item.payment_method {@@ -1698,20 +1727,30 @@ impl TryFrom<&PaymentsCancelRouterData> for SantanderPaymentsCancelRequest {SantanderBoletoCancelRequest::try_from((item, santander_mca_metadata))?;Ok(Self::Boleto(boleto_req))}- _ => Err(errors::ConnectorError::MissingRequiredField {- field_name: "payment_method",+ _ => Err(errors::ConnectorError::NotSupported {+ message: format!(+ "Pre-authorization Cancel for Payment method {}",+ item.payment_method+ ),+ connector: "Santander",}.into()),}}}-impl TryFrom<(&PaymentsCancelRouterData, SantanderMetadataObject)>- for SantanderBoletoCancelRequest+impl+ TryFrom<(+ &PaymentsPreAuthorizeCancelRouterData,+ SantanderMetadataObject,+ )> for SantanderBoletoCancelRequest{type Error = Error;fn try_from(- value: (&PaymentsCancelRouterData, SantanderMetadataObject),+ value: (+ &PaymentsPreAuthorizeCancelRouterData,+ SantanderMetadataObject,+ ),) -> Result<Self, Self::Error> {let boleto_mca_metadata = value.1@@ -1720,38 +1759,20 @@ impl TryFrom<(&PaymentsCancelRouterData, SantanderMetadataObject)>Ok(Self {operation: SantanderBoletoCancelOperation::Baixar,covenant_code: boleto_mca_metadata.covenant_code.clone(),- bank_number: extract_bank_number(value.0.request.connector_meta.clone())?,+ bank_number: value.0.connector_request_reference_id.clone(),})}}-impl TryFrom<&PaymentsCancelRouterData> for SantanderPixCancelRequest {+impl TryFrom<&PaymentsPreAuthorizeCancelRouterData> for SantanderPixCancelRequest {type Error = Error;- fn try_from(_value: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {+ fn try_from(_value: &PaymentsPreAuthorizeCancelRouterData) -> Result<Self, Self::Error> {Ok(Self {status: Some(SantanderVoidStatus::RemovidaPeloUsuarioRecebedor),})}}-fn extract_bank_number(value: Option<Value>) -> Result<String, errors::ConnectorError> {- let value = value.ok_or_else(|| errors::ConnectorError::NoConnectorMetaData)?;-- let map = value- .as_object()- .ok_or_else(|| errors::ConnectorError::NoConnectorMetaData)?;-- let bank_number = map- .get("bank_number")- .ok_or_else(|| errors::ConnectorError::NoConnectorMetaData)?;-- let bank_number_str = bank_number- .as_str()- .ok_or_else(|| errors::ConnectorError::NoConnectorMetaData)?- .to_string();- Ok(bank_number_str)-}-fn get_qr_code_data<F, T>(item: &ResponseRouterData<F, SantanderPaymentsResponse, T, PaymentsResponseData>,pix_data: &SantanderPixQRCodePaymentsResponse,@@ -2809,6 +2830,7 @@ pub fn decide_access_token_key_suffix(None => Some(AccessTokenUrlPath::Leg2),}}+ (_, Some(enums::PaymentMethodType::Boleto)) => Some(AccessTokenUrlPath::Boleto),(None, Some(enums::PaymentMethodType::PixAutomaticoPush)) => {Some(AccessTokenUrlPath::Leg2)}diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rsindex 22092441b5..5c567992aa 100644--- a/crates/hyperswitch_connectors/src/default_implementations.rs+++ b/crates/hyperswitch_connectors/src/default_implementations.rs@@ -36,8 +36,9 @@ use hyperswitch_domain_models::{Approve, AuthorizeSessionToken, CalculateSurcharge, CalculateTax, CompleteAuthorize,CompleteRefundSurchrge, CompleteSurcharge, CreateConnectorCustomer, CreateOrder,ExtendAuthorization, GenerateQr, GiftCardBalanceCheck, IncrementalAuthorization,- PostCaptureVoid, PostCaptureVoidSync, PostProcessing, PostSessionTokens, PreProcessing,- PushNotification, Reject, SdkSessionUpdate, SettlementSplitCreate, UpdateMetadata,+ PostCaptureVoid, PostCaptureVoidSync, PostProcessing, PostSessionTokens,+ PreAuthorizeVoid, PreProcessing, PushNotification, Reject, SdkSessionUpdate,+ SettlementSplitCreate, UpdateMetadata,},subscriptions::{GetSubscriptionEstimate, GetSubscriptionItemPrices, GetSubscriptionItems,@@ -72,11 +73,11 @@ use hyperswitch_domain_models::{PaymentsCompleteRefundSurchrgeData, PaymentsCompleteSurchargeData,PaymentsExtendAuthorizationData, PaymentsIncrementalAuthorizationData,PaymentsPostAuthenticateData, PaymentsPostProcessingData, PaymentsPostSessionTokensData,- PaymentsPreAuthenticateData, PaymentsPreProcessingData, PaymentsRejectData,- PaymentsSurchargeCalculationData, PaymentsTaxCalculationData, PaymentsUpdateMetadataData,- PushNotificationRequestData, RetrieveFileRequestData, SdkPaymentsSessionUpdateData,- SettlementSplitRequestData, SubmitEvidenceRequestData, UploadFileRequestData,- VaultRequestData, VerifyWebhookSourceRequestData,+ PaymentsPreAuthenticateData, PaymentsPreAuthorizeCancelData, PaymentsPreProcessingData,+ PaymentsRejectData, PaymentsSurchargeCalculationData, PaymentsTaxCalculationData,+ PaymentsUpdateMetadataData, PushNotificationRequestData, RetrieveFileRequestData,+ SdkPaymentsSessionUpdateData, SettlementSplitRequestData, SubmitEvidenceRequestData,+ UploadFileRequestData, VaultRequestData, VerifyWebhookSourceRequestData,},router_response_types::{merchant_connector_webhook_management::ConnectorWebhookRegisterResponse,@@ -146,12 +147,12 @@ use hyperswitch_interfaces::{ConnectorCustomer, ExternalVaultProxyPaymentsCreateV1, PaymentApprove,PaymentAuthorizeSessionToken, PaymentExtendAuthorization,PaymentIncrementalAuthorization, PaymentPostCaptureVoid, PaymentPostCaptureVoidSync,- PaymentPostSessionTokens, PaymentReject, PaymentSessionUpdate, PaymentUpdateMetadata,- PaymentsAuthenticate, PaymentsCompleteAuthorize, PaymentsCreateOrder,- PaymentsGenerateQr, PaymentsGiftCardBalanceCheck, PaymentsPostAuthenticate,- PaymentsPostProcessing, PaymentsPreAuthenticate, PaymentsPreProcessing,- PaymentsPushNotification, PaymentsSettlementSplitCreate, SurchargeCalculation,- SurchargeComplete, SurchargeRefund, TaxCalculation,+ PaymentPostSessionTokens, PaymentPreAuthorizeVoid, PaymentReject, PaymentSessionUpdate,+ PaymentUpdateMetadata, PaymentsAuthenticate, PaymentsCompleteAuthorize,+ PaymentsCreateOrder, PaymentsGenerateQr, PaymentsGiftCardBalanceCheck,+ PaymentsPostAuthenticate, PaymentsPostProcessing, PaymentsPreAuthenticate,+ PaymentsPreProcessing, PaymentsPushNotification, PaymentsSettlementSplitCreate,+ SurchargeCalculation, SurchargeComplete, SurchargeRefund, TaxCalculation,},revenue_recovery::RevenueRecovery,subscriptions::{@@ -10714,6 +10715,15 @@ default_imp_for_connector_webhook_register!(connectors::Zsl);+#[cfg(feature = "dummy_connector")]+impl<const T: u8> PaymentPreAuthorizeVoid for connectors::DummyConnector<T> {}+#[cfg(feature = "dummy_connector")]+impl<const T: u8>+ ConnectorIntegration<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, PaymentsResponseData>+ for connectors::DummyConnector<T>+{+}+#[cfg(feature = "dummy_connector")]impl<const T: u8> PaymentsCompleteAuthorize for connectors::DummyConnector<T> {}#[cfg(feature = "dummy_connector")]@@ -11820,3 +11830,176 @@ default_imp_for_push_notification_flow!(connectors::Zsl,connectors::CtpMastercard);++macro_rules! default_imp_for_pre_authorize_void {+ ($($path:ident::$connector:ident),*) => {+ $( impl PaymentPreAuthorizeVoid for $path::$connector {}+ impl+ ConnectorIntegration<+ PreAuthorizeVoid,+ PaymentsPreAuthorizeCancelData,+ PaymentsResponseData,+ > for $path::$connector+ {+ fn build_request(+ &self,+ _req: &hyperswitch_domain_models::types::PaymentsPreAuthorizeCancelRouterData,+ _connectors: &hyperswitch_interfaces::configs::Connectors+ ) -> CustomResult<Option<common_utils::request::Request>, hyperswitch_interfaces::errors::ConnectorError> {+ Err(hyperswitch_interfaces::errors::ConnectorError::NotImplemented(+ "Pre-authorize void not implemented for this connector".to_string(),+ ).into())+ }+ }+ )*+ };+}++default_imp_for_pre_authorize_void!(+ connectors::Payconex,+ connectors::Nuvei,+ connectors::Worldpayvantiv,+ connectors::Aci,+ connectors::Adyen,+ connectors::Adyenplatform,+ connectors::Affirm,+ connectors::Airwallex,+ connectors::Amazonpay,+ connectors::Archipel,+ connectors::Authipay,+ connectors::Authorizedotnet,+ connectors::Bambora,+ connectors::Bamboraapac,+ connectors::Bankofamerica,+ connectors::Barclaycard,+ connectors::Bitpay,+ connectors::Blackhawknetwork,+ connectors::Calida,+ connectors::Bluesnap,+ connectors::Braintree,+ connectors::Boku,+ connectors::Breadpay,+ connectors::Billwerk,+ connectors::Cashtocode,+ connectors::Celero,+ connectors::Chargebee,+ connectors::Checkbook,+ connectors::Checkout,+ connectors::Coinbase,+ connectors::Coingate,+ connectors::Cryptopay,+ connectors::Custombilling,+ connectors::Cybersource,+ connectors::Cybersourcedecisionmanager,+ connectors::Datatrans,+ connectors::Digitalvirgo,+ connectors::Dlocal,+ connectors::Dwolla,+ connectors::Ebanx,+ connectors::Elavon,+ connectors::Envoy,+ connectors::Facilitapay,+ connectors::Finix,+ connectors::Fiserv,+ connectors::Fiservemea,+ connectors::Forte,+ connectors::Getnet,+ connectors::Gigadat,+ connectors::Helcim,+ connectors::HyperswitchVault,+ connectors::Hyperwallet,+ connectors::Iatapay,+ connectors::Inespay,+ connectors::Itaubank,+ connectors::Jpmorgan,+ connectors::Juspaythreedsserver,+ connectors::Katapult,+ connectors::Klarna,+ connectors::Loonio,+ connectors::Paypal,+ connectors::Paysafe,+ connectors::Rapyd,+ connectors::Razorpay,+ connectors::Recurly,+ connectors::Redsys,+ connectors::Shift4,+ connectors::Sift,+ connectors::Silverflow,+ connectors::Signifyd,+ connectors::Square,+ connectors::Stax,+ connectors::Stripe,+ connectors::Stripebilling,+ connectors::Taxjar,+ connectors::Tesouro,+ connectors::Mifinity,+ connectors::Mollie,+ connectors::Moneris,+ connectors::Mpgs,+ connectors::Multisafepay,+ connectors::Netcetera,+ connectors::Nomupay,+ connectors::Noon,+ connectors::Nordea,+ connectors::Novalnet,+ connectors::Nexinets,+ connectors::Nexixpay,+ connectors::Opayo,+ connectors::Opennode,+ connectors::Nmi,+ connectors::Paybox,+ connectors::Payeezy,+ connectors::Payjustnow,+ connectors::Payjustnowinstore,+ connectors::Payload,+ connectors::Payme,+ connectors::Paystack,+ connectors::Paytm,+ connectors::Payu,+ connectors::Peachpayments,+ connectors::Phonepe,+ connectors::Placetopay,+ connectors::Plaid,+ connectors::Payone,+ connectors::Fiuu,+ connectors::Flexiti,+ connectors::Globalpay,+ connectors::Globepay,+ connectors::Gocardless,+ connectors::Gpayments,+ connectors::Hipay,+ connectors::Hyperpg,+ connectors::Wise,+ connectors::Worldline,+ connectors::Worldpay,+ connectors::Worldpaymodular,+ connectors::Worldpayxml,+ connectors::Wellsfargo,+ connectors::Wellsfargopayout,+ connectors::Xendit,+ connectors::Zift,+ connectors::Powertranz,+ connectors::Prophetpay,+ connectors::Riskified,+ connectors::Threedsecureio,+ connectors::Thunes,+ connectors::Tokenex,+ connectors::Tokenio,+ connectors::Truelayer,+ connectors::Trustpay,+ connectors::Trustpayments,+ connectors::Tsys,+ connectors::UnifiedAuthenticationService,+ connectors::Deutschebank,+ connectors::Vgs,+ connectors::Volt,+ connectors::Zen,+ connectors::Zsl,+ connectors::CtpMastercard,+ connectors::Fiservcommercehub,+ connectors::Imerchantsolutions,+ connectors::Interpayments,+ connectors::Revolv3,+ connectors::AbsaSanlam,+ connectors::Trustly+);diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rsindex 467f2d6d7d..72a2358223 100644--- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs@@ -23,9 +23,9 @@ use hyperswitch_domain_models::{CompleteAuthorize, CompleteRefundSurchrge, CompleteSurcharge, CreateConnectorCustomer,CreateOrder, ExtendAuthorization, ExternalVaultProxy, GenerateQr, GiftCardBalanceCheck,IncrementalAuthorization, PSync, PaymentMethodToken, PostCaptureVoid,- PostCaptureVoidSync, PostProcessing, PostSessionTokens, PreProcessing,- PushNotification, Reject, SdkSessionUpdate, Session, SettlementSplitCreate,- SetupMandate, UpdateMetadata, Void,+ PostCaptureVoidSync, PostProcessing, PostSessionTokens, PreAuthorizeVoid,+ PreProcessing, PushNotification, Reject, SdkSessionUpdate, Session,+ SettlementSplitCreate, SetupMandate, UpdateMetadata, Void,},refunds::{Execute, RSync},revenue_recovery::{@@ -53,12 +53,13 @@ use hyperswitch_domain_models::{PaymentsCompleteRefundSurchrgeData, PaymentsCompleteSurchargeData,PaymentsExtendAuthorizationData, PaymentsIncrementalAuthorizationData,PaymentsPostAuthenticateData, PaymentsPostProcessingData, PaymentsPostSessionTokensData,- PaymentsPreAuthenticateData, PaymentsPreProcessingData, PaymentsRejectData,- PaymentsSessionData, PaymentsSurchargeCalculationData, PaymentsSyncData,- PaymentsTaxCalculationData, PaymentsUpdateMetadataData, PushNotificationRequestData,- RefundsData, RetrieveFileRequestData, SdkPaymentsSessionUpdateData,- SettlementSplitRequestData, SetupMandateRequestData, SubmitEvidenceRequestData,- UploadFileRequestData, VaultRequestData, VerifyWebhookSourceRequestData,+ PaymentsPreAuthenticateData, PaymentsPreAuthorizeCancelData, PaymentsPreProcessingData,+ PaymentsRejectData, PaymentsSessionData, PaymentsSurchargeCalculationData,+ PaymentsSyncData, PaymentsTaxCalculationData, PaymentsUpdateMetadataData,+ PushNotificationRequestData, RefundsData, RetrieveFileRequestData,+ SdkPaymentsSessionUpdateData, SettlementSplitRequestData, SetupMandateRequestData,+ SubmitEvidenceRequestData, UploadFileRequestData, VaultRequestData,+ VerifyWebhookSourceRequestData,},router_response_types::{merchant_connector_webhook_management::ConnectorWebhookRegisterResponse,@@ -124,8 +125,8 @@ use hyperswitch_interfaces::{PaymentAuthorizeSessionTokenV2, PaymentAuthorizeV2, PaymentCaptureV2,PaymentCreateOrderV2, PaymentExtendAuthorizationV2, PaymentIncrementalAuthorizationV2,PaymentPostCaptureVoidSyncV2, PaymentPostCaptureVoidV2, PaymentPostSessionTokensV2,- PaymentRejectV2, PaymentSessionUpdateV2, PaymentSessionV2, PaymentSyncV2,- PaymentTokenV2, PaymentUpdateMetadataV2, PaymentV2, PaymentVoidV2,+ PaymentPreAuthorizeVoidV2, PaymentRejectV2, PaymentSessionUpdateV2, PaymentSessionV2,+ PaymentSyncV2, PaymentTokenV2, PaymentUpdateMetadataV2, PaymentV2, PaymentVoidV2,PaymentsAuthenticateV2, PaymentsCompleteAuthorizeV2, PaymentsGenerateQrV2,PaymentsGiftCardBalanceCheckV2, PaymentsPostAuthenticateV2, PaymentsPostProcessingV2,PaymentsPreAuthenticateV2, PaymentsPreProcessingV2, PaymentsPushNotificationV2,@@ -158,6 +159,7 @@ macro_rules! default_imp_for_new_connector_integration_payment {impl PaymentVoidV2 for $path::$connector{}impl PaymentPostCaptureVoidV2 for $path::$connector{}impl PaymentPostCaptureVoidSyncV2 for $path::$connector{}+ impl PaymentPreAuthorizeVoidV2 for $path::$connector{}impl PaymentApproveV2 for $path::$connector{}impl PaymentRejectV2 for $path::$connector{}impl PaymentCaptureV2 for $path::$connector{}@@ -201,6 +203,8 @@ macro_rules! default_imp_for_new_connector_integration_payment {implConnectorIntegrationV2<PostCaptureVoidSync, PaymentFlowData, PaymentsCancelPostCaptureSyncData, PaymentsResponseData>for $path::$connector{}+ impl ConnectorIntegrationV2<PreAuthorizeVoid, PaymentFlowData, PaymentsPreAuthorizeCancelData, PaymentsResponseData>+ for $path::$connector{}implConnectorIntegrationV2<Approve,PaymentFlowData, PaymentsApproveData, PaymentsResponseData>for $path::$connector{}diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs b/crates/hyperswitch_domain_models/src/router_flow_types/payments.rsindex a017f2e2c6..e86db34da7 100644--- a/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs+++ b/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs@@ -32,6 +32,9 @@ pub struct PostCaptureVoid;#[derive(Debug, Clone)]pub struct PostCaptureVoidSync;+#[derive(Debug, Clone)]+pub struct PreAuthorizeVoid;+#[derive(Debug, Clone)]pub struct Reject;diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rsindex 867b97d1e9..7a119b7fd3 100644--- a/crates/hyperswitch_domain_models/src/router_request_types.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs@@ -1171,6 +1171,12 @@ pub struct PaymentsCancelPostCaptureSyncData {pub minor_amount: Option<MinorUnit>,}+#[derive(Debug, Default, Clone, Serialize)]+pub struct PaymentsPreAuthorizeCancelData {+ pub connector_transaction_id: String,+ pub connector_meta: Option<serde_json::Value>,+}+#[derive(Debug, Default, Clone, Serialize)]pub struct PaymentsExtendAuthorizationData {pub minor_amount: MinorUnit,diff --git a/crates/hyperswitch_domain_models/src/types.rs b/crates/hyperswitch_domain_models/src/types.rsindex 700c2953b0..4d54e211e7 100644--- a/crates/hyperswitch_domain_models/src/types.rs+++ b/crates/hyperswitch_domain_models/src/types.rs@@ -17,7 +17,7 @@ use crate::{CompleteRefundSurchrge, CompleteSurcharge, CreateConnectorCustomer, CreateOrder, Execute,ExtendAuthorization, ExternalVaultProxy, GenerateQr, GiftCardBalanceCheck,IncrementalAuthorization, PSync, PaymentMethodToken, PostAuthenticate, PostCaptureVoid,- PostCaptureVoidSync, PostSessionTokens, PreAuthenticate, PreProcessing,+ PostCaptureVoidSync, PostSessionTokens, PreAuthenticate, PreAuthorizeVoid, PreProcessing,ProcessIncomingWebhook, PushNotification, RSync, SdkSessionUpdate, Session,SettlementSplitCreate, SetupMandate, UpdateMetadata, VerifyWebhookSource, Void,},@@ -45,11 +45,12 @@ use crate::{PaymentsCancelPostCaptureSyncData, PaymentsCaptureData, PaymentsCompleteRefundSurchrgeData,PaymentsCompleteSurchargeData, PaymentsExtendAuthorizationData,PaymentsIncrementalAuthorizationData, PaymentsPostAuthenticateData,- PaymentsPostSessionTokensData, PaymentsPreAuthenticateData, PaymentsPreProcessingData,- PaymentsSessionData, PaymentsSurchargeCalculationData, PaymentsSyncData,- PaymentsTaxCalculationData, PaymentsUpdateMetadataData, PushNotificationRequestData,- RefundsData, SdkPaymentsSessionUpdateData, SettlementSplitRequestData,- SetupMandateRequestData, VaultRequestData, VerifyWebhookSourceRequestData,+ PaymentsPostSessionTokensData, PaymentsPreAuthenticateData, PaymentsPreAuthorizeCancelData,+ PaymentsPreProcessingData, PaymentsSessionData, PaymentsSurchargeCalculationData,+ PaymentsSyncData, PaymentsTaxCalculationData, PaymentsUpdateMetadataData,+ PushNotificationRequestData, RefundsData, SdkPaymentsSessionUpdateData,+ SettlementSplitRequestData, SetupMandateRequestData, VaultRequestData,+ VerifyWebhookSourceRequestData,},router_response_types::{merchant_connector_webhook_management::ConnectorWebhookRegisterResponse,@@ -96,6 +97,8 @@ pub type PaymentsCancelPostCaptureRouterData =RouterData<PostCaptureVoid, PaymentsCancelPostCaptureData, PaymentsResponseData>;pub type PaymentsCancelPostCaptureSyncRouterData =RouterData<PostCaptureVoidSync, PaymentsCancelPostCaptureSyncData, PaymentsResponseData>;+pub type PaymentsPreAuthorizeCancelRouterData =+ RouterData<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, PaymentsResponseData>;pub type SetupMandateRouterData =RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>;pub type RefundsRouterData<F> = RouterData<F, RefundsData, RefundsResponseData>;diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rsindex 636ecd274e..9fedcb93c5 100644--- a/crates/hyperswitch_interfaces/src/api.rs+++ b/crates/hyperswitch_interfaces/src/api.rs@@ -461,6 +461,13 @@ pub trait ConnectorSpecifications {fn is_post_authentication_flow_required(&self, _current_flow: CurrentFlowInfo) -> bool {false}+ /// Check if pre-authenticate cancel flow is supported+ fn is_pre_authorize_cancel_supported(+ &self,+ _payment_method_type: Option<PaymentMethodType>,+ ) -> bool {+ false+ }/// Check if settlement split flow is requiredfn is_settlement_split_call_required(&self, _current_flow: CurrentFlowInfo) -> bool {falsediff --git a/crates/hyperswitch_interfaces/src/api/payments.rs b/crates/hyperswitch_interfaces/src/api/payments.rsindex afe798a768..60c287a470 100644--- a/crates/hyperswitch_interfaces/src/api/payments.rs+++ b/crates/hyperswitch_interfaces/src/api/payments.rs@@ -6,9 +6,9 @@ use hyperswitch_domain_models::{Approve, Authorize, AuthorizeSessionToken, CalculateSurcharge, CalculateTax, Capture,CompleteAuthorize, CompleteRefundSurchrge, CompleteSurcharge, CreateConnectorCustomer,ExtendAuthorization, GenerateQr, IncrementalAuthorization, PSync, PaymentMethodToken,- PostCaptureVoid, PostCaptureVoidSync, PostProcessing, PostSessionTokens, PreProcessing,- PushNotification, Reject, SdkSessionUpdate, Session, SettlementSplitCreate,- SetupMandate, UpdateMetadata, Void,+ PostCaptureVoid, PostCaptureVoidSync, PostProcessing, PostSessionTokens,+ PreAuthorizeVoid, PreProcessing, PushNotification, Reject, SdkSessionUpdate, Session,+ SettlementSplitCreate, SetupMandate, UpdateMetadata, Void,},Authenticate, CreateOrder, ExternalVaultProxy, GiftCardBalanceCheck, PostAuthenticate,PreAuthenticate,@@ -22,10 +22,11 @@ use hyperswitch_domain_models::{PaymentsCompleteRefundSurchrgeData, PaymentsCompleteSurchargeData,PaymentsExtendAuthorizationData, PaymentsIncrementalAuthorizationData,PaymentsPostAuthenticateData, PaymentsPostProcessingData, PaymentsPostSessionTokensData,- PaymentsPreAuthenticateData, PaymentsPreProcessingData, PaymentsRejectData,- PaymentsSessionData, PaymentsSurchargeCalculationData, PaymentsSyncData,- PaymentsTaxCalculationData, PaymentsUpdateMetadataData, PushNotificationRequestData,- SdkPaymentsSessionUpdateData, SettlementSplitRequestData, SetupMandateRequestData,+ PaymentsPreAuthenticateData, PaymentsPreAuthorizeCancelData, PaymentsPreProcessingData,+ PaymentsRejectData, PaymentsSessionData, PaymentsSurchargeCalculationData,+ PaymentsSyncData, PaymentsTaxCalculationData, PaymentsUpdateMetadataData,+ PushNotificationRequestData, SdkPaymentsSessionUpdateData, SettlementSplitRequestData,+ SetupMandateRequestData,},router_response_types::{CompleteRefundSurchrgeResponseData, CompleteSurchargeResponseData,@@ -52,6 +53,7 @@ pub trait Payment:+ PaymentVoid+ PaymentPostCaptureVoid+ PaymentPostCaptureVoidSync+ + PaymentPreAuthorizeVoid+ PaymentApprove+ PaymentReject+ MandateSetup@@ -125,6 +127,12 @@ pub trait PaymentPostCaptureVoidSync:{}+/// trait PaymentPreAuthorizeVoid+pub trait PaymentPreAuthorizeVoid:+ api::ConnectorIntegration<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, PaymentsResponseData>+{+}+/// trait PaymentExtendAuthorizationpub trait PaymentExtendAuthorization:api::ConnectorIntegration<diff --git a/crates/hyperswitch_interfaces/src/api/payments_v2.rs b/crates/hyperswitch_interfaces/src/api/payments_v2.rsindex 2143b20a5c..4f1bcbad83 100644--- a/crates/hyperswitch_interfaces/src/api/payments_v2.rs+++ b/crates/hyperswitch_interfaces/src/api/payments_v2.rs@@ -8,9 +8,9 @@ use hyperswitch_domain_models::{CompleteAuthorize, CompleteRefundSurchrge, CompleteSurcharge, CreateConnectorCustomer,CreateOrder, ExtendAuthorization, ExternalVaultProxy, GenerateQr,IncrementalAuthorization, PSync, PaymentMethodToken, PostCaptureVoid,- PostCaptureVoidSync, PostProcessing, PostSessionTokens, PreProcessing,- PushNotification, Reject, SdkSessionUpdate, Session, SettlementSplitCreate,- SetupMandate, UpdateMetadata, Void,+ PostCaptureVoidSync, PostProcessing, PostSessionTokens, PreAuthorizeVoid,+ PreProcessing, PushNotification, Reject, SdkSessionUpdate, Session,+ SettlementSplitCreate, SetupMandate, UpdateMetadata, Void,},Authenticate, GiftCardBalanceCheck, PostAuthenticate, PreAuthenticate,},@@ -23,10 +23,11 @@ use hyperswitch_domain_models::{PaymentsCompleteRefundSurchrgeData, PaymentsCompleteSurchargeData,PaymentsExtendAuthorizationData, PaymentsIncrementalAuthorizationData,PaymentsPostAuthenticateData, PaymentsPostProcessingData, PaymentsPostSessionTokensData,- PaymentsPreAuthenticateData, PaymentsPreProcessingData, PaymentsRejectData,- PaymentsSessionData, PaymentsSurchargeCalculationData, PaymentsSyncData,- PaymentsTaxCalculationData, PaymentsUpdateMetadataData, PushNotificationRequestData,- SdkPaymentsSessionUpdateData, SettlementSplitRequestData, SetupMandateRequestData,+ PaymentsPreAuthenticateData, PaymentsPreAuthorizeCancelData, PaymentsPreProcessingData,+ PaymentsRejectData, PaymentsSessionData, PaymentsSurchargeCalculationData,+ PaymentsSyncData, PaymentsTaxCalculationData, PaymentsUpdateMetadataData,+ PushNotificationRequestData, SdkPaymentsSessionUpdateData, SettlementSplitRequestData,+ SetupMandateRequestData,},router_response_types::{CompleteRefundSurchrgeResponseData, CompleteSurchargeResponseData,@@ -90,6 +91,17 @@ pub trait PaymentPostCaptureVoidSyncV2:{}+/// trait PaymentPreAuthorizeVoidV2+pub trait PaymentPreAuthorizeVoidV2:+ ConnectorIntegrationV2<+ PreAuthorizeVoid,+ PaymentFlowData,+ PaymentsPreAuthorizeCancelData,+ PaymentsResponseData,+>+{+}+/// trait PaymentApproveV2pub trait PaymentApproveV2:ConnectorIntegrationV2<Approve, PaymentFlowData, PaymentsApproveData, PaymentsResponseData>@@ -378,6 +390,7 @@ pub trait PaymentV2:+ PaymentVoidV2+ PaymentPostCaptureVoidV2+ PaymentPostCaptureVoidSyncV2+ + PaymentPreAuthorizeVoidV2+ PaymentApproveV2+ PaymentRejectV2+ MandateSetupV2diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rsindex 37f9366e9b..2b7da78520 100644--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs@@ -542,7 +542,7 @@ impl ConnectorValidation for ConnectorEnum {merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id_or_connector_name: String,current_flow: Option<CurrentFlowInfo>,- payment_method_type: Option<common_enums::enums::PaymentMethodType>,+ payment_method_type: Option<common_enums::PaymentMethodType>,is_mit_payment: Option<bool>,) -> CustomResult<String, errors::ConnectorError> {match self {@@ -654,6 +654,21 @@ 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 {+ 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)+ }+ }+ }+/// Check if connector supports authentication tokenfn authentication_token_for_token_creation(&self) -> bool {match self {diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rsindex 4ab79b4ca7..748ea628ce 100644--- a/crates/hyperswitch_interfaces/src/types.rs+++ b/crates/hyperswitch_interfaces/src/types.rs@@ -14,8 +14,8 @@ use hyperswitch_domain_models::{CompleteAuthorize, CompleteRefundSurchrge, CompleteSurcharge, CreateConnectorCustomer,CreateOrder, ExtendAuthorization, GenerateQr, IncrementalAuthorization, InitPayment,PSync, PaymentMethodToken, PostCaptureVoid, PostCaptureVoidSync, PostProcessing,- PostSessionTokens, PreProcessing, PushNotification, SdkSessionUpdate, Session,- SettlementSplitCreate, SetupMandate, UpdateMetadata, Void,+ PostSessionTokens, PreAuthorizeVoid, PreProcessing, PushNotification, SdkSessionUpdate,+ Session, SettlementSplitCreate, SetupMandate, UpdateMetadata, Void,},refunds::{Execute, RSync},revenue_recovery::{BillingConnectorPaymentsSync, InvoiceRecordBack},@@ -60,12 +60,12 @@ use hyperswitch_domain_models::{PaymentsCompleteSurchargeData, PaymentsExtendAuthorizationData,PaymentsIncrementalAuthorizationData, PaymentsPostAuthenticateData,PaymentsPostProcessingData, PaymentsPostSessionTokensData, PaymentsPreAuthenticateData,- PaymentsPreProcessingData, PaymentsSessionData, PaymentsSurchargeCalculationData,- PaymentsSyncData, PaymentsTaxCalculationData, PaymentsUpdateMetadataData,- PushNotificationRequestData, RefundsData, RetrieveFileRequestData,- SdkPaymentsSessionUpdateData, SettlementSplitRequestData, SetupMandateRequestData,- SubmitEvidenceRequestData, UploadFileRequestData, VaultRequestData,- VerifyWebhookSourceRequestData,+ PaymentsPreAuthorizeCancelData, PaymentsPreProcessingData, PaymentsSessionData,+ PaymentsSurchargeCalculationData, PaymentsSyncData, PaymentsTaxCalculationData,+ PaymentsUpdateMetadataData, PushNotificationRequestData, RefundsData,+ RetrieveFileRequestData, SdkPaymentsSessionUpdateData, SettlementSplitRequestData,+ SetupMandateRequestData, SubmitEvidenceRequestData, UploadFileRequestData,+ VaultRequestData, VerifyWebhookSourceRequestData,},router_response_types::{merchant_connector_webhook_management::ConnectorWebhookRegisterResponse,@@ -235,7 +235,12 @@ pub type PaymentsPostCaptureVoidSyncType = dyn ConnectorIntegration<PaymentsCancelPostCaptureSyncData,PaymentsResponseData,>;-+/// Type alias for `ConnectorIntegration<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, PaymentsResponseData>`+pub type PaymentsPreAuthorizeVoidType = dyn ConnectorIntegration<+ PreAuthorizeVoid,+ PaymentsPreAuthorizeCancelData,+ PaymentsResponseData,+>;/// Type alias for `ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>`pub type TokenizationType = dyn ConnectorIntegration<PaymentMethodToken,diff --git a/crates/router/src/compatibility/stripe/payment_intents.rs b/crates/router/src/compatibility/stripe/payment_intents.rsindex 712a264e76..c197962cba 100644--- a/crates/router/src/compatibility/stripe/payment_intents.rs+++ b/crates/router/src/compatibility/stripe/payment_intents.rs@@ -92,6 +92,7 @@ pub async fn payment_intents_create(None,eligible_connectors,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -175,6 +176,7 @@ pub async fn payment_intents_retrieve(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&*auth_type,@@ -264,6 +266,7 @@ pub async fn payment_intents_retrieve_with_gateway_creds(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&*auth_type,@@ -350,6 +353,7 @@ pub async fn payment_intents_update(None,eligible_connectors,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&*auth_type,@@ -444,6 +448,7 @@ pub async fn payment_intents_confirm(None,eligible_connectors,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&*auth_type,@@ -515,6 +520,7 @@ pub async fn payment_intents_capture(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -599,6 +605,7 @@ pub async fn payment_intents_cancel(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&*auth_type,diff --git a/crates/router/src/compatibility/stripe/setup_intents.rs b/crates/router/src/compatibility/stripe/setup_intents.rsindex aac6c0c4d3..af9afda835 100644--- a/crates/router/src/compatibility/stripe/setup_intents.rs+++ b/crates/router/src/compatibility/stripe/setup_intents.rs@@ -78,6 +78,7 @@ pub async fn setup_intents_create(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -161,6 +162,7 @@ pub async fn setup_intents_retrieve(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&*auth_type,@@ -246,6 +248,7 @@ pub async fn setup_intents_update(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&*auth_type,@@ -332,6 +335,7 @@ pub async fn setup_intents_confirm(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)},&*auth_type,diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs b/crates/router/src/core/fraud_check/operation/fraud_check_post.rsindex b9aa39a7ba..0cd0678e43 100644--- a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs+++ b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs@@ -280,6 +280,7 @@ whereNone,None,HeaderPayload::default(),+ None,)).await?;logger::debug!("payment_id : {:?} has been cancelled since it has been found fraudulent by configured frm connector",payment_data.get_payment_attempt().payment_id);@@ -336,6 +337,7 @@ whereNone,None,HeaderPayload::default(),+ None,)).await?;logger::debug!("payment_id : {:?} has been captured since it has been found legit by configured frm connector",payment_data.get_payment_attempt().payment_id);diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex e5dc9a8fba..192564ef2e 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -646,6 +646,7 @@ pub async fn payments_operation_core<'a, F, Req, Op, FData, D>(eligible_connectors: Option<Vec<enums::RoutableConnectors>>,header_payload: HeaderPayload,dimensions: &DimensionsWithProcessorAndProviderMerchantId,+ payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<(D, Req, Option<u16>, Option<u128>)>whereF: Send + Clone + Sync + Debug + 'static,@@ -704,6 +705,7 @@ where&header_payload,payment_method_fetch_data,dimensions,+ payment_pre_fetched_info,).await?;let dimensions = dimensions.with_profile_id(business_profile.get_id().clone());@@ -1594,6 +1596,7 @@ where&header_payload,operations::PaymentMethodFetchData::default(),dimensions,+ None,).await?;let dimensions = dimensions.with_profile_id(business_profile.get_id().clone());@@ -2652,6 +2655,7 @@ pub async fn payments_core<F, Res, Req, Op, FData, D>(shadow_ucs_call_connector_action: Option<CallConnectorAction>,eligible_connectors: Option<Vec<enums::Connector>>,header_payload: HeaderPayload,+ payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResponse<Res>whereF: Send + Clone + Sync + Debug + 'static,@@ -2693,6 +2697,7 @@ whereeligible_routable_connectors,header_payload.clone(),&dimensions,+ payment_pre_fetched_info,).await?;@@ -2849,6 +2854,7 @@ where&header_payload,payment_method_info,&dimensions,+ None,).await?;let dimensions = dimensions.with_profile_id(business_profile.get_id().clone());@@ -4474,6 +4480,7 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {None,None,HeaderPayload::default(),+ None,)).await?;let payments_response = match response {@@ -4667,6 +4674,7 @@ impl PaymentRedirectFlow for PaymentRedirectSync {None,None,HeaderPayload::default(),+ None,),).await?;@@ -5053,6 +5061,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {None,None,HeaderPayload::with_source(enums::PaymentSource::ExternalAuthenticator),+ None,)).await?} else {@@ -5075,6 +5084,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {None,None,HeaderPayload::with_source(enums::PaymentSource::ExternalAuthenticator),+ None,)).await?}@@ -5109,6 +5119,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {None,None,HeaderPayload::default(),+ None,),).await?@@ -9716,11 +9727,21 @@ where|| (in_progress && force_sync)|| capture_failure_webhook_over_success_payment}- "PaymentCancel" => matches!(- payment_data.get_payment_intent().status,- storage_enums::IntentStatus::RequiresCapture- | storage_enums::IntentStatus::PartiallyCapturedAndCapturable- ),+ "PaymentCancel" => {+ let flow_name = core_utils::get_flow_name::<F>().unwrap_or_default();+ match flow_name.as_str() {+ "Void" => matches!(+ payment_data.get_payment_intent().status,+ storage_enums::IntentStatus::RequiresCapture+ | storage_enums::IntentStatus::PartiallyCapturedAndCapturable+ ),+ "PreAuthorizeVoid" => matches!(+ payment_data.get_payment_intent().status,+ storage_enums::IntentStatus::RequiresCustomerAction+ ),+ _ => false,+ }+ }"PaymentCancelPostCapture" => matches!(payment_data.get_payment_intent().status,storage_enums::IntentStatus::Succeededdiff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rsindex 71135849ff..c63f890e3e 100644--- a/crates/router/src/core/payments/flows.rs+++ b/crates/router/src/core/payments/flows.rs@@ -9,6 +9,7 @@ pub mod extend_authorization_flow;pub mod external_proxy_flow;pub mod incremental_authorization_flow;pub mod post_session_tokens_flow;+pub mod pre_authorize_void_flow;pub mod psync_flow;pub mod reject_flow;pub mod session_flow;diff --git a/crates/router/src/core/payments/flows/pre_authorize_void_flow.rs b/crates/router/src/core/payments/flows/pre_authorize_void_flow.rsnew file mode 100644index 0000000000..7c0a16107a--- /dev/null+++ b/crates/router/src/core/payments/flows/pre_authorize_void_flow.rs@@ -0,0 +1,131 @@+use async_trait::async_trait;+use hyperswitch_domain_models::router_data_v2::PaymentFlowData;++use super::{ConstructFlowSpecificData, Feature};+use crate::{+ core::{+ errors::{ConnectorErrorExt, RouterResult},+ payments::{self, access_token, helpers, transformers, PaymentData},+ },+ routes::{metrics, SessionState},+ services,+ types::{self, api, domain},+};++#[cfg(feature = "v1")]+#[async_trait]+impl+ ConstructFlowSpecificData<+ api::PreAuthorizeVoid,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ > for PaymentData<api::PreAuthorizeVoid>+{+ async fn construct_router_data<'a>(+ &self,+ state: &SessionState,+ connector_id: &str,+ processor: &domain::Processor,+ merchant_connector_account: &helpers::MerchantConnectorAccountType,+ merchant_recipient_data: Option<types::MerchantRecipientData>,+ header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,+ _payment_method: Option<common_enums::PaymentMethod>,+ _payment_method_type: Option<common_enums::PaymentMethodType>,+ ) -> RouterResult<types::PaymentsPreAuthorizeVoidRouterData> {+ Box::pin(transformers::construct_payment_router_data::<+ api::PreAuthorizeVoid,+ types::PaymentsPreAuthorizeCancelData,+ >(+ state,+ self.clone(),+ connector_id,+ processor,+ merchant_connector_account,+ merchant_recipient_data,+ header_payload,+ None,+ None,+ ))+ .await+ }+}++#[async_trait]+impl Feature<api::PreAuthorizeVoid, types::PaymentsPreAuthorizeCancelData>+ for types::RouterData<+ api::PreAuthorizeVoid,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ >+{+ async fn decide_flows<'a>(+ self,+ state: &SessionState,+ connector: &api::ConnectorData,+ call_connector_action: payments::CallConnectorAction,+ connector_request: Option<services::Request>,+ _business_profile: &domain::Profile,+ _header_payload: hyperswitch_domain_models::payments::HeaderPayload,+ return_raw_connector_response: Option<bool>,+ gateway_context: payments::gateway::context::RouterGatewayContext,+ ) -> RouterResult<Self> {+ metrics::PAYMENT_CANCEL_COUNT.add(+ 1,+ router_env::metric_attributes!(("connector", connector.connector_name.to_string())),+ );++ payments::gateway::handle_gateway_call::<_, _, _, PaymentFlowData, _>(+ state,+ self,+ connector,+ &gateway_context,+ call_connector_action,+ connector_request,+ return_raw_connector_response,+ )+ .await+ }++ async fn add_access_token<'a>(+ &self,+ state: &SessionState,+ connector: &api::ConnectorData,+ _processor: &domain::Processor,+ creds_identifier: Option<&str>,+ gateway_context: &payments::gateway::context::RouterGatewayContext,+ ) -> RouterResult<types::AddAccessTokenResult> {+ Box::pin(access_token::add_access_token(+ state,+ connector,+ self,+ creds_identifier,+ gateway_context,+ None,+ ))+ .await+ }++ async fn build_flow_specific_connector_request(+ &mut self,+ state: &SessionState,+ connector: &api::ConnectorData,+ call_connector_action: payments::CallConnectorAction,+ ) -> RouterResult<(Option<services::Request>, bool)> {+ let request = match call_connector_action {+ payments::CallConnectorAction::Trigger => {+ let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<+ api::PreAuthorizeVoid,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ > = connector.connector.get_connector_integration();++ connector_integration+ .build_request(self, &state.conf.connectors)+ .to_payment_failed_response()?+ }+ _ => None,+ };++ Ok((request, true))+ }+}diff --git a/crates/router/src/core/payments/gateway.rs b/crates/router/src/core/payments/gateway.rsindex f4adc01113..faa029ee5c 100644--- a/crates/router/src/core/payments/gateway.rs+++ b/crates/router/src/core/payments/gateway.rs@@ -13,6 +13,7 @@ pub mod payment_method_token_create_gateway;pub mod post_authenticate_gateway;pub mod post_capture_void_sync_gateway;pub mod pre_authenticate_gateway;+pub mod pre_authorize_void_gateway;pub mod psync_gateway;pub mod push_notification_gateway;pub mod session_gateway;diff --git a/crates/router/src/core/payments/gateway/pre_authorize_void_gateway.rs b/crates/router/src/core/payments/gateway/pre_authorize_void_gateway.rsnew file mode 100644index 0000000000..109e8f77fe--- /dev/null+++ b/crates/router/src/core/payments/gateway/pre_authorize_void_gateway.rs@@ -0,0 +1,204 @@+use std::str::FromStr;++use async_trait::async_trait;+use common_enums::{CallConnectorAction, ExecutionPath};+use common_utils::{errors::CustomResult, id_type, request::Request, ucs_types};+use error_stack::ResultExt;+use hyperswitch_domain_models::{router_data::RouterData, router_flow_types as domain};+use hyperswitch_interfaces::{+ api::gateway as payment_gateway,+ connector_integration_interface::{BoxedConnectorIntegrationInterface, RouterDataConversion},+ errors::ConnectorError,+};+use unified_connector_service_client::payments as payments_grpc;++use crate::{+ core::{payments::gateway::context::RouterGatewayContext, unified_connector_service},+ routes::SessionState,+ services::logger,+ types::{self, transformers::ForeignTryFrom},+};++// =============================================================================+// PaymentGateway Implementation for domain::PreAuthorizeVoid+// =============================================================================++/// Implementation of PaymentGateway for api::PreAuthorizeVoid flow+#[async_trait]+impl<RCD>+ payment_gateway::PaymentGateway<+ SessionState,+ RCD,+ Self,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ RouterGatewayContext,+ > for domain::PreAuthorizeVoid+where+ RCD: Clone+ + Send+ + Sync+ + 'static+ + RouterDataConversion<+ Self,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ >,+{+ async fn execute(+ self: Box<Self>,+ state: &SessionState,+ _connector_integration: BoxedConnectorIntegrationInterface<+ Self,+ RCD,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ >,+ router_data: &RouterData<+ Self,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ >,+ _call_connector_action: CallConnectorAction,+ _connector_request: Option<Request>,+ _return_raw_connector_response: Option<bool>,+ context: RouterGatewayContext,+ ) -> CustomResult<+ RouterData<Self, types::PaymentsPreAuthorizeCancelData, types::PaymentsResponseData>,+ ConnectorError,+ > {+ let merchant_connector_account = context.merchant_connector_account;+ let processor = &context.processor;+ let lineage_ids = context.lineage_ids;+ let header_payload = context.header_payload;+ let unified_connector_service_execution_mode = context.execution_mode;+ let client = state+ .grpc_client+ .unified_connector_service_client+ .clone()+ .ok_or(ConnectorError::RequestEncodingFailed)+ .attach_printable("Failed to fetch Unified Connector Service client")?;++ let payment_void_request =+ payments_grpc::PaymentServiceVoidRequest::foreign_try_from(router_data)+ .change_context(ConnectorError::RequestEncodingFailed)+ .attach_printable("Failed to construct Payment Void Request")?;++ let connector_auth_metadata =+ unified_connector_service::build_unified_connector_service_auth_metadata(+ merchant_connector_account,+ processor,+ router_data.connector.clone(),+ )+ .change_context(ConnectorError::RequestEncodingFailed)+ .attach_printable("Failed to construct request metadata")?;++ let merchant_reference_id = unified_connector_service::parse_merchant_reference_id(+ header_payload+ .x_reference_id+ .as_deref()+ .unwrap_or(router_data.payment_id.as_str()),+ )+ .map(ucs_types::UcsReferenceId::Payment);++ let resource_id = id_type::PaymentResourceId::from_str(router_data.attempt_id.as_str())+ .inspect_err(+ |err| logger::warn!(error=?err, "Invalid Payment AttemptId for UCS resource id"),+ )+ .ok()+ .map(ucs_types::UcsResourceId::PaymentAttempt);++ let header_payload = state+ .get_grpc_headers_ucs(unified_connector_service_execution_mode)+ .external_vault_proxy_metadata(None)+ .merchant_reference_id(merchant_reference_id)+ .resource_id(resource_id)+ .lineage_ids(lineage_ids);++ Box::pin(unified_connector_service::ucs_logging_wrapper_granular(+ router_data.clone(),+ state,+ payment_void_request,+ header_payload,+ unified_connector_service_execution_mode,+ |mut router_data, payment_void_request, grpc_headers| async move {+ let response = client+ .payment_void(payment_void_request, connector_auth_metadata, grpc_headers)+ .await+ .attach_printable("Failed to Cancel payment")?;++ let payment_void_response = response.into_inner();++ let (router_data_response, status_code) =+ unified_connector_service::handle_unified_connector_service_response_for_payment_cancel(+ payment_void_response.clone(),+ router_data.status,+ )+ .attach_printable("Failed to deserialize UCS response")?;++ let router_data_response = match router_data_response {+ Ok((response, status)) => {+ router_data.status = status;+ Ok(response)+ }+ Err(err) => {+ logger::debug!("Error in UCS router data response");+ if let Some(attempt_status) = err.attempt_status {+ router_data.status = attempt_status;+ }+ Err(err)+ }+ };+ router_data.response = router_data_response;+ router_data.connector_http_status_code = Some(status_code);++ Ok((router_data, (), payment_void_response))+ },+ ))+ .await+ .map(|(router_data, _)| router_data)+ .change_context(ConnectorError::ResponseHandlingFailed)+ }+}++/// Implementation of FlowGateway for api::PreAuthorizeVoid+///+/// This allows the flow to provide its specific gateway based on execution path+impl<RCD>+ payment_gateway::FlowGateway<+ SessionState,+ RCD,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ RouterGatewayContext,+ > for domain::PreAuthorizeVoid+where+ RCD: Clone+ + Send+ + Sync+ + 'static+ + RouterDataConversion<+ Self,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ >,+{+ fn get_gateway(+ execution_path: ExecutionPath,+ ) -> Box<+ dyn payment_gateway::PaymentGateway<+ SessionState,+ RCD,+ Self,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ RouterGatewayContext,+ >,+ > {+ match execution_path {+ ExecutionPath::Direct => Box::new(payment_gateway::DirectGateway),+ ExecutionPath::UnifiedConnectorService+ | ExecutionPath::ShadowUnifiedConnectorService => Box::new(Self),+ }+ }+}diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rsindex 172bf4f320..bda3577273 100644--- a/crates/router/src/core/payments/operations.rs+++ b/crates/router/src/core/payments/operations.rs@@ -205,6 +205,13 @@ pub trait ValidateRequest<F, R, D> {) -> RouterResult<ValidateResult>;}+#[cfg(feature = "v1")]+/// Minimal payment information that can be passed to get_trackers to avoid redundant DB calls+pub struct PaymentPreFetchedInformation {+ pub payment_intent: storage::PaymentIntent,+ pub payment_attempt: storage::PaymentAttempt,+}+#[cfg(feature = "v2")]pub struct GetTrackerResponse<D> {pub payment_data: D,@@ -235,6 +242,7 @@ pub trait GetTracker<F: Clone, D, R>: Send {header_payload: &hyperswitch_domain_models::payments::HeaderPayload,payment_method_fetch_data: PaymentMethodFetchData,dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ payment_pre_fetched_info: Option<PaymentPreFetchedInformation>,) -> RouterResult<GetTrackerResponse<'a, F, R, D>>;#[cfg(feature = "v2")]diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rsindex 58b4fe5479..56214d288a 100644--- a/crates/router/src/core/payments/operations/payment_approve.rs+++ b/crates/router/src/core/payments/operations/payment_approve.rs@@ -45,6 +45,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsCaptureRequest, PaymentData<F>>,> {diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rsindex 5542f9058d..a08926d725 100644--- a/crates/router/src/core/payments/operations/payment_cancel.rs+++ b/crates/router/src/core/payments/operations/payment_cancel.rs@@ -47,6 +47,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsCancelRequest, PaymentData<F>>,> {diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rsindex 7ccb1697c8..bd4edbc352 100644--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs@@ -46,6 +46,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPo_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a,diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture_sync.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture_sync.rsindex de977ed4e0..37c76bc721 100644--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture_sync.rs+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture_sync.rs@@ -46,6 +46,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, id_type::PaymentId>_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, id_type::PaymentId, PaymentData<F>>>{let db = &*state.store;diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rsindex d89c63cee1..fe2a876563 100644--- a/crates/router/src/core/payments/operations/payment_capture.rs+++ b/crates/router/src/core/payments/operations/payment_capture.rs@@ -47,6 +47,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a,diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex 146ba273fb..7e4e377ee2 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -52,6 +52,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>{let db = &*state.store;diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex ccf7cf145f..ea576f8004 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -87,6 +87,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>header_payload: &hyperswitch_domain_models::payments::HeaderPayload,payment_method_fetch_data: operations::PaymentMethodFetchData,dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>{let operations::PaymentMethodFetchData {diff --git a/crates/router/src/core/payments/operations/payment_confirm_external_vault_proxy.rs b/crates/router/src/core/payments/operations/payment_confirm_external_vault_proxy.rsindex 4f9eaa42e8..695c414531 100644--- a/crates/router/src/core/payments/operations/payment_confirm_external_vault_proxy.rs+++ b/crates/router/src/core/payments/operations/payment_confirm_external_vault_proxy.rs@@ -94,6 +94,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsRequest>_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,payment_method_fetch_data: PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, PaymentsRequest, PaymentData<F>>> {let db = &*state.store;let payment_method_wrapper = payment_method_fetch_data.payment_method_with_raw_data;diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex dc5a92955f..d1b3ae4292 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -82,6 +82,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>header_payload: &hyperswitch_domain_models::payments::HeaderPayload,payment_method_fetch_data: operations::PaymentMethodFetchData,dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>{let operations::PaymentMethodFetchData {diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rsindex d57c7ee3ba..a2e5b39c6a 100644--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs@@ -47,6 +47,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSess_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a,diff --git a/crates/router/src/core/payments/operations/payment_recurrence.rs b/crates/router/src/core/payments/operations/payment_recurrence.rsindex 0c9e3b6ac2..b3711b8b4e 100644--- a/crates/router/src/core/payments/operations/payment_recurrence.rs+++ b/crates/router/src/core/payments/operations/payment_recurrence.rs@@ -52,6 +52,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,payment_method_fetch_data: operations::PaymentMethodFetchData,dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>{let operations::PaymentMethodFetchData {diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rsindex e3485dcd7b..65b6940627 100644--- a/crates/router/src/core/payments/operations/payment_reject.rs+++ b/crates/router/src/core/payments/operations/payment_reject.rs@@ -44,6 +44,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequest_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, PaymentsCancelRequest, PaymentData<F>>>{let db = &*state.store;diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 59e8834197..331a3deaa9 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -402,7 +402,7 @@ where#[derive(Debug, Clone, Copy, router_derive::PaymentOperation)]#[operation(operations = "post_update_tracker",- flow = "sync_data, cancel_data, authorize_data, capture_data, complete_authorize_data, approve_data, reject_data, setup_mandate_data, session_data,incremental_authorization_data, sdk_session_update_data, post_session_tokens_data, update_metadata_data, cancel_post_capture_data, extend_authorization_data, cancel_post_capture_sync_data"+ flow = "sync_data, cancel_data, authorize_data, capture_data, complete_authorize_data, approve_data, reject_data, setup_mandate_data, session_data, incremental_authorization_data, sdk_session_update_data, post_session_tokens_data, update_metadata_data, cancel_post_capture_data, extend_authorization_data, cancel_post_capture_sync_data, cancel_pre_authorize_data")]pub struct PaymentResponse;@@ -1475,6 +1475,47 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsCaptureData>}}+#[cfg(feature = "v1")]+#[async_trait]+impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsPreAuthorizeCancelData>+ for PaymentResponse+{+ async fn update_tracker<'b>(+ &'b self,+ db: &'b SessionState,+ processor: &domain::Processor,+ mut payment_data: PaymentData<F>,+ router_data: types::RouterData<+ F,+ types::PaymentsPreAuthorizeCancelData,+ types::PaymentsResponseData,+ >,+ locale: &Option<String>,+ #[cfg(all(feature = "v1", feature = "dynamic_routing"))] routable_connector: Vec<+ RoutableConnectorChoice,+ >,+ #[cfg(all(feature = "v1", feature = "dynamic_routing"))] business_profile: &domain::Profile,+ ) -> RouterResult<PaymentData<F>>+ where+ F: 'b + Send,+ {+ payment_data = Box::pin(payment_response_update_tracker(+ db,+ payment_data,+ router_data,+ processor,+ locale,+ #[cfg(all(feature = "v1", feature = "dynamic_routing"))]+ routable_connector,+ #[cfg(all(feature = "v1", feature = "dynamic_routing"))]+ business_profile,+ ))+ .await?;++ Ok(payment_data)+ }+}+#[cfg(feature = "v1")]#[async_trait]impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsCancelData> for PaymentResponse {diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex 83d94ac7b6..6bb06293ee 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -47,6 +47,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionR_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsSessionRequest, PaymentData<F>>,> {diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex ee23a0bc66..4846cb6761 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -47,6 +47,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReq_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsStartRequest, PaymentData<F>>,> {diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rsindex 27a17fd973..2c8e8a854b 100644--- a/crates/router/src/core/payments/operations/payment_status.rs+++ b/crates/router/src/core/payments/operations/payment_status.rs@@ -235,6 +235,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRetrieve_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRetrieveRequest, PaymentData<F>>,> {diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 0a9e108c02..09bfdcad22 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -61,6 +61,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>{let (mut payment_intent, mut payment_attempt, currency): (_, _, storage_enums::Currency);diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rsindex 680f90135f..bae6dd5e8c 100644--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs@@ -48,6 +48,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsUpdateMe_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsUpdateMetadataRequest, PaymentData<F>>,> {diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rsindex 17d605e42c..be72a89281 100644--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs@@ -46,6 +46,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsExtendAu_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a,diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rsindex 44f9401bba..a9496b6f00 100644--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs@@ -51,6 +51,7 @@ impl<F: Send + Clone + Sync>_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a,diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rsindex 1256235755..401314946e 100644--- a/crates/router/src/core/payments/operations/tax_calculation.rs+++ b/crates/router/src/core/payments/operations/tax_calculation.rs@@ -52,6 +52,7 @@ impl<F: Send + Clone + Sync>_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,_payment_method_fetch_data: operations::PaymentMethodFetchData,_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _payment_pre_fetched_info: Option<operations::PaymentPreFetchedInformation>,) -> RouterResult<operations::GetTrackerResponse<'a,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 62d11db490..d6b255cf11 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -5871,6 +5871,29 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsCancelDa}}+#[cfg(feature = "v1")]+impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreAuthorizeCancelData {+ type Error = error_stack::Report<errors::ApiErrorResponse>;++ fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> {+ let payment_data = additional_data.payment_data;+ let connector = api::ConnectorData::get_connector_by_name(+ &additional_data.state.conf.connectors,+ &additional_data.connector_name,+ api::GetToken::Connector,+ payment_data.payment_attempt.merchant_connector_id.clone(),+ )?;++ Ok(Self {+ connector_transaction_id: connector+ .connector+ .connector_transaction_id(&payment_data.payment_attempt)?+ .ok_or(errors::ApiErrorResponse::ResourceIdNotFound)?,+ connector_meta: payment_data.payment_attempt.connector_metadata.clone(),+ })+ }+}+#[cfg(feature = "v2")]impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsCancelPostCaptureData {type Error = error_stack::Report<errors::ApiErrorResponse>;diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex b077735832..b59bf5c64b 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -22,7 +22,7 @@ use hyperswitch_domain_models::{mandates::{MandateData, MandateDataType},router_data::{AccessToken, ErrorResponse, RouterData},router_flow_types::{- payments::{Authorize, Capture, PSync, SetupMandate},+ payments::{Authorize, Capture, PSync, PreAuthorizeVoid, SetupMandate},refunds::{Execute, RSync},unified_authentication_service as uas_flows, ExternalVaultProxy, IncrementalAuthorization,Session,@@ -30,8 +30,8 @@ use hyperswitch_domain_models::{router_request_types::{self, AuthenticationData, ExternalVaultProxyPaymentsData, PaymentsAuthorizeData,PaymentsCancelData, PaymentsCaptureData, PaymentsIncrementalAuthorizationData,- PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData,- SyncRequestType,+ PaymentsPreAuthorizeCancelData, PaymentsSessionData, PaymentsSyncData, RefundsData,+ SetupMandateRequestData, SyncRequestType,},router_response_types::{PaymentsResponseData, PayoutsResponseData, RedirectForm, RefundsResponseData,@@ -6129,6 +6129,49 @@ impl transformers::ForeignTryFrom<&RouterData<api::Void, PaymentsCancelData, Pay}}+impl+ transformers::ForeignTryFrom<+ &RouterData<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, PaymentsResponseData>,+ > for payments_grpc::PaymentServiceVoidRequest+{+ type Error = error_stack::Report<UnifiedConnectorServiceError>;++ fn foreign_try_from(+ router_data: &RouterData<+ PreAuthorizeVoid,+ PaymentsPreAuthorizeCancelData,+ PaymentsResponseData,+ >,+ ) -> Result<Self, Self::Error> {+ let state = router_data+ .access_token+ .as_ref()+ .map(ConnectorState::foreign_from);++ Ok(Self {+ merchant_void_id: Some(router_data.connector_request_reference_id.clone()),+ connector_transaction_id: router_data.request.connector_transaction_id.clone(),+ connector_feature_data: router_data+ .request+ .connector_meta+ .as_ref()+ .map(serde_json::to_string)+ .transpose()+ .change_context(UnifiedConnectorServiceError::RequestEncodingFailed)?+ .map(|s| s.into()),+ merchant_order_id: None,+ merchant_request_id: None,+ cancellation_reason: None,+ all_keys_required: None,+ browser_info: None,+ amount: None,+ metadata: None,+ state,+ test_mode: router_data.test_mode,+ })+ }+}+impl transformers::ForeignTryFrom<payments_grpc::RefundStatus> for RefundStatus {type Error = error_stack::Report<UnifiedConnectorServiceError>;diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex f1f1bee1a3..229bb63714 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -935,6 +935,7 @@ async fn payments_incoming_webhook_flow(shadow_ucs_call_connector_action,None,HeaderPayload::default(),+ None,)).await;// When mandate details are present in successful webhooks, and consuming webhooks are skipped during payment sync if the payment status is already updated to charged, this function is used to update the connector mandate details.@@ -1988,6 +1989,7 @@ async fn external_authentication_incoming_webhook_flow(None,None,HeaderPayload::with_source(enums::PaymentSource::ExternalAuthenticator),+ None,)).await?} else {@@ -2010,6 +2012,7 @@ async fn external_authentication_incoming_webhook_flow(None,None,HeaderPayload::with_source(enums::PaymentSource::ExternalAuthenticator),+ None,)).await?};@@ -2221,6 +2224,7 @@ async fn frm_incoming_webhook_flow(None,None,HeaderPayload::default(),+ None,)).await?}@@ -2250,6 +2254,7 @@ async fn frm_incoming_webhook_flow(None,None,HeaderPayload::default(),+ None,)).await?}@@ -2476,6 +2481,7 @@ async fn bank_transfer_webhook_flow(None,None,HeaderPayload::with_source(common_enums::PaymentSource::Webhook),+ None,)).await;(response, created_by)diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rsindex 605d72bd50..1fa8901101 100644--- a/crates/router/src/routes/payments.rs+++ b/crates/router/src/routes/payments.rs@@ -1,5 +1,8 @@use crate::{- core::api_locking::{self, GetLockingInput},+ core::{+ api_locking::{self, GetLockingInput},+ payments::operations::Operation,+ },services::authorization::permissions::Permission,};pub mod helpers;@@ -31,6 +34,7 @@ use crate::{api::{self as api_types, enums as api_enums,payments::{self as payment_types, PaymentIdTypeExt},+ ConnectorData, GetToken,},domain,transformers::{ForeignTryFrom, ForeignTryInto},@@ -589,6 +593,7 @@ pub async fn payments_start(None,None,HeaderPayload::default(),+ None,)},&auth::MerchantIdAuth(merchant_id),@@ -679,6 +684,7 @@ pub async fn payments_retrieve(None,None,header_payload.clone(),+ None,)},auth::auth_type(@@ -760,6 +766,7 @@ pub async fn payments_retrieve_with_gateway_creds(None,None,HeaderPayload::default(),+ None,)},&*auth_type,@@ -921,6 +928,7 @@ pub async fn payments_post_session_tokens(None,None,header_payload.clone(),+ None,)},&*auth,@@ -979,6 +987,7 @@ pub async fn payments_update_metadata(None,None,header_payload.clone(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -1116,6 +1125,7 @@ pub async fn payments_capture(None,None,HeaderPayload::default(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -1214,6 +1224,7 @@ pub async fn payments_dynamic_tax_calculation(None,None,header_payload.clone(),+ None,)},&*auth,@@ -1368,6 +1379,7 @@ pub async fn payments_connector_session(None,None,header_payload.clone(),+ None,)},&*auth,@@ -1639,6 +1651,7 @@ pub async fn payments_complete_authorize(None,None,HeaderPayload::default(),+ None,)},&*auth_type,@@ -1662,6 +1675,14 @@ pub async fn payments_cancel(tracing::Span::current().record("payment_id", payment_id.get_string_repr());payload.payment_id = payment_id;++ let header_payload = match HeaderPayload::foreign_try_from(req.headers()) {+ Ok(headers) => headers,+ Err(err) => {+ return api::log_and_return_error_response(err);+ }+ };+let locking_action = payload.get_locking_input(flow.clone());Box::pin(api::server_wrap(flow,@@ -1669,26 +1690,113 @@ pub async fn payments_cancel(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- payments::payments_core::<- api_types::Void,- payment_types::PaymentsResponse,- _,- _,- _,- payments::PaymentData<api_types::Void>,- >(- state,- req_state,- auth.platform,- auth.profile.map(|profile| profile.get_id().clone()),- payments::PaymentCancel,- req,- api::AuthFlow::Merchant,- payments::CallConnectorAction::Trigger,- None,- None,- HeaderPayload::default(),- )+ let header_payload = header_payload.clone();+ async move {+ let operation = payments::PaymentCancel;+ let payment_id_type =+ payment_types::PaymentIdType::PaymentIntentId(req.payment_id.clone());++ // Getting the intent status to determine which flow to use+ let payment_pre_fetched_info = {+ let preliminary_dimensions = dimension_state::Dimensions::new()+ .with_processor_merchant_id(+ auth.platform.get_processor().get_processor_merchant_id(),+ )+ .with_provider_merchant_id(+ auth.platform.get_provider().get_provider_merchant_id(),+ );+ let tracker_response = operation+ .to_get_tracker()?+ .get_trackers(+ &state,+ &payment_id_type,+ &req,+ &auth.platform,+ api::AuthFlow::Merchant,+ &header_payload,+ crate::core::payment_methods::transformers::PaymentMethodFetchData::default(),+ &preliminary_dimensions,+ None,+ )+ .await?;++ let get_tracker_payment_data: payments::PaymentData<api_types::Void> =+ tracker_response.payment_data;++ // Create PaymentPreFetchedInformation to pass to payments_core+ payments::operations::PaymentPreFetchedInformation {+ payment_intent: get_tracker_payment_data.payment_intent.clone(),+ payment_attempt: get_tracker_payment_data.payment_attempt.clone(),+ }+ };++ // Check if the payment status is RequiresCustomerAction and connector supports pre-authorize cancel+ let supports_pre_authorize_cancel =+ if let Some(ref connector_name_str) = payment_pre_fetched_info.payment_attempt.connector {+ ConnectorData::get_connector_by_name(+ &state.conf.connectors,+ connector_name_str,+ GetToken::Connector,+ None,+ )+ .map(|connector_data| {+ connector_data.connector.is_pre_authorize_cancel_supported(payment_pre_fetched_info.payment_attempt.payment_method_type)+ })+ .unwrap_or(false)+ } else {+ false+ };++ if payment_pre_fetched_info.payment_intent.status == api_enums::IntentStatus::RequiresCustomerAction+ && supports_pre_authorize_cancel+ {+ Box::pin(payments::payments_core::<+ api_types::PreAuthorizeVoid,+ payment_types::PaymentsResponse,+ _,+ _,+ _,+ payments::PaymentData<api_types::PreAuthorizeVoid>,+ >(+ state,+ req_state,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),+ operation,+ req,+ api::AuthFlow::Merchant,+ payments::CallConnectorAction::Trigger,+ None,+ None,+ header_payload.clone(),+ Some(payment_pre_fetched_info),+ ))+ .await+ } else {+ Box::pin(payments::payments_core::<+ api_types::Void,+ payment_types::PaymentsResponse,+ _,+ _,+ _,+ payments::PaymentData<api_types::Void>,+ >(+ state,+ req_state,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),+ operation,+ req,+ api::AuthFlow::Merchant,+ payments::CallConnectorAction::Trigger,+ None,+ None,+ header_payload.clone(),+ Some(payment_pre_fetched_info),+ ))+ .await+ }+ }},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -1825,6 +1933,7 @@ pub async fn payments_cancel_post_capture(None,None,HeaderPayload::default(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -1874,6 +1983,7 @@ pub async fn payments_cancel_post_capture_retrieve(None,None,HeaderPayload::default(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -2267,6 +2377,7 @@ pub async fn payments_approve(None,None,HeaderPayload::default(),+ None,)},match env::which() {@@ -2339,6 +2450,7 @@ pub async fn payments_reject(None,None,HeaderPayload::default(),+ None,)},match env::which() {@@ -2380,11 +2492,11 @@ whereOp: Sync+ Clone+ std::fmt::Debug- + payments::operations::Operation<+ + Operation<api_types::Authorize,api_models::payments::PaymentsRequest,Data = payments::PaymentData<api_types::Authorize>,- > + payments::operations::Operation<+ > + Operation<api_types::SetupMandate,api_models::payments::PaymentsRequest,Data = payments::PaymentData<api_types::SetupMandate>,@@ -2500,16 +2612,17 @@ whereeligible_routable_connectors.clone(),header_payload.clone(),&dimensions,+ None,)).await?;let connector = payment_data.get_payment_attempt_connector();if let Some(connector_name) = connector {- let connector_data = api_types::ConnectorData::get_connector_by_name(+ let connector_data = ConnectorData::get_connector_by_name(&state.conf.connectors,connector_name,- api_types::GetToken::Connector,+ GetToken::Connector,None,)?;let should_continue_further = connector_data@@ -2544,6 +2657,7 @@ whereeligible_routable_connectors,header_payload.clone(),&dimensions,+ None,)).await?;let total_ext_latency = match (external_latency, ext_latency) {@@ -2598,6 +2712,7 @@ whereNone,eligible_connectors,header_payload,+ None,).await}@@ -2646,6 +2761,7 @@ pub async fn payments_incremental_authorization(None,None,HeaderPayload::default(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -2696,6 +2812,7 @@ pub async fn payments_extend_authorization(None,None,HeaderPayload::default(),+ None,)},&auth::HeaderAuth(auth::ApiKeyAuth {diff --git a/crates/router/src/types.rs b/crates/router/src/types.rsindex 4f52df5d49..7b74bdcd3b 100644--- a/crates/router/src/types.rs+++ b/crates/router/src/types.rs@@ -41,8 +41,8 @@ use hyperswitch_domain_models::router_flow_types::{Capture, CompleteAuthorize, CompleteRefundSurchrge, CompleteSurcharge,CreateConnectorCustomer, CreateOrder, ExtendAuthorization, ExternalVaultProxy, GenerateQr,IncrementalAuthorization, InitPayment, PSync, PostCaptureVoid, PostCaptureVoidSync,- PostProcessing, PostSessionTokens, PreProcessing, PushNotification, Reject,- SdkSessionUpdate, Session, SetupMandate, UpdateMetadata, Void,+ PostProcessing, PostSessionTokens, PreAuthorizeVoid, PreProcessing, PushNotification,+ Reject, SdkSessionUpdate, Session, SetupMandate, UpdateMetadata, Void,},refunds::{Execute, RSync},webhooks::VerifyWebhookSource,@@ -83,12 +83,13 @@ pub use hyperswitch_domain_models::{PaymentsCompleteRefundSurchrgeData, PaymentsCompleteSurchargeData,PaymentsExtendAuthorizationData, PaymentsIncrementalAuthorizationData,PaymentsPostAuthenticateData, PaymentsPostProcessingData, PaymentsPostSessionTokensData,- PaymentsPreAuthenticateData, PaymentsPreProcessingData, PaymentsRejectData,- PaymentsSessionData, PaymentsSurchargeCalculationData, PaymentsSyncData,- PaymentsTaxCalculationData, PaymentsUpdateMetadataData, PushNotificationRequestData,- RefundsData, ResponseId, RetrieveFileRequestData, SdkPaymentsSessionUpdateData,- SetupMandateRequestData, SplitRefundsRequest, SubmitEvidenceRequestData, SyncRequestType,- UploadFileRequestData, VaultRequestData, VerifyWebhookSourceRequestData,+ PaymentsPreAuthenticateData, PaymentsPreAuthorizeCancelData, PaymentsPreProcessingData,+ PaymentsRejectData, PaymentsSessionData, PaymentsSurchargeCalculationData,+ PaymentsSyncData, PaymentsTaxCalculationData, PaymentsUpdateMetadataData,+ PushNotificationRequestData, RefundsData, ResponseId, RetrieveFileRequestData,+ SdkPaymentsSessionUpdateData, SetupMandateRequestData, SplitRefundsRequest,+ SubmitEvidenceRequestData, SyncRequestType, UploadFileRequestData, VaultRequestData,+ VerifyWebhookSourceRequestData,},router_response_types::{merchant_connector_webhook_management::ConnectorWebhookRegisterResponse,@@ -196,6 +197,8 @@ pub type PaymentsUpdateMetadataRouterData =RouterData<UpdateMetadata, PaymentsUpdateMetadataData, PaymentsResponseData>;pub type PaymentsCancelRouterData = RouterData<Void, PaymentsCancelData, PaymentsResponseData>;+pub type PaymentsPreAuthorizeVoidRouterData =+ RouterData<PreAuthorizeVoid, PaymentsPreAuthorizeCancelData, PaymentsResponseData>;pub type PaymentsCancelPostCaptureRouterData =RouterData<PostCaptureVoid, PaymentsCancelPostCaptureData, PaymentsResponseData>;pub type PaymentsCancelPostCaptureSyncRouterData =@@ -571,6 +574,7 @@ impl Capturable for PaymentsCancelData {}}impl Capturable for PaymentsCancelPostCaptureSyncData {}+impl Capturable for PaymentsPreAuthorizeCancelData {}impl Capturable for PaymentsCancelPostCaptureData {fn get_captured_amount<F>(&self,diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rsindex 2eded8a833..78b84d0b7b 100644--- a/crates/router/src/types/api/payments.rs+++ b/crates/router/src/types/api/payments.rs@@ -44,8 +44,8 @@ pub use hyperswitch_domain_models::router_flow_types::payments::{CreateConnectorCustomer, CreateOrder, ExtendAuthorization, ExternalVaultProxy, GenerateQr,IncrementalAuthorization, InitPayment, PSync, PaymentCreateIntent, PaymentGetIntent,PaymentMethodToken, PaymentUpdateIntent, PostCaptureVoid, PostCaptureVoidSync, PostProcessing,- PostSessionTokens, PreProcessing, PushNotification, RecordAttempt, Reject, SdkSessionUpdate,- Session, SetupMandate, UpdateMetadata, Void,+ PostSessionTokens, PreAuthorizeVoid, PreProcessing, PushNotification, RecordAttempt, Reject,+ SdkSessionUpdate, Session, SetupMandate, UpdateMetadata, Void,};pub use hyperswitch_interfaces::api::payments::{ConnectorCustomer, MandateSetup, Payment, PaymentApprove, PaymentAuthorize,diff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rsindex 2e59b2ee8f..6744acbd3a 100644--- a/crates/router/src/workflows/outgoing_webhook_retry.rs+++ b/crates/router/src/workflows/outgoing_webhook_retry.rs@@ -429,6 +429,7 @@ async fn get_outgoing_webhook_content_and_event_type(None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)).await?{diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rsindex 18394a2455..851e05ec64 100644--- a/crates/router/src/workflows/payment_sync.rs+++ b/crates/router/src/workflows/payment_sync.rs@@ -103,6 +103,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {None,hyperswitch_domain_models::payments::HeaderPayload::default(),&dimensions,+ None,)).await?;diff --git a/crates/router/src/workflows/post_capture_void_sync.rs b/crates/router/src/workflows/post_capture_void_sync.rsindex ca9053b4f8..de77bcef2f 100644--- a/crates/router/src/workflows/post_capture_void_sync.rs+++ b/crates/router/src/workflows/post_capture_void_sync.rs@@ -90,6 +90,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsPostCaptureVoidSyncWorkfloNone,hyperswitch_domain_models::payments::HeaderPayload::default(),&dimensions,+ None,)).await?;diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex 7c203ce13c..a01b45d00a 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -510,6 +510,7 @@ async fn payments_create_core() {None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)).await.unwrap();@@ -816,6 +817,7 @@ async fn payments_create_core_adyen_no_redirect() {None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)).await.unwrap();diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex 936efd031b..3fcabd6238 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -271,6 +271,7 @@ async fn payments_create_core() {None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)).await.unwrap();@@ -585,6 +586,7 @@ async fn payments_create_core_adyen_no_redirect() {None,None,hyperswitch_domain_models::payments::HeaderPayload::default(),+ None,)).await.unwrap();diff --git a/crates/router_derive/src/macros/operation.rs b/crates/router_derive/src/macros/operation.rsindex cfa7cf8170..4249f33056 100644--- a/crates/router_derive/src/macros/operation.rs+++ b/crates/router_derive/src/macros/operation.rs@@ -20,6 +20,8 @@ pub enum Derives {SyncData,CancelData,CancelPostCapture,+ CancelPreAuthorize,+ CancelPreAuthorizeData,CancelPostCaptureData,CancelPostCaptureSync,CancelPostCaptureSyncData,@@ -145,6 +147,12 @@ impl Conversion {Derives::CancelPostCaptureData => {syn::Ident::new("PaymentsCancelPostCaptureData", Span::call_site())}+ Derives::CancelPreAuthorize => {+ syn::Ident::new("PaymentsCancelPreAuthorizeRequest", Span::call_site())+ }+ Derives::CancelPreAuthorizeData => {+ syn::Ident::new("PaymentsPreAuthorizeCancelData", Span::call_site())+ }Derives::ExtendAuthorization => {syn::Ident::new("PaymentsExtendAuthorizationRequest", Span::call_site())}@@ -476,6 +484,7 @@ pub fn operation_derive_inner(input: DeriveInput) -> syn::Result<proc_macro::TokPaymentsUpdateMetadataData,PaymentsCancelPostCaptureData,PaymentsCancelPostCaptureSyncData,+ PaymentsPreAuthorizeCancelData,PaymentsExtendAuthorizationData,api::{