[PR #7561] [MERGED] refactor(stripe): centralize internal metadata management #7400

Closed
opened 2026-03-13 13:34:59 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7561
Author: @bytaesu
Created: 1/22/2026
Status: Merged
Merged: 1/23/2026
Merged by: @himself65

Base: canaryHead: 2026-01-23/refactor/stripe-metadata-centralization


📝 Commits (4)

  • 9bebae1 refactor: centralize internal metadata management
  • cf62d2c test: add internal metadata helpers test case
  • b9eda7c clear unnecessary type castings
  • a4ac77c Merge branch 'canary' into 2026-01-23/refactor/stripe-metadata-centralization

📊 Changes

5 files changed (+197 additions, -39 deletions)

View changed files

📝 packages/stripe/src/hooks.ts (+10 -5)
📝 packages/stripe/src/index.ts (+10 -6)
packages/stripe/src/metadata.ts (+94 -0)
📝 packages/stripe/src/routes.ts (+38 -28)
📝 packages/stripe/test/stripe.test.ts (+45 -0)

📄 Description

It was hard to distinguish which ones were internal metadata, and the spread order could lead to mistakes, so I refactored.


Summary by cubic

Centralized Stripe internal metadata with new helpers to protect required fields and provide typed access. Updated hooks, routes, and customer creation to use them, improving reliability of searches and event handling.

  • Refactors
    • Added metadata.ts with customerMetadata and subscriptionMetadata helpers (internal fields take priority).
    • Replaced direct metadata access in hooks, routes, and index; updated search queries to use helper keys.
    • Ensured checkout/session and subscription metadata merges preserve internal fields.
    • Added unit tests for set/get behavior.

Written for commit a4ac77cdf3. 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/7561 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 1/22/2026 **Status:** ✅ Merged **Merged:** 1/23/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-01-23/refactor/stripe-metadata-centralization` --- ### 📝 Commits (4) - [`9bebae1`](https://github.com/better-auth/better-auth/commit/9bebae1340eacaa2d0366e34bda447ff0ce57761) refactor: centralize internal metadata management - [`cf62d2c`](https://github.com/better-auth/better-auth/commit/cf62d2ca8ffd055e933426f14859f5b2cf6a93d9) test: add internal metadata helpers test case - [`b9eda7c`](https://github.com/better-auth/better-auth/commit/b9eda7cb4d60d5cf366a2ce35e9002761a777a3b) clear unnecessary type castings - [`a4ac77c`](https://github.com/better-auth/better-auth/commit/a4ac77cdf308da255288b17335d7a44c430ef79d) Merge branch 'canary' into 2026-01-23/refactor/stripe-metadata-centralization ### 📊 Changes **5 files changed** (+197 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/hooks.ts` (+10 -5) 📝 `packages/stripe/src/index.ts` (+10 -6) ➕ `packages/stripe/src/metadata.ts` (+94 -0) 📝 `packages/stripe/src/routes.ts` (+38 -28) 📝 `packages/stripe/test/stripe.test.ts` (+45 -0) </details> ### 📄 Description It was hard to distinguish which ones were internal metadata, and the spread order could lead to mistakes, so I refactored. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Centralized Stripe internal metadata with new helpers to protect required fields and provide typed access. Updated hooks, routes, and customer creation to use them, improving reliability of searches and event handling. - **Refactors** - Added metadata.ts with customerMetadata and subscriptionMetadata helpers (internal fields take priority). - Replaced direct metadata access in hooks, routes, and index; updated search queries to use helper keys. - Ensured checkout/session and subscription metadata merges preserve internal fields. - Added unit tests for set/get behavior. <sup>Written for commit a4ac77cdf308da255288b17335d7a44c430ef79d. 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:34:59 -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#7400