New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(bank-debit): remove billingdetails from bankdebit pmd #4371
Conversation
crates/router/src/connector/utils.rs
Outdated
.and_then(|billing_details| billing_details.address.as_ref()) | ||
.and_then(|billing_address| billing_address.get_optional_full_name()) | ||
.ok_or_else(missing_field_err( | ||
"payment_method_data.billing.address.full_name", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"payment_method_data.billing.address.full_name", | |
"payment_method_data.billing.address.first_name", |
crates/api_models/src/payments.rs
Outdated
address.first_name = bank_account_holder_name | ||
.or(address.first_name.as_ref()) | ||
.cloned(); | ||
address = address.map(|mut address| -> Address { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this changed?
}?; | ||
|
||
let billing_details_name = billing_details.name.expose(); | ||
let billing_details_name = item.get_billing_full_name()?.expose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a secret only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are converting it back to secret while returning.
crates/api_models/src/payments.rs
Outdated
/// The billing address for bank debits | ||
pub address: Option<AddressDetails>, | ||
} | ||
|
||
impl GetAddressFromPaymentMethodData for BankDebitBilling { | ||
fn get_billing_address(&self) -> Option<Address> { | ||
let address = if let Some(mut address) = self.address.clone() { | ||
address.first_name = Some(self.name.clone()); | ||
address.first_name = self.name.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, what if self.name
is none, won't we be overriding the value of address.first_name
? Instead you can put an or()
and then consider address.first_name
. Something like this
address.first_name = self.name.clone().or(address.first_name)
Type of Change
Description
This PR includes changes to use
payment_method_data.billing.name
andpayment_method_data.billing.email
andpayment_method_data.billing_address
instead ofpayment_method_data.[BankDebit->AchBankDebit].BankDebitBilling
andpayment_method_data.[BankDebit->AchBankDebit].bank_account_holder_name
at the connector level. The backwards compatibility is provided.Additional Changes
Motivation and Context
How did you test it?
Response
Response:
Checklist
cargo +nightly fmt --all
cargo clippy