feat(connector): [Adyen] Implement Alma BNPL and DANA Wallet (#1566)

Co-authored-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
This commit is contained in:
Sakil Mostak
2023-07-19 15:52:50 +05:30
committed by GitHub
parent cac9f5049e
commit 5dcf758ac0
7 changed files with 96 additions and 2 deletions

View File

@ -644,8 +644,12 @@ pub enum PayLaterData {
#[schema(value_type = String)]
billing_name: Secret<String>,
},
/// For PayBright Redirect as PayLater Option
PayBrightRedirect {},
/// For WalleyRedirect as PayLater Option
WalleyRedirect {},
/// For Alma Redirection as PayLater Option
AlmaRedirect {},
}
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, ToSchema, Eq, PartialEq)]
@ -966,6 +970,8 @@ pub enum WalletData {
ApplePayRedirect(Box<ApplePayRedirectData>),
/// Wallet data for apple pay third party sdk flow
ApplePayThirdPartySdk(Box<ApplePayThirdPartySdkData>),
/// Wallet data for DANA redirect flow
DanaRedirect {},
/// The wallet data for Google pay
GooglePay(GooglePayWalletData),
/// Wallet data for google pay redirect flow

View File

@ -557,6 +557,7 @@ pub enum PaymentMethodType {
AfterpayClearpay,
AliPay,
AliPayHk,
Alma,
ApplePay,
Bacs,
BancontactCard,
@ -567,6 +568,7 @@ pub enum PaymentMethodType {
ClassicReward,
Credit,
CryptoCurrency,
Dana,
Debit,
Eps,
Evoucher,

View File

@ -1540,6 +1540,7 @@ impl From<PaymentMethodType> for PaymentMethod {
PaymentMethodType::AfterpayClearpay => Self::PayLater,
PaymentMethodType::AliPay => Self::Wallet,
PaymentMethodType::AliPayHk => Self::Wallet,
PaymentMethodType::Alma => Self::PayLater,
PaymentMethodType::ApplePay => Self::Wallet,
PaymentMethodType::Bacs => Self::BankDebit,
PaymentMethodType::BancontactCard => Self::BankRedirect,
@ -1549,6 +1550,7 @@ impl From<PaymentMethodType> for PaymentMethod {
PaymentMethodType::ClassicReward => Self::Reward,
PaymentMethodType::Credit => Self::Card,
PaymentMethodType::CryptoCurrency => Self::Crypto,
PaymentMethodType::Dana => Self::Wallet,
PaymentMethodType::Debit => Self::Card,
PaymentMethodType::Eps => Self::BankRedirect,
PaymentMethodType::Evoucher => Self::Reward,

View File

@ -275,6 +275,7 @@ pub enum AdyenPaymentMethod<'a> {
AdyenKlarna(Box<AdyenPayLaterData>),
AdyenPaypal(Box<AdyenPaypal>),
AfterPay(Box<AdyenPayLaterData>),
AlmaPayLater(Box<AdyenPayLaterData>),
AliPay(Box<AliPayData>),
AliPayHk(Box<AliPayHkData>),
ApplePay(Box<AdyenApplePay>),
@ -282,6 +283,7 @@ pub enum AdyenPaymentMethod<'a> {
Bizum(Box<BankRedirectionPMData>),
Blik(Box<BlikRedirectionData>),
ClearPay(Box<AdyenPayLaterData>),
Dana(Box<DanaWalletData>),
Eps(Box<BankRedirectionWithIssuer<'a>>),
#[serde(rename = "gcash")]
Gcash(Box<GcashData>),
@ -674,6 +676,12 @@ pub struct AdyenApplePay {
apple_pay_token: Secret<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DanaWalletData {
#[serde(rename = "type")]
payment_type: PaymentType,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TwintWalletData {
#[serde(rename = "type")]
@ -725,10 +733,12 @@ pub enum PaymentType {
Alipay,
#[serde(rename = "alipay_hk")]
AlipayHk,
Alma,
Applepay,
Bizum,
Blik,
ClearPay,
Dana,
Eps,
Gcash,
Giropay,
@ -1267,6 +1277,12 @@ impl<'a> TryFrom<&api::WalletData> for AdyenPaymentMethod<'a> {
};
Ok(AdyenPaymentMethod::Vipps(Box::new(data)))
}
api_models::payments::WalletData::DanaRedirect { .. } => {
let data = DanaWalletData {
payment_type: PaymentType::Dana,
};
Ok(AdyenPaymentMethod::Dana(Box::new(data)))
}
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
}
}
@ -1323,6 +1339,11 @@ impl<'a> TryFrom<(&api::PayLaterData, Option<api_enums::CountryAlpha2>)>
payment_type: PaymentType::Walley,
})))
}
api_models::payments::PayLaterData::AlmaRedirect { .. } => Ok(
AdyenPaymentMethod::AlmaPayLater(Box::new(AdyenPayLaterData {
payment_type: PaymentType::Alma,
})),
),
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
}
}

