feat(core): Payments core modification for open banking connectors (#3947)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sarthak Soni
2024-07-17 14:57:50 +05:30
committed by GitHub
parent ecc862c354
commit eb6f27d64e
101 changed files with 1101 additions and 48 deletions

View File

@ -264,6 +264,8 @@ fn lower_comparison_inner<O: EuclidDirFilter>(
dir::DirKeyKind::UpiType => lower_enum!(UpiType, value),
dir::DirKeyKind::OpenBankingType => lower_enum!(OpenBankingType, value),
dir::DirKeyKind::VoucherType => lower_enum!(VoucherType, value),
dir::DirKeyKind::GiftCardType => lower_enum!(GiftCardType, value),

View File

@ -319,6 +319,13 @@ pub enum DirKeyKind {
props(Category = "Payment Method Types")
)]
RealTimePaymentType,
#[serde(rename = "open_banking")]
#[strum(
serialize = "open_banking",
detailed_message = "Supported types of open banking payment method",
props(Category = "Payment Method Types")
)]
OpenBankingType,
}
pub trait EuclidDirFilter: Sized
@ -367,6 +374,7 @@ impl DirKeyKind {
Self::SetupFutureUsage => types::DataType::EnumVariant,
Self::CardRedirectType => types::DataType::EnumVariant,
Self::RealTimePaymentType => types::DataType::EnumVariant,
Self::OpenBankingType => types::DataType::EnumVariant,
}
}
pub fn get_value_set(&self) -> Option<Vec<DirValue>> {
@ -498,6 +506,11 @@ impl DirKeyKind {
.map(DirValue::RealTimePaymentType)
.collect(),
),
Self::OpenBankingType => Some(
enums::OpenBankingType::iter()
.map(DirValue::OpenBankingType)
.collect(),
),
}
}
}
@ -565,6 +578,8 @@ pub enum DirValue {
CardRedirectType(enums::CardRedirectType),
#[serde(rename = "real_time_payment")]
RealTimePaymentType(enums::RealTimePaymentType),
#[serde(rename = "open_banking")]
OpenBankingType(enums::OpenBankingType),
}
impl DirValue {
@ -599,6 +614,7 @@ impl DirValue {
Self::VoucherType(_) => (DirKeyKind::VoucherType, None),
Self::GiftCardType(_) => (DirKeyKind::GiftCardType, None),
Self::RealTimePaymentType(_) => (DirKeyKind::RealTimePaymentType, None),
Self::OpenBankingType(_) => (DirKeyKind::OpenBankingType, None),
};
DirKey::new(kind, data)
@ -634,6 +650,7 @@ impl DirValue {
Self::SetupFutureUsage(_) => None,
Self::CardRedirectType(_) => None,
Self::RealTimePaymentType(_) => None,
Self::OpenBankingType(_) => None,
}
}

View File

@ -160,6 +160,26 @@ pub enum BankRedirectType {
Przelewy24,
Trustly,
}
#[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 OpenBankingType {
OpenBankingPIS,
}
#[derive(
Clone,
Debug,
@ -350,3 +370,4 @@ collect_variants!(VoucherType);
collect_variants!(GiftCardType);
collect_variants!(BankTransferType);
collect_variants!(CardRedirectType);
collect_variants!(OpenBankingType);

View File

@ -168,6 +168,14 @@ impl From<enums::BankRedirectType> for global_enums::PaymentMethodType {
}
}
impl From<enums::OpenBankingType> for global_enums::PaymentMethodType {
fn from(value: enums::OpenBankingType) -> Self {
match value {
enums::OpenBankingType::OpenBankingPIS => Self::OpenBankingPIS,
}
}
}
impl From<enums::CryptoType> for global_enums::PaymentMethodType {
fn from(value: enums::CryptoType) -> Self {
match value {
@ -238,6 +246,7 @@ fn lower_value(dir_value: dir::DirValue) -> Result<EuclidValue, AnalysisErrorTyp
dir::DirValue::RewardType(rt) => EuclidValue::PaymentMethodType(rt.into()),
dir::DirValue::BusinessLabel(bl) => EuclidValue::BusinessLabel(bl),
dir::DirValue::SetupFutureUsage(sfu) => EuclidValue::SetupFutureUsage(sfu),
dir::DirValue::OpenBankingType(ob) => EuclidValue::PaymentMethodType(ob.into()),
})
}

View File

@ -38,6 +38,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::RealTimePayment
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::OpenBanking
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
},
global_enums::PaymentMethodType::Bacs => match self.1 {
@ -53,6 +54,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::RealTimePayment
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::OpenBanking
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
},
global_enums::PaymentMethodType::Becs => Ok(dirval!(BankDebitType = Becs)),
@ -69,6 +71,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::RealTimePayment
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::OpenBanking
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
},
global_enums::PaymentMethodType::AliPay => Ok(dirval!(WalletType = AliPay)),
@ -182,6 +185,9 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
}
global_enums::PaymentMethodType::Venmo => Ok(dirval!(WalletType = Venmo)),
global_enums::PaymentMethodType::Mifinity => Ok(dirval!(WalletType = Mifinity)),
global_enums::PaymentMethodType::OpenBankingPIS => {
Ok(dirval!(OpenBankingType = OpenBankingPIS))
}
}
}
}