Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

bug(plugin-ecommerce): Stripe adapter exceeds 500-char metadata limit

Open
#19,017 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@sarankumar1325 is already working on this.

Since Oct 23, 2026.

  • #19024 by @lazerg — closed without merging
  • #19025 by @sarankumar1325 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
payments

Research direction

Read packages/plugin-ecommerce/src/payments/adapters/stripe/initiatePayment.ts and confirmOrder.ts, then run the reproduction's pnpm test:int for the 12 item cart case. The issue identifies transaction.items as the existing source for order items and describes removing the cart snapshot from Stripe metadata; also consider the address metadata limit it reports. Done means the reproduction passes and checkout can create the order.

Written by the indexing model from the issue text.

Description

Bug
Describe the Bug

The ecommerce plugin's Stripe adapter puts the entire cart into PaymentIntent metadata. Stripe caps every metadata value at 500 characters, so a checkout with more than a few cart items fails:

Error: Metadata values can have up to 500 characters, but you passed in a value that is 1090 characters. Invalid value: [{"q...6"}]

initiatePayment.ts sends cartItemsSnapshot: JSON.stringify(flattenedCart). Each item contributes roughly 60 characters (row id, product, quantity, optional variant, plus any custom properties from cartItemMatcher), so the limit is reached at around 8 items, and sooner with MongoDB ObjectIDs or custom item properties. The cart can't be checked out at all; the customer just gets Error initiating payment.

confirmOrder.ts then reads cartItemsSnapshot back from the metadata to create the order's items. That round-trip isn't needed: initiatePayment already stores the same flattenedCart on the transaction (items: flattenedCart), and confirmOrder already loads that transaction. Building the order from transaction.items would let cartItemsSnapshot be dropped from the metadata entirely.

shippingAddress is JSON-stringified into the metadata the same way. A typical address stays under the limit, but an unusually long one would hit the same error.

This affects both v3 and v4: the same code ships in 4.0.0-beta.4 and is on main.

Link to the code that reproduces this issue

https://github.com/jhb-software/payload-issue-reproductions/tree/main/stripe-adapter-metadata-exceeds-500-chars/

Reproduction Steps
  1. Clone this repo and open the stripe-adapter-metadata-exceeds-500-chars/ directory
  2. pnpm install
  3. pnpm test:int: the test creates 12 products and a guest cart holding all of them, then calls POST /api/payments/stripe/initiate. stripe is mocked, and the mock enforces Stripe's 500-character metadata limit with the real API's error message, so no Stripe account is needed.

The request fails with a 500:

ERROR: Error initiating payment with Stripe
    err: {
      "type": "Error",
      "message": "Metadata values can have up to 500 characters, but you passed in a value that is 712 characters.",
    }

FAIL  tests/int.spec.ts > stripeAdapter initiatePayment > initiates a payment for a cart with 12 items
AssertionError: expected 500 to be 200 // Object.is equality
Which area(s) are affected?

plugin: ecommerce

Environment Info
Relevant Packages:
  payload: 3.92.0
  @payloadcms/plugin-ecommerce: 3.92.0
  @payloadcms/db-sqlite: 3.92.0
  stripe: 18.3.0
Node: 22.23.3, pnpm: 11.5.1, darwin arm64
Dominant language
TypeScript
Stars
45.5k
Forks
4.3k
Avg merge
1d 19h
Merged PRs (30d)
309

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from payloadcms/payload

All issues in payloadcms/payload

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.