You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
plugin-ecommerce: restore the Stripe cart drift check with a metadata digest, and keep shippingAddress under the metadata limit #19055
Follow-up to #19024 (the fix for #19017), split out so that PR can ship on its own.
Problem
fix(plugin-ecommerce): drop cart items from Stripe payment intent metadata #19024 removes cartItemsSnapshot from the PaymentIntent metadata to stay under Stripe's 500-character limit. With it, validateSettlement no longer checks that transaction.items still match what was priced in initiatePayment. The amount check remains, but a change to the items between initiatePayment and confirmOrder is no longer detected. It also means a custom cart item field that the transactions schema does not store no longer fails confirmation (see the CodeRabbit thread on confirmOrder.ts in fix(plugin-ecommerce): drop cart items from Stripe payment intent metadata #19024).
shippingAddress is still written to the metadata as the JSON of the address object the client sends. A full saved address document (with id, customer, createdAt, updatedAt and long address lines) can go past 500 characters and fail paymentIntents.create in the same way as bug(plugin-ecommerce): Stripe adapter exceeds 500-char metadata limit #19017.
Proposal
Store a fixed-size digest instead of the snapshot: cartItemsHash = SHA-256 of stableSerialize(normalizeCartItems(flattenedCart)) (64 hex characters). validateSettlement compares it with the same hash of normalizeCartItems(transaction.items). Metadata can only be written with the secret key, so a plain hash is enough. PaymentIntents without the hash (created by the version that ships fix(plugin-ecommerce): drop cart items from Stripe payment intent metadata #19024) skip the comparison, so upgrading stays safe.
Add a shippingAddress field to the transactions collection, like billingAddress, and stop writing the address to the metadata.
Acceptance criteria
New PaymentIntents carry cartItemsHash, and validateSettlement rejects a mismatch.
PaymentIntents without cartItemsHash still confirm.
Normalization tests cover relationship objects vs IDs, key order, null variants and custom properties.
A test with a realistic full shipping address keeps every metadata value under 500 characters.
Hi @ratomirjovanovic, I would love to pick this up! I am currently investigating the crypto implementation for the cartItemsHash digest and the necessary schema updates for the shippingAddress. I'll start working on a draft PR and will reach out if I hit any roadblocks.
For the hash, the part that needs the most care is the normalization: relationship fields can arrive as an ID or as a populated document, and optional fields as undefined or null, so both sides need to reduce to the same shape before stableSerialize. The acceptance criteria list the cases I would test.
Adding shippingAddress to the transactions collection is a schema change for the SQL adapters, so a line about running a migration in the changeset would help.
@KRISH2507 heads up: #19024 was closed in favor of #19025, which already stores a hash of the cart items in the PaymentIntent metadata and checks it in confirmOrder. So the first half of this issue is covered there.
What #19025 does not change is shippingAddress, which is still sent as one JSON string and can pass Stripe's 500-character limit with long address lines. If you want to pick something up, that part is still open. Probably best to base it on #19025 so the two don't conflict in initiatePayment.
In case it helps: the cart hash part looks covered by #19025 already (hashCartItems in initiatePayment, checked in confirmOrder), so shippingAddress is probably the bit still open. @KRISH2507 also mentioned earlier that they were looking at this one.
Activity
KRISH2507 commentedon Oct 27, 2026
Hi @ratomirjovanovic, I would love to pick this up! I am currently investigating the crypto implementation for the cartItemsHash digest and the necessary schema updates for the shippingAddress. I'll start working on a draft PR and will reach out if I hit any roadblocks.
ratomirjovanovic commentedon Oct 27, 2026
Thanks @KRISH2507, go ahead. Two things that may save you some time:
cartItemsSnapshot), so it is probably easiest to branch from it or wait until it lands. Otherwise the two will conflict ininitiatePaymentandconfirmOrder.undefinedornull, so both sides need to reduce to the same shape beforestableSerialize. The acceptance criteria list the cases I would test.Adding
shippingAddressto the transactions collection is a schema change for the SQL adapters, so a line about running a migration in the changeset would help.Happy to review the PR when it is up.
ratomirjovanovic commentedon Oct 27, 2026
@KRISH2507 heads up: #19024 was closed in favor of #19025, which already stores a hash of the cart items in the PaymentIntent metadata and checks it in
confirmOrder. So the first half of this issue is covered there.What #19025 does not change is
shippingAddress, which is still sent as one JSON string and can pass Stripe's 500-character limit with long address lines. If you want to pick something up, that part is still open. Probably best to base it on #19025 so the two don't conflict ininitiatePayment.ratomirjovanovic commentedon Oct 30, 2026
In case it helps: the cart hash part looks covered by #19025 already (
hashCartItemsininitiatePayment, checked inconfirmOrder), soshippingAddressis probably the bit still open. @KRISH2507 also mentioned earlier that they were looking at this one.chore: resolve six more upstream payload reports