expo-iap 2.2.5-rc.5 → 2.2.6
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
|
-
|
|
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
|
}
|
|
@@ -86,24 +90,34 @@ class ExpoIapModule :
|
|
|
86
90
|
"purchaseStateAndroid" to purchase.purchaseState,
|
|
87
91
|
"packageNameAndroid" to purchase.packageName,
|
|
88
92
|
"developerPayloadAndroid" to purchase.developerPayload,
|
|
93
|
+
"platform" to "android",
|
|
89
94
|
)
|
|
90
95
|
purchase.accountIdentifiers?.let { accountIdentifiers ->
|
|
91
96
|
item["obfuscatedAccountIdAndroid"] = accountIdentifiers.obfuscatedAccountId
|
|
92
97
|
item["obfuscatedProfileIdAndroid"] = accountIdentifiers.obfuscatedProfileId
|
|
93
98
|
}
|
|
94
99
|
promiseItems.add(item.toMap())
|
|
95
|
-
|
|
100
|
+
try {
|
|
101
|
+
sendEvent(IapEvent.PURCHASE_UPDATED, item.toMap())
|
|
102
|
+
} catch (e: Exception) {
|
|
103
|
+
Log.e(TAG, "Failed to send PURCHASE_UPDATED event: ${e.message}")
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
106
|
PromiseUtils.resolvePromisesForKey(PROMISE_BUY_ITEM, promiseItems)
|
|
98
107
|
} else {
|
|
99
108
|
val result =
|
|
100
109
|
mutableMapOf<String, Any?>(
|
|
110
|
+
"platform" to "android",
|
|
101
111
|
"responseCode" to billingResult.responseCode,
|
|
102
112
|
"debugMessage" to billingResult.debugMessage,
|
|
103
113
|
"extraMessage" to
|
|
104
114
|
"The purchases are null. This is a normal behavior if you have requested DEFERRED proration. If not please report an issue.",
|
|
105
115
|
)
|
|
106
|
-
|
|
116
|
+
try {
|
|
117
|
+
sendEvent(IapEvent.PURCHASE_UPDATED, result.toMap())
|
|
118
|
+
} catch (e: Exception) {
|
|
119
|
+
Log.e(TAG, "Failed to send PURCHASE_UPDATED event: ${e.message}")
|
|
120
|
+
}
|
|
107
121
|
PromiseUtils.resolvePromisesForKey(PROMISE_BUY_ITEM, result)
|
|
108
122
|
}
|
|
109
123
|
}
|
|
@@ -169,7 +183,7 @@ class ExpoIapModule :
|
|
|
169
183
|
"description" to productDetails.description,
|
|
170
184
|
"type" to productDetails.productType,
|
|
171
185
|
"displayName" to productDetails.name,
|
|
172
|
-
"platform" to "android",
|
|
186
|
+
"platform" to "android",
|
|
173
187
|
"oneTimePurchaseOfferDetails" to
|
|
174
188
|
productDetails.oneTimePurchaseOfferDetails?.let {
|
|
175
189
|
mapOf(
|
|
@@ -239,6 +253,7 @@ class ExpoIapModule :
|
|
|
239
253
|
"packageNameAndroid" to purchase.packageName,
|
|
240
254
|
"obfuscatedAccountIdAndroid" to purchase.accountIdentifiers?.obfuscatedAccountId,
|
|
241
255
|
"obfuscatedProfileIdAndroid" to purchase.accountIdentifiers?.obfuscatedProfileId,
|
|
256
|
+
"platform" to "android",
|
|
242
257
|
)
|
|
243
258
|
if (type == BillingClient.ProductType.SUBS) {
|
|
244
259
|
item["autoRenewingAndroid"] = purchase.isAutoRenewing
|
|
@@ -281,6 +296,7 @@ class ExpoIapModule :
|
|
|
281
296
|
"dataAndroid" to purchase.originalJson,
|
|
282
297
|
"signatureAndroid" to purchase.signature,
|
|
283
298
|
"developerPayload" to purchase.developerPayload,
|
|
299
|
+
"platform" to "android",
|
|
284
300
|
)
|
|
285
301
|
items.add(item)
|
|
286
302
|
}
|
|
@@ -314,14 +330,18 @@ class ExpoIapModule :
|
|
|
314
330
|
|
|
315
331
|
if (type == BillingClient.ProductType.SUBS && skuArr.size != offerTokenArr.size) {
|
|
316
332
|
val debugMessage = "The number of skus (${skuArr.size}) must match: the number of offerTokens (${offerTokenArr.size}) for Subscriptions"
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
333
|
+
try {
|
|
334
|
+
sendEvent(
|
|
335
|
+
IapEvent.PURCHASE_ERROR,
|
|
336
|
+
mapOf(
|
|
337
|
+
"debugMessage" to debugMessage,
|
|
338
|
+
"code" to "E_SKU_OFFER_MISMATCH",
|
|
339
|
+
"message" to debugMessage,
|
|
340
|
+
)
|
|
323
341
|
)
|
|
324
|
-
)
|
|
342
|
+
} catch (e: Exception) {
|
|
343
|
+
Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
|
|
344
|
+
}
|
|
325
345
|
promise.reject("E_SKU_OFFER_MISMATCH", debugMessage, null)
|
|
326
346
|
return@ensureConnection
|
|
327
347
|
}
|
|
@@ -332,15 +352,19 @@ class ExpoIapModule :
|
|
|
332
352
|
if (selectedSku == null) {
|
|
333
353
|
val debugMessage =
|
|
334
354
|
"The sku was not found. Please fetch products first by calling getItems"
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
355
|
+
try {
|
|
356
|
+
sendEvent(
|
|
357
|
+
IapEvent.PURCHASE_ERROR,
|
|
358
|
+
mapOf(
|
|
359
|
+
"debugMessage" to debugMessage,
|
|
360
|
+
"code" to "E_SKU_NOT_FOUND",
|
|
361
|
+
"message" to debugMessage,
|
|
362
|
+
"productId" to sku,
|
|
363
|
+
),
|
|
364
|
+
)
|
|
365
|
+
} catch (e: Exception) {
|
|
366
|
+
Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
|
|
367
|
+
}
|
|
344
368
|
promise.reject("E_SKU_NOT_FOUND", debugMessage, null)
|
|
345
369
|
return@ensureConnection
|
|
346
370
|
}
|
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/ios/ExpoIapModule.swift
CHANGED
|
@@ -47,6 +47,7 @@ func serializeTransaction(_ transaction: Transaction) -> [String: Any?] {
|
|
|
47
47
|
"transactionId": String(transaction.id),
|
|
48
48
|
"transactionDate": transaction.purchaseDate.timeIntervalSince1970 * 1000,
|
|
49
49
|
"transactionReceipt": jwsReceipt,
|
|
50
|
+
"platform": "ios",
|
|
50
51
|
|
|
51
52
|
"quantityIos": transaction.purchasedQuantity,
|
|
52
53
|
"originalTransactionDateIos": transaction.originalPurchaseDate.timeIntervalSince1970 * 1000,
|
|
@@ -136,6 +137,7 @@ func serializeSubscriptionStatus(_ status: Product.SubscriptionInfo.Status) -> [
|
|
|
136
137
|
return [
|
|
137
138
|
"state": status.state.rawValue,
|
|
138
139
|
"renewalInfo": serializeRenewalInfo(status.renewalInfo),
|
|
140
|
+
"platform": "ios",
|
|
139
141
|
]
|
|
140
142
|
}
|
|
141
143
|
|
|
@@ -155,6 +157,7 @@ func serializeRenewalInfo(_ renewalInfo: VerificationResult<Product.Subscription
|
|
|
155
157
|
"currentProductID": info.currentProductID,
|
|
156
158
|
"debugDescription": info.debugDescription,
|
|
157
159
|
"gracePeriodExpirationDate": info.gracePeriodExpirationDate,
|
|
160
|
+
"platform": "ios",
|
|
158
161
|
]
|
|
159
162
|
}
|
|
160
163
|
}
|