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): [Trustly] fix payout and payment UCS flows with webhook rollout configs (#14402)
Vasanth59dbf6b60c08
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Trustly.js b/cypress-tests/cypress/e2e/configs/Payout/Trustly.jsnew file mode 100644index 0000000000..7ca8a31def--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payout/Trustly.js@@ -0,0 +1,152 @@+const billing = {+ address: {+ city: "Stockholm",+ country: "SE",+ line1: "Main street 1",+ line2: "Main street 2",+ zip: "SE-11253",+ state: "SE",+ first_name: "Steve",+ last_name: "Smith",+ },+ email: "[email protected]",+ phone: {+ number: "709876543",+ country_code: "+46",+ },+};++const bank_payout_method_data = {+ bank: {+ country_code: "SE",+ account_number: "69706212",+ bank_number: "6112",+ iban: null,+ },+};++const invalid_bank_payout_method_data = {+ bank: {+ country_code: "SE",+ account_number: "AASSSRMFKF",+ bank_number: "6112",+ iban: null,+ },+};++export const connectorDetails = {+ bank_transfer_pm: {+ open_banking: {+ Create: {+ Request: {+ amount: 10,+ currency: "EUR",+ payout_type: "bank",+ payout_method_data: bank_payout_method_data,+ billing: billing,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_confirmation",+ payout_type: "bank",+ },+ },+ },+ Confirm: {+ Request: {+ amount: 10,+ currency: "EUR",+ payout_type: "bank",+ payout_method_data: bank_payout_method_data,+ billing: billing,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_fulfillment",+ payout_type: "bank",+ },+ },+ },+ Fulfill: {+ Request: {+ amount: 10,+ currency: "EUR",+ payout_type: "bank",+ payout_method_data: bank_payout_method_data,+ billing: billing,+ },+ Response: {+ status: 200,+ body: {+ status: "initiated",+ payout_type: "bank",+ },+ },+ },+ RetrieveAfterFulfill: {+ Response: {+ status: 200,+ body: {+ status: "success",+ payout_type: "bank",+ },+ },+ },+ InvalidAccountNumber: {+ Request: {+ amount: 10,+ currency: "EUR",+ payout_type: "bank",+ payout_method_data: invalid_bank_payout_method_data,+ billing: billing,+ },+ Response: {+ status: 200,+ body: {+ status: "failed",+ error_code: "624",+ error_message: "ERROR_INVALID_BANK_ACCOUNT_NUMBER",+ },+ },+ },+ ConfirmWithoutBilling: {+ Request: {+ amount: 10,+ currency: "EUR",+ payout_type: "bank",+ payout_method_data: bank_payout_method_data,+ billing: null,+ },+ Response: {+ status: 200,+ body: {+ status: "initiated",+ payout_type: "bank",+ },+ },+ },+ // No SavePayoutMethod key: POST /payment_methods cannot vault a+ // trustly-typed bank transfer (v1 validate() allows trustly only under+ // bank_redirect) - recipients get saved via a recurring payout instead+ // (see 00005-SavePayout.cy.js).+ Token: {+ Request: {+ amount: 10,+ currency: "EUR",+ payout_token: "token",+ payout_type: "bank",+ billing: billing,+ },+ Response: {+ status: 200,+ body: {+ status: "initiated",+ payout_type: "bank",+ },+ },+ },+ },+ },+};diff --git a/cypress-tests/cypress/e2e/configs/Payout/Utils.js b/cypress-tests/cypress/e2e/configs/Payout/Utils.jsindex 14385da6b1..329f75b49f 100644--- a/cypress-tests/cypress/e2e/configs/Payout/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payout/Utils.js@@ -7,6 +7,7 @@ import { connectorDetails as gotymeSanlamConnectorDetails } from "./GotymeSanlamimport { connectorDetails as wiseConnectorDetails } from "./Wise.js";import { connectorDetails as nomupayConnectorDetails } from "./Nomupay.js";import { connectorDetails as truelayerConnectorDetails } from "./Truelayer.js";+import { connectorDetails as trustlyConnectorDetails } from "./Trustly.js";const connectorDetails = {adyen: adyenConnectorDetails,@@ -15,6 +16,7 @@ const connectorDetails = {gotyme_sanlam: gotymeSanlamConnectorDetails,nomupay: nomupayConnectorDetails,truelayer: truelayerConnectorDetails,+ trustly: trustlyConnectorDetails,wise: wiseConnectorDetails,};@@ -99,20 +101,24 @@ export const CONNECTOR_LISTS = {// gotyme_sanlam only supports bank transfer payouts (payshap /// payshap_proxy) and has no card payout method, so it is skipped for// the card payout tests in 00003-CardTest.cy.js- CARD_TEST: ["gotyme_sanlam"],+ CARD_TEST: ["gotyme_sanlam", "trustly"],},INCLUDE: {ENTITY_TYPE: ["wise"],// Payout recurring feature - only verified connectorsPAYOUT_RECURRING: ["adyenplatform"],PAYOUT_LINK: ["wise"],- BANK_TRANSFER_OPEN_BANKING: ["truelayer"],+ BANK_TRANSFER_OPEN_BANKING: ["truelayer", "trustly"],BANK_TRANSFER_OPEN_BANKING_INVALID_REFERENCE_FULFILL: [],+ BANK_TRANSFER_OPEN_BANKING_MANUAL_FULFILL: ["trustly"],+ BANK_TRANSFER_OPEN_BANKING_INVALID_ACCOUNT_NUMBER: ["trustly"],+ BANK_TRANSFER_OPEN_BANKING_NO_BILLING: ["trustly"],BANK_TRANSFER_PAYSHAP: ["gotyme_sanlam"],BANK_TRANSFER_PAYSHAP_PROXY: ["gotyme_sanlam"],BANK_TRANSFER_SEPA: ["adyen", "adyenplatform", "nomupay", "wise"],SAVED_CARD: ["adyen", "adyenplatform", "nomupay", "wise"],SAVED_BANK_TRANSFER_SEPA: ["adyen", "adyenplatform", "nomupay", "wise"],+ SAVED_BANK_TRANSFER_OPEN_BANKING: ["trustly"],},};diff --git a/cypress-tests/cypress/e2e/spec/Payment/18-BankRedirect.cy.js b/cypress-tests/cypress/e2e/spec/Payment/18-BankRedirect.cy.jsindex c0f8b93be9..4e4ad43c36 100644--- a/cypress-tests/cypress/e2e/spec/Payment/18-BankRedirect.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/18-BankRedirect.cy.js@@ -735,7 +735,31 @@ describe("Bank Redirect tests", () => {cy.step("Setup UCS rollout config", () => {// Trustly is UCS-only; this enables the Trustly authorize flow in primary mode.- cy.createRolloutConfig(globalState, "bank_redirect_trustly_Authorize");+ if (!globalState.get("ucsEnabled")) {+ cy.task(+ "cli_log",+ "Setup UCS rollout config: UCS_ENABLED env not set - auto-enabling UCS for trustly (UCS-only connector)"+ );+ globalState.set("ucsEnabled", true);+ }++ cy.setupConfigs(globalState, "ucs_enabled", "true");++ const proxyHttp = globalState.get("proxyHttp");+ const proxyHttps = globalState.get("proxyHttps");+ cy.createRolloutConfig(globalState, "bank_redirect_trustly_Authorize", {+ rollout_percent: 1.0,+ execution_mode: "primary",+ ...(proxyHttp && proxyHttps+ ? { http_url: proxyHttp, https_url: proxyHttps }+ : {}),+ });++ cy.createRolloutConfig(globalState, "Webhooks", {+ rollout_percent: 1.0,+ execution_mode: "primary",+ webhook_flows: ["Payment"],+ });});cy.step("Create Payment Intent", () => {diff --git a/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.jsindex e673bf9779..79b0e46e20 100644--- a/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js@@ -202,6 +202,30 @@ describe("[Payout] [Bank Transfer - Open Banking]", () => {}});+ context("[Payout] [Bank transfer - Open Banking] UCS config setup", () => {+ it("create-ucs-configs-call-test", function () {+ if (globalState.get("connectorId") !== "trustly") {+ this.skip();+ }++ if (!globalState.get("ucsEnabled")) {+ cy.task(+ "cli_log",+ "create-ucs-configs-call-test: UCS_ENABLED env not set - auto-enabling UCS for trustly (UCS-only connector)"+ );+ globalState.set("ucsEnabled", true);+ }++ cy.setupConfigs(globalState, "ucs_enabled", "true");++ cy.createRolloutConfig(globalState, "Webhooks", {+ rollout_percent: 1.0,+ execution_mode: "primary",+ webhook_flows: ["Payout"],+ });+ });+ });+context("[Payout] [Bank transfer - Open Banking] Auto Fulfill", () => {let shouldContinue = true;@@ -227,7 +251,14 @@ describe("[Payout] [Bank Transfer - Open Banking]", () => {});it("retrieve-payout-call-test", () => {- cy.retrievePayoutCallTest(globalState);+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["RetrieveAfterFulfill"];++ if (data) {+ cy.pollPayoutStatusCallTest(globalState);+ }+ cy.retrievePayoutCallTest(globalState, data);});});@@ -259,8 +290,31 @@ describe("[Payout] [Bank Transfer - Open Banking]", () => {if (shouldContinue) shouldContinue = utils.should_continue_further(data);});+ if (+ utils.CONNECTOR_LISTS.INCLUDE.BANK_TRANSFER_OPEN_BANKING_MANUAL_FULFILL.includes(+ Cypress.env("CONNECTOR")+ )+ ) {+ it("fulfill-payout-call-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["Fulfill"];++ cy.fulfillPayoutCallTest({}, data, globalState);+ if (shouldContinue)+ shouldContinue = utils.should_continue_further(data);+ });+ }+it("retrieve-payout-call-test", () => {- cy.retrievePayoutCallTest(globalState);+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["RetrieveAfterFulfill"];++ if (data) {+ cy.pollPayoutStatusCallTest(globalState);+ }+ cy.retrievePayoutCallTest(globalState, data);});});@@ -297,6 +351,87 @@ describe("[Payout] [Bank Transfer - Open Banking]", () => {});+ if (+ utils.CONNECTOR_LISTS.INCLUDE.BANK_TRANSFER_OPEN_BANKING_INVALID_ACCOUNT_NUMBER.includes(+ Cypress.env("CONNECTOR")+ )+ ) {+ context(+ "[Payout] [Bank transfer - Open Banking] Invalid Account Number",+ () => {+ const shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-with-invalid-account-number-test", () => {+ const data = utils.getConnectorDetails(+ globalState.get("connectorId")+ )["bank_transfer_pm"]["open_banking"]["InvalidAccountNumber"];++ cy.createConfirmPayoutTest(+ Cypress._.cloneDeep(fixtures.createPayoutBody),+ data,+ true,+ true,+ globalState+ );+ });+ }+ );+ }++ if (+ utils.CONNECTOR_LISTS.INCLUDE.BANK_TRANSFER_OPEN_BANKING_NO_BILLING.includes(+ Cypress.env("CONNECTOR")+ )+ ) {+ context(+ "[Payout] [Bank transfer - Open Banking] Without Billing Address",+ () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create customer", () => {+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);+ });++ it("confirm-payout-call-without-billing-test", () => {+ const data = utils.getConnectorDetails(+ globalState.get("connectorId")+ )["bank_transfer_pm"]["open_banking"]["ConfirmWithoutBilling"];++ cy.createConfirmPayoutTest(+ Cypress._.cloneDeep(fixtures.createPayoutBody),+ data,+ true,+ true,+ globalState+ );+ if (shouldContinue)+ shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-call-test", () => {+ const data = utils.getConnectorDetails(+ globalState.get("connectorId")+ )["bank_transfer_pm"]["open_banking"]["RetrieveAfterFulfill"];++ cy.pollPayoutStatusCallTest(globalState);+ cy.retrievePayoutCallTest(globalState, data);+ });+ }+ );+ }+if (utils.CONNECTOR_LISTS.INCLUDE.BANK_TRANSFER_OPEN_BANKING_INVALID_REFERENCE_FULFILL.includes(Cypress.env("CONNECTOR")diff --git a/cypress-tests/cypress/e2e/spec/Payout/00005-SavePayout.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00005-SavePayout.cy.jsindex 3e18fe7982..02768b0637 100644--- a/cypress-tests/cypress/e2e/spec/Payout/00005-SavePayout.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payout/00005-SavePayout.cy.js@@ -141,6 +141,115 @@ describe("[Payout] Saved Card", () => {);});+describe("[Payout] Saved Bank transfer - Open Banking", () => {+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails++ 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_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();+ }+ });++ // Trustly bank transfers can't be vaulted via POST /payment_methods (422+ // IR_06 - trustly subtype is only valid for bank_redirect), so the save is+ // exercised through the connector: a recurring payout makes the payout core+ // vault the recipient as a saved payout method (subtype "trustly"), which is+ // then listed and reused via payout_token.+ context(+ "[Payout] [Bank Transfer - Open Banking] Save payment method after successful transaction",+ () => {+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails++ beforeEach("reset payoutBody", () => {+ payoutBody = Cypress._.cloneDeep(fixtures.createPayoutBody);++ payoutBody.recurring = true;+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create customer", () => {+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);+ });++ it("confirm-payout-call-with-auto-fulfill-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["Fulfill"];++ cy.createConfirmPayoutTest(payoutBody, data, true, true, globalState);++ if (shouldContinue)+ shouldContinue = utils.should_continue_further(data);+ });++ it("list customer payment methods", () => {+ cy.listCustomerPMCallTest(globalState);+ });++ it("[Payout] [Bank transfer - Open Banking] Fulfill using Token", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["Token"];++ cy.createConfirmWithTokenPayoutTest(+ payoutBody,+ data,+ true,+ true,+ globalState+ );++ if (shouldContinue)+ shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-call-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["open_banking"]["RetrieveAfterFulfill"];++ if (data) {+ cy.pollPayoutStatusCallTest(globalState);+ }+ cy.retrievePayoutCallTest(globalState, data);+ });+ }+ );+});+describe("[Payout] Saved Bank transfer", () => {let shouldContinue = true; // variable that will be used to skip tests if a previous test failsdiff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex e360e7ca91..9267f2183f 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -175,7 +175,8 @@ function expectWebhookStatusMembers(actualWebhook, expectedWebhook) {function createIndividualRolloutConfig(methodFlow,globalState,- configType = "rollout"+ configType = "rollout",+ configValueOverride = null) {const merchantId = globalState.get("merchantId");const adminApiKey = globalState.get("adminApiKey");@@ -197,12 +198,14 @@ function createIndividualRolloutConfig(? "primary": "shadow";- const configValue = {- rollout_percent: rolloutPercent,- http_url: httpUrl,- https_url: httpsUrl,- execution_mode: executionMode,- };+ const configValue = configValueOverride+ ? { ...configValueOverride }+ : {+ rollout_percent: rolloutPercent,+ http_url: httpUrl,+ https_url: httpsUrl,+ execution_mode: executionMode,+ };const value = JSON.stringify(configValue);const headers = {@@ -371,7 +374,7 @@ function parseMethodFlows(methodFlowInput, connector) {];}-function createUcsConfigs(globalState, flow, type) {+function createUcsConfigs(globalState, flow, type, configValueOverride = null) {// --- Phase 1: Environment Setup & Validation ---const ucsEnabled = globalState.get("ucsEnabled");if (!ucsEnabled) {@@ -387,7 +390,7 @@ function createUcsConfigs(globalState, flow, type) {const connector = getConnectorIdForRedirect(globalState);const methodFlowInput = flow || globalState.get("methodFlow");- if (!httpUrl || !httpsUrl) {+ if ((!httpUrl || !httpsUrl) && !configValueOverride) {throw new Error(`Missing proxyHttp or proxyHttps in globalState. globalState.proxyHttp=${httpUrl}, globalState.proxyHttps=${httpsUrl}, Cypress.env("PROXY_HTTP")=${Cypress.env("PROXY_HTTP")}, Cypress.env("PROXY_HTTPS")=${Cypress.env("PROXY_HTTPS")}`);@@ -459,7 +462,8 @@ function createUcsConfigs(globalState, flow, type) {return createIndividualRolloutConfig(currentFlow,globalState,- type+ type,+ configValueOverride);}).then((result) => {@@ -1827,6 +1831,11 @@ Cypress.Commands.add(authDetails.additional_merchant_data;}+ if (authDetails && authDetails.connector_webhook_details) {+ createConnectorBody.connector_webhook_details =+ authDetails.connector_webhook_details;+ }+cy.request({method: "POST",url: url,@@ -2189,14 +2198,17 @@ Cypress.Commands.add(`${connectorName}_payout`);- if (connectorName === "truelayer") {- const { authDetails: truelayerAuthDetails } = getValueByKey(+ if (+ (connectorName === "truelayer" || connectorName === "trustly") &&+ authDetails === null+ ) {+ const { authDetails: paymentAuthDetails } = getValueByKey(authFileContent,connectorName);- if (truelayerAuthDetails !== null) {- authDetails = truelayerAuthDetails;+ if (paymentAuthDetails !== null) {+ authDetails = paymentAuthDetails;}}@@ -2211,6 +2223,11 @@ Cypress.Commands.add(createConnectorBody.connector_account_details =authDetails.connector_account_details;+ if (authDetails.connector_webhook_details) {+ createConnectorBody.connector_webhook_details =+ authDetails.connector_webhook_details;+ }+// Stash sensitive payout bank transfer details (if any) so payout// create/confirm commands can inject them at runtime instead of// keeping them in committed connector configs@@ -7359,6 +7376,53 @@ Cypress.Commands.add(});+Cypress.Commands.add(+ "pollPayoutStatusCallTest",+ (+ globalState,+ terminalStatuses = ["success", "failed", "cancelled"],+ maxAttempts = 2,+ intervalMs = 30000+ ) => {+ const payout_id = globalState.get("payoutID");+ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };++ const poll = (attempt) => {+ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/payouts/${payout_id}`,+ headers,+ failOnStatusCode: false,+ }).then((response) => {+ const status = response.body?.status;+ cy.task(+ "cli_log",+ `pollPayoutStatusCallTest: attempt ${attempt}/${maxAttempts}, status=${status}`+ );+ globalState.set("polledPayoutStatus", status);++ if (terminalStatuses.includes(status) || attempt >= maxAttempts) {+ if (!terminalStatuses.includes(status)) {+ cy.task(+ "cli_log",+ `pollPayoutStatusCallTest: gave up after ${maxAttempts} attempts - payout ${payout_id} still '${status}' (expected one of: ${terminalStatuses.join(", ")})`+ );+ }+ return;+ }++ cy.wait(intervalMs);+ poll(attempt + 1);+ });+ };++ poll(1);+ }+);+Cypress.Commands.add("updatePayoutCallTest",(payoutConfirmBody, data, auto_fulfill, globalState) => {@@ -8321,9 +8385,12 @@ Cypress.Commands.add("cleanupUCSConfigs", (globalState, connector) => {cy.setConfigs(globalState, "ucs_enabled", "true", "DELETE");});-Cypress.Commands.add("createRolloutConfig", (globalState, flow = null) => {- return createUcsConfigs(globalState, flow, "rollout");-});+Cypress.Commands.add(+ "createRolloutConfig",+ (globalState, flow = null, configValueOverride = null) => {+ return createUcsConfigs(globalState, flow, "rollout", configValueOverride);+ }+);Cypress.Commands.add("createShadowRolloutConfig",diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex d324477fd2..55d879d875 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -1732,7 +1732,7 @@ function bankRedirectRedirection(}});- cy.wait(30000);+ cy.wait(60000);verifyUrl = false;cy.then(() => {verifyReturnUrl(redirectionUrl, expectedUrl, verifyUrl);