react-nomba-checkout-sdk 2.0.2 → 2.0.5
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/dist/apis/useNombaCheckout.d.ts +3 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +75 -74
- package/src/apis/useNombaCheckout.ts +59 -55
package/package.json
CHANGED
|
@@ -1,76 +1,77 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
2
|
+
"name": "react-nomba-checkout-sdk",
|
|
3
|
+
"version": "2.0.5",
|
|
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
|
+
"caniuse-lite": "^1.0.30001757",
|
|
27
|
+
"react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
|
|
28
|
+
"react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
|
|
29
|
+
"react-test-renderer": "^18.3.1",
|
|
30
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
31
|
+
"styled-components": "^6.1.14"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/core": "^7.25.2",
|
|
35
|
+
"@babel/preset-env": "^7.25.3",
|
|
36
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
37
|
+
"@eslint/js": "^9.8.0",
|
|
38
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
39
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
40
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
41
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
42
|
+
"@testing-library/react": "^16.0.0",
|
|
43
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
44
|
+
"@types/jest": "^29.5.12",
|
|
45
|
+
"@types/react": "^18.3.3",
|
|
46
|
+
"@types/react-dom": "^18.3.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
48
|
+
"@typescript-eslint/parser": "^6.17.0",
|
|
49
|
+
"babel-eslint": "^10.1.0",
|
|
50
|
+
"babel-jest": "^29.5.0",
|
|
51
|
+
"eslint": "^9.8.0",
|
|
52
|
+
"eslint-config-prettier": "^9.1.0",
|
|
53
|
+
"eslint-config-standard": "^17.0.0",
|
|
54
|
+
"eslint-plugin-jest": "^28.7.0",
|
|
55
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
56
|
+
"eslint-plugin-react": "^7.35.0",
|
|
57
|
+
"globals": "^15.9.0",
|
|
58
|
+
"jest": "^29.5.0",
|
|
59
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
60
|
+
"prettier": "^3.3.3",
|
|
61
|
+
"rollup": "^4.20.0",
|
|
62
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
63
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
64
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
65
|
+
"ts-jest": "^29.2.4",
|
|
66
|
+
"typescript": "^5.5.4",
|
|
67
|
+
"typescript-eslint": "^8.0.0"
|
|
68
|
+
},
|
|
69
|
+
"repository": {
|
|
70
|
+
"type": "git",
|
|
71
|
+
"url": "git+https://github.com/kudi-inc/react-nomba-checkout-sdk.git"
|
|
72
|
+
},
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/kudi-inc/react-nomba-checkout-sdk/issues"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://github.com/kudi-inc/react-nomba-checkout-sdk#readme"
|
|
76
77
|
}
|
|
@@ -2,63 +2,67 @@ import eventBus from '../eventBus';
|
|
|
2
2
|
import { handleNombaApiCall } from './handleNombaApiCall';
|
|
3
3
|
|
|
4
4
|
interface CheckoutPayload {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
order: {
|
|
6
|
+
orderReference: string;
|
|
7
|
+
customerId: string;
|
|
8
|
+
callbackUrl: string;
|
|
9
|
+
customerEmail: string;
|
|
10
|
+
amount: string;
|
|
11
|
+
currency: string;
|
|
12
|
+
accountId: string;
|
|
13
|
+
splitRequest?: {
|
|
14
|
+
splitType: string;
|
|
15
|
+
splitList: [
|
|
16
|
+
{
|
|
17
|
+
accountId: string;
|
|
18
|
+
value: number;
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
};
|
|
22
|
+
orderMetaData?: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
tokenizeCard: boolean;
|
|
27
|
+
clientId: string;
|
|
28
|
+
accountId: string;
|
|
29
|
+
environment?: string;
|
|
30
|
+
onCreateOrder: (orderReference: string) => void;
|
|
31
|
+
onFailure: (e: any) => void;
|
|
32
|
+
onClose: () => {};
|
|
33
|
+
onPaymentSuccess: (order: any) => {};
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export const useNombaCheckout = async (payload: CheckoutPayload) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
try {
|
|
38
|
+
console.log('🔗 Using LOCAL SDK version!', payload.order.orderMetaData);
|
|
39
|
+
const response = await handleNombaApiCall(
|
|
40
|
+
'/checkout/order',
|
|
41
|
+
'POST',
|
|
42
|
+
{
|
|
43
|
+
order: {
|
|
44
|
+
...payload.order,
|
|
45
|
+
accountId: payload.accountId,
|
|
46
|
+
},
|
|
47
|
+
tokenizeCard: payload.tokenizeCard,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
accountId: payload.accountId,
|
|
51
|
+
public_key: payload.clientId,
|
|
52
|
+
'X-Nomba-Integration': 'react-sdk',
|
|
53
|
+
},
|
|
54
|
+
payload.environment
|
|
55
|
+
);
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
eventBus.emit('openModal', {
|
|
58
|
+
orderId: response?.data?.data?.orderReference,
|
|
59
|
+
onClose: payload.onClose,
|
|
60
|
+
onPaymentSuccess: payload.onPaymentSuccess,
|
|
61
|
+
environment: payload.environment,
|
|
62
|
+
});
|
|
63
|
+
return payload.onCreateOrder(response.data);
|
|
64
|
+
} catch (error: any) {
|
|
65
|
+
payload.onFailure?.(error);
|
|
66
|
+
return error;
|
|
67
|
+
}
|
|
64
68
|
};
|