stack/apps/backend/src/lib
Aman Ganapathy e9886bc45a
[Fix] [Refactor] Implement Base Settings for Stack-Auth Plans and Move Metadata from Stripe Webhook Event to Table (#1214)
### Context
We're looking at implementing plan pricing. While doing so, we
encountered a problem with Stripe.
**Problem:** when we run a stripe operation (purchase), the product info
is encoded as part of the stripe metadata request. Stripe encodes
metadata as key-value pairs, and the [value has a limit of 500
chars](https://docs.stripe.com/metadata#data). We do this because once
we run the stripe operation, stripe fires a webhook event which is
caught by our stripe webhook handler syncStripeSubscriptions. This gets
the stripe metadata info from the event and then updates our db in
prisma.

### Summary of Changes
We add a `ProductVersion` table and only pass the `productVersionId` via
stripe metadata instead of the whole product json. This
`productVersionId` is created by hashing the `productJson`. Since the
same product may be ordered differently without being intrinsically
different, we add a helper function for ensuring a canonical order to
the json. We also pass tenancy id and product id to the table.
Since there are existing subscriptions which used to pass the
productJson via metadata, we ensure backwards compatibility.
2026-02-23 22:09:27 -08:00
..
ai-chat Emails redesign (#1076) 2026-02-16 14:57:17 -08:00
cache.tsx Upgrade Prisma to v7 (#1064) 2025-12-26 08:13:34 -08:00
cel-evaluator.ts Sign up rules (#1138) 2026-02-03 11:08:24 -08:00
clickhouse.tsx Sign up rules (#1138) 2026-02-03 11:08:24 -08:00
config.tsx Don't return 500 if branch config override is invalid 2026-02-18 15:46:03 -08:00
contact-channel.tsx External db sync (#1036) 2026-02-05 12:04:31 -08:00
dev-perf-stats.tsx Fix dev-perf-stats 2026-02-04 13:59:31 -08:00
dev-request-stats.tsx Fix dev stats accuracy 2025-12-29 17:15:08 +01:00
email-delivery-stats.tsx Make most queries readonly 2026-01-02 04:25:05 +01:00
email-drafts.tsx fix types 2025-12-26 18:11:37 +01:00
email-queue-step.tsx [Refactor] Change Retry Logic in Email Sending (#1191) 2026-02-16 21:07:16 +00:00
email-rendering.test.tsx Emails redesign (#1076) 2026-02-16 14:57:17 -08:00
email-rendering.tsx Emails redesign (#1076) 2026-02-16 14:57:17 -08:00
emails-low-level.tsx [Refactor] Change Retry Logic in Email Sending (#1191) 2026-02-16 21:07:16 +00:00
emails.tsx Upgrade Prisma to v7 (#1064) 2025-12-26 08:13:34 -08:00
end-users.tsx Upgrade backend to Next.js 15 (#360) 2024-12-10 00:11:13 -08:00
events.tsx rename tabId to sessionReplaySegmentId (#1206) 2026-02-17 11:00:07 -08:00
external-db-sync-metadata.ts [Refactor] Improve CI Run Times by Reducing Test Flakiness and Speeding up Test Suite (#1166) 2026-02-10 19:43:10 -08:00
external-db-sync-queue.ts Clickhouse sync fixing (#1198) 2026-02-16 11:30:38 -08:00
external-db-sync.ts Clickhouse sync fixing (#1198) 2026-02-16 11:30:38 -08:00
images.tsx Project logo upload (#817) 2025-08-19 04:45:16 +02:00
internal-api-keys.tsx "Require publishable client key" toggle (#1158) 2026-02-19 10:23:16 -08:00
js-execution.tsx [Refactor] Rework Environment Variable Checks in Email-Rendering Pipeline (#1161) 2026-02-04 16:54:18 -08:00
notification-categories.ts Email outbox backend (#1030) 2025-12-12 10:26:38 -08:00
oauth.tsx Sign up rules (#1138) 2026-02-03 11:08:24 -08:00
openapi.tsx [Docs][Content] API/SK docs for payments (#935) 2025-10-11 14:47:25 -07:00
payments.test.tsx fix payment data integrity (#1137) 2026-01-28 09:01:43 -08:00
payments.tsx inline product cancelling (#1199) 2026-02-17 20:28:16 -08:00
permissions.tsx fix types 2025-12-26 18:11:37 +01:00
product-versions.tsx [Fix] [Refactor] Implement Base Settings for Stack-Auth Plans and Move Metadata from Stripe Webhook Event to Table (#1214) 2026-02-23 22:09:27 -08:00
projects.tsx [Fix] [Feat] Update OAuth Sign-In and Get Token Functions to Work (#1130) 2026-01-28 02:17:27 +00:00
redirect-urls.test.tsx [Fix] [Feat] Update OAuth Sign-In and Get Token Functions to Work (#1130) 2026-01-28 02:17:27 +00:00
redirect-urls.tsx [Fix] [Feat] Update OAuth Sign-In and Get Token Functions to Work (#1130) 2026-01-28 02:17:27 +00:00
request-checks.tsx Upgrade Prisma to v7 (#1064) 2025-12-26 08:13:34 -08:00
session-replays.tsx Analytics event tracking (#1208) 2026-02-17 18:33:01 -08:00
sign-up-rules.ts Test sign-up rules widget 2026-02-04 11:22:42 -08:00
stripe-proxy.tsx one time payments (#865) 2025-09-12 17:14:09 -07:00
stripe.tsx [Fix] [Refactor] Implement Base Settings for Stack-Auth Plans and Move Metadata from Stripe Webhook Event to Table (#1214) 2026-02-23 22:09:27 -08:00
telegram.tsx payment email templates (#1106) 2026-01-20 18:45:01 -08:00
tenancies.tsx Make most queries readonly 2026-01-02 04:25:05 +01:00
tokens.tsx rename tabId to sessionReplaySegmentId (#1206) 2026-02-17 11:00:07 -08:00
types.tsx Upgrade Prisma to v7 (#1064) 2025-12-26 08:13:34 -08:00
upstash.tsx Email outbox backend (#1030) 2025-12-12 10:26:38 -08:00
users.tsx Test sign-up rules widget 2026-02-04 11:22:42 -08:00
webhooks.tsx Rename USER to PROJECT in permissions (#576) 2025-03-27 09:39:48 -07:00