diff --git a/cypress-tests/.gitignore b/cypress-tests/.gitignore index 0954393e108c..85a05e1a6a81 100644 --- a/cypress-tests/.gitignore +++ b/cypress-tests/.gitignore @@ -1,2 +1,2 @@ creds.json -screenshots \ No newline at end of file +screenshots diff --git a/cypress-tests/cypress.env.json b/cypress-tests/cypress.env.json index 9e26dfeeb6e6..0967ef424bce 100644 --- a/cypress-tests/cypress.env.json +++ b/cypress-tests/cypress.env.json @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00000-AccountCreate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00000-AccountCreate.cy.js index 94700d1a1bb2..4c16fef8df41 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00000-AccountCreate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00000-AccountCreate.cy.js @@ -1,5 +1,5 @@ -import merchantCreateBody from "../../fixtures/merchant-create-body.json"; import apiKeyCreateBody from "../../fixtures/create-api-key-body.json"; +import merchantCreateBody from "../../fixtures/merchant-create-body.json"; import State from "../../utils/State"; let globalState; diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js index 935d8d634d0d..2f7e0ccaea27 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js @@ -1,8 +1,8 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; -import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; import confirmBody from "../../fixtures/confirm-body.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; +import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; +import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js index 4b1f2d6e8c64..43cab5e189f4 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js @@ -1,7 +1,7 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; import confirmBody from "../../fixtures/confirm-body.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; +import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js index 5c0a09ec5973..095ab5381d04 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js @@ -1,9 +1,9 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; -import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; +import captureBody from "../../fixtures/capture-flow-body.json"; import confirmBody from "../../fixtures/confirm-body.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; +import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; +import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; -import captureBody from "../../fixtures/capture-flow-body.json"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js index 7459a6cb83b3..a3808b4db16b 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js @@ -1,8 +1,8 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; import confirmBody from "../../fixtures/confirm-body.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; -import State from "../../utils/State"; +import createPaymentBody from "../../fixtures/create-payment-body.json"; import voidBody from "../../fixtures/void-payment-body.json"; +import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js index 645af22313ce..b0ee171ec250 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js @@ -1,7 +1,7 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; import confirmBody from "../../fixtures/confirm-body.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; +import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js index d3b1f467b2bb..9449bf0d86fb 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js @@ -1,12 +1,13 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; +import captureBody from "../../fixtures/capture-flow-body.json"; import confirmBody from "../../fixtures/confirm-body.json"; import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; -import captureBody from "../../fixtures/capture-flow-body.json"; -import refundBody from "../../fixtures/refund-flow-body.json"; import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; +import createPaymentBody from "../../fixtures/create-payment-body.json"; +import refundBody from "../../fixtures/refund-flow-body.json"; +import listRefundCall from "../../fixtures/list-refund-call-body.json"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; @@ -89,32 +90,32 @@ describe("Card - Refund flow test", () => { context("Fully Refund Card-NoThreeDS payment flow test Create+Confirm", () => { it("create+confirm-payment-call-test", () => { - console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); + console.log("confirm -> " + globalState.get("connectorId")); + let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState); }); - - it("retrieve-payment-call-test", () => { - cy.retrievePaymentCallTest(globalState); + + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); }); it("refund-call-test", () => { let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; cy.refundCallTest(refundBody, 6540, det, globalState); }); - + }); context("Partially Refund Card-NoThreeDS payment flow test Create+Confirm", () => { it("create+confirm-payment-call-test", () => { - console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); + console.log("confirm -> " + globalState.get("connectorId")); + let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState); }); - - it("retrieve-payment-call-test", () => { - cy.retrievePaymentCallTest(globalState); + + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); }); it("refund-call-test", () => { @@ -131,7 +132,7 @@ describe("Card - Refund flow test", () => { let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; cy.syncRefundCallTest(det, globalState); }); - + }); context("Card - Full Refund for fully captured No-3DS payment", () => { @@ -223,7 +224,7 @@ describe("Card - Refund flow test", () => { cy.syncRefundCallTest(det, globalState); }); it("list-refund-call-test", () => { - cy.listRefundCallTest(globalState); + cy.listRefundCallTest(listRefundCall, globalState); }); }); @@ -276,37 +277,37 @@ describe("Card - Refund flow test", () => { let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); }); - + it("payment_methods-call-test", () => { cy.paymentMethodsCallTest(globalState); }); - + it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; console.log("det -> " + det.card); cy.confirmCallTest(confirmBody, det, true, globalState); }); - + it("retrieve-payment-call-test", () => { cy.retrievePaymentCallTest(globalState); }); - + it("capture-call-test", () => { let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; console.log("det -> " + det.card); cy.captureCallTest(captureBody, 4000, det.paymentSuccessfulStatus, globalState); }); - + it("retrieve-payment-call-test", () => { cy.retrievePaymentCallTest(globalState); }); - + it("refund-call-test", () => { let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; cy.refundCallTest(refundBody, 3000, det, globalState); }); - + it("sync-refund-call-test", () => { let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; cy.syncRefundCallTest(det, globalState); @@ -333,10 +334,10 @@ describe("Card - Refund flow test", () => { let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; cy.refundCallTest(refundBody, 7000, det, globalState); }); - + it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.syncRefundCallTest(det, globalState); + let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + cy.syncRefundCallTest(det, globalState); }); }); diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js index 8d35475f2233..35f473d8a6db 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js @@ -1,8 +1,8 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; import confirmBody from "../../fixtures/confirm-body.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; -import refundBody from "../../fixtures/refund-flow-body.json" +import createPaymentBody from "../../fixtures/create-payment-body.json"; +import refundBody from "../../fixtures/refund-flow-body.json"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js index a3ad2a8f528f..04e177950364 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js @@ -1,8 +1,8 @@ import captureBody from "../../fixtures/capture-flow-body.json"; import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; @@ -27,7 +27,7 @@ describe("Card - SingleUse Mandates flow test", () => { console.log("confirm -> " + globalState.get("connectorId")); let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUseNo3DS"]; console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody,7000, det, true, "automatic", "new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState); }); it("Confirm No 3DS MIT", () => { @@ -41,7 +41,7 @@ describe("Card - SingleUse Mandates flow test", () => { console.log("confirm -> " + globalState.get("connectorId")); let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUseNo3DS"]; console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody,7000, det, true, "manual", "new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "manual", "new_mandate", globalState); }); it("cit-capture-call-test", () => { @@ -71,7 +71,7 @@ describe("Card - SingleUse Mandates flow test", () => { console.log("confirm -> " + globalState.get("connectorId")); let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUse3DS"]; console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody,6500, det, true, "automatic", "new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, 6500, det, true, "automatic", "new_mandate", globalState); }); it("cit-capture-call-test", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js index 65939d1e44f5..9990eeaadb5f 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js @@ -1,9 +1,8 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; import captureBody from "../../fixtures/capture-flow-body.json"; import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; @@ -29,7 +28,7 @@ describe("Card - MultiUse Mandates flow test", () => { console.log("confirm -> " + globalState.get("connectorId")); let det = getConnectorDetails(globalState.get("connectorId"))["MandateMultiUseNo3DS"]; console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic","new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState); }); it("Confirm No 3DS MIT", () => { @@ -46,7 +45,7 @@ describe("Card - MultiUse Mandates flow test", () => { console.log("confirm -> " + globalState.get("connectorId")); let det = getConnectorDetails(globalState.get("connectorId"))["MandateMultiUseNo3DS"]; console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "manual","new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "manual", "new_mandate", globalState); }); it("cit-capture-call-test", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js index 0ceb92d5ecbc..fea2a94cbcc8 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js @@ -1,7 +1,6 @@ import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; import getConnectorDetails from "../ConnectorUtils/utils"; -import customerCreateBody from "../../fixtures/create-customer-body.json"; import State from "../../utils/State"; @@ -28,7 +27,7 @@ describe("Card - SingleUse Mandates flow test", () => { console.log("confirm -> " + globalState.get("connectorId")); let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUseNo3DS"]; console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody,7000, det, true, "automatic", "new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState); }); it("Confirm No 3DS MIT", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js index 744b730b58ac..1aeb5199e736 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js @@ -1,129 +1,126 @@ -import createPaymentBody from "../../fixtures/create-payment-body.json"; +import captureBody from "../../fixtures/capture-flow-body.json"; import confirmBody from "../../fixtures/confirm-body.json"; import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; import customerCreateBody from "../../fixtures/create-customer-body.json"; -import captureBody from "../../fixtures/capture-flow-body.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; +import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; -describe("Card - SaveCard payment flow test", () => { +describe("Card - SaveCard payment flow test", () => { - before("seed global state", () => { - - cy.task('getGlobalState').then((state) => { - globalState = new State(state); - console.log("seeding globalState -> " + JSON.stringify(globalState)); - }) - }) - - after("flush global state", () => { - console.log("flushing globalState -> "+ JSON.stringify(globalState)); - cy.task('setGlobalState', globalState.data); + before("seed global state", () => { + + cy.task('getGlobalState').then((state) => { + globalState = new State(state); + console.log("seeding globalState -> " + JSON.stringify(globalState)); }) + }) + + after("flush global state", () => { + console.log("flushing globalState -> " + JSON.stringify(globalState)); + cy.task('setGlobalState', globalState.data); + }) + + + context("Save card for NoThreeDS automatic capture payment- Create+Confirm", () => { + it("customer-create-call-test", () => { + cy.createCustomerCallTest(customerCreateBody, globalState); + }); + + it("create+confirm-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; + cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState); + }); + + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); + }); + + it("retrieve-customerPM-call-test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("create-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "automatic", globalState); + }); + + it("confirm-save-card-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; + cy.saveCardConfirmCallTest(confirmBody, det, globalState); + }); + + }); + + context("Save card for NoThreeDS manual full capture payment- Create+Confirm", () => { + it("customer-create-call-test", () => { + cy.createCustomerCallTest(customerCreateBody, globalState); + }); + + it("create+confirm-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; + cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState); + }); + + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); + }); + + it("retrieve-customerPM-call-test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("create-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + }); + + + it("confirm-save-card-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; + cy.saveCardConfirmCallTest(confirmBody, det, globalState); + }); + + it("capture-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); + }); + }); + + context("Save card for NoThreeDS manual partial capture payment- Create + Confirm", () => { + it("customer-create-call-test", () => { + cy.createCustomerCallTest(customerCreateBody, globalState); + }); + + it("create+confirm-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; + cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState); + }); + + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); + }); + + it("retrieve-customerPM-call-test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("create-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + }); + + + it("confirm-save-card-payment-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; + cy.saveCardConfirmCallTest(confirmBody, det, globalState); + }); + + it("capture-call-test", () => { + let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + cy.captureCallTest(captureBody, 5500, det.paymentSuccessfulStatus, globalState); + }); + }); - - context("Save card for NoThreeDS automatic capture payment- Create+Confirm", () => { - it("customer-create-call-test", () => { - cy.createCustomerCallTest(customerCreateBody, globalState); - }); - - it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); - }); - - it("retrieve-payment-call-test", () => { - cy.retrievePaymentCallTest(globalState); - }); - - it("retrieve-customerPM-call-test", () => { - cy.listCustomerPMCallTest(globalState); - }); - - it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createPaymentIntentTest( createPaymentBody, det, "no_three_ds", "automatic", globalState); - }); - - it ("confirm-save-card-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; - cy.saveCardConfirmCallTest(confirmBody,det,globalState); - }); - - }); - - context("Save card for NoThreeDS manual full capture payment- Create+Confirm", () => { - it("customer-create-call-test", () => { - cy.createCustomerCallTest(customerCreateBody, globalState); - }); - - it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); - }); - - it("retrieve-payment-call-test", () => { - cy.retrievePaymentCallTest(globalState); - }); - - it("retrieve-customerPM-call-test", () => { - cy.listCustomerPMCallTest(globalState); - }); - - it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createPaymentIntentTest( createPaymentBody, det, "no_three_ds", "manual", globalState); - }); - - - it ("confirm-save-card-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; - cy.saveCardConfirmCallTest(confirmBody,det,globalState); - }); - - it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); - }); - - - - }); - - context("Save card for NoThreeDS manual partial capture payment- Create + Confirm", () => { - it("customer-create-call-test", () => { - cy.createCustomerCallTest(customerCreateBody, globalState); - }); - - it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); - }); - - it("retrieve-payment-call-test", () => { - cy.retrievePaymentCallTest(globalState); - }); - - it("retrieve-customerPM-call-test", () => { - cy.listCustomerPMCallTest(globalState); - }); - - it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createPaymentIntentTest( createPaymentBody, det, "no_three_ds", "manual", globalState); - }); - - - it ("confirm-save-card-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["SaveCardUseNo3DS"]; - cy.saveCardConfirmCallTest(confirmBody,det,globalState); - }); - - it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.captureCallTest(captureBody, 5500, det.paymentSuccessfulStatus, globalState); - }); - }); - }); \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js index 41d6c3a7b1c8..0208ca595ce7 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js @@ -1,8 +1,7 @@ -import captureBody from "../../fixtures/capture-flow-body.json"; import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; -import getConnectorDetails from "../ConnectorUtils/utils"; import State from "../../utils/State"; +import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; @@ -36,7 +35,7 @@ describe("Card - SingleUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { let det = getConnectorDetails(globalState.get("connectorId"))["MandateSingleUseNo3DS"]; - cy.citForMandatesCallTest(citConfirmBody,0, det, true, "automatic", "setup_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, 0, det, true, "automatic", "setup_mandate", globalState); }); it("Confirm No 3DS MIT", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Adyen.js b/cypress-tests/cypress/e2e/ConnectorUtils/Adyen.js index a7526a80696b..56ef464984d6 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Adyen.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Adyen.js @@ -23,7 +23,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "pending", "refundSyncStatus": "pending", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "No3DS": { @@ -33,7 +33,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "pending", "refundSyncStatus": "pending", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "MandateSingleUse3DS": { @@ -94,7 +94,7 @@ export const connectorDetails = { }, "SaveCardUseNo3DS": { "card": successfulNo3DSCardDetails, - "currency":"USD", + "currency": "USD", "paymentSuccessfulStatus": "succeeded", "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/BankOfAmerica.js b/cypress-tests/cypress/e2e/ConnectorUtils/BankOfAmerica.js index d868c325eaf8..996122faa7e5 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/BankOfAmerica.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/BankOfAmerica.js @@ -23,7 +23,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "pending", "refundSyncStatus": "pending", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "No3DS": { @@ -33,7 +33,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "pending", "refundSyncStatus": "pending", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "MandateSingleUse3DS": { @@ -94,7 +94,7 @@ export const connectorDetails = { }, "SaveCardUseNo3DS": { "card": successfulNo3DSCardDetails, - "currency":"USD", + "currency": "USD", "paymentSuccessfulStatus": "succeeded", "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", @@ -109,5 +109,5 @@ export const connectorDetails = { } }, }, - + }; \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Bluesnap.js b/cypress-tests/cypress/e2e/ConnectorUtils/Bluesnap.js index fc81654ff019..c42ef5ba5a88 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Bluesnap.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Bluesnap.js @@ -22,7 +22,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", "refundSyncStatus": "succeeded", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "No3DS": { @@ -32,7 +32,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", "refundSyncStatus": "succeeded", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "MandateSingleUse3DS": { @@ -93,7 +93,7 @@ export const connectorDetails = { }, "SaveCardUseNo3DS": { "card": successfulNo3DSCardDetails, - "currency":"USD", + "currency": "USD", "paymentSuccessfulStatus": "succeeded", "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Cybersource.js b/cypress-tests/cypress/e2e/ConnectorUtils/Cybersource.js index bc27520e806c..8daef2ffecfc 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Cybersource.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Cybersource.js @@ -22,7 +22,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "pending", "refundSyncStatus": "pending", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "No3DS": { @@ -32,7 +32,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "pending", "refundSyncStatus": "pending", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "MandateSingleUse3DS": { @@ -93,7 +93,7 @@ export const connectorDetails = { }, "SaveCardUseNo3DS": { "card": successfulNo3DSCardDetails, - "currency":"USD", + "currency": "USD", "paymentSuccessfulStatus": "succeeded", "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Nmi.js b/cypress-tests/cypress/e2e/ConnectorUtils/Nmi.js index 248ba4cfcd13..e2e4d4e80f8d 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Nmi.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Nmi.js @@ -22,7 +22,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "pending", "refundSyncStatus": "succeeded", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, @@ -33,7 +33,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "pending", "refundSyncStatus": "succeeded", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, "MandateSingleUse3DS": { @@ -94,7 +94,7 @@ export const connectorDetails = { }, "SaveCardUseNo3DS": { "card": successfulNo3DSCardDetails, - "currency":"USD", + "currency": "USD", "paymentSuccessfulStatus": "processing", "paymentSyncStatus": "succeeded", "refundStatus": "pending", diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Paypal.js b/cypress-tests/cypress/e2e/ConnectorUtils/Paypal.js index 6488d39f43c9..5337c3eac693 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Paypal.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Paypal.js @@ -21,7 +21,7 @@ export const connectorDetails = { "currency": "USD", "paymentSuccessfulStatus": "requires_customer_action", "paymentSyncStatus": "processing", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, @@ -30,7 +30,7 @@ export const connectorDetails = { "currency": "USD", "paymentSuccessfulStatus": "processing", "paymentSyncStatus": "processing", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session", }, @@ -84,7 +84,7 @@ export const connectorDetails = { }, "SaveCardUseNo3DS": { "card": successfulNo3DSCardDetails, - "currency":"USD", + "currency": "USD", "paymentSuccessfulStatus": "processing", "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index bd4a73f33ac4..2d8d5efa81bf 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -25,7 +25,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", "refundSyncStatus": "succeeded", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session" }, "No3DS": { @@ -35,7 +35,7 @@ export const connectorDetails = { "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", "refundSyncStatus": "succeeded", - "customer_acceptance":null, + "customer_acceptance": null, "setup_future_usage": "on_session" }, "MandateSingleUse3DS": { @@ -96,7 +96,7 @@ export const connectorDetails = { }, "SaveCardUseNo3DS": { "card": successfulTestCardDetails, - "currency":"USD", + "currency": "USD", "paymentSuccessfulStatus": "succeeded", "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js b/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js index c1c4155d102e..f6d6a88ffbb0 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js @@ -93,7 +93,7 @@ export const connectorDetails = { }, "SaveCardUseNo3DS": { "card": successfulNo3DSCardDetails, - "currency":"USD", + "currency": "USD", "paymentSuccessfulStatus": "succeeded", "paymentSyncStatus": "succeeded", "refundStatus": "succeeded", diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/utils.js b/cypress-tests/cypress/e2e/ConnectorUtils/utils.js index b447f303995a..c667c402c564 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/utils.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/utils.js @@ -7,8 +7,6 @@ import { connectorDetails as paypalConnectorDetails } from "./Paypal.js"; import { connectorDetails as stripeConnectorDetails } from "./Stripe.js"; import { connectorDetails as trustpayConnectorDetails } from "./Trustpay.js"; -import globalState from "../../utils/State.js"; - const connectorDetails = { "adyen": adyenConnectorDetails, "bankofamerica": bankOfAmericaConnectorDetails, @@ -34,6 +32,6 @@ function getValueByKey(jsonObject, key) { if (data && typeof data === 'object' && key in data) { return data[key]; } else { - return null; + return null; } } \ No newline at end of file diff --git a/cypress-tests/cypress/fixtures/capture-flow-body.json b/cypress-tests/cypress/fixtures/capture-flow-body.json index cafda7261d45..a28e06c014a8 100644 --- a/cypress-tests/cypress/fixtures/capture-flow-body.json +++ b/cypress-tests/cypress/fixtures/capture-flow-body.json @@ -2,4 +2,4 @@ "amount_to_capture": 100, "statement_descriptor_name": "Joseph", "statement_descriptor_suffix": "JS" -} \ No newline at end of file +} diff --git a/cypress-tests/cypress/fixtures/confirm-body.json b/cypress-tests/cypress/fixtures/confirm-body.json index 5222f4706fec..526d55e3fa84 100644 --- a/cypress-tests/cypress/fixtures/confirm-body.json +++ b/cypress-tests/cypress/fixtures/confirm-body.json @@ -19,10 +19,10 @@ "acceptance_type": "offline", "accepted_at": "1963-05-03T04:07:52.723Z", "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" } - }, + }, "billing": { "address": { "state": "New York", @@ -49,4 +49,4 @@ "java_enabled": true, "java_script_enabled": true } -} \ No newline at end of file +} diff --git a/cypress-tests/cypress/fixtures/create-api-key-body.json b/cypress-tests/cypress/fixtures/create-api-key-body.json index 2f67633e1711..1decb5578027 100644 --- a/cypress-tests/cypress/fixtures/create-api-key-body.json +++ b/cypress-tests/cypress/fixtures/create-api-key-body.json @@ -2,4 +2,4 @@ "name": "API Key 1", "description": null, "expiration": "2069-09-23T01:02:03.000Z" -} \ No newline at end of file +} diff --git a/cypress-tests/cypress/fixtures/create-confirm-body.json b/cypress-tests/cypress/fixtures/create-confirm-body.json index ed52cd456160..1f3307b61f50 100644 --- a/cypress-tests/cypress/fixtures/create-confirm-body.json +++ b/cypress-tests/cypress/fixtures/create-confirm-body.json @@ -1,83 +1,82 @@ { - "amount": 6540, - "currency": "USD", - "confirm": true, - - "capture_method": "automatic", - "capture_on": "2022-09-10T10:11:12Z", - "amount_to_capture": 6540, - "customer_id": "john123", - "email": "guest@example.com", - "name": "John Doe", - "phone": "999999999", - "phone_country_code": "+65", - "description": "Its my first payment request", - "authentication_type": "no_three_ds", - "return_url": "https://duck.com", - "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" - } - }, - "payment_method": "card", - "payment_method_type": "debit", - "payment_method_data": { - "card": { - "card_number": "4242424242424242", - "card_exp_month": "01", - "card_exp_year": "24", - "card_holder_name": "joseph Doe", - "card_cvc": "123" - } - }, + "amount": 6540, + "currency": "USD", + "confirm": true, + "capture_method": "automatic", + "capture_on": "2022-09-10T10:11:12Z", + "amount_to_capture": 6540, + "customer_id": "john123", + "email": "guest@example.com", + "name": "John Doe", + "phone": "999999999", + "phone_country_code": "+65", + "description": "Its my first payment request", + "authentication_type": "no_three_ds", + "return_url": "https://duck.com", + "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" + } + }, + "payment_method": "card", + "payment_method_type": "debit", + "payment_method_data": { + "card": { + "card_number": "4242424242424242", + "card_exp_month": "01", + "card_exp_year": "24", + "card_holder_name": "joseph Doe", + "card_cvc": "123" + } + }, - "billing": { - "address": { - "line1": "1467", - "line2": "Harrison Street", - "line3": "Harrison Street", - "city": "San Fransico", - "state": "California", - "zip": "94122", - "country": "US", - "first_name": "john", - "last_name": "doe" - } - }, - "shipping": { - "address": { - "line1": "1467", - "line2": "Harrison Street", - "line3": "Harrison Street", - "city": "San Fransico", - "state": "California", - "zip": "94122", - "country": "US", - "first_name": "john", - "last_name": "doe" - } - }, - "statement_descriptor_name": "joseph", - "statement_descriptor_suffix": "JS", - "metadata": { - "udf1": "value1", - "new_customer": "true", - "login_date": "2019-09-10T10:11:12Z" - }, - "browser_info": { - "ip_address": "129.0.0.1", - "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", - "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", - "language": "en-US", - "color_depth": 30, - "screen_height": 1117, - "screen_width": 1728, - "time_zone": -330, - "java_enabled": true, - "java_script_enabled": true + "billing": { + "address": { + "line1": "1467", + "line2": "Harrison Street", + "line3": "Harrison Street", + "city": "San Fransico", + "state": "California", + "zip": "94122", + "country": "US", + "first_name": "john", + "last_name": "doe" + } + }, + "shipping": { + "address": { + "line1": "1467", + "line2": "Harrison Street", + "line3": "Harrison Street", + "city": "San Fransico", + "state": "California", + "zip": "94122", + "country": "US", + "first_name": "john", + "last_name": "doe" } -} \ No newline at end of file + }, + "statement_descriptor_name": "joseph", + "statement_descriptor_suffix": "JS", + "metadata": { + "udf1": "value1", + "new_customer": "true", + "login_date": "2019-09-10T10:11:12Z" + }, + "browser_info": { + "ip_address": "129.0.0.1", + "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", + "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", + "language": "en-US", + "color_depth": 30, + "screen_height": 1117, + "screen_width": 1728, + "time_zone": -330, + "java_enabled": true, + "java_script_enabled": true + } +} diff --git a/cypress-tests/cypress/fixtures/create-connector-body.json b/cypress-tests/cypress/fixtures/create-connector-body.json index 37646fbf94c3..d3575c0b2ccf 100644 --- a/cypress-tests/cypress/fixtures/create-connector-body.json +++ b/cypress-tests/cypress/fixtures/create-connector-body.json @@ -1,62 +1,62 @@ { - "connector_type": "fiz_operations", - "connector_name": "stripe", - "business_country": "US", - "business_label": "default", - "connector_label": "first_stripe_connector", - "connector_account_details": { - "auth_type": "BodyKey", - "api_key": "api-key", - "key1": "value1" - }, - "test_mode": true, - "disabled": false, - "payment_methods_enabled": [ + "connector_type": "fiz_operations", + "connector_name": "stripe", + "business_country": "US", + "business_label": "default", + "connector_label": "first_stripe_connector", + "connector_account_details": { + "auth_type": "BodyKey", + "api_key": "api-key", + "key1": "value1" + }, + "test_mode": true, + "disabled": false, + "payment_methods_enabled": [ + { + "payment_method": "card", + "payment_method_types": [ { - "payment_method": "card", - "payment_method_types": [ - { - "payment_method_type": "credit", - "card_networks": [ - "AmericanExpress", - "Discover", - "Interac", - "JCB", - "Mastercard", - "Visa", - "DinersClub", - "UnionPay", - "RuPay" - ], - "minimum_amount": 0, - "maximum_amount": 68607706, - "recurring_enabled": false, - "installment_payment_enabled": true - }, - { - "payment_method_type": "debit", - "card_networks": [ - "AmericanExpress", - "Discover", - "Interac", - "JCB", - "Mastercard", - "Visa", - "DinersClub", - "UnionPay", - "RuPay" - ], - "minimum_amount": 0, - "maximum_amount": 68607706, - "recurring_enabled": false, - "installment_payment_enabled": true - } - ] + "payment_method_type": "credit", + "card_networks": [ + "AmericanExpress", + "Discover", + "Interac", + "JCB", + "Mastercard", + "Visa", + "DinersClub", + "UnionPay", + "RuPay" + ], + "minimum_amount": 0, + "maximum_amount": 68607706, + "recurring_enabled": false, + "installment_payment_enabled": true + }, + { + "payment_method_type": "debit", + "card_networks": [ + "AmericanExpress", + "Discover", + "Interac", + "JCB", + "Mastercard", + "Visa", + "DinersClub", + "UnionPay", + "RuPay" + ], + "minimum_amount": 0, + "maximum_amount": 68607706, + "recurring_enabled": false, + "installment_payment_enabled": true } - ], - "metadata": { - "city": "NY", - "unit": "245", - "endpoint_prefix": "AD" + ] } -} \ No newline at end of file + ], + "metadata": { + "city": "NY", + "unit": "245", + "endpoint_prefix": "AD" + } +} diff --git a/cypress-tests/cypress/fixtures/create-customer-body.json b/cypress-tests/cypress/fixtures/create-customer-body.json index 26c6bb9ec787..025e6bec35b3 100644 --- a/cypress-tests/cypress/fixtures/create-customer-body.json +++ b/cypress-tests/cypress/fixtures/create-customer-body.json @@ -1,23 +1,23 @@ { - "email": "guest@example.com", - "name": "John Doe", - "phone": "999999999", - "phone_country_code": "+65", - "description": "First customer", - "address": { - "city": "Bangalore", - "country": "IN", - "line1": "Juspay router", - "line2": "Koramangala", - "line3": "Stallion", - "state": "Karnataka", - "zip": "560095", - "first_name": "John", - "last_name": "Doe" - }, - "metadata": { - "udf1": "value1", - "new_customer": "true", - "login_date": "2019-09-10T10:11:12Z" - } -} \ No newline at end of file + "email": "guest@example.com", + "name": "John Doe", + "phone": "999999999", + "phone_country_code": "+65", + "description": "First customer", + "address": { + "city": "Bangalore", + "country": "IN", + "line1": "Juspay router", + "line2": "Koramangala", + "line3": "Stallion", + "state": "Karnataka", + "zip": "560095", + "first_name": "John", + "last_name": "Doe" + }, + "metadata": { + "udf1": "value1", + "new_customer": "true", + "login_date": "2019-09-10T10:11:12Z" + } +} diff --git a/cypress-tests/cypress/fixtures/create-mandate-cit.json b/cypress-tests/cypress/fixtures/create-mandate-cit.json index 1e297f5442f4..e75aab9d00fa 100644 --- a/cypress-tests/cypress/fixtures/create-mandate-cit.json +++ b/cypress-tests/cypress/fixtures/create-mandate-cit.json @@ -40,7 +40,7 @@ } } }, - "payment_type":"setup_mandate", + "payment_type": "setup_mandate", "billing": { "address": { "line1": "1467", @@ -87,4 +87,4 @@ "java_enabled": true, "java_script_enabled": true } -} \ No newline at end of file +} diff --git a/cypress-tests/cypress/fixtures/create-mandate-mit.json b/cypress-tests/cypress/fixtures/create-mandate-mit.json index 779fd0b0254a..9612eac32091 100644 --- a/cypress-tests/cypress/fixtures/create-mandate-mit.json +++ b/cypress-tests/cypress/fixtures/create-mandate-mit.json @@ -33,4 +33,4 @@ "java_enabled": true, "java_script_enabled": true } -} \ No newline at end of file +} diff --git a/cypress-tests/cypress/fixtures/create-payment-body.json b/cypress-tests/cypress/fixtures/create-payment-body.json index acd2160e8a8c..8dd1ff9579df 100644 --- a/cypress-tests/cypress/fixtures/create-payment-body.json +++ b/cypress-tests/cypress/fixtures/create-payment-body.json @@ -4,7 +4,7 @@ "authentication_type": "three_ds", "description": "Joseph First Crypto", "email": "hyperswitch_sdk_demo_id@gmail.com", - "setup_future_usage":"", + "setup_future_usage": "", "connector_metadata": { "noon": { "order_category": "applepay" @@ -17,4 +17,4 @@ }, "business_country": "US", "business_label": "default" -} \ No newline at end of file +} diff --git a/cypress-tests/cypress/fixtures/list-refund-call-body.json b/cypress-tests/cypress/fixtures/list-refund-call-body.json new file mode 100644 index 000000000000..9f6e3b6d9a34 --- /dev/null +++ b/cypress-tests/cypress/fixtures/list-refund-call-body.json @@ -0,0 +1,3 @@ +{ + "offset": 0 +} diff --git a/cypress-tests/cypress/fixtures/merchant-create-body.json b/cypress-tests/cypress/fixtures/merchant-create-body.json index 00a28adbf0d5..08ed09874251 100644 --- a/cypress-tests/cypress/fixtures/merchant-create-body.json +++ b/cypress-tests/cypress/fixtures/merchant-create-body.json @@ -41,4 +41,4 @@ "business": "default" } ] -} \ No newline at end of file +} diff --git a/cypress-tests/cypress/fixtures/refund-flow-body.json b/cypress-tests/cypress/fixtures/refund-flow-body.json index 4579d121a0ca..f027042c5b8f 100644 --- a/cypress-tests/cypress/fixtures/refund-flow-body.json +++ b/cypress-tests/cypress/fixtures/refund-flow-body.json @@ -1,11 +1,11 @@ { - "payment_id": "payment_id", - "amount": 100, - "reason": "FRAUD", - "refund_type": "instant", - "metadata": { - "udf1": "value1", - "new_customer": "true", - "login_date": "2019-09-10T10:11:12Z" - } -} \ No newline at end of file + "payment_id": "payment_id", + "amount": 100, + "reason": "FRAUD", + "refund_type": "instant", + "metadata": { + "udf1": "value1", + "new_customer": "true", + "login_date": "2019-09-10T10:11:12Z" + } +} diff --git a/cypress-tests/cypress/fixtures/save-card-confirm-body.json b/cypress-tests/cypress/fixtures/save-card-confirm-body.json index 777e1b110bb1..676e91871ff3 100644 --- a/cypress-tests/cypress/fixtures/save-card-confirm-body.json +++ b/cypress-tests/cypress/fixtures/save-card-confirm-body.json @@ -1,6 +1,6 @@ { - "client_secret": "{{client_secret}}", - "payment_method": "card", - "payment_token": "{{payment_token}}", - "card_cvc": "card_cvc" -} \ No newline at end of file + "client_secret": "{{client_secret}}", + "payment_method": "card", + "payment_token": "{{payment_token}}", + "card_cvc": "card_cvc" +} diff --git a/cypress-tests/cypress/fixtures/void-payment-body.json b/cypress-tests/cypress/fixtures/void-payment-body.json index 29b5c8be3fa1..471d90d6c486 100644 --- a/cypress-tests/cypress/fixtures/void-payment-body.json +++ b/cypress-tests/cypress/fixtures/void-payment-body.json @@ -1,3 +1,3 @@ { - "cancellation_reason": "requested_by_customer" -} \ No newline at end of file + "cancellation_reason": "requested_by_customer" +} diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 8a3ef5fa3ee2..61ce6a0970d1 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -26,12 +26,16 @@ // commands.js or your custom support file import * as RequestBodyUtils from "../utils/RequestBodyUtils"; -import ConnectorAuthDetails from "../../../.github/secrets/creds.json"; - +function logRequestId(xRequestId) { + if (xRequestId) { + cy.task('cli_log', "x-request-id -> " + xRequestId); + } else { + cy.task('cli_log', "x-request-id is not available in the response headers"); + } +} Cypress.Commands.add("merchantCreateCallTest", (merchantCreateBody, globalState) => { - const randomMerchantId = RequestBodyUtils.generateRandomString(); RequestBodyUtils.setMerchantId(merchantCreateBody, randomMerchantId); globalState.set("merchantId", randomMerchantId); @@ -46,15 +50,9 @@ Cypress.Commands.add("merchantCreateCallTest", (merchantCreateBody, globalState) }, body: merchantCreateBody, }).then((response) => { + logRequestId(response.headers['x-request-id']); - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } // Handle the response as needed - console.log(response.body); globalState.set("publishableKey", response.body.publishable_key); }); }); @@ -70,15 +68,9 @@ Cypress.Commands.add("apiKeyCreateTest", (apiKeyCreateBody, globalState) => { }, body: apiKeyCreateBody, }).then((response) => { + logRequestId(response.headers['x-request-id']); - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } // Handle the response as needed - console.log(response.body); globalState.set("apiKey", response.body.api_key); }); }); @@ -86,36 +78,30 @@ Cypress.Commands.add("apiKeyCreateTest", (apiKeyCreateBody, globalState) => { Cypress.Commands.add("createConnectorCallTest", (createConnectorBody, globalState) => { const merchantId = globalState.get("merchantId"); createConnectorBody.connector_name = globalState.get("connectorId"); - const authDetails = getValueByKey(ConnectorAuthDetails, globalState.get("connectorId")); - createConnectorBody.connector_account_details = authDetails; - cy.request({ - method: "POST", - url: `${globalState.get("baseUrl")}/account/${merchantId}/connectors`, - headers: { - "Content-Type": "application/json", - Accept: "application/json", - "api-key": globalState.get("adminApiKey"), - }, - body: createConnectorBody, - failOnStatusCode: false - }).then((response) => { - // Handle the response as needed - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } - - if (response.status === 200) { - expect(globalState.get("connectorId")).to.equal(response.body.connector_name); - } - else { - cy.task('cli_log', "response status ->> " + JSON.stringify(response.status)); - cy.task('cli_log', "res body ->> " + JSON.stringify(response.body)); - } - - + // 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((jsonContent) => { + const authDetails = getValueByKey(JSON.stringify(jsonContent), globalState.get("connectorId")); + createConnectorBody.connector_account_details = authDetails; + cy.request({ + method: "POST", + url: `${globalState.get("baseUrl")}/account/${merchantId}/connectors`, + headers: { + "Content-Type": "application/json", + Accept: "application/json", + "api-key": globalState.get("adminApiKey"), + }, + body: createConnectorBody, + failOnStatusCode: false + }).then((response) => { + logRequestId(response.headers['x-request-id']); + + if (response.status === 200) { + expect(globalState.get("connectorId")).to.equal(response.body.connector_name); + } else { + cy.task('cli_log', "response status -> " + JSON.stringify(response.status)); + } + }); }); }); @@ -138,13 +124,8 @@ Cypress.Commands.add("createCustomerCallTest", (customerCreateBody, globalState) }, body: customerCreateBody, }).then((response) => { + logRequestId(response.headers['x-request-id']); - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } // Handle the response as needed console.log(response); @@ -159,7 +140,7 @@ Cypress.Commands.add("createPaymentIntentTest", (request, det, authentication_ty request.currency = det.currency; request.authentication_type = authentication_type; request.capture_method = capture_method; - request.setup_future_usage= det.setup_future_usage; + request.setup_future_usage = det.setup_future_usage; request.customer_id = globalState.get("customerId"); globalState.set("paymentAmount", request.amount); cy.request({ @@ -172,12 +153,8 @@ Cypress.Commands.add("createPaymentIntentTest", (request, det, authentication_ty }, body: request, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); expect(response.body).to.have.property("client_secret"); const clientSecret = response.body.client_secret; @@ -203,12 +180,8 @@ Cypress.Commands.add("paymentMethodsCallTest", (globalState) => { "api-key": globalState.get("publishableKey"), }, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + console.log(response); expect(response.headers["content-type"]).to.include("application/json"); expect(response.body).to.have.property("redirect_url"); @@ -219,7 +192,6 @@ Cypress.Commands.add("paymentMethodsCallTest", (globalState) => { }); Cypress.Commands.add("confirmCallTest", (confirmBody, details, confirm, globalState) => { - const paymentIntentID = globalState.get("paymentID"); confirmBody.payment_method_data.card = details.card; confirmBody.confirm = confirm; @@ -235,14 +207,9 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, details, confirm, globalSt }, body: confirmBody, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); globalState.set("paymentID", paymentIntentID); if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { @@ -292,15 +259,10 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, deta }, body: createConfirmPaymentBody, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); expect(response.body).to.have.property("status"); - console.log(response.body); globalState.set("paymentAmount", createConfirmPaymentBody.amount); globalState.set("paymentID", response.body.payment_id); if (response.body.capture_method === "automatic") { @@ -331,12 +293,12 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, deta }); // This is consequent saved card payment confirm call test(Using payment token) -Cypress.Commands.add("saveCardConfirmCallTest", (confirmBody,det,globalState) => { +Cypress.Commands.add("saveCardConfirmCallTest", (confirmBody, det, globalState) => { const paymentIntentID = globalState.get("paymentID"); confirmBody.card_cvc = det.card.card_cvc; confirmBody.payment_token = globalState.get("paymentToken"); confirmBody.client_secret = globalState.get("clientSecret"); - console.log("conf conn ->" + globalState.get("connectorId")); + console.log("configured connector ->" + globalState.get("connectorId")); cy.request({ method: "POST", url: `${globalState.get("baseUrl")}/payments/${paymentIntentID}/confirm`, @@ -346,48 +308,42 @@ Cypress.Commands.add("saveCardConfirmCallTest", (confirmBody,det,globalState) => }, body: confirmBody, }) - .then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } - expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); - globalState.set("paymentID", paymentIntentID); - if (response.body.capture_method === "automatic") { - if (response.body.authentication_type === "three_ds") { - expect(response.body).to.have.property("next_action") - .to.have.property("redirect_to_url"); - const nextActionUrl = response.body.next_action.redirect_to_url; - } else if (response.body.authentication_type === "no_three_ds") { - expect(response.body.status).to.equal(det.paymentSuccessfulStatus); - expect(response.body.customer_id).to.equal(globalState.get("customerId")); - } else { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${authentication_type}`); - } - } else if (response.body.capture_method === "manual") { - if (response.body.authentication_type === "three_ds") { - expect(response.body).to.have.property("next_action") - .to.have.property("redirect_to_url") + .then((response) => { + logRequestId(response.headers['x-request-id']); + + expect(response.headers["content-type"]).to.include("application/json"); + globalState.set("paymentID", paymentIntentID); + if (response.body.capture_method === "automatic") { + if (response.body.authentication_type === "three_ds") { + expect(response.body).to.have.property("next_action") + .to.have.property("redirect_to_url"); + const nextActionUrl = response.body.next_action.redirect_to_url; + } else if (response.body.authentication_type === "no_three_ds") { + expect(response.body.status).to.equal(det.paymentSuccessfulStatus); + expect(response.body.customer_id).to.equal(globalState.get("customerId")); + } else { + // Handle other authentication types as needed + throw new Error(`Unsupported authentication type: ${authentication_type}`); + } + } else if (response.body.capture_method === "manual") { + if (response.body.authentication_type === "three_ds") { + expect(response.body).to.have.property("next_action") + .to.have.property("redirect_to_url") + } + else if (response.body.authentication_type === "no_three_ds") { + expect(response.body.status).to.equal("requires_capture"); + expect(response.body.customer_id).to.equal(globalState.get("customerId")); + } else { + // Handle other authentication types as needed + throw new Error(`Unsupported authentication type: ${authentication_type}`); + } } - else if (response.body.authentication_type === "no_three_ds") { - expect(response.body.status).to.equal("requires_capture"); - expect(response.body.customer_id).to.equal(globalState.get("customerId")); - } else { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${authentication_type}`); + else { + throw new Error(`Unsupported capture method: ${capture_method}`); } - } - else { - throw new Error(`Unsupported capture method: ${capture_method}`); - } - }); + }); }); - Cypress.Commands.add("captureCallTest", (requestBody, amount_to_capture, paymentSuccessfulStatus, globalState) => { const payment_id = globalState.get("paymentID"); requestBody.amount_to_capture = amount_to_capture; @@ -401,27 +357,22 @@ Cypress.Commands.add("captureCallTest", (requestBody, amount_to_capture, payment }, body: requestBody, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); expect(response.body.payment_id).to.equal(payment_id); - console.log(response.body); if (amount_to_capture == amount && response.body.status == "succeeded") { expect(response.body.amount).to.equal(amount_to_capture); expect(response.body.amount_capturable).to.equal(0); expect(response.body.amount_received).to.equal(amount); expect(response.body.status).to.equal(paymentSuccessfulStatus); - }else if (response.body.status=="processing") { + } else if (response.body.status == "processing") { expect(response.body.amount).to.equal(amount); expect(response.body.amount_capturable).to.equal(amount); expect(response.body.amount_received).to.equal(0); expect(response.body.status).to.equal(paymentSuccessfulStatus); } - else { + else { expect(response.body.amount).to.equal(amount); expect(response.body.amount_capturable).to.equal(0); expect(response.body.amount_received).to.equal(amount_to_capture); @@ -441,24 +392,19 @@ Cypress.Commands.add("voidCallTest", (requestBody, globalState) => { }, body: requestBody, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); expect(response.body.payment_id).to.equal(payment_id); expect(response.body.amount).to.equal(globalState.get("paymentAmount")); // expect(response.body.amount_capturable).to.equal(0); expect(response.body.amount_received).to.be.oneOf([0, null]); expect(response.body.status).to.equal("cancelled"); - console.log(response.body); }); }); Cypress.Commands.add("retrievePaymentCallTest", (globalState) => { - console.log("syncpaymentID------>" + globalState.get("paymentID")); + console.log("syncpaymentID ->" + globalState.get("paymentID")); const payment_id = globalState.get("paymentID"); cy.request({ method: "GET", @@ -468,14 +414,9 @@ Cypress.Commands.add("retrievePaymentCallTest", (globalState) => { "api-key": globalState.get("apiKey"), }, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); expect(response.body.payment_id).to.equal(payment_id); expect(response.body.amount).to.equal(globalState.get("paymentAmount")); globalState.set("paymentID", response.body.payment_id); @@ -496,14 +437,9 @@ Cypress.Commands.add("refundCallTest", (requestBody, refund_amount, det, globalS }, body: requestBody }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); globalState.set("refundId", response.body.refund_id); expect(response.body.status).to.equal(det.refundStatus); expect(response.body.amount).to.equal(refund_amount); @@ -521,22 +457,16 @@ Cypress.Commands.add("syncRefundCallTest", (det, globalState) => { "api-key": globalState.get("apiKey"), }, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); expect(response.body.status).to.equal(det.refundSyncStatus); }); }); -Cypress.Commands.add("citForMandatesCallTest", (requestBody,amount, details, confirm, capture_method, payment_type, globalState) => { - +Cypress.Commands.add("citForMandatesCallTest", (requestBody, amount, details, confirm, capture_method, payment_type, globalState) => { requestBody.payment_method_data.card = details.card; - requestBody.payment_type=payment_type; + requestBody.payment_type = payment_type; requestBody.confirm = confirm; requestBody.amount = amount; requestBody.currency = details.currency; @@ -553,15 +483,10 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody,amount, details, con }, body: requestBody, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); expect(response.body).to.have.property("mandate_id"); - console.log(response.body); globalState.set("mandateId", response.body.mandate_id); globalState.set("paymentID", response.body.payment_id); @@ -610,15 +535,10 @@ Cypress.Commands.add("mitForMandatesCallTest", (requestBody, amount, confirm, ca }, body: requestBody, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); globalState.set("paymentID", response.body.payment_id); - console.log(response.body); console.log("mit statusss-> " + response.body.status); if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { @@ -662,14 +582,10 @@ Cypress.Commands.add("listMandateCallTest", (globalState) => { "api-key": globalState.get("apiKey"), }, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); + let i = 0; for (i in response.body) { if (response.body[i].mandate_id === globalState.get("mandateId")) { @@ -690,14 +606,9 @@ Cypress.Commands.add("revokeMandateCallTest", (globalState) => { }, failOnStatusCode: false }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); if (response.body.status === 200) { expect(response.body.status).to.equal("revoked"); } else if (response.body.status === 400) { @@ -706,8 +617,8 @@ Cypress.Commands.add("revokeMandateCallTest", (globalState) => { }); }); - Cypress.Commands.add("handleRedirection", (globalState, expected_redirection) => { + let connectorId = globalState.get("connectorId"); let expected_url = new URL(expected_redirection); let redirection_url = new URL(globalState.get("nextActionUrl")); cy.visit(redirection_url.href); @@ -719,30 +630,30 @@ Cypress.Commands.add("handleRedirection", (globalState, expected_redirection) => cy.get('input[type="password"]').type("password"); cy.get('#buttonSubmit').click(); }) - } - else if (globalState.get("connectorId") === "cybersource" || globalState.get("connectorId") === "bankofamerica" ) { + } + else if (globalState.get("connectorId") === "cybersource" || globalState.get("connectorId") === "bankofamerica") { cy.get('iframe') .its('0.contentDocument.body') .within((body) => { cy.get('input[type="text"]').click().type("1234"); cy.get('input[value="SUBMIT"]').click(); - }) + }) } else if (globalState.get("connectorId") === "nmi" || globalState.get("connectorId") === "noon") { - cy.get('iframe',{ timeout: 100000 }) + cy.get('iframe', { timeout: 100000 }) .its('0.contentDocument.body') .within((body) => { - cy.get('iframe',{ timeout: 10000 }) + cy.get('iframe', { timeout: 10000 }) .its('0.contentDocument.body') .within((body) => { - cy.get('form[name="cardholderInput"]',{ timeout: 10000 }).should('exist').then(form => { - cy.get('input[name="challengeDataEntry"]').click().type("1234"); - cy.get('input[value="SUBMIT"]').click(); + cy.get('form[name="cardholderInput"]', { timeout: 10000 }).should('exist').then(form => { + cy.get('input[name="challengeDataEntry"]').click().type("1234"); + cy.get('input[value="SUBMIT"]').click(); + }) }) }) - }) } - else if (globalState.get("connectorId") === "stripe" ) { + else if (globalState.get("connectorId") === "stripe") { cy.get('iframe') .its('0.contentDocument.body') .within((body) => { @@ -752,35 +663,35 @@ Cypress.Commands.add("handleRedirection", (globalState, expected_redirection) => cy.get('#test-source-authorize-3ds').click(); }) }) - } - else if (globalState.get("connectorId") === "trustpay" ) { - cy.get('form[name="challengeForm"]',{ timeout: 10000 }).should('exist').then(form => { - cy.get('#outcomeSelect').select('Approve').should('have.value', 'Y') - cy.get('button[type="submit"]').click(); - }) + } + else if (globalState.get("connectorId") === "trustpay") { + cy.get('form[name="challengeForm"]', { timeout: 10000 }).should('exist').then(form => { + cy.get('#outcomeSelect').select('Approve').should('have.value', 'Y') + cy.get('button[type="submit"]').click(); + }) } - + else { - // If connectorId is neither of adyen, trustpay, nmi, stripe, bankofamerica or cybersource, wait for 30 seconds - cy.wait(30000); + // If connectorId is neither of adyen, trustpay, nmi, stripe, bankofamerica or cybersource, wait for 10 seconds + cy.wait(10000); } - + // Handling redirection if (redirection_url.host.endsWith(expected_url.host)) { // No CORS workaround needed cy.window().its('location.origin').should('eq', expected_url.origin); } else { // Workaround for CORS to allow cross-origin iframe - cy.origin(expected_url.origin, { args: { expected_url: expected_url.origin} }, ({expected_url}) => { + cy.origin(expected_url.origin, { args: { expected_url: expected_url.origin } }, ({ expected_url }) => { cy.window().its('location.origin').should('eq', expected_url); }) } - + }); Cypress.Commands.add("listCustomerPMCallTest", (globalState) => { - console.log("customerID------>" + globalState.get("customerId")); + console.log("customerID ->" + globalState.get("customerId")); const customerId = globalState.get("customerId"); cy.request({ method: "GET", @@ -790,26 +701,21 @@ Cypress.Commands.add("listCustomerPMCallTest", (globalState) => { "api-key": globalState.get("apiKey"), }, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); if (response.body.customer_payment_methods[0]?.payment_token) { const paymentToken = response.body.customer_payment_methods[0].payment_token; globalState.set("paymentToken", paymentToken); // Set paymentToken in globalState expect(paymentToken).to.equal(globalState.get("paymentToken")); // Verify paymentToken - } + } else { throw new Error(`Payment token not found`); - } + } }); }); -Cypress.Commands.add("listRefundCallTest", (globalState) => { +Cypress.Commands.add("listRefundCallTest", (requestBody, globalState) => { cy.request({ method: "POST", url: `${globalState.get("baseUrl")}/refunds/list`, @@ -817,17 +723,11 @@ Cypress.Commands.add("listRefundCallTest", (globalState) => { "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, - body:{"offset":0} + body: requestBody, }).then((response) => { - const xRequestId = response.headers['x-request-id']; - if (xRequestId) { - cy.task('cli_log', "x-request-id ->> " + xRequestId); - } else { - cy.task('cli_log', "x-request-id is not available in the response headers"); - } + logRequestId(response.headers['x-request-id']); + expect(response.headers["content-type"]).to.include("application/json"); - console.log(response.body); expect(response.body.data).to.be.an('array').and.not.empty; - - }); - }); \ No newline at end of file + }); +}); diff --git a/cypress-tests/cypress/support/e2e.js b/cypress-tests/cypress/support/e2e.js index 0e7290a13d9e..9b1ef71ce0f5 100644 --- a/cypress-tests/cypress/support/e2e.js +++ b/cypress-tests/cypress/support/e2e.js @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import './commands'; // Alternatively you can use CommonJS syntax: // require('./commands') \ No newline at end of file diff --git a/cypress-tests/cypress/utils/State.js b/cypress-tests/cypress/utils/State.js index 342c220a4160..dae4963000f0 100644 --- a/cypress-tests/cypress/utils/State.js +++ b/cypress-tests/cypress/utils/State.js @@ -5,6 +5,7 @@ class State { this.data["connectorId"] = Cypress.env("CONNECTOR"); this.data["baseUrl"] = Cypress.env("BASEURL"); this.data["adminApiKey"] = Cypress.env("ADMINAPIKEY"); + this.data["connectorAuthFilePath"] = Cypress.env("CONNECTOR_AUTH_FILE_PATH"); } set(key, val) { diff --git a/cypress-tests/package.json b/cypress-tests/package.json index 62eab5e38039..fff8cd8b3f17 100644 --- a/cypress-tests/package.json +++ b/cypress-tests/package.json @@ -4,9 +4,9 @@ "description": "", "main": "index.js", "scripts": { - "cypress":"npx cypress open", + "cypress": "npx cypress open", "cypress-e2e": "npx cypress run --e2e", - "cypress:ci":"npx cypress run --headless" + "cypress:ci": "npx cypress run --headless" }, "author": "", "license": "ISC" diff --git a/cypress-tests/yarn.lock b/cypress-tests/yarn.lock deleted file mode 100644 index fb57ccd13afb..000000000000 --- a/cypress-tests/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - -