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): add support for bank redirect for Paypal (#1107)

Prasunna Soppa57887bdf3a89
diff --git a/.github/testcases/ui_tests.json b/.github/testcases/ui_tests.json
index e0445ce8e8..f85ffa23d9 100644
--- a/.github/testcases/ui_tests.json
+++ b/.github/testcases/ui_tests.json
@@ -1,5 +1,4 @@
{
- "tests_to_ignore": [],
"1": {
"id": 1,
"name": "stripe giropay",
@@ -1348,6 +1347,75 @@
"id": 225,
"name": "Boleto Bancario",
"connector": "adyen_uk",
- "request": "{\"amount\":6540,\"currency\":\"BRL\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"voucher\",\"payment_method_type\":\"boleto_bancario\",\"payment_method_data\":{\"voucher\":{\"boleto_bancario\":{\"social_security_number\":\"56861752509\"}}}}"
- }
-}
+ "request": "{\"amount\":6540,\"currency\":\"BRL\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"voucher\",\"payment_method_type\":\"boleto\",\"payment_method_data\":{\"voucher\":{\"boleto\":{\"social_security_number\":\"56861752509\"}}}}"
+ },
+ "227": {
+ "id": 227,
+ "name": "authorizedotnet payment success for webhook",
+ "connector": "authorizedotnet",
+ "request": "{\"amount\":400,\"currency\":\"USD\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":40,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://hs-payments-test.netlify.app/payments\",\"payment_method\":\"card\",\"payment_method_type\":\"credit\",\"payment_method_data\":{\"card\":{\"card_number\":\"5424000000000015\",\"card_exp_month\":\"01\",\"card_exp_year\":\"2025\",\"card_holder_name\":\"joseph Doe\",\"card_cvc\":\"123\"}},\"billing\":{\"address\":{\"line1\":\"1467\",\"line2\":\"CA\",\"line3\":\"CA\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"joseph\",\"last_name\":\"Doe\"},\"phone\":{\"number\":\"8056594427\",\"country_code\":\"+91\"}},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"CA\",\"line3\":\"CA\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"joseph\",\"last_name\":\"Doe\"},\"phone\":{\"number\":\"8056594427\",\"country_code\":\"+91\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"ip_address\":\"127.2.2.0\",\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"}}"
+ },
+ "228": {
+ "id": 228,
+ "name": "BNI VA",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"IDR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"bank_transfer\",\"payment_method_type\":\"bni_va\",\"payment_method_data\":{\"bank_transfer\":{\"bni_va_bank_transfer\":{\"billing_details\":{\"first_name\":\"Some\",\"second_name\":\"one\",\"email\":\"[email protected]\"}}}}}"
+ },
+ "229": {
+ "id": 229,
+ "name": "pay_JbukS3WUqF6MVjTp2fe1",
+ "connector": "adyen",
+ "request": "{\"amount\":7000,\"currency\":\"SEK\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+65\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://hs-payments-test.netlify.app/payments\",\"billing\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"country\":\"SE\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"SE\",\"first_name\":\"John\",\"last_name\":\"Doe\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"order_details\":{\"product_name\":\"Socks\",\"amount\":7000,\"quantity\":1}},\"payment_method\":\"pay_later\",\"payment_method_type\":\"klarna\",\"payment_experience\":\"redirect_to_url\",\"payment_method_data\":{\"pay_later\":{\"klarna_redirect\":{\"billing_email\":\"[email protected]\",\"billing_country\":\"SE\"}}}}"
+ },
+ "230": {
+ "id": 230,
+ "name": "Indonesian Alfamart",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"IDR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"voucher\",\"payment_method_type\":\"alfamart\",\"payment_method_data\":{\"voucher\":{\"alfamart\":{\"first_name\":\"Some\",\"second_name\":\"one\",\"email\":\"[email protected]\"}}}}"
+ },
+ "231": {
+ "id": 231,
+ "name": "Indonesian Bank Transfer Permata",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"IDR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"bank_transfer\",\"payment_method_type\":\"permata_bank_transfer\",\"payment_method_data\":{\"bank_transfer\":{\"permata_bank_transfer\":{\"billing_details\":{\"first_name\":\"Some\",\"second_name\":\"one\",\"email\":\"[email protected]\"}}}}}"
+ },
+ "232": {
+ "id": 232,
+ "name": "Adyen Open Banking UK",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"GBP\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://hs-payments-test.netlify.app/payments\",\"payment_method\":\"bank_redirect\",\"payment_method_data\":{\"bank_redirect\":{\"open_banking_uk\":{\"issuer\":\"open_bank_success\",\"country\":\"GB\"}}},\"billing\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"GB\",\"first_name\":\"joseph\",\"last_name\":\"Doe\"},\"phone\":{\"number\":\"8056594427\",\"country_code\":\"+91\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"GB\",\"first_name\":\"joseph\",\"last_name\":\"Doe\"},\"phone\":{\"number\":\"8056594427\",\"country_code\":\"+91\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"}}"
+ },
+ "233": {
+ "id": 233,
+ "name": "paypal-giropay-success",
+ "connector": "paypal",
+ "request": "{\"amount\":1000,\"currency\":\"EUR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":1000,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+65\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://google.com\",\"billing\":{\"address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"DE\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"John\",\"last_name\":\"Doe\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"},\"payment_method\":\"bank_redirect\",\"payment_method_type\":\"giropay\",\"payment_method_data\":{\"bank_redirect\":{\"giropay\":{\"billing_details\":{\"billing_name\":\"John Doe\"},\"bank_name\":\"\",\"preferred_language\":\"en\",\"country\":\"DE\"}}}}"
+ },
+ "234": {
+ "id": 234,
+ "name": "paypal-eps-success",
+ "connector": "paypal",
+ "request": "{\"amount\":12300,\"currency\":\"EUR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":12300,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+65\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://google.com\",\"billing\":{\"address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"AT\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"John\",\"last_name\":\"Doe\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"},\"payment_method\":\"bank_redirect\",\"payment_method_type\":\"eps\",\"payment_method_data\":{\"bank_redirect\":{\"eps\":{\"billing_details\":{\"billing_name\":\"John Doe\"},\"bank_name\":\"american_express\",\"preferred_language\":\"en\",\"country\":\"AT\"}}}}"
+ },
+ "235": {
+ "id": 235,
+ "name": "paypal-sofort-success",
+ "connector": "paypal",
+ "request": "{\"amount\":1100,\"currency\":\"EUR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":1100,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+65\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://google.com\",\"billing\":{\"address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"AT\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"John\",\"last_name\":\"Doe\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"},\"payment_method\":\"bank_redirect\",\"payment_method_type\":\"sofort\",\"payment_method_data\":{\"bank_redirect\":{\"sofort\":{\"billing_details\":{\"billing_name\":\"John Doe\"},\"bank_name\":\"\",\"preferred_language\":\"en\",\"country\":\"AT\"}}}}"
+ },
+ "236": {
+ "id": 236,
+ "name": "Adyen Seven Eleven",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"JPY\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"voucher\",\"payment_method_type\":\"seven_eleven\",\"payment_method_data\":{\"voucher\":{\"seven_eleven\":{\"first_name\":\"Some\",\"last_name\":\"One\",\"email\":\"[email protected]\",\"phone_number\":\"1234567890\"}}}}"
+ },
+ "tests_to_ignore": [
+ "noon_ui::should_make_noon_3ds_payment_test",
+ "adyen_uk_ui::should_make_adyen_online_banking_thailand_payment_test",
+ "adyen_uk_ui::should_make_adyen_blik_payment_test",
+ "authorizedotnet_ui::should_make_paypal_payment_test",
+ "multisafepay_ui::should_make_multisafepay_3ds_payment_failed_test",
+ "multisafepay_ui::should_make_multisafepay_3ds_payment_success_test",
+ "nexinets_ui::*"
+ ]
+}
\ No newline at end of file
diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs
index 0d1b3f8f9b..248525fcc4 100644
--- a/crates/api_models/src/payment_methods.rs
+++ b/crates/api_models/src/payment_methods.rs
@@ -665,3 +665,13 @@ pub struct TokenizedBankTransferValue1 {
pub struct TokenizedBankTransferValue2 {
pub customer_id: Option<String>,
}
+
+#[derive(Debug, serde::Serialize, serde::Deserialize)]
+pub struct TokenizedBankRedirectValue1 {
+ pub data: payments::BankRedirectData,
+}
+
+#[derive(Debug, serde::Serialize, serde::Deserialize)]
+pub struct TokenizedBankRedirectValue2 {
+ pub customer_id: Option<String>,
+}
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 892590e58a..5f5294589a 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -803,6 +803,10 @@ pub enum BankRedirectData {
/// The hyperswitch bank code for eps
#[schema(value_type = BankNames, example = "triodos_bank")]
bank_name: Option<api_enums::BankNames>,
+
+ /// The country for bank payment
+ #[schema(value_type = CountryAlpha2, example = "US")]
+ country: Option<api_enums::CountryAlpha2>,
},
Giropay {
/// The billing details for bank redirection
@@ -816,6 +820,10 @@ pub enum BankRedirectData {
/// Bank account iban
#[schema(value_type = Option<String>)]
bank_account_iban: Option<Secret<String>>,
+
+ /// The country for bank payment
+ #[schema(value_type = CountryAlpha2, example = "US")]
+ country: Option<api_enums::CountryAlpha2>,
},
Ideal {
/// The billing details for bank redirection
@@ -824,6 +832,10 @@ pub enum BankRedirectData {
/// The hyperswitch bank code for ideal
#[schema(value_type = BankNames, example = "abn_amro")]
bank_name: Option<api_enums::BankNames>,
+
+ /// The country for bank payment
+ #[schema(value_type = CountryAlpha2, example = "US")]
+ country: Option<api_enums::CountryAlpha2>,
},
Interac {
/// The country for bank payment
diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs
index ec74a8f021..4c11529f16 100644
--- a/crates/router/src/connector/paypal.rs
+++ b/crates/router/src/connector/paypal.rs
@@ -54,7 +54,8 @@ impl Paypal {
connector_meta: &Option<serde_json::Value>,
) -> CustomResult<Option<String>, errors::ConnectorError> {
match payment_method {
- Some(diesel_models::enums::PaymentMethod::Wallet) => {
+ Some(diesel_models::enums::PaymentMethod::Wallet)
+ | Some(diesel_models::enums::PaymentMethod::BankRedirect) => {
let meta: PaypalMeta = to_connector_meta(connector_meta.clone())?;
Ok(Some(meta.order_id))
}
@@ -384,7 +385,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
res: Response,
) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
match data.payment_method {
- diesel_models::enums::PaymentMethod::Wallet => {
+ diesel_models::enums::PaymentMethod::Wallet
+ | diesel_models::enums::PaymentMethod::BankRedirect => {
let response: paypal::PaypalRedirectResponse = res
.response
.parse_struct("paypal PaymentsRedirectResponse")
@@ -516,7 +518,8 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
) -> CustomResult<String, errors::ConnectorError> {
let paypal_meta: PaypalMeta = to_connector_meta(req.request.connector_meta.clone())?;
match req.payment_method {
- diesel_models::enums::PaymentMethod::Wallet => Ok(format!(
+ diesel_models::enums::PaymentMethod::Wallet
+ | diesel_models::enums::PaymentMethod::BankRedirect => Ok(format!(
"{}v2/checkout/orders/{}",
self.base_url(connectors),
paypal_meta.order_id
@@ -561,7 +564,8 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
res: Response,
) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError> {
match data.payment_method {
- diesel_models::enums::PaymentMethod::Wallet => {
+ diesel_models::enums::PaymentMethod::Wallet
+ | diesel_models::enums::PaymentMethod::BankRedirect => {
let response: paypal::PaypalOrdersResponse = res
.response
.parse_struct("paypal PaymentsOrderResponse")
diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs
index 622651aa9a..4852016bfe 100644
--- a/crates/router/src/connector/paypal/transformers.rs
+++ b/crates/router/src/connector/paypal/transformers.rs
@@ -1,3 +1,4 @@
+use api_models::payments::BankRedirectData;
use common_utils::errors::CustomResult;
use masking::Secret;
use serde::{Deserialize, Serialize};
@@ -5,8 +6,8 @@ use url::Url;
use crate::{
connector::utils::{
- self, to_connector_meta, AccessTokenRequestInfo, AddressDetailsData, CardData,
- PaymentsAuthorizeRequestData,
+ self, to_connector_meta, AccessTokenRequestInfo, AddressDetailsData,
+ BankRedirectBillingData, CardData, PaymentsAuthorizeRequestData,
},
core::errors,
services,
@@ -58,6 +59,7 @@ pub struct RedirectRequest {
#[derive(Debug, Serialize)]
pub struct ContextStruct {
return_url: Option<String>,
+ cancel_url: Option<String>,
}
#[derive(Debug, Serialize)]
@@ -70,6 +72,10 @@ pub struct PaypalRedirectionRequest {
pub enum PaymentSourceItem {
Card(CardRequest),
Paypal(PaypalRedirectionRequest),
+ IDeal(RedirectRequest),
+ Eps(RedirectRequest),
+ Giropay(RedirectRequest),
+ Sofort(RedirectRequest),
}
#[derive(Debug, Serialize)]
@@ -93,6 +99,68 @@ fn get_address_info(
};
Ok(address)
}
+fn get_payment_source(
+ item: &types::PaymentsAuthorizeRouterData,
+ bank_redirection_data: &BankRedirectData,
+) -> Result<PaymentSourceItem, error_stack::Report<errors::ConnectorError>> {
+ match bank_redirection_data {
+ BankRedirectData::Eps {
+ billing_details,
+ bank_name: _,
+ country,
+ } => Ok(PaymentSourceItem::Eps(RedirectRequest {
+ name: billing_details.get_billing_name()?,
+ country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "eps.country",
+ })?,
+ experience_context: ContextStruct {
+ return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
+ },
+ })),
+ BankRedirectData::Giropay {
+ billing_details,
+ country,
+ ..
+ } => Ok(PaymentSourceItem::Giropay(RedirectRequest {
+ name: billing_details.get_billing_name()?,
+ country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "giropay.country",
+ })?,
+ experience_context: ContextStruct {
+ return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
+ },
+ })),
+ BankRedirectData::Ideal {
+ billing_details,
+ bank_name: _,
+ country,
+ } => Ok(PaymentSourceItem::IDeal(RedirectRequest {
+ name: billing_details.get_billing_name()?,
+ country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "ideal.country",
+ })?,
+ experience_context: ContextStruct {
+ return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
+ },
+ })),
+ BankRedirectData::Sofort {
+ country,
+ preferred_language: _,
+ billing_details,
+ } => Ok(PaymentSourceItem::Sofort(RedirectRequest {
+ name: billing_details.get_billing_name()?,
+ country_code: *country,
+ experience_context: ContextStruct {
+ return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
+ },
+ })),
+ _ => Err(errors::ConnectorError::NotImplemented("Bank Redirect".to_string()).into()),
+ }
+}
impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaypalPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
@@ -152,6 +220,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaypalPaymentsRequest {
Some(PaymentSourceItem::Paypal(PaypalRedirectionRequest {
experience_context: ContextStruct {
return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
},
}));
@@ -165,6 +234,31 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaypalPaymentsRequest {
"Payment Method".to_string(),
))?,
},
+ api::PaymentMethodData::BankRedirect(ref bank_redirection_data) => {
+ let intent = match item.request.is_auto_capture()? {
+ true => PaypalPaymentIntent::Capture,
+ false => Err(errors::ConnectorError::FlowNotSupported {
+ flow: "Manual capture method for Bank Redirect".to_string(),
+ connector: "Paypal".to_string(),
+ })?,
+ };
+ let amount = OrderAmount {
+ currency_code: item.request.currency,
+ value: item.request.amount.to_string(),
+ };
+ let reference_id = item.attempt_id.clone();
+ let purchase_units = vec![PurchaseUnitRequest {
+ reference_id,
+ amount,
+ }];
+ let payment_source = Some(get_payment_source(item, bank_redirection_data)?);
+
+ Ok(Self {
+ intent,
+ purchase_units,
+ payment_source,
+ })
+ }
_ => Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into()),
}
}
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 221ad0487b..e7f3644964 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -795,6 +795,18 @@ impl AddressDetailsData for api::AddressDetails {
}
}
+pub trait BankRedirectBillingData {
+ fn get_billing_name(&self) -> Result<Secret<String>, Error>;
+}
+
+impl BankRedirectBillingData for payments::BankRedirectBilling {
+ fn get_billing_name(&self) -> Result<Secret<String>, Error> {
+ self.billing_name
+ .clone()
+ .ok_or_else(missing_field_err("billing_details.billing_name"))
+ }
+}
+
pub trait MandateData {
fn get_end_date(&self, format: date_time::DateFormat) -> Result<String, Error>;
fn get_metadata(&self) -> Result<pii::SecretSerdeValue, Error>;
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 6dca567567..5a504a0fac 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -211,12 +211,57 @@ impl Vaultable for api::WalletData {
}
}
+impl Vaultable for api_models::payments::BankRedirectData {
+ fn get_value1(&self, _customer_id: Option<String>) -> CustomResult<String, errors::VaultError> {
+ let value1 = api_models::payment_methods::TokenizedBankRedirectValue1 {
+ data: self.to_owned(),
+ };
+
+ utils::Encode::<api_models::payment_methods::TokenizedBankRedirectValue1>::encode_to_string_of_json(&value1)
+ .change_context(errors::VaultError::RequestEncodingFailed)
+ .attach_printable("Failed to encode bank redirect data")
+ }
+
+ fn get_value2(&self, customer_id: Option<String>) -> CustomResult<String, errors::VaultError> {
+ let value2 = api_models::payment_methods::TokenizedBankRedirectValue2 { customer_id };
+
+ utils::Encode::<api_models::payment_methods::TokenizedBankRedirectValue2>::encode_to_string_of_json(&value2)
+ .change_context(errors::VaultError::RequestEncodingFailed)
+ .attach_printable("Failed to encode bank redirect supplementary data")
+ }
+
+ fn from_values(
+ value1: String,
+ value2: String,
+ ) -> CustomResult<(Self, SupplementaryVaultData), errors::VaultError> {
+ let value1: api_models::payment_methods::TokenizedBankRedirectValue1 = value1
+ .parse_struct("TokenizedBankRedirectValue1")
+ .change_context(errors::VaultError::ResponseDeserializationFailed)
+ .attach_printable("Could not deserialize into bank redirect data")?;
+
+ let value2: api_models::payment_methods::TokenizedBankRedirectValue2 = value2
+ .parse_struct("TokenizedBankRedirectValue2")
+ .change_context(errors::VaultError::ResponseDeserializationFailed)
+ .attach_printable("Could not deserialize into supplementary bank redirect data")?;
+
+ let bank_transfer_data = value1.data;
+
+ let supp_data = SupplementaryVaultData {
+ customer_id: value2.customer_id,
+ payment_method_id: None,
+ };
+
+ Ok((bank_transfer_data, supp_data))
+ }
+}
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum VaultPaymentMethod {
Card(String),
Wallet(String),
BankTransfer(String),
+ BankRedirect(String),
}
impl Vaultable for api::PaymentMethodData {
@@ -227,6 +272,9 @@ impl Vaultable for api::PaymentMethodData {
Self::BankTransfer(bank_transfer) => {
VaultPaymentMethod::BankTransfer(bank_transfer.get_value1(customer_id)?)
}
+ Self::BankRedirect(bank_redirect) => {
+ VaultPaymentMethod::BankRedirect(bank_redirect.get_value1(customer_id)?)
+ }
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.into_report()
.attach_printable("Payment method not supported")?,
@@ -244,6 +292,9 @@ impl Vaultable for api::PaymentMethodData {
Self::BankTransfer(bank_transfer) => {
VaultPaymentMethod::BankTransfer(bank_transfer.get_value2(customer_id)?)
}
+ Self::BankRedirect(bank_redirect) => {
+ VaultPaymentMethod::BankRedirect(bank_redirect.get_value2(customer_id)?)
+ }
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.into_report()
.attach_printable("Payment method not supported")?,
@@ -285,6 +336,15 @@ impl Vaultable for api::PaymentMethodData {
api_models::payments::BankTransferData::from_values(mvalue1, mvalue2)?;
Ok((Self::BankTransfer(Box::new(bank_transfer)), supp_data))
}
+ (
+ VaultPaymentMethod::BankRedirect(mvalue1),
+ VaultPaymentMethod::BankRedirect(mvalue2),
+ ) => {
+ let (bank_redirect, supp_data) =
+ api_models::payments::BankRedirectData::from_values(mvalue1, mvalue2)?;
+ Ok((Self::BankRedirect(bank_redirect), supp_data))
+ }
+
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.into_report()
.attach_printable("Payment method not supported"),
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 326ac77196..2970034d84 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -1258,6 +1258,11 @@ pub async fn make_pm_data<'a, F: Clone, R>(
Some(storage_enums::PaymentMethod::BankTransfer);
pm
}
+ Some(api::PaymentMethodData::BankRedirect(_)) => {
+ payment_data.payment_attempt.payment_method =
+ Some(storage_enums::PaymentMethod::BankRedirect);
+ pm
+ }
Some(_) => Err(errors::ApiErrorResponse::InternalServerError)
.into_report()
.attach_printable(
@@ -1280,7 +1285,6 @@ pub async fn make_pm_data<'a, F: Clone, R>(
Ok(pm_opt.to_owned())
}
(pm @ Some(api::PaymentMethodData::PayLater(_)), _) => Ok(pm.to_owned()),
- (pm @ Some(api::PaymentMethodData::BankRedirect(_)), _) => Ok(pm.to_owned()),
(pm @ Some(api::PaymentMethodData::Crypto(_)), _) => Ok(pm.to_owned()),
(pm @ Some(api::PaymentMethodData::BankDebit(_)), _) => Ok(pm.to_owned()),
(pm @ Some(api::PaymentMethodData::Upi(_)), _) => Ok(pm.to_owned()),
@@ -1311,6 +1315,18 @@ pub async fn make_pm_data<'a, F: Clone, R>(
payment_data.token = Some(token);
Ok(pm_opt.to_owned())
}
+ (pm_opt @ Some(pm @ api::PaymentMethodData::BankRedirect(_)), _) => {
+ let token = vault::Vault::store_payment_method_data_in_locker(
+ state,
+ None,
+ pm,
+ payment_data.payment_intent.customer_id.to_owned(),
+ enums::PaymentMethod::BankRedirect,
+ )
+ .await?;
+ payment_data.token = Some(token);
+ Ok(pm_opt.to_owned())
+ }
_ => Ok(None),
}?;
diff --git a/crates/test_utils/tests/connectors/paypal_ui.rs b/crates/test_utils/tests/connectors/paypal_ui.rs
index 3e9fc162dc..6f08c87be2 100644
--- a/crates/test_utils/tests/connectors/paypal_ui.rs
+++ b/crates/test_utils/tests/connectors/paypal_ui.rs
@@ -19,8 +19,8 @@ async fn should_make_paypal_paypal_wallet_payment(
web_driver,
&format!("{CHEKOUT_BASE_URL}/saved/21"),
vec![
- Event::Trigger(Trigger::Click(By::Css(".reviewButton"))),
- Event::Assert(Assert::IsPresent("How Search works")),
+ Event::Trigger(Trigger::Click(By::Css("#payment-submit-btn"))),
+ Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::ContainsAny(
Selector::QueryParamStr,
vec!["status=processing"],
@@ -31,8 +31,92 @@ async fn should_make_paypal_paypal_wallet_payment(
Ok(())
}
+async fn should_make_paypal_ideal_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = PaypalSeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/181"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Name("Successful"))),
+ Event::Assert(Assert::IsPresent("processing")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
+async fn should_make_paypal_giropay_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = PaypalSeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/233"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Name("Successful"))),
+ Event::Assert(Assert::IsPresent("processing")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
+async fn should_make_paypal_eps_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = PaypalSeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/234"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Name("Successful"))),
+ Event::Assert(Assert::IsPresent("processing")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
+async fn should_make_paypal_sofort_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = PaypalSeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/235"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Name("Successful"))),
+ Event::Assert(Assert::IsPresent("processing")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
#[test]
#[serial]
fn should_make_paypal_paypal_wallet_payment_test() {
tester!(should_make_paypal_paypal_wallet_payment);
}
+
+#[test]
+#[serial]
+fn should_make_paypal_ideal_payment_test() {
+ tester!(should_make_paypal_ideal_payment);
+}
+
+#[test]
+#[serial]
+fn should_make_paypal_giropay_payment_test() {
+ tester!(should_make_paypal_giropay_payment);
+}
+
+#[test]
+#[serial]
+fn should_make_paypal_eps_payment_test() {
+ tester!(should_make_paypal_eps_payment);
+}
+
+#[test]
+#[serial]
+fn should_make_paypal_sofort_payment_test() {
+ tester!(should_make_paypal_sofort_payment);
+}
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index 4db52f964b..e4d0c4bc5f 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -2827,7 +2827,8 @@
"type": "object",
"required": [
"billing_details",
- "bank_name"
+ "bank_name",
+ "country"
],
"properties": {
"billing_details": {
@@ -2835,6 +2836,9 @@
},
"bank_name": {
"$ref": "#/components/schemas/BankNames"
+ },
+ "country": {
+ "$ref": "#/components/schemas/CountryAlpha2"
}
}
}
@@ -2849,7 +2853,8 @@
"giropay": {
"type": "object",
"required": [
- "billing_details"
+ "billing_details",
+ "country"
],
"properties": {
"billing_details": {
@@ -2864,6 +2869,9 @@
"type": "string",
"description": "Bank account iban",
"nullable": true
+ },
+ "country": {
+ "$ref": "#/components/schemas/CountryAlpha2"
}
}
}
@@ -2879,7 +2887,8 @@
"type": "object",
"required": [
"billing_details",
- "bank_name"
+ "bank_name",
+ "country"
],
"properties": {
"billing_details": {
@@ -2887,6 +2896,9 @@
},
"bank_name": {
"$ref": "#/components/schemas/BankNames"
+ },
+ "country": {
+ "$ref": "#/components/schemas/CountryAlpha2"
}
}
}