-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metered product to checkout session (#9788)
Solves twentyhq/private-issues#238 **TLDR:** Add metered product in the checkout session when purchasing a subscription **In order to test:** 1. Have the environment variable IS_BILLING_ENABLED set to true and add the other required environment variables for Billing to work 2. Do a database reset (to ensure that the new feature flag is properly added and that the billing tables are created) 3. Run the command: npx nx run twenty-server:command billing:sync-plans-data (if you don't do that the products and prices will not be present in the database) 4. Run the server , the frontend, the worker, and the stripe listen command (stripe listen --forward-to http://localhost:3000/billing/webhooks) 5. Buy a subscription for the Acme workspace , in the checkout session you should see that there is two products
- Loading branch information
Showing
7 changed files
with
193 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...y-server/src/engine/core-modules/billing/types/billing-get-prices-per-plan-result.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BillingPrice } from 'src/engine/core-modules/billing/entities/billing-price.entity'; | ||
|
||
export type BillingGetPricesPerPlanResult = { | ||
baseProductPrice: BillingPrice; | ||
meteredProductsPrices: BillingPrice[]; | ||
otherLicensedProductsPrices: BillingPrice[]; | ||
}; |
14 changes: 14 additions & 0 deletions
14
.../src/engine/core-modules/billing/types/billing-portal-checkout-session-parameters.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum'; | ||
import { BillingGetPricesPerPlanResult } from 'src/engine/core-modules/billing/types/billing-get-prices-per-plan-result.type'; | ||
import { User } from 'src/engine/core-modules/user/user.entity'; | ||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; | ||
|
||
export type BillingPortalCheckoutSessionParameters = { | ||
user: User; | ||
workspace: Workspace; | ||
billingPricesPerPlan?: BillingGetPricesPerPlanResult; | ||
successUrlPath?: string; | ||
plan: BillingPlanKey; | ||
priceId?: string; | ||
requirePaymentMethod?: boolean; | ||
}; |