function makeCreateCheckoutSession
makeCreateCheckoutSession<Result>(
label: LogCategory,
create: (
baseUrl: string,
) => Promise<Result>
,
readResult: (result: Result) => { id: string | undefined; url:
string
| undefined
| null
; }
,
): ((
baseUrl: string,
) => Promise<CheckoutSessionResult>)

Build a provider's createCheckoutSession: call the provider's own create function, read the session id and URL off whatever shape it returns, and map that to a shared CheckoutSessionResult — all inside the standard checkout error guard. Each provider only supplies its create call, how to read the id/url, and its display label.

Type Parameters

Result

Parameters

label: LogCategory
create: (
baseUrl: string,
) => Promise<Result>
readResult: (result: Result) => { id: string | undefined; url:
string
| undefined
| null
; }

Return Type

((
baseUrl: string,
) => Promise<CheckoutSessionResult>)

Usage

import { makeCreateCheckoutSession } from "docs/payments.ts";