feat(connector): [Adyen] implement Online Banking Fpx for Adyen (#1584)

Co-authored-by: Sangamesh Kulkarni <59434228+Sangamesh26@users.noreply.github.com>
This commit is contained in:
AkshayaFoiger
2023-07-20 16:56:50 +05:30
committed by GitHub
parent c4c94241a9
commit 2e492ee6a9
12 changed files with 191 additions and 1 deletions

View File

@ -316,3 +316,9 @@ afterpay_clearpay = {fields = {stripe = [ # payment_method_type = afterpay_clea
[payouts]
payout_eligibility = true # Defaults the eligibility of a payout method to true in case connector does not provide checks for payout eligibility
[pm_filters.adyen]
online_banking_fpx = {country = "MY", currency = "MYR"}
[bank_config.online_banking_fpx]
adyen = { banks = "affin_bank,agro_bank,alliance_bank,am_bank,bank_islam,bank_muamalat,bank_rakyat,bank_simpanan_nasional,cimb_bank,hong_leong_bank,hsbc_bank,kuwait_finance_house,may_bank,ocbc_bank,public_bank,rhb_bank,standard_chartered_bank,uob_bank"}

View File

@ -194,6 +194,9 @@ adyen = { banks = "blik_psp,place_zipko,m_bank,pay_with_ing,santander_przelew24,
[bank_config.przelewy24]
stripe = { banks = "alior_bank,bank_millennium,bank_nowy_bfg_sa,bank_pekao_sa,banki_spbdzielcze,blik,bnp_paribas,boz,citi,credit_agricole,e_transfer_pocztowy24,getin_bank,idea_bank,inteligo,mbank_mtransfer,nest_przelew,noble_pay,pbac_z_ipko,plus_bank,santander_przelew24,toyota_bank,volkswagen_bank" }
[bank_config.online_banking_fpx]
adyen = { banks = "affin_bank,agro_bank,alliance_bank,am_bank,bank_islam,bank_muamalat,bank_rakyat,bank_simpanan_nasional,cimb_bank,hong_leong_bank,hsbc_bank,kuwait_finance_house,may_bank,ocbc_bank,public_bank,rhb_bank,standard_chartered_bank,uob_bank"}
[pm_filters.default]
google_pay = { country = "AL,DZ,AS,AO,AG,AR,AU,AT,AZ,BH,BY,BE,BR,BG,CA,CL,CO,HR,CZ,DK,DO,EG,EE,FI,FR,DE,GR,HK,HU,IN,ID,IE,IL,IT,JP,JO,KZ,KE,KW,LV,LB,LT,LU,MY,MX,NL,NZ,NO,OM,PK,PA,PE,PH,PL,PT,QA,RO,RU,SA,SG,SK,ZA,ES,LK,SE,CH,TW,TH,TR,UA,AE,GB,US,UY,VN" }
apple_pay = { country = "AU,CN,HK,JP,MO,MY,NZ,SG,TW,AM,AT,AZ,BY,BE,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GR,GL,GG,HU,IS,IE,IM,IT,KZ,JE,LV,LI,LT,LU,MT,MD,MC,ME,NL,NO,PL,PT,RO,SM,RS,SK,SI,ES,SE,CH,UA,GB,AR,CO,CR,BR,MX,PE,BH,IL,JO,KW,PS,QA,SA,AE,CA,UM,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD" }
@ -248,8 +251,9 @@ ali_pay_hk = {country = "HK", currency = "HKD"}
bizum = {country = "ES", currency = "EUR"}
go_pay = {country = "ID", currency = "IDR"}
kakao_pay = {country = "KR", currency = "KRW"}
gcash = {country = "PH", currency = "PHP"}
momo = {country = "VN", currency = "VND"}
gcash = {country = "PH", currency = "PHP"}
online_banking_fpx = {country = "MY", currency = "MYR"}
[pm_filters.braintree]
paypal = { currency = "AUD,BRL,CAD,CNY,CZK,DKK,EUR,HKD,HUF,ILS,JPY,MYR,MXN,TWD,NZD,NOK,PHP,PLN,GBP,RUB,SGD,SEK,CHF,THB,USD" }

View File

@ -199,3 +199,9 @@ refund_retrieve_tolerance = 100
[payouts]
payout_eligibility = true
[pm_filters.adyen]
online_banking_fpx = {country = "MY", currency = "MYR"}
[bank_config.online_banking_fpx]
adyen = { banks = "affin_bank,agro_bank,alliance_bank,am_bank,bank_islam,bank_muamalat,bank_rakyat,bank_simpanan_nasional,cimb_bank,hong_leong_bank,hsbc_bank,kuwait_finance_house,may_bank,ocbc_bank,public_bank,rhb_bank,standard_chartered_bank,uob_bank"}

View File

@ -277,12 +277,21 @@ impl From<PayoutConnectors> for RoutableConnectors {
#[serde(rename_all = "snake_case")]
pub enum BankNames {
AmericanExpress,
AffinBank,
AgroBank,
AllianceBank,
AmBank,
BankOfAmerica,
BankIslam,
BankMuamalat,
BankRakyat,
BankSimpananNasional,
Barclays,
BlikPSP,
CapitalOne,
Chase,
Citi,
CimbBank,
Discover,
NavyFederalCreditUnion,
PentagonFederalCreditUnion,
@ -292,8 +301,11 @@ pub enum BankNames {
AsnBank,
Bunq,
Handelsbanken,
HongLeongBank,
HsbcBank,
Ing,
Knab,
KuwaitFinanceHouse,
Moneyou,
Rabobank,
Regiobank,
@ -329,15 +341,20 @@ pub enum BankNames {
KomercniBanka,
MBank,
MarchfelderBank,
Maybank,
OberbankAg,
OsterreichischeArzteUndApothekerbank,
OcbcBank,
PayWithING,
PlaceZIPKO,
PlatnoscOnlineKartaPlatnicza,
PosojilnicaBankEGen,
PostovaBanka,
PublicBank,
RaiffeisenBankengruppeOsterreich,
RhbBank,
SchelhammerCapitalBankAg,
StandardCharteredBank,
SchoellerbankAg,
SpardaBankWien,
SporoPay,
@ -347,6 +364,7 @@ pub enum BankNames {
VolksbankGruppe,
VolkskreditbankAg,
VrBankBraunau,
UobBank,
PayWithAliorBank,
BankiSpoldzielcze,
PayWithInteligo,

View File

@ -855,6 +855,11 @@ pub enum BankRedirectData {
#[schema(value_type = CountryAlpha2, example = "US")]
country: api_enums::CountryAlpha2,
},
OnlineBankingFpx {
// Issuer banks
#[schema(value_type = BankNames)]
issuer: api_enums::BankNames,
},
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]

View File

@ -586,6 +586,7 @@ pub enum PaymentMethodType {
Multibanco,
OnlineBankingCzechRepublic,
OnlineBankingFinland,
OnlineBankingFpx,
OnlineBankingPoland,
OnlineBankingSlovakia,
PayBright,

View File

@ -1568,6 +1568,7 @@ impl From<PaymentMethodType> for PaymentMethod {
PaymentMethodType::Interac => Self::BankRedirect,
PaymentMethodType::OnlineBankingCzechRepublic => Self::BankRedirect,
PaymentMethodType::OnlineBankingFinland => Self::BankRedirect,
PaymentMethodType::OnlineBankingFpx => Self::BankRedirect,
PaymentMethodType::OnlineBankingPoland => Self::BankRedirect,
PaymentMethodType::OnlineBankingSlovakia => Self::BankRedirect,
PaymentMethodType::PayBright => Self::PayLater,

View File

@ -288,4 +288,22 @@ pub enum BankNames {
VolkswagenBank,
AliorBank,
Boz,
AffinBank,
AgroBank,
AllianceBank,
AmBank,
BankIslam,
BankMuamalat,
BankRakyat,
BankSimpananNasional,
CimbBank,
HongLeongBank,
HsbcBank,
KuwaitFinanceHouse,
Maybank,
OcbcBank,
PublicBank,
RhbBank,
StandardCharteredBank,
UobBank,
}

View File

@ -327,6 +327,8 @@ pub enum AdyenPaymentMethod<'a> {
OnlineBankingFinland(Box<OnlineBankingFinlandData>),
OnlineBankingPoland(Box<OnlineBankingPolandData>),
OnlineBankingSlovakia(Box<OnlineBankingSlovakiaData>),
#[serde(rename = "molpay_ebanking_fpx_MY")]
OnlineBankingFpx(Box<OnlineBankingFpxData>),
PayBright(Box<PayBrightData>),
Sofort(Box<BankRedirectionPMData>),
Trustly(Box<BankRedirectionPMData>),
@ -554,6 +556,12 @@ pub struct OnlineBankingSlovakiaData {
issuer: OnlineBankingSlovakiaBanks,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OnlineBankingFpxData {
issuer: AdyenIssuerID,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum OnlineBankingSlovakiaBanks {
@ -582,6 +590,37 @@ impl TryFrom<&api_enums::BankNames> for OnlineBankingSlovakiaBanks {
}
}
impl TryFrom<&api_enums::BankNames> for AdyenIssuerID {
type Error = Error;
fn try_from(bank_name: &api_enums::BankNames) -> Result<Self, Self::Error> {
match bank_name {
api::enums::BankNames::AffinBank => Ok(Self::FpxAbb),
api::enums::BankNames::AgroBank => Ok(Self::FpxAgrobank),
api::enums::BankNames::AllianceBank => Ok(Self::FpxAbmb),
api::enums::BankNames::AmBank => Ok(Self::FpxAmb),
api::enums::BankNames::BankIslam => Ok(Self::FpxBimb),
api::enums::BankNames::BankMuamalat => Ok(Self::FpxBmmb),
api::enums::BankNames::BankRakyat => Ok(Self::FpxBkrm),
api::enums::BankNames::BankSimpananNasional => Ok(Self::FpxBsn),
api::enums::BankNames::CimbBank => Ok(Self::FpxCimbclicks),
api::enums::BankNames::HongLeongBank => Ok(Self::FpxHlb),
api::enums::BankNames::HsbcBank => Ok(Self::FpxHsbc),
api::enums::BankNames::KuwaitFinanceHouse => Ok(Self::FpxKfh),
api::enums::BankNames::Maybank => Ok(Self::FpxMb2u),
api::enums::BankNames::OcbcBank => Ok(Self::FpxOcbc),
api::enums::BankNames::PublicBank => Ok(Self::FpxPbb),
api::enums::BankNames::RhbBank => Ok(Self::FpxRhb),
api::enums::BankNames::StandardCharteredBank => Ok(Self::FpxScb),
api::enums::BankNames::UobBank => Ok(Self::FpxUob),
_ => Err(errors::ConnectorError::NotSupported {
message: String::from("BankRedirect"),
connector: "Adyen",
payment_experience: api_enums::PaymentExperience::RedirectToUrl.to_string(),
})?,
}
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BlikRedirectionData {
@ -786,6 +825,8 @@ pub enum PaymentType {
OnlineBankingPoland,
#[serde(rename = "onlineBanking_SK")]
OnlineBankingSlovakia,
#[serde(rename = "molpay_ebanking_fpx_MY")]
OnlineBankingFpx,
PayBright,
Paypal,
Scheme,
@ -807,6 +848,29 @@ pub enum PaymentType {
Vipps,
}
#[derive(Debug, Eq, PartialEq, Serialize, Clone)]
#[serde(rename_all = "snake_case")]
pub enum AdyenIssuerID {
FpxAbb,
FpxAgrobank,
FpxAbmb,
FpxAmb,
FpxBimb,
FpxBmmb,
FpxBkrm,
FpxBsn,
FpxCimbclicks,
FpxHlb,
FpxHsbc,
FpxKfh,
FpxMb2u,
FpxOcbc,
FpxPbb,
FpxRhb,
FpxScb,
FpxUob,
}
pub struct AdyenTestBankNames<'a>(&'a str);
impl<'a> TryFrom<&api_enums::BankNames> for AdyenTestBankNames<'a> {
@ -1495,6 +1559,11 @@ impl<'a> TryFrom<&api_models::payments::BankRedirectData> for AdyenPaymentMethod
issuer: OnlineBankingSlovakiaBanks::try_from(issuer)?,
})),
),
api_models::payments::BankRedirectData::OnlineBankingFpx { issuer } => Ok(
AdyenPaymentMethod::OnlineBankingFpx(Box::new(OnlineBankingFpxData {
issuer: AdyenIssuerID::try_from(issuer)?,
})),
),
api_models::payments::BankRedirectData::Sofort { .. } => Ok(
AdyenPaymentMethod::Sofort(Box::new(BankRedirectionPMData {
payment_type: PaymentType::Sofort,

View File

@ -196,6 +196,7 @@ impl ForeignFrom<api_enums::PaymentMethodType> for api_enums::PaymentMethod {
| api_enums::PaymentMethodType::Blik
| api_enums::PaymentMethodType::OnlineBankingCzechRepublic
| api_enums::PaymentMethodType::OnlineBankingFinland
| api_enums::PaymentMethodType::OnlineBankingFpx
| api_enums::PaymentMethodType::OnlineBankingPoland
| api_enums::PaymentMethodType::OnlineBankingSlovakia
| api_enums::PaymentMethodType::Przelewy24

View File

@ -559,6 +559,23 @@ async fn should_make_adyen_dana_payment(driver: WebDriver) -> Result<(), WebDriv
Ok(())
}
async fn should_make_adyen_online_banking_fpx_payment(
web_driver: WebDriver,
) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_redirection_payment(
web_driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/172"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Click(By::Css("button[value='authorised']"))),
Event::Assert(Assert::IsPresent("succeeded")),
],
)
.await?;
Ok(())
}
#[test]
#[serial]
#[ignore]
@ -727,4 +744,10 @@ fn should_make_adyen_dana_payment_test() {
tester!(should_make_adyen_dana_payment);
}
#[test]
#[serial]
fn should_make_adyen_online_banking_fpx_payment_test() {
tester!(should_make_adyen_online_banking_fpx_payment);
}
// https://hs-payments-test.netlify.app/paypal-redirect?amount=70.00&country=US&currency=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD&apikey=dev_uFpxA0r6jjbVaxHSY3X0BZLL3erDUzvg3i51abwB1Bknu3fdiPxw475DQgnByn1z

View File

@ -2594,12 +2594,21 @@
"description": "Name of banks supported by Hyperswitch",
"enum": [
"american_express",
"affin_bank",
"agro_bank",
"alliance_bank",
"am_bank",
"bank_of_america",
"bank_islam",
"bank_muamalat",
"bank_rakyat",
"bank_simpanan_nasional",
"barclays",
"blik_p_s_p",
"capital_one",
"chase",
"citi",
"cimb_bank",
"discover",
"navy_federal_credit_union",
"pentagon_federal_credit_union",
@ -2609,8 +2618,11 @@
"asn_bank",
"bunq",
"handelsbanken",
"hong_leong_bank",
"hsbc_bank",
"ing",
"knab",
"kuwait_finance_house",
"moneyou",
"rabobank",
"regiobank",
@ -2646,15 +2658,20 @@
"komercni_banka",
"m_bank",
"marchfelder_bank",
"maybank",
"oberbank_ag",
"osterreichische_arzte_und_apothekerbank",
"ocbc_bank",
"pay_with_i_n_g",
"place_z_i_p_k_o",
"platnosc_online_karta_platnicza",
"posojilnica_bank_e_gen",
"postova_banka",
"public_bank",
"raiffeisen_bankengruppe_osterreich",
"rhb_bank",
"schelhammer_capital_bank_ag",
"standard_chartered_bank",
"schoellerbank_ag",
"sparda_bank_wien",
"sporo_pay",
@ -2664,6 +2681,7 @@
"volksbank_gruppe",
"volkskreditbank_ag",
"vr_bank_braunau",
"uob_bank",
"pay_with_alior_bank",
"banki_spoldzielcze",
"pay_with_inteligo",
@ -3052,6 +3070,25 @@
}
}
}
},
{
"type": "object",
"required": [
"online_banking_fpx"
],
"properties": {
"online_banking_fpx": {
"type": "object",
"required": [
"issuer"
],
"properties": {
"issuer": {
"$ref": "#/components/schemas/BankNames"
}
}
}
}
}
]
},
@ -7153,6 +7190,7 @@
"multibanco",
"online_banking_czech_republic",
"online_banking_finland",
"online_banking_fpx",
"online_banking_poland",
"online_banking_slovakia",
"pay_bright",