• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
stevekrouse

stevekrouse

newStripeSubscriber

Notify the Val Town team when we get new subscribers
Public
Like
5
newStripeSubscriber
Home
Code
2
README.md
H
main.tsx
Environment variables
Branches
2
Pull requests
Remixes
13
History
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
Viewing readonly version of teams-payment-links branch: v3
View latest version
README.md

New Stripe Subscription Handler

This webhook listens for new subscribers to Val Town Pro from Stripe and sends the Val Town team a Discord notification.

We have an additional webhook in the core Val Town app that takes care of updating user's tier to let Pro users access premium features.

Setup

To create your own Stripe webhook that listens for new subscribers:

  1. Fork this HTTP val
  2. Create a new webhook in Stripe
  3. Add your val's HTTP endpoint URL into the Stripe webhook
  4. Select invoice.payment_succeeded as the event to listen to
  5. Add your stripe_sk_customer_readonly to your Val Town Env Variables (you can find this on the left sidebar)
  6. Add your webhook's signing secret as STRIPE_WEBHOOK_SECRET to your Val Town Env Variables (you can find this on the left sidebar)

How the code works

  1. Verifies the webhook signature to ensure it's really from Stripe
  2. Checks if the event is a new subscription by looking for invoice.payment_succeeded with billing_reason === "subscription_create"
  3. Fetches the customer details from Stripe
  4. Sends a Discord notification with the customer's email

Why we use invoice.payment_succeeded

We listen to invoice.payment_succeeded events and filter for billing_reason === "subscription_create" because:

  • Works for all subscription methods: Covers standard checkout, payment links, invoices, and trials ending
  • Payment confirmation: Only fires when payment actually succeeds, preventing notifications for failed fraud attempts
  • Simpler implementation: Single event type to monitor, no need to track status transitions
  • More reliable: Catches the moment when a customer becomes a paying subscriber, regardless of how they signed up

This approach ensures we get notified exactly once per new paying customer, at the moment their first payment goes through.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.