@glomopay/react-native-sdk 3.1.0 → 4.1.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 +5 -1
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +13 -25
- package/lib/glomo-lrs-checkout.d.ts +4 -1
- package/lib/glomo-lrs-checkout.d.ts.map +1 -1
- package/lib/glomo-lrs-checkout.js +2 -2
- package/lib/glomo-standard-checkout.d.ts +1 -0
- package/lib/glomo-standard-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.js +3 -5
- 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 +27 -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 +5 -3
- package/lib/types/subscriptions-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.d.ts +2 -2
- package/lib/use-glomo-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.js +23 -2
- package/lib/use-lrs-checkout.d.ts +11 -3
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-lrs-checkout.js +18 -5
- package/lib/use-standard-checkout.d.ts +5 -8
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +30 -56
- 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 +4 -2
- package/src/glomo-checkout.tsx +26 -31
- package/src/glomo-lrs-checkout.tsx +9 -2
- package/src/glomo-standard-checkout.tsx +5 -7
- package/src/index.ts +4 -4
- package/src/types/checkout.ts +28 -17
- package/src/types/standard-checkout.ts +3 -5
- package/src/types/subscriptions-checkout.ts +5 -3
- package/src/use-glomo-checkout.tsx +30 -5
- package/src/use-lrs-checkout.tsx +33 -6
- package/src/use-standard-checkout.tsx +30 -103
- package/src/utils/analytics.ts +0 -27
|
@@ -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
|
}
|
|
@@ -71,6 +69,7 @@ export interface UseStandardCheckoutReturn {
|
|
|
71
69
|
export interface UseStandardCheckoutInternalOptions {
|
|
72
70
|
analyticsTrackers?: CheckoutAnalyticsTrackers;
|
|
73
71
|
_skipOrderIdValidation?: boolean;
|
|
72
|
+
_testInjectionScript?: string;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
/** The main SDK hook for the GlomoPay Standard Checkout flow */
|
|
@@ -84,9 +83,7 @@ export function useStandardCheckout(
|
|
|
84
83
|
onConnectionError,
|
|
85
84
|
onPaymentTerminate,
|
|
86
85
|
onSdkError,
|
|
87
|
-
|
|
88
|
-
onPayViaBankCompleted,
|
|
89
|
-
onPayViaBankBankConnectionSuccessful,
|
|
86
|
+
onUserJourneyCompleted,
|
|
90
87
|
onUserRefusedCameraPermissions,
|
|
91
88
|
devMode = false,
|
|
92
89
|
}: UseStandardCheckoutOptions,
|
|
@@ -395,53 +392,17 @@ export function useStandardCheckout(
|
|
|
395
392
|
setShowFlowWebView(false);
|
|
396
393
|
setFlowWebViewUrl("");
|
|
397
394
|
setStatus("bank_transfer_submitted");
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
},
|
|
406
|
-
],
|
|
407
|
-
"onBankTransferSubmitted",
|
|
408
|
-
devMode
|
|
409
|
-
);
|
|
395
|
+
const journeyPayload: GlomoUserJourneyCompletedPayload = {
|
|
396
|
+
journeyType: ASYNC_PAYMENT_EVENTS.BANK_TRANSFER_SUBMITTED,
|
|
397
|
+
orderId: payload?.orderId,
|
|
398
|
+
senderAccountNumber: payload?.senderAccountNumber,
|
|
399
|
+
transactionReference: payload?.transactionReference,
|
|
400
|
+
};
|
|
401
|
+
safeCallback(onUserJourneyCompleted, [journeyPayload], "onUserJourneyCompleted", devMode);
|
|
410
402
|
trackers.trackBankTransferSubmitted(orderId, publicKey, devMode, mockMode, checkoutUrl);
|
|
411
403
|
return;
|
|
412
404
|
}
|
|
413
405
|
|
|
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
406
|
/**
|
|
446
407
|
* Handling the generic glomoCheckoutJourneyTerminate event.
|
|
447
408
|
* This event is fired by the checkout page when the pay via bank (lean/open finance)
|
|
@@ -468,12 +429,12 @@ export function useStandardCheckout(
|
|
|
468
429
|
setShowCheckout(false);
|
|
469
430
|
setFlowWebViewUrl("");
|
|
470
431
|
setStatus("pay_via_bank_completed");
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
"
|
|
475
|
-
|
|
476
|
-
);
|
|
432
|
+
const journeyPayload: GlomoUserJourneyCompletedPayload = {
|
|
433
|
+
journeyType: ASYNC_PAYMENT_EVENTS.PAY_VIA_BANK_COMPLETED,
|
|
434
|
+
orderId: payload?.orderId,
|
|
435
|
+
status: payload?.status ?? "unknown",
|
|
436
|
+
};
|
|
437
|
+
safeCallback(onUserJourneyCompleted, [journeyPayload], "onUserJourneyCompleted", devMode);
|
|
477
438
|
trackers.trackPayViaBankCompleted(
|
|
478
439
|
orderId,
|
|
479
440
|
publicKey,
|
|
@@ -516,9 +477,7 @@ export function useStandardCheckout(
|
|
|
516
477
|
onPaymentSuccess,
|
|
517
478
|
onPaymentFailure,
|
|
518
479
|
onPaymentTerminate,
|
|
519
|
-
|
|
520
|
-
onPayViaBankCompleted,
|
|
521
|
-
onPayViaBankBankConnectionSuccessful,
|
|
480
|
+
onUserJourneyCompleted,
|
|
522
481
|
devMode,
|
|
523
482
|
mockMode,
|
|
524
483
|
orderId,
|
|
@@ -676,40 +635,6 @@ export function useStandardCheckout(
|
|
|
676
635
|
return;
|
|
677
636
|
}
|
|
678
637
|
|
|
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
638
|
// Handling glomoCheckoutJourneyTerminate from the flow WebView (pay via bank completion)
|
|
714
639
|
if (messageType === "glomoCheckoutJourneyTerminate") {
|
|
715
640
|
// Deduplication - both main and flow WebViews can emit this event
|
|
@@ -731,12 +656,12 @@ export function useStandardCheckout(
|
|
|
731
656
|
setShowCheckout(false);
|
|
732
657
|
setFlowWebViewUrl("");
|
|
733
658
|
setStatus("pay_via_bank_completed");
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
"
|
|
738
|
-
|
|
739
|
-
);
|
|
659
|
+
const journeyPayload: GlomoUserJourneyCompletedPayload = {
|
|
660
|
+
journeyType: ASYNC_PAYMENT_EVENTS.PAY_VIA_BANK_COMPLETED,
|
|
661
|
+
orderId: payload?.orderId,
|
|
662
|
+
status: payload?.status ?? "unknown",
|
|
663
|
+
};
|
|
664
|
+
safeCallback(onUserJourneyCompleted, [journeyPayload], "onUserJourneyCompleted", devMode);
|
|
740
665
|
trackers.trackPayViaBankCompleted(
|
|
741
666
|
orderId,
|
|
742
667
|
publicKey,
|
|
@@ -757,8 +682,7 @@ export function useStandardCheckout(
|
|
|
757
682
|
[
|
|
758
683
|
onPaymentSuccess,
|
|
759
684
|
onPaymentFailure,
|
|
760
|
-
|
|
761
|
-
onPayViaBankBankConnectionSuccessful,
|
|
685
|
+
onUserJourneyCompleted,
|
|
762
686
|
devMode,
|
|
763
687
|
mockMode,
|
|
764
688
|
orderId,
|
|
@@ -1197,7 +1121,10 @@ export function useStandardCheckout(
|
|
|
1197
1121
|
handleNavigationStateChange,
|
|
1198
1122
|
handleModalBackButton,
|
|
1199
1123
|
handleFlowBack,
|
|
1200
|
-
injectedMain:
|
|
1124
|
+
injectedMain:
|
|
1125
|
+
__DEV__ && internalOptions?._testInjectionScript
|
|
1126
|
+
? InjectionScripts.standard + internalOptions._testInjectionScript
|
|
1127
|
+
: InjectionScripts.standard,
|
|
1201
1128
|
injectedFlow: InjectionScripts.flow,
|
|
1202
1129
|
};
|
|
1203
1130
|
}
|
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
|
};
|