mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 13:30:39 +08:00
feat(payment_methods_v2): Implemented Diesel and Domain models for v2 (#5700)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -247,6 +247,8 @@ where
|
||||
let payment_method = {
|
||||
let existing_pm_by_pmid = db
|
||||
.find_payment_method(
|
||||
&(state.into()),
|
||||
key_store,
|
||||
&payment_method_id,
|
||||
merchant_account.storage_scheme,
|
||||
)
|
||||
@ -257,6 +259,8 @@ where
|
||||
locker_id = Some(payment_method_id.clone());
|
||||
let existing_pm_by_locker_id = db
|
||||
.find_payment_method_by_locker_id(
|
||||
&(state.into()),
|
||||
key_store,
|
||||
&payment_method_id,
|
||||
merchant_account.storage_scheme,
|
||||
)
|
||||
@ -289,6 +293,8 @@ where
|
||||
connector_token,
|
||||
)?;
|
||||
payment_methods::cards::update_payment_method_metadata_and_last_used(
|
||||
state,
|
||||
key_store,
|
||||
db,
|
||||
pm.clone(),
|
||||
pm_metadata,
|
||||
@ -308,7 +314,8 @@ where
|
||||
connector_mandate_id.clone(),
|
||||
)?;
|
||||
|
||||
payment_methods::cards::update_payment_method_connector_mandate_details(db, pm, connector_mandate_details, merchant_account.storage_scheme).await.change_context(
|
||||
payment_methods::cards::update_payment_method_connector_mandate_details(state,
|
||||
key_store,db, pm, connector_mandate_details, merchant_account.storage_scheme).await.change_context(
|
||||
errors::ApiErrorResponse::InternalServerError,
|
||||
)
|
||||
.attach_printable("Failed to update payment method in db")?;
|
||||
@ -356,6 +363,8 @@ where
|
||||
let payment_method = {
|
||||
let existing_pm_by_pmid = db
|
||||
.find_payment_method(
|
||||
&(state.into()),
|
||||
key_store,
|
||||
&payment_method_id,
|
||||
merchant_account.storage_scheme,
|
||||
)
|
||||
@ -366,6 +375,8 @@ where
|
||||
locker_id = Some(payment_method_id.clone());
|
||||
let existing_pm_by_locker_id = db
|
||||
.find_payment_method_by_locker_id(
|
||||
&(state.into()),
|
||||
key_store,
|
||||
&payment_method_id,
|
||||
merchant_account.storage_scheme,
|
||||
)
|
||||
@ -406,7 +417,8 @@ where
|
||||
connector_mandate_id.clone(),
|
||||
)?;
|
||||
|
||||
payment_methods::cards::update_payment_method_connector_mandate_details(db, pm.clone(), connector_mandate_details, merchant_account.storage_scheme).await.change_context(
|
||||
payment_methods::cards::update_payment_method_connector_mandate_details( state,
|
||||
key_store,db, pm.clone(), connector_mandate_details, merchant_account.storage_scheme).await.change_context(
|
||||
errors::ApiErrorResponse::InternalServerError,
|
||||
)
|
||||
.attach_printable("Failed to update payment method in db")?;
|
||||
@ -481,6 +493,8 @@ where
|
||||
if let Err(err) = add_card_resp {
|
||||
logger::error!(vault_err=?err);
|
||||
db.delete_payment_method_by_merchant_id_payment_method_id(
|
||||
&(state.into()),
|
||||
key_store,
|
||||
merchant_id,
|
||||
&resp.payment_method_id,
|
||||
)
|
||||
@ -495,9 +509,7 @@ where
|
||||
))?
|
||||
};
|
||||
|
||||
let existing_pm_data = payment_methods::cards::get_card_details_without_locker_fallback(&existing_pm,state,
|
||||
key_store,
|
||||
)
|
||||
let existing_pm_data = payment_methods::cards::get_card_details_without_locker_fallback(&existing_pm,state)
|
||||
.await?;
|
||||
|
||||
let updated_card = Some(CardDetailFromLocker {
|
||||
@ -539,6 +551,8 @@ where
|
||||
.attach_printable("Unable to encrypt payment method data")?;
|
||||
|
||||
payment_methods::cards::update_payment_method_and_last_used(
|
||||
state,
|
||||
key_store,
|
||||
db,
|
||||
existing_pm,
|
||||
pm_data_encrypted.map(Into::into),
|
||||
@ -559,6 +573,8 @@ where
|
||||
match state
|
||||
.store
|
||||
.find_payment_method_by_customer_id_merchant_id_list(
|
||||
&(state.into()),
|
||||
key_store,
|
||||
&customer_id,
|
||||
merchant_id,
|
||||
None,
|
||||
@ -594,6 +610,7 @@ where
|
||||
&customer_saved_pm,
|
||||
state,
|
||||
merchant_account.storage_scheme,
|
||||
key_store,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
@ -1007,7 +1024,7 @@ pub fn add_connector_mandate_details_in_payment_method(
|
||||
}
|
||||
|
||||
pub fn update_connector_mandate_details_in_payment_method(
|
||||
payment_method: diesel_models::PaymentMethod,
|
||||
payment_method: domain::PaymentMethod,
|
||||
payment_method_type: Option<storage_enums::PaymentMethodType>,
|
||||
authorized_amount: Option<i64>,
|
||||
authorized_currency: Option<storage_enums::Currency>,
|
||||
|
||||
Reference in New Issue
Block a user