@glomopay/react-native-sdk 2.0.2 → 3.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/MIGRATION.md +50 -0
  3. package/README.md +348 -316
  4. package/lib/config/base.d.ts +17 -11
  5. package/lib/config/base.d.ts.map +1 -1
  6. package/lib/config/base.js +19 -7
  7. package/lib/config/segment.js +3 -3
  8. package/lib/glomo-checkout.d.ts +8 -0
  9. package/lib/glomo-checkout.d.ts.map +1 -0
  10. package/lib/glomo-checkout.js +106 -0
  11. package/lib/glomo-lrs-checkout.js +9 -9
  12. package/lib/glomo-standard-checkout.d.ts +25 -0
  13. package/lib/glomo-standard-checkout.d.ts.map +1 -0
  14. package/lib/glomo-standard-checkout.js +229 -0
  15. package/lib/glomo-subscriptions-checkout.d.ts +8 -0
  16. package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
  17. package/lib/glomo-subscriptions-checkout.js +85 -0
  18. package/lib/index.d.ts +5 -4
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/index.js +7 -5
  21. package/lib/injections/index.d.ts +1 -0
  22. package/lib/injections/index.d.ts.map +1 -1
  23. package/lib/injections/index.js +2 -0
  24. package/lib/injections/webview-flow.injection.d.ts.map +1 -1
  25. package/lib/injections/webview-flow.injection.js +106 -69
  26. package/lib/injections/webview-main.injection.d.ts.map +1 -1
  27. package/lib/injections/webview-main.injection.js +112 -77
  28. package/lib/injections/webview-standard.injection.d.ts +3 -0
  29. package/lib/injections/webview-standard.injection.d.ts.map +1 -0
  30. package/lib/injections/webview-standard.injection.js +214 -0
  31. package/lib/services/order-type-fetcher.d.ts +28 -0
  32. package/lib/services/order-type-fetcher.d.ts.map +1 -0
  33. package/lib/services/order-type-fetcher.js +99 -0
  34. package/lib/types/checkout.d.ts +65 -0
  35. package/lib/types/checkout.d.ts.map +1 -0
  36. package/lib/types/checkout.js +3 -0
  37. package/lib/types/standard-checkout.d.ts +40 -0
  38. package/lib/types/standard-checkout.d.ts.map +1 -0
  39. package/lib/types/standard-checkout.js +3 -0
  40. package/lib/types/subscriptions-checkout.d.ts +29 -0
  41. package/lib/types/subscriptions-checkout.d.ts.map +1 -0
  42. package/lib/types/subscriptions-checkout.js +3 -0
  43. package/lib/use-glomo-checkout.d.ts +54 -0
  44. package/lib/use-glomo-checkout.d.ts.map +1 -0
  45. package/lib/use-glomo-checkout.js +261 -0
  46. package/lib/use-lrs-checkout.d.ts +9 -4
  47. package/lib/use-lrs-checkout.d.ts.map +1 -1
  48. package/lib/use-lrs-checkout.js +76 -93
  49. package/lib/use-standard-checkout.d.ts +74 -0
  50. package/lib/use-standard-checkout.d.ts.map +1 -0
  51. package/lib/use-standard-checkout.js +849 -0
  52. package/lib/utils/analytics.d.ts +188 -2
  53. package/lib/utils/analytics.d.ts.map +1 -1
  54. package/lib/utils/analytics.js +636 -22
  55. package/lib/utils/device-compliance.d.ts.map +1 -1
  56. package/lib/utils/device-compliance.js +3 -4
  57. package/lib/utils/validation.d.ts.map +1 -1
  58. package/lib/utils/validation.js +7 -6
  59. package/package.json +17 -5
  60. package/src/config/base.ts +36 -17
  61. package/src/config/segment.ts +3 -3
  62. package/src/glomo-checkout.tsx +147 -0
  63. package/src/glomo-lrs-checkout.tsx +9 -9
  64. package/src/glomo-standard-checkout.tsx +353 -0
  65. package/src/glomo-subscriptions-checkout.tsx +83 -0
  66. package/src/index.ts +13 -7
  67. package/src/injections/index.ts +2 -0
  68. package/src/injections/webview-flow.injection.ts +106 -69
  69. package/src/injections/webview-main.injection.ts +112 -77
  70. package/src/injections/webview-standard.injection.ts +211 -0
  71. package/src/services/order-type-fetcher.ts +86 -0
  72. package/src/types/checkout.ts +72 -0
  73. package/src/types/standard-checkout.ts +49 -0
  74. package/src/types/subscriptions-checkout.ts +31 -0
  75. package/src/use-glomo-checkout.tsx +369 -0
  76. package/src/use-lrs-checkout.tsx +91 -111
  77. package/src/use-standard-checkout.tsx +1203 -0
  78. package/src/utils/analytics.ts +908 -34
  79. package/src/utils/device-compliance.ts +3 -4
  80. package/src/utils/validation.ts +7 -8
@@ -2,18 +2,24 @@
2
2
  * Base Configuration variables for GlomoPay RN SDK
3
3
  * This file contains the default base configuration variables for the GlomoPay RN SDK.
4
4
  */
