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 65% rename from cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00007-VoidPayment.cy.js index c783f5e3d72..2b1295fd07c 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00007-VoidPayment.cy.js @@ -123,68 +123,65 @@ describe("Card - NoThreeDS Manual payment flow test", () => { } ); - context( - "Card - void payment in Requires_payment_method state flow test", - () => { - let should_continue = true; // variable that will be used to skip tests if a previous test fails + context("Card - void payment in success state flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails - beforeEach(function () { - if (!should_continue) { - this.skip(); - } - }); + beforeEach(function () { + if (!should_continue) { + this.skip(); + } + }); - it("create-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))[ - "card_pm" - ]["PaymentIntent"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.createPaymentIntentTest( - fixtures.createPaymentBody, - req_data, - res_data, - "no_three_ds", - "manual", - globalState - ); - if (should_continue) - should_continue = utils.should_continue_further(res_data); - }); + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "PaymentIntent" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + req_data, + res_data, + "no_three_ds", + "manual", + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); - it("payment_methods-call-test", () => { - cy.paymentMethodsCallTest(globalState); - }); + it("payment_methods-call-test", () => { + cy.paymentMethodsCallTest(globalState); + }); - it("confirm-call-test", () => { - console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))[ - "card_pm" - ]["No3DSManualCapture"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - console.log("det -> " + data.card); - cy.confirmCallTest( - fixtures.confirmBody, - req_data, - res_data, - false, - globalState - ); - if (should_continue) - should_continue = utils.should_continue_further(res_data); - }); + it("confirm-call-test", () => { + console.log("confirm -> " + globalState.get("connectorId")); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "No3DSManualCapture" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest( + fixtures.confirmBody, + req_data, + res_data, + false, + globalState + ); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); - it("void-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))[ - "card_pm" - ]["VoidAfterConfirm"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.voidCallTest(fixtures.voidBody, req_data, res_data, globalState); - if (should_continue) - should_continue = utils.should_continue_further(res_data); - }); - } - ); + it("void-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ + "VoidAfterConfirm" + ]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.voidCallTest(fixtures.voidBody, req_data, res_data, globalState); + if (should_continue) + should_continue = utils.should_continue_further(res_data); + }); + }); }); 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 99% rename from cypress-tests/cypress/e2e/PaymentTest/00008-RefundPayment.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00009-RefundPayment.cy.js index 70157e06ec6..9eb64c0acf2 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00008-RefundPayment.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00009-RefundPayment.cy.js @@ -421,7 +421,7 @@ describe("Card - Refund flow - No 3DS", () => { it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "Refund" + "manualPaymentRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -526,7 +526,7 @@ describe("Card - Refund flow - No 3DS", () => { it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "PartialRefund" + "manualPaymentPartialRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -542,7 +542,7 @@ describe("Card - Refund flow - No 3DS", () => { }); it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "PartialRefund" + "manualPaymentPartialRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -650,7 +650,7 @@ describe("Card - Refund flow - No 3DS", () => { it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "Refund" + "manualPaymentRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -755,7 +755,7 @@ describe("Card - Refund flow - No 3DS", () => { it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "PartialRefund" + "manualPaymentPartialRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -1297,7 +1297,7 @@ describe("Card - Refund flow - 3DS", () => { it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "Refund" + "manualPaymentRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -1405,7 +1405,7 @@ describe("Card - Refund flow - 3DS", () => { it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "Refund" + "manualPaymentPartialRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -1421,7 +1421,7 @@ describe("Card - Refund flow - 3DS", () => { }); it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "Refund" + "manualPaymentPartialRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -1529,7 +1529,7 @@ describe("Card - Refund flow - 3DS", () => { it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "Refund" + "manualPaymentRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -1637,7 +1637,7 @@ describe("Card - Refund flow - 3DS", () => { it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "Refund" + "manualPaymentRefund" ]; let req_data = data["Request"]; let res_data = data["Response"]; 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 72% rename from cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00014-SaveCardFlow.cy.js index e74c8fc9dd4..cbff06ed640 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00014-SaveCardFlow.cy.js @@ -493,4 +493,191 @@ 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( + "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 82% rename from cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00018-BankRedirect.cy.js index 85a63ca008c..f3c81c16ab2 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00017-BankRedirect.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00018-BankRedirect.cy.js @@ -196,71 +196,6 @@ describe("Bank Redirect tests", () => { }); }); - context("Giropay Create and Confirm flow test", () => { - let should_continue = true; // variable that will be used to skip tests if a previous test fails - - before("seed global state", () => { - cy.task("getGlobalState").then((state) => { - globalState = new State(state); - }); - }); - - beforeEach(function () { - if (!should_continue) { - this.skip(); - } - }); - it("create-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))[ - "bank_redirect_pm" - ]["PaymentIntent"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.createPaymentIntentTest( - fixtures.createPaymentBody, - req_data, - res_data, - "three_ds", - "automatic", - globalState - ); - if (should_continue) - should_continue = utils.should_continue_further(res_data); - }); - - it("payment_methods-call-test", () => { - cy.paymentMethodsCallTest(globalState); - }); - - it("Confirm bank redirect", () => { - let data = getConnectorDetails(globalState.get("connectorId"))[ - "bank_redirect_pm" - ]["Giropay"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.confirmBankRedirectCallTest( - fixtures.confirmBody, - req_data, - res_data, - true, - globalState - ); - if (should_continue) - should_continue = utils.should_continue_further(res_data); - }); - - it("Handle bank redirect redirection", () => { - // return_url is a static url (https://hyperswitch.io) taken from confirm-body fixture and is not updated - let expected_redirection = fixtures.confirmBody["return_url"]; - let payment_method_type = globalState.get("paymentMethodType"); - cy.handleBankRedirectRedirection( - globalState, - payment_method_type, - expected_redirection - ); - }); - }); - context("Sofort Create and Confirm flow test", () => { let should_continue = true; // variable that will be used to skip tests if a previous test fails 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..c27604a07d6 --- /dev/null +++ b/cypress-tests/cypress/e2e/PaymentTest/00022-PaymentMethods.cy.js @@ -0,0 +1,108 @@ +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", () => { + let data = getConnectorDetails("commons")["card_pm"]["PaymentMethod"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentMethodTest(globalState, req_data, res_data); + }); + + 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", () => { + let data = getConnectorDetails("commons")["card_pm"]["PaymentMethod"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentMethodTest(globalState, req_data, res_data); + }); + + 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); + }); + }); +}); 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..9ce384c7a74 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", }, }, }, @@ -178,7 +180,7 @@ export const connectorDetails = { }, }, }, - Void: { + VoidAfterConfirm: { Request: {}, Response: { status: 200, @@ -186,6 +188,12 @@ export const connectorDetails = { status: "processing", }, }, + ResponseCustom: { + status: 200, + body: { + status: "cancelled", + }, + }, }, Refund: { Request: { @@ -209,6 +217,48 @@ export const connectorDetails = { }, }, }, + manualPaymentRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: + "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + code: "IR_14", + }, + }, + }, + }, + manualPaymentPartialRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: + "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + code: "IR_14", + }, + }, + }, + }, SyncRefund: { Request: { currency: "USD", @@ -364,6 +414,37 @@ 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_type: "credit", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + setup_future_usage: "off_session", + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", @@ -391,6 +472,7 @@ export const connectorDetails = { SaveCardUseNo3DSAutoCaptureOffSession: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, @@ -708,7 +790,10 @@ export const connectorDetails = { Response: { status: 200, body: { - status: "requires_customer_action", + status: "processing", + error_code: "905_1", + error_message: + "Could not find an acquirer account for the provided txvariant (giropay), currency (EUR), and action (AUTH).", }, }, }, diff --git a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js index 17acf01e881..4a443e0962a 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", }, @@ -200,6 +202,7 @@ export const connectorDetails = { }, }, }, + PartialRefund: { Request: { payment_method: "card", @@ -216,6 +219,38 @@ export const connectorDetails = { }, }, }, + manualPaymentRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + manualPaymentPartialRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, SyncRefund: { Request: { payment_method: "card", @@ -376,6 +411,37 @@ 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_type: "credit", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + setup_future_usage: "off_session", + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", @@ -403,6 +469,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..6dfe0131bc3 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", }, }, }, @@ -171,6 +171,38 @@ export const connectorDetails = { }, }, }, + manualPaymentRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + manualPaymentPartialRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, SyncRefund: { Request: { payment_method: "card", @@ -199,6 +231,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_type: "credit", + 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 01905ee0532..41de9bf2ff4 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js @@ -56,6 +56,13 @@ const successfulThreeDSTestCardDetails = { card_cvc: "999", }; +const PaymentMethodCardDetails = { + card_number: "4111111145551142", + card_exp_month: "03", + card_exp_year: "30", + card_holder_name: "Joseph Doe", +}; + const singleUseMandateData = { customer_acceptance: { acceptance_type: "offline", @@ -707,6 +714,38 @@ export const connectorDetails = { }, }, }), + manualPaymentRefund: getCustomExchange({ + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "pending", + }, + }, + }), + manualPaymentPartialRefund: getCustomExchange({ + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "pending", + }, + }, + }), PartialRefund: getCustomExchange({ Request: { payment_method: "card", @@ -817,6 +856,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", @@ -879,6 +935,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", @@ -897,6 +966,19 @@ export const connectorDetails = { }, }, }), + PaymentMethod: { + Request: { + payment_method: "card", + payment_method_type: "credit", + payment_method_issuer: "Gpay", + payment_method_issuer_code: "jp_hdfc", + card: PaymentMethodCardDetails, + }, + Response: { + status: 200, + body: {}, + }, + }, PaymentMethodIdMandateNo3DSAutoCapture: 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..ca24a50bcef 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, }, }, }, @@ -200,6 +256,48 @@ export const connectorDetails = { }, }, }, + manualPaymentRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: + "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + code: "IR_14", + }, + }, + }, + }, + manualPaymentPartialRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: + "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + code: "IR_14", + }, + }, + }, + }, PartialRefund: { Request: { payment_method: "card", @@ -376,9 +474,41 @@ 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_type: "credit", + 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 +533,7 @@ export const connectorDetails = { SaveCardUseNo3DSAutoCaptureOffSession: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, @@ -426,6 +557,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..f6350ac84bd 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js @@ -14,6 +14,15 @@ const successfulThreeDSTestCardDetails = { card_cvc: "999", }; +const customerAcceptance = { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "127.0.0.1", + user_agent: "amet irure esse", + }, +}; + export const connectorDetails = { card_pm: { PaymentIntent: { @@ -35,7 +44,6 @@ export const connectorDetails = { payment_method_data: { card: successfulThreeDSTestCardDetails, }, - currency: "USD", customer_acceptance: null, setup_future_usage: "on_session", }, @@ -52,7 +60,6 @@ export const connectorDetails = { payment_method_data: { card: successfulThreeDSTestCardDetails, }, - currency: "USD", customer_acceptance: null, setup_future_usage: "on_session", }, @@ -69,7 +76,6 @@ export const connectorDetails = { payment_method_data: { card: successfulNo3DSCardDetails, }, - currency: "USD", customer_acceptance: null, setup_future_usage: "on_session", }, @@ -86,7 +92,6 @@ export const connectorDetails = { payment_method_data: { card: successfulNo3DSCardDetails, }, - currency: "USD", customer_acceptance: null, setup_future_usage: "on_session", }, @@ -103,7 +108,6 @@ export const connectorDetails = { payment_method_data: { card: successfulNo3DSCardDetails, }, - currency: "USD", customer_acceptance: null, }, Response: { @@ -127,6 +131,15 @@ export const connectorDetails = { }, }, Void: { + Request: {}, + Response: { + status: 200, + body: { + status: "cancelled", + }, + }, + }, + VoidAfterConfirm: { Request: {}, Response: { status: 400, @@ -140,13 +153,13 @@ export const connectorDetails = { }, }, }, + Refund: { Request: { payment_method: "card", payment_method_data: { card: successfulNo3DSCardDetails, }, - currency: "USD", customer_acceptance: null, }, Response: { @@ -162,7 +175,36 @@ export const connectorDetails = { payment_method_data: { card: successfulNo3DSCardDetails, }, - currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "pending", + }, + }, + }, + manualPaymentRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "pending", + }, + }, + }, + manualPaymentPartialRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, customer_acceptance: null, }, Response: { @@ -178,7 +220,6 @@ export const connectorDetails = { payment_method_data: { card: successfulNo3DSCardDetails, }, - currency: "USD", customer_acceptance: null, }, Response: { @@ -200,23 +241,48 @@ export const connectorDetails = { }, }, }, - SaveCardUseNo3DSAutoCapture: { + 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, }, - currency: "USD", - setup_future_usage: "on_session", - customer_acceptance: { - acceptance_type: "offline", - accepted_at: "1963-05-03T04:07:52.723Z", - online: { - ip_address: "127.0.0.1", - user_agent: "amet irure esse", + }, + 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", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + setup_future_usage: "on_session", + customer_acceptance: customerAcceptance, + }, Response: { status: 200, body: { @@ -230,16 +296,8 @@ export const connectorDetails = { payment_method_data: { card: successfulNo3DSCardDetails, }, - currency: "USD", setup_future_usage: "on_session", - customer_acceptance: { - acceptance_type: "offline", - accepted_at: "1963-05-03T04:07:52.723Z", - online: { - ip_address: "127.0.0.1", - user_agent: "amet irure esse", - }, - }, + customer_acceptance: customerAcceptance, }, Response: { status: 200, @@ -248,5 +306,42 @@ export const connectorDetails = { }, }, }, + PaymentMethodIdMandate3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + mandate_data: null, + authentication_type: "three_ds", + customer_acceptance: customerAcceptance, + }, + Response: { + // Skipping redirection here for mandate 3ds auto capture as it requires changes from the core + trigger_skip: true, + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + PaymentMethodIdMandate3DSManualCapture: { + Request: { + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + mandate_data: null, + authentication_type: "three_ds", + customer_acceptance: customerAcceptance, + }, + Response: { + trigger_skip: true, + + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, }, }; diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js b/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js index 1c64393dda2..269fd3ea0b8 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", }, }, }, @@ -173,6 +173,38 @@ export const connectorDetails = { }, }, }, + manualPaymentRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + manualPaymentPartialRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, SyncRefund: { Request: { payment_method: "card", @@ -201,6 +233,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_type: "credit", + 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", @@ -333,7 +399,7 @@ export const connectorDetails = { status: 200, body: { status: "failed", - error_code: "NOT_AUTHORIZED", + error_code: "PERMISSION_DENIED", }, }, }, @@ -370,7 +436,7 @@ export const connectorDetails = { status: 200, body: { status: "failed", - error_code: "NOT_AUTHORIZED", + error_code: "PERMISSION_DENIED", }, }, }, diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js index 3b44f0e4e1e..98af56b882c 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: { @@ -255,6 +257,37 @@ export const connectorDetails = { }, }, }, + manualPaymentRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + manualPaymentPartialRefund: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, PartialRefund: { Request: { payment_method: "card", @@ -431,6 +464,37 @@ 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_type: "credit", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + setup_future_usage: "off_session", + }, + }, + }, SaveCardUseNo3DSAutoCapture: { Request: { payment_method: "card", @@ -506,6 +570,7 @@ export const connectorDetails = { SaveCardUseNo3DSAutoCaptureOffSession: { Request: { payment_method: "card", + payment_method_type: "debit", payment_method_data: { card: successfulNo3DSCardDetails, }, @@ -575,6 +640,20 @@ 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/e2e/PaymentUtils/Trustpay.js b/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js index c209fe5a6dc..36d8906fadb 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js @@ -214,6 +214,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_type: "credit", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + }, + Response: { + status: 501, + body: { + error: { + type: "invalid_request", + message: "Setup Mandate flow for Trustpay is not implemented", + code: "IR_00", + }, + }, + }, + }, SaveCardUseNo3DSAutoCapture: { 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 54a96d8f6ee..724119e0dfc 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/imports.js b/cypress-tests/cypress/fixtures/imports.js index d5cc66b7d29..900e4f4ea3a 100644 --- a/cypress-tests/cypress/fixtures/imports.js +++ b/cypress-tests/cypress/fixtures/imports.js @@ -2,6 +2,7 @@ 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"; @@ -17,7 +18,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,6 +32,7 @@ export { citConfirmBody, configs, confirmBody, + createBusinessProfile, createConfirmPaymentBody, createConnectorBody, createPaymentBody, @@ -44,6 +48,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 5b2ae9bb8ad..6204c86f44a 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 @@ -418,6 +474,8 @@ Cypress.Commands.add( createConnectorBody.connector_type = connectorType; createConnectorBody.connector_name = connectorName; createConnectorBody.connector_type = "payout_processor"; + createConnectorBody.profile_id = globalState.get("profileId"); + // readFile is used to read the contents of the file and it always returns a promise ([Object Object]) due to its asynchronous nature // it is best to use then() to handle the response within the same block of code cy.readFile(globalState.get("connectorAuthFilePath")).then( @@ -588,9 +646,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 +843,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 +883,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 +914,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 ); @@ -916,23 +1005,39 @@ Cypress.Commands.add( "createPaymentMethodTest", (globalState, req_data, res_data) => { req_data.customer_id = globalState.get("customerId"); + const merchant_id = globalState.get("merchantId"); 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: req_data, + 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("payment_method_id"); - expect(response.body).to.have.property("client_secret"); + expect(response.body.client_secret, "client_secret").to.include( + "_secret_" + ).and.to.not.be.null; + expect(response.body.payment_method_id, "payment_method_id").to.not.be + .null; + expect(response.body.merchant_id, "merchant_id").to.equal(merchant_id); + expect(req_data.payment_method_type, "payment_method_type").to.equal( + response.body.payment_method_type + ); + expect(req_data.payment_method, "payment_method").to.equal( + response.body.payment_method + ); + expect(response.body.last_used_at, "last_used_at").to.not.be.null; + expect(req_data.customer_id, "customer_id").to.equal( + response.body.customer_id + ); globalState.set("paymentMethodId", response.body.payment_method_id); } else { defaultErrorHandler(response, res_data); @@ -941,6 +1046,54 @@ Cypress.Commands.add( } ); +Cypress.Commands.add("deletePaymentMethodTest", (globalState, res_data) => { + 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, res_data); + } + }); +}); + +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) => { @@ -968,21 +1121,18 @@ Cypress.Commands.add( 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; + if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { expect(response.body) @@ -1279,6 +1429,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 +1444,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 +1463,6 @@ 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).to.have.property("status"); if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { @@ -1384,6 +1532,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 +1550,27 @@ Cypress.Commands.add( expect(response.headers["content-type"]).to.include("application/json"); if (response.status === 200) { globalState.set("paymentID", paymentIntentID); + + 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; + if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { expect(response.body) @@ -1543,10 +1715,6 @@ 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; } if (autoretries) { @@ -1671,6 +1839,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); @@ -1761,6 +1942,18 @@ 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; if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { expect(response.body) @@ -2022,7 +2215,61 @@ 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(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; + }); +}); + +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)