react-nomba-checkout-sdk 2.0.1 → 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/package.json CHANGED
@@ -1,76 +1,77 @@
1
1
  {
2
- "name": "react-nomba-checkout-sdk",
3
- "version": "2.0.1",
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"
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
- 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
- };
23
- tokenizeCard: boolean;
24
- clientId: string;
25
- accountId: string;
26
- environment?: string;
27
- onCreateOrder: (orderReference: string) => void;
28
- onFailure: (e: any) => void;
29
- onClose: () => {};
30
- onPaymentSuccess: (order: any) => {};
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
- try {
35
- const response = await handleNombaApiCall(
36
- '/checkout/order',
37
- 'POST',
38
- {
39
- order: {
40
- ...payload.order,
41
- accountId: payload.accountId,
42
- },
43
- tokenizeCard: payload.tokenizeCard,
44
- },
45
- {
46
- accountId: payload.accountId,
47
- public_key: payload.clientId,
48
- 'X-Nomba-Integration': 'react-sdk',
49
- },
50
- payload.environment
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
- eventBus.emit('openModal', {
54
- orderId: response?.data?.data?.orderReference,
55
- onClose: payload.onClose,
56
- onPaymentSuccess: payload.onPaymentSuccess,
57
- environment: payload.environment,
58
- });
59
- return payload.onCreateOrder(response.data);
60
- } catch (error: any) {
61
- payload.onFailure?.(error);
62
- return error;
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
  };
@@ -136,7 +136,10 @@ const modalStyles: { [key: string]: React.CSSProperties } = {
136
136
  position: 'relative',
137
137
  height: '600px',
138
138
  maxHeight: '95vh',
139
+
140
+ ...(window.innerWidth <= 768 ? { width: '98vw', maxWidth: '98vw' } : {}),
139
141
  },
142
+
140
143
  header: {
141
144
  position: 'relative',
142
145
  display: 'flex',