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

refactor(payment_methods): insert payment_method_id in redis for wallet tokens (#3989)

Chethan Raod997e298f261
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index df1fb1e358..220a28771c 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -192,6 +192,8 @@ impl PaymentMethodRetrieve for Oss {
)
.await
}
+
+ storage::PaymentTokenData::WalletToken(_) => Ok(None),
}
}
}
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 3f4248c4b3..fccacfef45 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -2820,6 +2820,12 @@ pub async fn list_customer_payment_method(
}
}
+ enums::PaymentMethod::Wallet => (
+ None,
+ None,
+ PaymentTokenData::wallet_token(pm.payment_method_id.clone()),
+ ),
+
_ => (
None,
None,
diff --git a/crates/router/src/types/storage/payment_method.rs b/crates/router/src/types/storage/payment_method.rs
index dee7a8d452..ba6e1b1320 100644
--- a/crates/router/src/types/storage/payment_method.rs
+++ b/crates/router/src/types/storage/payment_method.rs
@@ -24,6 +24,11 @@ pub struct GenericTokenData {
pub token: String,
}
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+pub struct WalletTokenData {
+ pub payment_method_id: String,
+}
+
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum PaymentTokenData {
@@ -34,6 +39,7 @@ pub enum PaymentTokenData {
Permanent(CardTokenData),
PermanentCard(CardTokenData),
AuthBankDebit(payment_methods::BankAccountConnectorDetails),
+ WalletToken(WalletTokenData),
}
impl PaymentTokenData {
@@ -52,6 +58,10 @@ impl PaymentTokenData {
pub fn temporary_generic(token: String) -> Self {
Self::TemporaryGeneric(GenericTokenData { token })
}
+
+ pub fn wallet_token(payment_method_id: String) -> Self {
+ Self::WalletToken(WalletTokenData { payment_method_id })
+ }
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]