[PR #7962] [CLOSED] fix(stripe): replace customers.search with customers.list for regional compatibility #7655

Closed
opened 2026-03-13 13:44:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7962
Author: @bhagyamudgal
Created: 2/13/2026
Status: Closed

Base: canaryHead: fix/stripe-customers-search-regional-availability


📝 Commits (1)

  • 1acec8d fix(stripe): replace customers.search with customers.list for regional compatibility

📊 Changes

7 files changed (+69 additions, -75 deletions)

View changed files

📝 packages/stripe/src/index.ts (+9 -5)
📝 packages/stripe/src/routes.ts (+14 -9)
📝 packages/stripe/src/utils.ts (+0 -11)
📝 packages/stripe/test/seat-based-billing.test.ts (+1 -2)
📝 packages/stripe/test/stripe-organization.test.ts (+0 -1)
📝 packages/stripe/test/stripe.test.ts (+44 -32)
📝 packages/stripe/test/utils.test.ts (+1 -15)

📄 Description

Summary

  • Replace all 3 customers.search calls with customers.list + client-side filtering
  • Remove now-unused escapeStripeSearchValue utility
  • Update all test mocks and assertions

Problem

The Stripe Search API (/v1/customers/search) is unavailable in India and other regions. This breaks the entire
subscription flow for merchants in those regions.

Solution

customers.list is universally available. For user lookups, we filter by email (a native list parameter) and exclude organization customers client-side. For org
lookups, we list customers and filter by organizationId metadata client-side.

The behavior is identical — same data, same filtering logic — just using a globally available API.

Changes

File Change
src/index.ts Replace customers.search in user.create hook
src/routes.ts Replace customers.search in org + user paths of upgradeSubscription
src/utils.ts Remove escapeStripeSearchValue (no longer needed)
test/stripe.test.ts Update mocks from customers.search to customers.list
test/seat-based-billing.test.ts Update mock setup
test/stripe-organization.test.ts Remove unused search mock
test/utils.test.ts Remove escapeStripeSearchValue tests

Test plan

  • pnpm build succeeds (all 19 packages)
  • pnpm --filter @better-auth/stripe test passes (112/112 tests)
  • pnpm format produces no changes

Closes #7959


Summary by cubic

Replaced Stripe customers.search with customers.list + client-side filtering to restore subscription flow in regions where Search API isn’t available (e.g., India). Behavior is unchanged; now globally compatible.

  • Bug Fixes
    • User lookup: list by email and ignore organization customers client-side.
    • Org lookup: list customers and filter by organizationId metadata client-side.
    • Removed escapeStripeSearchValue; updated all mocks and tests to use customers.list.

Written for commit 1acec8deda. 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/7962 **Author:** [@bhagyamudgal](https://github.com/bhagyamudgal) **Created:** 2/13/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/stripe-customers-search-regional-availability` --- ### 📝 Commits (1) - [`1acec8d`](https://github.com/better-auth/better-auth/commit/1acec8deda42c5913feb150f641ffc2f6407ecff) fix(stripe): replace customers.search with customers.list for regional compatibility ### 📊 Changes **7 files changed** (+69 additions, -75 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/index.ts` (+9 -5) 📝 `packages/stripe/src/routes.ts` (+14 -9) 📝 `packages/stripe/src/utils.ts` (+0 -11) 📝 `packages/stripe/test/seat-based-billing.test.ts` (+1 -2) 📝 `packages/stripe/test/stripe-organization.test.ts` (+0 -1) 📝 `packages/stripe/test/stripe.test.ts` (+44 -32) 📝 `packages/stripe/test/utils.test.ts` (+1 -15) </details> ### 📄 Description ## Summary - Replace all 3 `customers.search` calls with `customers.list` + client-side filtering - Remove now-unused `escapeStripeSearchValue` utility - Update all test mocks and assertions ## Problem The Stripe Search API (`/v1/customers/search`) is [unavailable in India and other regions](https://docs.stripe.com/search#supported-countries). This breaks the entire subscription flow for merchants in those regions. ## Solution `customers.list` is universally available. For user lookups, we filter by `email` (a native list parameter) and exclude organization customers client-side. For org lookups, we list customers and filter by `organizationId` metadata client-side. The behavior is identical — same data, same filtering logic — just using a globally available API. ## Changes | File | Change | |------|--------| | `src/index.ts` | Replace `customers.search` in user.create hook | | `src/routes.ts` | Replace `customers.search` in org + user paths of upgradeSubscription | | `src/utils.ts` | Remove `escapeStripeSearchValue` (no longer needed) | | `test/stripe.test.ts` | Update mocks from `customers.search` to `customers.list` | | `test/seat-based-billing.test.ts` | Update mock setup | | `test/stripe-organization.test.ts` | Remove unused `search` mock | | `test/utils.test.ts` | Remove `escapeStripeSearchValue` tests | ## Test plan - [x] `pnpm build` succeeds (all 19 packages) - [x] `pnpm --filter @better-auth/stripe test` passes (112/112 tests) - [x] `pnpm format` produces no changes Closes #7959 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Replaced Stripe customers.search with customers.list + client-side filtering to restore subscription flow in regions where Search API isn’t available (e.g., India). Behavior is unchanged; now globally compatible. - **Bug Fixes** - User lookup: list by email and ignore organization customers client-side. - Org lookup: list customers and filter by organizationId metadata client-side. - Removed escapeStripeSearchValue; updated all mocks and tests to use customers.list. <sup>Written for commit 1acec8deda42c5913feb150f641ffc2f6407ecff. 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-03-13 13:44:35 -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#7655