react-nomba-checkout-sdk 1.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/babel.config.js +13 -0
- package/dist/apis/handleApiCall.d.ts +3 -0
- package/dist/apis/useCardCheckout.d.ts +8 -0
- package/dist/apis/useCardCheckoutOtp.d.ts +8 -0
- package/dist/apis/useFetchUssdBanks.d.ts +1 -0
- package/dist/apis/useGenerateQrCode.d.ts +1 -0
- package/dist/apis/useGetOrder.d.ts +1 -0
- package/dist/apis/useGetUssdCode.d.ts +15 -0
- package/dist/apis/useResendOtp.d.ts +1 -0
- package/dist/apis/useVerifyOrderStatus.d.ts +1 -0
- package/dist/assets/CloseIcon.d.ts +2 -0
- package/dist/assets/Loader.d.ts +3 -0
- package/dist/components/NombaCheckoutButton.d.ts +17 -0
- package/dist/components/NombaCheckoutModal.d.ts +16 -0
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.esm.css +2 -0
- package/dist/index.esm.css.map +1 -0
- package/dist/index.esm.js +4105 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +4116 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
- package/rollup.config.js +43 -0
- package/src/apis/handleApiCall.ts +20 -0
- package/src/apis/useCardCheckout.ts +35 -0
- package/src/apis/useCardCheckoutOtp.ts +21 -0
- package/src/apis/useFetchUssdBanks.ts +10 -0
- package/src/apis/useGenerateQrCode.ts +13 -0
- package/src/apis/useGetOrder.ts +13 -0
- package/src/apis/useGetUssdCode.ts +28 -0
- package/src/apis/useResendOtp.ts +12 -0
- package/src/apis/useVerifyOrderStatus.ts +14 -0
- package/src/assets/CloseIcon.tsx +19 -0
- package/src/assets/Loader.tsx +18 -0
- package/src/components/NombaCheckoutButton.tsx +67 -0
- package/src/components/NombaCheckoutModal.tsx +132 -0
- package/src/index.tsx +24 -0
- package/src/styles.css +14 -0
- package/tsconfig.json +80 -0
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-nomba-checkout-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.esm.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "rm -rf dist && rollup -c --bundleConfigAsCjs",
|
|
9
|
+
"build:watch": "rm -rf dist && rollup -c --watch --bundleConfigAsCjs",
|
|
10
|
+
"format": "prettier --write '**/**/*.{js,}'",
|
|
11
|
+
"lint": "eslint .",
|
|
12
|
+
"lint:fix": "npm run lint -- --fix",
|
|
13
|
+
"test": "jest --env=jsdom",
|
|
14
|
+
"test:watch": "jest --watch --verbose --env=jsdom"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "Israel Itua",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"description": "Nomba checkout sdk for react apps.",
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
|
|
22
|
+
"react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"axios": "^1.7.9",
|
|
26
|
+
"react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
|
|
27
|
+
"react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
|
|
28
|
+
"react-test-renderer": "^18.3.1",
|
|
29
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
30
|
+
"styled-components": "^6.1.14"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@babel/core": "^7.25.2",
|
|
34
|
+
"@babel/preset-env": "^7.25.3",
|
|
35
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
36
|
+
"@eslint/js": "^9.8.0",
|
|
37
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
38
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
39
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
40
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
41
|
+
"@testing-library/react": "^16.0.0",
|
|
42
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
43
|
+
"@types/jest": "^29.5.12",
|
|
44
|
+
"@types/react": "^18.3.3",
|
|
45
|
+
"@types/react-dom": "^18.3.0",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
47
|
+
"@typescript-eslint/parser": "^6.17.0",
|
|
48
|
+
"babel-eslint": "^10.1.0",
|
|
49
|
+
"babel-jest": "^29.5.0",
|
|
50
|
+
"eslint": "^9.8.0",
|
|
51
|
+
"eslint-config-prettier": "^9.1.0",
|
|
52
|
+
"eslint-config-standard": "^17.0.0",
|
|
53
|
+
"eslint-plugin-jest": "^28.7.0",
|
|
54
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
55
|
+
"eslint-plugin-react": "^7.35.0",
|
|
56
|
+
"globals": "^15.9.0",
|
|
57
|
+
"jest": "^29.5.0",
|
|
58
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
59
|
+
"prettier": "^3.3.3",
|
|
60
|
+
"rollup": "^4.20.0",
|
|
61
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
62
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
63
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
64
|
+
"ts-jest": "^29.2.4",
|
|
65
|
+
"typescript": "^5.5.4",
|
|
66
|
+
"typescript-eslint": "^8.0.0"
|
|
67
|
+
},
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/kudi-inc/react-nomba-checkout-sdk.git"
|
|
71
|
+
},
|
|
72
|
+
"bugs": {
|
|
73
|
+
"url": "https://github.com/kudi-inc/react-nomba-checkout-sdk/issues"
|
|
74
|
+
},
|
|
75
|
+
"homepage": "https://github.com/kudi-inc/react-nomba-checkout-sdk#readme"
|
|
76
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import typescript from "rollup-plugin-typescript2";
|
|
2
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
3
|
+
import external from "rollup-plugin-peer-deps-external";
|
|
4
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
5
|
+
import postcss from "rollup-plugin-postcss";
|
|
6
|
+
import json from "@rollup/plugin-json";
|
|
7
|
+
import pkg from "./package.json";
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
input: "src/index.tsx",
|
|
11
|
+
output: [
|
|
12
|
+
{
|
|
13
|
+
file: pkg.main,
|
|
14
|
+
format: "cjs",
|
|
15
|
+
exports: "named",
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
file: pkg.module,
|
|
20
|
+
format: "es",
|
|
21
|
+
exports: "named",
|
|
22
|
+
sourcemap: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
plugins: [
|
|
26
|
+
external(),
|
|
27
|
+
resolve({
|
|
28
|
+
browser: true,
|
|
29
|
+
preferBuiltins: false,
|
|
30
|
+
}),
|
|
31
|
+
json(),
|
|
32
|
+
typescript({
|
|
33
|
+
clean: true,
|
|
34
|
+
}),
|
|
35
|
+
commonjs(),
|
|
36
|
+
postcss({
|
|
37
|
+
extract: true,
|
|
38
|
+
modules: true,
|
|
39
|
+
minimize: true,
|
|
40
|
+
sourceMap: true,
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
export const handleApiCall = async (
|
|
4
|
+
url: string,
|
|
5
|
+
method: string,
|
|
6
|
+
body?: {} | null,
|
|
7
|
+
customHeaders?: { [key: string]: string }
|
|
8
|
+
) => {
|
|
9
|
+
const options = {
|
|
10
|
+
method: method,
|
|
11
|
+
headers: {
|
|
12
|
+
"content-type": "application/json",
|
|
13
|
+
...customHeaders,
|
|
14
|
+
},
|
|
15
|
+
data: body && body,
|
|
16
|
+
url: `https://vendor-api.kudi.ai/v1${url}`,
|
|
17
|
+
};
|
|
18
|
+
const response = await axios(options);
|
|
19
|
+
return response;
|
|
20
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { handleApiCall } from "./handleApiCall";
|
|
2
|
+
|
|
3
|
+
interface CardCheckoutPayload {
|
|
4
|
+
orderReference: string;
|
|
5
|
+
cardDetails: string;
|
|
6
|
+
saveCard?: boolean;
|
|
7
|
+
accountId?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const useCardCheckout = async (payload: CardCheckoutPayload) => {
|
|
11
|
+
try {
|
|
12
|
+
const response = await handleApiCall(
|
|
13
|
+
"/checkout/checkout-card-detail",
|
|
14
|
+
"POST",
|
|
15
|
+
{
|
|
16
|
+
...payload,
|
|
17
|
+
key: "",
|
|
18
|
+
deviceInformation: {
|
|
19
|
+
httpBrowserLanguage: navigator.language,
|
|
20
|
+
httpBrowserJavaEnabled: "true",
|
|
21
|
+
httpBrowserJavaScriptEnabled: "true",
|
|
22
|
+
httpBrowserColorDepth: window.screen.colorDepth.toString(),
|
|
23
|
+
httpBrowserScreenHeight: window.screen.height.toString(),
|
|
24
|
+
httpBrowserScreenWidth: window.screen.width.toString(),
|
|
25
|
+
httpBrowserTimeDifference: new Date().getTimezoneOffset().toString(),
|
|
26
|
+
userAgentBrowserValue: navigator.userAgent,
|
|
27
|
+
deviceChannel: "Browser",
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
return response.data;
|
|
32
|
+
} catch (error: any) {
|
|
33
|
+
return error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { handleApiCall } from "./handleApiCall";
|
|
2
|
+
|
|
3
|
+
interface OtpRequest {
|
|
4
|
+
otp: string;
|
|
5
|
+
orderReference: string | undefined;
|
|
6
|
+
transactionId?: string | undefined;
|
|
7
|
+
accountId?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const useCardCheckoutOtp = async (payload: OtpRequest) => {
|
|
11
|
+
try {
|
|
12
|
+
const response = await handleApiCall(
|
|
13
|
+
"/checkout/checkout-card-otp",
|
|
14
|
+
"POST",
|
|
15
|
+
payload
|
|
16
|
+
);
|
|
17
|
+
return response.data;
|
|
18
|
+
} catch (error: any) {
|
|
19
|
+
return error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { handleApiCall } from "./handleApiCall";
|
|
2
|
+
|
|
3
|
+
export const useGenerateQrCode = async (orderReference: string) => {
|
|
4
|
+
try {
|
|
5
|
+
const response = await handleApiCall(
|
|
6
|
+
`/checkout/qr/${orderReference}`,
|
|
7
|
+
"GET"
|
|
8
|
+
);
|
|
9
|
+
return response.data;
|
|
10
|
+
} catch (error: any) {
|
|
11
|
+
return error;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { handleApiCall } from "./handleApiCall";
|
|
2
|
+
|
|
3
|
+
export const useGetOrder = async (orderReference: string) => {
|
|
4
|
+
try {
|
|
5
|
+
const response = await handleApiCall(
|
|
6
|
+
`/checkout/order/${orderReference}`,
|
|
7
|
+
"GET"
|
|
8
|
+
);
|
|
9
|
+
return response.data;
|
|
10
|
+
} catch (error: any) {
|
|
11
|
+
return error;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { handleApiCall } from "./handleApiCall";
|
|
2
|
+
|
|
3
|
+
interface UssdCodeRequest {
|
|
4
|
+
ussdBankId: string;
|
|
5
|
+
bankName: string;
|
|
6
|
+
bankCode: string;
|
|
7
|
+
processor: string;
|
|
8
|
+
processorCodeName: string;
|
|
9
|
+
ussdCodeFormat: string;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
promptMessage: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const useGetUssdCode = async (payload: {
|
|
15
|
+
ussdCode: UssdCodeRequest;
|
|
16
|
+
orderId: string;
|
|
17
|
+
}) => {
|
|
18
|
+
try {
|
|
19
|
+
const response = await handleApiCall(
|
|
20
|
+
`/checkout/ussd/code`,
|
|
21
|
+
"POST",
|
|
22
|
+
payload
|
|
23
|
+
);
|
|
24
|
+
return response.data;
|
|
25
|
+
} catch (error: any) {
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { handleApiCall } from "./handleApiCall";
|
|
2
|
+
|
|
3
|
+
export const useResendOtp = async (orderReference: string) => {
|
|
4
|
+
try {
|
|
5
|
+
const response = await handleApiCall("/checkout/resend-otp", "POST", {
|
|
6
|
+
orderReference,
|
|
7
|
+
});
|
|
8
|
+
return response.data;
|
|
9
|
+
} catch (error: any) {
|
|
10
|
+
return error;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { handleApiCall } from "./handleApiCall";
|
|
2
|
+
|
|
3
|
+
export const useVerifyOrderStatus = async (orderReference: string) => {
|
|
4
|
+
try {
|
|
5
|
+
const response = await handleApiCall(
|
|
6
|
+
"/checkout/confirm-transaction-receipt",
|
|
7
|
+
"POST",
|
|
8
|
+
{ orderReference }
|
|
9
|
+
);
|
|
10
|
+
return response.data;
|
|
11
|
+
} catch (error: any) {
|
|
12
|
+
return error;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const CloseIcon = () => (
|
|
4
|
+
<svg
|
|
5
|
+
width="32"
|
|
6
|
+
height="32"
|
|
7
|
+
viewBox="0 0 32 32"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
>
|
|
11
|
+
<rect width="32" height="32" rx="16" fill="#F2F2F2" fill-opacity="0.64" />
|
|
12
|
+
<path
|
|
13
|
+
fill-rule="evenodd"
|
|
14
|
+
clip-rule="evenodd"
|
|
15
|
+
d="M11.7646 11.7646C11.8948 11.6344 12.1059 11.6344 12.236 11.7646L16.0003 15.5289L19.7646 11.7646C19.8948 11.6344 20.1059 11.6344 20.236 11.7646C20.3662 11.8948 20.3662 12.1059 20.236 12.236L16.4717 16.0003L20.236 19.7646C20.3662 19.8948 20.3662 20.1059 20.236 20.236C20.1059 20.3662 19.8948 20.3662 19.7646 20.236L16.0003 16.4717L12.236 20.236C12.1059 20.3662 11.8948 20.3662 11.7646 20.236C11.6344 20.1059 11.6344 19.8948 11.7646 19.7646L15.5289 16.0003L11.7646 12.236C11.6344 12.1059 11.6344 11.8948 11.7646 11.7646Z"
|
|
16
|
+
fill="#0D0D0D"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
const Loader = () => (
|
|
4
|
+
<svg
|
|
5
|
+
width="18"
|
|
6
|
+
height="21"
|
|
7
|
+
viewBox="0 0 18 21"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
>
|
|
11
|
+
<path
|
|
12
|
+
d="M10.3203 8.49095L12.002 7.47669L13.6836 6.46243L15.3652 5.44817L17.0468 4.43393V0.545959L15.3652 1.56021L13.6836 2.57447L12.002 3.58872L10.3203 4.60297L8.63871 5.6172V7.56118L6.95709 6.54697L5.27546 5.53271L3.50974 4.51845L1.82811 3.5042L0.146484 2.48994V6.37789L1.82811 7.39215L3.50974 8.40641L5.19136 9.42067L6.87298 10.4349L8.5546 11.4492L6.87298 12.4634L5.19136 13.4777L3.50974 14.4919L1.82811 15.5062L0.146484 16.3514V20.2394L1.82811 19.2251L3.50974 18.2108L5.19136 17.1966L6.87298 16.1824L8.5546 15.1681V13.2241L10.2362 14.2383L11.9179 15.2526L13.5995 16.2669L15.2811 17.2811L16.9628 18.2954V14.4074L15.2811 13.3932L13.5995 12.3789L11.9179 11.3646L10.2362 10.3504L8.5546 9.33613L10.3203 8.49095Z"
|
|
13
|
+
fill="#121212"
|
|
14
|
+
/>
|
|
15
|
+
</svg>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default Loader;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import { NombaCheckoutModal } from "./NombaCheckoutModal";
|
|
3
|
+
|
|
4
|
+
interface NombaCheckoutButtonProps {
|
|
5
|
+
orderId: string;
|
|
6
|
+
buttonText?: string;
|
|
7
|
+
buttonStyle?: React.CSSProperties;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface NombaCheckoutButtonState {
|
|
13
|
+
showModal: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class NombaCheckoutButton extends Component<
|
|
17
|
+
NombaCheckoutButtonProps,
|
|
18
|
+
NombaCheckoutButtonState
|
|
19
|
+
> {
|
|
20
|
+
constructor(props: NombaCheckoutButtonProps) {
|
|
21
|
+
super(props);
|
|
22
|
+
this.state = {
|
|
23
|
+
showModal: false,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
handleClose = () => {
|
|
28
|
+
this.setState({ showModal: false });
|
|
29
|
+
this.props.onClose?.();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
render() {
|
|
33
|
+
const { orderId, children, buttonStyle, buttonText } = this.props;
|
|
34
|
+
const { showModal } = this.state;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div>
|
|
38
|
+
<button
|
|
39
|
+
style={buttonStyle || styles.button}
|
|
40
|
+
onClick={
|
|
41
|
+
showModal
|
|
42
|
+
? () => this.handleClose()
|
|
43
|
+
: () => this.setState({ showModal: true })
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
{children || buttonText || "Pay with Nomba"}
|
|
47
|
+
</button>
|
|
48
|
+
|
|
49
|
+
{showModal && (
|
|
50
|
+
<NombaCheckoutModal orderId={orderId} onClose={this.handleClose} />
|
|
51
|
+
)}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const styles: { [key: string]: React.CSSProperties } = {
|
|
57
|
+
button: {
|
|
58
|
+
height: "48px",
|
|
59
|
+
width: "100%",
|
|
60
|
+
background: "#ffcc00",
|
|
61
|
+
fontSize: "16px",
|
|
62
|
+
fontWeight: 500,
|
|
63
|
+
borderRadius: "8px",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { NombaCheckoutButton };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import "../styles.css";
|
|
3
|
+
import Loader from "../assets/Loader";
|
|
4
|
+
import { CloseIcon } from "../assets/CloseIcon";
|
|
5
|
+
|
|
6
|
+
interface NombaCheckoutModalProps {
|
|
7
|
+
orderId: string;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface NombaCheckoutModalState {
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class NombaCheckoutModal extends Component<
|
|
16
|
+
NombaCheckoutModalProps,
|
|
17
|
+
NombaCheckoutModalState
|
|
18
|
+
> {
|
|
19
|
+
constructor(props: NombaCheckoutModalProps) {
|
|
20
|
+
super(props);
|
|
21
|
+
this.state = {
|
|
22
|
+
isLoading: true,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
handleClose = () => {
|
|
27
|
+
this.props.onClose?.();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
handleIframeLoad = () => {
|
|
31
|
+
this.setState({ isLoading: false });
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
render() {
|
|
35
|
+
const { orderId } = this.props;
|
|
36
|
+
const { isLoading } = this.state;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div style={modalStyles.overlay} onClick={this.handleClose}>
|
|
40
|
+
<div style={modalStyles.modal} onClick={(e) => e.stopPropagation()}>
|
|
41
|
+
<div style={modalStyles.content}>
|
|
42
|
+
{isLoading && (
|
|
43
|
+
<div style={modalStyles.loader}>
|
|
44
|
+
<div className="spinner"></div>
|
|
45
|
+
<Loader />
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
<button style={modalStyles.closeButton} onClick={this.handleClose}>
|
|
50
|
+
<CloseIcon />
|
|
51
|
+
</button>
|
|
52
|
+
|
|
53
|
+
<iframe
|
|
54
|
+
src={`https://checkout.nomba.com/pay/${orderId}`}
|
|
55
|
+
allow="clipboard-write clipboard-read"
|
|
56
|
+
width="100%"
|
|
57
|
+
height="80vh"
|
|
58
|
+
style={modalStyles.iframe}
|
|
59
|
+
title="Nomba checkout"
|
|
60
|
+
onLoad={this.handleIframeLoad}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const modalStyles: { [key: string]: React.CSSProperties } = {
|
|
70
|
+
overlay: {
|
|
71
|
+
position: "fixed",
|
|
72
|
+
top: 0,
|
|
73
|
+
left: 0,
|
|
74
|
+
right: 0,
|
|
75
|
+
bottom: 0,
|
|
76
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
77
|
+
display: "flex",
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
alignItems: "center",
|
|
80
|
+
zIndex: 9999,
|
|
81
|
+
},
|
|
82
|
+
modal: {
|
|
83
|
+
backgroundColor: "white",
|
|
84
|
+
width: "100%",
|
|
85
|
+
maxWidth: "60vw",
|
|
86
|
+
borderRadius: "8px",
|
|
87
|
+
boxShadow: "0 4px 8px rgba(0, 0, 0, 0.1)",
|
|
88
|
+
position: "relative",
|
|
89
|
+
height: "600px",
|
|
90
|
+
maxHeight: "95vh",
|
|
91
|
+
},
|
|
92
|
+
header: {
|
|
93
|
+
position: "relative",
|
|
94
|
+
display: "flex",
|
|
95
|
+
justifyContent: "space-between",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
},
|
|
98
|
+
closeButton: {
|
|
99
|
+
position: "absolute",
|
|
100
|
+
top: "16px",
|
|
101
|
+
right: "16px",
|
|
102
|
+
border: "none",
|
|
103
|
+
background: "transparent",
|
|
104
|
+
},
|
|
105
|
+
content: {
|
|
106
|
+
position: "relative",
|
|
107
|
+
},
|
|
108
|
+
iframe: {
|
|
109
|
+
border: "none",
|
|
110
|
+
borderRadius: "8px",
|
|
111
|
+
width: "100%",
|
|
112
|
+
maxHeight: "95vh",
|
|
113
|
+
height: "600px",
|
|
114
|
+
display: "block",
|
|
115
|
+
},
|
|
116
|
+
loader: {
|
|
117
|
+
position: "absolute",
|
|
118
|
+
top: 0,
|
|
119
|
+
left: 0,
|
|
120
|
+
width: "100%",
|
|
121
|
+
height: "100%",
|
|
122
|
+
backgroundColor: "rgba(255, 255, 255, 0.8)",
|
|
123
|
+
display: "flex",
|
|
124
|
+
flexDirection: "column",
|
|
125
|
+
alignItems: "center",
|
|
126
|
+
justifyContent: "center",
|
|
127
|
+
fontSize: "18px",
|
|
128
|
+
fontWeight: "bold",
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export { NombaCheckoutModal };
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NombaCheckoutButton } from "./components/NombaCheckoutButton";
|
|
2
|
+
import { NombaCheckoutModal } from "./components/NombaCheckoutModal";
|
|
3
|
+
|
|
4
|
+
import { useGetOrder } from "./apis/useGetOrder";
|
|
5
|
+
import { useCardCheckout } from "./apis/useCardCheckout";
|
|
6
|
+
import { useCardCheckoutOtp } from "./apis/useCardCheckoutOtp";
|
|
7
|
+
import { useGenerateQrCode } from "./apis/useGenerateQrCode";
|
|
8
|
+
import { useVerifyOrderStatus } from "./apis/useVerifyOrderStatus";
|
|
9
|
+
import { useResendOtp } from "./apis/useResendOtp";
|
|
10
|
+
import { useFetchUssdBanks } from "./apis/useFetchUssdBanks";
|
|
11
|
+
import { useGetUssdCode } from "./apis/useGetUssdCode";
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
NombaCheckoutButton,
|
|
15
|
+
NombaCheckoutModal,
|
|
16
|
+
useGetOrder,
|
|
17
|
+
useCardCheckout,
|
|
18
|
+
useCardCheckoutOtp,
|
|
19
|
+
useResendOtp,
|
|
20
|
+
useGenerateQrCode,
|
|
21
|
+
useVerifyOrderStatus,
|
|
22
|
+
useFetchUssdBanks,
|
|
23
|
+
useGetUssdCode,
|
|
24
|
+
};
|
package/src/styles.css
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
5
|
+
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
|
6
|
+
"module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
7
|
+
"lib": [
|
|
8
|
+
"es6",
|
|
9
|
+
"dom",
|
|
10
|
+
"es2016",
|
|
11
|
+
"es2017",
|
|
12
|
+
"esnext"
|
|
13
|
+
] /* Specify library files to be included in the compilation. */,
|
|
14
|
+
"allowJs": false /* Allow javascript files to be compiled. */,
|
|
15
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
16
|
+
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
|
|
17
|
+
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
|
18
|
+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
19
|
+
"sourceMap": true /* Generates corresponding '.map' file. */,
|
|
20
|
+
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
|
21
|
+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
22
|
+
// "composite": true, /* Enable project compilation */
|
|
23
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
24
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
25
|
+
"noEmit": true /* Do not emit outputs. */,
|
|
26
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
27
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
28
|
+
"isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
|
|
29
|
+
/* Strict Type-Checking Options */
|
|
30
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
31
|
+
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
|
32
|
+
"strictNullChecks": true /* Enable strict null checks. */,
|
|
33
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
34
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
35
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
36
|
+
"noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
|
|
37
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
38
|
+
"skipLibCheck": true,
|
|
39
|
+
/* Additional Checks */
|
|
40
|
+
"noUnusedLocals": true /* Report errors on unused locals. */,
|
|
41
|
+
"noUnusedParameters": true /* Report errors on unused parameters. */,
|
|
42
|
+
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
|
|
43
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
44
|
+
|
|
45
|
+
/* Module Resolution Options */
|
|
46
|
+
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
|
47
|
+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
48
|
+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
49
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
50
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
51
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
|
52
|
+
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
|
|
53
|
+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
54
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
55
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
56
|
+
|
|
57
|
+
/* Source Map Options */
|
|
58
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
59
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
60
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
61
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
62
|
+
|
|
63
|
+
/* Experimental Options */
|
|
64
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
65
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
66
|
+
|
|
67
|
+
/* Advanced Options */
|
|
68
|
+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
69
|
+
},
|
|
70
|
+
"include": ["src"],
|
|
71
|
+
"exclude": [
|
|
72
|
+
"node_modules",
|
|
73
|
+
"test",
|
|
74
|
+
"example",
|
|
75
|
+
"dist",
|
|
76
|
+
"**/*.spec.ts",
|
|
77
|
+
"rollup.config.js",
|
|
78
|
+
"build"
|
|
79
|
+
]
|
|
80
|
+
}
|