Skip to content
Switch branches/tags

Latest commit

* feat: upsertCharge

* fix: remove unused props from charge schema

* fix: listen to charge webhook events

* fix: add charge unit tests

* chore: new migration script to clean up charges table

* chore: tidy up

* fix: ts warning

Git stats


Failed to load latest commit information.

Stripe Sync Engine (Experimental)

Continuously synchronizes a Stripe account to a Postgres database.

Note: this is experimental. There are no guarantees that it will be supported in the future.

Sync Stripe with Postgres


Sometimes you want to analyze your billing data using SQL. Even more importantly, you want to join your billing data to your product/business data.

This server synchronizes your Stripe account to a Postgres database. It can be a new database, or an existing Postgres database.

How it works

How it works

  • Creates a new schema stripe in a Postgres database, with tables & columns matching Stripe.
  • Exposes a /webhooks endpoint that listens to any Stripe webhooks.
  • Inserts/updates/deletes changes into the tables whenever there is a change to Stripe.

Not implemented

  • This will not do an initial load of existing Stripe data. You should use CSV loads for this. We might implement this in the future.
  • We are progressively working through webhooks.

Webhook Progress

  • balance.available
  • charge.captured
  • charge.dispute.created
  • charge.failed
  • charge.refunded
  • charge.succeeded
  • checkout.session.async_payment_failed
  • checkout.session.async_payment_succeeded
  • checkout.session.completed
  • customer.created 🟢
  • customer.deleted
  • customer.source.created
  • customer.source.updated
  • customer.subscription.created 🟢
  • customer.subscription.deleted 🟢
  • customer.subscription.updated 🟢
  • customer.updated 🟢
  • invoice.created 🟢
  • invoice.finalized 🟢
  • invoice.paid 🟢
  • invoice.payment_failed 🟢
  • invoice.payment_succeeded 🟢
  • invoice.updated 🟢
  • issuing_authorization.request
  • issuing_card.created
  • issuing_cardholder.created
  • payment_intent.amount_capturable_updated
  • payment_intent.canceled
  • payment_intent.created
  • payment_intent.payment_failed
  • payment_intent.succeeded
  • payment_method.attached
  • plan.created
  • plan.deleted
  • plan.updated
  • price.created 🟢
  • price.deleted 🟢
  • price.updated 🟢
  • product.created 🟢
  • product.deleted 🟢
  • product.updated 🟢
  • setup_intent.canceled
  • setup_intent.created
  • setup_intent.setup_failed
  • setup_intent.succeeded
  • subscription_schedule.canceled
  • subscription_schedule.created
  • subscription_schedule.released
  • subscription_schedule.updated


  • Update your Stripe account with all valid webhooks and get the webhook secret
  • mv .env.sample .env and then rename all the variables
  • Make sure the database URL has search_path stripe. eg: DATABASE_URL=postgres://postgres:postgres@hostname:5432/postgres?sslmode=disable&search_path=stripe
  • Deploy the docker image to your favourite hosting service and expose port 8080
    • eg: docker run -e PORT=8080 --env-file .env supabase/stripe-sync-engine
    • This will automatically run any migrations on your database
  • Point your Stripe webooks to your deployed app.

Future ideas

  • Expose a "sync" endpoint for each table which will manually fetch and sync from Stripe.
  • Expose an "initialize" endpoint that will fetch data from Stripe and do an initial load (or perhaps POST a CSV to an endpoint).


Set up

  • Create a Postgres database on (or another Postgres provider)
  • Update Stripe with all valid webhooks and get the webhook secret
  • mv .env.sample .env and then rename all the variables


  • npm run dev to start the local server
  • npm run test to run tests

Building Docker

docker build -t stripe-sync-engine .
docker run -p 8080:8080 stripe-sync-engine


Handled by GitHub actions whenever their is a commit to the main branch with fix or feat in the description.


Apache 2.0


Supabase is building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves.

New Sponsor