[PR #5952] feat(stripe): stripe customer for organization #14592

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

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

State: closed
Merged: No


This PR is based on https://github.com/better-auth/better-auth/pull/2794 by @Cmion

Closes https://github.com/better-auth/better-auth/issues/2079
Closes https://github.com/better-auth/better-auth/issues/3772

Tasks

  • Refactor the Stripe plugin
  • Add a baseline for Stripe customer support at the organization level
  • Add new unit test cases
  • Test it in a real application
  • Migrate existing test cases to getTestInstance
  • Update docs

To-do (Not in this PR)

  • We need two API endpoints to fetch and update stripeAdminId since the admin can change in an organization.

Summary by cubic

Added organization Stripe customer support with automatic customer creation, syncing, and safer deletion checks. Also strengthened Stripe error handling and consolidated utilities for clear, consistent messages across subscription and webhook flows.

  • New Features

    • Added enableOrganizationCustomer to create and link Stripe customers to organizations.
    • Synced organization name changes to Stripe; deleted Stripe customer on org deletion.
    • Blocked organization deletion when active Stripe subscriptions exist.
    • Used activeOrganizationId to scope customer and subscription operations.
    • Extended schema with organization.stripeCustomerId and organization.stripeAdminUserId.
    • Added onOrganizationCustomerCreate callback to run after creating an organization customer.
  • Bug Fixes

    • Added strict webhook validation with explicit errors for missing signature/secret and invalid events.
    • Returned BAD_REQUEST with specific error codes for common failures (price, subscription, customer, request body), avoiding generic 500s.

Written for commit 8d1036799a. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5952 **State:** closed **Merged:** No --- This PR is based on https://github.com/better-auth/better-auth/pull/2794 by @Cmion Closes https://github.com/better-auth/better-auth/issues/2079 Closes https://github.com/better-auth/better-auth/issues/3772 ### Tasks - [x] Refactor the Stripe plugin - [x] Add a baseline for Stripe customer support at the organization level - [x] Add new unit test cases - [x] Test it in a real application - [x] Migrate existing test cases to getTestInstance - [x] Update docs ### To-do (Not in this PR) - We need two API endpoints to fetch and update `stripeAdminId` since the admin can change in an organization. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Added organization Stripe customer support with automatic customer creation, syncing, and safer deletion checks. Also strengthened Stripe error handling and consolidated utilities for clear, consistent messages across subscription and webhook flows. - New Features - Added enableOrganizationCustomer to create and link Stripe customers to organizations. - Synced organization name changes to Stripe; deleted Stripe customer on org deletion. - Blocked organization deletion when active Stripe subscriptions exist. - Used activeOrganizationId to scope customer and subscription operations. - Extended schema with organization.stripeCustomerId and organization.stripeAdminUserId. - Added onOrganizationCustomerCreate callback to run after creating an organization customer. - Bug Fixes - Added strict webhook validation with explicit errors for missing signature/secret and invalid events. - Returned BAD_REQUEST with specific error codes for common failures (price, subscription, customer, request body), avoiding generic 500s. <sup>Written for commit 8d1036799a86d4c498103f64754df71a1864c96e. 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:32:14 -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#14592