import type {TurboModule} from 'react-native'; import {TurboModuleRegistry} from 'react-native'; type NativeStartOptions = { appId: string; apiKey: string; userId?: string; allowAnonymousPurchase?: boolean; enableDeferredPurchaseListener?: boolean; enableStorekitV2?: boolean; lang?: string; environment?: string; sdkVersion?: string; sdk?: string; }; type NativeDeviceParams = {[key: string]: string}; type NativeUserTags = {[key: string]: string}; type NativeBuyOptions = { crossPlatformConflict: boolean; prorationMode?: string; }; type NativeGetProductsOptions = { includeSubscriptionStates: string[]; }; type NativeShowManageSubscriptionsOptions = { sku?: string; }; type NativeSubscriptionIntroPhase = { type: string; price: number; currency: string; localizedPrice: string; cycleDuration: string; cycleCount: number; payment: string; }; type NativeProduct = { id: string; type: string; sku: string; price: number; currency: string | null; localizedPrice: string | null; localizedTitle: string | null; localizedDescription: string | null; alias: string | null; group: string | null; groupName: string | null; subscriptionDuration: string | null; subscriptionIntroPhases?: NativeSubscriptionIntroPhase[]; metadata: {[key: string]: string}; }; type NativeActiveProduct = NativeProduct & { purchase: string | null; purchaseDate: string | null; platform: string | null; isSandbox: boolean; isPromo: boolean; promoCode: string | null; originalPurchase: string | null; expirationDate: string | null; isSubscriptionRenewable: boolean; isFamilyShare: boolean; subscriptionRenewalProduct: string | null; subscriptionRenewalProductSku: string | null; subscriptionState: string | null; subscriptionPeriodType: string | null; }; type NativeTransaction = NativeActiveProduct & { webhookStatus: string | null; user: string | null; }; type NativeProducts = { productsForSale: NativeProduct[]; activeProducts: NativeActiveProduct[]; }; type NativeRestoreResponse = { newPurchases: NativeTransaction[]; transferredActiveProducts: NativeActiveProduct[]; }; type NativeError = { code: string; message: string; subcode?: string; params?: {[key: string]: string}; }; type NativeBillingStatus = { error: NativeError | null; filteredProductIds: string[]; }; type NativeEventName = | 'onUserUpdate' | 'onDeferredPurchase' | 'onError' | 'onBuyRequest' | 'onReceipt'; export interface Spec extends TurboModule { start(options: NativeStartOptions): Promise; stop(): Promise; getSDKVersion?(): Promise; setLang(lang: string): Promise; login(userId: string): Promise; getUserId(): Promise; logout(): Promise; setDeviceParams(params: NativeDeviceParams): Promise; setUserTags(tags: NativeUserTags): Promise; buy(sku: string, options: NativeBuyOptions): Promise; restore(): Promise; getActiveProducts(options: NativeGetProductsOptions): Promise; getProductsForSale(): Promise; getProducts(options: NativeGetProductsOptions): Promise; getBillingStatus(): Promise; presentCodeRedemptionSheet(): Promise; showManageSubscriptions(options: NativeShowManageSubscriptionsOptions): Promise; addListener(eventName: NativeEventName): void; removeListeners(count: number): void; } export default TurboModuleRegistry.getEnforcing('NativeIaphub');