Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(connector): [Multisafepay] implement Paypal for Multisafepay (#1459)

AkshayaFoiger2c10e0b05c57
diff --git a/crates/router/src/connector/multisafepay/transformers.rs b/crates/router/src/connector/multisafepay/transformers.rs
index 28231334f5..b8110701e2 100644
--- a/crates/router/src/connector/multisafepay/transformers.rs
+++ b/crates/router/src/connector/multisafepay/transformers.rs
@@ -31,6 +31,7 @@ pub enum Gateway {
Visa,
Klarna,
Googlepay,
+ Paypal,
}
#[serde_with::skip_serializing_none]
@@ -243,14 +244,26 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
let payment_type = match item.request.payment_method_data {
api::PaymentMethodData::Card(ref _ccard) => Type::Direct,
- api::PaymentMethodData::Wallet(api::WalletData::GooglePay(_)) => Type::Direct,
+ api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data {
+ api::WalletData::GooglePay(_) => Type::Direct,
+ api::WalletData::PaypalRedirect(_) => Type::Redirect,
+ _ => Err(errors::ConnectorError::NotImplemented(
+ "Payment method".to_string(),
+ ))?,
+ },
api::PaymentMethodData::PayLater(ref _paylater) => Type::Redirect,
_ => Type::Redirect,
};
let gateway = match item.request.payment_method_data {
api::PaymentMethodData::Card(ref ccard) => Gateway::try_from(ccard.get_card_issuer()?)?,
- api::PaymentMethodData::Wallet(api::WalletData::GooglePay(_)) => Gateway::Googlepay,
+ api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data {
+ api::WalletData::GooglePay(_) => Gateway::Googlepay,
+ api::WalletData::PaypalRedirect(_) => Gateway::Paypal,
+ _ => Err(errors::ConnectorError::NotImplemented(
+ "Payment method".to_string(),
+ ))?,
+ },
api::PaymentMethodData::PayLater(
api_models::payments::PayLaterData::KlarnaRedirect {
billing_email: _,
@@ -312,7 +325,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
};
let gateway_info = match item.request.payment_method_data {
- api::PaymentMethodData::Card(ref ccard) => GatewayInfo::Card(CardInfo {
+ api::PaymentMethodData::Card(ref ccard) => Some(GatewayInfo::Card(CardInfo {
card_number: Some(ccard.card_number.clone()),
card_expiry_date: Some(
(format!(
@@ -328,25 +341,33 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
flexible_3d: None,
moto: None,
term_url: None,
- }),
- api::PaymentMethodData::Wallet(api::WalletData::GooglePay(ref google_pay)) => {
- GatewayInfo::Wallet(WalletInfo::GooglePay({
- GpayInfo {
- payment_token: Some(google_pay.tokenization_data.token.clone()),
- }
+ })),
+ api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data {
+ api::WalletData::GooglePay(ref google_pay) => {
+ Some(GatewayInfo::Wallet(WalletInfo::GooglePay({
+ GpayInfo {
+ payment_token: Some(google_pay.tokenization_data.token.clone()),
+ }
+ })))
+ }
+ api::WalletData::PaypalRedirect(_) => None,
+ _ => Err(errors::ConnectorError::NotImplemented(
+ "Payment method".to_string(),
+ ))?,
+ },
+ api::PaymentMethodData::PayLater(ref paylater) => {
+ Some(GatewayInfo::PayLater(PayLaterInfo {
+ email: Some(match paylater {
+ api_models::payments::PayLaterData::KlarnaRedirect {
+ billing_email,
+ ..
+ } => billing_email.clone(),
+ _ => Err(errors::ConnectorError::NotImplemented(
+ "Payment method".to_string(),
+ ))?,
+ }),
}))
}
- api::PaymentMethodData::PayLater(ref paylater) => GatewayInfo::PayLater(PayLaterInfo {
- email: Some(match paylater {
- api_models::payments::PayLaterData::KlarnaRedirect {
- billing_email,
- billing_country: _,
- } => billing_email.clone(),
- _ => Err(errors::ConnectorError::NotImplemented(
- "Only KlarnaRedirect is implemented".to_string(),
- ))?,
- }),
- }),
_ => Err(errors::ConnectorError::NotImplemented(
"Payment method".to_string(),
))?,
@@ -362,7 +383,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
payment_options: Some(payment_options),
customer: Some(customer),
delivery: Some(delivery),
- gateway_info: Some(gateway_info),
+ gateway_info,
checkout_options: None,
shopping_cart: None,
capture: None,
diff --git a/crates/router/tests/connectors/multisafepay_ui.rs b/crates/router/tests/connectors/multisafepay_ui.rs
index 292634cdb1..7866fb63d9 100644
--- a/crates/router/tests/connectors/multisafepay_ui.rs
+++ b/crates/router/tests/connectors/multisafepay_ui.rs
@@ -11,10 +11,10 @@ impl SeleniumTest for MultisafepaySeleniumTest {
}
}
-async fn should_make_gpay_payment(c: WebDriver) -> Result<(), WebDriverError> {
+async fn should_make_gpay_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
let conn = MultisafepaySeleniumTest {};
conn.make_redirection_payment(
- c,
+ web_driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/153"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
@@ -26,8 +26,31 @@ async fn should_make_gpay_payment(c: WebDriver) -> Result<(), WebDriverError> {
Ok(())
}
+async fn should_make_paypal_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = MultisafepaySeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/154"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Css(
+ "button[class='btn btn-msp-success btn-block']",
+ ))),
+ Event::Assert(Assert::IsPresent("succeeded")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
#[test]
#[serial]
fn should_make_gpay_payment_test() {
tester!(should_make_gpay_payment);
}
+
+#[test]
+#[serial]
+fn should_make_paypal_payment_test() {
+ tester!(should_make_paypal_payment);
+}