Add apps/stripe service for Stripe webhook handling#3654
Conversation
- Create new apps/stripe package with Hono server for Stripe webhooks - Move Stripe webhook route, billing-bridge logic, and stripe-sync integration - Move all stripe-*.ts scripts (backfill, sync-entitlements, etc.) - Move stripe middleware for webhook signature verification - Add Dockerfile and fly.toml for deployment - Remove extracted code from apps/api (keep /billing/start-trial route) - apps/api retains stripe.ts integration for start-trial functionality Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
✅ Deploy Preview for hyprnote-storybook canceled.
|
✅ Deploy Preview for hyprnote canceled.
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Devin Review found 1 potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ STRIPE_WEBHOOK_SECRET still required in apps/api env validation despite webhook being moved (apps/api/src/env.ts:20)
The apps/api/src/env.ts still requires STRIPE_WEBHOOK_SECRET as a mandatory environment variable (line 20), but the Stripe webhook handling has been moved to apps/stripe. The Stripe middleware was removed from apps/api/src/middleware/index.ts and the /webhook/stripe route was removed from apps/api/src/routes/webhook.ts.
Root Cause
The env validation at apps/api/src/env.ts:20 defines STRIPE_WEBHOOK_SECRET: z.string().min(1) as a required field. However, after the extraction, this secret is only needed in apps/stripe (which correctly defines it in apps/stripe/src/env.ts:14).
Impact: The apps/api service will fail to start if STRIPE_WEBHOOK_SECRET is not provided in the environment, even though this value is no longer used by the API. This creates an unnecessary deployment dependency and could cause issues when setting up new environments.
View 5 additional findings in Devin Review.
|
Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it. |
…ripe) Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
… API) Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Summary
Adds a new dedicated
apps/stripeapplication for Stripe webhook handling. This PR does not modifyapps/api- it only adds the new service to enable a safe rollout strategy:apps/stripeapps/apiin a follow-up PRWhat's in
apps/stripe:POST /webhook/stripe)billing-bridge.ts(syncBillingBridge function)stripe-sync.tsintegrationGET /health)The new service includes Dockerfile and fly.toml for Fly.io deployment on port 8788.
Updates since last revision
stripe_cd.yamlGitHub Actions workflow for Fly.io deployment (same pattern asapi_cd.yaml)doxxer.stripe.tomlfor version tagging (stripe_v*tags)Review & Testing Checklist for Human
fly apps create hyprnote-stripebefore first deploymentDATABASE_URL,SUPABASE_URL,SUPABASE_SERVICE_ROLE_KEY,STRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET,SENTRY_DSN(optional)pnpm -F @hypr/stripe devand send a test webhook using Stripe CLIstripe_cd.yamland verify deployment succeedshyprnote-stripeservice URLRecommended test plan:
hyprnote-stripeapp in Fly.io and set environment variablesstripe_cd.yamlworkflow (manual dispatch)Notes
Requested by @yujonglee
Devin session: https://app.devin.ai/sessions/bcc7b78aed544138bc19afb3adfc277c