react-native-iap 9.0.0-beta2 → 9.0.0-beta5

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.
Binary file
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)
@@ -386,10 +388,10 @@ class RNIapModule(
386
388
  type: String,
387
389
  sku: String, // TODO: should this now be an array?
388
390
  purchaseToken: String?,
389
- prorationMode: Int?,
391
+ prorationMode: Int,
390
392
  obfuscatedAccountId: String?,
391
393
  obfuscatedProfileId: String?,
392
- selectedOfferIndex: Int?, // New optional parameter in V5, TODO: should it be an array?
394
+ selectedOfferIndex: Int, // New optional parameter in V5, TODO: should it be an array?
393
395
  promise: Promise
394
396
  ) {
395
397
  val activity = currentActivity
@@ -419,7 +421,7 @@ class RNIapModule(
419
421
  return@ensureConnection
420
422
  }
421
423
  var productParams = BillingFlowParams.ProductDetailsParams.newBuilder().setProductDetails(selectedSku)
422
- if (selectedOfferIndex != null && (
424
+ if (selectedOfferIndex > -1 && (
423
425
  selectedSku.subscriptionOfferDetails?.size
424
426
  ?: 0
425
427
  ) > selectedOfferIndex
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "9.0.0-beta2",
3
+ "version": "9.0.0-beta5",
4
4
  "packageManager": "yarn@3.2.0",
5
5
  "description": "React Native In App Purchase Module.",
6
6
  "main": "index.js",
package/src/iap.js CHANGED
@@ -148,13 +148,15 @@ var fillProductsAdditionalData = function (products) { return __awaiter(void 0,
148
148
  export var getProducts = function (skus) {
149
149
  return (Platform.select({
150
150
  ios: function () { return __awaiter(void 0, void 0, void 0, function () {
151
+ var products;
151
152
  return __generator(this, function (_a) {
152
153
  switch (_a.label) {
153
- case 0: return [4 /*yield*/, getIosModule()
154
- .getItems(skus)
155
- .filter(function (item) { return skus.includes(item.productId); })
156
- .filter(function (item) { return item.type === 'iap'; })];
157
- case 1: return [2 /*return*/, _a.sent()];
154
+ case 0: return [4 /*yield*/, getIosModule().getItems(skus)];
155
+ case 1:
156
+ products = _a.sent();
157
+ return [2 /*return*/, products.filter(function (item) {
158
+ return skus.includes(item.productId) && item.type === 'iap';
159
+ })];
158
160
  }
159
161
  });
160
162
  }); },
@@ -179,13 +181,15 @@ export var getProducts = function (skus) {
179
181
  export var getSubscriptions = function (skus) {
180
182
  return (Platform.select({
181
183
  ios: function () { return __awaiter(void 0, void 0, void 0, function () {
184
+ var subscriptions;
182
185
  return __generator(this, function (_a) {
183
186
  switch (_a.label) {
184
- case 0: return [4 /*yield*/, getIosModule()
185
- .getItems(skus)
186
- .filter(function (item) { return skus.includes(item.productId); })
187
- .filter(function (item) { return item.type === 'subs'; })];
188
- case 1: return [2 /*return*/, _a.sent()];
187
+ case 0: return [4 /*yield*/, getIosModule().getItems(skus)];
188
+ case 1:
189
+ subscriptions = _a.sent();
190
+ return [2 /*return*/, subscriptions.filter(function (item) {
191
+ return skus.includes(item.productId) && item.type === 'subs';
192
+ })];
189
193
  }
190
194
  });
191
195
  }); },
@@ -306,7 +310,7 @@ export var requestPurchase = function (_a) {
306
310
  * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise
307
311
  */
308
312
  export var requestSubscription = function (_a) {
309
- 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;
310
314
  return (Platform.select({
311
315
  ios: function () { return __awaiter(void 0, void 0, void 0, function () {
312
316
  return __generator(this, function (_a) {
@@ -62,28 +62,6 @@ export interface ProductPurchase {
62
62
  developerPayloadAndroid?: string;
63
63
  obfuscatedAccountIdAndroid?: string;
64
64
  obfuscatedProfileIdAndroid?: string;
65
- title?: string;
66
- description?: string;
67
- productType?: string;
68
- name?: string;
69
- oneTimePurchaseOfferDetails?: {
70
- priceCurrencyCode?: string;
71
- formattedPrice?: string;
72
- priceAmountMicros?: string;
73
- }[];
74
- subscriptionOfferDetails?: {
75
- offerToken?: string[];
76
- pricingPhases: {
77
- pricingPhaseList: {
78
- formattedPrice?: string;
79
- priceCurrencyCode?: string;
80
- billingPeriod?: string;
81
- billingCycleCount?: number;
82
- priceAmountMicros?: string;
83
- recurrenceMode?: number;
84
- };
85
- };
86
- }[];
87
65
  userIdAmazon?: string;
88
66
  userMarketplaceAmazon?: string;
89
67
  userJsonAmazon?: string;
@@ -136,6 +114,26 @@ export interface Subscription extends ProductCommon {
136
114
  introductoryPricePeriodAndroid?: string;
137
115
  subscriptionPeriodAndroid?: string;
138
116
  freeTrialPeriodAndroid?: string;
117
+ productType?: string;
118
+ name?: string;
119
+ oneTimePurchaseOfferDetails?: {
120
+ priceCurrencyCode?: string;
121
+ formattedPrice?: string;
122
+ priceAmountMicros?: string;
123
+ }[];
124
+ subscriptionOfferDetails?: {
125
+ offerToken?: string[];
126
+ pricingPhases: {
127
+ pricingPhaseList: {
128
+ formattedPrice?: string;
129
+ priceCurrencyCode?: string;
130
+ billingPeriod?: string;
131
+ billingCycleCount?: number;
132
+ priceAmountMicros?: string;
133
+ recurrenceMode?: number;
134
+ };
135
+ };
136
+ }[];
139
137
  }
140
138
  export interface RequestPurchase {
141
139
  sku: string;