@ridwan-retainer/paywall 0.1.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.
- package/README.md +64 -0
- package/dist/__mocks__/async-storage.d.ts +12 -0
- package/dist/__mocks__/async-storage.d.ts.map +1 -0
- package/dist/__mocks__/async-storage.js +14 -0
- package/dist/__mocks__/react-native-purchases-ui.d.ts +17 -0
- package/dist/__mocks__/react-native-purchases-ui.d.ts.map +1 -0
- package/dist/__mocks__/react-native-purchases-ui.js +16 -0
- package/dist/__mocks__/react-native-purchases.d.ts +22 -0
- package/dist/__mocks__/react-native-purchases.d.ts.map +1 -0
- package/dist/__mocks__/react-native-purchases.js +25 -0
- package/dist/components/Paywall.d.ts +13 -0
- package/dist/components/Paywall.d.ts.map +1 -0
- package/dist/components/Paywall.js +18 -0
- package/dist/components/PaywallFooter.d.ts +13 -0
- package/dist/components/PaywallFooter.d.ts.map +1 -0
- package/dist/components/PaywallFooter.js +60 -0
- package/dist/components/PaywallGate.d.ts +12 -0
- package/dist/components/PaywallGate.d.ts.map +1 -0
- package/dist/components/PaywallGate.js +66 -0
- package/dist/components/PurchaseButton.d.ts +13 -0
- package/dist/components/PurchaseButton.d.ts.map +1 -0
- package/dist/components/PurchaseButton.js +30 -0
- package/dist/components/RestoreButton.d.ts +16 -0
- package/dist/components/RestoreButton.d.ts.map +1 -0
- package/dist/components/RestoreButton.js +35 -0
- package/dist/components/SubscriptionGate.d.ts +14 -0
- package/dist/components/SubscriptionGate.d.ts.map +1 -0
- package/dist/components/SubscriptionGate.js +22 -0
- package/dist/config/RevenueCatConfig.d.ts +4 -0
- package/dist/config/RevenueCatConfig.d.ts.map +1 -0
- package/dist/config/RevenueCatConfig.js +61 -0
- package/dist/config/environment.d.ts +3 -0
- package/dist/config/environment.d.ts.map +1 -0
- package/dist/config/environment.js +16 -0
- package/dist/config/types.d.ts +16 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/entitlements/CustomerInfoManager.d.ts +14 -0
- package/dist/entitlements/CustomerInfoManager.d.ts.map +1 -0
- package/dist/entitlements/CustomerInfoManager.js +59 -0
- package/dist/entitlements/EntitlementCache.d.ts +5 -0
- package/dist/entitlements/EntitlementCache.d.ts.map +1 -0
- package/dist/entitlements/EntitlementCache.js +39 -0
- package/dist/entitlements/subscriptionUtils.d.ts +10 -0
- package/dist/entitlements/subscriptionUtils.d.ts.map +1 -0
- package/dist/entitlements/subscriptionUtils.js +34 -0
- package/dist/entitlements/types.d.ts +13 -0
- package/dist/entitlements/types.d.ts.map +1 -0
- package/dist/entitlements/types.js +2 -0
- package/dist/hooks/useCurrentOffering.d.ts +11 -0
- package/dist/hooks/useCurrentOffering.d.ts.map +1 -0
- package/dist/hooks/useCurrentOffering.js +46 -0
- package/dist/hooks/useCustomerInfo.d.ts +8 -0
- package/dist/hooks/useCustomerInfo.d.ts.map +1 -0
- package/dist/hooks/useCustomerInfo.js +34 -0
- package/dist/hooks/useEntitlement.d.ts +10 -0
- package/dist/hooks/useEntitlement.d.ts.map +1 -0
- package/dist/hooks/useEntitlement.js +48 -0
- package/dist/hooks/useOfferings.d.ts +9 -0
- package/dist/hooks/useOfferings.d.ts.map +1 -0
- package/dist/hooks/useOfferings.js +58 -0
- package/dist/hooks/usePaywall.d.ts +6 -0
- package/dist/hooks/usePaywall.d.ts.map +1 -0
- package/dist/hooks/usePaywall.js +23 -0
- package/dist/hooks/usePurchase.d.ts +14 -0
- package/dist/hooks/usePurchase.d.ts.map +1 -0
- package/dist/hooks/usePurchase.js +48 -0
- package/dist/hooks/useRestorePurchases.d.ts +14 -0
- package/dist/hooks/useRestorePurchases.d.ts.map +1 -0
- package/dist/hooks/useRestorePurchases.js +48 -0
- package/dist/hooks/useRevenueCatInitialization.d.ts +5 -0
- package/dist/hooks/useRevenueCatInitialization.d.ts.map +1 -0
- package/dist/hooks/useRevenueCatInitialization.js +44 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/offerings/OfferingsManager.d.ts +12 -0
- package/dist/offerings/OfferingsManager.d.ts.map +1 -0
- package/dist/offerings/OfferingsManager.js +44 -0
- package/dist/offerings/packageUtils.d.ts +11 -0
- package/dist/offerings/packageUtils.d.ts.map +1 -0
- package/dist/offerings/packageUtils.js +44 -0
- package/dist/offerings/types.d.ts +8 -0
- package/dist/offerings/types.d.ts.map +1 -0
- package/dist/offerings/types.js +2 -0
- package/dist/paywall/PaywallController.d.ts +21 -0
- package/dist/paywall/PaywallController.d.ts.map +1 -0
- package/dist/paywall/PaywallController.js +61 -0
- package/dist/paywall/types.d.ts +60 -0
- package/dist/paywall/types.d.ts.map +1 -0
- package/dist/paywall/types.js +10 -0
- package/dist/purchase/PurchaseManager.d.ts +10 -0
- package/dist/purchase/PurchaseManager.d.ts.map +1 -0
- package/dist/purchase/PurchaseManager.js +45 -0
- package/dist/purchase/errorHandling.d.ts +5 -0
- package/dist/purchase/errorHandling.d.ts.map +1 -0
- package/dist/purchase/errorHandling.js +36 -0
- package/dist/purchase/purchaseCache.d.ts +19 -0
- package/dist/purchase/purchaseCache.d.ts.map +1 -0
- package/dist/purchase/purchaseCache.js +57 -0
- package/dist/purchase/types.d.ts +23 -0
- package/dist/purchase/types.d.ts.map +1 -0
- package/dist/purchase/types.js +11 -0
- package/dist/restore/RestoreManager.d.ts +26 -0
- package/dist/restore/RestoreManager.d.ts.map +1 -0
- package/dist/restore/RestoreManager.js +72 -0
- package/dist/restore/autoRestore.d.ts +13 -0
- package/dist/restore/autoRestore.d.ts.map +1 -0
- package/dist/restore/autoRestore.js +37 -0
- package/dist/restore/errorHandling.d.ts +10 -0
- package/dist/restore/errorHandling.d.ts.map +1 -0
- package/dist/restore/errorHandling.js +30 -0
- package/dist/restore/types.d.ts +22 -0
- package/dist/restore/types.d.ts.map +1 -0
- package/dist/restore/types.js +11 -0
- package/package.json +60 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRevenueCatInitialization.d.ts","sourceRoot":"","sources":["../../src/hooks/useRevenueCatInitialization.ts"],"names":[],"mappings":"AAGA,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;;;EA6C7E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRevenueCatInitialization = useRevenueCatInitialization;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const RevenueCatConfig_1 = require("../config/RevenueCatConfig");
|
|
6
|
+
function useRevenueCatInitialization(apiKey, appUserID) {
|
|
7
|
+
const [isInitialized, setIsInitialized] = (0, react_1.useState)(false);
|
|
8
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
let mounted = true;
|
|
11
|
+
async function initialize() {
|
|
12
|
+
try {
|
|
13
|
+
if (!apiKey) {
|
|
14
|
+
throw new Error('RevenueCat API key is required');
|
|
15
|
+
}
|
|
16
|
+
const config = {
|
|
17
|
+
iosApiKey: apiKey,
|
|
18
|
+
androidApiKey: apiKey,
|
|
19
|
+
};
|
|
20
|
+
await (0, RevenueCatConfig_1.initializeRevenueCat)(config, appUserID);
|
|
21
|
+
if (mounted) {
|
|
22
|
+
setIsInitialized(true);
|
|
23
|
+
if (__DEV__) {
|
|
24
|
+
console.error('[RevenueCat] SDK initialized successfully');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
if (mounted) {
|
|
30
|
+
const errorMessage = err instanceof Error ? err.message : 'Initialization failed';
|
|
31
|
+
setError(errorMessage);
|
|
32
|
+
if (__DEV__) {
|
|
33
|
+
console.error('[RevenueCat] Initialization error:', errorMessage);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
initialize();
|
|
39
|
+
return () => {
|
|
40
|
+
mounted = false;
|
|
41
|
+
};
|
|
42
|
+
}, [apiKey, appUserID]);
|
|
43
|
+
return { isInitialized, error };
|
|
44
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { initializeRevenueCat, isRevenueCatConfigured } from './config/RevenueCatConfig';
|
|
2
|
+
export { getRevenueCatConfig } from './config/environment';
|
|
3
|
+
export type { RevenueCatConfig, PlatformConfig } from './config/types';
|
|
4
|
+
export { offeringsManager, OfferingsManager } from './offerings/OfferingsManager';
|
|
5
|
+
export * from './offerings/packageUtils';
|
|
6
|
+
export type { PurchasesOfferings, PurchasesOffering, PurchasesPackage, PurchasesStoreProduct, OfferingsFetchResult, } from './offerings/types';
|
|
7
|
+
export { customerInfoManager, CustomerInfoManager } from './entitlements/CustomerInfoManager';
|
|
8
|
+
export * from './entitlements/subscriptionUtils';
|
|
9
|
+
export * from './entitlements/EntitlementCache';
|
|
10
|
+
export type { CustomerInfo, PurchasesEntitlementInfos, PurchasesEntitlementInfo, EntitlementCheckResult, CustomerInfoState, } from './entitlements/types';
|
|
11
|
+
export { purchaseManager, PurchaseManager } from './purchase/PurchaseManager';
|
|
12
|
+
export * from './purchase/errorHandling';
|
|
13
|
+
export * from './purchase/purchaseCache';
|
|
14
|
+
export { PurchaseState } from './purchase/types';
|
|
15
|
+
export type { PurchaseResult, PurchaseError, PurchaseStatus, } from './purchase/types';
|
|
16
|
+
export { restoreManager, RestoreManager } from './restore/RestoreManager';
|
|
17
|
+
export * from './restore/errorHandling';
|
|
18
|
+
export * from './restore/autoRestore';
|
|
19
|
+
export { RestoreState } from './restore/types';
|
|
20
|
+
export type { RestoreResult, RestoreError, RestoreStatus, } from './restore/types';
|
|
21
|
+
export { paywallController, PaywallController } from './paywall/PaywallController';
|
|
22
|
+
export { PaywallResult } from './paywall/types';
|
|
23
|
+
export type { PaywallOptions, PaywallCallbacks, } from './paywall/types';
|
|
24
|
+
export { useRevenueCatInitialization } from './hooks/useRevenueCatInitialization';
|
|
25
|
+
export { useOfferings } from './hooks/useOfferings';
|
|
26
|
+
export { useCurrentOffering } from './hooks/useCurrentOffering';
|
|
27
|
+
export { useCustomerInfo } from './hooks/useCustomerInfo';
|
|
28
|
+
export { useEntitlement } from './hooks/useEntitlement';
|
|
29
|
+
export { usePurchase } from './hooks/usePurchase';
|
|
30
|
+
export { useRestorePurchases } from './hooks/useRestorePurchases';
|
|
31
|
+
export { usePaywall } from './hooks/usePaywall';
|
|
32
|
+
export { SubscriptionGate } from './components/SubscriptionGate';
|
|
33
|
+
export { PurchaseButton } from './components/PurchaseButton';
|
|
34
|
+
export { RestoreButton } from './components/RestoreButton';
|
|
35
|
+
export { Paywall } from './components/Paywall';
|
|
36
|
+
export { PaywallFooter } from './components/PaywallFooter';
|
|
37
|
+
export { PaywallGate } from './components/PaywallGate';
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAClF,cAAc,0BAA0B,CAAC;AACzC,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9F,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,YAAY,EACV,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9E,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EACV,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1E,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.PaywallGate = exports.PaywallFooter = exports.Paywall = exports.RestoreButton = exports.PurchaseButton = exports.SubscriptionGate = exports.usePaywall = exports.useRestorePurchases = exports.usePurchase = exports.useEntitlement = exports.useCustomerInfo = exports.useCurrentOffering = exports.useOfferings = exports.useRevenueCatInitialization = exports.PaywallResult = exports.PaywallController = exports.paywallController = exports.RestoreState = exports.RestoreManager = exports.restoreManager = exports.PurchaseState = exports.PurchaseManager = exports.purchaseManager = exports.CustomerInfoManager = exports.customerInfoManager = exports.OfferingsManager = exports.offeringsManager = exports.getRevenueCatConfig = exports.isRevenueCatConfigured = exports.initializeRevenueCat = void 0;
|
|
18
|
+
// Configuration
|
|
19
|
+
var RevenueCatConfig_1 = require("./config/RevenueCatConfig");
|
|
20
|
+
Object.defineProperty(exports, "initializeRevenueCat", { enumerable: true, get: function () { return RevenueCatConfig_1.initializeRevenueCat; } });
|
|
21
|
+
Object.defineProperty(exports, "isRevenueCatConfigured", { enumerable: true, get: function () { return RevenueCatConfig_1.isRevenueCatConfigured; } });
|
|
22
|
+
var environment_1 = require("./config/environment");
|
|
23
|
+
Object.defineProperty(exports, "getRevenueCatConfig", { enumerable: true, get: function () { return environment_1.getRevenueCatConfig; } });
|
|
24
|
+
// Offerings
|
|
25
|
+
var OfferingsManager_1 = require("./offerings/OfferingsManager");
|
|
26
|
+
Object.defineProperty(exports, "offeringsManager", { enumerable: true, get: function () { return OfferingsManager_1.offeringsManager; } });
|
|
27
|
+
Object.defineProperty(exports, "OfferingsManager", { enumerable: true, get: function () { return OfferingsManager_1.OfferingsManager; } });
|
|
28
|
+
__exportStar(require("./offerings/packageUtils"), exports);
|
|
29
|
+
// Entitlements
|
|
30
|
+
var CustomerInfoManager_1 = require("./entitlements/CustomerInfoManager");
|
|
31
|
+
Object.defineProperty(exports, "customerInfoManager", { enumerable: true, get: function () { return CustomerInfoManager_1.customerInfoManager; } });
|
|
32
|
+
Object.defineProperty(exports, "CustomerInfoManager", { enumerable: true, get: function () { return CustomerInfoManager_1.CustomerInfoManager; } });
|
|
33
|
+
__exportStar(require("./entitlements/subscriptionUtils"), exports);
|
|
34
|
+
__exportStar(require("./entitlements/EntitlementCache"), exports);
|
|
35
|
+
// Purchase
|
|
36
|
+
var PurchaseManager_1 = require("./purchase/PurchaseManager");
|
|
37
|
+
Object.defineProperty(exports, "purchaseManager", { enumerable: true, get: function () { return PurchaseManager_1.purchaseManager; } });
|
|
38
|
+
Object.defineProperty(exports, "PurchaseManager", { enumerable: true, get: function () { return PurchaseManager_1.PurchaseManager; } });
|
|
39
|
+
__exportStar(require("./purchase/errorHandling"), exports);
|
|
40
|
+
__exportStar(require("./purchase/purchaseCache"), exports);
|
|
41
|
+
var types_1 = require("./purchase/types");
|
|
42
|
+
Object.defineProperty(exports, "PurchaseState", { enumerable: true, get: function () { return types_1.PurchaseState; } });
|
|
43
|
+
// Restore
|
|
44
|
+
var RestoreManager_1 = require("./restore/RestoreManager");
|
|
45
|
+
Object.defineProperty(exports, "restoreManager", { enumerable: true, get: function () { return RestoreManager_1.restoreManager; } });
|
|
46
|
+
Object.defineProperty(exports, "RestoreManager", { enumerable: true, get: function () { return RestoreManager_1.RestoreManager; } });
|
|
47
|
+
__exportStar(require("./restore/errorHandling"), exports);
|
|
48
|
+
__exportStar(require("./restore/autoRestore"), exports);
|
|
49
|
+
var types_2 = require("./restore/types");
|
|
50
|
+
Object.defineProperty(exports, "RestoreState", { enumerable: true, get: function () { return types_2.RestoreState; } });
|
|
51
|
+
// Paywall
|
|
52
|
+
var PaywallController_1 = require("./paywall/PaywallController");
|
|
53
|
+
Object.defineProperty(exports, "paywallController", { enumerable: true, get: function () { return PaywallController_1.paywallController; } });
|
|
54
|
+
Object.defineProperty(exports, "PaywallController", { enumerable: true, get: function () { return PaywallController_1.PaywallController; } });
|
|
55
|
+
var types_3 = require("./paywall/types");
|
|
56
|
+
Object.defineProperty(exports, "PaywallResult", { enumerable: true, get: function () { return types_3.PaywallResult; } });
|
|
57
|
+
// Hooks
|
|
58
|
+
var useRevenueCatInitialization_1 = require("./hooks/useRevenueCatInitialization");
|
|
59
|
+
Object.defineProperty(exports, "useRevenueCatInitialization", { enumerable: true, get: function () { return useRevenueCatInitialization_1.useRevenueCatInitialization; } });
|
|
60
|
+
var useOfferings_1 = require("./hooks/useOfferings");
|
|
61
|
+
Object.defineProperty(exports, "useOfferings", { enumerable: true, get: function () { return useOfferings_1.useOfferings; } });
|
|
62
|
+
var useCurrentOffering_1 = require("./hooks/useCurrentOffering");
|
|
63
|
+
Object.defineProperty(exports, "useCurrentOffering", { enumerable: true, get: function () { return useCurrentOffering_1.useCurrentOffering; } });
|
|
64
|
+
var useCustomerInfo_1 = require("./hooks/useCustomerInfo");
|
|
65
|
+
Object.defineProperty(exports, "useCustomerInfo", { enumerable: true, get: function () { return useCustomerInfo_1.useCustomerInfo; } });
|
|
66
|
+
var useEntitlement_1 = require("./hooks/useEntitlement");
|
|
67
|
+
Object.defineProperty(exports, "useEntitlement", { enumerable: true, get: function () { return useEntitlement_1.useEntitlement; } });
|
|
68
|
+
var usePurchase_1 = require("./hooks/usePurchase");
|
|
69
|
+
Object.defineProperty(exports, "usePurchase", { enumerable: true, get: function () { return usePurchase_1.usePurchase; } });
|
|
70
|
+
var useRestorePurchases_1 = require("./hooks/useRestorePurchases");
|
|
71
|
+
Object.defineProperty(exports, "useRestorePurchases", { enumerable: true, get: function () { return useRestorePurchases_1.useRestorePurchases; } });
|
|
72
|
+
var usePaywall_1 = require("./hooks/usePaywall");
|
|
73
|
+
Object.defineProperty(exports, "usePaywall", { enumerable: true, get: function () { return usePaywall_1.usePaywall; } });
|
|
74
|
+
// Components
|
|
75
|
+
var SubscriptionGate_1 = require("./components/SubscriptionGate");
|
|
76
|
+
Object.defineProperty(exports, "SubscriptionGate", { enumerable: true, get: function () { return SubscriptionGate_1.SubscriptionGate; } });
|
|
77
|
+
var PurchaseButton_1 = require("./components/PurchaseButton");
|
|
78
|
+
Object.defineProperty(exports, "PurchaseButton", { enumerable: true, get: function () { return PurchaseButton_1.PurchaseButton; } });
|
|
79
|
+
var RestoreButton_1 = require("./components/RestoreButton");
|
|
80
|
+
Object.defineProperty(exports, "RestoreButton", { enumerable: true, get: function () { return RestoreButton_1.RestoreButton; } });
|
|
81
|
+
var Paywall_1 = require("./components/Paywall");
|
|
82
|
+
Object.defineProperty(exports, "Paywall", { enumerable: true, get: function () { return Paywall_1.Paywall; } });
|
|
83
|
+
var PaywallFooter_1 = require("./components/PaywallFooter");
|
|
84
|
+
Object.defineProperty(exports, "PaywallFooter", { enumerable: true, get: function () { return PaywallFooter_1.PaywallFooter; } });
|
|
85
|
+
var PaywallGate_1 = require("./components/PaywallGate");
|
|
86
|
+
Object.defineProperty(exports, "PaywallGate", { enumerable: true, get: function () { return PaywallGate_1.PaywallGate; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PurchasesOfferings, PurchasesOffering } from './types';
|
|
2
|
+
export declare class OfferingsManager {
|
|
3
|
+
private cachedOfferings;
|
|
4
|
+
private lastFetchTime;
|
|
5
|
+
private readonly CACHE_DURATION;
|
|
6
|
+
getOfferings(forceRefresh?: boolean): Promise<PurchasesOfferings>;
|
|
7
|
+
getCurrentOffering(): Promise<PurchasesOffering | null>;
|
|
8
|
+
getOffering(identifier: string): Promise<PurchasesOffering | null>;
|
|
9
|
+
clearCache(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const offeringsManager: OfferingsManager;
|
|
12
|
+
//# sourceMappingURL=OfferingsManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OfferingsManager.d.ts","sourceRoot":"","sources":["../../src/offerings/OfferingsManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAErE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAG1C,YAAY,CAAC,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiBxE,kBAAkB,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAMvD,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAMxE,UAAU,IAAI,IAAI;CAInB;AAGD,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.offeringsManager = exports.OfferingsManager = void 0;
|
|
7
|
+
const react_native_purchases_1 = __importDefault(require("react-native-purchases"));
|
|
8
|
+
class OfferingsManager {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.cachedOfferings = null;
|
|
11
|
+
this.lastFetchTime = 0;
|
|
12
|
+
this.CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
|
|
13
|
+
}
|
|
14
|
+
// Fetch offerings from RevenueCat with 5-minute caching
|
|
15
|
+
async getOfferings(forceRefresh = false) {
|
|
16
|
+
const now = Date.now();
|
|
17
|
+
const cacheExpired = now - this.lastFetchTime > this.CACHE_DURATION;
|
|
18
|
+
if (this.cachedOfferings && !cacheExpired && !forceRefresh) {
|
|
19
|
+
return this.cachedOfferings;
|
|
20
|
+
}
|
|
21
|
+
const offerings = await react_native_purchases_1.default.getOfferings();
|
|
22
|
+
this.cachedOfferings = offerings;
|
|
23
|
+
this.lastFetchTime = now;
|
|
24
|
+
return offerings;
|
|
25
|
+
}
|
|
26
|
+
// Get current offering (default offering from dashboard)
|
|
27
|
+
async getCurrentOffering() {
|
|
28
|
+
const offerings = await this.getOfferings();
|
|
29
|
+
return offerings.current;
|
|
30
|
+
}
|
|
31
|
+
// Get specific offering by identifier
|
|
32
|
+
async getOffering(identifier) {
|
|
33
|
+
const offerings = await this.getOfferings();
|
|
34
|
+
return offerings.all[identifier] || null;
|
|
35
|
+
}
|
|
36
|
+
// Clear cached offerings
|
|
37
|
+
clearCache() {
|
|
38
|
+
this.cachedOfferings = null;
|
|
39
|
+
this.lastFetchTime = 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.OfferingsManager = OfferingsManager;
|
|
43
|
+
// Singleton instance
|
|
44
|
+
exports.offeringsManager = new OfferingsManager();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PurchasesPackage, PurchasesOffering } from './types';
|
|
2
|
+
export declare function getMonthlyPackage(offering: PurchasesOffering): PurchasesPackage | null;
|
|
3
|
+
export declare function getAnnualPackage(offering: PurchasesOffering): PurchasesPackage | null;
|
|
4
|
+
export declare function getLifetimePackage(offering: PurchasesOffering): PurchasesPackage | null;
|
|
5
|
+
export declare function getSortedPackages(offering: PurchasesOffering): PurchasesPackage[];
|
|
6
|
+
export declare function formatPackagePrice(pkg: PurchasesPackage): string;
|
|
7
|
+
export declare function getPackageTitle(pkg: PurchasesPackage): string;
|
|
8
|
+
export declare function getPackageDescription(pkg: PurchasesPackage): string;
|
|
9
|
+
export declare function hasFreeTrial(pkg: PurchasesPackage): boolean;
|
|
10
|
+
export declare function getFreeTrialText(pkg: PurchasesPackage): string | null;
|
|
11
|
+
//# sourceMappingURL=packageUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageUtils.d.ts","sourceRoot":"","sources":["../../src/offerings/packageUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGnE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,CAEtF;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,CAErF;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,CAEvF;AAGD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,gBAAgB,EAAE,CAEjF;AAGD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAEhE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAE7D;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAEnE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAE3D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAKrE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMonthlyPackage = getMonthlyPackage;
|
|
4
|
+
exports.getAnnualPackage = getAnnualPackage;
|
|
5
|
+
exports.getLifetimePackage = getLifetimePackage;
|
|
6
|
+
exports.getSortedPackages = getSortedPackages;
|
|
7
|
+
exports.formatPackagePrice = formatPackagePrice;
|
|
8
|
+
exports.getPackageTitle = getPackageTitle;
|
|
9
|
+
exports.getPackageDescription = getPackageDescription;
|
|
10
|
+
exports.hasFreeTrial = hasFreeTrial;
|
|
11
|
+
exports.getFreeTrialText = getFreeTrialText;
|
|
12
|
+
// Get specific package type from offering
|
|
13
|
+
function getMonthlyPackage(offering) {
|
|
14
|
+
return offering.monthly || null;
|
|
15
|
+
}
|
|
16
|
+
function getAnnualPackage(offering) {
|
|
17
|
+
return offering.annual || null;
|
|
18
|
+
}
|
|
19
|
+
function getLifetimePackage(offering) {
|
|
20
|
+
return offering.lifetime || null;
|
|
21
|
+
}
|
|
22
|
+
// Get all packages from offering
|
|
23
|
+
function getSortedPackages(offering) {
|
|
24
|
+
return offering.availablePackages;
|
|
25
|
+
}
|
|
26
|
+
// Format package price (already localized by store)
|
|
27
|
+
function formatPackagePrice(pkg) {
|
|
28
|
+
return pkg.product.priceString;
|
|
29
|
+
}
|
|
30
|
+
function getPackageTitle(pkg) {
|
|
31
|
+
return pkg.product.title;
|
|
32
|
+
}
|
|
33
|
+
function getPackageDescription(pkg) {
|
|
34
|
+
return pkg.product.description;
|
|
35
|
+
}
|
|
36
|
+
function hasFreeTrial(pkg) {
|
|
37
|
+
return pkg.product.introPrice !== null;
|
|
38
|
+
}
|
|
39
|
+
function getFreeTrialText(pkg) {
|
|
40
|
+
const introPrice = pkg.product.introPrice;
|
|
41
|
+
if (!introPrice)
|
|
42
|
+
return null;
|
|
43
|
+
return introPrice.priceString;
|
|
44
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PurchasesOfferings, PurchasesOffering, PurchasesPackage, PurchasesStoreProduct } from 'react-native-purchases';
|
|
2
|
+
export type { PurchasesOfferings, PurchasesOffering, PurchasesPackage, PurchasesStoreProduct };
|
|
3
|
+
export interface OfferingsFetchResult {
|
|
4
|
+
offerings: PurchasesOfferings | null;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/offerings/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACtB,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACrC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PaywallResult, type PaywallOptions } from './types';
|
|
2
|
+
export declare class PaywallController {
|
|
3
|
+
/**
|
|
4
|
+
* Present paywall if user doesn't have specified entitlement
|
|
5
|
+
* Official docs: https://www.revenuecat.com/docs/tools/paywalls/displaying-paywalls
|
|
6
|
+
*
|
|
7
|
+
* From docs: "Displays a paywall only if the customer lacks an unlocked entitlement"
|
|
8
|
+
*/
|
|
9
|
+
presentPaywallIfNeeded(entitlementId: string, _options?: PaywallOptions): Promise<PaywallResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Present paywall unconditionally
|
|
12
|
+
* Official docs: https://www.revenuecat.com/docs/tools/paywalls/displaying-paywalls
|
|
13
|
+
*/
|
|
14
|
+
presentPaywall(_options?: PaywallOptions): Promise<PaywallResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Map RevenueCat result to our enum
|
|
17
|
+
*/
|
|
18
|
+
private mapPaywallResult;
|
|
19
|
+
}
|
|
20
|
+
export declare const paywallController: PaywallController;
|
|
21
|
+
//# sourceMappingURL=PaywallController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaywallController.d.ts","sourceRoot":"","sources":["../../src/paywall/PaywallController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE7D,qBAAa,iBAAiB;IAC5B;;;;;OAKG;IACG,sBAAsB,CAC1B,aAAa,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,aAAa,CAAC;IAazB;;;OAGG;IACG,cAAc,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAWvE;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAazB;AAGD,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.paywallController = exports.PaywallController = void 0;
|
|
7
|
+
const react_native_purchases_ui_1 = __importDefault(require("react-native-purchases-ui"));
|
|
8
|
+
const types_1 = require("./types");
|
|
9
|
+
class PaywallController {
|
|
10
|
+
/**
|
|
11
|
+
* Present paywall if user doesn't have specified entitlement
|
|
12
|
+
* Official docs: https://www.revenuecat.com/docs/tools/paywalls/displaying-paywalls
|
|
13
|
+
*
|
|
14
|
+
* From docs: "Displays a paywall only if the customer lacks an unlocked entitlement"
|
|
15
|
+
*/
|
|
16
|
+
async presentPaywallIfNeeded(entitlementId, _options) {
|
|
17
|
+
try {
|
|
18
|
+
const result = await react_native_purchases_ui_1.default.presentPaywallIfNeeded({
|
|
19
|
+
requiredEntitlementIdentifier: entitlementId,
|
|
20
|
+
});
|
|
21
|
+
return this.mapPaywallResult(result);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error('[PaywallController] Error presenting conditional paywall:', error);
|
|
25
|
+
return types_1.PaywallResult.ERROR;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Present paywall unconditionally
|
|
30
|
+
* Official docs: https://www.revenuecat.com/docs/tools/paywalls/displaying-paywalls
|
|
31
|
+
*/
|
|
32
|
+
async presentPaywall(_options) {
|
|
33
|
+
try {
|
|
34
|
+
const result = await react_native_purchases_ui_1.default.presentPaywall({});
|
|
35
|
+
return this.mapPaywallResult(result);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error('[PaywallController] Error presenting paywall:', error);
|
|
39
|
+
return types_1.PaywallResult.ERROR;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Map RevenueCat result to our enum
|
|
44
|
+
*/
|
|
45
|
+
mapPaywallResult(result) {
|
|
46
|
+
// Official result types from RevenueCat
|
|
47
|
+
switch (result) {
|
|
48
|
+
case react_native_purchases_ui_1.default.PAYWALL_RESULT.PURCHASED:
|
|
49
|
+
return types_1.PaywallResult.PURCHASED;
|
|
50
|
+
case react_native_purchases_ui_1.default.PAYWALL_RESULT.RESTORED:
|
|
51
|
+
return types_1.PaywallResult.RESTORED;
|
|
52
|
+
case react_native_purchases_ui_1.default.PAYWALL_RESULT.CANCELLED:
|
|
53
|
+
return types_1.PaywallResult.CANCELLED;
|
|
54
|
+
default:
|
|
55
|
+
return types_1.PaywallResult.ERROR;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.PaywallController = PaywallController;
|
|
60
|
+
// Singleton instance
|
|
61
|
+
exports.paywallController = new PaywallController();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { PurchasesPackage, CustomerInfo, PurchasesError } from 'react-native-purchases';
|
|
2
|
+
export declare enum PaywallResult {
|
|
3
|
+
PURCHASED = "PURCHASED",
|
|
4
|
+
RESTORED = "RESTORED",
|
|
5
|
+
CANCELLED = "CANCELLED",
|
|
6
|
+
ERROR = "ERROR"
|
|
7
|
+
}
|
|
8
|
+
export interface PaywallOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Offering to display in paywall
|
|
11
|
+
* If not provided, uses current offering
|
|
12
|
+
*/
|
|
13
|
+
offering?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Display mode for the paywall
|
|
16
|
+
*/
|
|
17
|
+
displayMode?: 'fullScreen' | 'sheet';
|
|
18
|
+
}
|
|
19
|
+
export interface PaywallCallbacks {
|
|
20
|
+
/**
|
|
21
|
+
* Called when user completes a purchase
|
|
22
|
+
*/
|
|
23
|
+
onPurchaseCompleted?: (data: {
|
|
24
|
+
customerInfo: CustomerInfo;
|
|
25
|
+
storeTransaction: any;
|
|
26
|
+
}) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Called when user starts a purchase
|
|
29
|
+
*/
|
|
30
|
+
onPurchaseStarted?: (data: {
|
|
31
|
+
packageBeingPurchased: PurchasesPackage;
|
|
32
|
+
}) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Called when purchase fails
|
|
35
|
+
*/
|
|
36
|
+
onPurchaseError?: (data: {
|
|
37
|
+
error: PurchasesError;
|
|
38
|
+
}) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Called when user cancels purchase
|
|
41
|
+
*/
|
|
42
|
+
onPurchaseCancelled?: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* Called when user completes restore
|
|
45
|
+
*/
|
|
46
|
+
onRestoreCompleted?: (data: {
|
|
47
|
+
customerInfo: CustomerInfo;
|
|
48
|
+
}) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Called when restore fails
|
|
51
|
+
*/
|
|
52
|
+
onRestoreError?: (data: {
|
|
53
|
+
error: PurchasesError;
|
|
54
|
+
}) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Called when user dismisses paywall
|
|
57
|
+
*/
|
|
58
|
+
onDismiss?: () => void;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paywall/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7F,oBAAY,aAAa;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;CACtC;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,YAAY,EAAE,YAAY,CAAC;QAAC,gBAAgB,EAAE,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAE5F;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,qBAAqB,EAAE,gBAAgB,CAAA;KAAE,KAAK,IAAI,CAAC;IAEhF;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,cAAc,CAAA;KAAE,KAAK,IAAI,CAAC;IAE5D;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IAEjC;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,YAAY,EAAE,YAAY,CAAA;KAAE,KAAK,IAAI,CAAC;IAEpE;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,cAAc,CAAA;KAAE,KAAK,IAAI,CAAC;IAE3D;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaywallResult = void 0;
|
|
4
|
+
var PaywallResult;
|
|
5
|
+
(function (PaywallResult) {
|
|
6
|
+
PaywallResult["PURCHASED"] = "PURCHASED";
|
|
7
|
+
PaywallResult["RESTORED"] = "RESTORED";
|
|
8
|
+
PaywallResult["CANCELLED"] = "CANCELLED";
|
|
9
|
+
PaywallResult["ERROR"] = "ERROR";
|
|
10
|
+
})(PaywallResult || (exports.PaywallResult = PaywallResult = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PurchasesPackage } from 'react-native-purchases';
|
|
2
|
+
import type { PurchaseResult, PurchaseError } from './types';
|
|
3
|
+
export declare class PurchaseManager {
|
|
4
|
+
purchasePackage(pkg: PurchasesPackage): Promise<PurchaseResult>;
|
|
5
|
+
private handlePurchaseError;
|
|
6
|
+
isUserCancellation(error: PurchaseError): boolean;
|
|
7
|
+
isNetworkError(error: PurchaseError): boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const purchaseManager: PurchaseManager;
|
|
10
|
+
//# sourceMappingURL=PurchaseManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PurchaseManager.d.ts","sourceRoot":"","sources":["../../src/purchase/PurchaseManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7D,qBAAa,eAAe;IAEpB,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IAcrE,OAAO,CAAC,mBAAmB;IAe3B,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAIjD,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;CAG9C;AAGD,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.purchaseManager = exports.PurchaseManager = void 0;
|
|
7
|
+
const react_native_purchases_1 = __importDefault(require("react-native-purchases"));
|
|
8
|
+
const CustomerInfoManager_1 = require("../entitlements/CustomerInfoManager");
|
|
9
|
+
class PurchaseManager {
|
|
10
|
+
// Purchase a package - RevenueCat handles transaction finishing automatically
|
|
11
|
+
async purchasePackage(pkg) {
|
|
12
|
+
try {
|
|
13
|
+
const result = await react_native_purchases_1.default.purchasePackage(pkg);
|
|
14
|
+
CustomerInfoManager_1.customerInfoManager.clearCache();
|
|
15
|
+
return {
|
|
16
|
+
customerInfo: result.customerInfo,
|
|
17
|
+
productIdentifier: result.productIdentifier,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
throw this.handlePurchaseError(error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
handlePurchaseError(error) {
|
|
25
|
+
const err = error;
|
|
26
|
+
const purchaseError = {
|
|
27
|
+
message: err.message || 'Purchase failed',
|
|
28
|
+
userCancelled: err.userCancelled === true,
|
|
29
|
+
code: err.code,
|
|
30
|
+
};
|
|
31
|
+
if (__DEV__) {
|
|
32
|
+
console.error('[PurchaseManager] Purchase error:', purchaseError);
|
|
33
|
+
}
|
|
34
|
+
return purchaseError;
|
|
35
|
+
}
|
|
36
|
+
isUserCancellation(error) {
|
|
37
|
+
return error.userCancelled === true;
|
|
38
|
+
}
|
|
39
|
+
isNetworkError(error) {
|
|
40
|
+
return error.code === 'NETWORK_ERROR' || error.message.includes('network');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.PurchaseManager = PurchaseManager;
|
|
44
|
+
// Singleton instance
|
|
45
|
+
exports.purchaseManager = new PurchaseManager();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PurchaseError } from './types';
|
|
2
|
+
export declare function getUserFriendlyErrorMessage(error: PurchaseError): string;
|
|
3
|
+
export declare function isRecoverableError(error: PurchaseError): boolean;
|
|
4
|
+
export declare function requiresUserAction(error: PurchaseError): boolean;
|
|
5
|
+
//# sourceMappingURL=errorHandling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../src/purchase/errorHandling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAoBxE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAOhE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAGhE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserFriendlyErrorMessage = getUserFriendlyErrorMessage;
|
|
4
|
+
exports.isRecoverableError = isRecoverableError;
|
|
5
|
+
exports.requiresUserAction = requiresUserAction;
|
|
6
|
+
function getUserFriendlyErrorMessage(error) {
|
|
7
|
+
if (error.userCancelled) {
|
|
8
|
+
return 'Purchase cancelled';
|
|
9
|
+
}
|
|
10
|
+
switch (error.code) {
|
|
11
|
+
case 'NETWORK_ERROR':
|
|
12
|
+
return 'Network connection error. Please check your internet and try again.';
|
|
13
|
+
case 'PURCHASE_NOT_ALLOWED':
|
|
14
|
+
return 'Purchases are not allowed on this device.';
|
|
15
|
+
case 'PURCHASE_INVALID':
|
|
16
|
+
return 'This purchase is not available. Please try another option.';
|
|
17
|
+
case 'PRODUCT_NOT_AVAILABLE':
|
|
18
|
+
return 'This product is currently unavailable. Please try again later.';
|
|
19
|
+
case 'PAYMENT_PENDING':
|
|
20
|
+
return 'Your payment is pending approval. Please check back later.';
|
|
21
|
+
case 'UNKNOWN':
|
|
22
|
+
default:
|
|
23
|
+
return error.message || 'An unexpected error occurred. Please try again.';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function isRecoverableError(error) {
|
|
27
|
+
if (error.userCancelled) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
const recoverableCodes = ['NETWORK_ERROR', 'UNKNOWN'];
|
|
31
|
+
return recoverableCodes.includes(error.code || '');
|
|
32
|
+
}
|
|
33
|
+
function requiresUserAction(error) {
|
|
34
|
+
const actionRequiredCodes = ['PURCHASE_NOT_ALLOWED', 'PAYMENT_PENDING'];
|
|
35
|
+
return actionRequiredCodes.includes(error.code || '');
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PurchasesPackage } from 'react-native-purchases';
|
|
2
|
+
interface PurchaseAttempt {
|
|
3
|
+
packageIdentifier: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Cache last purchase attempt for retry on network failure
|
|
8
|
+
*/
|
|
9
|
+
export declare function cachePurchaseAttempt(pkg: PurchasesPackage): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Get last purchase attempt
|
|
12
|
+
*/
|
|
13
|
+
export declare function getLastPurchaseAttempt(): Promise<PurchaseAttempt | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Clear purchase attempt cache
|
|
16
|
+
*/
|
|
17
|
+
export declare function clearPurchaseAttempt(): Promise<void>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=purchaseCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purchaseCache.d.ts","sourceRoot":"","sources":["../../src/purchase/purchaseCache.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,UAAU,eAAe;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAU/E;AAED;;GAEG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAkB9E;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM1D"}
|