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: v18View latest version
This val receives Stripe webhook notifications when invoices are paid and sends notifications to Discord.
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 your val's HTTP URL (you'll get this after deploying)
- Select the event:
invoice.payment_succeeded - Copy the webhook signing secret and set it as
STRIPE_WEBHOOK_SECRET
You can test the webhook by:
- Creating a test invoice in Stripe
- Marking it as paid
- Checking your Discord channel for the notification
- ✅ Verifies Stripe webhook signatures for security
- ✅ Sends rich Discord embeds with payment details
- ✅ Includes invoice amount, customer email, and invoice number
- ✅ Links to the hosted invoice when available
- ✅ Proper error handling and logging
Currently handles:
invoice.payment_succeeded- When an invoice is successfully paid
- Webhook signature verification ensures requests are from Stripe
- Environment variables keep sensitive data secure
- Proper error handling prevents information leakage