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): [WorldpayWPG][Checkout] Populate auth_code from connector response (#13954)
Vani Guptae6546babfba9
diff --git a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rsindex a2068f69db..7e61d9fda4 100644--- a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs@@ -1773,6 +1773,13 @@ implconnector_mandate_request_reference_id: Some(item.response.id.clone()),});+ 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()),redirection_data: Box::new(redirection_data),@@ -1801,6 +1808,7 @@ implSome(err) => Err(err),None => Ok(payments_response_data),},+ connector_response: additional_information,..item.data})}diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rsindex c61ac3794f..9a8282d59e 100644--- a/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs@@ -20,7 +20,10 @@ use hyperswitch_domain_models::{payment_method_data::{ApplePayWalletData, Card, GooglePayWalletData, PaymentMethodData, WalletData,},- router_data::{ConnectorAuthType, ErrorResponse, PaymentMethodToken, RouterData},+ router_data::{+ AdditionalPaymentMethodConnectorResponse, ConnectorAuthType, ConnectorResponseData,+ ErrorResponse, PaymentMethodToken, RouterData,+ },router_flow_types::refunds::{Execute, RSync},router_request_types::{CompleteAuthorizeData, PaymentsAuthorizeData, PaymentsSyncData, ResponseId,@@ -2192,6 +2195,10 @@ impl<F>payment_data.last_event,Some(&item.data.status),)?;+ let connector_response = get_connector_response_data(+ &payment_data,+ item.data.request.payment_method_type,+ );let response = process_payment_response(status,&payment_data,@@ -2204,6 +2211,7 @@ impl<F>Ok(Self {status,response,+ connector_response,..item.data})} else {@@ -2524,6 +2532,10 @@ impl<F>if let Some(payment_data) = order_status.payment {let status = get_attempt_status(is_auto_capture, payment_data.last_event, None)?;+ let connector_response = get_connector_response_data(+ &payment_data,+ item.data.request.payment_method_type,+ );let response = process_payment_response(status,&payment_data,@@ -2535,6 +2547,7 @@ impl<F>Ok(Self {status,response,+ connector_response,..item.data})} else if let Some(challenge_required) = order_status.challenge_required {@@ -2917,6 +2930,10 @@ impl<F>payment_data.last_event,Some(&item.data.status),)?;+ let connector_response = get_connector_response_data(+ &payment_data,+ item.data.request.payment_method_type,+ );let response = process_payment_response(status,&payment_data,@@ -2928,6 +2945,7 @@ impl<F>Ok(Self {status,response,+ connector_response,..item.data})} else {@@ -3011,6 +3029,10 @@ impl<F>if let Some(payment_data) = order_status.payment {let status = get_attempt_status(is_auto_capture, payment_data.last_event, None)?;+ let connector_response = get_connector_response_data(+ &payment_data,+ item.data.request.payment_method_type,+ );let response = process_payment_response(status,&payment_data,@@ -3022,6 +3044,7 @@ impl<F>Ok(Self {status,response,+ connector_response,..item.data})} else if let Some(challenge_required) = order_status.challenge_required {@@ -3965,6 +3988,43 @@ fn get_mandate_reference(}}+/// Extracts the `AuthorisationId` returned by Worldpay (the scheme authorization code) and maps it+/// to the auth code exposed in the connector response.+fn get_connector_response_data(+ payment_data: &Payment,+ payment_method_type: Option<enums::PaymentMethodType>,+) -> Option<ConnectorResponseData> {+ let auth_code = payment_data+ .authorisation_id+ .as_ref()+ .and_then(|authorisation_id| authorisation_id.id.clone())+ .map(|id| id.expose())?;++ let additional_payment_method_data = match payment_method_type {+ Some(enums::PaymentMethodType::GooglePay) => {+ AdditionalPaymentMethodConnectorResponse::GooglePay {+ auth_code: Some(auth_code),+ }+ }+ Some(enums::PaymentMethodType::ApplePay) => {+ AdditionalPaymentMethodConnectorResponse::ApplePay {+ auth_code: Some(auth_code),+ }+ }+ _ => AdditionalPaymentMethodConnectorResponse::Card {+ authentication_data: None,+ payment_checks: None,+ card_network: None,+ domestic_network: None,+ auth_code: Some(auth_code),+ },+ };++ Some(ConnectorResponseData::with_additional_payment_method_data(+ additional_payment_method_data,+ ))+}+fn process_payment_response(status: common_enums::AttemptStatus,payment_data: &Payment,