home / skills / andrelandgraf / fullstackrecipes / stripe-sync

stripe-sync skill

/.agents/skills/stripe-sync

This skill automates Stripe subscriptions syncing with Postgres via webhooks, Vercel flags for plan configuration, and billing portal integration.

npx playbooks add skill andrelandgraf/fullstackrecipes --skill stripe-sync

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
574 B
---
name: stripe-sync
description: Complete subscription system with Stripe, Vercel Flags for plan configuration, webhook handling for syncing subscription state to Postgres, usage tracking, and billing portal integration.
---

# Stripe Subscriptions DB Sync

To set up Stripe Subscriptions DB Sync, refer to the fullstackrecipes MCP server resource:

**Resource URI:** `recipe://fullstackrecipes.com/stripe-sync`

If the MCP server is not configured, fetch the recipe directly:

```bash
curl -H "Accept: text/plain" https://fullstackrecipes.com/api/recipes/stripe-sync
```

Overview

This skill implements a complete Stripe subscription system that syncs billing state to Postgres, integrates a billing portal, tracks usage, and supports plan configuration via Vercel Flags. It provides webhook handling and production-ready patterns to keep your database in sync with Stripe subscription lifecycle events. The codebase is TypeScript-first and designed for full-stack AI web apps.

How this skill works

The skill wires Stripe webhooks to server endpoints that parse events and update subscription, customer, and invoice records in Postgres. Vercel Flags drive plan definitions and feature toggles so you can change pricing or entitlements without redeploying. Usage tracking routes metered events into Stripe and your DB, and a billing portal link lets customers manage payment methods and plans. The implementation includes robust idempotency and verification to avoid duplicate state updates.

When to use it

  • You need a reliable, auditable sync between Stripe subscription state and your application database.
  • You want feature and plan control via Vercel Flags for rapid experimentation and rollout.
  • You must support metered usage billing alongside recurring subscriptions.
  • You need an integrated billing portal for user self-service and payment management.
  • You want production-ready webhook handling with idempotency and security best practices.

Best practices

  • Validate Stripe webhook signatures and enforce idempotency keys on processing.
  • Model subscriptions, invoices, and usage records in Postgres to reflect Stripe canonical state.
  • Use Vercel Flags to separate plan configuration from code and avoid migrations for pricing changes.
  • Throttle and queue webhook processing for peak traffic to maintain consistent DB writes.
  • Log events and store raw webhook payloads for debugging and audit trails.

Example use cases

  • Sync new subscription creation to Postgres when a customer purchases a plan on your website.
  • Record metered usage events and reconcile them with Stripe invoicing at period end.
  • Automatically update local user entitlements when Stripe invoices are paid or subscriptions canceled.
  • Expose a billing portal link in user settings so customers can update cards or change plans.
  • Run experiments by toggling feature access and plan tiers via Vercel Flags without redeploying.

FAQ

Does this handle webhook retries and duplicate events?

Yes. The webhook handlers verify signatures, apply idempotency checks, and are safe to retry.

Can I change plan pricing without deploying code?

Yes. Use Vercel Flags to adjust plan configuration and entitlements dynamically.