diff --git a/cypress-tests/cypress/e2e/PaymentTest/00021-CoreFlows.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00021-CoreFlows.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00000-AccountCreate.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00001-AccountCreate.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00000-AccountCreate.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00001-AccountCreate.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00001-CustomerCreate.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00002-CustomerCreate.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00001-CustomerCreate.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00002-CustomerCreate.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00002-ConnectorCreate.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00003-ConnectorCreate.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00002-ConnectorCreate.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00003-ConnectorCreate.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00003-NoThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00004-NoThreeDSAutoCapture.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00003-NoThreeDSAutoCapture.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00004-NoThreeDSAutoCapture.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00004-ThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00005-ThreeDSAutoCapture.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00004-ThreeDSAutoCapture.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00005-ThreeDSAutoCapture.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00005-NoThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00006-NoThreeDSManualCapture.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00005-NoThreeDSManualCapture.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00006-NoThreeDSManualCapture.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00007-VoidPayment.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00007-VoidPayment.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00007-SyncPayment.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00008-SyncPayment.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00007-SyncPayment.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00008-SyncPayment.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00008-RefundPayment.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00009-RefundPayment.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00008-RefundPayment.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00009-RefundPayment.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00009-SyncRefund.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00010-SyncRefund.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00009-SyncRefund.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00010-SyncRefund.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00010-CreateSingleuseMandate.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00011-CreateSingleuseMandate.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00010-CreateSingleuseMandate.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00011-CreateSingleuseMandate.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00011-CreateMultiuseMandate.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00012-CreateMultiuseMandate.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00011-CreateMultiuseMandate.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00012-CreateMultiuseMandate.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00012-ListAndRevokeMandate.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00013-ListAndRevokeMandate.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00012-ListAndRevokeMandate.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00013-ListAndRevokeMandate.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00014-SaveCardFlow.cy.js similarity index 67% rename from cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00014-SaveCardFlow.cy.js index 6e9289d4d0b..6cbba95fb2d 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00014-SaveCardFlow.cy.js @@ -488,4 +488,235 @@ describe("Card - SaveCard payment flow test", () => { }); } ); + + context( + "Save card for NoThreeDS automatic capture payment - create and confirm [off_session]", + () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + saveCardBody = Cypress._.cloneDeep(fixtures.saveCardConfirmBody); + if (!should_continue) { + this.skip(); + } + }); + + it("customer-create-call-test", () => { + cy.createCustomerCallTest(fixtures.customerCreateBody, globalState); + }); + + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentIntentOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("confirm-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["SaveCardUseNo3DSAutoCaptureOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest( + fixtures.confirmBody, + req_data, + res_data, + true, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); + }); + + it("retrieve-customerPM-call-test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentIntentOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("confirm-save-card-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["SaveCardConfirmAutoCaptureOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + + cy.saveCardConfirmCallTest( + saveCardBody, + req_data, + res_data, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + } + ); + context("Save card payment using existing customer[off_session]", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + saveCardBody = Cypress._.cloneDeep(fixtures.saveCardConfirmBody); + if (!should_continue) { + this.skip(); + } + }); + + it("retrieve-customerPM-call-test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "PaymentIntentOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("confirm-save-card-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "SaveCardConfirmAutoCaptureOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + + cy.saveCardConfirmCallTest(saveCardBody, req_data, res_data, globalState); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + }); + context( + "Use billing address from payment method during subsequent payment[off_session]", + () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + saveCardBody = Cypress._.cloneDeep(fixtures.saveCardConfirmBody); + if (!should_continue) { + this.skip(); + } + }); + + it("customer-create-call-test", () => { + cy.createCustomerCallTest(fixtures.customerCreateBody, globalState); + }); + + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentIntentOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("confirm-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["SaveCardUseNo3DSAutoCaptureOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest( + fixtures.confirmBody, + req_data, + res_data, + true, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("retrieve-customerPM-call-test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentIntentOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("confirm-save-card-payment-call-test-without-billing", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["SaveCardConfirmAutoCaptureOffSessionWithoutBilling"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + + cy.saveCardConfirmCallTest( + saveCardBody, + req_data, + res_data, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + } + ); }); diff --git a/cypress-tests/cypress/e2e/PaymentTest/00014-ZeroAuthMandate.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00015-ZeroAuthMandate.cy.js similarity index 53% rename from cypress-tests/cypress/e2e/PaymentTest/00014-ZeroAuthMandate.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00015-ZeroAuthMandate.cy.js index a6e085658c6..b9083142727 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00014-ZeroAuthMandate.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00015-ZeroAuthMandate.cy.js @@ -108,4 +108,92 @@ describe("Card - SingleUse Mandates flow test", () => { }); } ); + + context("Card - Zero Auth Payment", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if (!should_continue) { + this.skip(); + } + }); + + it("Create No 3DS Payment Intent", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "ZeroAuthPaymentIntent" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("Confirm No 3DS payment", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "ZeroAuthConfirmPayment" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest( + fixtures.confirmBody, + req_data, + res_data, + true, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("Retrieve Payment Call Test", () => { + cy.retrievePaymentCallTest(globalState); + }); + + it("Retrieve CustomerPM Call Test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("Create Recurring Payment Intent", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "PaymentIntentOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("Confirm Recurring Payment", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "SaveCardConfirmAutoCaptureOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + + cy.saveCardConfirmCallTest( + fixtures.saveCardConfirmBody, + req_data, + res_data, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + }); }); diff --git a/cypress-tests/cypress/e2e/PaymentTest/00015-ThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00016-ThreeDSManualCapture.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00015-ThreeDSManualCapture.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00016-ThreeDSManualCapture.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00016-BankTransfers.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00017-BankTransfers.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00016-BankTransfers.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00017-BankTransfers.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00018-BankRedirect.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00018-BankRedirect.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00018-MandatesUsingPMID.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00019-MandatesUsingPMID.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00018-MandatesUsingPMID.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00019-MandatesUsingPMID.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00019-UPI.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00020-UPI.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00019-UPI.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00020-UPI.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00020-Variations.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00021-Variations.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00020-Variations.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00021-Variations.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00022-PaymentMethods.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00022-PaymentMethods.cy.js new file mode 100644 index 00000000000..67004198104 --- /dev/null +++ b/cypress-tests/cypress/e2e/PaymentTest/00022-PaymentMethods.cy.js @@ -0,0 +1,128 @@ +import * as fixtures from "../../fixtures/imports"; +import State from "../../utils/State"; +import getConnectorDetails, * as utils from "../PaymentUtils/Utils"; + +let globalState; + +describe("Payment Methods Tests", () => { + let should_continue = true; + + before("seed global state", () => { + cy.task("getGlobalState").then((state) => { + globalState = new State(state); + }); + }); + + after("flush global state", () => { + cy.task("setGlobalState", globalState.data); + }); + + context("Create payment method for customer", () => { + let should_continue = true; + + beforeEach(function () { + if (!should_continue) { + this.skip(); + } + }); + + it("Create customer", () => { + cy.createCustomerCallTest(fixtures.customerCreateBody, globalState); + }); + + it("Create Payment Method", () => { + cy.createPaymentMethodTest(fixtures.createPaymentMethodBody, globalState); + + it("List PM for customer", () => { + cy.listCustomerPMCallTest(globalState); + }); + }); + }); + + context("Set default payment method", () => { + let should_continue = true; + + beforeEach(function () { + if (!should_continue) { + this.skip(); + } + }); + + it("List PM for customer", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("Create Payment Method", () => { + cy.createPaymentMethodTest(fixtures.createPaymentMethodBody, globalState); + }); + + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "PaymentIntentOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("confirm-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "SaveCardUseNo3DSAutoCaptureOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest( + fixtures.confirmBody, + req_data, + res_data, + true, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("List PM for customer", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("Set default payment method", () => { + cy.setDefaultPaymentMethodTest(globalState); + }); + }); + + context("Delete payment method for customer", () => { + let should_continue = true; + + beforeEach(function () { + if (!should_continue) { + this.skip(); + } + }); + + it("Create customer", () => { + cy.createCustomerCallTest(fixtures.customerCreateBody, globalState); + }); + + it("Create Payment Method", () => { + cy.createPaymentMethodTest(fixtures.createPaymentMethodBody, globalState); + }); + + it("List PM for customer", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("Delete Payment Method for a customer", () => { + cy.deletePaymentMethodTest(globalState); + }); + }); +}); diff --git a/cypress-tests/cypress/e2e/PaymentTest/00023-ConnectorAgnostic.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00023-ConnectorAgnostic.cy.js new file mode 100644 index 00000000000..64abe296b29 --- /dev/null +++ b/cypress-tests/cypress/e2e/PaymentTest/00023-ConnectorAgnostic.cy.js @@ -0,0 +1,250 @@ +import * as fixtures from "../../fixtures/imports"; +import State from "../../utils/State"; +import { payment_methods_enabled } from "../PaymentUtils/Commons"; +import getConnectorDetails, * as utils from "../PaymentUtils/Utils"; +let globalState; +describe("Connector Agnostic Tests", () => { + before("seed global state", () => { + cy.task("getGlobalState").then((state) => { + globalState = new State(state); + }); + }); + + after("flush global state", () => { + cy.task("setGlobalState", globalState.data); + }); + context( + "Connector Agnostic Disabled for Profile 1 and Enabled for Profile 2", + () => { + let should_continue = true; + + beforeEach(function () { + if (!should_continue) { + this.skip(); + } + }); + + it("Create Business Profile", () => { + cy.createBusinessProfileTest( + fixtures.createBusinessProfile, + globalState + ); + }); + + it("connector-create-call-test", () => { + cy.createConnectorCallTest( + "payment_processor", + fixtures.createConnectorBody, + payment_methods_enabled, + globalState + ); + }); + + it("Create Customer", () => { + cy.createCustomerCallTest(fixtures.customerCreateBody, globalState); + }); + + it("Create Payment Intent", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentIntentOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("Confirm Payment", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["SaveCardUseNo3DSAutoCaptureOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest( + fixtures.confirmBody, + req_data, + res_data, + true, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("List Payment Method for Customer using Client Secret", () => { + cy.listCustomerPMByClientSecret(globalState); + }); + + it("Create Business Profile", () => { + cy.createBusinessProfileTest( + fixtures.createBusinessProfile, + globalState + ); + }); + + it("connector-create-call-test", () => { + cy.createConnectorCallTest( + "payment_processor", + fixtures.createConnectorBody, + payment_methods_enabled, + globalState + ); + }); + + it("Enable Connector Agnostic for Business Profile", () => { + cy.UpdateBusinessProfileTest( + fixtures.updateBusinessProfile, + true, + globalState + ); + }); + + it("Create Payment Intent", () => { + let data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentIntentOffSession"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("List Payment Method for Customer", () => { + cy.listCustomerPMByClientSecret(globalState); + }); + } + ); + + context("Connector Agnostic Enabled for Profile 1 and Profile 2", () => { + let should_continue = true; + + beforeEach(function () { + if (!should_continue) { + this.skip(); + } + }); + + it("Create Business Profile", () => { + cy.createBusinessProfileTest(fixtures.createBusinessProfile, globalState); + }); + + it("connector-create-call-test", () => { + cy.createConnectorCallTest( + "payment_processor", + fixtures.createConnectorBody, + payment_methods_enabled, + globalState + ); + }); + + it("Create Customer", () => { + cy.createCustomerCallTest(fixtures.customerCreateBody, globalState); + }); + + it("Enable Connector Agnostic for Business Profile", () => { + cy.UpdateBusinessProfileTest( + fixtures.updateBusinessProfile, + true, + globalState + ); + }); + + it("Create Payment Intent", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "PaymentIntentOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("Confirm Payment", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "SaveCardUseNo3DSAutoCaptureOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest( + fixtures.confirmBody, + req_data, + res_data, + true, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("List Payment Method for Customer using Client Secret", () => { + cy.listCustomerPMByClientSecret(globalState); + }); + + it("Create Business Profile", () => { + cy.createBusinessProfileTest(fixtures.createBusinessProfile, globalState); + }); + + it("connector-create-call-test", () => { + cy.createConnectorCallTest( + "payment_processor", + fixtures.createConnectorBody, + payment_methods_enabled, + globalState + ); + }); + + it("Enable Connector Agnostic for Business Profile", () => { + cy.UpdateBusinessProfileTest( + fixtures.updateBusinessProfile, + true, + globalState + ); + }); + + it("Create Payment Intent", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "PaymentIntentOffSession" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "automatic", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + + it("List Payment Method for Customer", () => { + cy.listCustomerPMByClientSecret(globalState); + }); + }); +}); diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js index e39838d03a8..d0ffefca453 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js @@ -67,6 +67,8 @@ export const connectorDetails = { }, PaymentIntentOffSession: { Request: { + amount: 6500, + authentication_type: "no_three_ds", currency: "USD", customer_acceptance: null, setup_future_usage: "off_session", @@ -91,7 +93,7 @@ export const connectorDetails = { Response: { status: 200, body: { - status: "processing", + status: "requires_customer_action", }, }, }, @@ -364,6 +366,36 @@ export const connectorDetails = { }, }, }, + ZeroAuthPaymentIntent: { + Request: { + amount: 0, + setup_future_usage: "off_session", + currency: "USD", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + setup_future_usage: "off_session", + }, + }, + }, + ZeroAuthConfirmPayment: { + Request: { + payment_type: "setup_mandate", + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + setup_future_usage: "off_session", + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", @@ -391,6 +423,7 @@ export const connectorDetails = { SaveCardUseNo3DSAutoCaptureOffSession: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, diff --git a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js index 17acf01e881..671dae42877 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js @@ -66,6 +66,8 @@ export const connectorDetails = { PaymentIntentOffSession: { Request: { currency: "USD", + amount: 6500, + authentication_type: "no_three_ds", customer_acceptance: null, setup_future_usage: "off_session", }, @@ -376,6 +378,36 @@ export const connectorDetails = { }, }, }, + ZeroAuthPaymentIntent: { + Request: { + amount: 0, + setup_future_usage: "off_session", + currency: "USD", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + setup_future_usage: "off_session", + }, + }, + }, + ZeroAuthConfirmPayment: { + Request: { + payment_type: "setup_mandate", + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + setup_future_usage: "off_session", + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", @@ -403,6 +435,7 @@ export const connectorDetails = { SaveCardUseNo3DSAutoCaptureOffSession: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js b/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js index 74548be9d41..70e1ead1b62 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js @@ -43,7 +43,7 @@ export const connectorDetails = { status: 200, trigger_skip: true, body: { - status: "requires_capture", + status: "requires_customer_action", }, }, }, @@ -199,6 +199,39 @@ export const connectorDetails = { }, }, }, + ZeroAuthPaymentIntent: { + Request: { + amount: 0, + setup_future_usage: "off_session", + currency: "USD", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + setup_future_usage: "off_session", + }, + }, + }, + ZeroAuthConfirmPayment: { + Request: { + payment_type: "setup_mandate", + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 501, + body: { + error: { + type: "invalid_request", + message: "Setup Mandate flow for Bluesnap is not implemented", + code: "IR_00", + }, + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js index 73e54fee916..d45ea48cf73 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js @@ -796,6 +796,23 @@ export const connectorDetails = { mandate_data: singleUseMandateData, }, }), + ZeroAuthPaymentIntent: getCustomExchange({ + Request: { + amount: 0, + setup_future_usage: "off_session", + currency: "USD", + payment_type: "setup_mandate", + }, + }), + ZeroAuthConfirmPayment: getCustomExchange({ + Request: { + payment_type: "setup_mandate", + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + }), SaveCardUseNo3DSAutoCapture: getCustomExchange({ Request: { payment_method: "card", @@ -858,6 +875,19 @@ export const connectorDetails = { setup_future_usage: "off_session", }, }), + SaveCardConfirmAutoCaptureOffSessionWithoutBilling: { + Request: { + setup_future_usage: "off_session", + billing: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + billing: null, + }, + }, + }, SaveCardUseNo3DSManualCapture: getCustomExchange({ Request: { payment_method: "card", diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js index d71f11b4e6e..ad5d3bc343c 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js @@ -48,6 +48,48 @@ const multiUseMandateData = { }, }; +const payment_method_data_no3ds = { + card: { + last4: "4242", + card_type: "CREDIT", + card_network: "Visa", + card_issuer: "STRIPE PAYMENTS UK LIMITED", + card_issuing_country: "UNITEDKINGDOM", + card_isin: "424242", + card_extended_bin: null, + card_exp_month: "01", + card_exp_year: "25", + card_holder_name: null, + payment_checks: { + avs_response: { + code: "Y", + codeRaw: "Y", + }, + card_verification: null, + }, + authentication_data: null, + }, + billing: null, +}; + +const payment_method_data_3ds = { + card: { + last4: "1091", + card_type: "CREDIT", + card_network: "Visa", + card_issuer: "INTL HDQTRS-CENTER OWNED", + card_issuing_country: "UNITEDSTATES", + card_isin: "400000", + card_extended_bin: null, + card_exp_month: "01", + card_exp_year: "25", + card_holder_name: null, + payment_checks: null, + authentication_data: null, + }, + billing: null, +}; + export const connectorDetails = { card_pm: { PaymentIntent: { @@ -60,12 +102,15 @@ export const connectorDetails = { status: 200, body: { status: "requires_payment_method", + setup_future_usage: "on_session", }, }, }, PaymentIntentOffSession: { Request: { currency: "USD", + amount: 6500, + authentication_type: "no_three_ds", customer_acceptance: null, setup_future_usage: "off_session", }, @@ -73,6 +118,7 @@ export const connectorDetails = { status: 200, body: { status: "requires_payment_method", + setup_future_usage: "off_session", }, }, }, @@ -89,7 +135,9 @@ export const connectorDetails = { Response: { status: 200, body: { - status: "requires_capture", + status: "requires_customer_action", + setup_future_usage: "on_session", + payment_method_data: payment_method_data_3ds, }, }, }, @@ -107,6 +155,8 @@ export const connectorDetails = { status: 200, body: { status: "requires_customer_action", + setup_future_usage: "on_session", + payment_method_data: payment_method_data_3ds, }, }, }, @@ -124,6 +174,9 @@ export const connectorDetails = { status: 200, body: { status: "requires_capture", + payment_method: "card", + attempt_count: 1, + payment_method_data: payment_method_data_no3ds, }, }, }, @@ -141,6 +194,9 @@ export const connectorDetails = { status: 200, body: { status: "succeeded", + payment_method: "card", + attempt_count: 1, + payment_method_data: payment_method_data_no3ds, }, }, }, @@ -376,9 +432,40 @@ export const connectorDetails = { }, }, }, + ZeroAuthPaymentIntent: { + Request: { + amount: 0, + setup_future_usage: "off_session", + currency: "USD", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + setup_future_usage: "off_session", + }, + }, + }, + ZeroAuthConfirmPayment: { + Request: { + payment_type: "setup_mandate", + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + setup_future_usage: "off_session", + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, @@ -403,6 +490,7 @@ export const connectorDetails = { SaveCardUseNo3DSAutoCaptureOffSession: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, @@ -426,6 +514,7 @@ export const connectorDetails = { SaveCardUseNo3DSManualCaptureOffSession: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js b/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js index 30a9e3eb9b2..3b6ea26d9b2 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js @@ -200,6 +200,39 @@ export const connectorDetails = { }, }, }, + ZeroAuthPaymentIntent: { + Request: { + amount: 0, + setup_future_usage: "off_session", + currency: "USD", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + setup_future_usage: "off_session", + }, + }, + }, + ZeroAuthConfirmPayment: { + Request: { + payment_type: "setup_mandate", + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 501, + body: { + error: { + type: "invalid_request", + message: "Setup Mandate flow for Nmi is not implemented", + code: "IR_00", + }, + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js b/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js index 1c64393dda2..a40997452ba 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js @@ -45,7 +45,7 @@ export const connectorDetails = { status: 200, trigger_skip: true, body: { - status: "requires_capture", + status: "requires_customer_action", }, }, }, @@ -201,6 +201,39 @@ export const connectorDetails = { }, }, }, + ZeroAuthPaymentIntent: { + Request: { + amount: 0, + setup_future_usage: "off_session", + currency: "USD", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + setup_future_usage: "off_session", + }, + }, + }, + ZeroAuthConfirmPayment: { + Request: { + payment_type: "setup_mandate", + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 501, + body: { + error: { + type: "invalid_request", + message: "Setup Mandate flow for Paypal is not implemented", + code: "IR_00", + }, + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js index 3b44f0e4e1e..bd35f5831dc 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js @@ -110,6 +110,8 @@ export const connectorDetails = { Request: { currency: "USD", customer_acceptance: null, + amount: 6500, + authentication_type: "no_three_ds", setup_future_usage: "off_session", }, Response: { @@ -431,6 +433,36 @@ export const connectorDetails = { }, }, }, + ZeroAuthPaymentIntent: { + Request: { + amount: 0, + setup_future_usage: "off_session", + currency: "USD", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + setup_future_usage: "off_session", + }, + }, + }, + ZeroAuthConfirmPayment: { + Request: { + payment_type: "setup_mandate", + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + setup_future_usage: "off_session", + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", @@ -506,6 +538,7 @@ export const connectorDetails = { SaveCardUseNo3DSAutoCaptureOffSession: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, @@ -575,6 +608,19 @@ export const connectorDetails = { }, }, }, + SaveCardConfirmAutoCaptureOffSessionWithoutBilling: { + Request: { + setup_future_usage: "off_session", + billing: null, + }, + Response: { + status: 200, + body: { + status: "failed", + error_message: "You cannot confirm with `off_session=true` when `setup_future_usage` is also set on the PaymentIntent. The customer needs to be on-session to perform the steps which may be required to set up the PaymentMethod for future usage. Please confirm this PaymentIntent with your customer on-session.", + }, + }, + }, PaymentMethodIdMandateNo3DSManualCapture: { Request: { payment_method: "card", diff --git a/cypress-tests/cypress/fixtures/create-business-profile.json b/cypress-tests/cypress/fixtures/create-business-profile.json new file mode 100644 index 00000000000..cdce8636157 --- /dev/null +++ b/cypress-tests/cypress/fixtures/create-business-profile.json @@ -0,0 +1,3 @@ +{ + "profile_name": "default" +} \ No newline at end of file diff --git a/cypress-tests/cypress/fixtures/create-connector-body.json b/cypress-tests/cypress/fixtures/create-connector-body.json index 5e0ce73aedc..23a28ded158 100644 --- a/cypress-tests/cypress/fixtures/create-connector-body.json +++ b/cypress-tests/cypress/fixtures/create-connector-body.json @@ -1,7 +1,6 @@ { "connector_name": "stripe", - "business_country": "US", - "business_label": "default", + "profile_id": "{{profile_id}}", "connector_account_details": { "auth_type": "BodyKey", "api_key": "api-key", diff --git a/cypress-tests/cypress/fixtures/create-payment-body.json b/cypress-tests/cypress/fixtures/create-payment-body.json index c9982e4d755..ea1d22d364e 100644 --- a/cypress-tests/cypress/fixtures/create-payment-body.json +++ b/cypress-tests/cypress/fixtures/create-payment-body.json @@ -5,6 +5,7 @@ "description": "Joseph First Crypto", "email": "hyperswitch_sdk_demo_id@gmail.com", "setup_future_usage": null, + "profile_id": "{{profile_id}}", "connector_metadata": { "noon": { "order_category": "applepay" diff --git a/cypress-tests/cypress/fixtures/create-payment-method-body.json b/cypress-tests/cypress/fixtures/create-payment-method-body.json new file mode 100644 index 00000000000..fd6f69ccc37 --- /dev/null +++ b/cypress-tests/cypress/fixtures/create-payment-method-body.json @@ -0,0 +1,35 @@ +{ + "payment_method": "card", + "payment_method_type": "credit", + "payment_method_issuer": "Gpay", + "payment_method_issuer_code": "jp_hdfc", + "card": { + "card_number": "4111111145551142", + "card_exp_month": "03", + "card_exp_year": "30", + "card_holder_name": "Likhin" + }, + "customer_id": "{{customer_id}}", + "billing": { + "address": { + "line1": "1467", + "line2": "Harrison Street", + "line3": "Harrison Street", + "city": "San Fransico", + "state": "California", + "zip": "94122", + "country": "US", + "first_name": "joseph", + "last_name": "Doe" + }, + "phone": { + "number": "9123345678", + "country_code": "+91" + }, + "email": "p143@example.com" + }, + "metadata": { + "city": "NY", + "unit": "245" + } +} diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.js index d5cc66b7d29..5ffc69c2fc6 100644 --- a/cypress-tests/cypress/fixtures/imports.js +++ b/cypress-tests/cypress/fixtures/imports.js @@ -2,12 +2,14 @@ import captureBody from "./capture-flow-body.json"; import configs from "./configs.json"; import confirmBody from "./confirm-body.json"; import apiKeyCreateBody from "./create-api-key-body.json"; +import createBusinessProfile from "./create-business-profile.json"; import createConfirmPaymentBody from "./create-confirm-body.json"; import createConnectorBody from "./create-connector-body.json"; import customerCreateBody from "./create-customer-body.json"; import citConfirmBody from "./create-mandate-cit.json"; import mitConfirmBody from "./create-mandate-mit.json"; import createPaymentBody from "./create-payment-body.json"; +import createPaymentMethodBody from "./create-payment-method-body.json"; import createPayoutBody from "./create-payout-confirm-body.json"; import pmIdConfirmBody from "./create-pm-id-mit.json"; import gsmBody from "./gsm-body.json"; @@ -17,7 +19,9 @@ import merchantUpdateBody from "./merchant-update-body.json"; import refundBody from "./refund-flow-body.json"; import routingConfigBody from "./routing-config-body.json"; import saveCardConfirmBody from "./save-card-confirm-body.json"; +import sessionTokenBody from "./session-token.json"; import apiKeyUpdateBody from "./update-api-key-body.json"; +import updateBusinessProfile from "./update-business-profile.json"; import updateConnectorBody from "./update-connector-body.json"; import customerUpdateBody from "./update-customer-body.json"; import voidBody from "./void-payment-body.json"; @@ -29,9 +33,11 @@ export { citConfirmBody, configs, confirmBody, + createBusinessProfile, createConfirmPaymentBody, createConnectorBody, createPaymentBody, + createPaymentMethodBody, createPayoutBody, customerCreateBody, customerUpdateBody, @@ -44,6 +50,8 @@ export { refundBody, routingConfigBody, saveCardConfirmBody, + sessionTokenBody, + updateBusinessProfile, updateConnectorBody, voidBody, }; diff --git a/cypress-tests/cypress/fixtures/session-token.json b/cypress-tests/cypress/fixtures/session-token.json new file mode 100644 index 00000000000..84d5be3ff75 --- /dev/null +++ b/cypress-tests/cypress/fixtures/session-token.json @@ -0,0 +1,5 @@ +{ + "payment_id": "{{payment_id}}", + "client_secret": "{{client_secret}}", + "wallets": [] +} diff --git a/cypress-tests/cypress/fixtures/update-business-profile.json b/cypress-tests/cypress/fixtures/update-business-profile.json new file mode 100644 index 00000000000..9d69534bae6 --- /dev/null +++ b/cypress-tests/cypress/fixtures/update-business-profile.json @@ -0,0 +1,3 @@ +{ + "is_connector_agnostic_mit_enabled": true +} diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index a6436e7f67c..fcab4a3ef32 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -57,6 +57,7 @@ Cypress.Commands.add( logRequestId(response.headers["x-request-id"]); // Handle the response as needed + globalState.set("profileId", response.body.default_profile); globalState.set("publishableKey", response.body.publishable_key); globalState.set("merchantDetails", response.body.merchant_details); }); @@ -163,6 +164,59 @@ Cypress.Commands.add( } ); +Cypress.Commands.add( + "createBusinessProfileTest", + (createBusinessProfile, globalState) => { + const merchant_id = globalState.get("merchantId"); + const randomProfileName = `profile_${Math.random().toString(36).substring(7)}`; + createBusinessProfile.profile_name = randomProfileName; + cy.request({ + method: "POST", + url: `${globalState.get("baseUrl")}/account/${merchant_id}/business_profile`, + headers: { + Accept: "application/json", + "Content-Type": "application/json", + "api-key": globalState.get("adminApiKey"), + }, + body: createBusinessProfile, + failOnStatusCode: false, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + globalState.set("profileId", response.body.profile_id); + if (response.status === 200) { + expect(response.body.profile_id).to.not.to.be.null; + } else { + throw new Error( + `Business Profile call failed ${response.body.error.message}` + ); + } + }); + } +); + +Cypress.Commands.add( + "UpdateBusinessProfileTest", + (updateBusinessProfile, is_connector_agnostic_mit_enabled, globalState) => { + updateBusinessProfile.is_connector_agnostic_mit_enabled = + is_connector_agnostic_mit_enabled; + const merchant_id = globalState.get("merchantId"); + const profile_id = globalState.get("profileId"); + cy.request({ + method: "POST", + url: `${globalState.get("baseUrl")}/account/${merchant_id}/business_profile/${profile_id}`, + headers: { + Accept: "application/json", + "Content-Type": "application/json", + "api-key": globalState.get("adminApiKey"), + }, + body: updateBusinessProfile, + failOnStatusCode: false, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + }); + } +); + Cypress.Commands.add("apiKeyCreateTest", (apiKeyCreateBody, globalState) => { cy.request({ method: "POST", @@ -353,6 +407,7 @@ Cypress.Commands.add( ) => { const merchantId = globalState.get("merchantId"); createConnectorBody.connector_type = connectorType; + createConnectorBody.profile_id = globalState.get("profileId"); createConnectorBody.connector_name = globalState.get("connectorId"); createConnectorBody.payment_methods_enabled = payment_methods_enabled; // readFile is used to read the contents of the file and it always returns a promise ([Object Object]) due to its asynchronous nature @@ -390,6 +445,7 @@ Cypress.Commands.add( expect(globalState.get("connectorId")).to.equal( response.body.connector_name ); + globalState.set("profileId", response.body.profile_id); globalState.set( "merchantConnectorId", response.body.merchant_connector_id @@ -588,9 +644,22 @@ Cypress.Commands.add( }, body: customerCreateBody, }).then((response) => { - logRequestId(response.headers["x-request-id"]); - expect(response.body.customer_id).to.not.be.empty; globalState.set("customerId", response.body.customer_id); + logRequestId(response.headers["x-request-id"]); + expect(response.body.customer_id, "customer_id").to.not.be.empty; + expect(customerCreateBody.email, "email").to.equal(response.body.email); + expect(customerCreateBody.name, "name").to.equal(response.body.name); + expect(customerCreateBody.phone, "phone").to.equal(response.body.phone); + expect(customerCreateBody.metadata, "metadata").to.deep.equal( + response.body.metadata + ); + expect(customerCreateBody.address, "address").to.deep.equal( + response.body.address + ); + expect( + customerCreateBody.phone_country_code, + "phone_country_code" + ).to.equal(response.body.phone_country_code); }); } ); @@ -772,6 +841,22 @@ Cypress.Commands.add( } ); +Cypress.Commands.add("sessionTokenCall", (apiKeyCreateBody, globalState) => { + cy.request({ + method: "POST", + url: `${globalState.get("baseUrl")}/payments/session_tokens`, + headers: { + Accept: "application/json", + "Content-Type": "application/json", + "api-key": globalState.get("publishableKey"), + }, + body: sessionTokenBody, + failOnStatusCode: false, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + }); +}); + Cypress.Commands.add( "createPaymentIntentTest", ( @@ -796,9 +881,9 @@ Cypress.Commands.add( createPaymentBody[key] = req_data[key]; } createPaymentBody.authentication_type = authentication_type; - createPaymentBody.capture_method = capture_method; createPaymentBody.customer_id = globalState.get("customerId"); + createPaymentBody.profile_id = globalState.get("profileId"); globalState.set("paymentAmount", createPaymentBody.amount); cy.request({ method: "POST", @@ -827,6 +912,8 @@ Cypress.Commands.add( `Expected ${res_data.body[key]} but got ${response.body[key]}` ); } + expect(response.body.payment_id, "payment_id").to.not.be.null; + expect(response.body.merchant_id, "merchant_id").to.not.be.null; expect(createPaymentBody.amount, "amount").to.equal( response.body.amount ); @@ -883,6 +970,16 @@ Cypress.Commands.add( ).to.be.null; expect(response.body.connector_mandate_id, "connector_mandate_id").to.be .null; + let recurringEnabled = 0; + if ( + response.body.setup_future_usage === "on_session" || + response.body.setup_future_usage === "off_session" + ) { + recurringEnabled = 1; + } + + // Store the value in globalState + globalState.set("recurring_enabled", recurringEnabled); } else { defaultErrorHandler(response, res_data); } @@ -914,33 +1011,101 @@ Cypress.Commands.add("paymentMethodsCallTest", (globalState) => { Cypress.Commands.add( "createPaymentMethodTest", - (globalState, req_data, res_data) => { - req_data.customer_id = globalState.get("customerId"); - + (createPaymentMethodBody, globalState) => { + createPaymentMethodBody.customer_id = globalState.get("customerId"); + createPaymentMethodBody.client_secret = globalState.get("clientSecret"); cy.request({ method: "POST", url: `${globalState.get("baseUrl")}/payment_methods`, - body: req_data, headers: { "Content-Type": "application/json", Accept: "application/json", "api-key": globalState.get("apiKey"), }, + body: createPaymentMethodBody, }).then((response) => { logRequestId(response.headers["x-request-id"]); expect(response.headers["content-type"]).to.include("application/json"); if (response.status === 200) { - expect(response.body).to.have.property("payment_method_id"); - expect(response.body).to.have.property("client_secret"); + expect(response.body.client_secret, "client_secret").to.equal( + response.body.client_secret + ); + expect(response.body.payment_method_id, "payment_method_id").to.equal( + response.body.payment_method_id + ); + expect(response.body.merchant_id, "merchant_id").to.equal( + response.body.merchant_id + ); + expect(response.body.payment_method, "payment_method").to.equal( + response.body.payment_method + ); + expect( + response.body.payment_method_type, + "payment_method_type" + ).to.equal(response.body.payment_method_type); + expect(response.body.last_used_at, "last_used_at").to.equal( + response.body.last_used_at + ); + expect(response.body.customer_id, "customer_id").to.equal( + response.body.customer_id + ); globalState.set("paymentMethodId", response.body.payment_method_id); } else { - defaultErrorHandler(response, res_data); + defaultErrorHandler(response); } }); } ); +Cypress.Commands.add("deletePaymentMethodTest", (globalState) => { + const payment_method_id = globalState.get("paymentMethodId"); + cy.request({ + method: "DELETE", + url: `${globalState.get("baseUrl")}/payment_methods/${payment_method_id}`, + headers: { + Accept: "application/json", + "api-key": globalState.get("apiKey"), + }, + failOnStatusCode: false, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + expect(response.headers["content-type"]).to.include("application/json"); + + if (response.status === 200) { + expect(response.body.payment_method_id).to.equal(payment_method_id); + expect(response.body.deleted).to.be.true; + } else { + defaultErrorHandler(response); + } + }); +}); + +Cypress.Commands.add("setDefaultPaymentMethodTest", (globalState) => { + const payment_method_id = globalState.get("paymentMethodId"); + const customer_id = globalState.get("customerId"); + cy.request({ + method: "POST", + url: `${globalState.get("baseUrl")}/customers/${customer_id}/payment_methods/${payment_method_id}/default`, + headers: { + "api-key": globalState.get("apiKey"), + }, + failOnStatusCode: false, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + expect(response.headers["content-type"]).to.include("application/json"); + if (response.status === 200) { + expect(response.body).to.have.property( + "default_payment_method_id", + payment_method_id + ); + expect(response.body).to.have.property("customer_id", customer_id); + } else { + defaultErrorHandler(response); + } + }); +}); + Cypress.Commands.add( "confirmCallTest", (confirmBody, req_data, res_data, confirm, globalState) => { @@ -963,26 +1128,37 @@ Cypress.Commands.add( logRequestId(response.headers["x-request-id"]); expect(response.headers["content-type"]).to.include("application/json"); if (response.status === 200) { + const recurringEnabledFromConfirm = + globalState.get("recurring_enabled"); + if ( + req_data.customer_acceptance === "object" && + req_data.customer_acceptance !== null + ) { + recurringEnabledFromConfirm += 1; + } + globalState.set("recurring_enabled", recurringEnabledFromConfirm); + globalState.set("paymentID", paymentIntentID); globalState.set("connectorId", response.body.connector); expect(response.body.connector, "connector").to.equal( globalState.get("connectorId") ); - expect(response.body.payment_id, "payment_id").to.equal( - paymentIntentID + expect(paymentIntentID, "payment_id").to.equal( + response.body.payment_id ); expect(response.body.payment_method_data, "payment_method_data").to.not .be.empty; - expect(response.body.merchant_connector_id, "connector_id").to.equal( - globalState.get("merchantConnectorId") + expect(globalState.get("merchantConnectorId"), "connector_id").to.equal( + response.body.merchant_connector_id ); expect(response.body.customer, "customer").to.not.be.empty; expect(response.body.billing, "billing_address").to.not.be.empty; expect(response.body.profile_id, "profile_id").to.not.be.null; - expect( - response.body.connector_transaction_id, - "connector_transaction_id" - ).to.not.be.null; + // expect( + // response.body.connector_transaction_id, + // "connector_transaction_id" + // ).to.not.be.null; + if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { expect(response.body) @@ -1279,6 +1455,7 @@ Cypress.Commands.add( createConfirmPaymentBody.authentication_type = authentication_type; createConfirmPaymentBody.capture_method = capture_method; createConfirmPaymentBody.customer_id = globalState.get("customerId"); + createConfirmPaymentBody.profile_id = globalState.get("profileId"); for (const key in req_data) { createConfirmPaymentBody[key] = req_data[key]; } @@ -1293,6 +1470,7 @@ Cypress.Commands.add( body: createConfirmPaymentBody, }).then((response) => { logRequestId(response.headers["x-request-id"]); + globalState.set("clientSecret", response.body.client_secret); expect(response.headers["content-type"]).to.include("application/json"); if (response.status === 200) { globalState.set("paymentAmount", createConfirmPaymentBody.amount); @@ -1311,10 +1489,10 @@ Cypress.Commands.add( expect(response.body.customer, "customer").to.not.be.empty; expect(response.body.billing, "billing_address").to.not.be.empty; expect(response.body.profile_id, "profile_id").to.not.be.null; - expect( - response.body.connector_transaction_id, - "connector_transaction_id" - ).to.not.be.null; + // expect( + // response.body.connector_transaction_id, + // "connector_transaction_id" + // ).to.not.be.null; expect(response.body).to.have.property("status"); if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { @@ -1384,6 +1562,9 @@ Cypress.Commands.add( } saveCardConfirmBody.payment_token = globalState.get("paymentToken"); saveCardConfirmBody.client_secret = globalState.get("clientSecret"); + for (const key in req_data) { + saveCardConfirmBody[key] = req_data[key]; + } cy.request({ method: "POST", url: `${globalState.get("baseUrl")}/payments/${paymentIntentID}/confirm`, @@ -1399,6 +1580,40 @@ Cypress.Commands.add( expect(response.headers["content-type"]).to.include("application/json"); if (response.status === 200) { globalState.set("paymentID", paymentIntentID); + const recurringEnabledFromConfirm = + globalState.get("recurring_enabled"); + if ( + req_data.customer_acceptance === "object" && + req_data.customer_acceptance !== null + ) { + recurringEnabledFromConfirm += 1; + } + globalState.set("recurring_enabled", recurringEnabledFromConfirm); + + globalState.set("paymentID", paymentIntentID); + globalState.set("connectorId", response.body.connector); + expect(response.body.connector, "connector").to.equal( + globalState.get("connectorId") + ); + expect(paymentIntentID, "payment_id").to.equal( + response.body.payment_id + ); + expect(response.body.payment_method_data, "payment_method_data").to.not + .be.empty; + expect(globalState.get("merchantConnectorId"), "connector_id").to.equal( + response.body.merchant_connector_id + ); + expect(response.body.customer, "customer").to.not.be.empty; + if (req_data.billing !== null) { + expect(response.body.billing, "billing_address").to.not.be.empty; + } + expect(response.body.profile_id, "profile_id").to.not.be.null; + expect(response.body.payment_token, "payment_token").to.not.be.null; + // expect( + // response.body.connector_transaction_id, + // "connector_transaction_id" + // ).to.not.be.null; + if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { expect(response.body) @@ -1543,10 +1758,10 @@ Cypress.Commands.add( expect(response.body.merchant_connector_id, "connector_id").to.equal( globalState.get("merchantConnectorId") ); - expect( - response.body.connector_transaction_id, - "connector_transaction_id" - ).to.not.be.null; + // expect( + // response.body.connector_transaction_id, + // "connector_transaction_id" + // ).to.not.be.null; } if (autoretries) { @@ -1671,6 +1886,19 @@ Cypress.Commands.add( if (response.status === 200) { globalState.set("paymentID", response.body.payment_id); + expect(response.body.payment_method_data, "payment_method_data").to.not + .be.empty; + expect(response.body.connector, "connector").to.equal( + globalState.get("connectorId") + ); + expect(globalState.get("merchantConnectorId"), "connector_id").to.equal( + response.body.merchant_connector_id + ); + expect(response.body.customer, "customer").to.not.be.empty; + expect(response.body.profile_id, "profile_id").to.not.be.null; + expect(response.body.payment_method_id, "payment_method_id").to.not.be + .null; + if (requestBody.mandate_data === null) { expect(response.body).to.have.property("payment_method_id"); globalState.set("paymentMethodId", response.body.payment_method_id); @@ -1680,7 +1908,6 @@ Cypress.Commands.add( } if (response.body.capture_method === "automatic") { - expect(response.body).to.have.property("mandate_id"); if (response.body.authentication_type === "three_ds") { expect(response.body) .to.have.property("next_action") @@ -1761,6 +1988,22 @@ Cypress.Commands.add( expect(response.headers["content-type"]).to.include("application/json"); if (response.status === 200) { globalState.set("paymentID", response.body.payment_id); + expect(response.body.payment_method_data, "payment_method_data").to.not + .be.empty; + expect(response.body.connector, "connector").to.equal( + globalState.get("connectorId") + ); + expect(globalState.get("merchantConnectorId"), "connector_id").to.equal( + response.body.merchant_connector_id + ); + expect(response.body.customer, "customer").to.not.be.empty; + expect(response.body.profile_id, "profile_id").to.not.be.null; + expect(response.body.payment_method_id, "payment_method_id").to.not.be + .null; + // expect( + // response.body.connector_transaction_id, + // "connector_transaction_id" + // ).to.not.be.null; if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { expect(response.body) @@ -2006,7 +2249,88 @@ Cypress.Commands.add("listCustomerPMCallTest", (globalState) => { if (response.body.customer_payment_methods[0]?.payment_token) { const paymentToken = response.body.customer_payment_methods[0].payment_token; + const paymentMethodId = + response.body.customer_payment_methods[0].payment_method_id; globalState.set("paymentToken", paymentToken); // Set paymentToken in globalState + globalState.set("paymentMethodId", paymentMethodId); // Set paymentMethodId in globalState + } else { + // We only get an empty array if something's wrong. One exception is a 4xx when no customer exist but it is handled in the test + expect(response.body) + .to.have.property("customer_payment_methods") + .to.be.an("array").and.empty; + } + expect(response.body.customer_payment_methods[0].card, "card").to.be.an( + "object" + ); + expect(response.body.customer_payment_methods[0].card, "card").to.not.be + .empty; + expect(globalState.get("customerId"), "customer_id").to.equal( + response.body.customer_payment_methods[0].customer_id + ); + expect( + response.body.customer_payment_methods[0].payment_token, + "payment_token" + ).to.not.be.null; + expect( + response.body.customer_payment_methods[0].payment_method_id, + "payment_method_id" + ).to.not.be.null; + expect( + response.body.customer_payment_methods[0].payment_method, + "payment_method" + ).to.not.be.null; + expect( + response.body.customer_payment_methods[0].payment_method_type, + "payment_method_type" + ).to.not.be.null; + expect(response.body.customer_payment_methods[0].billing, "billing").to.not + .be.null; + const finalRecurringEnabledValue = globalState.get("recurring_enabled"); + if (finalRecurringEnabledValue === 2) { + expect( + response.body.customer_payment_methods[0].recurring_enabled, + "recurring_enabled" + ).to.be.true; + expect( + response.body.customer_payment_methods[0].requires_cvv, + "requires_cvv" + ).to.be.false; + } else { + expect( + response.body.customer_payment_methods[0].recurring_enabled, + "recurring_enabled" + ).to.be.false; + expect( + response.body.customer_payment_methods[0].requires_cvv, + "requires_cvv" + ).to.be.true; + } + }); +}); + +Cypress.Commands.add("listCustomerPMByClientSecret", (globalState) => { + const clientSecret = globalState.get("clientSecret"); + cy.request({ + method: "GET", + url: `${globalState.get("baseUrl")}/customers/payment_methods?client_secret=${clientSecret}`, + headers: { + "Content-Type": "application/json", + "api-key": globalState.get("publishableKey"), + }, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + expect(response.headers["content-type"]).to.include("application/json"); + if (response.body.customer_payment_methods[0]?.payment_token) { + const paymentToken = + response.body.customer_payment_methods[0].payment_token; + const paymentMethodId = + response.body.customer_payment_methods[0].payment_method_id; + globalState.set("paymentToken", paymentToken); + globalState.set("paymentMethodId", paymentMethodId); + expect( + response.body.customer_payment_methods[0].payment_method_id, + "payment_method_id" + ).to.not.be.null; } else { // We only get an empty array if something's wrong. One exception is a 4xx when no customer exist but it is handled in the test expect(response.body) @@ -2446,51 +2770,55 @@ Cypress.Commands.add( } ); -Cypress.Commands.add("updateConfig", (configType, configData, globalState, value) => { - const base_url = globalState.get("baseUrl"); - const merchant_id = globalState.get("merchantId"); - const api_key = globalState.get("adminApiKey"); - - let key; - let url; - let body; - - switch (configType) { - case 'autoRetry': - key = `should_call_gsm_${merchant_id}`; - url = `${base_url}/configs/${key}`; - body = { key: key, value: value }; - break; - case 'maxRetries': - key = `max_auto_retries_enabled_${merchant_id}`; - url = `${base_url}/configs/${key}`; - body = { key: key, value: value }; - break; - case 'stepUp': - key = `step_up_enabled_${merchant_id}`; - url = `${base_url}/configs/${key}`; - body = { key: key, value: value }; - break; - default: - throw new Error(`Invalid config type passed into the configs: "${api_key}: ${value}"`); - } - - cy.request({ - method: 'POST', - url: url, - headers: { - "Content-Type": "application/json", - "api-key": api_key, - }, - body: body, - failOnStatusCode: false, - }).then((response) => { - logRequestId(response.headers["x-request-id"]); - - if (response.status === 200) { - expect(response.body).to.have.property("key").to.equal(key); - expect(response.body).to.have.property("value").to.equal(value); +Cypress.Commands.add( + "updateConfig", + (configType, configData, globalState, value) => { + const base_url = globalState.get("baseUrl"); + const merchant_id = globalState.get("merchantId"); + const api_key = globalState.get("adminApiKey"); + + let key; + let url; + let body; + + switch (configType) { + case "autoRetry": + key = `should_call_gsm_${merchant_id}`; + url = `${base_url}/configs/${key}`; + body = { key: key, value: value }; + break; + case "maxRetries": + key = `max_auto_retries_enabled_${merchant_id}`; + url = `${base_url}/configs/${key}`; + body = { key: key, value: value }; + break; + case "stepUp": + key = `step_up_enabled_${merchant_id}`; + url = `${base_url}/configs/${key}`; + body = { key: key, value: value }; + break; + default: + throw new Error( + `Invalid config type passed into the configs: "${api_key}: ${value}"` + ); } - }); -}); + cy.request({ + method: "POST", + url: url, + headers: { + "Content-Type": "application/json", + "api-key": api_key, + }, + body: body, + failOnStatusCode: false, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + + if (response.status === 200) { + expect(response.body).to.have.property("key").to.equal(key); + expect(response.body).to.have.property("value").to.equal(value); + } + }); + } +);