Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 470
feat(clerk-js,types,localizations): Preliminary Commerce work including PricingTable and Checkout components#5248
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
1be9179
add pricing table basics
aeliox b23b7b4
pricing table as customizables / elements
aeliox 3411e5b
add some variants to plan cards
aeliox 6f4aef0
plan annual price toggle
aeliox 8e36198
plan card width, plan sorting
aeliox fb04388
bump
aeliox db1b6eb
checkout blade work
aeliox c0ede3b
checkout happy path
aeliox 01d7259
commerce blade component
aeliox 646cdc6
cancel subscription from plan detail blade, wip
aeliox 92dab17
Conclude merge and update changes
aeliox e93d3c1
sprinkle in a bunch of __experimental_
aeliox a2bfdd8
address PR feedback
aeliox 66849fd
wip
alexcarpenter e979c41
Update pnpm-lock.yaml
alexcarpenter eac3fff
SegmentedControl
alexcarpenter 87d4597
text alignment
alexcarpenter b24e790
sandbox tweaks
alexcarpenter 95a2c29
Update template.html
alexcarpenter 4a0fa41
secondary bordered button
alexcarpenter 9b59ae9
remove text-center
alexcarpenter be4c0ed
disclosure
alexcarpenter 73b2afc
fix
alexcarpenter b4e088a
feat(clerk-js): `<LineItems />` component (#5302)
alexcarpenter 585942d
animations
alexcarpenter c305b58
some checkout work, WIP
aeliox 2b288a9
clean up useCheckout state
aeliox 0392107
PR feedback
aeliox 111fee2
Merge branch 'main' into keiran/commerce-pricing-table
aeliox 283cd46
fix payment method line on checkout complete
aeliox b710814
toggle features
alexcarpenter e269613
address remaining pieces of feedback
aeliox 2420725
tag missing localization TODOs
aeliox 33aa00c
Merge branch 'main' into keiran/commerce-pricing-table
aeliox fbde87a
fix tests
aeliox 42feca9
Merge branch 'main' into keiran/commerce-pricing-table
aeliox cef81aa
add changeset
aeliox 5842e6b
Include stripe dependencies to only Checkout
panteliselef f008948
bump bundlewatch sizes, pin stripe package versions
aeliox 3d93892
pnpm dedupe
aeliox 2c1c7ee
another bundlewatch bump
aeliox 6c203b6
linter fix
aeliox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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,8 @@ | ||
| --- | ||
| '@clerk/localizations': patch | ||
| '@clerk/clerk-js': patch | ||
| '@clerk/clerk-react': patch | ||
| '@clerk/types': patch | ||
| --- | ||
| Introduce experimental billing APIs and components |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import type { | ||
| __experimental_AddPaymentSourceParams, | ||
| __experimental_CommerceBillingNamespace, | ||
| __experimental_CommerceNamespace, | ||
| __experimental_CommercePaymentSourceJSON, | ||
| ClerkPaginatedResponse, | ||
| } from '@clerk/types'; | ||
| import { __experimental_CommercePaymentSource, BaseResource } from '../../resources/internal'; | ||
| import { __experimental_CommerceBilling } from './CommerceBilling'; | ||
| export class __experimental_Commerce implements __experimental_CommerceNamespace { | ||
| private static _billing: __experimental_CommerceBillingNamespace; | ||
| get __experimental_billing(): __experimental_CommerceBillingNamespace { | ||
| if (!__experimental_Commerce._billing) { | ||
| __experimental_Commerce._billing = new __experimental_CommerceBilling(); | ||
| } | ||
| return __experimental_Commerce._billing; | ||
| } | ||
| addPaymentSource = async (params: __experimental_AddPaymentSourceParams) => { | ||
| const json = ( | ||
| await BaseResource._fetch({ | ||
| path: `/me/commerce/payment_sources`, | ||
| method: 'POST', | ||
| body: params as any, | ||
| }) | ||
| )?.response as unknown as __experimental_CommercePaymentSourceJSON; | ||
| return new __experimental_CommercePaymentSource(json); | ||
| }; | ||
| getPaymentSources = async () => { | ||
| return await BaseResource._fetch({ | ||
| path: `/me/commerce/payment_sources`, | ||
| method: 'GET', | ||
| }).then(res => { | ||
| const { data: paymentSources, total_count } = | ||
| res as unknown as ClerkPaginatedResponse<__experimental_CommercePaymentSourceJSON>; | ||
| return { | ||
| total_count, | ||
| data: paymentSources.map(paymentSource => new __experimental_CommercePaymentSource(paymentSource)), | ||
| }; | ||
| }); | ||
| }; | ||
| } |
37 changes: 37 additions & 0 deletions
37 packages/clerk-js/src/core/modules/commerce/CommerceBilling.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,37 @@ | ||
| import type { | ||
| __experimental_CommerceBillingNamespace, | ||
| __experimental_CommerceCheckoutJSON, | ||
| __experimental_CommercePlanResource, | ||
| __experimental_CommerceProductJSON, | ||
| __experimental_CreateCheckoutParams, | ||
| __experimental_GetPlansParams, | ||
| ClerkPaginatedResponse, | ||
| } from '@clerk/types'; | ||
| import { convertPageToOffsetSearchParams } from '../../../utils/convertPageToOffsetSearchParams'; | ||
| import { __experimental_CommerceCheckout, __experimental_CommercePlan, BaseResource } from '../../resources/internal'; | ||
| export class __experimental_CommerceBilling implements __experimental_CommerceBillingNamespace { | ||
| getPlans = async (params?: __experimental_GetPlansParams): Promise<__experimental_CommercePlanResource[]> => { | ||
| const { data: products } = (await BaseResource._fetch({ | ||
| path: `/commerce/products`, | ||
| method: 'GET', | ||
| search: convertPageToOffsetSearchParams(params), | ||
| })) as unknown as ClerkPaginatedResponse<__experimental_CommerceProductJSON>; | ||
| const defaultProduct = products.find(product => product.is_default); | ||
| return defaultProduct?.plans.map(plan => new __experimental_CommercePlan(plan)) || []; | ||
| }; | ||
| startCheckout = async (params: __experimental_CreateCheckoutParams) => { | ||
| const json = ( | ||
| await BaseResource._fetch<__experimental_CommerceCheckoutJSON>({ | ||
| path: `/me/commerce/checkouts`, | ||
| method: 'POST', | ||
| body: params as any, | ||
| }) | ||
| )?.response as unknown as __experimental_CommerceCheckoutJSON; | ||
| return new __experimental_CommerceCheckout(json); | ||
| }; | ||
| } |
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,2 @@ | ||
| export * from './Commerce'; | ||
| export * from './CommerceBilling'; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import type { | ||
| __experimental_CommerceCheckoutJSON, | ||
| __experimental_CommerceCheckoutResource, | ||
| __experimental_CommerceTotals, | ||
| __experimental_ConfirmCheckoutParams, | ||
| } from '@clerk/types'; | ||
| import { commerceTotalsFromJSON } from '../../utils'; | ||
| import { | ||
| __experimental_CommerceInvoice, | ||
| __experimental_CommercePaymentSource, | ||
| __experimental_CommercePlan, | ||
| __experimental_CommerceSubscription, | ||
| BaseResource, | ||
| } from './internal'; | ||
| export class __experimental_CommerceCheckout extends BaseResource implements __experimental_CommerceCheckoutResource { | ||
| pathRoot = '/me/commerce/checkouts'; | ||
| id!: string; | ||
aeliox marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| externalClientSecret!: string; | ||
| externalGatewayId!: string; | ||
| invoice?: __experimental_CommerceInvoice; | ||
| paymentSource?: __experimental_CommercePaymentSource; | ||
| plan!: __experimental_CommercePlan; | ||
| planPeriod!: string; | ||
| status!: string; | ||
| subscription?: __experimental_CommerceSubscription; | ||
| totals!: __experimental_CommerceTotals; | ||
| constructor(data: __experimental_CommerceCheckoutJSON) { | ||
| super(); | ||
| this.fromJSON(data); | ||
| } | ||
| protected fromJSON(data: __experimental_CommerceCheckoutJSON | null): this { | ||
| if (!data) { | ||
| return this; | ||
| } | ||
| this.id = data.id; | ||
| this.externalClientSecret = data.external_client_secret; | ||
| this.externalGatewayId = data.external_gateway_id; | ||
| this.invoice = data.invoice ? new __experimental_CommerceInvoice(data.invoice) : undefined; | ||
| this.paymentSource = data.payment_source | ||
| ? new __experimental_CommercePaymentSource(data.payment_source) | ||
| : undefined; | ||
| this.plan = new __experimental_CommercePlan(data.plan); | ||
| this.planPeriod = data.plan_period; | ||
| this.status = data.status; | ||
| this.subscription = data.subscription ? new __experimental_CommerceSubscription(data.subscription) : undefined; | ||
| this.totals = commerceTotalsFromJSON(data.totals); | ||
| return this; | ||
| } | ||
| confirm = (params?: __experimental_ConfirmCheckoutParams): Promise<this> => { | ||
| return this._basePatch({ | ||
| path: this.path('confirm'), | ||
| body: params as any, | ||
| }); | ||
| }; | ||
| } | ||
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,30 @@ | ||
| import type { __experimental_CommerceFeatureJSON, __experimental_CommerceFeatureResource } from '@clerk/types'; | ||
| import { BaseResource } from './internal'; | ||
| export class __experimental_CommerceFeature extends BaseResource implements __experimental_CommerceFeatureResource { | ||
| id!: string; | ||
| name!: string; | ||
| description!: string; | ||
| slug!: string; | ||
| avatarUrl!: string; | ||
| constructor(data: __experimental_CommerceFeatureJSON) { | ||
| super(); | ||
| this.fromJSON(data); | ||
| } | ||
| protected fromJSON(data: __experimental_CommerceFeatureJSON | null): this { | ||
| if (!data) { | ||
| return this; | ||
| } | ||
| this.id = data.id; | ||
| this.name = data.name; | ||
| this.description = data.description; | ||
| this.slug = data.slug; | ||
| this.avatarUrl = data.avatar_url; | ||
| return this; | ||
| } | ||
| } |
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.