a0-purchases
Version:
Lightweight subscription management for AI apps with auto-detecting providers
49 lines • 1.71 kB
TypeScript
import { PurchasesPackage } from '../revenuecat-types';
import { PurchasesConfig } from '../types';
import { StoreProduct } from './commerceState';
export interface Purchase {
id: string;
transactionId?: string;
transactionReceipt?: string;
}
export interface IPlatformAdapter {
readonly name: string;
/**
* Check if this adapter can run on the current platform
*/
isSupported(): boolean;
/**
* Initialize the adapter (connect to native IAP, init Stripe, etc.)
*/
init(config?: PurchasesConfig): Promise<void>;
/**
* Fetch platform-specific store products for the given SKUs
* Returns empty array on web/unsupported platforms
*/
fetchStoreProducts(skus: string[]): Promise<StoreProduct[]>;
/**
* Execute a purchase for the given package
* This should handle the platform-specific purchase flow
*/
purchase(pkg: PurchasesPackage, userId?: string): Promise<Purchase>;
/**
* Restore previous purchases (native only)
* Web implementation can be a no-op
*/
restore(userId?: string): Promise<void>;
/**
* Clean up resources, remove listeners, etc.
*/
dispose(): void;
}
export declare abstract class BasePlatformAdapter implements IPlatformAdapter {
abstract readonly name: string;
protected config: PurchasesConfig;
abstract isSupported(): boolean;
abstract init(config?: PurchasesConfig): Promise<void>;
abstract purchase(pkg: PurchasesPackage, userId?: string): Promise<Purchase>;
fetchStoreProducts(_skus: string[]): Promise<StoreProduct[]>;
restore(_userId?: string): Promise<void>;
dispose(): void;
}
//# sourceMappingURL=adapters.d.ts.map