refactor: pass customer object to make_pm_data (#3246)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Chethan Rao
2024-01-09 20:06:28 +05:30
committed by GitHub
parent eba789640b
commit 36c32c377a
17 changed files with 100 additions and 21 deletions

View File

@ -52,6 +52,7 @@ use crate::{
storage,
transformers::ForeignTryFrom,
},
utils::ext_traits::OptionExt,
};
pub async fn create_link_token(
@ -618,6 +619,7 @@ pub async fn retrieve_payment_method_from_auth_service(
key_store: &domain::MerchantKeyStore,
auth_token: &payment_methods::BankAccountConnectorDetails,
payment_intent: &PaymentIntent,
customer: &Option<domain::Customer>,
) -> RouterResult<Option<(PaymentMethodData, enums::PaymentMethod)>> {
let db = state.store.as_ref();
@ -710,10 +712,17 @@ pub async fn retrieve_payment_method_from_auth_service(
last_name,
}
});
let email = customer
.as_ref()
.and_then(|customer| customer.email.clone())
.map(common_utils::pii::Email::from)
.get_required_value("email")?;
let payment_method_data = PaymentMethodData::BankDebit(BankDebitData::AchBankDebit {
billing_details: BankDebitBilling {
name: name.unwrap_or_default(),
email: common_utils::pii::Email::from(masking::Secret::new("".to_string())),
email,
address: address_details,
},
account_number: masking::Secret::new(bank_account.account_number.clone()),