[PR #734] [MERGED] feat: add multi subscription support #1147

Closed
opened 2026-02-26 19:32:02 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/734
Author: @dguyen
Created: 12/6/2023
Status: Merged
Merged: 12/14/2023
Merged by: @dguyen

Base: mainHead: feat/multi-subscription-support


📝 Commits (4)

  • 77ade7d feat: add multi subscription support
  • f52eef8 chore: refactor based on feedback
  • 7053c95 fix: remove redundant customerId
  • 0c33118 chore: remove whitespace

📊 Changes

28 files changed (+289 additions, -367 deletions)

View changed files

📝 .env.example (+0 -4)
📝 apps/marketing/process-env.d.ts (+0 -2)
apps/marketing/src/components/(marketing)/claim-plan-dialog.tsx (+0 -160)
📝 apps/marketing/src/components/(marketing)/pricing-table.tsx (+3 -8)
📝 apps/web/process-env.d.ts (+0 -2)
📝 apps/web/src/app/(dashboard)/admin/users/data-table-users.tsx (+17 -4)
📝 apps/web/src/app/(dashboard)/admin/users/page.tsx (+15 -2)
📝 apps/web/src/app/(dashboard)/settings/billing/billing-plans.tsx (+1 -1)
📝 apps/web/src/app/(dashboard)/settings/billing/create-billing-portal.action.ts (+2 -35)
📝 apps/web/src/app/(dashboard)/settings/billing/create-checkout.action.ts (+12 -31)
📝 apps/web/src/app/(dashboard)/settings/billing/page.tsx (+26 -7)
📝 packages/ee/server-only/limits/server.ts (+23 -17)
packages/ee/server-only/stripe/create-customer.ts (+0 -31)
📝 packages/ee/server-only/stripe/get-customer.ts (+75 -0)
📝 packages/ee/server-only/stripe/get-prices-by-interval.ts (+12 -3)
packages/ee/server-only/stripe/get-prices-by-type.ts (+11 -0)
📝 packages/ee/server-only/stripe/webhook/handler.ts (+16 -16)
📝 packages/ee/server-only/stripe/webhook/on-subscription-deleted.ts (+2 -5)
📝 packages/ee/server-only/stripe/webhook/on-subscription-updated.ts (+4 -7)
📝 packages/lib/server-only/admin/get-users-stats.ts (+3 -1)

...and 8 more files

📄 Description

Description

Previously we assumed that there can only be 1 subscription per user. However, that will soon no longer the case with the introduction of the Teams subscription.

This PR will apply the required migrations to support multiple subscriptions.

Changes Made

  • Updated the Prisma schema to allow for multiple Subscriptions per User
  • Added a Stripe customerId field to the User model
  • Updated relevant billing sections to support multiple subscriptions

Testing Performed

  • Tested running the Prisma migration on a demo database created on the main branch

Will require a lot of additional testing.

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have followed the project's coding style guidelines.

Additional Notes

Added the following custom SQL statement to the migration:

DELETE FROM "Subscription" WHERE "planId" IS NULL OR "priceId" IS NULL;

Prior to deployment this will require changes to Stripe products:

  • Adding type meta attribute

Summary by CodeRabbit

  • New Features

    • Search functionality with a new search bar added to the app interface.
    • Pricing plans updated to reflect monthly options only.
    • Billing and subscription management logic updated to handle multiple subscriptions per user.
  • Bug Fixes

    • Fixed issues with subscription status updates in billing settings.
    • Corrected user statistics calculations to account for multiple subscriptions.
  • Documentation

    • Updated environment configuration examples to match current variables.
  • Refactor

    • Streamlined Stripe customer retrieval and subscription management processes.
    • Improved handling of Stripe webhook events for subscription updates and deletions.
  • Style

    • Enhanced styles for the new search bar component.
  • Chores

    • Database migrations to support multiple subscriptions per user.
    • Adjustments to TypeScript configurations following updated environment variables.
  • Revert

    • None reported.

🔄 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/documenso/documenso/pull/734 **Author:** [@dguyen](https://github.com/dguyen) **Created:** 12/6/2023 **Status:** ✅ Merged **Merged:** 12/14/2023 **Merged by:** [@dguyen](https://github.com/dguyen) **Base:** `main` ← **Head:** `feat/multi-subscription-support` --- ### 📝 Commits (4) - [`77ade7d`](https://github.com/documenso/documenso/commit/77ade7d155fee2749c65c9e0e014d8773b74444e) feat: add multi subscription support - [`f52eef8`](https://github.com/documenso/documenso/commit/f52eef845981761e2702870abd6f370a26b4e7d6) chore: refactor based on feedback - [`7053c95`](https://github.com/documenso/documenso/commit/7053c957aa74a28fca505c54a4d46389edbfba76) fix: remove redundant customerId - [`0c33118`](https://github.com/documenso/documenso/commit/0c33118af28cd5711b97d2ae65862606e632db79) chore: remove whitespace ### 📊 Changes **28 files changed** (+289 additions, -367 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+0 -4) 📝 `apps/marketing/process-env.d.ts` (+0 -2) ➖ `apps/marketing/src/components/(marketing)/claim-plan-dialog.tsx` (+0 -160) 📝 `apps/marketing/src/components/(marketing)/pricing-table.tsx` (+3 -8) 📝 `apps/web/process-env.d.ts` (+0 -2) 📝 `apps/web/src/app/(dashboard)/admin/users/data-table-users.tsx` (+17 -4) 📝 `apps/web/src/app/(dashboard)/admin/users/page.tsx` (+15 -2) 📝 `apps/web/src/app/(dashboard)/settings/billing/billing-plans.tsx` (+1 -1) 📝 `apps/web/src/app/(dashboard)/settings/billing/create-billing-portal.action.ts` (+2 -35) 📝 `apps/web/src/app/(dashboard)/settings/billing/create-checkout.action.ts` (+12 -31) 📝 `apps/web/src/app/(dashboard)/settings/billing/page.tsx` (+26 -7) 📝 `packages/ee/server-only/limits/server.ts` (+23 -17) ➖ `packages/ee/server-only/stripe/create-customer.ts` (+0 -31) 📝 `packages/ee/server-only/stripe/get-customer.ts` (+75 -0) 📝 `packages/ee/server-only/stripe/get-prices-by-interval.ts` (+12 -3) ➕ `packages/ee/server-only/stripe/get-prices-by-type.ts` (+11 -0) 📝 `packages/ee/server-only/stripe/webhook/handler.ts` (+16 -16) 📝 `packages/ee/server-only/stripe/webhook/on-subscription-deleted.ts` (+2 -5) 📝 `packages/ee/server-only/stripe/webhook/on-subscription-updated.ts` (+4 -7) 📝 `packages/lib/server-only/admin/get-users-stats.ts` (+3 -1) _...and 8 more files_ </details> ### 📄 Description ## Description Previously we assumed that there can only be 1 subscription per user. However, that will soon no longer the case with the introduction of the Teams subscription. This PR will apply the required migrations to support multiple subscriptions. ## Changes Made - Updated the Prisma schema to allow for multiple `Subscriptions` per `User` - Added a Stripe `customerId` field to the `User` model - Updated relevant billing sections to support multiple subscriptions ## Testing Performed - Tested running the Prisma migration on a demo database created on the main branch Will require a lot of additional testing. ## Checklist - [ ] I have tested these changes locally and they work as expected. - [ ] I have added/updated tests that prove the effectiveness of these changes. - [X] I have followed the project's coding style guidelines. ## Additional Notes Added the following custom SQL statement to the migration: > DELETE FROM "Subscription" WHERE "planId" IS NULL OR "priceId" IS NULL; Prior to deployment this will require changes to Stripe products: - Adding `type` meta attribute <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Search functionality with a new search bar added to the app interface. - Pricing plans updated to reflect monthly options only. - Billing and subscription management logic updated to handle multiple subscriptions per user. - **Bug Fixes** - Fixed issues with subscription status updates in billing settings. - Corrected user statistics calculations to account for multiple subscriptions. - **Documentation** - Updated environment configuration examples to match current variables. - **Refactor** - Streamlined Stripe customer retrieval and subscription management processes. - Improved handling of Stripe webhook events for subscription updates and deletions. - **Style** - Enhanced styles for the new search bar component. - **Chores** - Database migrations to support multiple subscriptions per user. - Adjustments to TypeScript configurations following updated environment variables. - **Revert** - None reported. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:32:02 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#1147
No description provided.