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 CHANGED
@@ -1,7 +1,8 @@
1
1
  # ![image](https://user-images.githubusercontent.com/27461460/75094417-20321b00-55ce-11ea-8de7-a1df42a4b7df.png)
2
2
 
3
3
  [![Version](http://img.shields.io/npm/v/react-native-iap.svg?style=flat-square)](https://npmjs.org/package/react-native-iap)
4
- <!-- [![Next](https://img.shields.io/npm/v/react-native-iap/next.svg?style=flat-square)](https://npmjs.org/package/react-native-iap) -->
4
+ [![Next Version](https://img.shields.io/npm/v/react-native-iap/next)](https://npmjs.org/package/react-native-iap)
5
+
5
6
  [![Download](http://img.shields.io/npm/dm/react-native-iap.svg?style=flat-square)](https://npmjs.org/package/react-native-iap)
6
7
  [![CI](https://github.com/dooboolab/react-native-iap/actions/workflows/ci.yml/badge.svg)](https://github.com/dooboolab/react-native-iap/actions/workflows/ci.yml)
7
8
  [![document](https://github.com/dooboolab/react-native-iap/actions/workflows/deploy-document.yml/badge.svg)](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
- - Current module is ported to [expo-iap](https://www.npmjs.com/package/expo-iap) which share the same codebase but different environment. This is currently experimental but you can use it in expo managed workflow. The source code is maintained in branch [expo](https://github.com/dooboolab/react-native-iap/tree/expo).
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: String = skuArr.getString(i)
204
- skuList.add(
205
- QueryProductDetailsParams.Product.newBuilder().setProductId(sku)
206
- .setProductType(type).build()
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]) // TODO: should be a list
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?, // New optional parameter in V5, TODO: should it be an array?
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 != null && (
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 != null && prorationMode != -1) {
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.SkuType.SUBS) {
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?, // New optional parameter in V5 (added to maintain interface consistency)
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: String = skuArr.getString(i)
200
- skuList.add(sku)
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?, // New optional parameter in V5 (added to maintain interface consistency)
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
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "9.0.0-beta3",
4
- "packageManager": "yarn@3.2.0",
3
+ "version": "9.0.0-beta6",
5
4
  "description": "React Native In App Purchase Module.",
6
5
  "main": "index.js",
7
6
  "types": "index.d.ts",
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 ? undefined : _g;
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) {
@@ -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
- obfuscatedAccountIdAndroid: string | undefined;
151
- obfuscatedProfileIdAndroid: string | undefined;
152
- selectedOfferIndex?: number | undefined;
150
+ selectedOfferIndex: number | undefined;
153
151
  }
Binary file