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(checkout): populate auth code from connector-response (#13669)
Aniket Burman700f950dd0ac
diff --git a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rsindex 8d93d5e6a1..1abe2da6f5 100644--- a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs@@ -1309,6 +1309,7 @@ pub struct PaymentsResponse {approved: Option<bool>,processed_on: Option<String>,source: Option<Source>,+ auth_code: Option<String>,}#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]@@ -1415,9 +1416,12 @@ 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 additional_information = convert_to_additional_payment_method_connector_response(+ item.response.source.as_ref(),+ item.response.auth_code.clone(),+ item.data.request.payment_method_type,+ )+ .map(ConnectorResponseData::with_additional_payment_method_data);let payments_response_data = PaymentsResponseData::TransactionResponse {resource_id: ResponseId::ConnectorTransactionId(item.response.id.clone()),@@ -1629,9 +1633,12 @@ 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 additional_information = convert_to_additional_payment_method_connector_response(+ item.response.source.as_ref(),+ item.response.auth_code.clone(),+ item.data.request.payment_method_type,+ )+ .map(ConnectorResponseData::with_additional_payment_method_data);let payments_response_data = PaymentsResponseData::TransactionResponse {resource_id: ResponseId::ConnectorTransactionId(item.response.id.clone()),@@ -2134,6 +2141,7 @@ pub struct CheckoutWebhookData {pub currency: String,pub processed_on: Option<String>,pub approved: Option<bool>,+ pub auth_code: Option<String>,}#[derive(Debug, Deserialize)]@@ -2344,6 +2352,7 @@ impl TryFrom<&webhooks::IncomingWebhookRequestDetails<'_>> for PaymentsResponse}),scheme_id: None,processing: None,+ auth_code: data.auth_code,};Ok(psync_struct)@@ -2405,18 +2414,31 @@ impl From<String> for utils::ErrorCodeAndMessage {fn convert_to_additional_payment_method_connector_response(source: Option<&Source>,+ auth_code: Option<String>,+ payment_method_type: Option<enums::PaymentMethodType>,) -> 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,- auth_code: None,+ match payment_method_type {+ Some(enums::PaymentMethodType::GooglePay) => {+ Some(AdditionalPaymentMethodConnectorResponse::GooglePay { auth_code })+ }+ Some(enums::PaymentMethodType::ApplePay) => {+ Some(AdditionalPaymentMethodConnectorResponse::ApplePay { auth_code })+ }+ _ => {+ let payment_checks = source.map(|code| {+ serde_json::json!({+ "avs_result": code.avs_check,+ "card_validation_result": code.cvv_check,+ })+ });++ Some(AdditionalPaymentMethodConnectorResponse::Card {+ authentication_data: None,+ payment_checks,+ card_network: None,+ domestic_network: None,+ auth_code,+ })}- })+ }}