mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
feat(core): billing_details inclusion in Payment Intent (#5090)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -3151,6 +3151,7 @@ mod tests {
|
||||
charges: None,
|
||||
frm_metadata: None,
|
||||
customer_details: None,
|
||||
billing_details: None,
|
||||
merchant_order_reference_id: None,
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
@ -3212,6 +3213,7 @@ mod tests {
|
||||
charges: None,
|
||||
frm_metadata: None,
|
||||
customer_details: None,
|
||||
billing_details: None,
|
||||
merchant_order_reference_id: None,
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
@ -3272,6 +3274,7 @@ mod tests {
|
||||
charges: None,
|
||||
frm_metadata: None,
|
||||
customer_details: None,
|
||||
billing_details: None,
|
||||
merchant_order_reference_id: None,
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
|
||||
@ -22,6 +22,7 @@ use crate::{
|
||||
blocklist::utils as blocklist_utils,
|
||||
errors::{self, CustomResult, RouterResult, StorageErrorExt},
|
||||
mandate::helpers as m_helpers,
|
||||
payment_methods::cards::create_encrypted_data,
|
||||
payments::{
|
||||
self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress,
|
||||
PaymentData,
|
||||
@ -1218,6 +1219,10 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
|
||||
.in_current_span(),
|
||||
);
|
||||
|
||||
let billing_address = payment_data.address.get_payment_billing();
|
||||
let billing_details = billing_address
|
||||
.async_and_then(|_| async { create_encrypted_data(key_store, billing_address).await })
|
||||
.await;
|
||||
let m_payment_data_payment_intent = payment_data.payment_intent.clone();
|
||||
let m_customer_id = customer_id.clone();
|
||||
let m_shipping_address_id = shipping_address_id.clone();
|
||||
@ -1263,6 +1268,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
|
||||
frm_metadata: m_frm_metadata,
|
||||
customer_details,
|
||||
merchant_order_reference_id: None,
|
||||
billing_details,
|
||||
},
|
||||
&m_key_store,
|
||||
storage_scheme,
|
||||
|
||||
@ -1045,6 +1045,16 @@ impl PaymentCreate {
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)?
|
||||
.map(Secret::new);
|
||||
|
||||
// Derivation of directly supplied Billing Address data in our Payment Create Request
|
||||
// Encrypting our Billing Address Details to be stored in Payment Intent
|
||||
let billing_details = request
|
||||
.billing
|
||||
.clone()
|
||||
.async_and_then(|_| async {
|
||||
create_encrypted_data(key_store, request.billing.clone()).await
|
||||
})
|
||||
.await;
|
||||
|
||||
// Derivation of directly supplied Customer data in our Payment Create Request
|
||||
let raw_customer_details = if request.customer_id.is_none()
|
||||
&& (request.name.is_some()
|
||||
@ -1116,6 +1126,7 @@ impl PaymentCreate {
|
||||
.request_external_three_ds_authentication,
|
||||
charges,
|
||||
frm_metadata: request.frm_metadata.clone(),
|
||||
billing_details,
|
||||
customer_details,
|
||||
merchant_order_reference_id: request.merchant_order_reference_id.clone(),
|
||||
})
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use api_models::{
|
||||
enums::FrmSuggestion, mandates::RecurringDetails, payments::RequestSurchargeDetails,
|
||||
enums::FrmSuggestion,
|
||||
mandates::RecurringDetails,
|
||||
payments::{Address, RequestSurchargeDetails},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use common_utils::{
|
||||
@ -18,6 +20,7 @@ use crate::{
|
||||
core::{
|
||||
errors::{self, CustomResult, RouterResult, StorageErrorExt},
|
||||
mandate::helpers as m_helpers,
|
||||
payment_methods::cards::create_encrypted_data,
|
||||
payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData},
|
||||
utils as core_utils,
|
||||
},
|
||||
@ -218,6 +221,14 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
|
||||
)
|
||||
.await?;
|
||||
|
||||
let billing_details: Option<Address> = billing_address.as_ref().map(From::from);
|
||||
payment_intent.billing_details = billing_details
|
||||
.clone()
|
||||
.async_and_then(|_| async {
|
||||
create_encrypted_data(key_store, billing_details.clone()).await
|
||||
})
|
||||
.await;
|
||||
|
||||
let payment_method_billing = helpers::create_or_update_address_for_payment_by_request(
|
||||
db,
|
||||
request
|
||||
@ -438,7 +449,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
|
||||
customer_acceptance,
|
||||
address: PaymentAddress::new(
|
||||
shipping_address.as_ref().map(From::from),
|
||||
billing_address.as_ref().map(From::from),
|
||||
billing_details,
|
||||
payment_method_billing.as_ref().map(From::from),
|
||||
business_profile.use_billing_as_payment_method_billing,
|
||||
),
|
||||
@ -716,7 +727,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
|
||||
.payment_intent
|
||||
.merchant_order_reference_id
|
||||
.clone();
|
||||
|
||||
let billing_details = payment_data.payment_intent.billing_details.clone();
|
||||
payment_data.payment_intent = state
|
||||
.store
|
||||
.update_payment_intent(
|
||||
@ -747,6 +758,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
|
||||
frm_metadata,
|
||||
customer_details,
|
||||
merchant_order_reference_id,
|
||||
billing_details,
|
||||
},
|
||||
key_store,
|
||||
storage_scheme,
|
||||
|
||||
Reference in New Issue
Block a user