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:
Swangi Kumari
2023-07-01 15:27:33 +05:30
committed by GitHub
parent 2f9c28938f
commit f091be60cc
3 changed files with 90 additions and 12 deletions

View File

@ -1,4 +1,5 @@
use api_models::payments; use api_models::payments;
use common_utils::pii::Email;
use error_stack::IntoReport; use error_stack::IntoReport;
use masking::Secret; use masking::Secret;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -46,6 +47,8 @@ pub enum PaymentMethodData {
Ideal(Box<IdealMethodData>), Ideal(Box<IdealMethodData>),
Paypal(Box<PaypalMethodData>), Paypal(Box<PaypalMethodData>),
Sofort, Sofort,
Przelewy24(Box<Przelewy24MethodData>),
Bancontact,
DirectDebit(Box<DirectDebitMethodData>), DirectDebit(Box<DirectDebitMethodData>),
} }
@ -68,6 +71,12 @@ pub struct PaypalMethodData {
shipping_address: Option<Address>, shipping_address: Option<Address>,
} }
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Przelewy24MethodData {
billing_email: Option<Email>,
}
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct DirectDebitMethodData { 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::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()), _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
} }
} }

View File

@ -130,6 +130,52 @@ async fn should_make_mollie_giropay_payment(c: WebDriver) -> Result<(), WebDrive
Ok(()) 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] #[test]
#[serial] #[serial]
fn should_make_mollie_paypal_payment_test() { 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() { fn should_make_mollie_giropay_payment_test() {
tester!(should_make_mollie_giropay_payment); 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);
}

View File

@ -504,18 +504,23 @@ pub fn make_capabilities(s: &str) -> Capabilities {
} }
} }
fn get_chrome_profile_path() -> Result<String, WebDriverError> { fn get_chrome_profile_path() -> Result<String, WebDriverError> {
let exe = env::current_exe()?; env::var("CHROME_PROFILE_PATH").map_or_else(
let dir = exe.parent().expect("Executable must be in some directory"); |_| -> Result<String, WebDriverError> {
let mut base_path = dir let exe = env::current_exe()?;
.to_str() let dir = exe.parent().expect("Executable must be in some directory");
.map(|str| { let mut base_path = dir
let mut fp = str.split(MAIN_SEPARATOR).collect::<Vec<_>>(); .to_str()
fp.truncate(3); .map(|str| {
fp.join(&MAIN_SEPARATOR.to_string()) let mut fp = str.split(MAIN_SEPARATOR).collect::<Vec<_>>();
}) fp.truncate(3);
.unwrap(); fp.join(&MAIN_SEPARATOR.to_string())
base_path.push_str(r#"/Library/Application\ Support/Google/Chrome/Default"#); })
Ok(base_path) .unwrap();
base_path.push_str(r#"/Library/Application\ Support/Google/Chrome/Default"#);
Ok(base_path)
},
Ok,
)
} }
fn get_firefox_profile_path() -> Result<String, WebDriverError> { fn get_firefox_profile_path() -> Result<String, WebDriverError> {
let exe = env::current_exe()?; let exe = env::current_exe()?;