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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
ci(cypress): add cryptopay connector (#10812)
likhinbopanna0a436e7221e8
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex 0ec397477e..1d9f2b767b 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -432,6 +432,22 @@ export const payment_methods_enabled = [},],},+ {+ payment_method: "crypto",+ payment_method_types: [+ {+ payment_method_type: "crypto_currency",+ payment_experience: "redirect_to_url",+ card_networks: null,+ accepted_currencies: null,+ accepted_countries: null,+ minimum_amount: 0,+ maximum_amount: 68607706,+ recurring_enabled: true,+ installment_payment_enabled: false,+ },+ ],+ },];export const connectorDetails = {@@ -1958,6 +1974,47 @@ export const connectorDetails = {},}),},+ crypto_pm: {+ PaymentIntent: getCustomExchange({+ Request: {+ currency: "USD",+ 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: standardBillingAddress,+ },+ }),+ CryptoCurrencyManualCapture: getCustomExchange({+ Request: {+ payment_method: "crypto",+ payment_method_type: "crypto_currency",+ payment_method_data: {+ crypto: {+ network: "bitcoin",+ pay_currency: "BTC",+ },+ },+ billing: standardBillingAddress,+ },+ }),+ },pm_list: {PmListResponse: {PmListNull: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Cryptopay.js b/cypress-tests/cypress/e2e/configs/Payment/Cryptopay.jsnew file mode 100644index 0000000000..b0294bc008--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payment/Cryptopay.js@@ -0,0 +1,118 @@+import { standardBillingAddress } from "./Commons";++const successfulNo3DSCardDetails = {+ card_number: "4111111111111111",+ card_exp_month: "03",+ card_exp_year: "30",+ card_holder_name: "John Doe",+ card_cvc: "737",+};++export const connectorDetails = {+ crypto_pm: {+ PaymentIntent: {+ Request: {+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ },+ CryptoCurrency: {+ Request: {+ payment_method: "crypto",+ payment_method_type: "crypto_currency",+ payment_method_data: {+ crypto: {+ network: "bitcoin",+ pay_currency: "BTC",+ },+ },+ billing: standardBillingAddress,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ },+ },+ },+ CryptoCurrencyManualCapture: {+ Request: {+ payment_method: "crypto",+ payment_method_type: "crypto_currency",+ payment_method_data: {+ crypto: {+ network: "bitcoin",+ pay_currency: "BTC",+ },+ },+ billing: standardBillingAddress,+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message: "Payment method type not supported",+ code: "IR_19",+ reason: "manual is not supported by cryptopay",+ },+ },+ },+ },+ },+ card_pm: {+ ZeroAuthMandate: {+ Response: {+ status: 501,+ body: {+ error: {+ type: "invalid_request",+ message: "Setup Mandate flow for Cryptopay is not implemented",+ code: "IR_00",+ },+ },+ },+ },+ ZeroAuthPaymentIntent: {+ Request: {+ amount: 0,+ setup_future_usage: "off_session",+ currency: "USD",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ setup_future_usage: "off_session",+ },+ },+ },+ ZeroAuthConfirmPayment: {+ Request: {+ payment_type: "setup_mandate",+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ },+ Response: {+ status: 501,+ body: {+ error: {+ type: "invalid_request",+ message: "Setup Mandate flow for Cryptopay is not implemented",+ code: "IR_00",+ },+ },+ },+ },+ },+};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Elavon.js b/cypress-tests/cypress/e2e/configs/Payment/Elavon.jsindex c1db250788..2620aae73b 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Elavon.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Elavon.js@@ -3,7 +3,7 @@ import customerAcceptance from "./Commons";const successfulNo3DSCardDetails = {card_number: "4111111111111111",card_exp_month: "06",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "joseph Doe",card_cvc: "123",};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Payload.js b/cypress-tests/cypress/e2e/configs/Payment/Payload.jsindex fa01fdf0b2..595d469302 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Payload.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Payload.js@@ -11,7 +11,7 @@ const DUPLICATION_TIMEOUT = 30000; // 30 secondsconst successfulNo3DSCardDetails = {card_number: "4242424242424242",card_exp_month: "12",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "John Doe",card_cvc: "123",};@@ -23,7 +23,7 @@ const successfulThreeDSTestCardDetails = {const failedNo3DSCardDetails = {card_number: "4111111111119903",card_exp_month: "01",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "John Doe",card_cvc: "123",};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Paysafe.js b/cypress-tests/cypress/e2e/configs/Payment/Paysafe.jsindex 95ec7e02d8..112308efe4 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Paysafe.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Paysafe.js@@ -3,7 +3,7 @@ import { customerAcceptance } from "./Commons";const successfulNo3DSCardDetails = {card_number: "4530910000012345",card_exp_month: "10",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "John",card_cvc: "111",};@@ -11,7 +11,7 @@ const successfulNo3DSCardDetails = {const successfulNoThreeDsCardDetailsRequest = {card_number: "4530910000012345",card_exp_month: "10",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "John",card_cvc: "111",};@@ -19,7 +19,7 @@ const successfulNoThreeDsCardDetailsRequest = {const successfulThreeDSTestCardDetails = {card_number: "4000000000001091",card_exp_month: "10",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "Joseph",card_cvc: "111",};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Redsys.js b/cypress-tests/cypress/e2e/configs/Payment/Redsys.jsindex 5b3ecec03a..469dad934d 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Redsys.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Redsys.js@@ -3,7 +3,7 @@ import { getCustomExchange } from "./Modifiers";const ThreeDSChallengeTestCardDetails = {card_number: "4548817212493017",card_exp_month: "12",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "Joseph",card_cvc: "123",};@@ -11,7 +11,7 @@ const ThreeDSChallengeTestCardDetails = {const threeDSFrictionlessTestCardDetails = {card_number: "4548814479727229",card_exp_month: "12",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "Joseph",card_cvc: "123",};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 41418b8840..a048323d52 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -20,6 +20,7 @@ import { connectorDetails as celeroConnectorDetails } from "./Celero.js";import { connectorDetails as checkbookConnectorDetails } from "./Checkbook.js";import { connectorDetails as checkoutConnectorDetails } from "./Checkout.js";import { connectorDetails as commonConnectorDetails } from "./Commons.js";+import { connectorDetails as cryptopayConnectorDetails } from "./Cryptopay.js";import { connectorDetails as cybersourceConnectorDetails } from "./Cybersource.js";import { connectorDetails as datatransConnectorDetails } from "./Datatrans.js";import { connectorDetails as deutschebankConnectorDetails } from "./Deutschebank.js";@@ -87,6 +88,7 @@ const connectorDetails = {checkout: checkoutConnectorDetails,checkbook: checkbookConnectorDetails,commons: commonConnectorDetails,+ cryptopay: cryptopayConnectorDetails,cybersource: cybersourceConnectorDetails,dlocal: dlocalConnectorDetails,datatrans: datatransConnectorDetails,diff --git a/cypress-tests/cypress/e2e/spec/Payment/00037-CryptoPayment.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00037-CryptoPayment.cy.jsnew file mode 100644index 0000000000..0899c24724--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/00037-CryptoPayment.cy.js@@ -0,0 +1,129 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Crypto Payment", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("Crypto Currency Payment 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"))[+ "crypto_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 Crypto Currency Payment", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "crypto_pm"+ ]["CryptoCurrency"];++ cy.confirmRewardCallTest(fixtures.confirmBody, data, true, globalState);++ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("Handle redirection", () => {+ const expected_redirection = fixtures.confirmBody["return_url"];+ const payment_method_type = globalState.get("paymentMethodType");+ cy.handleCryptoRedirection(+ globalState,+ payment_method_type,+ expected_redirection+ );+ });++ it("Retrieve Payment Call Test", () => {+ cy.retrievePaymentCallTest(globalState);+ });+ });++ context("Crypto Currency manual capture flow", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "crypto_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ globalState+ );++ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("Payment Methods Call Test", () => {+ cy.paymentMethodsCallTest(globalState);+ });++ it("Confirm Crypto Currency Payment", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "crypto_pm"+ ]["CryptoCurrencyManualCapture"];++ cy.confirmRewardCallTest(fixtures.confirmBody, data, true, globalState);++ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("Handle redirection", () => {+ const expected_redirection = fixtures.confirmBody["return_url"];+ const payment_method_type = globalState.get("paymentMethodType");+ cy.handleCryptoRedirection(+ globalState,+ payment_method_type,+ expected_redirection+ );+ });++ it("Retrieve Payment Call Test", () => {+ cy.retrievePaymentCallTest(globalState);+ });+ });+});diff --git a/cypress-tests/cypress/e2e/spec/Payment/00037-DynamicFields.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00038-DynamicFields.cy.jssimilarity index 100%rename from cypress-tests/cypress/e2e/spec/Payment/00037-DynamicFields.cy.jsrename to cypress-tests/cypress/e2e/spec/Payment/00038-DynamicFields.cy.jsdiff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 338dfa93a4..8888b81a6f 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -3722,6 +3722,24 @@ Cypress.Commands.add(});+Cypress.Commands.add(+ "handleCryptoRedirection",+ (globalState, paymentMethodType, expectedRedirection) => {+ const connectorId = globalState.get("connectorId");+ const nextActionUrl = globalState.get("nextActionUrl");++ const expectedUrl = new URL(expectedRedirection);+ const redirectionUrl = new URL(nextActionUrl);++ handleRedirection(+ "crypto",+ { redirectionUrl, expectedUrl },+ connectorId,+ paymentMethodType+ );+ }+);+Cypress.Commands.add("confirmRealTimePaymentCallTest",(confirmBody, data, confirm, globalState) => {diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex cf4ba5ae9d..e16ea17977 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -70,11 +70,68 @@ export function handleRedirection(paymentMethodType);break;+ case "crypto":+ cryptoRedirection(+ urls.redirectionUrl,+ urls.expectedUrl,+ connectorId,+ paymentMethodType+ );+ break;default:throw new Error(`Unknown redirection type: ${redirectionType}`);}}+function cryptoRedirection(+ redirectionUrl,+ expectedUrl,+ connectorId,+ paymentMethodType+) {+ // Crypto payments are async → never verify return URL+ const verifyUrl = false;++ if (redirectionUrl && redirectionUrl.href) {+ cy.visit(redirectionUrl.href);++ // Ensure redirect happened+ waitForRedirect(redirectionUrl.href);++ cy.wait(CONSTANTS.WAIT_TIME / 5);++ // Verify QR is present+ cy.get("canvas.BbpsQr__canvas", { timeout: 5000 })+ .should("exist")+ .and("be.visible");++ handleFlow(+ redirectionUrl,+ expectedUrl,+ connectorId,+ ({ paymentMethodType }) => {+ switch (paymentMethodType) {+ case "crypto_currency":+ cy.log("Handling crypto currency payment redirection");+ break;++ default:+ throw new Error(+ `Unsupported crypto payment method type: ${paymentMethodType}`+ );+ }+ },+ { paymentMethodType }+ );+ } else {+ cy.log("Skipping crypto redirection - no valid redirect URL provided");+ }++ cy.then(() => {+ verifyReturnUrl(redirectionUrl, expectedUrl, verifyUrl);+ });+}+function bankTransferRedirection(redirectionUrl,expectedUrl,