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 payjustnowinstore connector test cases (#13195)
HS-QUALIBOTcd6de272fbe8
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex 25bce311cb..3c85bd6ad2 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -1879,6 +1879,31 @@ export const connectorDetails = {},},}),+ Payjustnowinstore: 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/Payjustnowinstore.js b/cypress-tests/cypress/e2e/configs/Payment/Payjustnowinstore.jsnew file mode 100644index 0000000000..b50731cd69--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payment/Payjustnowinstore.js@@ -0,0 +1,116 @@+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",+ },+ },+ }),+ Payjustnowinstore: getCustomExchange({+ Configs: {+ skipPaymentMethodStatusAssertion: true,+ },+ 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({+ Configs: {+ TRIGGER_SKIP: true,+ },+ }),+ PartialRefund: getCustomExchange({+ Configs: {+ TRIGGER_SKIP: true,+ },+ }),+ SyncRefund: getCustomExchange({+ Configs: {+ TRIGGER_SKIP: true,+ },+ }),+ },+};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 5e98fdadd0..7686e070c5 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -58,6 +58,7 @@ 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 payjustnowinstoreConnectorDetails } from "./Payjustnowinstore.js";import { connectorDetails as payloadConnectorDetails } from "./Payload.js";import { connectorDetails as paypalConnectorDetails } from "./Paypal.js";import { connectorDetails as paysafeConnectorDetails } from "./Paysafe.js";@@ -140,6 +141,7 @@ const connectorDetails = {nuvei: nuveiConnectorDetails,paybox: payboxConnectorDetails,payjustnow: payjustnowConnectorDetails,+ payjustnowinstore: payjustnowinstoreConnectorDetails,payload: payloadConnectorDetails,paypal: paypalConnectorDetails,paysafe: paysafeConnectorDetails,@@ -689,10 +691,12 @@ export const CONNECTOR_LISTS = {"mollie","affirm","payjustnow",+ "payjustnowinstore",],AFFIRM: ["stripe"],ATOME: ["adyen"],PAYJUSTNOW: ["payjustnow"],+ PAYJUSTNOWINSTORE: ["payjustnowinstore"],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.jsindex 47c2f49d37..0b4d19899d 100644--- a/cypress-tests/cypress/e2e/spec/Payment/43-PayLater.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/43-PayLater.cy.js@@ -1136,4 +1136,327 @@ describe("PayLater tests", () => {});});});++ context("PayJustNow In-Store PayLater - Create and Confirm flow test", () => {+ before(+ "skip if connector does not support PayJustNow In-Store",+ function () {+ if (+ shouldIncludeConnector(+ globalState.get("connectorId"),+ CONNECTOR_LISTS.INCLUDE.PAYJUSTNOWINSTORE+ )+ ) {+ 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"]("Payjustnowinstore");+ 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"+ ]["Payjustnowinstore"];+ 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"+ ]["Payjustnowinstore"];+ cy.retrievePaymentCallTest({ globalState, data });+ });+ });+ });++ context("PayJustNow In-Store PayLater - Full Refund flow test", () => {+ before(+ "skip if connector does not support PayJustNow In-Store",+ function () {+ if (+ shouldIncludeConnector(+ globalState.get("connectorId"),+ CONNECTOR_LISTS.INCLUDE.PAYJUSTNOWINSTORE+ )+ ) {+ 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"]("Payjustnowinstore");+ 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"+ ]["Payjustnowinstore"];+ 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"+ ]["Payjustnowinstore"];+ 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 In-Store PayLater - Partial Refund flow test", () => {+ before(+ "skip if connector does not support PayJustNow In-Store",+ function () {+ if (+ shouldIncludeConnector(+ globalState.get("connectorId"),+ CONNECTOR_LISTS.INCLUDE.PAYJUSTNOWINSTORE+ )+ ) {+ 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"]("Payjustnowinstore");+ 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"+ ]["Payjustnowinstore"];+ 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"+ ]["Payjustnowinstore"];+ 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.jsindex bf3b52d666..8a560fe13b 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -4194,10 +4194,12 @@ Cypress.Commands.add(: "inactive";// Validate the status- expect(- response.body.payment_method_status,- "payment_method_status"- ).to.equal(expectedStatus);+ if (!configs.skipPaymentMethodStatusAssertion) {+ expect(+ response.body.payment_method_status,+ "payment_method_status"+ ).to.equal(expectedStatus);+ }}if (autoretries) {@@ -4390,10 +4392,16 @@ Cypress.Commands.add(Response: resData,} = data || {};+ const validatedConfigs = validateConfig(configs);+ if (validatedConfigs?.TRIGGER_SKIP) {+ cy.task("cli_log", "TRIGGER_SKIP enabled, skipping refundCallTest");+ return;+ }+const payment_id = globalState.get("paymentID");// we only need this to set the delay. We don't need the return value- execConfig(validateConfig(configs));+ execConfig(validatedConfigs);for (const key in reqData) {requestBody[key] = reqData[key];diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex 4552141855..d80fa4dcf9 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -1486,11 +1486,12 @@ function bankRedirectRedirection(verifyUrl = false;} else if (- connectorId === "payjustnow" &&+ (connectorId === "payjustnow" || connectorId === "payjustnowinstore") &&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).+ // PayJustNow (both online and in-store variants) 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@@ -2476,7 +2477,8 @@ function bankRedirectRedirection(}break;- // payjustnow is handled in its own else-if branch above (before handleFlow)+ // payjustnow and payjustnowinstore are handled in their own+ // else-if branch above (before handleFlow)// using two sequential cy.origin() calls, because cy.origin cannot be nested.default:diff --git a/cypress-tests/cypress/utils/featureFlags.js b/cypress-tests/cypress/utils/featureFlags.jsindex 0937e51374..41dd65a544 100644--- a/cypress-tests/cypress/utils/featureFlags.js+++ b/cypress-tests/cypress/utils/featureFlags.js@@ -4,6 +4,7 @@ const config_fields = ["DELAY","TRIGGER_SKIP","LOCAL_VAULT_REQUIRED",+ "skipPaymentMethodStatusAssertion",];const DEFAULT_CONNECTOR = "connector_1";@@ -82,6 +83,7 @@ function validateConfigValue(key, value) {case "TRIGGER_SKIP":case "LOCAL_VAULT_REQUIRED":case "DELAY.STATUS":+ case "skipPaymentMethodStatusAssertion":if (!validateType(value, "boolean")) return false;break;