a0-purchases
Version:
Lightweight subscription management for AI apps with auto-detecting providers
129 lines • 3.79 kB
TypeScript
import type { Product, SubscriptionProduct, ProductPurchase, SubscriptionPurchase } from 'expo-iap';
import { CustomerInfo, PurchasesOffering, PurchasesOfferings, PurchasesPackage, PACKAGE_TYPE } from "./revenuecat-types";
export { CustomerInfo, PurchasesOffering, PurchasesOfferings, PurchasesPackage, PACKAGE_TYPE };
export declare enum PURCHASES_ERROR_CODE {
UNKNOWN_ERROR = 0,
PURCHASE_CANCELLED_ERROR = 1,
STORE_PROBLEM_ERROR = 2,
PURCHASE_NOT_ALLOWED_ERROR = 3,
PURCHASE_INVALID_ERROR = 4,
PRODUCT_NOT_AVAILABLE_FOR_PURCHASE_ERROR = 5,
PRODUCT_ALREADY_PURCHASED_ERROR = 6,
RECEIPT_ALREADY_IN_USE_ERROR = 7,
INVALID_RECEIPT_ERROR = 8,
MISSING_RECEIPT_FILE_ERROR = 9,
NETWORK_ERROR = 10,
INVALID_CREDENTIALS_ERROR = 11,
UNEXPECTED_BACKEND_RESPONSE_ERROR = 12,
RECEIPT_IN_USE_BY_OTHER_SUBSCRIBER_ERROR = 13,
INVALID_APP_USER_ID_ERROR = 14,
OPERATION_ALREADY_IN_PROGRESS_ERROR = 15,
UNKNOWN_BACKEND_ERROR = 16,
MISSING_PROJECT_ID_ERROR = 17,
INITIALIZATION_ERROR = 100,
PRODUCT_NOT_AVAILABLE_ERROR = 101,
PURCHASE_IN_PROGRESS_ERROR = 102,
REFRESH_ERROR = 103,
RESTORE_ERROR = 104,
BACKEND_VALIDATION_ERROR = 105,
SERVICE_UNAVAILABLE = 106,
NATIVE_IAP_UNAVAILABLE_ERROR = 107
}
export interface LibraryError extends Error {
code: PURCHASES_ERROR_CODE;
underlyingError?: any;
userCancelled?: boolean;
}
export interface PurchasesError {
code: PURCHASES_ERROR_CODE;
message: string;
readableErrorCode?: string;
userInfo?: {
readableErrorCode?: string;
};
underlyingErrorMessage?: string;
userCancelled?: boolean;
}
export type PLATFORM_TYPES = 'ios' | 'android' | 'stripe' | 'amazon' | 'global';
export interface BackendProduct {
id: string;
name: string;
appId: string;
type: 'consumable' | 'non_consumable' | 'subscription';
price: number;
currency: string;
durationUnit?: string;
durationValue?: number;
platform: PLATFORM_TYPES;
storeProductId: string;
trialPeriod?: string;
description?: string;
status: 'active' | 'inactive';
createdAt: string;
updatedAt: string;
}
export interface BackendProductListResponse {
products: BackendProduct[];
}
export interface BackendPackage {
id: string;
identifier: string;
displayName: string;
appId: string;
description?: string;
offeringId: string;
packageType: PACKAGE_TYPE;
products: string[];
entitlements: string[];
createdAt: string;
updatedAt: string;
}
export interface MakePurchaseResult {
productIdentifier: string;
customerInfo: CustomerInfo;
transaction: {
transactionIdentifier: string;
productIdentifier: string;
purchaseDate: string;
};
}
export type StoreProduct = (Product | SubscriptionProduct) & {
id?: string;
productId?: string;
};
export type Purchase = (ProductPurchase | SubscriptionPurchase) & {
id: string;
productId?: string;
};
export interface PurchaseSuccessResult {
customerInfo: CustomerInfo;
productIdentifier: string;
transactionId?: string;
}
export interface A0Config {
projectId: string;
live: boolean;
snackUrl: string;
apiUrl: string;
iconUrl: string;
ek: string;
apiKey: string;
runtimeVersion: string;
initialDeployment: {
deploymentId: string;
deploymentData: string;
};
}
export interface PurchasesConfig {
/**
* Enable debug logging for the purchases service
* @default false
*/
debug?: boolean;
/**
* Optional custom App User ID to use instead of anonymous ID
* If not provided, an anonymous ID will be generated
*/
appUserId?: string;
}
//# sourceMappingURL=types.d.ts.map