react-native-purchases 7.1.0 → 7.3.0

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", '7.1.0'
27
+ spec.dependency "PurchasesHybridCommon", '7.3.0'
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 '7.1.0'
32
+ versionName '7.3.0'
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:7.1.0'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:7.3.0'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -0,0 +1,19 @@
1
+ package com.revenuecat.purchases.react;
2
+
3
+ class GoogleUpgradeInfo {
4
+ private final String oldProductIdentifier;
5
+ private final Integer prorationMode;
6
+
7
+ public GoogleUpgradeInfo(String oldProductIdentifier, Integer prorationMode) {
8
+ this.oldProductIdentifier = oldProductIdentifier;
9
+ this.prorationMode = prorationMode;
10
+ }
11
+
12
+ public String getOldProductIdentifier() {
13
+ return oldProductIdentifier;
14
+ }
15
+
16
+ public Integer getProrationMode() {
17
+ return prorationMode;
18
+ }
19
+ }
@@ -37,7 +37,6 @@ import java.util.ArrayList;
37
37
  import java.util.HashMap;
38
38
  import java.util.List;
39
39
  import java.util.Map;
40
- import java.util.Set;
41
40
 
42
41
  import kotlin.UninitializedPropertyAccessException;
43
42
 
@@ -46,7 +45,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
46
45
  private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
47
46
  private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
48
47
  public static final String PLATFORM_NAME = "react-native";
49
- public static final String PLUGIN_VERSION = "7.1.0";
48
+ public static final String PLUGIN_VERSION = "7.3.0";
50
49
 
51
50
  private final ReactApplicationContext reactContext;
52
51
 
@@ -145,19 +144,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
145
144
  @Nullable final ReadableMap googleInfo,
146
145
  @Nullable final String presentedOfferingIdentifier,
147
146
  final Promise promise) {
148
- String googleOldProductId = null;
149
- Integer googleProrationMode = null;
150
-
151
- if (googleProductChangeInfo != null) {
152
- // GoogleProductChangeInfo in V6 and later
153
- googleOldProductId = googleProductChangeInfo.hasKey("oldProductIdentifier") ? googleProductChangeInfo.getString("oldProductIdentifier") : null;
154
- googleProrationMode = googleProductChangeInfo.hasKey("prorationMode") ? googleProductChangeInfo.getInt("prorationMode") : null;
155
-
156
- // Legacy UpgradeInfo in V5 and earlier
157
- if (googleOldProductId == null) {
158
- googleOldProductId = googleProductChangeInfo.hasKey("oldSKU") ? googleProductChangeInfo.getString("oldSKU") : null;
159
- }
160
- }
147
+ GoogleUpgradeInfo googleUpgradeInfo = getUpgradeInfo(googleProductChangeInfo);
161
148
 
162
149
  Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
163
150
 
@@ -166,8 +153,8 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
166
153
  productIdentifier,
167
154
  type,
168
155
  null,
169
- googleOldProductId,
170
- googleProrationMode,
156
+ googleUpgradeInfo.getOldProductIdentifier(),
157
+ googleUpgradeInfo.getProrationMode(),
171
158
  googleIsPersonalized,
172
159
  presentedOfferingIdentifier,
173
160
  getOnResult(promise));
@@ -180,27 +167,16 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
180
167
  @Nullable final String discountTimestamp,
181
168
  @Nullable final ReadableMap googleInfo,
182
169
  final Promise promise) {
183
- String googleOldProductId = null;
184
- Integer googleProrationMode = null;
170
+ GoogleUpgradeInfo googleUpgradeInfo = getUpgradeInfo(googleProductChangeInfo);
185
171
 
186
- if (googleProductChangeInfo != null) {
187
- // GoogleProductChangeInfo in V6 and later
188
- googleOldProductId = googleProductChangeInfo.hasKey("oldProductIdentifier") ? googleProductChangeInfo.getString("oldProductIdentifier") : null;
189
- googleProrationMode = googleProductChangeInfo.hasKey("prorationMode") ? googleProductChangeInfo.getInt("prorationMode") : null;
190
-
191
- // Legacy UpgradeInfo in V5 and earlier
192
- if (googleOldProductId == null) {
193
- googleOldProductId = googleProductChangeInfo.hasKey("oldSKU") ? googleProductChangeInfo.getString("oldSKU") : null;
194
- }
195
- }
196
172
  Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
197
173
 
198
174
  CommonKt.purchasePackage(
199
175
  getCurrentActivity(),
200
176
  packageIdentifier,
201
177
  offeringIdentifier,
202
- googleOldProductId,
203
- googleProrationMode,
178
+ googleUpgradeInfo.getOldProductIdentifier(),
179
+ googleUpgradeInfo.getProrationMode(),
204
180
  googleIsPersonalized,
205
181
  getOnResult(promise));
206
182
  }
@@ -213,8 +189,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
213
189
  @Nullable final ReadableMap googleInfo,
214
190
  @Nullable final String presentedOfferingIdentifier,
215
191
  final Promise promise) {
216
- String googleOldProductId = upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null;
217
- Integer googleProrationMode = upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null;
192
+ GoogleUpgradeInfo googleUpgradeInfo = getUpgradeInfo(upgradeInfo);
218
193
 
219
194
  Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
220
195
 
@@ -222,8 +197,8 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
222
197
  getCurrentActivity(),
223
198
  productIdentifer,
224
199
  optionIdentifier,
225
- googleOldProductId,
226
- googleProrationMode,
200
+ googleUpgradeInfo.getOldProductIdentifier(),
201
+ googleUpgradeInfo.getProrationMode(),
227
202
  googleIsPersonalized,
228
203
  presentedOfferingIdentifier,
229
204
  getOnResult(promise));
@@ -514,4 +489,21 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
514
489
  };
515
490
  }
516
491
 
492
+ private static GoogleUpgradeInfo getUpgradeInfo(ReadableMap upgradeInfo) {
493
+ String googleOldProductId = null;
494
+ Integer googleProrationMode = null;
495
+
496
+ if (upgradeInfo != null) {
497
+ // GoogleProductChangeInfo in V6 and later
498
+ googleOldProductId = upgradeInfo.hasKey("oldProductIdentifier") ? upgradeInfo.getString("oldProductIdentifier") : null;
499
+ googleProrationMode = upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null;
500
+
501
+ // Legacy UpgradeInfo in V5 and earlier
502
+ if (googleOldProductId == null) {
503
+ googleOldProductId = upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null;
504
+ }
505
+ }
506
+
507
+ return new GoogleUpgradeInfo(googleOldProductId, googleProrationMode);
508
+ }
517
509
  }
package/ios/RNPurchases.m CHANGED
@@ -470,7 +470,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
470
470
  }
471
471
 
472
472
  - (NSString *)platformFlavorVersion {
473
- return @"7.1.0";
473
+ return @"7.3.0";
474
474
  }
475
475
 
476
476
  @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": "7.1.0",
4
+ "version": "7.3.0",
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",
@@ -95,6 +95,6 @@
95
95
  ]
96
96
  },
97
97
  "dependencies": {
98
- "@revenuecat/purchases-typescript-internal": "7.1.0"
98
+ "@revenuecat/purchases-typescript-internal": "7.3.0"
99
99
  }
100
100
  }
@@ -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/7.1.0/" />
5
+ <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/7.3.0/" />
6
6
  </head>
7
7
  <body>
8
8
  </body>