[PR #6345] [CLOSED] fix(stripe): properly merge subscription_data to preserve free trial #6607

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6345
Author: @mohamede1945
Created: 11/27/2025
Status: Closed

Base: canaryHead: fix/stripe-subscription-data-merge


📝 Commits (2)

  • c12de27 fix(stripe): properly merge subscription_data to preserve free trial
  • 1367ab7 Merge branch 'canary' into fix/stripe-subscription-data-merge

📊 Changes

1 file changed (+4 additions, -3 deletions)

View changed files

📝 packages/stripe/src/index.ts (+4 -3)

📄 Description

Summary

  • Fixes an issue where using getCheckoutSessionParams to add custom subscription_data (e.g., description or metadata) would overwrite the free trial settings
  • Ensures subscription_data from user params is properly merged with freeTrial instead of replacing it entirely

Problem

When adding custom subscription data like this:

return {
  params: {
    subscription_data: {
      metadata: {
        organization_name: organization.slug,
      },
      description: `Product XYZ ${planName} subscription for ${organization.slug}`,
    },
  },
};

The free trial would be disabled because ...params?.params was spread after subscription_data, completely replacing it.

Solution

Move the subscription_data object to be defined after ...params?.params and properly merge both the freeTrial settings and any user-provided subscription_data options.

Test plan

  • Verify that free trial works when no custom subscription_data is passed
  • Verify that free trial works when custom subscription_data (description, metadata) is passed via getCheckoutSessionParams

🤖 Generated with Claude Code


Summary by cubic

Fixes a bug where custom subscription_data passed to getCheckoutSessionParams disabled the free trial. We now merge user subscription_data with the freeTrial settings, preserving trials while keeping custom description/metadata.

Written for commit 1367ab7286. Summary will update automatically 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/6345 **Author:** [@mohamede1945](https://github.com/mohamede1945) **Created:** 11/27/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/stripe-subscription-data-merge` --- ### 📝 Commits (2) - [`c12de27`](https://github.com/better-auth/better-auth/commit/c12de2754cb26ff1dea2cdaa462211422b543abd) fix(stripe): properly merge subscription_data to preserve free trial - [`1367ab7`](https://github.com/better-auth/better-auth/commit/1367ab728681b9d46afbf1647e72a07d14585014) Merge branch 'canary' into fix/stripe-subscription-data-merge ### 📊 Changes **1 file changed** (+4 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/index.ts` (+4 -3) </details> ### 📄 Description ## Summary - Fixes an issue where using `getCheckoutSessionParams` to add custom `subscription_data` (e.g., description or metadata) would overwrite the free trial settings - Ensures `subscription_data` from user params is properly merged with `freeTrial` instead of replacing it entirely ## Problem When adding custom subscription data like this: ```ts return { params: { subscription_data: { metadata: { organization_name: organization.slug, }, description: `Product XYZ ${planName} subscription for ${organization.slug}`, }, }, }; ``` The free trial would be disabled because `...params?.params` was spread after `subscription_data`, completely replacing it. ## Solution Move the `subscription_data` object to be defined after `...params?.params` and properly merge both the `freeTrial` settings and any user-provided `subscription_data` options. ## Test plan - [x] Verify that free trial works when no custom `subscription_data` is passed - [x] Verify that free trial works when custom `subscription_data` (description, metadata) is passed via `getCheckoutSessionParams` 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes a bug where custom subscription_data passed to getCheckoutSessionParams disabled the free trial. We now merge user subscription_data with the freeTrial settings, preserving trials while keeping custom description/metadata. <sup>Written for commit 1367ab728681b9d46afbf1647e72a07d14585014. Summary will update automatically 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:05:15 -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#6607