@glomopay/react-native-sdk 1.3.4 → 2.0.1

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 (34) hide show
  1. package/README.md +9 -4
  2. package/lib/config/base.d.ts +14 -5
  3. package/lib/config/base.d.ts.map +1 -1
  4. package/lib/config/base.js +22 -6
  5. package/lib/glomo-lrs-checkout.d.ts.map +1 -1
  6. package/lib/glomo-lrs-checkout.js +156 -9
  7. package/lib/index.d.ts +1 -0
  8. package/lib/index.d.ts.map +1 -1
  9. package/lib/injections/index.d.ts +1 -0
  10. package/lib/injections/index.d.ts.map +1 -1
  11. package/lib/injections/index.js +2 -0
  12. package/lib/injections/webview-education-carousel.injection.d.ts +3 -0
  13. package/lib/injections/webview-education-carousel.injection.d.ts.map +1 -0
  14. package/lib/injections/webview-education-carousel.injection.js +157 -0
  15. package/lib/injections/webview-flow.injection.d.ts.map +1 -1
  16. package/lib/injections/webview-flow.injection.js +3 -5
  17. package/lib/injections/webview-main.injection.d.ts.map +1 -1
  18. package/lib/injections/webview-main.injection.js +3 -5
  19. package/lib/use-lrs-checkout.d.ts +14 -1
  20. package/lib/use-lrs-checkout.d.ts.map +1 -1
  21. package/lib/use-lrs-checkout.js +124 -8
  22. package/lib/utils/analytics.d.ts +11 -0
  23. package/lib/utils/analytics.d.ts.map +1 -1
  24. package/lib/utils/analytics.js +22 -0
  25. package/package.json +1 -1
  26. package/src/config/base.ts +35 -5
  27. package/src/glomo-lrs-checkout.tsx +206 -10
  28. package/src/index.ts +1 -0
  29. package/src/injections/index.ts +2 -0
  30. package/src/injections/webview-education-carousel.injection.ts +154 -0
  31. package/src/injections/webview-flow.injection.ts +3 -5
  32. package/src/injections/webview-main.injection.ts +3 -5
  33. package/src/use-lrs-checkout.tsx +161 -8
  34. package/src/utils/analytics.ts +29 -0
@@ -2,9 +2,16 @@
2
2
  import React from "react";
3
3
  import { type NativeSyntheticEvent } from "react-native";
4
4
  import { WebViewNavigation, WebViewMessageEvent, type WebView } from "react-native-webview";
5
+ import { type GlomoLrsServer } from "./config/base";
5
6
  import { type SdkError } from "./utils/analytics";
6
7
  /** LRS checkout statuses */
7
8
  export type LrsCheckoutStatus = "ready" | "payment_in_progress" | "payment_successful" | "payment_failed" | "payment_cancelled";
9
+ /**
10
+ * Tracks whether the education carousel WebView has signalled that it has content to show.
11
+ * - "pending": waiting for the carousel to report its state (default/reset value)
12
+ * - "hasContent": carousel sent lrs.has_education_steps and should be shown to the user
13
+ */
14
+ export type EducationCarouselState = "pending" | "hasContent";
8
15
  /** The payload for a successful or failed payment */