5
- /** The publicly documented server environments for the SDK */
6
- export type GlomoLrsServer = "prod" | "staging";
7
- /** Internal extension that adds "local" for development use not exported */
8
- type InternalGlomoLrsServer = GlomoLrsServer | "local";
5
+ /** The publicly documented server environments for the SDK (v3 alias) */
6
+ export type GlomoServer = "prod" | "staging";
7
+ /** Internal extension that adds "local" for development use - not exported */
8
+ type InternalGlomoServer = GlomoServer | "local";
9
9
  /** Base URLs for a given server environment */
10
- export interface GlomoLrsServerConfig {
11
- checkoutBaseUrl: string;
12
- educationCarouselBaseUrl: string;
10
+ export interface GlomoServerBaseUrls {
11
+ lrsCheckout: string;
12
+ standardCheckout: string;
13
+ lrsEducationCarousel: string;
14
+ api: string;
13
15
  }
14
- export declare const DEFAULT_SERVER: InternalGlomoLrsServer;
15
- export declare const SERVER_CONFIGS: Record<InternalGlomoLrsServer, GlomoLrsServerConfig>;
16
- /** Returns the server config for the given environment, falling back to the default (prod) server */
17
- export declare function resolveServerConfig(server?: InternalGlomoLrsServer): GlomoLrsServerConfig;
16
+ /** Server config with nested base URLs */
17
+ export interface GlomoServerConfig {
18
+ baseUrl: GlomoServerBaseUrls;
19
+ }
20
+ export declare const DEFAULT_SERVER: InternalGlomoServer;
21
+ export declare const SERVER_CONFIGS: Record<InternalGlomoServer, GlomoServerConfig>;
22
+ /** Returns the full server config for the given environment, falling back to prod */
23
+ export declare function resolveServerConfig(server?: InternalGlomoServer): GlomoServerConfig;
18
24
  export {};
19
25
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/config/base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhD,8EAA8E;AAC9E,KAAK,sBAAsB,GAAG,cAAc,GAAG,OAAO,CAAC;AAEvD,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,MAAM,CAAC;CACpC;AAED,eAAO,MAAM,cAAc,EAAE,sBAA+B,CAAC;AAE7D,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,sBAAsB,EAAE,oBAAoB,CAa/E,CAAC;AAEF,qGAAqG;AACrG,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,oBAAoB,CAIzF"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/config/base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;AAE7C,8EAA8E;AAC9E,KAAK,mBAAmB,GAAG,WAAW,GAAG,OAAO,CAAC;AAEjD,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;CACf;AAED,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,mBAAmB,CAAC;CAChC;AAED,eAAO,MAAM,cAAc,EAAE,mBAA4B,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,CAyBzE,CAAC;AAEF,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,CAInF"}
@@ -9,19 +9,31 @@ exports.resolveServerConfig = resolveServerConfig;
9
9
  exports.DEFAULT_SERVER = "prod";
10
10
  exports.SERVER_CONFIGS = {
11
11
  prod: {
12
- checkoutBaseUrl: "https://lrs-checkout.glomopay.com/",
13
- educationCarouselBaseUrl: "https://glomopay-utilities.web.app/lrs-education-carousel/",
12
+ baseUrl: {
13
+ lrsCheckout: "https://lrs-checkout.glomopay.com/",
14
+ standardCheckout: "https://checkout.glomopay.com/",
15
+ lrsEducationCarousel: "https://glomopay-utilities.web.app/lrs-education-carousel/",
16
+ api: "https://api.glomopay.com",
17
+ },
14
18
  },
15
19
  staging: {
16
- checkoutBaseUrl: "https://lrs-checkout-page-staging.web.app/",
17
- educationCarouselBaseUrl: "https://glomopay-utilities-staging.web.app/lrs-education-carousel/",
20
+ baseUrl: {
21
+ lrsCheckout: "https://lrs-checkout-page-staging.web.app/",
22
+ standardCheckout: "https://glomopay-checkout-page-staging.web.app/",
23
+ lrsEducationCarousel: "https://glomopay-utilities-staging.web.app/lrs-education-carousel/",
24
+ api: "https://staging-api.glomopay.com",
25
+ },
18
26
  },
19
27
  local: {
20
- checkoutBaseUrl: "http://localhost:6870/",
21
- educationCarouselBaseUrl: "http://localhost:6871/lrs-education-carousel/",
28
+ baseUrl: {
29
+ lrsCheckout: "http://localhost:6870/",
30
+ standardCheckout: "http://localhost:4444/",
31
+ lrsEducationCarousel: "http://localhost:6871/lrs-education-carousel/",
32
+ api: "http://localhost:3000",
33
+ },
22
34
  },
23
35
  };
