feat(connector): [Adyen] Implement Twint in Wallets (#1549)

Co-authored-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
Co-authored-by: Arjun Karthik <m.arjunkarthik@gmail.com>
This commit is contained in:
Sakil Mostak
2023-07-18 13:07:38 +05:30
committed by GitHub
parent a7c66ddea2
commit d317021bc5
7 changed files with 58 additions and 0 deletions

View File

@ -975,6 +975,8 @@ pub enum WalletData {
PaypalSdk(PayPalWalletData), PaypalSdk(PayPalWalletData),
/// The wallet data for Samsung Pay /// The wallet data for Samsung Pay
SamsungPay(Box<SamsungPayWalletData>), SamsungPay(Box<SamsungPayWalletData>),
/// Wallet data for Twint Redirection
TwintRedirect {},
/// The wallet data for WeChat Pay Redirection /// The wallet data for WeChat Pay Redirection
WeChatPayRedirect(Box<WeChatPayRedirection>), WeChatPayRedirect(Box<WeChatPayRedirection>),
/// The wallet data for WeChat Pay /// The wallet data for WeChat Pay

View File

@ -589,6 +589,7 @@ pub enum PaymentMethodType {
Sofort, Sofort,
Swish, Swish,
Trustly, Trustly,
Twint,
UpiCollect, UpiCollect,
Walley, Walley,
WeChatPay, WeChatPay,

View File

@ -1573,6 +1573,7 @@ impl From<PaymentMethodType> for PaymentMethod {
PaymentMethodType::Sofort => Self::BankRedirect, PaymentMethodType::Sofort => Self::BankRedirect,
PaymentMethodType::Swish => Self::BankRedirect, PaymentMethodType::Swish => Self::BankRedirect,
PaymentMethodType::Trustly => Self::BankRedirect, PaymentMethodType::Trustly => Self::BankRedirect,
PaymentMethodType::Twint => Self::Wallet,
PaymentMethodType::UpiCollect => Self::Upi, PaymentMethodType::UpiCollect => Self::Upi,
PaymentMethodType::Walley => Self::PayLater, PaymentMethodType::Walley => Self::PayLater,
PaymentMethodType::WeChatPay => Self::Wallet, PaymentMethodType::WeChatPay => Self::Wallet,

View File

@ -305,6 +305,7 @@ pub enum AdyenPaymentMethod<'a> {
SepaDirectDebit(Box<SepaDirectDebitData>), SepaDirectDebit(Box<SepaDirectDebitData>),
BacsDirectDebit(Box<BacsDirectDebitData>), BacsDirectDebit(Box<BacsDirectDebitData>),
SamsungPay(Box<SamsungPayPmData>), SamsungPay(Box<SamsungPayPmData>),
Twint(Box<TwintWalletData>),
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
@ -658,6 +659,12 @@ pub struct AdyenApplePay {
apple_pay_token: Secret<String>, apple_pay_token: Secret<String>,
} }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TwintWalletData {
#[serde(rename = "type")]
payment_type: PaymentType,
}
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AdyenPayLaterData { pub struct AdyenPayLaterData {
#[serde(rename = "type")] #[serde(rename = "type")]
@ -735,6 +742,7 @@ pub enum PaymentType {
#[serde(rename = "directdebit_GB")] #[serde(rename = "directdebit_GB")]
BacsDirectDebit, BacsDirectDebit,
Samsungpay, Samsungpay,
Twint,
} }
pub struct AdyenTestBankNames<'a>(&'a str); pub struct AdyenTestBankNames<'a>(&'a str);
@ -1209,6 +1217,12 @@ impl<'a> TryFrom<&api::WalletData> for AdyenPaymentMethod<'a> {
}; };
Ok(AdyenPaymentMethod::SamsungPay(Box::new(data))) Ok(AdyenPaymentMethod::SamsungPay(Box::new(data)))
} }
api_models::payments::WalletData::TwintRedirect { .. } => {
let data = TwintWalletData {
payment_type: PaymentType::Twint,
};
Ok(AdyenPaymentMethod::Twint(Box::new(data)))
}
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()), _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
} }
} }

View File

@ -174,6 +174,7 @@ impl ForeignFrom<api_enums::PaymentMethodType> for api_enums::PaymentMethod {
| api_enums::PaymentMethodType::MbWay | api_enums::PaymentMethodType::MbWay
| api_enums::PaymentMethodType::MobilePay | api_enums::PaymentMethodType::MobilePay
| api_enums::PaymentMethodType::SamsungPay | api_enums::PaymentMethodType::SamsungPay
| api_enums::PaymentMethodType::Twint
| api_enums::PaymentMethodType::WeChatPay | api_enums::PaymentMethodType::WeChatPay
| api_enums::PaymentMethodType::GoPay => Self::Wallet, | api_enums::PaymentMethodType::GoPay => Self::Wallet,
api_enums::PaymentMethodType::Affirm api_enums::PaymentMethodType::Affirm

View File

@ -209,6 +209,26 @@ async fn should_make_adyen_clearpay_payment(driver: WebDriver) -> Result<(), Web
Ok(()) Ok(())
} }
async fn should_make_adyen_twint_payment(driver: WebDriver) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_redirection_payment(
driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/170"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Sleep(5)),
Event::Trigger(Trigger::Click(By::Css("button[value='authorised']"))),
Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::ContainsAny(
Selector::QueryParamStr,
vec!["status=succeeded"],
)),
],
)
.await?;
Ok(())
}
#[test] #[test]
#[serial] #[serial]
#[ignore] #[ignore]
@ -266,4 +286,10 @@ fn should_make_adyen_clearpay_payment_test() {
tester!(should_make_adyen_clearpay_payment); tester!(should_make_adyen_clearpay_payment);
} }
#[test]
#[serial]
fn should_make_adyen_twint_payment_test() {
tester!(should_make_adyen_twint_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 // 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

@ -6823,6 +6823,7 @@
"sofort", "sofort",
"swish", "swish",
"trustly", "trustly",
"twint",
"upi_collect", "upi_collect",
"walley", "walley",
"we_chat_pay" "we_chat_pay"
@ -9041,6 +9042,18 @@
} }
} }
}, },
{
"type": "object",
"required": [
"twint_redirect"
],
"properties": {
"twint_redirect": {
"type": "object",
"description": "Wallet data for Twint Redirection"
}
}
},
{ {
"type": "object", "type": "object",
"required": [ "required": [