From 055347606b7d023d732ba6900e153513c4fe2a9c Mon Sep 17 00:00:00 2001 From: likhinbopanna <131246334+likhinbopanna@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:17:45 +0530 Subject: [PATCH] ci(cypress): Add bank redirects for stripe (#4772) Co-authored-by: Likhin Bopanna --- .../e2e/PaymentTest/00017-BankRedirect.cy.js | 60 +++++++- .../cypress/e2e/PaymentUtils/Adyen.js | 28 +++- .../cypress/e2e/PaymentUtils/Commons.js | 16 +++ .../cypress/e2e/PaymentUtils/Stripe.js | 135 ++++++++++++++++++ .../cypress/e2e/PaymentUtils/Trustpay.js | 1 - .../fixtures/create-connector-body.json | 11 ++ .../cypress/support/redirectionHandler.js | 26 +++- 7 files changed, 273 insertions(+), 4 deletions(-) diff --git a/cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js index 0706cf15b13f..f031f15140aa 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js @@ -301,7 +301,65 @@ describe("Bank Redirect tests", () => { cy.handleBankRedirectRedirection( globalState, payment_method_type, - expected_redirection, + expected_redirection + ); + }); + }); + + context("Przelewy24 Create and Confirm flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if (!should_continue) { + this.skip(); + } + }); + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "bank_redirect_pm" + ]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + createPaymentBody, + req_data, + res_data, + "three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("payment_methods-call-test", () => { + cy.paymentMethodsCallTest(globalState); + }); + + it("Confirm bank redirect", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "bank_redirect_pm" + ]["przelewy24"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmBankRedirectCallTest( + confirmBody, + req_data, + res_data, + true, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("Handle bank redirect redirection", () => { + let expected_redirection = confirmBody["return_url"]; + let payment_method_type = globalState.get("paymentMethodType"); + cy.handleBankRedirectRedirection( + globalState, + payment_method_type, + expected_redirection ); }); }); diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js index 19b6f342249a..36c3d2c205de 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js @@ -441,7 +441,6 @@ export const connectorDetails = { bank_name: "", bank_account_bic: "", bank_account_iban: "", - preferred_language: "en", country: "DE", }, }, @@ -493,6 +492,33 @@ export const connectorDetails = { }, }, }, + przelewy24: { + Request: { + payment_method: "bank_redirect", + payment_method_type: "przelewy24", + payment_method_data: { + bank_redirect: { + przelewy24: { + bank_name: "citi", + billing_details: { + email: "guest@juspay.in", + }, + }, + }, + }, + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: "Payment method type not supported", + code: "HE_03", + reason: "automatic for przelewy24 is not supported by adyen", + }, + }, + }, + }, blik: { Request: { payment_method: "bank_redirect", diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js index d3228396fc7f..250396cb25f7 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js @@ -481,6 +481,22 @@ export const connectorDetails = { }, }, }), + przelewy24: getCustomExchange({ + Request: { + payment_method: "bank_redirect", + payment_method_type: "przelewy24", + payment_method_data: { + bank_redirect: { + przelewy24: { + bank_name: "citi", + billing_details: { + email: "guest@juspay.in", + }, + }, + }, + }, + }, + }), blikPaymentIntent: getCustomExchange({ Request: { currency: "PLN", diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js index 841c40b87361..7af51bf00758 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js @@ -1,3 +1,5 @@ +import { getCustomExchange } from "./Commons"; + const successfulTestCard = "4242424242424242"; const successful3DSCard = "4000002760003184"; @@ -370,4 +372,137 @@ export const connectorDetails = { }, }, }, + bank_redirect_pm: { + PaymentIntent: getCustomExchange({ + Request: { + currency: "EUR", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + }, + }, + }), + ideal: { + Request: { + payment_method: "bank_redirect", + payment_method_type: "ideal", + payment_method_data: { + bank_redirect: { + ideal: { + bank_name: "ing", + country: "NL", + }, + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + giropay: { + Request: { + payment_method: "bank_redirect", + payment_method_type: "giropay", + payment_method_data: { + bank_redirect: { + giropay: { + country: "DE", + }, + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + sofort: { + Request: { + payment_method: "bank_redirect", + payment_method_type: "sofort", + payment_method_data: { + bank_redirect: { + sofort: { + country: "DE", + preferred_language: "en", + }, + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + eps: { + Request: { + payment_method: "bank_redirect", + payment_method_type: "eps", + payment_method_data: { + bank_redirect: { + eps: { + bank_name: "bank_austria", + }, + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + blik: { + Request: { + payment_method: "bank_redirect", + payment_method_type: "blik", + payment_method_data: { + bank_redirect: { + blik: { + blik_code: "777987", + }, + }, + }, + }, + Response: { + status: 200, + body: { + status: "failed", + error_code: "payment_intent_invalid_parameter", + }, + }, + }, + przelewy24: { + Request: { + payment_method: "bank_redirect", + payment_method_type: "przelewy24", + payment_method_data: { + bank_redirect: { + przelewy24: { + bank_name: "citi", + billing_details: { + email: "guest@juspay.in", + }, + }, + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + }, }; diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js b/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js index d2a8b956b9d6..338371f72e60 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js @@ -470,7 +470,6 @@ export const connectorDetails = { bank_name: "", bank_account_bic: "", bank_account_iban: "", - preferred_language: "en", country: "DE", }, }, diff --git a/cypress-tests/cypress/fixtures/create-connector-body.json b/cypress-tests/cypress/fixtures/create-connector-body.json index 9ab253565ed7..0bfa7e49113a 100644 --- a/cypress-tests/cypress/fixtures/create-connector-body.json +++ b/cypress-tests/cypress/fixtures/create-connector-body.json @@ -122,6 +122,17 @@ "maximum_amount": 68607706, "recurring_enabled": true, "installment_payment_enabled": true + }, + { + "payment_method_type": "przelewy24", + "payment_experience": null, + "card_networks": null, + "accepted_currencies": null, + "accepted_countries": null, + "minimum_amount": 1, + "maximum_amount": 68607706, + "recurring_enabled": true, + "installment_payment_enabled": true } ] } diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.js index f6b65d825142..67953a0907ad 100644 --- a/cypress-tests/cypress/support/redirectionHandler.js +++ b/cypress-tests/cypress/support/redirectionHandler.js @@ -193,7 +193,31 @@ function bankRedirectRedirection( break; default: throw new Error( - `Unsupported payment method type: ${payment_method_type}`, + `Unsupported payment method type: ${payment_method_type}` + ); + } + verifyUrl = true; + break; + case "stripe": + switch (payment_method_type) { + case "eps": + cy.get('a[name="success"]').click(); + break; + case "ideal": + cy.get('a[name="success"]').click(); + break; + case "giropay": + cy.get('a[name="success"]').click(); + break; + case "sofort": + cy.get('a[name="success"]').click(); + break; + case "przelewy24": + cy.get('a[name="success"]').click(); + break; + default: + throw new Error( + `Unsupported payment method type: ${payment_method_type}` ); } verifyUrl = true;