@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.
Files changed (127) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/MIGRATION.md +112 -0
  3. package/README.md +173 -36
  4. package/lib/bridge/file-input-handler.d.ts +25 -0
  5. package/lib/bridge/file-input-handler.d.ts.map +1 -0
  6. package/lib/bridge/file-input-handler.js +38 -0
  7. package/lib/bridge/file-save-handler.d.ts +32 -0
  8. package/lib/bridge/file-save-handler.d.ts.map +1 -0
  9. package/lib/bridge/file-save-handler.js +92 -0
  10. package/lib/bridge/message-router.d.ts +44 -0
  11. package/lib/bridge/message-router.d.ts.map +1 -0
  12. package/lib/bridge/message-router.js +48 -0
  13. package/lib/bridge/payment-payload.d.ts +18 -0
  14. package/lib/bridge/payment-payload.d.ts.map +1 -0
  15. package/lib/bridge/payment-payload.js +31 -0
  16. package/lib/capabilities/file-save.d.ts +40 -0
  17. package/lib/capabilities/file-save.d.ts.map +1 -0
  18. package/lib/capabilities/file-save.js +101 -0
  19. package/lib/capabilities/index.d.ts +22 -0
  20. package/lib/capabilities/index.d.ts.map +1 -0
  21. package/lib/capabilities/index.js +34 -0
  22. package/lib/capabilities/use-capability-reporting.d.ts +24 -0
  23. package/lib/capabilities/use-capability-reporting.d.ts.map +1 -0
  24. package/lib/capabilities/use-capability-reporting.js +44 -0
  25. package/lib/config/base.d.ts +12 -0
  26. package/lib/config/base.d.ts.map +1 -1
  27. package/lib/config/base.js +13 -1
  28. package/lib/glomo-checkout.d.ts +9 -1
  29. package/lib/glomo-checkout.d.ts.map +1 -1
  30. package/lib/glomo-checkout.js +14 -5
  31. package/lib/glomo-lrs-checkout.d.ts +3 -0
  32. package/lib/glomo-lrs-checkout.d.ts.map +1 -1
  33. package/lib/glomo-lrs-checkout.js +34 -11
  34. package/lib/glomo-standard-checkout.d.ts +4 -1
  35. package/lib/glomo-standard-checkout.d.ts.map +1 -1
  36. package/lib/glomo-standard-checkout.js +21 -13
  37. package/lib/glomo-subscriptions-checkout.d.ts.map +1 -1
  38. package/lib/glomo-subscriptions-checkout.js +1 -1
  39. package/lib/index.d.ts +2 -2
  40. package/lib/index.d.ts.map +1 -1
  41. package/lib/index.js +4 -3
  42. package/lib/injections/index.d.ts +24 -0
  43. package/lib/injections/index.d.ts.map +1 -1
  44. package/lib/injections/index.js +41 -0
  45. package/lib/injections/webview-flow.injection.d.ts.map +1 -1
  46. package/lib/injections/webview-flow.injection.js +76 -0
  47. package/lib/injections/webview-main.injection.d.ts.map +1 -1
  48. package/lib/injections/webview-main.injection.js +31 -0
  49. package/lib/injections/webview-standard.injection.d.ts.map +1 -1
  50. package/lib/injections/webview-standard.injection.js +31 -0
  51. package/lib/services/file-saver.d.ts +109 -0
  52. package/lib/services/file-saver.d.ts.map +1 -0
  53. package/lib/services/file-saver.js +416 -0
  54. package/lib/types/checkout.d.ts +67 -6
  55. package/lib/types/checkout.d.ts.map +1 -1
  56. package/lib/types/checkout.js +24 -2
  57. package/lib/types/standard-checkout.d.ts +6 -6
  58. package/lib/types/standard-checkout.d.ts.map +1 -1
  59. package/lib/types/subscriptions-checkout.d.ts +5 -3
  60. package/lib/types/subscriptions-checkout.d.ts.map +1 -1
  61. package/lib/use-glomo-checkout.d.ts +2 -2
  62. package/lib/use-glomo-checkout.d.ts.map +1 -1
  63. package/lib/use-glomo-checkout.js +25 -4
  64. package/lib/use-lrs-checkout.d.ts +18 -6
  65. package/lib/use-lrs-checkout.d.ts.map +1 -1
  66. package/lib/use-lrs-checkout.js +330 -171
  67. package/lib/use-standard-checkout.d.ts +18 -13
  68. package/lib/use-standard-checkout.d.ts.map +1 -1
  69. package/lib/use-standard-checkout.js +282 -206
  70. package/lib/utils/analytics.d.ts +177 -51
  71. package/lib/utils/analytics.d.ts.map +1 -1
  72. package/lib/utils/analytics.js +299 -81
  73. package/lib/utils/device-compliance.d.ts +57 -12
  74. package/lib/utils/device-compliance.d.ts.map +1 -1
  75. package/lib/utils/device-compliance.js +101 -37
  76. package/lib/utils/event-projections.d.ts +56 -0
  77. package/lib/utils/event-projections.d.ts.map +1 -0
  78. package/lib/utils/event-projections.js +42 -0
  79. package/lib/utils/file-metadata.d.ts +52 -0
  80. package/lib/utils/file-metadata.d.ts.map +1 -0
  81. package/lib/utils/file-metadata.js +134 -0
  82. package/lib/utils/use-sdk-session.d.ts +12 -0
  83. package/lib/utils/use-sdk-session.d.ts.map +1 -0
  84. package/lib/utils/use-sdk-session.js +37 -0
  85. package/lib/utils/validation.d.ts +37 -3
  86. package/lib/utils/validation.d.ts.map +1 -1
  87. package/lib/utils/validation.js +64 -8
  88. package/lib/webview/capability-props.d.ts +27 -0
  89. package/lib/webview/capability-props.d.ts.map +1 -0
  90. package/lib/webview/capability-props.js +61 -0
  91. package/lib/webview/use-permission-request.d.ts +33 -0
  92. package/lib/webview/use-permission-request.d.ts.map +1 -0
  93. package/lib/webview/use-permission-request.js +89 -0
  94. package/package.json +13 -3
  95. package/src/bridge/file-input-handler.ts +66 -0
  96. package/src/bridge/file-save-handler.ts +141 -0
  97. package/src/bridge/message-router.ts +92 -0
  98. package/src/bridge/payment-payload.ts +31 -0
  99. package/src/capabilities/file-save.ts +124 -0
  100. package/src/capabilities/index.ts +34 -0
  101. package/src/capabilities/use-capability-reporting.ts +55 -0
  102. package/src/config/base.ts +13 -0
  103. package/src/glomo-checkout.tsx +28 -11
  104. package/src/glomo-lrs-checkout.tsx +49 -27
  105. package/src/glomo-standard-checkout.tsx +33 -34
  106. package/src/glomo-subscriptions-checkout.tsx +1 -0
  107. package/src/index.ts +4 -2
  108. package/src/injections/index.ts +43 -0
  109. package/src/injections/webview-flow.injection.ts +76 -0
  110. package/src/injections/webview-main.injection.ts +31 -0
  111. package/src/injections/webview-standard.injection.ts +31 -0
  112. package/src/services/file-saver.ts +497 -0
  113. package/src/types/checkout.ts +72 -6
  114. package/src/types/standard-checkout.ts +6 -6
  115. package/src/types/subscriptions-checkout.ts +9 -3
  116. package/src/use-glomo-checkout.tsx +32 -7
  117. package/src/use-lrs-checkout.tsx +684 -366
  118. package/src/use-standard-checkout.tsx +731 -465
  119. package/src/utils/analytics.ts +422 -117
  120. package/src/utils/device-compliance.ts +148 -38
  121. package/src/utils/event-projections.ts +74 -0
  122. package/src/utils/file-metadata.ts +140 -0
  123. package/src/utils/use-sdk-session.ts +41 -0
  124. package/src/utils/validation.ts +70 -10
  125. package/src/webview/capability-props.ts +86 -0
  126. package/src/webview/use-permission-request.ts +114 -0
  127. 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?.toLowerCase().startsWith("test_") ?? false;
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.