@glomopay/react-native-sdk 3.1.0 → 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 +23 -2
- package/MIGRATION.md +79 -0
- package/README.md +62 -93
- package/lib/glomo-checkout.d.ts +2 -1
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +9 -24
- 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.map +1 -1
- package/lib/glomo-standard-checkout.js +2 -4
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -3
- package/lib/types/checkout.d.ts +18 -19
- 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 +3 -3
- package/lib/types/subscriptions-checkout.d.ts.map +1 -1
- 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 +4 -8
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +27 -55
- package/lib/utils/analytics.d.ts +0 -2
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +0 -19
- package/package.json +1 -1
- package/src/glomo-checkout.tsx +9 -27
- package/src/glomo-lrs-checkout.tsx +1 -1
- package/src/glomo-standard-checkout.tsx +2 -6
- package/src/index.ts +4 -4
- package/src/types/checkout.ts +18 -17
- package/src/types/standard-checkout.ts +3 -5
- package/src/types/subscriptions-checkout.ts +3 -3
- package/src/use-lrs-checkout.tsx +1 -1
- package/src/use-standard-checkout.tsx +25 -102
- package/src/utils/analytics.ts +0 -27
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { type GlomoServer } from "../config/base";
|
|
4
4
|
import { type SdkError } from "../utils/analytics";
|
|
5
|
-
import { type GlomoCheckoutPayload, type
|
|
5
|
+
import { type GlomoCheckoutPayload, type GlomoUserJourneyCompletedPayload } from "./checkout";
|
|
6
6
|
import { type StandardCheckoutStatus } from "./standard-checkout";
|
|
7
7
|
|
|
8
8
|
/** Props for the subscriptions checkout component */
|
|
@@ -14,8 +14,8 @@ export interface GlomoSubscriptionsCheckoutProps {
|
|
|
14
14
|
onPaymentFailure: (payload: GlomoCheckoutPayload) => void;
|
|
15
15
|
onConnectionError?: (error: unknown) => void;
|
|
16
16
|
onPaymentTerminate?: () => void;
|
|
17
|
-
onSdkError
|
|
18
|
-
|
|
17
|
+
onSdkError: (error: Array<SdkError>) => void;
|
|
18
|
+
onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
|
|
19
19
|
onUserRefusedCameraPermissions?: () => void;
|
|
20
20
|
devMode?: boolean;
|
|
21
21
|
}
|
package/src/use-lrs-checkout.tsx
CHANGED
|
@@ -74,7 +74,7 @@ export interface UseLrsCheckoutOptions {
|
|
|
74
74
|
onPaymentFailure: (payload: GlomoLrsCheckoutPayload) => void;
|
|
75
75
|
onConnectionError?: (error: unknown) => void;
|
|
76
76
|
onPaymentTerminate?: () => void;
|
|
77
|
-
onSdkError
|
|
77
|
+
onSdkError: (error: Array<SdkError>) => void;
|
|
78
78
|
devMode?: boolean;
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -12,7 +12,7 @@ import { isValidPublicKey, isValidOrderId, isValidUrl, isValidPaymentPayload, sa
|
|
|
12
12
|
import { checkDeviceCompliance, isComplianceCheckAvailable } from "./utils/device-compliance";
|
|
13
13
|
import { type SdkError, type CheckoutAnalyticsTrackers, standardCheckoutTrackers } from "./utils/analytics";
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { ASYNC_PAYMENT_EVENTS, type GlomoUserJourneyCompletedPayload } from "./types/checkout";
|
|
16
16
|
import { type StandardCheckoutStatus, type GlomoStandardCheckoutPayload } from "./types/standard-checkout";
|
|
17
17
|
|
|
18
18
|
/** Android-only WebView permission request, not yet in react-native-webview type definitions */
|
|
@@ -31,10 +31,8 @@ export interface UseStandardCheckoutOptions {
|
|
|
31
31
|
onPaymentFailure: (payload: GlomoStandardCheckoutPayload) => void;
|
|
32
32
|
onConnectionError?: (error: unknown) => void;
|
|
33
33
|
onPaymentTerminate?: () => void;
|
|
34
|
-
onSdkError
|
|
35
|
-
|
|
36
|
-
onPayViaBankCompleted?: (payload: { status: string }) => void;
|
|
37
|
-
onPayViaBankBankConnectionSuccessful?: (payload: GlomoPayViaBankConnectionPayload | null | undefined) => void;
|
|
34
|
+
onSdkError: (error: Array<SdkError>) => void;
|
|
35
|
+
onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
|
|
38
36
|
onUserRefusedCameraPermissions?: () => void;
|
|
39
37
|
devMode?: boolean;
|
|
40
38
|
}
|
|
@@ -84,9 +82,7 @@ export function useStandardCheckout(
|
|
|
84
82
|
onConnectionError,
|
|
85
83
|
onPaymentTerminate,
|
|
86
84
|
onSdkError,
|
|
87
|
-
|
|
88
|
-
onPayViaBankCompleted,
|
|
89
|
-
onPayViaBankBankConnectionSuccessful,
|
|
85
|
+
onUserJourneyCompleted,
|
|
90
86
|
onUserRefusedCameraPermissions,
|
|
91
87
|
devMode = false,
|
|
92
88
|
}: UseStandardCheckoutOptions,
|
|
@@ -395,53 +391,17 @@ export function useStandardCheckout(
|
|
|
395
391
|
setShowFlowWebView(false);
|
|
396
392
|
setFlowWebViewUrl("");
|
|
397
393
|
setStatus("bank_transfer_submitted");
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
},
|
|
406
|
-
],
|
|
407
|
-
"onBankTransferSubmitted",
|
|
408
|
-
devMode
|
|
409
|
-
);
|
|
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);
|
|
410
401
|
trackers.trackBankTransferSubmitted(orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
411
402
|
return;
|
|
412
403
|
}
|
|
413
404
|
|
|
414
|
-
// Handling pay via bank - bank connection successful event (informational, no status change)
|
|
415
|
-
if (messageType === "pay_via_bank.bank.connection_successful") {
|
|
416
|
-
const payload = messageData?.payload;
|
|
417
|
-
if (devMode) {
|
|
418
|
-
console.log("[Glomo-RN-SDK Standard] Pay via bank - bank connection successful:", payload);
|
|
419
|
-
}
|
|
420
|
-
safeCallback(
|
|
421
|
-
onPayViaBankBankConnectionSuccessful,
|
|
422
|
-
[
|
|
423
|
-
{
|
|
424
|
-
bankIdentifier: payload?.bankIdentifier ?? "",
|
|
425
|
-
cooldownPeriodInMinutes: payload?.cooldownPeriodInMinutes ?? 0,
|
|
426
|
-
bankName: payload?.bankName ?? "",
|
|
427
|
-
bankImageSrc: payload?.bankImageSrc ?? "",
|
|
428
|
-
bankImageAlt: payload?.bankImageAlt ?? "",
|
|
429
|
-
},
|
|
430
|
-
],
|
|
431
|
-
"onPayViaBankBankConnectionSuccessful",
|
|
432
|
-
devMode
|
|
433
|
-
);
|
|
434
|
-
trackers.trackPayViaBankBankConnectionSuccessful(
|
|
435
|
-
orderId,
|
|
436
|
-
publicKey,
|
|
437
|
-
payload?.bankIdentifier ?? "",
|
|
438
|
-
devMode,
|
|
439
|
-
mockMode,
|
|
440
|
-
checkoutUrl
|
|
441
|
-
);
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
405
|
/**
|
|
446
406
|
* Handling the generic glomoCheckoutJourneyTerminate event.
|
|
447
407
|
* This event is fired by the checkout page when the pay via bank (lean/open finance)
|
|
@@ -468,12 +428,12 @@ export function useStandardCheckout(
|
|
|
468
428
|
setShowCheckout(false);
|
|
469
429
|
setFlowWebViewUrl("");
|
|
470
430
|
setStatus("pay_via_bank_completed");
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
"
|
|
475
|
-
|
|
476
|
-
);
|
|
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);
|
|
477
437
|
trackers.trackPayViaBankCompleted(
|
|
478
438
|
orderId,
|
|
479
439
|
publicKey,
|
|
@@ -516,9 +476,7 @@ export function useStandardCheckout(
|
|
|
516
476
|
onPaymentSuccess,
|
|
517
477
|
onPaymentFailure,
|
|
518
478
|
onPaymentTerminate,
|
|
519
|
-
|
|
520
|
-
onPayViaBankCompleted,
|
|
521
|
-
onPayViaBankBankConnectionSuccessful,
|
|
479
|
+
onUserJourneyCompleted,
|
|
522
480
|
devMode,
|
|
523
481
|
mockMode,
|
|
524
482
|
orderId,
|
|
@@ -676,40 +634,6 @@ export function useStandardCheckout(
|
|
|
676
634
|
return;
|
|
677
635
|
}
|
|
678
636
|
|
|
679
|
-
// Handling pay via bank - bank connection successful event from the flow WebView
|
|
680
|
-
if (messageType === "pay_via_bank.bank.connection_successful") {
|
|
681
|
-
const payload = messageData?.payload;
|
|
682
|
-
if (devMode) {
|
|
683
|
-
console.log(
|
|
684
|
-
"[Glomo-RN-SDK Standard] Pay via bank - bank connection successful via FlowWebView:",
|
|
685
|
-
payload
|
|
686
|
-
);
|
|
687
|
-
}
|
|
688
|
-
safeCallback(
|
|
689
|
-
onPayViaBankBankConnectionSuccessful,
|
|
690
|
-
[
|
|
691
|
-
{
|
|
692
|
-
bankIdentifier: payload?.bankIdentifier ?? "",
|
|
693
|
-
cooldownPeriodInMinutes: payload?.cooldownPeriodInMinutes ?? 0,
|
|
694
|
-
bankName: payload?.bankName ?? "",
|
|
695
|
-
bankImageSrc: payload?.bankImageSrc ?? "",
|
|
696
|
-
bankImageAlt: payload?.bankImageAlt ?? "",
|
|
697
|
-
},
|
|
698
|
-
],
|
|
699
|
-
"onPayViaBankBankConnectionSuccessful",
|
|
700
|
-
devMode
|
|
701
|
-
);
|
|
702
|
-
trackers.trackPayViaBankBankConnectionSuccessful(
|
|
703
|
-
orderId,
|
|
704
|
-
publicKey,
|
|
705
|
-
payload?.bankIdentifier ?? "",
|
|
706
|
-
devMode,
|
|
707
|
-
mockMode,
|
|
708
|
-
checkoutUrl
|
|
709
|
-
);
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
637
|
// Handling glomoCheckoutJourneyTerminate from the flow WebView (pay via bank completion)
|
|
714
638
|
if (messageType === "glomoCheckoutJourneyTerminate") {
|
|
715
639
|
// Deduplication - both main and flow WebViews can emit this event
|
|
@@ -731,12 +655,12 @@ export function useStandardCheckout(
|
|
|
731
655
|
setShowCheckout(false);
|
|
732
656
|
setFlowWebViewUrl("");
|
|
733
657
|
setStatus("pay_via_bank_completed");
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
"
|
|
738
|
-
|
|
739
|
-
);
|
|
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);
|
|
740
664
|
trackers.trackPayViaBankCompleted(
|
|
741
665
|
orderId,
|
|
742
666
|
publicKey,
|
|
@@ -757,8 +681,7 @@ export function useStandardCheckout(
|
|
|
757
681
|
[
|
|
758
682
|
onPaymentSuccess,
|
|
759
683
|
onPaymentFailure,
|
|
760
|
-
|
|
761
|
-
onPayViaBankBankConnectionSuccessful,
|
|
684
|
+
onUserJourneyCompleted,
|
|
762
685
|
devMode,
|
|
763
686
|
mockMode,
|
|
764
687
|
orderId,
|
package/src/utils/analytics.ts
CHANGED
|
@@ -935,25 +935,6 @@ export function trackStandardPayViaBankCompleted(
|
|
|
935
935
|
});
|
|
936
936
|
}
|
|
937
937
|
|
|
938
|
-
export function trackStandardPayViaBankBankConnectionSuccessful(
|
|
939
|
-
orderId: string,
|
|
940
|
-
publicKey: string,
|
|
941
|
-
bankIdentifier: string,
|
|
942
|
-
devMode: boolean = false,
|
|
943
|
-
mockMode: boolean = false,
|
|
944
|
-
standardUrl?: string
|
|
945
|
-
): void {
|
|
946
|
-
const properties = {
|
|
947
|
-
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
948
|
-
bankIdentifier,
|
|
949
|
-
};
|
|
950
|
-
trackEvent("Standard Pay Via Bank Bank Connection Successful", properties, devMode).catch((error) => {
|
|
951
|
-
if (devMode) {
|
|
952
|
-
console.error("[Glomo-RN-SDK] Event tracking error on standard pay via bank connection:", error);
|
|
953
|
-
}
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
|
|
957
938
|
// ---------------------------------------------------------------------------
|
|
958
939
|
// Order Type Detection Trackers (Unified Flow)
|
|
959
940
|
// ---------------------------------------------------------------------------
|
|
@@ -1403,7 +1384,6 @@ export interface CheckoutAnalyticsTrackers {
|
|
|
1403
1384
|
trackSdkError: typeof trackStandardSdkError;
|
|
1404
1385
|
trackBankTransferSubmitted: typeof trackStandardBankTransferSubmitted;
|
|
1405
1386
|
trackPayViaBankCompleted: typeof trackStandardPayViaBankCompleted;
|
|
1406
|
-
trackPayViaBankBankConnectionSuccessful: typeof trackStandardPayViaBankBankConnectionSuccessful;
|
|
1407
1387
|
}
|
|
1408
1388
|
|
|
1409
1389
|
/** Standard checkout tracker map - delegates to trackStandard* functions */
|
|
@@ -1421,7 +1401,6 @@ export const standardCheckoutTrackers: CheckoutAnalyticsTrackers = {
|
|
|
1421
1401
|
trackSdkError: trackStandardSdkError,
|
|
1422
1402
|
trackBankTransferSubmitted: trackStandardBankTransferSubmitted,
|
|
1423
1403
|
trackPayViaBankCompleted: trackStandardPayViaBankCompleted,
|
|
1424
|
-
trackPayViaBankBankConnectionSuccessful: trackStandardPayViaBankBankConnectionSuccessful,
|
|
1425
1404
|
};
|
|
1426
1405
|
|
|
1427
1406
|
/** Subscription checkout tracker map - delegates to trackSubscription* functions, no-ops for bank transfer */
|
|
@@ -1449,10 +1428,4 @@ export const subscriptionCheckoutTrackers: CheckoutAnalyticsTrackers = {
|
|
|
1449
1428
|
console.warn("[Glomo-RN-SDK] Unexpected pay via bank completed event in subscription flow");
|
|
1450
1429
|
}
|
|
1451
1430
|
},
|
|
1452
|
-
trackPayViaBankBankConnectionSuccessful: (...args) => {
|
|
1453
|
-
const devMode = args[3];
|
|
1454
|
-
if (devMode) {
|
|
1455
|
-
console.warn("[Glomo-RN-SDK] Unexpected pay via bank connection event in subscription flow");
|
|
1456
|
-
}
|
|
1457
|
-
},
|
|
1458
1431
|
};
|