24
- /** Returns the server config for the given environment, falling back to the default (prod) server */
36
+ /** Returns the full server config for the given environment, falling back to prod */
25
37
  function resolveServerConfig(server) {
26
38
  const resolvedServer = server && server in exports.SERVER_CONFIGS ? server : exports.DEFAULT_SERVER;
27
39
  return exports.SERVER_CONFIGS[resolvedServer];
@@ -72,7 +72,7 @@ function initializeSegment(devMode = false) {
72
72
  // Preventing multiple initialization attempts
73
73
  if (initializationAttempted) {
74
74
  if (devMode) {
75
- console.log("[GlomoPay RN SDK] Segment initialization already attempted");
75
+ console.log("[Glomo-RN-SDK] Segment initialization already attempted");
76
76
  }
77
77
  return segmentApiClient !== null;
78
78
  }
@@ -92,14 +92,14 @@ function initializeSegment(devMode = false) {
92
92
  timeout: 10000, // 10 second timeout
93
93
  });
94
94
  if (devMode) {
95
- console.log("[GlomoPay RN SDK] Segment Analytics initialized successfully");
95
+ console.log("[Glomo-RN-SDK] Segment Analytics initialized successfully");
96
96
  }
97
97
  return true;
98
98
  }
99
99
  catch (error) {
100
100
  if (devMode) {
101
101
  const errorMessage = error instanceof Error ? error.message : String(error);
102
- console.error("[GlomoPay RN SDK] Failed to initialize Segment:", errorMessage);
102
+ console.error("[Glomo-RN-SDK] Failed to initialize Segment:", errorMessage);
103
103
  }
104
104
  // Resetting the flag to allow retrying if needed
105
105
  initializationAttempted = false;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The unified GlomoPay Checkout Component (v3).
3
+ * Detects order type (LRS vs Standard) and delegates rendering to the appropriate inner component.
4
+ */
5
+ import React from "react";
6
+ import { type GlomoCheckoutRef, type GlomoCheckoutProps } from "./types/checkout";
7
+ export declare const GlomoCheckout: React.ForwardRefExoticComponent<GlomoCheckoutProps & React.RefAttributes<GlomoCheckoutRef>>;
8
+ //# sourceMappingURL=glomo-checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glomo-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-checkout.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAsE,MAAM,OAAO,CAAC;AAG3F,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAwIlF,eAAO,MAAM,aAAa,6FAA2E,CAAC"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ /**
3
+ * The unified GlomoPay Checkout Component (v3).
4
+ * Detects order type (LRS vs Standard) and delegates rendering to the appropriate inner component.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.GlomoCheckout = void 0;
41
+ const react_1 = __importStar(require("react"));
42
+ const use_glomo_checkout_1 = require("./use-glomo-checkout");
43
+ const analytics_1 = require("./utils/analytics");
44
+ const glomo_lrs_checkout_1 = require("./glomo-lrs-checkout");
45
+ const glomo_standard_checkout_1 = require("./glomo-standard-checkout");
46
+ const glomo_subscriptions_checkout_1 = require("./glomo-subscriptions-checkout");
47
+ function GlomoCheckoutComponent(props, ref) {
48
+ var _a;
49
+ // useGlomoCheckout handles order type detection and exposes start/getStatus for the ref
50
+ const { orderType, start, getStatus, innerLrsRef, innerStandardRef, innerSubscriptionsRef, props: passedProps, } = (0, use_glomo_checkout_1.useGlomoCheckout)(props, { _suppressDeprecationWarning: true });
51
+ // Exposing start() and getStatus() via the forwarded ref for the merchant to call
52
+ (0, react_1.useImperativeHandle)(ref, () => ({
53
+ start,
54
+ getStatus,
55
+ }));
56
+ // Tracking unsupported callback props on subscription flows (fires once per mount)
57
+ const hasTrackedUnsupportedRef = (0, react_1.useRef)(false);
58
+ const devMode = (_a = passedProps.devMode) !== null && _a !== void 0 ? _a : false;
59
+ const mockMode = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = passedProps.publicKey) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith("test_")) !== null && _b !== void 0 ? _b : false; }, [passedProps.publicKey]);
60
+ // Extracting stable booleans for the tracking effect to avoid depending on passedProps object
61
+ const hasBankTransferCallback = !!passedProps.onBankTransferSubmitted;
62
+ const hasPayViaBankCallback = !!passedProps.onPayViaBankCompleted;
63
+ const hasBankConnectionCallback = !!passedProps.onPayViaBankBankConnectionSuccessful;
64
+ (0, react_1.useEffect)(() => {
65
+ if (orderType !== "subscriptions" || hasTrackedUnsupportedRef.current)
66
+ return;
67
+ hasTrackedUnsupportedRef.current = true;
68
+ const unsupported = [
69
+ hasBankTransferCallback && "onBankTransferSubmitted",
70
+ hasPayViaBankCallback && "onPayViaBankCompleted",
71
+ hasBankConnectionCallback && "onPayViaBankBankConnectionSuccessful",
72
+ ].filter(Boolean);
73
+ for (const name of unsupported) {
74
+ (0, analytics_1.trackUseOfUnsupportedFunctionality)(name, passedProps.subscriptionId, passedProps.publicKey, devMode, mockMode, "");
75
+ }
76
+ }, [
77
+ orderType,
78
+ hasBankTransferCallback,
79
+ hasPayViaBankCallback,
80
+ hasBankConnectionCallback,
81
+ passedProps.subscriptionId,
82
+ passedProps.publicKey,
83
+ devMode,
84
+ mockMode,
85
+ ]);
86
+ // Delegating to the LRS checkout component once order type is resolved as LRS
87
+ if (orderType === "lrs") {
88
+ return (<glomo_lrs_checkout_1.GlomoLrsCheckout ref={innerLrsRef} server={passedProps.server} publicKey={passedProps.publicKey} orderId={passedProps.orderId} onPaymentSuccess={passedProps.onPaymentSuccess} onPaymentFailure={passedProps.onPaymentFailure} onConnectionError={passedProps.onConnectionError} onPaymentTerminate={passedProps.onPaymentTerminate} onSdkError={passedProps.onSdkError} devMode={passedProps.devMode}/>);
89
+ }
90
+ // Delegating to the Standard checkout component once order type is resolved as Standard
91
+ if (orderType === "standard") {
92
+ return (<glomo_standard_checkout_1.GlomoStandardCheckout ref={innerStandardRef} server={passedProps.server} publicKey={passedProps.publicKey} orderId={passedProps.orderId} onPaymentSuccess={passedProps.onPaymentSuccess} onPaymentFailure={passedProps.onPaymentFailure} onConnectionError={passedProps.onConnectionError} onPaymentTerminate={passedProps.onPaymentTerminate} onSdkError={passedProps.onSdkError} onBankTransferSubmitted={passedProps.onBankTransferSubmitted} onPayViaBankCompleted={passedProps.onPayViaBankCompleted} onPayViaBankBankConnectionSuccessful={passedProps.onPayViaBankBankConnectionSuccessful} onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions} devMode={passedProps.devMode}/>);
93
+ }
94
+ // Delegating to the Subscriptions checkout component when subscriptionId is provided (no API call)
95
+ if (orderType === "subscriptions") {
96
+ return (<glomo_subscriptions_checkout_1.GlomoSubscriptionsCheckout ref={innerSubscriptionsRef} server={passedProps.server} publicKey={passedProps.publicKey} subscriptionId={passedProps.subscriptionId} onPaymentSuccess={passedProps.onPaymentSuccess} onPaymentFailure={passedProps.onPaymentFailure} onConnectionError={passedProps.onConnectionError} onPaymentTerminate={passedProps.onPaymentTerminate} onSdkError={passedProps.onSdkError} onPayViaBankBankConnectionSuccessful={passedProps.onPayViaBankBankConnectionSuccessful} onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions} devMode={passedProps.devMode}/>);
97
+ }
98
+ /**
99
+ * No modal for detecting state - avoids iOS pageSheet conflict where
100
+ * dismissing the detecting modal interferes with the checkout modal presentation.
101
+ * The order type detection is fast enough that a loading indicator is not needed.
102
+ */
103
+ return null;
104
+ }
105
+ exports.GlomoCheckout = (0, react_1.forwardRef)(GlomoCheckoutComponent);
106
+ exports.GlomoCheckout.displayName = "GlomoCheckout";
@@ -65,7 +65,7 @@ function GlomoLrsCheckoutComponent({ server, publicKey, orderId, onPaymentSucces
65
65
  var _a;
66
66
  const resolvedMockMode = (_a = publicKey === null || publicKey === void 0 ? void 0 : publicKey.toLowerCase().startsWith("test_")) !== null && _a !== void 0 ? _a : false;
67
67
  if (devMode) {
68
- console.log(`[GlomoPay RN SDK] ${resolvedMockMode ? "Using" : "Not using"} Mock mode for publicKey: ${publicKey}`);
68
+ console.log(`[Glomo-RN-SDK LRS] ${resolvedMockMode ? "Using" : "Not using"} Mock mode for publicKey: ${publicKey}`);
69
69
  }
70
70
  return resolvedMockMode;
71
71
  }, [publicKey, devMode]);
