diff --git a/config/config.example.toml b/config/config.example.toml index 57c3a6a378..ac17722def 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -952,7 +952,6 @@ apple_pay = { country = "US,CA,IL,GB", currency = "ILS,USD,EUR" } apple_pay = {country = "AF,AX,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BT,BO,BQ,BA,BW,BV,BR,IO,BN,BG,BF,BI,KH,CM,CA,CV,KY,CF,TD,CL,CN,CX,CC,CO,KM,CG,CD,CK,CR,CI,HR,CU,CW,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,GF,PF,TF,GA,GM,GE,DE,GH,GI,GR,GL,GD,GP,GU,GT,GG,GN,GW,GY,HT,HM,HN,HK,HU,IS,IN,ID,IR,IQ,IE,IM,IL,IT,JM,JP,JE,JO,KZ,KE,KI,KP,KR,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,MX,FM,MD,MC,MN,ME,MS,MA,MZ,MM,NA,NR,NP,NC,NZ,NI,NE,NG,NU,NF,MP,NO,OM,PK,PW,PS,PA,PG,PY,PE,PH,PN,PL,PT,PR,QA,RE,RO,RU,RW,BL,SH,KN,LC,MF,VC,WS,SM,ST,SA,SN,RS,SC,SL,SG,SX,SK,SI,SB,SO,ZA,GS,SS,ES,LK,PM,SD,SR,SJ,SZ,SE,CH,SY,TW,TJ,TZ,TH,NL,TL,TG,TK,TO,TT,TN,TR,TM,TC,TV,UG,UA,AE,GB,US,UM,UY,UZ,VU,VA,VE,VN,VG,VI,WF,EH,YE,ZM,ZW", currency = "ARS,AUD,AZN,BHD,BOB,BAM,BRL,BGN,CAD,CLP,CNY,COP,CRC,HRK,CZK,DKK,DOP,XCD,EGP,ETB,EUR,FJD,GEL,GTQ,HTG,HNL,HKD,HUF,INR,IDR,JMD,JPY,JOD,KZT,KES,KRW,KWD,LBP,LYD,MWK,MUR,MXN,MDL,MAD,ILS,NZD,NGN,NOK,OMR,PKR,PAB,PYG,PEN,PHP,PLN,GBP,QAR,RON,RUB,RWF,SAR,RSD,SGD,ZAR,LKR,SEK,CHF,SYP,TWD,THB,TTD,TND,TRY,UAH,AED,UYU,USD,VND" } [connector_customer] -connector_list = "authorizedotnet,dwolla,facilitapay,gocardless,hyperswitch_vault,stax,stripe" payout_connector_list = "nomupay,stripe,wise" [bank_config.online_banking_fpx] diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 1f12befea6..2976a3da1a 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -201,7 +201,6 @@ force_cookies = true enabled = true [connector_customer] -connector_list = "authorizedotnet,dwolla,facilitapay,gocardless,hyperswitch_vault,stax,stripe" payout_connector_list = "nomupay,stripe,wise" [delayed_session_response] diff --git a/config/deployments/production.toml b/config/deployments/production.toml index 2393a9d9e0..7d3aeff7ed 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -15,7 +15,6 @@ open_banking_uk.adyen.banks = "aib,bank_of_scotland,danske_bank,first_direct,fir przelewy24.stripe.banks = "alior_bank,bank_millennium,bank_nowy_bfg_sa,bank_pekao_sa,banki_spbdzielcze,blik,bnp_paribas,boz,citi,credit_agricole,e_transfer_pocztowy24,getin_bank,idea_bank,inteligo,mbank_mtransfer,nest_przelew,noble_pay,pbac_z_ipko,plus_bank,santander_przelew24,toyota_bank,volkswagen_bank" [connector_customer] -connector_list = "authorizedotnet,dwolla,facilitapay,gocardless,hyperswitch_vault,stax,stripe" payout_connector_list = "nomupay,stripe,wise" # Connector configuration, provided attributes will be used to fulfill API requests. diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index a3baebc0ae..6ea4ee0cf1 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -15,7 +15,6 @@ open_banking_uk.adyen.banks = "aib,bank_of_scotland,danske_bank,first_direct,fir przelewy24.stripe.banks = "alior_bank,bank_millennium,bank_nowy_bfg_sa,bank_pekao_sa,banki_spbdzielcze,blik,bnp_paribas,boz,citi,credit_agricole,e_transfer_pocztowy24,getin_bank,idea_bank,inteligo,mbank_mtransfer,nest_przelew,noble_pay,pbac_z_ipko,plus_bank,santander_przelew24,toyota_bank,volkswagen_bank" [connector_customer] -connector_list = "authorizedotnet,dwolla,facilitapay,gocardless,hyperswitch_vault,stax,stripe" payout_connector_list = "nomupay,stripe,wise" # Connector configuration, provided attributes will be used to fulfill API requests. diff --git a/config/development.toml b/config/development.toml index 6b53c46e05..29d2e8695b 100644 --- a/config/development.toml +++ b/config/development.toml @@ -1026,7 +1026,6 @@ nexixpay = { payment_method = "card" } redsys = { payment_method = "card" } [connector_customer] -connector_list = "authorizedotnet,dwolla,facilitapay,gocardless,hyperswitch_vault,stax,stripe" payout_connector_list = "nomupay,stripe,wise" [dummy_connector] diff --git a/config/docker_compose.toml b/config/docker_compose.toml index 93bef2e3ef..c9a6cf6532 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -1037,7 +1037,6 @@ card.debit = { connector_list = "cybersource" } connector_list = "adyen,archipel,checkout,cybersource,novalnet,stripe,worldpay,worldpayvantiv" [connector_customer] -connector_list = "authorizedotnet,dwolla,facilitapay,gocardless,hyperswitch_vault,stax,stripe" payout_connector_list = "nomupay,stripe,wise" diff --git a/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs b/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs index 7105bf0b0d..85d982cb84 100644 --- a/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs +++ b/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs @@ -1301,4 +1301,11 @@ impl ConnectorSpecifications for Authorizedotnet { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { Some(&AUTHORIZEDOTNET_SUPPORTED_WEBHOOK_FLOWS) } + + fn should_call_connector_customer( + &self, + _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + true + } } diff --git a/crates/hyperswitch_connectors/src/connectors/dwolla.rs b/crates/hyperswitch_connectors/src/connectors/dwolla.rs index 001436b779..3b52832d2f 100644 --- a/crates/hyperswitch_connectors/src/connectors/dwolla.rs +++ b/crates/hyperswitch_connectors/src/connectors/dwolla.rs @@ -1002,4 +1002,11 @@ impl ConnectorSpecifications for Dwolla { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { Some(&DWOLLA_SUPPORTED_WEBHOOK_FLOWS) } + + fn should_call_connector_customer( + &self, + _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + true + } } diff --git a/crates/hyperswitch_connectors/src/connectors/facilitapay.rs b/crates/hyperswitch_connectors/src/connectors/facilitapay.rs index 19f4c87856..d9df449dc7 100644 --- a/crates/hyperswitch_connectors/src/connectors/facilitapay.rs +++ b/crates/hyperswitch_connectors/src/connectors/facilitapay.rs @@ -961,4 +961,11 @@ impl ConnectorSpecifications for Facilitapay { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { Some(&*FACILITAPAY_SUPPORTED_WEBHOOK_FLOWS) } + + fn should_call_connector_customer( + &self, + _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + true + } } diff --git a/crates/hyperswitch_connectors/src/connectors/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rs index b94ba5b278..2105af7bab 100644 --- a/crates/hyperswitch_connectors/src/connectors/gocardless.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs @@ -947,4 +947,11 @@ impl ConnectorSpecifications for Gocardless { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { Some(&GOCARDLESS_SUPPORTED_WEBHOOK_FLOWS) } + + fn should_call_connector_customer( + &self, + _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + true + } } diff --git a/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs b/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs index 6fd91612fa..f8aa7fdd20 100644 --- a/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs +++ b/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs @@ -489,4 +489,11 @@ impl webhooks::IncomingWebhook for HyperswitchVault { } } -impl ConnectorSpecifications for HyperswitchVault {} +impl ConnectorSpecifications for HyperswitchVault { + fn should_call_connector_customer( + &self, + _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + true + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/stax.rs b/crates/hyperswitch_connectors/src/connectors/stax.rs index b9e3d56db4..d4f906bf01 100644 --- a/crates/hyperswitch_connectors/src/connectors/stax.rs +++ b/crates/hyperswitch_connectors/src/connectors/stax.rs @@ -1021,4 +1021,11 @@ impl ConnectorSpecifications for Stax { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { Some(&STAX_SUPPORTED_WEBHOOK_FLOWS) } + + fn should_call_connector_customer( + &self, + _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + true + } } diff --git a/crates/hyperswitch_connectors/src/connectors/stripe.rs b/crates/hyperswitch_connectors/src/connectors/stripe.rs index ce144a410f..f584660066 100644 --- a/crates/hyperswitch_connectors/src/connectors/stripe.rs +++ b/crates/hyperswitch_connectors/src/connectors/stripe.rs @@ -3301,4 +3301,11 @@ impl ConnectorSpecifications for Stripe { fn get_supported_webhook_flows(&self) -> Option<&'static [common_enums::EventClass]> { Some(&STRIPE_SUPPORTED_WEBHOOK_FLOWS) } + + fn should_call_connector_customer( + &self, + _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + true + } } diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index b71f20ec55..f8a813c7ea 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -401,6 +401,15 @@ pub trait ConnectorSpecifications { false } + /// Check if connector should make another request to create an customer + /// Connectors should override this method if they require to create a connector customer + fn should_call_connector_customer( + &self, + _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + false + } + #[cfg(not(feature = "v2"))] /// Generate connector request reference ID fn generate_connector_request_reference_id( diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs index 66a1e29175..47ead156e2 100644 --- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs +++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs @@ -564,6 +564,17 @@ impl ConnectorSpecifications for ConnectorEnum { } } } + + /// Check if connector requires create customer call + fn should_call_connector_customer( + &self, + payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, + ) -> bool { + match self { + Self::Old(connector) => connector.should_call_connector_customer(payment_attempt), + Self::New(connector) => connector.should_call_connector_customer(payment_attempt), + } + } } impl ConnectorCommon for ConnectorEnum { diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs index d504cce40f..6a7bf22547 100644 --- a/crates/router/src/configs/settings.rs +++ b/crates/router/src/configs/settings.rs @@ -534,8 +534,6 @@ pub struct TempLockerEnableConfig(pub HashMap, #[cfg(feature = "payouts")] #[serde(deserialize_with = "deserialize_hashset")] pub payout_connector_list: HashSet, diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index a96c0a6028..72cf0b80bd 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -6434,7 +6434,10 @@ where let (should_call_connector, existing_connector_customer_id) = customers::should_call_connector_create_customer( - state, &connector, customer, &label, + &connector, + customer, + payment_data.get_payment_attempt(), + &label, ); if should_call_connector { @@ -6512,9 +6515,9 @@ where let (should_call_connector, existing_connector_customer_id) = customers::should_call_connector_create_customer( - state, &connector, customer, + payment_data.get_payment_attempt(), merchant_connector_account, ); diff --git a/crates/router/src/core/payments/customers.rs b/crates/router/src/core/payments/customers.rs index f3926365cb..08e3195559 100644 --- a/crates/router/src/core/payments/customers.rs +++ b/crates/router/src/core/payments/customers.rs @@ -1,4 +1,5 @@ use common_utils::pii; +use hyperswitch_interfaces::api::ConnectorSpecifications; use masking::ExposeOptionInterface; use router_env::{instrument, tracing}; @@ -76,17 +77,15 @@ pub async fn create_connector_customer( #[cfg(feature = "v1")] pub fn should_call_connector_create_customer<'a>( - state: &SessionState, connector: &api::ConnectorData, customer: &'a Option, + payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, connector_label: &str, ) -> (bool, Option<&'a str>) { // Check if create customer is required for the connector - let connector_needs_customer = state - .conf - .connector_customer - .connector_list - .contains(&connector.connector_name); + let connector_needs_customer = connector + .connector + .should_call_connector_customer(payment_attempt); let connector_customer_details = customer .as_ref() .and_then(|customer| customer.get_connector_customer_id(connector_label)); @@ -102,19 +101,17 @@ pub fn should_call_connector_create_customer<'a>( #[cfg(feature = "v2")] pub fn should_call_connector_create_customer<'a>( - state: &SessionState, connector: &api::ConnectorData, customer: &'a Option, + payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, merchant_connector_account: &domain::MerchantConnectorAccountTypeDetails, ) -> (bool, Option<&'a str>) { // Check if create customer is required for the connector match merchant_connector_account { domain::MerchantConnectorAccountTypeDetails::MerchantConnectorAccount(_) => { - let connector_needs_customer = state - .conf - .connector_customer - .connector_list - .contains(&connector.connector_name); + let connector_needs_customer = connector + .connector + .should_call_connector_customer(payment_attempt); if connector_needs_customer { let connector_customer_details = customer diff --git a/crates/router/src/core/payments/vault_session.rs b/crates/router/src/core/payments/vault_session.rs index 228b72bd9a..4b5912e90b 100644 --- a/crates/router/src/core/payments/vault_session.rs +++ b/crates/router/src/core/payments/vault_session.rs @@ -165,9 +165,9 @@ where let (should_call_connector, existing_connector_customer_id) = customers::should_call_connector_create_customer( - state, &connector, customer, + payment_data.get_payment_attempt(), merchant_connector_account_type, ); diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 93d4f00e01..014f2fffb5 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -701,7 +701,6 @@ globalpay = { long_lived_token = false, payment_method = "card", flow = "mandate dwolla = { long_lived_token = true, payment_method = "bank_debit" } [connector_customer] -connector_list = "authorizedotnet,dwolla,facilitapay,gocardless,hyperswitch_vault,stax,stripe" payout_connector_list = "nomupay,wise" [dummy_connector]