react-nomba-checkout-sdk 1.0.1 → 2.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.
Files changed (36) hide show
  1. package/README.md +99 -19
  2. package/dist/apis/handleNombaApiCall.d.ts +3 -0
  3. package/dist/apis/handleVendorApiCall.d.ts +3 -0
  4. package/dist/apis/useGenerateToken.d.ts +8 -0
  5. package/dist/apis/useNombaCheckout.d.ts +30 -0
  6. package/dist/assets/CloseIcon.d.ts +1 -1
  7. package/dist/components/NombaCheckoutModal.d.ts +14 -9
  8. package/dist/eventBus.d.ts +8 -0
  9. package/dist/helpers/InitializeNombaCheckout.d.ts +1 -0
  10. package/dist/index.d.ts +12 -11
  11. package/dist/index.esm.js +273 -151
  12. package/dist/index.esm.js.map +1 -1
  13. package/dist/index.js +275 -152
  14. package/dist/index.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/apis/handleNombaApiCall.ts +26 -0
  17. package/src/apis/handleVendorApiCall.ts +26 -0
  18. package/src/apis/useCardCheckout.ts +2 -2
  19. package/src/apis/useCardCheckoutOtp.ts +2 -2
  20. package/src/apis/useFetchUssdBanks.ts +2 -2
  21. package/src/apis/useGenerateQrCode.ts +2 -2
  22. package/src/apis/useGenerateToken.ts +30 -0
  23. package/src/apis/useGetOrder.ts +2 -2
  24. package/src/apis/useGetUssdCode.ts +2 -2
  25. package/src/apis/useNombaCheckout.ts +64 -0
  26. package/src/apis/useResendOtp.ts +2 -2
  27. package/src/apis/useVerifyOrderStatus.ts +2 -2
  28. package/src/assets/CloseIcon.tsx +11 -11
  29. package/src/components/NombaCheckoutModal.tsx +110 -63
  30. package/src/eventBus.ts +25 -0
  31. package/src/helpers/InitializeNombaCheckout.tsx +26 -0
  32. package/src/index.tsx +14 -13
  33. package/dist/apis/handleApiCall.d.ts +0 -3
  34. package/dist/components/NombaCheckoutButton.d.ts +0 -17
  35. package/src/apis/handleApiCall.ts +0 -20
  36. package/src/components/NombaCheckoutButton.tsx +0 -67
@@ -1,20 +0,0 @@
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
- };
@@ -1,67 +0,0 @@
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 };