@glomopay/react-native-sdk 2.0.2 → 3.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 (70) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +261 -310
  3. package/lib/config/base.d.ts +17 -11
  4. package/lib/config/base.d.ts.map +1 -1
  5. package/lib/config/base.js +19 -7
  6. package/lib/config/segment.js +3 -3
  7. package/lib/glomo-checkout.d.ts +8 -0
  8. package/lib/glomo-checkout.d.ts.map +1 -0
  9. package/lib/glomo-checkout.js +69 -0
  10. package/lib/glomo-lrs-checkout.js +9 -9
  11. package/lib/glomo-standard-checkout.d.ts +5 -0
  12. package/lib/glomo-standard-checkout.d.ts.map +1 -0
  13. package/lib/glomo-standard-checkout.js +218 -0
  14. package/lib/index.d.ts +5 -4
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/index.js +7 -5
  17. package/lib/injections/index.d.ts +1 -0
  18. package/lib/injections/index.d.ts.map +1 -1
  19. package/lib/injections/index.js +2 -0
  20. package/lib/injections/webview-flow.injection.d.ts.map +1 -1
  21. package/lib/injections/webview-flow.injection.js +106 -69
  22. package/lib/injections/webview-main.injection.d.ts.map +1 -1
  23. package/lib/injections/webview-main.injection.js +112 -77
  24. package/lib/injections/webview-standard.injection.d.ts +3 -0
  25. package/lib/injections/webview-standard.injection.d.ts.map +1 -0
  26. package/lib/injections/webview-standard.injection.js +214 -0
  27. package/lib/services/order-type-fetcher.d.ts +28 -0
  28. package/lib/services/order-type-fetcher.d.ts.map +1 -0
  29. package/lib/services/order-type-fetcher.js +99 -0
  30. package/lib/types/checkout.d.ts +53 -0
  31. package/lib/types/checkout.d.ts.map +1 -0
  32. package/lib/types/checkout.js +3 -0
  33. package/lib/types/standard-checkout.d.ts +40 -0
  34. package/lib/types/standard-checkout.d.ts.map +1 -0
  35. package/lib/types/standard-checkout.js +3 -0
  36. package/lib/use-glomo-checkout.d.ts +24 -0
  37. package/lib/use-glomo-checkout.d.ts.map +1 -0
  38. package/lib/use-glomo-checkout.js +182 -0
  39. package/lib/use-lrs-checkout.d.ts +9 -4
  40. package/lib/use-lrs-checkout.d.ts.map +1 -1
  41. package/lib/use-lrs-checkout.js +76 -93
  42. package/lib/use-standard-checkout.d.ts +65 -0
  43. package/lib/use-standard-checkout.d.ts.map +1 -0
  44. package/lib/use-standard-checkout.js +832 -0
  45. package/lib/utils/analytics.d.ts +102 -1
  46. package/lib/utils/analytics.d.ts.map +1 -1
  47. package/lib/utils/analytics.js +294 -21
  48. package/lib/utils/device-compliance.js +3 -3
  49. package/lib/utils/validation.d.ts.map +1 -1
  50. package/lib/utils/validation.js +7 -6
  51. package/package.json +3 -2
  52. package/src/config/base.ts +36 -17
  53. package/src/config/segment.ts +3 -3
  54. package/src/glomo-checkout.tsx +73 -0
  55. package/src/glomo-lrs-checkout.tsx +9 -9
  56. package/src/glomo-standard-checkout.tsx +324 -0
  57. package/src/index.ts +13 -7
  58. package/src/injections/index.ts +2 -0
  59. package/src/injections/webview-flow.injection.ts +106 -69
  60. package/src/injections/webview-main.injection.ts +112 -77
  61. package/src/injections/webview-standard.injection.ts +211 -0
  62. package/src/services/order-type-fetcher.ts +86 -0
  63. package/src/types/checkout.ts +65 -0
  64. package/src/types/standard-checkout.ts +49 -0
  65. package/src/use-glomo-checkout.tsx +228 -0
  66. package/src/use-lrs-checkout.tsx +91 -111
  67. package/src/use-standard-checkout.tsx +1185 -0
  68. package/src/utils/analytics.ts +431 -22
  69. package/src/utils/device-compliance.ts +3 -3
  70. package/src/utils/validation.ts +7 -8
