Stripe Data Plan Webhook Setup
This project uses a dedicated Stripe webhook endpoint for cellular data plan purchases:
https://aovis.app/api/webhooks/data-plan
Keep this endpoint separate from the existing hardware order webhook at /api/stripe/webhook.
Stripe Dashboard steps
- Open Stripe Dashboard.
- Go to
Developers -> Webhooks. - Click
Add endpoint. - Set the endpoint URL to:
https://aovis.app/api/webhooks/data-plan
- Do not edit the existing hardware order webhook endpoint.
- Recommendation: add a second webhook endpoint just for data plans so the hardware order flow stays isolated.
Events to subscribe to
Subscribe the new endpoint to these Stripe events:
checkout.session.completedpayment_intent.succeededpayment_intent.payment_failedcharge.refunded
Important note:
- Stripe does not support filtering webhook events by
metadata.typeat the Dashboard level. - Filtering must happen in application code.
- The current implementation in
app/api/webhooks/data-plan/route.tsalready checkssession.metadata.type === 'data_plan'before creating aDataPlanPurchase. - Unrelated events are acknowledged with
200so Stripe does not retry them.
Signing secret
After creating the endpoint:
- Open the new endpoint details page.
- Click
RevealunderSigning secret. - Copy the
whsec_...value. - Store it on the VM in:
STRIPE_DATA_PLAN_WEBHOOK_SECRET=whsec_...
This variable must be appended to the VM's .env.production manually. It should not be committed to git and should not be bulk-overwritten.
Verification checklist
After the endpoint is created and the secret is added to the VM:
- Send a test event from Stripe Dashboard to the new endpoint.
- Confirm Stripe shows the delivery as
200. - Check server logs for the received event:
pm2 logs aovis-store-staging --lines 200
- Run a real or test data-plan purchase and confirm a
DataPlanPurchaserow is created.