9
16
  export interface GlomoLrsCheckoutPayload {
10
17
  orderId: string;
@@ -13,7 +20,7 @@ export interface GlomoLrsCheckoutPayload {
13
20
  }
14
21
  /** The options for the useLrsCheckout hook */
15
22
  export interface UseLrsCheckoutOptions {
16
- server?: string;
23
+ server?: GlomoLrsServer;
17
24
  publicKey: string;
18
25
  orderId: string;
19
26
  onPaymentSuccess: (payload: GlomoLrsCheckoutPayload) => void;
@@ -30,11 +37,15 @@ export interface UseLrsCheckoutReturn {
30
37
  showCheckout: boolean;
31
38
  flowWebViewUrl: string;
32
39
  showFlowWebView: boolean;
40
+ educationCarouselUrl: string;
41
+ educationCarouselState: EducationCarouselState;
33
42
  checkoutUrl: string;
34
43
  mainWebViewRef: React.RefObject<WebView>;
35
44
  flowWebViewRef: React.RefObject<WebView>;
45
+ educationCarouselWebViewRef: React.RefObject<WebView>;
36
46
  handleMainWebViewMessage: (event: WebViewMessageEvent) => void;
37
47
  handleFlowWebViewMessage: (event: WebViewMessageEvent) => void;
48
+ handleEducationCarouselWebViewMessage: (event: WebViewMessageEvent) => void;
38
49
  handleError: (syntheticEvent: NativeSyntheticEvent<{
39
50
  code?: number;
40
51
  domain?: string;
@@ -46,8 +57,10 @@ export interface UseLrsCheckoutReturn {
46
57
  }>) => void;
47
58
  handleNavigationStateChange: (navState: WebViewNavigation) => void;
48
59
  handleModalBackButton: () => void;
60
+ handleFlowBack: () => void;
49
61
  injectedMain?: string;
50
62
  injectedFlow?: string;
63
+ injectedEducationCarousel?: string;
51
64
  }
52
65
  /** The main SDK hook for the GlomoPay LRS Checkout flow */
53
66
  export declare function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymentFailure, onConnectionError, onPaymentTerminate, onSdkError, devMode, }: UseLrsCheckoutOptions, mockMode: boolean): UseLrsCheckoutReturn;
@@ -1 +1 @@
1
- {"version":3,"file":"use-lrs-checkout.d.ts","sourceRoot":"","sources":["../src/use-lrs-checkout.tsx"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAO5F,OAAO,EAYH,KAAK,QAAQ,EAChB,MAAM,mBAAmB,CAAC;AAE3B,4BAA4B;AAC5B,MAAM,MAAM,iBAAiB,GAEvB,OAAO,GAGP,qBAAqB,GAGrB,oBAAoB,GAGpB,gBAAgB,GAGhB,mBAAmB,CAAC;AAE1B,qDAAqD;AACrD,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC7D,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC7D,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,kBAAkB,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AAK,IAAI,CAAC;IACnE,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAC1B,EACI,MAAM,EACN,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,OAAe,GAClB,EAAE,qBAAqB,EACxB,QAAQ,EAAE,OAAO,GAClB,oBAAoB,CA82BtB"}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.useLrsCheckout = useLrsCheckout;
5
5
  const react_1 = require("react");
6
6
  const react_native_1 = require("react-native");
7
- const injections_1 = require("./injections");
7
+ const index_1 = require("./injections/index");
8
8
  const segment_1 = require("./config/segment");
9
9
  const base_1 = require("./config/base");
10
10
  const validation_1 = require("./utils/validation");
@@ -15,8 +15,10 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
15
15
  // Refs for the WebViews
16
16
  const mainWebViewRef = (0, react_1.useRef)(null);
17
17
  const flowWebViewRef = (0, react_1.useRef)(null);
18
- // Using the server prop if provided, otherwise using the default production URL
19
- const baseCheckoutUrl = (0, react_1.useMemo)(() => server !== null && server !== void 0 ? server : base_1.DEFAULT_BASE_CHECKOUT_URL, [server]);
18
+ const educationCarouselWebViewRef = (0, react_1.useRef)(null);
19
+ // Resolving checkout and carousel URLs from the selected SDK server
20
+ const serverConfig = (0, react_1.useMemo)(() => (0, base_1.resolveServerConfig)(server), [server]);
21
+ const baseCheckoutUrl = serverConfig.checkoutBaseUrl;
20
22
  /**
21
23
  * The main checkout URL for the LRS flow
22
24
  * In future, this needs to come from the LRS Checkout SDK.
@@ -66,12 +68,60 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
66
68
  return "";
67
69
  }
68
70
  }, [baseCheckoutUrl, orderId, publicKey, mockMode, devMode, onSdkError]);
71
+ /**
72
+ * The education carousel URL, built from the server config with the current orderId and publicKey.
73
+ * Loaded in a hidden WebView alongside the flow WebView; shown only once the carousel signals it has content.
74
+ */
75
+ const educationCarouselUrl = (0, react_1.useMemo)(() => {
76
+ try {
77
+ const baseEducationCarouselUrl = serverConfig.educationCarouselBaseUrl;
78
+ const separator = baseEducationCarouselUrl.includes("?") ? "&" : "?";
79
+ const finalUrl = `${baseEducationCarouselUrl}${separator}orderId=${encodeURIComponent(orderId)}` +
80
+ `&publicKey=${encodeURIComponent(publicKey)}`;
81
+ if (!(0, validation_1.isValidUrl)(finalUrl)) {
82
+ if (devMode) {
83
+ console.error("[GlomoPay RN SDK] Generated invalid education carousel URL:", finalUrl);
84
+ }
85
+ const errors = [
86
+ {
87
+ type: "validation_error",
88
+ message: "Generated invalid education carousel URL",
89
+ },
90
+ ];
91
+ (0, analytics_1.trackSdkError)(errors, orderId, publicKey, devMode, mockMode, finalUrl ? finalUrl : finalUrl === null ? "null" : "undefined");
92
+ return "";
93
+ }
94
+ if (devMode) {
95
+ console.log("[GlomoPay RN SDK] Education Carousel URL:", finalUrl);
96
+ }
97
+ return finalUrl;
98
+ }
99
+ catch (error) {
100
+ if (devMode) {
101
+ console.error("[GlomoPay RN SDK] Error building education carousel URL:", error);
102
+ }
103
+ const errors = [
104
+ {
105
+ type: "validation_error",
106
+ message: `Error building education carousel URL: ${error instanceof Error ? error.message : "Unknown error"}`,
107
+ },
108
+ ];
109
+ (0, analytics_1.trackSdkError)(errors, orderId, publicKey, devMode, mockMode, "");
110
+ return "";
111
+ }
112
+ }, [serverConfig, orderId, publicKey, devMode, mockMode]);
69
113
  // Checkout status state
70
114
  const [status, setStatus] = (0, react_1.useState)("ready");
71
115
  // Visibility state for the main checkout modal
72
116
  const [showCheckout, setShowCheckout] = (0, react_1.useState)(false);
73
117
  const [showFlowWebView, setShowFlowWebView] = (0, react_1.useState)(false);
74
118
  const [flowWebViewUrl, setFlowWebViewUrl] = (0, react_1.useState)("");
119
+ const [educationCarouselState, setEducationCarouselState] = (0, react_1.useState)("pending");
120
+ (0, react_1.useEffect)(() => {
121
+ if (devMode) {
122
+ console.log(`[GlomoPay RN SDK] Carousel state snapshot: status=${status}, showCheckout=${showCheckout}, showFlowWebView=${showFlowWebView}, flowWebViewUrl=${flowWebViewUrl || "<empty>"}, educationCarouselState=${educationCarouselState}, educationCarouselUrl=${educationCarouselUrl || "<empty>"}`);
123
+ }
124
+ }, [devMode, status, showCheckout, showFlowWebView, flowWebViewUrl, educationCarouselState, educationCarouselUrl]);
75
125
  // Handler for the WebView errors
76
126
  const handleError = (0, react_1.useCallback)((syntheticEvent) => {
77
127
  try {
@@ -100,6 +150,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
100
150
  setShowCheckout(false);
101
151
  setShowFlowWebView(false);
102
152
  setFlowWebViewUrl("");
153
+ setEducationCarouselState("pending");
103
154
  // Calling onConnectionError callback if provided
104
155
  (0, validation_1.safeCallback)(onConnectionError, [nativeEvent], "onConnectionError", devMode);
105
156
  // Tracking connection error
@@ -116,7 +167,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
116
167
  console.error("[GlomoPay RN SDK] Error in handleError:", error);
117
168
  }
118
169
  }
119
- }, [devMode, onConnectionError, checkoutUrl]);
170
+ }, [devMode, onConnectionError, checkoutUrl, orderId, publicKey, mockMode]);
120
171
  // Handler for the WebView HTTP errors
