react-native-iap 12.8.5 → 12.9.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 +58 -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 +3 -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 +19 -29
- 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 +3 -5
- 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 +16 -22
- 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 +9 -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 +1 -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 +18 -17
- package/plugin/build/withIAP.d.ts +1 -1
- package/src/hooks/withIAPContext.tsx +1 -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,12 +76,12 @@ 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
|
}
|
|
@@ -100,7 +100,7 @@ class RNIapModule(
|
|
|
100
100
|
if (billingClientCache?.isReady == true) {
|
|
101
101
|
Log.i(
|
|
102
102
|
TAG,
|
|
103
|
-
"Already initialized, you should only call initConnection() once when your app starts"
|
|
103
|
+
"Already initialized, you should only call initConnection() once when your app starts",
|
|
104
104
|
)
|
|
105
105
|
promise.safeResolve(true)
|
|
106
106
|
return
|
|
@@ -118,7 +118,7 @@ class RNIapModule(
|
|
|
118
118
|
override fun onBillingServiceDisconnected() {
|
|
119
119
|
Log.i(TAG, "Billing service disconnected")
|
|
120
120
|
}
|
|
121
|
-
}
|
|
121
|
+
},
|
|
122
122
|
)
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -135,11 +135,11 @@ class RNIapModule(
|
|
|
135
135
|
private fun consumeItems(
|
|
136
136
|
purchases: List<Purchase>,
|
|
137
137
|
promise: Promise,
|
|
138
|
-
expectedResponseCode: Int = BillingClient.BillingResponseCode.OK
|
|
138
|
+
expectedResponseCode: Int = BillingClient.BillingResponseCode.OK,
|
|
139
139
|
) {
|
|
140
140
|
for (purchase in purchases) {
|
|
141
141
|
ensureConnection(
|
|
142
|
-
promise
|
|
142
|
+
promise,
|
|
143
143
|
) { billingClient ->
|
|
144
144
|
val consumeParams =
|
|
145
145
|
ConsumeParams.newBuilder().setPurchaseToken(purchase.purchaseToken)
|
|
@@ -149,7 +149,7 @@ class RNIapModule(
|
|
|
149
149
|
if (billingResult.responseCode != expectedResponseCode) {
|
|
150
150
|
PlayUtils.rejectPromiseWithBillingError(
|
|
151
151
|
promise,
|
|
152
|
-
billingResult.responseCode
|
|
152
|
+
billingResult.responseCode,
|
|
153
153
|
)
|
|
154
154
|
return@ConsumeResponseListener
|
|
155
155
|
}
|
|
@@ -164,12 +164,12 @@ class RNIapModule(
|
|
|
164
164
|
@ReactMethod
|
|
165
165
|
fun flushFailedPurchasesCachedAsPending(promise: Promise) {
|
|
166
166
|
ensureConnection(
|
|
167
|
-
promise
|
|
167
|
+
promise,
|
|
168
168
|
) { billingClient ->
|
|
169
169
|
billingClient.queryPurchasesAsync(
|
|
170
170
|
QueryPurchasesParams.newBuilder().setProductType(
|
|
171
|
-
BillingClient.ProductType.INAPP
|
|
172
|
-
).build()
|
|
171
|
+
BillingClient.ProductType.INAPP,
|
|
172
|
+
).build(),
|
|
173
173
|
) { billingResult: BillingResult, list: List<Purchase>? ->
|
|
174
174
|
if (!isValidResult(billingResult, promise)) return@queryPurchasesAsync
|
|
175
175
|
if (list == null) {
|
|
@@ -188,7 +188,7 @@ class RNIapModule(
|
|
|
188
188
|
consumeItems(
|
|
189
189
|
pendingPurchases,
|
|
190
190
|
promise,
|
|
191
|
-
BillingClient.BillingResponseCode.ITEM_NOT_OWNED
|
|
191
|
+
BillingClient.BillingResponseCode.ITEM_NOT_OWNED,
|
|
192
192
|
)
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -197,7 +197,7 @@ class RNIapModule(
|
|
|
197
197
|
@ReactMethod
|
|
198
198
|
fun getItemsByType(type: String, skuArr: ReadableArray, promise: Promise) {
|
|
199
199
|
ensureConnection(
|
|
200
|
-
promise
|
|
200
|
+
promise,
|
|
201
201
|
) { billingClient ->
|
|
202
202
|
val skuList = ArrayList<QueryProductDetailsParams.Product>()
|
|
203
203
|
for (i in 0 until skuArr.size()) {
|
|
@@ -205,14 +205,14 @@ class RNIapModule(
|
|
|
205
205
|
skuArr.getString(i)?.let { sku -> // null check for older versions of RN
|
|
206
206
|
skuList.add(
|
|
207
207
|
QueryProductDetailsParams.Product.newBuilder().setProductId(sku)
|
|
208
|
-
.setProductType(type).build()
|
|
208
|
+
.setProductType(type).build(),
|
|
209
209
|
)
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
val params = QueryProductDetailsParams.newBuilder().setProductList(skuList)
|
|
214
214
|
billingClient.queryProductDetailsAsync(
|
|
215
|
-
params.build()
|
|
215
|
+
params.build(),
|
|
216
216
|
) { billingResult: BillingResult, skuDetailsList: List<ProductDetails> ->
|
|
217
217
|
if (!isValidResult(billingResult, promise)) return@queryProductDetailsAsync
|
|
218
218
|
|
|
@@ -230,12 +230,12 @@ class RNIapModule(
|
|
|
230
230
|
skuDetails.oneTimePurchaseOfferDetails?.let {
|
|
231
231
|
oneTimePurchaseOfferDetails.putString(
|
|
232
232
|
"priceCurrencyCode",
|
|
233
|
-
it.priceCurrencyCode
|
|
233
|
+
it.priceCurrencyCode,
|
|
234
234
|
)
|
|
235
235
|
oneTimePurchaseOfferDetails.putString("formattedPrice", it.formattedPrice)
|
|
236
236
|
oneTimePurchaseOfferDetails.putString(
|
|
237
237
|
"priceAmountMicros",
|
|
238
|
-
it.priceAmountMicros.toString()
|
|
238
|
+
it.priceAmountMicros.toString(),
|
|
239
239
|
)
|
|
240
240
|
item.putMap("oneTimePurchaseOfferDetails", oneTimePurchaseOfferDetails)
|
|
241
241
|
}
|
|
@@ -245,15 +245,15 @@ class RNIapModule(
|
|
|
245
245
|
val offerDetails = Arguments.createMap()
|
|
246
246
|
offerDetails.putString(
|
|
247
247
|
"basePlanId",
|
|
248
|
-
subscriptionOfferDetailsItem.basePlanId
|
|
248
|
+
subscriptionOfferDetailsItem.basePlanId,
|
|
249
249
|
)
|
|
250
250
|
offerDetails.putString(
|
|
251
251
|
"offerId",
|
|
252
|
-
subscriptionOfferDetailsItem.offerId
|
|
252
|
+
subscriptionOfferDetailsItem.offerId,
|
|
253
253
|
)
|
|
254
254
|
offerDetails.putString(
|
|
255
255
|
"offerToken",
|
|
256
|
-
subscriptionOfferDetailsItem.offerToken
|
|
256
|
+
subscriptionOfferDetailsItem.offerToken,
|
|
257
257
|
)
|
|
258
258
|
val offerTags = Arguments.createArray()
|
|
259
259
|
subscriptionOfferDetailsItem.offerTags.forEach { offerTag ->
|
|
@@ -266,20 +266,20 @@ class RNIapModule(
|
|
|
266
266
|
val pricingPhase = Arguments.createMap()
|
|
267
267
|
pricingPhase.putString(
|
|
268
268
|
"formattedPrice",
|
|
269
|
-
pricingPhaseItem.formattedPrice
|
|
269
|
+
pricingPhaseItem.formattedPrice,
|
|
270
270
|
)
|
|
271
271
|
pricingPhase.putString(
|
|
272
272
|
"priceCurrencyCode",
|
|
273
|
-
pricingPhaseItem.priceCurrencyCode
|
|
273
|
+
pricingPhaseItem.priceCurrencyCode,
|
|
274
274
|
)
|
|
275
275
|
pricingPhase.putString("billingPeriod", pricingPhaseItem.billingPeriod)
|
|
276
276
|
pricingPhase.putInt(
|
|
277
277
|
"billingCycleCount",
|
|
278
|
-
pricingPhaseItem.billingCycleCount
|
|
278
|
+
pricingPhaseItem.billingCycleCount,
|
|
279
279
|
)
|
|
280
280
|
pricingPhase.putString(
|
|
281
281
|
"priceAmountMicros",
|
|
282
|
-
pricingPhaseItem.priceAmountMicros.toString()
|
|
282
|
+
pricingPhaseItem.priceAmountMicros.toString(),
|
|
283
283
|
)
|
|
284
284
|
pricingPhase.putInt("recurrenceMode", pricingPhaseItem.recurrenceMode)
|
|
285
285
|
|
|
@@ -304,7 +304,7 @@ class RNIapModule(
|
|
|
304
304
|
*/
|
|
305
305
|
private fun isValidResult(
|
|
306
306
|
billingResult: BillingResult,
|
|
307
|
-
promise: Promise
|
|
307
|
+
promise: Promise,
|
|
308
308
|
): Boolean {
|
|
309
309
|
Log.d(TAG, "responseCode: " + billingResult.responseCode)
|
|
310
310
|
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
|
|
@@ -317,13 +317,13 @@ class RNIapModule(
|
|
|
317
317
|
@ReactMethod
|
|
318
318
|
fun getAvailableItemsByType(type: String, promise: Promise) {
|
|
319
319
|
ensureConnection(
|
|
320
|
-
promise
|
|
320
|
+
promise,
|
|
321
321
|
) { billingClient ->
|
|
322
322
|
val items = WritableNativeArray()
|
|
323
323
|
billingClient.queryPurchasesAsync(
|
|
324
324
|
QueryPurchasesParams.newBuilder().setProductType(
|
|
325
|
-
if (type == "subs") BillingClient.ProductType.SUBS else BillingClient.ProductType.INAPP
|
|
326
|
-
).build()
|
|
325
|
+
if (type == "subs") BillingClient.ProductType.SUBS else BillingClient.ProductType.INAPP,
|
|
326
|
+
).build(),
|
|
327
327
|
) { billingResult: BillingResult, purchases: List<Purchase>? ->
|
|
328
328
|
if (!isValidResult(billingResult, promise)) return@queryPurchasesAsync
|
|
329
329
|
purchases?.forEach { purchase ->
|
|
@@ -344,11 +344,11 @@ class RNIapModule(
|
|
|
344
344
|
item.putString("packageNameAndroid", purchase.packageName)
|
|
345
345
|
item.putString(
|
|
346
346
|
"obfuscatedAccountIdAndroid",
|
|
347
|
-
purchase.accountIdentifiers?.obfuscatedAccountId
|
|
347
|
+
purchase.accountIdentifiers?.obfuscatedAccountId,
|
|
348
348
|
)
|
|
349
349
|
item.putString(
|
|
350
350
|
"obfuscatedProfileIdAndroid",
|
|
351
|
-
purchase.accountIdentifiers?.obfuscatedProfileId
|
|
351
|
+
purchase.accountIdentifiers?.obfuscatedProfileId,
|
|
352
352
|
)
|
|
353
353
|
if (type == BillingClient.ProductType.SUBS) {
|
|
354
354
|
item.putBoolean("autoRenewingAndroid", purchase.isAutoRenewing)
|
|
@@ -363,12 +363,12 @@ class RNIapModule(
|
|
|
363
363
|
@ReactMethod
|
|
364
364
|
fun getPurchaseHistoryByType(type: String, promise: Promise) {
|
|
365
365
|
ensureConnection(
|
|
366
|
-
promise
|
|
366
|
+
promise,
|
|
367
367
|
) { billingClient ->
|
|
368
368
|
billingClient.queryPurchaseHistoryAsync(
|
|
369
369
|
QueryPurchaseHistoryParams.newBuilder().setProductType(
|
|
370
|
-
if (type == "subs") BillingClient.ProductType.SUBS else BillingClient.ProductType.INAPP
|
|
371
|
-
).build()
|
|
370
|
+
if (type == "subs") BillingClient.ProductType.SUBS else BillingClient.ProductType.INAPP,
|
|
371
|
+
).build(),
|
|
372
372
|
) {
|
|
373
373
|
billingResult: BillingResult, purchaseHistoryRecordList: MutableList<PurchaseHistoryRecord>? ->
|
|
374
374
|
|
|
@@ -405,7 +405,7 @@ class RNIapModule(
|
|
|
405
405
|
obfuscatedProfileId: String?,
|
|
406
406
|
offerTokenArr: ReadableArray, // New parameter in V5
|
|
407
407
|
isOfferPersonalized: Boolean, // New parameter in V5
|
|
408
|
-
promise: Promise
|
|
408
|
+
promise: Promise,
|
|
409
409
|
) {
|
|
410
410
|
val activity = currentActivity
|
|
411
411
|
if (activity == null) {
|
|
@@ -413,11 +413,11 @@ class RNIapModule(
|
|
|
413
413
|
return
|
|
414
414
|
}
|
|
415
415
|
ensureConnection(
|
|
416
|
-
promise
|
|
416
|
+
promise,
|
|
417
417
|
) { billingClient ->
|
|
418
418
|
PromiseUtils.addPromiseForKey(
|
|
419
419
|
PROMISE_BUY_ITEM,
|
|
420
|
-
promise
|
|
420
|
+
promise,
|
|
421
421
|
)
|
|
422
422
|
if (type == BillingClient.ProductType.SUBS && skuArr.size() != offerTokenArr.size()) {
|
|
423
423
|
val debugMessage =
|
|
@@ -471,7 +471,7 @@ class RNIapModule(
|
|
|
471
471
|
== BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
|
|
472
472
|
) {
|
|
473
473
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
474
|
-
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
|
|
474
|
+
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
|
|
475
475
|
)
|
|
476
476
|
if (type != BillingClient.ProductType.SUBS) {
|
|
477
477
|
val debugMessage =
|
|
@@ -492,27 +492,27 @@ class RNIapModule(
|
|
|
492
492
|
== BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION
|
|
493
493
|
) {
|
|
494
494
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
495
|
-
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION
|
|
495
|
+
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION,
|
|
496
496
|
)
|
|
497
497
|
} else if (prorationMode == BillingFlowParams.ProrationMode.DEFERRED) {
|
|
498
498
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
499
|
-
BillingFlowParams.ProrationMode.DEFERRED
|
|
499
|
+
BillingFlowParams.ProrationMode.DEFERRED,
|
|
500
500
|
)
|
|
501
501
|
} else if (prorationMode
|
|
502
502
|
== BillingFlowParams.ProrationMode.IMMEDIATE_WITH_TIME_PRORATION
|
|
503
503
|
) {
|
|
504
504
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
505
|
-
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION
|
|
505
|
+
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION,
|
|
506
506
|
)
|
|
507
507
|
} else if (prorationMode
|
|
508
508
|
== BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE
|
|
509
509
|
) {
|
|
510
510
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
511
|
-
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE
|
|
511
|
+
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE,
|
|
512
512
|
)
|
|
513
513
|
} else {
|
|
514
514
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
515
|
-
BillingFlowParams.ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY
|
|
515
|
+
BillingFlowParams.ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY,
|
|
516
516
|
)
|
|
517
517
|
}
|
|
518
518
|
}
|
|
@@ -533,17 +533,17 @@ class RNIapModule(
|
|
|
533
533
|
fun acknowledgePurchase(
|
|
534
534
|
token: String,
|
|
535
535
|
developerPayLoad: String?,
|
|
536
|
-
promise: Promise
|
|
536
|
+
promise: Promise,
|
|
537
537
|
) {
|
|
538
538
|
ensureConnection(
|
|
539
|
-
promise
|
|
539
|
+
promise,
|
|
540
540
|
) { billingClient ->
|
|
541
541
|
val acknowledgePurchaseParams =
|
|
542
542
|
AcknowledgePurchaseParams.newBuilder().setPurchaseToken(
|
|
543
|
-
token
|
|
543
|
+
token,
|
|
544
544
|
).build()
|
|
545
545
|
billingClient.acknowledgePurchase(
|
|
546
|
-
acknowledgePurchaseParams
|
|
546
|
+
acknowledgePurchaseParams,
|
|
547
547
|
) { billingResult: BillingResult ->
|
|
548
548
|
if (!isValidResult(billingResult, promise)) return@acknowledgePurchase
|
|
549
549
|
|
|
@@ -562,14 +562,14 @@ class RNIapModule(
|
|
|
562
562
|
fun consumeProduct(
|
|
563
563
|
token: String,
|
|
564
564
|
developerPayLoad: String?,
|
|
565
|
-
promise: Promise
|
|
565
|
+
promise: Promise,
|
|
566
566
|
) {
|
|
567
567
|
val params = ConsumeParams.newBuilder().setPurchaseToken(token).build()
|
|
568
568
|
ensureConnection(
|
|
569
|
-
promise
|
|
569
|
+
promise,
|
|
570
570
|
) { billingClient ->
|
|
571
571
|
billingClient.consumeAsync(
|
|
572
|
-
params
|
|
572
|
+
params,
|
|
573
573
|
) { billingResult: BillingResult, purchaseToken: String? ->
|
|
574
574
|
if (!isValidResult(billingResult, promise)) return@consumeAsync
|
|
575
575
|
|
|
@@ -621,11 +621,11 @@ class RNIapModule(
|
|
|
621
621
|
if (accountIdentifiers != null) {
|
|
622
622
|
item.putString(
|
|
623
623
|
"obfuscatedAccountIdAndroid",
|
|
624
|
-
accountIdentifiers.obfuscatedAccountId
|
|
624
|
+
accountIdentifiers.obfuscatedAccountId,
|
|
625
625
|
)
|
|
626
626
|
item.putString(
|
|
627
627
|
"obfuscatedProfileIdAndroid",
|
|
628
|
-
accountIdentifiers.obfuscatedProfileId
|
|
628
|
+
accountIdentifiers.obfuscatedProfileId,
|
|
629
629
|
)
|
|
630
630
|
}
|
|
631
631
|
promiseItems.pushMap(item.copy())
|
|
@@ -639,7 +639,7 @@ class RNIapModule(
|
|
|
639
639
|
result.putString(
|
|
640
640
|
"extraMessage",
|
|
641
641
|
"The purchases are null. This is a normal behavior if you have requested DEFERRED" +
|
|
642
|
-
" proration. If not please report an issue."
|
|
642
|
+
" proration. If not please report an issue.",
|
|
643
643
|
)
|
|
644
644
|
sendEvent(reactContext, "purchase-updated", result)
|
|
645
645
|
PromiseUtils.resolvePromisesForKey(PROMISE_BUY_ITEM, null)
|
|
@@ -648,14 +648,14 @@ class RNIapModule(
|
|
|
648
648
|
|
|
649
649
|
private fun sendUnconsumedPurchases(promise: Promise) {
|
|
650
650
|
ensureConnection(
|
|
651
|
-
promise
|
|
651
|
+
promise,
|
|
652
652
|
) { billingClient ->
|
|
653
653
|
val types = arrayOf(BillingClient.ProductType.INAPP, BillingClient.ProductType.SUBS)
|
|
654
654
|
for (type in types) {
|
|
655
655
|
billingClient.queryPurchasesAsync(
|
|
656
656
|
QueryPurchasesParams.newBuilder().setProductType(
|
|
657
|
-
type
|
|
658
|
-
).build()
|
|
657
|
+
type,
|
|
658
|
+
).build(),
|
|
659
659
|
) { billingResult: BillingResult, list: List<Purchase> ->
|
|
660
660
|
if (!isValidResult(billingResult, promise)) return@queryPurchasesAsync
|
|
661
661
|
|
|
@@ -688,7 +688,7 @@ class RNIapModule(
|
|
|
688
688
|
private fun sendEvent(
|
|
689
689
|
reactContext: ReactContext,
|
|
690
690
|
eventName: String,
|
|
691
|
-
params: WritableMap
|
|
691
|
+
params: WritableMap?,
|
|
692
692
|
) {
|
|
693
693
|
reactContext
|
|
694
694
|
.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);
|