-
Notifications
You must be signed in to change notification settings - Fork 453
feat(clerk-js,localizations,shared,ui): Annual-only plans #8012
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5c88c16
feat(clerk-js,localizations,shared,ui): Annual-only plans
dstaley e15d316
feat(ui): Update PricingTable for annual only plans
dstaley df2dad2
fix(msw): Enable billing by default
dstaley 430c73c
chore(repo): Add changeset
dstaley 5c4beab
feat(backend): Add support for annual-only Billing plans
dstaley 7648ea3
fix(ui): Determine plan period correctly
dstaley 1968bf5
chore(ui): Simplify component
dstaley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,9 @@ | ||
| --- | ||
| '@clerk/backend': minor | ||
| '@clerk/localizations': minor | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/shared': minor | ||
| '@clerk/ui': minor | ||
| --- | ||
|
|
||
| Add support for annual-only Billing plans. |
This file contains hidden or 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 hidden or 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
157 changes: 157 additions & 0 deletions
157
packages/clerk-js/sandbox/scenarios/annual-only-plans.ts
This file contains hidden or 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,157 @@ | ||
| import { | ||
| clerkHandlers, | ||
| http, | ||
| HttpResponse, | ||
| EnvironmentService, | ||
| SessionService, | ||
| setClerkState, | ||
| type MockScenario, | ||
| UserService, | ||
| } from '@clerk/msw'; | ||
| import type { BillingPlanJSON } from '@clerk/shared/types'; | ||
|
|
||
| export function AnnualOnlyPlans(): MockScenario { | ||
| const user = UserService.create(); | ||
| const session = SessionService.create(user); | ||
| const money = (amount: number) => ({ | ||
| amount, | ||
| amount_formatted: (amount / 100).toFixed(2), | ||
| currency: 'USD', | ||
| currency_symbol: '$', | ||
| }); | ||
| const mockFeatures = [ | ||
| { | ||
| object: 'feature' as const, | ||
| id: 'feature_custom_domains', | ||
| name: 'Custom domains', | ||
| description: 'Connect and manage branded domains.', | ||
| slug: 'custom-domains', | ||
| avatar_url: null, | ||
| }, | ||
| { | ||
| object: 'feature' as const, | ||
| id: 'feature_saml_sso', | ||
| name: 'SAML SSO', | ||
| description: 'Single sign-on with enterprise identity providers.', | ||
| slug: 'saml-sso', | ||
| avatar_url: null, | ||
| }, | ||
| { | ||
| object: 'feature' as const, | ||
| id: 'feature_audit_logs', | ||
| name: 'Audit logs', | ||
| description: 'Track account activity and security events.', | ||
| slug: 'audit-logs', | ||
| avatar_url: null, | ||
| }, | ||
| { | ||
| object: 'feature' as const, | ||
| id: 'feature_priority_support', | ||
| name: 'Priority support', | ||
| description: 'Faster response times from the support team.', | ||
| slug: 'priority-support', | ||
| avatar_url: null, | ||
| }, | ||
| { | ||
| object: 'feature' as const, | ||
| id: 'feature_rate_limit_boost', | ||
| name: 'Rate limit boost', | ||
| description: 'Higher API request thresholds for production traffic.', | ||
| slug: 'rate-limit-boost', | ||
| avatar_url: null, | ||
| }, | ||
| ]; | ||
|
|
||
| setClerkState({ | ||
| environment: EnvironmentService.MULTI_SESSION, | ||
| session, | ||
| user, | ||
| }); | ||
|
|
||
| const subscriptionHandler = http.get('https://*.clerk.accounts.dev/v1/me/billing/subscription', () => { | ||
| return HttpResponse.json({ | ||
| response: { | ||
| data: {}, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| const paymentMethodsHandler = http.get('https://*.clerk.accounts.dev/v1/me/billing/payment_methods', () => { | ||
| return HttpResponse.json({ | ||
| response: { | ||
| data: {}, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| const plansHandler = http.get('https://*.clerk.accounts.dev/v1/billing/plans', () => { | ||
| return HttpResponse.json({ | ||
| data: [ | ||
| { | ||
| object: 'commerce_plan', | ||
| id: 'plan_a_sbb', | ||
| name: 'Monthly-only', | ||
| fee: money(5000), | ||
| annual_fee: null, | ||
| annual_monthly_fee: null, | ||
| description: null, | ||
| is_default: false, | ||
| is_recurring: true, | ||
| has_base_fee: true, | ||
| for_payer_type: 'user', | ||
| publicly_visible: true, | ||
| slug: 'plan-a-sbb', | ||
| avatar_url: null, | ||
| features: mockFeatures, | ||
| free_trial_enabled: false, | ||
| free_trial_days: null, | ||
| }, | ||
| { | ||
| object: 'commerce_plan', | ||
| id: 'plan_b_sbb', | ||
| name: 'Monthly & Annual', | ||
| fee: money(5000), | ||
| annual_fee: money(50000), | ||
| annual_monthly_fee: money(4167), | ||
| description: null, | ||
| is_default: false, | ||
| is_recurring: true, | ||
| has_base_fee: true, | ||
| for_payer_type: 'user', | ||
| publicly_visible: true, | ||
| slug: 'plan-b-sbb', | ||
| avatar_url: null, | ||
| features: mockFeatures, | ||
| free_trial_enabled: false, | ||
| free_trial_days: null, | ||
| }, | ||
| { | ||
| object: 'commerce_plan', | ||
| id: 'plan_c_sbb', | ||
| name: 'Annual-only', | ||
| fee: null, | ||
| annual_fee: money(50000), | ||
| annual_monthly_fee: money(4167), | ||
| description: null, | ||
| is_default: false, | ||
| is_recurring: true, | ||
| has_base_fee: false, | ||
| for_payer_type: 'user', | ||
| publicly_visible: true, | ||
| slug: 'plan-c-sbb', | ||
| avatar_url: null, | ||
| features: mockFeatures, | ||
| free_trial_enabled: false, | ||
| free_trial_days: null, | ||
| }, | ||
| ] as BillingPlanJSON[], | ||
| }); | ||
| }); | ||
|
|
||
| return { | ||
| description: 'PricingTable with annual-only billing plans', | ||
| handlers: [plansHandler, subscriptionHandler, paymentMethodsHandler, ...clerkHandlers], | ||
| initialState: { session, user }, | ||
| name: 'annual-only-plans', | ||
| }; | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export { UserButtonSignedIn } from './user-button-signed-in'; | ||
| export { CheckoutAccountCredit } from './checkout-account-credit'; | ||
| export { AnnualOnlyPlans } from './annual-only-plans'; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not blocking just curious) what is this change for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for the mock scenario system. this sets all mock scenarios to default to having billing enabled.