expo-iap 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.0.3 - 2025-09-14
4
+
5
+ - Types: Align Expo IAP surface with [react-native-iap #3006](https://github.com/hyochan/react-native-iap/pull/3006) by renaming subscription aliases, adding StoreKit product enums, and exposing optional purchase metadata (quantity, purchaseState, isAutoRenewing).
6
+ - Errors: Switch JS helpers and docs to camelCase `ErrorCode` members and tighten error inspection utilities to avoid `any` usage.
7
+
3
8
  ## 3.0.2 - 2025-09-13
4
9
 
5
10
  - iOS: Fix build error “cannot convert value of type '[[String : Any?]]'” in Expo bridge by returning non‑optional dictionaries and removing double‑serialization in `showManageSubscriptionsIOS` (Fixes #202).
@@ -4,6 +4,14 @@ export type ChangeEventPayload = {
4
4
  value: string;
5
5
  };
6
6
  export type ProductType = 'inapp' | 'subs';
7
+ export declare enum PurchaseState {
8
+ Pending = "pending",
9
+ Purchased = "purchased",
10
+ Failed = "failed",
11
+ Restored = "restored",
12
+ Deferred = "deferred",
13
+ Unknown = "unknown"
14
+ }
7
15
  export type ProductCommon = {
8
16
  id: string;
9
17
  title: string;
@@ -20,10 +28,13 @@ export type PurchaseCommon = {
20
28
  id: string;
21
29
  productId: string;
22
30
  ids?: string[];
31
+ transactionId?: string;
23
32
  transactionDate: number;
24
- transactionReceipt: string;
25
33
  purchaseToken?: string;
26
34
  platform?: string;
35
+ quantity?: number;
36
+ purchaseState?: PurchaseState;
37
+ isAutoRenewing?: boolean;
27
38
  };
28
39
  export type ProductSubscriptionCommon = ProductCommon & {
29
40
  type: 'subs';
@@ -35,7 +46,8 @@ export type AndroidPlatform = {
35
46
  platform: 'android';
36
47
  };
37
48
  export type Product = (ProductAndroid & AndroidPlatform) | (ProductIOS & IosPlatform);
38
- export type SubscriptionProduct = (ProductSubscriptionAndroid & AndroidPlatform) | (ProductSubscriptionIOS & IosPlatform);
49
+ export type ProductSubscription = (ProductSubscriptionAndroid & AndroidPlatform) | (ProductSubscriptionIOS & IosPlatform);
50
+ export type SubscriptionProduct = ProductSubscription;
39
51
  export * from './types/ExpoIapAndroid.types';
40
52
  export * from './types/ExpoIapIOS.types';
41
53
  export type Purchase = (PurchaseAndroid & AndroidPlatform) | (PurchaseIOS & IosPlatform);
@@ -51,40 +63,40 @@ export type PurchaseResult = {
51
63
  * These are mapped to platform-specific error codes and provide consistent error handling
52
64
  */
53
65
  export declare enum ErrorCode {
54
- E_UNKNOWN = "E_UNKNOWN",
55
- E_USER_CANCELLED = "E_USER_CANCELLED",
56
- E_USER_ERROR = "E_USER_ERROR",
57
- E_ITEM_UNAVAILABLE = "E_ITEM_UNAVAILABLE",
58
- E_REMOTE_ERROR = "E_REMOTE_ERROR",
59
- E_NETWORK_ERROR = "E_NETWORK_ERROR",
60
- E_SERVICE_ERROR = "E_SERVICE_ERROR",
61
- E_RECEIPT_FAILED = "E_RECEIPT_FAILED",
62
- E_RECEIPT_FINISHED = "E_RECEIPT_FINISHED",
63
- E_RECEIPT_FINISHED_FAILED = "E_RECEIPT_FINISHED_FAILED",
64
- E_NOT_PREPARED = "E_NOT_PREPARED",
65
- E_NOT_ENDED = "E_NOT_ENDED",
66
- E_ALREADY_OWNED = "E_ALREADY_OWNED",
67
- E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR",
68
- E_BILLING_RESPONSE_JSON_PARSE_ERROR = "E_BILLING_RESPONSE_JSON_PARSE_ERROR",
69
- E_DEFERRED_PAYMENT = "E_DEFERRED_PAYMENT",
70
- E_INTERRUPTED = "E_INTERRUPTED",
71
- E_IAP_NOT_AVAILABLE = "E_IAP_NOT_AVAILABLE",
72
- E_PURCHASE_ERROR = "E_PURCHASE_ERROR",
73
- E_SYNC_ERROR = "E_SYNC_ERROR",
74
- E_TRANSACTION_VALIDATION_FAILED = "E_TRANSACTION_VALIDATION_FAILED",
75
- E_ACTIVITY_UNAVAILABLE = "E_ACTIVITY_UNAVAILABLE",
76
- E_ALREADY_PREPARED = "E_ALREADY_PREPARED",
77
- E_PENDING = "E_PENDING",
78
- E_CONNECTION_CLOSED = "E_CONNECTION_CLOSED",
79
- E_INIT_CONNECTION = "E_INIT_CONNECTION",
80
- E_SERVICE_DISCONNECTED = "E_SERVICE_DISCONNECTED",
81
- E_QUERY_PRODUCT = "E_QUERY_PRODUCT",
82
- E_SKU_NOT_FOUND = "E_SKU_NOT_FOUND",
83
- E_SKU_OFFER_MISMATCH = "E_SKU_OFFER_MISMATCH",
84
- E_ITEM_NOT_OWNED = "E_ITEM_NOT_OWNED",
85
- E_BILLING_UNAVAILABLE = "E_BILLING_UNAVAILABLE",
86
- E_FEATURE_NOT_SUPPORTED = "E_FEATURE_NOT_SUPPORTED",
87
- E_EMPTY_SKU_LIST = "E_EMPTY_SKU_LIST"
66
+ Unknown = "E_UNKNOWN",
67
+ UserCancelled = "E_USER_CANCELLED",
68
+ UserError = "E_USER_ERROR",
69
+ ItemUnavailable = "E_ITEM_UNAVAILABLE",
70
+ RemoteError = "E_REMOTE_ERROR",
71
+ NetworkError = "E_NETWORK_ERROR",
72
+ ServiceError = "E_SERVICE_ERROR",
73
+ ReceiptFailed = "E_RECEIPT_FAILED",
74
+ ReceiptFinished = "E_RECEIPT_FINISHED",
75
+ ReceiptFinishedFailed = "E_RECEIPT_FINISHED_FAILED",
76
+ NotPrepared = "E_NOT_PREPARED",
77
+ NotEnded = "E_NOT_ENDED",
78
+ AlreadyOwned = "E_ALREADY_OWNED",
79
+ DeveloperError = "E_DEVELOPER_ERROR",
80
+ BillingResponseJsonParseError = "E_BILLING_RESPONSE_JSON_PARSE_ERROR",
81
+ DeferredPayment = "E_DEFERRED_PAYMENT",
82
+ Interrupted = "E_INTERRUPTED",
83
+ IapNotAvailable = "E_IAP_NOT_AVAILABLE",
84
+ PurchaseError = "E_PURCHASE_ERROR",
85
+ SyncError = "E_SYNC_ERROR",
86
+ TransactionValidationFailed = "E_TRANSACTION_VALIDATION_FAILED",
87
+ ActivityUnavailable = "E_ACTIVITY_UNAVAILABLE",
88
+ AlreadyPrepared = "E_ALREADY_PREPARED",
89
+ Pending = "E_PENDING",
90
+ ConnectionClosed = "E_CONNECTION_CLOSED",
91
+ InitConnection = "E_INIT_CONNECTION",
92
+ ServiceDisconnected = "E_SERVICE_DISCONNECTED",
93
+ QueryProduct = "E_QUERY_PRODUCT",
94
+ SkuNotFound = "E_SKU_NOT_FOUND",
95
+ SkuOfferMismatch = "E_SKU_OFFER_MISMATCH",
96
+ ItemNotOwned = "E_ITEM_NOT_OWNED",
97
+ BillingUnavailable = "E_BILLING_UNAVAILABLE",
98
+ FeatureNotSupported = "E_FEATURE_NOT_SUPPORTED",
99
+ EmptySkuList = "E_EMPTY_SKU_LIST"
88
100
  }
89
101
  export declare const ErrorCodeMapping: {
90
102
  readonly ios: {
@@ -260,6 +272,7 @@ export interface RequestPurchaseAndroidProps {
260
272
  * Android-specific subscription request parameters
261
273
  */
262
274
  export interface RequestSubscriptionAndroidProps extends RequestPurchaseAndroidProps {
275
+ readonly purchaseTokenAndroid?: string;
263
276
  readonly replacementModeAndroid?: number;
264
277
  readonly subscriptionOffers: {
265
278
  sku: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIap.types.d.ts","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,0BAA0B,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAM3C,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAA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oBAAoB,GAAG,+BAA+B,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,mCAAmC,CAAC"}
@@ -1,4 +1,13 @@
1
1
  import { NATIVE_ERROR_CODES } from './ExpoIapModule';
2
+ export var PurchaseState;
3
+ (function (PurchaseState) {
4
+ PurchaseState["Pending"] = "pending";
5
+ PurchaseState["Purchased"] = "purchased";
6
+ PurchaseState["Failed"] = "failed";
7
+ PurchaseState["Restored"] = "restored";
8
+ PurchaseState["Deferred"] = "deferred";
9
+ PurchaseState["Unknown"] = "unknown";
10
+ })(PurchaseState || (PurchaseState = {}));
2
11
  // Re-export all platform-specific types to avoid deep imports
3
12
  export * from './types/ExpoIapAndroid.types';
4
13
  export * from './types/ExpoIapIOS.types';
@@ -8,41 +17,41 @@ export * from './types/ExpoIapIOS.types';
8
17
  */
9
18
  export var ErrorCode;
10
19
  (function (ErrorCode) {
11
- ErrorCode["E_UNKNOWN"] = "E_UNKNOWN";
12
- ErrorCode["E_USER_CANCELLED"] = "E_USER_CANCELLED";
13
- ErrorCode["E_USER_ERROR"] = "E_USER_ERROR";
14
- ErrorCode["E_ITEM_UNAVAILABLE"] = "E_ITEM_UNAVAILABLE";
15
- ErrorCode["E_REMOTE_ERROR"] = "E_REMOTE_ERROR";
16
- ErrorCode["E_NETWORK_ERROR"] = "E_NETWORK_ERROR";
17
- ErrorCode["E_SERVICE_ERROR"] = "E_SERVICE_ERROR";
18
- ErrorCode["E_RECEIPT_FAILED"] = "E_RECEIPT_FAILED";
19
- ErrorCode["E_RECEIPT_FINISHED"] = "E_RECEIPT_FINISHED";
20
- ErrorCode["E_RECEIPT_FINISHED_FAILED"] = "E_RECEIPT_FINISHED_FAILED";
21
- ErrorCode["E_NOT_PREPARED"] = "E_NOT_PREPARED";
22
- ErrorCode["E_NOT_ENDED"] = "E_NOT_ENDED";
23
- ErrorCode["E_ALREADY_OWNED"] = "E_ALREADY_OWNED";
24
- ErrorCode["E_DEVELOPER_ERROR"] = "E_DEVELOPER_ERROR";
25
- ErrorCode["E_BILLING_RESPONSE_JSON_PARSE_ERROR"] = "E_BILLING_RESPONSE_JSON_PARSE_ERROR";
26
- ErrorCode["E_DEFERRED_PAYMENT"] = "E_DEFERRED_PAYMENT";
27
- ErrorCode["E_INTERRUPTED"] = "E_INTERRUPTED";
28
- ErrorCode["E_IAP_NOT_AVAILABLE"] = "E_IAP_NOT_AVAILABLE";
29
- ErrorCode["E_PURCHASE_ERROR"] = "E_PURCHASE_ERROR";
30
- ErrorCode["E_SYNC_ERROR"] = "E_SYNC_ERROR";
31
- ErrorCode["E_TRANSACTION_VALIDATION_FAILED"] = "E_TRANSACTION_VALIDATION_FAILED";
32
- ErrorCode["E_ACTIVITY_UNAVAILABLE"] = "E_ACTIVITY_UNAVAILABLE";
33
- ErrorCode["E_ALREADY_PREPARED"] = "E_ALREADY_PREPARED";
34
- ErrorCode["E_PENDING"] = "E_PENDING";
35
- ErrorCode["E_CONNECTION_CLOSED"] = "E_CONNECTION_CLOSED";
20
+ ErrorCode["Unknown"] = "E_UNKNOWN";
21
+ ErrorCode["UserCancelled"] = "E_USER_CANCELLED";
22
+ ErrorCode["UserError"] = "E_USER_ERROR";
23
+ ErrorCode["ItemUnavailable"] = "E_ITEM_UNAVAILABLE";
24
+ ErrorCode["RemoteError"] = "E_REMOTE_ERROR";
25
+ ErrorCode["NetworkError"] = "E_NETWORK_ERROR";
26
+ ErrorCode["ServiceError"] = "E_SERVICE_ERROR";
27
+ ErrorCode["ReceiptFailed"] = "E_RECEIPT_FAILED";
28
+ ErrorCode["ReceiptFinished"] = "E_RECEIPT_FINISHED";
29
+ ErrorCode["ReceiptFinishedFailed"] = "E_RECEIPT_FINISHED_FAILED";
30
+ ErrorCode["NotPrepared"] = "E_NOT_PREPARED";
31
+ ErrorCode["NotEnded"] = "E_NOT_ENDED";
32
+ ErrorCode["AlreadyOwned"] = "E_ALREADY_OWNED";
33
+ ErrorCode["DeveloperError"] = "E_DEVELOPER_ERROR";
34
+ ErrorCode["BillingResponseJsonParseError"] = "E_BILLING_RESPONSE_JSON_PARSE_ERROR";
35
+ ErrorCode["DeferredPayment"] = "E_DEFERRED_PAYMENT";
36
+ ErrorCode["Interrupted"] = "E_INTERRUPTED";
37
+ ErrorCode["IapNotAvailable"] = "E_IAP_NOT_AVAILABLE";
38
+ ErrorCode["PurchaseError"] = "E_PURCHASE_ERROR";
39
+ ErrorCode["SyncError"] = "E_SYNC_ERROR";
40
+ ErrorCode["TransactionValidationFailed"] = "E_TRANSACTION_VALIDATION_FAILED";
41
+ ErrorCode["ActivityUnavailable"] = "E_ACTIVITY_UNAVAILABLE";
42
+ ErrorCode["AlreadyPrepared"] = "E_ALREADY_PREPARED";
43
+ ErrorCode["Pending"] = "E_PENDING";
44
+ ErrorCode["ConnectionClosed"] = "E_CONNECTION_CLOSED";
36
45
  // Additional detailed errors (Android-focused, kept cross-platform)
37
- ErrorCode["E_INIT_CONNECTION"] = "E_INIT_CONNECTION";
38
- ErrorCode["E_SERVICE_DISCONNECTED"] = "E_SERVICE_DISCONNECTED";
39
- ErrorCode["E_QUERY_PRODUCT"] = "E_QUERY_PRODUCT";
40
- ErrorCode["E_SKU_NOT_FOUND"] = "E_SKU_NOT_FOUND";
41
- ErrorCode["E_SKU_OFFER_MISMATCH"] = "E_SKU_OFFER_MISMATCH";
42
- ErrorCode["E_ITEM_NOT_OWNED"] = "E_ITEM_NOT_OWNED";
43
- ErrorCode["E_BILLING_UNAVAILABLE"] = "E_BILLING_UNAVAILABLE";
44
- ErrorCode["E_FEATURE_NOT_SUPPORTED"] = "E_FEATURE_NOT_SUPPORTED";
45
- ErrorCode["E_EMPTY_SKU_LIST"] = "E_EMPTY_SKU_LIST";
46
+ ErrorCode["InitConnection"] = "E_INIT_CONNECTION";
47
+ ErrorCode["ServiceDisconnected"] = "E_SERVICE_DISCONNECTED";
48
+ ErrorCode["QueryProduct"] = "E_QUERY_PRODUCT";
49
+ ErrorCode["SkuNotFound"] = "E_SKU_NOT_FOUND";
50
+ ErrorCode["SkuOfferMismatch"] = "E_SKU_OFFER_MISMATCH";
51
+ ErrorCode["ItemNotOwned"] = "E_ITEM_NOT_OWNED";
52
+ ErrorCode["BillingUnavailable"] = "E_BILLING_UNAVAILABLE";
53
+ ErrorCode["FeatureNotSupported"] = "E_FEATURE_NOT_SUPPORTED";
54
+ ErrorCode["EmptySkuList"] = "E_EMPTY_SKU_LIST";
46
55
  })(ErrorCode || (ErrorCode = {}));
47
56
  // Fast lookup set for validating standardized error code strings
48
57
  const OPENIAP_ERROR_CODE_SET = new Set(Object.values(ErrorCode));
@@ -52,40 +61,40 @@ const OPENIAP_ERROR_CODE_SET = new Set(Object.values(ErrorCode));
52
61
  */
53
62
  // Shared OpenIAP string code mapping for both platforms
54
63
  const COMMON_ERROR_CODE_MAP = {
55
- [ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',
56
- [ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',
57
- [ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',
58
- [ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',
59
- [ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',
60
- [ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',
61
- [ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',
62
- [ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',
63
- [ErrorCode.E_RECEIPT_FINISHED]: 'E_RECEIPT_FINISHED',
64
- [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',
65
- [ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',
66
- [ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',
67
- [ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',
68
- [ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',
69
- [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
70
- [ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',
71
- [ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',
72
- [ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',
73
- [ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',
74
- [ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',
75
- [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 'E_TRANSACTION_VALIDATION_FAILED',
76
- [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',
77
- [ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',
78
- [ErrorCode.E_PENDING]: 'E_PENDING',
79
- [ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',
80
- [ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',
81
- [ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',
82
- [ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',
83
- [ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',
84
- [ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',
85
- [ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',
86
- [ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',
87
- [ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',
88
- [ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',
64
+ [ErrorCode.Unknown]: 'E_UNKNOWN',
65
+ [ErrorCode.UserCancelled]: 'E_USER_CANCELLED',
66
+ [ErrorCode.UserError]: 'E_USER_ERROR',
67
+ [ErrorCode.ItemUnavailable]: 'E_ITEM_UNAVAILABLE',
68
+ [ErrorCode.RemoteError]: 'E_REMOTE_ERROR',
69
+ [ErrorCode.NetworkError]: 'E_NETWORK_ERROR',
70
+ [ErrorCode.ServiceError]: 'E_SERVICE_ERROR',
71
+ [ErrorCode.ReceiptFailed]: 'E_RECEIPT_FAILED',
72
+ [ErrorCode.ReceiptFinished]: 'E_RECEIPT_FINISHED',
73
+ [ErrorCode.ReceiptFinishedFailed]: 'E_RECEIPT_FINISHED_FAILED',
74
+ [ErrorCode.NotPrepared]: 'E_NOT_PREPARED',
75
+ [ErrorCode.NotEnded]: 'E_NOT_ENDED',
76
+ [ErrorCode.AlreadyOwned]: 'E_ALREADY_OWNED',
77
+ [ErrorCode.DeveloperError]: 'E_DEVELOPER_ERROR',
78
+ [ErrorCode.BillingResponseJsonParseError]: 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
79
+ [ErrorCode.DeferredPayment]: 'E_DEFERRED_PAYMENT',
80
+ [ErrorCode.Interrupted]: 'E_INTERRUPTED',
81
+ [ErrorCode.IapNotAvailable]: 'E_IAP_NOT_AVAILABLE',
82
+ [ErrorCode.PurchaseError]: 'E_PURCHASE_ERROR',
83
+ [ErrorCode.SyncError]: 'E_SYNC_ERROR',
84
+ [ErrorCode.TransactionValidationFailed]: 'E_TRANSACTION_VALIDATION_FAILED',
85
+ [ErrorCode.ActivityUnavailable]: 'E_ACTIVITY_UNAVAILABLE',
86
+ [ErrorCode.AlreadyPrepared]: 'E_ALREADY_PREPARED',
87
+ [ErrorCode.Pending]: 'E_PENDING',
88
+ [ErrorCode.ConnectionClosed]: 'E_CONNECTION_CLOSED',
89
+ [ErrorCode.InitConnection]: 'E_INIT_CONNECTION',
90
+ [ErrorCode.ServiceDisconnected]: 'E_SERVICE_DISCONNECTED',
91
+ [ErrorCode.QueryProduct]: 'E_QUERY_PRODUCT',
92
+ [ErrorCode.SkuNotFound]: 'E_SKU_NOT_FOUND',
93
+ [ErrorCode.SkuOfferMismatch]: 'E_SKU_OFFER_MISMATCH',
94
+ [ErrorCode.ItemNotOwned]: 'E_ITEM_NOT_OWNED',
95
+ [ErrorCode.BillingUnavailable]: 'E_BILLING_UNAVAILABLE',
96
+ [ErrorCode.FeatureNotSupported]: 'E_FEATURE_NOT_SUPPORTED',
97
+ [ErrorCode.EmptySkuList]: 'E_EMPTY_SKU_LIST',
89
98
  };
90
99
  export const ErrorCodeMapping = {
91
100
  // iOS: standardized OpenIAP string codes
@@ -134,7 +143,7 @@ export class PurchaseError {
134
143
  static fromPlatformError(errorData, platform) {
135
144
  const errorCode = errorData.code
136
145
  ? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)
137
- : ErrorCode.E_UNKNOWN;
146
+ : ErrorCode.Unknown;
138
147
  return new PurchaseError({
139
148
  message: errorData.message || 'Unknown error occurred',
140
149
  responseCode: errorData.responseCode,
@@ -196,7 +205,7 @@ export const ErrorCodeUtils = {
196
205
  return errorCode;
197
206
  }
198
207
  }
199
- return ErrorCode.E_UNKNOWN;
208
+ return ErrorCode.Unknown;
200
209
  },
201
210
  /**
202
211
  * Maps an ErrorCode enum to platform-specific code
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAoDnD,8DAA8D;AAC9D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AAczC;;;GAGG;AACH,MAAM,CAAN,IAAY,SAoCX;AApCD,WAAY,SAAS;IACnB,oCAAuB,CAAA;IACvB,kDAAqC,CAAA;IACrC,0CAA6B,CAAA;IAC7B,sDAAyC,CAAA;IACzC,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,kDAAqC,CAAA;IACrC,sDAAyC,CAAA;IACzC,oEAAuD,CAAA;IACvD,8CAAiC,CAAA;IAC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ductAndroid,\n PurchaseAndroid,\n ProductSubscriptionAndroid,\n} from './types/ExpoIapAndroid.types';\nimport type {\n ProductIOS,\n PurchaseIOS,\n ProductSubscriptionIOS,\n} from './types/ExpoIapIOS.types';\nimport {NATIVE_ERROR_CODES} from './ExpoIapModule';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ProductType = 'inapp' | 'subs';\n\n// =============================================================================\n// COMMON TYPES (Base types shared across all platforms)\n// =============================================================================\n\nexport type ProductCommon = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice: string;\n currency: string;\n price?: number;\n debugDescription?: string;\n platform?: string;\n};\n\nexport type PurchaseCommon = {\n id: string; // Transaction identifier - used by finishTransaction\n productId: string; // Product identifier - which product was purchased\n ids?: string[]; // Product identifiers for purchases that include multiple products\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string; // Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android)\n platform?: string;\n};\n\nexport type ProductSubscriptionCommon = ProductCommon & {\n type: 'subs';\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\n// Platform-agnostic unified product types (public API)\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIOS & IosPlatform);\n\nexport type SubscriptionProduct =\n | (ProductSubscriptionAndroid & AndroidPlatform)\n | (ProductSubscriptionIOS & IosPlatform);\n\n// Re-export all platform-specific types to avoid deep imports\nexport * from './types/ExpoIapAndroid.types';\nexport * from './types/ExpoIapIOS.types';\n\n// Unified purchase type for both products and subscriptions\nexport type Purchase =\n | (PurchaseAndroid & AndroidPlatform)\n | (PurchaseIOS & IosPlatform);\n\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n};\n/**\n * Centralized error codes for expo-iap\n * These are mapped to platform-specific error codes and provide consistent error handling\n */\nexport enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED = 'E_RECEIPT_FINISHED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',\n E_SYNC_ERROR = 'E_SYNC_ERROR',\n E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',\n E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',\n E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',\n E_PENDING = 'E_PENDING',\n E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',\n // Additional detailed errors (Android-focused, kept cross-platform)\n E_INIT_CONNECTION = 'E_INIT_CONNECTION',\n E_SERVICE_DISCONNECTED = 'E_SERVICE_DISCONNECTED',\n E_QUERY_PRODUCT = 'E_QUERY_PRODUCT',\n E_SKU_NOT_FOUND = 'E_SKU_NOT_FOUND',\n E_SKU_OFFER_MISMATCH = 'E_SKU_OFFER_MISMATCH',\n E_ITEM_NOT_OWNED = 'E_ITEM_NOT_OWNED',\n E_BILLING_UNAVAILABLE = 'E_BILLING_UNAVAILABLE',\n E_FEATURE_NOT_SUPPORTED = 'E_FEATURE_NOT_SUPPORTED',\n E_EMPTY_SKU_LIST = 'E_EMPTY_SKU_LIST',\n}\n\n// Fast lookup set for validating standardized error code strings\nconst OPENIAP_ERROR_CODE_SET: Set<string> = new Set(\n Object.values(ErrorCode) as string[],\n);\n\n/**\n * Platform-specific error code mappings\n * Maps ErrorCode enum values to platform-specific integer codes\n */\n// Shared OpenIAP string code mapping for both platforms\nconst COMMON_ERROR_CODE_MAP = {\n [ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',\n [ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',\n [ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',\n [ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',\n [ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',\n [ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',\n [ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',\n [ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',\n [ErrorCode.E_RECEIPT_FINISHED]: 'E_RECEIPT_FINISHED',\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',\n [ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',\n [ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',\n [ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',\n [ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:\n 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n [ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',\n [ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',\n [ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',\n [ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:\n 'E_TRANSACTION_VALIDATION_FAILED',\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',\n [ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',\n [ErrorCode.E_PENDING]: 'E_PENDING',\n [ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',\n [ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',\n [ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',\n [ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',\n [ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',\n [ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',\n [ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',\n [ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',\n [ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',\n [ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',\n} as const;\n\nexport const ErrorCodeMapping = {\n // iOS: standardized OpenIAP string codes\n ios: COMMON_ERROR_CODE_MAP,\n // Android: standardized OpenIAP string codes\n android: COMMON_ERROR_CODE_MAP,\n} as const;\n\nexport type PurchaseErrorProps = {\n message: string;\n responseCode?: number;\n debugMessage?: string;\n code?: ErrorCode;\n productId?: string;\n platform?: 'ios' | 'android';\n};\n\nexport class PurchaseError implements Error {\n public name: string;\n public message: string;\n public responseCode?: number;\n public debugMessage?: string;\n public code?: ErrorCode;\n public productId?: string;\n public platform?: 'ios' | 'android';\n\n // Backwards-compatible constructor: accepts either props object or legacy positional args\n constructor(messageOrProps: string | PurchaseErrorProps, ...rest: any[]) {\n this.name = '[expo-iap]: PurchaseError';\n\n if (typeof messageOrProps === 'string') {\n // Legacy signature: (name, message, responseCode?, debugMessage?, code?, productId?, platform?)\n // The first legacy argument was a name which we always override, so treat it as message here\n const message = messageOrProps;\n this.message = message;\n this.responseCode = rest[0];\n this.debugMessage = rest[1];\n this.code = rest[2];\n this.productId = rest[3];\n this.platform = rest[4];\n } else {\n const props = messageOrProps;\n this.message = props.message;\n this.responseCode = props.responseCode;\n this.debugMessage = props.debugMessage;\n this.code = props.code;\n this.productId = props.productId;\n this.platform = props.platform;\n }\n }\n\n /**\n * Creates a PurchaseError from platform-specific error data\n * @param errorData Raw error data from native modules\n * @param platform Platform where the error occurred\n * @returns Properly typed PurchaseError instance\n */\n static fromPlatformError(\n errorData: any,\n platform: 'ios' | 'android',\n ): PurchaseError {\n const errorCode = errorData.code\n ? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)\n : ErrorCode.E_UNKNOWN;\n\n return new PurchaseError({\n message: errorData.message || 'Unknown error occurred',\n responseCode: errorData.responseCode,\n debugMessage: errorData.debugMessage,\n code: errorCode,\n productId: errorData.productId,\n platform,\n });\n }\n\n /**\n * Gets the platform-specific error code for this error\n * @returns Platform-specific error code\n */\n getPlatformCode(): string | number | undefined {\n if (!this.code || !this.platform) return undefined;\n return ErrorCodeUtils.toPlatformCode(this.code, this.platform);\n }\n}\n\n/**\n * Utility functions for error code mapping and validation\n */\nexport const ErrorCodeUtils = {\n /**\n * Gets the native error code for the current platform\n * @param errorCode ErrorCode enum value\n * @returns Platform-specific error code from native constants\n */\n getNativeErrorCode: (errorCode: ErrorCode): string => {\n return NATIVE_ERROR_CODES[errorCode] || errorCode;\n },\n\n /**\n * Maps a platform-specific error code back to the standardized ErrorCode enum\n * @param platformCode Platform-specific error code (string for Android, number for iOS)\n * @param platform Target platform\n * @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found\n */\n fromPlatformCode: (\n platformCode: string | number,\n platform: 'ios' | 'android',\n ): ErrorCode => {\n // If native sent standardized string code, accept it directly\n if (typeof platformCode === 'string' && platformCode.startsWith('E_')) {\n if (OPENIAP_ERROR_CODE_SET.has(platformCode)) {\n return platformCode as ErrorCode;\n }\n }\n // Prefer dynamic native mapping for iOS to avoid drift\n if (platform === 'ios') {\n for (const [, value] of Object.entries(NATIVE_ERROR_CODES || {})) {\n if (value === platformCode) {\n // Native maps friendly keys to standardized 'E_*' codes\n if (typeof value === 'string' && OPENIAP_ERROR_CODE_SET.has(value)) {\n return value as ErrorCode;\n }\n }\n }\n }\n\n const mapping = ErrorCodeMapping[platform];\n for (const [errorCode, mappedCode] of Object.entries(mapping)) {\n if (mappedCode === platformCode) {\n return errorCode as ErrorCode;\n }\n }\n\n return ErrorCode.E_UNKNOWN;\n },\n\n /**\n * Maps an ErrorCode enum to platform-specific code\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns Platform-specific error code\n */\n toPlatformCode: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): string | number => {\n if (platform === 'ios') {\n const native = (NATIVE_ERROR_CODES as any)?.[errorCode];\n if (native !== undefined) return native;\n }\n const mapping = ErrorCodeMapping[platform] as Record<\n ErrorCode,\n string | number\n >;\n return mapping[errorCode] ?? 'E_UNKNOWN';\n },\n\n /**\n * Checks if an error code is valid for the specified platform\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns True if the error code is supported on the platform\n */\n isValidForPlatform: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): boolean => {\n return errorCode in ErrorCodeMapping[platform];\n },\n};\n\n// ============================================================================\n// Enhanced Unified Request Types\n// ============================================================================\n\n/**\n * Unified request props that work on both iOS and Android platforms\n * iOS will use 'sku', Android will use 'skus' (or convert sku to skus array)\n */\nexport interface UnifiedRequestPurchaseProps {\n // Universal properties - works on both platforms\n readonly sku?: string; // Single SKU (iOS native, Android fallback)\n readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)\n\n // iOS-specific properties (ignored on Android)\n readonly andDangerouslyFinishTransactionAutomatically?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n\n // Android-specific properties (ignored on iOS)\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n// ============================================================================\n// New Platform-Specific Request Types (v2.7.0+)\n// ============================================================================\n\n/**\n * iOS-specific purchase request parameters\n */\nexport interface RequestPurchaseIosProps {\n readonly sku: string;\n readonly andDangerouslyFinishTransactionAutomatically?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n}\n\n/**\n * Android-specific purchase request parameters\n */\nexport interface RequestPurchaseAndroidProps {\n readonly skus: string[];\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n/**\n * Android-specific subscription request parameters\n */\nexport interface RequestSubscriptionAndroidProps\n extends RequestPurchaseAndroidProps {\n readonly replacementModeAndroid?: number;\n readonly subscriptionOffers: {\n sku: string;\n offerToken: string;\n }[];\n}\n\n/**\n * Modern platform-specific request structure (v2.7.0+)\n * Allows clear separation of iOS and Android parameters\n */\nexport interface RequestPurchasePropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestPurchaseAndroidProps;\n}\n\n/**\n * Modern platform-specific subscription request structure (v2.7.0+)\n */\nexport interface RequestSubscriptionPropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestSubscriptionAndroidProps;\n}\n\n/**\n * Modern request purchase parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestPurchaseProps = RequestPurchasePropsByPlatforms;\n\n/**\n * Modern request subscription parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;\n"]}
1
+ {"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAQnD,MAAM,CAAN,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;IACrB,sCAAqB,CAAA;IACrB,oCAAmB,CAAA;AACrB,CAAC,EAPW,aAAa,KAAb,aAAa,QAOxB;AAoDD,8DAA8D;AAC9D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AAczC;;;GAGG;AACH,MAAM,CAAN,IAAY,SAoCX;AApCD,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,+CAAkC,CAAA;IAClC,uCAA0B,CAAA;IAC1B,mDAAsC,CAAA;IACtC,2CAA8B,CAAA;IAC9B,6CAAgC,CAAA;IAChC,6CAAgC,CAAA;IAChC,+CAAkC,CAAA;IAClC,mDAAsC,CAAA;IACtC,gEAAmD,CAAA;IACnD,2CAA8B,CAAA;IAC9B,qCAAwB,CAAA;IACxB,6CAAgC,CAAA;IAChC,iDAAoC,CAAA;IACpC,kFAAqE,CAAA;IACrE,mDAAsC,CAAA;IACtC,0CAA6B,CAAA;IAC7B,oDAAuC,CAAA;IACvC,+CAAkC,CAAA;IAClC,uCAA0B,CAAA;IAC1B,4EAA+D,CAAA;IAC/D,2DAA8C,CAAA;IAC9C,mDAAsC,CAAA;IACtC,kCAAqB,CAAA;IACrB,qDAAwC,CAAA;IACxC,oEAAoE;IACpE,iDAAoC,CAAA;IACpC,2DAA8C,CAAA;IAC9C,6CAAgC,CAAA;IAChC,4CAA+B,CAAA;IAC/B,sDAAyC,CAAA;IACz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,CAAC,CAAC;QAC3C,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9D,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;gBAChC,OAAO,SAAsB,CAAC;YAChC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,cAAc,EAAE,CACd,SAAoB,EACpB,QAA2B,EACV,EAAE;QACnB,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YACvB,MAAM,MAAM,GAAI,kBAA0B,EAAE,CAAC,SAAS,CAAC,CAAC;YACxD,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC;QAC1C,CAAC;QACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAGxC,CAAC;QACF,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,EAAE,CAClB,SAAoB,EACpB,QAA2B,EAClB,EAAE;QACX,OAAO,SAAS,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;CACF,CAAC","sourcesContent":["import type {\n ProductAndroid,\n PurchaseAndroid,\n ProductSubscriptionAndroid,\n} from './types/ExpoIapAndroid.types';\nimport type {\n ProductIOS,\n PurchaseIOS,\n ProductSubscriptionIOS,\n} from './types/ExpoIapIOS.types';\nimport {NATIVE_ERROR_CODES} from './ExpoIapModule';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ProductType = 'inapp' | 'subs';\n\nexport enum PurchaseState {\n Pending = 'pending',\n Purchased = 'purchased',\n Failed = 'failed',\n Restored = 'restored',\n Deferred = 'deferred',\n Unknown = 'unknown',\n}\n\n// =============================================================================\n// COMMON TYPES (Base types shared across all platforms)\n// =============================================================================\n\nexport type ProductCommon = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice: string;\n currency: string;\n price?: number;\n debugDescription?: string;\n platform?: string;\n};\n\nexport type PurchaseCommon = {\n id: string; // Transaction identifier - used by finishTransaction\n productId: string; // Product identifier - which product was purchased\n ids?: string[]; // Product identifiers for purchases that include multiple products\n transactionId?: string; // Legacy identifier\n transactionDate: number;\n purchaseToken?: string; // Unified token (iOS: JWS, Android: purchaseToken)\n platform?: string;\n quantity?: number;\n purchaseState?: PurchaseState;\n isAutoRenewing?: boolean;\n};\n\nexport type ProductSubscriptionCommon = ProductCommon & {\n type: 'subs';\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\n// Platform-agnostic unified product types (public API)\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIOS & IosPlatform);\n\nexport type ProductSubscription =\n | (ProductSubscriptionAndroid & AndroidPlatform)\n | (ProductSubscriptionIOS & IosPlatform);\n\n// Legacy naming retained for backward compatibility\nexport type SubscriptionProduct = ProductSubscription;\n\n// Re-export all platform-specific types to avoid deep imports\nexport * from './types/ExpoIapAndroid.types';\nexport * from './types/ExpoIapIOS.types';\n\n// Unified purchase type for both products and subscriptions\nexport type Purchase =\n | (PurchaseAndroid & AndroidPlatform)\n | (PurchaseIOS & IosPlatform);\n\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n};\n/**\n * Centralized error codes for expo-iap\n * These are mapped to platform-specific error codes and provide consistent error handling\n */\nexport enum ErrorCode {\n Unknown = 'E_UNKNOWN',\n UserCancelled = 'E_USER_CANCELLED',\n UserError = 'E_USER_ERROR',\n ItemUnavailable = 'E_ITEM_UNAVAILABLE',\n RemoteError = 'E_REMOTE_ERROR',\n NetworkError = 'E_NETWORK_ERROR',\n ServiceError = 'E_SERVICE_ERROR',\n ReceiptFailed = 'E_RECEIPT_FAILED',\n ReceiptFinished = 'E_RECEIPT_FINISHED',\n ReceiptFinishedFailed = 'E_RECEIPT_FINISHED_FAILED',\n NotPrepared = 'E_NOT_PREPARED',\n NotEnded = 'E_NOT_ENDED',\n AlreadyOwned = 'E_ALREADY_OWNED',\n DeveloperError = 'E_DEVELOPER_ERROR',\n BillingResponseJsonParseError = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n DeferredPayment = 'E_DEFERRED_PAYMENT',\n Interrupted = 'E_INTERRUPTED',\n IapNotAvailable = 'E_IAP_NOT_AVAILABLE',\n PurchaseError = 'E_PURCHASE_ERROR',\n SyncError = 'E_SYNC_ERROR',\n TransactionValidationFailed = 'E_TRANSACTION_VALIDATION_FAILED',\n ActivityUnavailable = 'E_ACTIVITY_UNAVAILABLE',\n AlreadyPrepared = 'E_ALREADY_PREPARED',\n Pending = 'E_PENDING',\n ConnectionClosed = 'E_CONNECTION_CLOSED',\n // Additional detailed errors (Android-focused, kept cross-platform)\n InitConnection = 'E_INIT_CONNECTION',\n ServiceDisconnected = 'E_SERVICE_DISCONNECTED',\n QueryProduct = 'E_QUERY_PRODUCT',\n SkuNotFound = 'E_SKU_NOT_FOUND',\n SkuOfferMismatch = 'E_SKU_OFFER_MISMATCH',\n ItemNotOwned = 'E_ITEM_NOT_OWNED',\n BillingUnavailable = 'E_BILLING_UNAVAILABLE',\n FeatureNotSupported = 'E_FEATURE_NOT_SUPPORTED',\n EmptySkuList = 'E_EMPTY_SKU_LIST',\n}\n\n// Fast lookup set for validating standardized error code strings\nconst OPENIAP_ERROR_CODE_SET: Set<string> = new Set(\n Object.values(ErrorCode) as string[],\n);\n\n/**\n * Platform-specific error code mappings\n * Maps ErrorCode enum values to platform-specific integer codes\n */\n// Shared OpenIAP string code mapping for both platforms\nconst COMMON_ERROR_CODE_MAP = {\n [ErrorCode.Unknown]: 'E_UNKNOWN',\n [ErrorCode.UserCancelled]: 'E_USER_CANCELLED',\n [ErrorCode.UserError]: 'E_USER_ERROR',\n [ErrorCode.ItemUnavailable]: 'E_ITEM_UNAVAILABLE',\n [ErrorCode.RemoteError]: 'E_REMOTE_ERROR',\n [ErrorCode.NetworkError]: 'E_NETWORK_ERROR',\n [ErrorCode.ServiceError]: 'E_SERVICE_ERROR',\n [ErrorCode.ReceiptFailed]: 'E_RECEIPT_FAILED',\n [ErrorCode.ReceiptFinished]: 'E_RECEIPT_FINISHED',\n [ErrorCode.ReceiptFinishedFailed]: 'E_RECEIPT_FINISHED_FAILED',\n [ErrorCode.NotPrepared]: 'E_NOT_PREPARED',\n [ErrorCode.NotEnded]: 'E_NOT_ENDED',\n [ErrorCode.AlreadyOwned]: 'E_ALREADY_OWNED',\n [ErrorCode.DeveloperError]: 'E_DEVELOPER_ERROR',\n [ErrorCode.BillingResponseJsonParseError]:\n 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n [ErrorCode.DeferredPayment]: 'E_DEFERRED_PAYMENT',\n [ErrorCode.Interrupted]: 'E_INTERRUPTED',\n [ErrorCode.IapNotAvailable]: 'E_IAP_NOT_AVAILABLE',\n [ErrorCode.PurchaseError]: 'E_PURCHASE_ERROR',\n [ErrorCode.SyncError]: 'E_SYNC_ERROR',\n [ErrorCode.TransactionValidationFailed]: 'E_TRANSACTION_VALIDATION_FAILED',\n [ErrorCode.ActivityUnavailable]: 'E_ACTIVITY_UNAVAILABLE',\n [ErrorCode.AlreadyPrepared]: 'E_ALREADY_PREPARED',\n [ErrorCode.Pending]: 'E_PENDING',\n [ErrorCode.ConnectionClosed]: 'E_CONNECTION_CLOSED',\n [ErrorCode.InitConnection]: 'E_INIT_CONNECTION',\n [ErrorCode.ServiceDisconnected]: 'E_SERVICE_DISCONNECTED',\n [ErrorCode.QueryProduct]: 'E_QUERY_PRODUCT',\n [ErrorCode.SkuNotFound]: 'E_SKU_NOT_FOUND',\n [ErrorCode.SkuOfferMismatch]: 'E_SKU_OFFER_MISMATCH',\n [ErrorCode.ItemNotOwned]: 'E_ITEM_NOT_OWNED',\n [ErrorCode.BillingUnavailable]: 'E_BILLING_UNAVAILABLE',\n [ErrorCode.FeatureNotSupported]: 'E_FEATURE_NOT_SUPPORTED',\n [ErrorCode.EmptySkuList]: 'E_EMPTY_SKU_LIST',\n} as const;\n\nexport const ErrorCodeMapping = {\n // iOS: standardized OpenIAP string codes\n ios: COMMON_ERROR_CODE_MAP,\n // Android: standardized OpenIAP string codes\n android: COMMON_ERROR_CODE_MAP,\n} as const;\n\nexport type PurchaseErrorProps = {\n message: string;\n responseCode?: number;\n debugMessage?: string;\n code?: ErrorCode;\n productId?: string;\n platform?: 'ios' | 'android';\n};\n\nexport class PurchaseError implements Error {\n public name: string;\n public message: string;\n public responseCode?: number;\n public debugMessage?: string;\n public code?: ErrorCode;\n public productId?: string;\n public platform?: 'ios' | 'android';\n\n // Backwards-compatible constructor: accepts either props object or legacy positional args\n constructor(messageOrProps: string | PurchaseErrorProps, ...rest: any[]) {\n this.name = '[expo-iap]: PurchaseError';\n\n if (typeof messageOrProps === 'string') {\n // Legacy signature: (name, message, responseCode?, debugMessage?, code?, productId?, platform?)\n // The first legacy argument was a name which we always override, so treat it as message here\n const message = messageOrProps;\n this.message = message;\n this.responseCode = rest[0];\n this.debugMessage = rest[1];\n this.code = rest[2];\n this.productId = rest[3];\n this.platform = rest[4];\n } else {\n const props = messageOrProps;\n this.message = props.message;\n this.responseCode = props.responseCode;\n this.debugMessage = props.debugMessage;\n this.code = props.code;\n this.productId = props.productId;\n this.platform = props.platform;\n }\n }\n\n /**\n * Creates a PurchaseError from platform-specific error data\n * @param errorData Raw error data from native modules\n * @param platform Platform where the error occurred\n * @returns Properly typed PurchaseError instance\n */\n static fromPlatformError(\n errorData: any,\n platform: 'ios' | 'android',\n ): PurchaseError {\n const errorCode = errorData.code\n ? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)\n : ErrorCode.Unknown;\n\n return new PurchaseError({\n message: errorData.message || 'Unknown error occurred',\n responseCode: errorData.responseCode,\n debugMessage: errorData.debugMessage,\n code: errorCode,\n productId: errorData.productId,\n platform,\n });\n }\n\n /**\n * Gets the platform-specific error code for this error\n * @returns Platform-specific error code\n */\n getPlatformCode(): string | number | undefined {\n if (!this.code || !this.platform) return undefined;\n return ErrorCodeUtils.toPlatformCode(this.code, this.platform);\n }\n}\n\n/**\n * Utility functions for error code mapping and validation\n */\nexport const ErrorCodeUtils = {\n /**\n * Gets the native error code for the current platform\n * @param errorCode ErrorCode enum value\n * @returns Platform-specific error code from native constants\n */\n getNativeErrorCode: (errorCode: ErrorCode): string => {\n return NATIVE_ERROR_CODES[errorCode] || errorCode;\n },\n\n /**\n * Maps a platform-specific error code back to the standardized ErrorCode enum\n * @param platformCode Platform-specific error code (string for Android, number for iOS)\n * @param platform Target platform\n * @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found\n */\n fromPlatformCode: (\n platformCode: string | number,\n platform: 'ios' | 'android',\n ): ErrorCode => {\n // If native sent standardized string code, accept it directly\n if (typeof platformCode === 'string' && platformCode.startsWith('E_')) {\n if (OPENIAP_ERROR_CODE_SET.has(platformCode)) {\n return platformCode as ErrorCode;\n }\n }\n // Prefer dynamic native mapping for iOS to avoid drift\n if (platform === 'ios') {\n for (const [, value] of Object.entries(NATIVE_ERROR_CODES || {})) {\n if (value === platformCode) {\n // Native maps friendly keys to standardized 'E_*' codes\n if (typeof value === 'string' && OPENIAP_ERROR_CODE_SET.has(value)) {\n return value as ErrorCode;\n }\n }\n }\n }\n\n const mapping = ErrorCodeMapping[platform];\n for (const [errorCode, mappedCode] of Object.entries(mapping)) {\n if (mappedCode === platformCode) {\n return errorCode as ErrorCode;\n }\n }\n\n return ErrorCode.Unknown;\n },\n\n /**\n * Maps an ErrorCode enum to platform-specific code\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns Platform-specific error code\n */\n toPlatformCode: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): string | number => {\n if (platform === 'ios') {\n const native = (NATIVE_ERROR_CODES as any)?.[errorCode];\n if (native !== undefined) return native;\n }\n const mapping = ErrorCodeMapping[platform] as Record<\n ErrorCode,\n string | number\n >;\n return mapping[errorCode] ?? 'E_UNKNOWN';\n },\n\n /**\n * Checks if an error code is valid for the specified platform\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns True if the error code is supported on the platform\n */\n isValidForPlatform: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): boolean => {\n return errorCode in ErrorCodeMapping[platform];\n },\n};\n\n// ============================================================================\n// Enhanced Unified Request Types\n// ============================================================================\n\n/**\n * Unified request props that work on both iOS and Android platforms\n * iOS will use 'sku', Android will use 'skus' (or convert sku to skus array)\n */\nexport interface UnifiedRequestPurchaseProps {\n // Universal properties - works on both platforms\n readonly sku?: string; // Single SKU (iOS native, Android fallback)\n readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)\n\n // iOS-specific properties (ignored on Android)\n readonly andDangerouslyFinishTransactionAutomatically?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n\n // Android-specific properties (ignored on iOS)\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n// ============================================================================\n// New Platform-Specific Request Types (v2.7.0+)\n// ============================================================================\n\n/**\n * iOS-specific purchase request parameters\n */\nexport interface RequestPurchaseIosProps {\n readonly sku: string;\n readonly andDangerouslyFinishTransactionAutomatically?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n}\n\n/**\n * Android-specific purchase request parameters\n */\nexport interface RequestPurchaseAndroidProps {\n readonly skus: string[];\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n/**\n * Android-specific subscription request parameters\n */\nexport interface RequestSubscriptionAndroidProps\n extends RequestPurchaseAndroidProps {\n readonly purchaseTokenAndroid?: string;\n readonly replacementModeAndroid?: number;\n readonly subscriptionOffers: {\n sku: string;\n offerToken: string;\n }[];\n}\n\n/**\n * Modern platform-specific request structure (v2.7.0+)\n * Allows clear separation of iOS and Android parameters\n */\nexport interface RequestPurchasePropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestPurchaseAndroidProps;\n}\n\n/**\n * Modern platform-specific subscription request structure (v2.7.0+)\n */\nexport interface RequestSubscriptionPropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestSubscriptionAndroidProps;\n}\n\n/**\n * Modern request purchase parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestPurchaseProps = RequestPurchasePropsByPlatforms;\n\n/**\n * Modern request subscription parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;\n"]}
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Product, Purchase, PurchaseError, PurchaseResult, RequestSubscriptionProps, RequestPurchaseProps, SubscriptionProduct } from './ExpoIap.types';
1
+ import { Product, Purchase, PurchaseError, PurchaseResult, RequestSubscriptionProps, RequestPurchaseProps, ProductSubscription } from './ExpoIap.types';
2
2
  export * from './ExpoIap.types';
3
3
  export * from './modules/android';
4
4
  export * from './modules/ios';
@@ -72,7 +72,7 @@ export declare function endConnection(): Promise<boolean>;
72
72
  export declare const fetchProducts: ({ skus, type, }: {
73
73
  skus: string[];
74
74
  type?: "inapp" | "subs";
75
- }) => Promise<Product[] | SubscriptionProduct[]>;
75
+ }) => Promise<Product[] | ProductSubscription[]>;
76
76
  export declare const getAvailablePurchases: ({ alsoPublishToEventListenerIOS, onlyIncludeActiveItemsIOS, }?: {
77
77
  alsoPublishToEventListenerIOS?: boolean;
78
78
  onlyIncludeActiveItemsIOS?: boolean;
package/build/index.js CHANGED
@@ -106,7 +106,7 @@ export const fetchProducts = async ({ skus, type = 'inapp', }) => {
106
106
  if (!skus?.length) {
107
107
  throw new PurchaseError({
108
108
  message: 'No SKUs provided',
109
- code: ErrorCode.E_EMPTY_SKU_LIST,
109
+ code: ErrorCode.EmptySkuList,
110
110
  });
111
111
  }
112
112
  if (Platform.OS === 'ios') {
@@ -297,7 +297,7 @@ export const finishTransaction = ({ purchase, isConsumable = false, }) => {
297
297
  if (!token) {
298
298
  return Promise.reject(new PurchaseError({
299
299
  message: 'Purchase token is required to finish transaction',
300
- code: 'E_DEVELOPER_ERROR',
300
+ code: ErrorCode.DeveloperError,
301
301
  productId: androidPurchase.productId,
302
302
  platform: 'android',
303
303
  }));