Overview
Alana Shopping sends webhook events for billing and subscription changes via Stripe. Your application can listen for these events to automate workflows.
Supported events
| Event | Description |
|---|
checkout.session.completed | Customer completed a checkout session |
customer.subscription.created | New subscription created |
customer.subscription.updated | Subscription plan changed, renewed, or modified |
customer.subscription.deleted | Subscription canceled |
invoice.paid | Invoice payment succeeded |
invoice.payment_failed | Invoice payment failed |
Webhook security
All webhook payloads are signed by Stripe. Always verify the signature before processing:
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
export async function POST(request) {
const body = await request.text();
const signature = request.headers.get('stripe-signature');
const event = stripe.webhooks.constructEvent(
body,
signature,
process.env.STRIPE_WEBHOOK_SECRET
);
// Process the verified event
switch (event.type) {
case 'customer.subscription.updated':
// Update workspace plan
break;
case 'invoice.payment_failed':
// Notify workspace owner
break;
}
}
Never process webhook events without verifying the Stripe signature. Unverified webhooks could be spoofed by malicious actors.
Retry policy
Stripe retries failed webhook deliveries with exponential backoff for up to 3 days. Ensure your endpoint returns a 200 status code promptly to avoid retries.