Skip to main content

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

EventDescription
checkout.session.completedCustomer completed a checkout session
customer.subscription.createdNew subscription created
customer.subscription.updatedSubscription plan changed, renewed, or modified
customer.subscription.deletedSubscription canceled
invoice.paidInvoice payment succeeded
invoice.payment_failedInvoice 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.