stripe
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v43View latest version
This val receives Stripe webhook notifications when Val Town Teams invoices ($50+) are paid and sends notifications to Discord. Regular smaller invoices are filtered out.
- ✅ Filters for Val Town Teams invoices only (≥$50)
- ✅ Verifies Stripe webhook signatures for security
- ✅ Sends rich Discord embeds with payment details
- ✅ Includes invoice amount, customer info, billing period, and invoice number
- ✅ Links to the hosted invoice when available
- ✅ Proper error handling and logging
You need to set these environment variables in your Val Town settings:
STRIPE_SECRET_KEY: Your Stripe secret key (starts withsk_)STRIPE_WEBHOOK_SECRET: Your Stripe webhook endpoint secret (starts withwhsec_)DISCORD_WEBHOOK_URL: Your Discord webhook URL
- Go to your Discord server settings
- Navigate to Integrations → Webhooks
- Click "New Webhook"
- Choose the channel where you want notifications
- Copy the webhook URL and set it as
DISCORD_WEBHOOK_URL
- Go to your Stripe Dashboard → Developers → Webhooks
- Click "Add endpoint"
- Set the endpoint URL to:
https://charmaine--19e6c204a3a811f0a7f30224a6c84d84.web.val.run - Select the event:
invoice.payment_succeeded - Copy the webhook signing secret and set it as
STRIPE_WEBHOOK_SECRET
- Val Town Teams Invoice Test: Visit
simple-test.ts- Tests a $50 invoice (should trigger notification) - Small Invoice Filter Test: Visit
test-small-invoice.ts- Tests a $29.99 invoice (should be filtered out)
-
Stripe CLI (Recommended):
stripe listen --forward-to https://charmaine--19e6c204a3a811f0a7f30224a6c84d84.web.val.run stripe trigger invoice.payment_succeeded -
Stripe Dashboard: Send test webhooks from Developers → Webhooks → Send test webhook
-
Real Invoice: Create a test Teams invoice in Stripe and mark it as paid
Currently handles:
invoice.payment_succeeded- When a Val Town Teams invoice (≥$50) is successfully paid
The webhook only processes invoices where:
amount_dueORtotalORamount_paid≥ 5000 cents ($50.00)- This ensures only Val Town Teams invoices trigger notifications
- Webhook signature verification ensures requests are from Stripe
- Environment variables keep sensitive data secure
- Proper error handling prevents information leakage
The Discord notification includes:
- 💰 Amount (in USD)
- 📄 Invoice number
- 👤 Customer email/info
- 📅 Billing period (start - end dates)
- ✅ Payment status
- 🔗 Payment intent ID
- 🔗 Link to view the invoice (if available)