expo-iap 2.4.5 → 2.5.1

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/.eslintignore ADDED
@@ -0,0 +1,5 @@
1
+ docs/
2
+ example/
3
+ build/
4
+ node_modules/
5
+ *.d.ts
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 hyochan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,67 +1,35 @@
1
- <img src="https://github.com/user-attachments/assets/f51a4b1b-b257-47bf-afe7-5ef8692f0594" />
1
+ # Expo IAP
2
2
 
3
- [![Version](http://img.shields.io/npm/v/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![Download](http://img.shields.io/npm/dm/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap?ref=badge_shield&issueType=license)
4
-
5
- In App Purchase module in Expo
6
-
7
- # Notice
3
+ | In app purchase module in [Expo](https://docs.expo.dev/guides/in-app-purchases)
8
4
 
9
- The `expo-iap` module has been migrated from [react-native-iap](https://github.com/dooboolab/react-native-iap). Moving forward, the `react-native-iap` repository will gradually be deprecated, and `expo-iap` will become the actively maintained module. Please take note of this transition. For more details, refer to the [Future Roadmap and Discussion in react-native-iap](https://github.com/dooboolab-community/react-native-iap/discussions/2754). Additionally, you can check the [Current Project Status comment](https://github.com/dooboolab-community/react-native-iap/discussions/2754#discussioncomment-10510249) to stay updated on the project's progress.
5
+ <div>
6
+ <img src="https://github.com/user-attachments/assets/3257a1e0-800b-441b-8522-94c35ce751d2" width="400" />
7
+ </div>
10
8
 
11
- # API documentation
9
+ [![Version](http://img.shields.io/npm/v/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![Download](http://img.shields.io/npm/dm/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap?ref=badge_shield&issueType=license)
12
10
 
13
- - [Documentation](./docs/IAP.md)
14
- - [Error Code Management](./docs/ERROR_CODES.md)
11
+ ## 📚 Documentation
15
12
 
16
- ## Error Handling
13
+ **[📖 Visit our comprehensive documentation site →](https://expo-iap.hyo.dev)**
17
14
 
18
- expo-iap now provides a centralized error code system that works consistently across iOS and Android platforms. This system maps platform-specific error codes to standardized TypeScript enums.
15
+ - [🚀 Quick Start Guide](https://expo-iap.hyo.dev/docs/intro)
16
+ - [💽 Installation](https://expo-iap.hyo.dev/docs/installation)
17
+ - [🍎 iOS Setup](https://expo-iap.hyo.dev/docs/getting-started/setup-ios)
18
+ - [🤖 Android Setup](https://expo-iap.hyo.dev/docs/getting-started/setup-android)
19
+ - [🎣 useIAP Hook API](https://expo-iap.hyo.dev/docs/api/use-iap)
20
+ - [⚠️ Error Codes](https://expo-iap.hyo.dev/docs/api/error-codes)
19
21
 
20
- ### Error Codes
22
+ # Notice
21
23
 
22
- ```typescript
23
- import {ErrorCode} from 'expo-iap';
24
+ The `expo-iap` module has been migrated from [react-native-iap](https://github.com/dooboolab/react-native-iap). Moving forward, the `react-native-iap` repository will gradually be deprecated, and `expo-iap` will become the actively maintained module. Please take note of this transition. For more details, refer to the [Future Roadmap and Discussion in react-native-iap](https://github.com/dooboolab-community/react-native-iap/discussions/2754). Additionally, you can check the [Current Project Status comment](https://github.com/dooboolab-community/react-native-iap/discussions/2754#discussioncomment-10510249) to stay updated on the project's progress.
24
25
 
25
- // Standardized error codes
26
- ErrorCode.E_USER_CANCELLED; // User cancelled the purchase
27
- ErrorCode.E_NETWORK_ERROR; // Network connectivity issue
28
- ErrorCode.E_ITEM_UNAVAILABLE; // Product not available
29
- ErrorCode.E_SERVICE_ERROR; // Store service error
30
- // ... and more
31
- ```
26
+ ## Installation
32
27
 
33
- ### Error Utilities
34
-
35
- ```typescript
36
- import {
37
- mapPlatformError,
38
- isUserCancelledError,
39
- getUserFriendlyErrorMessage,
40
- } from 'expo-iap';
41
-
42
- // Handle purchase errors
43
- try {
44
- await requestPurchase({sku: 'product_id'});
45
- } catch (error) {
46
- if (isUserCancelledError(error)) {
47
- // User cancelled - don't show error
48
- return;
49
- }
50
-
51
- // Show user-friendly message
52
- const message = getUserFriendlyErrorMessage(error);
53
- Alert.alert('Purchase Failed', message);
54
- }
28
+ ```bash
29
+ npx expo install expo-iap
55
30
  ```
56
31
 
57
- ### Platform-Specific Error Mapping
58
-
59
- The system automatically maps platform codes:
60
-
61
- - **iOS**: Integer codes (0, 1, 2, etc.) → ErrorCode enum
62
- - **Android**: String codes ("E_USER_CANCELLED", etc.) → ErrorCode enum
63
-
64
- This ensures consistent error handling regardless of platform.
32
+ For detailed usage examples and error handling, see the [documentation](https://expo-iap.hyo.dev).
65
33
 
66
34
  > Sharing your thoughts—any feedback would be greatly appreciated!
67
35
 
@@ -28,27 +28,6 @@ class ExpoIapModule :
28
28
  PurchasesUpdatedListener {
29
29
  companion object {
30
30
  const val TAG = "ExpoIapModule"
31
-
32
- // Error codes for IAP operations
33
- const val E_NOT_PREPARED = "E_NOT_PREPARED"
34
- const val E_INIT_CONNECTION = "E_INIT_CONNECTION"
35
- const val E_QUERY_PRODUCT = "E_QUERY_PRODUCT"
36
- const val E_UNKNOWN = "E_UNKNOWN"
37
- const val E_SKU_OFFER_MISMATCH = "E_SKU_OFFER_MISMATCH"
38
- const val E_SKU_NOT_FOUND = "E_SKU_NOT_FOUND"
39
- const val E_USER_CANCELLED = "E_USER_CANCELLED"
40
- const val E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR"
41
- const val E_ITEM_UNAVAILABLE = "E_ITEM_UNAVAILABLE"
42
- const val E_SERVICE_ERROR = "E_SERVICE_ERROR"
43
- const val E_PURCHASE_ERROR = "E_PURCHASE_ERROR"
44
-
45
- const val EMPTY_SKU_LIST = "EMPTY_SKU_LIST"
46
- private const val PROMISE_BUY_ITEM = "PROMISE_BUY_ITEM"
47
- }
48
-
49
- object IapEvent {
50
- const val PURCHASE_UPDATED = "purchase-updated"
51
- const val PURCHASE_ERROR = "purchase-error"
52
31
  }
53
32
 
54
33
  private var billingClientCache: BillingClient? = null
@@ -79,7 +58,7 @@ class ExpoIapModule :
79
58
  } catch (e: Exception) {
80
59
  Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
81
60
  }
82
- PromiseUtils.rejectPromisesForKey(PROMISE_BUY_ITEM, errorData.code, errorData.message, null)
61
+ PromiseUtils.rejectPromisesForKey(IapConstants.PROMISE_BUY_ITEM, errorData.code, errorData.message, null)
83
62
  return
84
63
  }
85
64
 
@@ -114,7 +93,7 @@ class ExpoIapModule :
114
93
  Log.e(TAG, "Failed to send PURCHASE_UPDATED event: ${e.message}")
115
94
  }
116
95
  }
117
- PromiseUtils.resolvePromisesForKey(PROMISE_BUY_ITEM, promiseItems)
96
+ PromiseUtils.resolvePromisesForKey(IapConstants.PROMISE_BUY_ITEM, promiseItems)
118
97
  } else {
119
98
  val result =
120
99
  mutableMapOf<String, Any?>(
@@ -129,7 +108,7 @@ class ExpoIapModule :
129
108
  } catch (e: Exception) {
130
109
  Log.e(TAG, "Failed to send PURCHASE_UPDATED event: ${e.message}")
131
110
  }
132
- PromiseUtils.resolvePromisesForKey(PROMISE_BUY_ITEM, result)
111
+ PromiseUtils.resolvePromisesForKey(IapConstants.PROMISE_BUY_ITEM, result)
133
112
  }
134
113
  }
135
114
 
@@ -138,19 +117,7 @@ class ExpoIapModule :
138
117
  Name("ExpoIap")
139
118
 
140
119
  Constants(
141
- "ERROR_CODES" to mapOf(
142
- "E_UNKNOWN" to E_UNKNOWN,
143
- "E_USER_CANCELLED" to E_USER_CANCELLED,
144
- "E_NOT_PREPARED" to E_NOT_PREPARED,
145
- "E_SERVICE_ERROR" to E_SERVICE_ERROR,
146
- "E_ITEM_UNAVAILABLE" to E_ITEM_UNAVAILABLE,
147
- "E_PURCHASE_ERROR" to E_PURCHASE_ERROR,
148
- "E_DEVELOPER_ERROR" to E_DEVELOPER_ERROR,
149
- "E_SKU_NOT_FOUND" to E_SKU_NOT_FOUND,
150
- "E_SKU_OFFER_MISMATCH" to E_SKU_OFFER_MISMATCH,
151
- "E_INIT_CONNECTION" to E_INIT_CONNECTION,
152
- "E_QUERY_PRODUCT" to E_QUERY_PRODUCT,
153
- )
120
+ "ERROR_CODES" to IapErrorCode.toMap()
154
121
  )
155
122
 
156
123
  Events(IapEvent.PURCHASE_UPDATED, IapEvent.PURCHASE_ERROR)
@@ -178,7 +145,7 @@ class ExpoIapModule :
178
145
  }
179
146
 
180
147
  if (skuList.isEmpty()) {
181
- promise.reject(EMPTY_SKU_LIST, "The SKU list is empty.", null)
148
+ promise.reject(IapConstants.EMPTY_SKU_LIST, "The SKU list is empty.", null)
182
149
  return@ensureConnection
183
150
  }
184
151
 
@@ -191,7 +158,7 @@ class ExpoIapModule :
191
158
  billingClient.queryProductDetailsAsync(params) { billingResult, productDetailsList ->
192
159
  if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
193
160
  promise.reject(
194
- E_QUERY_PRODUCT,
161
+ IapErrorCode.E_QUERY_PRODUCT,
195
162
  "Error querying product details: ${billingResult.debugMessage}",
196
163
  null,
197
164
  )
@@ -355,12 +322,12 @@ class ExpoIapModule :
355
322
  val isOfferPersonalized = params["isOfferPersonalized"] as? Boolean ?: false
356
323
 
357
324
  if (currentActivity == null) {
358
- promise.reject(E_UNKNOWN, "getCurrentActivity returned null", null)
325
+ promise.reject(IapErrorCode.E_UNKNOWN, "getCurrentActivity returned null", null)
359
326
  return@AsyncFunction
360
327
  }
361
328
 
362
329
  ensureConnection(promise) { billingClient ->
363
- PromiseUtils.addPromiseForKey(PROMISE_BUY_ITEM, promise)
330
+ PromiseUtils.addPromiseForKey(IapConstants.PROMISE_BUY_ITEM, promise)
364
331
 
365
332
  if (type == BillingClient.ProductType.SUBS && skuArr.size != offerTokenArr.size) {
366
333
  val debugMessage = "The number of skus (${skuArr.size}) must match: the number of offerTokens (${offerTokenArr.size}) for Subscriptions"
@@ -369,14 +336,14 @@ class ExpoIapModule :
369
336
  IapEvent.PURCHASE_ERROR,
370
337
  mapOf(
371
338
  "debugMessage" to debugMessage,
372
- "code" to E_SKU_OFFER_MISMATCH,
339
+ "code" to IapErrorCode.E_SKU_OFFER_MISMATCH,
373
340
  "message" to debugMessage,
374
341
  )
375
342
  )
376
343
  } catch (e: Exception) {
377
344
  Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
378
345
  }
379
- promise.reject(E_SKU_OFFER_MISMATCH, debugMessage, null)
346
+ promise.reject(IapErrorCode.E_SKU_OFFER_MISMATCH, debugMessage, null)
380
347
  return@ensureConnection
381
348
  }
382
349
 
@@ -391,7 +358,7 @@ class ExpoIapModule :
391
358
  IapEvent.PURCHASE_ERROR,
392
359
  mapOf(
393
360
  "debugMessage" to debugMessage,
394
- "code" to E_SKU_NOT_FOUND,
361
+ "code" to IapErrorCode.E_SKU_NOT_FOUND,
395
362
  "message" to debugMessage,
396
363
  "productId" to sku,
397
364
  ),
@@ -399,7 +366,7 @@ class ExpoIapModule :
399
366
  } catch (e: Exception) {
400
367
  Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
401
368
  }
402
- promise.reject(E_SKU_NOT_FOUND, debugMessage, null)
369
+ promise.reject(IapErrorCode.E_SKU_NOT_FOUND, debugMessage, null)
403
370
  return@ensureConnection
404
371
  }
405
372
 
@@ -560,7 +527,7 @@ class ExpoIapModule :
560
527
  ) {
561
528
  Log.i(TAG, "Google Play Services are not available on this device")
562
529
  promise.reject(
563
- E_NOT_PREPARED,
530
+ IapErrorCode.E_NOT_PREPARED,
564
531
  "Google Play Services are not available on this device",
565
532
  null,
566
533
  )
@@ -579,7 +546,7 @@ class ExpoIapModule :
579
546
  override fun onBillingSetupFinished(billingResult: BillingResult) {
580
547
  if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
581
548
  promise.reject(
582
- E_INIT_CONNECTION,
549
+ IapErrorCode.E_INIT_CONNECTION,
583
550
  "Billing setup finished with error: ${billingResult.debugMessage}",
584
551
  null,
585
552
  )
@@ -0,0 +1,55 @@
1
+ package expo.modules.iap
2
+
3
+ /**
4
+ * Error codes for IAP operations - centralized error code management
5
+ * Single source of truth for all error codes used across the module
6
+ */
7
+ object IapErrorCode {
8
+ // Constants for code usage - Android specific error codes
9
+ const val E_NOT_PREPARED = "E_NOT_PREPARED"
10
+ const val E_INIT_CONNECTION = "E_INIT_CONNECTION"
11
+ const val E_QUERY_PRODUCT = "E_QUERY_PRODUCT"
12
+ const val E_UNKNOWN = "E_UNKNOWN"
13
+ const val E_SKU_OFFER_MISMATCH = "E_SKU_OFFER_MISMATCH"
14
+ const val E_SKU_NOT_FOUND = "E_SKU_NOT_FOUND"
15
+ const val E_USER_CANCELLED = "E_USER_CANCELLED"
16
+ const val E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR"
17
+ const val E_ITEM_UNAVAILABLE = "E_ITEM_UNAVAILABLE"
18
+ const val E_SERVICE_ERROR = "E_SERVICE_ERROR"
19
+ const val E_PURCHASE_ERROR = "E_PURCHASE_ERROR"
20
+
21
+ // Cached map for Constants export - initialized once at class loading time
22
+ // Using constants as keys to avoid duplication and ensure type safety
23
+ private val _cachedMap: Map<String, String> = mapOf(
24
+ E_NOT_PREPARED to E_NOT_PREPARED,
25
+ E_INIT_CONNECTION to E_INIT_CONNECTION,
26
+ E_QUERY_PRODUCT to E_QUERY_PRODUCT,
27
+ E_UNKNOWN to E_UNKNOWN,
28
+ E_SKU_OFFER_MISMATCH to E_SKU_OFFER_MISMATCH,
29
+ E_SKU_NOT_FOUND to E_SKU_NOT_FOUND,
30
+ E_USER_CANCELLED to E_USER_CANCELLED,
31
+ E_DEVELOPER_ERROR to E_DEVELOPER_ERROR,
32
+ E_ITEM_UNAVAILABLE to E_ITEM_UNAVAILABLE,
33
+ E_SERVICE_ERROR to E_SERVICE_ERROR,
34
+ E_PURCHASE_ERROR to E_PURCHASE_ERROR
35
+ )
36
+
37
+ // Return cached map reference - no new allocations on repeated calls
38
+ fun toMap(): Map<String, String> = _cachedMap
39
+ }
40
+
41
+ /**
42
+ * IAP Event constants
43
+ */
44
+ object IapEvent {
45
+ const val PURCHASE_UPDATED = "purchase-updated"
46
+ const val PURCHASE_ERROR = "purchase-error"
47
+ }
48
+
49
+ /**
50
+ * Other IAP-related constants
51
+ */
52
+ object IapConstants {
53
+ const val EMPTY_SKU_LIST = "EMPTY_SKU_LIST"
54
+ const val PROMISE_BUY_ITEM = "PROMISE_BUY_ITEM"
55
+ }
@@ -3,9 +3,7 @@ import { ProductIos, ProductPurchaseIos, RequestPurchaseIosProps, RequestSubscri
3
3
  export type ChangeEventPayload = {
4
4
  value: string;
5
5
  };
6
- /**
7
- * Base product type with common properties shared between iOS and Android
8
- */
6
+ export type ProductType = 'inapp' | 'subs';
9
7
  export type ProductBase = {
10
8
  id: string;
11
9
  title: string;
@@ -16,28 +14,29 @@ export type ProductBase = {
16
14
  currency: string;
17
15
  price?: number;
18
16
  };
19
- export type IosPlatform = {
20
- platform: 'ios';
21
- };
22
- export type AndroidPlatform = {
23
- platform: 'android';
24
- };
25
- export type ProductType = 'inapp' | 'subs';
26
17
  export type PurchaseBase = {
27
18
  id: string;
28
19
  transactionId?: string;
29
20
  transactionDate: number;
30
21
  transactionReceipt: string;
31
22
  };
23
+ export type IosPlatform = {
24
+ platform: 'ios';
25
+ };
26
+ export type AndroidPlatform = {
27
+ platform: 'android';
28
+ };
32
29
  export type Product = (ProductAndroid & AndroidPlatform) | (ProductIos & IosPlatform);
30
+ export type SubscriptionProduct = (SubscriptionProductAndroid & AndroidPlatform) | (SubscriptionProductIos & IosPlatform);
31
+ export type RequestPurchaseProps = RequestPurchaseIosProps | RequestPurchaseAndroidProps;
32
+ export type RequestSubscriptionProps = RequestSubscriptionAndroidProps | RequestSubscriptionIosProps;
33
+ export type { ProductPurchaseAndroid } from './types/ExpoIapAndroid.types';
34
+ export type { ProductPurchaseIos } from './types/ExpoIapIos.types';
33
35
  export type ProductPurchase = (ProductPurchaseAndroid & AndroidPlatform) | (ProductPurchaseIos & IosPlatform);
34
36
  export type SubscriptionPurchase = (ProductPurchaseAndroid & AndroidPlatform & {
35
37
  autoRenewingAndroid: boolean;
36
38
  }) | (ProductPurchaseIos & IosPlatform);
37
39
  export type Purchase = ProductPurchase | SubscriptionPurchase;
38
- export type RequestPurchaseProps = RequestPurchaseIosProps | RequestPurchaseAndroidProps;
39
- export type SubscriptionProduct = (SubscriptionProductAndroid & AndroidPlatform) | (SubscriptionProductIos & IosPlatform);
40
- export type RequestSubscriptionProps = RequestSubscriptionAndroidProps | RequestSubscriptionIosProps;
41
40
  export type PurchaseResult = {
42
41
  responseCode?: number;
43
42
  debugMessage?: string;
@@ -187,4 +186,30 @@ export declare const ErrorCodeUtils: {
187
186
  */
188
187
  isValidForPlatform: (errorCode: ErrorCode, platform: "ios" | "android") => boolean;
189
188
  };
189
+ /**
190
+ * Unified request props that work on both iOS and Android platforms
191
+ * iOS will use 'sku', Android will use 'skus' (or convert sku to skus array)
192
+ */
193
+ export interface UnifiedRequestPurchaseProps {
194
+ readonly sku?: string;
195
+ readonly skus?: string[];
196
+ readonly andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;
197
+ readonly appAccountToken?: string;
198
+ readonly quantity?: number;
199
+ readonly withOffer?: import('./types/ExpoIapIos.types').PaymentDiscount;
200
+ readonly obfuscatedAccountIdAndroid?: string;
201
+ readonly obfuscatedProfileIdAndroid?: string;
202
+ readonly isOfferPersonalized?: boolean;
203
+ }
204
+ /**
205
+ * Unified subscription request props
206
+ */
207
+ export interface UnifiedRequestSubscriptionProps extends UnifiedRequestPurchaseProps {
208
+ readonly purchaseTokenAndroid?: string;
209
+ readonly replacementModeAndroid?: number;
210
+ readonly subscriptionOffers?: {
211
+ sku: string;
212
+ offerToken: string;
213
+ }[];
214
+ }
190
215
  //# sourceMappingURL=ExpoIap.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIap.types.d.ts","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,2BAA2B,EAC3B,+BAA+B,EAC/B,0BAA0B,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAA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,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,+BACf,SAAQ,2BAA2B;IAEnC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;QAC5B,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;KACpB,EAAE,CAAC;CACL"}
@@ -181,4 +181,9 @@ export const ErrorCodeUtils = {
181
181
  return errorCode in ErrorCodeMapping[platform];
182
182
  },
183
183
  };
184
+ // ============================================================================
185
+ // ============================================================================
186
+ // Type Guards and Utility Functions
187
+ // ============================================================================
188
+ // Note: Type guard functions are exported from index.ts to avoid conflicts
184
189
  //# sourceMappingURL=ExpoIap.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAsEnD;;;GAGG;AACH,MAAM,CAAN,IAAY,SAyBX;AAzBD,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,oEAAuD,CAAA;IACvD,8CAAiC,CAAA;IACjC,wCAA2B,CAAA;IAC3B,gDAAmC,CAAA;IACnC,oDAAuC,CAAA;IACvC,wFAA2E,CAAA;IAC3E,sDAAyC,CAAA;IACzC,4CAA+B,CAAA;IAC/B,wDAA2C,CAAA;IAC3C,kDAAqC,CAAA;IACrC,0CAA6B,CAAA;IAC7B,gFAAmE,CAAA;IACnE,8DAAiD,CAAA;IACjD,sDAAyC,CAAA;IACzC,oCAAuB,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ProductAndroid,\n ProductPurchaseAndroid,\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n SubscriptionProductAndroid,\n} from './types/ExpoIapAndroid.types';\nimport {\n ProductIos,\n ProductPurchaseIos,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n SubscriptionProductIos,\n} from './types/ExpoIapIos.types';\nimport {NATIVE_ERROR_CODES} from './ExpoIapModule';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\n/**\n * Base product type with common properties shared between iOS and Android\n */\nexport type ProductBase = {\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};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\nexport type ProductType = 'inapp' | 'subs';\n\n// Common base purchase type\nexport type PurchaseBase = {\n id: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n};\n\n// Union type for platform-specific product types with proper discriminators\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIos & IosPlatform);\n\n// Union type for platform-specific purchase types with proper discriminators\nexport type ProductPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform)\n | (ProductPurchaseIos & IosPlatform);\n\n// Union type for platform-specific subscription purchase types with proper discriminators\nexport type SubscriptionPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform & {autoRenewingAndroid: boolean})\n | (ProductPurchaseIos & IosPlatform);\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\nexport type RequestPurchaseProps =\n | RequestPurchaseIosProps\n | RequestPurchaseAndroidProps;\n\nexport type SubscriptionProduct =\n | (SubscriptionProductAndroid & AndroidPlatform)\n | (SubscriptionProductIos & IosPlatform);\n\nexport type RequestSubscriptionProps =\n | RequestSubscriptionAndroidProps\n | RequestSubscriptionIosProps;\n\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseTokenAndroid?: string;\n};\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_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}\n\n/**\n * Platform-specific error code mappings\n * Maps ErrorCode enum values to platform-specific integer codes\n */\nexport const ErrorCodeMapping = {\n ios: {\n [ErrorCode.E_UNKNOWN]: 0,\n [ErrorCode.E_SERVICE_ERROR]: 1,\n [ErrorCode.E_USER_CANCELLED]: 2,\n [ErrorCode.E_USER_ERROR]: 3,\n [ErrorCode.E_ITEM_UNAVAILABLE]: 4,\n [ErrorCode.E_REMOTE_ERROR]: 5,\n [ErrorCode.E_NETWORK_ERROR]: 6,\n [ErrorCode.E_RECEIPT_FAILED]: 7,\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 8,\n [ErrorCode.E_DEVELOPER_ERROR]: 9,\n [ErrorCode.E_PURCHASE_ERROR]: 10,\n [ErrorCode.E_SYNC_ERROR]: 11,\n [ErrorCode.E_DEFERRED_PAYMENT]: 12,\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 13,\n [ErrorCode.E_NOT_PREPARED]: 14,\n [ErrorCode.E_NOT_ENDED]: 15,\n [ErrorCode.E_ALREADY_OWNED]: 16,\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 17,\n [ErrorCode.E_INTERRUPTED]: 18,\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 19,\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 20,\n [ErrorCode.E_ALREADY_PREPARED]: 21,\n [ErrorCode.E_PENDING]: 22,\n [ErrorCode.E_CONNECTION_CLOSED]: 23,\n },\n android: {\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_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 },\n} as const;\n\nexport class PurchaseError implements Error {\n constructor(\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 this.name = '[expo-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n this.platform = platform;\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 '[expo-iap]: PurchaseError',\n errorData.message || 'Unknown error occurred',\n errorData.responseCode,\n errorData.debugMessage,\n errorCode,\n 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 const mapping = ErrorCodeMapping[platform];\n\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 return (\n ErrorCodeMapping[platform][errorCode] ??\n (platform === 'ios' ? 0 : 'E_UNKNOWN')\n );\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"]}
1
+ {"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.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AAC,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,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,cAAc,EAAE,CACd,SAAoB,EACpB,QAA2B,EACV,EAAE;QACnB,OAAO,CACL,gBAAgB,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC;YACrC,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CACvC,CAAC;IACJ,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;AAyCF,+EAA+E;AAC/E,+EAA+E;AAC/E,oCAAoC;AACpC,+EAA+E;AAE/E,2EAA2E","sourcesContent":["import {\n ProductAndroid,\n ProductPurchaseAndroid,\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n SubscriptionProductAndroid,\n} from './types/ExpoIapAndroid.types';\nimport {\n ProductIos,\n ProductPurchaseIos,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n SubscriptionProductIos,\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 type ProductBase = {\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};\n\nexport type PurchaseBase = {\n id: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\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 | (SubscriptionProductAndroid & AndroidPlatform)\n | (SubscriptionProductIos & IosPlatform);\n\n// Internal platform-specific types (used for native interop only)\nexport type RequestPurchaseProps =\n | RequestPurchaseIosProps\n | RequestPurchaseAndroidProps;\n\nexport type RequestSubscriptionProps =\n | RequestSubscriptionAndroidProps\n | RequestSubscriptionIosProps;\n\n// ============================================================================\n// Legacy Types (For backward compatibility with useIap hook)\n// ============================================================================\n\n// Re-export platform-specific purchase types for legacy compatibility\nexport type {ProductPurchaseAndroid} from './types/ExpoIapAndroid.types';\nexport type {ProductPurchaseIos} from './types/ExpoIapIos.types';\n\n// Union type for platform-specific purchase types (legacy support)\nexport type ProductPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform)\n | (ProductPurchaseIos & IosPlatform);\n\n// Union type for platform-specific subscription purchase types (legacy support)\nexport type SubscriptionPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform & {autoRenewingAndroid: boolean})\n | (ProductPurchaseIos & IosPlatform);\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\n// Legacy result type\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseTokenAndroid?: 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_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}\n\n/**\n * Platform-specific error code mappings\n * Maps ErrorCode enum values to platform-specific integer codes\n */\nexport const ErrorCodeMapping = {\n ios: {\n [ErrorCode.E_UNKNOWN]: 0,\n [ErrorCode.E_SERVICE_ERROR]: 1,\n [ErrorCode.E_USER_CANCELLED]: 2,\n [ErrorCode.E_USER_ERROR]: 3,\n [ErrorCode.E_ITEM_UNAVAILABLE]: 4,\n [ErrorCode.E_REMOTE_ERROR]: 5,\n [ErrorCode.E_NETWORK_ERROR]: 6,\n [ErrorCode.E_RECEIPT_FAILED]: 7,\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 8,\n [ErrorCode.E_DEVELOPER_ERROR]: 9,\n [ErrorCode.E_PURCHASE_ERROR]: 10,\n [ErrorCode.E_SYNC_ERROR]: 11,\n [ErrorCode.E_DEFERRED_PAYMENT]: 12,\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 13,\n [ErrorCode.E_NOT_PREPARED]: 14,\n [ErrorCode.E_NOT_ENDED]: 15,\n [ErrorCode.E_ALREADY_OWNED]: 16,\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 17,\n [ErrorCode.E_INTERRUPTED]: 18,\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 19,\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 20,\n [ErrorCode.E_ALREADY_PREPARED]: 21,\n [ErrorCode.E_PENDING]: 22,\n [ErrorCode.E_CONNECTION_CLOSED]: 23,\n },\n android: {\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_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 },\n} as const;\n\nexport class PurchaseError implements Error {\n constructor(\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 this.name = '[expo-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n this.platform = platform;\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 '[expo-iap]: PurchaseError',\n errorData.message || 'Unknown error occurred',\n errorData.responseCode,\n errorData.debugMessage,\n errorCode,\n 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 const mapping = ErrorCodeMapping[platform];\n\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 return (\n ErrorCodeMapping[platform][errorCode] ??\n (platform === 'ios' ? 0 : 'E_UNKNOWN')\n );\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 andDangerouslyFinishTransactionAutomaticallyIOS?: 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 * Unified subscription request props\n */\nexport interface UnifiedRequestSubscriptionProps\n extends UnifiedRequestPurchaseProps {\n // Android subscription-specific properties\n readonly purchaseTokenAndroid?: string;\n readonly replacementModeAndroid?: number;\n readonly subscriptionOffers?: {\n sku: string;\n offerToken: string;\n }[];\n}\n\n// ============================================================================\n// ============================================================================\n// Type Guards and Utility Functions\n// ============================================================================\n\n// Note: Type guard functions are exported from index.ts to avoid conflicts\n"]}
package/build/useIap.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { requestPurchase as requestPurchaseInternal } from './';
2
1
  import { Product, ProductPurchase, Purchase, PurchaseError, PurchaseResult, SubscriptionProduct, SubscriptionPurchase } from './ExpoIap.types';
3
2
  type UseIap = {
4
3
  connected: boolean;
@@ -14,12 +13,15 @@ type UseIap = {
14
13
  finishTransaction: ({ purchase, isConsumable, }: {
15
14
  purchase: Purchase;
16
15
  isConsumable?: boolean;
17
- }) => Promise<string | boolean | PurchaseResult | void>;
16
+ }) => Promise<PurchaseResult | boolean>;
18
17
  getAvailablePurchases: (skus: string[]) => Promise<void>;
19
18
  getPurchaseHistories: (skus: string[]) => Promise<void>;
20
19
  getProducts: (skus: string[]) => Promise<void>;
21
20
  getSubscriptions: (skus: string[]) => Promise<void>;
22
- requestPurchase: typeof requestPurchaseInternal;
21
+ requestPurchase: (params: {
22
+ request: any;
23
+ type?: 'inapp' | 'subs';
24
+ }) => Promise<any>;
23
25
  validateReceipt: (sku: string, androidOptions?: {
24
26
  packageName: string;
25
27
  productToken: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useIap.d.ts","sourceRoot":"","sources":["../src/useIap.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,eAAe,IAAI,uBAAuB,EAI3C,MAAM,IAAI,CAAC;AAEZ,OAAO,EACL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,iB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AE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,eAAe,EAAE,CAAC,MAAM,EAAE;QACxB,OAAO,EAAE,GAAG,CAAC;QACb,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KACzB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACnB,eAAe,EAAE,CACf,GAAG,EAAE,MAAM,EACX,cAAc,CAAC,EAAE;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,KACE,OAAO,CAAC,GAAG,CAAC,CAAC;IAClB,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,iBAAiB,CAAC,EAAE,CAClB,QAAQ,EAAE,eAAe,GAAG,oBAAoB,KAC7C,IAAI,CAAC;IACV,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACjD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CA0TtD"}
package/build/useIap.js CHANGED
@@ -1,4 +1,6 @@
1
- import { endConnection, initConnection, purchaseErrorListener, purchaseUpdatedListener, getProducts, getAvailablePurchases, getPurchaseHistory, finishTransaction as finishTransactionInternal, getSubscriptions, requestPurchase as requestPurchaseInternal, sync, validateReceiptIos, validateReceiptAndroid, } from './';
1
+ import { endConnection, initConnection, purchaseErrorListener, purchaseUpdatedListener, getProducts, getAvailablePurchases, getPurchaseHistory, finishTransaction as finishTransactionInternal, getSubscriptions, requestPurchase as requestPurchaseInternal, } from './';
2
+ import { sync, validateReceiptIos } from './modules/ios';
3
+ import { validateReceiptAndroid } from './modules/android';
2
4
  import { useCallback, useEffect, useState, useRef } from 'react';
3
5
  import { Platform } from 'react-native';
4
6
  export function useIAP(options) {
@@ -37,15 +39,31 @@ export function useIAP(options) {
37
39
  setCurrentPurchaseError(undefined);
38
40
  }, []);
39
41
  const getProductsInternal = useCallback(async (skus) => {
40
- const newProducts = await getProducts(skus);
41
- setProducts((prevProducts) => mergeWithDuplicateCheck(prevProducts, newProducts, (product) => product.id));
42
+ try {
43
+ const result = await getProducts(skus);
44
+ setProducts((prevProducts) => mergeWithDuplicateCheck(prevProducts, result, (product) => product.id));
45
+ }
46
+ catch (error) {
47
+ console.error('Error fetching products:', error);
48
+ }
42
49
  }, [mergeWithDuplicateCheck]);
43
50
  const getSubscriptionsInternal = useCallback(async (skus) => {
44
- const newSubscriptions = await getSubscriptions(skus);
45
- setSubscriptions((prevSubscriptions) => mergeWithDuplicateCheck(prevSubscriptions, newSubscriptions, (subscription) => subscription.id));
51
+ try {
52
+ const result = await getSubscriptions(skus);
53
+ setSubscriptions((prevSubscriptions) => mergeWithDuplicateCheck(prevSubscriptions, result, (subscription) => subscription.id));
54
+ }
55
+ catch (error) {
56
+ console.error('Error fetching subscriptions:', error);
57
+ }
46
58
  }, [mergeWithDuplicateCheck]);
47
59
  const getAvailablePurchasesInternal = useCallback(async () => {
48
- setAvailablePurchases(await getAvailablePurchases());
60
+ try {
61
+ const result = await getAvailablePurchases();
62
+ setAvailablePurchases(result);
63
+ }
64
+ catch (error) {
65
+ console.error('Error fetching available purchases:', error);
66
+ }
49
67
  }, []);
50
68
  const getPurchaseHistoriesInternal = useCallback(async () => {
51
69
  setPurchaseHistories(await getPurchaseHistory());