mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
…or non stackable offer <!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> <!-- RECURSEML_SUMMARY:START --> ## High-level PR Summary This PR improves error messaging in the payments system by addressing two main issues: (1) providing clearer error messages when an item ID is mistakenly used as a product ID, including distinguishing between non-existent products, server-only products, and cases where an item exists with that ID, and (2) preventing checkout creation for non-stackable products that a customer already owns by adding an early validation check. The changes update the `ProductDoesNotExist` known error to include contextual information, introduce a new `getCustomerPurchaseContext` helper function to check existing purchases, and update related test snapshots to reflect the improved error messages. ⏱️ Estimated Review Time: 15-30 minutes <details> <summary>💡 Review Order Suggestion</summary> | Order | File Path | |-------|-----------| | 1 | `packages/stack-shared/src/known-errors.tsx` | | 2 | `apps/backend/src/lib/payments.tsx` | | 3 | `apps/backend/src/app/api/latest/payments/purchases/create-purchase-url/route.ts` | | 4 | `apps/e2e/tests/backend/endpoints/api/v1/payments/create-purchase-url.test.ts` | | 5 | `apps/e2e/tests/backend/endpoints/api/v1/payments/before-offer-to-product-rename/outdated--create-purchase-url.test.ts` | </details> [](https://discord.gg/n3SsVDAW6U) [![Analyze latest changes]( |
||
|---|---|---|
| .. | ||
| src | ||
| .eslintrc.cjs | ||
| CHANGELOG.md | ||
| LICENSE | ||
| package.json | ||
| tsconfig.json | ||
| tsup.config.ts | ||
| vitest.config.ts | ||