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(unified_connector_service): scope Google Pay decrypted-token substitution to connectors that consume it (#13213)

Amitsingh Tanwar924753b583a7
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index 1d15c96f8c..1f0612d4e3 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -46,9 +46,10 @@ use crate::{
errors::{self, RouterResult},
payments::{
helpers::{
- is_ucs_enabled, should_execute_based_on_rollout,
- should_execute_based_on_rollout_with_precedence, MerchantConnectorAccountType,
- ProxyOverride, WebhookRolloutConfig, WebhookRolloutExecutionResult,
+ is_googlepay_predecrypted_flow_supported, is_ucs_enabled,
+ should_execute_based_on_rollout, should_execute_based_on_rollout_with_precedence,
+ MerchantConnectorAccountType, ProxyOverride, WebhookRolloutConfig,
+ WebhookRolloutExecutionResult,
},
OperationSessionGetters, OperationSessionSetters,
},
@@ -87,12 +88,14 @@ fn get_apple_pay_payment_data(
}
}
-/// Returns Google Pay tokenization data from payment method token when it has decrypt data,
-/// otherwise returns the original tokenization data.
fn get_google_pay_tokenization_data(
tokenization_data: &common_types::payments::GpayTokenizationData,
payment_method_token: Option<&PaymentMethodToken>,
+ connector_meta_data: Option<&common_utils::pii::SecretSerdeValue>,
) -> common_types::payments::GpayTokenizationData {
+ if !is_googlepay_predecrypted_flow_supported(connector_meta_data.cloned()) {
+ return tokenization_data.clone();
+ }
match (tokenization_data, payment_method_token) {
(
common_types::payments::GpayTokenizationData::Encrypted(_),
@@ -759,6 +762,7 @@ pub fn build_unified_connector_service_payment_method(
payment_method_data: hyperswitch_domain_models::payment_method_data::PaymentMethodData,
payment_method_type: Option<PaymentMethodType>,
payment_method_token: Option<&PaymentMethodToken>,
+ connector_meta_data: Option<&common_utils::pii::SecretSerdeValue>,
) -> CustomResult<payments_grpc::PaymentMethod, UnifiedConnectorServiceError> {
match payment_method_data {
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Card(card) => {
@@ -1376,6 +1380,7 @@ pub fn build_unified_connector_service_payment_method(
let google_pay_tokenization_data = get_google_pay_tokenization_data(
&google_pay_wallet_data.tokenization_data,
payment_method_token,
+ connector_meta_data,
);
let tokenization_data =
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index e5d12eeb11..782dd92301 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -303,6 +303,7 @@ impl
router_data.request.payment_method_data.clone(),
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)?;
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
@@ -371,6 +372,7 @@ impl
router_data.request.payment_method_data.clone(),
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)?;
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
@@ -599,6 +601,7 @@ impl
payment_method_data,
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)
})
.transpose()?;
@@ -1135,6 +1138,7 @@ impl
payment_method_data,
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)
})
.transpose()?;
@@ -1240,6 +1244,7 @@ impl
payment_method_data,
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)
})
.transpose()?;
@@ -1328,6 +1333,7 @@ impl
router_data.request.payment_method_data.clone(),
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)?;
let capture_method = router_data
@@ -1505,6 +1511,7 @@ impl
payment_method_data,
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)
})
.transpose()?;
@@ -1645,6 +1652,7 @@ impl
router_data.request.payment_method_data.clone(),
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)?;
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
@@ -2011,8 +2019,11 @@ impl
router_data.request.payment_method_data.clone(),
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)?;
+
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
@@ -2294,6 +2305,7 @@ impl
payment_method_data,
router_data.request.payment_method_type,
router_data.payment_method_token.as_ref(),
+ router_data.connector_meta_data.as_ref(),
)
})
.transpose()?;