feat(connectors): [Iatapay] add payment methods (#4968)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: SamraatBansal <55536657+SamraatBansal@users.noreply.github.com>
This commit is contained in:
AkshayaFoiger
2024-06-13 09:15:09 +05:30
committed by GitHub
parent 27ca8be0da
commit 0e059e7d84
74 changed files with 588 additions and 43 deletions

View File

@ -68,6 +68,7 @@ impl cgraph::NodeViz for dir::DirValue {
Self::BusinessLabel(bl) => bl.value.to_string(),
Self::SetupFutureUsage(sfu) => sfu.to_string(),
Self::CardRedirectType(crt) => crt.to_string(),
Self::RealTimePaymentType(rtpt) => rtpt.to_string(),
}
}
}

View File

@ -26,5 +26,9 @@ pub static ANALYSIS_GRAPH: Lazy<hyperswitch_constraint_graph::ConstraintGraph<'_
// Payment Method should be `GiftCard` for a GiftCardType to
// be present
PaymentMethod(GiftCard) ->> GiftCardType(any);
// Payment Method should be `RealTimePayment` for a RealTimePaymentType to
// be present
PaymentMethod(RealTimePayment) ->> RealTimePaymentType(any);
}
});

View File

@ -272,6 +272,8 @@ fn lower_comparison_inner<O: EuclidDirFilter>(
dir::DirKeyKind::CardRedirectType => lower_enum!(CardRedirectType, value),
dir::DirKeyKind::RealTimePaymentType => lower_enum!(RealTimePaymentType, value),
dir::DirKeyKind::CardBin => {
let validation_closure = |st: &String| -> Result<(), AnalysisErrorType> {
if st.len() == 6 && st.chars().all(|x| x.is_ascii_digit()) {

View File

@ -311,6 +311,13 @@ pub enum DirKeyKind {
)]
#[serde(rename = "card_redirect")]
CardRedirectType,
#[serde(rename = "real_time_payment")]
#[strum(
serialize = "real_time_payment",
detailed_message = "Supported types of real time payment method",
props(Category = "Payment Method Types")
)]
RealTimePaymentType,
}
pub trait EuclidDirFilter: Sized
@ -358,6 +365,7 @@ impl DirKeyKind {
Self::BusinessLabel => types::DataType::StrValue,
Self::SetupFutureUsage => types::DataType::EnumVariant,
Self::CardRedirectType => types::DataType::EnumVariant,
Self::RealTimePaymentType => types::DataType::EnumVariant,
}
}
pub fn get_value_set(&self) -> Option<Vec<DirValue>> {
@ -484,6 +492,11 @@ impl DirKeyKind {
.map(DirValue::CardRedirectType)
.collect(),
),
Self::RealTimePaymentType => Some(
enums::RealTimePaymentType::iter()
.map(DirValue::RealTimePaymentType)
.collect(),
),
}
}
}
@ -549,6 +562,8 @@ pub enum DirValue {
SetupFutureUsage(enums::SetupFutureUsage),
#[serde(rename = "card_redirect")]
CardRedirectType(enums::CardRedirectType),
#[serde(rename = "real_time_payment")]
RealTimePaymentType(enums::RealTimePaymentType),
}
impl DirValue {
@ -582,6 +597,7 @@ impl DirValue {
Self::CardRedirectType(_) => (DirKeyKind::CardRedirectType, None),
Self::VoucherType(_) => (DirKeyKind::VoucherType, None),
Self::GiftCardType(_) => (DirKeyKind::GiftCardType, None),
Self::RealTimePaymentType(_) => (DirKeyKind::RealTimePaymentType, None),
};
DirKey::new(kind, data)
@ -616,6 +632,7 @@ impl DirValue {
Self::BusinessLabel(_) => None,
Self::SetupFutureUsage(_) => None,
Self::CardRedirectType(_) => None,
Self::RealTimePaymentType(_) => None,
}
}
@ -655,6 +672,7 @@ impl DirValue {
(Self::MandateType(mt1), Self::MandateType(mt2)) => mt1 == mt2,
(Self::MandateAcceptanceType(mat1), Self::MandateAcceptanceType(mat2)) => mat1 == mat2,
(Self::RewardType(rt1), Self::RewardType(rt2)) => rt1 == rt2,
(Self::RealTimePaymentType(rtp1), Self::RealTimePaymentType(rtp2)) => rtp1 == rtp2,
(Self::Connector(c1), Self::Connector(c2)) => c1 == c2,
(Self::BusinessLabel(bl1), Self::BusinessLabel(bl2)) => bl1 == bl2,
(Self::SetupFutureUsage(sfu1), Self::SetupFutureUsage(sfu2)) => sfu1 == sfu2,

View File

@ -149,6 +149,7 @@ pub enum BankRedirectType {
BancontactCard,
Blik,
Interac,
LocalBankRedirect,
OnlineBankingCzechRepublic,
OnlineBankingFinland,
OnlineBankingPoland,
@ -252,6 +253,28 @@ pub enum CryptoType {
CryptoCurrency,
}
#[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 RealTimePaymentType {
Fps,
DuitNow,
PromptPay,
VietQr,
}
#[derive(
Clone,
Debug,
@ -321,6 +344,7 @@ collect_variants!(BankRedirectType);
collect_variants!(BankDebitType);
collect_variants!(CryptoType);
collect_variants!(RewardType);
collect_variants!(RealTimePaymentType);
collect_variants!(UpiType);
collect_variants!(VoucherType);
collect_variants!(GiftCardType);

View File

@ -154,6 +154,7 @@ impl From<enums::BankRedirectType> for global_enums::PaymentMethodType {
enums::BankRedirectType::BancontactCard => Self::BancontactCard,
enums::BankRedirectType::Blik => Self::Blik,
enums::BankRedirectType::Interac => Self::Interac,
enums::BankRedirectType::LocalBankRedirect => Self::LocalBankRedirect,
enums::BankRedirectType::OnlineBankingCzechRepublic => Self::OnlineBankingCzechRepublic,
enums::BankRedirectType::OnlineBankingFinland => Self::OnlineBankingFinland,
enums::BankRedirectType::OnlineBankingPoland => Self::OnlineBankingPoland,
@ -184,6 +185,17 @@ impl From<enums::RewardType> for global_enums::PaymentMethodType {
}
}
impl From<enums::RealTimePaymentType> for global_enums::PaymentMethodType {
fn from(value: enums::RealTimePaymentType) -> Self {
match value {
enums::RealTimePaymentType::Fps => Self::Fps,
enums::RealTimePaymentType::DuitNow => Self::DuitNow,
enums::RealTimePaymentType::PromptPay => Self::PromptPay,
enums::RealTimePaymentType::VietQr => Self::VietQr,
}
}
}
/// Analyses of the lowering of the DirValues to EuclidValues .
///
/// For example,
@ -209,6 +221,7 @@ fn lower_value(dir_value: dir::DirValue) -> Result<EuclidValue, AnalysisErrorTyp
dir::DirValue::CardRedirectType(crt) => EuclidValue::PaymentMethodType(crt.into()),
dir::DirValue::BankRedirectType(brt) => EuclidValue::PaymentMethodType(brt.into()),
dir::DirValue::CryptoType(ct) => EuclidValue::PaymentMethodType(ct.into()),
dir::DirValue::RealTimePaymentType(rtpt) => EuclidValue::PaymentMethodType(rtpt.into()),
dir::DirValue::AuthenticationType(at) => EuclidValue::AuthenticationType(at),
dir::DirValue::CaptureMethod(cm) => EuclidValue::CaptureMethod(cm),
dir::DirValue::PaymentAmount(pa) => EuclidValue::PaymentAmount(pa),

View File

@ -11,7 +11,9 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
global_enums::PaymentMethodType::Giropay => Ok(dirval!(BankRedirectType = Giropay)),
global_enums::PaymentMethodType::Ideal => Ok(dirval!(BankRedirectType = Ideal)),
global_enums::PaymentMethodType::Sofort => Ok(dirval!(BankRedirectType = Sofort)),
global_enums::PaymentMethodType::DuitNow => Ok(dirval!(RealTimePaymentType = DuitNow)),
global_enums::PaymentMethodType::Eps => Ok(dirval!(BankRedirectType = Eps)),
global_enums::PaymentMethodType::Fps => Ok(dirval!(RealTimePaymentType = Fps)),
global_enums::PaymentMethodType::Klarna => Ok(dirval!(PayLaterType = Klarna)),
global_enums::PaymentMethodType::Affirm => Ok(dirval!(PayLaterType = Affirm)),
global_enums::PaymentMethodType::AfterpayClearpay => {
@ -33,6 +35,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::BankRedirect
| global_enums::PaymentMethod::Crypto
| global_enums::PaymentMethod::Reward
| global_enums::PaymentMethod::RealTimePayment
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
@ -47,6 +50,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::BankRedirect
| global_enums::PaymentMethod::Crypto
| global_enums::PaymentMethod::Reward
| global_enums::PaymentMethod::RealTimePayment
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
@ -62,6 +66,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
| global_enums::PaymentMethod::BankRedirect
| global_enums::PaymentMethod::Crypto
| global_enums::PaymentMethod::Reward
| global_enums::PaymentMethod::RealTimePayment
| global_enums::PaymentMethod::Upi
| global_enums::PaymentMethod::Voucher
| global_enums::PaymentMethod::GiftCard => Err(AnalysisErrorType::NotSupported),
@ -102,6 +107,9 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
global_enums::PaymentMethodType::Przelewy24 => {
Ok(dirval!(BankRedirectType = Przelewy24))
}
global_enums::PaymentMethodType::PromptPay => {
Ok(dirval!(RealTimePaymentType = PromptPay))
}
global_enums::PaymentMethodType::WeChatPay => Ok(dirval!(WalletType = WeChatPay)),
global_enums::PaymentMethodType::ClassicReward => {
@ -116,12 +124,16 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
global_enums::PaymentMethodType::Twint => Ok(dirval!(WalletType = Twint)),
global_enums::PaymentMethodType::Gcash => Ok(dirval!(WalletType = Gcash)),
global_enums::PaymentMethodType::Vipps => Ok(dirval!(WalletType = Vipps)),
global_enums::PaymentMethodType::VietQr => Ok(dirval!(RealTimePaymentType = VietQr)),
global_enums::PaymentMethodType::Momo => Ok(dirval!(WalletType = Momo)),
global_enums::PaymentMethodType::Alma => Ok(dirval!(PayLaterType = Alma)),
global_enums::PaymentMethodType::Dana => Ok(dirval!(WalletType = Dana)),
global_enums::PaymentMethodType::OnlineBankingFpx => {
Ok(dirval!(BankRedirectType = OnlineBankingFpx))
}
global_enums::PaymentMethodType::LocalBankRedirect => {
Ok(dirval!(BankRedirectType = LocalBankRedirect))
}
global_enums::PaymentMethodType::OnlineBankingThailand => {
Ok(dirval!(BankRedirectType = OnlineBankingThailand))
}