@@ -33,7 +33,7 @@ export type NestedEndpoint = {
3333 supportsPagination : boolean
3434}
3535
36- function resolveTableName ( resourceId : string , aliases : Record < string , string > ) : string {
36+ export function resolveTableName ( resourceId : string , aliases : Record < string , string > ) : string {
3737 const alias = aliases [ resourceId ]
3838 if ( alias ) return alias
3939 const normalized = resourceId . toLowerCase ( ) . replace ( / [ . ] / g, '_' )
@@ -206,7 +206,6 @@ export function isV2Path(apiPath: string): boolean {
206206// ---------------------------------------------------------------------------
207207
208208const STRIPE_API_BASE = 'https://api.stripe.com'
209- const V2_STRIPE_VERSION = '2026-02-25.clover'
210209
211210function authHeaders ( apiKey : string ) : Record < string , string > {
212211 return { Authorization : `Bearer ${ apiKey } ` }
@@ -216,16 +215,17 @@ function authHeaders(apiKey: string): Record<string, string> {
216215 * Build a callable list function that hits the Stripe HTTP API directly.
217216 * Supports both v1 (has_more pagination) and v2 (next_page_url pagination).
218217 */
219- export function buildListFn ( apiKey : string , apiPath : string ) : ListFn {
218+ export function buildListFn ( apiKey : string , apiPath : string , apiVersion ?: string ) : ListFn {
220219 if ( isV2Path ( apiPath ) ) {
221220 return async ( params ) => {
222221 const qs = new URLSearchParams ( )
223222 qs . set ( 'limit' , String ( Math . min ( params . limit ?? 20 , 20 ) ) )
224223 if ( params . starting_after ) qs . set ( 'page' , params . starting_after )
225224
226- const response = await fetch ( `${ STRIPE_API_BASE } ${ apiPath } ?${ qs } ` , {
227- headers : { ...authHeaders ( apiKey ) , 'Stripe-Version' : V2_STRIPE_VERSION } ,
228- } )
225+ const headers = authHeaders ( apiKey )
226+ if ( apiVersion ) headers [ 'Stripe-Version' ] = apiVersion
227+
228+ const response = await fetch ( `${ STRIPE_API_BASE } ${ apiPath } ?${ qs } ` , { headers } )
229229 const body = ( await response . json ( ) ) as {
230230 data : unknown [ ]
231231 next_page_url ?: string | null
@@ -257,12 +257,13 @@ export function buildListFn(apiKey: string, apiPath: string): ListFn {
257257/**
258258 * Build a callable retrieve function that hits the Stripe HTTP API directly.
259259 */
260- export function buildRetrieveFn ( apiKey : string , apiPath : string ) : RetrieveFn {
260+ export function buildRetrieveFn ( apiKey : string , apiPath : string , apiVersion ?: string ) : RetrieveFn {
261261 if ( isV2Path ( apiPath ) ) {
262262 return async ( id ) => {
263- const response = await fetch ( `${ STRIPE_API_BASE } ${ apiPath } /${ id } ` , {
264- headers : { ...authHeaders ( apiKey ) , 'Stripe-Version' : V2_STRIPE_VERSION } ,
265- } )
263+ const headers = authHeaders ( apiKey )
264+ if ( apiVersion ) headers [ 'Stripe-Version' ] = apiVersion
265+
266+ const response = await fetch ( `${ STRIPE_API_BASE } ${ apiPath } /${ id } ` , { headers } )
266267 return await response . json ( )
267268 }
268269 }
0 commit comments