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(payment-methods): enable decrypted wallet data save for on_session transaction in modular service (#14905)

Sakil Mostak2902a6a332d1
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 71ce68808a..2c62707980 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -5464,6 +5464,22 @@ pub enum WalletData {
WeChatPayRedirect(Box<WeChatPayRedirection>),
}
+impl WalletData {
+ pub fn is_decrypted_flow(&self) -> bool {
+ match self {
+ Self::ApplePay(apple_pay) => match apple_pay.payment_data {
+ common_types::payments::ApplePayPaymentData::Decrypted(_) => true,
+ common_types::payments::ApplePayPaymentData::Encrypted(_) => false,
+ },
+ Self::GooglePay(google_pay) => match google_pay.tokenization_data {
+ common_types::payments::GpayTokenizationData::Decrypted(_) => true,
+ common_types::payments::GpayTokenizationData::Encrypted(_) => false,
+ },
+ _ => false,
+ }
+ }
+}
+
impl GetAddressFromPaymentMethodData for WalletData {
fn get_billing_address(&self) -> Option<Address> {
match self {
diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rs
index 9ee51c8281..3d6cde2706 100644
--- a/crates/hyperswitch_domain_models/src/router_data.rs
+++ b/crates/hyperswitch_domain_models/src/router_data.rs
@@ -558,6 +558,10 @@ impl PaymentMethodToken {
pub fn is_google_pay_decrypt(&self) -> bool {
matches!(self, Self::GooglePayDecrypt(_))
}
+
+ pub fn is_decrypted_flow(&self) -> bool {
+ self.is_apple_pay_decrypt() || self.is_google_pay_decrypt()
+ }
}
impl TryFrom<(api_models::payments::PaymentMethodData, PaymentMethodToken)>
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 301f63b35e..f9348bfe68 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1199,10 +1199,21 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
.as_ref()
.and_then(|pmd| pmd.payment_method_data.as_ref())
{
- Some(api_models::payments::PaymentMethodData::Wallet(_)) => {
- req.setup_future_usage
- .or(payment_data.payment_intent.setup_future_usage)
- == Some(common_enums::FutureUsage::OffSession)
+ Some(api_models::payments::PaymentMethodData::Wallet(
+ wallet_data,
+ )) => {
+ let payment_method_token =
+ payment_data.get_payment_method_token().cloned();
+ let is_decrypted_flow = payment_method_token
+ .map(|pmt| pmt.is_decrypted_flow())
+ .unwrap_or(false)
+ || wallet_data.is_decrypted_flow();
+
+ is_decrypted_flow
+ || req
+ .setup_future_usage
+ .or(payment_data.payment_intent.setup_future_usage)
+ == Some(common_enums::FutureUsage::OffSession)
}
Some(api_models::payments::PaymentMethodData::Card(_))
| Some(api_models::payments::PaymentMethodData::CardWithNoCVC(_))