-
Notifications
You must be signed in to change notification settings - Fork 391
chore(clerk-js,backend): Replace /commerce
endpoints with /billing
endpoints
#6854
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: main
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': patch | ||
'@clerk/backend': patch | ||
--- | ||
|
||
Replace `/commerce` endpoints with `/billing` endpoints. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import type { | |
import { unixEpochToDate } from '@/utils/date'; | ||
|
||
import { billingTotalsFromJSON } from '../../utils'; | ||
import { Billing } from '../modules/billing/namespace'; | ||
import { BillingPayer } from './BillingPayer'; | ||
import { BaseResource, BillingPaymentSource, BillingPlan, isClerkAPIResponseError } from './internal'; | ||
|
||
|
@@ -60,9 +61,7 @@ export class BillingCheckout extends BaseResource implements BillingCheckoutReso | |
return retry( | ||
() => | ||
this._basePatch({ | ||
path: this.payer.organizationId | ||
? `/organizations/${this.payer.organizationId}/commerce/checkouts/${this.id}/confirm` | ||
: `/me/commerce/checkouts/${this.id}/confirm`, | ||
path: Billing.path(`/checkouts/${this.id}/confirm`, { orgId: this.payer.organizationId }), | ||
body: params as any, | ||
}), | ||
Comment on lines
+64
to
66
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. Confirm checkout fails for organization payers Line 64 relies on 🤖 Prompt for AI Agents
|
||
{ | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,6 +13,7 @@ import type { | |||||||||||||||||
import { unixEpochToDate } from '@/utils/date'; | ||||||||||||||||||
|
||||||||||||||||||
import { billingMoneyAmountFromJSON } from '../../utils'; | ||||||||||||||||||
import { Billing } from '../modules/billing/namespace'; | ||||||||||||||||||
import { BaseResource, BillingPlan, DeletedObject } from './internal'; | ||||||||||||||||||
|
||||||||||||||||||
export class BillingSubscription extends BaseResource implements BillingSubscriptionResource { | ||||||||||||||||||
|
@@ -110,9 +111,7 @@ export class BillingSubscriptionItem extends BaseResource implements BillingSubs | |||||||||||||||||
const { orgId } = params; | ||||||||||||||||||
const json = ( | ||||||||||||||||||
await BaseResource._fetch({ | ||||||||||||||||||
path: orgId | ||||||||||||||||||
? `/organizations/${orgId}/commerce/subscription_items/${this.id}` | ||||||||||||||||||
: `/me/commerce/subscription_items/${this.id}`, | ||||||||||||||||||
path: Billing.path(`/subscription_items/${this.id}`, { orgId }), | ||||||||||||||||||
method: 'DELETE', | ||||||||||||||||||
}) | ||||||||||||||||||
Comment on lines
+114
to
116
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. Restore organization billing routes before merging Line 114: static path(subPath: string, param?: { orgId?: string }): string {
const { orgId } = param || {};
- let prefix = '';
- if (orgId) {
- prefix = `/organizations/${orgId}`;
- }
- prefix = '/me';
+ const prefix = orgId ? `/organizations/${orgId}` : '/me';
return `${prefix}${Billing.#pathRoot}${subPath}`;
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||
)?.response as unknown as DeletedObjectJSON; | ||||||||||||||||||
|
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.
Org-specific billing routes are now broken.
Billing.path
always resets the prefix to/me
, so every caller—including those that passorgId
—now hits/me/billing/...
. This regresses all organization-scoped billing operations (statements, payment sources, subscription items, checkout confirmation, etc.), which will 404 or operate on the wrong tenant. Please restore the conditional prefix so that orgId-backed requests keep using/organizations/{orgId}/billing/...
.📝 Committable suggestion
🤖 Prompt for AI Agents