121
172
  const handleHttpError = (0, react_1.useCallback)((syntheticEvent) => {
122
173
  try {
@@ -163,6 +214,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
163
214
  }
164
215
  setFlowWebViewUrl(url);
165
216
  setShowFlowWebView(true);
217
+ setEducationCarouselState("pending");
166
218
  // Tracking window.open interception
167
219
  (0, analytics_1.trackWindowOpen)("main", url, orderId, publicKey, devMode, mockMode, checkoutUrl);
168
220
  }
@@ -179,6 +231,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
179
231
  }
180
232
  setShowFlowWebView(false);
181
233
  setFlowWebViewUrl("");
234
+ setEducationCarouselState("pending");
182
235
  // Tracking window.close interception
183
236
  (0, analytics_1.trackWindowClose)("main", orderId, publicKey, devMode, mockMode, checkoutUrl);
184
237
  return;
@@ -197,6 +250,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
197
250
  setShowCheckout(false);
198
251
  setShowFlowWebView(false);
199
252
  setFlowWebViewUrl("");
253
+ setEducationCarouselState("pending");
200
254
  setStatus("payment_successful");
201
255
  (0, validation_1.safeCallback)(onPaymentSuccess, [payload], "onPaymentSuccess", devMode);
202
256
  // Tracking payment success callback
