Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(core): populate billing_address for payment with pm_id (#6411)

Sakil Mostak8e58b56b43ad
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index 005b5aeba6..87078dfa5a 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -753,6 +753,7 @@ pub(crate) async fn get_payment_method_create_request(
payment_method_type: Option<storage_enums::PaymentMethodType>,
customer_id: &Option<id_type::CustomerId>,
billing_name: Option<Secret<String>>,
+ payment_method_billing_address: Option<&api_models::payments::Address>,
) -> RouterResult<payment_methods::PaymentMethodCreate> {
match payment_method_data {
Some(pm_data) => match payment_method {
@@ -787,7 +788,7 @@ pub(crate) async fn get_payment_method_create_request(
.map(|card_network| card_network.to_string()),
client_secret: None,
payment_method_data: None,
- billing: None,
+ billing: payment_method_billing_address.cloned(),
connector_mandate_details: None,
network_transaction_id: None,
};
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index ae64fe41b1..6b243ba72a 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -1047,6 +1047,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
where
F: 'b + Clone + Send + Sync,
{
+ let payment_method_billing_address = payment_data.address.get_payment_method_billing();
let billing_name = resp
.address
.get_payment_method_billing()
@@ -1079,7 +1080,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
resp.request.payment_method_type,
key_store,
billing_name,
- None,
+ payment_method_billing_address,
business_profile,
))
.await?;
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index b4e5ade569..43353227c8 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -180,6 +180,7 @@ where
payment_method_type,
&customer_id.clone(),
billing_name,
+ payment_method_billing_address,
)
.await?;
let customer_id = customer_id.to_owned().get_required_value("customer_id")?;