@@ -139,7 +139,7 @@ function GlomoLrsCheckoutComponent({ server, publicKey, orderId, onPaymentSucces
139
139
  // Preventing a render if no injection script is provided
140
140
  if (!injectedJavaScript) {
141
141
  if (devMode) {
142
- console.warn(`[GlomoPay RN SDK] JavaScript Injection missing for ${url}. Skipping ${identifier} Render.`);
142
+ console.warn(`[Glomo-RN-SDK LRS] JavaScript Injection missing for ${url}. Skipping ${identifier} Render.`);
143
143
  }
144
144
  return null;
145
145
  }
@@ -148,29 +148,29 @@ function GlomoLrsCheckoutComponent({ server, publicKey, orderId, onPaymentSucces
148
148
  // Redundantly checking for surprise/extreme edge cases
149
149
  if (!(0, validation_1.isValidUrl)(url)) {
150
150
  if (devMode) {
151
- console.error(`[GlomoPay RN SDK] Invalid non-empty URL ${url} provided. Skipping ${identifier} Render.`);
151
+ console.error(`[Glomo-RN-SDK LRS] Invalid non-empty URL ${url} provided. Skipping ${identifier} Render.`);
152
152
  }
153
153
  return null;
154
154
  }
155
155
  if (devMode) {
156
- console.error(`[GlomoPay RN SDK] Empty or invalid URL provided. Skipping ${identifier} Render.`);
156
+ console.error(`[Glomo-RN-SDK LRS] Empty or invalid URL provided. Skipping ${identifier} Render.`);
157
157
  }
158
158
  return null;
159
159
  }
160
160
  return (<react_native_webview_1.WebView ref={ref} webviewDebuggingEnabled={__DEV__ && devMode} javaScriptEnabled={true} domStorageEnabled={true} onMessage={messageHandler} onError={handleError} onHttpError={handleHttpError} onNavigationStateChange={handleNavigationStateChange} onLoadStart={() => {
161
161
  if (devMode) {
162
- console.log(`[GlomoPay RN SDK] [${identifier}] WebView load started for ${url}`);
162
+ console.log(`[Glomo-RN-SDK LRS] [${identifier}] WebView load started for ${url}`);
163
163
  }
164
164
  }} onLoadEnd={() => {
165
165
  if (identifier === "educationCarousel" && ref.current && carouselViewportGuardScript) {
166
166
  ref.current.injectJavaScript(carouselViewportGuardScript);
167
167
  }
168
168
  if (devMode) {
169
- console.log(`[GlomoPay RN SDK] [${identifier}] WebView load ended for ${url}`);
169
+ console.log(`[Glomo-RN-SDK LRS] [${identifier}] WebView load ended for ${url}`);
170
170
  }
171
171
  }} onLoadProgress={({ nativeEvent }) => {
172
172
  if (devMode && identifier === "educationCarousel") {
173
- console.log(`[GlomoPay RN SDK] [educationCarousel] load progress=${nativeEvent.progress} url=${nativeEvent.url}`);
173
+ console.log(`[Glomo-RN-SDK LRS] [educationCarousel] load progress=${nativeEvent.progress} url=${nativeEvent.url}`);
174
174
  }
175
175
  }} source={{ uri: url }} javaScriptCanOpenWindowsAutomatically={true} setSupportMultipleWindows={true} incognito={true} cacheEnabled={false} cacheMode='LOAD_NO_CACHE' pullToRefreshEnabled={false} limitsNavigationsToAppBoundDomains={false} menuItems={[]} injectedJavaScript={injectedJavaScript} injectedJavaScriptBeforeContentLoaded={injectedJavaScriptBeforeContentLoaded} style={styles.webview} showsHorizontalScrollIndicator={false} showsVerticalScrollIndicator={false} mixedContentMode='always' thirdPartyCookiesEnabled={true} sharedCookiesEnabled={true} allowsInlineMediaPlayback={true} mediaPlaybackRequiresUserAction={false} {...additionalProps}/>);
176
176
  }, [handleError, handleHttpError, handleNavigationStateChange, devMode, carouselViewportGuardScript]);
@@ -194,7 +194,7 @@ function GlomoLrsCheckoutComponent({ server, publicKey, orderId, onPaymentSucces
194
194
  const shouldShowModal = (0, react_1.useMemo)(() => {
195
195
  const value = isVisible && (checkoutUrl !== null && checkoutUrl !== void 0 ? checkoutUrl : "").trim().length > 0;
196
196
  if (devMode) {
197
- console.log(`[GlomoPay RN SDK] computed visibilityHook: ${value} for internal switch ${isVisible}, and checkout=${checkoutUrl};`);
197
+ console.log(`[Glomo-RN-SDK LRS] computed visibilityHook: ${value} for internal switch ${isVisible}, and checkout=${checkoutUrl};`);
198
198
  }
199
199
  return value;
200
200
  }, [isVisible, checkoutUrl, devMode]);
@@ -210,7 +210,7 @@ function GlomoLrsCheckoutComponent({ server, publicKey, orderId, onPaymentSucces
210
210
  const shouldRenderFlowOverlay = Boolean(showFlowWebView && flowWebViewUrl && FlowWebViewComponent);
211
211
  const shouldRenderEducationCarousel = Boolean(shouldRenderFlowOverlay && EducationCarouselWebViewComponent);
212
212
  if (devMode) {
213
- console.log(`[GlomoPay RN SDK] Render gates: modal=${shouldShowModal}, flowOverlay=${shouldRenderFlowOverlay}, educationCarouselWebView=${shouldRenderEducationCarousel}, educationCarouselVisible=${showCarousel}, flowWebViewUrl=${flowWebViewUrl || "<empty>"}, educationCarouselUrl=${resolvedEducationCarouselUrl || "<empty>"}`);
213
+ console.log(`[Glomo-RN-SDK LRS] Render gates: modal=${shouldShowModal}, flowOverlay=${shouldRenderFlowOverlay}, educationCarouselWebView=${shouldRenderEducationCarousel}, educationCarouselVisible=${showCarousel}, flowWebViewUrl=${flowWebViewUrl || "<empty>"}, educationCarouselUrl=${resolvedEducationCarouselUrl || "<empty>"}`);
214
214
  }
215
215
  return (<ModalComponent visible={shouldShowModal} animationType='slide' presentationStyle={react_native_1.Platform.OS === "ios" ? "pageSheet" : "fullScreen"} onRequestClose={handleModalBackButton}>
216
216
  <react_native_1.View style={styles.modalContainer}>
@@ -0,0 +1,25 @@
1
+ /** The GlomoPay Standard Checkout Component */
2
+ import React from "react";
3
+ import { type GlomoStandardCheckoutRef, type GlomoStandardCheckoutProps } from "./types/standard-checkout";
4
+ import { type CheckoutAnalyticsTrackers } from "./utils/analytics";
5
+ /**
6
+ * Internal-only props for GlomoStandardCheckout.
7
+ * Used by GlomoSubscriptionsCheckout to inject subscription analytics trackers.
8
+ * Not exported to merchants via index.ts.
9
+ */
10
+ export interface GlomoStandardCheckoutInternalProps extends GlomoStandardCheckoutProps {
11
+ _analyticsTrackers?: CheckoutAnalyticsTrackers;
12
+ _skipOrderIdValidation?: boolean;
13
+ }
14
+ /**
15
+ * Widening the internal type to GlomoStandardCheckoutInternalProps for internal SDK use,
16
+ * then narrowing the public export to GlomoStandardCheckoutProps so merchants cannot
17
+ * pass internal-only props like _analyticsTrackers.
18
+ */
19
+ export declare const GlomoStandardCheckout: React.ForwardRefExoticComponent<GlomoStandardCheckoutProps & React.RefAttributes<GlomoStandardCheckoutRef>>;
20
+ /**
21
+ * Internal reference - accepts GlomoStandardCheckoutInternalProps.
22
+ * Not re-exported from index.ts.
23
+ */
24
+ export declare const GlomoStandardCheckoutInternal: React.ForwardRefExoticComponent<GlomoStandardCheckoutInternalProps & React.RefAttributes<GlomoStandardCheckoutRef>>;
25
+ //# sourceMappingURL=glomo-standard-checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glomo-standard-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-standard-checkout.tsx"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAGnE;;;;GAIG;AACH,MAAM,WAAW,kCAAmC,SAAQ,0BAA0B;IAClF,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC;AAmQD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAiD,KAAK,CAAC,yBAAyB,CAC9G,0BAA0B,GAAG,KAAK,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAC7E,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,qHAEzC,CAAC"}
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ /** The GlomoPay Standard Checkout Component */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.GlomoStandardCheckoutInternal = exports.GlomoStandardCheckout = void 0;
38
+ const react_1 = __importStar(require("react"));
39
+ const react_native_1 = require("react-native");
40
+ const react_native_webview_1 = require("react-native-webview");
41
+ const use_standard_checkout_1 = require("./use-standard-checkout");
42
+ const validation_1 = require("./utils/validation");
43
+ /**
44
+ * The Main GlomoPay Standard Checkout Component
45
+ *
46
+ * @param server - Optional. The SDK server environment. For development builds ONLY.
47
+ * @param publicKey - The public key for the merchant. If it starts with "test_", mock mode will be enabled automatically. Otherwise, live mode is used.
48
+ * @param orderId - The order ID. Always starts with "order_"
49
+ *
50
+ * @param onPaymentSuccess - The success callback with payload, for a successful payment
51
+ * @param onPaymentFailure - The failure callback with payload, for a failed payment
52
+ * @param onPaymentTerminate - Optional callback called when the checkout is terminated either from the webpage (back button or close button) or mobile component (user dismissing the modal on iOS or user pressing the back button on Android)
53
+ *
54
+ * @param onConnectionError - Optional callback for connection/network errors
55
+ * @param onSdkError - Optional callback for handling SDK validation errors and configuration issues
56
+ *
57
+ * @param ref - The ref for the component
58
+ * @param devMode - Turn on to see all logs, warnings, and errors in the console. Off by default
59
+ */
60
+ function GlomoStandardCheckoutComponent({ server, publicKey, orderId, onPaymentSuccess, onPaymentFailure, onConnectionError, onPaymentTerminate, onSdkError, onBankTransferSubmitted, onPayViaBankCompleted, onPayViaBankBankConnectionSuccessful, onUserRefusedCameraPermissions, devMode = false, _analyticsTrackers, _skipOrderIdValidation, }, ref) {
61
+ // Computing mockMode based on the publicKey prefix
62
+ const mockMode = (0, react_1.useMemo)(() => {
63
+ var _a;
64
+ const resolvedMockMode = (_a = publicKey === null || publicKey === void 0 ? void 0 : publicKey.toLowerCase().startsWith("test_")) !== null && _a !== void 0 ? _a : false;
65
+ if (devMode) {
66
+ console.log(`[Glomo-RN-SDK Standard] ${resolvedMockMode ? "Using" : "Not using"} Mock mode for publicKey: ${publicKey}`);
67
+ }
68
+ return resolvedMockMode;
69
+ }, [publicKey, devMode]);
70
+ const { start, status, showCheckout, flowWebViewUrl, showFlowWebView, checkoutUrl, mainWebViewRef, flowWebViewRef, handleMainWebViewMessage, handleFlowWebViewMessage, handleError, handleHttpError, handleNavigationStateChange, handleModalBackButton, handleFlowBack, handlePermissionRequest, injectedMain, injectedFlow, } = (0, use_standard_checkout_1.useStandardCheckout)({
71
+ server,
72
+ publicKey,
73
+ orderId,
74
+ onPaymentSuccess,
75
+ onPaymentFailure,
76
+ onConnectionError,
77
+ onPaymentTerminate,
78
+ onSdkError,
79
+ onBankTransferSubmitted,
80
+ onPayViaBankCompleted,
81
+ onPayViaBankBankConnectionSuccessful,
82
+ onUserRefusedCameraPermissions,
83
+ devMode,
84
+ }, mockMode, { analyticsTrackers: _analyticsTrackers, _skipOrderIdValidation });
85
+ // Exposing the start() and getStatus() methods via the ref
86
+ (0, react_1.useImperativeHandle)(ref, () => ({
87
+ start,
88
+ getStatus: () => status,
89
+ }));
90
+ // Making the WebView component
91
+ const makeWebView = react_1.default.useCallback((ref, url, messageHandler, identifier, injectedJavaScript, injectedJavaScriptBeforeContentLoaded, additionalProps) => {
92
+ // Preventing a render if no injection script is provided
93
+ if (!injectedJavaScript) {
94
+ if (devMode) {
95
+ console.warn(`[Glomo-RN-SDK Standard] JavaScript Injection missing for ${url}. Skipping ${identifier} Render.`);
96
+ }
97
+ return null;
98
+ }
99
+ // Preventing a render if URL is empty or invalid
100
+ if (!url || url.trim() === "") {
101
+ // Redundantly checking for surprise/extreme edge cases
102
+ if (!(0, validation_1.isValidUrl)(url)) {
103
+ if (devMode) {
104
+ console.error(`[Glomo-RN-SDK Standard] Invalid non-empty URL ${url} provided. Skipping ${identifier} Render.`);
105
+ }
106
+ return null;
107
+ }
108
+ if (devMode) {
109
+ console.error(`[Glomo-RN-SDK Standard] Empty or invalid URL provided. Skipping ${identifier} Render.`);
110
+ }
111
+ return null;
112
+ }
113
+ return (<react_native_webview_1.WebView ref={ref} webviewDebuggingEnabled={__DEV__ && devMode} javaScriptEnabled={true} domStorageEnabled={true} onMessage={messageHandler} onError={handleError} onHttpError={handleHttpError} onNavigationStateChange={handleNavigationStateChange} onLoadStart={() => {
114
+ if (devMode) {
115
+ console.log(`[Glomo-RN-SDK Standard] [${identifier}] WebView load started for ${url}`);
116
+ }
117
+ }} onLoadEnd={() => {
118
+ if (devMode) {
119
+ console.log(`[Glomo-RN-SDK Standard] [${identifier}] WebView load ended for ${url}`);
120
+ }
121
+ }} source={{ uri: url }} javaScriptCanOpenWindowsAutomatically={true} setSupportMultipleWindows={true} incognito={true} cacheEnabled={false} cacheMode='LOAD_NO_CACHE' pullToRefreshEnabled={false} limitsNavigationsToAppBoundDomains={false} menuItems={[]} injectedJavaScript={injectedJavaScript} injectedJavaScriptBeforeContentLoaded={injectedJavaScriptBeforeContentLoaded} style={styles.webview} showsHorizontalScrollIndicator={false} showsVerticalScrollIndicator={false} mixedContentMode='always' thirdPartyCookiesEnabled={true} sharedCookiesEnabled={true} allowsInlineMediaPlayback={true} mediaPlaybackRequiresUserAction={false} mediaCapturePermissionGrantType='prompt' allowFileAccess={true} allowUniversalAccessFromFileURLs={true} allowFileAccessFromFileURLs={true} androidLayerType='hardware'
122
+ // @ts-expect-error onPermissionRequest is an Android-only WebView prop not yet in react-native-webview type definitions
123
+ onPermissionRequest={handlePermissionRequest} {...additionalProps}/>);
124
+ }, [handleError, handleHttpError, handleNavigationStateChange, handlePermissionRequest, devMode]);
125
+ const MainWebViewComponent = (0, react_1.useMemo)(() => makeWebView(mainWebViewRef, checkoutUrl, handleMainWebViewMessage, "main", injectedMain), [makeWebView, checkoutUrl, handleMainWebViewMessage, injectedMain, mainWebViewRef]);
126
+ const FlowWebViewComponent = (0, react_1.useMemo)(() => flowWebViewUrl
127
+ ? makeWebView(flowWebViewRef, flowWebViewUrl, handleFlowWebViewMessage, "flow", injectedFlow)
128
+ : null, [makeWebView, flowWebViewUrl, handleFlowWebViewMessage, injectedFlow, flowWebViewRef]);
129
+ const isVisible = showCheckout;
130
+ // Prevent extreme edge cases where validations inside start() do not prevent the flow initialization
131
+ const shouldShowModal = (0, react_1.useMemo)(() => {
132
+ const value = isVisible && (checkoutUrl !== null && checkoutUrl !== void 0 ? checkoutUrl : "").trim().length > 0;
133
+ if (devMode) {
134
+ console.log(`[Glomo-RN-SDK Standard] computed visibilityHook: ${value} for internal switch ${isVisible}, and checkout=${checkoutUrl};`);
135
+ }
136
+ return value;
137
+ }, [isVisible, checkoutUrl, devMode]);
138
+ // Alias to ensure explicit component reference for React Native
139
+ const ModalComponent = react_native_1.Modal;
140
+ /**
141
+ * Deriving render gates from state:
142
+ * shouldRenderFlowOverlay: flow overlay is mounted only when there is an active flow URL
143
+ */
144
+ const shouldRenderFlowOverlay = Boolean(showFlowWebView && flowWebViewUrl && FlowWebViewComponent);
145
+ if (devMode) {
146
+ console.log(`[Glomo-RN-SDK Standard] Render gates: modal=${shouldShowModal}, flowOverlay=${shouldRenderFlowOverlay}, flowWebViewUrl=${flowWebViewUrl || "<empty>"}`);
147
+ }
148
+ return (<ModalComponent visible={shouldShowModal} animationType='slide' presentationStyle={react_native_1.Platform.OS === "ios" ? "pageSheet" : "fullScreen"} onRequestClose={handleModalBackButton}>
149
+ <react_native_1.View style={styles.modalContainer}>
150
+ <react_native_1.View style={styles.mainWebViewContainer}>{MainWebViewComponent}</react_native_1.View>
151
+
152
+ {shouldRenderFlowOverlay && (<react_native_1.View style={styles.flowWebViewContainer}>
153
+ <react_native_1.SafeAreaView style={styles.flowHeader}>
154
+ <react_native_1.TouchableOpacity onPress={handleFlowBack} style={styles.flowBackButton}>
155
+ <react_native_1.Text style={styles.flowBackChevron}>{"\u2039"}</react_native_1.Text>
156
+ </react_native_1.TouchableOpacity>
157
+ </react_native_1.SafeAreaView>
158
+ <react_native_1.View style={styles.flowWebViewContent}>{FlowWebViewComponent}</react_native_1.View>
159
+ </react_native_1.View>)}
160
+ </react_native_1.View>
161
+ </ModalComponent>);
162
+ }
163
+ /**
164
+ * Widening the internal type to GlomoStandardCheckoutInternalProps for internal SDK use,
165
+ * then narrowing the public export to GlomoStandardCheckoutProps so merchants cannot
166
+ * pass internal-only props like _analyticsTrackers.
167
+ */
168
+ exports.GlomoStandardCheckout = (0, react_1.forwardRef)(GlomoStandardCheckoutComponent);
169
+ exports.GlomoStandardCheckout.displayName = "GlomoStandardCheckout";
170
+ /**
171
+ * Internal reference - accepts GlomoStandardCheckoutInternalProps.
172
+ * Not re-exported from index.ts.
173
+ */
174
+ exports.GlomoStandardCheckoutInternal = (0, react_1.forwardRef)(GlomoStandardCheckoutComponent);
175
+ exports.GlomoStandardCheckoutInternal.displayName = "GlomoStandardCheckoutInternal";
176
+ const styles = react_native_1.StyleSheet.create({
177
+ modalContainer: {
178
+ flex: 1,
179
+ backgroundColor: "#fff",
180
+ },
181
+ mainWebViewContainer: {
182
+ flex: 1,
183
+ position: "relative",
184
+ },
185
+ webview: {
186
+ flex: 1,
187
+ },
188
+ flowWebViewContainer: {
189
+ position: "absolute",
190
+ top: 0,
191
+ left: 0,
192
+ right: 0,
193
+ bottom: 0,
194
+ flexDirection: "column",
195
+ backgroundColor: "#fff",
196
+ zIndex: 99999,
197
+ elevation: 99999,
198
+ },
199
+ flowHeader: {
200
+ backgroundColor: "#fff",
201
+ borderBottomWidth: 1,
202
+ borderBottomColor: "#e0e0e0",
203
+ },
204
+ flowBackButton: {
205
+ paddingVertical: 0,
206
+ paddingLeft: 20,
207
+ },
208
+ flowBackChevron: {
209
+ fontSize: 42,
210
+ color: "#333",
211
+ lineHeight: 42,
212
+ },
213
+ flowWebViewContent: {
214
+ flex: 1,
215
+ },
216
+ errorContainer: {
217
+ flex: 1,
218
+ justifyContent: "center",
219
+ alignItems: "center",
220
+ padding: 20,
221
+ backgroundColor: "#fff",
222
+ },
223
+ errorText: {
224
+ color: "#d32f2f",
225
+ fontSize: 14,
226
+ textAlign: "center",
227
+ lineHeight: 20,
228
+ },
229
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GlomoSubscriptionsCheckout - thin wrapper around GlomoStandardCheckout
3
+ * that accepts a subscriptionId (sub_*) instead of an orderId (order_*).
4
+ */
5
+ import React from "react";
6
+ import { type GlomoSubscriptionsCheckoutProps, type GlomoSubscriptionsCheckoutRef } from "./types/subscriptions-checkout";
7
+ export declare const GlomoSubscriptionsCheckout: React.ForwardRefExoticComponent<GlomoSubscriptionsCheckoutProps & React.RefAttributes<GlomoSubscriptionsCheckoutRef>>;
8
+ //# sourceMappingURL=glomo-subscriptions-checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glomo-subscriptions-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-subscriptions-checkout.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAA6D,MAAM,OAAO,CAAC;AAIlF,OAAO,EACH,KAAK,+BAA+B,EACpC,KAAK,6BAA6B,EACrC,MAAM,gCAAgC,CAAC;AAkExC,eAAO,MAAM,0BAA0B,uHAEtC,CAAC"}