react-native-iap 9.0.0-beta3 → 9.0.0-beta6
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/README.md +7 -2
- package/android/src/play/java/com/dooboolab/RNIap/RNIapModule.kt +23 -11
- package/android/src/play/java/com/dooboolab/RNIap/RNIapModuleInterface.kt +2 -2
- package/android/src/play/java/com/dooboolab/RNIap/RNIapModuleV4.kt +6 -4
- package/ios/RNIapIos.m +0 -1
- package/package.json +1 -2
- package/src/iap.js +1 -1
- package/src/types/index.d.ts +4 -6
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-3.2.0.cjs +0 -785
- package/.yarnrc.yml +0 -3
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# 
|
|
2
2
|
|
|
3
3
|
[](https://npmjs.org/package/react-native-iap)
|
|
4
|
-
|
|
4
|
+
[](https://npmjs.org/package/react-native-iap)
|
|
5
|
+
|
|
5
6
|
[](https://npmjs.org/package/react-native-iap)
|
|
6
7
|
[](https://github.com/dooboolab/react-native-iap/actions/workflows/ci.yml)
|
|
7
8
|
[](https://github.com/dooboolab/react-native-iap/actions/workflows/deploy-document.yml)
|
|
@@ -20,7 +21,11 @@ Published in [website](https://react-native-iap.dooboolab.com).
|
|
|
20
21
|
|
|
21
22
|
## Announcement
|
|
22
23
|
|
|
23
|
-
-
|
|
24
|
+
- Version `9.0.0` is currently in release candidate. The module migrates android sdk to [play billing library v5](https://qonversion.io/blog/google-play-billing-library-5-0) and iOS sdk to [storekit2](https://developer.apple.com/videos/play/wwdc2021/10114). Our core maintainer [andresesfm](https://github.com/andresesfm) is working hard on this. Please [fund the project](https://opencollective.com/react-native-iap) if you wish to support his effort. The fund goes to maintainers. To try the earlier version please use the `next` package.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
yarn add react-native-iap@next
|
|
28
|
+
```
|
|
24
29
|
|
|
25
30
|
- Version `8.0.0` has finally landed in Jan 28th. Since this is early release, please use it with caution 🚧. We recommend user to use `>=8.0.0` with react-native `>=0.65.1`. The `next` package is no longer updated until we organize the roadmap for `9.0.0`.
|
|
26
31
|
|
|
@@ -200,11 +200,13 @@ class RNIapModule(
|
|
|
200
200
|
val skuList = ArrayList<QueryProductDetailsParams.Product>()
|
|
201
201
|
for (i in 0 until skuArr.size()) {
|
|
202
202
|
if (skuArr.getType(i) == ReadableType.String) {
|
|
203
|
-
val sku
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
.
|
|
207
|
-
|
|
203
|
+
val sku = skuArr.getString(i)
|
|
204
|
+
sku?.let {
|
|
205
|
+
skuList.add(
|
|
206
|
+
QueryProductDetailsParams.Product.newBuilder().setProductId(sku)
|
|
207
|
+
.setProductType(type).build()
|
|
208
|
+
)
|
|
209
|
+
}
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
212
|
val params = QueryProductDetailsParams.newBuilder().setProductList(skuList)
|
|
@@ -319,7 +321,10 @@ class RNIapModule(
|
|
|
319
321
|
for (i in purchases.indices) {
|
|
320
322
|
val purchase = purchases[i]
|
|
321
323
|
val item = WritableNativeMap()
|
|
322
|
-
item.putString("productId", purchase.products[0])
|
|
324
|
+
item.putString("productId", purchase.products[0])// kept for convenience/backward-compatibility. productIds has the complete list
|
|
325
|
+
val products = Arguments.createArray()
|
|
326
|
+
purchase.products.forEach { products.pushString(it) }
|
|
327
|
+
item.putArray("productIds", products)
|
|
323
328
|
item.putString("transactionId", purchase.orderId)
|
|
324
329
|
item.putDouble("transactionDate", purchase.purchaseTime.toDouble())
|
|
325
330
|
item.putString("transactionReceipt", purchase.originalJson)
|
|
@@ -368,6 +373,9 @@ class RNIapModule(
|
|
|
368
373
|
purchaseHistoryRecordList?.forEach { purchase ->
|
|
369
374
|
val item = Arguments.createMap()
|
|
370
375
|
item.putString("productId", purchase.products[0])
|
|
376
|
+
val products = Arguments.createArray()
|
|
377
|
+
purchase.products.forEach { products.pushString(it) }
|
|
378
|
+
item.putArray("productIds", products)
|
|
371
379
|
item.putDouble("transactionDate", purchase.purchaseTime.toDouble())
|
|
372
380
|
item.putString("transactionReceipt", purchase.originalJson)
|
|
373
381
|
item.putString("purchaseToken", purchase.purchaseToken)
|
|
@@ -386,10 +394,10 @@ class RNIapModule(
|
|
|
386
394
|
type: String,
|
|
387
395
|
sku: String, // TODO: should this now be an array?
|
|
388
396
|
purchaseToken: String?,
|
|
389
|
-
prorationMode: Int
|
|
397
|
+
prorationMode: Int,
|
|
390
398
|
obfuscatedAccountId: String?,
|
|
391
399
|
obfuscatedProfileId: String?,
|
|
392
|
-
selectedOfferIndex: Int
|
|
400
|
+
selectedOfferIndex: Int, // New optional parameter in V5, TODO: should it be an array?
|
|
393
401
|
promise: Promise
|
|
394
402
|
) {
|
|
395
403
|
val activity = currentActivity
|
|
@@ -419,7 +427,7 @@ class RNIapModule(
|
|
|
419
427
|
return@ensureConnection
|
|
420
428
|
}
|
|
421
429
|
var productParams = BillingFlowParams.ProductDetailsParams.newBuilder().setProductDetails(selectedSku)
|
|
422
|
-
if (selectedOfferIndex
|
|
430
|
+
if (selectedOfferIndex > -1 && (
|
|
423
431
|
selectedSku.subscriptionOfferDetails?.size
|
|
424
432
|
?: 0
|
|
425
433
|
) > selectedOfferIndex
|
|
@@ -440,14 +448,14 @@ class RNIapModule(
|
|
|
440
448
|
if (obfuscatedProfileId != null) {
|
|
441
449
|
builder.setObfuscatedProfileId(obfuscatedProfileId)
|
|
442
450
|
}
|
|
443
|
-
if (prorationMode !=
|
|
451
|
+
if (prorationMode != -1) {
|
|
444
452
|
if (prorationMode
|
|
445
453
|
== BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
|
|
446
454
|
) {
|
|
447
455
|
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
|
|
448
456
|
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
|
|
449
457
|
)
|
|
450
|
-
if (type != BillingClient.
|
|
458
|
+
if (type != BillingClient.ProductType.SUBS) {
|
|
451
459
|
val debugMessage =
|
|
452
460
|
(
|
|
453
461
|
"IMMEDIATE_AND_CHARGE_PRORATED_PRICE for proration mode only works in" +
|
|
@@ -559,6 +567,7 @@ class RNIapModule(
|
|
|
559
567
|
.getBillingResponseData(billingResult.responseCode)
|
|
560
568
|
map.putString("code", errorData[0])
|
|
561
569
|
map.putString("message", errorData[1])
|
|
570
|
+
map.putString("purchaseToken",purchaseToken)
|
|
562
571
|
promise.safeResolve(map)
|
|
563
572
|
}
|
|
564
573
|
}
|
|
@@ -584,6 +593,9 @@ class RNIapModule(
|
|
|
584
593
|
val item = Arguments.createMap()
|
|
585
594
|
val purchase = purchases[i]
|
|
586
595
|
item.putString("productId", purchase.products[0])
|
|
596
|
+
val products = Arguments.createArray()
|
|
597
|
+
purchase.products.forEach { products.pushString(it) }
|
|
598
|
+
item.putArray("productIds", products)
|
|
587
599
|
item.putString("transactionId", purchase.orderId)
|
|
588
600
|
item.putDouble("transactionDate", purchase.purchaseTime.toDouble())
|
|
589
601
|
item.putString("transactionReceipt", purchase.originalJson)
|
|
@@ -20,10 +20,10 @@ interface RNIapModuleInterface {
|
|
|
20
20
|
type: String,
|
|
21
21
|
sku: String,
|
|
22
22
|
purchaseToken: String?,
|
|
23
|
-
prorationMode: Int
|
|
23
|
+
prorationMode: Int,
|
|
24
24
|
obfuscatedAccountId: String?,
|
|
25
25
|
obfuscatedProfileId: String?,
|
|
26
|
-
selectedOfferIndex: Int
|
|
26
|
+
selectedOfferIndex: Int, // New optional parameter in V5 (added to maintain interface consistency)
|
|
27
27
|
promise: Promise
|
|
28
28
|
)
|
|
29
29
|
fun acknowledgePurchase(
|
|
@@ -196,8 +196,10 @@ class RNIapModuleV4(
|
|
|
196
196
|
val skuList = ArrayList<String>()
|
|
197
197
|
for (i in 0 until skuArr.size()) {
|
|
198
198
|
if (skuArr.getType(i) == ReadableType.String) {
|
|
199
|
-
val sku
|
|
200
|
-
|
|
199
|
+
val sku = skuArr.getString(i)
|
|
200
|
+
sku?.let {
|
|
201
|
+
skuList.add(sku)
|
|
202
|
+
}
|
|
201
203
|
}
|
|
202
204
|
}
|
|
203
205
|
val params = SkuDetailsParams.newBuilder()
|
|
@@ -361,10 +363,10 @@ class RNIapModuleV4(
|
|
|
361
363
|
type: String,
|
|
362
364
|
sku: String,
|
|
363
365
|
purchaseToken: String?,
|
|
364
|
-
prorationMode: Int
|
|
366
|
+
prorationMode: Int,
|
|
365
367
|
obfuscatedAccountId: String?,
|
|
366
368
|
obfuscatedProfileId: String?,
|
|
367
|
-
selectedOfferIndex: Int
|
|
369
|
+
selectedOfferIndex: Int, // New optional parameter in V5 (added to maintain interface consistency)
|
|
368
370
|
promise: Promise
|
|
369
371
|
) {
|
|
370
372
|
val activity = currentActivity
|
package/ios/RNIapIos.m
CHANGED
|
@@ -18,7 +18,6 @@ RCT_EXTERN_METHOD(getAvailableItems:
|
|
|
18
18
|
reject:(RCTPromiseRejectBlock)reject)
|
|
19
19
|
RCT_EXTERN_METHOD(buyProduct:
|
|
20
20
|
(NSString*)sku
|
|
21
|
-
appAccountToken:(NSString*)appAccountToken
|
|
22
21
|
andDangerouslyFinishTransactionAutomatically:(BOOL)andDangerouslyFinishTransactionAutomatically
|
|
23
22
|
applicationUsername:(NSString)applicationUsername
|
|
24
23
|
resolve:(RCTPromiseResolveBlock)resolve
|
package/package.json
CHANGED
package/src/iap.js
CHANGED
|
@@ -310,7 +310,7 @@ export var requestPurchase = function (_a) {
|
|
|
310
310
|
* @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise
|
|
311
311
|
*/
|
|
312
312
|
export var requestSubscription = function (_a) {
|
|
313
|
-
var sku = _a.sku, _b = _a.andDangerouslyFinishTransactionAutomaticallyIOS, andDangerouslyFinishTransactionAutomaticallyIOS = _b === void 0 ? false : _b, _c = _a.purchaseTokenAndroid, purchaseTokenAndroid = _c === void 0 ? undefined : _c, _d = _a.prorationModeAndroid, prorationModeAndroid = _d === void 0 ? -1 : _d, _e = _a.obfuscatedAccountIdAndroid, obfuscatedAccountIdAndroid = _e === void 0 ? undefined : _e, _f = _a.obfuscatedProfileIdAndroid, obfuscatedProfileIdAndroid = _f === void 0 ? undefined : _f, _g = _a.selectedOfferIndex, selectedOfferIndex = _g === void 0 ?
|
|
313
|
+
var sku = _a.sku, _b = _a.andDangerouslyFinishTransactionAutomaticallyIOS, andDangerouslyFinishTransactionAutomaticallyIOS = _b === void 0 ? false : _b, _c = _a.purchaseTokenAndroid, purchaseTokenAndroid = _c === void 0 ? undefined : _c, _d = _a.prorationModeAndroid, prorationModeAndroid = _d === void 0 ? -1 : _d, _e = _a.obfuscatedAccountIdAndroid, obfuscatedAccountIdAndroid = _e === void 0 ? undefined : _e, _f = _a.obfuscatedProfileIdAndroid, obfuscatedProfileIdAndroid = _f === void 0 ? undefined : _f, _g = _a.selectedOfferIndex, selectedOfferIndex = _g === void 0 ? -1 : _g;
|
|
314
314
|
return (Platform.select({
|
|
315
315
|
ios: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
316
316
|
return __generator(this, function (_a) {
|
package/src/types/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export declare enum InstallSourceAndroid {
|
|
|
37
37
|
export interface ProductCommon {
|
|
38
38
|
type: 'subs' | 'sub' | 'inapp' | 'iap';
|
|
39
39
|
productId: string;
|
|
40
|
+
productIds?: string[];
|
|
40
41
|
title: string;
|
|
41
42
|
description: string;
|
|
42
43
|
price: string;
|
|
@@ -46,6 +47,7 @@ export interface ProductCommon {
|
|
|
46
47
|
}
|
|
47
48
|
export interface ProductPurchase {
|
|
48
49
|
productId: string;
|
|
50
|
+
productIds?: string[];
|
|
49
51
|
transactionId?: string;
|
|
50
52
|
transactionDate: number;
|
|
51
53
|
transactionReceipt: string;
|
|
@@ -142,12 +144,8 @@ export interface RequestPurchase {
|
|
|
142
144
|
obfuscatedAccountIdAndroid: string | undefined;
|
|
143
145
|
obfuscatedProfileIdAndroid: string | undefined;
|
|
144
146
|
}
|
|
145
|
-
export interface RequestSubscription {
|
|
146
|
-
sku: string;
|
|
147
|
-
andDangerouslyFinishTransactionAutomaticallyIOS: boolean;
|
|
147
|
+
export interface RequestSubscription extends RequestPurchase {
|
|
148
148
|
purchaseTokenAndroid: string | undefined;
|
|
149
149
|
prorationModeAndroid: ProrationModesAndroid;
|
|
150
|
-
|
|
151
|
-
obfuscatedProfileIdAndroid: string | undefined;
|
|
152
|
-
selectedOfferIndex?: number | undefined;
|
|
150
|
+
selectedOfferIndex: number | undefined;
|
|
153
151
|
}
|
package/.yarn/install-state.gz
DELETED
|
Binary file
|