Skip to content

Commit 7dfbf3a

Browse files
authored
fix(clerk-js, types): Remove orgId from BillingPayerMethods interface (#7087)
1 parent 439427e commit 7dfbf3a

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

.changeset/great-bees-fix.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
'@clerk/shared': minor
4+
'@clerk/types': minor
5+
---
6+
7+
[Billing Beta] Remove unnecessary `orgId` from BillingPayerMethods interface.

packages/clerk-js/src/core/modules/billing/payment-source-methods.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import { Billing } from './namespace';
1313

1414
const PAYMENT_METHODS_PATH = '/payment_methods';
1515

16-
export const initializePaymentMethod = async (params: InitializePaymentMethodParams) => {
16+
type WithOptionalOrgType<T> = T & {
17+
orgId?: string;
18+
};
19+
20+
export const initializePaymentMethod = async (params: WithOptionalOrgType<InitializePaymentMethodParams>) => {
1721
const { orgId, ...rest } = params;
1822
const json = (
1923
await BaseResource._fetch({
@@ -25,7 +29,7 @@ export const initializePaymentMethod = async (params: InitializePaymentMethodPar
2529
return new BillingInitializedPaymentMethod(json);
2630
};
2731

28-
export const addPaymentMethod = async (params: AddPaymentMethodParams) => {
32+
export const addPaymentMethod = async (params: WithOptionalOrgType<AddPaymentMethodParams>) => {
2933
const { orgId, ...rest } = params;
3034

3135
const json = (
@@ -38,8 +42,8 @@ export const addPaymentMethod = async (params: AddPaymentMethodParams) => {
3842
return new BillingPaymentMethod(json);
3943
};
4044

41-
export const getPaymentMethods = async (params: GetPaymentMethodsParams) => {
42-
const { orgId, ...rest } = params;
45+
export const getPaymentMethods = async (params?: WithOptionalOrgType<GetPaymentMethodsParams>) => {
46+
const { orgId, ...rest } = params ?? {};
4347

4448
return await BaseResource._fetch({
4549
path: Billing.path(PAYMENT_METHODS_PATH, { orgId }),

packages/types/src/billing.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,16 @@ export interface BillingPayerMethods {
8989
/**
9090
* @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.
9191
*/
92-
initializePaymentMethod: (
93-
params: Exclude<InitializePaymentMethodParams, 'orgId'>,
94-
) => Promise<BillingInitializedPaymentMethodResource>;
92+
initializePaymentMethod: (params: InitializePaymentMethodParams) => Promise<BillingInitializedPaymentMethodResource>;
9593
/**
9694
* @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.
9795
*/
98-
addPaymentMethod: (params: Exclude<AddPaymentMethodParams, 'orgId'>) => Promise<BillingPaymentMethodResource>;
96+
addPaymentMethod: (params: AddPaymentMethodParams) => Promise<BillingPaymentMethodResource>;
9997
/**
10098
* @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.
10199
*/
102100
getPaymentMethods: (
103-
params: Exclude<GetPaymentMethodsParams, 'orgId'>,
101+
params?: GetPaymentMethodsParams,
104102
) => Promise<ClerkPaginatedResponse<BillingPaymentMethodResource>>;
105103
}
106104

@@ -226,29 +224,29 @@ export type BillingPaymentMethodStatus = 'active' | 'expired' | 'disconnected';
226224
/**
227225
* @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.
228226
*/
229-
export type GetPaymentMethodsParams = WithOptionalOrgType<ClerkPaginationParams>;
227+
export type GetPaymentMethodsParams = ClerkPaginationParams;
230228

231229
/**
232230
* @inline
233231
*
234232
* @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.
235233
*/
236-
export type PaymentGateway = 'stripe' | 'paypal';
234+
export type PaymentGateway = 'stripe';
237235

238236
/**
239237
* @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.
240238
*/
241-
export type InitializePaymentMethodParams = WithOptionalOrgType<{
239+
export type InitializePaymentMethodParams = {
242240
/**
243241
* The payment gateway to use.
244242
*/
245243
gateway: PaymentGateway;
246-
}>;
244+
};
247245

248246
/**
249247
* @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.
250248
*/
251-
export type AddPaymentMethodParams = WithOptionalOrgType<{
249+
export type AddPaymentMethodParams = {
252250
/**
253251
* The payment gateway to use.
254252
*/
@@ -257,7 +255,7 @@ export type AddPaymentMethodParams = WithOptionalOrgType<{
257255
* A token representing payment details, usually from a payment form.
258256
*/
259257
paymentToken: string;
260-
}>;
258+
};
261259

262260
/**
263261
* @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.

0 commit comments

Comments
 (0)