[PR #7965] [MERGED] fix(stripe): fall back to customers.list when customers.search API is unavailable #24557

Closed
opened 2026-04-15 22:25:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7965
Author: @bytaesu
Created: 2/13/2026
Status: Merged
Merged: 2/15/2026
Merged by: @himself65

Base: canaryHead: 2026-02-14/fix/stripe-search-api-regional-fallback


📝 Commits (3)

  • ee0b484 fix(stripe): fall back to customers.list when Search API is unavailable
  • 7ba0d69 chore: add logger
  • 0231560 test: improve case

📊 Changes

3 files changed (+231 additions, -20 deletions)

View changed files

📝 packages/stripe/src/index.ts (+26 -6)
📝 packages/stripe/src/routes.ts (+52 -14)
📝 packages/stripe/test/stripe.test.ts (+153 -0)

📄 Description

Note

https://github.com/stripe/stripe-node#auto-pagination

Since emails aren't directly tied to the organization, there's no server side filter we can use with the list method. Using search is the optimal approach, but Stripe mentions that this API may not be available in some countries.

In those cases, even if there are performance tradeoffs, we'll fall back to list method.


Summary by cubic

Add a safe fallback to Stripe customers.list when customers.search is unavailable in some regions, preventing duplicate customers for users and organizations.

  • Bug Fixes
    • Try customers.search first; on failure, log a warning and scan customers.list (limit 100) to find existing records.
    • For users, match by email and skip organization customers via metadata (customerType !== "organization").
    • For organizations, match by metadata organizationId.
    • Applied in user signup/customer link and upgradeSubscription flows.
    • Tests cover signup and upgrade fallbacks to ensure no duplicate creation.

Written for commit 0231560939. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7965 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/13/2026 **Status:** ✅ Merged **Merged:** 2/15/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-02-14/fix/stripe-search-api-regional-fallback` --- ### 📝 Commits (3) - [`ee0b484`](https://github.com/better-auth/better-auth/commit/ee0b4844455050efe3499d07d0f30b259a043cc0) fix(stripe): fall back to customers.list when Search API is unavailable - [`7ba0d69`](https://github.com/better-auth/better-auth/commit/7ba0d69f9a430d31193cdaefd424384d8bc9157e) chore: add logger - [`0231560`](https://github.com/better-auth/better-auth/commit/023156093929a0755a002a2baf917392c68d6c24) test: improve case ### 📊 Changes **3 files changed** (+231 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/index.ts` (+26 -6) 📝 `packages/stripe/src/routes.ts` (+52 -14) 📝 `packages/stripe/test/stripe.test.ts` (+153 -0) </details> ### 📄 Description > [!NOTE] > https://github.com/stripe/stripe-node#auto-pagination Since emails aren't directly tied to the organization, there's no server side filter we can use with the list method. Using search is the optimal approach, but Stripe mentions that this API may not be available in some countries. In those cases, even if there are performance tradeoffs, we'll fall back to list method. - Closes #7959 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add a safe fallback to Stripe customers.list when customers.search is unavailable in some regions, preventing duplicate customers for users and organizations. - **Bug Fixes** - Try customers.search first; on failure, log a warning and scan customers.list (limit 100) to find existing records. - For users, match by email and skip organization customers via metadata (customerType !== "organization"). - For organizations, match by metadata organizationId. - Applied in user signup/customer link and upgradeSubscription flows. - Tests cover signup and upgrade fallbacks to ensure no duplicate creation. <sup>Written for commit 023156093929a0755a002a2baf917392c68d6c24. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:25:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#24557