@@ -219,6 +273,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
219
273
  setShowCheckout(false);
220
274
  setShowFlowWebView(false);
221
275
  setFlowWebViewUrl("");
276
+ setEducationCarouselState("pending");
222
277
  setStatus("payment_failed");
223
278
  (0, validation_1.safeCallback)(onPaymentFailure, [payload], "onPaymentFailure", devMode);
224
279
  // Tracking payment failure callback
@@ -239,6 +294,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
239
294
  setShowCheckout(false);
240
295
  setShowFlowWebView(false);
241
296
  setFlowWebViewUrl("");
297
+ setEducationCarouselState("pending");
242
298
  (0, validation_1.safeCallback)(onPaymentTerminate, [], "onPaymentTerminate", devMode);
243
299
  // Tracking payment terminate callback
244
300
  (0, analytics_1.trackPaymentTerminate)(orderId, "checkout_closed", publicKey, devMode, mockMode, checkoutUrl);
@@ -282,6 +338,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
282
338
  console.log(`[GlomoPay RN SDK] window.open called from FlowWebView: ${url}`);
283
339
  }
284
340
  setFlowWebViewUrl(url);
341
+ setEducationCarouselState("pending");
285
342
  // Tracking window.open interception
286
343
  (0, analytics_1.trackWindowOpen)("flow", url, orderId, publicKey, devMode, mockMode, checkoutUrl);
287
344
  }
@@ -298,6 +355,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
298
355
  }
299
356
  setShowFlowWebView(false);
300
357
  setFlowWebViewUrl("");
358
+ setEducationCarouselState("pending");
301
359
  // Tracking window.close interception
302
360
  (0, analytics_1.trackWindowClose)("flow", orderId, publicKey, devMode, mockMode, checkoutUrl);
303
361
  return;
@@ -315,6 +373,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
315
373
  setShowFlowWebView(false);
316
374
  setShowCheckout(false);
317
375
  setFlowWebViewUrl("");
376
+ setEducationCarouselState("pending");
318
377
  setStatus("payment_successful");
319
378
  (0, validation_1.safeCallback)(onPaymentSuccess, [payload], "onPaymentSuccess", devMode);
320
379
  // Tracking payment success callback
@@ -337,6 +396,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
337
396
  setShowFlowWebView(false);
338
397
  setShowCheckout(false);
339
398
  setFlowWebViewUrl("");
399
+ setEducationCarouselState("pending");
340
400
  setStatus("payment_failed");
341
401
  (0, validation_1.safeCallback)(onPaymentFailure, [payload], "onPaymentFailure", devMode);
342
402
  // Tracking payment failure callback
@@ -357,6 +417,43 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
357
417
  }
358
418
  }
