@@ -9,6 +9,7 @@ import type {
99 ClerkPaginatedResponse ,
1010} from '@clerk/types' ;
1111
12+ import { convertPageToOffsetSearchParams } from '../../../utils/convertPageToOffsetSearchParams' ;
1213import {
1314 __experimental_CommerceInitializedPaymentSource ,
1415 __experimental_CommercePaymentSource ,
@@ -27,35 +28,42 @@ export class __experimental_Commerce implements __experimental_CommerceNamespace
2728 }
2829
2930 initializePaymentSource = async ( params : __experimental_InitializePaymentSourceParams ) => {
31+ const { orgId, ...rest } = params ;
3032 const json = (
3133 await BaseResource . _fetch ( {
32- path : `/me/commerce/payment_sources/initialize` ,
34+ path : orgId
35+ ? `/organizations/${ orgId } /commerce/payment_sources/initialize`
36+ : `/me/commerce/payment_sources/initialize` ,
3337 method : 'POST' ,
34- body : params as any ,
38+ body : rest as any ,
3539 } )
3640 ) ?. response as unknown as __experimental_CommerceInitializedPaymentSourceJSON ;
3741 return new __experimental_CommerceInitializedPaymentSource ( json ) ;
3842 } ;
3943
4044 addPaymentSource = async ( params : __experimental_AddPaymentSourceParams ) => {
45+ const { orgId, ...rest } = params ;
46+
4147 const json = (
4248 await BaseResource . _fetch ( {
43- path : `/me/commerce/payment_sources` ,
49+ path : orgId ? `/organizations/ ${ orgId } /commerce/payment_sources` : `/me/commerce/payment_sources` ,
4450 method : 'POST' ,
45- body : params as any ,
51+ body : rest as any ,
4652 } )
4753 ) ?. response as unknown as __experimental_CommercePaymentSourceJSON ;
4854 return new __experimental_CommercePaymentSource ( json ) ;
4955 } ;
5056
5157 getPaymentSources = async ( params : __experimental_GetPaymentSourcesParams ) => {
58+ const { orgId, ...rest } = params ;
59+
5260 return await BaseResource . _fetch ( {
53- path : `/me/commerce/payment_sources` ,
61+ path : orgId ? `/organizations/ ${ orgId } /commerce/payment_sources` : `/me/commerce/payment_sources` ,
5462 method : 'GET' ,
55- search : { orgId : params . orgId || '' } ,
63+ search : convertPageToOffsetSearchParams ( rest ) ,
5664 } ) . then ( res => {
5765 const { data : paymentSources , total_count } =
58- res as unknown as ClerkPaginatedResponse < __experimental_CommercePaymentSourceJSON > ;
66+ res ?. response as unknown as ClerkPaginatedResponse < __experimental_CommercePaymentSourceJSON > ;
5967 return {
6068 total_count,
6169 data : paymentSources . map ( paymentSource => new __experimental_CommercePaymentSource ( paymentSource ) ) ,
0 commit comments