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

test(cypress): add coingate crypto payment coverage (#12699)

HS-QUALIBOT15c5c15b55ca
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Coingate.js b/cypress-tests/cypress/e2e/configs/Payment/Coingate.js
new file mode 100644
index 0000000000..b5f1745c33
--- /dev/null
+++ b/cypress-tests/cypress/e2e/configs/Payment/Coingate.js
@@ -0,0 +1,87 @@
+import { getCustomExchange } from "./Modifiers";
+import { standardBillingAddress } from "./Commons";
+
+const nlBillingAddress = {
+ ...standardBillingAddress,
+ address: {
+ ...standardBillingAddress.address,
+ line1: "Damrak 1",
+ line2: "",
+ line3: "",
+ city: "Amsterdam",
+ state: "NH",
+ zip: "1012 LG",
+ country: "NL",
+ first_name: "Jan",
+ last_name: "Jansen",
+ },
+ phone: {
+ number: "612345678",
+ country_code: "+31",
+ },
+};
+
+export const connectorDetails = {
+ crypto_pm: {
+ PaymentIntent: getCustomExchange({
+ Request: {
+ currency: "EUR",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ CryptoCurrency: getCustomExchange({
+ Request: {
+ payment_method: "crypto",
+ payment_method_type: "crypto_currency",
+ payment_method_data: {
+ crypto: {
+ network: "bitcoin",
+ pay_currency: "BTC",
+ },
+ },
+ billing: nlBillingAddress,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ }),
+ // Coingate does not support manual capture for crypto payments.
+ // The IR_19 error response causes should_continue_further() to return false
+ // (because Response.body contains an `error` object), which skips the
+ // redirect-handling and retrieve-payment steps in the spec.
+ CryptoCurrencyManualCapture: getCustomExchange({
+ Request: {
+ payment_method: "crypto",
+ payment_method_type: "crypto_currency",
+ payment_method_data: {
+ crypto: {
+ network: "bitcoin",
+ pay_currency: "BTC",
+ },
+ },
+ billing: nlBillingAddress,
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "No eligible connector was found for the current payment method configuration",
+ code: "IR_19",
+ },
+ },
+ },
+ }),
+ },
+};
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 30c3335931..b711623188 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -22,6 +22,7 @@ import { connectorDetails as cashtocodeConnectorDetails } from "./Cashtocode.js"
import { connectorDetails as celeroConnectorDetails } from "./Celero.js";
import { connectorDetails as checkbookConnectorDetails } from "./Checkbook.js";
import { connectorDetails as checkoutConnectorDetails } from "./Checkout.js";
+import { connectorDetails as coingateConnectorDetails } from "./Coingate.js";
import { connectorDetails as commonConnectorDetails } from "./Commons.js";
import { connectorDetails as cryptopayConnectorDetails } from "./Cryptopay.js";
import { connectorDetails as cybersourceConnectorDetails } from "./Cybersource.js";
@@ -102,6 +103,7 @@ const connectorDetails = {
checkout: checkoutConnectorDetails,
checkbook: checkbookConnectorDetails,
commons: commonConnectorDetails,
+ coingate: coingateConnectorDetails,
cryptopay: cryptopayConnectorDetails,
cybersource: cybersourceConnectorDetails,
dlocal: dlocalConnectorDetails,
@@ -641,6 +643,7 @@ export const CONNECTOR_LISTS = {
REFUND_MANUAL_UPDATE: ["bankofamerica", "cybersource"],
REFUND_TYPE: ["stripe", "adyen", "checkout"],
MANUAL_PAYMENT_UPDATE: ["stripe"],
+ CRYPTO_PAYMENT: ["bitpay", "coingate", "cryptopay"],
STEP_UP_RETRY: [
"cybersource",
"checkout",
diff --git a/cypress-tests/cypress/e2e/spec/Payment/39-CryptoPayment.cy.js b/cypress-tests/cypress/e2e/spec/Payment/39-CryptoPayment.cy.js
index b9d9c3f4d1..61608a14af 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/39-CryptoPayment.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/39-CryptoPayment.cy.js
@@ -5,12 +5,27 @@ import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
describe("Crypto Payment", () => {
+ let shouldContinue = true;
+
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
+ if (
+ !utils.CONNECTOR_LISTS.INCLUDE.CRYPTO_PAYMENT.includes(
+ globalState.get("connectorId")
+ )
+ ) {
+ shouldContinue = false;
+ }
});
});
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});
@@ -89,6 +104,9 @@ describe("Crypto Payment", () => {
});
});
+ // Manual capture is not supported by all crypto connectors (e.g. Coingate returns IR_19).
+ // The error response in the connector config causes should_continue_further() to return false,
+ // which skips the redirect-handling and retrieve-payment steps for unsupported connectors.
context("Crypto Currency manual capture flow", () => {
it("Create Payment Intent -> Payment Methods Call Test -> Confirm Crypto Currency Payment -> Handle redirection -> Retrieve Payment Call Test", () => {
let shouldContinue = true;
diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.js
index fd36379b83..206d186f95 100644
--- a/cypress-tests/cypress/support/redirectionHandler.js
+++ b/cypress-tests/cypress/support/redirectionHandler.js
@@ -26,6 +26,15 @@ const CONSTANTS = {
],
};
+const COINGATE_BILLING = {
+ email: "[email protected]",
+ firstName: "Jan",
+ lastName: "Jansen",
+ dobMonth: "1",
+ dobDay: "1",
+ dobYear: "1990",
+};
+
function normalizeConnectorForRedirect(connectorId) {
return connectorId === "stripeconnect" ? "stripe" : connectorId;
}
@@ -202,6 +211,139 @@ function cryptoRedirection(
.click();
cy.log("Submitted Bitpay login credentials");
+ } else if (connectorId === "coingate") {
+ cy.document().should("have.property", "readyState", "complete");
+ cy.title({ timeout: CONSTANTS.WAIT_TIME }).should("include", "CoinGate");
+ cy.log("Coingate payment page loaded");
+
+ // Wait for Next.js app to render the currency selection dropdown
+ cy.contains(/Select currency/i, { timeout: CONSTANTS.WAIT_TIME }).should(
+ "be.visible"
+ );
+ cy.log("Coingate currency selection screen rendered");
+
+ // Open the currency dropdown
+ cy.contains(/Select currency/i).click();
+ cy.log("Opened currency selector dropdown");
+
+ // Step 1: Select Bitcoin from the currency dropdown
+ cy.contains(/Bitcoin/i, { timeout: CONSTANTS.WAIT_TIME })
+ .first()
+ .should("be.visible")
+ .click();
+ cy.log("Selected Bitcoin as payment currency");
+
+ // Step 2: Wait briefly for any network selection modal to appear,
+ // then select Bitcoin mainchain if the modal is present.
+ cy.wait(2000);
+ cy.get("body").then(($body) => {
+ if ($body.text().includes("Select network")) {
+ cy.log(
+ "Network selection modal appeared - selecting Bitcoin mainchain"
+ );
+ cy.contains(/^Bitcoin$/i, { timeout: CONSTANTS.WAIT_TIME })
+ .should("be.visible")
+ .click();
+ cy.log("Selected Bitcoin mainchain network");
+ } else {
+ cy.log("No network selection modal - proceeding to Continue");
+ }
+ });
+
+ // Click Continue to proceed to the payment address screen
+ cy.contains(/Continue/i, { timeout: CONSTANTS.WAIT_TIME })
+ .should("be.visible")
+ .click();
+ cy.log("Clicked Continue on Coingate payment page");
+
+ handleFlow(
+ redirectionUrl,
+ expectedUrl,
+ connectorId,
+ // NOTE: this callback runs inside cy.origin — CONSTANTS and
+ // COINGATE_BILLING are not in scope. Use `constants` and
+ // `coingateBilling` from the destructured args instead.
+ ({ paymentMethodType, constants, coingateBilling }) => {
+ switch (paymentMethodType) {
+ case "crypto_currency": {
+ cy.log("Coingate Bitcoin payment: checking for KYC billing form");
+
+ cy.document().should("have.property", "readyState", "complete");
+
+ // Coingate may require billing details (KYC) before showing
+ // the BTC payment address. Fill the form if it appears.
+ cy.get("body").then(($body) => {
+ const bodyText = $body.text();
+ if (
+ bodyText.includes("Billing details") ||
+ bodyText.includes("First name")
+ ) {
+ cy.log("Billing details form detected - filling KYC fields");
+
+ // Email (optional, but fill it)
+ cy.get('input[type="email"]').then(($el) => {
+ if ($el.length > 0) {
+ cy.wrap($el.first())
+ .clear()
+ .type(coingateBilling.email);
+ }
+ });
+
+ // First name + Last name (inputs with latin-characters placeholder)
+ cy.get('input[placeholder*="latin"]').then(($inputs) => {
+ if ($inputs.length >= 1) {
+ cy.wrap($inputs.eq(0)).clear().type(coingateBilling.firstName);
+ }
+ if ($inputs.length >= 2) {
+ cy.wrap($inputs.eq(1)).clear().type(coingateBilling.lastName);
+ }
+ });
+
+ // Date of birth — select Month=January, Day=1, Year=1990
+ // Use jQuery .find() instead of cy.get("select") to avoid
+ // Cypress retry timeout when no <select> elements exist on
+ // the Coingate billing form.
+ const $selects = $body.find("select");
+ if ($selects.length >= 1) {
+ cy.wrap($selects.eq(0)).select(coingateBilling.dobMonth);
+ }
+ if ($selects.length >= 2) {
+ cy.wrap($selects.eq(1)).select(coingateBilling.dobDay);
+ }
+ if ($selects.length >= 3) {
+ cy.wrap($selects.eq(2)).select(coingateBilling.dobYear);
+ }
+
+ cy.wait(500);
+
+ // Submit the billing form
+ cy.contains(/Continue/i, { timeout: constants.WAIT_TIME })
+ .last()
+ .click();
+ cy.log("Billing form submitted");
+ cy.wait(3000);
+ } else {
+ cy.log("No billing form - proceeding to payment address");
+ }
+ });
+
+ // After the billing form (or if skipped), the BTC payment
+ // address screen should appear.
+ cy.contains(/Amount|BTC|address|0\./i, {
+ timeout: constants.WAIT_TIME,
+ }).should("be.visible");
+ cy.log("Coingate Bitcoin payment details displayed successfully");
+ break;
+ }
+
+ default:
+ throw new Error(
+ `Unsupported crypto payment method type: ${paymentMethodType}`
+ );
+ }
+ },
+ { paymentMethodType, coingateBilling: COINGATE_BILLING }
+ );
} else {
cy.get("canvas.BbpsQr__canvas", { timeout: 5000 })
.should("exist")