react-native-iap 12.8.5 → 12.10.0
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/android/build.gradle +1 -1
- package/android/src/amazon/AndroidManifest.xml +1 -1
- package/android/src/amazon/java/com/dooboolab/{RNIap → rniap}/EventSender.kt +2 -2
- package/android/src/amazon/java/com/dooboolab/{RNIap → rniap}/PurchasingServiceProxy.kt +1 -1
- package/android/src/amazon/java/com/dooboolab/{RNIap → rniap}/PurchasingServiceProxyAmazonImpl.kt +1 -1
- package/android/src/amazon/java/com/dooboolab/{RNIap → rniap}/RNIapActivityListener.kt +1 -1
- package/android/src/amazon/java/com/dooboolab/{RNIap → rniap}/RNIapAmazonListener.kt +20 -20
- package/android/src/amazon/java/com/dooboolab/{RNIap → rniap}/RNIapAmazonModule.kt +5 -5
- package/android/src/amazon/java/com/dooboolab/{RNIap → rniap}/RNIapPackage.kt +1 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/dooboolab/{RNIap → rniap}/PromiseUtils.kt +2 -2
- package/android/src/main/java/com/dooboolab/{RNIap → rniap}/PromiseUtlis.kt +1 -1
- package/android/src/play/java/com/dooboolab/{RNIap → rniap}/PlayUtils.kt +12 -12
- package/android/src/play/java/com/dooboolab/{RNIap → rniap}/RNIapActivityListener.kt +1 -1
- package/android/src/play/java/com/dooboolab/{RNIap → rniap}/RNIapModule.kt +83 -58
- package/android/src/play/java/com/dooboolab/{RNIap → rniap}/RNIapPackage.kt +1 -1
- package/android/src/testAmazon/java/com/dooboolab/{RNIap → rniap}/RNIapAmazonModuleTest.kt +2 -2
- package/lib/commonjs/eventEmitter.js +3 -17
- package/lib/commonjs/eventEmitter.js.map +1 -1
- package/lib/commonjs/hooks/index.js +0 -2
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useIAP.js +0 -7
- package/lib/commonjs/hooks/useIAP.js.map +1 -1
- package/lib/commonjs/hooks/withIAPContext.js +0 -11
- package/lib/commonjs/hooks/withIAPContext.js.map +1 -1
- package/lib/commonjs/iap.js +15 -84
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/index.js +0 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/enhancedFetch.js +0 -4
- package/lib/commonjs/internal/enhancedFetch.js.map +1 -1
- package/lib/commonjs/internal/fillProductsWithAdditionalData.js +3 -6
- package/lib/commonjs/internal/fillProductsWithAdditionalData.js.map +1 -1
- package/lib/commonjs/internal/index.js +0 -6
- package/lib/commonjs/internal/index.js.map +1 -1
- package/lib/commonjs/internal/platform.js +6 -40
- package/lib/commonjs/internal/platform.js.map +1 -1
- package/lib/commonjs/modules/amazon.js +3 -12
- package/lib/commonjs/modules/amazon.js.map +1 -1
- package/lib/commonjs/modules/android.js +16 -17
- package/lib/commonjs/modules/android.js.map +1 -1
- package/lib/commonjs/modules/index.js +0 -8
- package/lib/commonjs/modules/index.js.map +1 -1
- package/lib/commonjs/modules/ios.js +9 -39
- package/lib/commonjs/modules/ios.js.map +1 -1
- package/lib/commonjs/modules/iosSk2.js +5 -19
- package/lib/commonjs/modules/iosSk2.js.map +1 -1
- package/lib/commonjs/purchaseError.js +4 -8
- package/lib/commonjs/purchaseError.js.map +1 -1
- package/lib/commonjs/types/android.js +32 -30
- package/lib/commonjs/types/android.js.map +1 -1
- package/lib/commonjs/types/apple.js +1 -3
- package/lib/commonjs/types/apple.js.map +1 -1
- package/lib/commonjs/types/appleSk2.js +2 -13
- package/lib/commonjs/types/appleSk2.js.map +1 -1
- package/lib/commonjs/types/index.js +21 -31
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/eventEmitter.js +3 -6
- package/lib/module/eventEmitter.js.map +1 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useIAP.js +0 -2
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/hooks/withIAPContext.js +0 -3
- package/lib/module/hooks/withIAPContext.js.map +1 -1
- package/lib/module/iap.js +15 -43
- package/lib/module/iap.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/enhancedFetch.js +0 -2
- package/lib/module/internal/enhancedFetch.js.map +1 -1
- package/lib/module/internal/fillProductsWithAdditionalData.js +3 -3
- package/lib/module/internal/fillProductsWithAdditionalData.js.map +1 -1
- package/lib/module/internal/index.js.map +1 -1
- package/lib/module/internal/platform.js +8 -14
- package/lib/module/internal/platform.js.map +1 -1
- package/lib/module/modules/amazon.js +3 -3
- package/lib/module/modules/amazon.js.map +1 -1
- package/lib/module/modules/android.js +16 -6
- package/lib/module/modules/android.js.map +1 -1
- package/lib/module/modules/index.js.map +1 -1
- package/lib/module/modules/ios.js +9 -20
- package/lib/module/modules/ios.js.map +1 -1
- package/lib/module/modules/iosSk2.js +5 -5
- package/lib/module/modules/iosSk2.js.map +1 -1
- package/lib/module/purchaseError.js +3 -6
- package/lib/module/purchaseError.js.map +1 -1
- package/lib/module/types/android.js +27 -21
- package/lib/module/types/android.js.map +1 -1
- package/lib/module/types/apple.js +1 -1
- package/lib/module/types/apple.js.map +1 -1
- package/lib/module/types/appleSk2.js +2 -3
- package/lib/module/types/appleSk2.js.map +1 -1
- package/lib/module/types/index.js +17 -25
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/plugin/src/withIAP.d.ts +1 -1
- package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/hooks/withIAPContext.d.ts +1 -1
- package/lib/typescript/src/hooks/withIAPContext.d.ts.map +1 -1
- package/lib/typescript/src/iap.d.ts +1 -1
- package/lib/typescript/src/iap.d.ts.map +1 -1
- package/lib/typescript/src/internal/platform.d.ts +7 -5
- package/lib/typescript/src/internal/platform.d.ts.map +1 -1
- package/lib/typescript/src/modules/amazon.d.ts +8 -8
- package/lib/typescript/src/modules/amazon.d.ts.map +1 -1
- package/lib/typescript/src/modules/android.d.ts +16 -9
- package/lib/typescript/src/modules/android.d.ts.map +1 -1
- package/lib/typescript/src/modules/ios.d.ts +11 -11
- package/lib/typescript/src/modules/ios.d.ts.map +1 -1
- package/lib/typescript/src/modules/iosSk2.d.ts +11 -11
- package/lib/typescript/src/modules/iosSk2.d.ts.map +1 -1
- package/lib/typescript/src/types/amazon.d.ts +2 -2
- package/lib/typescript/src/types/amazon.d.ts.map +1 -1
- package/lib/typescript/src/types/android.d.ts +16 -1
- package/lib/typescript/src/types/android.d.ts.map +1 -1
- package/lib/typescript/src/types/appleSk2.d.ts +11 -11
- package/lib/typescript/src/types/appleSk2.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +10 -10
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +20 -19
- package/plugin/build/withIAP.d.ts +1 -1
- package/src/hooks/withIAPContext.tsx +1 -0
- package/src/modules/android.ts +20 -1
- package/src/types/android.ts +16 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.dooboolab.
|
|
1
|
+
package com.dooboolab.rniap
|
|
2
2
|
|
|
3
3
|
import android.util.Log
|
|
4
4
|
import com.android.billingclient.api.AcknowledgePurchaseParams
|
|
@@ -39,7 +39,7 @@ import java.util.ArrayList
|
|
|
39
39
|
class RNIapModule(
|
|
40
40
|
private val reactContext: ReactApplicationContext,
|
|
41
41
|
private val builder: BillingClient.Builder = BillingClient.newBuilder(reactContext).enablePendingPurchases(),
|
|
42
|
-
private val googleApiAvailability: GoogleApiAvailability = GoogleApiAvailability.getInstance()
|
|
42
|
+
private val googleApiAvailability: GoogleApiAvailability = GoogleApiAvailability.getInstance(),
|
|
43
43
|
) :
|
|
44
44
|
ReactContextBaseJavaModule(reactContext),
|
|
45
45
|
PurchasesUpdatedListener {
|
|
@@ -52,7 +52,7 @@ class RNIapModule(
|
|
|
52
52
|
|
|
53
53
|
fun ensureConnection(
|
|
54
54
|
promise: Promise,
|
|
55
|
-
callback: (billingClient: BillingClient) -> Unit
|
|
55
|
+
callback: (billingClient: BillingClient) -> Unit,
|
|
56
56
|
) {
|
|
57
57
|
val billingClient = billingClientCache
|
|
58
58
|
if (billingClient?.isReady == true) {
|
|
@@ -76,17 +76,42 @@ class RNIapModule(
|
|
|
76
76
|
if (it.size > 1 && it[0] is String && it[1] is String) {
|
|
77
77
|
promise.safeReject(
|
|
78
78
|
it[0] as String,
|
|
79
|
-
it[1] as String
|
|
79
|
+
it[1] as String,
|
|
80
80
|
)
|
|
81
81
|
} else {
|
|
82
82
|
Log.i(TAG, "Incorrect parameters in reject")
|
|
83
83
|
}
|
|
84
|
-
}
|
|
84
|
+
},
|
|
85
85
|
)
|
|
86
86
|
initConnection(nested)
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
@ReactMethod
|
|
91
|
+
fun isFeatureSupported(feature: String, promise: Promise) {
|
|
92
|
+
ensureConnection(
|
|
93
|
+
promise,
|
|
94
|
+
) { billingClient ->
|
|
95
|
+
val f = when (feature) {
|
|
96
|
+
"IN_APP_MESSAGING" ->
|
|
97
|
+
BillingClient.FeatureType.IN_APP_MESSAGING
|
|
98
|
+
"PRICE_CHANGE_CONFIRMATION" ->
|
|
99
|
+
BillingClient.FeatureType.PRICE_CHANGE_CONFIRMATION
|
|
100
|
+
"PRODUCT_DETAILS" ->
|
|
101
|
+
BillingClient.FeatureType.PRODUCT_DETAILS
|
|
102
|
+
"SUBSCRIPTIONS" ->
|
|
103
|
+
BillingClient.FeatureType.SUBSCRIPTIONS
|
|
104
|
+
"SUBSCRIPTIONS_UPDATE" ->
|
|
105
|
+
BillingClient.FeatureType.SUBSCRIPTIONS_UPDATE
|
|
106
|
+
else -> {
|
|
107
|
+
promise.safeReject("Invalid Feature name")
|
|
108
|
+
return@ensureConnection
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
promise.safeResolve(billingClient.isFeatureSupported(f))
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
90
115
|
@ReactMethod
|
|
91
116
|
fun initConnection(promise: Promise) {
|
|
92
117
|
if (googleApiAvailability.isGooglePlayServicesAvailable(reactContext)
|
|
@@ -100,7 +125,7 @@ class RNIapModule(
|
|
|
100
125
|
if (billingClientCache?.isReady == true) {
|
|
101
126
|
Log.i(
|
|
102
127
|
TAG,
|
|
103
|
-
"Already initialized, you should only call initConnection() once when your app starts"
|
|
128
|
+
"Already initialized, you should only call initConnection() once when your app starts",
|
|
104
129
|
)
|
|
105
130
|
promise.safeResolve(true)
|
|
106
131
|
return
|
|
@@ -118,7 +143,7 @@ class RNIapModule(
|
|
|
118
143
|
override fun onBillingServiceDisconnected() {
|
|
119
144
|
Log.i(TAG, "Billing service disconnected")
|
|
120
145
|
}
|
|
121
|
-
}
|
|
146
|
+
},
|
|
122
147
|
)
|
|
123
148
|
}
|
|
124
149
|
}
|
|
@@ -135,11 +160,11 @@ class RNIapModule(
|
|
|
135
160
|
private fun consumeItems(
|
|
136
161
|
purchases: List<Purchase>,
|
|
137
162
|
promise: Promise,
|
|
138
|
-
expectedResponseCode: Int = BillingClient.BillingResponseCode.OK
|
|
163
|
+
expectedResponseCode: Int = BillingClient.BillingResponseCode.OK,
|
|
139
164
|
) {
|
|
140
165
|
for (purchase in purchases) {
|
|
141
166
|
ensureConnection(
|
|
142
|
-
promise
|
|
167
|
+
promise,
|
|
143
168
|
) { billingClient ->
|
|
144
169
|
val consumeParams =
|
|
145
170
|
ConsumeParams.newBuilder().setPurchaseToken(purchase.purchaseToken)
|
|
@@ -149,7 +174,7 @@ class RNIapModule(
|
|
|
149
174
|
if (billingResult.responseCode != expectedResponseCode) {
|
|
150
175
|
PlayUtils.rejectPromiseWithBillingError(
|
|
151
176
|
promise,
|
|
152
|
-
billingResult.responseCode
|
|
177
|
+
billingResult.responseCode,
|
|
153
178
|
)
|
|
154
179
|
return@ConsumeResponseListener
|
|
155
180
|
}
|
|
@@ -164,12 +189,12 @@ class RNIapModule(
|
|
|
164
189
|
@ReactMethod
|
|
165
190
|
fun flushFailedPurchasesCachedAsPending(promise: Promise) {
|
|
166
191
|
ensureConnection(
|
|
167
|
-
promise
|
|
192
|
+
promise,
|
|
168
193
|
) { billingClient ->
|
|
169
194
|
billingClient.queryPurchasesAsync(
|
|
170
195
|
QueryPurchasesParams.newBuilder().setProductType(
|
|
171
|
-
BillingClient.ProductType.INAPP
|
|
172
|
-
).build()
|
|
196
|
+
BillingClient.ProductType.INAPP,
|
|
197
|
+
).build(),
|
|
173
198
|
) { billingResult: BillingResult, list: List<Purchase>? ->
|
|
174
199
|
if (!isValidResult(billingResult, promise)) return@queryPurchasesAsync
|
|
175
200
|
if (list == null) {
|
|
@@ -188,7 +213,7 @@ class RNIapModule(
|
|
|
188
213
|
consumeItems(
|
|
189
214
|
pendingPurchases,
|
|
190
215
|
promise,
|
|
191
|
-
BillingClient.BillingResponseCode.ITEM_NOT_OWNED
|
|
216
|
+
BillingClient.BillingResponseCode.ITEM_NOT_OWNED,
|
|
192
217
|
)
|
|
193
218
|
}
|
|
194
219
|
}
|
|
@@ -197,7 +222,7 @@ class RNIapModule(
|
|
|
197
222
|
@ReactMethod
|
|
198
223
|
fun getItemsByType(type: String, skuArr: ReadableArray, promise: Promise) {
|
|
199
224
|
ensureConnection(
|
|
200
|
-
promise
|
|
225
|
+
promise,
|
|
201
226
|
) { billingClient ->
|
|
202
227
|
val skuList = ArrayList<QueryProductDetailsParams.Product>()
|
|
203
228
|
for (i in 0 until skuArr.size()) {
|
|
@@ -205,14 +230,14 @@ class RNIapModule(
|
|
|
205
230
|
skuArr.getString(i)?.let { sku -> // null check for older versions of RN
|
|
206
231
|
skuList.add(
|
|
207
232
|
QueryProductDetailsParams.Product.newBuilder().setProductId(sku)
|
|
208
|
-
.setProductType(type).build()
|
|
233
|
+
.setProductType(type).build(),
|
|
209
234
|
)
|
|
210
235
|
}
|
|
211
236
|
}
|
|
212
237
|
}
|
|
213
238
|
val params = QueryProductDetailsParams.newBuilder().setProductList(skuList)
|
|
214
239
|
billingClient.queryProductDetailsAsync(
|
|
215
|
-
params.build()
|
|
240
|
+
params.build(),
|
|
216
241
|
) { billingResult: BillingResult, skuDetailsList: List<ProductDetails> ->
|
|
217
242
|
if (!isValidResult(billingResult, promise)) return@queryProductDetailsAsync
|
|
218
243
|
|
|
@@ -230,12 +255,12 @@ class RNIapModule(
|
|
|
230
255
|
skuDetails.oneTimePurchaseOfferDetails?.let {
|
|
231
256
|
oneTimePurchaseOfferDetails.putString(
|
|
232
257
|
"priceCurrencyCode",
|
|
233
|
-
it.priceCurrencyCode
|
|
258
|
+
it.priceCurrencyCode,
|
|
234
259
|
)
|
|
235
260
|
oneTimePurchaseOfferDetails.putString("formattedPrice", it.formattedPrice)
|
|
236
261
|
oneTimePurchaseOfferDetails.putString(
|
|
237
262
|
"priceAmountMicros",
|
|
238
|
-
it.priceAmountMicros.toString()
|
|
263
|
+
it.priceAmountMicros.toString(),
|
|
239
264
|
)
|
|
240
265
|
item.putMap("oneTimePurchaseOfferDetails", oneTimePurchaseOfferDetails)
|
|
241
266
|
}
|
|
@@ -245,15 +270,15 @@ class RNIapModule(
|
|
|
245
270
|
val offerDetails = Arguments.createMap()
|
|
246
271
|
offerDetails.putString(
|
|
247
272
|
"basePlanId",
|
|
248
|
-
subscriptionOfferDetailsItem.basePlanId
|
|
273
|
+
subscriptionOfferDetailsItem.basePlanId,
|
|
249
274
|
)
|
|
250
275
|
offerDetails.putString(
|
|
251
276
|
"offerId",
|
|
252
|
-
subscriptionOfferDetailsItem.offerId
|
|
277
|
+
subscriptionOfferDetailsItem.offerId,
|
|
253
278
|
)
|
|
254
279
|
offerDetails.putString(
|
|
255
280
|
"offerToken",
|
|
256
|
-
subscriptionOfferDetailsItem.offerToken
|
|
281
|
+
subscriptionOfferDetailsItem.offerToken,
|
|
257
282
|
)
|
|
258
283
|
val offerTags = Arguments.createArray()
|
|
259
284
|
subscriptionOfferDetailsItem.offerTags.forEach { offerTag ->
|
|
@@ -266,20 +291,20 @@ class RNIapModule(
|
|
|
266
291
|
val pricingPhase = Arguments.createMap()
|
|
267
292
|
pricingPhase.putString(
|
|
268
293
|
"formattedPrice",
|
|
269
|
-
pricingPhaseItem.formattedPrice
|
|
294
|
+
pricingPhaseItem.formattedPrice,
|
|
270
295
|
)
|
|
271
296
|
pricingPhase.putString(
|
|
272
297
|
"priceCurrencyCode",
|
|
273
|
-
pricingPhaseItem.priceCurrencyCode
|
|
298
|
+
pricingPhaseItem.priceCurrencyCode,
|
|
274
299
|
)
|
|
275
300
|
pricingPhase.putString("billingPeriod", pricingPhaseItem.billingPeriod)
|
|
276
301
|
pricingPhase.putInt(
|
|
277
302
|
"billingCycleCount",
|
|
278
|
-
pricingPhaseItem.billingCycleCount
|
|
303
|
+
pricingPhaseItem.billingCycleCount,
|
|
279
304
|
)
|
|
280
305
|
pricingPhase.putString(
|
|
281
306
|
"priceAmountMicros",
|
|
282
|
-
pricingPhaseItem.priceAmountMicros.toString()
|
|
307
|
+
pricingPhaseItem.priceAmountMicros.toString(),
|
|
283
308
|
)
|
|
284
309
|
pricingPhase.putInt("recurrenceMode", pricingPhaseItem.recurrenceMode)
|
|
285
310
|
|
|
@@ -304,7 +329,7 @@ class RNIapModule(
|
|
|
304
329
|
*/
|
|
305
330
|
private fun isValidResult(
|
|
306
331
|
billingResult: BillingResult,
|
|
307
|
-
promise: Promise
|
|
332
|
+
promise: Promise,
|
|
308
333
|
): Boolean {
|
|
309
334
|
Log.d(TAG, "responseCode: " + billingResult.responseCode)
|
|
310
335
|
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
|
|
@@ -317,13 +342,13 @@ class RNIapModule(
|
|
|
317
342
|
@ReactMethod
|
|
318
343
|
fun getAvailableItemsByType(type: String, promise: Promise) {
|
|
319
344
|
ensureConnection(
|
|
320
|
-
promise
|
|
345
|
+
promise,
|
|
321
346
|
) { billingClient ->
|
|
322
347
|
val items = WritableNativeArray()
|
|
323
348
|
billingClient.queryPurchasesAsync(
|
|
324
349
|
QueryPurchasesParams.newBuilder().setProductType(
|
|
325
|
-
if (type == "subs") BillingClient.ProductType.SUBS else BillingClient.ProductType.INAPP
|
|
326
|
-
).build()
|
|
350
|
+
if (type == "subs") BillingClient.ProductType.SUBS else BillingClient.ProductType.INAPP,
|
|
351
|
+
).build(),
|
|
327
352
|
) { billingResult: BillingResult, purchases: List<Purchase>? ->
|
|
328
353
|
if (!isValidResult(billingResult, promise)) return@queryPurchasesAsync
|
|
329
354
|
purchases?.forEach { purchase ->
|
|
@@ -344,11 +369,11 @@ class RNIapModule(
|
|
|
344
369
|
item.putString("packageNameAndroid", purchase.packageName)
|
|
345
370
|
item.putString(
|
|
346
371
|
"obfuscatedAccountIdAndroid",
|
|
347
|
-
purchase.accountIdentifiers?.obfuscatedAccountId
|
|
372
|
+
purchase.accountIdentifiers?.obfuscatedAccountId,
|
|
348
373
|
)
|
|
349
374
|
item.putString(
|
|
350
375
|
"obfuscatedProfileIdAndroid",
|
|
351
|
-
purchase.accountIdentifiers?.obfuscatedProfileId
|
|
376
|
+
purchase.accountIdentifiers?.obfuscatedProfileId,
|
|
352
377
|
)
|
|
353
378
|
if (type == BillingClient.ProductType.SUBS) {
|
|
354
379
|
item.putBoolean("autoRenewingAndroid", purchase.isAutoRenewing)
|
|
@@ -363,12 +388,12 @@ class RNIapModule(
|
|
|
363
388
|
@ReactMethod
|
|
364
389
|
fun getPurchaseHistoryByType(type: String, promise: Promise) {
|
|
365
390
|
ensureConnection(
|
|
366
|
-
promise
|
|
391
|
+
promise,
|
|
367
392
|
) { billingClient ->
|
|
368
393
|
billingClient.queryPurchaseHistoryAsync(
|
|
369
394
|
QueryPurchaseHistoryParams.newBuilder().setProductType(
|
|
370
|
-
if (type == "subs") BillingClient.ProductType.SUBS else BillingClient.ProductType.INAPP
|
|
371
|
-
).build()
|
|
395
|
+
if (type == "subs") BillingClient.ProductType.SUBS else BillingClient.ProductType.INAPP,
|
|
396
|
+
).build(),
|
|
372
397
|
) {
|
|
373
398
|
billingResult: BillingResult, purchaseHistoryRecordList: MutableList<PurchaseHistoryRecord>? ->
|
|
374
399
|
|
|
@@ -405,7 +430,7 @@ class RNIapModule(
|
|
|
405
430
|
obfuscatedProfileId: String?,
|
|
406
431
|
offerTokenArr: ReadableArray, // New parameter in V5
|
|
407
432
|
isOfferPersonalized: Boolean, // New parameter in V5
|
|
408
|
-
promise: Promise
|
|
433
|
+
promise: Promise,
|
|
409
434
|
) {
|
|
410
435
|
val activity = currentActivity
|
|
411
436
|
if (activity == null) {
|
|
@@ -413,11 +438,11 @@ class RNIapModule(
|
|
|
413
438
|
return
|
|
414
439
|
}
|
|
415
440
|
ensureConnection(
|
|
416
|
-
promise
|
|
441
|
+
promise,
|
|
417
442
|
) { billingClient ->
|
|
418
443
|
PromiseUtils.addPromiseForKey(
|
|
419
444
|
PROMISE_BUY_ITEM,
|
|
420
|
-
promise
|
|
445
|
+
promise,
|
|
421
446
|
)
|
|
422
447
|
if (type == BillingClient.ProductType.SUBS && skuArr.size() != offerTokenArr.size()) {
|
|
423
448
|
val debugMessage =
|
|
@@ -471,7 +496,7 @@ class RNIapModule(
|
|
|
471
496
|
== BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
|
|
472
497
|
) {
|
|
473
498
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
474
|
-
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
|
|
499
|
+
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
|
|
475
500
|
)
|
|
476
501
|
if (type != BillingClient.ProductType.SUBS) {
|
|
477
502
|
val debugMessage =
|
|
@@ -492,27 +517,27 @@ class RNIapModule(
|
|
|
492
517
|
== BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION
|
|
493
518
|
) {
|
|
494
519
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
495
|
-
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION
|
|
520
|
+
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION,
|
|
496
521
|
)
|
|
497
522
|
} else if (prorationMode == BillingFlowParams.ProrationMode.DEFERRED) {
|
|
498
523
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
499
|
-
BillingFlowParams.ProrationMode.DEFERRED
|
|
524
|
+
BillingFlowParams.ProrationMode.DEFERRED,
|
|
500
525
|
)
|
|
501
526
|
} else if (prorationMode
|
|
502
527
|
== BillingFlowParams.ProrationMode.IMMEDIATE_WITH_TIME_PRORATION
|
|
503
528
|
) {
|
|
504
529
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
505
|
-
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION
|
|
530
|
+
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION,
|
|
506
531
|
)
|
|
507
532
|
} else if (prorationMode
|
|
508
533
|
== BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE
|
|
509
534
|
) {
|
|
510
535
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
511
|
-
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE
|
|
536
|
+
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE,
|
|
512
537
|
)
|
|
513
538
|
} else {
|
|
514
539
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
515
|
-
BillingFlowParams.ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY
|
|
540
|
+
BillingFlowParams.ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY,
|
|
516
541
|
)
|
|
517
542
|
}
|
|
518
543
|
}
|
|
@@ -533,17 +558,17 @@ class RNIapModule(
|
|
|
533
558
|
fun acknowledgePurchase(
|
|
534
559
|
token: String,
|
|
535
560
|
developerPayLoad: String?,
|
|
536
|
-
promise: Promise
|
|
561
|
+
promise: Promise,
|
|
537
562
|
) {
|
|
538
563
|
ensureConnection(
|
|
539
|
-
promise
|
|
564
|
+
promise,
|
|
540
565
|
) { billingClient ->
|
|
541
566
|
val acknowledgePurchaseParams =
|
|
542
567
|
AcknowledgePurchaseParams.newBuilder().setPurchaseToken(
|
|
543
|
-
token
|
|
568
|
+
token,
|
|
544
569
|
).build()
|
|
545
570
|
billingClient.acknowledgePurchase(
|
|
546
|
-
acknowledgePurchaseParams
|
|
571
|
+
acknowledgePurchaseParams,
|
|
547
572
|
) { billingResult: BillingResult ->
|
|
548
573
|
if (!isValidResult(billingResult, promise)) return@acknowledgePurchase
|
|
549
574
|
|
|
@@ -562,14 +587,14 @@ class RNIapModule(
|
|
|
562
587
|
fun consumeProduct(
|
|
563
588
|
token: String,
|
|
564
589
|
developerPayLoad: String?,
|
|
565
|
-
promise: Promise
|
|
590
|
+
promise: Promise,
|
|
566
591
|
) {
|
|
567
592
|
val params = ConsumeParams.newBuilder().setPurchaseToken(token).build()
|
|
568
593
|
ensureConnection(
|
|
569
|
-
promise
|
|
594
|
+
promise,
|
|
570
595
|
) { billingClient ->
|
|
571
596
|
billingClient.consumeAsync(
|
|
572
|
-
params
|
|
597
|
+
params,
|
|
573
598
|
) { billingResult: BillingResult, purchaseToken: String? ->
|
|
574
599
|
if (!isValidResult(billingResult, promise)) return@consumeAsync
|
|
575
600
|
|
|
@@ -621,11 +646,11 @@ class RNIapModule(
|
|
|
621
646
|
if (accountIdentifiers != null) {
|
|
622
647
|
item.putString(
|
|
623
648
|
"obfuscatedAccountIdAndroid",
|
|
624
|
-
accountIdentifiers.obfuscatedAccountId
|
|
649
|
+
accountIdentifiers.obfuscatedAccountId,
|
|
625
650
|
)
|
|
626
651
|
item.putString(
|
|
627
652
|
"obfuscatedProfileIdAndroid",
|
|
628
|
-
accountIdentifiers.obfuscatedProfileId
|
|
653
|
+
accountIdentifiers.obfuscatedProfileId,
|
|
629
654
|
)
|
|
630
655
|
}
|
|
631
656
|
promiseItems.pushMap(item.copy())
|
|
@@ -639,7 +664,7 @@ class RNIapModule(
|
|
|
639
664
|
result.putString(
|
|
640
665
|
"extraMessage",
|
|
641
666
|
"The purchases are null. This is a normal behavior if you have requested DEFERRED" +
|
|
642
|
-
" proration. If not please report an issue."
|
|
667
|
+
" proration. If not please report an issue.",
|
|
643
668
|
)
|
|
644
669
|
sendEvent(reactContext, "purchase-updated", result)
|
|
645
670
|
PromiseUtils.resolvePromisesForKey(PROMISE_BUY_ITEM, null)
|
|
@@ -648,14 +673,14 @@ class RNIapModule(
|
|
|
648
673
|
|
|
649
674
|
private fun sendUnconsumedPurchases(promise: Promise) {
|
|
650
675
|
ensureConnection(
|
|
651
|
-
promise
|
|
676
|
+
promise,
|
|
652
677
|
) { billingClient ->
|
|
653
678
|
val types = arrayOf(BillingClient.ProductType.INAPP, BillingClient.ProductType.SUBS)
|
|
654
679
|
for (type in types) {
|
|
655
680
|
billingClient.queryPurchasesAsync(
|
|
656
681
|
QueryPurchasesParams.newBuilder().setProductType(
|
|
657
|
-
type
|
|
658
|
-
).build()
|
|
682
|
+
type,
|
|
683
|
+
).build(),
|
|
659
684
|
) { billingResult: BillingResult, list: List<Purchase> ->
|
|
660
685
|
if (!isValidResult(billingResult, promise)) return@queryPurchasesAsync
|
|
661
686
|
|
|
@@ -688,7 +713,7 @@ class RNIapModule(
|
|
|
688
713
|
private fun sendEvent(
|
|
689
714
|
reactContext: ReactContext,
|
|
690
715
|
eventName: String,
|
|
691
|
-
params: WritableMap
|
|
716
|
+
params: WritableMap?,
|
|
692
717
|
) {
|
|
693
718
|
reactContext
|
|
694
719
|
.getJSModule(RCTDeviceEventEmitter::class.java)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.dooboolab.
|
|
1
|
+
package com.dooboolab.rniap
|
|
2
2
|
|
|
3
3
|
import com.amazon.device.iap.model.PurchaseResponse
|
|
4
4
|
import com.amazon.device.iap.model.Receipt
|
|
@@ -97,7 +97,7 @@ class RNIapAmazonModuleTest {
|
|
|
97
97
|
|
|
98
98
|
every { purchasingServiceProxy.purchase(any()) } answers {
|
|
99
99
|
listener.onPurchaseResponse(
|
|
100
|
-
purchaseResponse
|
|
100
|
+
purchaseResponse,
|
|
101
101
|
); RequestId.fromString("0")
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transactionListener = exports.purchaseUpdatedListener = exports.purchaseErrorListener = exports.promotedProductListener = void 0;
|
|
7
|
-
|
|
8
7
|
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
8
|
var _appleSk = require("./types/appleSk2");
|
|
11
|
-
|
|
12
9
|
var _iap = require("./iap");
|
|
13
|
-
|
|
14
10
|
var _internal = require("./internal");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* Add IAP purchase event
|
|
18
13
|
* Register a callback that gets called when the store has any updates to purchases that have not yet been finished, consumed or acknowledged. Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates. Register you listener as soon as possible and react to updates at all times.
|
|
@@ -53,6 +48,7 @@ const purchaseUpdatedListener = listener => {
|
|
|
53
48
|
const emitterSubscription = eventEmitter.addListener('purchase-updated', proxyListener);
|
|
54
49
|
return emitterSubscription;
|
|
55
50
|
};
|
|
51
|
+
|
|
56
52
|
/**
|
|
57
53
|
* Add IAP purchase error event
|
|
58
54
|
* Register a callback that gets called when there has been an error with a purchase. Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates.
|
|
@@ -86,14 +82,12 @@ const App = () => {
|
|
|
86
82
|
```
|
|
87
83
|
|
|
88
84
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
85
|
exports.purchaseUpdatedListener = purchaseUpdatedListener;
|
|
92
|
-
|
|
93
86
|
const purchaseErrorListener = listener => {
|
|
94
87
|
const eventEmitter = new _reactNative.NativeEventEmitter((0, _internal.getNativeModule)());
|
|
95
88
|
return eventEmitter.addListener('purchase-error', listener);
|
|
96
89
|
};
|
|
90
|
+
|
|
97
91
|
/**
|
|
98
92
|
* Add IAP promoted subscription event
|
|
99
93
|
* Add IAP promoted subscription event.
|
|
@@ -129,18 +123,15 @@ const App = () => {
|
|
|
129
123
|
*
|
|
130
124
|
* @platform iOS
|
|
131
125
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
126
|
exports.purchaseErrorListener = purchaseErrorListener;
|
|
135
|
-
|
|
136
127
|
const promotedProductListener = listener => {
|
|
137
128
|
if (_internal.isIos && !(0, _iap.isIosStorekit2)()) {
|
|
138
129
|
const eventEmitter = new _reactNative.NativeEventEmitter((0, _internal.getIosModule)());
|
|
139
130
|
return eventEmitter.addListener('iap-promoted-product', listener);
|
|
140
131
|
}
|
|
141
|
-
|
|
142
132
|
return null;
|
|
143
133
|
};
|
|
134
|
+
|
|
144
135
|
/**
|
|
145
136
|
* Updated transactions for iOS Sk2
|
|
146
137
|
* Register a callback that gets called when the store has any updates to transactions related to purchases that have not yet been finished, consumed or acknowledged.
|
|
@@ -183,18 +174,13 @@ const App = () => {
|
|
|
183
174
|
*
|
|
184
175
|
* @platform iOS (Sk2)
|
|
185
176
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
177
|
exports.promotedProductListener = promotedProductListener;
|
|
189
|
-
|
|
190
178
|
const transactionListener = listener => {
|
|
191
179
|
if (_internal.isIos && (0, _iap.isIosStorekit2)()) {
|
|
192
180
|
const eventEmitter = new _reactNative.NativeEventEmitter((0, _internal.getIosModule)());
|
|
193
181
|
return eventEmitter.addListener('iap-transaction-updated', listener);
|
|
194
182
|
}
|
|
195
|
-
|
|
196
183
|
return null;
|
|
197
184
|
};
|
|
198
|
-
|
|
199
185
|
exports.transactionListener = transactionListener;
|
|
200
186
|
//# sourceMappingURL=eventEmitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["purchaseUpdatedListener","listener","eventEmitter","NativeEventEmitter","getNativeModule","proxyListener","isIosStorekit2","event","transactionSk2ToPurchaseMap","emitterSubscription","addListener","purchaseErrorListener","promotedProductListener","isIos","getIosModule","transactionListener"],"sourceRoot":"../../src","sources":["eventEmitter.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_appleSk","_iap","_internal","purchaseUpdatedListener","listener","eventEmitter","NativeEventEmitter","getNativeModule","proxyListener","isIosStorekit2","event","transactionSk2ToPurchaseMap","emitterSubscription","addListener","exports","purchaseErrorListener","promotedProductListener","isIos","getIosModule","transactionListener"],"sourceRoot":"../../src","sources":["eventEmitter.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,uBAAuB,GAClCC,QAAmC,IAChC;EACH,MAAMC,YAAY,GAAG,IAAIC,+BAAkB,CAAC,IAAAC,yBAAe,GAAE,CAAC;EAC9D,MAAMC,aAAa,GAAG,IAAAC,mBAAc,GAAE,GACjCC,KAAe,IAAK;IACnBN,QAAQ,CAAC,IAAAO,oCAA2B,EAACD,KAAK,CAAQ,CAAC;EACrD,CAAC,GACDN,QAAQ;EACZ,MAAMQ,mBAAmB,GAAGP,YAAY,CAACQ,WAAW,CAClD,kBAAkB,EAClBL,aAAa,CACd;EAED,OAAOI,mBAAmB;AAC5B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAhCAE,OAAA,CAAAX,uBAAA,GAAAA,uBAAA;AAiCO,MAAMY,qBAAqB,GAChCX,QAAwC,IAChB;EACxB,MAAMC,YAAY,GAAG,IAAIC,+BAAkB,CAAC,IAAAC,yBAAe,GAAE,CAAC;EAC9D,OAAOF,YAAY,CAACQ,WAAW,CAAC,gBAAgB,EAAET,QAAQ,CAAC;AAC7D,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlCAU,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAmCO,MAAMC,uBAAuB,GAAIZ,QAAoB,IAAK;EAC/D,IAAIa,eAAK,IAAI,CAAC,IAAAR,mBAAc,GAAE,EAAE;IAC9B,MAAMJ,YAAY,GAAG,IAAIC,+BAAkB,CAAC,IAAAY,sBAAY,GAAE,CAAC;IAC3D,OAAOb,YAAY,CAACQ,WAAW,CAAC,sBAAsB,EAAET,QAAQ,CAAC;EACnE;EAEA,OAAO,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAzCAU,OAAA,CAAAE,uBAAA,GAAAA,uBAAA;AA0CO,MAAMG,mBAAmB,GAC9Bf,QAA2C,IACxC;EACH,IAAIa,eAAK,IAAI,IAAAR,mBAAc,GAAE,EAAE;IAC7B,MAAMJ,YAAY,GAAG,IAAIC,+BAAkB,CAAC,IAAAY,sBAAY,GAAE,CAAC;IAC3D,OAAOb,YAAY,CAACQ,WAAW,CAAC,yBAAyB,EAAET,QAAQ,CAAC;EACtE;EAEA,OAAO,IAAI;AACb,CAAC;AAACU,OAAA,CAAAK,mBAAA,GAAAA,mBAAA"}
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _useIAP = require("./useIAP");
|
|
8
|
-
|
|
9
7
|
Object.keys(_useIAP).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _useIAP[key]) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_useIAP","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useIAP = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _iap = require("../iap");
|
|
11
|
-
|
|
12
9
|
var _withIAPContext = require("./withIAPContext");
|
|
13
|
-
|
|
14
10
|
const useIAP = () => {
|
|
15
11
|
const {
|
|
16
12
|
connected,
|
|
@@ -57,7 +53,6 @@ const useIAP = () => {
|
|
|
57
53
|
isConsumable,
|
|
58
54
|
developerPayloadAndroid
|
|
59
55
|
} = _ref3;
|
|
60
|
-
|
|
61
56
|
try {
|
|
62
57
|
return await (0, _iap.finishTransaction)({
|
|
63
58
|
purchase,
|
|
@@ -70,7 +65,6 @@ const useIAP = () => {
|
|
|
70
65
|
if (purchase.productId === (currentPurchase === null || currentPurchase === void 0 ? void 0 : currentPurchase.productId)) {
|
|
71
66
|
setCurrentPurchase(undefined);
|
|
72
67
|
}
|
|
73
|
-
|
|
74
68
|
if (purchase.productId === (currentPurchaseError === null || currentPurchaseError === void 0 ? void 0 : currentPurchaseError.productId)) {
|
|
75
69
|
setCurrentPurchaseError(undefined);
|
|
76
70
|
}
|
|
@@ -95,6 +89,5 @@ const useIAP = () => {
|
|
|
95
89
|
requestSubscription: _iap.requestSubscription
|
|
96
90
|
};
|
|
97
91
|
};
|
|
98
|
-
|
|
99
92
|
exports.useIAP = useIAP;
|
|
100
93
|
//# sourceMappingURL=useIAP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIAP","connected","products","promotedProductsIOS","subscriptions","purchaseHistory","availablePurchases","currentPurchase","currentPurchaseError","initConnectionError","setProducts","setSubscriptions","setAvailablePurchases","setPurchaseHistory","setCurrentPurchase","setCurrentPurchaseError","useIAPContext","getProducts","useCallback","skus","iapGetProducts","getSubscriptions","iapGetSubscriptions","getAvailablePurchases","iapGetAvailablePurchases","getPurchaseHistory","iapGetPurchaseHistory","finishTransaction","purchase","isConsumable","developerPayloadAndroid","iapFinishTransaction","err","productId","undefined","requestPurchase","iapRequestPurchase","requestSubscription","iapRequestSubscription"],"sourceRoot":"../../../src","sources":["hooks/useIAP.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_react","require","_iap","_withIAPContext","useIAP","connected","products","promotedProductsIOS","subscriptions","purchaseHistory","availablePurchases","currentPurchase","currentPurchaseError","initConnectionError","setProducts","setSubscriptions","setAvailablePurchases","setPurchaseHistory","setCurrentPurchase","setCurrentPurchaseError","useIAPContext","getProducts","useCallback","_ref","skus","iapGetProducts","getSubscriptions","_ref2","iapGetSubscriptions","getAvailablePurchases","iapGetAvailablePurchases","getPurchaseHistory","iapGetPurchaseHistory","finishTransaction","_ref3","purchase","isConsumable","developerPayloadAndroid","iapFinishTransaction","err","productId","undefined","requestPurchase","iapRequestPurchase","requestSubscription","iapRequestSubscription","exports"],"sourceRoot":"../../../src","sources":["hooks/useIAP.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAYA,IAAAE,eAAA,GAAAF,OAAA;AA6BO,MAAMG,MAAM,GAAGA,CAAA,KAAkB;EACtC,MAAM;IACJC,SAAS;IACTC,QAAQ;IACRC,mBAAmB;IACnBC,aAAa;IACbC,eAAe;IACfC,kBAAkB;IAClBC,eAAe;IACfC,oBAAoB;IACpBC,mBAAmB;IACnBC,WAAW;IACXC,gBAAgB;IAChBC,qBAAqB;IACrBC,kBAAkB;IAClBC,kBAAkB;IAClBC;EACF,CAAC,GAAG,IAAAC,6BAAa,GAAE;EAEnB,MAAMC,WAAW,GAAG,IAAAC,kBAAW,EAC7B,MAAAC,IAAA,IAAmD;IAAA,IAA5C;MAACC;IAAsB,CAAC,GAAAD,IAAA;IAC7BT,WAAW,CAAC,MAAM,IAAAW,gBAAc,EAAC;MAACD;IAAI,CAAC,CAAC,CAAC;EAC3C,CAAC,EACD,CAACV,WAAW,CAAC,CACd;EAED,MAAMY,gBAAgB,GAAG,IAAAJ,kBAAW,EAClC,MAAAK,KAAA,IAAmD;IAAA,IAA5C;MAACH;IAAsB,CAAC,GAAAG,KAAA;IAC7BZ,gBAAgB,CAAC,MAAM,IAAAa,qBAAmB,EAAC;MAACJ;IAAI,CAAC,CAAC,CAAC;EACrD,CAAC,EACD,CAACT,gBAAgB,CAAC,CACnB;EAED,MAAMc,qBAAqB,GAAG,IAAAP,kBAAW,EAAC,YAA2B;IACnEN,qBAAqB,CAAC,MAAM,IAAAc,0BAAwB,GAAE,CAAC;EACzD,CAAC,EAAE,CAACd,qBAAqB,CAAC,CAAC;EAE3B,MAAMe,kBAAkB,GAAG,IAAAT,kBAAW,EAAC,YAA2B;IAChEL,kBAAkB,CAAC,MAAM,IAAAe,uBAAqB,GAAE,CAAC;EACnD,CAAC,EAAE,CAACf,kBAAkB,CAAC,CAAC;EAExB,MAAMgB,iBAAiB,GAAG,IAAAX,kBAAW,EACnC,MAAAY,KAAA,IAQyD;IAAA,IARlD;MACLC,QAAQ;MACRC,YAAY;MACZC;IAKF,CAAC,GAAAH,KAAA;IACC,IAAI;MACF,OAAO,MAAM,IAAAI,sBAAoB,EAAC;QAChCH,QAAQ;QACRC,YAAY;QACZC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOE,GAAG,EAAE;MACZ,MAAMA,GAAG;IACX,CAAC,SAAS;MACR,IAAIJ,QAAQ,CAACK,SAAS,MAAK7B,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAE6B,SAAS,GAAE;QACrDtB,kBAAkB,CAACuB,SAAS,CAAC;MAC/B;MAEA,IAAIN,QAAQ,CAACK,SAAS,MAAK5B,oBAAoB,aAApBA,oBAAoB,uBAApBA,oBAAoB,CAAE4B,SAAS,GAAE;QAC1DrB,uBAAuB,CAACsB,SAAS,CAAC;MACpC;IACF;EACF,CAAC,EACD,CACE9B,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAE6B,SAAS,EAC1B5B,oBAAoB,aAApBA,oBAAoB,uBAApBA,oBAAoB,CAAE4B,SAAS,EAC/BtB,kBAAkB,EAClBC,uBAAuB,CACxB,CACF;EAED,OAAO;IACLd,SAAS;IACTC,QAAQ;IACRC,mBAAmB;IACnBC,aAAa;IACbC,eAAe;IACfC,kBAAkB;IAClBC,eAAe;IACfC,oBAAoB;IACpBC,mBAAmB;IACnBoB,iBAAiB;IACjBZ,WAAW;IACXK,gBAAgB;IAChBG,qBAAqB;IACrBE,kBAAkB;IAClBW,eAAe,EAAEC,oBAAkB;IACnCC,mBAAmB,EAAEC;EACvB,CAAC;AACH,CAAC;AAACC,OAAA,CAAA1C,MAAA,GAAAA,MAAA"}
|
|
@@ -5,30 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useIAPContext = useIAPContext;
|
|
7
7
|
exports.withIAPContext = withIAPContext;
|
|
8
|
-
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
|
|
11
9
|
var _eventEmitter = require("../eventEmitter");
|
|
12
|
-
|
|
13
10
|
var _iap = require("../iap");
|
|
14
|
-
|
|
15
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
-
|
|
17
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
|
-
|
|
19
13
|
// @ts-ignore
|
|
20
14
|
const IAPContext = /*#__PURE__*/_react.default.createContext(null);
|
|
21
|
-
|
|
22
15
|
function useIAPContext() {
|
|
23
16
|
const ctx = (0, _react.useContext)(IAPContext);
|
|
24
|
-
|
|
25
17
|
if (!ctx) {
|
|
26
18
|
throw new Error('You need wrap your app with withIAPContext HOC');
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
return ctx;
|
|
30
21
|
}
|
|
31
|
-
|
|
32
22
|
function withIAPContext(Component) {
|
|
33
23
|
return function WrapperComponent(props) {
|
|
34
24
|
const [connected, setConnected] = (0, _react.useState)(false);
|
|
@@ -69,7 +59,6 @@ function withIAPContext(Component) {
|
|
|
69
59
|
if (!connected) {
|
|
70
60
|
return;
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
const purchaseUpdateSubscription = (0, _eventEmitter.purchaseUpdatedListener)(async purchase => {
|
|
74
63
|
setCurrentPurchaseError(undefined);
|
|
75
64
|
setCurrentPurchase(purchase);
|