Skip to content

Commit

Permalink
feat: auto-expand api lists (#104)
Browse files Browse the repository at this point in the history
When Stripe sends webhooks with nested lists, Stripe only sends the first 10 items. For example, if you get a webhook for an invoice and you have more than 10 line items, Stripe won't send the exhaustive list, but only the first 10 items. This leads to missing data in the synced database.

PR introduces a new AUTO_EXPAND_LISTS (opt-in) environment variable to automatically expand API lists that are not exhaustive. Supported lists:

-invoice.lines
-charges.refunds
-subscription.items

When the nested lists are not exhaustive (hasMore: true), we query the Stripe API to fetch the full list before persisting. the entry.

Misc

- Update Github actions to latest majors
- Update local Supabase Postgres image to latest
- Cleaned up duplicate imports from stripe
  • Loading branch information
kevcodez authored Jan 19, 2024
1 parent 03fef42 commit bf5925f
Show file tree
Hide file tree
Showing 15 changed files with 903 additions and 369 deletions.
8 changes: 8 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ PORT=8080

# optional
STRIPE_API_VERSION="2020-08-27"

# optional, needed if you want to automatically fetch related lists that extend 10 entries (Stripe limits the number of entries returned to 10)
# STRIPE_SECRET_KEY needs to be set in order for this to work, as the Stripe API is queried
# Supported lists so far:
## - invoice.lines
## - charges.refunds
## - subscription.items
AUTO_EXPAND_LISTS=false
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
new-release-version: ${{ steps.semantic-release.outputs.new_release_version }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Run semantic-release
id: semantic-release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 19
env:
Expand Down
Loading

0 comments on commit bf5925f

Please sign in to comment.