expo-iap 2.2.5-rc.5 → 2.2.5

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.
@@ -63,7 +63,11 @@ class ExpoIapModule :
63
63
  val errorData = PlayUtils.getBillingResponseData(responseCode)
64
64
  error["code"] = errorData.code
65
65
  error["message"] = errorData.message
66
- sendEvent(IapEvent.PURCHASE_ERROR, error.toMap())
66
+ try {
67
+ sendEvent(IapEvent.PURCHASE_ERROR, error.toMap())
68
+ } catch (e: Exception) {
69
+ Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
70
+ }
67
71
  PromiseUtils.rejectPromisesForKey(PROMISE_BUY_ITEM, errorData.code, errorData.message, null)
68
72
  return
69
73
  }
@@ -92,7 +96,11 @@ class ExpoIapModule :
92
96
  item["obfuscatedProfileIdAndroid"] = accountIdentifiers.obfuscatedProfileId
93
97
  }
94
98
  promiseItems.add(item.toMap())
95
- sendEvent(IapEvent.PURCHASE_UPDATED, item.toMap())
99
+ try {
100
+ sendEvent(IapEvent.PURCHASE_UPDATED, item.toMap())
101
+ } catch (e: Exception) {
102
+ Log.e(TAG, "Failed to send PURCHASE_UPDATED event: ${e.message}")
103
+ }
96
104
  }
97
105
  PromiseUtils.resolvePromisesForKey(PROMISE_BUY_ITEM, promiseItems)
98
106
  } else {
@@ -103,7 +111,11 @@ class ExpoIapModule :
103
111
  "extraMessage" to
104
112
  "The purchases are null. This is a normal behavior if you have requested DEFERRED proration. If not please report an issue.",
105
113
  )
106
- sendEvent(IapEvent.PURCHASE_UPDATED, result.toMap())
114
+ try {
115
+ sendEvent(IapEvent.PURCHASE_UPDATED, result.toMap())
116
+ } catch (e: Exception) {
117
+ Log.e(TAG, "Failed to send PURCHASE_UPDATED event: ${e.message}")
118
+ }
107
119
  PromiseUtils.resolvePromisesForKey(PROMISE_BUY_ITEM, result)
108
120
  }
109
121
  }
@@ -314,14 +326,18 @@ class ExpoIapModule :
314
326
 
315
327
  if (type == BillingClient.ProductType.SUBS && skuArr.size != offerTokenArr.size) {
316
328
  val debugMessage = "The number of skus (${skuArr.size}) must match: the number of offerTokens (${offerTokenArr.size}) for Subscriptions"
317
- sendEvent(
318
- IapEvent.PURCHASE_ERROR,
319
- mapOf(
320
- "debugMessage" to debugMessage,
321
- "code" to "E_SKU_OFFER_MISMATCH",
322
- "message" to debugMessage,
329
+ try {
330
+ sendEvent(
331
+ IapEvent.PURCHASE_ERROR,
332
+ mapOf(
333
+ "debugMessage" to debugMessage,
334
+ "code" to "E_SKU_OFFER_MISMATCH",
335
+ "message" to debugMessage,
336
+ )
323
337
  )
324
- )
338
+ } catch (e: Exception) {
339
+ Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
340
+ }
325
341
  promise.reject("E_SKU_OFFER_MISMATCH", debugMessage, null)
326
342
  return@ensureConnection
327
343
  }
@@ -332,15 +348,19 @@ class ExpoIapModule :
332
348
  if (selectedSku == null) {
333
349
  val debugMessage =
334
350
  "The sku was not found. Please fetch products first by calling getItems"
335
- sendEvent(
336
- IapEvent.PURCHASE_ERROR,
337
- mapOf(
338
- "debugMessage" to debugMessage,
339
- "code" to "E_SKU_NOT_FOUND",
340
- "message" to debugMessage,
341
- "productId" to sku,
342
- ),
343
- )
351
+ try {
352
+ sendEvent(
353
+ IapEvent.PURCHASE_ERROR,
354
+ mapOf(
355
+ "debugMessage" to debugMessage,
356
+ "code" to "E_SKU_NOT_FOUND",
357
+ "message" to debugMessage,
358
+ "productId" to sku,
359
+ ),
360
+ )
361
+ } catch (e: Exception) {
362
+ Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
363
+ }
344
364
  promise.reject("E_SKU_NOT_FOUND", debugMessage, null)
345
365
  return@ensureConnection
346
366
  }
package/iap.md CHANGED
@@ -147,6 +147,7 @@ This section describes purchase properties in `expo-iap`.
147
147
  ### Android-Only Purchase Types
148
148
 
149
149
  - **`ProductPurchase`**:
150
+
150
151
  - Adds the following properties specific to in-app product purchases:
151
152
  - **`ids`**: `string[]` - A list of product IDs associated with the purchase (for multi-item purchases).
152
153
  - **`dataAndroid`**: `string` - The raw purchase data from Google Play (e.g., JSON payload).
@@ -154,6 +155,7 @@ This section describes purchase properties in `expo-iap`.
154
155
  - **`purchaseStateAndroid`**: `number` - The state of the purchase (e.g., 0 = purchased, 1 = canceled, 2 = pending).
155
156
 
156
157
  - **`SubscriptionPurchase`**:
158
+
157
159
  - Extends the base properties and includes:
158
160
  - **`autoRenewingAndroid`**: `boolean` - Indicates whether the subscription automatically renews (true) or not (false).
159
161
 
@@ -163,6 +165,7 @@ This section describes purchase properties in `expo-iap`.
163
165
  ### iOS-Only Purchase Types
164
166
 
165
167
  - **`ProductPurchase`**:
168
+
166
169
  - Extends the base purchase properties with iOS-specific fields:
167
170
  - **`quantityIos`**: `number` - The quantity of the product purchased (e.g., how many units of an item were bought).
168
171
  - **`expirationDateIos`**: `number?` - The expiration date of the purchase as a Unix timestamp (in milliseconds), if applicable (optional, may be null for non-expiring products).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "2.2.5-rc.5",
3
+ "version": "2.2.5",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",