react-native-purchases 9.4.0 → 9.4.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/RNPurchases.podspec +1 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java +8 -8
- package/dist/browser/nativeModule.js +10 -9
- package/dist/browser/simulatedstore/alertHelper.d.ts +5 -0
- package/dist/browser/simulatedstore/alertHelper.js +118 -0
- package/dist/browser/simulatedstore/offeringsLoader.d.ts +9 -0
- package/dist/browser/simulatedstore/offeringsLoader.js +76 -0
- package/dist/browser/simulatedstore/purchaseSimulatedPackageHelper.d.ts +2 -0
- package/dist/browser/simulatedstore/purchaseSimulatedPackageHelper.js +96 -0
- package/ios/RNPurchases.m +1 -1
- package/package.json +3 -3
package/RNPurchases.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -29,7 +29,7 @@ android {
|
|
|
29
29
|
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
30
30
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
31
31
|
versionCode 1
|
|
32
|
-
versionName '9.4.
|
|
32
|
+
versionName '9.4.2'
|
|
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:17.
|
|
124
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:17.6.0'
|
|
125
125
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
126
126
|
}
|
|
@@ -47,7 +47,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
47
47
|
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
|
|
48
48
|
private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
|
|
49
49
|
public static final String PLATFORM_NAME = "react-native";
|
|
50
|
-
public static final String PLUGIN_VERSION = "9.4.
|
|
50
|
+
public static final String PLUGIN_VERSION = "9.4.2";
|
|
51
51
|
|
|
52
52
|
private final ReactApplicationContext reactContext;
|
|
53
53
|
|
|
@@ -88,7 +88,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
88
88
|
boolean shouldShowInAppMessagesAutomatically,
|
|
89
89
|
@Nullable String entitlementVerificationMode,
|
|
90
90
|
boolean pendingTransactionsForPrepaidPlansEnabled,
|
|
91
|
-
boolean diagnosticsEnabled,
|
|
91
|
+
boolean diagnosticsEnabled,
|
|
92
92
|
boolean automaticDeviceIdentifierCollectionEnabled,
|
|
93
93
|
@Nullable String preferredUILocaleOverride) {
|
|
94
94
|
PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
|
|
@@ -176,7 +176,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
CommonKt.purchaseProduct(
|
|
179
|
-
getCurrentActivity(),
|
|
179
|
+
getReactApplicationContext().getCurrentActivity(),
|
|
180
180
|
productIdentifier,
|
|
181
181
|
type,
|
|
182
182
|
null,
|
|
@@ -201,7 +201,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
201
201
|
Map<String, Object> mapPresentedOfferingContext = presentedOfferingContext.toHashMap();
|
|
202
202
|
|
|
203
203
|
CommonKt.purchasePackage(
|
|
204
|
-
getCurrentActivity(),
|
|
204
|
+
getReactApplicationContext().getCurrentActivity(),
|
|
205
205
|
packageIdentifier,
|
|
206
206
|
mapPresentedOfferingContext,
|
|
207
207
|
googleUpgradeInfo.getOldProductIdentifier(),
|
|
@@ -228,7 +228,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
CommonKt.purchaseSubscriptionOption(
|
|
231
|
-
getCurrentActivity(),
|
|
231
|
+
getReactApplicationContext().getCurrentActivity(),
|
|
232
232
|
productIdentifer,
|
|
233
233
|
optionIdentifier,
|
|
234
234
|
googleUpgradeInfo.getOldProductIdentifier(),
|
|
@@ -348,7 +348,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
//================================================================================
|
|
351
|
-
// Virtual Currencies
|
|
351
|
+
// Virtual Currencies
|
|
352
352
|
//================================================================================
|
|
353
353
|
@ReactMethod
|
|
354
354
|
public void getVirtualCurrencies(final Promise promise) {
|
|
@@ -540,7 +540,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
540
540
|
@ReactMethod
|
|
541
541
|
public void showInAppMessages(ReadableArray messageTypes, final Promise promise) {
|
|
542
542
|
if (messageTypes == null) {
|
|
543
|
-
CommonKt.showInAppMessagesIfNeeded(getCurrentActivity());
|
|
543
|
+
CommonKt.showInAppMessagesIfNeeded(getReactApplicationContext().getCurrentActivity());
|
|
544
544
|
} else {
|
|
545
545
|
ArrayList<InAppMessageType> messageTypesList = new ArrayList<>();
|
|
546
546
|
InAppMessageType[] inAppMessageTypes = InAppMessageType.values();
|
|
@@ -556,7 +556,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
556
556
|
Log.e("RNPurchases", "Invalid in-app message type: " + messageTypeInt);
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
-
CommonKt.showInAppMessagesIfNeeded(getCurrentActivity(), messageTypesList);
|
|
559
|
+
CommonKt.showInAppMessagesIfNeeded(getReactApplicationContext().getCurrentActivity(), messageTypesList);
|
|
560
560
|
}
|
|
561
561
|
promise.resolve(null);
|
|
562
562
|
}
|
|
@@ -39,9 +39,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.browserNativeModuleRNPurchases = void 0;
|
|
40
40
|
var purchases_typescript_internal_1 = require("@revenuecat/purchases-typescript-internal");
|
|
41
41
|
var purchases_js_hybrid_mappings_1 = require("@revenuecat/purchases-js-hybrid-mappings");
|
|
42
|
-
var utils_1 = require("./utils");
|
|
43
42
|
var typeGuards_1 = require("./typeGuards");
|
|
44
43
|
var environment_1 = require("../utils/environment");
|
|
44
|
+
var utils_1 = require("./utils");
|
|
45
|
+
var purchaseSimulatedPackageHelper_1 = require("./simulatedstore/purchaseSimulatedPackageHelper");
|
|
45
46
|
var packageVersion = '9.1.0';
|
|
46
47
|
/**
|
|
47
48
|
* Browser implementation of the native module. This will be used in the browser and Expo Go.
|
|
@@ -245,14 +246,14 @@ exports.browserNativeModuleRNPurchases = {
|
|
|
245
246
|
switch (_a.label) {
|
|
246
247
|
case 0:
|
|
247
248
|
(0, utils_1.ensurePurchasesConfigured)();
|
|
248
|
-
if ((0, environment_1.isExpoGo)())
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
case
|
|
249
|
+
if (!(0, environment_1.isExpoGo)()) return [3 /*break*/, 2];
|
|
250
|
+
return [4 /*yield*/, (0, purchaseSimulatedPackageHelper_1.purchaseSimulatedPackage)(packageIdentifier, presentedOfferingContext)];
|
|
251
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
252
|
+
case 2: return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().purchasePackage({
|
|
253
|
+
packageIdentifier: packageIdentifier,
|
|
254
|
+
presentedOfferingContext: presentedOfferingContext,
|
|
255
|
+
})];
|
|
256
|
+
case 3:
|
|
256
257
|
purchaseResult = _a.sent();
|
|
257
258
|
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(purchaseResult, typeGuards_1.isMakePurchaseResult, 'MakePurchaseResult')];
|
|
258
259
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PurchasesPackage } from "@revenuecat/purchases-typescript-internal";
|
|
2
|
+
/**
|
|
3
|
+
* Shows a simulated purchase alert for platforms that don't support DOM manipulation.
|
|
4
|
+
*/
|
|
5
|
+
export declare function showSimulatedPurchaseAlert(packageIdentifier: string, offeringIdentifier: string, onPurchase: (packageInfo: PurchasesPackage) => Promise<void>, onFailedPurchase: () => void, onCancel: () => void): Promise<void>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.showSimulatedPurchaseAlert = void 0;
|
|
40
|
+
var react_native_1 = require("react-native");
|
|
41
|
+
var offeringsLoader_1 = require("./offeringsLoader");
|
|
42
|
+
/**
|
|
43
|
+
* Shows a simulated purchase alert for platforms that don't support DOM manipulation.
|
|
44
|
+
*/
|
|
45
|
+
function showSimulatedPurchaseAlert(packageIdentifier, offeringIdentifier, onPurchase, onFailedPurchase, onCancel) {
|
|
46
|
+
var _this = this;
|
|
47
|
+
return new Promise(function (resolve, reject) {
|
|
48
|
+
var handleCancel = function () {
|
|
49
|
+
onCancel();
|
|
50
|
+
resolve();
|
|
51
|
+
};
|
|
52
|
+
var handleFailedPurchase = function () {
|
|
53
|
+
onFailedPurchase();
|
|
54
|
+
resolve();
|
|
55
|
+
};
|
|
56
|
+
var handlePurchase = function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
57
|
+
var error_1;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
_a.trys.push([0, 2, , 3]);
|
|
62
|
+
return [4 /*yield*/, onPurchase(data.packageInfo)];
|
|
63
|
+
case 1:
|
|
64
|
+
_a.sent();
|
|
65
|
+
resolve();
|
|
66
|
+
return [3 /*break*/, 3];
|
|
67
|
+
case 2:
|
|
68
|
+
error_1 = _a.sent();
|
|
69
|
+
reject(error_1);
|
|
70
|
+
return [3 /*break*/, 3];
|
|
71
|
+
case 3: return [2 /*return*/];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}); };
|
|
75
|
+
(0, offeringsLoader_1.loadSimulatedPurchaseData)(packageIdentifier, offeringIdentifier)
|
|
76
|
+
.then(function (data) {
|
|
77
|
+
var packageInfo = data.packageInfo, offers = data.offers;
|
|
78
|
+
var message = "\u26A0\uFE0F This is a test purchase and should only be used during development. In production, use an Apple/Google API key from RevenueCat.\n\n";
|
|
79
|
+
message += "Package ID: ".concat(packageInfo.identifier, "\n");
|
|
80
|
+
message += "Product ID: ".concat(packageInfo.product.identifier, "\n");
|
|
81
|
+
message += "Title: ".concat(packageInfo.product.title, "\n");
|
|
82
|
+
message += "Price: ".concat(packageInfo.product.priceString, "\n");
|
|
83
|
+
if (packageInfo.product.subscriptionPeriod) {
|
|
84
|
+
message += "Period: ".concat(packageInfo.product.subscriptionPeriod, "\n");
|
|
85
|
+
}
|
|
86
|
+
if (offers.length > 0) {
|
|
87
|
+
message += "\nOffers:\n".concat(offers.map(function (offer) { return "\u2022 ".concat(offer); }).join('\n'));
|
|
88
|
+
}
|
|
89
|
+
react_native_1.Alert.alert('Test Purchase', message, [
|
|
90
|
+
{
|
|
91
|
+
text: 'Cancel',
|
|
92
|
+
style: 'cancel',
|
|
93
|
+
onPress: handleCancel,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
text: 'Test Failed Purchase',
|
|
97
|
+
style: 'destructive',
|
|
98
|
+
onPress: handleFailedPurchase,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
text: 'Test Valid Purchase',
|
|
102
|
+
onPress: function () { return handlePurchase(data); },
|
|
103
|
+
},
|
|
104
|
+
], { cancelable: true, onDismiss: handleCancel });
|
|
105
|
+
})
|
|
106
|
+
.catch(function (error) {
|
|
107
|
+
console.error('Error loading package details:', error);
|
|
108
|
+
var errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
109
|
+
react_native_1.Alert.alert('Test Purchase Error', "Error loading package details: ".concat(errorMessage), [
|
|
110
|
+
{
|
|
111
|
+
text: 'Close',
|
|
112
|
+
onPress: function () { reject(error); },
|
|
113
|
+
},
|
|
114
|
+
], { cancelable: true, onDismiss: function () { reject(error); } });
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exports.showSimulatedPurchaseAlert = showSimulatedPurchaseAlert;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PurchasesPackage } from "@revenuecat/purchases-typescript-internal";
|
|
2
|
+
export interface SimulatedPurchaseData {
|
|
3
|
+
packageInfo: PurchasesPackage;
|
|
4
|
+
offers: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Loads package data and formats offer information
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadSimulatedPurchaseData(packageIdentifier: string, offeringIdentifier: string): Promise<SimulatedPurchaseData>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.loadSimulatedPurchaseData = void 0;
|
|
40
|
+
var purchases_js_hybrid_mappings_1 = require("@revenuecat/purchases-js-hybrid-mappings");
|
|
41
|
+
var typeGuards_1 = require("../typeGuards");
|
|
42
|
+
/**
|
|
43
|
+
* Loads package data and formats offer information
|
|
44
|
+
*/
|
|
45
|
+
function loadSimulatedPurchaseData(packageIdentifier, offeringIdentifier) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
var offeringsResult, offerings, targetOffering, targetPackage, offers;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0: return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getOfferings()];
|
|
51
|
+
case 1:
|
|
52
|
+
offeringsResult = _a.sent();
|
|
53
|
+
offerings = (0, typeGuards_1.validateAndTransform)(offeringsResult, typeGuards_1.isPurchasesOfferings, 'PurchasesOfferings');
|
|
54
|
+
targetOffering = offerings.all[offeringIdentifier];
|
|
55
|
+
if (!targetOffering) {
|
|
56
|
+
throw new Error("Offering with identifier ".concat(offeringIdentifier, " not found"));
|
|
57
|
+
}
|
|
58
|
+
targetPackage = targetOffering.availablePackages.find(function (pkg) { return pkg.identifier === packageIdentifier; });
|
|
59
|
+
if (!targetPackage) {
|
|
60
|
+
throw new Error("Package with identifier ".concat(packageIdentifier, " not found in offering ").concat(offeringIdentifier));
|
|
61
|
+
}
|
|
62
|
+
offers = [];
|
|
63
|
+
if (targetPackage.product.introPrice) {
|
|
64
|
+
offers.push("Intro: ".concat(targetPackage.product.introPrice.priceString, " for ").concat(targetPackage.product.introPrice.cycles, " ").concat(targetPackage.product.introPrice.periodUnit.toLowerCase(), "(s)"));
|
|
65
|
+
}
|
|
66
|
+
if (targetPackage.product.discounts && targetPackage.product.discounts.length > 0) {
|
|
67
|
+
targetPackage.product.discounts.forEach(function (discount) {
|
|
68
|
+
offers.push("Discount: ".concat(discount.priceString, " for ").concat(discount.cycles, " ").concat(discount.periodUnit.toLowerCase(), "(s)"));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return [2 /*return*/, { packageInfo: targetPackage, offers: offers }];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.loadSimulatedPurchaseData = loadSimulatedPurchaseData;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.purchaseSimulatedPackage = void 0;
|
|
40
|
+
var purchases_typescript_internal_1 = require("@revenuecat/purchases-typescript-internal");
|
|
41
|
+
var purchases_js_hybrid_mappings_1 = require("@revenuecat/purchases-js-hybrid-mappings");
|
|
42
|
+
var alertHelper_1 = require("./alertHelper");
|
|
43
|
+
// This will allow only to purchase simulated products in Expo Go since
|
|
44
|
+
// neither StoreKit, Play Store, nor Web Billing store are available.
|
|
45
|
+
function purchaseSimulatedPackage(packageIdentifier, presentedOfferingContext) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
var offeringIdentifier;
|
|
48
|
+
var _this = this;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
offeringIdentifier = presentedOfferingContext === null || presentedOfferingContext === void 0 ? void 0 : presentedOfferingContext.offeringIdentifier;
|
|
51
|
+
if (!offeringIdentifier) {
|
|
52
|
+
throw new Error('No offering identifier provided in presentedOfferingContext');
|
|
53
|
+
}
|
|
54
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
55
|
+
var handlePurchase = function (_) { return __awaiter(_this, void 0, void 0, function () {
|
|
56
|
+
var purchaseResult, error_1;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
_a.trys.push([0, 2, , 3]);
|
|
61
|
+
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance()._purchaseSimulatedStorePackage({
|
|
62
|
+
packageIdentifier: packageIdentifier,
|
|
63
|
+
presentedOfferingContext: presentedOfferingContext,
|
|
64
|
+
})];
|
|
65
|
+
case 1:
|
|
66
|
+
purchaseResult = _a.sent();
|
|
67
|
+
resolve(purchaseResult);
|
|
68
|
+
return [3 /*break*/, 3];
|
|
69
|
+
case 2:
|
|
70
|
+
error_1 = _a.sent();
|
|
71
|
+
reject(error_1);
|
|
72
|
+
return [3 /*break*/, 3];
|
|
73
|
+
case 3: return [2 /*return*/];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}); };
|
|
77
|
+
var handleFailedPurchase = function () {
|
|
78
|
+
reject({
|
|
79
|
+
code: purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PRODUCT_NOT_AVAILABLE_FOR_PURCHASE_ERROR,
|
|
80
|
+
userCancelled: false,
|
|
81
|
+
message: 'Test purchase failure: no real transaction occurred'
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
var handleCancel = function () {
|
|
85
|
+
reject({
|
|
86
|
+
code: purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR,
|
|
87
|
+
userCancelled: true,
|
|
88
|
+
message: 'User cancelled purchase.'
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
(0, alertHelper_1.showSimulatedPurchaseAlert)(packageIdentifier, offeringIdentifier, handlePurchase, handleFailedPurchase, handleCancel).catch(reject);
|
|
92
|
+
})];
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.purchaseSimulatedPackage = purchaseSimulatedPackage;
|
package/ios/RNPurchases.m
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-purchases",
|
|
3
3
|
"title": "React Native Purchases",
|
|
4
|
-
"version": "9.4.
|
|
4
|
+
"version": "9.4.2",
|
|
5
5
|
"description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android. ",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
]
|
|
115
115
|
},
|
|
116
116
|
"dependencies": {
|
|
117
|
-
"@revenuecat/purchases-js-hybrid-mappings": "17.
|
|
118
|
-
"@revenuecat/purchases-typescript-internal": "17.
|
|
117
|
+
"@revenuecat/purchases-js-hybrid-mappings": "17.6.0",
|
|
118
|
+
"@revenuecat/purchases-typescript-internal": "17.6.0"
|
|
119
119
|
}
|
|
120
120
|
}
|