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(connectors): [Adyen] Make shopper_reference optional for on_session payments (#10520)

Anurag Thakurb8b57395f229
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
index e6763edce7..a903d5d81d 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
@@ -2011,23 +2011,32 @@ fn get_shopper_statement(item: &PaymentsAuthorizeRouterData) -> Option<String> {
fn get_recurring_processing_model(
item: &PaymentsAuthorizeRouterData,
) -> Result<RecurringDetails, Error> {
- let shopper_reference = item.get_connector_customer_id()?;
+ let shopper_reference = item.get_connector_customer_id().ok();
match (item.request.setup_future_usage, item.request.off_session) {
+ // Setup for future off-session usage
(Some(storage_enums::FutureUsage::OffSession), _) => {
let store_payment_method = item.request.is_mandate_payment();
+ let shopper_reference =
+ shopper_reference.ok_or_else(missing_field_err("connector_customer_id"))?;
Ok((
Some(AdyenRecurringModel::UnscheduledCardOnFile),
Some(store_payment_method),
Some(shopper_reference),
))
}
- (_, Some(true)) => Ok((
- Some(AdyenRecurringModel::UnscheduledCardOnFile),
- None,
- Some(shopper_reference),
- )),
- _ => Ok((None, None, None)),
+ // Off-session payment
+ (_, Some(true)) => {
+ let shopper_reference =
+ shopper_reference.ok_or_else(missing_field_err("connector_customer_id"))?;
+ Ok((
+ Some(AdyenRecurringModel::UnscheduledCardOnFile),
+ None,
+ Some(shopper_reference),
+ ))
+ }
+ // On-session payment
+ _ => Ok((None, None, shopper_reference)),
}
}
@@ -3186,8 +3195,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 = item.router_data.get_connector_customer_id().ok();
- let (recurring_processing_model, store_payment_method, _) =
+ let (recurring_processing_model, store_payment_method, shopper_reference) =
get_recurring_processing_model(item.router_data)?;
let browser_info = get_browser_info(item.router_data)?;
let billing_address =
@@ -3956,8 +3964,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 = item.router_data.get_connector_customer_id().ok();
- let (recurring_processing_model, store_payment_method, _) =
+ let (recurring_processing_model, store_payment_method, shopper_reference) =
get_recurring_processing_model(item.router_data)?;
let return_url = item.router_data.request.get_router_return_url()?;
let shopper_name = get_shopper_name(item.router_data.get_optional_billing());
@@ -6580,8 +6587,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 = item.router_data.get_connector_customer_id().ok();
- let (recurring_processing_model, store_payment_method, _) =
+ let (recurring_processing_model, store_payment_method, shopper_reference) =
get_recurring_processing_model(item.router_data)?;
let browser_info = get_browser_info(item.router_data)?;
let billing_address =