Skip to main content
Version: 2.7

Types

IAPKit - In-App Purchase Solution

This page contains the TypeScript types and interfaces used throughout the expo-iap library.

Core Types​

Product​

type ProductType = 'inapp' | 'subs';
interface Product {
id: string;
title: string;
description: string;
type: ProductType;
displayName?: string;
displayPrice: string;
currency: string;
price?: number;
}

⚠️ Breaking Change Notice (v2.6+)​

Version 2.6+ Migration: The subscription field in ProductIOS has changed from a required field to an optional field (subscription?). This reflects that not all iOS products have subscription information. Please update your code to handle this field as optional when working with non-subscription products.

iOS product contains additional information:

type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | '';
type PaymentMode = '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';

type ProductIOS = Product & {
displayName: string;
isFamilyShareable: boolean;
jsonRepresentation: string;
subscription?: SubscriptionInfo;
introductoryPriceNumberOfPeriodsIOS?: string;
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
};

type SubscriptionInfo = {
introductoryOffer?: SubscriptionOffer;
promotionalOffers?: SubscriptionOffer[];
subscriptionGroupID: string;
subscriptionPeriod: {
unit: SubscriptionIosPeriod;
value: number;
};
};

type SubscriptionOffer = {
displayPrice: string;
id: string;
paymentMode: PaymentMode;
period: {
unit: SubscriptionIosPeriod;
value: number;
};
periodCount: number;
price: number;
type: 'introductory' | 'promotional';
};

Purchase​

interface Purchase {
purchaseId: string;
productId: string;
transactionId: string;
transactionDate: number;
purchaseState: PurchaseState;
isAcknowledged: boolean;
originalJson?: string;
signature?: string;
}

PurchaseState​

enum PurchaseState {
PURCHASED = 'PURCHASED',
PENDING = 'PENDING',
UNSPECIFIED_STATE = 'UNSPECIFIED_STATE',
}

Subscription​

interface Subscription {
productId: string;
purchaseToken: string;
isAutoRenewing: boolean;
expiryTimeMillis: number;
autoResumeTimeMillis?: number;
priceCurrencyCode?: string;
priceAmountMicros?: number;
countryCode?: string;
orderId?: string;
packageName?: string;
}

Platform-Specific Types​

iOS​

For other iOS-specific types and enums, refer to the iOS setup guide.

Android​

For Android-specific types and enums, refer to the Android setup guide.

Error Types​

For error codes and error handling types, see the Error Codes documentation.