@@ -10,8 +10,14 @@
10
10
  * Analytics failures never break the SDK.
11
11
  */
12
12
 
13
+ import { Platform } from "react-native";
13
14
  import { getSegmentClient, isSegmentAvailable, getAnonymousId, getSegmentWriteKey } from "../config/segment";
14
15
 
16
+ /**
17
+ * Flow type for checkout
18
+ */
19
+ export type FlowType = "lrs" | "standard" | "unified";
20
+
15
21
  /**
16
22
  * Common properties that should be included with every event
17
23
  */
@@ -21,7 +27,11 @@ export interface CommonEventProperties {
21
27
  mockMode?: boolean;
22
28
  orderId?: string;
23
29
  publicKey?: string;
24
- lrsUrl?: string;
30
+ checkoutUrl?: string;
31
+ platform: "react-native";
32
+ deviceOS: "ios" | "android" | string;
33
+ deviceOSVersion: string;
34
+ flowType?: FlowType;
25
35
  timestamp?: string;
26
36
  [key: string]: unknown;
27
37
  }
@@ -58,7 +68,8 @@ function getSdkVersion(): string {
58
68
  * @param publicKey - The public key of the merchant
59
69
  * @param devMode - Whether dev mode is enabled
60
70
  * @param mockMode - Whether mock mode is enabled
61
- * @param lrsUrl - The LRS checkout URL
71
+ * @param checkoutUrl - The checkout URL
72
+ * @param flowType - The flow type
62
73
  * @returns Common properties object
63
74
  */
64
75
  function buildCommonProperties(
@@ -66,16 +77,21 @@ function buildCommonProperties(
66
77
  publicKey?: string,
67
78
  devMode: boolean = false,
68
79
  mockMode: boolean = false,
69
- lrsUrl?: string
80
+ checkoutUrl?: string,
81
+ flowType?: FlowType
70
82
  ): CommonEventProperties {
71
83
  return {
72
84
  orderId,
73
85
  publicKey,
74
- lrsUrl,
86
+ checkoutUrl,
75
87
  devMode,
76
88
  mockMode,
89
+ platform: "react-native",
90
+ deviceOS: Platform.OS,
91
+ deviceOSVersion: String(Platform.Version),
77
92
  sdkVersion: getSdkVersion(),
78
93
  timestamp: new Date().toISOString(),
94
+ ...(flowType && { flowType }),
79
95
  };
80
96
  }
81
97
 
@@ -97,7 +113,7 @@ async function trackEvent(
97
113
  // Returning early if GlomoPay Segment is not available
98
114
  if (!isSegmentAvailable()) {
99
115
  if (devMode) {
100
- console.log(`[GlomoPay RN SDK] Segment not available. Event "${eventName}" not tracked.`, properties);
116
+ console.log(`[Glomo-RN-SDK] Segment not available. Event "${eventName}" not tracked.`, properties);
101
117
  }
102
118
  return;
103
119
  }
@@ -109,7 +125,7 @@ async function trackEvent(
109
125
  // Double-checking if the client exists (TypeScript safety)
110
126
  if (!client || !anonymousId) {
111
127
  if (devMode) {
112
- console.log(`[GlomoPay RN SDK] Segment client is null. Event "${eventName}" not tracked.`);
128
+ console.log(`[Glomo-RN-SDK] Segment client is null. Event "${eventName}" not tracked.`);
113
129
  }
114
130
  return;
115
131
  }
@@ -139,12 +155,12 @@ async function trackEvent(
139
155
  await client.post("/track", payload);
140
156
 
141
157
  if (devMode) {
142
- console.log(`[GlomoPay RN SDK] Tracked event: ${eventName}`, eventProperties);
158
+ console.log(`[Glomo-RN-SDK] Tracked event: ${eventName}`, eventProperties);
143
159
  }
144
160
  } catch (error) {
145
161
  if (devMode) {
146
162
  const errorMessage = error instanceof Error ? error.message : String(error);
147
- console.error(`[GlomoPay RN SDK] Error tracking event ${eventName}:`, errorMessage);
163
+ console.error(`[Glomo-RN-SDK] Error tracking event ${eventName}:`, errorMessage);
148
164
  }
149
165
  // Silently failing - GlomoPay analytics should never break the SDK
150
166
  }
@@ -181,7 +197,7 @@ export function trackStartSuccess(
181
197
  // Async tracking to avoid blocking the main thread
182
198
  trackEvent("LRS Checkout Started", properties, devMode).catch((error) => {
183
199
  if (devMode) {
184
- console.error(`[GlomoPay RN SDK] Event tracking error on start() success:`, error);
200
+ console.error(`[Glomo-RN-SDK] Event tracking error on start() success:`, error);
185
201
  }
186
202
  });
187
203
  }
@@ -220,7 +236,7 @@ export function trackStartAttempt(
220
236
  // Async tracking to avoid blocking the main thread
221
237
  trackEvent("LRS Checkout Start Attempted", properties, devMode).catch((error) => {
222
238
  if (devMode) {
223
- console.error(`[GlomoPay RN SDK] Event tracking error on start() attempt:`, error);
239
+ console.error(`[Glomo-RN-SDK] Event tracking error on start() attempt:`, error);
224
240
  }
225
241
  });
226
242
  }
@@ -259,7 +275,7 @@ export function trackStartFailure(
259
275
  // Async tracking to avoid blocking the main thread
260
276
  trackEvent("LRS Checkout Start Failed", properties, devMode).catch((error) => {
261
277
  if (devMode) {
262
- console.error(`[GlomoPay RN SDK] Event tracking error on start() failure:`, error);
278
+ console.error(`[Glomo-RN-SDK] Event tracking error on start() failure:`, error);
263
279
  }
264
280
  });
265
281
  }
@@ -292,7 +308,7 @@ export function trackWindowOpen(
292
308
  // Async tracking to avoid blocking the main thread
293
309
  trackEvent("LRS Checkout Window Open", properties, devMode).catch((error) => {
294
310
  if (devMode) {
295
- console.error(`[GlomoPay RN SDK] Event tracking error on window.open:`, error);
311
+ console.error(`[Glomo-RN-SDK] Event tracking error on window.open:`, error);
296
312
  }
297
313
  });
298
314
  }
@@ -322,7 +338,7 @@ export function trackWindowClose(
322
338
  // Async tracking to avoid blocking the main thread
323
339
  trackEvent("LRS Checkout Window Close", properties, devMode).catch((error) => {
324
340
  if (devMode) {
325
- console.error(`[GlomoPay RN SDK] Event tracking error on window.close:`, error);
341
+ console.error(`[Glomo-RN-SDK] Event tracking error on window.close:`, error);
326
342
  }
327
343
  });
328
344
  }
@@ -377,7 +393,7 @@ export function trackInvalidMessageReceived(
377
393
  // Async tracking to avoid blocking the main thread
378
394
  trackEvent("LRS Checkout Invalid Message Received", properties, devMode).catch((error) => {
379
395
  if (devMode) {
380
- console.error(`[GlomoPay RN SDK] Event tracking error for invalid message received event:`, error);
396
+ console.error(`[Glomo-RN-SDK] Event tracking error for invalid message received event:`, error);
381
397
  }
382
398
  });
383
399
  }
@@ -407,7 +423,7 @@ export function trackPaymentSuccess(
407
423
  // Async tracking to avoid blocking the main thread
408
424
  trackEvent("LRS Payment Success", properties, devMode).catch((error) => {
409
425
  if (devMode) {
410
- console.error(`[GlomoPay RN SDK] Event tracking error on payment success callback:`, error);
426
+ console.error(`[Glomo-RN-SDK] Event tracking error on payment success callback:`, error);
411
427
  }
412
428
  });
413
429
  }
@@ -437,7 +453,7 @@ export function trackPaymentFailure(
437
453
  // Async tracking to avoid blocking the main thread
438
454
  trackEvent("LRS Payment Failure", properties, devMode).catch((error) => {
439
455
  if (devMode) {
440
- console.error(`[GlomoPay RN SDK] Event tracking error on payment failure callback:`, error);
456
+ console.error(`[Glomo-RN-SDK] Event tracking error on payment failure callback:`, error);
441
457
  }
442
458
  });
443
459
  }
@@ -467,7 +483,7 @@ export function trackPaymentTerminate(
467
483
  // Async tracking to avoid blocking the main thread
468
484
  trackEvent("LRS Payment Terminated", properties, devMode).catch((error) => {
469
485
  if (devMode) {
470
- console.error(`[GlomoPay RN SDK] Event tracking error on payment terminate callback:`, error);
486
+ console.error(`[Glomo-RN-SDK] Event tracking error on payment terminate callback:`, error);
471
487
  }
472
488
  });
473
489
  }
@@ -497,7 +513,7 @@ export function trackConnectionError(
497
513
  // Async tracking to avoid blocking the main thread
498
514
  trackEvent("LRS Connection Error", properties, devMode).catch((error) => {
499
515
  if (devMode) {
500
- console.error(`[GlomoPay RN SDK] Event tracking error on connection error callback:`, error);
516
+ console.error(`[Glomo-RN-SDK] Event tracking error on connection error callback:`, error);
501
517
  }
502
518
  });
503
519
  }
@@ -526,7 +542,36 @@ export function trackEducationStepsShown(
526
542
  };
527
543
  trackEvent("LRS Has Education Steps", properties, devMode).catch((error) => {
528
544
  if (devMode) {
529
- console.error(`[GlomoPay RN SDK] Event tracking error on education steps shown event:`, error);
545
+ console.error(`[Glomo-RN-SDK] Event tracking error on education steps shown event:`, error);
546
+ }
547
+ });
548
+ }
549
+
550
+ /**
551
+ * Tracks when the education carousel URL is invalid and the carousel cannot be shown
552
+ *
553
+ * @param orderId - The order ID
554
+ * @param publicKey - The public key of the merchant
555
+ * @param devMode - Whether dev mode is enabled
556
+ * @param mockMode - Whether mock mode is enabled
557
+ * @param lrsUrl - The LRS checkout URL
558
+ * @param reason - Why the carousel failed to show
559
+ */
560
+ export function trackEducationStepsFailedToShow(
561
+ orderId: string,
562
+ publicKey: string,
563
+ devMode: boolean = false,
564
+ mockMode: boolean = false,
565
+ lrsUrl?: string,
566
+ reason?: string
567
+ ): void {
568
+ const properties = {
569
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
570
+ ...(reason && { reason }),
571
+ };
572
+ trackEvent("LRS Education Steps Failed To Show", properties, devMode).catch((error) => {
573
+ if (devMode) {
574
+ console.error(`[Glomo-RN-SDK] Event tracking error on education steps failed to show event:`, error);
530
575
  }
531
576
  });
532
577
  }
@@ -557,7 +602,371 @@ export function trackSdkError(
557
602
  // Async tracking to avoid blocking the main thread
558
603
  trackEvent("LRS SDK Error", properties, devMode).catch((error) => {
559
604
  if (devMode) {
560
- console.error(`[GlomoPay RN SDK] Event tracking error on SDK error callback:`, error);
605
+ console.error(`[Glomo-RN-SDK] Event tracking error on SDK error callback:`, error);
606
+ }
607
+ });
608
+ }
609
+
610
+ // ---------------------------------------------------------------------------
611
+ // Standard Checkout Trackers
612
+ // ---------------------------------------------------------------------------
613
+
614
+ /**
615
+ * Tracks when the standard checkout start() method has been called successfully
616
+ */
617
+ export function trackStandardStartSuccess(
618
+ orderId: string,
619
+ publicKey: string,
620
+ devMode: boolean = false,
621
+ mockMode: boolean = false,
622
+ standardUrl?: string,
623
+ jailbreakDetectionInfo?: {
624
+ jailbreakDetectionLibraryInstalled: boolean;
625
+ jailbreakDetected: boolean | null;
626
+ }
627
+ ): void {
628
+ const properties = {
629
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
630
+ ...(jailbreakDetectionInfo && {
631
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
632
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
633
+ }),
634
+ };
635
+ trackEvent("Standard Checkout Started", properties, devMode).catch(() => {});
636
+ }
637
+
638
+ /**
639
+ * Tracks when the standard checkout start() method is called (attempted)
640
+ */
641
+ export function trackStandardStartAttempt(
642
+ status: string,
643
+ orderId: string,
644
+ publicKey: string,
645
+ devMode: boolean = false,
646
+ mockMode: boolean = false,
647
+ standardUrl?: string,
648
+ jailbreakDetectionInfo?: {
649
+ jailbreakDetectionLibraryInstalled: boolean;
650
+ jailbreakDetected: boolean | null;
651
+ }
652
+ ): void {
653
+ const properties = {
654
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
655
+ status,
656
+ ...(jailbreakDetectionInfo && {
657
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
658
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
659
+ }),
660
+ };
661
+ trackEvent("Standard Checkout Start Attempted", properties, devMode).catch(() => {});
662
+ }
663
+
664
+ /**
665
+ * Tracks when the standard checkout start() method fails
666
+ */
667
+ export function trackStandardStartFailure(
668
+ reason: "device_forbidden" | "validation_error" | "payment_successful" | "invalid_status" | "invalid_url",
669
+ orderId?: string,
670
+ publicKey?: string,
671
+ devMode: boolean = false,
672
+ mockMode: boolean = false,
673
+ standardUrl?: string,
674
+ jailbreakDetectionInfo?: {
675
+ jailbreakDetectionLibraryInstalled: boolean;
676
+ jailbreakDetected: boolean | null;
677
+ }
678
+ ): void {
679
+ const properties = {
680
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
681
+ failureReason: reason,
682
+ ...(jailbreakDetectionInfo && {
683
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
684
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
685
+ }),
686
+ };
687
+ trackEvent("Standard Checkout Start Failed", properties, devMode).catch(() => {});
688
+ }
689
+
690
+ /**
691
+ * Tracks when window.open is intercepted from the standard checkout WebView
692
+ */
693
+ export function trackStandardWindowOpen(
694
+ source: "main" | "flow",
695
+ url: string,
696
+ orderId: string,
697
+ publicKey: string,
698
+ devMode: boolean = false,
699
+ mockMode: boolean = false,
700
+ standardUrl?: string
701
+ ): void {
702
+ const properties = {
703
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
704
+ source,
705
+ url,
706
+ };
707
+ trackEvent("Standard Checkout Window Open", properties, devMode).catch(() => {});
708
+ }
709
+
710
+ /**
711
+ * Tracks when window.close is intercepted from the standard checkout WebView
712
+ */
713
+ export function trackStandardWindowClose(
714
+ source: "main" | "flow",
715
+ orderId: string,
716
+ publicKey: string,
717
+ devMode: boolean = false,
718
+ mockMode: boolean = false,
719
+ standardUrl?: string
720
+ ): void {
721
+ const properties = {
722
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
723
+ source,
724
+ };
725
+ trackEvent("Standard Checkout Window Close", properties, devMode).catch(() => {});
726
+ }
727
+
728
+ /**
729
+ * Tracks when invalid message data is received from a standard checkout WebView
730
+ */
731
+ export function trackStandardInvalidMessageReceived(
732
+ webviewType: "main" | "flow",
733
+ data: unknown,
734
+ url: string | undefined,
735
+ orderId: string,
736
+ publicKey: string,
737
+ devMode: boolean = false,
738
+ mockMode: boolean = false,
739
+ standardUrl?: string
740
+ ): void {
741
+ let dataString: string;
742
+ try {
743
+ if (data === null) {
744
+ dataString = "null";
745
+ } else if (data === undefined) {
746
+ dataString = "undefined";
747
+ } else if (typeof data === "string") {
748
+ dataString = data;
749
+ } else if (typeof data === "object") {
750
+ dataString = JSON.stringify(data);
751
+ } else {
752
+ dataString = String(data);
753
+ }
754
+ } catch {
755
+ dataString = "[unable to stringify]";
756
+ }
757
+
758
+ const properties = {
759
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
760
+ webviewType,
761
+ data: dataString,
762
+ dataType: data === null ? "null" : typeof data,
763
+ ...(url && { url }),
764
+ };
765
+ trackEvent("Standard Checkout Invalid Message Received", properties, devMode).catch(() => {});
766
+ }
767
+
768
+ /**
769
+ * Tracks when standard checkout onPaymentSuccess callback is invoked
770
+ */
771
+ export function trackStandardPaymentSuccess(
772
+ orderId: string,
773
+ paymentId: string,
774
+ publicKey: string,
775
+ devMode: boolean = false,
776
+ mockMode: boolean = false,
777
+ standardUrl?: string
778
+ ): void {
779
+ const properties = {
780
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
781
+ paymentId,
782
+ };
783
+ trackEvent("Standard Payment Success", properties, devMode).catch(() => {});
784
+ }
785
+
786
+ /**
787
+ * Tracks when standard checkout onPaymentFailure callback is invoked
788
+ */
789
+ export function trackStandardPaymentFailure(
790
+ orderId: string,
791
+ paymentId: string,
792
+ publicKey: string,
793
+ devMode: boolean = false,
794
+ mockMode: boolean = false,
795
+ standardUrl?: string
796
+ ): void {
797
+ const properties = {
798
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
799
+ paymentId,
800
+ };
801
+ trackEvent("Standard Payment Failure", properties, devMode).catch(() => {});
802
+ }
803
+
804
+ /**
805
+ * Tracks when standard checkout onPaymentTerminate callback is invoked
806
+ */
807
+ export function trackStandardPaymentTerminate(
808
+ orderId: string,
809
+ source: "user_dismiss" | "back_button" | "checkout_closed",
810
+ publicKey: string,
811
+ devMode: boolean = false,
812
+ mockMode: boolean = false,
813
+ standardUrl?: string
814
+ ): void {
815
+ const properties = {
816
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
817
+ terminationSource: source,
818
+ };
819
+ trackEvent("Standard Payment Terminated", properties, devMode).catch(() => {});
820
+ }
821
+
822
+ /**
823
+ * Tracks when standard checkout onConnectionError callback is invoked
824
+ */
825
+ export function trackStandardConnectionError(
826
+ orderId: string,
827
+ errorCode: number | undefined,
828
+ publicKey: string,
829
+ devMode: boolean = false,
830
+ mockMode: boolean = false,
831
+ standardUrl?: string
832
+ ): void {
833
+ const properties = {
834
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
835
+ ...(errorCode !== undefined && { errorCode }),
836
+ };
837
+ trackEvent("Standard Connection Error", properties, devMode).catch(() => {});
838
+ }
839
+
840
+ /**
841
+ * Tracks when standard checkout onSdkError callback is invoked
842
+ */
843
+ export function trackStandardSdkError(
844
+ errors: Array<SdkError>,
845
+ orderId?: string,
846
+ publicKey?: string,
847
+ devMode: boolean = false,
848
+ mockMode: boolean = false,
849
+ standardUrl?: string
850
+ ): void {
851
+ const properties = {
852
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
853
+ errors,
854
+ errorCount: errors.length,
855
+ };
856
+ trackEvent("Standard SDK Error", properties, devMode).catch(() => {});
857
+ }
858
+
859
+ export function trackStandardBankTransferSubmitted(
860
+ orderId: string,
861
+ publicKey: string,
862
+ devMode: boolean = false,
863
+ mockMode: boolean = false,
864
+ standardUrl?: string
865
+ ): void {
866
+ const properties = {
867
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
868
+ };
869
+ trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch(() => {});
870
+ }
871
+
872
+ export function trackStandardPayViaBankCompleted(
873
+ orderId: string,
874
+ publicKey: string,
875
+ status: string,
876
+ devMode: boolean = false,
877
+ mockMode: boolean = false,
878
+ standardUrl?: string
879
+ ): void {
880
+ const properties = {
881
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
882
+ payViaBankStatus: status,
883
+ };
884
+ trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch(() => {});
885
+ }
886
+
887
+ export function trackStandardPayViaBankBankConnectionSuccessful(
888
+ orderId: string,
889
+ publicKey: string,
890
+ bankIdentifier: string,
891
+ devMode: boolean = false,
892
+ mockMode: boolean = false,
893
+ standardUrl?: string
894
+ ): void {
895
+ const properties = {
896
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
897
+ bankIdentifier,
898
+ };
899
+ trackEvent("Standard Pay Via Bank Bank Connection Successful", properties, devMode).catch(() => {});
900
+ }
901
+
902
+ // ---------------------------------------------------------------------------
903
+ // Order Type Detection Trackers (Unified Flow)
904
+ // ---------------------------------------------------------------------------
905
+
906
+ /**
907
+ * Tracks when order type detection starts
908
+ *
909
+ * @param orderId - The order ID
910
+ * @param publicKey - The public key of the merchant
911
+ * @param devMode - Whether dev mode is enabled
912
+ */
913
+ export function trackOrderTypeDetectionStarted(orderId: string, publicKey: string, devMode: boolean = false): void {
914
+ const properties = {
915
+ ...buildCommonProperties(orderId, publicKey, devMode, false, undefined, "unified"),
916
+ };
917
+ trackEvent("Order Type Detection Started", properties, devMode).catch((error) => {
918
+ if (devMode) {
919
+ console.error(`[Glomo-RN-SDK] Event tracking error on order type detection started:`, error);
920
+ }
921
+ });
922
+ }
923
+
924
+ /**
925
+ * Tracks when order type detection resolves successfully
926
+ *
927
+ * @param orderId - The order ID
928
+ * @param publicKey - The public key of the merchant
929
+ * @param resolvedType - The resolved order type ("lrs" or "standard")
930
+ * @param devMode - Whether dev mode is enabled
931
+ */
932
+ export function trackOrderTypeDetectionResolved(
933
+ orderId: string,
934
+ publicKey: string,
935
+ resolvedType: "lrs" | "standard",
936
+ devMode: boolean = false
937
+ ): void {
938
+ const eventName = resolvedType === "lrs" ? "Order Type Resolved LRS" : "Order Type Resolved Standard";
939
+ const properties = {
940
+ ...buildCommonProperties(orderId, publicKey, devMode, false, undefined, "unified"),
941
+ };
942
+ trackEvent(eventName, properties, devMode).catch((error) => {
943
+ if (devMode) {
944
+ console.error(`[Glomo-RN-SDK] Event tracking error on order type detection resolved:`, error);
945
+ }
946
+ });
947
+ }
948
+
949
+ /**
950
+ * Tracks when order type detection fails
951
+ *
952
+ * @param orderId - The order ID
953
+ * @param publicKey - The public key of the merchant
954
+ * @param error - The error message
955
+ * @param devMode - Whether dev mode is enabled
956
+ */
957
+ export function trackOrderTypeDetectionFailed(
958
+ orderId: string,
959
+ publicKey: string,
960
+ error: string,
961
+ devMode: boolean = false
962
+ ): void {
963
+ const properties = {
964
+ ...buildCommonProperties(orderId, publicKey, devMode, false, undefined, "unified"),
965
+ error,
966
+ };
967
+ trackEvent("Order Type Detection Failed", properties, devMode).catch((trackError) => {
968
+ if (devMode) {
969
+ console.error(`[Glomo-RN-SDK] Event tracking error on order type detection failed:`, trackError);
561
970
  }
562
971
  });
563
972
  }
@@ -574,9 +983,9 @@ export function checkAnalyticsStatus(devMode: boolean = false): boolean {
574
983
 
575
984
  if (devMode) {
576
985
  if (available) {
577
- console.log("[GlomoPay RN SDK] Analytics: ENABLED");
986
+ console.log("[Glomo-RN-SDK] Analytics: ENABLED");
578
987
  } else {
579
- console.log("[GlomoPay RN SDK] Analytics: DISABLED");
988
+ console.log("[Glomo-RN-SDK] Analytics: DISABLED");
580
989
  }
581
990
  }
582
991
 
@@ -39,7 +39,7 @@ export function checkDeviceCompliance(devMode: boolean = false): boolean | null
39
39
  if (!JailMonkey) {
40
40
  if (devMode) {
41
41
  console.log(
42
- "[GlomoPay RN SDK] jail-monkey not available. Device compliance check skipped. " +
42
+ "[Glomo-RN-SDK] jail-monkey not available. Device compliance check skipped. " +
43
43
  "Install jail-monkey for enhanced security compliance."
44
44
  );
45
45
  }
@@ -52,14 +52,14 @@ export function checkDeviceCompliance(devMode: boolean = false): boolean | null
52
52
  const isCompromised = JailMonkey.isJailBroken();
53
53
  if (devMode) {
54
54
  console.log(
55
- `[GlomoPay RN SDK] Device compliance check: ${isCompromised ? "FAILED (device compromised)" : "PASSED"}`
55
+ `[Glomo-RN-SDK] Device compliance check: ${isCompromised ? "FAILED (device compromised)" : "PASSED"}`
56
56
  );
57
57
  }
58
58
  return isCompromised;
59
59
  } catch (error) {
60
60
  if (devMode) {
61
61
  const errorMessage = error instanceof Error ? error.message : String(error);
62
- console.error("[GlomoPay RN SDK] Error checking device compliance:", errorMessage);
62
+ console.error("[Glomo-RN-SDK] Error checking device compliance:", errorMessage);
63
63
  }
64
64
  // On error, allowing checkout to proceed (fail open strategy)
65
65
  return null;
@@ -60,14 +60,13 @@ export function isValidPaymentPayload(payload: unknown): payload is {
60
60
  return false;
61
61
  }
62
62
  const p = payload as Record<string, unknown>;
63
- return (
64
- typeof p.orderId === "string" &&
65
- p.orderId.length > 0 &&
66
- typeof p.paymentId === "string" &&
67
- p.paymentId.length > 0 &&
68
- typeof p.signature === "string" &&
69
- p.signature.length > 0
70
- );
63
+ /**
64
+ * Accept payloads where orderId, paymentId, and signature are strings.
65
+ * Empty strings are allowed because some flows (e.g. open banking / pay via bank)
66
+ * send payment.success with empty fields when the payment completes on the
67
+ * bank's side before the checkout backend has resolved ids.
68
+ */
69
+ return typeof p.orderId === "string" && typeof p.paymentId === "string" && typeof p.signature === "string";
71
70
  }
72
71
 
73
72
  /**