Skip to content

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

fix(ucs): derive integrity_object from PaymentServiceAuthorizeResponse.amount (#12834)

Pa1NarK8d0d41697c1b
diff --git a/crates/router/src/core/payments/gateway/authorize_gateway.rs b/crates/router/src/core/payments/gateway/authorize_gateway.rs
index bf3bb75799..c517de8955 100644
--- a/crates/router/src/core/payments/gateway/authorize_gateway.rs
+++ b/crates/router/src/core/payments/gateway/authorize_gateway.rs
@@ -1,10 +1,13 @@
use std::str::FromStr;
use async_trait::async_trait;
-use common_enums::{CallConnectorAction, ExecutionPath};
+use common_enums::{CallConnectorAction, Currency, ExecutionPath};
use common_utils::{errors::CustomResult, id_type, request::Request, ucs_types};
use error_stack::ResultExt;
-use hyperswitch_domain_models::{router_data::RouterData, router_flow_types as domain};
+use hyperswitch_domain_models::{
+ router_data::RouterData, router_flow_types as domain,
+ router_request_types::AuthoriseIntegrityObject,
+};
use hyperswitch_interfaces::{
api::gateway as payment_gateway,
connector_integration_interface::{BoxedConnectorIntegrationInterface, RouterDataConversion},
@@ -342,6 +345,25 @@ where
};
router_data.response = router_data_response;
+ router_data.request.integrity_object = payment_authorize_response
+ .authorized_money
+ .map(|money| -> Result<_, error_stack::Report<ConnectorError>> {
+ let grpc_currency = payments_grpc::Currency::try_from(money.currency)
+ .change_context(ConnectorError::ResponseDeserializationFailed)
+ .attach_printable("Invalid currency received from UCS response")?;
+ let currency = Currency::foreign_try_from(grpc_currency)
+ .change_context(ConnectorError::ResponseDeserializationFailed)?;
+
+ Ok(AuthoriseIntegrityObject {
+ amount: MinorUnit::new(money.minor_amount),
+ currency,
+ })
+ })
+ .transpose()
+ .change_context(
+ UnifiedConnectorServiceError::ResponseDeserializationFailed,
+ )?;
+
router_data.amount_captured = payment_authorize_response.captured_amount;
router_data.minor_amount_captured = payment_authorize_response
.captured_amount