Prerequisites
- An AuthForge account with an app created
- An AuthForge Developer API key
- A Stripe account with API keys
- A Node.js backend (examples use Express.js)
One-time purchases
Flow overview
1. Create a Stripe Checkout session
2. Handle the Stripe webhook
3. Generate the license key
4. Deliver the key
Options for delivering the license key to the customer:- Email — Send an automated email with the key after payment.
- Success page — Redirect to a page that displays the key (retrieve it by session ID).
- Customer portal — Store keys in your database and let users view them in their account.
Subscriptions
For recurring payments, you’ll generate a license when the subscription starts and revoke it when the subscription ends.Events to handle
| Stripe Event | AuthForge Action |
|---|---|
customer.subscription.created | Create a license key |
customer.subscription.deleted | Revoke the license key |
customer.subscription.updated | Extend expiry on renewal |
invoice.payment_failed | Optionally revoke or warn |
Complete subscription handler
Subscription created — generate license
Subscription deleted — revoke license
Subscription updated — extend expiry on renewal
Payment failed — optional revocation
Idempotency
Stripe retries webhook deliveries on failure. Guard against duplicate license creation by:- Storing the Stripe session/subscription ID alongside each license in your database.
- Checking for an existing record before creating a new license.
- Returning early if a license already exists for that payment.
Next steps
- Subscription Lifecycle Management — Detailed subscription patterns
- Custom Integration Guide — Build your own payment integration