payloadcms / payloadcms/payload

plugin-ecommerce: Stripe adapter hardcodes PaymentIntent amount to cart.subtotal

Open
#15,784 2 comments 0 reactions 1 assignee View on GitHub

@paulpopus is already working on this.

Since Feb 27, 2026.

Bug created-by: Contributor
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Summary

The Stripe payment adapter in @payloadcms/plugin-ecommerce hardcodes the PaymentIntent amount to cart.subtotal:

// packages/plugin-ecommerce/src/payments/stripe/initiatePayment.ts
const amount = cart.subtotal
const paymentIntent = await stripe.paymentIntents.create({ amount, ... })

There is no way to customize this amount, which makes it impossible to include additional costs like shipping fees or apply discounts like gift cards without replacing the entire adapter.

Problem

In a typical e-commerce checkout, the total charged to the customer is:

charge = cart.subtotal + shippingCost - discounts

Since the adapter only uses cart.subtotal, consumers who need to charge shipping or apply gift card discounts are forced to copy the entire Stripe adapter into their project and maintain a custom fork — just to change the amount calculation.

The initiatePayment endpoint already passes through extra fields from the request body to the adapter via data (which accepts [key: string]: any), but the adapter ignores them.

Proposed solution

Add a resolveAmount hook to the adapter config

This lets consumers define how the amount is calculated:

stripeAdapter({
  secretKey: '...',
  resolveAmount: ({ cart, data }) => {
    return (cart.subtotal ?? 0) + (data.shippingCost ?? 0) - (data.giftCardDiscount ?? 0)
  },
})

Use cases

  • Shipping costs: Charge subtotal + shippingCost (shipping is not a cart item)
  • Gift cards / vouchers: Reduce the Stripe charge when a gift card covers part of the order
  • Handling fees, taxes, surcharges: Any cost that isn't a product line item

Current workaround

The only option today is to copy the entire Stripe adapter source into the project and maintain a custom version, which is brittle across plugin updates.

Contributor guide

Open the contributing guide

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.