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(ucs): add TrustPay wallet support (Apple Pay & Google Pay) (#11282)

Pa1NarK326bd130f1b4
diff --git a/Cargo.lock b/Cargo.lock
index b8868318c8..fc7e8af2f2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2183,7 +2183,7 @@ dependencies = [
[[package]]
name = "config_patch_derive"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=425566c6060cff496b7fcf03d6d4ba36ed3bdf64#425566c6060cff496b7fcf03d6d4ba36ed3bdf64"
+source = "git+https://github.com/juspay/connector-service?rev=5976300a6eb3746990502970ca089b4eac4b4e24#5976300a6eb3746990502970ca089b4eac4b4e24"
dependencies = [
"proc-macro2",
"quote",
@@ -3854,7 +3854,7 @@ dependencies = [
[[package]]
name = "grpc-api-types"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=425566c6060cff496b7fcf03d6d4ba36ed3bdf64#425566c6060cff496b7fcf03d6d4ba36ed3bdf64"
+source = "git+https://github.com/juspay/connector-service?rev=5976300a6eb3746990502970ca089b4eac4b4e24#5976300a6eb3746990502970ca089b4eac4b4e24"
dependencies = [
"axum 0.8.4",
"error-stack 0.5.0",
@@ -7561,7 +7561,7 @@ dependencies = [
[[package]]
name = "rust-grpc-client"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=425566c6060cff496b7fcf03d6d4ba36ed3bdf64#425566c6060cff496b7fcf03d6d4ba36ed3bdf64"
+source = "git+https://github.com/juspay/connector-service?rev=5976300a6eb3746990502970ca089b4eac4b4e24#5976300a6eb3746990502970ca089b4eac4b4e24"
dependencies = [
"grpc-api-types",
]
@@ -10362,7 +10362,7 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]]
name = "ucs_cards"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=425566c6060cff496b7fcf03d6d4ba36ed3bdf64#425566c6060cff496b7fcf03d6d4ba36ed3bdf64"
+source = "git+https://github.com/juspay/connector-service?rev=5976300a6eb3746990502970ca089b4eac4b4e24#5976300a6eb3746990502970ca089b4eac4b4e24"
dependencies = [
"bytes 1.10.1",
"error-stack 0.4.1",
@@ -10378,7 +10378,7 @@ dependencies = [
[[package]]
name = "ucs_common_enums"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=425566c6060cff496b7fcf03d6d4ba36ed3bdf64#425566c6060cff496b7fcf03d6d4ba36ed3bdf64"
+source = "git+https://github.com/juspay/connector-service?rev=5976300a6eb3746990502970ca089b4eac4b4e24#5976300a6eb3746990502970ca089b4eac4b4e24"
dependencies = [
"serde",
"strum 0.26.3",
@@ -10389,7 +10389,7 @@ dependencies = [
[[package]]
name = "ucs_common_utils"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=425566c6060cff496b7fcf03d6d4ba36ed3bdf64#425566c6060cff496b7fcf03d6d4ba36ed3bdf64"
+source = "git+https://github.com/juspay/connector-service?rev=5976300a6eb3746990502970ca089b4eac4b4e24#5976300a6eb3746990502970ca089b4eac4b4e24"
dependencies = [
"anyhow",
"base64 0.21.7",
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index 313709761e..511a64935e 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 = "425566c6060cff496b7fcf03d6d4ba36ed3bdf64", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5976300a6eb3746990502970ca089b4eac4b4e24", package = "rust-grpc-client" }
open-feature = { version = "0.2.5", optional = true }
superposition_provider = { version = "0.97.0", optional = true }
diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs b/crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs
index 7e92689b7d..cbbd31d875 100644
--- a/crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs
@@ -154,6 +154,7 @@ impl TryFrom<CreateOrderResponseRouterData<AirwallexOrderResponse>>
Ok(Self {
response: Ok(PaymentsResponseData::PaymentsCreateOrderResponse {
order_id: item.response.id.clone(),
+ session_token: None,
}),
..item.data
})
diff --git a/crates/hyperswitch_connectors/src/connectors/razorpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/razorpay/transformers.rs
index 51e9e5ebb3..d7dfdade73 100644
--- a/crates/hyperswitch_connectors/src/connectors/razorpay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/razorpay/transformers.rs
@@ -106,6 +106,7 @@ impl TryFrom<CreateOrderResponseRouterData<RazorpayOrderResponse>>
Ok(Self {
response: Ok(PaymentsResponseData::PaymentsCreateOrderResponse {
order_id: item.response.id.clone(),
+ session_token: None,
}),
..item.data
})
diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs
index 57a7624c46..1cb3aa5a2a 100644
--- a/crates/hyperswitch_domain_models/src/router_response_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_response_types.rs
@@ -118,6 +118,7 @@ pub enum PaymentsResponseData {
},
PaymentsCreateOrderResponse {
order_id: String,
+ session_token: Option<api_models::payments::SessionToken>,
},
}
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index 726552f613..570e039313 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -30,7 +30,7 @@ strum = { version = "0.26", features = ["derive"] }
thiserror = "1.0.69"
time = "0.3.41"
url = { version = "2.5.4", features = ["serde"] }
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "425566c6060cff496b7fcf03d6d4ba36ed3bdf64", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5976300a6eb3746990502970ca089b4eac4b4e24", package = "rust-grpc-client" }
unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.11.24.0", package = "masking" }
tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }
diff --git a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
index 10b628377d..076f3595bd 100644
--- a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
+++ b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
@@ -1,3 +1,5 @@
+use std::str::FromStr;
+
use common_enums::AttemptStatus;
use common_types::primitive_wrappers::{ExtendedAuthorizationAppliedBool, OvercaptureEnabledBool};
use common_utils::request::Method;
@@ -9,6 +11,7 @@ use hyperswitch_domain_models::{
},
router_response_types::{PaymentsResponseData, RedirectForm},
};
+use unified_connector_service_masking::ExposeInterface;
use crate::{
helpers::{ForeignFrom, ForeignTryFrom},
@@ -430,6 +433,34 @@ impl ForeignTryFrom<payments_grpc::AdditionalPaymentMethodConnectorResponse>
) => Ok(Self::ApplePay {
auth_code: apple_pay_data.auth_code,
}),
+ Some(payments_grpc::additional_payment_method_connector_response::PaymentMethodData::BankRedirect(bank_redirect_data)) => {
+ let interac = bank_redirect_data.interac.map(|proto_interac| {
+ hyperswitch_domain_models::router_data::InteracCustomerInfo {
+ customer_info: proto_interac.customer_info.map(|info| {
+ common_types::payments::InteracCustomerInfoDetails {
+ customer_name: info.customer_name.map(|secret| masking::Secret::new(secret.expose())),
+ customer_email: info.customer_email
+ .and_then(|secret| {
+ common_utils::pii::Email::from_str(&secret.expose())
+ .map_err(|e| {
+ router_env::logger::warn!(
+ email_parse_error=?e,
+ "Failed to parse customer_email from UCS InteracCustomerInfo"
+ );
+ e
+ })
+ .ok()
+ }),
+ customer_phone_number: info.customer_phone_number.map(|secret| masking::Secret::new(secret.expose())),
+ customer_bank_id: info.customer_bank_id.map(|secret| masking::Secret::new(secret.expose())),
+ customer_bank_name: info.customer_bank_name.map(|secret| masking::Secret::new(secret.expose())),
+ }
+ }),
+ }
+ });
+ Ok(Self::BankRedirect { interac })
+
+ }
None => Err(error_stack::Report::new(
UnifiedConnectorServiceError::ResponseDeserializationFailed,
)
@@ -458,8 +489,6 @@ impl ForeignTryFrom<payments_grpc::Ach>
type Error = error_stack::Report<UnifiedConnectorServiceError>;
fn foreign_try_from(ach: payments_grpc::Ach) -> Result<Self, Self::Error> {
- use unified_connector_service_masking::ExposeInterface;
-
let bank_name = payments_grpc::BankNames::try_from(ach.bank_name)
.ok()
.and_then(|bn| common_enums::BankNames::foreign_try_from(bn).ok());
@@ -506,8 +535,6 @@ impl ForeignTryFrom<payments_grpc::Sepa>
type Error = error_stack::Report<UnifiedConnectorServiceError>;
fn foreign_try_from(sepa: payments_grpc::Sepa) -> Result<Self, Self::Error> {
- use unified_connector_service_masking::ExposeInterface;
-
Ok(Self::SepaBankDebit {
iban: masking::Secret::new(
sepa.iban
@@ -529,8 +556,6 @@ impl ForeignTryFrom<payments_grpc::Bacs>
type Error = error_stack::Report<UnifiedConnectorServiceError>;
fn foreign_try_from(bacs: payments_grpc::Bacs) -> Result<Self, Self::Error> {
- use unified_connector_service_masking::ExposeInterface;
-
Ok(Self::BacsBankDebit {
account_number: masking::Secret::new(
bacs.account_number
@@ -559,8 +584,6 @@ impl ForeignTryFrom<payments_grpc::Becs>
type Error = error_stack::Report<UnifiedConnectorServiceError>;
fn foreign_try_from(becs: payments_grpc::Becs) -> Result<Self, Self::Error> {
- use unified_connector_service_masking::ExposeInterface;
-
Ok(Self::BecsBankDebit {
account_number: masking::Secret::new(
becs.account_number
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index e4188a2ad9..98d3f6772a 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -90,8 +90,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 = "425566c6060cff496b7fcf03d6d4ba36ed3bdf64", package = "rust-grpc-client" }
-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "425566c6060cff496b7fcf03d6d4ba36ed3bdf64", package = "ucs_cards" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5976300a6eb3746990502970ca089b4eac4b4e24", package = "rust-grpc-client" }
+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "5976300a6eb3746990502970ca089b4eac4b4e24", package = "ucs_cards" }
unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.11.24.0", package = "masking" }
rustc-hash = "1.1.0"
rustls = "0.22"
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 3238055de1..7dacc66992 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -4463,12 +4463,20 @@ where
(router_data, false)
};
- if let Ok(router_types::PaymentsResponseData::PreProcessingResponse {
- session_token: Some(session_token),
- ..
- }) = router_data.response.to_owned()
- {
- payment_data.push_sessions_token(session_token);
+ let session_token = match router_data.response.to_owned() {
+ Ok(router_types::PaymentsResponseData::PreProcessingResponse {
+ session_token: Some(token),
+ ..
+ }) => Some(token),
+ Ok(router_types::PaymentsResponseData::PaymentsCreateOrderResponse {
+ session_token: Some(token),
+ ..
+ }) => Some(token),
+ _ => None,
+ };
+
+ if let Some(token) = session_token {
+ payment_data.push_sessions_token(token);
};
// In case of authorize flow, pre-task and post-tasks are being called in build request
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index 78cf708459..68af9235be 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -937,10 +937,19 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
let order_create_response = order_create_response_router_data.response.clone();
let create_order_resp = match &order_create_response {
- Ok(types::PaymentsResponseData::PaymentsCreateOrderResponse { order_id }) => {
+ Ok(types::PaymentsResponseData::PaymentsCreateOrderResponse {
+ order_id,
+ session_token,
+ }) => {
+ let should_continue_further = if session_token.is_some() {
+ // if SDK session token is returned in order create response, do not continue and return control to SDK
+ false
+ } else {
+ should_continue_payment
+ };
types::CreateOrderResult {
create_order_result: Ok(order_id.clone()),
- should_continue_further: should_continue_payment,
+ should_continue_further,
}
}
// Some connector return PreProcessingResponse and TransactionResponse response type
diff --git a/crates/router/src/core/payments/flows/external_proxy_flow.rs b/crates/router/src/core/payments/flows/external_proxy_flow.rs
index be8da9f69c..ca5e7575af 100644
--- a/crates/router/src/core/payments/flows/external_proxy_flow.rs
+++ b/crates/router/src/core/payments/flows/external_proxy_flow.rs
@@ -312,8 +312,10 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
let create_order_resp = match resp.response {
Ok(res) => {
- if let types::PaymentsResponseData::PaymentsCreateOrderResponse { order_id } =
- res
+ if let types::PaymentsResponseData::PaymentsCreateOrderResponse {
+ order_id,
+ ..
+ } = res
{
Ok(order_id)
} else {
diff --git a/crates/router/src/core/payments/gateway/create_order_gateway.rs b/crates/router/src/core/payments/gateway/create_order_gateway.rs
index e7873c274c..64d878de1a 100644
--- a/crates/router/src/core/payments/gateway/create_order_gateway.rs
+++ b/crates/router/src/core/payments/gateway/create_order_gateway.rs
@@ -130,11 +130,15 @@ where
let (router_data_response, status_code) =
handle_unified_connector_service_response_for_create_order(
create_order_response.clone(),
+ router_data.status,
)
.attach_printable("Failed to deserialize UCS response")?;
let router_data_response = match router_data_response {
- Ok(response) => Ok(response),
+ Ok((response, status)) => {
+ router_data.status = status;
+ Ok(response)
+ }
Err(err) => {
logger::debug!("Error in UCS router data response");
if let Some(attempt_status) = err.attempt_status {
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index 06f791cf8f..3e27d988e5 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -2528,9 +2528,14 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
}
None => (None, None, None),
},
- types::PaymentsResponseData::PaymentsCreateOrderResponse { .. } => {
- (None, None, None)
- }
+ types::PaymentsResponseData::PaymentsCreateOrderResponse { .. } => (
+ None,
+ Some(storage::PaymentAttemptUpdate::StatusUpdate {
+ status: updated_attempt_status,
+ updated_by: processor.get_account().storage_scheme.to_string(),
+ }),
+ None,
+ ),
types::PaymentsResponseData::PostCaptureVoidResponse { .. } => {
(None, None, None)
}
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index e111abc8c3..70b3e6a747 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -172,6 +172,14 @@ type UnifiedConnectorServiceResult = CustomResult<
type UnifiedConnectorServiceRefundResult =
CustomResult<(Result<RefundsResponseData, ErrorResponse>, u16), UnifiedConnectorServiceError>;
+type UnifiedConnectorServiceCreateOrderResult = CustomResult<
+ (
+ Result<(PaymentsResponseData, AttemptStatus), ErrorResponse>,
+ u16,
+ ),
+ UnifiedConnectorServiceError,
+>;
+
/// Checks if the Unified Connector Service (UCS) is available for use
async fn check_ucs_availability(state: &SessionState) -> UcsAvailability {
let is_client_available = state.grpc_client.unified_connector_service_client.is_some();
@@ -1561,12 +1569,15 @@ pub fn handle_unified_connector_service_response_for_create_connector_customer(
pub fn handle_unified_connector_service_response_for_create_order(
response: payments_grpc::PaymentServiceCreateOrderResponse,
-) -> CustomResult<(Result<PaymentsResponseData, ErrorResponse>, u16), UnifiedConnectorServiceError>
-{
+ prev_status: AttemptStatus,
+) -> UnifiedConnectorServiceCreateOrderResult {
let status_code = transformers::convert_connector_service_status_code(response.status_code)?;
let router_data_response =
- Result::<PaymentsResponseData, ErrorResponse>::foreign_try_from(response)?;
+ Result::<(PaymentsResponseData, AttemptStatus), ErrorResponse>::foreign_try_from((
+ response,
+ prev_status,
+ ))?;
Ok((router_data_response, status_code))
}
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index d80ca922de..9ca639bb38 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -636,6 +636,11 @@ impl
merchant_account_metadata,
state,
test_mode: router_data.test_mode,
+ payment_method_type: router_data
+ .payment_method_type
+ .map(payments_grpc::PaymentMethodType::foreign_try_from)
+ .transpose()?
+ .map(|payment_method_type| payment_method_type.into()),
})
}
}
@@ -4231,23 +4236,37 @@ impl ForeignFrom<common_enums::PaymentMethodType> for payments_grpc::PaymentMeth
}
}
-impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreateOrderResponse>
- for Result<PaymentsResponseData, ErrorResponse>
+impl
+ transformers::ForeignTryFrom<(
+ payments_grpc::PaymentServiceCreateOrderResponse,
+ AttemptStatus,
+ )> for Result<(PaymentsResponseData, AttemptStatus), ErrorResponse>
{
type Error = error_stack::Report<UnifiedConnectorServiceError>;
fn foreign_try_from(
- response: payments_grpc::PaymentServiceCreateOrderResponse,
+ (response, prev_status): (
+ payments_grpc::PaymentServiceCreateOrderResponse,
+ AttemptStatus,
+ ),
) -> Result<Self, Self::Error> {
let status_code = convert_connector_service_status_code(response.status_code)?;
let response = if response.error_code.is_some() {
+ let attempt_status = match response.status() {
+ payments_grpc::PaymentStatus::AttemptStatusUnspecified => None,
+ _ => Some(AttemptStatus::foreign_try_from((
+ response.status(),
+ prev_status,
+ ))?),
+ };
+
Err(ErrorResponse {
code: response.error_code().to_owned(),
message: response.error_message().to_owned(),
reason: Some(response.error_message().to_owned()),
status_code,
- attempt_status: None,
+ attempt_status,
connector_transaction_id: None,
connector_response_reference_id: None,
network_decline_code: None,
@@ -4258,6 +4277,7 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreateOrderRespon
} else {
let order_id = response
.order_id
+ .clone()
.and_then(|id| id.id_type)
.and_then(|id_type| match id_type {
payments_grpc::identifier::IdType::Id(id) => Some(id),
@@ -4268,9 +4288,22 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreateOrderRespon
})
.ok_or(UnifiedConnectorServiceError::ResponseDeserializationFailed)?;
+ let status = AttemptStatus::foreign_try_from((response.status(), prev_status))?;
+
+ let session_token = response
+ .session_token
+ .map(SessionToken::foreign_try_from)
+ .transpose()?;
+
// For order creation, we typically return a successful response with the order_id
// Since this is not a standard payment response, we'll create a simple success response
- Ok(PaymentsResponseData::PaymentsCreateOrderResponse { order_id })
+ Ok((
+ PaymentsResponseData::PaymentsCreateOrderResponse {
+ order_id,
+ session_token,
+ },
+ status,
+ ))
};
Ok(response)