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),
/// The wallet data for Samsung Pay
SamsungPay(Box<SamsungPayWalletData>),
/// Wallet data for Twint Redirection
TwintRedirect {},
/// The wallet data for WeChat Pay Redirection
WeChatPayRedirect(Box<WeChatPayRedirection>),
/// The wallet data for WeChat Pay

View File

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

View File

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

View File

@ -305,6 +305,7 @@ pub enum AdyenPaymentMethod<'a> {
SepaDirectDebit(Box<SepaDirectDebitData>),
BacsDirectDebit(Box<BacsDirectDebitData>),
SamsungPay(Box<SamsungPayPmData>),
Twint(Box<TwintWalletData>),
}
#[derive(Debug, Clone, Serialize)]
@ -658,6 +659,12 @@ pub struct AdyenApplePay {
apple_pay_token: Secret<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TwintWalletData {
#[serde(rename = "type")]
payment_type: PaymentType,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AdyenPayLaterData {
#[serde(rename = "type")]
@ -735,6 +742,7 @@ pub enum PaymentType {
#[serde(rename = "directdebit_GB")]
BacsDirectDebit,
Samsungpay,
Twint,
}
pub struct AdyenTestBankNames<'a>(&'a str);
@ -1209,6 +1217,12 @@ impl<'a> TryFrom<&api::WalletData> for AdyenPaymentMethod<'a> {
};
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()),
}
}

View File

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

View File

@ -209,6 +209,26 @@ async fn should_make_adyen_clearpay_payment(driver: WebDriver) -> Result<(), Web
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]
#[serial]
#[ignore]
@ -266,4 +286,10 @@ fn should_make_adyen_clearpay_payment_test() {
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

View File

@ -6823,6 +6823,7 @@
"sofort",
"swish",
"trustly",
"twint",
"upi_collect",
"walley",
"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",
"required": [