Skip to content

Rate and confirm express checkout with the wallet's coupon - #1550

Open
pbennett1-godaddy wants to merge 6 commits into
mainfrom
feat/express-discount-codes
Open

pbennett1-godaddy wants to merge 6 commits into
mainfrom
feat/express-discount-codes

Conversation

@pbennett1-godaddy

@pbennett1-godaddy pbennett1-godaddy commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

Checkout is making express checkout (GoDaddy and Stripe wallets) work like standard checkout when a coupon is applied:

  • Shipping rates use the subtotal after product discounts, including a coupon applied in the wallet. Shipping discounts lower the shipping charge, not the rated subtotal.
  • On confirm, the server re-prices the wallet's discounts from its coupon codes and recalculates its taxes, failing with DISCOUNT_MISMATCH or TAX_MISMATCH before charging if either differs from what the wallet showed.

The server accepts the new optional discountCodes inputs and falls back to existing behavior without them, so current clients keep working. This PR is the client side.

What

  • Rates use the wallet's coupon. Express shipping rates are fetched with the applied coupon as discountCodes (calculatedShippingRates(discountCodes:)), in both GoDaddy and Stripe express.
  • GoDaddy express re-rates when the coupon changes in the wallet. It previously kept the old rates. It now re-fetches them for the new coupon, sends the updated shippingMethods, and keeps the selected method (or the cheapest) at its new cost. Stripe express has no in-sheet coupon entry.
  • Confirm sends discountCodes alongside calculatedAdjustments, so the server prices from the code. Codes are only sent with the adjustments they priced.
  • Quotes pass straight through. The server now declares each discount line's calculationLine non-null, so the quote is sent back to confirm unchanged; no client-side reshaping.
  • Error messages. DISCOUNT_MISMATCH and TAX_MISMATCH are added in every locale, so buyers see "Discounts/Taxes have changed. Review your order and try again." instead of the raw code.
  • Types. checkout-env.ts is regenerated from the current checkout API schema. Besides the new fields, it picks up schema changes that had already shipped: the non-null calculationLine input, and paymentTargets on the session.

Standard checkout is unchanged; only the providers under checkout-buttons/express send the new fields.

Testing

  • GoDaddy express (express/godaddy.test.tsx): rates are fetched with the applied coupon; a coupon change re-fetches rates and sends the new shipping methods (replacing the earlier "keeps the wallet shipping methods" test); confirm sends discountCodes, or neither codes nor adjustments without a coupon.
  • Stripe express (express/stripe.test.tsx, use-stripe-checkout.integration.test.tsx): rates are fetched with the applied coupon; confirm sends codes with their adjustments, omits them when none were applied, and never sends codes without adjustments.
  • Each new behavior test fails without its change.
  • @godaddy/react: pnpm typecheck passes, and vitest run passes (982 tests). @godaddy/localizations: pnpm typecheck passes. Biome is clean on the changed files.

🤖 Generated with Claude Code

Checkout-api now re-prices express discounts from coupon codes and
recalculates express taxes on confirm, failing with DISCOUNT_MISMATCH or
TAX_MISMATCH when they differ from what the wallet showed.

- Send the applied coupon as discountCodes when confirming GoDaddy and
  Stripe express checkout, so the server prices from the code rather than
  reading it from the adjustments.
- Shape price adjustment quotes as confirm's calculatedAdjustments input,
  which now requires each line's calculationLine id and type.
- Add DISCOUNT_MISMATCH and TAX_MISMATCH messages in every locale.
- Regenerate checkout-env.ts from the current checkout-api schema.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pbennett1-godaddy
pbennett1-godaddy requested a review from a team as a code owner December 3, 2026 18:43
@changeset-bot

changeset-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc23a0f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@godaddy/react Patch
@godaddy/localizations Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Checkout now rates express shipping the way standard checkout does: on the
subtotal after product discounts, including a coupon applied in the wallet.

- Pass the wallet's coupon as discountCodes when fetching express shipping
  rates (GoDaddy and Stripe). GoDaddy express re-fetches rates when the
  coupon changes in the wallet and keeps the selected method at its new
  cost; it previously kept the old rates.
- Pass price adjustment quotes straight back to confirm. The server now
  declares each line's calculationLine non-null, so the client-side
  reshaping is no longer needed.
- Regenerate checkout-env.ts from the current checkout-api schema.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pbennett1-godaddy pbennett1-godaddy changed the title Verify express discounts by coupon code on confirm Rate and confirm express checkout with the wallet's coupon Dec 3, 2026
pbennett1-godaddy and others added 4 commits December 3, 2026 14:10
A coupon applied in standard checkout stays on the order. When the buyer
removed it in the express wallet, the wallet showed and taxed the order
without it, but checkout still charged the saved discount.

With no coupon in the wallet, GoDaddy and Stripe express now:
- fetch rates and confirm with an empty discountCodes list, so checkout
  rates the full subtotal and removes the order's saved discounts before
  charging;
- quote taxes with an empty discountAdjustments override, so the saved
  discounts aren't taxed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a new code gets no rates or is rejected, restore the coupon, adjustments,
shipping method and rates, taxes and totals the wallet showed before the change,
so a bad code never wipes the buyer's shipping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant