11import type {
22 __experimental_AddPaymentSourceParams ,
33 __experimental_CommerceBillingNamespace ,
4+ __experimental_CommerceInitializedPaymentSourceJSON ,
45 __experimental_CommerceNamespace ,
56 __experimental_CommercePaymentSourceJSON ,
7+ __experimental_GetPaymentSourcesParams ,
8+ __experimental_InitializePaymentSourceParams ,
69 ClerkPaginatedResponse ,
710} from '@clerk/types' ;
811
9- import { __experimental_CommercePaymentSource , BaseResource } from '../../resources/internal' ;
12+ import {
13+ __experimental_CommerceInitializedPaymentSource ,
14+ __experimental_CommercePaymentSource ,
15+ BaseResource ,
16+ } from '../../resources/internal' ;
1017import { __experimental_CommerceBilling } from './CommerceBilling' ;
1118
1219export class __experimental_Commerce implements __experimental_CommerceNamespace {
@@ -19,6 +26,17 @@ export class __experimental_Commerce implements __experimental_CommerceNamespace
1926 return __experimental_Commerce . _billing ;
2027 }
2128
29+ initializePaymentSource = async ( params : __experimental_InitializePaymentSourceParams ) => {
30+ const json = (
31+ await BaseResource . _fetch ( {
32+ path : `/me/commerce/payment_sources/initialize` ,
33+ method : 'POST' ,
34+ body : params as any ,
35+ } )
36+ ) ?. response as unknown as __experimental_CommerceInitializedPaymentSourceJSON ;
37+ return new __experimental_CommerceInitializedPaymentSource ( json ) ;
38+ } ;
39+
2240 addPaymentSource = async ( params : __experimental_AddPaymentSourceParams ) => {
2341 const json = (
2442 await BaseResource . _fetch ( {
@@ -30,10 +48,11 @@ export class __experimental_Commerce implements __experimental_CommerceNamespace
3048 return new __experimental_CommercePaymentSource ( json ) ;
3149 } ;
3250
33- getPaymentSources = async ( ) => {
51+ getPaymentSources = async ( params : __experimental_GetPaymentSourcesParams ) => {
3452 return await BaseResource . _fetch ( {
3553 path : `/me/commerce/payment_sources` ,
3654 method : 'GET' ,
55+ search : { orgId : params . orgId || '' } ,
3756 } ) . then ( res => {
3857 const { data : paymentSources , total_count } =
3958 res as unknown as ClerkPaginatedResponse < __experimental_CommercePaymentSourceJSON > ;
0 commit comments