@glomopay/react-native-sdk 3.0.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -2
- package/MIGRATION.md +129 -0
- package/README.md +176 -126
- package/lib/glomo-checkout.d.ts +2 -1
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +25 -3
- package/lib/glomo-lrs-checkout.d.ts +1 -1
- package/lib/glomo-lrs-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.d.ts +20 -0
- package/lib/glomo-standard-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.js +15 -6
- package/lib/glomo-subscriptions-checkout.d.ts +8 -0
- package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
- package/lib/glomo-subscriptions-checkout.js +85 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -3
- package/lib/types/checkout.d.ts +33 -22
- package/lib/types/checkout.d.ts.map +1 -1
- package/lib/types/checkout.js +12 -1
- package/lib/types/standard-checkout.d.ts +3 -7
- package/lib/types/standard-checkout.d.ts.map +1 -1
- package/lib/types/subscriptions-checkout.d.ts +29 -0
- package/lib/types/subscriptions-checkout.d.ts.map +1 -0
- package/lib/types/subscriptions-checkout.js +3 -0
- package/lib/use-glomo-checkout.d.ts +34 -4
- package/lib/use-glomo-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.js +92 -13
- package/lib/use-lrs-checkout.d.ts +1 -1
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.d.ts +14 -9
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +74 -85
- package/lib/utils/analytics.d.ts +86 -3
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +344 -22
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +0 -1
- package/package.json +15 -4
- package/src/glomo-checkout.tsx +65 -9
- package/src/glomo-lrs-checkout.tsx +1 -1
- package/src/glomo-standard-checkout.tsx +35 -10
- package/src/glomo-subscriptions-checkout.tsx +83 -0
- package/src/index.ts +5 -5
- package/src/types/checkout.ts +28 -20
- package/src/types/standard-checkout.ts +3 -5
- package/src/types/subscriptions-checkout.ts +31 -0
- package/src/use-glomo-checkout.tsx +158 -17
- package/src/use-lrs-checkout.tsx +1 -1
- package/src/use-standard-checkout.tsx +94 -153
- package/src/utils/analytics.ts +469 -31
- package/src/utils/device-compliance.ts +0 -1
|
@@ -10,25 +10,9 @@ import { initializeSegment } from "./config/segment";
|
|
|
10
10
|
import { resolveServerConfig, type GlomoServer } from "./config/base";
|
|
11
11
|
import { isValidPublicKey, isValidOrderId, isValidUrl, isValidPaymentPayload, safeCallback } from "./utils/validation";
|
|
12
12
|
import { checkDeviceCompliance, isComplianceCheckAvailable } from "./utils/device-compliance";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
trackStandardStartFailure,
|
|
17
|
-
trackStandardWindowOpen,
|
|
18
|
-
trackStandardWindowClose,
|
|
19
|
-
trackStandardPaymentSuccess,
|
|
20
|
-
trackStandardPaymentFailure,
|
|
21
|
-
trackStandardPaymentTerminate,
|
|
22
|
-
trackStandardConnectionError,
|
|
23
|
-
trackStandardSdkError,
|
|
24
|
-
trackStandardInvalidMessageReceived,
|
|
25
|
-
trackStandardBankTransferSubmitted,
|
|
26
|
-
trackStandardPayViaBankCompleted,
|
|
27
|
-
trackStandardPayViaBankBankConnectionSuccessful,
|
|
28
|
-
type SdkError,
|
|
29
|
-
} from "./utils/analytics";
|
|
30
|
-
|
|
31
|
-
import { type GlomoBankTransferPayload, type GlomoPayViaBankConnectionPayload } from "./types/checkout";
|
|
13
|
+
import { type SdkError, type CheckoutAnalyticsTrackers, standardCheckoutTrackers } from "./utils/analytics";
|
|
14
|
+
|
|
15
|
+
import { ASYNC_PAYMENT_EVENTS, type GlomoUserJourneyCompletedPayload } from "./types/checkout";
|
|
32
16
|
import { type StandardCheckoutStatus, type GlomoStandardCheckoutPayload } from "./types/standard-checkout";
|
|
33
17
|
|
|
34
18
|
/** Android-only WebView permission request, not yet in react-native-webview type definitions */
|
|
@@ -47,10 +31,8 @@ export interface UseStandardCheckoutOptions {
|
|
|
47
31
|
onPaymentFailure: (payload: GlomoStandardCheckoutPayload) => void;
|
|
48
32
|
onConnectionError?: (error: unknown) => void;
|
|
49
33
|
onPaymentTerminate?: () => void;
|
|
50
|
-
onSdkError
|
|
51
|
-
|
|
52
|
-
onPayViaBankCompleted?: (payload: { status: string }) => void;
|
|
53
|
-
onPayViaBankBankConnectionSuccessful?: (payload: GlomoPayViaBankConnectionPayload | null | undefined) => void;
|
|
34
|
+
onSdkError: (error: Array<SdkError>) => void;
|
|
35
|
+
onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
|
|
54
36
|
onUserRefusedCameraPermissions?: () => void;
|
|
55
37
|
devMode?: boolean;
|
|
56
38
|
}
|
|
@@ -79,6 +61,16 @@ export interface UseStandardCheckoutReturn {
|
|
|
79
61
|
injectedFlow?: string;
|
|
80
62
|
}
|
|
81
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Internal options for useStandardCheckout.
|
|
66
|
+
* Used by subscription checkout to inject subscription-specific analytics trackers.
|
|
67
|
+
* Not exported to merchants.
|
|
68
|
+
*/
|
|
69
|
+
export interface UseStandardCheckoutInternalOptions {
|
|
70
|
+
analyticsTrackers?: CheckoutAnalyticsTrackers;
|
|
71
|
+
_skipOrderIdValidation?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
82
74
|
/** The main SDK hook for the GlomoPay Standard Checkout flow */
|
|
83
75
|
export function useStandardCheckout(
|
|
84
76
|
{
|
|
@@ -90,14 +82,15 @@ export function useStandardCheckout(
|
|
|
90
82
|
onConnectionError,
|
|
91
83
|
onPaymentTerminate,
|
|
92
84
|
onSdkError,
|
|
93
|
-
|
|
94
|
-
onPayViaBankCompleted,
|
|
95
|
-
onPayViaBankBankConnectionSuccessful,
|
|
85
|
+
onUserJourneyCompleted,
|
|
96
86
|
onUserRefusedCameraPermissions,
|
|
97
87
|
devMode = false,
|
|
98
88
|
}: UseStandardCheckoutOptions,
|
|
99
|
-
mockMode: boolean
|
|
89
|
+
mockMode: boolean,
|
|
90
|
+
internalOptions?: UseStandardCheckoutInternalOptions
|
|
100
91
|
): UseStandardCheckoutReturn {
|
|
92
|
+
// Resolving analytics trackers - defaults to standard, subscription flow overrides
|
|
93
|
+
const trackers = internalOptions?.analyticsTrackers ?? standardCheckoutTrackers;
|
|
101
94
|
// Refs for the WebViews
|
|
102
95
|
const mainWebViewRef = useRef<WebView>(null);
|
|
103
96
|
const flowWebViewRef = useRef<WebView>(null);
|
|
@@ -204,7 +197,14 @@ export function useStandardCheckout(
|
|
|
204
197
|
// Calling onConnectionError callback if provided
|
|
205
198
|
safeCallback(onConnectionError, [nativeEvent], "onConnectionError", devMode);
|
|
206
199
|
// Tracking connection error
|
|
207
|
-
|
|
200
|
+
trackers.trackConnectionError(
|
|
201
|
+
orderId,
|
|
202
|
+
nativeEvent?.code,
|
|
203
|
+
publicKey,
|
|
204
|
+
devMode,
|
|
205
|
+
mockMode,
|
|
206
|
+
checkoutUrl
|
|
207
|
+
);
|
|
208
208
|
} else {
|
|
209
209
|
if (devMode) {
|
|
210
210
|
console.error("[Glomo-RN-SDK Standard] WebView error:", nativeEvent);
|
|
@@ -216,7 +216,7 @@ export function useStandardCheckout(
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
},
|
|
219
|
-
[devMode, onConnectionError, checkoutUrl, orderId, publicKey, mockMode]
|
|
219
|
+
[devMode, onConnectionError, checkoutUrl, orderId, publicKey, mockMode, trackers]
|
|
220
220
|
);
|
|
221
221
|
|
|
222
222
|
// Handler for the WebView HTTP errors
|
|
@@ -252,7 +252,7 @@ export function useStandardCheckout(
|
|
|
252
252
|
console.warn("[Glomo-RN-SDK Standard] Invalid message data from MainWebView");
|
|
253
253
|
}
|
|
254
254
|
// Tracking invalid message received
|
|
255
|
-
|
|
255
|
+
trackers.trackInvalidMessageReceived(
|
|
256
256
|
"main",
|
|
257
257
|
data,
|
|
258
258
|
checkoutUrl,
|
|
@@ -289,7 +289,7 @@ export function useStandardCheckout(
|
|
|
289
289
|
setFlowWebViewUrl(url);
|
|
290
290
|
setShowFlowWebView(true);
|
|
291
291
|
// Tracking window.open interception
|
|
292
|
-
|
|
292
|
+
trackers.trackWindowOpen("main", url, orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
293
293
|
} else {
|
|
294
294
|
if (devMode) {
|
|
295
295
|
console.log(
|
|
@@ -310,7 +310,7 @@ export function useStandardCheckout(
|
|
|
310
310
|
setShowFlowWebView(false);
|
|
311
311
|
setFlowWebViewUrl("");
|
|
312
312
|
// Tracking window.close interception
|
|
313
|
-
|
|
313
|
+
trackers.trackWindowClose("main", orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
314
314
|
return;
|
|
315
315
|
}
|
|
316
316
|
|
|
@@ -334,7 +334,7 @@ export function useStandardCheckout(
|
|
|
334
334
|
setStatus("payment_successful");
|
|
335
335
|
safeCallback(onPaymentSuccess, [payload], "onPaymentSuccess", devMode);
|
|
336
336
|
// Tracking payment success callback
|
|
337
|
-
|
|
337
|
+
trackers.trackPaymentSuccess(
|
|
338
338
|
payload.orderId,
|
|
339
339
|
payload.paymentId,
|
|
340
340
|
publicKey,
|
|
@@ -365,7 +365,7 @@ export function useStandardCheckout(
|
|
|
365
365
|
setStatus("payment_failed");
|
|
366
366
|
safeCallback(onPaymentFailure, [payload], "onPaymentFailure", devMode);
|
|
367
367
|
// Tracking payment failure callback
|
|
368
|
-
|
|
368
|
+
trackers.trackPaymentFailure(
|
|
369
369
|
payload.orderId,
|
|
370
370
|
payload.paymentId,
|
|
371
371
|
publicKey,
|
|
@@ -391,50 +391,14 @@ export function useStandardCheckout(
|
|
|
391
391
|
setShowFlowWebView(false);
|
|
392
392
|
setFlowWebViewUrl("");
|
|
393
393
|
setStatus("bank_transfer_submitted");
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
],
|
|
403
|
-
"onBankTransferSubmitted",
|
|
404
|
-
devMode
|
|
405
|
-
);
|
|
406
|
-
trackStandardBankTransferSubmitted(orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Handling pay via bank - bank connection successful event (informational, no status change)
|
|
411
|
-
if (messageType === "pay_via_bank.bank.connection_successful") {
|
|
412
|
-
const payload = messageData?.payload;
|
|
413
|
-
if (devMode) {
|
|
414
|
-
console.log("[Glomo-RN-SDK Standard] Pay via bank - bank connection successful:", payload);
|
|
415
|
-
}
|
|
416
|
-
safeCallback(
|
|
417
|
-
onPayViaBankBankConnectionSuccessful,
|
|
418
|
-
[
|
|
419
|
-
{
|
|
420
|
-
bankIdentifier: payload?.bankIdentifier ?? "",
|
|
421
|
-
cooldownPeriodInMinutes: payload?.cooldownPeriodInMinutes ?? 0,
|
|
422
|
-
bankName: payload?.bankName ?? "",
|
|
423
|
-
bankImageSrc: payload?.bankImageSrc ?? "",
|
|
424
|
-
bankImageAlt: payload?.bankImageAlt ?? "",
|
|
425
|
-
},
|
|
426
|
-
],
|
|
427
|
-
"onPayViaBankBankConnectionSuccessful",
|
|
428
|
-
devMode
|
|
429
|
-
);
|
|
430
|
-
trackStandardPayViaBankBankConnectionSuccessful(
|
|
431
|
-
orderId,
|
|
432
|
-
publicKey,
|
|
433
|
-
payload?.bankIdentifier ?? "",
|
|
434
|
-
devMode,
|
|
435
|
-
mockMode,
|
|
436
|
-
checkoutUrl
|
|
437
|
-
);
|
|
394
|
+
const journeyPayload: GlomoUserJourneyCompletedPayload = {
|
|
395
|
+
journeyType: ASYNC_PAYMENT_EVENTS.BANK_TRANSFER_SUBMITTED,
|
|
396
|
+
orderId: payload?.orderId,
|
|
397
|
+
senderAccountNumber: payload?.senderAccountNumber,
|
|
398
|
+
transactionReference: payload?.transactionReference,
|
|
399
|
+
};
|
|
400
|
+
safeCallback(onUserJourneyCompleted, [journeyPayload], "onUserJourneyCompleted", devMode);
|
|
401
|
+
trackers.trackBankTransferSubmitted(orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
438
402
|
return;
|
|
439
403
|
}
|
|
440
404
|
|
|
@@ -464,13 +428,13 @@ export function useStandardCheckout(
|
|
|
464
428
|
setShowCheckout(false);
|
|
465
429
|
setFlowWebViewUrl("");
|
|
466
430
|
setStatus("pay_via_bank_completed");
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
"
|
|
471
|
-
|
|
472
|
-
);
|
|
473
|
-
|
|
431
|
+
const journeyPayload: GlomoUserJourneyCompletedPayload = {
|
|
432
|
+
journeyType: ASYNC_PAYMENT_EVENTS.PAY_VIA_BANK_COMPLETED,
|
|
433
|
+
orderId: payload?.orderId,
|
|
434
|
+
status: payload?.status ?? "unknown",
|
|
435
|
+
};
|
|
436
|
+
safeCallback(onUserJourneyCompleted, [journeyPayload], "onUserJourneyCompleted", devMode);
|
|
437
|
+
trackers.trackPayViaBankCompleted(
|
|
474
438
|
orderId,
|
|
475
439
|
publicKey,
|
|
476
440
|
payload?.status ?? "unknown",
|
|
@@ -491,7 +455,7 @@ export function useStandardCheckout(
|
|
|
491
455
|
setFlowWebViewUrl("");
|
|
492
456
|
safeCallback(onPaymentTerminate, [], "onPaymentTerminate", devMode);
|
|
493
457
|
// Tracking payment terminate callback
|
|
494
|
-
|
|
458
|
+
trackers.trackPaymentTerminate(
|
|
495
459
|
orderId,
|
|
496
460
|
"checkout_closed",
|
|
497
461
|
publicKey,
|
|
@@ -512,14 +476,13 @@ export function useStandardCheckout(
|
|
|
512
476
|
onPaymentSuccess,
|
|
513
477
|
onPaymentFailure,
|
|
514
478
|
onPaymentTerminate,
|
|
515
|
-
|
|
516
|
-
onPayViaBankCompleted,
|
|
517
|
-
onPayViaBankBankConnectionSuccessful,
|
|
479
|
+
onUserJourneyCompleted,
|
|
518
480
|
devMode,
|
|
519
481
|
mockMode,
|
|
520
482
|
orderId,
|
|
521
483
|
publicKey,
|
|
522
484
|
checkoutUrl,
|
|
485
|
+
trackers,
|
|
523
486
|
]
|
|
524
487
|
);
|
|
525
488
|
|
|
@@ -538,7 +501,7 @@ export function useStandardCheckout(
|
|
|
538
501
|
console.warn("[Glomo-RN-SDK Standard] Invalid message data from FlowWebView");
|
|
539
502
|
}
|
|
540
503
|
// Tracking invalid message received
|
|
541
|
-
|
|
504
|
+
trackers.trackInvalidMessageReceived(
|
|
542
505
|
"flow",
|
|
543
506
|
data,
|
|
544
507
|
flowWebViewUrl,
|
|
@@ -573,7 +536,7 @@ export function useStandardCheckout(
|
|
|
573
536
|
}
|
|
574
537
|
setFlowWebViewUrl(url);
|
|
575
538
|
// Tracking window.open interception
|
|
576
|
-
|
|
539
|
+
trackers.trackWindowOpen("flow", url, orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
577
540
|
} else {
|
|
578
541
|
if (devMode) {
|
|
579
542
|
console.log(
|
|
@@ -594,7 +557,7 @@ export function useStandardCheckout(
|
|
|
594
557
|
setShowFlowWebView(false);
|
|
595
558
|
setFlowWebViewUrl("");
|
|
596
559
|
// Tracking window.close interception
|
|
597
|
-
|
|
560
|
+
trackers.trackWindowClose("flow", orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
598
561
|
return;
|
|
599
562
|
}
|
|
600
563
|
|
|
@@ -618,7 +581,7 @@ export function useStandardCheckout(
|
|
|
618
581
|
setStatus("payment_successful");
|
|
619
582
|
safeCallback(onPaymentSuccess, [payload], "onPaymentSuccess", devMode);
|
|
620
583
|
// Tracking payment success callback
|
|
621
|
-
|
|
584
|
+
trackers.trackPaymentSuccess(
|
|
622
585
|
payload.orderId,
|
|
623
586
|
payload.paymentId,
|
|
624
587
|
publicKey,
|
|
@@ -652,7 +615,7 @@ export function useStandardCheckout(
|
|
|
652
615
|
setStatus("payment_failed");
|
|
653
616
|
safeCallback(onPaymentFailure, [payload], "onPaymentFailure", devMode);
|
|
654
617
|
// Tracking payment failure callback
|
|
655
|
-
|
|
618
|
+
trackers.trackPaymentFailure(
|
|
656
619
|
payload.orderId,
|
|
657
620
|
payload.paymentId,
|
|
658
621
|
publicKey,
|
|
@@ -671,40 +634,6 @@ export function useStandardCheckout(
|
|
|
671
634
|
return;
|
|
672
635
|
}
|
|
673
636
|
|
|
674
|
-
// Handling pay via bank - bank connection successful event from the flow WebView
|
|
675
|
-
if (messageType === "pay_via_bank.bank.connection_successful") {
|
|
676
|
-
const payload = messageData?.payload;
|
|
677
|
-
if (devMode) {
|
|
678
|
-
console.log(
|
|
679
|
-
"[Glomo-RN-SDK Standard] Pay via bank - bank connection successful via FlowWebView:",
|
|
680
|
-
payload
|
|
681
|
-
);
|
|
682
|
-
}
|
|
683
|
-
safeCallback(
|
|
684
|
-
onPayViaBankBankConnectionSuccessful,
|
|
685
|
-
[
|
|
686
|
-
{
|
|
687
|
-
bankIdentifier: payload?.bankIdentifier ?? "",
|
|
688
|
-
cooldownPeriodInMinutes: payload?.cooldownPeriodInMinutes ?? 0,
|
|
689
|
-
bankName: payload?.bankName ?? "",
|
|
690
|
-
bankImageSrc: payload?.bankImageSrc ?? "",
|
|
691
|
-
bankImageAlt: payload?.bankImageAlt ?? "",
|
|
692
|
-
},
|
|
693
|
-
],
|
|
694
|
-
"onPayViaBankBankConnectionSuccessful",
|
|
695
|
-
devMode
|
|
696
|
-
);
|
|
697
|
-
trackStandardPayViaBankBankConnectionSuccessful(
|
|
698
|
-
orderId,
|
|
699
|
-
publicKey,
|
|
700
|
-
payload?.bankIdentifier ?? "",
|
|
701
|
-
devMode,
|
|
702
|
-
mockMode,
|
|
703
|
-
checkoutUrl
|
|
704
|
-
);
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
637
|
// Handling glomoCheckoutJourneyTerminate from the flow WebView (pay via bank completion)
|
|
709
638
|
if (messageType === "glomoCheckoutJourneyTerminate") {
|
|
710
639
|
// Deduplication - both main and flow WebViews can emit this event
|
|
@@ -726,13 +655,13 @@ export function useStandardCheckout(
|
|
|
726
655
|
setShowCheckout(false);
|
|
727
656
|
setFlowWebViewUrl("");
|
|
728
657
|
setStatus("pay_via_bank_completed");
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
"
|
|
733
|
-
|
|
734
|
-
);
|
|
735
|
-
|
|
658
|
+
const journeyPayload: GlomoUserJourneyCompletedPayload = {
|
|
659
|
+
journeyType: ASYNC_PAYMENT_EVENTS.PAY_VIA_BANK_COMPLETED,
|
|
660
|
+
orderId: payload?.orderId,
|
|
661
|
+
status: payload?.status ?? "unknown",
|
|
662
|
+
};
|
|
663
|
+
safeCallback(onUserJourneyCompleted, [journeyPayload], "onUserJourneyCompleted", devMode);
|
|
664
|
+
trackers.trackPayViaBankCompleted(
|
|
736
665
|
orderId,
|
|
737
666
|
publicKey,
|
|
738
667
|
payload?.status ?? "unknown",
|
|
@@ -752,14 +681,14 @@ export function useStandardCheckout(
|
|
|
752
681
|
[
|
|
753
682
|
onPaymentSuccess,
|
|
754
683
|
onPaymentFailure,
|
|
755
|
-
|
|
756
|
-
onPayViaBankBankConnectionSuccessful,
|
|
684
|
+
onUserJourneyCompleted,
|
|
757
685
|
devMode,
|
|
758
686
|
mockMode,
|
|
759
687
|
orderId,
|
|
760
688
|
publicKey,
|
|
761
689
|
flowWebViewUrl,
|
|
762
690
|
checkoutUrl,
|
|
691
|
+
trackers,
|
|
763
692
|
]
|
|
764
693
|
);
|
|
765
694
|
|
|
@@ -797,13 +726,13 @@ export function useStandardCheckout(
|
|
|
797
726
|
safeCallback(onPaymentTerminate, [], "onPaymentTerminate", devMode);
|
|
798
727
|
// Tracking payment terminate callback (user dismiss/back button)
|
|
799
728
|
const terminateSource = Platform.OS === "ios" ? "user_dismiss" : "back_button";
|
|
800
|
-
|
|
729
|
+
trackers.trackPaymentTerminate(orderId, terminateSource, publicKey, devMode, mockMode, checkoutUrl);
|
|
801
730
|
} catch (error) {
|
|
802
731
|
if (devMode) {
|
|
803
732
|
console.error("[Glomo-RN-SDK Standard] Error in handleModalBackButton:", error);
|
|
804
733
|
}
|
|
805
734
|
}
|
|
806
|
-
}, [showFlowWebView, devMode, onPaymentTerminate, status, orderId, publicKey, mockMode, checkoutUrl]);
|
|
735
|
+
}, [showFlowWebView, devMode, onPaymentTerminate, status, orderId, publicKey, mockMode, checkoutUrl, trackers]);
|
|
807
736
|
|
|
808
737
|
/** Closes the flow WebView and returns to the main checkout */
|
|
809
738
|
const handleFlowBack = useCallback(() => {
|
|
@@ -812,8 +741,8 @@ export function useStandardCheckout(
|
|
|
812
741
|
}
|
|
813
742
|
setShowFlowWebView(false);
|
|
814
743
|
setFlowWebViewUrl("");
|
|
815
|
-
|
|
816
|
-
}, [devMode, orderId, publicKey, mockMode, checkoutUrl]);
|
|
744
|
+
trackers.trackWindowClose("flow", orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
745
|
+
}, [devMode, orderId, publicKey, mockMode, checkoutUrl, trackers]);
|
|
817
746
|
|
|
818
747
|
/**
|
|
819
748
|
* Handler for WebView permission requests (e.g. camera access for bank authentication).
|
|
@@ -931,7 +860,7 @@ export function useStandardCheckout(
|
|
|
931
860
|
}
|
|
932
861
|
|
|
933
862
|
// Tracking start attempt with current status
|
|
934
|
-
|
|
863
|
+
trackers.trackStartAttempt(status, orderId, publicKey, devMode, mockMode, checkoutUrl, jailbreakDetectionInfo);
|
|
935
864
|
|
|
936
865
|
if (deviceComplianceCheck === true) {
|
|
937
866
|
// Device detected as compromised
|
|
@@ -946,7 +875,7 @@ export function useStandardCheckout(
|
|
|
946
875
|
];
|
|
947
876
|
safeCallback(onSdkError, [errors], "onSdkError", devMode);
|
|
948
877
|
// Tracking start() failure
|
|
949
|
-
|
|
878
|
+
trackers.trackStartFailure(
|
|
950
879
|
"device_forbidden",
|
|
951
880
|
orderId,
|
|
952
881
|
publicKey,
|
|
@@ -974,8 +903,8 @@ export function useStandardCheckout(
|
|
|
974
903
|
},
|
|
975
904
|
];
|
|
976
905
|
safeCallback(onSdkError, [errors], "onSdkError", devMode);
|
|
977
|
-
|
|
978
|
-
|
|
906
|
+
trackers.trackSdkError(errors, orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
907
|
+
trackers.trackStartFailure(
|
|
979
908
|
"validation_error",
|
|
980
909
|
orderId,
|
|
981
910
|
publicKey,
|
|
@@ -1000,7 +929,7 @@ export function useStandardCheckout(
|
|
|
1000
929
|
errors.push(error);
|
|
1001
930
|
}
|
|
1002
931
|
|
|
1003
|
-
if (!isValidOrderId(orderId)) {
|
|
932
|
+
if (!internalOptions?._skipOrderIdValidation && !isValidOrderId(orderId)) {
|
|
1004
933
|
const error: SdkError = {
|
|
1005
934
|
type: "validation_error",
|
|
1006
935
|
message: "Invalid orderId: must start with 'order_' and be a valid string",
|
|
@@ -1030,8 +959,8 @@ export function useStandardCheckout(
|
|
|
1030
959
|
}
|
|
1031
960
|
safeCallback(onSdkError, [errors], "onSdkError", devMode);
|
|
1032
961
|
// Tracking start() failure
|
|
1033
|
-
|
|
1034
|
-
|
|
962
|
+
trackers.trackSdkError(errors, orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
963
|
+
trackers.trackStartFailure(
|
|
1035
964
|
"validation_error",
|
|
1036
965
|
orderId,
|
|
1037
966
|
publicKey,
|
|
@@ -1051,7 +980,7 @@ export function useStandardCheckout(
|
|
|
1051
980
|
);
|
|
1052
981
|
}
|
|
1053
982
|
// Tracking start() failure
|
|
1054
|
-
|
|
983
|
+
trackers.trackStartFailure(
|
|
1055
984
|
"payment_successful",
|
|
1056
985
|
orderId,
|
|
1057
986
|
publicKey,
|
|
@@ -1076,7 +1005,7 @@ export function useStandardCheckout(
|
|
|
1076
1005
|
console.log(`[Glomo-RN-SDK Standard] Cannot start checkout. Unknown status: ${status}.`);
|
|
1077
1006
|
}
|
|
1078
1007
|
// Tracking start() failure
|
|
1079
|
-
|
|
1008
|
+
trackers.trackStartFailure(
|
|
1080
1009
|
"invalid_status",
|
|
1081
1010
|
orderId,
|
|
1082
1011
|
publicKey,
|
|
@@ -1094,7 +1023,7 @@ export function useStandardCheckout(
|
|
|
1094
1023
|
console.error("[Glomo-RN-SDK Standard] Cannot start checkout. Invalid checkout URL.");
|
|
1095
1024
|
}
|
|
1096
1025
|
// Tracking start() failure
|
|
1097
|
-
|
|
1026
|
+
trackers.trackStartFailure(
|
|
1098
1027
|
"invalid_url",
|
|
1099
1028
|
orderId,
|
|
1100
1029
|
publicKey,
|
|
@@ -1118,12 +1047,24 @@ export function useStandardCheckout(
|
|
|
1118
1047
|
setStatus("payment_in_progress");
|
|
1119
1048
|
|
|
1120
1049
|
// Tracking successful start
|
|
1121
|
-
|
|
1050
|
+
trackers.trackStartSuccess(orderId, publicKey, devMode, mockMode, checkoutUrl, jailbreakDetectionInfo);
|
|
1122
1051
|
|
|
1123
1052
|
// Opening the checkout modal
|
|
1124
1053
|
setShowCheckout(true);
|
|
1125
1054
|
return true;
|
|
1126
|
-
}, [
|
|
1055
|
+
}, [
|
|
1056
|
+
devMode,
|
|
1057
|
+
status,
|
|
1058
|
+
publicKey,
|
|
1059
|
+
orderId,
|
|
1060
|
+
baseCheckoutUrl,
|
|
1061
|
+
checkoutUrl,
|
|
1062
|
+
mockMode,
|
|
1063
|
+
onSdkError,
|
|
1064
|
+
server,
|
|
1065
|
+
trackers,
|
|
1066
|
+
internalOptions,
|
|
1067
|
+
]);
|
|
1127
1068
|
|
|
1128
1069
|
// Initializing Segment analytics
|
|
1129
1070
|
useEffect(() => {
|