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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
test(cypress): add paysafe bank redirect, wallet, and gift card coverage (#12357)
HS-QUALIBOTa27c43e60c1b
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex 58fdbf95b2..7285c7d133 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -614,7 +614,7 @@ export const payment_methods_enabled = [},{payment_method_type: "pay_safe_card",- payment_experience: null,+ payment_experience: "redirect_to_url",card_networks: null,accepted_currencies: null,accepted_countries: null,@@ -1258,6 +1258,17 @@ export const connectorDetails = {},},}),+ Skrill: getCustomExchange({+ Request: {+ payment_method: "wallet",+ payment_method_type: "skrill",+ payment_method_data: {+ wallet: {+ skrill: {},+ },+ },+ },+ }),},pay_later_pm: {PaymentIntent: (paymentMethodType) =>@@ -3671,6 +3682,17 @@ export const connectorDetails = {body: { status: "failed" },},}),+ PaySafeCard: getCustomExchange({+ Request: {+ payment_method: "gift_card",+ payment_method_type: "pay_safe_card",+ payment_method_data: {+ gift_card: {+ pay_safe_card: {},+ },+ },+ },+ }),},pm_collect_link: {pmCollectLinkCreate: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.jsindex eac81d2116..dd5679be93 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js@@ -198,6 +198,8 @@ const CURRENCY_MAP = {Interac: "CAD", // Canadian payment methodAliPayHk: "HKD", // Hong Kong payment methodMifinity: "EUR", // Mifinity wallet payment method+ Skrill: "USD", // Skrill wallet payment method+ PaySafeCard: "USD", // PaySafeCard gift card payment method};export const getCurrency = (paymentMethodType) => {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Paysafe.js b/cypress-tests/cypress/e2e/configs/Payment/Paysafe.jsindex 112308efe4..b1c378ff7d 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Paysafe.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Paysafe.js@@ -1,4 +1,5 @@import { customerAcceptance } from "./Commons";+import { getCurrency, getCustomExchange } from "./Modifiers";const successfulNo3DSCardDetails = {card_number: "4530910000012345",@@ -551,4 +552,124 @@ export const connectorDetails = {},},},+ bank_redirect_pm: {+ PaymentIntent: (paymentMethodType) =>+ getCustomExchange({+ Request: { currency: getCurrency(paymentMethodType) },+ Response: {+ status: 200,+ body: { status: "requires_payment_method" },+ },+ }),+ Interac: {+ Request: {+ payment_method: "bank_redirect",+ payment_method_type: "interac",+ payment_method_data: {+ bank_redirect: {+ interac: {+ email: "[email protected]",+ },+ },+ },+ billing: {+ email: "[email protected]",+ address: {+ line1: "1467",+ line2: "Harrison Street",+ line3: "Harrison Street",+ city: "Toronto",+ state: "ON",+ zip: "M5V 2T6",+ country: "CA",+ first_name: "joseph",+ last_name: "Doe",+ },+ phone: {+ number: "9123456789",+ country_code: "+1",+ },+ },+ },+ Response: {+ status: 200,+ body: { status: "requires_customer_action" },+ },+ },+ },+ wallet_pm: {+ PaymentIntent: (paymentMethodType) =>+ getCustomExchange({+ Request: {+ currency: getCurrency(paymentMethodType),+ },+ Response: {+ status: 200,+ body: { status: "requires_payment_method" },+ },+ }),+ Skrill: {+ Request: {+ payment_method: "wallet",+ payment_method_type: "skrill",+ payment_method_data: {+ wallet: {+ skrill: {},+ },+ },+ billing: {+ email: "[email protected]",+ address: {+ line1: "1467",+ line2: "Harrison Street",+ line3: "Harrison Street",+ city: "San Fransico",+ state: "CA",+ zip: "94122",+ country: "US",+ first_name: "joseph",+ last_name: "Doe",+ },+ phone: {+ number: "9123456789",+ country_code: "+1",+ },+ },+ },+ Response: {+ status: 200,+ body: { status: "requires_customer_action" },+ },+ },+ },+ gift_card_pm: {+ PaySafeCard: {+ Request: {+ payment_method: "gift_card",+ payment_method_type: "pay_safe_card",+ payment_method_data: {+ gift_card: {+ pay_safe_card: {},+ },+ },+ billing: {+ email: "[email protected]",+ address: {+ line1: "1467",+ line2: "Harrison Street",+ city: "Toronto",+ state: "ON",+ zip: "M5V 2T6",+ country: "CA",+ first_name: "John",+ last_name: "Doe",+ },+ },+ },+ Response: {+ status: 200,+ body: { status: "requires_customer_action" },+ },+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex a8008a4be0..379a80e0ba 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -530,6 +530,8 @@ export const CONNECTOR_LISTS = {ALIPAY_HK_WALLET: ["adyen"],PAYPAL_WALLET: ["novalnet", "paypal"],MIFINITY_WALLET: ["mifinity"],+ SKRILL_WALLET: ["paysafe"],+ PAYSAFECARD_GIFT_CARD: ["paysafe"],PAYPAL_MANDATE: ["paypal"],CARD_INSTALLMENTS: ["adyen"],BILLING_DESCRIPTOR: [diff --git a/cypress-tests/cypress/e2e/spec/Payment/19-Wallet.cy.js b/cypress-tests/cypress/e2e/spec/Payment/19-Wallet.cy.jsindex eecfb1416c..9b2515d762 100644--- a/cypress-tests/cypress/e2e/spec/Payment/19-Wallet.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/19-Wallet.cy.js@@ -517,3 +517,99 @@ describe("PayPal Wallet tests", () => {});});});++describe("Skrill Wallet tests", () => {+ before("seed global state", function () {+ let skip = false;++ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);+ const connector = globalState.get("connectorId");++ if (+ shouldIncludeConnector(+ connector,+ CONNECTOR_LISTS.INCLUDE.SKRILL_WALLET+ )+ ) {+ skip = true;+ return;+ }+ })+ .then(() => {+ if (skip) {+ cy.log(+ "Skipping Skrill wallet tests — connector not in SKRILL_WALLET list"+ );+ this.skip();+ }+ });+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("Skrill - Create and Confirm flow test", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payment-call-test", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["PaymentIntent"]("Skrill");++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );+ if (shouldContinue) shouldContinue = should_continue_further(data);+ });++ it("payment_methods-call-test", () => {+ cy.paymentMethodsCallTest(globalState);+ });++ it("Confirm Skrill wallet redirect", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["Skrill"];++ cy.confirmBankRedirectCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState+ );++ if (shouldContinue) shouldContinue = should_continue_further(data);+ });++ it("Handle Skrill bank redirect redirection", () => {+ const expected_redirection = fixtures.confirmBody["return_url"];+ const payment_method_type = globalState.get("paymentMethodType");+ cy.handleBankRedirectRedirection(+ globalState,+ payment_method_type,+ expected_redirection+ );+ });++ it("Sync payment status", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["Skrill"];++ cy.retrievePaymentCallTest({ globalState, data });+ });+ });+});diff --git a/cypress-tests/cypress/e2e/spec/Payment/42-GiftCardPayment.cy.js b/cypress-tests/cypress/e2e/spec/Payment/42-GiftCardPayment.cy.jsindex 2df99b7d60..c3744bc056 100644--- a/cypress-tests/cypress/e2e/spec/Payment/42-GiftCardPayment.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/42-GiftCardPayment.cy.js@@ -299,3 +299,101 @@ describe("Gift Card Payment - Adyen Givex", () => {});});});++describe("PaySafeCard Payment - Paysafe", () => {+ let globalState;+ let connector;++ before("seed global state", function () {+ let skip = false;++ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);+ connector = globalState.get("connectorId");++ if (+ shouldIncludeConnector(+ connector,+ CONNECTOR_LISTS.INCLUDE.PAYSAFECARD_GIFT_CARD+ )+ ) {+ skip = true;+ return;+ }+ })+ .then(() => {+ if (skip) {+ cy.log(+ `Skipping PaySafeCard tests for connector: ${connector} — not in PAYSAFECARD_GIFT_CARD inclusion list`+ );+ this.skip();+ }+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("PaySafeCard - Create and Confirm flow test", () => {+ it("create-and-confirm-paysafecard-payment", () => {+ let shouldContinue = true;++ cy.step("Create and Confirm PaySafeCard Payment", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "gift_card_pm"+ ]["PaySafeCard"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (data.Request && data.Request.payment_method_type) {+ globalState.set(+ "paymentMethodType",+ data.Request.payment_method_type+ );+ }++ if (!should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Handle Bank Redirect Redirection", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Handle Bank Redirect Redirection");+ return;+ }+ const expected_redirection = fixtures.confirmBody["return_url"];+ const payment_method_type = globalState.get("paymentMethodType");+ cy.handleBankRedirectRedirection(+ globalState,+ payment_method_type,+ expected_redirection+ );+ });++ cy.step("Retrieve Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "gift_card_pm"+ ]["PaySafeCard"];++ cy.retrievePaymentCallTest({ globalState, data });+ });+ });+ });+});diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex bfa798ca5e..c559c34a9f 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -1281,6 +1281,30 @@ function bankRedirectRedirection(}break;+ case "paysafe":+ switch (paymentMethodType) {+ case "interac":+ cy.log("Handling Paysafe Interac bank redirect flow");++ verifyUrl = false;+ break;+ case "skrill":+ cy.log("Handling Paysafe Skrill wallet redirect flow");++ verifyUrl = false;+ break;+ case "pay_safe_card":+ cy.log("Handling Paysafe PaySafeCard gift card redirect flow");++ verifyUrl = false;+ break;+ default:+ throw new Error(+ `Unsupported Paysafe payment method type in handleFlow: ${paymentMethodType}`+ );+ }+ break;+default:throw new Error(`Unsupported connector in handleFlow: ${connectorId}`