@glomopay/react-native-sdk 4.0.0 → 5.0.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/CHANGELOG.md +29 -0
- package/MIGRATION.md +112 -0
- package/README.md +173 -36
- package/lib/bridge/file-input-handler.d.ts +25 -0
- package/lib/bridge/file-input-handler.d.ts.map +1 -0
- package/lib/bridge/file-input-handler.js +38 -0
- package/lib/bridge/file-save-handler.d.ts +32 -0
- package/lib/bridge/file-save-handler.d.ts.map +1 -0
- package/lib/bridge/file-save-handler.js +92 -0
- package/lib/bridge/message-router.d.ts +44 -0
- package/lib/bridge/message-router.d.ts.map +1 -0
- package/lib/bridge/message-router.js +48 -0
- package/lib/bridge/payment-payload.d.ts +18 -0
- package/lib/bridge/payment-payload.d.ts.map +1 -0
- package/lib/bridge/payment-payload.js +31 -0
- package/lib/capabilities/file-save.d.ts +40 -0
- package/lib/capabilities/file-save.d.ts.map +1 -0
- package/lib/capabilities/file-save.js +101 -0
- package/lib/capabilities/index.d.ts +22 -0
- package/lib/capabilities/index.d.ts.map +1 -0
- package/lib/capabilities/index.js +34 -0
- package/lib/capabilities/use-capability-reporting.d.ts +24 -0
- package/lib/capabilities/use-capability-reporting.d.ts.map +1 -0
- package/lib/capabilities/use-capability-reporting.js +44 -0
- package/lib/config/base.d.ts +12 -0
- package/lib/config/base.d.ts.map +1 -1
- package/lib/config/base.js +13 -1
- package/lib/glomo-checkout.d.ts +9 -1
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +14 -5
- package/lib/glomo-lrs-checkout.d.ts +3 -0
- package/lib/glomo-lrs-checkout.d.ts.map +1 -1
- package/lib/glomo-lrs-checkout.js +34 -11
- package/lib/glomo-standard-checkout.d.ts +4 -1
- package/lib/glomo-standard-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.js +21 -13
- package/lib/glomo-subscriptions-checkout.d.ts.map +1 -1
- package/lib/glomo-subscriptions-checkout.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/injections/index.d.ts +24 -0
- package/lib/injections/index.d.ts.map +1 -1
- package/lib/injections/index.js +41 -0
- package/lib/injections/webview-flow.injection.d.ts.map +1 -1
- package/lib/injections/webview-flow.injection.js +76 -0
- package/lib/injections/webview-main.injection.d.ts.map +1 -1
- package/lib/injections/webview-main.injection.js +31 -0
- package/lib/injections/webview-standard.injection.d.ts.map +1 -1
- package/lib/injections/webview-standard.injection.js +31 -0
- package/lib/services/file-saver.d.ts +109 -0
- package/lib/services/file-saver.d.ts.map +1 -0
- package/lib/services/file-saver.js +416 -0
- package/lib/types/checkout.d.ts +67 -6
- package/lib/types/checkout.d.ts.map +1 -1
- package/lib/types/checkout.js +24 -2
- package/lib/types/standard-checkout.d.ts +6 -6
- package/lib/types/standard-checkout.d.ts.map +1 -1
- package/lib/types/subscriptions-checkout.d.ts +5 -3
- package/lib/types/subscriptions-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.d.ts +2 -2
- package/lib/use-glomo-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.js +25 -4
- package/lib/use-lrs-checkout.d.ts +18 -6
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-lrs-checkout.js +330 -171
- package/lib/use-standard-checkout.d.ts +18 -13
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +282 -206
- package/lib/utils/analytics.d.ts +177 -51
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +299 -81
- package/lib/utils/device-compliance.d.ts +57 -12
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +101 -37
- package/lib/utils/event-projections.d.ts +56 -0
- package/lib/utils/event-projections.d.ts.map +1 -0
- package/lib/utils/event-projections.js +42 -0
- package/lib/utils/file-metadata.d.ts +52 -0
- package/lib/utils/file-metadata.d.ts.map +1 -0
- package/lib/utils/file-metadata.js +134 -0
- package/lib/utils/use-sdk-session.d.ts +12 -0
- package/lib/utils/use-sdk-session.d.ts.map +1 -0
- package/lib/utils/use-sdk-session.js +37 -0
- package/lib/utils/validation.d.ts +37 -3
- package/lib/utils/validation.d.ts.map +1 -1
- package/lib/utils/validation.js +64 -8
- package/lib/webview/capability-props.d.ts +27 -0
- package/lib/webview/capability-props.d.ts.map +1 -0
- package/lib/webview/capability-props.js +61 -0
- package/lib/webview/use-permission-request.d.ts +33 -0
- package/lib/webview/use-permission-request.d.ts.map +1 -0
- package/lib/webview/use-permission-request.js +89 -0
- package/package.json +13 -3
- package/src/bridge/file-input-handler.ts +66 -0
- package/src/bridge/file-save-handler.ts +141 -0
- package/src/bridge/message-router.ts +92 -0
- package/src/bridge/payment-payload.ts +31 -0
- package/src/capabilities/file-save.ts +124 -0
- package/src/capabilities/index.ts +34 -0
- package/src/capabilities/use-capability-reporting.ts +55 -0
- package/src/config/base.ts +13 -0
- package/src/glomo-checkout.tsx +28 -11
- package/src/glomo-lrs-checkout.tsx +49 -27
- package/src/glomo-standard-checkout.tsx +33 -34
- package/src/glomo-subscriptions-checkout.tsx +1 -0
- package/src/index.ts +4 -2
- package/src/injections/index.ts +43 -0
- package/src/injections/webview-flow.injection.ts +76 -0
- package/src/injections/webview-main.injection.ts +31 -0
- package/src/injections/webview-standard.injection.ts +31 -0
- package/src/services/file-saver.ts +497 -0
- package/src/types/checkout.ts +72 -6
- package/src/types/standard-checkout.ts +6 -6
- package/src/types/subscriptions-checkout.ts +9 -3
- package/src/use-glomo-checkout.tsx +32 -7
- package/src/use-lrs-checkout.tsx +684 -366
- package/src/use-standard-checkout.tsx +731 -465
- package/src/utils/analytics.ts +422 -117
- package/src/utils/device-compliance.ts +148 -38
- package/src/utils/event-projections.ts +74 -0
- package/src/utils/file-metadata.ts +140 -0
- package/src/utils/use-sdk-session.ts +41 -0
- package/src/utils/validation.ts +70 -10
- package/src/webview/capability-props.ts +86 -0
- package/src/webview/use-permission-request.ts +114 -0
- package/src/jail-monkey.d.ts +0 -19
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
import { useState, useRef, useCallback, useEffect } from "react";
|
|
7
7
|
|
|
8
|
-
import { type GlomoCheckoutProps, type CheckoutStatus } from "./types/checkout";
|
|
8
|
+
import { type GlomoCheckoutProps, type GlomoCheckoutInternalProps, type CheckoutStatus } from "./types/checkout";
|
|
9
9
|
import { type GlomoLrsCheckoutRef } from "./glomo-lrs-checkout";
|
|
10
10
|
import { type GlomoStandardCheckoutRef } from "./types/standard-checkout";
|
|
11
11
|
import { type GlomoSubscriptionsCheckoutRef } from "./types/subscriptions-checkout";
|
|
12
12
|
import { type OrderType, fetchOrderType } from "./services/order-type-fetcher";
|
|
13
|
-
import { isValidPublicKey, isValidOrderId, safeCallback } from "./utils/validation";
|
|
13
|
+
import { isValidPublicKey, isValidOrderId, isMockModeKey, safeCallback } from "./utils/validation";
|
|
14
14
|
import {
|
|
15
15
|
type SdkError,
|
|
16
16
|
trackOrderTypeDetectionStarted,
|
|
@@ -63,14 +63,14 @@ export interface UseGlomoCheckoutInternalReturn {
|
|
|
63
63
|
*/
|
|
64
64
|
export function useGlomoCheckout(props: GlomoCheckoutProps): UseGlomoCheckoutReturn;
|
|
65
65
|
export function useGlomoCheckout(
|
|
66
|
-
props: GlomoCheckoutProps,
|
|
66
|
+
props: GlomoCheckoutProps & GlomoCheckoutInternalProps,
|
|
67
67
|
internalOptions: { _suppressDeprecationWarning: true }
|
|
68
68
|
): UseGlomoCheckoutInternalReturn;
|
|
69
69
|
export function useGlomoCheckout(
|
|
70
|
-
props: GlomoCheckoutProps,
|
|
70
|
+
props: GlomoCheckoutProps & GlomoCheckoutInternalProps,
|
|
71
71
|
internalOptions?: { _suppressDeprecationWarning?: boolean }
|
|
72
72
|
): UseGlomoCheckoutInternalReturn {
|
|
73
|
-
const { server, publicKey, orderId, subscriptionId, onSdkError, devMode = false } = props;
|
|
73
|
+
const { server, publicKey, orderId, subscriptionId, onSdkError, devMode = false, _forceOrderType } = props;
|
|
74
74
|
|
|
75
75
|
// Order type resolved from the API - null until detection completes
|
|
76
76
|
const [orderType, setOrderType] = useState<ExtendedOrderType | null>(null);
|
|
@@ -85,7 +85,7 @@ export function useGlomoCheckout(
|
|
|
85
85
|
|
|
86
86
|
// One-time deprecation warning for direct merchant usage
|
|
87
87
|
const suppressWarning = internalOptions?._suppressDeprecationWarning ?? false;
|
|
88
|
-
const mockMode = publicKey
|
|
88
|
+
const mockMode = isMockModeKey(publicKey);
|
|
89
89
|
const hasWarnedRef = useRef(false);
|
|
90
90
|
useEffect(() => {
|
|
91
91
|
if (!hasWarnedRef.current && !suppressWarning) {
|
|
@@ -248,6 +248,31 @@ export function useGlomoCheckout(
|
|
|
248
248
|
return false;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Bypassing the fetchOrderType API call
|
|
253
|
+
* and using the provided order type directly,
|
|
254
|
+
* if _forceOrderType is set.
|
|
255
|
+
*
|
|
256
|
+
* This is ONLY meant to be used by automated testing harnesses,
|
|
257
|
+
* to simulate a checkout without actual API calls.
|
|
258
|
+
*
|
|
259
|
+
* Only available in __DEV__ builds (debug)
|
|
260
|
+
*/
|
|
261
|
+
if (__DEV__ && _forceOrderType) {
|
|
262
|
+
++fetchGenerationRef.current;
|
|
263
|
+
|
|
264
|
+
if (devMode) {
|
|
265
|
+
console.log(`[Glomo-RN-SDK] Forcing order type: ${_forceOrderType}`);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
setOrderType(_forceOrderType);
|
|
269
|
+
|
|
270
|
+
return new Promise<boolean>((resolve) => {
|
|
271
|
+
pendingStartResolveRef.current = resolve;
|
|
272
|
+
pendingStartRef.current = true;
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
251
276
|
// Detecting order type via the API
|
|
252
277
|
setDetecting(true);
|
|
253
278
|
const thisGeneration = ++fetchGenerationRef.current;
|
|
@@ -294,7 +319,7 @@ export function useGlomoCheckout(
|
|
|
294
319
|
pendingStartResolveRef.current = resolve;
|
|
295
320
|
pendingStartRef.current = true;
|
|
296
321
|
});
|
|
297
|
-
}, [devMode, publicKey, orderId, subscriptionId, server, onSdkError, propsError]);
|
|
322
|
+
}, [devMode, publicKey, orderId, subscriptionId, server, onSdkError, propsError, _forceOrderType]);
|
|
298
323
|
|
|
299
324
|
/**
|
|
300
325
|
* Auto-starting the inner component after order type is resolved and the component has rendered.
|