feat(payment_methods): added kv support for payment_methods table (#4311)

Co-authored-by: Akshay S <akshay.s@Akshay-Subramanian-D66TQ6D97K.local>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
akshay-97
2024-04-10 19:29:50 +05:30
committed by GitHub
parent 9448673c1c
commit eb3cecdd74
35 changed files with 1017 additions and 315 deletions

View File

@ -5,7 +5,7 @@ use api_models::{
payment_methods::{self, BankAccountAccessCreds},
payments::{AddressDetails, BankDebitBilling, BankDebitData, PaymentMethodData},
};
use common_enums::PaymentMethodType;
use common_enums::{enums::MerchantStorageScheme, PaymentMethodType};
use hex;
pub mod helpers;
pub mod transformers;
@ -455,7 +455,13 @@ async fn store_bank_details_in_payment_methods(
};
}
store_in_db(update_entries, new_entries, db).await?;
store_in_db(
update_entries,
new_entries,
db,
merchant_account.storage_scheme,
)
.await?;
Ok(())
}
@ -464,15 +470,16 @@ async fn store_in_db(
update_entries: Vec<(storage::PaymentMethod, storage::PaymentMethodUpdate)>,
new_entries: Vec<storage::PaymentMethodNew>,
db: &dyn StorageInterface,
storage_scheme: MerchantStorageScheme,
) -> RouterResult<()> {
let update_entries_futures = update_entries
.into_iter()
.map(|(pm, pm_update)| db.update_payment_method(pm, pm_update))
.map(|(pm, pm_update)| db.update_payment_method(pm, pm_update, storage_scheme))
.collect::<Vec<_>>();
let new_entries_futures = new_entries
.into_iter()
.map(|pm_new| db.insert_payment_method(pm_new))
.map(|pm_new| db.insert_payment_method(pm_new, storage_scheme))
.collect::<Vec<_>>();
let update_futures = futures::future::join_all(update_entries_futures);