Skip to content

Commit

Permalink
fix(payment_methods): insert locker_id as null in case of payment met…
Browse files Browse the repository at this point in the history
…hod not getting stored in locker
  • Loading branch information
Chethan-rao committed Mar 1, 2024
1 parent 0bca3d7 commit fb38238
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion crates/router/src/core/payments/tokenization.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit fb38238

Please sign in to comment.