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 PayJustNow PayLater coverage for payjustnow (#12243)

HS-QUALIBOT057bb054f2f2
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 54969c7e5a..db8a1f2da1 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -874,6 +874,23 @@ export const payment_methods_enabled = [
recurring_enabled: false,
installment_payment_enabled: false,
},
+ {
+ payment_method_type: "payjustnow",
+ payment_experience: "redirect_to_url",
+ card_networks: null,
+ accepted_currencies: {
+ type: "enable_only",
+ list: ["ZAR"],
+ },
+ accepted_countries: {
+ type: "enable_only",
+ list: ["ZA"],
+ },
+ minimum_amount: 100,
+ maximum_amount: 100000000,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
{
payment_method_type: "affirm",
payment_experience: "redirect_to_url",
@@ -1767,6 +1784,31 @@ export const connectorDetails = {
},
}),
SyncRefund: getCustomExchange({}),
+ Payjustnow: getCustomExchange({
+ Request: {
+ payment_method: "pay_later",
+ payment_method_type: "payjustnow",
+ payment_method_data: {
+ pay_later: {
+ payjustnow_redirect: {},
+ },
+ },
+ billing: {
+ email: "[email protected]",
+ address: {
+ line1: "123 Main Street",
+ line2: "",
+ line3: "",
+ city: "Johannesburg",
+ state: "Gauteng",
+ zip: "2001",
+ country: "ZA",
+ first_name: "Test",
+ last_name: "Customer",
+ },
+ },
+ },
+ }),
SyncRefundScheduled: getCustomExchange({}),
AfterpayClearpay: getCustomExchange({
Request: {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
index 847a1d4649..96edf27c60 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
@@ -198,6 +198,7 @@ const CURRENCY_MAP = {
OnlineBankingFpx: "MYR", // Malaysian payment methods
Interac: "CAD", // Canadian payment method
AliPayHk: "HKD", // Hong Kong payment method
+ Payjustnow: "ZAR", // South African BNPL
Affirm: "USD", // US BNPL payment method
AliPay: "CNY", // Default ISO-4217 currency; MultiSafepay sandbox overrides to EUR (see Multisafepay.js::wallet_pm.PaymentIntent)
WeChatPay: "CNY", // Default ISO-4217 currency; MultiSafepay sandbox overrides to EUR (see Multisafepay.js::wallet_pm.PaymentIntent)
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Payjustnow.js b/cypress-tests/cypress/e2e/configs/Payment/Payjustnow.js
new file mode 100644
index 0000000000..4a49694f85
--- /dev/null
+++ b/cypress-tests/cypress/e2e/configs/Payment/Payjustnow.js
@@ -0,0 +1,128 @@
+import { getCustomExchange } from "./Modifiers";
+
+export const connectorDetails = {
+ pay_later_pm: {
+ AutoCapture: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ }),
+ ManualCapture: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ }),
+ Klarna: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ }),
+ CaptureOnWrongStatus: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ }),
+ ConfirmWithoutPmData: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ }),
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ PaymentIntent: (_paymentMethodType) =>
+ getCustomExchange({
+ Request: {
+ currency: "ZAR",
+ amount: 10000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ Payjustnow: getCustomExchange({
+ Request: {
+ payment_method: "pay_later",
+ payment_method_type: "payjustnow",
+ return_url: "https://example.com/return",
+ payment_method_data: {
+ pay_later: {
+ payjustnow_redirect: {},
+ },
+ },
+ billing: {
+ email: "[email protected]",
+ address: {
+ line1: "123 Main Street",
+ line2: "",
+ line3: "",
+ city: "Johannesburg",
+ state: "Gauteng",
+ zip: "2001",
+ country: "ZA",
+ first_name: "Test",
+ last_name: "Customer",
+ },
+ },
+ shipping: {
+ email: "[email protected]",
+ address: {
+ line1: "123 Main Street",
+ line2: "",
+ line3: "",
+ city: "Johannesburg",
+ state: "Gauteng",
+ zip: "2001",
+ country: "ZA",
+ first_name: "Test",
+ last_name: "Customer",
+ },
+ },
+ order_details: [
+ {
+ product_name: "Test Product",
+ quantity: 1,
+ amount: 10000,
+ },
+ ],
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ }),
+ Refund: getCustomExchange({
+ Request: {
+ amount: 10000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ }),
+ PartialRefund: getCustomExchange({
+ Request: {
+ amount: 5000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ }),
+ SyncRefund: getCustomExchange({
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ }),
+ },
+};
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 7ab882636f..912be54e60 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -56,6 +56,7 @@ import { connectorDetails as noonConnectorDetails } from "./Noon.js";
import { connectorDetails as novalnetConnectorDetails } from "./Novalnet.js";
import { connectorDetails as nuveiConnectorDetails } from "./Nuvei.js";
import { connectorDetails as payboxConnectorDetails } from "./Paybox.js";
+import { connectorDetails as payjustnowConnectorDetails } from "./Payjustnow.js";
import { connectorDetails as payloadConnectorDetails } from "./Payload.js";
import { connectorDetails as paypalConnectorDetails } from "./Paypal.js";
import { connectorDetails as paysafeConnectorDetails } from "./Paysafe.js";
@@ -136,6 +137,7 @@ const connectorDetails = {
novalnet: novalnetConnectorDetails,
nuvei: nuveiConnectorDetails,
paybox: payboxConnectorDetails,
+ payjustnow: payjustnowConnectorDetails,
payload: payloadConnectorDetails,
paypal: paypalConnectorDetails,
paysafe: paysafeConnectorDetails,
@@ -629,9 +631,11 @@ export const CONNECTOR_LISTS = {
"airwallex",
"mollie",
"affirm",
+ "payjustnow",
],
AFFIRM: ["stripe"],
ATOME: ["adyen"],
+ PAYJUSTNOW: ["payjustnow"],
AUTH_SERVICE_ELIGIBILITY: ["stripe", "cybersource"],
STEP_UP_AUTH: ["cybersource"],
PARTIAL_AUTH: ["nuvei", "checkout", "worldpay", "worldpayvantiv"],
diff --git a/cypress-tests/cypress/e2e/spec/Payment/43-PayLater.cy.js b/cypress-tests/cypress/e2e/spec/Payment/43-PayLater.cy.js
index ccf2c1a5d2..47c2f49d37 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/43-PayLater.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/43-PayLater.cy.js
@@ -822,4 +822,318 @@ describe("PayLater tests", () => {
});
});
});
+
+ context("PayJustNow PayLater - Create and Confirm flow test", () => {
+ before("skip if connector does not support PayJustNow", function () {
+ if (
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.PAYJUSTNOW
+ )
+ ) {
+ this.skip();
+ }
+ });
+
+ it("Create Payment Intent -> List Merchant Payment Methods -> Confirm PayLater Payment -> Handle Bank Redirect Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["PaymentIntent"]("Payjustnow");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm PayLater Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm PayLater Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["Payjustnow"];
+ cy.confirmBankRedirectCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Bank Redirect Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Bank Redirect Redirection");
+ return;
+ }
+ const expected_redirection =
+ globalState.get("baseUrl") + "/payments/completion";
+ 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"))[
+ "pay_later_pm"
+ ]["Payjustnow"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("PayJustNow PayLater - Full Refund flow test", () => {
+ before("skip if connector does not support PayJustNow", function () {
+ if (
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.PAYJUSTNOW
+ )
+ ) {
+ this.skip();
+ }
+ });
+
+ it("Create Payment Intent -> List Merchant Payment Methods -> Confirm PayLater Payment -> Handle Bank Redirect Redirection -> Retrieve Payment -> Refund Payment -> Sync Refund", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["PaymentIntent"]("Payjustnow");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm PayLater Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm PayLater Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["Payjustnow"];
+ cy.confirmBankRedirectCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Bank Redirect Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Bank Redirect Redirection");
+ return;
+ }
+ const expected_redirection =
+ globalState.get("baseUrl") + "/payments/completion";
+ 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"))[
+ "pay_later_pm"
+ ]["Payjustnow"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Refund Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Refund Payment");
+ return;
+ }
+ const refundData = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["Refund"];
+ cy.refundCallTest(fixtures.refundBody, refundData, globalState);
+ if (!utils.should_continue_further(refundData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Sync Refund", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Sync Refund");
+ return;
+ }
+ const syncRefundData = getConnectorDetails(
+ globalState.get("connectorId")
+ )["pay_later_pm"]["SyncRefund"];
+ cy.syncRefundCallTest(syncRefundData, globalState);
+ });
+ });
+ });
+
+ context("PayJustNow PayLater - Partial Refund flow test", () => {
+ before("skip if connector does not support PayJustNow", function () {
+ if (
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.PAYJUSTNOW
+ )
+ ) {
+ this.skip();
+ }
+ });
+
+ it("Create Payment Intent -> List Merchant Payment Methods -> Confirm PayLater Payment -> Handle Bank Redirect Redirection -> Retrieve Payment -> Partial Refund Payment -> Sync Refund", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["PaymentIntent"]("Payjustnow");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm PayLater Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm PayLater Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "pay_later_pm"
+ ]["Payjustnow"];
+ cy.confirmBankRedirectCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Bank Redirect Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Bank Redirect Redirection");
+ return;
+ }
+ const expected_redirection =
+ globalState.get("baseUrl") + "/payments/completion";
+ 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"))[
+ "pay_later_pm"
+ ]["Payjustnow"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Partial Refund Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Partial Refund Payment");
+ return;
+ }
+ const partialRefundData = getConnectorDetails(
+ globalState.get("connectorId")
+ )["pay_later_pm"]["PartialRefund"];
+ cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
+ if (!utils.should_continue_further(partialRefundData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Sync Refund", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Sync Refund");
+ return;
+ }
+ const syncRefundData = getConnectorDetails(
+ globalState.get("connectorId")
+ )["pay_later_pm"]["SyncRefund"];
+ cy.syncRefundCallTest(syncRefundData, globalState);
+ });
+ });
+ });
});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 54954f0ea2..95bda3f24d 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -2358,6 +2358,15 @@ Cypress.Commands.add(
Response: resData,
} = data || {};
+ const validatedConfigs = validateConfig(configs);
+ if (validatedConfigs?.TRIGGER_SKIP) {
+ cy.task(
+ "cli_log",
+ "TRIGGER_SKIP enabled, skipping createPaymentIntentTest"
+ );
+ return;
+ }
+
if (
!createPaymentBody ||
typeof createPaymentBody !== "object" ||
@@ -2368,7 +2377,7 @@ Cypress.Commands.add(
);
}
- const configInfo = execConfig(validateConfig(configs));
+ const configInfo = execConfig(validatedConfigs);
const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);
const body = JSON.parse(JSON.stringify(createPaymentBody));
@@ -5195,12 +5204,17 @@ Cypress.Commands.add(
// explicitly restricting `sofort` payment method by adyen from running as it stops other tests from running
// trying to handle that specific case results in stripe 3ds tests to fail
if (!(connectorId == "adyen" && paymentMethodType == "sofort")) {
- handleRedirection(
- "bank_redirect",
- { redirectionUrl, expectedUrl },
- connectorId,
- paymentMethodType
- );
+ // Wrap in cy.then() so that commands enqueued by handleRedirection
+ // (especially cy.origin() calls for PayJustNow) are chained inline
+ // and complete before subsequent test steps (Retrieve Payment, Refund).
+ cy.then(() => {
+ handleRedirection(
+ "bank_redirect",
+ { redirectionUrl, expectedUrl },
+ connectorId,
+ paymentMethodType
+ );
+ });
}
}
);
diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.js
index 89deb1cf49..66c575bc2d 100644
--- a/cypress-tests/cypress/support/redirectionHandler.js
+++ b/cypress-tests/cypress/support/redirectionHandler.js
@@ -1484,6 +1484,231 @@ function bankRedirectRedirection(
}
);
+ verifyUrl = false;
+ } else if (
+ connectorId === "payjustnow" &&
+ paymentMethodType === "payjustnow"
+ ) {
+ // PayJustNow is handled outside handleFlow for the same reason as Adyen/Airwallex
+ // iDEAL: cy.origin cannot be nested (https://github.com/cypress-io/cypress/issues/20718).
+ // The flow crosses THREE origins sequentially:
+ // 1. sandbox-app.payjustnow.com — login → checkout → PIN
+ // 2. sandbox-app.payjustnow.com — optional /confirm-card OTP
+ // 3. test.oppwa.com — 3DS simulator challenge form
+ // We must leave each cy.origin before the page auto-navigates to the next
+ // origin, otherwise Cypress throws an origin-mismatch error.
+
+ // ------------------------------------------------------------------
+ // ORIGIN 1: sandbox-app.payjustnow.com — login, checkout, PIN
+ // ------------------------------------------------------------------
+ cy.origin(
+ "https://sandbox-app.payjustnow.com",
+ { args: { constants: CONSTANTS } },
+ ({ constants }) => {
+ cy.on("uncaught:exception", () => false);
+
+ // Wait for the Vue SPA to fully render
+ cy.document().should("have.property", "readyState", "complete");
+ cy.wait(3000);
+
+ // STEP 1: Login
+ cy.get("body", { timeout: constants.TIMEOUT }).then(($body) => {
+ const editableEmail = $body.find("#email:not([disabled])");
+ if (editableEmail.length > 0) {
+ cy.wrap(editableEmail.first())
+ .should("be.visible")
+ .click()
+ .clear()
+ .type("[email protected]", { delay: 50 });
+ }
+ });
+
+ cy.get('input[name="password"]', { timeout: constants.TIMEOUT })
+ .should("be.visible")
+ .click()
+ .clear()
+ .type("password", { delay: 50 });
+
+ cy.contains("button", "Log In", { timeout: constants.TIMEOUT })
+ .should("be.visible")
+ .click({ force: true });
+
+ // STEP 2: Checkout — Confirm and Pay
+ cy.location("pathname", { timeout: constants.TIMEOUT }).should(
+ "include",
+ "/checkout/"
+ );
+ cy.wait(2000);
+
+ // Some checkouts require the terms-and-conditions checkbox to be ticked
+ // before "Confirm and Pay" becomes actionable.
+ cy.get("body").then(($body) => {
+ const termsCheckbox = $body
+ .find('input[type="checkbox"]')
+ .filter((_, el) => {
+ const label = $body.find(`label[for="${el.id}"]`);
+ const parentText = Cypress.$(el).closest("label").text();
+ const labelText = label.text();
+ const combined = `${parentText} ${labelText}`;
+ return (
+ combined.includes("South African citizen") ||
+ combined.includes("confirm that I am") ||
+ combined.includes("Terms and Conditions")
+ );
+ });
+
+ if (termsCheckbox.length > 0 && !termsCheckbox.is(":checked")) {
+ cy.wrap(termsCheckbox).check();
+ }
+ });
+
+ cy.get("#checkout-bnpl-confirm-and-pay", {
+ timeout: constants.TIMEOUT,
+ })
+ .scrollIntoView()
+ .should("be.visible")
+ .click({ force: true });
+
+ // STEP 3: Confirm PIN (/confirm-pin/:token)
+ cy.location("pathname", { timeout: constants.TIMEOUT }).should(
+ "include",
+ "/confirm-pin/"
+ );
+ cy.wait(2000);
+
+ cy.get(".otp-wrapper input", { timeout: constants.TIMEOUT }).then(
+ ($pinInputs) => {
+ ["1", "1", "1", "1"].forEach((digit, idx) => {
+ cy.wrap($pinInputs.eq(idx))
+ .should("be.visible")
+ .click()
+ .type(digit, { delay: 100 });
+ });
+ }
+ );
+
+ cy.wait(1000);
+ cy.contains("button", "next", { timeout: constants.TIMEOUT })
+ .should("exist")
+ .click({ force: true });
+ // Give the page time to process the PIN and start redirecting
+ // before we leave this cy.origin block. The 3DS auto-submit on
+ // /3dsecure-acs fires after ~3.5s, so 2s is safe.
+ cy.wait(2000);
+ }
+ );
+
+ // ------------------------------------------------------------------
+ // OUTSIDE ORIGIN: decide whether an OTP (/confirm-card/) step exists.
+ // Reading the URL here is safe because we are not inside cy.origin.
+ // ------------------------------------------------------------------
+ cy.url({ timeout: CONSTANTS.TIMEOUT }).should((url) => {
+ expect(
+ url.includes("/confirm-card/") ||
+ url.includes("/3dsecure-acs") ||
+ new URL(url).hostname === "test.oppwa.com",
+ "post-PIN URL to be /confirm-card/, /3dsecure-acs, or test.oppwa.com"
+ ).to.be.true;
+ });
+
+ cy.url().then((url) => {
+ if (url.includes("/confirm-card/")) {
+ cy.log("PayJustNow: /confirm-card/ detected — entering OTP step");
+
+ // ORIGIN 2 (optional): sandbox-app.payjustnow.com — OTP
+ cy.origin(
+ "https://sandbox-app.payjustnow.com",
+ { args: { constants: CONSTANTS } },
+ ({ constants }) => {
+ cy.on("uncaught:exception", () => false);
+ cy.wait(2000);
+
+ cy.get(".otp-wrapper input", {
+ timeout: constants.TIMEOUT,
+ }).then(($otpInputs) => {
+ ["1", "1", "1", "1"].forEach((digit, idx) => {
+ cy.wrap($otpInputs.eq(idx))
+ .should("be.visible")
+ .click()
+ .type(digit, { delay: 100 });
+ });
+ });
+
+ cy.contains("button", "next", { timeout: constants.TIMEOUT })
+ .should("be.visible")
+ .click({ force: true });
+
+ cy.log("PayJustNow: submitted OTP 1111");
+ }
+ );
+ }
+ });
+
+ // ------------------------------------------------------------------
+ // Wait for the 3DS challenge page on test.oppwa.com.
+ // ------------------------------------------------------------------
+ cy.location("origin", { timeout: CONSTANTS.TIMEOUT }).should(
+ "eq",
+ "https://test.oppwa.com"
+ );
+
+ // ------------------------------------------------------------------
+ // ORIGIN 3: test.oppwa.com — submit the 3DS challenge form directly.
+ // ------------------------------------------------------------------
+ cy.origin(
+ "https://test.oppwa.com",
+ { args: { TIMEOUT: CONSTANTS.TIMEOUT } },
+ ({ TIMEOUT }) => {
+ cy.on("uncaught:exception", () => false);
+
+ // Wait for the challenge form with the required creq input
+ cy.get('form[method="post"]', { timeout: TIMEOUT })
+ .should("have.length.at.least", 1)
+ .first()
+ .within(() => {
+ cy.get('input[name="creq"]', { timeout: TIMEOUT }).should("exist");
+ });
+
+ // Click the submit button instead of .submit() to trigger JS handlers
+ cy.get('button[type="submit"]', { timeout: TIMEOUT })
+ .should("exist")
+ .click({ force: true });
+
+ // Give the form submission a moment to start. The response redirects
+ // to sandbox-app.payjustnow.com/3dsecure-transaction-status/ which
+ // then polls the connector and finally redirects back to Hyperswitch.
+ cy.wait(2000);
+ }
+ );
+
+ // ------------------------------------------------------------------
+ // Wait for the 3DS form submission to redirect away from test.oppwa.com.
+ // After submission we land on sandbox-app.payjustnow.com which shows an
+ // intermediate "Confirming your 3DSecure transaction" page while it
+ // polls the connector. Give that page time to finish instead of waiting
+ // for the final redirect back to Hyperswitch (which can take long or fail
+ // to fire in headless mode).
+ // ------------------------------------------------------------------
+ cy.location("origin", { timeout: CONSTANTS.TIMEOUT }).should(
+ "not.eq",
+ "https://test.oppwa.com"
+ );
+
+ cy.location("host").then((host) => {
+ if (host.includes("payjustnow")) {
+ cy.origin("https://sandbox-app.payjustnow.com", () => {
+ cy.on("uncaught:exception", () => false);
+
+ // The status page polls PayJustNow's backend to confirm 3DS.
+ // A 15s wait lets it resolve before we move on.
+ cy.wait(15000);
+ });
+ }
+ });
+
+ // Buffer for the final redirect back to Hyperswitch (if any).
+ cy.wait(5000);
+
verifyUrl = false;
} else {
handleFlow(
@@ -2251,6 +2476,9 @@ function bankRedirectRedirection(
}
break;
+ // payjustnow is handled in its own else-if branch above (before handleFlow)
+ // using two sequential cy.origin() calls, because cy.origin cannot be nested.
+
default:
throw new Error(
`Unsupported connector in handleFlow: ${connectorId}`
@@ -2260,6 +2488,7 @@ function bankRedirectRedirection(
{ paymentMethodType } // Pass options to handleFlow
);
}
+
cy.then(() => {
// The value of verifyUrl determined by the specific flow (Adyen iDEAL or handleFlow callback)
verifyReturnUrl(redirectionUrl, expectedUrl, verifyUrl);