refactor(router): use the saved billing details in the recurring payments (#5631)

This commit is contained in:
Shankar Singh C
2024-08-14 20:49:52 +05:30
committed by GitHub
parent 56791c2743
commit 5fa7b147aa
2 changed files with 46 additions and 2 deletions

View File

@ -42,7 +42,7 @@ pub async fn construct_payment_router_data<'a, F, T>(
payment_data: PaymentData<F>,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
key_store: &domain::MerchantKeyStore,
customer: &'a Option<domain::Customer>,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
merchant_recipient_data: Option<types::MerchantRecipientData>,
@ -135,6 +135,26 @@ where
Some(merchant_connector_account),
);
let unified_address =
if let Some(payment_method_info) = payment_data.payment_method_info.clone() {
let payment_method_billing =
crate::core::payment_methods::cards::decrypt_generic_data::<Address>(
state,
payment_method_info.payment_method_billing_address,
key_store,
)
.await
.attach_printable("unable to decrypt payment method billing address details")?;
payment_data
.address
.clone()
.unify_with_payment_data_billing(payment_method_billing)
} else {
payment_data.address
};
crate::logger::debug!("unified address details {:?}", unified_address);
router_data = types::RouterData {
flow: PhantomData,
merchant_id: merchant_account.get_id().clone(),
@ -147,7 +167,7 @@ where
connector_auth_type: auth_type,
description: payment_data.payment_intent.description.clone(),
return_url: payment_data.payment_intent.return_url.clone(),
address: payment_data.address.clone(),
address: unified_address,
auth_type: payment_data
.payment_attempt
.authentication_type