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(ucs): populate connector_order_reference_id and access_token on PostAuthenticate requests (#14125)
Tushar Shukla1e23b324359f
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rsindex c96e93ad07..1ae06ab0ce 100644--- a/crates/hyperswitch_domain_models/src/router_request_types.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs@@ -1028,6 +1028,7 @@ pub struct PaymentsPostAuthenticateData {pub minor_amount: Option<MinorUnit>,pub metadata: Option<pii::SecretSerdeValue>,pub complete_authorize_url: Option<String>,+ pub order_id: Option<String>,}impl TryFrom<CompleteAuthorizeData> for PaymentsPostAuthenticateData {@@ -1047,6 +1048,7 @@ impl TryFrom<CompleteAuthorizeData> for PaymentsPostAuthenticateData {redirect_response: data.redirect_response,metadata: data.connector_meta.map(Secret::new),complete_authorize_url: data.complete_authorize_url,+ order_id: data.order_id,})}}@@ -1164,6 +1166,7 @@ pub struct CompleteAuthorizeData {pub recipient_details: Option<api_models::payments::RecipientDetails>,pub business_country: Option<common_enums::CountryAlpha2>,pub connector_intent_metadata: Option<ConnectorMetadata>,+ pub order_id: Option<String>,pub force_3ds_challenge: Option<bool>,}diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rsindex 24b77ea5ef..1bd1791767 100644--- a/crates/router/src/core/authentication.rs+++ b/crates/router/src/core/authentication.rs@@ -890,6 +890,7 @@ async fn call_ucs_post_authenticate_proxy<F: Clone>(}),metadata: None,complete_authorize_url: None,+ order_id: None,};let psp_router_data: core_types::RouterData<diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 5dd41a7e40..130391cd7a 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -7378,6 +7378,29 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz.get_connector_metadata_from_intent().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to parse connector metadata")?;+ let connector = api_models::enums::Connector::from_str(connector_name)+ .change_context(errors::ConnectorError::InvalidConnectorName)+ .change_context(errors::ApiErrorResponse::InvalidDataValue {+ field_name: "connector".into(),+ })+ .attach_printable_lazy(|| {+ format!("unable to parse connector name {connector_name:?}")+ })?;+ let connector_creates_order =+ payment_data+ .payment_attempt+ .payment_method+ .is_some_and(|payment_method| {+ connector.requires_order_creation_before_payment(payment_method)+ });+ let order_id = connector_creates_order+ .then(|| {+ payment_data+ .payment_attempt+ .connector_response_reference_id+ .clone()+ })+ .flatten();Ok(Self {setup_future_usage: payment_data@@ -7430,6 +7453,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthorizrecipient_details,business_country: payment_data.payment_intent.business_country,connector_intent_metadata,+ order_id,force_3ds_challenge: payment_data.payment_intent.force_3ds_challenge_triggerdiff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex 7299c7fd3b..c4755e4a02 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -1034,8 +1034,11 @@ impl.map(payments_grpc::Tokenization::foreign_from).map(Into::into),l2_l3_data: None,- // Captures the order created before the redirect instead of creating a new one.- connector_order_id: router_data.request.connector_transaction_id.clone(),+ connector_order_id: router_data+ .request+ .order_id+ .clone()+ .or_else(|| router_data.request.connector_transaction_id.clone()),merchant_request_id: None,partner_merchant_identifier_details: None,// TODO: Populate currency_conversion_data when Dynamic Currency Conversion (DCC) is implemented@@ -1723,7 +1726,11 @@ impl.map(payments_grpc::BrowserInformation::foreign_try_from).transpose()?,connector_feature_data: None,- connector_order_reference_id: router_data.request.connector_transaction_id.clone(),+ connector_order_reference_id: router_data+ .request+ .order_id+ .clone()+ .or_else(|| router_data.request.connector_transaction_id.clone()),capture_method: capture_method.map(|capture_method| capture_method.into()),})}@@ -1807,7 +1814,10 @@ implmetadata: None,return_url: None,continue_redirection_url: None,- state: None,+ state: router_data+ .access_token+ .as_ref()+ .map(ConnectorState::foreign_from),redirection_response: router_data.request.redirect_response@@ -1823,7 +1833,11 @@ impl.map(payments_grpc::BrowserInformation::foreign_try_from).transpose()?,connector_feature_data: None,- connector_order_reference_id: None,+ connector_order_reference_id: router_data+ .request+ .order_id+ .clone()+ .or_else(|| router_data.request.connector_transaction_id.clone()),capture_method: capture_method.map(|capture_method| capture_method.into()),})}@@ -2267,7 +2281,11 @@ implthreeds_completion_indicator: None,redirection_response: None,continue_redirection_url: None,- connector_order_id: None,+ connector_order_id: router_data+ .request+ .order_id+ .clone()+ .or_else(|| router_data.request.connector_transaction_id.clone()),l2_l3_data: None,merchant_request_id: None,partner_merchant_identifier_details: None,