UNPKG

@better-auth-ui/core

Version:

Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.

75 lines (74 loc) 3.42 kB
import { stripeClient } from '@better-auth/stripe/client'; import { commetClient } from '@commet/better-auth/client'; import { creemClient } from '@creem_io/better-auth/client'; import { dodopaymentsClient } from '@dodopayments/better-auth/client'; import { polarClient } from '@polar-sh/better-auth/client'; import { IAutumnClient } from 'autumn-js/react'; import { AuthClient } from '../../lib/auth-client'; import { BillingAdapter, BillingPlan } from './billing-adapter'; export type StripeBillingClient = AuthClient<{ plugins: [ReturnType<typeof stripeClient<{ subscription: true; }>>]; }>; export type PolarBillingClient = AuthClient<{ plugins: [ReturnType<typeof polarClient>]; }>; export type AutumnBillingClient = Pick<IAutumnClient, "getOrCreateCustomer" | "attach" | "updateSubscription" | "openCustomerPortal">; export type CreemBillingClient = AuthClient<{ plugins: [ReturnType<typeof creemClient>]; }>; export type DodoPaymentsBillingClient = AuthClient<{ plugins: [ReturnType<typeof dodopaymentsClient>]; }>; export type CommetBillingClient = AuthClient<{ plugins: [ReturnType<typeof commetClient>]; }>; export type VendorBillingAdapterOptions = { plans: BillingPlan[]; successUrl: string; cancelUrl: string; returnUrl: string; }; export type PolarBillingAdapterOptions = VendorBillingAdapterOptions & { /** Polar checkout product or configured slug for each BAUI plan ID. */ products?: Record<string, { type: "slug"; value: string; } | { type: "product"; value: string; }>; }; export type ProductBillingAdapterOptions = VendorBillingAdapterOptions & { /** Provider product ID for each BAUI plan ID. */ products?: Record<string, string>; }; export type DodoPaymentsBillingAdapterOptions = VendorBillingAdapterOptions & { /** Dodo product or configured slug for each BAUI plan ID. */ products?: Record<string, { type: "slug"; value: string; } | { type: "product"; value: string; }>; }; export type AutumnBillingAdapterOptions = VendorBillingAdapterOptions & { /** Autumn license plan used for seat quantity on each BAUI plan. */ seatLicensePlans?: Record<string, string>; }; export type CommetBillingAdapterOptions = VendorBillingAdapterOptions & { /** Commet plan ID for each BAUI plan ID. */ planIds?: Record<string, string>; /** Commet seat feature updated by BAUI's seat editor. */ seatFeatureCode?: string; /** Read metered feature access into BAUI usage rows. @default false */ usage?: boolean; }; export declare function createStripeBillingAdapter(client: StripeBillingClient, options: VendorBillingAdapterOptions): BillingAdapter; export declare function createPolarBillingAdapter(client: PolarBillingClient, options: PolarBillingAdapterOptions): BillingAdapter; export declare function createAutumnBillingAdapter(client: AutumnBillingClient, options: AutumnBillingAdapterOptions): BillingAdapter; export declare function createCreemBillingAdapter(client: CreemBillingClient, options: ProductBillingAdapterOptions): BillingAdapter; export declare function createDodoPaymentsBillingAdapter(client: DodoPaymentsBillingClient, options: DodoPaymentsBillingAdapterOptions): BillingAdapter; export declare function createCommetBillingAdapter(client: CommetBillingClient, options: CommetBillingAdapterOptions): BillingAdapter;