ashutoshpw/stripe-sync-engine

No description

0 stars0 forksUpdated Jan 25, 2026
npx skills add ashutoshpw/stripe-sync-engine

README

Stripe Sync Engine

Test

A TypeScript library to synchronize Stripe data into a PostgreSQL database, designed for use in Node.js backends and serverless environments.

Features

  • Sync Stripe objects (customers, invoices, products, etc.) to your PostgreSQL database.
  • Handles Stripe webhooks for real-time updates.
  • Supports backfilling and entity revalidation.

Installation

npm install stripe-sync-engine stripe
# or
pnpm add stripe-sync-engine stripe
# or
yarn add stripe-sync-engine stripe
# or
bun add stripe-sync-engine stripe

For Deno, leverage npm specifiers:

import { StripeSync } from 'npm:stripe-sync-engine@latest'

Usage

import { StripeSync } from 'stripe-sync-engine'

const sync = new StripeSync({
  poolConfig: {
    connectionString: 'postgres://user:pass@host:port/db',
    max: 10, // Maximum number of connections
  },
  stripeSecretKey: 'sk_test_...',
  stripeWebhookSecret: 'whsec_...',
  // logger: <a pino logger>
})

// Example: process a Stripe webhook
await sync.processWebhook(payload, signature)

Configuration

OptionTypeDescription
databaseUrlstringDeprecated: Use poolConfig with a connection string instead.
schemastringDatabase schema name (default: stripe)
tablePrefixstringOptional prefix for all table names. An underscore is auto-appended if not present. Example: 'billing' results in billing_products, billing_customers, etc. (default: empty string)
stripeSecretKeystringStripe secret key
stripeWebhookSecretstringStripe webhook signing secret
stripeApiVersionstringStripe API version (default: 2020-08-27)
autoExpandListsbooleanFetch all list items from Stripe (not just the default 10)
backfillRelatedEntitiesbooleanEnsure related entities are present for foreign key integrity
revalidateObjectsViaStripeApiArrayAlways fetch latest entity from Stripe instead of trusting webhook payload, possible values: charge, credit_note, customer, dispute, invoice, payment_intent, payment_method, plan, price, product, refund, review, radar.early_fraud_warning, setup

...

Read full README

Publisher

ashutoshpwashutoshpw

Statistics

Stars0
Forks0
Open Issues0
CreatedNov 10, 2025