Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(connector): adyen connector creates connector's customer reference on the fly fixed (#8447)

sweta-sharma7ad293266060
diff --git a/config/config.example.toml b/config/config.example.toml
index 040e027dcf..08589cbcc6 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -827,7 +827,7 @@ credit = {country = "AU,NZ,CN,HK,IN,LK,KR,MY,SG,GB,BE,FR,DE,IT,ME,NL,PL,ES,ZA,AR
debit = {country = "AU,NZ,CN,HK,IN,LK,KR,MY,SG,GB,BE,FR,DE,IT,ME,NL,PL,ES,ZA,AR,BR,CO,MX,PA,UY,US,CA", currency = "AFN,ALL,DZD,AOA,ARS,AMD,AWG,AUD,AZN,BSD,BHD,BDT,BBD,BYN,BZD,BMD,BTN,BOB,VES,BAM,BWP,BRL,BND,BGN,BIF,KHR,CAD,CVE,KYD,XAF,CLP,CNY,COP,KMF,CDF,CRC,HRK,CUP,CZK,DKK,DJF,DOP,XCD,EGP,ERN,ETB,EUR,FKP,FJD,XPF,GMD,GEL,GHS,GIP,GTQ,GNF,GYD,HTG,HNL,HKD,HUF,ISK,INR,IDR,IRR,IQD,ILS,JMD,JPY,JOD,KZT,KES,KGS,KWD,LAK,LBP,LSL,LRD,LYD,MOP,MKD,MGA,MWK,MYR,MVR,MRU,MUR,MXN,MDL,MNT,MAD,MZN,MMK,NAD,NPR,ANG,NZD,NIO,NGN,VUV,KPW,NOK,OMR,PKR,PAB,PGK,PYG,PEN,PHP,PLN,GBP,QAR,RON,RUB,RWF,SHP,SVC,WST,STN,SAR,RSD,SCR,SLL,SGD,SBD,SOS,ZAR,KRW,SSP,LKR,SDG,SRD,SZL,SEK,CHF,SYP,TWD,TJS,TZS,THB,TOP,TTD,TND,TRY,TMT,UGX,UAH,AED,USD,UYU,UZS,VND,XOF,YER,ZMW,ZWL"}
[connector_customer]
-connector_list = "gocardless,stax,stripe,facilitapay,hyperswitch_vault"
+connector_list = "adyen,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 513cb58717..f4c3e3815d 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -174,7 +174,7 @@ force_cookies = true
enabled = true
[connector_customer]
-connector_list = "gocardless,stax,stripe,facilitapay,hyperswitch_vault"
+connector_list = "adyen,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 4b990ad046..23f5c72e3c 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -15,7 +15,7 @@ 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 = "stax,stripe,gocardless,facilitapay,hyperswitch_vault"
+connector_list = "adyen,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 d00b12c751..e09aa5f88f 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -15,7 +15,7 @@ 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 = "stax,stripe,gocardless,facilitapay,hyperswitch_vault"
+connector_list = "adyen,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 95484d6b01..8107dce388 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -872,7 +872,7 @@ nexixpay = { payment_method = "card" }
redsys = { payment_method = "card" }
[connector_customer]
-connector_list = "gocardless,stax,stripe,facilitapay,hyperswitch_vault"
+connector_list = "adyen,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 b029fb9987..484dd76097 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -883,7 +883,7 @@ card.debit = { connector_list = "cybersource" }
connector_list = "adyen,archipel,cybersource,novalnet,stripe,worldpay"
[connector_customer]
-connector_list = "gocardless,stax,stripe,facilitapay,hyperswitch_vault"
+connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,stripe,wise"
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
index c78daba6c4..504635fe07 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
@@ -1765,29 +1765,31 @@ type RecurringDetails = (Option<AdyenRecurringModel>, Option<bool>, Option<Strin
fn get_recurring_processing_model(
item: &PaymentsAuthorizeRouterData,
) -> Result<RecurringDetails, Error> {
- match (item.request.setup_future_usage, item.request.off_session) {
- (Some(storage_enums::FutureUsage::OffSession), _) => {
+ let shopper_reference = match item.get_connector_customer_id() {
+ Ok(connector_customer_id) => Some(connector_customer_id),
+ Err(_) => {
let customer_id = item.get_customer_id()?;
- let shopper_reference = format!(
+ Some(format!(
"{}_{}",
item.merchant_id.get_string_repr(),
customer_id.get_string_repr()
- );
+ ))
+ }
+ };
+
+ match (item.request.setup_future_usage, item.request.off_session) {
+ (Some(storage_enums::FutureUsage::OffSession), _) => {
let store_payment_method = item.request.is_mandate_payment();
Ok((
Some(AdyenRecurringModel::UnscheduledCardOnFile),
Some(store_payment_method),
- Some(shopper_reference),
+ shopper_reference,
))
}
(_, Some(true)) => Ok((
Some(AdyenRecurringModel::UnscheduledCardOnFile),
None,
- Some(format!(
- "{}_{}",
- item.merchant_id.get_string_repr(),
- item.get_customer_id()?.get_string_repr()
- )),
+ shopper_reference,
)),
_ => Ok((None, None, None)),
}
@@ -1967,17 +1969,18 @@ fn get_social_security_number(voucher_data: &VoucherData) -> Option<Secret<Strin
}
}
-fn build_shopper_reference(
- customer_id: &Option<common_utils::id_type::CustomerId>,
- merchant_id: common_utils::id_type::MerchantId,
-) -> Option<String> {
- customer_id.clone().map(|c_id| {
- format!(
- "{}_{}",
- merchant_id.get_string_repr(),
- c_id.get_string_repr()
- )
- })
+fn build_shopper_reference(item: &PaymentsAuthorizeRouterData) -> Option<String> {
+ match item.get_connector_customer_id() {
+ Ok(connector_customer_id) => Some(connector_customer_id),
+ Err(_) => match item.get_customer_id() {
+ Ok(customer_id) => Some(format!(
+ "{}_{}",
+ item.merchant_id.get_string_repr(),
+ customer_id.get_string_repr()
+ )),
+ Err(_) => None,
+ },
+ }
}
impl TryFrom<(&BankDebitData, &PaymentsAuthorizeRouterData)> for AdyenPaymentMethod<'_> {
@@ -2898,10 +2901,7 @@ impl TryFrom<(&AdyenRouterData<&PaymentsAuthorizeRouterData>, &Card)> for AdyenP
let amount = get_amount_data(item);
let auth_type = AdyenAuthType::try_from(&item.router_data.connector_auth_type)?;
let shopper_interaction = AdyenShopperInteraction::from(item.router_data);
- let shopper_reference = build_shopper_reference(
- &item.router_data.customer_id,
- item.router_data.merchant_id.clone(),
- );
+ let shopper_reference = build_shopper_reference(item.router_data);
let (recurring_processing_model, store_payment_method, _) =
get_recurring_processing_model(item.router_data)?;
let browser_info = get_browser_info(item.router_data)?;
@@ -3506,10 +3506,7 @@ impl
let additional_data = get_additional_data(item.router_data);
let country_code = get_country_code(item.router_data.get_optional_billing());
let shopper_interaction = AdyenShopperInteraction::from(item.router_data);
- let shopper_reference = build_shopper_reference(
- &item.router_data.customer_id,
- item.router_data.merchant_id.clone(),
- );
+ let shopper_reference = build_shopper_reference(item.router_data);
let (recurring_processing_model, store_payment_method, _) =
get_recurring_processing_model(item.router_data)?;
let return_url = item.router_data.request.get_router_return_url()?;
@@ -5822,10 +5819,7 @@ impl
let amount = get_amount_data(item);
let auth_type = AdyenAuthType::try_from(&item.router_data.connector_auth_type)?;
let shopper_interaction = AdyenShopperInteraction::from(item.router_data);
- let shopper_reference = build_shopper_reference(
- &item.router_data.customer_id,
- item.router_data.merchant_id.clone(),
- );
+ let shopper_reference = build_shopper_reference(item.router_data);
let (recurring_processing_model, store_payment_method, _) =
get_recurring_processing_model(item.router_data)?;
let browser_info = get_browser_info(item.router_data)?;
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 5a59523eeb..b82746362d 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -554,7 +554,7 @@ gocardless = { long_lived_token = true, payment_method = "bank_debit" }
billwerk = { long_lived_token = false, payment_method = "card" }
[connector_customer]
-connector_list = "gocardless,stax,stripe,facilitapay,hyperswitch_vault"
+connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,wise"
[dummy_connector]