[PR #5834] fix(stripe): allow custom metadata in subscription_data without overwriting internal fields #14508

Closed
opened 2026-04-13 09:30:44 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5834

State: closed
Merged: No


Allow passing metadata to Stripe subscription via subscription_data while preserving internal fields

Closes https://github.com/better-auth/better-auth/issues/4104


Summary by cubic

Allows custom metadata in Stripe checkout sessions via subscription_data and metadata, merging safely with internal fields and trial settings. Also passes through safe checkout session params while blocking overrides of protected fields.

  • Bug Fixes
    • Merge subscription_data with freeTrial to keep trial_period_days and preserve subscription_data.metadata.
    • Merge custom metadata with internal keys (userId, subscriptionId, referenceId); internal keys win.
    • Pass through non-protected params from getCheckoutSessionParams (e.g., allow_promotion_codes, tax_id_collection, custom_text) and options (e.g., idempotencyKey); block overrides of customer, customer_email, line_items, mode, client_reference_id, success_url, cancel_url.
    • Added tests for metadata merging, safe param passthrough, and idempotencyKey.

Written for commit ef666b830a. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5834 **State:** closed **Merged:** No --- Allow passing metadata to Stripe subscription via `subscription_data` while preserving internal fields Closes https://github.com/better-auth/better-auth/issues/4104 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Allows custom metadata in Stripe checkout sessions via subscription_data and metadata, merging safely with internal fields and trial settings. Also passes through safe checkout session params while blocking overrides of protected fields. - **Bug Fixes** - Merge subscription_data with freeTrial to keep trial_period_days and preserve subscription_data.metadata. - Merge custom metadata with internal keys (userId, subscriptionId, referenceId); internal keys win. - Pass through non-protected params from getCheckoutSessionParams (e.g., allow_promotion_codes, tax_id_collection, custom_text) and options (e.g., idempotencyKey); block overrides of customer, customer_email, line_items, mode, client_reference_id, success_url, cancel_url. - Added tests for metadata merging, safe param passthrough, and idempotencyKey. <sup>Written for commit ef666b830adecde4038bfd417ff82ef72e13282c. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:30:44 -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#14508