diff --git a/.changeset/kind-ghosts-smile.md b/.changeset/kind-ghosts-smile.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/kind-ghosts-smile.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/clerk-js/src/core/resources/BillingPaymentSource.ts b/packages/clerk-js/src/core/resources/BillingPaymentSource.ts index cb47f12d87a..7d2cc33843b 100644 --- a/packages/clerk-js/src/core/resources/BillingPaymentSource.ts +++ b/packages/clerk-js/src/core/resources/BillingPaymentSource.ts @@ -9,6 +9,8 @@ import type { RemovePaymentMethodParams, } from '@clerk/types'; +import { Billing } from '@/core/modules/billing'; + import { BaseResource, DeletedObject } from './internal'; export class BillingPaymentMethod extends BaseResource implements BillingPaymentMethodResource { @@ -47,9 +49,7 @@ export class BillingPaymentMethod extends BaseResource implements BillingPayment const { orgId } = params ?? {}; const json = ( await BaseResource._fetch({ - path: orgId - ? `/organizations/${orgId}/commerce/payment_sources/${this.id}` - : `/me/commerce/payment_sources/${this.id}`, + path: Billing.path(`/payment_methods/${this.id}`, { orgId }), method: 'DELETE', }) )?.response as unknown as DeletedObjectJSON; @@ -60,11 +60,9 @@ export class BillingPaymentMethod extends BaseResource implements BillingPayment public async makeDefault(params?: MakeDefaultPaymentMethodParams) { const { orgId } = params ?? {}; await BaseResource._fetch({ - path: orgId - ? `/organizations/${orgId}/commerce/payers/default_payment_source` - : `/me/commerce/payers/default_payment_source`, + path: Billing.path(`/payers/default_payment_method`, { orgId }), method: 'PUT', - body: { payment_source_id: this.id } as any, + body: { payment_method_id: this.id } as any, }); return null; diff --git a/packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx b/packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx index 89178c8b543..92747208304 100644 --- a/packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx +++ b/packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx @@ -366,7 +366,7 @@ describe('Checkout', () => { freeTrialDays: 14, freeTrialEnabled: true, }, - paymentSource: undefined, + paymentMethod: undefined, confirm: vi.fn(), freeTrialEndsAt, } as any); @@ -758,7 +758,7 @@ describe('Checkout', () => { onOpenChange={() => {}} > , @@ -897,7 +897,7 @@ describe('Checkout', () => { onOpenChange={() => {}} > , @@ -1036,7 +1036,7 @@ describe('Checkout', () => { onOpenChange={() => {}} > , diff --git a/packages/shared/src/react/hooks/useCheckout.ts b/packages/shared/src/react/hooks/useCheckout.ts index 507553b0c6b..9bdfcc45970 100644 --- a/packages/shared/src/react/hooks/useCheckout.ts +++ b/packages/shared/src/react/hooks/useCheckout.ts @@ -111,7 +111,7 @@ export const useCheckout = (options?: Params): __experimental_UseCheckoutReturn isImmediatePlanChange: null, planPeriod: null, plan: null, - paymentSource: null, + paymentMethod: null, freeTrialEndsAt: null, payer: null, }; diff --git a/packages/types/src/json.ts b/packages/types/src/json.ts index 8860137b287..e9c42a815c6 100644 --- a/packages/types/src/json.ts +++ b/packages/types/src/json.ts @@ -698,7 +698,7 @@ export interface BillingPaymentMethodJSON extends ClerkResourceJSON { * @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 BillingInitializedPaymentMethodJSON extends ClerkResourceJSON { - object: 'commerce_payment_source_initialize'; + object: 'commerce_payment_method_initialize'; external_client_secret: string; external_gateway_id: string; payment_method_order: string[];