@glomopay/react-native-sdk 1.3.5 → 2.0.2

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 +5 -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 +137 -11
  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 +13 -1
  20. package/lib/use-lrs-checkout.d.ts.map +1 -1
  21. package/lib/use-lrs-checkout.js +129 -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 +190 -13
  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 +173 -8
  34. package/src/utils/analytics.ts +29 -0
@@ -1 +1 @@
1
- {"version":3,"file":"use-lrs-checkout.d.ts","sourceRoot":"","sources":["../src/use-lrs-checkout.ts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AgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,OAAe,GAClB,EAAE,qBAAqB,EACxB,QAAQ,EAAE,OAAO,GAClB,oBAAoB,CAs4BtB"}
@@ -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,7 @@ 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]);
399
497
  /** Closes the flow WebView and returns to the main checkout */
400
498
  const handleFlowBack = (0, react_1.useCallback)(() => {
401
499
  if (devMode) {
@@ -403,6 +501,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
403
501
  }
404
502
  setShowFlowWebView(false);
405
503
  setFlowWebViewUrl("");
504
+ setEducationCarouselState("pending");
406
505
  (0, analytics_1.trackWindowClose)("flow", orderId, publicKey, devMode, mockMode, checkoutUrl);
407
506
  }, [devMode, orderId, publicKey, mockMode, checkoutUrl]);
408
507
  /**
@@ -454,6 +553,21 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
454
553
  // This warning was intentionally not gated behind a devMode check to ensure merchants are aware of the strong recommendation to install jail-monkey for enhanced security compliance.
455
554
  console.warn("[GlomoPay RN SDK] Device security library not installed - the SDK won't be able to automatically detect rooted/jailbroken devices. It is HIGHLY recommended to install jail-monkey as per the README, and prevent LRS checkouts from compromised devices.");
456
555
  }
556
+ // Enforcing devMode requirement for development servers
557
+ const resolvedServer = server || "prod";
558
+ if (!devMode && resolvedServer !== "prod") {
559
+ const errors = [
560
+ {
561
+ type: "validation_error",
562
+ message: "Development servers can only be used when devMode is enabled.",
563
+ },
564
+ ];
565
+ (0, validation_1.safeCallback)(onSdkError, [errors], "onSdkError", devMode);
566
+ (0, analytics_1.trackSdkError)(errors, orderId, publicKey, devMode, mockMode, checkoutUrl);
567
+ (0, analytics_1.trackStartFailure)("validation_error", orderId, publicKey, devMode, mockMode, checkoutUrl, jailbreakDetectionInfo);
568
+ setShowCheckout(false);
569
+ return false;
570
+ }
457
571
  // Checking validation errors with detailed field-level messages
458
572
  const errors = [];
459
573
  if (!(0, validation_1.isValidPublicKey)(publicKey)) {
@@ -532,6 +646,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
532
646
  }
533
647
  setShowFlowWebView(false);
534
648
  setFlowWebViewUrl("");
649
+ setEducationCarouselState("pending");
535
650
  setStatus("payment_in_progress");
536
651
  // Tracking successful start
537
652
  (0, analytics_1.trackStartSuccess)(orderId, publicKey, devMode, mockMode, checkoutUrl, jailbreakDetectionInfo);
@@ -545,7 +660,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
545
660
  // Resetting checkout flow if orderId or publicKey are changed
546
661
  (0, react_1.useEffect)(() => {
547
662
  if (orderId && publicKey) {
548
- // Only resetting the checkout flow if the current status is that ofa terminal state
663
+ // Only resetting the checkout flow if the current status is that of a terminal state
549
664
  if (status === "payment_successful" || status === "payment_failed" || status === "payment_cancelled") {
550
665
  if (devMode) {
551
666
  console.log(`[GlomoPay RN SDK] Resetting checkout status ${status} for new orderId ${orderId} and publicKey ${publicKey}`);
@@ -562,6 +677,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
562
677
  setShowCheckout(false);
563
678
  setShowFlowWebView(false);
564
679
  setFlowWebViewUrl("");
680
+ setEducationCarouselState("pending");
565
681
  };
566
682
  }, []);
567
683
  return {
@@ -570,17 +686,22 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
570
686
  showCheckout,
571
687
  flowWebViewUrl,
572
688
  showFlowWebView,
689
+ educationCarouselUrl,
690
+ educationCarouselState,
573
691
  checkoutUrl,
574
692
  mainWebViewRef,
575
693
  flowWebViewRef,
694
+ educationCarouselWebViewRef,
576
695
  handleMainWebViewMessage,
577
696
  handleFlowWebViewMessage,
697
+ handleEducationCarouselWebViewMessage,
578
698
  handleError,
579
699
  handleHttpError,
580
700
  handleNavigationStateChange,
581
701
  handleModalBackButton,
582
702
  handleFlowBack,
583
- injectedMain: injections_1.InjectionScripts.main,
584
- injectedFlow: injections_1.InjectionScripts.flow,
703
+ injectedMain: index_1.InjectionScripts.main,
704
+ injectedFlow: index_1.InjectionScripts.flow,
705
+ injectedEducationCarousel: index_1.InjectionScripts.educationCarousel,
585
706
  };
586
707
  }
@@ -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,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,4BAA4B;AAC5B,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CAAC;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,sBAAsB,CAAC;CAChF;AAuHD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAe,EACxB,QAAQ,GAAE,OAAe,EACzB,MAAM,CAAC,EAAE,MAAM,EACf,sBAAsB,CAAC,EAAE;IACrB,kCAAkC,EAAE,OAAO,CAAC;IAC5C,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAC;CACrC,GACF,IAAI,CAcN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAe,EACxB,QAAQ,GAA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M,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.5",
3
+ "version": "2.0.2",
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
+ }