359
419
  }, [onPaymentSuccess, onPaymentFailure, devMode, mockMode, orderId, publicKey, flowWebViewUrl, checkoutUrl]);
420
+ // Handler for the education carousel WebView messages
421
+ const handleEducationCarouselWebViewMessage = (0, react_1.useCallback)((event) => {
422
+ var _a;
423
+ try {
424
+ const data = (_a = event.nativeEvent) === null || _a === void 0 ? void 0 : _a.data;
425
+ if (!data || typeof data !== "string") {
426
+ if (devMode) {
427
+ console.warn("[GlomoPay RN SDK] Invalid message data from EducationCarouselWebView");
428
+ }
429
+ return;
430
+ }
431
+ const message = JSON.parse(data);
432
+ if (devMode) {
433
+ console.log("[GlomoPay RN SDK] EducationCarouselWebView Message received:", message.type, message);
434
+ }
435
+ if (message.type === "console") {
436
+ if (devMode) {
437
+ console.log(`[GlomoPay RN SDK] [EducationCarousel] ${message.message}`);
438
+ }
439
+ return;
440
+ }
441
+ if (message.type === "lrs.has_education_steps") {
442
+ const nextState = "hasContent";
443
+ if (devMode) {
444
+ console.log(`[GlomoPay RN SDK] Education carousel signal received: value=${String(message.value)} source=${message.source || "unknown"} payload=${JSON.stringify(message.payload || {})}`);
445
+ }
446
+ (0, analytics_1.trackEducationStepsShown)(orderId, publicKey, devMode, mockMode, checkoutUrl, message.source);
447
+ setEducationCarouselState(nextState);
448
+ return;
449
+ }
450
+ }
451
+ catch (error) {
452
+ if (devMode) {
453
+ console.error("[GlomoPay RN SDK] Error parsing EducationCarouselWebView message:", error);
454
+ }
455
+ }
456
+ }, [checkoutUrl, devMode, mockMode, orderId, publicKey]);
360
457
  // Handler for the navigation state changes
