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): insert `locker_id` as null in case of payment method not getting stored in locker (#3919)

Chethan Rao9917dd065444
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 4f69185921..ce7f48405e 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -351,7 +351,13 @@ pub async fn add_payment_method(
None => {
let pm_metadata = resp.metadata.as_ref().map(|data| data.peek());
- let locker_id = Some(resp.payment_method_id);
+ let locker_id = if resp.payment_method == api_enums::PaymentMethod::Card
+ || resp.payment_method == api_enums::PaymentMethod::BankTransfer
+ {
+ Some(resp.payment_method_id)
+ } else {
+ None
+ };
resp.payment_method_id = generate_id(consts::ID_LENGTH, "pm");
insert_payment_method(
db,
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index 21fd4cf85e..1f793e2e18 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -1,4 +1,5 @@
use api_models::payment_methods::PaymentMethodsData;
+use common_enums::PaymentMethod;
use common_utils::{ext_traits::ValueExt, pii};
use error_stack::{report, ResultExt};
use masking::ExposeInterface;
@@ -342,7 +343,11 @@ where
None => {
let pm_metadata = create_payment_method_metadata(None, connector_token)?;
- locker_id = Some(resp.payment_method_id);
+ locker_id = if resp.payment_method == PaymentMethod::Card {
+ Some(resp.payment_method_id)
+ } else {
+ None
+ };
resp.payment_method_id = generate_id(consts::ID_LENGTH, "pm");
payment_methods::cards::create_payment_method(
db,