@glomopay/react-native-sdk 2.0.2 → 3.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 +79 -0
- package/MIGRATION.md +50 -0
- package/README.md +348 -316
- package/lib/config/base.d.ts +17 -11
- package/lib/config/base.d.ts.map +1 -1
- package/lib/config/base.js +19 -7
- package/lib/config/segment.js +3 -3
- package/lib/glomo-checkout.d.ts +8 -0
- package/lib/glomo-checkout.d.ts.map +1 -0
- package/lib/glomo-checkout.js +106 -0
- package/lib/glomo-lrs-checkout.js +9 -9
- package/lib/glomo-standard-checkout.d.ts +25 -0
- package/lib/glomo-standard-checkout.d.ts.map +1 -0
- package/lib/glomo-standard-checkout.js +229 -0
- 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 +5 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -5
- package/lib/injections/index.d.ts +1 -0
- package/lib/injections/index.d.ts.map +1 -1
- package/lib/injections/index.js +2 -0
- package/lib/injections/webview-flow.injection.d.ts.map +1 -1
- package/lib/injections/webview-flow.injection.js +106 -69
- package/lib/injections/webview-main.injection.d.ts.map +1 -1
- package/lib/injections/webview-main.injection.js +112 -77
- package/lib/injections/webview-standard.injection.d.ts +3 -0
- package/lib/injections/webview-standard.injection.d.ts.map +1 -0
- package/lib/injections/webview-standard.injection.js +214 -0
- package/lib/services/order-type-fetcher.d.ts +28 -0
- package/lib/services/order-type-fetcher.d.ts.map +1 -0
- package/lib/services/order-type-fetcher.js +99 -0
- package/lib/types/checkout.d.ts +65 -0
- package/lib/types/checkout.d.ts.map +1 -0
- package/lib/types/checkout.js +3 -0
- package/lib/types/standard-checkout.d.ts +40 -0
- package/lib/types/standard-checkout.d.ts.map +1 -0
- package/lib/types/standard-checkout.js +3 -0
- 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 +54 -0
- package/lib/use-glomo-checkout.d.ts.map +1 -0
- package/lib/use-glomo-checkout.js +261 -0
- package/lib/use-lrs-checkout.d.ts +9 -4
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-lrs-checkout.js +76 -93
- package/lib/use-standard-checkout.d.ts +74 -0
- package/lib/use-standard-checkout.d.ts.map +1 -0
- package/lib/use-standard-checkout.js +849 -0
- package/lib/utils/analytics.d.ts +188 -2
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +636 -22
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +3 -4
- package/lib/utils/validation.d.ts.map +1 -1
- package/lib/utils/validation.js +7 -6
- package/package.json +17 -5
- package/src/config/base.ts +36 -17
- package/src/config/segment.ts +3 -3
- package/src/glomo-checkout.tsx +147 -0
- package/src/glomo-lrs-checkout.tsx +9 -9
- package/src/glomo-standard-checkout.tsx +353 -0
- package/src/glomo-subscriptions-checkout.tsx +83 -0
- package/src/index.ts +13 -7
- package/src/injections/index.ts +2 -0
- package/src/injections/webview-flow.injection.ts +106 -69
- package/src/injections/webview-main.injection.ts +112 -77
- package/src/injections/webview-standard.injection.ts +211 -0
- package/src/services/order-type-fetcher.ts +86 -0
- package/src/types/checkout.ts +72 -0
- package/src/types/standard-checkout.ts +49 -0
- package/src/types/subscriptions-checkout.ts +31 -0
- package/src/use-glomo-checkout.tsx +369 -0
- package/src/use-lrs-checkout.tsx +91 -111
- package/src/use-standard-checkout.tsx +1203 -0
- package/src/utils/analytics.ts +908 -34
- package/src/utils/device-compliance.ts +3 -4
- package/src/utils/validation.ts +7 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-compliance.d.ts","sourceRoot":"","sources":["../../src/utils/device-compliance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"device-compliance.d.ts","sourceRoot":"","sources":["../../src/utils/device-compliance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,OAAe,GAAG,OAAO,GAAG,IAAI,CA+B9E;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD"}
|
|
@@ -16,7 +16,6 @@ exports.isComplianceCheckAvailable = isComplianceCheckAvailable;
|
|
|
16
16
|
*/
|
|
17
17
|
function getJailMonkey() {
|
|
18
18
|
try {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
20
19
|
const JailMonkey = require("jail-monkey");
|
|
21
20
|
if (JailMonkey && typeof JailMonkey.isJailBroken === "function") {
|
|
22
21
|
return JailMonkey;
|
|
@@ -40,7 +39,7 @@ function checkDeviceCompliance(devMode = false) {
|
|
|
40
39
|
const JailMonkey = getJailMonkey();
|
|
41
40
|
if (!JailMonkey) {
|
|
42
41
|
if (devMode) {
|
|
43
|
-
console.log("[
|
|
42
|
+
console.log("[Glomo-RN-SDK] jail-monkey not available. Device compliance check skipped. " +
|
|
44
43
|
"Install jail-monkey for enhanced security compliance.");
|
|
45
44
|
}
|
|
46
45
|
// Check unavailable - allowing checkout to proceed
|
|
@@ -49,14 +48,14 @@ function checkDeviceCompliance(devMode = false) {
|
|
|
49
48
|
try {
|
|
50
49
|
const isCompromised = JailMonkey.isJailBroken();
|
|
51
50
|
if (devMode) {
|
|
52
|
-
console.log(`[
|
|
51
|
+
console.log(`[Glomo-RN-SDK] Device compliance check: ${isCompromised ? "FAILED (device compromised)" : "PASSED"}`);
|
|
53
52
|
}
|
|
54
53
|
return isCompromised;
|
|
55
54
|
}
|
|
56
55
|
catch (error) {
|
|
57
56
|
if (devMode) {
|
|
58
57
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
59
|
-
console.error("[
|
|
58
|
+
console.error("[Glomo-RN-SDK] Error checking device compliance:", errorMessage);
|
|
60
59
|
}
|
|
61
60
|
// On error, allowing checkout to proceed (fail open strategy)
|
|
62
61
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAU3D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAOvD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAM/C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAU3D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAOvD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAM/C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB,CAYA;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAC3D,QAAQ,EAAE,CAAC,GAAG,SAAS,EACvB,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EACnB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,OAAe,GACzB,IAAI,CAWN"}
|
package/lib/utils/validation.js
CHANGED
|
@@ -54,12 +54,13 @@ function isValidPaymentPayload(payload) {
|
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
const p = payload;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Accept payloads where orderId, paymentId, and signature are strings.
|
|
59
|
+
* Empty strings are allowed because some flows (e.g. open banking / pay via bank)
|
|
60
|
+
* send payment.success with empty fields when the payment completes on the
|
|
61
|
+
* bank's side before the checkout backend has resolved ids.
|
|
62
|
+
*/
|
|
63
|
+
return typeof p.orderId === "string" && typeof p.paymentId === "string" && typeof p.signature === "string";
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
66
|
* Safely executes a callback with error handling
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glomopay/react-native-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "The React Native SDK for GlomoPay",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"test": "jest",
|
|
22
22
|
"prettier:check": "prettier --check \"**/*.{js,ts,jsx,tsx,json}\"",
|
|
23
23
|
"prettier:format": "prettier --write \"**/*.{js,ts,jsx,tsx,json}\"",
|
|
24
|
+
"lint": "eslint src/",
|
|
24
25
|
"clean": "rm -rf lib",
|
|
25
26
|
"prepublishOnly": "npm run clean && tsc --noEmit && npm run build"
|
|
26
27
|
},
|
|
@@ -49,27 +50,38 @@
|
|
|
49
50
|
},
|
|
50
51
|
"homepage": "https://github.com/glomopay/glomopay-rn-sdk#readme",
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"axios": "
|
|
53
|
+
"axios": "1.13.2"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"jail-monkey": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
53
59
|
},
|
|
54
60
|
"peerDependencies": {
|
|
61
|
+
"jail-monkey": "^2.6.0",
|
|
55
62
|
"react": ">=17.0.0",
|
|
56
63
|
"react-native": ">=0.68.0",
|
|
57
|
-
"react-native-webview": "^13.0.0"
|
|
58
|
-
"jail-monkey": "^2.6.0"
|
|
64
|
+
"react-native-webview": "^13.0.0"
|
|
59
65
|
},
|
|
60
66
|
"devDependencies": {
|
|
61
67
|
"@types/react": "^18.0.0",
|
|
62
68
|
"@types/react-native": "^0.73.0",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.60.1",
|
|
70
|
+
"eslint": "^9.39.4",
|
|
71
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
63
72
|
"jest": "^29.6.3",
|
|
64
73
|
"prettier": "^3.0.0",
|
|
65
74
|
"react": "18.2.0",
|
|
66
75
|
"react-native": "0.73.5",
|
|
67
|
-
"typescript": "^5.0.0"
|
|
76
|
+
"typescript": "^5.0.0",
|
|
77
|
+
"typescript-eslint": "^8.60.1"
|
|
68
78
|
},
|
|
69
79
|
"files": [
|
|
70
80
|
"lib",
|
|
71
81
|
"src",
|
|
72
82
|
"README.md",
|
|
83
|
+
"CHANGELOG.md",
|
|
84
|
+
"MIGRATION.md",
|
|
73
85
|
"LICENSE"
|
|
74
86
|
],
|
|
75
87
|
"engines": {
|
package/src/config/base.ts
CHANGED
|
@@ -3,37 +3,56 @@
|
|
|
3
3
|
* This file contains the default base configuration variables for the GlomoPay RN SDK.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/** The publicly documented server environments for the SDK */
|
|
7
|
-
export type
|
|
6
|
+
/** The publicly documented server environments for the SDK (v3 alias) */
|
|
7
|
+
export type GlomoServer = "prod" | "staging";
|
|
8
8
|
|
|
9
|
-
/** Internal extension that adds "local" for development use
|
|
10
|
-
type
|
|
9
|
+
/** Internal extension that adds "local" for development use - not exported */
|
|
10
|
+
type InternalGlomoServer = GlomoServer | "local";
|
|
11
11
|
|
|
12
12
|
/** Base URLs for a given server environment */
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export interface GlomoServerBaseUrls {
|
|
14
|
+
lrsCheckout: string;
|
|
15
|
+
standardCheckout: string;
|
|
16
|
+
lrsEducationCarousel: string;
|
|
17
|
+
api: string;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
/** Server config with nested base URLs */
|
|
21
|
+
export interface GlomoServerConfig {
|
|
22
|
+
baseUrl: GlomoServerBaseUrls;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const DEFAULT_SERVER: InternalGlomoServer = "prod";
|
|
19
26
|
|
|
20
|
-
export const SERVER_CONFIGS: Record<
|
|
27
|
+
export const SERVER_CONFIGS: Record<InternalGlomoServer, GlomoServerConfig> = {
|
|
21
28
|
prod: {
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
baseUrl: {
|
|
30
|
+
lrsCheckout: "https://lrs-checkout.glomopay.com/",
|
|
31
|
+
standardCheckout: "https://checkout.glomopay.com/",
|
|
32
|
+
lrsEducationCarousel: "https://glomopay-utilities.web.app/lrs-education-carousel/",
|
|
33
|
+
api: "https://api.glomopay.com",
|
|
34
|
+
},
|
|
24
35
|
},
|
|
25
36
|
staging: {
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
baseUrl: {
|
|
38
|
+
lrsCheckout: "https://lrs-checkout-page-staging.web.app/",
|
|
39
|
+
standardCheckout: "https://glomopay-checkout-page-staging.web.app/",
|
|
40
|
+
lrsEducationCarousel: "https://glomopay-utilities-staging.web.app/lrs-education-carousel/",
|
|
41
|
+
api: "https://staging-api.glomopay.com",
|
|
42
|
+
},
|
|
28
43
|
},
|
|
29
44
|
local: {
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
baseUrl: {
|
|
46
|
+
lrsCheckout: "http://localhost:6870/",
|
|
47
|
+
standardCheckout: "http://localhost:4444/",
|
|
48
|
+
lrsEducationCarousel: "http://localhost:6871/lrs-education-carousel/",
|
|
49
|
+
api: "http://localhost:3000",
|
|
50
|
+
},
|
|
32
51
|
},
|
|
33
52
|
};
|
|
34
53
|
|
|
35
|
-
/** Returns the server config for the given environment, falling back to
|
|
36
|
-
export function resolveServerConfig(server?:
|
|
54
|
+
/** Returns the full server config for the given environment, falling back to prod */
|
|
55
|
+
export function resolveServerConfig(server?: InternalGlomoServer): GlomoServerConfig {
|
|
37
56
|
const resolvedServer = server && server in SERVER_CONFIGS ? server : DEFAULT_SERVER;
|
|
38
57
|
|
|
39
58
|
return SERVER_CONFIGS[resolvedServer];
|
package/src/config/segment.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function initializeSegment(devMode: boolean = false): boolean {
|
|
|
67
67
|
// Preventing multiple initialization attempts
|
|
68
68
|
if (initializationAttempted) {
|
|
69
69
|
if (devMode) {
|
|
70
|
-
console.log("[
|
|
70
|
+
console.log("[Glomo-RN-SDK] Segment initialization already attempted");
|
|
71
71
|
}
|
|
72
72
|
return segmentApiClient !== null;
|
|
73
73
|
}
|
|
@@ -91,14 +91,14 @@ export function initializeSegment(devMode: boolean = false): boolean {
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
if (devMode) {
|
|
94
|
-
console.log("[
|
|
94
|
+
console.log("[Glomo-RN-SDK] Segment Analytics initialized successfully");
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
return true;
|
|
98
98
|
} catch (error) {
|
|
99
99
|
if (devMode) {
|
|
100
100
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
101
|
-
console.error("[
|
|
101
|
+
console.error("[Glomo-RN-SDK] Failed to initialize Segment:", errorMessage);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
// Resetting the flag to allow retrying if needed
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The unified GlomoPay Checkout Component (v3).
|
|
3
|
+
* Detects order type (LRS vs Standard) and delegates rendering to the appropriate inner component.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useImperativeHandle, useRef, useEffect, useMemo, forwardRef } from "react";
|
|
7
|
+
|
|
8
|
+
import { useGlomoCheckout, type UseGlomoCheckoutInternalReturn } from "./use-glomo-checkout";
|
|
9
|
+
import { type GlomoCheckoutRef, type GlomoCheckoutProps } from "./types/checkout";
|
|
10
|
+
import { trackUseOfUnsupportedFunctionality } from "./utils/analytics";
|
|
11
|
+
import { GlomoLrsCheckout } from "./glomo-lrs-checkout";
|
|
12
|
+
import { GlomoStandardCheckout } from "./glomo-standard-checkout";
|
|
13
|
+
import { GlomoSubscriptionsCheckout } from "./glomo-subscriptions-checkout";
|
|
14
|
+
|
|
15
|
+
function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedRef<GlomoCheckoutRef>) {
|
|
16
|
+
// useGlomoCheckout handles order type detection and exposes start/getStatus for the ref
|
|
17
|
+
const {
|
|
18
|
+
orderType,
|
|
19
|
+
start,
|
|
20
|
+
getStatus,
|
|
21
|
+
innerLrsRef,
|
|
22
|
+
innerStandardRef,
|
|
23
|
+
innerSubscriptionsRef,
|
|
24
|
+
props: passedProps,
|
|
25
|
+
}: UseGlomoCheckoutInternalReturn = useGlomoCheckout(props, { _suppressDeprecationWarning: true });
|
|
26
|
+
|
|
27
|
+
// Exposing start() and getStatus() via the forwarded ref for the merchant to call
|
|
28
|
+
useImperativeHandle(ref, () => ({
|
|
29
|
+
start,
|
|
30
|
+
getStatus,
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
// Tracking unsupported callback props on subscription flows (fires once per mount)
|
|
34
|
+
const hasTrackedUnsupportedRef = useRef(false);
|
|
35
|
+
const devMode = passedProps.devMode ?? false;
|
|
36
|
+
const mockMode = useMemo(
|
|
37
|
+
() => passedProps.publicKey?.toLowerCase().startsWith("test_") ?? false,
|
|
38
|
+
[passedProps.publicKey]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// Extracting stable booleans for the tracking effect to avoid depending on passedProps object
|
|
42
|
+
const hasBankTransferCallback = !!passedProps.onBankTransferSubmitted;
|
|
43
|
+
const hasPayViaBankCallback = !!passedProps.onPayViaBankCompleted;
|
|
44
|
+
const hasBankConnectionCallback = !!passedProps.onPayViaBankBankConnectionSuccessful;
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (orderType !== "subscriptions" || hasTrackedUnsupportedRef.current) return;
|
|
48
|
+
hasTrackedUnsupportedRef.current = true;
|
|
49
|
+
|
|
50
|
+
const unsupported = [
|
|
51
|
+
hasBankTransferCallback && "onBankTransferSubmitted",
|
|
52
|
+
hasPayViaBankCallback && "onPayViaBankCompleted",
|
|
53
|
+
hasBankConnectionCallback && "onPayViaBankBankConnectionSuccessful",
|
|
54
|
+
].filter(Boolean) as string[];
|
|
55
|
+
|
|
56
|
+
for (const name of unsupported) {
|
|
57
|
+
trackUseOfUnsupportedFunctionality(
|
|
58
|
+
name,
|
|
59
|
+
passedProps.subscriptionId,
|
|
60
|
+
passedProps.publicKey,
|
|
61
|
+
devMode,
|
|
62
|
+
mockMode,
|
|
63
|
+
""
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}, [
|
|
67
|
+
orderType,
|
|
68
|
+
hasBankTransferCallback,
|
|
69
|
+
hasPayViaBankCallback,
|
|
70
|
+
hasBankConnectionCallback,
|
|
71
|
+
passedProps.subscriptionId,
|
|
72
|
+
passedProps.publicKey,
|
|
73
|
+
devMode,
|
|
74
|
+
mockMode,
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
// Delegating to the LRS checkout component once order type is resolved as LRS
|
|
78
|
+
if (orderType === "lrs") {
|
|
79
|
+
return (
|
|
80
|
+
<GlomoLrsCheckout
|
|
81
|
+
ref={innerLrsRef}
|
|
82
|
+
server={passedProps.server}
|
|
83
|
+
publicKey={passedProps.publicKey}
|
|
84
|
+
orderId={passedProps.orderId!}
|
|
85
|
+
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
86
|
+
onPaymentFailure={passedProps.onPaymentFailure}
|
|
87
|
+
onConnectionError={passedProps.onConnectionError}
|
|
88
|
+
onPaymentTerminate={passedProps.onPaymentTerminate}
|
|
89
|
+
onSdkError={passedProps.onSdkError}
|
|
90
|
+
devMode={passedProps.devMode}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Delegating to the Standard checkout component once order type is resolved as Standard
|
|
96
|
+
if (orderType === "standard") {
|
|
97
|
+
return (
|
|
98
|
+
<GlomoStandardCheckout
|
|
99
|
+
ref={innerStandardRef}
|
|
100
|
+
server={passedProps.server}
|
|
101
|
+
publicKey={passedProps.publicKey}
|
|
102
|
+
orderId={passedProps.orderId!}
|
|
103
|
+
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
104
|
+
onPaymentFailure={passedProps.onPaymentFailure}
|
|
105
|
+
onConnectionError={passedProps.onConnectionError}
|
|
106
|
+
onPaymentTerminate={passedProps.onPaymentTerminate}
|
|
107
|
+
onSdkError={passedProps.onSdkError}
|
|
108
|
+
onBankTransferSubmitted={passedProps.onBankTransferSubmitted}
|
|
109
|
+
onPayViaBankCompleted={passedProps.onPayViaBankCompleted}
|
|
110
|
+
onPayViaBankBankConnectionSuccessful={passedProps.onPayViaBankBankConnectionSuccessful}
|
|
111
|
+
onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions}
|
|
112
|
+
devMode={passedProps.devMode}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Delegating to the Subscriptions checkout component when subscriptionId is provided (no API call)
|
|
118
|
+
if (orderType === "subscriptions") {
|
|
119
|
+
return (
|
|
120
|
+
<GlomoSubscriptionsCheckout
|
|
121
|
+
ref={innerSubscriptionsRef}
|
|
122
|
+
server={passedProps.server}
|
|
123
|
+
publicKey={passedProps.publicKey}
|
|
124
|
+
subscriptionId={passedProps.subscriptionId!}
|
|
125
|
+
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
126
|
+
onPaymentFailure={passedProps.onPaymentFailure}
|
|
127
|
+
onConnectionError={passedProps.onConnectionError}
|
|
128
|
+
onPaymentTerminate={passedProps.onPaymentTerminate}
|
|
129
|
+
onSdkError={passedProps.onSdkError}
|
|
130
|
+
onPayViaBankBankConnectionSuccessful={passedProps.onPayViaBankBankConnectionSuccessful}
|
|
131
|
+
onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions}
|
|
132
|
+
devMode={passedProps.devMode}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* No modal for detecting state - avoids iOS pageSheet conflict where
|
|
139
|
+
* dismissing the detecting modal interferes with the checkout modal presentation.
|
|
140
|
+
* The order type detection is fast enough that a loading indicator is not needed.
|
|
141
|
+
*/
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const GlomoCheckout = forwardRef<GlomoCheckoutRef, GlomoCheckoutProps>(GlomoCheckoutComponent);
|
|
146
|
+
|
|
147
|
+
GlomoCheckout.displayName = "GlomoCheckout";
|
|
@@ -57,7 +57,7 @@ function GlomoLrsCheckoutComponent(
|
|
|
57
57
|
const resolvedMockMode = publicKey?.toLowerCase().startsWith("test_") ?? false;
|
|
58
58
|
if (devMode) {
|
|
59
59
|
console.log(
|
|
60
|
-
`[
|
|
60
|
+
`[Glomo-RN-SDK LRS] ${resolvedMockMode ? "Using" : "Not using"} Mock mode for publicKey: ${publicKey}`
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
return resolvedMockMode;
|
|
@@ -179,7 +179,7 @@ function GlomoLrsCheckoutComponent(
|
|
|
179
179
|
if (!injectedJavaScript) {
|
|
180
180
|
if (devMode) {
|
|
181
181
|
console.warn(
|
|
182
|
-
`[
|
|
182
|
+
`[Glomo-RN-SDK LRS] JavaScript Injection missing for ${url}. Skipping ${identifier} Render.`
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
185
|
return null;
|
|
@@ -191,14 +191,14 @@ function GlomoLrsCheckoutComponent(
|
|
|
191
191
|
if (!isValidUrl(url)) {
|
|
192
192
|
if (devMode) {
|
|
193
193
|
console.error(
|
|
194
|
-
`[
|
|
194
|
+
`[Glomo-RN-SDK LRS] Invalid non-empty URL ${url} provided. Skipping ${identifier} Render.`
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
197
|
return null;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
if (devMode) {
|
|
201
|
-
console.error(`[
|
|
201
|
+
console.error(`[Glomo-RN-SDK LRS] Empty or invalid URL provided. Skipping ${identifier} Render.`);
|
|
202
202
|
}
|
|
203
203
|
return null;
|
|
204
204
|
}
|
|
@@ -215,7 +215,7 @@ function GlomoLrsCheckoutComponent(
|
|
|
215
215
|
onNavigationStateChange={handleNavigationStateChange}
|
|
216
216
|
onLoadStart={() => {
|
|
217
217
|
if (devMode) {
|
|
218
|
-
console.log(`[
|
|
218
|
+
console.log(`[Glomo-RN-SDK LRS] [${identifier}] WebView load started for ${url}`);
|
|
219
219
|
}
|
|
220
220
|
}}
|
|
221
221
|
onLoadEnd={() => {
|
|
@@ -223,13 +223,13 @@ function GlomoLrsCheckoutComponent(
|
|
|
223
223
|
ref.current.injectJavaScript(carouselViewportGuardScript);
|
|
224
224
|
}
|
|
225
225
|
if (devMode) {
|
|
226
|
-
console.log(`[
|
|
226
|
+
console.log(`[Glomo-RN-SDK LRS] [${identifier}] WebView load ended for ${url}`);
|
|
227
227
|
}
|
|
228
228
|
}}
|
|
229
229
|
onLoadProgress={({ nativeEvent }) => {
|
|
230
230
|
if (devMode && identifier === "educationCarousel") {
|
|
231
231
|
console.log(
|
|
232
|
-
`[
|
|
232
|
+
`[Glomo-RN-SDK LRS] [educationCarousel] load progress=${nativeEvent.progress} url=${nativeEvent.url}`
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
235
|
}}
|
|
@@ -304,7 +304,7 @@ function GlomoLrsCheckoutComponent(
|
|
|
304
304
|
|
|
305
305
|
if (devMode) {
|
|
306
306
|
console.log(
|
|
307
|
-
`[
|
|
307
|
+
`[Glomo-RN-SDK LRS] computed visibilityHook: ${value} for internal switch ${isVisible}, and checkout=${checkoutUrl};`
|
|
308
308
|
);
|
|
309
309
|
}
|
|
310
310
|
return value;
|
|
@@ -325,7 +325,7 @@ function GlomoLrsCheckoutComponent(
|
|
|
325
325
|
|
|
326
326
|
if (devMode) {
|
|
327
327
|
console.log(
|
|
328
|
-
`[
|
|
328
|
+
`[Glomo-RN-SDK LRS] Render gates: modal=${shouldShowModal}, flowOverlay=${shouldRenderFlowOverlay}, educationCarouselWebView=${shouldRenderEducationCarousel}, educationCarouselVisible=${showCarousel}, flowWebViewUrl=${flowWebViewUrl || "<empty>"}, educationCarouselUrl=${resolvedEducationCarouselUrl || "<empty>"}`
|
|
329
329
|
);
|
|
330
330
|
}
|
|
331
331
|
|