361
458
  const handleNavigationStateChange = (0, react_1.useCallback)((navState) => {
362
459
  if (devMode) {
@@ -372,6 +469,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
372
469
  if (showFlowWebView) {
373
470
  setShowFlowWebView(false);
374
471
  setFlowWebViewUrl("");
472
+ setEducationCarouselState("pending");
375
473
  }
376
474
  setShowCheckout(false);
377
475
  if (status === "payment_in_progress") {
@@ -395,7 +493,17 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
395
493
  console.error("[GlomoPay RN SDK] Error in handleModalBackButton:", error);
396
494
  }
397
495
  }
398
- }, [showFlowWebView, devMode, onPaymentTerminate, status, orderId, mockMode, checkoutUrl]);
496
+ }, [showFlowWebView, devMode, onPaymentTerminate, status, orderId, publicKey, mockMode, checkoutUrl]);
497
+ /** Closes the flow WebView and returns to the main checkout */
498
+ const handleFlowBack = (0, react_1.useCallback)(() => {
499
+ if (devMode) {
500
+ console.log("[GlomoPay RN SDK] Flow WebView back button pressed");
501
+ }
502
+ setShowFlowWebView(false);
503
+ setFlowWebViewUrl("");
504
+ setEducationCarouselState("pending");
505
+ (0, analytics_1.trackWindowClose)("flow", orderId, publicKey, devMode, mockMode, checkoutUrl);
506
+ }, [devMode, orderId, publicKey, mockMode, checkoutUrl]);
399
507
  /**
400
508
  * Initiator method for the LRS Checkout flow.
401
509
  * Using a ref, the LRS flow can be started by calling this method.
@@ -523,6 +631,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
523
631
  }
524
632
  setShowFlowWebView(false);
525
633
  setFlowWebViewUrl("");
634
+ setEducationCarouselState("pending");
526
635
  setStatus("payment_in_progress");
527
636
  // Tracking successful start
528
637
  (0, analytics_1.trackStartSuccess)(orderId, publicKey, devMode, mockMode, checkoutUrl, jailbreakDetectionInfo);
@@ -536,7 +645,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
536
645
  // Resetting checkout flow if orderId or publicKey are changed
537
646
  (0, react_1.useEffect)(() => {
538
647
  if (orderId && publicKey) {
539
- // Only resetting the checkout flow if the current status is that ofa terminal state
648
+ // Only resetting the checkout flow if the current status is that of a terminal state
540
649
  if (status === "payment_successful" || status === "payment_failed" || status === "payment_cancelled") {
541
650
  if (devMode) {
542
651
  console.log(`[GlomoPay RN SDK] Resetting checkout status ${status} for new orderId ${orderId} and publicKey ${publicKey}`);
@@ -553,6 +662,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
553
662
  setShowCheckout(false);
554
663
  setShowFlowWebView(false);
555
664
  setFlowWebViewUrl("");
665
+ setEducationCarouselState("pending");
556
666
  };
557
667
  }, []);
558
668
  return {
@@ -561,16 +671,22 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
561
671
  showCheckout,
562
672
  flowWebViewUrl,
563
673
  showFlowWebView,
674
+ educationCarouselUrl,
675
+ educationCarouselState,
564
676
  checkoutUrl,
565
677
  mainWebViewRef,
566
678
  flowWebViewRef,
679
+ educationCarouselWebViewRef,
567
680
  handleMainWebViewMessage,
568
681
  handleFlowWebViewMessage,
682
+ handleEducationCarouselWebViewMessage,
569
683
  handleError,
570
684
  handleHttpError,
571
685
  handleNavigationStateChange,
572
686
  handleModalBackButton,
573
- injectedMain: injections_1.InjectionScripts.main,
574
- injectedFlow: injections_1.InjectionScripts.flow,
687
+ handleFlowBack,
688
+ injectedMain: index_1.InjectionScripts.main,
689
+ injectedFlow: index_1.InjectionScripts.flow,
690
+ injectedEducationCarousel: index_1.InjectionScripts.educationCarousel,
575
691
  };
576
692
  }
@@ -152,6 +152,17 @@ export declare function trackPaymentTerminate(orderId: string, source: "user_dis
152
152
  * @param lrsUrl - The LRS checkout URL
153
153
  */
154
154
  export declare function trackConnectionError(orderId: string, errorCode: number | undefined, publicKey: string, devMode?: boolean, mockMode?: boolean, lrsUrl?: string): void;
