Skip to content

Commit dac7ce3

Browse files
authored
chore(clerk-js,types): Update payment source endpoints (#6962)
1 parent c2f8797 commit dac7ce3

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

.changeset/kind-ghosts-smile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/clerk-js/src/core/resources/BillingPaymentSource.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import type {
99
RemovePaymentMethodParams,
1010
} from '@clerk/types';
1111

12+
import { Billing } from '@/core/modules/billing';
13+
1214
import { BaseResource, DeletedObject } from './internal';
1315

1416
export class BillingPaymentMethod extends BaseResource implements BillingPaymentMethodResource {
@@ -47,9 +49,7 @@ export class BillingPaymentMethod extends BaseResource implements BillingPayment
4749
const { orgId } = params ?? {};
4850
const json = (
4951
await BaseResource._fetch({
50-
path: orgId
51-
? `/organizations/${orgId}/commerce/payment_sources/${this.id}`
52-
: `/me/commerce/payment_sources/${this.id}`,
52+
path: Billing.path(`/payment_methods/${this.id}`, { orgId }),
5353
method: 'DELETE',
5454
})
5555
)?.response as unknown as DeletedObjectJSON;
@@ -60,11 +60,9 @@ export class BillingPaymentMethod extends BaseResource implements BillingPayment
6060
public async makeDefault(params?: MakeDefaultPaymentMethodParams) {
6161
const { orgId } = params ?? {};
6262
await BaseResource._fetch({
63-
path: orgId
64-
? `/organizations/${orgId}/commerce/payers/default_payment_source`
65-
: `/me/commerce/payers/default_payment_source`,
63+
path: Billing.path(`/payers/default_payment_method`, { orgId }),
6664
method: 'PUT',
67-
body: { payment_source_id: this.id } as any,
65+
body: { payment_method_id: this.id } as any,
6866
});
6967

7068
return null;

packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ describe('Checkout', () => {
366366
freeTrialDays: 14,
367367
freeTrialEnabled: true,
368368
},
369-
paymentSource: undefined,
369+
paymentMethod: undefined,
370370
confirm: vi.fn(),
371371
freeTrialEndsAt,
372372
} as any);
@@ -758,7 +758,7 @@ describe('Checkout', () => {
758758
onOpenChange={() => {}}
759759
>
760760
<Checkout
761-
planId='plan_with_payment_sources'
761+
planId='plan_with_payment_methods'
762762
planPeriod='month'
763763
/>
764764
</Drawer.Root>,
@@ -897,7 +897,7 @@ describe('Checkout', () => {
897897
onOpenChange={() => {}}
898898
>
899899
<Checkout
900-
planId='plan_with_payment_sources'
900+
planId='plan_with_payment_methods'
901901
planPeriod='month'
902902
/>
903903
</Drawer.Root>,
@@ -1036,7 +1036,7 @@ describe('Checkout', () => {
10361036
onOpenChange={() => {}}
10371037
>
10381038
<Checkout
1039-
planId='plan_with_payment_sources'
1039+
planId='plan_with_payment_methods'
10401040
planPeriod='month'
10411041
/>
10421042
</Drawer.Root>,

packages/shared/src/react/hooks/useCheckout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const useCheckout = (options?: Params): __experimental_UseCheckoutReturn
111111
isImmediatePlanChange: null,
112112
planPeriod: null,
113113
plan: null,
114-
paymentSource: null,
114+
paymentMethod: null,
115115
freeTrialEndsAt: null,
116116
payer: null,
117117
};

packages/types/src/json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ export interface BillingPaymentMethodJSON extends ClerkResourceJSON {
698698
* @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.
699699
*/
700700
export interface BillingInitializedPaymentMethodJSON extends ClerkResourceJSON {
701-
object: 'commerce_payment_source_initialize';
701+
object: 'commerce_payment_method_initialize';
702702
external_client_secret: string;
703703
external_gateway_id: string;
704704
payment_method_order: string[];

0 commit comments

Comments
 (0)