mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
feat(connector): [Mollie] Implement Przelewy24 and BancontactCard Bank Redirects for Mollie connector (#1303)
Co-authored-by: Jagan Elavarasan <jaganelavarasan@gmail.com>
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use api_models::payments;
|
||||
use common_utils::pii::Email;
|
||||
use error_stack::IntoReport;
|
||||
use masking::Secret;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -46,6 +47,8 @@ pub enum PaymentMethodData {
|
||||
Ideal(Box<IdealMethodData>),
|
||||
Paypal(Box<PaypalMethodData>),
|
||||
Sofort,
|
||||
Przelewy24(Box<Przelewy24MethodData>),
|
||||
Bancontact,
|
||||
DirectDebit(Box<DirectDebitMethodData>),
|
||||
}
|
||||
|
||||
@ -68,6 +71,12 @@ pub struct PaypalMethodData {
|
||||
shipping_address: Option<Address>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Przelewy24MethodData {
|
||||
billing_email: Option<Email>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DirectDebitMethodData {
|
||||
@ -159,6 +168,12 @@ impl TryFrom<&api_models::payments::BankRedirectData> for PaymentMethodData {
|
||||
})))
|
||||
}
|
||||
api_models::payments::BankRedirectData::Sofort { .. } => Ok(Self::Sofort),
|
||||
api_models::payments::BankRedirectData::Przelewy24 {
|
||||
billing_details, ..
|
||||
} => Ok(Self::Przelewy24(Box::new(Przelewy24MethodData {
|
||||
billing_email: billing_details.email.clone(),
|
||||
}))),
|
||||
api_models::payments::BankRedirectData::BancontactCard { .. } => Ok(Self::Bancontact),
|
||||
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +130,52 @@ async fn should_make_mollie_giropay_payment(c: WebDriver) -> Result<(), WebDrive
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn should_make_mollie_bancontact_card_payment(c: WebDriver) -> Result<(), WebDriverError> {
|
||||
let conn = MollieSeleniumTest {};
|
||||
conn.make_redirection_payment(
|
||||
c,
|
||||
vec![
|
||||
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/86"))),
|
||||
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
|
||||
Event::Assert(Assert::IsPresent("Test profile")),
|
||||
Event::Trigger(Trigger::Click(By::Css("input[value='paid']"))),
|
||||
Event::Trigger(Trigger::Click(By::Css(
|
||||
"button[class='button form__button']",
|
||||
))),
|
||||
Event::Assert(Assert::IsPresent("Google")),
|
||||
Event::Assert(Assert::Contains(
|
||||
Selector::QueryParamStr,
|
||||
"status=succeeded",
|
||||
)),
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn should_make_mollie_przelewy24_payment(c: WebDriver) -> Result<(), WebDriverError> {
|
||||
let conn = MollieSeleniumTest {};
|
||||
conn.make_redirection_payment(
|
||||
c,
|
||||
vec![
|
||||
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/87"))),
|
||||
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
|
||||
Event::Assert(Assert::IsPresent("Test profile")),
|
||||
Event::Trigger(Trigger::Click(By::Css("input[value='paid']"))),
|
||||
Event::Trigger(Trigger::Click(By::Css(
|
||||
"button[class='button form__button']",
|
||||
))),
|
||||
Event::Assert(Assert::IsPresent("Google")),
|
||||
Event::Assert(Assert::Contains(
|
||||
Selector::QueryParamStr,
|
||||
"status=succeeded",
|
||||
)),
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn should_make_mollie_paypal_payment_test() {
|
||||
@ -159,3 +205,15 @@ fn should_make_mollie_eps_payment_test() {
|
||||
fn should_make_mollie_giropay_payment_test() {
|
||||
tester!(should_make_mollie_giropay_payment);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn should_make_mollie_bancontact_card_payment_test() {
|
||||
tester!(should_make_mollie_bancontact_card_payment);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn should_make_mollie_przelewy24_payment_test() {
|
||||
tester!(should_make_mollie_przelewy24_payment);
|
||||
}
|
||||
|
||||
@ -504,18 +504,23 @@ pub fn make_capabilities(s: &str) -> Capabilities {
|
||||
}
|
||||
}
|
||||
fn get_chrome_profile_path() -> Result<String, WebDriverError> {
|
||||
let exe = env::current_exe()?;
|
||||
let dir = exe.parent().expect("Executable must be in some directory");
|
||||
let mut base_path = dir
|
||||
.to_str()
|
||||
.map(|str| {
|
||||
let mut fp = str.split(MAIN_SEPARATOR).collect::<Vec<_>>();
|
||||
fp.truncate(3);
|
||||
fp.join(&MAIN_SEPARATOR.to_string())
|
||||
})
|
||||
.unwrap();
|
||||
base_path.push_str(r#"/Library/Application\ Support/Google/Chrome/Default"#);
|
||||
Ok(base_path)
|
||||
env::var("CHROME_PROFILE_PATH").map_or_else(
|
||||
|_| -> Result<String, WebDriverError> {
|
||||
let exe = env::current_exe()?;
|
||||
let dir = exe.parent().expect("Executable must be in some directory");
|
||||
let mut base_path = dir
|
||||
.to_str()
|
||||
.map(|str| {
|
||||
let mut fp = str.split(MAIN_SEPARATOR).collect::<Vec<_>>();
|
||||
fp.truncate(3);
|
||||
fp.join(&MAIN_SEPARATOR.to_string())
|
||||
})
|
||||
.unwrap();
|
||||
base_path.push_str(r#"/Library/Application\ Support/Google/Chrome/Default"#);
|
||||
Ok(base_path)
|
||||
},
|
||||
Ok,
|
||||
)
|
||||
}
|
||||
fn get_firefox_profile_path() -> Result<String, WebDriverError> {
|
||||
let exe = env::current_exe()?;
|
||||
|
||||
Reference in New Issue
Block a user