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 stripe payout vendor metadata and end-to-end payout coverage (#15187)

venkatakarthikm-maker8e743d368de6
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Stripe.js b/cypress-tests/cypress/e2e/configs/Payout/Stripe.js
new file mode 100644
index 0000000000..a8fb6fd49f
--- /dev/null
+++ b/cypress-tests/cypress/e2e/configs/Payout/Stripe.js
@@ -0,0 +1,196 @@
+const billing = {
+ address: {
+ line1: "100 Main St",
+ city: "San Francisco",
+ state: "CA",
+ zip: "94105",
+ country: "US",
+ first_name: "John",
+ last_name: "Doe",
+ },
+};
+
+// Stripe test bank account (ACH) from Stripe's testing documentation.
+const ach_payout_method_data = {
+ bank: {
+ bank_name: "Stripe Test Bank",
+ bank_account_number: "000123456789",
+ bank_routing_number: "110000000",
+ bank_country_code: "US",
+ },
+};
+
+const ach_payout_request = {
+ amount: 1000,
+ currency: "USD",
+ payout_type: "bank",
+ payout_method_data: ach_payout_method_data,
+ billing: billing,
+};
+
+// Stripe Connect vendor details. account_type must be one of
+// custom / express / standard (PayoutAccountType in
+// hyperswitch_connectors/src/connectors/stripe/transformers/connect.rs).
+const vendor_details = {
+ account_type: "custom",
+ business_type: "individual",
+ capabilities_transfers: true,
+ business_profile_mcc: 5734,
+ business_profile_url: "https://accessible.stripe.com",
+};
+
+// Stripe test values that let a Custom account verify instantly, so the
+// transfers capability becomes active and the payout runs end to end.
+const individual_details = {
+ external_account_account_holder_type: "individual",
+ tos_acceptance_date: 1609459200,
+ tos_acceptance_ip: "8.8.8.8",
+ date_of_birth: "1901-01-01",
+ individual_id_number: "000000000",
+ individual_ssn_last_4: "0000",
+};
+
+// Stripe payouts read payout metadata as PayoutVendorAccountDetails
+// ({ vendor_details, individual_details }, both required). Metadata that
+// carries either key but fails to parse is rejected with the parse error;
+// metadata without either key is treated as absent and the Stripe connector
+// then reports vendor_details as missing (PR #14846).
+const missingVendorDetailsError = {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Missing required param: vendor_details",
+ code: "IR_04",
+ },
+ },
+};
+
+export const connectorDetails = {
+ bank_transfer_pm: {
+ ach_bank_transfer: {
+ // A payout with an existing customer_id uses that customer's phone, and
+ // Stripe Connect account creation rejects the default customer fixture's
+ // phone ("999999999", "+65"). The valid case creates a customer with a
+ // US phone first.
+ VendorMetadataCustomer: {
+ Request: {
+ phone: "2015550123",
+ phone_country_code: "+1",
+ },
+ },
+ VendorMetadataValid: {
+ Request: {
+ ...ach_payout_request,
+ // Stripe test address that passes address verification.
+ billing: {
+ address: { ...billing.address, line1: "address_full_match" },
+ },
+ metadata: {
+ vendor_details: vendor_details,
+ individual_details: individual_details,
+ },
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_vendor_account_creation",
+ payout_type: "bank",
+ },
+ },
+ },
+ RetrieveAfterAccountAttach: {
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ payout_type: "bank",
+ },
+ },
+ },
+ VendorMetadataMissingIndividual: {
+ Request: {
+ ...ach_payout_request,
+ metadata: {
+ vendor_details: vendor_details,
+ },
+ },
+ Response: {
+ status: 422,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "Invalid payout metadata: missing field `individual_details`",
+ code: "IR_06",
+ },
+ },
+ },
+ },
+ VendorMetadataMissingVendor: {
+ Request: {
+ ...ach_payout_request,
+ metadata: {
+ individual_details: {},
+ },
+ },
+ Response: {
+ status: 422,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "Invalid payout metadata: missing field `vendor_details`",
+ code: "IR_06",
+ },
+ },
+ },
+ },
+ VendorMetadataInvalidFieldType: {
+ Request: {
+ ...ach_payout_request,
+ metadata: {
+ vendor_details: {
+ ...vendor_details,
+ account_type: 123,
+ },
+ individual_details: {},
+ },
+ },
+ Response: {
+ status: 422,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "Invalid payout metadata: invalid type: integer `123`, expected a string",
+ code: "IR_06",
+ },
+ },
+ },
+ },
+ VendorMetadataUnrelatedKeys: {
+ Request: {
+ ...ach_payout_request,
+ metadata: {
+ ref: "123",
+ },
+ },
+ Response: missingVendorDetailsError,
+ },
+ VendorMetadataAbsent: {
+ // undefined overrides the base fixture's metadata and is dropped when
+ // the request body is serialized, so the key is absent on the wire.
+ Request: { ...ach_payout_request, metadata: undefined },
+ Response: missingVendorDetailsError,
+ },
+ VendorMetadataNull: {
+ Request: {
+ ...ach_payout_request,
+ metadata: null,
+ },
+ Response: missingVendorDetailsError,
+ },
+ },
+ },
+};
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Utils.js b/cypress-tests/cypress/e2e/configs/Payout/Utils.js
index ef92f3479c..b499d9d908 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 nomupayConnectorDetails } from "./Nomupay.js";
import { connectorDetails as paypalConnectorDetails } from "./Paypal.js";
+import { connectorDetails as stripeConnectorDetails } from "./Stripe.js";
import { connectorDetails as truelayerConnectorDetails } from "./Truelayer.js";
import { connectorDetails as trustlyConnectorDetails } from "./Trustly.js";
import { connectorDetails as wiseConnectorDetails } from "./Wise.js";
@@ -17,6 +18,7 @@ const connectorDetails = {
gotyme_sanlam: gotymeSanlamConnectorDetails,
nomupay: nomupayConnectorDetails,
paypal: paypalConnectorDetails,
+ stripe: stripeConnectorDetails,
truelayer: truelayerConnectorDetails,
trustly: trustlyConnectorDetails,
wise: wiseConnectorDetails,
@@ -107,7 +109,7 @@ export const CONNECTOR_LISTS = {
// supports wallet payouts (see configs/Payout/Paypal.js), and truelayer
// does not implement card payout eligibility over UCS, so they have no
// card payout method either and are skipped for the same reason.
- CARD_TEST: ["gotyme_sanlam", "trustly", "paypal", "truelayer"],
+ CARD_TEST: ["gotyme_sanlam", "trustly", "paypal", "truelayer", "stripe"],
VENMO_WALLET_FULFILL: ["paypal"],
},
INCLUDE: {
@@ -130,6 +132,7 @@ export const CONNECTOR_LISTS = {
SAVED_CARD: ["adyen", "adyenplatform", "nomupay", "wise"],
SAVED_BANK_TRANSFER_SEPA: ["adyen", "adyenplatform", "nomupay", "wise"],
SAVED_BANK_TRANSFER_OPEN_BANKING: ["trustly"],
+ PAYOUT_VENDOR_METADATA: ["stripe"],
},
};
diff --git a/cypress-tests/cypress/e2e/spec/Payout/00011-PayoutVendorMetadata.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00011-PayoutVendorMetadata.cy.js
new file mode 100644
index 0000000000..d66fc8a24b
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payout/00011-PayoutVendorMetadata.cy.js
@@ -0,0 +1,112 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import * as utils from "../../configs/Payout/Utils";
+
+let globalState;
+let payoutBody;
+
+// Stripe payouts parse payout metadata into PayoutVendorAccountDetails.
+// Metadata that carries vendor details but fails to parse must return the
+// parse error naming the field, and metadata without vendor details must keep
+// the previous behavior (PR #14846).
+describe("[Payout] [Bank Transfer - ACH] Vendor Metadata", () => {
+ 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.PAYOUT_VENDOR_METADATA.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();
+ }
+ payoutBody = Cypress._.cloneDeep(fixtures.createPayoutBody);
+ });
+
+ context("[Payout] Vendor Metadata - Valid", () => {
+ let shouldContinue = true;
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create-customer-with-us-phone-test", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "bank_transfer_pm"
+ ]["ach_bank_transfer"]["VendorMetadataCustomer"];
+
+ cy.createCustomerCallTest(
+ {
+ ...Cypress._.cloneDeep(fixtures.customerCreateBody),
+ ...data.Request,
+ },
+ globalState
+ );
+ });
+
+ it("create-payout-with-valid-vendor-metadata-test", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "bank_transfer_pm"
+ ]["ach_bank_transfer"]["VendorMetadataValid"];
+
+ cy.createConfirmPayoutTest(payoutBody, data, true, true, globalState);
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("retrieve-payout-after-account-attach-test", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "bank_transfer_pm"
+ ]["ach_bank_transfer"]["RetrieveAfterAccountAttach"];
+
+ // Stripe account, transfer and payout calls run in the background
+ // attach-account task, scheduled 15s after create plus scheduler lag.
+ cy.wait(50000);
+ cy.retrievePayoutCallTest(globalState, data);
+ });
+ });
+
+ context("[Payout] Vendor Metadata - Parse Errors And Absent Metadata", () => {
+ [
+ { key: "VendorMetadataMissingIndividual", name: "missing-individual" },
+ { key: "VendorMetadataMissingVendor", name: "missing-vendor" },
+ { key: "VendorMetadataInvalidFieldType", name: "invalid-field-type" },
+ { key: "VendorMetadataUnrelatedKeys", name: "unrelated-metadata" },
+ { key: "VendorMetadataAbsent", name: "without-metadata" },
+ { key: "VendorMetadataNull", name: "null-metadata" },
+ ].forEach(({ key, name }) => {
+ it(`create-payout-with-${name}-test`, () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "bank_transfer_pm"
+ ]["ach_bank_transfer"][key];
+
+ cy.createConfirmPayoutTest(payoutBody, data, true, true, globalState);
+ });
+ });
+ });
+});