react-native-iap 8.5.1 → 8.5.2

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/ios/RNIapIos.m CHANGED
@@ -18,9 +18,8 @@ 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
- applicationUsername:(NSString)applicationUsername
22
+ applicationUsername:(NSString*)applicationUsername
24
23
  resolve:(RCTPromiseResolveBlock)resolve
25
24
  reject:(RCTPromiseRejectBlock)reject)
26
25
  RCT_EXTERN_METHOD(buyProductWithOffer:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "8.5.1",
3
+ "version": "8.5.2",
4
4
  "description": "React Native In App Purchase Module.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/src/iap.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as Amazon from './types/amazon';
2
2
  import * as Android from './types/android';
3
3
  import * as Apple from './types/apple';
4
4
  import { EmitterSubscription } from 'react-native';
5
- import { InAppPurchase, InstallSourceAndroid, Product, ProductPurchase, ProrationModesAndroid, PurchaseError, PurchaseResult, Subscription, SubscriptionPurchase } from './types';
5
+ import { InAppPurchase, InstallSourceAndroid, Product, ProductPurchase, PurchaseError, PurchaseResult, RequestPurchase, RequestSubscription, Subscription, SubscriptionPurchase } from './types';
6
6
  export declare const getInstallSourceAndroid: () => InstallSourceAndroid;
7
7
  /**
8
8
  * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.
@@ -50,10 +50,11 @@ export declare const getAvailablePurchases: () => Promise<(InAppPurchase | Subsc
50
50
  * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
51
51
  * @returns {Promise<InAppPurchase>}
52
52
  */
53
- export declare const requestPurchase: (sku: string, appAccountToken: string, andDangerouslyFinishTransactionAutomaticallyIOS?: boolean, obfuscatedAccountIdAndroid?: string | undefined, obfuscatedProfileIdAndroid?: string | undefined, applicationUsername?: string | undefined) => Promise<InAppPurchase>;
53
+ export declare const requestPurchase: ({ sku, andDangerouslyFinishTransactionAutomaticallyIOS, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, applicationUsername, }: RequestPurchase) => Promise<InAppPurchase>;
54
54
  /**
55
55
  * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
56
56
  * @param {string} [sku] The product's sku/ID
57
+ * @param {string} [applicationUsername] The purchaser's user ID
57
58
  * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.
58
59
  * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).
59
60
  * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
@@ -61,7 +62,7 @@ export declare const requestPurchase: (sku: string, appAccountToken: string, and
61
62
  * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
62
63
  * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise
63
64
  */
64
- export declare const requestSubscription: (sku: string, andDangerouslyFinishTransactionAutomaticallyIOS?: boolean, purchaseTokenAndroid?: string | undefined, prorationModeAndroid?: ProrationModesAndroid, obfuscatedAccountIdAndroid?: string | undefined, obfuscatedProfileIdAndroid?: string | undefined) => Promise<SubscriptionPurchase | null>;
65
+ export declare const requestSubscription: ({ sku, andDangerouslyFinishTransactionAutomaticallyIOS, purchaseTokenAndroid, prorationModeAndroid, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, applicationUsername, }: RequestSubscription) => Promise<SubscriptionPurchase | null>;
65
66
  /**
66
67
  * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
67
68
  * @param {string} sku The product's sku/ID
package/src/iap.js CHANGED
@@ -264,11 +264,8 @@ export var getAvailablePurchases = function () {
264
264
  * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
265
265
  * @returns {Promise<InAppPurchase>}
266
266
  */
267
- export var requestPurchase = function (sku, appAccountToken, andDangerouslyFinishTransactionAutomaticallyIOS, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, applicationUsername) {
268
- if (andDangerouslyFinishTransactionAutomaticallyIOS === void 0) { andDangerouslyFinishTransactionAutomaticallyIOS = false; }
269
- if (obfuscatedAccountIdAndroid === void 0) { obfuscatedAccountIdAndroid = undefined; }
270
- if (obfuscatedProfileIdAndroid === void 0) { obfuscatedProfileIdAndroid = undefined; }
271
- if (applicationUsername === void 0) { applicationUsername = undefined; }
267
+ export var requestPurchase = function (_a) {
268
+ var sku = _a.sku, _b = _a.andDangerouslyFinishTransactionAutomaticallyIOS, andDangerouslyFinishTransactionAutomaticallyIOS = _b === void 0 ? false : _b, _c = _a.obfuscatedAccountIdAndroid, obfuscatedAccountIdAndroid = _c === void 0 ? undefined : _c, _d = _a.obfuscatedProfileIdAndroid, obfuscatedProfileIdAndroid = _d === void 0 ? undefined : _d, _e = _a.applicationUsername, applicationUsername = _e === void 0 ? undefined : _e;
272
269
  return (Platform.select({
273
270
  ios: function () { return __awaiter(void 0, void 0, void 0, function () {
274
271
  return __generator(this, function (_a) {
@@ -291,6 +288,7 @@ export var requestPurchase = function (sku, appAccountToken, andDangerouslyFinis
291
288
  /**
292
289
  * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
293
290
  * @param {string} [sku] The product's sku/ID
291
+ * @param {string} [applicationUsername] The purchaser's user ID
294
292
  * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.
295
293
  * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).
296
294
  * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
@@ -298,12 +296,8 @@ export var requestPurchase = function (sku, appAccountToken, andDangerouslyFinis
298
296
  * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
299
297
  * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise
300
298
  */
301
- export var requestSubscription = function (sku, andDangerouslyFinishTransactionAutomaticallyIOS, purchaseTokenAndroid, prorationModeAndroid, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid) {
302
- if (andDangerouslyFinishTransactionAutomaticallyIOS === void 0) { andDangerouslyFinishTransactionAutomaticallyIOS = false; }
303
- if (purchaseTokenAndroid === void 0) { purchaseTokenAndroid = undefined; }
304
- if (prorationModeAndroid === void 0) { prorationModeAndroid = -1; }
305
- if (obfuscatedAccountIdAndroid === void 0) { obfuscatedAccountIdAndroid = undefined; }
306
- if (obfuscatedProfileIdAndroid === void 0) { obfuscatedProfileIdAndroid = undefined; }
299
+ export var requestSubscription = function (_a) {
300
+ 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.applicationUsername, applicationUsername = _g === void 0 ? undefined : _g;
307
301
  return (Platform.select({
308
302
  ios: function () { return __awaiter(void 0, void 0, void 0, function () {
309
303
  return __generator(this, function (_a) {
@@ -313,7 +307,7 @@ export var requestSubscription = function (sku, andDangerouslyFinishTransactionA
313
307
  // eslint-disable-next-line max-len
314
308
  'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.');
315
309
  }
316
- return [2 /*return*/, getIosModule().buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS)];
310
+ return [2 /*return*/, getIosModule().buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, applicationUsername)];
317
311
  });
318
312
  }); },
319
313
  android: function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -123,3 +123,7 @@ export interface RequestPurchase {
123
123
  obfuscatedProfileIdAndroid: string | undefined;
124
124
  selectedOfferIndex: number;
125
125
  }
126
+ export interface RequestSubscription extends RequestPurchase {
127
+ purchaseTokenAndroid: string | undefined;
128
+ prorationModeAndroid: ProrationModesAndroid;
129
+ }