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

ci(cypress): added assertions for payment_account_reference and auth_code (#13947)

Vasanth019df7128a35
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Checkout.js b/cypress-tests/cypress/e2e/configs/Payment/Checkout.js
index 735faa661b..e31a43a2e2 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Checkout.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Checkout.js
@@ -40,6 +40,22 @@ const partialAuthCardDetails = {
card_cvc: "152",
};
+const parPositiveCardDetails = {
+ card_number: "4242424242424242",
+ card_exp_month: "01",
+ card_exp_year: "50",
+ card_holder_name: "joseph Doe",
+ card_cvc: "123",
+};
+
+const parNegativeCardDetails = {
+ card_number: "378282246310005",
+ card_exp_month: "12",
+ card_exp_year: "30",
+ card_holder_name: "joseph Doe",
+ card_cvc: "1000",
+};
+
const singleUseMandateData = {
customer_acceptance: customerAcceptance,
mandate_type: {
@@ -236,6 +252,57 @@ export const connectorDetails = {
},
},
},
+ PARPositiveNo3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: parPositiveCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ payment_account_reference: "dynamic_par",
+ },
+ },
+ },
+ PARNegativeNo3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: parNegativeCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ payment_account_reference: null,
+ },
+ },
+ },
+ AuthCodeNo3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ payment_method_data: {},
+ },
+ },
+ },
Capture: {
Request: {
amount_to_capture: 6000,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Stripe.js b/cypress-tests/cypress/e2e/configs/Payment/Stripe.js
index cd5e788b87..1387ce5e62 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Stripe.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Stripe.js
@@ -37,6 +37,22 @@ const failedNo3DSCardDetails = {
card_cvc: "123",
};
+const parPositiveCardDetails = {
+ card_number: "4242424242424242",
+ card_exp_month: "10",
+ card_exp_year: "50",
+ card_holder_name: "morino",
+ card_cvc: "737",
+};
+
+const parNegativeCardDetails = {
+ card_number: "378282246310005",
+ card_exp_month: "10",
+ card_exp_year: "50",
+ card_holder_name: "morino",
+ card_cvc: "737",
+};
+
const singleUseMandateData = {
customer_acceptance: customerAcceptance,
mandate_type: {
@@ -390,6 +406,42 @@ export const connectorDetails = {
},
},
},
+ PARPositiveNo3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: parPositiveCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ payment_account_reference: "dynamic_par",
+ },
+ },
+ },
+ PARNegativeNo3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: parNegativeCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ payment_account_reference: null,
+ },
+ },
+ },
L2L3Data: {
// Stripe L2/L3 data: Level 2 (tax/shipping) and Level 3 (line items) for payment processing
// Amount must equal sum of order_details excluding shipping_cost
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index e16e5025b0..d92bd8d5fc 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -829,6 +829,8 @@ export const CONNECTOR_LISTS = {
CLIENT_SESSION_VALIDATION: ["stripe"],
WEBHOOK_CONFIG: ["stripe"],
REQUIRES_CVV: ["bankofamerica"],
+ PAYMENT_ACCOUNT_REFERENCE: ["stripe", "checkout"],
+ AUTH_CODE: ["checkout", "worldpayxml"],
ZERO_AUTH_MANDATE: ["peachpayments"],
BLOCK_IMPLICIT_CUSTOMER_CREATION: ["adyen"],
// Add more inclusion lists
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Worldpayxml.js b/cypress-tests/cypress/e2e/configs/Payment/Worldpayxml.js
index d871b93d39..bfae74af9a 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Worldpayxml.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Worldpayxml.js
@@ -150,6 +150,26 @@ export const connectorDetails = {
},
},
},
+ AuthCodeNo3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ payment_method_type: "debit",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ payment_method_data: {},
+ },
+ },
+ },
Capture: {
Request: {
amount_to_capture: 6000,
diff --git a/cypress-tests/cypress/e2e/spec/Payment/16-PaymentAccountReference.cy.js b/cypress-tests/cypress/e2e/spec/Payment/16-PaymentAccountReference.cy.js
new file mode 100644
index 0000000000..da4bd1b767
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/16-PaymentAccountReference.cy.js
@@ -0,0 +1,246 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, {
+ CONNECTOR_LISTS,
+ shouldIncludeConnector,
+ should_continue_further,
+} from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Card - Payment Account Reference and auth_code validation", () => {
+ before("seed global state", function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+
+ if (
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.PAYMENT_ACCOUNT_REFERENCE
+ ) &&
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.AUTH_CODE
+ )
+ ) {
+ skip = true;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ this.skip();
+ }
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("PAR positive - card returning payment_account_reference", () => {
+ before(function () {
+ if (
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.PAYMENT_ACCOUNT_REFERENCE
+ )
+ ) {
+ this.skip();
+ }
+ });
+
+ it("Create Payment Intent -> Confirm Payment -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Confirm Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PARPositiveNo3DSAutoCapture"];
+
+ cy.confirmCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+
+ if (!should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PARPositiveNo3DSAutoCapture"];
+
+ cy.retrievePaymentCallTest({ globalState, data: confirmData });
+ });
+ });
+ });
+
+ context("PAR negative - card without payment_account_reference", () => {
+ before(function () {
+ if (
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.PAYMENT_ACCOUNT_REFERENCE
+ )
+ ) {
+ this.skip();
+ }
+ });
+
+ it("Create Payment Intent -> Confirm Payment -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Confirm Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PARNegativeNo3DSAutoCapture"];
+
+ cy.confirmCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+
+ if (!should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PARNegativeNo3DSAutoCapture"];
+
+ cy.retrievePaymentCallTest({ globalState, data: confirmData });
+ });
+ });
+ });
+
+ context("auth_code - card returning auth_code", () => {
+ before(function () {
+ if (
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.AUTH_CODE
+ )
+ ) {
+ this.skip();
+ }
+ });
+
+ it("Create Payment Intent -> Confirm Payment -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Confirm Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["AuthCodeNo3DSAutoCapture"];
+
+ cy.confirmCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+
+ if (!should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["AuthCodeNo3DSAutoCapture"];
+
+ cy.retrievePaymentCallTest({ globalState, data: confirmData });
+ });
+ });
+ });
+});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index c1f48f5b9c..c09a7b440e 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -107,6 +107,12 @@ function supportsSplitPayments(globalState) {
);
}
+function shouldAssertAuthCode(globalState) {
+ return CONNECTOR_LISTS.INCLUDE.AUTH_CODE.includes(
+ globalState.get("connectorId")
+ );
+}
+
function updateConnectorState(globalState, responseConnector) {
if (isAliasedConnector(globalState)) {
const originalConnectorId = getOriginalConnectorId(globalState);
@@ -3496,7 +3502,7 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
@@ -3535,13 +3541,20 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
response.body[key]?.card?.auth_code,
"payment_method_data.card.auth_code"
).to.be.a("string").and.not.be.empty;
+ } else if (key === "payment_account_reference") {
+ if (resData.body[key] === null) {
+ expect(response.body[key], [key]).to.be.null;
+ } else {
+ expect(response.body[key], [key]).to.be.a("string").and.not
+ .be.empty;
+ }
} else {
expect(resData.body[key], [key]).to.deep.equal(
response.body[key]
@@ -3604,7 +3617,7 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
@@ -3632,13 +3645,20 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
response.body[key]?.card?.auth_code,
"payment_method_data.card.auth_code"
).to.be.a("string").and.not.be.empty;
+ } else if (key === "payment_account_reference") {
+ if (resData.body[key] === null) {
+ expect(response.body[key], [key]).to.be.null;
+ } else {
+ expect(response.body[key], [key]).to.be.a("string").and.not
+ .be.empty;
+ }
} else {
expect(resData.body[key], [key]).to.deep.equal(
response.body[key]
@@ -4368,7 +4388,7 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
@@ -4385,13 +4405,20 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
response.body[key]?.card?.auth_code,
"payment_method_data.card.auth_code"
).to.be.a("string").and.not.be.empty;
+ } else if (key === "payment_account_reference") {
+ if (resData.body[key] === null) {
+ expect(response.body[key], [key]).to.be.null;
+ } else {
+ expect(response.body[key], [key]).to.be.a("string").and.not
+ .be.empty;
+ }
} else {
expect(resData.body[key], [key]).to.deep.equal(
response.body[key]
@@ -4435,7 +4462,7 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
@@ -4452,13 +4479,20 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
response.body[key]?.card?.auth_code,
"payment_method_data.card.auth_code"
).to.be.a("string").and.not.be.empty;
+ } else if (key === "payment_account_reference") {
+ if (resData.body[key] === null) {
+ expect(response.body[key], [key]).to.be.null;
+ } else {
+ expect(response.body[key], [key]).to.be.a("string").and.not
+ .be.empty;
+ }
} else {
expect(resData.body[key], [key]).to.deep.equal(
response.body[key]
@@ -4584,7 +4618,7 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
@@ -4644,7 +4678,7 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
@@ -4724,13 +4758,20 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
response.body[key]?.card?.auth_code,
"payment_method_data.card.auth_code"
).to.be.a("string").and.not.be.empty;
+ } else if (key === "payment_account_reference") {
+ if (resData.body[key] === null) {
+ expect(response.body[key], [key]).to.be.null;
+ } else {
+ expect(response.body[key], [key]).to.be.a("string").and.not.be
+ .empty;
+ }
} else {
expect(resData.body[key], [key]).to.equal(response.body[key]);
}
@@ -4857,7 +4898,7 @@ Cypress.Commands.add(
connectedMerchantId,
unconfirmedPayment = false,
}) => {
- const { Configs: configs = {} } = data || {};
+ const { Configs: configs = {}, Response: resData = {} } = data || {};
const configInfo = execConfig(validateConfig(configs));
const payment_id = globalState.get("paymentID");
@@ -4899,6 +4940,41 @@ Cypress.Commands.add(
}
expect(response.body.customer, "customer").to.not.be.empty;
+ if (
+ resData.body &&
+ Object.prototype.hasOwnProperty.call(
+ resData.body,
+ "payment_account_reference"
+ )
+ ) {
+ if (resData.body.payment_account_reference === null) {
+ expect(
+ response.body.payment_account_reference,
+ "payment_account_reference"
+ ).to.be.null;
+ } else {
+ expect(
+ response.body.payment_account_reference,
+ "payment_account_reference"
+ ).to.be.a("string").and.to.not.be.empty;
+ }
+ }
+
+ if (
+ resData.body &&
+ Object.prototype.hasOwnProperty.call(
+ resData.body,
+ "payment_method_data"
+ ) &&
+ shouldAssertAuthCode(globalState)
+ ) {
+ expect(response.body.payment_method_data, "payment_method_data").to
+ .not.be.empty;
+ // auth_code is populated only in the authorize/confirm response from
+ // the connector response; it is not returned in subsequent
+ // retrieve (GET /payments) responses, so skip asserting it here.
+ }
+
if (expectedIntentStatus) {
expect(
response.body.status,
@@ -5431,7 +5507,7 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(
@@ -5522,7 +5598,7 @@ Cypress.Commands.add(
for (const key in resData.body) {
if (
key === "payment_method_data" &&
- globalState.get("connectorId") === "checkout"
+ shouldAssertAuthCode(globalState)
) {
expect(response.body[key], [key]).to.not.be.empty;
expect(