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

test(cypress): add airwallex alternative payment coverage for paylater, and wallet (#12370)

HS-QUALIBOTd91290241278
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Airwallex.js b/cypress-tests/cypress/e2e/configs/Payment/Airwallex.js
index 5e919a6840..5ddf25b362 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Airwallex.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Airwallex.js
@@ -1,5 +1,5 @@
-import { customerAcceptance } from "./Commons";
-import { getCustomExchange } from "./Modifiers";
+import { customerAcceptance, standardBillingAddress } from "./Commons";
+import { getCurrency, getCustomExchange } from "./Modifiers";
const successfulNo3DSCardDetails = {
card_number: "4111111111111111", // Non-3DS Airwallex test card
@@ -1046,6 +1046,172 @@ export const connectorDetails = {
},
},
}),
+ AtomeAutoCapture: getCustomExchange({
+ Request: {
+ currency: "SGD",
+ capture_method: "automatic",
+ description: "Test Order",
+ return_url: "https://google.com/",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ Atome: getCustomExchange({
+ Request: {
+ payment_method: "pay_later",
+ payment_method_type: "atome",
+ payment_experience: "redirect_to_url",
+ payment_method_data: {
+ pay_later: {
+ atome_redirect: {},
+ },
+ },
+ billing: {
+ email: "[email protected]",
+ address: {
+ line1: "1467",
+ line2: "Harrison Street",
+ line3: "Harrison Street",
+ city: "San Fransico",
+ state: "California",
+ zip: "94122",
+ country: "SG",
+ first_name: "joseph",
+ last_name: "Doe",
+ },
+ phone: {
+ number: "9876543210",
+ country_code: "+65",
+ },
+ },
+ shipping: {
+ address: {
+ line1: "1467",
+ line2: "Harrison Street",
+ city: "San Fransico",
+ state: "California",
+ zip: "94122",
+ country: "SG",
+ },
+ },
+ order_details: [
+ {
+ product_name: "Test Product",
+ quantity: 1,
+ amount: 6000,
+ total_amount: 6000,
+ },
+ ],
+ 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",
+ },
+ return_url: "https://google.com/",
+ },
+ 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",
+ },
+ },
+ }),
+ PaypalRedirect: getCustomExchange({
+ Request: {
+ payment_method: "wallet",
+ payment_method_type: "paypal",
+ authentication_type: "no_three_ds",
+ payment_method_data: {
+ wallet: {
+ paypal_redirect: {},
+ },
+ },
+ billing: standardBillingAddress,
+ return_url: "https://example.com",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ }),
+ Skrill: getCustomExchange({
+ Request: {
+ payment_method: "wallet",
+ payment_method_type: "skrill",
+ authentication_type: "no_three_ds",
+ payment_method_data: {
+ wallet: {
+ skrill: {},
+ },
+ },
+ billing: {
+ ...standardBillingAddress,
+ email: "[email protected]",
+ },
+ return_url: "https://example.com",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ }),
+ AutoCapture: getCustomExchange({
+ Request: {
+ currency: "USD",
+ capture_method: "automatic",
+ return_url: "https://example.com",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ ManualCapture: getCustomExchange({
+ Request: {
+ currency: "USD",
+ capture_method: "manual",
+ return_url: "https://example.com",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
},
webhook: {
TransactionIdConfig: {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index d39b35f9ba..872fdd9ee8 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -805,6 +805,17 @@ export const payment_methods_enabled = [
recurring_enabled: false,
installment_payment_enabled: false,
},
+ {
+ payment_method_type: "atome",
+ payment_experience: "redirect_to_url",
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
],
},
];
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
index 9addc95b34..41720cde45 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
@@ -217,6 +217,7 @@ const CURRENCY_MAP = {
PayEasy: "JPY",
Skrill: "USD", // Skrill wallet payment method
PaySafeCard: "USD", // PaySafeCard gift card payment method
+ PaypalRedirect: "USD",
};
export const getCurrency = (paymentMethodType) => {
diff --git a/cypress-tests/cypress/e2e/spec/Payment/52-AlternativePayments.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-AlternativePayments.cy.js
new file mode 100644
index 0000000000..2434fce7b7
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/52-AlternativePayments.cy.js
@@ -0,0 +1,311 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails from "../../configs/Payment/Utils";
+import * as utils from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Airwallex Alternative Payments", () => {
+ before("seed global state", function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ const connector = globalState.get("connectorId");
+ if (connector !== "airwallex") {
+ skip = true;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ this.skip();
+ }
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("PayPal Wallet Redirect flow", () => {
+ let shouldContinue = true;
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["AtomeAutoCapture"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("payment_methods-call-test", () => {
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ it("confirm-paypal-redirect-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["PaypalRedirect"];
+
+ cy.confirmBankRedirectCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("handle-wallet-redirection-call-test", () => {
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ const nextActionUrl = globalState.get("nextActionUrl");
+
+ expect(
+ nextActionUrl,
+ "nextActionUrl should be defined before handling wallet redirection"
+ ).to.be.a("string");
+
+ cy.handleWalletRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ it("sync-payment-status-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["PaypalRedirect"];
+
+ cy.retrievePaymentCallTest({
+ globalState,
+ data,
+ expectedIntentStatus: "requires_customer_action",
+ });
+ });
+ });
+
+ context("Skrill Wallet Redirect flow", () => {
+ 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,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("payment_methods-call-test", () => {
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ it("confirm-skrill-redirect-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["Skrill"];
+
+ cy.confirmBankRedirectCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("handle-wallet-redirection-call-test", () => {
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ const nextActionUrl = globalState.get("nextActionUrl");
+
+ expect(
+ nextActionUrl,
+ "nextActionUrl should be defined before handling wallet redirection"
+ ).to.be.a("string");
+
+ cy.handleWalletRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ it("sync-payment-status-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["Skrill"];
+
+ cy.wait(5000);
+ cy.retrievePaymentCallTest({
+ globalState,
+ data,
+ expectedIntentStatus: "succeeded",
+ });
+ });
+ });
+
+ context("Klarna PayLater Auto Capture flow", () => {
+ let shouldContinue = true;
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["AutoCapture"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("payment_methods-call-test", () => {
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ it("confirm-klarna-redirect-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["Klarna"];
+
+ cy.confirmBankRedirectCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("handle-paylater-redirection-call-test", () => {
+ const expected_redirection =
+ globalState.get("baseUrl") + "/payments/completion";
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handlePayLaterRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ it("sync-payment-status-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["Klarna"];
+
+ cy.retrievePaymentCallTest({
+ globalState,
+ data,
+ expectedIntentStatus: "requires_customer_action",
+ });
+ });
+ });
+
+ context("Atome PayLater Auto Capture flow", () => {
+ let shouldContinue = true;
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["AtomeAutoCapture"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("payment_methods-call-test", () => {
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ it("confirm-atome-redirect-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["Atome"];
+
+ cy.confirmBankRedirectCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("handle-paylater-redirection-call-test", () => {
+ const expected_redirection =
+ globalState.get("baseUrl") + "/payments/completion";
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handlePayLaterRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ it("sync-payment-status-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["Atome"];
+
+ cy.retrievePaymentCallTest({
+ globalState,
+ data,
+ expectedIntentStatus: "requires_customer_action",
+ });
+ });
+ });
+});
diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.js
index 071797c895..ad71f68af9 100644
--- a/cypress-tests/cypress/support/redirectionHandler.js
+++ b/cypress-tests/cypress/support/redirectionHandler.js
@@ -399,51 +399,74 @@ function payLaterRedirection(
break;
case "airwallex":
- // Airwallex Klarna PayLater - follows similar pattern to other Klarna flows
cy.log(`Handling Airwallex ${paymentMethodType} pay_later flow`);
// Wait for the page to load
cy.get("body", { timeout: constants.TIMEOUT }).should("exist");
- // Airwallex Klarna redirects to standard Klarna playground
- // Verify we landed on a Klarna page
- cy.get("body", { timeout: constants.TIMEOUT }).then(($body) => {
- const bodyText = $body.text();
- const klarnaIndicators = [
- /klarna/i,
- /playground/i,
- /buy now.*pay later/i,
- /continue.*klarna/i,
- /smoooth/i,
- ];
-
- const hasKlarnaIndicator = klarnaIndicators.some((pattern) =>
- pattern.test(bodyText)
- );
-
- if (hasKlarnaIndicator) {
- cy.log(
- "Successfully navigated to Klarna page - verified redirection"
- );
- } else {
- // Check URL as fallback
- cy.url().then((url) => {
+ if (paymentMethodType === "atome") {
+ // Atome redirects to sandbox-gateway.apaylater.net
+ cy.url().then((url) => {
+ try {
+ const urlObj = new URL(url);
+ const hostname = urlObj.hostname;
if (
- url.includes("klarna") ||
- url.includes("playground") ||
- url.includes("airwallex")
+ hostname === "apaylater.net" ||
+ hostname.endsWith(".apaylater.net")
) {
cy.log(
- "URL indicates Klarna redirect - verified navigation"
+ "Successfully navigated to Atome page - verified redirection"
);
} else {
cy.log(
- `Warning: URL (${url}) does not contain expected Klarna indicators`
+ `Warning: URL (${url}) does not contain expected Atome indicators`
);
}
- });
- }
- });
+ } catch {
+ cy.log(`Warning: Could not parse URL: ${url}`);
+ }
+ });
+ } else {
+ // Airwallex Klarna redirects to standard Klarna playground
+ // Verify we landed on a Klarna page
+ cy.get("body", { timeout: constants.TIMEOUT }).then(($body) => {
+ const bodyText = $body.text();
+ const klarnaIndicators = [
+ /klarna/i,
+ /playground/i,
+ /buy now.*pay later/i,
+ /continue.*klarna/i,
+ /smoooth/i,
+ ];
+
+ const hasKlarnaIndicator = klarnaIndicators.some((pattern) =>
+ pattern.test(bodyText)
+ );
+
+ if (hasKlarnaIndicator) {
+ cy.log(
+ "Successfully navigated to Klarna page - verified redirection"
+ );
+ } else {
+ // Check URL as fallback
+ cy.url().then((url) => {
+ if (
+ url.includes("klarna") ||
+ url.includes("playground") ||
+ url.includes("airwallex")
+ ) {
+ cy.log(
+ "URL indicates Klarna redirect - verified navigation"
+ );
+ } else {
+ cy.log(
+ `Warning: URL (${url}) does not contain expected Klarna indicators`
+ );
+ }
+ });
+ }
+ });
+ }
verifyUrl = false; // Don't complete payment, just verify navigation
break;
@@ -1238,6 +1261,25 @@ function bankRedirectRedirection(
}
break;
+ case "airwallex":
+ if (paymentMethodType === "paypal") {
+ cy.log("Handling Airwallex PayPal wallet redirect");
+ cy.get("body", { timeout: constants.TIMEOUT }).should("exist");
+ verifyUrl = false;
+ } else if (paymentMethodType === "skrill") {
+ cy.log("Handling Airwallex Skrill wallet redirect");
+ cy.get("body", { timeout: constants.TIMEOUT }).should("exist");
+ cy.get("button#approve", { timeout: constants.TIMEOUT })
+ .should("be.visible")
+ .click();
+ verifyUrl = true;
+ } else {
+ throw new Error(
+ `Unsupported Airwallex payment method type: ${paymentMethodType}`
+ );
+ }
+ break;
+
case "paypal":
if (["eps", "ideal", "giropay"].includes(paymentMethodType)) {
cy.get('button[name="Successful"][value="SUCCEEDED"]').click();