refactor(billing): store payment_method_data_billing for recurring payments (#4513)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Narayan Bhat
2024-05-09 18:42:05 +05:30
committed by GitHub
parent e70d58afc9
commit 55ae0fc5f7
18 changed files with 333 additions and 152 deletions

View File

@ -577,7 +577,7 @@ pub trait CustomerAddress {
customer_id: &str,
key: &[u8],
storage_scheme: storage::enums::MerchantStorageScheme,
) -> CustomResult<domain::Address, common_utils::errors::CryptoError>;
) -> CustomResult<domain::CustomerAddress, common_utils::errors::CryptoError>;
}
#[async_trait::async_trait]
@ -645,9 +645,9 @@ impl CustomerAddress for api_models::customers::CustomerRequest {
customer_id: &str,
key: &[u8],
storage_scheme: storage::enums::MerchantStorageScheme,
) -> CustomResult<domain::Address, common_utils::errors::CryptoError> {
) -> CustomResult<domain::CustomerAddress, common_utils::errors::CryptoError> {
async {
Ok(domain::Address {
let address = domain::Address {
id: None,
city: address_details.city,
country: address_details.country,
@ -685,10 +685,8 @@ impl CustomerAddress for api_models::customers::CustomerRequest {
.async_lift(|inner| encrypt_optional(inner, key))
.await?,
country_code: self.phone_country_code.clone(),
customer_id: Some(customer_id.to_string()),
merchant_id: merchant_id.to_string(),
address_id: generate_id(consts::ID_LENGTH, "add"),
payment_id: None,
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
updated_by: storage_scheme.to_string(),
@ -698,6 +696,11 @@ impl CustomerAddress for api_models::customers::CustomerRequest {
.cloned()
.async_lift(|inner| encrypt_optional(inner.map(|inner| inner.expose()), key))
.await?,
};
Ok(domain::CustomerAddress {
address,
customer_id: customer_id.to_string(),
})
}
.await