Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(connector): [Adyen] Implement Momo Atm(Napas) in Card Redirects #1820

Merged
merged 11 commits into from
Aug 8, 2023
87 changes: 78 additions & 9 deletions .github/testcases/ui_tests.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ pub struct Card {
pub enum CardRedirectData {
Knet {},
Benefit {},
MomoAtm {},
}

#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
Expand Down
1 change: 1 addition & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ pub enum PaymentMethodType {
MbWay,
MobilePay,
Momo,
MomoAtm,
Multibanco,
OnlineBankingThailand,
OnlineBankingCzechRepublic,
Expand Down
1 change: 1 addition & 0 deletions crates/common_enums/src/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,7 @@ impl From<PaymentMethodType> for PaymentMethod {
PaymentMethodType::MbWay => Self::Wallet,
PaymentMethodType::MobilePay => Self::Wallet,
PaymentMethodType::Momo => Self::Wallet,
PaymentMethodType::MomoAtm => Self::CardRedirect,
PaymentMethodType::Multibanco => Self::BankTransfer,
PaymentMethodType::MandiriVa => Self::BankTransfer,
PaymentMethodType::Interac => Self::BankRedirect,
Expand Down
7 changes: 7 additions & 0 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ pub enum AdyenPaymentMethod<'a> {
MobilePay(Box<MobilePayData>),
#[serde(rename = "momo_wallet")]
Momo(Box<MomoData>),
#[serde(rename = "momo_atm")]
MomoAtm,
#[serde(rename = "touchngo")]
TouchNGo(Box<TouchNGoData>),
OnlineBankingCzechRepublic(Box<OnlineBankingCzechRepublicData>),
Expand Down Expand Up @@ -1011,6 +1013,8 @@ pub enum PaymentType {
MobilePay,
#[serde(rename = "momo_wallet")]
Momo,
#[serde(rename = "momo_atm")]
MomoAtm,
#[serde(rename = "onlineBanking_CZ")]
OnlineBankingCzechRepublic,
#[serde(rename = "ebanking_FI")]
Expand Down Expand Up @@ -2047,6 +2051,7 @@ impl<'a> TryFrom<&api_models::payments::CardRedirectData> for AdyenPaymentMethod
match card_redirect_data {
payments::CardRedirectData::Knet {} => Ok(AdyenPaymentMethod::Knet),
payments::CardRedirectData::Benefit {} => Ok(AdyenPaymentMethod::Benefit),
payments::CardRedirectData::MomoAtm {} => Ok(AdyenPaymentMethod::MomoAtm),
}
}
}
Expand Down Expand Up @@ -2996,6 +3001,7 @@ pub fn get_wait_screen_metadata(
| PaymentType::Kakaopay
| PaymentType::MobilePay
| PaymentType::Momo
| PaymentType::MomoAtm
| PaymentType::OnlineBankingCzechRepublic
| PaymentType::OnlineBankingFinland
| PaymentType::OnlineBankingPoland
Expand Down Expand Up @@ -3101,6 +3107,7 @@ pub fn get_present_to_shopper_metadata(
| PaymentType::Benefit
| PaymentType::MobilePay
| PaymentType::Momo
| PaymentType::MomoAtm
| PaymentType::OnlineBankingCzechRepublic
| PaymentType::OnlineBankingFinland
| PaymentType::OnlineBankingPoland
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ impl TryFrom<enums::PaymentMethodType> for StripePaymentMethodType {
| enums::PaymentMethodType::MbWay
| enums::PaymentMethodType::MobilePay
| enums::PaymentMethodType::Momo
| enums::PaymentMethodType::MomoAtm
| enums::PaymentMethodType::Multibanco
| enums::PaymentMethodType::OnlineBankingThailand
| enums::PaymentMethodType::OnlineBankingCzechRepublic
Expand Down Expand Up @@ -876,6 +877,7 @@ fn infer_stripe_pay_later_type(
| enums::PaymentMethodType::MbWay
| enums::PaymentMethodType::MobilePay
| enums::PaymentMethodType::Momo
| enums::PaymentMethodType::MomoAtm
| enums::PaymentMethodType::Multibanco
| enums::PaymentMethodType::OnlineBankingThailand
| enums::PaymentMethodType::OnlineBankingCzechRepublic
Expand Down
4 changes: 3 additions & 1 deletion crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,9 @@ pub fn validate_payment_method_type_against_payment_method(
}
api_enums::PaymentMethod::CardRedirect => matches!(
payment_method_type,
api_enums::PaymentMethodType::Knet | api_enums::PaymentMethodType::Benefit
api_enums::PaymentMethodType::Knet
| api_enums::PaymentMethodType::Benefit
| api_enums::PaymentMethodType::MomoAtm
),
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/router/src/types/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ impl ForeignFrom<api_enums::PaymentMethodType> for api_enums::PaymentMethod {
api_enums::PaymentMethodType::Givex | api_enums::PaymentMethodType::PaySafeCard => {
Self::GiftCard
}
api_enums::PaymentMethodType::Benefit | api_enums::PaymentMethodType::Knet => {
Self::CardRedirect
}
api_enums::PaymentMethodType::Benefit
| api_enums::PaymentMethodType::Knet
| api_enums::PaymentMethodType::MomoAtm => Self::CardRedirect,
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions crates/test_utils/tests/connectors/adyen_uk_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,32 @@ async fn should_make_adyen_blik_payment(driver: WebDriver) -> Result<(), WebDriv
Ok(())
}

async fn should_make_adyen_momo_atm_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/238"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Sleep(5)), // Delay for provider to not reject payment for botting
Event::Trigger(Trigger::SendKeys(
By::Id("card-number"),
"9704 0000 0000 0018",
)),
Event::Trigger(Trigger::SendKeys(By::Id("card-expire"), "03/07")),
Event::Trigger(Trigger::SendKeys(By::Id("card-name"), "NGUYEN VAN A")),
Event::Trigger(Trigger::SendKeys(By::Id("number-phone"), "987656666")),
Event::Trigger(Trigger::Click(By::Id("btn-pay-card"))),
Event::Trigger(Trigger::SendKeys(By::Id("napasOtpCode"), "otp")),
Event::Trigger(Trigger::Click(By::Id("napasProcessBtn1"))),
Event::Trigger(Trigger::Sleep(5)), // Delay to get to status page
Event::Assert(Assert::IsPresent("succeeded")),
],
)
.await?;
Ok(())
}

#[test]
#[serial]
#[ignore]
Expand Down Expand Up @@ -825,3 +851,9 @@ fn should_make_adyen_online_banking_thailand_payment_test() {
fn should_make_adyen_touch_n_go_payment_test() {
tester!(should_make_adyen_touch_n_go_payment);
}

#[test]
#[serial]
fn should_make_adyen_momo_atm_payment_test() {
tester!(should_make_adyen_momo_atm_payment);
}
12 changes: 12 additions & 0 deletions openapi/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3666,6 +3666,17 @@
"type": "object"
}
}
},
{
"type": "object",
"required": [
"momo_atm"
],
"properties": {
"momo_atm": {
"type": "object"
}
}
}
]
},
Expand Down Expand Up @@ -7809,6 +7820,7 @@
"mb_way",
"mobile_pay",
"momo",
"momo_atm",
"multibanco",
"online_banking_thailand",
"online_banking_czech_republic",
Expand Down
Loading