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(nmi): add support for apple pay mandates (#10241)
Shankar Singh Cb9169ea02207
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex 979a7cbd8f..df7f3bec14 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -217,7 +217,7 @@ bank_debit.sepa = { connector_list = "gocardless,adyen" }card.credit.connector_list = "checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"card.debit.connector_list = "checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"pay_later.klarna.connector_list = "adyen"-wallet.apple_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet"+wallet.apple_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet,nmi"wallet.samsung_pay.connector_list = "cybersource"wallet.google_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet"wallet.paypal.connector_list = "adyen,novalnet"@@ -241,7 +241,7 @@ bank_debit.sepa = { connector_list = "gocardless,adyen,stripe,deutschebank" }card.credit.connector_list = "aci,checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"card.debit.connector_list = "aci,checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"pay_later.klarna.connector_list = "adyen,aci"-wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nexinets,novalnet,nuvei,authorizedotnet,wellsfargo,finix"+wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nexinets,novalnet,nuvei,authorizedotnet,wellsfargo,finix,nmi"wallet.samsung_pay.connector_list = "cybersource"wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica,noon,globalpay,multisafepay,novalnet,nuvei,authorizedotnet,wellsfargo,finix"wallet.paypal.connector_list = "adyen,globalpay,nexinets,novalnet,paypal,authorizedotnet"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 34a47b9816..0ccf1e4ed6 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -217,7 +217,7 @@ bank_debit.sepa = { connector_list = "gocardless,adyen" }card.credit.connector_list = "checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"card.debit.connector_list = "checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"pay_later.klarna.connector_list = "adyen"-wallet.apple_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet"+wallet.apple_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet,nmi"wallet.samsung_pay.connector_list = "cybersource"wallet.google_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet"wallet.paypal.connector_list = "adyen,novalnet"@@ -241,7 +241,7 @@ bank_debit.sepa = { connector_list = "gocardless,adyen,stripe,deutschebank" }card.credit.connector_list = "aci,checkout,stripe,zift,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"card.debit.connector_list = "aci,checkout,stripe,zift,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"pay_later.klarna.connector_list = "adyen,aci"-wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nexinets,novalnet,nuvei,authorizedotnet,wellsfargo,finix"+wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nexinets,novalnet,nuvei,authorizedotnet,wellsfargo,finix,nmi"wallet.samsung_pay.connector_list = "cybersource"wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica,noon,globalpay,multisafepay,novalnet,nuvei,authorizedotnet,wellsfargo,finix"wallet.paypal.connector_list = "adyen,globalpay,nexinets,novalnet,paypal,authorizedotnet"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex 146f5664d9..759f91c277 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -224,7 +224,7 @@ bank_debit.sepa = { connector_list = "gocardless,adyen" }card.credit.connector_list = "checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"card.debit.connector_list = "checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"pay_later.klarna.connector_list = "adyen"-wallet.apple_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet"+wallet.apple_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet,nmi"wallet.samsung_pay.connector_list = "cybersource"wallet.google_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet"wallet.paypal.connector_list = "adyen,novalnet"@@ -248,7 +248,7 @@ bank_debit.sepa = { connector_list = "gocardless,adyen,stripe,deutschebank" }card.credit.connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"card.debit.connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"pay_later.klarna.connector_list = "adyen,aci"-wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nexinets,novalnet,nuvei,authorizedotnet,wellsfargo,worldpayvantiv,finix"+wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nexinets,novalnet,nuvei,authorizedotnet,wellsfargo,worldpayvantiv,finix,nmi"wallet.samsung_pay.connector_list = "cybersource"wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica,noon,globalpay,multisafepay,novalnet,nuvei,authorizedotnet,wellsfargo,worldpayvantiv,finix"wallet.paypal.connector_list = "adyen,globalpay,nexinets,novalnet,paypal,authorizedotnet"diff --git a/config/development.toml b/config/development.tomlindex 1e8f947598..47940ff252 100644--- a/config/development.toml+++ b/config/development.toml@@ -1123,7 +1123,7 @@ bank_debit.sepa = { connector_list = "gocardless,adyen,stripe,deutschebank" }card.credit.connector_list = "aci,checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"card.debit.connector_list = "aci,checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"pay_later.klarna.connector_list = "adyen,aci"-wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nuvei,nexinets,novalnet,authorizedotnet,wellsfargo,worldpayvantiv,finix"+wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nuvei,nexinets,novalnet,authorizedotnet,wellsfargo,worldpayvantiv,finix,nmi"wallet.samsung_pay.connector_list = "cybersource"wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica,noon,globalpay,multisafepay,novalnet,nuvei,authorizedotnet,wellsfargo,worldpayvantiv,finix"wallet.paypal.connector_list = "adyen,globalpay,nexinets,novalnet,paypal,authorizedotnet"diff --git a/crates/hyperswitch_connectors/src/connectors/nmi.rs b/crates/hyperswitch_connectors/src/connectors/nmi.rsindex 65fb134df0..73826e4f65 100644--- a/crates/hyperswitch_connectors/src/connectors/nmi.rs+++ b/crates/hyperswitch_connectors/src/connectors/nmi.rs@@ -156,8 +156,10 @@ impl ConnectorValidation for Nmi {pm_type: Option<enums::PaymentMethodType>,pm_data: hyperswitch_domain_models::payment_method_data::PaymentMethodData,) -> CustomResult<(), ConnectorError> {- let mandate_supported_pmd =- std::collections::HashSet::from([utils::PaymentMethodDataType::Card]);+ let mandate_supported_pmd = std::collections::HashSet::from([+ utils::PaymentMethodDataType::Card,+ utils::PaymentMethodDataType::ApplePay,+ ]);utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())}}@@ -1076,7 +1078,7 @@ static NMI_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLoenums::PaymentMethod::Wallet,enums::PaymentMethodType::ApplePay,PaymentMethodDetails {- mandates: enums::FeatureStatus::NotSupported,+ mandates: enums::FeatureStatus::Supported,refunds: enums::FeatureStatus::Supported,supported_capture_methods,specific_features: None,diff --git a/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rsindex 4840eb701a..868de256a8 100644--- a/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs@@ -424,13 +424,18 @@ pub struct NmiValidateRequest {#[serde(rename = "type")]transaction_type: TransactionType,security_key: Secret<String>,- ccnumber: CardNumber,- ccexp: Secret<String>,- cvv: Secret<String>,+ #[serde(flatten)]+ payment_data: NmiValidatePaymentData,orderid: String,customer_vault: CustomerAction,}+#[derive(Debug, Serialize)]+pub enum NmiValidatePaymentData {+ ApplePay(Box<ApplePayData>),+ Card(Box<CardData>),+}+#[derive(Debug, Serialize)]pub struct NmiPaymentsRequest {#[serde(rename = "type")]@@ -767,13 +772,49 @@ impl TryFrom<&SetupMandateRouterData> for NmiValidateRequest {_ => {if let PaymentMethodData::Card(card_details) = &item.request.payment_method_data {let auth_type: NmiAuthType = (&item.connector_auth_type).try_into()?;- Ok(Self {- transaction_type: TransactionType::Validate,- security_key: auth_type.api_key,++ let card_data = CardData {ccnumber: card_details.card_number.clone(),ccexp: card_details.get_card_expiry_month_year_2_digit_with_delimiter("".to_string())?,cvv: card_details.card_cvc.clone(),+ };+ Ok(Self {+ transaction_type: TransactionType::Validate,+ security_key: auth_type.api_key,+ payment_data: NmiValidatePaymentData::Card(Box::new(card_data)),+ orderid: item.connector_request_reference_id.clone(),+ customer_vault: CustomerAction::AddCustomer,+ })+ } else if let PaymentMethodData::Wallet(WalletData::ApplePay(+ apple_pay_wallet_data,+ )) = &item.request.payment_method_data+ {+ let auth_type: NmiAuthType = (&item.connector_auth_type).try_into()?;++ let apple_pay_encrypted_data = apple_pay_wallet_data+ .payment_data+ .get_encrypted_apple_pay_payment_data_mandatory()+ .change_context(ConnectorError::MissingRequiredField {+ field_name: "Apple pay encrypted data",+ })?;++ let base64_decoded_apple_pay_data = base64::prelude::BASE64_STANDARD+ .decode(apple_pay_encrypted_data)+ .change_context(ConnectorError::InvalidDataFormat {+ field_name: "apple_pay_encrypted_data",+ })?;++ let hex_encoded_apple_pay_data = hex::encode(base64_decoded_apple_pay_data);++ let apple_pay_data = ApplePayData {+ applepay_payment_data: Secret::new(hex_encoded_apple_pay_data),+ };++ Ok(Self {+ transaction_type: TransactionType::Validate,+ security_key: auth_type.api_key,+ payment_data: NmiValidatePaymentData::ApplePay(Box::new(apple_pay_data)),orderid: item.connector_request_reference_id.clone(),customer_vault: CustomerAction::AddCustomer,})