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): [checkout] Add NTID flow (#9449)
Vani Guptad692928080d7
diff --git a/config/config.example.toml b/config/config.example.tomlindex ea27effe83..499dd8e806 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -1180,7 +1180,7 @@ webhook_source_verification_key= "" # webhook source verification key to verifyconnector_list = "adyen,cybersource" # Supported connectors for network tokenization[network_transaction_id_supported_connectors]-connector_list = "adyen,archipel,cybersource,novalnet,stripe,worldpay,worldpayvantiv" # Supported connectors for network transaction id+connector_list = "adyen,archipel,checkout,cybersource,novalnet,stripe,worldpay,worldpayvantiv" # Supported connectors for network transaction id[grpc_client.dynamic_routing_client] # Dynamic Routing Client Configurationhost = "localhost" # Client Hostdiff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex c381bc0596..3f2586eeeb 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -262,7 +262,7 @@ card.credit = { connector_list = "cybersource" } # Update Mandate supcard.debit = { connector_list = "cybersource" } # Update Mandate supported payment method type and connector for card[network_transaction_id_supported_connectors]-connector_list = "adyen,archipel,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"+connector_list = "adyen,archipel,checkout,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"[payouts]diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 34bfffa8f3..5f157f4de0 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -262,7 +262,7 @@ card.credit = { connector_list = "cybersource" } # Update Mandate supcard.debit = { connector_list = "cybersource" } # Update Mandate supported payment method type and connector for card[network_transaction_id_supported_connectors]-connector_list = "adyen,archipel,stripe,nuvei,worldpayvantiv"+connector_list = "adyen,archipel,checkout,stripe,nuvei,worldpayvantiv"[payouts]payout_eligibility = true # Defaults the eligibility of a payout method to true in case connector does not provide checks for payout eligibilitydiff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex a13157b860..74e5ea0e39 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -269,7 +269,7 @@ card.credit = { connector_list = "cybersource" } # Update Mandate supcard.debit = { connector_list = "cybersource" } # Update Mandate supported payment method type and connector for card[network_transaction_id_supported_connectors]-connector_list = "adyen,archipel,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"+connector_list = "adyen,archipel,checkout,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"[payouts]diff --git a/config/development.toml b/config/development.tomlindex b05755409e..7a8ff3048a 100644--- a/config/development.toml+++ b/config/development.toml@@ -1112,7 +1112,7 @@ card.credit = { connector_list = "cybersource" }card.debit = { connector_list = "cybersource" }[network_transaction_id_supported_connectors]-connector_list = "adyen,archipel,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"+connector_list = "adyen,archipel,checkout,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"[connector_request_reference_id_config]merchant_ids_send_payment_id_as_connector_request_id = []diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 896f3eeba6..9d70cc9d61 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -1027,7 +1027,7 @@ card.credit = { connector_list = "cybersource" }card.debit = { connector_list = "cybersource" }[network_transaction_id_supported_connectors]-connector_list = "adyen,archipel,cybersource,novalnet,stripe,worldpay,worldpayvantiv"+connector_list = "adyen,archipel,checkout,cybersource,novalnet,stripe,worldpay,worldpayvantiv"[connector_customer]connector_list = "authorizedotnet,dwolla,facilitapay,gocardless,hyperswitch_vault,stax,stripe"diff --git a/crates/hyperswitch_connectors/src/connectors/checkout.rs b/crates/hyperswitch_connectors/src/connectors/checkout.rsindex 6b8b2b92d5..53f3887429 100644--- a/crates/hyperswitch_connectors/src/connectors/checkout.rs+++ b/crates/hyperswitch_connectors/src/connectors/checkout.rs@@ -203,7 +203,10 @@ impl ConnectorValidation for Checkout {pm_type: Option<enums::PaymentMethodType>,pm_data: PaymentMethodData,) -> CustomResult<(), errors::ConnectorError> {- let mandate_supported_pmd = std::collections::HashSet::from([PaymentMethodDataType::Card]);+ let mandate_supported_pmd = std::collections::HashSet::from([+ PaymentMethodDataType::Card,+ PaymentMethodDataType::NetworkTransactionIdAndCardDetails,+ ]);is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())}fn validate_connector_against_payment_request(diff --git a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rsindex 8ebe17a2ac..42ff1d537d 100644--- a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs@@ -206,7 +206,7 @@ pub struct CardSource {pub number: cards::CardNumber,pub expiry_month: Secret<String>,pub expiry_year: Secret<String>,- pub cvv: Secret<String>,+ pub cvv: Option<Secret<String>>,}#[derive(Debug, Serialize)]@@ -256,8 +256,8 @@ pub enum CheckoutSourceTypes {#[derive(Debug, Serialize)]pub enum CheckoutPaymentType {- Recurring,Regular,+ Unscheduled,#[serde(rename = "MOTO")]Moto,}@@ -338,7 +338,7 @@ pub struct PaymentsRequest {pub payment_type: CheckoutPaymentType,pub merchant_initiated: Option<bool>,pub previous_payment_id: Option<String>,-+ pub store_for_future_use: Option<bool>,// Level 2/3 data fieldspub customer: Option<CheckoutCustomer>,pub processing: Option<CheckoutProcessing>,@@ -407,92 +407,62 @@ impl TryFrom<&CheckoutRouterData<&PaymentsAuthorizeRouterData>> for PaymentsRequSome(enums::CaptureMethod::Automatic));- let (payment_type, challenge_indicator) = if item.router_data.request.payment_channel- == Some(PaymentChannel::MailOrder)- || item.router_data.request.payment_channel == Some(PaymentChannel::TelephoneOrder)- {- (- CheckoutPaymentType::Moto,- CheckoutChallengeIndicator::ChallengeRequested,- )+ let payment_type = if matches!(+ item.router_data.request.payment_channel,+ Some(PaymentChannel::MailOrder | PaymentChannel::TelephoneOrder)+ ) {+ CheckoutPaymentType::Moto} else if item.router_data.request.is_mandate_payment() {- (- CheckoutPaymentType::Recurring,- CheckoutChallengeIndicator::ChallengeRequestedMandate,- )+ CheckoutPaymentType::Unscheduled} else {- (- CheckoutPaymentType::Regular,- CheckoutChallengeIndicator::ChallengeRequested,- )+ CheckoutPaymentType::Regular};- let (source_var, previous_payment_id, merchant_initiated, payment_type) =- match item.router_data.request.payment_method_data.clone() {- PaymentMethodData::Card(ccard) => {- let a = PaymentSource::Card(CardSource {- source_type: CheckoutSourceTypes::Card,- number: ccard.card_number.clone(),- expiry_month: ccard.card_exp_month.clone(),- expiry_year: ccard.card_exp_year.clone(),- cvv: ccard.card_cvc,- });- Ok((a, None, Some(false), payment_type))- }- PaymentMethodData::Wallet(wallet_data) => match wallet_data {- WalletData::GooglePay(_) => {- let p_source = PaymentSource::Wallets(WalletSource {- source_type: CheckoutSourceTypes::Token,- token: match item.router_data.get_payment_method_token()? {- PaymentMethodToken::Token(token) => token,- PaymentMethodToken::ApplePayDecrypt(_) => {- Err(unimplemented_payment_method!(- "Apple Pay",- "Simplified",- "Checkout"- ))?- }- PaymentMethodToken::PazeDecrypt(_) => {- Err(unimplemented_payment_method!("Paze", "Checkout"))?- }- PaymentMethodToken::GooglePayDecrypt(_) => {- Err(unimplemented_payment_method!("Google Pay", "Checkout"))?- }- },- });- Ok((p_source, None, Some(false), payment_type))- }- WalletData::ApplePay(_) => {- let payment_method_token = item.router_data.get_payment_method_token()?;- match payment_method_token {- PaymentMethodToken::Token(apple_pay_payment_token) => {- let p_source = PaymentSource::Wallets(WalletSource {- source_type: CheckoutSourceTypes::Token,- token: apple_pay_payment_token,- });- Ok((p_source, None, Some(false), payment_type))- }- PaymentMethodToken::ApplePayDecrypt(decrypt_data) => {- let exp_month = decrypt_data.get_expiry_month().change_context(- errors::ConnectorError::InvalidDataFormat {- field_name: "expiration_month",- },- )?;- let expiry_year_4_digit = decrypt_data.get_four_digit_expiry_year();- let p_source = PaymentSource::ApplePayPredecrypt(Box::new(- ApplePayPredecrypt {- token: decrypt_data.application_primary_account_number,- decrypt_type: "network_token".to_string(),- token_type: "applepay".to_string(),- expiry_month: exp_month,- expiry_year: expiry_year_4_digit,- eci: decrypt_data.payment_data.eci_indicator,- cryptogram: decrypt_data- .payment_data- .online_payment_cryptogram,- },- ));- Ok((p_source, None, Some(false), payment_type))+ let (challenge_indicator, store_for_future_use) =+ if item.router_data.request.is_mandate_payment() {+ (+ CheckoutChallengeIndicator::ChallengeRequestedMandate,+ Some(true),+ )+ } else {+ (CheckoutChallengeIndicator::ChallengeRequested, None)+ };++ let (+ source_var,+ previous_payment_id,+ merchant_initiated,+ payment_type,+ store_for_future_use,+ ) = match item.router_data.request.payment_method_data.clone() {+ PaymentMethodData::Card(ccard) => {+ let payment_source = PaymentSource::Card(CardSource {+ source_type: CheckoutSourceTypes::Card,+ number: ccard.card_number.clone(),+ expiry_month: ccard.card_exp_month.clone(),+ expiry_year: ccard.card_exp_year.clone(),+ cvv: Some(ccard.card_cvc),+ });+ Ok((+ payment_source,+ None,+ Some(false),+ payment_type,+ store_for_future_use,+ ))+ }+ PaymentMethodData::Wallet(wallet_data) => match wallet_data {+ WalletData::GooglePay(_) => {+ let p_source = PaymentSource::Wallets(WalletSource {+ source_type: CheckoutSourceTypes::Token,+ token: match item.router_data.get_payment_method_token()? {+ PaymentMethodToken::Token(token) => token,+ PaymentMethodToken::ApplePayDecrypt(_) => {+ Err(unimplemented_payment_method!(+ "Apple Pay",+ "Simplified",+ "Checkout"+ ))?}PaymentMethodToken::PazeDecrypt(_) => {Err(unimplemented_payment_method!("Paze", "Checkout"))?@@ -500,29 +470,107 @@ impl TryFrom<&CheckoutRouterData<&PaymentsAuthorizeRouterData>> for PaymentsRequPaymentMethodToken::GooglePayDecrypt(_) => {Err(unimplemented_payment_method!("Google Pay", "Checkout"))?}+ },+ });+ Ok((+ p_source,+ None,+ Some(false),+ payment_type,+ store_for_future_use,+ ))+ }+ WalletData::ApplePay(_) => {+ let payment_method_token = item.router_data.get_payment_method_token()?;+ match payment_method_token {+ PaymentMethodToken::Token(apple_pay_payment_token) => {+ let p_source = PaymentSource::Wallets(WalletSource {+ source_type: CheckoutSourceTypes::Token,+ token: apple_pay_payment_token,+ });+ Ok((+ p_source,+ None,+ Some(false),+ payment_type,+ store_for_future_use,+ ))+ }+ PaymentMethodToken::ApplePayDecrypt(decrypt_data) => {+ let exp_month = decrypt_data.get_expiry_month().change_context(+ errors::ConnectorError::InvalidDataFormat {+ field_name: "expiration_month",+ },+ )?;+ let expiry_year_4_digit = decrypt_data.get_four_digit_expiry_year();+ let p_source =+ PaymentSource::ApplePayPredecrypt(Box::new(ApplePayPredecrypt {+ token: decrypt_data.application_primary_account_number,+ decrypt_type: "network_token".to_string(),+ token_type: "applepay".to_string(),+ expiry_month: exp_month,+ expiry_year: expiry_year_4_digit,+ eci: decrypt_data.payment_data.eci_indicator,+ cryptogram: decrypt_data.payment_data.online_payment_cryptogram,+ }));+ Ok((+ p_source,+ None,+ Some(false),+ payment_type,+ store_for_future_use,+ ))+ }+ PaymentMethodToken::PazeDecrypt(_) => {+ Err(unimplemented_payment_method!("Paze", "Checkout"))?+ }+ PaymentMethodToken::GooglePayDecrypt(_) => {+ Err(unimplemented_payment_method!("Google Pay", "Checkout"))?}}- _ => Err(errors::ConnectorError::NotImplemented(- utils::get_unimplemented_payment_method_error_message("checkout"),- )),- },- PaymentMethodData::MandatePayment => {- let mandate_source = PaymentSource::MandatePayment(MandateSource {- source_type: CheckoutSourceTypes::SourceId,- source_id: item.router_data.request.connector_mandate_id(),- });- let previous_id = Some(- item.router_data- .request- .get_connector_mandate_request_reference_id()?,- );- let p_type = CheckoutPaymentType::Recurring;- Ok((mandate_source, previous_id, Some(true), p_type))}_ => Err(errors::ConnectorError::NotImplemented(utils::get_unimplemented_payment_method_error_message("checkout"),)),- }?;+ },+ PaymentMethodData::MandatePayment => {+ let mandate_source = PaymentSource::MandatePayment(MandateSource {+ source_type: CheckoutSourceTypes::SourceId,+ source_id: item.router_data.request.connector_mandate_id(),+ });+ let previous_id = Some(+ item.router_data+ .request+ .get_connector_mandate_request_reference_id()?,+ );+ let p_type = CheckoutPaymentType::Unscheduled;+ Ok((mandate_source, previous_id, Some(true), p_type, None))+ }+ PaymentMethodData::CardDetailsForNetworkTransactionId(ccard) => {+ let payment_source = PaymentSource::Card(CardSource {+ source_type: CheckoutSourceTypes::Card,+ number: ccard.card_number.clone(),+ expiry_month: ccard.card_exp_month.clone(),+ expiry_year: ccard.card_exp_year.clone(),+ cvv: None,+ });++ let previous_id = Some(+ item.router_data+ .request+ .get_optional_network_transaction_id()+ .ok_or_else(utils::missing_field_err("network_transaction_id"))+ .attach_printable("Checkout unable to find NTID for MIT")?,+ );++ let p_type = CheckoutPaymentType::Unscheduled;++ Ok((payment_source, previous_id, Some(true), p_type, None))+ }+ _ => Err(errors::ConnectorError::NotImplemented(+ utils::get_unimplemented_payment_method_error_message("checkout"),+ )),+ }?;let authentication_data = item.router_data.request.authentication_data.as_ref();@@ -628,6 +676,7 @@ impl TryFrom<&CheckoutRouterData<&PaymentsAuthorizeRouterData>> for PaymentsRequpayment_type,merchant_initiated,previous_payment_id,+ store_for_future_use,customer,processing,shipping,diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex b486974e6c..4edb577a10 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -405,7 +405,7 @@ export const CONNECTOR_LISTS = {// Inclusion lists (only run for these connectors)INCLUDE: {- MANDATES_USING_NTID_PROXY: ["cybersource"],+ MANDATES_USING_NTID_PROXY: ["cybersource", "checkout"],INCREMENTAL_AUTH: ["archipel",// "cybersource", // issues with MULTIPLE_CONNECTORS handlingdiff --git a/loadtest/config/development.toml b/loadtest/config/development.tomlindex e072a370b9..19e4d3cbd9 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -765,7 +765,7 @@ card.credit = { connector_list = "cybersource" }card.debit = { connector_list = "cybersource" }[network_transaction_id_supported_connectors]-connector_list = "adyen,archipel,cybersource,novalnet,stripe,worldpay,worldpayvantiv"+connector_list = "adyen,archipel,checkout,cybersource,novalnet,stripe,worldpay,worldpayvantiv"[analytics]source = "sqlx"