-
Notifications
You must be signed in to change notification settings - Fork 435
feat(clerk-js,shared): Add parsing for SBB fields #7785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/seat-based-billing
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/shared': minor | ||
| --- | ||
|
|
||
| Add support for parsing seat-based billing fields from FAPI. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,6 +206,10 @@ export interface BillingPlanResource extends ClerkResource { | |
| * The Features the Plan offers. | ||
| */ | ||
| features: FeatureResource[]; | ||
| /** | ||
| * Per-unit pricing tiers for this Plan (for example, seats). | ||
| */ | ||
| unitPrices?: BillingPlanUnitPrice[]; | ||
| /** | ||
| * The number of days of the free trial for the Plan. `null` if the Plan does not have a free trial. | ||
| */ | ||
|
|
@@ -216,6 +220,102 @@ export interface BillingPlanResource extends ClerkResource { | |
| freeTrialEnabled: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * The `BillingSubscriptionItemSeats` type represents seat entitlements attached to a subscription item. | ||
| * | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| */ | ||
| export interface BillingSubscriptionItemSeats { | ||
| /** | ||
| * The seat limit active while the parent subscription item was active. `null` means unlimited. | ||
| */ | ||
| quantity: number | null; | ||
| } | ||
|
|
||
| /** | ||
| * The `BillingPlanUnitPriceTier` type represents a single pricing tier for a unit type on a plan. | ||
| * | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| */ | ||
| export interface BillingPlanUnitPriceTier { | ||
| /** | ||
| * The unique identifier of the unit price tier. | ||
| */ | ||
| id: string; | ||
|
Comment on lines
+241
to
+244
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember, were we exposing this? |
||
| /** | ||
| * The first block number this tier applies to. | ||
| */ | ||
| startsAtBlock: number; | ||
| /** | ||
| * The final block this tier applies to. `null` means unlimited. | ||
| */ | ||
| endsAfterBlock: number | null; | ||
| /** | ||
| * The fee charged for each block in this tier. | ||
| */ | ||
| feePerBlock: BillingMoneyAmount; | ||
| } | ||
|
|
||
| /** | ||
| * The `BillingPlanUnitPrice` type represents unit pricing for a specific unit type (for example, seats) on a plan. | ||
| * | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| */ | ||
| export interface BillingPlanUnitPrice { | ||
| /** | ||
| * The unit name, for example `seats`. | ||
| */ | ||
| name: string; | ||
| /** | ||
| * Number of units represented by one billable block. | ||
| */ | ||
| blockSize: number; | ||
| /** | ||
| * Tiers that define how each block range is priced. | ||
| */ | ||
| tiers: BillingPlanUnitPriceTier[]; | ||
| } | ||
|
|
||
| /** | ||
| * The `BillingPerUnitTotalTier` type represents the cost breakdown for a single tier in checkout totals. | ||
| * | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| */ | ||
| export interface BillingPerUnitTotalTier { | ||
| /** | ||
| * The quantity billed within this tier. `null` means unlimited. | ||
| */ | ||
| quantity: number | null; | ||
| /** | ||
| * The fee charged per block for this tier. | ||
| */ | ||
| feePerBlock: BillingMoneyAmount; | ||
| /** | ||
| * The total billed amount for this tier. | ||
| */ | ||
| total: BillingMoneyAmount; | ||
| } | ||
|
|
||
| /** | ||
| * The `BillingPerUnitTotal` type represents the per-unit cost breakdown in checkout totals. | ||
| * | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| */ | ||
| export interface BillingPerUnitTotal { | ||
| /** | ||
| * The unit name, for example `seats`. | ||
| */ | ||
| name: string; | ||
| /** | ||
| * Number of units represented by one billable block. | ||
| */ | ||
| blockSize: number; | ||
| /** | ||
| * Detailed tier breakdown for this unit total. | ||
| */ | ||
| tiers: BillingPerUnitTotalTier[]; | ||
| } | ||
|
|
||
| /** | ||
| * The `FeatureResource` type represents a Feature of a Plan. | ||
| * | ||
|
|
@@ -593,6 +693,11 @@ export interface BillingSubscriptionItemResource extends ClerkResource { | |
| */ | ||
| amount: BillingMoneyAmount; | ||
| }; | ||
| /** | ||
| * Seat entitlement details for this subscription item. Only set for organization subscription items with | ||
| * seat-based billing. | ||
| */ | ||
| seats?: BillingSubscriptionItemSeats; | ||
| /** | ||
| * A function to cancel the subscription item. Accepts the following parameters: | ||
| * <ul> | ||
|
|
@@ -708,6 +813,10 @@ export interface BillingCheckoutTotals { | |
| * The amount of tax included in the checkout. | ||
| */ | ||
| taxTotal: BillingMoneyAmount; | ||
| /** | ||
| * Per-unit cost breakdown for this checkout (for example, seats). | ||
| */ | ||
| perUnitTotals?: BillingPerUnitTotal[]; | ||
| /** | ||
| * The amount that needs to be immediately paid to complete the checkout. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -596,6 +596,68 @@ export interface FeatureJSON extends ClerkResourceJSON { | |
| avatar_url: string | null; | ||
| } | ||
|
|
||
| /** | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| */ | ||
| export interface BillingSubscriptionItemSeatsJSON { | ||
| /** | ||
| * The number of seats available. `null` means unlimited. | ||
| */ | ||
| quantity: number | null; | ||
| } | ||
|
|
||
| /** | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| * | ||
| * Represents a single pricing tier for a unit type on a plan. | ||
| */ | ||
| export interface BillingPlanUnitPriceTierJSON { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| id: string; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forget if we were exposing this or not.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| object: 'commerce_unit_price'; | ||
| starts_at_block: number; | ||
| /** | ||
| * `null` means unlimited. | ||
| */ | ||
| ends_after_block: number | null; | ||
| fee_per_block: BillingMoneyAmountJSON; | ||
| } | ||
|
|
||
| /** | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| * | ||
| * Represents unit pricing for a specific unit type (for example, seats) on a plan. | ||
| */ | ||
| export interface BillingPlanUnitPriceJSON { | ||
| name: string; | ||
| block_size: number; | ||
| tiers: BillingPlanUnitPriceTierJSON[]; | ||
| } | ||
|
|
||
| /** | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| * | ||
| * Represents the cost breakdown for a single tier in checkout totals. | ||
| */ | ||
| export interface BillingPerUnitTotalTierJSON { | ||
| /** | ||
| * `null` means unlimited. | ||
| */ | ||
| quantity: number | null; | ||
| fee_per_block: BillingMoneyAmountJSON; | ||
| total: BillingMoneyAmountJSON; | ||
| } | ||
|
|
||
| /** | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| * | ||
| * Represents the per-unit cost breakdown in checkout totals. | ||
| */ | ||
| export interface BillingPerUnitTotalJSON { | ||
| name: string; | ||
| block_size: number; | ||
| tiers: BillingPerUnitTotalTierJSON[]; | ||
| } | ||
|
|
||
| /** | ||
| * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes. | ||
| */ | ||
|
|
@@ -617,6 +679,10 @@ export interface BillingPlanJSON extends ClerkResourceJSON { | |
| features?: FeatureJSON[]; | ||
| free_trial_days?: number | null; | ||
| free_trial_enabled?: boolean; | ||
| /** | ||
| * Per-unit pricing tiers for this plan (for example, seats). | ||
| */ | ||
| unit_prices?: BillingPlanUnitPriceJSON[]; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -695,6 +761,11 @@ export interface BillingSubscriptionItemJSON extends ClerkResourceJSON { | |
| credit?: { | ||
| amount: BillingMoneyAmountJSON; | ||
| }; | ||
| /** | ||
| * Seat entitlement details for this subscription item. Only set for organization subscription items with | ||
| * seat-based billing. | ||
| */ | ||
| seats?: BillingSubscriptionItemSeatsJSON; | ||
| plan: BillingPlanJSON; | ||
| plan_period: BillingSubscriptionPlanPeriod; | ||
| status: BillingSubscriptionStatus; | ||
|
|
@@ -751,6 +822,10 @@ export interface BillingCheckoutTotalsJSON { | |
| grand_total: BillingMoneyAmountJSON; | ||
| subtotal: BillingMoneyAmountJSON; | ||
| tax_total: BillingMoneyAmountJSON; | ||
| /** | ||
| * Per-unit cost breakdown for this checkout (for example, seats). | ||
| */ | ||
| per_unit_totals?: BillingPerUnitTotalJSON[]; | ||
| total_due_now: BillingMoneyAmountJSON; | ||
| credit: BillingMoneyAmountJSON | null; | ||
| past_due: BillingMoneyAmountJSON | null; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.