react-native-purchases 5.13.4 → 6.0.0-beta.1

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.
@@ -24,6 +24,6 @@ Pod::Spec.new do |spec|
24
24
  ]
25
25
 
26
26
  spec.dependency "React-Core"
27
- spec.dependency "PurchasesHybridCommon", '4.14.3'
27
+ spec.dependency "PurchasesHybridCommon", '5.0.0-beta.6'
28
28
  spec.swift_version = '5.0'
29
29
  end
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '5.13.4'
32
+ versionName '6.0.0-beta.1'
33
33
  }
34
34
 
35
35
  buildTypes {
@@ -121,6 +121,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
121
121
  dependencies {
122
122
  //noinspection GradleDynamicVersion
123
123
  api 'com.facebook.react:react-native:+'
124
- implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.14.3'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:5.0.0-beta.6'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -26,6 +26,7 @@ import com.revenuecat.purchases.hybridcommon.OnResultList;
26
26
  import com.revenuecat.purchases.hybridcommon.SubscriberAttributesKt;
27
27
  import com.revenuecat.purchases.hybridcommon.mappers.CustomerInfoMapperKt;
28
28
  import com.revenuecat.purchases.interfaces.UpdatedCustomerInfoListener;
29
+ import com.revenuecat.purchases.models.GoogleProrationMode;
29
30
 
30
31
  import org.jetbrains.annotations.NotNull;
31
32
  import org.json.JSONException;
@@ -127,16 +128,40 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
127
128
 
128
129
  @ReactMethod
129
130
  public void purchaseProduct(final String productIdentifier,
130
- @Nullable final ReadableMap upgradeInfo,
131
+ @Nullable final ReadableMap googleProductChangeInfo,
131
132
  final String type,
132
133
  @Nullable final String discountTimestamp,
134
+ @Nullable final ReadableMap googleInfo,
135
+ @Nullable final String presentedOfferingIdentifier,
133
136
  final Promise promise) {
137
+ String googleOldProductId = null;
138
+ Integer googleProrationMode = null;
139
+
140
+ if (googleProductChangeInfo != null) {
141
+ // GoogleProductChangeInfo in V6 and later
142
+ googleOldProductId = googleProductChangeInfo.hasKey("oldProductIdentifier") ? googleProductChangeInfo.getString("oldProductIdentifier") : null;
143
+ googleProrationMode = googleProductChangeInfo.hasKey("prorationMode") ? googleProductChangeInfo.getInt("prorationMode") : null;
144
+
145
+ // Legacy UpgradeInfo in V5 and earlier
146
+ if (googleOldProductId == null) {
147
+ googleOldProductId = googleProductChangeInfo.hasKey("oldSKU") ? googleProductChangeInfo.getString("oldSKU") : null;
148
+ }
149
+ if (googleProrationMode == null) {
150
+ googleProrationMode = googleProductChangeInfo.hasKey("prorationMode") ? googleProductChangeInfo.getInt("prorationMode") : null;
151
+ }
152
+ }
153
+
154
+ Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
155
+
134
156
  CommonKt.purchaseProduct(
135
157
  getCurrentActivity(),
136
158
  productIdentifier,
137
- upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
138
- upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
139
159
  type,
160
+ null,
161
+ googleOldProductId,
162
+ googleProrationMode,
163
+ googleIsPersonalized,
164
+ presentedOfferingIdentifier,
140
165
  getOnResult(promise));
141
166
  }
142
167
 
@@ -145,13 +170,44 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
145
170
  final String offeringIdentifier,
146
171
  @Nullable final ReadableMap upgradeInfo,
147
172
  @Nullable final String discountTimestamp,
173
+ @Nullable final ReadableMap googleInfo,
148
174
  final Promise promise) {
175
+ String googleOldProductId = upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null;
176
+ Integer googleProrationMode = upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null;
177
+
178
+ Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
179
+
149
180
  CommonKt.purchasePackage(
150
181
  getCurrentActivity(),
151
182
  packageIdentifier,
152
183
  offeringIdentifier,
153
- upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
154
- upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
184
+ googleOldProductId,
185
+ googleProrationMode,
186
+ googleIsPersonalized,
187
+ getOnResult(promise));
188
+ }
189
+
190
+ @ReactMethod
191
+ public void purchaseSubscriptionOption(final String productIdentifer,
192
+ final String optionIdentifier,
193
+ @Nullable final ReadableMap upgradeInfo,
194
+ @Nullable final String discountTimestamp,
195
+ @Nullable final ReadableMap googleInfo,
196
+ @Nullable final String presentedOfferingIdentifier,
197
+ final Promise promise) {
198
+ String googleOldProductId = upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null;
199
+ Integer googleProrationMode = upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null;
200
+
201
+ Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
202
+
203
+ CommonKt.purchaseSubscriptionOption(
204
+ getCurrentActivity(),
205
+ productIdentifer,
206
+ optionIdentifier,
207
+ googleOldProductId,
208
+ googleProrationMode,
209
+ googleIsPersonalized,
210
+ presentedOfferingIdentifier,
155
211
  getOnResult(promise));
156
212
  }
157
213
 
@@ -69,14 +69,17 @@ export interface PurchasesStoreProduct {
69
69
  readonly title: string;
70
70
  /**
71
71
  * Price of the product in the local currency.
72
+ * Contains the price value of defaultOption for Google Play.
72
73
  */
73
74
  readonly price: number;
74
75
  /**
75
76
  * Formatted price of the item, including its currency sign.
77
+ * Contains the formatted price value of defaultOption for Google Play.
76
78
  */
77
79
  readonly priceString: string;
78
80
  /**
79
81
  * Currency code for price and original price.
82
+ * Contains the currency code value of defaultOption for Google Play.
80
83
  */
81
84
  readonly currencyCode: string;
82
85
  /**
@@ -87,6 +90,10 @@ export interface PurchasesStoreProduct {
87
90
  * Collection of discount offers for a product. Null for Android.
88
91
  */
89
92
  readonly discounts: PurchasesStoreProductDiscount[] | null;
93
+ /**
94
+ * Product category.
95
+ */
96
+ readonly productCategory: PRODUCT_CATEGORY | null;
90
97
  /**
91
98
  * Subscription period, specified in ISO 8601 format. For example,
92
99
  * P1W equates to one week, P1M equates to one month,
@@ -95,6 +102,33 @@ export interface PurchasesStoreProduct {
95
102
  * Note: Not available for Amazon.
96
103
  */
97
104
  readonly subscriptionPeriod: string | null;
105
+ /**
106
+ * Default subscription option for a product. Google Play only.
107
+ */
108
+ readonly defaultOption: SubscriptionOption | null;
109
+ /**
110
+ * Collection of subscription options for a product. Google Play only.
111
+ */
112
+ readonly subscriptionOptions: SubscriptionOption[] | null;
113
+ /**
114
+ * Offering identifier the store product was presented from.
115
+ * Null if not using offerings or if fetched directly from store via getProducts.
116
+ */
117
+ readonly presentedOfferingIdentifier: string | null;
118
+ }
119
+ export declare enum PRODUCT_CATEGORY {
120
+ /**
121
+ * A type of product for non-subscription.
122
+ */
123
+ NON_SUBSCRIPTION = "NON_SUBSCRIPTION",
124
+ /**
125
+ * A type of product for subscriptions.
126
+ */
127
+ SUBSCRIPTION = "SUBSCRIPTION",
128
+ /**
129
+ * A type of product for unknowns.
130
+ */
131
+ UNKNOWN = "UNKNOWN"
98
132
  }
99
133
  export interface PurchasesStoreProductDiscount {
100
134
  /**
@@ -238,6 +272,7 @@ export interface PurchasesOfferings {
238
272
  }
239
273
  /**
240
274
  * Holds the information used when upgrading from another sku. For Android use only.
275
+ * @deprecated, use GoogleProductChangeInfo
241
276
  */
242
277
  export interface UpgradeInfo {
243
278
  /**
@@ -249,6 +284,19 @@ export interface UpgradeInfo {
249
284
  */
250
285
  readonly prorationMode?: PRORATION_MODE;
251
286
  }
287
+ /**
288
+ * Holds the information used when upgrading from another sku. For Android use only.
289
+ */
290
+ export interface GoogleProductChangeInfo {
291
+ /**
292
+ * The old product identifier to upgrade from.
293
+ */
294
+ readonly oldProductIdentifier: string;
295
+ /**
296
+ * The [PRORATION_MODE] to use when upgrading the given oldSKU.
297
+ */
298
+ readonly prorationMode?: PRORATION_MODE;
299
+ }
252
300
  /**
253
301
  * Holds the introductory price status
254
302
  */
@@ -299,3 +347,156 @@ export declare enum PRORATION_MODE {
299
347
  */
300
348
  IMMEDIATE_AND_CHARGE_FULL_PRICE = 5
301
349
  }
350
+ /**
351
+ * Contains all details associated with a SubscriptionOption
352
+ * Used only for Google
353
+ */
354
+ export interface SubscriptionOption {
355
+ /**
356
+ * Identifier of the subscription option
357
+ * If this SubscriptionOption represents a base plan, this will be the basePlanId.
358
+ * If it represents an offer, it will be {basePlanId}:{offerId}
359
+ */
360
+ readonly id: string;
361
+ /**
362
+ * Identifier of the StoreProduct associated with this SubscriptionOption
363
+ * This will be {subId}:{basePlanId}
364
+ */
365
+ readonly storeProductId: string;
366
+ /**
367
+ * Identifer of the subscription associated with this SubscriptionOption
368
+ * This will be {subId}
369
+ */
370
+ readonly productId: string;
371
+ /**
372
+ * Pricing phases defining a user's payment plan for the product over time.
373
+ */
374
+ readonly pricingPhases: PricingPhase[];
375
+ /**
376
+ * Tags defined on the base plan or offer. Empty for Amazon.
377
+ */
378
+ readonly tags: string[];
379
+ /**
380
+ * True if this SubscriptionOption represents a subscription base plan (rather than an offer).
381
+ */
382
+ readonly isBasePlan: boolean;
383
+ /**
384
+ * The subscription period of fullPricePhase (after free and intro trials).
385
+ */
386
+ readonly billingPeriod: Period | null;
387
+ /**
388
+ * The full price PricingPhase of the subscription.
389
+ * Looks for the last price phase of the SubscriptionOption.
390
+ */
391
+ readonly fullPricePhase: PricingPhase | null;
392
+ /**
393
+ * The free trial PricingPhase of the subscription.
394
+ * Looks for the first pricing phase of the SubscriptionOption where amountMicros is 0.
395
+ * There can be a freeTrialPhase and an introductoryPhase in the same SubscriptionOption.
396
+ */
397
+ readonly freePhase: PricingPhase | null;
398
+ /**
399
+ * The intro trial PricingPhase of the subscription.
400
+ * Looks for the first pricing phase of the SubscriptionOption where amountMicros is greater than 0.
401
+ * There can be a freeTrialPhase and an introductoryPhase in the same SubscriptionOption.
402
+ */
403
+ readonly introPhase: PricingPhase | null;
404
+ /**
405
+ * Offering identifier the subscription option was presented from
406
+ */
407
+ readonly presentedOfferingIdentifier: string | null;
408
+ }
409
+ /**
410
+ * Contains all the details associated with a PricingPhase
411
+ */
412
+ export interface PricingPhase {
413
+ /**
414
+ * Billing period for which the PricingPhase applies
415
+ */
416
+ readonly billingPeriod: Period;
417
+ /**
418
+ * Recurrence mode of the PricingPhase
419
+ */
420
+ readonly recurrenceMode: RECURRENCE_MODE | null;
421
+ /**
422
+ * Number of cycles for which the pricing phase applies.
423
+ * Null for infiniteRecurring or finiteRecurring recurrence modes.
424
+ */
425
+ readonly billingCycleCount: number | null;
426
+ /**
427
+ * Price of the PricingPhase
428
+ */
429
+ readonly price: Price;
430
+ /**
431
+ * Indicates how the pricing phase is charged for finiteRecurring pricing phases
432
+ */
433
+ readonly offerPaymentMode: OFFER_PAYMENT_MODE | null;
434
+ }
435
+ /**
436
+ * Recurrence mode for a pricing phase
437
+ */
438
+ export declare enum RECURRENCE_MODE {
439
+ INFINITE_RECURRING = 1,
440
+ FINITE_RECURRING = 2,
441
+ NON_RECURRING = 3
442
+ }
443
+ /**
444
+ * Payment mode for offer pricing phases. Google Play only.
445
+ */
446
+ export declare enum OFFER_PAYMENT_MODE {
447
+ FREE_TRIAL = "FREE_TRIAL",
448
+ SINGLE_PAYMENT = "SINGLE_PAYMENT",
449
+ DISCOUNTED_RECURRING_PAYMENT = "DISCOUNTED_RECURRING_PAYMENT"
450
+ }
451
+ /**
452
+ * Contains all the details associated with a Price
453
+ */
454
+ export interface Price {
455
+ /**
456
+ * Formatted price of the item, including its currency sign. For example $3.00
457
+ */
458
+ readonly formatted: string;
459
+ /**
460
+ * Price in micro-units, where 1,000,000 micro-units equal one unit of the currency.
461
+ *
462
+ * For example, if price is "€7.99", price_amount_micros is 7,990,000. This value represents
463
+ * the localized, rounded price for a particular currency.
464
+ */
465
+ readonly amountMicros: number;
466
+ /**
467
+ * Returns ISO 4217 currency code for price and original price.
468
+ *
469
+ * For example, if price is specified in British pounds sterling, price_currency_code is "GBP".
470
+ * If currency code cannot be determined, currency symbol is returned.
471
+ */
472
+ readonly currencyCode: string;
473
+ }
474
+ /**
475
+ * Contains all the details associated with a Period
476
+ */
477
+ export interface Period {
478
+ /**
479
+ * The number of period units: day, week, month, year, unknown
480
+ */
481
+ readonly unit: PERIOD_UNIT;
482
+ /**
483
+ * The increment of time that a subscription period is specified in
484
+ */
485
+ readonly value: number;
486
+ /**
487
+ * Specified in ISO 8601 format. For example, P1W equates to one week,
488
+ * P1M equates to one month, P3M equates to three months, P6M equates to six months,
489
+ * and P1Y equates to one year
490
+ */
491
+ readonly iso8601: string;
492
+ }
493
+ /**
494
+ * Time duration unit for Period.
495
+ */
496
+ export declare enum PERIOD_UNIT {
497
+ DAY = "DAY",
498
+ WEEK = "WEEK",
499
+ MONTH = "MONTH",
500
+ YEAR = "YEAR",
501
+ UNKNOWN = "UNKNOWN"
502
+ }
package/dist/offerings.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRORATION_MODE = exports.INTRO_ELIGIBILITY_STATUS = exports.PACKAGE_TYPE = void 0;
3
+ exports.PERIOD_UNIT = exports.OFFER_PAYMENT_MODE = exports.RECURRENCE_MODE = exports.PRORATION_MODE = exports.PRODUCT_CATEGORY = exports.INTRO_ELIGIBILITY_STATUS = exports.PACKAGE_TYPE = void 0;
4
4
  var PACKAGE_TYPE;
5
5
  (function (PACKAGE_TYPE) {
6
6
  /**
@@ -59,6 +59,21 @@ var INTRO_ELIGIBILITY_STATUS;
59
59
  */
60
60
  INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS["INTRO_ELIGIBILITY_STATUS_NO_INTRO_OFFER_EXISTS"] = 3] = "INTRO_ELIGIBILITY_STATUS_NO_INTRO_OFFER_EXISTS";
61
61
  })(INTRO_ELIGIBILITY_STATUS = exports.INTRO_ELIGIBILITY_STATUS || (exports.INTRO_ELIGIBILITY_STATUS = {}));
62
+ var PRODUCT_CATEGORY;
63
+ (function (PRODUCT_CATEGORY) {
64
+ /**
65
+ * A type of product for non-subscription.
66
+ */
67
+ PRODUCT_CATEGORY["NON_SUBSCRIPTION"] = "NON_SUBSCRIPTION";
68
+ /**
69
+ * A type of product for subscriptions.
70
+ */
71
+ PRODUCT_CATEGORY["SUBSCRIPTION"] = "SUBSCRIPTION";
72
+ /**
73
+ * A type of product for unknowns.
74
+ */
75
+ PRODUCT_CATEGORY["UNKNOWN"] = "UNKNOWN";
76
+ })(PRODUCT_CATEGORY = exports.PRODUCT_CATEGORY || (exports.PRODUCT_CATEGORY = {}));
62
77
  var PRORATION_MODE;
63
78
  (function (PRORATION_MODE) {
64
79
  PRORATION_MODE[PRORATION_MODE["UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY"] = 0] = "UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY";
@@ -90,3 +105,32 @@ var PRORATION_MODE;
90
105
  */
91
106
  PRORATION_MODE[PRORATION_MODE["IMMEDIATE_AND_CHARGE_FULL_PRICE"] = 5] = "IMMEDIATE_AND_CHARGE_FULL_PRICE";
92
107
  })(PRORATION_MODE = exports.PRORATION_MODE || (exports.PRORATION_MODE = {}));
108
+ /**
109
+ * Recurrence mode for a pricing phase
110
+ */
111
+ var RECURRENCE_MODE;
112
+ (function (RECURRENCE_MODE) {
113
+ RECURRENCE_MODE[RECURRENCE_MODE["INFINITE_RECURRING"] = 1] = "INFINITE_RECURRING";
114
+ RECURRENCE_MODE[RECURRENCE_MODE["FINITE_RECURRING"] = 2] = "FINITE_RECURRING";
115
+ RECURRENCE_MODE[RECURRENCE_MODE["NON_RECURRING"] = 3] = "NON_RECURRING";
116
+ })(RECURRENCE_MODE = exports.RECURRENCE_MODE || (exports.RECURRENCE_MODE = {}));
117
+ /**
118
+ * Payment mode for offer pricing phases. Google Play only.
119
+ */
120
+ var OFFER_PAYMENT_MODE;
121
+ (function (OFFER_PAYMENT_MODE) {
122
+ OFFER_PAYMENT_MODE["FREE_TRIAL"] = "FREE_TRIAL";
123
+ OFFER_PAYMENT_MODE["SINGLE_PAYMENT"] = "SINGLE_PAYMENT";
124
+ OFFER_PAYMENT_MODE["DISCOUNTED_RECURRING_PAYMENT"] = "DISCOUNTED_RECURRING_PAYMENT";
125
+ })(OFFER_PAYMENT_MODE = exports.OFFER_PAYMENT_MODE || (exports.OFFER_PAYMENT_MODE = {}));
126
+ /**
127
+ * Time duration unit for Period.
128
+ */
129
+ var PERIOD_UNIT;
130
+ (function (PERIOD_UNIT) {
131
+ PERIOD_UNIT["DAY"] = "DAY";
132
+ PERIOD_UNIT["WEEK"] = "WEEK";
133
+ PERIOD_UNIT["MONTH"] = "MONTH";
134
+ PERIOD_UNIT["YEAR"] = "YEAR";
135
+ PERIOD_UNIT["UNKNOWN"] = "UNKNOWN";
136
+ })(PERIOD_UNIT = exports.PERIOD_UNIT || (exports.PERIOD_UNIT = {}));
@@ -1,6 +1,6 @@
1
1
  import { PURCHASES_ERROR_CODE, UninitializedPurchasesError, UnsupportedPlatformError } from "./errors";
2
2
  import { CustomerInfo, PurchasesEntitlementInfo } from "./customerInfo";
3
- import { PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount } from "./offerings";
3
+ import { PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount, SubscriptionOption, PRODUCT_CATEGORY, GoogleProductChangeInfo } from "./offerings";
4
4
  /**
5
5
  * Listener used on updated customer info
6
6
  * @callback CustomerInfoUpdateListener
@@ -13,6 +13,9 @@ export type MakePurchaseResult = {
13
13
  customerInfo: CustomerInfo;
14
14
  };
15
15
  export type LogHandler = (logLevel: LOG_LEVEL, message: string) => void;
16
+ /**
17
+ * @deprecated, use PRODUCT_CATEGORY
18
+ */
16
19
  export declare enum PURCHASE_TYPE {
17
20
  /**
18
21
  * A type of SKU for in-app products.
@@ -130,8 +133,15 @@ export default class Purchases {
130
133
  * Supported SKU types.
131
134
  * @readonly
132
135
  * @enum {string}
136
+ * @deprecated, use PRODUCT_CATEGORY
133
137
  */
134
138
  static PURCHASE_TYPE: typeof PURCHASE_TYPE;
139
+ /**
140
+ * Supported product categories.
141
+ * @readonly
142
+ * @enum {string}
143
+ */
144
+ static PRODUCT_CATEGORY: typeof PRODUCT_CATEGORY;
135
145
  /**
136
146
  * Enum for billing features.
137
147
  * Currently, these are only relevant for Google Play Android users:
@@ -256,13 +266,13 @@ export default class Purchases {
256
266
  /**
257
267
  * Fetch the product info
258
268
  * @param {String[]} productIdentifiers Array of product identifiers
259
- * @param {String} type Optional type of products to fetch, can be inapp or subs. Subs by default
269
+ * @param {String} type Optional type of products to fetch, can be SUBSCRIPTION or NON_SUBSCRIPTION. SUBSCRIPTION by default
260
270
  * @returns {Promise<PurchasesStoreProduct[]>} A promise containing an array of products. The promise will be rejected
261
271
  * if the products are not properly configured in RevenueCat or if there is another error retrieving them.
262
272
  * Rejections return an error code, and a userInfo object with more information. The promise will also be rejected
263
273
  * if configure has not been called yet.
264
274
  */
265
- static getProducts(productIdentifiers: string[], type?: PURCHASE_TYPE): Promise<PurchasesStoreProduct[]>;
275
+ static getProducts(productIdentifiers: string[], type?: PURCHASE_TYPE | PRODUCT_CATEGORY): Promise<PurchasesStoreProduct[]>;
266
276
  /**
267
277
  * Make a purchase
268
278
  *
@@ -270,17 +280,35 @@ export default class Purchases {
270
280
  * @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU
271
281
  * and the optional prorationMode.
272
282
  * @param {String} type Optional type of product, can be inapp or subs. Subs by default
283
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
284
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
285
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
286
+ * @deprecated, use purchaseStoreProduct instead
287
+ */
288
+ static purchaseProduct(productIdentifier: string, upgradeInfo?: UpgradeInfo | null, type?: PURCHASE_TYPE): Promise<MakePurchaseResult>;
289
+ /**
290
+ * Make a purchase
291
+ *
292
+ * @param {PurchasesStoreProduct} product The product you want to purchase
293
+ * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you
294
+ * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
295
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
296
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
297
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
273
298
  * @returns {Promise<{ productIdentifier: string, customerInfo:CustomerInfo }>} A promise of an object containing
274
299
  * a customer info object and a product identifier. Rejections return an error code,
275
300
  * a boolean indicating if the user cancelled the purchase, and an object with more information. The promise will
276
301
  * also be rejected if configure has not been called yet.
277
302
  */
278
- static purchaseProduct(productIdentifier: string, upgradeInfo?: UpgradeInfo | null, type?: PURCHASE_TYPE): Promise<MakePurchaseResult>;
303
+ static purchaseStoreProduct(product: PurchasesStoreProduct, googleProductChangeInfo?: GoogleProductChangeInfo | null, googleIsPersonalizedPrice?: boolean | null): Promise<MakePurchaseResult>;
279
304
  /**
280
305
  * iOS only. Purchase a product applying a given discount.
281
306
  *
282
307
  * @param {PurchasesStoreProduct} product The product you want to purchase
283
308
  * @param {PurchasesPromotionalOffer} discount Discount to apply to this package. Retrieve this discount using getPromotionalOffer.
309
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
310
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
311
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
284
312
  * @returns {Promise<{ productIdentifier: string, customerInfo:CustomerInfo }>} A promise of an object containing
285
313
  * a customer info object and a product identifier. Rejections return an error code,
286
314
  * a boolean indicating if the user cancelled the purchase, and an object with more information. The promise will be
@@ -291,14 +319,33 @@ export default class Purchases {
291
319
  * Make a purchase
292
320
  *
293
321
  * @param {PurchasesPackage} aPackage The Package you wish to purchase. You can get the Packages by calling getOfferings
294
- * @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU
295
- * and the optional prorationMode.
322
+ * @param {UpgradeInfo} upgradeInfo DEPRECATED. Use googleProductChangeInfo.
323
+ * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you
324
+ * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
325
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
326
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
327
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
328
+ * @returns {Promise<{ productIdentifier: string, customerInfo: CustomerInfo }>} A promise of an object containing
329
+ * a customer info object and a product identifier. Rejections return an error code, a boolean indicating if the
330
+ * user cancelled the purchase, and an object with more information. The promise will be also be rejected if configure
331
+ * has not been called yet.
332
+ */
333
+ static purchasePackage(aPackage: PurchasesPackage, upgradeInfo?: UpgradeInfo | null, googleProductChangeInfo?: GoogleProductChangeInfo | null, googleIsPersonalizedPrice?: boolean | null): Promise<MakePurchaseResult>;
334
+ /**
335
+ * Google only. Make a purchase of a subscriptionOption
336
+ *
337
+ * @param {SubscriptionOption} subscriptionOption The SubscriptionOption you wish to purchase. You can get the SubscriptionOption from StoreProducts by calling getOfferings
338
+ * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you
339
+ * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
340
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
341
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
342
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
296
343
  * @returns {Promise<{ productIdentifier: string, customerInfo: CustomerInfo }>} A promise of an object containing
297
344
  * a customer info object and a product identifier. Rejections return an error code, a boolean indicating if the
298
345
  * user cancelled the purchase, and an object with more information. The promise will be also be rejected if configure
299
346
  * has not been called yet.
300
347
  */
301
- static purchasePackage(aPackage: PurchasesPackage, upgradeInfo?: UpgradeInfo | null): Promise<MakePurchaseResult>;
348
+ static purchaseSubscriptionOption(subscriptionOption: SubscriptionOption, googleProductChangeInfo?: GoogleProductChangeInfo | null, googleIsPersonalizedPrice?: boolean | null): Promise<MakePurchaseResult>;
302
349
  /**
303
350
  * iOS only. Purchase a package applying a given discount.
304
351
  *
@@ -368,7 +415,7 @@ export default class Purchases {
368
415
  * This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation
369
416
  * for subscriptions anytime a sync is needed, like after a successful purchase.
370
417
  *
371
- * @warning This function should only be called if you're not calling purchaseProduct/purchasePackage.
418
+ * @warning This function should only be called if you're not calling purchaseProduct/purchaseStoreProduct/purchasePackage/purchaseSubscriptionOption.
372
419
  * @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
373
420
  * syncing purchases.
374
421
  */
package/dist/purchases.js CHANGED
@@ -60,6 +60,9 @@ eventEmitter.addListener("Purchases-LogHandlerEvent", function (_a) {
60
60
  var logLevelEnum = LOG_LEVEL[logLevel];
61
61
  customLogHandler(logLevelEnum, message);
62
62
  });
63
+ /**
64
+ * @deprecated, use PRODUCT_CATEGORY
65
+ */
63
66
  var PURCHASE_TYPE;
64
67
  (function (PURCHASE_TYPE) {
65
68
  /**
@@ -272,14 +275,14 @@ var Purchases = /** @class */ (function () {
272
275
  /**
273
276
  * Fetch the product info
274
277
  * @param {String[]} productIdentifiers Array of product identifiers
275
- * @param {String} type Optional type of products to fetch, can be inapp or subs. Subs by default
278
+ * @param {String} type Optional type of products to fetch, can be SUBSCRIPTION or NON_SUBSCRIPTION. SUBSCRIPTION by default
276
279
  * @returns {Promise<PurchasesStoreProduct[]>} A promise containing an array of products. The promise will be rejected
277
280
  * if the products are not properly configured in RevenueCat or if there is another error retrieving them.
278
281
  * Rejections return an error code, and a userInfo object with more information. The promise will also be rejected
279
282
  * if configure has not been called yet.
280
283
  */
281
284
  Purchases.getProducts = function (productIdentifiers, type) {
282
- if (type === void 0) { type = PURCHASE_TYPE.SUBS; }
285
+ if (type === void 0) { type = offerings_1.PRODUCT_CATEGORY.SUBSCRIPTION; }
283
286
  return __awaiter(this, void 0, void 0, function () {
284
287
  return __generator(this, function (_a) {
285
288
  switch (_a.label) {
@@ -298,20 +301,49 @@ var Purchases = /** @class */ (function () {
298
301
  * @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU
299
302
  * and the optional prorationMode.
300
303
  * @param {String} type Optional type of product, can be inapp or subs. Subs by default
304
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
305
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
306
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
307
+ * @deprecated, use purchaseStoreProduct instead
308
+ */
309
+ Purchases.purchaseProduct = function (productIdentifier, upgradeInfo, type) {
310
+ if (type === void 0) { type = PURCHASE_TYPE.SUBS; }
311
+ return __awaiter(this, void 0, void 0, function () {
312
+ return __generator(this, function (_a) {
313
+ switch (_a.label) {
314
+ case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
315
+ case 1:
316
+ _a.sent();
317
+ return [2 /*return*/, RNPurchases.purchaseProduct(productIdentifier, upgradeInfo, type, null, null, null).catch(function (error) {
318
+ error.userCancelled = error.code === errors_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
319
+ throw error;
320
+ })];
321
+ }
322
+ });
323
+ });
324
+ };
325
+ /**
326
+ * Make a purchase
327
+ *
328
+ * @param {PurchasesStoreProduct} product The product you want to purchase
329
+ * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you
330
+ * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
331
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
332
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
333
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
301
334
  * @returns {Promise<{ productIdentifier: string, customerInfo:CustomerInfo }>} A promise of an object containing
302
335
  * a customer info object and a product identifier. Rejections return an error code,
303
336
  * a boolean indicating if the user cancelled the purchase, and an object with more information. The promise will
304
337
  * also be rejected if configure has not been called yet.
305
338
  */
306
- Purchases.purchaseProduct = function (productIdentifier, upgradeInfo, type) {
307
- if (type === void 0) { type = PURCHASE_TYPE.SUBS; }
339
+ Purchases.purchaseStoreProduct = function (product, googleProductChangeInfo, googleIsPersonalizedPrice) {
308
340
  return __awaiter(this, void 0, void 0, function () {
309
341
  return __generator(this, function (_a) {
310
342
  switch (_a.label) {
311
343
  case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
312
344
  case 1:
313
345
  _a.sent();
314
- return [2 /*return*/, RNPurchases.purchaseProduct(productIdentifier, upgradeInfo, type, null).catch(function (error) {
346
+ return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, googleProductChangeInfo, product.productCategory, null, googleIsPersonalizedPrice == null ? null : { isPersonalizedPrice: googleIsPersonalizedPrice }, product.presentedOfferingIdentifier).catch(function (error) {
315
347
  error.userCancelled = error.code === errors_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
316
348
  throw error;
317
349
  })];
@@ -324,6 +356,9 @@ var Purchases = /** @class */ (function () {
324
356
  *
325
357
  * @param {PurchasesStoreProduct} product The product you want to purchase
326
358
  * @param {PurchasesPromotionalOffer} discount Discount to apply to this package. Retrieve this discount using getPromotionalOffer.
359
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
360
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
361
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
327
362
  * @returns {Promise<{ productIdentifier: string, customerInfo:CustomerInfo }>} A promise of an object containing
328
363
  * a customer info object and a product identifier. Rejections return an error code,
329
364
  * a boolean indicating if the user cancelled the purchase, and an object with more information. The promise will be
@@ -339,7 +374,7 @@ var Purchases = /** @class */ (function () {
339
374
  if (typeof discount === "undefined" || discount == null) {
340
375
  throw new Error("A discount is required");
341
376
  }
342
- return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString()).catch(function (error) {
377
+ return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString(), null, product.presentedOfferingIdentifier).catch(function (error) {
343
378
  error.userCancelled = error.code === errors_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
344
379
  throw error;
345
380
  })];
@@ -351,21 +386,57 @@ var Purchases = /** @class */ (function () {
351
386
  * Make a purchase
352
387
  *
353
388
  * @param {PurchasesPackage} aPackage The Package you wish to purchase. You can get the Packages by calling getOfferings
354
- * @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU
355
- * and the optional prorationMode.
389
+ * @param {UpgradeInfo} upgradeInfo DEPRECATED. Use googleProductChangeInfo.
390
+ * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you
391
+ * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
392
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
393
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
394
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
356
395
  * @returns {Promise<{ productIdentifier: string, customerInfo: CustomerInfo }>} A promise of an object containing
357
396
  * a customer info object and a product identifier. Rejections return an error code, a boolean indicating if the
358
397
  * user cancelled the purchase, and an object with more information. The promise will be also be rejected if configure
359
398
  * has not been called yet.
360
399
  */
361
- Purchases.purchasePackage = function (aPackage, upgradeInfo) {
400
+ Purchases.purchasePackage = function (aPackage, upgradeInfo, googleProductChangeInfo, googleIsPersonalizedPrice) {
362
401
  return __awaiter(this, void 0, void 0, function () {
363
402
  return __generator(this, function (_a) {
364
403
  switch (_a.label) {
365
404
  case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
366
405
  case 1:
367
406
  _a.sent();
368
- return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.offeringIdentifier, upgradeInfo, null).catch(function (error) {
407
+ return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.offeringIdentifier, googleProductChangeInfo || upgradeInfo, null, googleIsPersonalizedPrice == null ? null : { isPersonalizedPrice: googleIsPersonalizedPrice }).catch(function (error) {
408
+ error.userCancelled = error.code === errors_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
409
+ throw error;
410
+ })];
411
+ }
412
+ });
413
+ });
414
+ };
415
+ /**
416
+ * Google only. Make a purchase of a subscriptionOption
417
+ *
418
+ * @param {SubscriptionOption} subscriptionOption The SubscriptionOption you wish to purchase. You can get the SubscriptionOption from StoreProducts by calling getOfferings
419
+ * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you
420
+ * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode.
421
+ * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU.
422
+ * For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true.
423
+ * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.
424
+ * @returns {Promise<{ productIdentifier: string, customerInfo: CustomerInfo }>} A promise of an object containing
425
+ * a customer info object and a product identifier. Rejections return an error code, a boolean indicating if the
426
+ * user cancelled the purchase, and an object with more information. The promise will be also be rejected if configure
427
+ * has not been called yet.
428
+ */
429
+ Purchases.purchaseSubscriptionOption = function (subscriptionOption, googleProductChangeInfo, googleIsPersonalizedPrice) {
430
+ return __awaiter(this, void 0, void 0, function () {
431
+ return __generator(this, function (_a) {
432
+ switch (_a.label) {
433
+ case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
434
+ case 1:
435
+ _a.sent();
436
+ return [4 /*yield*/, Purchases.throwIfIOSPlatform()];
437
+ case 2:
438
+ _a.sent();
439
+ return [2 /*return*/, RNPurchases.purchaseSubscriptionOption(subscriptionOption.productId, subscriptionOption.id, googleProductChangeInfo, null, googleIsPersonalizedPrice == null ? null : { isPersonalizedPrice: googleIsPersonalizedPrice }, subscriptionOption.presentedOfferingIdentifier).catch(function (error) {
369
440
  error.userCancelled = error.code === errors_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
370
441
  throw error;
371
442
  })];
@@ -535,7 +606,7 @@ var Purchases = /** @class */ (function () {
535
606
  * This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation
536
607
  * for subscriptions anytime a sync is needed, like after a successful purchase.
537
608
  *
538
- * @warning This function should only be called if you're not calling purchaseProduct/purchasePackage.
609
+ * @warning This function should only be called if you're not calling purchaseProduct/purchaseStoreProduct/purchasePackage/purchaseSubscriptionOption.
539
610
  * @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
540
611
  * syncing purchases.
541
612
  */
@@ -1363,8 +1434,15 @@ var Purchases = /** @class */ (function () {
1363
1434
  * Supported SKU types.
1364
1435
  * @readonly
1365
1436
  * @enum {string}
1437
+ * @deprecated, use PRODUCT_CATEGORY
1366
1438
  */
1367
1439
  Purchases.PURCHASE_TYPE = PURCHASE_TYPE;
1440
+ /**
1441
+ * Supported product categories.
1442
+ * @readonly
1443
+ * @enum {string}
1444
+ */
1445
+ Purchases.PRODUCT_CATEGORY = offerings_1.PRODUCT_CATEGORY;
1368
1446
  /**
1369
1447
  * Enum for billing features.
1370
1448
  * Currently, these are only relevant for Google Play Android users:
package/ios/RNPurchases.m CHANGED
@@ -86,6 +86,8 @@ RCT_REMAP_METHOD(purchaseProduct,
86
86
  upgradeInfo:(NSDictionary *)upgradeInfo
87
87
  type:(NSString *)type
88
88
  signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
89
+ googleInfo:(NSDictionary *)googleInfo
90
+ presentedOfferingIdentifier:(NSString *)presentedOfferingIdentifier
89
91
  resolve:(RCTPromiseResolveBlock)resolve
90
92
  reject:(RCTPromiseRejectBlock)reject) {
91
93
  [RCCommonFunctionality purchaseProduct:productIdentifier
@@ -99,6 +101,7 @@ RCT_REMAP_METHOD(purchasePackage,
99
101
  offeringIdentifier:(NSString *)offeringIdentifier
100
102
  upgradeInfo:(NSDictionary *)upgradeInfo
101
103
  signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
104
+ googleInfo:(NSDictionary *)googleInfo
102
105
  resolve:(RCTPromiseResolveBlock)resolve
103
106
  reject:(RCTPromiseRejectBlock)reject) {
104
107
  [RCCommonFunctionality purchasePackage:packageIdentifier
@@ -439,7 +442,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
439
442
  }
440
443
 
441
444
  - (NSString *)platformFlavorVersion {
442
- return @"5.13.4";
445
+ return @"6.0.0-beta.1";
443
446
  }
444
447
 
445
448
  @end
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-purchases",
3
3
  "title": "React Native Purchases",
4
- "version": "5.13.4",
4
+ "version": "6.0.0-beta.1",
5
5
  "description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android. ",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -2,7 +2,7 @@
2
2
  <!DOCTYPE html>
3
3
  <html>
4
4
  <head>
5
- <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.13.4/" />
5
+ <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/6.0.0-beta.1/" />
6
6
  </head>
7
7
  <body>
8
8
  </body>
@@ -680,7 +680,8 @@ global.productStub = {
680
680
  price: 0.99,
681
681
  description: "The best service.",
682
682
  title: "One Month Free Trial",
683
- identifier: "onemonth_freetrial"
683
+ identifier: "onemonth_freetrial",
684
+ productCategory: "SUBSCRIPTION",
684
685
  };
685
686
 
686
687
  global.productsStub = [