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
test(cypress): add client-auth payout confirm coverage for paypal (#14547) (#14626)
HS-QUALIBOTf6ec56c6fe23
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Commons.js b/cypress-tests/cypress/e2e/configs/Payout/Commons.jsindex 210bd73d45..68420b5478 100644--- a/cypress-tests/cypress/e2e/configs/Payout/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payout/Commons.js@@ -304,4 +304,100 @@ export const connectorDetails = {},}),},+ wallet_pm: {+ // Cross-connector skeleton for wallet payouts. Wallet payouts are only+ // supported by wallet-capable payout connectors, so the connector-driven+ // success keys (Create / ConfirmMerchantAuth / ConfirmClientAuth /+ // RetrieveAfterConfirm) default to the 501 not-implemented response —+ // connectors override them with their real responses. The client-auth+ // restricted-field validations are enforced by the router before the+ // payout state is loaded or mutated, so their error envelopes are+ // connector-agnostic and shared here as the default.+ Create: getCustomExchange({+ Request: {+ payout_type: "wallet",+ },+ }),+ ConfirmClientAuthRestrictedFields: getCustomExchange({+ Request: {+ amount: 10000,+ payout_type: "wallet",+ },+ Response: {+ status: 422,+ body: {+ error: {+ type: "invalid_request",+ message:+ "The following fields cannot be provided for client-authenticated payout confirmation: amount",+ code: "IR_06",+ },+ },+ },+ }),+ ConfirmClientAuthMultipleRestrictedFields: getCustomExchange({+ Request: {+ amount: 10000,+ currency: "USD",+ auto_fulfill: false,+ payout_type: "wallet",+ },+ Response: {+ status: 422,+ body: {+ error: {+ type: "invalid_request",+ message:+ "The following fields cannot be provided for client-authenticated payout confirmation: amount, auto_fulfill, currency",+ code: "IR_06",+ },+ },+ },+ }),+ ConfirmClientAuthMissingClientSecret: getCustomExchange({+ Request: {+ client_secret: null,+ amount: 10000,+ payout_type: "wallet",+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message: "Missing required param: client_secret",+ code: "IR_04",+ },+ },+ },+ }),+ ConfirmMerchantAuth: getCustomExchange({+ Request: {+ amount: 100,+ payout_type: "wallet",+ },+ }),+ ConfirmClientAuth: getCustomExchange({+ Request: {+ payout_type: "wallet",+ },+ }),+ RetrieveAfterClientAuthErrors: getCustomExchange({+ Response: {+ status: 200,+ body: {+ status: "requires_confirmation",+ payout_type: "wallet",+ },+ },+ }),+ RetrieveAfterConfirm: getCustomExchange({+ Response: {+ status: 200,+ body: {+ status: "requires_fulfillment",+ },+ },+ }),+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payout/Paypal.js b/cypress-tests/cypress/e2e/configs/Payout/Paypal.jsnew file mode 100644index 0000000000..432cecdf8b--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payout/Paypal.js@@ -0,0 +1,149 @@+const wallet_data = {+ telephone_number: "16608213349",+};++export const connectorDetails = {+ wallet_pm: {+ Create: {+ Request: {+ amount: 100,+ currency: "GBP",+ payout_type: "wallet",+ payout_method_data: {+ wallet: {+ paypal: wallet_data,+ },+ },+ entity_type: "NaturalPerson",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_confirmation",+ payout_type: "wallet",+ },+ },+ },+ ConfirmClientAuth: {+ Request: {+ payout_type: "wallet",+ payout_method_data: {+ wallet: {+ paypal: wallet_data,+ },+ },+ },+ Response: {+ status: 200,+ body: {+ status: "pending",+ payout_type: "wallet",+ },+ },+ },+ ConfirmClientAuthRestrictedFields: {+ Request: {+ amount: 10000,+ payout_type: "wallet",+ payout_method_data: {+ wallet: {+ paypal: wallet_data,+ },+ },+ },+ Response: {+ status: 422,+ body: {+ error: {+ type: "invalid_request",+ message:+ "The following fields cannot be provided for client-authenticated payout confirmation: amount",+ code: "IR_06",+ },+ },+ },+ },+ ConfirmClientAuthMultipleRestrictedFields: {+ Request: {+ amount: 10000,+ currency: "USD",+ auto_fulfill: false,+ payout_type: "wallet",+ payout_method_data: {+ wallet: {+ paypal: wallet_data,+ },+ },+ },+ Response: {+ status: 422,+ body: {+ error: {+ type: "invalid_request",+ message:+ "The following fields cannot be provided for client-authenticated payout confirmation: amount, auto_fulfill, currency",+ code: "IR_06",+ },+ },+ },+ },+ ConfirmClientAuthMissingClientSecret: {+ Request: {+ client_secret: null,+ amount: 10000,+ payout_type: "wallet",+ payout_method_data: {+ wallet: {+ paypal: wallet_data,+ },+ },+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message: "Missing required param: client_secret",+ code: "IR_04",+ },+ },+ },+ },+ ConfirmMerchantAuth: {+ Request: {+ amount: 100,+ payout_type: "wallet",+ payout_method_data: {+ wallet: {+ paypal: wallet_data,+ },+ },+ },+ Response: {+ status: 200,+ body: {+ status: "pending",+ payout_type: "wallet",+ },+ },+ },+ RetrieveAfterClientAuthErrors: {+ Response: {+ status: 200,+ body: {+ status: "requires_confirmation",+ payout_type: "wallet",+ },+ },+ },+ RetrieveAfterConfirm: {+ Response: {+ status: 200,+ body: {+ status: "pending",+ payout_type: "wallet",+ },+ },+ },+ },+};diff --git a/cypress-tests/cypress/e2e/configs/Payout/Utils.js b/cypress-tests/cypress/e2e/configs/Payout/Utils.jsindex 329f75b49f..da9b76d149 100644--- a/cypress-tests/cypress/e2e/configs/Payout/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payout/Utils.js@@ -6,6 +6,7 @@ import { connectorDetails as CommonConnectorDetails } from "./Commons.js";import { connectorDetails as gotymeSanlamConnectorDetails } from "./GotymeSanlam.js";import { connectorDetails as wiseConnectorDetails } from "./Wise.js";import { connectorDetails as nomupayConnectorDetails } from "./Nomupay.js";+import { connectorDetails as paypalConnectorDetails } from "./Paypal.js";import { connectorDetails as truelayerConnectorDetails } from "./Truelayer.js";import { connectorDetails as trustlyConnectorDetails } from "./Trustly.js";@@ -15,6 +16,7 @@ const connectorDetails = {commons: CommonConnectorDetails,gotyme_sanlam: gotymeSanlamConnectorDetails,nomupay: nomupayConnectorDetails,+ paypal: paypalConnectorDetails,truelayer: truelayerConnectorDetails,trustly: trustlyConnectorDetails,wise: wiseConnectorDetails,@@ -108,6 +110,9 @@ export const CONNECTOR_LISTS = {// Payout recurring feature - only verified connectorsPAYOUT_RECURRING: ["adyenplatform"],PAYOUT_LINK: ["wise"],+ // Client-authenticated payout confirm (PR #14547) - only verified+ // connectors+ CLIENT_AUTH_CONFIRM: ["paypal"],BANK_TRANSFER_OPEN_BANKING: ["truelayer", "trustly"],BANK_TRANSFER_OPEN_BANKING_INVALID_REFERENCE_FULFILL: [],BANK_TRANSFER_OPEN_BANKING_MANUAL_FULFILL: ["trustly"],diff --git a/cypress-tests/cypress/e2e/spec/Payout/00009-ClientAuthPayoutConfirm.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00009-ClientAuthPayoutConfirm.cy.jsnew file mode 100644index 0000000000..9f2e6b4c97--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payout/00009-ClientAuthPayoutConfirm.cy.js@@ -0,0 +1,142 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import * as utils from "../../configs/Payout/Utils";++let globalState;+let payoutBody;++describe("[Payout] Client Auth Confirm", () => {+ 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);++ if (!globalState.get("payoutsExecution")) {+ shouldContinue = false;+ }++ if (+ !utils.CONNECTOR_LISTS.INCLUDE.CLIENT_AUTH_CONFIRM.includes(+ globalState.get("connectorId")+ )+ ) {+ shouldContinue = false;+ }+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ payoutBody = Cypress._.cloneDeep(fixtures.createPayoutBody);+ });++ context("[Payout] Client Auth Confirm - Restricted Fields", () => {+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-for-client-auth-confirm-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["Create"];++ cy.createConfirmPayoutTest(payoutBody, data, false, true, globalState);+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("client-auth-confirm-with-restricted-field-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["ConfirmClientAuthRestrictedFields"];++ cy.confirmPayoutCallTest({}, data, true, globalState);+ });++ it("client-auth-confirm-with-multiple-restricted-fields-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["ConfirmClientAuthMultipleRestrictedFields"];++ cy.confirmPayoutCallTest({}, data, true, globalState);+ });++ it("client-auth-confirm-without-client-secret-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["ConfirmClientAuthMissingClientSecret"];++ cy.confirmPayoutCallTest({}, data, true, globalState);+ });++ it("retrieve-payout-after-client-auth-errors-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["RetrieveAfterClientAuthErrors"];++ cy.retrievePayoutCallTest(globalState, data);+ });++ it("merchant-auth-confirm-with-restricted-fields-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["ConfirmMerchantAuth"];++ cy.confirmPayoutCallTest({}, data, false, globalState);+ });++ it("retrieve-payout-after-merchant-auth-confirm-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["RetrieveAfterConfirm"];++ cy.retrievePayoutCallTest(globalState, data);+ });+ });++ context("[Payout] Client Auth Confirm - Valid Request", () => {+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-for-client-auth-confirm-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["Create"];++ cy.createConfirmPayoutTest(payoutBody, data, false, true, globalState);+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("client-auth-confirm-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["ConfirmClientAuth"];++ cy.confirmPayoutCallTest({}, data, true, globalState);+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-after-client-auth-confirm-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "wallet_pm"+ ]["RetrieveAfterConfirm"];++ cy.retrievePayoutCallTest(globalState, data);+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 77bb57222e..9bff9f9740 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -2199,7 +2199,9 @@ Cypress.Commands.add();if (- (connectorName === "truelayer" || connectorName === "trustly") &&+ (connectorName === "truelayer" ||+ connectorName === "trustly" ||+ connectorName === "paypal") &&authDetails === null) {const { authDetails: paymentAuthDetails } = getValueByKey(@@ -7571,6 +7573,12 @@ Cypress.Commands.add(if (response.status === 200) {globalState.set("payoutAmount", createConfirmPayoutBody.amount);globalState.set("payoutID", response.body.payout_id);+ if (response.body.client_secret) {+ globalState.set(+ "payoutClientSecret",+ response.body.client_secret+ );+ }if (response.body.payout_method_id) {globalState.set("payoutMethodId", response.body.payout_method_id);}@@ -7708,6 +7716,82 @@ Cypress.Commands.add(});+/**+ * Confirms a payout via POST /payouts/{payout_id}/confirm, supporting both+ * authentication modes of the payout confirm API. This is the payout-side+ * analogue of confirmCallTest (payments): it confirms an EXISTING payout on+ * its dedicated confirm endpoint. It cannot be replaced by+ * createConfirmPayoutTest, which always creates a NEW payout on+ * POST /payouts/create — a route with merchant-key-only auth where the+ * client-authenticated confirm flow is unreachable.+ * - client-authenticated (clientAuth=true): publishable key in the api-key+ * header and the client_secret (stashed in globalState as+ * payoutClientSecret by createConfirmPayoutTest) in the request body.+ * Restricted fields (amount, auto_fulfill, currency, connector, routing)+ * in the config Request exercise the client-auth field restrictions.+ * A config Request may pin client_secret (e.g. null) to exercise the+ * missing-client_secret error path.+ * - merchant-authenticated (clientAuth=false): merchant secret key in the+ * api-key header and no client_secret in the request body.+ * @param {Object} payoutConfirmBody - Base request body (config Request fields are merged on top)+ * @param {Object} data - Connector config entry with Request/Response+ * @param {boolean} clientAuth - true for publishable-key auth, false for merchant secret-key auth+ * @param {Object} globalState - The global state object+ */+Cypress.Commands.add(+ "confirmPayoutCallTest",+ (payoutConfirmBody, data, clientAuth, globalState) => {+ const { Request: reqData, Response: resData } = data || {};+ const payout_id = globalState.get("payoutID");++ for (const key in reqData) {+ payoutConfirmBody[key] = reqData[key];+ }++ if (clientAuth) {+ if (!("client_secret" in reqData)) {+ payoutConfirmBody.client_secret = globalState.get("payoutClientSecret");+ }+ } else {+ delete payoutConfirmBody.client_secret;+ }++ const headers = {+ "Content-Type": "application/json",+ "api-key": clientAuth+ ? globalState.get("publishableKey")+ : globalState.get("apiKey"),+ };++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payouts/${payout_id}/confirm`,+ headers,+ failOnStatusCode: false,+ body: payoutConfirmBody,+ }).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) {+ if (resData.body) {+ for (const key in resData.body) {+ expect(resData.body[key], [key]).to.deep.equal(+ response.body[key]+ );+ }+ }+ } else {+ expect(response.status).to.equal(resData.status);+ defaultErrorHandler(response, resData);+ }+ });+ });+ }+);+Cypress.Commands.add("pollPayoutStatusCallTest",(