mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +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)]
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct BankAccountTokenData {
|
pub struct BankAccountTokenData {
|
||||||
pub payment_method_type: api_enums::PaymentMethodType,
|
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 {
|
impl From<GooglePayWalletData> for payment_methods::PaymentMethodDataWalletInfo {
|
||||||
fn from(item: GooglePayWalletData) -> Self {
|
fn from(item: GooglePayWalletData) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@ -1181,6 +1181,22 @@ impl PaymentCreate {
|
|||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
PaymentMethodsData::WalletDetails(wallet) => match payment_method_type {
|
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(enums::PaymentMethodType::GooglePay) => {
|
||||||
Some(api_models::payments::AdditionalPaymentData::Wallet {
|
Some(api_models::payments::AdditionalPaymentData::Wallet {
|
||||||
apple_pay: None,
|
apple_pay: None,
|
||||||
|
|||||||
@ -259,6 +259,12 @@ where
|
|||||||
(Some(card), _) => Some(PaymentMethodsData::Card(
|
(Some(card), _) => Some(PaymentMethodsData::Card(
|
||||||
CardDetailsPaymentMethod::from((card.clone(), co_badged_card_data)),
|
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)),
|
domain::PaymentMethodData::Wallet(domain::WalletData::GooglePay(googlepay)),
|
||||||
|
|||||||
@ -13,8 +13,8 @@ pub use api_models::{
|
|||||||
ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest,
|
ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest,
|
||||||
},
|
},
|
||||||
payments::{
|
payments::{
|
||||||
Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, CryptoData,
|
Address, AddressDetails, Amount, ApplepayPaymentMethod, AuthenticationForStartResponse,
|
||||||
CustomerDetails, CustomerDetailsResponse, HyperswitchVaultSessionDetails,
|
Card, CryptoData, CustomerDetails, CustomerDetailsResponse, HyperswitchVaultSessionDetails,
|
||||||
MandateAmountData, MandateData, MandateTransactionType, MandateType,
|
MandateAmountData, MandateData, MandateTransactionType, MandateType,
|
||||||
MandateValidationFields, NextActionType, OpenBankingSessionToken, PayLaterData,
|
MandateValidationFields, NextActionType, OpenBankingSessionToken, PayLaterData,
|
||||||
PaymentIdType, PaymentListConstraints, PaymentListFilters, PaymentListFiltersV2,
|
PaymentIdType, PaymentListConstraints, PaymentListFilters, PaymentListFiltersV2,
|
||||||
|
|||||||
Reference in New Issue
Block a user