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 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,3 @@
1
+ export declare const handleNombaApiCall: (url: string, method: string, body?: {} | null, customHeaders?: {
2
+ [key: string]: string;
3
+ }, environment?: string) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -0,0 +1,3 @@
1
+ export declare const handleVendorApiCall: (url: string, method: string, body?: {} | null, customHeaders?: {
2
+ [key: string]: string;
3
+ }, environment?: string) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -0,0 +1,8 @@
1
+ interface GenerateTokenPayload {
2
+ clientId: string;
3
+ clientSecret: string;
4
+ accountId: string;
5
+ environment?: string;
6
+ }
7
+ export declare const useGenerateToken: (payload: GenerateTokenPayload) => Promise<any>;
8
+ export {};
@@ -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 "react";
2
- import "../styles.css";
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<NombaCheckoutModalProps, NombaCheckoutModalState> {
11
- constructor(props: NombaCheckoutModalProps);
10
+ declare class NombaCheckoutModal extends Component<{}, NombaCheckoutModalState> {
11
+ constructor(props: {});
12
+ handleOpen: (orderId: string) => void;
12
13
  handleClose: () => void;
13
14
  handleIframeLoad: () => void;
14
- render(): React.JSX.Element;
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
- export { NombaCheckoutButton, NombaCheckoutModal, useGetOrder, useCardCheckout, useCardCheckoutOtp, useResendOtp, useGenerateQrCode, useVerifyOrderStatus, useFetchUssdBanks, useGetUssdCode, };
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 };