Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

ci(cypress): add `realtime_payment` payment method (#10467)

likhinbopannaf5728e9a8928
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 20971eee7c..ff01a26ae3 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -652,6 +652,34 @@ export const connectorDetails = {
},
}),
},
+ real_time_payment_pm: {
+ PaymentIntent: getCustomExchange({
+ Request: {
+ currency: "MYR",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ billing: standardBillingAddress,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ DuitNow: getCustomExchange({
+ Request: {
+ payment_method: "real_time_payment",
+ payment_method_type: "duit_now",
+ payment_method_data: {
+ real_time_payment: {
+ duit_now: {},
+ },
+ },
+ billing: standardBillingAddress,
+ },
+ }),
+ },
card_pm: {
PaymentIntent: getCustomExchange({
Request: {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js b/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js
index a0cfe09d13..8d9aef9def 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js
@@ -60,6 +60,30 @@ const billingAddress = {
};
export const connectorDetails = {
+ real_time_payment_pm: {
+ DuitNow: {
+ Request: {
+ payment_method: "real_time_payment",
+ payment_method_type: "duit_now",
+ payment_method_data: {
+ real_time_payment: {
+ duit_now: {},
+ },
+ },
+ billing: billingAddress,
+ currency: "MYR",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ net_amount: 6000,
+ amount_received: null,
+ amount: 6000,
+ },
+ },
+ },
+ },
card_pm: {
PaymentIntent: {
Request: {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Iatapay.js b/cypress-tests/cypress/e2e/configs/Payment/Iatapay.js
index 18dab177f3..2015c9d208 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Iatapay.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Iatapay.js
@@ -55,6 +55,58 @@ export const connectorDetails = {
},
},
},
+ real_time_payment_pm: {
+ PaymentIntent: {
+ Configs: {
+ CONNECTOR_CREDENTIAL: {
+ specName: ["realTimePayment"],
+ value: "connector_2",
+ },
+ },
+ Request: {
+ currency: "MYR",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ },
+ DuitNow: {
+ Configs: {
+ CONNECTOR_CREDENTIAL: {
+ specName: ["realTimePayment"],
+ value: "connector_2",
+ },
+ },
+ Request: {
+ payment_method: "real_time_payment",
+ payment_method_type: "duit_now",
+ payment_method_data: {
+ real_time_payment: {
+ duit_now: {},
+ },
+ },
+ billing: {
+ ...billingAddress,
+ address: {
+ ...billingAddress.address,
+ country: "MY",
+ },
+ },
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ net_amount: 6000,
+ amount_received: null,
+ amount: 6000,
+ },
+ },
+ },
+ },
card_pm: {
ZeroAuthMandate: {
Response: {
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00030-RealTimePayment.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00030-RealTimePayment.cy.js
new file mode 100644
index 0000000000..7839c58eee
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/00030-RealTimePayment.cy.js
@@ -0,0 +1,62 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Real Time Payment", () => {
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("DuitNow automatic capture flow", () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "real_time_payment_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Payment Methods Call Test", () => {
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ it("Confirm DuitNow", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "real_time_payment_pm"
+ ]["DuitNow"];
+
+ cy.confirmRealTimePaymentCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+ });
+});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00033-PaymentsEligibilityAPI.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00034-PaymentsEligibilityAPI.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/spec/Payment/00033-PaymentsEligibilityAPI.cy.js
rename to cypress-tests/cypress/e2e/spec/Payment/00034-PaymentsEligibilityAPI.cy.js
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00030-DynamicFields.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00035-DynamicFields.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/spec/Payment/00030-DynamicFields.cy.js
rename to cypress-tests/cypress/e2e/spec/Payment/00035-DynamicFields.cy.js
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 985d5be415..14d7801520 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -3323,6 +3323,92 @@ Cypress.Commands.add(
}
);
+Cypress.Commands.add(
+ "confirmRealTimePaymentCallTest",
+ (confirmBody, data, confirm, globalState) => {
+ const {
+ Configs: configs = {},
+ Request: reqData,
+ Response: resData,
+ } = data || {};
+
+ const configInfo = execConfig(validateConfig(configs));
+ const paymentIntentID = globalState.get("paymentID");
+ const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);
+
+ for (const key in reqData) {
+ confirmBody[key] = reqData[key];
+ }
+ confirmBody.client_secret = globalState.get("clientSecret");
+ confirmBody.confirm = confirm;
+ confirmBody.profile_id = profile_id;
+
+ globalState.set("paymentMethodType", confirmBody.payment_method_type);
+
+ cy.request({
+ method: "POST",
+ url: `${globalState.get("baseUrl")}/payments/${paymentIntentID}/confirm`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": globalState.get("publishableKey"),
+ },
+ failOnStatusCode: false,
+ body: confirmBody,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ expect(response.headers["content-type"]).to.include("application/json");
+ if (response.status === 200) {
+ globalState.set("paymentID", paymentIntentID);
+
+ validateErrorMessage(response, resData);
+
+ if (
+ response.body.capture_method === "automatic" ||
+ response.body.capture_method === "manual"
+ ) {
+ switch (response.body.payment_method_type) {
+ case "duit_now":
+ if (response.body.connector === "fiuu")
+ expect(response.body)
+ .to.have.property("next_action")
+ .and.have.nested.property("image_data_url").and.not.be.null;
+ for (const key in resData.body) {
+ expect(resData.body[key], [key]).to.deep.equal(
+ response.body[key]
+ );
+ }
+ if (response.body.connector === "iatapay")
+ expect(response.body)
+ .to.have.property("next_action")
+ .to.have.property("redirect_to_url");
+ break;
+
+ default:
+ expect(response.body)
+ .to.have.property("next_action")
+ .to.have.property("image_data_url");
+ globalState.set(
+ "image_data_url",
+ response.body.next_action.redirect_to_url
+ );
+ globalState.set("nextActionType", "image_data_url");
+ break;
+ }
+ } else {
+ throw new Error(
+ `Invalid capture method ${response.body.capture_method}`
+ );
+ }
+ } else {
+ defaultErrorHandler(response, resData);
+ }
+ });
+ });
+ }
+);
+
Cypress.Commands.add(
"handleUpiRedirection",
(globalState, paymentMethodType, expected_redirection) => {