mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
refactor(payment_methods): refactor customer payment methods list v2 code to follow better code practices (#6433)
This commit is contained in:
@ -32,7 +32,7 @@ use crate::{
|
||||
self,
|
||||
api::{self, CardDetailFromLocker, CardDetailsPaymentMethod, PaymentMethodCreateExt},
|
||||
domain,
|
||||
storage::{self, enums as storage_enums},
|
||||
storage::enums as storage_enums,
|
||||
},
|
||||
utils::{generate_id, OptionExt},
|
||||
};
|
||||
@ -1149,9 +1149,9 @@ pub fn add_connector_mandate_details_in_payment_method(
|
||||
authorized_currency: Option<storage_enums::Currency>,
|
||||
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
connector_mandate_id: Option<String>,
|
||||
mandate_metadata: Option<serde_json::Value>,
|
||||
mandate_metadata: Option<Secret<serde_json::Value>>,
|
||||
connector_mandate_request_reference_id: Option<String>,
|
||||
) -> Option<storage::PaymentsMandateReference> {
|
||||
) -> Option<diesel_models::PaymentsMandateReference> {
|
||||
let mut mandate_details = HashMap::new();
|
||||
|
||||
if let Some((mca_id, connector_mandate_id)) =
|
||||
@ -1159,7 +1159,7 @@ pub fn add_connector_mandate_details_in_payment_method(
|
||||
{
|
||||
mandate_details.insert(
|
||||
mca_id,
|
||||
storage::PaymentsMandateReferenceRecord {
|
||||
diesel_models::PaymentsMandateReferenceRecord {
|
||||
connector_mandate_id,
|
||||
payment_method_type,
|
||||
original_payment_authorized_amount: authorized_amount,
|
||||
@ -1169,20 +1169,20 @@ pub fn add_connector_mandate_details_in_payment_method(
|
||||
connector_mandate_request_reference_id,
|
||||
},
|
||||
);
|
||||
Some(storage::PaymentsMandateReference(mandate_details))
|
||||
Some(diesel_models::PaymentsMandateReference(mandate_details))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn update_connector_mandate_details(
|
||||
mandate_details: Option<storage::PaymentsMandateReference>,
|
||||
mandate_details: Option<diesel_models::PaymentsMandateReference>,
|
||||
payment_method_type: Option<storage_enums::PaymentMethodType>,
|
||||
authorized_amount: Option<i64>,
|
||||
authorized_currency: Option<storage_enums::Currency>,
|
||||
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
connector_mandate_id: Option<String>,
|
||||
mandate_metadata: Option<serde_json::Value>,
|
||||
mandate_metadata: Option<Secret<serde_json::Value>>,
|
||||
connector_mandate_request_reference_id: Option<String>,
|
||||
) -> RouterResult<Option<serde_json::Value>> {
|
||||
let mandate_reference = match mandate_details {
|
||||
@ -1190,7 +1190,7 @@ pub fn update_connector_mandate_details(
|
||||
if let Some((mca_id, connector_mandate_id)) =
|
||||
merchant_connector_id.clone().zip(connector_mandate_id)
|
||||
{
|
||||
let updated_record = storage::PaymentsMandateReferenceRecord {
|
||||
let updated_record = diesel_models::PaymentsMandateReferenceRecord {
|
||||
connector_mandate_id: connector_mandate_id.clone(),
|
||||
payment_method_type,
|
||||
original_payment_authorized_amount: authorized_amount,
|
||||
@ -1204,7 +1204,7 @@ pub fn update_connector_mandate_details(
|
||||
payment_mandate_reference
|
||||
.entry(mca_id)
|
||||
.and_modify(|pm| *pm = updated_record)
|
||||
.or_insert(storage::PaymentsMandateReferenceRecord {
|
||||
.or_insert(diesel_models::PaymentsMandateReferenceRecord {
|
||||
connector_mandate_id,
|
||||
payment_method_type,
|
||||
original_payment_authorized_amount: authorized_amount,
|
||||
|
||||
Reference in New Issue
Block a user