feat(core): add Mobile Payment (Direct Carrier Billing) as a payment method (#6196)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sakil Mostak
2024-11-14 01:19:59 +05:30
committed by GitHub
parent 600cf44684
commit d0a041c361
94 changed files with 1111 additions and 310 deletions

View File

@ -274,6 +274,8 @@ fn lower_comparison_inner<O: EuclidDirFilter>(
dir::DirKeyKind::CardRedirectType => lower_enum!(CardRedirectType, value),
dir::DirKeyKind::MobilePaymentType => lower_enum!(MobilePaymentType, value),
dir::DirKeyKind::RealTimePaymentType => lower_enum!(RealTimePaymentType, value),
dir::DirKeyKind::CardBin => {

View File

@ -278,6 +278,13 @@ pub enum DirKeyKind {
props(Category = "Payment Method Types")
)]
OpenBankingType,
#[serde(rename = "mobile_payment")]
#[strum(
serialize = "mobile_payment",
detailed_message = "Supported types of mobile payment method",
props(Category = "Payment Method Types")
)]
MobilePaymentType,
}
pub trait EuclidDirFilter: Sized
@ -327,6 +334,7 @@ impl DirKeyKind {
Self::CardRedirectType => types::DataType::EnumVariant,
Self::RealTimePaymentType => types::DataType::EnumVariant,
Self::OpenBankingType => types::DataType::EnumVariant,
Self::MobilePaymentType => types::DataType::EnumVariant,
}
}
pub fn get_value_set(&self) -> Option<Vec<DirValue>> {
@ -459,6 +467,11 @@ impl DirKeyKind {
.map(DirValue::OpenBankingType)
.collect(),
),
Self::MobilePaymentType => Some(
enums::MobilePaymentType::iter()
.map(DirValue::MobilePaymentType)
.collect(),
),
}
}
}
@ -528,6 +541,8 @@ pub enum DirValue {
RealTimePaymentType(enums::RealTimePaymentType),
#[serde(rename = "open_banking")]
OpenBankingType(enums::OpenBankingType),
#[serde(rename = "mobile_payment")]
MobilePaymentType(enums::MobilePaymentType),
}
impl DirValue {
@ -563,6 +578,7 @@ impl DirValue {
Self::GiftCardType(_) => (DirKeyKind::GiftCardType, None),
Self::RealTimePaymentType(_) => (DirKeyKind::RealTimePaymentType, None),
Self::OpenBankingType(_) => (DirKeyKind::OpenBankingType, None),
Self::MobilePaymentType(_) => (DirKeyKind::MobilePaymentType, None),
};
DirKey::new(kind, data)
@ -599,6 +615,7 @@ impl DirValue {
Self::CardRedirectType(_) => None,
Self::RealTimePaymentType(_) => None,
Self::OpenBankingType(_) => None,
Self::MobilePaymentType(_) => None,
}
}

View File

@ -255,6 +255,25 @@ pub enum CardRedirectType {
CardRedirect,
}
#[derive(
Clone,
Debug,
Hash,
PartialEq,
Eq,
strum::Display,
strum::VariantNames,
strum::EnumIter,
strum::EnumString,
serde::Serialize,
serde::Deserialize,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum MobilePaymentType {
DirectCarrierBilling,
}
#[derive(
Clone,
Debug,
@ -372,3 +391,4 @@ collect_variants!(GiftCardType);
collect_variants!(BankTransferType);
collect_variants!(CardRedirectType);
collect_variants!(OpenBankingType);
collect_variants!(MobilePaymentType);

View File

@ -144,6 +144,14 @@ impl From<enums::CardRedirectType> for global_enums::PaymentMethodType {
}
}
impl From<enums::MobilePaymentType> for global_enums::PaymentMethodType {
fn from(value: enums::MobilePaymentType) -> Self {
match value {
enums::MobilePaymentType::DirectCarrierBilling => Self::DirectCarrierBilling,
}
}
}
impl From<enums::BankRedirectType> for global_enums::PaymentMethodType {
fn from(value: enums::BankRedirectType) -> Self {
match value {
@ -248,6 +256,7 @@ fn lower_value(dir_value: dir::DirValue) -> Result<EuclidValue, AnalysisErrorTyp
dir::DirValue::BusinessLabel(bl) => EuclidValue::BusinessLabel(bl),
dir::DirValue::SetupFutureUsage(sfu) => EuclidValue::SetupFutureUsage(sfu),
dir::DirValue::OpenBankingType(ob) => EuclidValue::PaymentMethodType(ob.into()),
dir::DirValue::MobilePaymentType(mp) => EuclidValue::PaymentMethodType(mp.into()),
})
}

View File

@ -39,6 +39,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::OpenBanking
| global_enums::PaymentMethod::MobilePayment
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
},
global_enums::PaymentMethodType::Bacs => match self.1 {
@ -55,6 +56,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::OpenBanking
| global_enums::PaymentMethod::MobilePayment
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
},
global_enums::PaymentMethodType::Becs => Ok(dirval!(BankDebitType = Becs)),
@ -72,6 +74,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::OpenBanking
| global_enums::PaymentMethod::MobilePayment
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
},
global_enums::PaymentMethodType::AliPay => Ok(dirval!(WalletType = AliPay)),
@ -189,6 +192,9 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
Ok(dirval!(OpenBankingType = OpenBankingPIS))
}
global_enums::PaymentMethodType::Paze => Ok(dirval!(WalletType = Paze)),
global_enums::PaymentMethodType::DirectCarrierBilling => {
Ok(dirval!(MobilePaymentType = DirectCarrierBilling))
}
}
}
}