Continuously synchronizes a Stripe account to a Postgres database.
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.
- 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.
-
balance.available
-
charge.captured
π’ -
charge.expired
π’ -
charge.failed
π’ -
charge.pending
π’ -
charge.refunded
π’ -
charge.succeeded
π’ -
charge.updated
π’ -
charge.dispute.closed
π’ -
charge.dispute.created
π’ -
charge.dispute.funds_reinstated
π’ -
charge.dispute.funds_withdrawn
π’ -
charge.dispute.updated
π’ -
checkout.session.async_payment_failed
-
checkout.session.async_payment_succeeded
-
checkout.session.completed
-
credit_note.created
π’ -
credit_note.updated
π’ -
credit_note.voided
π’ -
customer.created
π’ -
customer.deleted
π’ -
customer.source.created
-
customer.source.updated
-
customer.subscription.created
π’ -
customer.subscription.deleted
π’ -
customer.subscription.paused
π’ -
customer.subscription.pending_update_applied
π’ -
customer.subscription.pending_update_expired
π’ -
customer.subscription.resumed
π’ -
customer.subscription.trial_will_end
π’ -
customer.subscription.updated
π’ -
customer.tax_id.created
π’ -
customer.tax_id.deleted
π’ -
customer.tax_id.updated
π’ -
customer.updated
π’ -
invoice.created
π’ -
invoice.deleted
π’ -
invoice.finalized
π’ -
invoice.finalization_failed
π’ -
invoice.marked_uncollectible
π’ -
invoice.paid
π’ -
invoice.payment_action_required
π’ -
invoice.payment_failed
π’ -
invoice.payment_succeeded
π’ -
invoice.sent
π’ -
invoice.upcoming
π’ -
invoice.updated
π’ -
invoice.voided
π’ -
issuing_authorization.request
-
issuing_card.created
-
issuing_cardholder.created
-
payment_intent.amount_capturable_updated
π’ -
payment_intent.canceled
π’ -
payment_intent.created
π’ -
payment_intent.partially_refunded
π’ -
payment_intent.payment_failed
π’ -
payment_intent.processing
π’ -
payment_intent.requires_action
π’ -
payment_intent.succeeded
π’ -
payment_method.attached
π’ -
payment_method.automatically_updated
π’ -
payment_method.detached
π’ -
payment_method.updated
π’ -
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.requires_action
π’ -
setup_intent.setup_failed
π’ -
setup_intent.succeeded
π’ -
subscription_schedule.aborted
π’ -
subscription_schedule.canceled
π’ -
subscription_schedule.completed
π’ -
subscription_schedule.created
π’ -
subscription_schedule.expiring
π’ -
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:https://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
- eg:
- Point your Stripe webooks to your deployed app.
POST /sync
body: {
"object": "product",
"created": {
"gte": 1643872333
}
}
object
all | charge | customer | dispute | invoice | payment_method | payment_intent | plan | price | product | setup_intent | subscriptioncreated
is Stripe.RangeQueryParam. It supports gt, gte, lt, lte
POST /sync/daily
---
POST /sync/daily
body: {
"object": "product"
}
To backfill/update a single entity, you can use
POST /sync/single/cus_12345
The entity type is recognized automatically, based on the prefix.
- 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 supabase.com (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
Develop
npm run dev
to start the local servernpm run test
to run tests
Building Docker
docker build -t stripe-sync-engine .
docker run -p 8080:8080 stripe-sync-engine
Release
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.