import { Config, Product, Purchase, Order, PlanChange } from './types'; /** * Response from Iaptic's /stripe/products API * @internal */ export interface GetProductsResponse { /** Whether the request was successful */ ok: boolean; /** Array of available products */ products: Product[]; } /** * Response from Iaptic's /stripe/checkout API * @internal */ export interface PostCheckoutSessionResponse { /** Whether the request was successful */ ok: boolean; /** Stripe Checkout URL where the customer will be redirected */ url: string; /** Access token for the customer */ accessToken: string; } /** * Response from Iaptic's /stripe/purchases API * @internal */ export interface GetPurchasesResponse { /** Whether the request was successful */ ok: boolean; /** Array of customer's purchases */ purchases: Purchase[]; /** Optional new access token */ newAccessToken?: string; } /** * Response from Iaptic's /stripe/change-plan API * @internal */ export interface ChangePlanResponse { /** Whether the request was successful */ ok: boolean; /** Updated purchase details */ purchase: Purchase; /** Optional new access token */ newAccessToken?: string; } /** * Main class for interacting with Iaptic's Stripe integration * @remarks * This class handles all Stripe-related operations including product listing, * checkout sessions, and subscription management. */ export declare class IapticStripe { private readonly iapticUrl; private readonly appName; private readonly apiKey; private readonly refreshScheduler; /** * Creates a new IapticStripe instance * @param config - Configuration options for the Stripe integration * @throws Error if required configuration is missing */ constructor(config: Config); private authorizationHeader; /** * Gets a list of available products and their pricing * @returns Promise resolving to an array of products * @remarks * Results are cached locally. Use refreshProducts() to force a fresh fetch. */ getProducts(): Promise; /** * Forces a refresh of the products list from the server * @returns Promise resolving to an array of products */ refreshProducts(): Promise; /** * Gets the current access token if one exists * @returns The current access token or undefined if none exists */ getAccessToken(): string | undefined; /** * Creates a new order and redirects to Stripe Checkout * @param params - Order parameters including product and URLs * @throws Error if the checkout session creation fails * @remarks * This method will redirect the user to Stripe's checkout page on success */ order(params: Order): Promise; /** * Gets the customer's purchase history * @param accessToken - Optional access token (uses stored token if not provided) * @returns Promise resolving to an array of purchases * @remarks * This method will automatically schedule refresh operations for active subscriptions */ getPurchases(accessToken?: string): Promise; /** * Redirects to Stripe Customer Portal for subscription management * @param params - Portal parameters including return URL * @throws Error if portal session creation fails * @remarks * This method will redirect the user to Stripe's customer portal on success */ redirectToCustomerPortal(params: { returnUrl?: string; accessToken?: string; }): Promise; /** * Changes a subscription plan * @param planChange - Plan change parameters * @returns Promise resolving to the updated purchase details * @remarks * This method handles immediate plan changes without requiring customer portal access */ changePlan(planChange: PlanChange): Promise; /** * Clears all stored data including access tokens and cached products */ clearStoredData(): void; private _accessTokenChangeCallbacks; onAccessTokenChange(callback: (accessToken: string) => void): void; private _notifyAccessTokenChange; private _storeAccessToken; private _getStoredAccessToken; private _getCachedProducts; private _setCachedProducts; } //# sourceMappingURL=iaptic-stripe.d.ts.map