diff --git a/connector-template/mod.rs b/connector-template/mod.rs index d9aa340b1dc8..6c311844c883 100644 --- a/connector-template/mod.rs +++ b/connector-template/mod.rs @@ -131,8 +131,8 @@ impl ConnectorIntegration for {{project-name | downcase | pascal_case}} { diff --git a/crates/router/src/compatibility/stripe/setup_intents.rs b/crates/router/src/compatibility/stripe/setup_intents.rs index 4b25a0e54e09..b9da2f8e3ee1 100644 --- a/crates/router/src/compatibility/stripe/setup_intents.rs +++ b/crates/router/src/compatibility/stripe/setup_intents.rs @@ -54,7 +54,7 @@ pub async fn setup_intents_create( &req, create_payment_req, |state, auth, req| { - payments::payments_core::( + payments::payments_core::( state, auth.merchant_account, auth.key_store, @@ -178,7 +178,7 @@ pub async fn setup_intents_update( &req, payload, |state, auth, req| { - payments::payments_core::( + payments::payments_core::( state, auth.merchant_account, auth.key_store, @@ -244,7 +244,7 @@ pub async fn setup_intents_confirm( &req, payload, |state, auth, req| { - payments::payments_core::( + payments::payments_core::( state, auth.merchant_account, auth.key_store, diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rs index b5d23410ce54..0a6e0d8a6099 100644 --- a/crates/router/src/connector/aci.rs +++ b/crates/router/src/connector/aci.rs @@ -122,12 +122,12 @@ impl // Not Implemented (R) } -impl api::PreVerify for Aci {} +impl api::MandateSetup for Aci {} impl services::ConnectorIntegration< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > for Aci { diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index 5089d86b803a..8347e43757b4 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -114,7 +114,7 @@ impl api::PaymentAuthorize for Adyen {} impl api::PaymentSync for Adyen {} impl api::PaymentVoid for Adyen {} impl api::PaymentCapture for Adyen {} -impl api::PreVerify for Adyen {} +impl api::MandateSetup for Adyen {} impl api::ConnectorAccessToken for Adyen {} impl api::PaymentToken for Adyen {} @@ -140,19 +140,19 @@ impl impl services::ConnectorIntegration< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > for Adyen { fn get_headers( &self, - req: &types::VerifyRouterData, + req: &types::SetupMandateRouterData, _connectors: &settings::Connectors, ) -> CustomResult)>, errors::ConnectorError> { let mut header = vec![( headers::CONTENT_TYPE.to_string(), - types::PaymentsVerifyType::get_content_type(self) + types::SetupMandateType::get_content_type(self) .to_string() .into(), )]; @@ -163,14 +163,14 @@ impl fn get_url( &self, - _req: &types::VerifyRouterData, + _req: &types::SetupMandateRouterData, connectors: &settings::Connectors, ) -> CustomResult { Ok(format!("{}{}", self.base_url(connectors), "v68/payments")) } fn get_request_body( &self, - req: &types::VerifyRouterData, + req: &types::SetupMandateRouterData, ) -> CustomResult, errors::ConnectorError> { let authorize_req = types::PaymentsAuthorizeRouterData::from(( req, @@ -193,32 +193,34 @@ impl } fn build_request( &self, - req: &types::VerifyRouterData, + req: &types::SetupMandateRouterData, connectors: &settings::Connectors, ) -> CustomResult, errors::ConnectorError> { Ok(Some( services::RequestBuilder::new() .method(services::Method::Post) - .url(&types::PaymentsVerifyType::get_url(self, req, connectors)?) + .url(&types::SetupMandateType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::PaymentsVerifyType::get_headers( - self, req, connectors, - )?) - .body(types::PaymentsVerifyType::get_request_body(self, req)?) + .headers(types::SetupMandateType::get_headers(self, req, connectors)?) + .body(types::SetupMandateType::get_request_body(self, req)?) .build(), )) } fn handle_response( &self, - data: &types::VerifyRouterData, + data: &types::SetupMandateRouterData, res: types::Response, ) -> CustomResult< - types::RouterData, + types::RouterData< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + >, errors::ConnectorError, > where - api::Verify: Clone, - types::VerifyRequestData: Clone, + api::SetupMandate: Clone, + types::SetupMandateRequestData: Clone, types::PaymentsResponseData: Clone, { let response: adyen::AdyenPaymentResponse = res diff --git a/crates/router/src/connector/airwallex.rs b/crates/router/src/connector/airwallex.rs index f7086cfb7ade..de1947d81817 100644 --- a/crates/router/src/connector/airwallex.rs +++ b/crates/router/src/connector/airwallex.rs @@ -110,9 +110,13 @@ impl ConnectorValidation for Airwallex { impl api::Payment for Airwallex {} impl api::PaymentsCompleteAuthorize for Airwallex {} -impl api::PreVerify for Airwallex {} -impl ConnectorIntegration - for Airwallex +impl api::MandateSetup for Airwallex {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Airwallex { } diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs index c40317ea3761..3f5b0a22b2c6 100644 --- a/crates/router/src/connector/authorizedotnet.rs +++ b/crates/router/src/connector/authorizedotnet.rs @@ -104,10 +104,14 @@ impl ConnectorIntegration - for Authorizedotnet +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Authorizedotnet { // Issue: #173 } diff --git a/crates/router/src/connector/bambora.rs b/crates/router/src/connector/bambora.rs index a8ea787eaf4f..b59645a40904 100644 --- a/crates/router/src/connector/bambora.rs +++ b/crates/router/src/connector/bambora.rs @@ -128,9 +128,13 @@ impl // Not Implemented (R) } -impl api::PreVerify for Bambora {} -impl ConnectorIntegration - for Bambora +impl api::MandateSetup for Bambora {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Bambora { } diff --git a/crates/router/src/connector/bitpay.rs b/crates/router/src/connector/bitpay.rs index 471cab7199f0..2dc634426f3e 100644 --- a/crates/router/src/connector/bitpay.rs +++ b/crates/router/src/connector/bitpay.rs @@ -33,7 +33,7 @@ impl api::Payment for Bitpay {} impl api::PaymentToken for Bitpay {} impl api::PaymentSession for Bitpay {} impl api::ConnectorAccessToken for Bitpay {} -impl api::PreVerify for Bitpay {} +impl api::MandateSetup for Bitpay {} impl api::PaymentAuthorize for Bitpay {} impl api::PaymentSync for Bitpay {} impl api::PaymentCapture for Bitpay {} @@ -133,8 +133,12 @@ impl ConnectorIntegration - for Bitpay +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Bitpay { } diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index 7e7af9352267..00901a55ba36 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -201,9 +201,13 @@ impl // Not Implemented (R) } -impl api::PreVerify for Bluesnap {} -impl ConnectorIntegration - for Bluesnap +impl api::MandateSetup for Bluesnap {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Bluesnap { } diff --git a/crates/router/src/connector/boku.rs b/crates/router/src/connector/boku.rs index 65e962f5aa08..826d218cd56e 100644 --- a/crates/router/src/connector/boku.rs +++ b/crates/router/src/connector/boku.rs @@ -37,7 +37,7 @@ pub struct Boku; impl api::Payment for Boku {} impl api::PaymentSession for Boku {} impl api::ConnectorAccessToken for Boku {} -impl api::PreVerify for Boku {} +impl api::MandateSetup for Boku {} impl api::PaymentAuthorize for Boku {} impl api::PaymentSync for Boku {} impl api::PaymentCapture for Boku {} @@ -162,8 +162,12 @@ impl ConnectorIntegration - for Boku +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Boku { } diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index 1dddc876c148..6a6411082830 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -375,11 +375,15 @@ impl } } -impl api::PreVerify for Braintree {} +impl api::MandateSetup for Braintree {} #[allow(dead_code)] -impl ConnectorIntegration - for Braintree +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Braintree { // Not Implemented (R) } diff --git a/crates/router/src/connector/cashtocode.rs b/crates/router/src/connector/cashtocode.rs index a185c6a653b5..cf30c5f83e5e 100644 --- a/crates/router/src/connector/cashtocode.rs +++ b/crates/router/src/connector/cashtocode.rs @@ -32,7 +32,7 @@ pub struct Cashtocode; impl api::Payment for Cashtocode {} impl api::PaymentSession for Cashtocode {} impl api::ConnectorAccessToken for Cashtocode {} -impl api::PreVerify for Cashtocode {} +impl api::MandateSetup for Cashtocode {} impl api::PaymentAuthorize for Cashtocode {} impl api::PaymentSync for Cashtocode {} impl api::PaymentCapture for Cashtocode {} @@ -149,8 +149,12 @@ impl ConnectorIntegration - for Cashtocode +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Cashtocode { } diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index 9e28adb57b7f..b9d0e70a8cb5 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -275,10 +275,14 @@ impl ConnectorIntegration - for Checkout +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Checkout { // Issue: #173 } diff --git a/crates/router/src/connector/coinbase.rs b/crates/router/src/connector/coinbase.rs index 463a8e679a1a..17d78750afa3 100644 --- a/crates/router/src/connector/coinbase.rs +++ b/crates/router/src/connector/coinbase.rs @@ -34,7 +34,7 @@ impl api::Payment for Coinbase {} impl api::PaymentToken for Coinbase {} impl api::PaymentSession for Coinbase {} impl api::ConnectorAccessToken for Coinbase {} -impl api::PreVerify for Coinbase {} +impl api::MandateSetup for Coinbase {} impl api::PaymentAuthorize for Coinbase {} impl api::PaymentSync for Coinbase {} impl api::PaymentCapture for Coinbase {} @@ -148,8 +148,12 @@ impl ConnectorIntegration - for Coinbase +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Coinbase { } diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rs index 2387a9bf4019..91e62f72e7ed 100644 --- a/crates/router/src/connector/cryptopay.rs +++ b/crates/router/src/connector/cryptopay.rs @@ -39,7 +39,7 @@ pub struct Cryptopay; impl api::Payment for Cryptopay {} impl api::PaymentSession for Cryptopay {} impl api::ConnectorAccessToken for Cryptopay {} -impl api::PreVerify for Cryptopay {} +impl api::MandateSetup for Cryptopay {} impl api::PaymentAuthorize for Cryptopay {} impl api::PaymentSync for Cryptopay {} impl api::PaymentCapture for Cryptopay {} @@ -183,8 +183,12 @@ impl ConnectorIntegration - for Cryptopay +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Cryptopay { } diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs index 26fd156abe89..11f76ec33131 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/router/src/connector/cybersource.rs @@ -226,7 +226,7 @@ impl api::PaymentAuthorize for Cybersource {} impl api::PaymentSync for Cybersource {} impl api::PaymentVoid for Cybersource {} impl api::PaymentCapture for Cybersource {} -impl api::PreVerify for Cybersource {} +impl api::MandateSetup for Cybersource {} impl api::ConnectorAccessToken for Cybersource {} impl api::PaymentToken for Cybersource {} @@ -240,8 +240,12 @@ impl // Not Implemented (R) } -impl ConnectorIntegration - for Cybersource +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Cybersource { } diff --git a/crates/router/src/connector/dlocal.rs b/crates/router/src/connector/dlocal.rs index 2e18030ff4fe..90be2399ba0e 100644 --- a/crates/router/src/connector/dlocal.rs +++ b/crates/router/src/connector/dlocal.rs @@ -37,7 +37,7 @@ impl api::Payment for Dlocal {} impl api::PaymentToken for Dlocal {} impl api::PaymentSession for Dlocal {} impl api::ConnectorAccessToken for Dlocal {} -impl api::PreVerify for Dlocal {} +impl api::MandateSetup for Dlocal {} impl api::PaymentAuthorize for Dlocal {} impl api::PaymentSync for Dlocal {} impl api::PaymentCapture for Dlocal {} @@ -171,8 +171,12 @@ impl ConnectorIntegration - for Dlocal +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Dlocal { } diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs index 4c7fc6c4347b..af87029a682c 100644 --- a/crates/router/src/connector/dummyconnector.rs +++ b/crates/router/src/connector/dummyconnector.rs @@ -30,7 +30,7 @@ pub struct DummyConnector; impl api::Payment for DummyConnector {} impl api::PaymentSession for DummyConnector {} impl api::ConnectorAccessToken for DummyConnector {} -impl api::PreVerify for DummyConnector {} +impl api::MandateSetup for DummyConnector {} impl api::PaymentAuthorize for DummyConnector {} impl api::PaymentSync for DummyConnector {} impl api::PaymentCapture for DummyConnector {} @@ -144,8 +144,11 @@ impl } impl - ConnectorIntegration - for DummyConnector + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for DummyConnector { } diff --git a/crates/router/src/connector/fiserv.rs b/crates/router/src/connector/fiserv.rs index 83bbf592f80b..70f58ffe6eb0 100644 --- a/crates/router/src/connector/fiserv.rs +++ b/crates/router/src/connector/fiserv.rs @@ -195,11 +195,15 @@ impl // Not Implemented (R) } -impl api::PreVerify for Fiserv {} +impl api::MandateSetup for Fiserv {} #[allow(dead_code)] -impl ConnectorIntegration - for Fiserv +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Fiserv { } diff --git a/crates/router/src/connector/forte.rs b/crates/router/src/connector/forte.rs index ecb63bcd752a..6f20e93e8c8d 100644 --- a/crates/router/src/connector/forte.rs +++ b/crates/router/src/connector/forte.rs @@ -36,7 +36,7 @@ pub struct Forte; impl api::Payment for Forte {} impl api::PaymentSession for Forte {} impl api::ConnectorAccessToken for Forte {} -impl api::PreVerify for Forte {} +impl api::MandateSetup for Forte {} impl api::PaymentAuthorize for Forte {} impl api::PaymentSync for Forte {} impl api::PaymentCapture for Forte {} @@ -159,8 +159,12 @@ impl ConnectorIntegration - for Forte +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Forte { } diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index 8d803913c4a9..761d91ae0130 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -331,9 +331,13 @@ impl // Not Implemented (R) } -impl api::PreVerify for Globalpay {} -impl ConnectorIntegration - for Globalpay +impl api::MandateSetup for Globalpay {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Globalpay { } diff --git a/crates/router/src/connector/globepay.rs b/crates/router/src/connector/globepay.rs index e0bb9e1fd3fd..c1bda5932834 100644 --- a/crates/router/src/connector/globepay.rs +++ b/crates/router/src/connector/globepay.rs @@ -31,7 +31,7 @@ pub struct Globepay; impl api::Payment for Globepay {} impl api::PaymentSession for Globepay {} impl api::ConnectorAccessToken for Globepay {} -impl api::PreVerify for Globepay {} +impl api::MandateSetup for Globepay {} impl api::PaymentAuthorize for Globepay {} impl api::PaymentSync for Globepay {} impl api::PaymentCapture for Globepay {} @@ -138,8 +138,12 @@ impl ConnectorIntegration - for Globepay +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Globepay { } diff --git a/crates/router/src/connector/gocardless.rs b/crates/router/src/connector/gocardless.rs index 6692c869e0cc..d2593df03259 100644 --- a/crates/router/src/connector/gocardless.rs +++ b/crates/router/src/connector/gocardless.rs @@ -32,7 +32,7 @@ pub struct Gocardless; impl api::Payment for Gocardless {} impl api::PaymentSession for Gocardless {} impl api::ConnectorAccessToken for Gocardless {} -impl api::PreVerify for Gocardless {} +impl api::MandateSetup for Gocardless {} impl api::PaymentAuthorize for Gocardless {} impl api::PaymentSync for Gocardless {} impl api::PaymentCapture for Gocardless {} @@ -422,8 +422,12 @@ impl ConnectorIntegration - for Gocardless +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Gocardless { } diff --git a/crates/router/src/connector/helcim.rs b/crates/router/src/connector/helcim.rs index e5444b53be0f..a3cb5f7a22e6 100644 --- a/crates/router/src/connector/helcim.rs +++ b/crates/router/src/connector/helcim.rs @@ -29,7 +29,7 @@ pub struct Helcim; impl api::Payment for Helcim {} impl api::PaymentSession for Helcim {} impl api::ConnectorAccessToken for Helcim {} -impl api::PreVerify for Helcim {} +impl api::MandateSetup for Helcim {} impl api::PaymentAuthorize for Helcim {} impl api::PaymentSync for Helcim {} impl api::PaymentCapture for Helcim {} @@ -128,8 +128,12 @@ impl ConnectorIntegration - for Helcim +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Helcim { } diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs index f55ee22a23b9..0106b7087159 100644 --- a/crates/router/src/connector/iatapay.rs +++ b/crates/router/src/connector/iatapay.rs @@ -34,7 +34,7 @@ pub struct Iatapay; impl api::Payment for Iatapay {} impl api::PaymentSession for Iatapay {} impl api::ConnectorAccessToken for Iatapay {} -impl api::PreVerify for Iatapay {} +impl api::MandateSetup for Iatapay {} impl api::PaymentAuthorize for Iatapay {} impl api::PaymentSync for Iatapay {} impl api::PaymentCapture for Iatapay {} @@ -235,8 +235,12 @@ impl ConnectorIntegration - for Iatapay +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Iatapay { } diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 2611c062ebe3..87f007cb3ac8 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -207,12 +207,12 @@ impl } } -impl api::PreVerify for Klarna {} +impl api::MandateSetup for Klarna {} impl services::ConnectorIntegration< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > for Klarna { diff --git a/crates/router/src/connector/mollie.rs b/crates/router/src/connector/mollie.rs index 5759a4f8a0af..d0b2b635fce0 100644 --- a/crates/router/src/connector/mollie.rs +++ b/crates/router/src/connector/mollie.rs @@ -33,7 +33,7 @@ pub struct Mollie; impl api::Payment for Mollie {} impl api::PaymentSession for Mollie {} impl api::ConnectorAccessToken for Mollie {} -impl api::PreVerify for Mollie {} +impl api::MandateSetup for Mollie {} impl api::PaymentToken for Mollie {} impl api::PaymentAuthorize for Mollie {} impl api::PaymentsCompleteAuthorize for Mollie {} @@ -197,8 +197,12 @@ impl } } -impl ConnectorIntegration - for Mollie +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Mollie { } diff --git a/crates/router/src/connector/multisafepay.rs b/crates/router/src/connector/multisafepay.rs index 160a135b1734..1629f2ab36d9 100644 --- a/crates/router/src/connector/multisafepay.rs +++ b/crates/router/src/connector/multisafepay.rs @@ -115,9 +115,13 @@ impl // Not Implemented (R) } -impl api::PreVerify for Multisafepay {} -impl ConnectorIntegration - for Multisafepay +impl api::MandateSetup for Multisafepay {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Multisafepay { } diff --git a/crates/router/src/connector/nexinets.rs b/crates/router/src/connector/nexinets.rs index f0a490cfbd10..30ae4ab25e50 100644 --- a/crates/router/src/connector/nexinets.rs +++ b/crates/router/src/connector/nexinets.rs @@ -33,7 +33,7 @@ pub struct Nexinets; impl api::Payment for Nexinets {} impl api::PaymentSession for Nexinets {} impl api::ConnectorAccessToken for Nexinets {} -impl api::PreVerify for Nexinets {} +impl api::MandateSetup for Nexinets {} impl api::PaymentAuthorize for Nexinets {} impl api::PaymentSync for Nexinets {} impl api::PaymentCapture for Nexinets {} @@ -159,8 +159,12 @@ impl ConnectorIntegration - for Nexinets +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Nexinets { } diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs index d2834d99664e..cdeb9c99d5ea 100644 --- a/crates/router/src/connector/nmi.rs +++ b/crates/router/src/connector/nmi.rs @@ -27,7 +27,7 @@ pub struct Nmi; impl api::Payment for Nmi {} impl api::PaymentSession for Nmi {} impl api::ConnectorAccessToken for Nmi {} -impl api::PreVerify for Nmi {} +impl api::MandateSetup for Nmi {} impl api::PaymentAuthorize for Nmi {} impl api::PaymentSync for Nmi {} impl api::PaymentCapture for Nmi {} @@ -113,12 +113,16 @@ impl ConnectorIntegration - for Nmi +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Nmi { fn get_headers( &self, - req: &types::VerifyRouterData, + req: &types::SetupMandateRouterData, connectors: &settings::Connectors, ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) @@ -126,7 +130,7 @@ impl ConnectorIntegration CustomResult { Ok(format!("{}api/transact.php", self.base_url(connectors))) @@ -134,7 +138,7 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { let connector_req = nmi::NmiPaymentsRequest::try_from(req)?; let nmi_req = types::RequestBody::log_and_get_request_body( @@ -147,26 +151,24 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { Ok(Some( services::RequestBuilder::new() .method(services::Method::Post) - .url(&types::PaymentsVerifyType::get_url(self, req, connectors)?) - .headers(types::PaymentsVerifyType::get_headers( - self, req, connectors, - )?) - .body(types::PaymentsVerifyType::get_request_body(self, req)?) + .url(&types::SetupMandateType::get_url(self, req, connectors)?) + .headers(types::SetupMandateType::get_headers(self, req, connectors)?) + .body(types::SetupMandateType::get_request_body(self, req)?) .build(), )) } fn handle_response( &self, - data: &types::VerifyRouterData, + data: &types::SetupMandateRouterData, res: types::Response, - ) -> CustomResult { + ) -> CustomResult { let response: nmi::StandardResponse = serde_urlencoded::from_bytes(&res.response) .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; diff --git a/crates/router/src/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rs index 13cf1426b90f..a57ac4271d05 100644 --- a/crates/router/src/connector/nmi/transformers.rs +++ b/crates/router/src/connector/nmi/transformers.rs @@ -158,9 +158,9 @@ impl From<&api_models::payments::ApplePayWalletData> for PaymentMethod { } } -impl TryFrom<&types::VerifyRouterData> for NmiPaymentsRequest { +impl TryFrom<&types::SetupMandateRouterData> for NmiPaymentsRequest { type Error = Error; - fn try_from(item: &types::VerifyRouterData) -> Result { + fn try_from(item: &types::SetupMandateRouterData) -> Result { let auth_type: NmiAuthType = (&item.connector_auth_type).try_into()?; let payment_method = PaymentMethod::try_from(&item.request.payment_method_data)?; Ok(Self { @@ -314,13 +314,18 @@ pub struct StandardResponse { impl TryFrom< - types::ResponseRouterData, - > for types::RouterData + types::ResponseRouterData< + api::SetupMandate, + StandardResponse, + T, + types::PaymentsResponseData, + >, + > for types::RouterData { type Error = Error; fn try_from( item: types::ResponseRouterData< - api::Verify, + api::SetupMandate, StandardResponse, T, types::PaymentsResponseData, diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index 8b7c984083c7..bf1ab53453e1 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -38,7 +38,7 @@ pub struct Noon; impl api::Payment for Noon {} impl api::PaymentSession for Noon {} impl api::ConnectorAccessToken for Noon {} -impl api::PreVerify for Noon {} +impl api::MandateSetup for Noon {} impl api::PaymentAuthorize for Noon {} impl api::PaymentSync for Noon {} impl api::PaymentCapture for Noon {} @@ -167,8 +167,12 @@ impl ConnectorIntegration - for Noon +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Noon { } diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs index b2bcb39c5ea1..52388c849adc 100644 --- a/crates/router/src/connector/nuvei.rs +++ b/crates/router/src/connector/nuvei.rs @@ -98,7 +98,7 @@ impl // Not Implemented (R) } -impl api::PreVerify for Nuvei {} +impl api::MandateSetup for Nuvei {} impl api::PaymentVoid for Nuvei {} impl api::PaymentSync for Nuvei {} impl api::PaymentCapture for Nuvei {} @@ -110,8 +110,12 @@ impl api::RefundSync for Nuvei {} impl api::PaymentsCompleteAuthorize for Nuvei {} impl api::ConnectorAccessToken for Nuvei {} -impl ConnectorIntegration - for Nuvei +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Nuvei { } diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs index c64cfe7ea0c0..89e16416d27f 100644 --- a/crates/router/src/connector/opayo.rs +++ b/crates/router/src/connector/opayo.rs @@ -31,7 +31,7 @@ pub struct Opayo; impl api::Payment for Opayo {} impl api::PaymentSession for Opayo {} impl api::ConnectorAccessToken for Opayo {} -impl api::PreVerify for Opayo {} +impl api::MandateSetup for Opayo {} impl api::PaymentAuthorize for Opayo {} impl api::PaymentSync for Opayo {} impl api::PaymentCapture for Opayo {} @@ -137,8 +137,12 @@ impl ConnectorIntegration - for Opayo +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Opayo { } diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rs index 2a997e0adb0b..df2b2170d028 100644 --- a/crates/router/src/connector/opennode.rs +++ b/crates/router/src/connector/opennode.rs @@ -33,7 +33,7 @@ impl api::PaymentSession for Opennode {} impl api::PaymentToken for Opennode {} impl api::ConnectorAccessToken for Opennode {} -impl api::PreVerify for Opennode {} +impl api::MandateSetup for Opennode {} impl api::PaymentAuthorize for Opennode {} impl api::PaymentSync for Opennode {} impl api::PaymentCapture for Opennode {} @@ -133,8 +133,12 @@ impl ConnectorIntegration - for Opennode +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Opennode { } diff --git a/crates/router/src/connector/payeezy.rs b/crates/router/src/connector/payeezy.rs index 6baa01f087e9..da7126054378 100644 --- a/crates/router/src/connector/payeezy.rs +++ b/crates/router/src/connector/payeezy.rs @@ -140,9 +140,13 @@ impl ConnectorValidation for Payeezy { impl api::Payment for Payeezy {} -impl api::PreVerify for Payeezy {} -impl ConnectorIntegration - for Payeezy +impl api::MandateSetup for Payeezy {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Payeezy { } diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index beb0b7c83ef2..f3af084a97dc 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -33,7 +33,7 @@ impl api::Payment for Payme {} impl api::PaymentSession for Payme {} impl api::PaymentsCompleteAuthorize for Payme {} impl api::ConnectorAccessToken for Payme {} -impl api::PreVerify for Payme {} +impl api::MandateSetup for Payme {} impl api::PaymentAuthorize for Payme {} impl api::PaymentSync for Payme {} impl api::PaymentCapture for Payme {} @@ -326,8 +326,12 @@ impl ConnectorIntegration - for Payme +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Payme { } diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 4aa50bb2d676..b82223f3acca 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -41,7 +41,7 @@ impl api::Payment for Paypal {} impl api::PaymentSession for Paypal {} impl api::PaymentToken for Paypal {} impl api::ConnectorAccessToken for Paypal {} -impl api::PreVerify for Paypal {} +impl api::MandateSetup for Paypal {} impl api::PaymentAuthorize for Paypal {} impl api::PaymentsCompleteAuthorize for Paypal {} impl api::PaymentSync for Paypal {} @@ -316,8 +316,12 @@ impl ConnectorIntegration - for Paypal +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Paypal { } diff --git a/crates/router/src/connector/payu.rs b/crates/router/src/connector/payu.rs index dd78c214ee60..6433735f7c53 100644 --- a/crates/router/src/connector/payu.rs +++ b/crates/router/src/connector/payu.rs @@ -117,9 +117,13 @@ impl ConnectorValidation for Payu { impl api::Payment for Payu {} -impl api::PreVerify for Payu {} -impl ConnectorIntegration - for Payu +impl api::MandateSetup for Payu {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Payu { } diff --git a/crates/router/src/connector/powertranz.rs b/crates/router/src/connector/powertranz.rs index 32303dc073d5..bcbe2113f616 100644 --- a/crates/router/src/connector/powertranz.rs +++ b/crates/router/src/connector/powertranz.rs @@ -36,7 +36,7 @@ pub struct Powertranz; impl api::Payment for Powertranz {} impl api::PaymentSession for Powertranz {} impl api::ConnectorAccessToken for Powertranz {} -impl api::PreVerify for Powertranz {} +impl api::MandateSetup for Powertranz {} impl api::PaymentAuthorize for Powertranz {} impl api::PaymentsCompleteAuthorize for Powertranz {} impl api::PaymentSync for Powertranz {} @@ -149,8 +149,12 @@ impl ConnectorIntegration - for Powertranz +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Powertranz { } diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs index d0a5259157d5..04748edd2346 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/router/src/connector/rapyd.rs @@ -255,11 +255,11 @@ impl impl api::Payment for Rapyd {} -impl api::PreVerify for Rapyd {} +impl api::MandateSetup for Rapyd {} impl services::ConnectorIntegration< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > for Rapyd { diff --git a/crates/router/src/connector/shift4.rs b/crates/router/src/connector/shift4.rs index ae777b286006..a17546711f14 100644 --- a/crates/router/src/connector/shift4.rs +++ b/crates/router/src/connector/shift4.rs @@ -148,9 +148,13 @@ impl ConnectorIntegration - for Shift4 +impl api::MandateSetup for Shift4 {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Shift4 { } diff --git a/crates/router/src/connector/square.rs b/crates/router/src/connector/square.rs index 6ef1b6a29c76..aedd2f93dadd 100644 --- a/crates/router/src/connector/square.rs +++ b/crates/router/src/connector/square.rs @@ -37,7 +37,7 @@ pub struct Square; impl api::Payment for Square {} impl api::PaymentSession for Square {} impl api::ConnectorAccessToken for Square {} -impl api::PreVerify for Square {} +impl api::MandateSetup for Square {} impl api::PaymentAuthorize for Square {} impl api::PaymentSync for Square {} impl api::PaymentCapture for Square {} @@ -153,8 +153,12 @@ impl ConnectorIntegration - for Square +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Square { } diff --git a/crates/router/src/connector/stax.rs b/crates/router/src/connector/stax.rs index 522876390715..82a4c7ff3233 100644 --- a/crates/router/src/connector/stax.rs +++ b/crates/router/src/connector/stax.rs @@ -34,7 +34,7 @@ pub struct Stax; impl api::Payment for Stax {} impl api::PaymentSession for Stax {} impl api::ConnectorAccessToken for Stax {} -impl api::PreVerify for Stax {} +impl api::MandateSetup for Stax {} impl api::PaymentAuthorize for Stax {} impl api::PaymentSync for Stax {} impl api::PaymentCapture for Stax {} @@ -311,8 +311,12 @@ impl ConnectorIntegration - for Stax +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Stax { } diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index 5e31a89bed55..cc1e3be81d45 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -453,7 +453,7 @@ impl } } -impl api::PreVerify for Stripe {} +impl api::MandateSetup for Stripe {} impl services::ConnectorIntegration< @@ -965,20 +965,24 @@ impl } type Verify = dyn services::ConnectorIntegration< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, >; impl services::ConnectorIntegration< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > for Stripe { fn get_headers( &self, - req: &types::RouterData, + req: &types::RouterData< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + >, _connectors: &settings::Connectors, ) -> CustomResult)>, errors::ConnectorError> { let mut header = vec![( @@ -997,8 +1001,8 @@ impl fn get_url( &self, _req: &types::RouterData< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, >, connectors: &settings::Connectors, @@ -1012,7 +1016,11 @@ impl fn get_request_body( &self, - req: &types::RouterData, + req: &types::RouterData< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + >, ) -> CustomResult, errors::ConnectorError> { let req = stripe::SetupIntentRequest::try_from(req)?; let stripe_req = types::RequestBody::log_and_get_request_body( @@ -1025,7 +1033,11 @@ impl fn build_request( &self, - req: &types::RouterData, + req: &types::RouterData< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + >, connectors: &settings::Connectors, ) -> CustomResult, errors::ConnectorError> { Ok(Some( @@ -1042,18 +1054,22 @@ impl fn handle_response( &self, data: &types::RouterData< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, >, res: types::Response, ) -> CustomResult< - types::RouterData, + types::RouterData< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + >, errors::ConnectorError, > where - api::Verify: Clone, - types::VerifyRequestData: Clone, + api::SetupMandate: Clone, + types::SetupMandateRequestData: Clone, types::PaymentsResponseData: Clone, { let response: stripe::SetupIntentResponse = res diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 57a7935f0300..a3711a5497c1 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1929,9 +1929,9 @@ fn get_payment_method_type_for_saved_payment_method_payment( } } -impl TryFrom<&types::VerifyRouterData> for SetupIntentRequest { +impl TryFrom<&types::SetupMandateRouterData> for SetupIntentRequest { type Error = error_stack::Report; - fn try_from(item: &types::VerifyRouterData) -> Result { + fn try_from(item: &types::SetupMandateRouterData) -> Result { let metadata_order_id = item.connector_request_reference_id.clone(); let metadata_txn_id = format!("{}_{}_{}", item.merchant_id, item.payment_id, "1"); let metadata_txn_uuid = Uuid::new_v4().to_string(); diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index bfecc563c5e2..3d4f0a14a997 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -164,9 +164,13 @@ impl // Not Implemented (R) } -impl api::PreVerify for Trustpay {} -impl ConnectorIntegration - for Trustpay +impl api::MandateSetup for Trustpay {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Trustpay { } diff --git a/crates/router/src/connector/tsys.rs b/crates/router/src/connector/tsys.rs index b7e4f5aece2f..869aa5356364 100644 --- a/crates/router/src/connector/tsys.rs +++ b/crates/router/src/connector/tsys.rs @@ -30,7 +30,7 @@ pub struct Tsys; impl api::Payment for Tsys {} impl api::PaymentSession for Tsys {} impl api::ConnectorAccessToken for Tsys {} -impl api::PreVerify for Tsys {} +impl api::MandateSetup for Tsys {} impl api::PaymentAuthorize for Tsys {} impl api::PaymentSync for Tsys {} impl api::PaymentCapture for Tsys {} @@ -105,8 +105,12 @@ impl ConnectorIntegration - for Tsys +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Tsys { } diff --git a/crates/router/src/connector/wise.rs b/crates/router/src/connector/wise.rs index e64e95ed90e5..9616533a4554 100644 --- a/crates/router/src/connector/wise.rs +++ b/crates/router/src/connector/wise.rs @@ -119,7 +119,7 @@ impl api::PaymentAuthorize for Wise {} impl api::PaymentSync for Wise {} impl api::PaymentVoid for Wise {} impl api::PaymentCapture for Wise {} -impl api::PreVerify for Wise {} +impl api::MandateSetup for Wise {} impl api::ConnectorAccessToken for Wise {} impl api::PaymentToken for Wise {} impl ConnectorValidation for Wise {} @@ -144,8 +144,8 @@ impl impl services::ConnectorIntegration< - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > for Wise { diff --git a/crates/router/src/connector/worldline.rs b/crates/router/src/connector/worldline.rs index ed9acec34c92..2dddb2ed9e2c 100644 --- a/crates/router/src/connector/worldline.rs +++ b/crates/router/src/connector/worldline.rs @@ -162,9 +162,13 @@ impl ConnectorIntegration - for Worldline +impl api::MandateSetup for Worldline {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Worldline { } diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rs index 20185cf81abe..53e26f749fce 100644 --- a/crates/router/src/connector/worldpay.rs +++ b/crates/router/src/connector/worldpay.rs @@ -111,9 +111,13 @@ impl ConnectorValidation for Worldpay { impl api::Payment for Worldpay {} -impl api::PreVerify for Worldpay {} -impl ConnectorIntegration - for Worldpay +impl api::MandateSetup for Worldpay {} +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Worldpay { } diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rs index a284352bf420..11b3b7076dd2 100644 --- a/crates/router/src/connector/zen.rs +++ b/crates/router/src/connector/zen.rs @@ -36,7 +36,7 @@ pub struct Zen; impl api::Payment for Zen {} impl api::PaymentSession for Zen {} impl api::ConnectorAccessToken for Zen {} -impl api::PreVerify for Zen {} +impl api::MandateSetup for Zen {} impl api::PaymentAuthorize for Zen {} impl api::PaymentSync for Zen {} impl api::PaymentCapture for Zen {} @@ -161,8 +161,12 @@ impl ConnectorIntegration - for Zen +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Zen { } diff --git a/crates/router/src/core/errors/utils.rs b/crates/router/src/core/errors/utils.rs index e63471e01346..8a86be2036be 100644 --- a/crates/router/src/core/errors/utils.rs +++ b/crates/router/src/core/errors/utils.rs @@ -118,7 +118,7 @@ pub trait ConnectorErrorExt { #[track_caller] fn to_payment_failed_response(self) -> error_stack::Result; #[track_caller] - fn to_verify_failed_response(self) -> error_stack::Result; + fn to_setup_mandate_failed_response(self) -> error_stack::Result; #[track_caller] fn to_dispute_failed_response(self) -> error_stack::Result; #[cfg(feature = "payouts")] @@ -211,7 +211,7 @@ impl ConnectorErrorExt for error_stack::Result }) } - fn to_verify_failed_response(self) -> error_stack::Result { + fn to_setup_mandate_failed_response(self) -> error_stack::Result { self.map_err(|err| { let error = err.current_context(); let data = match error { diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index e7c19ac2a69f..b8919dab30a1 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -6,7 +6,7 @@ pub mod complete_authorize_flow; pub mod psync_flow; pub mod reject_flow; pub mod session_flow; -pub mod verify_flow; +pub mod setup_mandate_flow; use async_trait::async_trait; diff --git a/crates/router/src/core/payments/flows/verify_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs similarity index 84% rename from crates/router/src/core/payments/flows/verify_flow.rs rename to crates/router/src/core/payments/flows/setup_mandate_flow.rs index 1ecf2199b806..756600ce2e7e 100644 --- a/crates/router/src/core/payments/flows/verify_flow.rs +++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs @@ -15,8 +15,12 @@ use crate::{ }; #[async_trait] -impl ConstructFlowSpecificData - for PaymentData +impl + ConstructFlowSpecificData< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for PaymentData { async fn construct_router_data<'a>( &self, @@ -26,8 +30,11 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, - ) -> RouterResult { - transformers::construct_payment_router_data::( + ) -> RouterResult { + transformers::construct_payment_router_data::< + api::SetupMandate, + types::SetupMandateRequestData, + >( state, self.clone(), connector_id, @@ -41,7 +48,7 @@ impl ConstructFlowSpecificData for types::VerifyRouterData { +impl Feature for types::SetupMandateRouterData { async fn decide_flows<'a>( self, state: &AppState, @@ -54,8 +61,8 @@ impl Feature for types::VerifyRouterData ) -> RouterResult { let connector_integration: services::BoxedConnectorIntegration< '_, - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > = connector.connector.get_connector_integration(); let resp = services::execute_connector_processing_step( @@ -66,7 +73,7 @@ impl Feature for types::VerifyRouterData connector_request, ) .await - .to_verify_failed_response()?; + .to_setup_mandate_failed_response()?; let pm_id = tokenization::save_payment_method( state, @@ -132,8 +139,8 @@ impl Feature for types::VerifyRouterData payments::CallConnectorAction::Trigger => { let connector_integration: services::BoxedConnectorIntegration< '_, - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > = connector.connector.get_connector_integration(); @@ -149,9 +156,9 @@ impl Feature for types::VerifyRouterData } } -impl TryFrom for types::ConnectorCustomerData { +impl TryFrom for types::ConnectorCustomerData { type Error = error_stack::Report; - fn try_from(data: types::VerifyRequestData) -> Result { + fn try_from(data: types::SetupMandateRequestData) -> Result { Ok(Self { email: data.email, description: None, @@ -163,7 +170,7 @@ impl TryFrom for types::ConnectorCustomerData { } #[allow(clippy::too_many_arguments)] -impl types::VerifyRouterData { +impl types::SetupMandateRouterData { pub async fn decide_flow<'a, 'b>( &'b self, state: &'a AppState, @@ -178,8 +185,8 @@ impl types::VerifyRouterData { Some(true) => { let connector_integration: services::BoxedConnectorIntegration< '_, - api::Verify, - types::VerifyRequestData, + api::SetupMandate, + types::SetupMandateRequestData, types::PaymentsResponseData, > = connector.connector.get_connector_integration(); let resp = services::execute_connector_processing_step( @@ -190,7 +197,7 @@ impl types::VerifyRouterData { None, ) .await - .to_verify_failed_response()?; + .to_setup_mandate_failed_response()?; let payment_method_type = self.request.payment_method_type; let pm_id = tokenization::save_payment_method( @@ -211,7 +218,7 @@ impl types::VerifyRouterData { } } -impl mandate::MandateBehaviour for types::VerifyRequestData { +impl mandate::MandateBehaviour for types::SetupMandateRequestData { fn get_amount(&self) -> i64 { 0 } @@ -237,10 +244,10 @@ impl mandate::MandateBehaviour for types::VerifyRequestData { } } -impl TryFrom for types::PaymentMethodTokenizationData { +impl TryFrom for types::PaymentMethodTokenizationData { type Error = error_stack::Report; - fn try_from(data: types::VerifyRequestData) -> Result { + fn try_from(data: types::SetupMandateRequestData) -> Result { Ok(Self { payment_method_data: data.payment_method_data, browser_info: None, diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index 328319c3912d..d3cb4f818f01 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -32,7 +32,7 @@ use crate::{ #[derive(Debug, Clone, Copy, router_derive::PaymentOperation)] #[operation( ops = "post_tracker", - flow = "syncdata,authorizedata,canceldata,capturedata,completeauthorizedata,approvedata,rejectdata,verifydata,sessiondata" + flow = "syncdata,authorizedata,canceldata,capturedata,completeauthorizedata,approvedata,rejectdata,setupmandatedata,sessiondata" )] pub struct PaymentResponse; @@ -230,13 +230,19 @@ impl PostUpdateTracker, types::PaymentsRejectData> f } #[async_trait] -impl PostUpdateTracker, types::VerifyRequestData> for PaymentResponse { +impl PostUpdateTracker, types::SetupMandateRequestData> + for PaymentResponse +{ async fn update_tracker<'b>( &'b self, db: &dyn StorageInterface, payment_id: &api::PaymentIdType, mut payment_data: PaymentData, - router_data: types::RouterData, + router_data: types::RouterData< + F, + types::SetupMandateRequestData, + types::PaymentsResponseData, + >, storage_scheme: enums::MerchantStorageScheme, ) -> RouterResult> diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 96c8a8a2cb5a..a8069b4d4a62 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -1160,7 +1160,7 @@ impl TryFrom> for types::PaymentsSessionD } } -impl TryFrom> for types::VerifyRequestData { +impl TryFrom> for types::SetupMandateRequestData { type Error = error_stack::Report; fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result { diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs index bd58d55191e2..db27929be3a7 100644 --- a/crates/router/src/routes/payments.rs +++ b/crates/router/src/routes/payments.rs @@ -860,7 +860,10 @@ where + Clone + std::fmt::Debug + payments::operations::Operation - + payments::operations::Operation, + + payments::operations::Operation< + api_types::SetupMandate, + api_models::payments::PaymentsRequest, + >, { // TODO: Change for making it possible for the flow to be inferred internally or through validation layer // This is a temporary fix. @@ -868,8 +871,10 @@ where // the operation are flow agnostic, and the flow is only required in the post_update_tracker // Thus the flow can be generated just before calling the connector instead of explicitly passing it here. - match req.amount.as_ref() { - Some(api_types::Amount::Value(_)) | None => payments::payments_core::< + match req.payment_type { + api_models::enums::PaymentType::Normal + | api_models::enums::PaymentType::RecurringMandate + | api_models::enums::PaymentType::NewMandate => payments::payments_core::< api_types::Authorize, payment_types::PaymentsResponse, _, @@ -886,9 +891,14 @@ where header_payload, ) .await, - - Some(api_types::Amount::Zero) => { - payments::payments_core::( + api_models::enums::PaymentType::SetupMandate => { + payments::payments_core::< + api_types::SetupMandate, + payment_types::PaymentsResponse, + _, + _, + _, + >( state, merchant_account, key_store, diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 13ad129f4ac9..3b1becb25e17 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -101,8 +101,11 @@ pub type RefundsResponseRouterData = pub type PaymentsAuthorizeType = dyn services::ConnectorIntegration; -pub type PaymentsVerifyType = - dyn services::ConnectorIntegration; +pub type SetupMandateType = dyn services::ConnectorIntegration< + api::SetupMandate, + SetupMandateRequestData, + PaymentsResponseData, +>; pub type PaymentsPreProcessingType = dyn services::ConnectorIntegration< api::PreProcessing, PaymentsPreProcessingData, @@ -204,7 +207,8 @@ pub type DefendDisputeType = dyn services::ConnectorIntegration< DefendDisputeResponse, >; -pub type VerifyRouterData = RouterData; +pub type SetupMandateRouterData = + RouterData; pub type AcceptDisputeRouterData = RouterData; @@ -510,7 +514,7 @@ pub struct PaymentsSessionData { } #[derive(Debug, Clone)] -pub struct VerifyRequestData { +pub struct SetupMandateRequestData { pub currency: storage_enums::Currency, pub payment_method_data: payments::PaymentMethodData, pub amount: Option, @@ -557,7 +561,7 @@ impl Capturable for CompleteAuthorizeData { Some(self.amount) } } -impl Capturable for VerifyRequestData {} +impl Capturable for SetupMandateRequestData {} impl Capturable for PaymentsCancelData {} impl Capturable for PaymentsApproveData {} impl Capturable for PaymentsRejectData {} @@ -1014,7 +1018,7 @@ pub trait Tokenizable { fn set_session_token(&mut self, token: Option); } -impl Tokenizable for VerifyRequestData { +impl Tokenizable for SetupMandateRequestData { fn get_pm_data(&self) -> RouterResult { Ok(self.payment_method_data.clone()) } @@ -1039,8 +1043,8 @@ impl Tokenizable for CompleteAuthorizeData { fn set_session_token(&mut self, _token: Option) {} } -impl From<&VerifyRouterData> for PaymentsAuthorizeData { - fn from(data: &VerifyRouterData) -> Self { +impl From<&SetupMandateRouterData> for PaymentsAuthorizeData { + fn from(data: &SetupMandateRouterData) -> Self { Self { currency: data.request.currency, payment_method_data: data.request.payment_method_data.clone(), diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index eecaac6ced61..b00a7f0cbdac 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -76,7 +76,7 @@ pub struct PaymentMethodToken; pub struct CreateConnectorCustomer; #[derive(Debug, Clone)] -pub struct Verify; +pub struct SetupMandate; #[derive(Debug, Clone)] pub struct PreProcessing; @@ -159,8 +159,8 @@ pub trait PaymentSession: { } -pub trait PreVerify: - api::ConnectorIntegration +pub trait MandateSetup: + api::ConnectorIntegration { } @@ -210,7 +210,7 @@ pub trait Payment: + PaymentVoid + PaymentApprove + PaymentReject - + PreVerify + + MandateSetup + PaymentSession + PaymentToken + PaymentsPreProcessing diff --git a/crates/router_derive/src/macros/operation.rs b/crates/router_derive/src/macros/operation.rs index c6504f1d9c49..cf71370a293d 100644 --- a/crates/router_derive/src/macros/operation.rs +++ b/crates/router_derive/src/macros/operation.rs @@ -20,7 +20,7 @@ enum Derives { Capturedata, CompleteAuthorizeData, Rejectdata, - VerifyData, + SetupMandateData, Start, Verify, Session, @@ -44,7 +44,7 @@ impl From for Derives { "rejectdata" => Self::Rejectdata, "start" => Self::Start, "verify" => Self::Verify, - "verifydata" => Self::VerifyData, + "setupmandatedata" => Self::SetupMandateData, "session" => Self::Session, "sessiondata" => Self::SessionData, _ => Self::Authorize, @@ -126,7 +126,9 @@ impl Conversion { } Derives::Start => syn::Ident::new("PaymentsStartRequest", Span::call_site()), Derives::Verify => syn::Ident::new("VerifyRequest", Span::call_site()), - Derives::VerifyData => syn::Ident::new("VerifyRequestData", Span::call_site()), + Derives::SetupMandateData => { + syn::Ident::new("SetupMandateRequestData", Span::call_site()) + } Derives::Session => syn::Ident::new("PaymentsSessionRequest", Span::call_site()), Derives::SessionData => syn::Ident::new("PaymentsSessionData", Span::call_site()), } @@ -336,7 +338,7 @@ pub fn operation_derive_inner(input: DeriveInput) -> syn::Result