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(connector): add apple pay decrypt support for Adyen (#8605)
Shankar Singh C064113a4c96c
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex cdf94d6e43..77fb8141c0 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -286,7 +286,7 @@ label="Payment Processing Details At"placeholder="Enter Payment Processing Details At"required=truetype="Radio"-options=["Connector"]+options=["Connector", "Hyperswitch"][[adyen.metadata.google_pay]]name="merchant_name"diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.tomlindex b9a98f5aed..cf9c19fcab 100644--- a/crates/connector_configs/toml/production.toml+++ b/crates/connector_configs/toml/production.toml@@ -192,7 +192,7 @@ label="Payment Processing Details At"placeholder="Enter Payment Processing Details At"required=truetype="Radio"-options=["Connector"]+options=["Connector", "Hyperswitch"][[adyen.metadata.google_pay]]name="merchant_name"diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex 21801d380b..28aca80b17 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -284,7 +284,7 @@ label="Payment Processing Details At"placeholder="Enter Payment Processing Details At"required=truetype="Radio"-options=["Connector"]+options=["Connector", "Hyperswitch"][[adyen.metadata.google_pay]]name="merchant_name"diff --git a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rsindex 241d1d6ccc..bafbc7920a 100644--- a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs@@ -57,9 +57,10 @@ use crate::{SubmitEvidenceRouterData,},utils::{- self, is_manual_capture, missing_field_err, AddressDetailsData, BrowserInformationData,- CardData, ForeignTryFrom, NetworkTokenData as UtilsNetworkTokenData,- PaymentsAuthorizeRequestData, PhoneDetailsData, RouterData as OtherRouterData,+ self, is_manual_capture, missing_field_err, AddressDetailsData, ApplePayDecrypt,+ BrowserInformationData, CardData, ForeignTryFrom,+ NetworkTokenData as UtilsNetworkTokenData, PaymentsAuthorizeRequestData, PhoneDetailsData,+ RouterData as OtherRouterData,},};@@ -309,7 +310,8 @@ struct AdyenSplitData {struct AdyenMpiData {directory_response: String,authentication_response: String,- token_authentication_verification_value: Secret<String>,+ cavv: Option<Secret<String>>,+ token_authentication_verification_value: Option<Secret<String>>,eci: Option<String>,}@@ -675,6 +677,7 @@ pub enum AdyenPaymentMethod<'a> {#[serde(rename = "alipay_hk")]AliPayHk,ApplePay(Box<AdyenApplePay>),+ ApplePayDecrypt(Box<AdyenApplePayDecryptData>),Atome,#[serde(rename = "scheme")]BancontactCard(Box<AdyenCard>),@@ -1253,6 +1256,18 @@ pub struct AdyenPazeData {network_payment_reference: Option<Secret<String>>,}+#[serde_with::skip_serializing_none]+#[derive(Debug, Clone, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct AdyenApplePayDecryptData {+ number: Secret<String>,+ expiry_month: Secret<String>,+ expiry_year: Secret<String>,+ brand: String,+ #[serde(rename = "type")]+ payment_type: PaymentType,+}+#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "lowercase")]pub enum CardBrand {@@ -2194,11 +2209,27 @@ impl TryFrom<(&WalletData, &PaymentsAuthorizeRouterData)> for AdyenPaymentMethodOk(AdyenPaymentMethod::Gpay(Box::new(gpay_data)))}WalletData::ApplePay(data) => {- let apple_pay_data = AdyenApplePay {- apple_pay_token: Secret::new(data.payment_data.to_string()),- };-- Ok(AdyenPaymentMethod::ApplePay(Box::new(apple_pay_data)))+ if let Some(PaymentMethodToken::ApplePayDecrypt(apple_pay_decrypte)) =+ item.payment_method_token.clone()+ {+ let expiry_year_4_digit = apple_pay_decrypte.get_four_digit_expiry_year()?;+ let exp_month = apple_pay_decrypte.get_expiry_month()?;+ let apple_pay_decrypted_data = AdyenApplePayDecryptData {+ number: apple_pay_decrypte.application_primary_account_number,+ expiry_month: exp_month,+ expiry_year: expiry_year_4_digit,+ brand: "applepay".to_string(),+ payment_type: PaymentType::Scheme,+ };+ Ok(AdyenPaymentMethod::ApplePayDecrypt(Box::new(+ apple_pay_decrypted_data,+ )))+ } else {+ let apple_pay_data = AdyenApplePay {+ apple_pay_token: Secret::new(data.payment_data.to_string()),+ };+ Ok(AdyenPaymentMethod::ApplePay(Box::new(apple_pay_data)))+ }}WalletData::PaypalRedirect(_) => Ok(AdyenPaymentMethod::AdyenPaypal),WalletData::AliPayRedirect(_) => Ok(AdyenPaymentMethod::AliPay),@@ -3428,15 +3459,23 @@ impl TryFrom<(&AdyenRouterData<&PaymentsAuthorizeRouterData>, &WalletData)>let shopper_email = get_shopper_email(item.router_data, store_payment_method.is_some())?;let billing_address =get_address_info(item.router_data.get_optional_billing()).and_then(Result::ok);- let mpi_data = if let WalletData::Paze(_) = wallet_data {+ let mpi_data = if matches!(wallet_data, WalletData::Paze(_) | WalletData::ApplePay(_)) {match item.router_data.payment_method_token.clone() {- Some(PaymentMethodToken::PazeDecrypt(paze_decrypted_data)) => Some(AdyenMpiData {+ Some(PaymentMethodToken::PazeDecrypt(paze_data)) => Some(AdyenMpiData {directory_response: "Y".to_string(),authentication_response: "Y".to_string(),- token_authentication_verification_value: paze_decrypted_data- .token- .payment_account_reference,- eci: paze_decrypted_data.eci,+ cavv: None,+ token_authentication_verification_value: Some(+ paze_data.token.payment_account_reference,+ ),+ eci: paze_data.eci,+ }),+ Some(PaymentMethodToken::ApplePayDecrypt(apple_data)) => Some(AdyenMpiData {+ directory_response: "Y".to_string(),+ authentication_response: "Y".to_string(),+ cavv: Some(apple_data.payment_data.online_payment_cryptogram),+ token_authentication_verification_value: None,+ eci: apple_data.payment_data.eci_indicator,}),_ => None,}@@ -5854,10 +5893,10 @@ impllet mpi_data = AdyenMpiData {directory_response: "Y".to_string(),authentication_response: "Y".to_string(),- token_authentication_verification_value: token_data- .get_cryptogram()- .clone()- .unwrap_or_default(),+ cavv: None,+ token_authentication_verification_value: Some(+ token_data.get_cryptogram().clone().unwrap_or_default(),+ ),eci: Some("02".to_string()),};let (store, splits) = match item.router_data.request.split_payments.as_ref() {