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
fix(connector): [checkout] Add AVS, CVV check in the response (#9389)
Vani Guptaa05827e0ed8c
diff --git a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rsindex b4c9572615..912ea1f5d3 100644--- a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs@@ -8,7 +8,10 @@ use common_utils::{use error_stack::ResultExt;use hyperswitch_domain_models::{payment_method_data::{PaymentMethodData, WalletData},- router_data::{ConnectorAuthType, ErrorResponse, PaymentMethodToken, RouterData},+ router_data::{+ AdditionalPaymentMethodConnectorResponse, ConnectorAuthType, ConnectorResponseData,+ ErrorResponse, PaymentMethodToken, RouterData,+ },router_flow_types::{Execute, RSync, SetupMandate},router_request_types::{ResponseId, SetupMandateRequestData},router_response_types::{@@ -680,6 +683,8 @@ pub struct Links {#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]pub struct Source {id: Option<String>,+ avs_check: Option<String>,+ cvv_check: Option<String>,}#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]@@ -799,6 +804,10 @@ impl TryFrom<PaymentsResponseRouterData<PaymentsResponse>> for PaymentsAuthorizeNone};+ let additional_information =+ convert_to_additional_payment_method_connector_response(item.response.source.as_ref())+ .map(ConnectorResponseData::with_additional_payment_method_data);+let payments_response_data = PaymentsResponseData::TransactionResponse {resource_id: ResponseId::ConnectorTransactionId(item.response.id.clone()),redirection_data: Box::new(redirection_data),@@ -814,6 +823,7 @@ impl TryFrom<PaymentsResponseRouterData<PaymentsResponse>> for PaymentsAuthorizeOk(Self {status,response: Ok(payments_response_data),+ connector_response: additional_information,..item.data})}@@ -966,6 +976,10 @@ impl TryFrom<PaymentsSyncResponseRouterData<PaymentsResponse>> for PaymentsSyncRNone};+ let additional_information =+ convert_to_additional_payment_method_connector_response(item.response.source.as_ref())+ .map(ConnectorResponseData::with_additional_payment_method_data);+let payments_response_data = PaymentsResponseData::TransactionResponse {resource_id: ResponseId::ConnectorTransactionId(item.response.id.clone()),redirection_data: Box::new(redirection_data),@@ -981,6 +995,7 @@ impl TryFrom<PaymentsSyncResponseRouterData<PaymentsResponse>> for PaymentsSyncROk(Self {status,response: error_response.map_or_else(|| Ok(payments_response_data), Err),+ connector_response: additional_information,..item.data})}@@ -1627,7 +1642,9 @@ impl TryFrom<&webhooks::IncomingWebhookRequestDetails<'_>> for PaymentsResponseprocessed_on: data.processed_on,approved: data.approved,source: Some(Source {- id: details.source.and_then(|src| src.id),+ id: details.source.clone().and_then(|src| src.id),+ avs_check: details.source.clone().and_then(|src| src.avs_check),+ cvv_check: details.source.clone().and_then(|src| src.cvv_check),}),scheme_id: None,processing: None,@@ -1691,3 +1708,20 @@ impl From<String> for utils::ErrorCodeAndMessage {}}}++fn convert_to_additional_payment_method_connector_response(+ source: Option<&Source>,+) -> Option<AdditionalPaymentMethodConnectorResponse> {+ source.map(|code| {+ let payment_checks = serde_json::json!({+ "avs_result": code.avs_check,+ "card_validation_result": code.cvv_check,+ });+ AdditionalPaymentMethodConnectorResponse::Card {+ authentication_data: None,+ payment_checks: Some(payment_checks),+ card_network: None,+ domestic_network: None,+ }+ })+}diff --git a/cypress-tests/cypress/e2e/configs/Payment/Checkout.js b/cypress-tests/cypress/e2e/configs/Payment/Checkout.jsindex aeb463f9f4..a2e2f1ef6d 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Checkout.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Checkout.js@@ -7,11 +7,11 @@ const successfulNo3DSCardDetails = {};const successfulThreeDSTestCardDetails = {- card_number: "4242424242424242",- card_exp_month: "01",- card_exp_year: "50",+ card_number: "4111111111111111",+ card_exp_month: "12",+ card_exp_year: "30",card_holder_name: "joseph Doe",- card_cvc: "123",+ card_cvc: "100",};const customerAcceptance = {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.jsindex 62d942a9fb..89310933db 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js@@ -11,6 +11,7 @@ const connectorName = normalize(globalState.get("connectorId"));function normalize(input) {const exceptions = {+ adyen: "Adyen",archipel: "Archipel",bankofamerica: "Bank of America",cybersource: "Cybersource",