mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(payments): propagate additional payment method data for apple pay during MIT (#7170)
This commit is contained in:
@ -1053,6 +1053,35 @@ impl From<PaymentMethodDataWalletInfo> for payments::additional_info::WalletAddi
|
||||
}
|
||||
}
|
||||
|
||||
impl From<payments::ApplepayPaymentMethod> for PaymentMethodDataWalletInfo {
|
||||
fn from(item: payments::ApplepayPaymentMethod) -> Self {
|
||||
Self {
|
||||
last4: item
|
||||
.display_name
|
||||
.chars()
|
||||
.rev()
|
||||
.take(4)
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
.rev()
|
||||
.collect(),
|
||||
card_network: item.network,
|
||||
card_type: Some(item.pm_type),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<PaymentMethodDataWalletInfo> for payments::ApplepayPaymentMethod {
|
||||
type Error = error_stack::Report<errors::ValidationError>;
|
||||
fn try_from(item: PaymentMethodDataWalletInfo) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
display_name: item.last4,
|
||||
network: item.card_network,
|
||||
pm_type: item.card_type.get_required_value("card_type")?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct BankAccountTokenData {
|
||||
pub payment_method_type: api_enums::PaymentMethodType,
|
||||
|
||||
@ -1963,6 +1963,25 @@ impl From<Card> for ExtendedCardInfo {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ApplePayWalletData> for payment_methods::PaymentMethodDataWalletInfo {
|
||||
fn from(item: ApplePayWalletData) -> Self {
|
||||
Self {
|
||||
last4: item
|
||||
.payment_method
|
||||
.display_name
|
||||
.chars()
|
||||
.rev()
|
||||
.take(4)
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
.rev()
|
||||
.collect(),
|
||||
card_network: item.payment_method.network,
|
||||
card_type: Some(item.payment_method.pm_type),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<GooglePayWalletData> for payment_methods::PaymentMethodDataWalletInfo {
|
||||
fn from(item: GooglePayWalletData) -> Self {
|
||||
Self {
|
||||
|
||||
@ -1181,6 +1181,22 @@ impl PaymentCreate {
|
||||
)))
|
||||
}
|
||||
PaymentMethodsData::WalletDetails(wallet) => match payment_method_type {
|
||||
Some(enums::PaymentMethodType::ApplePay) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Wallet {
|
||||
apple_pay: api::payments::ApplepayPaymentMethod::try_from(
|
||||
wallet,
|
||||
)
|
||||
.inspect_err(|err| {
|
||||
logger::error!(
|
||||
"Unable to transform PaymentMethodDataWalletInfo to ApplepayPaymentMethod: {:?}",
|
||||
err
|
||||
)
|
||||
})
|
||||
.ok(),
|
||||
google_pay: None,
|
||||
samsung_pay: None,
|
||||
})
|
||||
}
|
||||
Some(enums::PaymentMethodType::GooglePay) => {
|
||||
Some(api_models::payments::AdditionalPaymentData::Wallet {
|
||||
apple_pay: None,
|
||||
|
||||
@ -259,6 +259,12 @@ where
|
||||
(Some(card), _) => Some(PaymentMethodsData::Card(
|
||||
CardDetailsPaymentMethod::from((card.clone(), co_badged_card_data)),
|
||||
)),
|
||||
(
|
||||
_,
|
||||
domain::PaymentMethodData::Wallet(domain::WalletData::ApplePay(applepay)),
|
||||
) => Some(PaymentMethodsData::WalletDetails(
|
||||
PaymentMethodDataWalletInfo::from(applepay),
|
||||
)),
|
||||
(
|
||||
_,
|
||||
domain::PaymentMethodData::Wallet(domain::WalletData::GooglePay(googlepay)),
|
||||
|
||||
@ -13,8 +13,8 @@ pub use api_models::{
|
||||
ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest,
|
||||
},
|
||||
payments::{
|
||||
Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, CryptoData,
|
||||
CustomerDetails, CustomerDetailsResponse, HyperswitchVaultSessionDetails,
|
||||
Address, AddressDetails, Amount, ApplepayPaymentMethod, AuthenticationForStartResponse,
|
||||
Card, CryptoData, CustomerDetails, CustomerDetailsResponse, HyperswitchVaultSessionDetails,
|
||||
MandateAmountData, MandateData, MandateTransactionType, MandateType,
|
||||
MandateValidationFields, NextActionType, OpenBankingSessionToken, PayLaterData,
|
||||
PaymentIdType, PaymentListConstraints, PaymentListFilters, PaymentListFiltersV2,
|
||||
|
||||
Reference in New Issue
Block a user