155
+ /**
156
+ * Tracks when the education carousel reports that it has visible education steps
157
+ *
158
+ * @param orderId - The order ID
159
+ * @param publicKey - The public key of the merchant
160
+ * @param devMode - Whether dev mode is enabled
161
+ * @param mockMode - Whether mock mode is enabled
162
+ * @param lrsUrl - The LRS checkout URL
163
+ * @param source - Where the carousel event originated
164
+ */
165
+ export declare function trackEducationStepsShown(orderId: string, publicKey: string, devMode?: boolean, mockMode?: boolean, lrsUrl?: string, source?: string): void;
155
166
  /**
156
167
  * Tracks when onSdkError callback is invoked
157
168
  *
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/utils/analytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,M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B,IAAI,CAWN;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,cAAc,GAAG,aAAa,GAAG,iBAAiB,EAC1D,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAe,EACxB,QAAQ,GAAE,OAAe,EACzB,MAAM,CAAC,EAAE,MAAM,GAChB,IAAI,CAWN;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAe,EACxB,QAAQ,GAAE,OAAe,EACzB,MAAM,CAAC,EAAE,MAAM,GAChB,IAAI,CAWN;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAe,EACxB,QAAQ,GAAE,OAAe,EACzB,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAChB,IAAI,CAUN;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CACzB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,GAAE,OAAe,EACxB,QAAQ,GAAE,OAAe,EACzB,MAAM,CAAC,EAAE,MAAM,GAChB,IAAI,CAYN;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,OAAe,GAAG,OAAO,CAYtE"}
@@ -21,6 +21,7 @@ exports.trackPaymentSuccess = trackPaymentSuccess;
21
21
  exports.trackPaymentFailure = trackPaymentFailure;
22
22
  exports.trackPaymentTerminate = trackPaymentTerminate;
23
23
  exports.trackConnectionError = trackConnectionError;
24
+ exports.trackEducationStepsShown = trackEducationStepsShown;
24
25
  exports.trackSdkError = trackSdkError;
25
26
  exports.checkAnalyticsStatus = checkAnalyticsStatus;
26
27
  const segment_1 = require("../config/segment");
@@ -386,6 +387,27 @@ function trackConnectionError(orderId, errorCode, publicKey, devMode = false, mo
386
387
  }
387
388
  });
388
389
  }
390
+ /**
391
+ * Tracks when the education carousel reports that it has visible education steps
392
+ *
393
+ * @param orderId - The order ID
394
+ * @param publicKey - The public key of the merchant
395
+ * @param devMode - Whether dev mode is enabled
396
+ * @param mockMode - Whether mock mode is enabled
397
+ * @param lrsUrl - The LRS checkout URL
398
+ * @param source - Where the carousel event originated
399
+ */
400
+ function trackEducationStepsShown(orderId, publicKey, devMode = false, mockMode = false, lrsUrl, source) {
401
+ const properties = {
402
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
403
+ ...(source && { source }),
404
+ };
405
+ trackEvent("LRS Has Education Steps", properties, devMode).catch((error) => {
406
+ if (devMode) {
407
+ console.error(`[GlomoPay RN SDK] Event tracking error on education steps shown event:`, error);
408
+ }
409
+ });
410
+ }
389
411
  /**
390
412
  * Tracks when onSdkError callback is invoked
391
413
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glomopay/react-native-sdk",
3
- "version": "1.3.4",
3
+ "version": "2.0.1",
4
4
  "description": "The React Native SDK for GlomoPay",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
@@ -3,8 +3,38 @@
3
3
  * This file contains the default base configuration variables for the GlomoPay RN SDK.
4
4
  */
5
5
 
6
- /**
7
- * The default URL points to the production environment.
8
- * - DEFAULT_BASE_CHECKOUT_URL: The default base checkout URL for the LRS checkout flow.
9
- */
10
- export const DEFAULT_BASE_CHECKOUT_URL = "https://lrs-checkout.glomopay.com/";
6
+ /** The publicly documented server environments for the SDK */
7
+ export type GlomoLrsServer = "prod" | "staging";
8
+
9
+ /** Internal extension that adds "local" for development use — not exported */
10
+ type InternalGlomoLrsServer = GlomoLrsServer | "local";
11
+
12
+ /** Base URLs for a given server environment */
13
+ export interface GlomoLrsServerConfig {
14
+ checkoutBaseUrl: string;
15
+ educationCarouselBaseUrl: string;
16
+ }
17
+
18
+ export const DEFAULT_SERVER: InternalGlomoLrsServer = "prod";
19
+
20
+ export const SERVER_CONFIGS: Record<InternalGlomoLrsServer, GlomoLrsServerConfig> = {
21
+ prod: {
22
+ checkoutBaseUrl: "https://lrs-checkout.glomopay.com/",
23
+ educationCarouselBaseUrl: "https://glomopay-utilities.web.app/lrs-education-carousel/",
24
+ },
25
+ staging: {
26
+ checkoutBaseUrl: "https://lrs-checkout-page-staging.web.app/",
27
+ educationCarouselBaseUrl: "https://glomopay-utilities-staging.web.app/lrs-education-carousel/",
28
+ },
29
+ local: {
30
+ checkoutBaseUrl: "http://localhost:6870/",
31
+ educationCarouselBaseUrl: "http://localhost:6871/lrs-education-carousel/",
32
+ },
33
+ };
34
+
35
+ /** Returns the server config for the given environment, falling back to the default (prod) server */
36
+ export function resolveServerConfig(server?: InternalGlomoLrsServer): GlomoLrsServerConfig {
37
+ const resolvedServer = server && server in SERVER_CONFIGS ? server : DEFAULT_SERVER;
38
+
39
+ return SERVER_CONFIGS[resolvedServer];
40
+ }