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
feat(cypress): add Truelayer open banking payout tests (#13706)
Vasantha75df14e9012
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Truelayer.js b/cypress-tests/cypress/e2e/configs/Payout/Truelayer.jsnew file mode 100644index 0000000000..845a5e9b93--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payout/Truelayer.js@@ -0,0 +1,228 @@+const billing = {+ address: {+ line1: "123 Main St",+ line2: "Apt 4B",+ city: "Los Angeles",+ state: "GB",+ zip: "90001",+ country: "NL",+ first_name: "John",+ last_name: "Doe",+ },+};++const passthrough_data = {+ psp_token: "0f03fd53-c3c9-5a84-a406-1082bfd65c7a",+ psp_customer_id: "a29d2d16-15e2-4b66-8646-bc29e206210a",+ token_type: "open_banking_uk",+};++const error = {+ type: "invalid_request",+ message: "Payout Eligibility for Truelayer is not implemented",+ code: "IR_00",+};++export const connectorDetails = {+ bank_transfer_pm: {+ open_banking: {+ Create: {+ Request: {+ amount: 10,+ currency: "GBP",+ payout_type: "bank_redirect",+ payout_method_data: {+ passthrough: passthrough_data,+ },+ billing: billing,+ billing_descriptor: {+ reference: "heellow-world",+ },+ },+ Response: {+ status: 200,+ body: {+ status: "requires_confirmation",+ payout_type: "bank_redirect",+ },+ },+ },+ Confirm: {+ Request: {+ amount: 10,+ currency: "GBP",+ payout_type: "bank_redirect",+ payout_method_data: {+ passthrough: passthrough_data,+ },+ billing: billing,+ billing_descriptor: {+ reference: "heellow-world",+ },+ },+ Response: {+ status: 200,+ body: {+ status: "requires_fulfillment",+ payout_type: "bank_redirect",+ },+ },+ },+ Fulfill: {+ Request: {+ amount: 10,+ currency: "GBP",+ payout_type: "bank_redirect",+ payout_method_data: {+ passthrough: passthrough_data,+ },+ billing: billing,+ billing_descriptor: {+ reference: "heellow-world",+ },+ },+ Response: {+ status: 200,+ body: {+ status: "initiated",+ payout_type: "bank_redirect",+ },+ },+ },+ SavePayoutMethod: {+ Request: {+ payment_method: "bank_transfer",+ payment_method_type: "open_banking",+ bank_transfer: passthrough_data,+ },+ Response: {+ status: 200,+ body: {+ payment_method: "bank_transfer",+ payment_method_type: "open_banking",+ status: "active",+ },+ },+ },+ Token: {+ Request: {+ payout_token: "token",+ payout_type: "bank",+ },+ Response: {+ status: 200,+ body: {+ status: "initiated",+ payout_type: "bank",+ },+ },+ },+ InvalidBillingDescriptorConfirm: {+ Request: {+ amount: 10,+ currency: "GBP",+ payout_type: "bank_redirect",+ payout_method_data: {+ passthrough: passthrough_data,+ },+ billing: billing,+ billing_descriptor: {+ reference: "heellow-world",+ },+ },+ Response: {+ status: 200,+ body: {+ status: "requires_fulfillment",+ payout_type: "bank_redirect",+ },+ },+ },+ InvalidBillingDescriptor: {+ Request: {+ billing_descriptor: {+ reference: "invalid reference!!!",+ },+ },+ Response: {+ status: 422,+ body: {+ error: {+ code: "IR_16",+ message:+ "alphanumeric, hyphen, or period and length between 1 and 18 characters",+ },+ },+ },+ },+ },+ sepa_bank_transfer: {+ Create: {+ Configs: {+ TRIGGER_SKIP: true,+ },+ Request: {+ currency: "EUR",+ payout_type: "bank",+ payout_method_data: {+ bank_transfer: {+ payout_method_type: "sepa_bank_transfer",+ iban: "DE57331060435647542639",+ },+ },+ billing: billing,+ },+ Response: {+ status: 501,+ body: {+ error: error,+ },+ },+ },+ Confirm: {+ Configs: {+ TRIGGER_SKIP: true,+ },+ Request: {+ currency: "EUR",+ payout_type: "bank",+ payout_method_data: {+ bank_transfer: {+ payout_method_type: "sepa_bank_transfer",+ iban: "DE57331060435647542639",+ },+ },+ billing: billing,+ },+ Response: {+ status: 501,+ body: {+ error: error,+ },+ },+ },+ Fulfill: {+ Configs: {+ TRIGGER_SKIP: true,+ },+ Request: {+ currency: "EUR",+ payout_type: "bank",+ payout_method_data: {+ bank_transfer: {+ payout_method_type: "sepa_bank_transfer",+ iban: "DE57331060435647542639",+ },+ },+ billing: billing,+ },+ Response: {+ status: 501,+ body: {+ error: error,+ },+ },+ },+ },+ },+};diff --git a/cypress-tests/cypress/e2e/configs/Payout/Utils.js b/cypress-tests/cypress/e2e/configs/Payout/Utils.jsindex 6a59e02eb5..c40717503a 100644--- a/cypress-tests/cypress/e2e/configs/Payout/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payout/Utils.js@@ -5,13 +5,15 @@ import { connectorDetails as adyenPlatformConnectorDetails } from "./AdyenPlatfoimport { connectorDetails as CommonConnectorDetails } from "./Commons.js";import { connectorDetails as wiseConnectorDetails } from "./Wise.js";import { connectorDetails as nomupayConnectorDetails } from "./Nomupay.js";+import { connectorDetails as truelayerConnectorDetails } from "./Truelayer.js";const connectorDetails = {adyen: adyenConnectorDetails,adyenplatform: adyenPlatformConnectorDetails,commons: CommonConnectorDetails,- wise: wiseConnectorDetails,nomupay: nomupayConnectorDetails,+ truelayer: truelayerConnectorDetails,+ wise: wiseConnectorDetails,};export function getConnectorDetails(connectorId) {@@ -95,6 +97,11 @@ export const CONNECTOR_LISTS = {// Payout recurring feature - only verified connectorsPAYOUT_RECURRING: ["adyenplatform"],PAYOUT_LINK: ["wise"],+ BANK_TRANSFER_OPEN_BANKING: ["truelayer"],+ BANK_TRANSFER_OPEN_BANKING_INVALID_REFERENCE_FULFILL: [],+ BANK_TRANSFER_SEPA: ["adyen", "adyenplatform", "nomupay", "wise"],+ SAVED_CARD: ["adyen", "adyenplatform", "nomupay", "wise"],+ SAVED_BANK_TRANSFER_SEPA: ["adyen", "adyenplatform", "nomupay", "wise"],},};diff --git a/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.jsindex c98af3eb7b..3710fa9fea 100644--- a/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js@@ -59,15 +59,28 @@ describe.skip("[Payout] [Bank Transfer - BACS]", () => {describe("[Payout] [Bank Transfer - SEPA]", () => {let shouldContinue = true; // variable that will be used to skip tests if a previous test fails- before("seed global state", () => {- cy.task("getGlobalState").then((state) => {- globalState = new State(state);+ before("seed global state", function () {+ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);- // Check if the connector supports card payouts (based on the connector configuration in creds)- if (!globalState.get("payoutsExecution")) {- shouldContinue = false;- }- });+ if (!globalState.get("payoutsExecution")) {+ shouldContinue = false;+ }++ if (+ !utils.CONNECTOR_LISTS.INCLUDE.BANK_TRANSFER_SEPA.includes(+ globalState.get("connectorId")+ )+ ) {+ shouldContinue = false;+ }+ })+ .then(() => {+ if (!shouldContinue) {+ this.skip();+ }+ });});after("flush global state", () => {@@ -151,3 +164,171 @@ describe("[Payout] [Bank Transfer - SEPA]", () => {});});});++describe("[Payout] [Bank Transfer - Open Banking]", () => {+ let shouldContinue = true;++ before("seed global state", function () {+ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);++ if (!globalState.get("payoutsExecution")) {+ shouldContinue = false;+ }++ if (+ !utils.CONNECTOR_LISTS.INCLUDE.BANK_TRANSFER_OPEN_BANKING.includes(+ globalState.get("connectorId")+ )+ ) {+ shouldContinue = false;+ }+ })+ .then(() => {+ if (!shouldContinue) {+ this.skip();+ }+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ context("[Payout] [Bank transfer - Open Banking] Auto Fulfill", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("confirm-payout-call-with-auto-fulfill-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["Fulfill"];++ cy.createConfirmPayoutTest(+ fixtures.createPayoutBody,+ data,+ true,+ true,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-call-test", () => {+ cy.retrievePayoutCallTest(globalState);+ });+ });++ context("[Payout] [Bank transfer - Open Banking] Manual Fulfill", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create customer", () => {+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);+ });++ it("confirm-payout-call-with-manual-fulfill-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["Confirm"];++ cy.createConfirmPayoutTest(+ fixtures.createPayoutBody,+ data,+ true,+ false,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-call-test", () => {+ cy.retrievePayoutCallTest(globalState);+ });+ });++ context(+ "[Payout] [Bank transfer - Open Banking] Create without confirm",+ () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-without-confirm-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["Create"];++ cy.createConfirmPayoutTest(+ fixtures.createPayoutBody,+ data,+ false,+ false,+ globalState+ );+ if (shouldContinue)+ shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-call-test", () => {+ cy.retrievePayoutCallTest(globalState);+ });+ }+ );++ if (+ utils.CONNECTOR_LISTS.INCLUDE.BANK_TRANSFER_OPEN_BANKING_INVALID_REFERENCE_FULFILL.includes(+ Cypress.env("CONNECTOR")+ )+ ) {+ context(+ "[Payout] [Bank transfer - Open Banking] Invalid Billing Descriptor",+ () => {+ const shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-with-invalid-billing-descriptor-test", () => {+ const data = utils.getConnectorDetails(+ globalState.get("connectorId")+ )["bank_transfer_pm"]["open_banking"][+ "InvalidBillingDescriptorConfirm"+ ];++ cy.createConfirmPayoutTest(+ fixtures.createPayoutBody,+ data,+ true,+ false,+ globalState+ );+ });+ }+ );+ }+});diff --git a/cypress-tests/cypress/e2e/spec/Payout/00005-SavePayout.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00005-SavePayout.cy.jsindex ba9cbc5892..3e18fe7982 100644--- a/cypress-tests/cypress/e2e/spec/Payout/00005-SavePayout.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payout/00005-SavePayout.cy.js@@ -8,15 +8,28 @@ let payoutBody;describe("[Payout] Saved Card", () => {let shouldContinue = true; // variable that will be used to skip tests if a previous test fails- before("seed global state", () => {- cy.task("getGlobalState").then((state) => {- globalState = new State(state);-- // Check if the connector supports card payouts (based on the connector configuration in creds)- if (!globalState.get("payoutsExecution")) {- shouldContinue = false;- }- });+ before("seed global state", function () {+ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);++ if (!globalState.get("payoutsExecution")) {+ shouldContinue = false;+ }++ if (+ !utils.CONNECTOR_LISTS.INCLUDE.SAVED_CARD.includes(+ globalState.get("connectorId")+ )+ ) {+ shouldContinue = false;+ }+ })+ .then(() => {+ if (!shouldContinue) {+ this.skip();+ }+ });});after("flush global state", () => {@@ -131,15 +144,28 @@ describe("[Payout] Saved Card", () => {describe("[Payout] Saved Bank transfer", () => {let shouldContinue = true; // variable that will be used to skip tests if a previous test fails- before("seed global state", () => {- cy.task("getGlobalState").then((state) => {- globalState = new State(state);+ before("seed global state", function () {+ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);- // Check if the connector supports card payouts (based on the connector configuration in creds)- if (!globalState.get("payoutsExecution")) {- shouldContinue = false;- }- });+ if (!globalState.get("payoutsExecution")) {+ shouldContinue = false;+ }++ if (+ !utils.CONNECTOR_LISTS.INCLUDE.SAVED_BANK_TRANSFER_SEPA.includes(+ globalState.get("connectorId")+ )+ ) {+ shouldContinue = false;+ }+ })+ .then(() => {+ if (!shouldContinue) {+ this.skip();+ }+ });});after("flush global state", () => {diff --git a/cypress-tests/cypress/e2e/spec/Payout/00006-PayoutUsingPayoutMethodId.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00006-PayoutUsingPayoutMethodId.cy.jsindex 1307e2809c..d073cd4d55 100644--- a/cypress-tests/cypress/e2e/spec/Payout/00006-PayoutUsingPayoutMethodId.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payout/00006-PayoutUsingPayoutMethodId.cy.js@@ -8,15 +8,28 @@ let payoutBody;describe("[Payout] Saved Bank transfer", () => {let shouldContinue = true; // variable that will be used to skip tests if a previous test fails- before("seed global state", () => {- cy.task("getGlobalState").then((state) => {- globalState = new State(state);-- // Check if the connector supports card payouts (based on the connector configuration in creds)- if (!globalState.get("payoutsExecution")) {- shouldContinue = false;- }- });+ before("seed global state", function () {+ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);++ if (!globalState.get("payoutsExecution")) {+ shouldContinue = false;+ }++ if (+ !utils.CONNECTOR_LISTS.INCLUDE.SAVED_BANK_TRANSFER_SEPA.includes(+ globalState.get("connectorId")+ )+ ) {+ shouldContinue = false;+ }+ })+ .then(() => {+ if (!shouldContinue) {+ this.skip();+ }+ });});after("flush global state", () => {diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 5ed9cab32a..04a83f7c69 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -2017,15 +2017,31 @@ Cypress.Commands.add(createConnectorBody.connector_type = "payout_processor";createConnectorBody.profile_id = globalState.get("profileId");+ if (connectorName === "truelayer") {+ createConnectorBody.test_mode = false;+ }+// 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 codecy.readFile(globalState.get("connectorAuthFilePath")).then((jsonContent) => {- const { authDetails } = getValueByKey(- JSON.stringify(jsonContent),+ const authFileContent = JSON.stringify(jsonContent);+ let { authDetails } = getValueByKey(+ authFileContent,`${connectorName}_payout`);+ if (connectorName === "truelayer") {+ const { authDetails: truelayerAuthDetails } = getValueByKey(+ authFileContent,+ connectorName+ );++ if (truelayerAuthDetails !== null) {+ authDetails = truelayerAuthDetails;+ }+ }+// If the connector does not have payout connector creds in creds file, set payoutsExecution to falseif (authDetails === null) {globalState.set("payoutsExecution", false);@@ -6726,15 +6742,16 @@ Cypress.Commands.add(createConfirmPayoutBody.auto_fulfill = auto_fulfill;createConfirmPayoutBody.confirm = confirm;createConfirmPayoutBody.customer_id = globalState.get("customerId");+ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };return cy.request({method: "POST",url: `${globalState.get("baseUrl")}/payouts/create`,- headers: {- "Content-Type": "application/json",- "api-key": globalState.get("apiKey"),- },+ headers,failOnStatusCode: false,body: createConfirmPayoutBody,})@@ -6775,14 +6792,15 @@ Cypress.Commands.add(createConfirmPayoutBody.payout_token = globalState.get("paymentToken");createConfirmPayoutBody.auto_fulfill = auto_fulfill;createConfirmPayoutBody.confirm = confirm;+ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };cy.request({method: "POST",url: `${globalState.get("baseUrl")}/payouts/create`,- headers: {- "Content-Type": "application/json",- "api-key": globalState.get("apiKey"),- },+ headers,failOnStatusCode: false,body: createConfirmPayoutBody,}).then((response) => {@@ -6818,14 +6836,15 @@ Cypress.Commands.add(createConfirmPayoutBody.confirm = confirm;createConfirmPayoutBody.payout_method_id = globalState.data.paymentMethodId;delete createConfirmPayoutBody.payout_token;+ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };cy.request({method: "POST",url: `${globalState.get("baseUrl")}/payouts/create`,- headers: {- "Content-Type": "application/json",- "api-key": globalState.get("apiKey"),- },+ headers,failOnStatusCode: false,body: createConfirmPayoutBody,}).then((response) => {@@ -6854,14 +6873,15 @@ Cypress.Commands.add(const { Response: resData } = data || {};payoutFulfillBody.payout_id = globalState.get("payoutID");+ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };cy.request({method: "POST",url: `${globalState.get("baseUrl")}/payouts/${globalState.get("payoutID")}/fulfill`,- headers: {- "Content-Type": "application/json",- "api-key": globalState.get("apiKey"),- },+ headers,failOnStatusCode: false,body: payoutFulfillBody,}).then((response) => {