react-nomba-checkout-sdk 1.0.0 β 1.0.3
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/README.md +85 -0
- package/dist/apis/handleNombaApiCall.d.ts +3 -0
- package/dist/apis/handleVendorApiCall.d.ts +3 -0
- package/dist/apis/useGenerateToken.d.ts +8 -0
- package/dist/apis/useNombaCheckout.d.ts +30 -0
- package/dist/components/NombaCheckoutModal.d.ts +12 -9
- package/dist/eventBus.d.ts +8 -0
- package/dist/helpers/InitializeNombaCheckout.d.ts +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.esm.js +264 -151
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +266 -152
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/apis/handleNombaApiCall.ts +26 -0
- package/src/apis/handleVendorApiCall.ts +26 -0
- package/src/apis/useCardCheckout.ts +2 -2
- package/src/apis/useCardCheckoutOtp.ts +2 -2
- package/src/apis/useFetchUssdBanks.ts +2 -2
- package/src/apis/useGenerateQrCode.ts +2 -2
- package/src/apis/useGenerateToken.ts +30 -0
- package/src/apis/useGetOrder.ts +2 -2
- package/src/apis/useGetUssdCode.ts +2 -2
- package/src/apis/useNombaCheckout.ts +70 -0
- package/src/apis/useResendOtp.ts +2 -2
- package/src/apis/useVerifyOrderStatus.ts +2 -2
- package/src/components/NombaCheckoutModal.tsx +95 -62
- package/src/eventBus.ts +25 -0
- package/src/helpers/InitializeNombaCheckout.tsx +26 -0
- package/src/index.tsx +6 -5
- package/dist/apis/handleApiCall.d.ts +0 -3
- package/dist/components/NombaCheckoutButton.d.ts +0 -17
- package/src/apis/handleApiCall.ts +0 -20
- package/src/components/NombaCheckoutButton.tsx +0 -67
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# React Nomba Checkout SDK
|
|
2
|
+
|
|
3
|
+
The `react-nomba-checkout-sdk` is a lightweight JavaScript library designed to simplify payment processing and checkout experiences in your react web applications.
|
|
4
|
+
|
|
5
|
+
## π Getting Started
|
|
6
|
+
|
|
7
|
+
To install the SDK, use npm or yarn:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install react-nomba-checkout-sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add react-nomba-checkout-sdk
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Hereβs how to integrate the SDK into your project:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## π Usage
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
import { useState } from 'react';
|
|
24
|
+
import {
|
|
25
|
+
useNombaCheckout,
|
|
26
|
+
InitializeNombaCheckout,
|
|
27
|
+
} from 'react-nomba-checkout-sdk';
|
|
28
|
+
import './App.css';
|
|
29
|
+
|
|
30
|
+
//initialize nomba checkout
|
|
31
|
+
InitializeNombaCheckout();
|
|
32
|
+
|
|
33
|
+
function App() {
|
|
34
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
35
|
+
|
|
36
|
+
const handleCheckout = async () => {
|
|
37
|
+
setIsLoading(true);
|
|
38
|
+
|
|
39
|
+
const res = await useNombaCheckout({
|
|
40
|
+
accountId: 'accountid',
|
|
41
|
+
clientId: 'clientid',
|
|
42
|
+
clientSecret: 'clientsecret',
|
|
43
|
+
order: {
|
|
44
|
+
callbackUrl: 'samplecallbackurl',
|
|
45
|
+
customerEmail: 'abcde@gmail.com',
|
|
46
|
+
amount: '10000.00',
|
|
47
|
+
currency: 'NGN',
|
|
48
|
+
splitRequest: {
|
|
49
|
+
splitType: 'PERCENTAGE',
|
|
50
|
+
splitList: [
|
|
51
|
+
{
|
|
52
|
+
accountId: 'sample accountid',
|
|
53
|
+
value: '65.45',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
tokenizeCard: 'true',
|
|
59
|
+
onSuccess: (orderReference) => {
|
|
60
|
+
//handle success
|
|
61
|
+
setIsLoading(false);
|
|
62
|
+
console.log({ orderReference });
|
|
63
|
+
},
|
|
64
|
+
onFailure: (err) => {
|
|
65
|
+
//handle failure
|
|
66
|
+
setIsLoading(false);
|
|
67
|
+
console.log(err);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
<h1>Vite pay checkout</h1>
|
|
74
|
+
|
|
75
|
+
<button onClick={handleCheckout}>
|
|
76
|
+
{isLoading ? 'Please wait...' : 'Pay with Nomba checkout'}
|
|
77
|
+
</button>
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default App;
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface CheckoutPayload {
|
|
2
|
+
order: {
|
|
3
|
+
orderReference: string;
|
|
4
|
+
customerId: string;
|
|
5
|
+
callbackUrl: string;
|
|
6
|
+
customerEmail: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
currency: string;
|
|
9
|
+
accountId: string;
|
|
10
|
+
splitRequest?: {
|
|
11
|
+
splitType: string;
|
|
12
|
+
splitList: [
|
|
13
|
+
{
|
|
14
|
+
accountId: string;
|
|
15
|
+
value: number;
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
tokenizeCard: boolean;
|
|
21
|
+
clientId: string;
|
|
22
|
+
clientSecret: string;
|
|
23
|
+
accountId: string;
|
|
24
|
+
environment?: string;
|
|
25
|
+
onSuccess: (orderReference: string) => void;
|
|
26
|
+
onFailure: (e: any) => void;
|
|
27
|
+
onClose: () => {};
|
|
28
|
+
}
|
|
29
|
+
export declare const useNombaCheckout: (payload: CheckoutPayload) => Promise<any>;
|
|
30
|
+
export {};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import React, { Component } from
|
|
2
|
-
import
|
|
3
|
-
interface NombaCheckoutModalProps {
|
|
4
|
-
orderId: string;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
}
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import '../styles.css';
|
|
7
3
|
interface NombaCheckoutModalState {
|
|
4
|
+
orderId: string;
|
|
8
5
|
isLoading: boolean;
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
environment: string;
|
|
9
9
|
}
|
|
10
|
-
declare class NombaCheckoutModal extends Component<
|
|
11
|
-
constructor(props:
|
|
10
|
+
declare class NombaCheckoutModal extends Component<{}, NombaCheckoutModalState> {
|
|
11
|
+
constructor(props: {});
|
|
12
|
+
handleOpen: (orderId: string) => void;
|
|
12
13
|
handleClose: () => void;
|
|
13
14
|
handleIframeLoad: () => void;
|
|
14
|
-
|
|
15
|
+
componentDidMount(): void;
|
|
16
|
+
componentWillUnmount(): void;
|
|
17
|
+
render(): React.JSX.Element | null;
|
|
15
18
|
}
|
|
16
19
|
export { NombaCheckoutModal };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare class EventBus {
|
|
2
|
+
private events;
|
|
3
|
+
on(event: string, listener: (data: any) => void): void;
|
|
4
|
+
emit(event: string, data: any): void;
|
|
5
|
+
off(event: string, listener: (data: any) => void): void;
|
|
6
|
+
}
|
|
7
|
+
declare const eventBus: EventBus;
|
|
8
|
+
export default eventBus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InitializeNombaCheckout: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { NombaCheckoutButton } from "./components/NombaCheckoutButton";
|
|
2
|
-
import { NombaCheckoutModal } from "./components/NombaCheckoutModal";
|
|
3
1
|
import { useGetOrder } from "./apis/useGetOrder";
|
|
4
2
|
import { useCardCheckout } from "./apis/useCardCheckout";
|
|
5
3
|
import { useCardCheckoutOtp } from "./apis/useCardCheckoutOtp";
|
|
@@ -8,4 +6,7 @@ import { useVerifyOrderStatus } from "./apis/useVerifyOrderStatus";
|
|
|
8
6
|
import { useResendOtp } from "./apis/useResendOtp";
|
|
9
7
|
import { useFetchUssdBanks } from "./apis/useFetchUssdBanks";
|
|
10
8
|
import { useGetUssdCode } from "./apis/useGetUssdCode";
|
|
11
|
-
|
|
9
|
+
import { useGenerateToken } from "./apis/useGenerateToken";
|
|
10
|
+
import { useNombaCheckout } from "./apis/useNombaCheckout";
|
|
11
|
+
import { InitializeNombaCheckout } from "./helpers/InitializeNombaCheckout";
|
|
12
|
+
export { useGetOrder, useCardCheckout, useCardCheckoutOtp, useResendOtp, useGenerateQrCode, useVerifyOrderStatus, useFetchUssdBanks, useGetUssdCode, useGenerateToken, useNombaCheckout, InitializeNombaCheckout };
|