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

feat: Add granular authorize support for Unified Connector Service (#10348)

Hrithikeshd2c4b0e016f3
diff --git a/Cargo.lock b/Cargo.lock
index a5a0c40443..a5e0000b18 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3789,7 +3789,7 @@ dependencies = [
[[package]]
name = "grpc-api-types"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6#ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6"
+source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
dependencies = [
"axum 0.8.4",
"error-stack 0.5.0",
@@ -7427,7 +7427,7 @@ dependencies = [
[[package]]
name = "rust-grpc-client"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6#ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6"
+source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
dependencies = [
"grpc-api-types",
]
@@ -10217,7 +10217,7 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]]
name = "ucs_cards"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6#ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6"
+source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
dependencies = [
"bytes 1.10.1",
"error-stack 0.4.1",
@@ -10233,7 +10233,7 @@ dependencies = [
[[package]]
name = "ucs_common_enums"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6#ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6"
+source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
dependencies = [
"serde",
"strum 0.26.3",
@@ -10244,7 +10244,7 @@ dependencies = [
[[package]]
name = "ucs_common_utils"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6#ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6"
+source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
dependencies = [
"anyhow",
"base64 0.21.7",
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index ee0e414868..23825cc1f5 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -69,7 +69,7 @@ reqwest = { version = "0.11.27", features = ["rustls-tls"] }
http = "0.2.12"
url = { version = "2.5.4", features = ["serde"] }
quick-xml = { version = "0.31.0", features = ["serialize"] }
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d", package = "rust-grpc-client" }
open-feature = { version = "0.2.5", optional = true }
superposition_provider = { version = "0.88.1", optional = true }
diff --git a/crates/external_services/src/grpc_client/unified_connector_service.rs b/crates/external_services/src/grpc_client/unified_connector_service.rs
index 1bec8d3491..adb6c62752 100644
--- a/crates/external_services/src/grpc_client/unified_connector_service.rs
+++ b/crates/external_services/src/grpc_client/unified_connector_service.rs
@@ -153,6 +153,35 @@ impl UnifiedConnectorServiceClient {
}
}
+ /// Performs Payment Granular Authorize
+ pub async fn payment_authorize_granular(
+ &self,
+ payment_authorize_only_request: payments_grpc::PaymentServiceAuthorizeOnlyRequest,
+ connector_auth_metadata: ConnectorAuthMetadata,
+ grpc_headers: GrpcHeadersUcs,
+ ) -> UnifiedConnectorServiceResult<tonic::Response<PaymentServiceAuthorizeResponse>> {
+ let mut request = tonic::Request::new(payment_authorize_only_request);
+
+ let connector_name = connector_auth_metadata.connector_name.clone();
+ let metadata =
+ build_unified_connector_service_grpc_headers(connector_auth_metadata, grpc_headers)?;
+ *request.metadata_mut() = metadata;
+
+ self.client
+ .clone()
+ .authorize_only(request)
+ .await
+ .change_context(UnifiedConnectorServiceError::PaymentAuthorizeGranularFailure)
+ .inspect_err(|error| {
+ logger::error!(
+ grpc_error=?error,
+ method="authorize_only",
+ connector_name=?connector_name,
+ "UCS authorize_only gRPC call failed"
+ )
+ })
+ }
+
/// Performs Payment Pre Authenticate
pub async fn payment_pre_authenticate(
&self,
diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rs
index fc9deb950f..fdcaa8a008 100644
--- a/crates/hyperswitch_domain_models/src/router_data.rs
+++ b/crates/hyperswitch_domain_models/src/router_data.rs
@@ -438,6 +438,15 @@ pub enum PaymentMethodToken {
PazeDecrypt(Box<PazeDecryptedData>),
}
+impl PaymentMethodToken {
+ pub fn get_payment_method_token(&self) -> Option<Secret<String>> {
+ match self {
+ Self::Token(secret_token) => Some(secret_token.clone()),
+ _ => None,
+ }
+ }
+}
+
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplePayPredecryptDataInternal {
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index 98c64880e6..688f55d705 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -29,7 +29,7 @@ serde_json = "1.0.140"
strum = { version = "0.26", features = ["derive"] }
thiserror = "1.0.69"
time = "0.3.41"
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d", package = "rust-grpc-client" }
unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.09.24.0", package = "masking" }
tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }
# First party crates
diff --git a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
index 8d2740aba7..29a6f35bb6 100644
--- a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
+++ b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
@@ -78,6 +78,26 @@ pub enum UnifiedConnectorServiceError {
#[error("Failed to inject metadata into request headers: {0}")]
HeaderInjectionFailed(String),
+ /// Failed to perform Payment Authorize from gRPC Server
+ #[error("Failed to perform Payment Authorize from gRPC Server")]
+ PaymentAuthorizeGranularFailure,
+
+ /// Failed to perform Payment Authorize from gRPC Server
+ #[error("Failed to perform Payment Authorize from gRPC Server")]
+ PaymentCreateSessionTokenFailure,
+
+ /// Failed to perform Payment Authorize from gRPC Server
+ #[error("Failed to perform Payment Authorize from gRPC Server")]
+ PaymentCreateAccessTokenFailure,
+
+ /// Failed to perform Payment Authorize from gRPC Server
+ #[error("Failed to perform Payment Authorize from gRPC Server")]
+ PaymentMethodTokenCreateFailure,
+
+ /// Failed to perform Payment Authorize from gRPC Server
+ #[error("Failed to perform Payment Authorize from gRPC Server")]
+ PaymentConnectorCustomerCreateFailure,
+
/// Failed to perform Payment Authorize from gRPC Server
#[error("Failed to perform Payment Authorize from gRPC Server")]
PaymentAuthorizeFailure,
@@ -261,6 +281,8 @@ impl ForeignTryFrom<payments_grpc::PaymentStatus> for AttemptStatus {
}
payments_grpc::PaymentStatus::VoidedPostCapture => Ok(Self::Voided),
payments_grpc::PaymentStatus::AttemptStatusUnspecified => Ok(Self::Unresolved),
+ payments_grpc::PaymentStatus::PartiallyAuthorized => Ok(Self::PartiallyAuthorized),
+ payments_grpc::PaymentStatus::Expired => Ok(Self::Expired),
}
}
}
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 262362ca25..cd5c3e2483 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -89,8 +89,8 @@ reqwest = { version = "0.11.27", features = ["json", "rustls-tls", "gzip", "mult
ring = "0.17.14"
rust_decimal = { version = "1.37.1", features = ["serde-with-float", "serde-with-str"] }
rust-i18n = { git = "https://github.com/kashif-m/rust-i18n", rev = "f2d8096aaaff7a87a847c35a5394c269f75e077a" }
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6", package = "rust-grpc-client" }
-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "ec91d1b92127e29d3be4fa0f3ec5e74a723ea0e6", package = "ucs_cards" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d", package = "rust-grpc-client" }
+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d", package = "ucs_cards" }
unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.09.24.0", package = "masking" }
rustc-hash = "1.1.0"
rustls = "0.22"
diff --git a/crates/router/src/core/payments/gateway.rs b/crates/router/src/core/payments/gateway.rs
index 564dbaa1f3..4c83b668a5 100644
--- a/crates/router/src/core/payments/gateway.rs
+++ b/crates/router/src/core/payments/gateway.rs
@@ -1,3 +1,4 @@
+pub mod authorize_gateway;
pub mod context;
pub mod psync_gateway;
diff --git a/crates/router/src/core/payments/gateway/authorize_gateway.rs b/crates/router/src/core/payments/gateway/authorize_gateway.rs
new file mode 100644
index 0000000000..8bde689c67
--- /dev/null
+++ b/crates/router/src/core/payments/gateway/authorize_gateway.rs
@@ -0,0 +1,201 @@
+use std::str::FromStr;
+
+use async_trait::async_trait;
+use common_enums::{CallConnectorAction, 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_interfaces::{
+ api::gateway as payment_gateway,
+ connector_integration_interface::{BoxedConnectorIntegrationInterface, RouterDataConversion},
+ errors::ConnectorError,
+};
+use unified_connector_service_client::payments as payments_grpc;
+use unified_connector_service_masking::ExposeInterface as UcsMaskingExposeInterface;
+
+use crate::{
+ core::{
+ payments::gateway::context::RouterGatewayContext, unified_connector_service,
+ unified_connector_service::handle_unified_connector_service_response_for_payment_authorize,
+ },
+ routes::SessionState,
+ services::logger,
+ types::{self, transformers::ForeignTryFrom, MinorUnit},
+};
+
+// =============================================================================
+// PaymentGateway Implementation for domain::Authorize
+// =============================================================================
+
+/// Implementation of PaymentGateway for api::PSync flow
+#[async_trait]
+impl<RCD>
+ payment_gateway::PaymentGateway<
+ SessionState,
+ RCD,
+ Self,
+ types::PaymentsAuthorizeData,
+ types::PaymentsResponseData,
+ RouterGatewayContext,
+ > for domain::Authorize
+where
+ RCD: Clone
+ + Send
+ + Sync
+ + 'static
+ + RouterDataConversion<Self, types::PaymentsAuthorizeData, types::PaymentsResponseData>,
+{
+ async fn execute(
+ self: Box<Self>,
+ state: &SessionState,
+ _connector_integration: BoxedConnectorIntegrationInterface<
+ Self,
+ RCD,
+ types::PaymentsAuthorizeData,
+ types::PaymentsResponseData,
+ >,
+ router_data: &RouterData<Self, types::PaymentsAuthorizeData, types::PaymentsResponseData>,
+ call_connector_action: CallConnectorAction,
+ _connector_request: Option<Request>,
+ _return_raw_connector_response: Option<bool>,
+ context: RouterGatewayContext,
+ ) -> CustomResult<
+ RouterData<Self, types::PaymentsAuthorizeData, types::PaymentsResponseData>,
+ ConnectorError,
+ > {
+ let merchant_connector_account = context.merchant_connector_account;
+ let platform = context.platform;
+ let lineage_ids = context.lineage_ids;
+ let header_payload = context.header_payload;
+ let unified_connector_service_execution_mode = context.execution_mode;
+ let merchant_order_reference_id = header_payload.x_reference_id.clone();
+ let client = state
+ .grpc_client
+ .unified_connector_service_client
+ .clone()
+ .ok_or(ConnectorError::RequestEncodingFailed)
+ .attach_printable("Failed to fetch Unified Connector Service client")?;
+
+ let granular_authorize_request =
+ payments_grpc::PaymentServiceAuthorizeOnlyRequest::foreign_try_from((
+ router_data,
+ call_connector_action,
+ ))
+ .change_context(ConnectorError::RequestEncodingFailed)
+ .attach_printable("Failed to construct Payment Get Request")?;
+
+ let connector_auth_metadata =
+ unified_connector_service::build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ &platform,
+ )
+ .change_context(ConnectorError::RequestEncodingFailed)
+ .attach_printable("Failed to construct request metadata")?;
+ let merchant_reference_id = header_payload
+ .x_reference_id
+ .clone()
+ .or(merchant_order_reference_id)
+ .map(|id| id_type::PaymentReferenceId::from_str(id.as_str()))
+ .transpose()
+ .inspect_err(|err| logger::warn!(error=?err, "Invalid Merchant ReferenceId found"))
+ .ok()
+ .flatten()
+ .map(ucs_types::UcsReferenceId::Payment);
+ let header_payload = state
+ .get_grpc_headers_ucs(unified_connector_service_execution_mode)
+ .external_vault_proxy_metadata(None)
+ .merchant_reference_id(merchant_reference_id)
+ .lineage_ids(lineage_ids);
+ let updated_router_data = Box::pin(unified_connector_service::ucs_logging_wrapper_new(
+ router_data.clone(),
+ state,
+ granular_authorize_request,
+ header_payload,
+ |mut router_data, granular_authorize_request, grpc_headers| async move {
+ let response = Box::pin(client.payment_authorize_granular(
+ granular_authorize_request,
+ connector_auth_metadata,
+ grpc_headers,
+ ))
+ .await
+ .attach_printable("Failed to get payment")?;
+
+ let payment_authorize_response = response.into_inner();
+
+ let ucs_data = handle_unified_connector_service_response_for_payment_authorize(
+ payment_authorize_response.clone(),
+ )
+ .attach_printable("Failed to deserialize UCS response")?;
+
+ let router_data_response =
+ ucs_data.router_data_response.map(|(response, status)| {
+ router_data.status = status;
+ response
+ });
+ router_data.response = router_data_response;
+ router_data.amount_captured = payment_authorize_response.captured_amount;
+ router_data.minor_amount_captured = payment_authorize_response
+ .minor_captured_amount
+ .map(MinorUnit::new);
+ router_data.raw_connector_response = payment_authorize_response
+ .raw_connector_response
+ .clone()
+ .map(|raw_connector_response| raw_connector_response.expose().into());
+ router_data.connector_http_status_code = Some(ucs_data.status_code);
+
+ // Populate connector_customer_id if present
+ ucs_data.connector_customer_id.map(|connector_customer_id| {
+ router_data.connector_customer = Some(connector_customer_id);
+ });
+
+ ucs_data.connector_response.map(|customer_response| {
+ router_data.connector_response = Some(customer_response);
+ });
+
+ Ok((router_data, payment_authorize_response))
+ },
+ ))
+ .await
+ .change_context(ConnectorError::ResponseHandlingFailed)?;
+
+ Ok(updated_router_data)
+ }
+}
+
+/// Implementation of FlowGateway for api::PSync
+///
+/// This allows the flow to provide its specific gateway based on execution path
+impl<RCD>
+ payment_gateway::FlowGateway<
+ SessionState,
+ RCD,
+ types::PaymentsAuthorizeData,
+ types::PaymentsResponseData,
+ RouterGatewayContext,
+ > for domain::Authorize
+where
+ RCD: Clone
+ + Send
+ + Sync
+ + 'static
+ + RouterDataConversion<Self, types::PaymentsAuthorizeData, types::PaymentsResponseData>,
+{
+ fn get_gateway(
+ execution_path: ExecutionPath,
+ ) -> Box<
+ dyn payment_gateway::PaymentGateway<
+ SessionState,
+ RCD,
+ Self,
+ types::PaymentsAuthorizeData,
+ types::PaymentsResponseData,
+ RouterGatewayContext,
+ >,
+ > {
+ match execution_path {
+ ExecutionPath::Direct => Box::new(payment_gateway::DirectGateway),
+ ExecutionPath::UnifiedConnectorService
+ | ExecutionPath::ShadowUnifiedConnectorService => Box::new(Self),
+ }
+ }
+}
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index d4fe7b6f7e..bd3fa708cc 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -64,6 +64,186 @@ impl ForeignFrom<&AccessToken> for ConnectorState {
}
}
}
+
+impl
+ transformers::ForeignTryFrom<(
+ &RouterData<Authorize, PaymentsAuthorizeData, PaymentsResponseData>,
+ common_enums::CallConnectorAction,
+ )> for payments_grpc::PaymentServiceAuthorizeOnlyRequest
+{
+ type Error = error_stack::Report<UnifiedConnectorServiceError>;
+
+ fn foreign_try_from(
+ (router_data, _call_connector_action): (
+ &RouterData<Authorize, PaymentsAuthorizeData, PaymentsResponseData>,
+ common_enums::CallConnectorAction,
+ ),
+ ) -> Result<Self, Self::Error> {
+ let currency = payments_grpc::Currency::foreign_try_from(router_data.request.currency)?;
+
+ let payment_method = router_data
+ .request
+ .payment_method_type
+ .map(|payment_method_type| {
+ unified_connector_service::build_unified_connector_service_payment_method(
+ router_data.request.payment_method_data.clone(),
+ payment_method_type,
+ )
+ })
+ .transpose()?;
+
+ let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
+
+ let auth_type = payments_grpc::AuthenticationType::foreign_try_from(router_data.auth_type)?;
+
+ let browser_info = router_data
+ .request
+ .browser_info
+ .clone()
+ .map(payments_grpc::BrowserInformation::foreign_try_from)
+ .transpose()?;
+
+ let capture_method = router_data
+ .request
+ .capture_method
+ .map(payments_grpc::CaptureMethod::foreign_try_from)
+ .transpose()?;
+
+ let authentication_data = router_data
+ .request
+ .authentication_data
+ .clone()
+ .map(payments_grpc::AuthenticationData::foreign_try_from)
+ .transpose()?;
+ let merchant_account_metadata = router_data
+ .connector_meta_data
+ .as_ref()
+ .and_then(|val| val.peek().as_object())
+ .map(|map| {
+ map.iter()
+ .filter_map(|(k, v)| v.as_str().map(|s| (k.clone(), s.to_string())))
+ .collect::<HashMap<String, String>>()
+ })
+ .unwrap_or_default();
+ let metadata = router_data
+ .request
+ .metadata
+ .as_ref()
+ .and_then(|val| val.as_object())
+ .map(|map| {
+ map.iter()
+ .filter_map(|(k, v)| v.as_str().map(|s| (k.clone(), s.to_string())))
+ .collect::<HashMap<String, String>>()
+ })
+ .unwrap_or_default();
+ let setup_future_usage = router_data
+ .request
+ .setup_future_usage
+ .map(payments_grpc::FutureUsage::foreign_try_from)
+ .transpose()?;
+
+ let customer_acceptance = router_data
+ .request
+ .customer_acceptance
+ .clone()
+ .map(payments_grpc::CustomerAcceptance::foreign_try_from)
+ .transpose()?;
+
+ let state = router_data
+ .access_token
+ .as_ref()
+ .map(ConnectorState::foreign_from);
+
+ Ok(Self {
+ amount: router_data.request.amount,
+ currency: currency.into(),
+ payment_method,
+ return_url: router_data.request.router_return_url.clone(),
+ address: Some(address),
+ auth_type: auth_type.into(),
+ enrolled_for_3ds: router_data.request.enrolled_for_3ds,
+ request_incremental_authorization: router_data
+ .request
+ .request_incremental_authorization,
+ minor_amount: router_data.request.amount,
+ email: router_data
+ .request
+ .email
+ .clone()
+ .map(|e| e.expose().expose().into()),
+ browser_info,
+
+ session_token: None,
+ order_tax_amount: router_data
+ .request
+ .order_tax_amount
+ .map(|order_tax_amount| order_tax_amount.get_amount_as_i64()),
+ customer_name: router_data
+ .request
+ .customer_name
+ .clone()
+ .map(|customer_name| customer_name.peek().to_owned()),
+ capture_method: capture_method.map(|capture_method| capture_method.into()),
+ webhook_url: router_data.request.webhook_url.clone(),
+ complete_authorize_url: router_data.request.complete_authorize_url.clone(),
+ setup_future_usage: setup_future_usage.map(|s| s.into()),
+ off_session: router_data.request.off_session,
+ customer_acceptance,
+ order_category: router_data.request.order_category.clone(),
+ payment_experience: None,
+ authentication_data,
+ request_extended_authorization: router_data
+ .request
+ .request_extended_authorization
+ .map(|request_extended_authorization| request_extended_authorization.is_true()),
+ merchant_order_reference_id: router_data.request.merchant_order_reference_id.clone(),
+ shipping_cost: router_data
+ .request
+ .shipping_cost
+ .map(|shipping_cost| shipping_cost.get_amount_as_i64()),
+ request_ref_id: Some(Identifier {
+ id_type: Some(payments_grpc::identifier::IdType::Id(
+ router_data.connector_request_reference_id.clone(),
+ )),
+ }),
+ customer_id: router_data
+ .request
+ .customer_id
+ .as_ref()
+ .map(|id| id.get_string_repr().to_string()),
+ metadata,
+ test_mode: router_data.test_mode,
+ connector_customer_id: router_data.connector_customer.clone(),
+ state,
+ payment_method_token: router_data
+ .payment_method_token
+ .as_ref()
+ .and_then(|pmt| pmt.get_payment_method_token())
+ .map(ExposeInterface::expose),
+ access_token: None,
+ merchant_account_metadata,
+ description: router_data.description.clone(),
+ setup_mandate_details: router_data
+ .request
+ .setup_mandate_details
+ .as_ref()
+ .map(payments_grpc::SetupMandateDetails::foreign_try_from)
+ .transpose()?,
+ statement_descriptor_name: router_data
+ .request
+ .billing_descriptor
+ .as_ref()
+ .and_then(|descriptor| descriptor.statement_descriptor.clone()),
+ statement_descriptor_suffix: router_data
+ .request
+ .billing_descriptor
+ .as_ref()
+ .and_then(|descriptor| descriptor.statement_descriptor_suffix.clone()),
+ order_details: vec![],
+ })
+ }
+}
+
impl
transformers::ForeignTryFrom<(
&RouterData<PSync, PaymentsSyncData, PaymentsResponseData>,
@@ -618,6 +798,7 @@ impl
setup_mandate_details: None,
statement_descriptor_name: None,
statement_descriptor_suffix: None,
+ order_details: vec![],
})
}
}
@@ -786,6 +967,7 @@ impl
.billing_descriptor
.as_ref()
.and_then(|descriptor| descriptor.statement_descriptor_suffix.clone()),
+ order_details: vec![],
})
}
}
@@ -950,6 +1132,7 @@ impl
.transpose()?,
statement_descriptor_name: router_data.request.statement_descriptor.clone(),
statement_descriptor_suffix: router_data.request.statement_descriptor_suffix.clone(),
+ order_details: vec![],
})
}
}