mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(payment_method_data): populate additional payment method data fields across all the methods in payments response (#5788)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -225,7 +225,7 @@ impl
|
||||
customer_email: Some(item.router_data.get_billing_email()?),
|
||||
}))
|
||||
}
|
||||
domain::BankRedirectData::Interac {} => {
|
||||
domain::BankRedirectData::Interac { .. } => {
|
||||
Self::BankRedirect(Box::new(BankRedirectionPMData {
|
||||
payment_brand: PaymentBrand::InteracOnline,
|
||||
bank_account_country: Some(item.router_data.get_billing_country()?),
|
||||
@ -238,7 +238,7 @@ impl
|
||||
customer_email: Some(item.router_data.get_billing_email()?),
|
||||
}))
|
||||
}
|
||||
domain::BankRedirectData::Trustly {} => {
|
||||
domain::BankRedirectData::Trustly { .. } => {
|
||||
Self::BankRedirect(Box::new(BankRedirectionPMData {
|
||||
payment_brand: PaymentBrand::Trustly,
|
||||
bank_account_country: None,
|
||||
|
||||
@ -2951,7 +2951,7 @@ fn get_redirect_extra_details(
|
||||
let country = item.get_optional_billing_country();
|
||||
Ok((preferred_language.clone(), country))
|
||||
}
|
||||
domain::BankRedirectData::Trustly {}
|
||||
domain::BankRedirectData::Trustly { .. }
|
||||
| domain::BankRedirectData::OpenBankingUk { .. } => {
|
||||
let country = item.get_optional_billing_country();
|
||||
Ok((None, country))
|
||||
|
||||
@ -285,6 +285,7 @@ impl TryFrom<(&domain::BankDebitData, &types::TokenizationRouterData)> for Custo
|
||||
domain::BankDebitData::BecsBankDebit {
|
||||
account_number,
|
||||
bsb_number,
|
||||
..
|
||||
} => {
|
||||
let country_code = item.get_billing_country()?;
|
||||
let account_holder_name = item.get_billing_full_name()?;
|
||||
|
||||
@ -160,7 +160,7 @@ impl
|
||||
| domain::BankRedirectData::Giropay { .. }
|
||||
| domain::BankRedirectData::Interac { .. }
|
||||
| domain::BankRedirectData::OnlineBankingCzechRepublic { .. }
|
||||
| domain::BankRedirectData::OnlineBankingFinland {}
|
||||
| domain::BankRedirectData::OnlineBankingFinland { .. }
|
||||
| domain::BankRedirectData::OnlineBankingPoland { .. }
|
||||
| domain::BankRedirectData::OnlineBankingSlovakia { .. }
|
||||
| domain::BankRedirectData::OpenBankingUk { .. }
|
||||
|
||||
@ -265,7 +265,7 @@ fn get_payment_source(
|
||||
bank_redirection_data: &domain::BankRedirectData,
|
||||
) -> Result<PaymentSourceItem, error_stack::Report<errors::ConnectorError>> {
|
||||
match bank_redirection_data {
|
||||
domain::BankRedirectData::Eps { bank_name: _ } => {
|
||||
domain::BankRedirectData::Eps { bank_name: _, .. } => {
|
||||
Ok(PaymentSourceItem::Eps(RedirectRequest {
|
||||
name: item.get_billing_full_name()?,
|
||||
country_code: item.get_billing_country()?,
|
||||
@ -315,6 +315,7 @@ fn get_payment_source(
|
||||
}
|
||||
domain::BankRedirectData::Sofort {
|
||||
preferred_language: _,
|
||||
..
|
||||
} => Ok(PaymentSourceItem::Sofort(RedirectRequest {
|
||||
name: item.get_billing_full_name()?,
|
||||
country_code: item.get_billing_country()?,
|
||||
|
||||
@ -4,14 +4,19 @@ use std::{borrow::Cow, str::FromStr};
|
||||
use api_models::customers::CustomerRequestWithEmail;
|
||||
use api_models::{
|
||||
mandates::RecurringDetails,
|
||||
payments::{AddressDetailsWithPhone, RequestSurchargeDetails},
|
||||
payments::{
|
||||
additional_info as payment_additional_types, AddressDetailsWithPhone,
|
||||
RequestSurchargeDetails,
|
||||
},
|
||||
};
|
||||
use base64::Engine;
|
||||
use common_enums::ConnectorType;
|
||||
use common_utils::{
|
||||
crypto::Encryptable,
|
||||
ext_traits::{AsyncExt, ByteSliceExt, Encode, ValueExt},
|
||||
fp_utils, generate_id, id_type, pii, type_name,
|
||||
fp_utils, generate_id, id_type,
|
||||
new_type::{MaskedIban, MaskedSortCode},
|
||||
pii, type_name,
|
||||
types::{
|
||||
keymanager::{Identifier, KeyManagerState, ToEncryptable},
|
||||
MinorUnit,
|
||||
@ -3933,16 +3938,69 @@ pub async fn get_additional_payment_data(
|
||||
domain::BankRedirectData::Eps { bank_name, .. } => {
|
||||
Some(api_models::payments::AdditionalPaymentData::BankRedirect {
|
||||
bank_name: bank_name.to_owned(),
|
||||
details: None,
|
||||
})
|
||||
}
|
||||
domain::BankRedirectData::Ideal { bank_name, .. } => {
|
||||
Some(api_models::payments::AdditionalPaymentData::BankRedirect {
|
||||
bank_name: bank_name.to_owned(),
|
||||
details: None,
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
Some(api_models::payments::AdditionalPaymentData::BankRedirect { bank_name: None })
|
||||
domain::BankRedirectData::BancontactCard {
|
||||
card_number,
|
||||
card_exp_month,
|
||||
card_exp_year,
|
||||
card_holder_name,
|
||||
} => Some(api_models::payments::AdditionalPaymentData::BankRedirect {
|
||||
bank_name: None,
|
||||
details: Some(
|
||||
payment_additional_types::BankRedirectDetails::BancontactCard(Box::new(
|
||||
payment_additional_types::BancontactBankRedirectAdditionalData {
|
||||
last4: card_number.as_ref().map(|c| c.get_last4()),
|
||||
card_exp_month: card_exp_month.clone(),
|
||||
card_exp_year: card_exp_year.clone(),
|
||||
card_holder_name: card_holder_name.clone(),
|
||||
},
|
||||
)),
|
||||
),
|
||||
}),
|
||||
domain::BankRedirectData::Blik { blik_code } => {
|
||||
Some(api_models::payments::AdditionalPaymentData::BankRedirect {
|
||||
bank_name: None,
|
||||
details: blik_code.as_ref().map(|blik_code| {
|
||||
payment_additional_types::BankRedirectDetails::Blik(Box::new(
|
||||
payment_additional_types::BlikBankRedirectAdditionalData {
|
||||
blik_code: Some(blik_code.to_owned()),
|
||||
},
|
||||
))
|
||||
}),
|
||||
})
|
||||
}
|
||||
domain::BankRedirectData::Giropay {
|
||||
bank_account_bic,
|
||||
bank_account_iban,
|
||||
country,
|
||||
} => Some(api_models::payments::AdditionalPaymentData::BankRedirect {
|
||||
bank_name: None,
|
||||
details: Some(payment_additional_types::BankRedirectDetails::Giropay(
|
||||
Box::new(
|
||||
payment_additional_types::GiropayBankRedirectAdditionalData {
|
||||
bic: bank_account_bic
|
||||
.as_ref()
|
||||
.map(|bic| MaskedSortCode::from(bic.to_owned())),
|
||||
iban: bank_account_iban
|
||||
.as_ref()
|
||||
.map(|iban| MaskedIban::from(iban.to_owned())),
|
||||
country: *country,
|
||||
},
|
||||
),
|
||||
)),
|
||||
}),
|
||||
_ => Some(api_models::payments::AdditionalPaymentData::BankRedirect {
|
||||
bank_name: None,
|
||||
details: None,
|
||||
}),
|
||||
},
|
||||
domain::PaymentMethodData::Wallet(wallet) => match wallet {
|
||||
domain::WalletData::ApplePay(apple_pay_wallet_data) => {
|
||||
@ -3959,14 +4017,20 @@ pub async fn get_additional_payment_data(
|
||||
domain::PaymentMethodData::PayLater(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::PayLater { klarna_sdk: None })
|
||||
}
|
||||
domain::PaymentMethodData::BankTransfer(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::BankTransfer {})
|
||||
domain::PaymentMethodData::BankTransfer(bank_transfer) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::BankTransfer {
|
||||
details: Some((*(bank_transfer.to_owned())).into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::Crypto(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Crypto {})
|
||||
domain::PaymentMethodData::Crypto(crypto) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Crypto {
|
||||
details: Some(crypto.to_owned().into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::BankDebit(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::BankDebit {})
|
||||
domain::PaymentMethodData::BankDebit(bank_debit) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::BankDebit {
|
||||
details: Some(bank_debit.to_owned().into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::MandatePayment => {
|
||||
Some(api_models::payments::AdditionalPaymentData::MandatePayment {})
|
||||
@ -3974,26 +4038,40 @@ pub async fn get_additional_payment_data(
|
||||
domain::PaymentMethodData::Reward => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Reward {})
|
||||
}
|
||||
domain::PaymentMethodData::RealTimePayment(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::RealTimePayment {})
|
||||
domain::PaymentMethodData::RealTimePayment(realtime_payment) => Some(
|
||||
api_models::payments::AdditionalPaymentData::RealTimePayment {
|
||||
details: Some((*(realtime_payment.to_owned())).into()),
|
||||
},
|
||||
),
|
||||
domain::PaymentMethodData::Upi(upi) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Upi {
|
||||
details: Some(upi.to_owned().into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::Upi(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Upi {})
|
||||
domain::PaymentMethodData::CardRedirect(card_redirect) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::CardRedirect {
|
||||
details: Some(card_redirect.to_owned().into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::CardRedirect(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::CardRedirect {})
|
||||
domain::PaymentMethodData::Voucher(voucher) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Voucher {
|
||||
details: Some(voucher.to_owned().into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::Voucher(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Voucher {})
|
||||
domain::PaymentMethodData::GiftCard(gift_card) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::GiftCard {
|
||||
details: Some((*(gift_card.to_owned())).into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::GiftCard(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::GiftCard {})
|
||||
domain::PaymentMethodData::CardToken(card_token) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::CardToken {
|
||||
details: Some(card_token.to_owned().into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::CardToken(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::CardToken {})
|
||||
}
|
||||
domain::PaymentMethodData::OpenBanking(_) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::OpenBanking {})
|
||||
domain::PaymentMethodData::OpenBanking(open_banking) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::OpenBanking {
|
||||
details: Some(open_banking.to_owned().into()),
|
||||
})
|
||||
}
|
||||
domain::PaymentMethodData::NetworkToken(_) => None,
|
||||
}
|
||||
|
||||
@ -860,17 +860,21 @@ pub async fn retrieve_payment_method_from_auth_service(
|
||||
bank_name: None,
|
||||
bank_type,
|
||||
bank_holder_type: None,
|
||||
card_holder_name: None,
|
||||
bank_account_holder_name: None,
|
||||
})
|
||||
}
|
||||
pm_auth_types::PaymentMethodTypeDetails::Bacs(bacs) => {
|
||||
domain::PaymentMethodData::BankDebit(domain::BankDebitData::BacsBankDebit {
|
||||
account_number: bacs.account_number.clone(),
|
||||
sort_code: bacs.sort_code.clone(),
|
||||
bank_account_holder_name: None,
|
||||
})
|
||||
}
|
||||
pm_auth_types::PaymentMethodTypeDetails::Sepa(sepa) => {
|
||||
domain::PaymentMethodData::BankDebit(domain::BankDebitData::SepaBankDebit {
|
||||
iban: sepa.iban.clone(),
|
||||
bank_account_holder_name: None,
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user