View File

@ -171,6 +171,7 @@ impl ForeignFrom<api_enums::PaymentMethodType> for api_enums::PaymentMethod {
| api_enums::PaymentMethodType::Paypal
| api_enums::PaymentMethodType::AliPay
| api_enums::PaymentMethodType::AliPayHk
| api_enums::PaymentMethodType::Dana
| api_enums::PaymentMethodType::MbWay
| api_enums::PaymentMethodType::MobilePay
| api_enums::PaymentMethodType::SamsungPay
@ -182,6 +183,7 @@ impl ForeignFrom<api_enums::PaymentMethodType> for api_enums::PaymentMethod {
| api_enums::PaymentMethodType::Momo
| api_enums::PaymentMethodType::KakaoPay => Self::Wallet,
api_enums::PaymentMethodType::Affirm
| api_enums::PaymentMethodType::Alma
| api_enums::PaymentMethodType::AfterpayClearpay
| api_enums::PaymentMethodType::Klarna
| api_enums::PaymentMethodType::PayBright

View File

@ -532,6 +532,33 @@ async fn should_make_adyen_walley_payment(web_driver: WebDriver) -> Result<(), W
Ok(())
}
async fn should_make_adyen_dana_payment(driver: WebDriver) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_redirection_payment(
driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/175"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::SendKeys(
By::Css("input[type='number']"),
"12345678901",
)), // Mobile Number can be any random 11 digit number
Event::Trigger(Trigger::Click(By::Css("button"))),
Event::Trigger(Trigger::SendKeys(By::Css("input[type='number']"), "111111")), // PIN can be any random 11 digit number
Event::Trigger(Trigger::Click(By::ClassName("btn-next"))),
Event::Trigger(Trigger::Sleep(3)),
Event::Trigger(Trigger::Click(By::ClassName("btn-next"))),
Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::ContainsAny(
Selector::QueryParamStr,
vec!["status=succeeded"],
)),
],
)
.await?;
Ok(())
}
#[test]
#[serial]
#[ignore]
@ -693,4 +720,10 @@ fn should_make_adyen_walley_payment_test() {
tester!(should_make_adyen_walley_payment);
}
#[test]
#[serial]
fn should_make_adyen_dana_payment_test() {
tester!(should_make_adyen_dana_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

@ -6151,7 +6151,8 @@
],
"properties": {
"pay_bright_redirect": {
"type": "object"
"type": "object",
"description": "For PayBright Redirect as PayLater Option"
}
}
},
@ -6162,7 +6163,20 @@
],
"properties": {
"walley_redirect": {
"type": "object"
"type": "object",
"description": "For WalleyRedirect as PayLater Option"
}
}
},
{
"type": "object",
"required": [
"alma_redirect"
],
"properties": {
"alma_redirect": {
"type": "object",
"description": "For Alma Redirection as PayLater Option"
}
}
}
@ -6806,6 +6820,7 @@
"afterpay_clearpay",
"ali_pay",
"ali_pay_hk",
"alma",
"apple_pay",
"bacs",
"bancontact_card",
@ -6815,6 +6830,7 @@
"classic",
"credit",
"crypto_currency",
"dana",
"debit",
"eps",
"evoucher",
@ -9007,6 +9023,18 @@
}
}
},
{
"type": "object",
"required": [
"dana_redirect"
],
"properties": {
"dana_redirect": {
"type": "object",
"description": "Wallet data for DANA redirect flow"
}
}
},
{
"type": "object",
"required": [