@tryheliumai/paywall-sdk-react-native 0.1.26 → 0.1.28
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/lib/commonjs/handlers/revenuecat.js +146 -0
- package/lib/commonjs/handlers/revenuecat.js.map +1 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-interface.js +33 -15
- package/lib/commonjs/native-interface.js.map +1 -1
- package/lib/commonjs/types.js +27 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/handlers/revenuecat.js +138 -0
- package/lib/module/handlers/revenuecat.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-interface.js +33 -15
- package/lib/module/native-interface.js.map +1 -1
- package/lib/module/types.js +23 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/src/handlers/revenuecat.d.ts +16 -0
- package/lib/typescript/commonjs/src/handlers/revenuecat.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +3 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/native-interface.d.ts +2 -2
- package/lib/typescript/commonjs/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +22 -3
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/handlers/revenuecat.d.ts +16 -0
- package/lib/typescript/module/src/handlers/revenuecat.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +3 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/native-interface.d.ts +2 -2
- package/lib/typescript/module/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +22 -3
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/handlers/revenuecat.ts +132 -0
- package/src/index.ts +3 -1
- package/src/native-interface.tsx +41 -18
- package/src/types.ts +42 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["findNodeHandle","NativeModules","View","NativeEventEmitter","requireNativeComponent","React","createRef","useEffect","useState","createContext","useContext","jsx","_jsx","jsxs","_jsxs","HeliumBridge","heliumEventEmitter","NativeHeliumUpsellView","isProviderMounted","providerMountedPromise","resolveProviderMounted","Promise","resolve","globalDownloadStatus","getDownloadStatus","HeliumContext","undefined","setDownloadStatusRef","updateDownloadStatus","status","useHelium","context","Error","fallbackRef","FallbackViewComponent","HeliumProvider","children","fallbackView","FallbackView","downloadStatus","setDownloadStatus","Provider","value","ref","collapsable","style","display","initialize","
|
|
1
|
+
{"version":3,"names":["findNodeHandle","NativeModules","View","NativeEventEmitter","requireNativeComponent","React","createRef","useEffect","useState","createContext","useContext","RevenueCatHeliumHandler","jsx","_jsx","jsxs","_jsxs","HeliumBridge","heliumEventEmitter","NativeHeliumUpsellView","isProviderMounted","providerMountedPromise","resolveProviderMounted","Promise","resolve","globalDownloadStatus","getDownloadStatus","HeliumContext","undefined","setDownloadStatusRef","updateDownloadStatus","status","useHelium","context","Error","fallbackRef","FallbackViewComponent","HeliumProvider","children","fallbackView","FallbackView","downloadStatus","setDownloadStatus","Provider","value","ref","collapsable","style","display","initialize","config","viewTag","current","purchaseHandler","purchaseConfig","type","rcHandler","apiKey","makePurchase","bind","restorePurchases","addListener","event","paywallTemplateName","setNativeProps","onHeliumPaywallEvent","result","productId","handlePurchaseResponse","transactionId","error","success","handleRestoreResponse","fallbackPaywall","triggers","customUserId","customAPIEndpoint","customUserTraits","presentUpsell","triggerName","onFallback","getFetchedTriggerNames","triggerNames","includes","hideUpsell","UpsellView","trigger","fallbackViewProps","fallbackViewWrapperStyles","HELIUM_CTA_NAMES","SCHEDULE_CALL","SUBSCRIBE_BUTTON"],"sourceRoot":"../../src","sources":["native-interface.tsx"],"mappings":";;AAAA,SAASA,cAAc,EAAEC,aAAa,EAAEC,IAAI,EAAEC,kBAAkB,EAA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AAC;AAED,OAAO,MAAMG,gBAAgB,GAAG;EAC9BC,aAAa,EAAE,eAAe;EAC9BC,gBAAgB,EAAE;AACpB,CAAC","ignoreList":[]}
|
package/lib/module/types.js
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
// --- Purchase Configuration Types ---
|
|
4
|
+
|
|
5
|
+
/** Interface for providing custom purchase handling logic. */
|
|
6
|
+
|
|
7
|
+
/** Configuration for using the built-in RevenueCat handler. */
|
|
8
|
+
|
|
9
|
+
// Union type for the purchase configuration
|
|
10
|
+
|
|
11
|
+
// Add other config types here in the future, e.g. | StripePurchaseConfig
|
|
12
|
+
|
|
13
|
+
// Helper function for creating Custom Purchase Config
|
|
14
|
+
export function CustomPurchaseConfig(callbacks) {
|
|
15
|
+
return {
|
|
16
|
+
type: 'custom',
|
|
17
|
+
makePurchase: callbacks.makePurchase,
|
|
18
|
+
restorePurchases: callbacks.restorePurchases
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// --- Main Helium Configuration ---
|
|
23
|
+
|
|
24
|
+
// --- Other Existing Types ---
|
|
2
25
|
//# sourceMappingURL=types.js.map
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["CustomPurchaseConfig","callbacks","type","makePurchase","restorePurchases"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAOA;;AAEA;;AAQA;;AAQA;;AAEA;;AAEA;AACA,OAAO,SAASA,oBAAoBA,CAACC,SAGpC,EAA2B;EAC1B,OAAO;IACLC,IAAI,EAAE,QAAQ;IACdC,YAAY,EAAEF,SAAS,CAACE,YAAY;IACpCC,gBAAgB,EAAEH,SAAS,CAACG;EAC9B,CAAC;AACH;;AAEA;;AAiBA","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HeliumPurchaseResult, RevenueCatPurchaseConfig } from '../types';
|
|
2
|
+
export declare function RevenueCatConfig(config?: {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
}): RevenueCatPurchaseConfig;
|
|
5
|
+
export declare class RevenueCatHeliumHandler {
|
|
6
|
+
private productIdToPackageMapping;
|
|
7
|
+
private isMappingInitialized;
|
|
8
|
+
private initializationPromise;
|
|
9
|
+
constructor(apiKey?: string);
|
|
10
|
+
private initializePackageMapping;
|
|
11
|
+
private ensureMappingInitialized;
|
|
12
|
+
makePurchase(productId: string): Promise<HeliumPurchaseResult>;
|
|
13
|
+
private isProductActive;
|
|
14
|
+
restorePurchases(): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=revenuecat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revenuecat.d.ts","sourceRoot":"","sources":["../../../../../src/handlers/revenuecat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAI/E,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,wBAAwB,CAKvF;AAED,qBAAa,uBAAuB;IAChC,OAAO,CAAC,yBAAyB,CAAwC;IACzE,OAAO,CAAC,oBAAoB,CAAkB;IAC9C,OAAO,CAAC,qBAAqB,CAA8B;gBAE/C,MAAM,CAAC,EAAE,MAAM;YAQb,wBAAwB;YAyBxB,wBAAwB;IAQhC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA0DpE,OAAO,CAAC,eAAe;IAMjB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;CAS7C"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { RevenueCatConfig } from './handlers/revenuecat';
|
|
1
2
|
export { HeliumProvider, initialize, presentUpsell, hideUpsell, UpsellView, HELIUM_CTA_NAMES, useHelium, NativeHeliumUpsellView } from './native-interface';
|
|
2
|
-
export type { HeliumTransactionStatus,
|
|
3
|
+
export type { HeliumTransactionStatus, HeliumConfig, HeliumUpsellViewProps, RevenueCatPurchaseConfig } from './types';
|
|
4
|
+
export { CustomPurchaseConfig } from './types';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5J,YAAY,EAAE,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5J,YAAY,EAAE,uBAAuB,EAAE,YAAY,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACtH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { HeliumConfig, HeliumUpsellViewProps, HeliumDownloadStatus } from './types';
|
|
3
3
|
export declare const NativeHeliumUpsellView: import("react-native").HostComponent<HeliumUpsellViewProps>;
|
|
4
4
|
export declare const getDownloadStatus: () => HeliumDownloadStatus;
|
|
5
5
|
interface HeliumContextType {
|
|
@@ -12,7 +12,7 @@ interface HeliumProviderProps {
|
|
|
12
12
|
fallbackView: React.ComponentType;
|
|
13
13
|
}
|
|
14
14
|
export declare const HeliumProvider: ({ children, fallbackView: FallbackView }: HeliumProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare const initialize: (
|
|
15
|
+
export declare const initialize: (config: HeliumConfig) => Promise<void>;
|
|
16
16
|
export declare const presentUpsell: ({ triggerName, onFallback }: {
|
|
17
17
|
triggerName: string;
|
|
18
18
|
onFallback?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAwB,MAAM,SAAS,CAAC;AAQ/G,eAAO,MAAM,sBAAsB,6DAAoE,CAAC;AAkBxG,eAAO,MAAM,iBAAiB,4BAA6B,CAAC;AAG5D,UAAU,iBAAiB;IACzB,cAAc,EAAE,oBAAoB,CAAC;IACrC,iBAAiB,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAYD,eAAO,MAAM,SAAS,yBAMrB,CAAC;AAEF,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC;CACnC;AAQD,eAAO,MAAM,cAAc,6CAA8C,mBAAmB,4CAmC3F,CAAC;AAGF,eAAO,MAAM,UAAU,WAAkB,YAAY,kBAwGpD,CAAC;AAGF,eAAO,MAAM,aAAa,gCAGvB;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB,SAcA,CAAC;AAEF,eAAO,MAAM,UAAU,YAEtB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,GAAG;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjD,CAoBA,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA"}
|
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
export type HeliumTransactionStatus = '
|
|
1
|
+
export type HeliumTransactionStatus = 'purchased' | 'failed' | 'cancelled' | 'pending' | 'restored';
|
|
2
2
|
export type HeliumPurchaseResult = {
|
|
3
3
|
status: HeliumTransactionStatus;
|
|
4
4
|
error?: string;
|
|
5
5
|
};
|
|
6
6
|
export type HeliumDownloadStatus = 'success' | 'failed' | 'inProgress' | 'notStarted';
|
|
7
|
-
|
|
7
|
+
/** Interface for providing custom purchase handling logic. */
|
|
8
|
+
export interface CustomPurchaseCallbacks {
|
|
8
9
|
makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
|
|
9
10
|
restorePurchases: () => Promise<boolean>;
|
|
10
|
-
|
|
11
|
+
/** Discriminant property to identify custom callbacks */
|
|
12
|
+
type: 'custom';
|
|
13
|
+
}
|
|
14
|
+
/** Configuration for using the built-in RevenueCat handler. */
|
|
15
|
+
export interface RevenueCatPurchaseConfig {
|
|
16
|
+
/** Optional RevenueCat API Key. If not provided, RevenueCat must be configured elsewhere. */
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
/** Discriminant property to identify RevenueCat config */
|
|
19
|
+
type: 'revenuecat';
|
|
11
20
|
}
|
|
21
|
+
export type HeliumPurchaseConfig = CustomPurchaseCallbacks | RevenueCatPurchaseConfig;
|
|
22
|
+
export declare function CustomPurchaseConfig(callbacks: {
|
|
23
|
+
makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
|
|
24
|
+
restorePurchases: () => Promise<boolean>;
|
|
25
|
+
}): CustomPurchaseCallbacks;
|
|
12
26
|
export interface HeliumConfig {
|
|
27
|
+
/** Your Helium API Key */
|
|
13
28
|
apiKey: string;
|
|
29
|
+
/** Configuration for handling purchases. Can be custom functions or a pre-built handler config. */
|
|
30
|
+
purchaseConfig: HeliumPurchaseConfig;
|
|
31
|
+
/** Callback for receiving all Helium paywall events. */
|
|
32
|
+
onHeliumPaywallEvent: (event: any) => void;
|
|
14
33
|
fallbackView?: number;
|
|
15
34
|
triggers?: string[];
|
|
16
35
|
customUserId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAItF,8DAA8D;AAC9D,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,CAAC,SAAS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string;
|
|
4
|
+
}): RevenueCatPurchaseConfig;
|
|
5
|
+
export declare class RevenueCatHeliumHandler {
|
|
6
|
+
private productIdToPackageMapping;
|
|
7
|
+
private isMappingInitialized;
|
|
8
|
+
private initializationPromise;
|
|
9
|
+
constructor(apiKey?: string);
|
|
10
|
+
private initializePackageMapping;
|
|
11
|
+
private ensureMappingInitialized;
|
|
12
|
+
makePurchase(productId: string): Promise<HeliumPurchaseResult>;
|
|
13
|
+
private isProductActive;
|
|
14
|
+
restorePurchases(): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=revenuecat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revenuecat.d.ts","sourceRoot":"","sources":["../../../../../src/handlers/revenuecat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAI/E,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,wBAAwB,CAKvF;AAED,qBAAa,uBAAuB;IAChC,OAAO,CAAC,yBAAyB,CAAwC;IACzE,OAAO,CAAC,oBAAoB,CAAkB;IAC9C,OAAO,CAAC,qBAAqB,CAA8B;gBAE/C,MAAM,CAAC,EAAE,MAAM;YAQb,wBAAwB;YAyBxB,wBAAwB;IAQhC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA0DpE,OAAO,CAAC,eAAe;IAMjB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;CAS7C"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { RevenueCatConfig } from './handlers/revenuecat';
|
|
1
2
|
export { HeliumProvider, initialize, presentUpsell, hideUpsell, UpsellView, HELIUM_CTA_NAMES, useHelium, NativeHeliumUpsellView } from './native-interface';
|
|
2
|
-
export type { HeliumTransactionStatus,
|
|
3
|
+
export type { HeliumTransactionStatus, HeliumConfig, HeliumUpsellViewProps, RevenueCatPurchaseConfig } from './types';
|
|
4
|
+
export { CustomPurchaseConfig } from './types';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5J,YAAY,EAAE,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5J,YAAY,EAAE,uBAAuB,EAAE,YAAY,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACtH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { HeliumConfig, HeliumUpsellViewProps, HeliumDownloadStatus } from './types';
|
|
3
3
|
export declare const NativeHeliumUpsellView: import("react-native").HostComponent<HeliumUpsellViewProps>;
|
|
4
4
|
export declare const getDownloadStatus: () => HeliumDownloadStatus;
|
|
5
5
|
interface HeliumContextType {
|
|
@@ -12,7 +12,7 @@ interface HeliumProviderProps {
|
|
|
12
12
|
fallbackView: React.ComponentType;
|
|
13
13
|
}
|
|
14
14
|
export declare const HeliumProvider: ({ children, fallbackView: FallbackView }: HeliumProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare const initialize: (
|
|
15
|
+
export declare const initialize: (config: HeliumConfig) => Promise<void>;
|
|
16
16
|
export declare const presentUpsell: ({ triggerName, onFallback }: {
|
|
17
17
|
triggerName: string;
|
|
18
18
|
onFallback?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAwB,MAAM,SAAS,CAAC;AAQ/G,eAAO,MAAM,sBAAsB,6DAAoE,CAAC;AAkBxG,eAAO,MAAM,iBAAiB,4BAA6B,CAAC;AAG5D,UAAU,iBAAiB;IACzB,cAAc,EAAE,oBAAoB,CAAC;IACrC,iBAAiB,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAYD,eAAO,MAAM,SAAS,yBAMrB,CAAC;AAEF,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC;CACnC;AAQD,eAAO,MAAM,cAAc,6CAA8C,mBAAmB,4CAmC3F,CAAC;AAGF,eAAO,MAAM,UAAU,WAAkB,YAAY,kBAwGpD,CAAC;AAGF,eAAO,MAAM,aAAa,gCAGvB;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB,SAcA,CAAC;AAEF,eAAO,MAAM,UAAU,YAEtB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,GAAG;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjD,CAoBA,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA"}
|
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
export type HeliumTransactionStatus = '
|
|
1
|
+
export type HeliumTransactionStatus = 'purchased' | 'failed' | 'cancelled' | 'pending' | 'restored';
|
|
2
2
|
export type HeliumPurchaseResult = {
|
|
3
3
|
status: HeliumTransactionStatus;
|
|
4
4
|
error?: string;
|
|
5
5
|
};
|
|
6
6
|
export type HeliumDownloadStatus = 'success' | 'failed' | 'inProgress' | 'notStarted';
|
|
7
|
-
|
|
7
|
+
/** Interface for providing custom purchase handling logic. */
|
|
8
|
+
export interface CustomPurchaseCallbacks {
|
|
8
9
|
makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
|
|
9
10
|
restorePurchases: () => Promise<boolean>;
|
|
10
|
-
|
|
11
|
+
/** Discriminant property to identify custom callbacks */
|
|
12
|
+
type: 'custom';
|
|
13
|
+
}
|
|
14
|
+
/** Configuration for using the built-in RevenueCat handler. */
|
|
15
|
+
export interface RevenueCatPurchaseConfig {
|
|
16
|
+
/** Optional RevenueCat API Key. If not provided, RevenueCat must be configured elsewhere. */
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
/** Discriminant property to identify RevenueCat config */
|
|
19
|
+
type: 'revenuecat';
|
|
11
20
|
}
|
|
21
|
+
export type HeliumPurchaseConfig = CustomPurchaseCallbacks | RevenueCatPurchaseConfig;
|
|
22
|
+
export declare function CustomPurchaseConfig(callbacks: {
|
|
23
|
+
makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
|
|
24
|
+
restorePurchases: () => Promise<boolean>;
|
|
25
|
+
}): CustomPurchaseCallbacks;
|
|
12
26
|
export interface HeliumConfig {
|
|
27
|
+
/** Your Helium API Key */
|
|
13
28
|
apiKey: string;
|
|
29
|
+
/** Configuration for handling purchases. Can be custom functions or a pre-built handler config. */
|
|
30
|
+
purchaseConfig: HeliumPurchaseConfig;
|
|
31
|
+
/** Callback for receiving all Helium paywall events. */
|
|
32
|
+
onHeliumPaywallEvent: (event: any) => void;
|
|
14
33
|
fallbackView?: number;
|
|
15
34
|
triggers?: string[];
|
|
16
35
|
customUserId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAItF,8DAA8D;AAC9D,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACnE,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,yDAAyD;IACzD,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,+DAA+D;AAC/D,MAAM,WAAW,wBAAwB;IACvC,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC3D,IAAI,EAAE,YAAY,CAAC;CACpB;AAGD,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,GAAG,wBAAwB,CAAC;AAItF,wBAAgB,oBAAoB,CAAC,SAAS,EAAE;IAC9C,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACnE,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C,GAAG,uBAAuB,CAM1B;AAGD,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,mGAAmG;IACnG,cAAc,EAAE,oBAAoB,CAAC;IACrC,wDAAwD;IACxD,oBAAoB,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAG3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxC;AAID,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryheliumai/paywall-sdk-react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "Paywall SDK Helium",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"react": "18.2.0",
|
|
90
90
|
"react-native": "0.71.7",
|
|
91
91
|
"react-native-builder-bob": "^0.37.0",
|
|
92
|
+
"react-native-purchases": ">=5.1.0",
|
|
92
93
|
"release-it": "^17.10.0",
|
|
93
94
|
"turbo": "^1.10.7",
|
|
94
95
|
"typescript": "^5.2.2"
|
|
@@ -98,7 +99,8 @@
|
|
|
98
99
|
},
|
|
99
100
|
"peerDependencies": {
|
|
100
101
|
"react": ">=18.2.0",
|
|
101
|
-
"react-native": ">=0.71.7"
|
|
102
|
+
"react-native": ">=0.71.7",
|
|
103
|
+
"react-native-purchases": ">=5.1.0"
|
|
102
104
|
},
|
|
103
105
|
"workspaces": [
|
|
104
106
|
"example"
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import Purchases, { PURCHASES_ERROR_CODE } from 'react-native-purchases';
|
|
2
|
+
import type { HeliumPurchaseResult, RevenueCatPurchaseConfig } from '../types';
|
|
3
|
+
import type { PurchasesError, PurchasesPackage, CustomerInfoUpdateListener, CustomerInfo, PurchasesEntitlementInfo } from 'react-native-purchases';
|
|
4
|
+
|
|
5
|
+
// Rename the factory function
|
|
6
|
+
export function RevenueCatConfig(config?: { apiKey?: string }): RevenueCatPurchaseConfig {
|
|
7
|
+
return {
|
|
8
|
+
type: 'revenuecat',
|
|
9
|
+
apiKey: config?.apiKey,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class RevenueCatHeliumHandler {
|
|
14
|
+
private productIdToPackageMapping: Record<string, PurchasesPackage> = {};
|
|
15
|
+
private isMappingInitialized: boolean = false;
|
|
16
|
+
private initializationPromise: Promise<void> | null = null;
|
|
17
|
+
|
|
18
|
+
constructor(apiKey?: string) {
|
|
19
|
+
if (apiKey) {
|
|
20
|
+
Purchases.configure({ apiKey });
|
|
21
|
+
} else {
|
|
22
|
+
}
|
|
23
|
+
this.initializePackageMapping();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private async initializePackageMapping(): Promise<void> {
|
|
27
|
+
if (this.initializationPromise) {
|
|
28
|
+
return this.initializationPromise;
|
|
29
|
+
}
|
|
30
|
+
this.initializationPromise = (async () => {
|
|
31
|
+
try {
|
|
32
|
+
const offerings = await Purchases.getOfferings();
|
|
33
|
+
if (offerings.current?.availablePackages) {
|
|
34
|
+
offerings.current.availablePackages.forEach((pkg: PurchasesPackage) => {
|
|
35
|
+
if (pkg.product?.identifier) {
|
|
36
|
+
this.productIdToPackageMapping[pkg.product.identifier] = pkg;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
}
|
|
41
|
+
this.isMappingInitialized = true;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
this.isMappingInitialized = false;
|
|
44
|
+
} finally {
|
|
45
|
+
this.initializationPromise = null;
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
48
|
+
return this.initializationPromise;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private async ensureMappingInitialized(): Promise<void> {
|
|
52
|
+
if (!this.isMappingInitialized && !this.initializationPromise) {
|
|
53
|
+
await this.initializePackageMapping();
|
|
54
|
+
} else if (this.initializationPromise) {
|
|
55
|
+
await this.initializationPromise;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async makePurchase(productId: string): Promise<HeliumPurchaseResult> {
|
|
60
|
+
await this.ensureMappingInitialized();
|
|
61
|
+
|
|
62
|
+
const pkg: PurchasesPackage | undefined = this.productIdToPackageMapping[productId];
|
|
63
|
+
if (!pkg) {
|
|
64
|
+
return { status: 'failed', error: `RevenueCat Package not found for ID: ${productId}` };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const { customerInfo } = await Purchases.purchasePackage(pkg);
|
|
69
|
+
const isActive = this.isProductActive(customerInfo, productId);
|
|
70
|
+
if (isActive) {
|
|
71
|
+
return { status: 'purchased' };
|
|
72
|
+
} else {
|
|
73
|
+
// This case might occur if the purchase succeeded but the entitlement wasn't immediately active
|
|
74
|
+
// or if a different product became active.
|
|
75
|
+
// Consider if polling/listening might be needed here too, similar to pending.
|
|
76
|
+
// For now, returning failed as the specific product isn't confirmed active.
|
|
77
|
+
return { status: 'failed', error: 'Purchase possibly complete but entitlement/subscription not active for this product.' };
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
const purchasesError = error as PurchasesError;
|
|
81
|
+
|
|
82
|
+
if (purchasesError?.code === PURCHASES_ERROR_CODE.PAYMENT_PENDING_ERROR) {
|
|
83
|
+
// Wait for a terminal state for up to 5 seconds
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
// Define the listener function separately to remove it later
|
|
86
|
+
const updateListener: CustomerInfoUpdateListener = (updatedCustomerInfo: CustomerInfo) => {
|
|
87
|
+
const isActive = this.isProductActive(updatedCustomerInfo, productId);
|
|
88
|
+
if (isActive) {
|
|
89
|
+
clearTimeout(timeoutId);
|
|
90
|
+
// Remove listener using the function reference
|
|
91
|
+
Purchases.removeCustomerInfoUpdateListener(updateListener);
|
|
92
|
+
resolve({ status: 'purchased' });
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const timeoutId = setTimeout(() => {
|
|
97
|
+
// Remove listener using the function reference on timeout
|
|
98
|
+
Purchases.removeCustomerInfoUpdateListener(updateListener);
|
|
99
|
+
resolve({ status: 'pending' });
|
|
100
|
+
}, 5000);
|
|
101
|
+
|
|
102
|
+
// Add the listener
|
|
103
|
+
Purchases.addCustomerInfoUpdateListener(updateListener);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (purchasesError?.code === PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR) {
|
|
108
|
+
return { status: 'cancelled' };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Handle other errors
|
|
112
|
+
return { status: 'failed', error: purchasesError?.message || 'RevenueCat purchase failed.' };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Helper function to check if a product is active in CustomerInfo
|
|
117
|
+
private isProductActive(customerInfo: CustomerInfo, productId: string): boolean {
|
|
118
|
+
return Object.values(customerInfo.entitlements.active).some((entitlement: PurchasesEntitlementInfo) => entitlement.productIdentifier === productId)
|
|
119
|
+
|| customerInfo.activeSubscriptions.includes(productId)
|
|
120
|
+
|| customerInfo.allPurchasedProductIdentifiers.includes(productId);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async restorePurchases(): Promise<boolean> {
|
|
124
|
+
try {
|
|
125
|
+
const customerInfo = await Purchases.restorePurchases();
|
|
126
|
+
const isActive = Object.keys(customerInfo.entitlements.active).length > 0;
|
|
127
|
+
return isActive;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { RevenueCatConfig } from './handlers/revenuecat';
|
|
1
2
|
export { HeliumProvider, initialize, presentUpsell, hideUpsell, UpsellView, HELIUM_CTA_NAMES, useHelium, NativeHeliumUpsellView } from './native-interface';
|
|
2
|
-
export type { HeliumTransactionStatus,
|
|
3
|
+
export type { HeliumTransactionStatus, HeliumConfig, HeliumUpsellViewProps, RevenueCatPurchaseConfig } from './types';
|
|
4
|
+
export { CustomPurchaseConfig } from './types';
|
package/src/native-interface.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { findNodeHandle, NativeModules, View, NativeEventEmitter, requireNativeComponent } from 'react-native';
|
|
2
2
|
import React, { createRef, useEffect, useState, createContext, useContext } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type { HeliumConfig, HeliumUpsellViewProps, HeliumDownloadStatus, HeliumPurchaseResult } from './types';
|
|
4
|
+
import { RevenueCatHeliumHandler } from './handlers/revenuecat';
|
|
4
5
|
|
|
5
6
|
const { HeliumBridge } = NativeModules;
|
|
6
7
|
const heliumEventEmitter = new NativeEventEmitter(HeliumBridge);
|
|
@@ -89,7 +90,7 @@ export const HeliumProvider = ({ children, fallbackView: FallbackView }: HeliumP
|
|
|
89
90
|
ref={fallbackRef}
|
|
90
91
|
collapsable={false}
|
|
91
92
|
style={{
|
|
92
|
-
display: 'none'
|
|
93
|
+
display: 'none'
|
|
93
94
|
}}
|
|
94
95
|
>
|
|
95
96
|
<FallbackView />
|
|
@@ -99,8 +100,8 @@ export const HeliumProvider = ({ children, fallbackView: FallbackView }: HeliumP
|
|
|
99
100
|
);
|
|
100
101
|
};
|
|
101
102
|
|
|
102
|
-
// Update initialize to accept config
|
|
103
|
-
export const initialize = async (
|
|
103
|
+
// Update initialize to accept full config
|
|
104
|
+
export const initialize = async (config: HeliumConfig) => {
|
|
104
105
|
// Wait for the provider to be mounted if it's not already
|
|
105
106
|
if (!isProviderMounted) {
|
|
106
107
|
await providerMountedPromise;
|
|
@@ -111,6 +112,30 @@ export const initialize = async (heliumCallbacks: HeliumCallbacks, config: Parti
|
|
|
111
112
|
throw new Error('Failed to get fallback view reference. Make sure HeliumProvider is mounted with a fallback view.');
|
|
112
113
|
}
|
|
113
114
|
|
|
115
|
+
// Determine purchase handlers based on config
|
|
116
|
+
let purchaseHandler: {
|
|
117
|
+
makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
|
|
118
|
+
restorePurchases: () => Promise<boolean>;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
if (config.purchaseConfig.type === 'revenuecat') {
|
|
122
|
+
// Instantiate RevenueCat handler
|
|
123
|
+
const rcHandler = new RevenueCatHeliumHandler(config.purchaseConfig.apiKey);
|
|
124
|
+
purchaseHandler = {
|
|
125
|
+
makePurchase: rcHandler.makePurchase.bind(rcHandler),
|
|
126
|
+
restorePurchases: rcHandler.restorePurchases.bind(rcHandler),
|
|
127
|
+
};
|
|
128
|
+
} else if (config.purchaseConfig.type === 'custom') {
|
|
129
|
+
// Use custom callbacks
|
|
130
|
+
purchaseHandler = {
|
|
131
|
+
makePurchase: config.purchaseConfig.makePurchase,
|
|
132
|
+
restorePurchases: config.purchaseConfig.restorePurchases,
|
|
133
|
+
};
|
|
134
|
+
} else {
|
|
135
|
+
// Handle potential future types or throw error
|
|
136
|
+
throw new Error('Invalid purchaseConfig type provided.');
|
|
137
|
+
}
|
|
138
|
+
|
|
114
139
|
// Update download status to inProgress
|
|
115
140
|
updateDownloadStatus('inProgress');
|
|
116
141
|
|
|
@@ -123,7 +148,7 @@ export const initialize = async (heliumCallbacks: HeliumCallbacks, config: Parti
|
|
|
123
148
|
updateDownloadStatus('success');
|
|
124
149
|
} else if (event.type === 'paywallsDownloadError') {
|
|
125
150
|
updateDownloadStatus('failed');
|
|
126
|
-
}
|
|
151
|
+
}
|
|
127
152
|
// Handle fallback view visibility
|
|
128
153
|
else if (event.type === 'paywallOpen' && event.paywallTemplateName === 'Fallback') {
|
|
129
154
|
if (fallbackRef.current) {
|
|
@@ -138,29 +163,30 @@ export const initialize = async (heliumCallbacks: HeliumCallbacks, config: Parti
|
|
|
138
163
|
});
|
|
139
164
|
}
|
|
140
165
|
}
|
|
141
|
-
|
|
142
|
-
// Forward all events to the callback
|
|
143
|
-
|
|
166
|
+
|
|
167
|
+
// Forward all events to the callback provided in config
|
|
168
|
+
config.onHeliumPaywallEvent(event);
|
|
144
169
|
}
|
|
145
170
|
);
|
|
146
171
|
|
|
147
|
-
// Set up purchase event listener
|
|
172
|
+
// Set up purchase event listener using the determined handler
|
|
148
173
|
heliumEventEmitter.addListener(
|
|
149
174
|
'helium_make_purchase',
|
|
150
175
|
async (event: { productId: string; transactionId: string }) => {
|
|
151
|
-
const
|
|
176
|
+
const result = await purchaseHandler.makePurchase(event.productId);
|
|
152
177
|
HeliumBridge.handlePurchaseResponse({
|
|
153
178
|
transactionId: event.transactionId,
|
|
154
|
-
status: status
|
|
179
|
+
status: result.status,
|
|
180
|
+
error: result.error
|
|
155
181
|
});
|
|
156
182
|
}
|
|
157
183
|
);
|
|
158
184
|
|
|
159
|
-
// Set up restore purchases event listener
|
|
185
|
+
// Set up restore purchases event listener using the determined handler
|
|
160
186
|
heliumEventEmitter.addListener(
|
|
161
187
|
'helium_restore_purchases',
|
|
162
188
|
async (event: { transactionId: string }) => {
|
|
163
|
-
const success = await
|
|
189
|
+
const success = await purchaseHandler.restorePurchases();
|
|
164
190
|
HeliumBridge.handleRestoreResponse({
|
|
165
191
|
transactionId: event.transactionId,
|
|
166
192
|
status: success ? 'restored' : 'failed'
|
|
@@ -168,17 +194,14 @@ export const initialize = async (heliumCallbacks: HeliumCallbacks, config: Parti
|
|
|
168
194
|
}
|
|
169
195
|
);
|
|
170
196
|
|
|
171
|
-
// Initialize the bridge with merged config
|
|
172
197
|
HeliumBridge.initialize(
|
|
173
|
-
{
|
|
198
|
+
{
|
|
174
199
|
apiKey: config.apiKey,
|
|
175
200
|
fallbackPaywall: viewTag,
|
|
176
201
|
triggers: config.triggers || [],
|
|
177
202
|
customUserId: config.customUserId || null,
|
|
178
203
|
customAPIEndpoint: config.customAPIEndpoint || null,
|
|
179
|
-
customUserTraits: config.customUserTraits == null ? {
|
|
180
|
-
"exampleUserTrait": "test_value"
|
|
181
|
-
} : config.customUserTraits
|
|
204
|
+
customUserTraits: config.customUserTraits == null ? {} : config.customUserTraits
|
|
182
205
|
},
|
|
183
206
|
{}
|
|
184
207
|
);
|