@vindhq/sloud-payment-sdk 1.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 (163) hide show
  1. package/README.md +398 -0
  2. package/dist/index.cjs.js +51442 -0
  3. package/dist/index.cjs.js.map +1 -0
  4. package/dist/index.d.ts +29 -0
  5. package/dist/index.esm.js +51440 -0
  6. package/dist/index.esm.js.map +1 -0
  7. package/dist/index.umd.js +51448 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/react/index.esm.js +51440 -0
  10. package/dist/react/index.esm.js.map +1 -0
  11. package/dist/react/rollup.config.d.ts +8 -0
  12. package/dist/react/rollup.config.dts.d.ts +3 -0
  13. package/dist/react/src/components/Button/Button.types.d.ts +6 -0
  14. package/dist/react/src/components/Button/index.d.ts +3 -0
  15. package/dist/react/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +4 -0
  16. package/dist/react/src/components/CopyToClipboardSpan/index.d.ts +3 -0
  17. package/dist/react/src/components/Input/Input.types.d.ts +17 -0
  18. package/dist/react/src/components/Input/index.d.ts +3 -0
  19. package/dist/react/src/components/Skeleton/PaymentOptionSkeletons.d.ts +6 -0
  20. package/dist/react/src/components/TextArea/TextArea.types.d.ts +19 -0
  21. package/dist/react/src/components/TextArea/index.d.ts +3 -0
  22. package/dist/react/src/components/Widget.d.ts +6 -0
  23. package/dist/react/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +2 -0
  24. package/dist/react/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +2 -0
  25. package/dist/react/src/components/modals/Modal.d.ts +10 -0
  26. package/dist/react/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +2 -0
  27. package/dist/react/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +7 -0
  28. package/dist/react/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +2 -0
  29. package/dist/react/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +11 -0
  30. package/dist/react/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +5 -0
  31. package/dist/react/src/components/modals/SuccessModal/SuccessModal.d.ts +2 -0
  32. package/dist/react/src/components/modals/state/actions/data.d.ts +10 -0
  33. package/dist/react/src/components/modals/state/actions/index.d.ts +5 -0
  34. package/dist/react/src/components/modals/state/actions/modal.d.ts +5 -0
  35. package/dist/react/src/components/modals/state/actions/payment.d.ts +7 -0
  36. package/dist/react/src/components/modals/state/constants/actionTypes.d.ts +24 -0
  37. package/dist/react/src/components/modals/state/constants/index.d.ts +2 -0
  38. package/dist/react/src/components/modals/state/constants/initialState.d.ts +36 -0
  39. package/dist/react/src/components/modals/state/reducers/data.d.ts +2 -0
  40. package/dist/react/src/components/modals/state/reducers/index.d.ts +2 -0
  41. package/dist/react/src/components/modals/state/reducers/modal.d.ts +2 -0
  42. package/dist/react/src/components/modals/state/reducers/payment.d.ts +2 -0
  43. package/dist/react/src/components/modals/state/types/common.d.ts +12 -0
  44. package/dist/react/src/components/modals/state/types/data.d.ts +34 -0
  45. package/dist/react/src/components/modals/state/types/index.d.ts +8 -0
  46. package/dist/react/src/components/modals/state/types/modal.d.ts +12 -0
  47. package/dist/react/src/components/modals/state/types/payment.d.ts +14 -0
  48. package/dist/react/src/components/modals/state/utils/index.d.ts +37 -0
  49. package/dist/react/src/context/ModalProvider.d.ts +4 -0
  50. package/dist/react/src/context/PaymentInfoContext.d.ts +26 -0
  51. package/dist/react/src/context/PaymentWidgetContext.d.ts +13 -0
  52. package/dist/react/src/context/modal.d.ts +4 -0
  53. package/dist/react/src/context/types.d.ts +28 -0
  54. package/dist/react/src/hooks/types.d.ts +34 -0
  55. package/dist/react/src/hooks/useModalControl.d.ts +27 -0
  56. package/dist/react/src/hooks/usePaymentAPI.d.ts +10 -0
  57. package/dist/react/src/hooks/useShortPolling.d.ts +4 -0
  58. package/dist/react/src/index.d.ts +2 -0
  59. package/dist/react/src/services/config/endpoints.d.ts +9 -0
  60. package/dist/react/src/services/config/error.d.ts +5 -0
  61. package/dist/react/src/services/index.d.ts +27 -0
  62. package/dist/react/src/services/payments/index.d.ts +4 -0
  63. package/dist/react/src/services/payments/types.d.ts +68 -0
  64. package/dist/react/src/services/products/index.d.ts +1 -0
  65. package/dist/react/src/services/products/types.d.ts +124 -0
  66. package/dist/react/src/services/store/index.d.ts +2 -0
  67. package/dist/react/src/services/store/types.d.ts +57 -0
  68. package/dist/react/src/services/utils/widgetConfig.d.ts +20 -0
  69. package/dist/react/src/svg_components/ArrowLeftIcon.d.ts +3 -0
  70. package/dist/react/src/svg_components/BankTransferIcon.d.ts +2 -0
  71. package/dist/react/src/svg_components/CancelIcon.d.ts +7 -0
  72. package/dist/react/src/svg_components/CardIcon.d.ts +2 -0
  73. package/dist/react/src/svg_components/CloseIcon.d.ts +3 -0
  74. package/dist/react/src/svg_components/CopyIcon.d.ts +2 -0
  75. package/dist/react/src/svg_components/EyeCloseIcon.d.ts +5 -0
  76. package/dist/react/src/svg_components/EyeOpenIcon.d.ts +5 -0
  77. package/dist/react/src/svg_components/SloudIcon.d.ts +2 -0
  78. package/dist/react/src/utils/enums/AxiosErrorCodes.d.ts +7 -0
  79. package/dist/react/src/utils/enums/AxiosMethods.d.ts +7 -0
  80. package/dist/react/src/utils/helpers/classNames.d.ts +7 -0
  81. package/dist/react/src/utils/helpers/formatCurrency.d.ts +10 -0
  82. package/dist/react/src/utils/helpers/phoneDefaults.d.ts +3 -0
  83. package/dist/react/src/utils/helpers/validatePhone.d.ts +7 -0
  84. package/dist/react/src/utils/image_utils/index.d.ts +9 -0
  85. package/dist/react/src/utils/storage/index.d.ts +9 -0
  86. package/dist/react/src/widget.d.ts +27 -0
  87. package/dist/rollup.config.d.ts +8 -0
  88. package/dist/rollup.config.dts.d.ts +3 -0
  89. package/dist/src/components/Button/Button.types.d.ts +6 -0
  90. package/dist/src/components/Button/index.d.ts +3 -0
  91. package/dist/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +4 -0
  92. package/dist/src/components/CopyToClipboardSpan/index.d.ts +3 -0
  93. package/dist/src/components/Input/Input.types.d.ts +17 -0
  94. package/dist/src/components/Input/index.d.ts +3 -0
  95. package/dist/src/components/Skeleton/PaymentOptionSkeletons.d.ts +6 -0
  96. package/dist/src/components/TextArea/TextArea.types.d.ts +19 -0
  97. package/dist/src/components/TextArea/index.d.ts +3 -0
  98. package/dist/src/components/Widget.d.ts +6 -0
  99. package/dist/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +2 -0
  100. package/dist/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +2 -0
  101. package/dist/src/components/modals/Modal.d.ts +10 -0
  102. package/dist/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +2 -0
  103. package/dist/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +7 -0
  104. package/dist/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +2 -0
  105. package/dist/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +11 -0
  106. package/dist/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +5 -0
  107. package/dist/src/components/modals/SuccessModal/SuccessModal.d.ts +2 -0
  108. package/dist/src/components/modals/state/actions/data.d.ts +10 -0
  109. package/dist/src/components/modals/state/actions/index.d.ts +5 -0
  110. package/dist/src/components/modals/state/actions/modal.d.ts +5 -0
  111. package/dist/src/components/modals/state/actions/payment.d.ts +7 -0
  112. package/dist/src/components/modals/state/constants/actionTypes.d.ts +24 -0
  113. package/dist/src/components/modals/state/constants/index.d.ts +2 -0
  114. package/dist/src/components/modals/state/constants/initialState.d.ts +36 -0
  115. package/dist/src/components/modals/state/reducers/data.d.ts +2 -0
  116. package/dist/src/components/modals/state/reducers/index.d.ts +2 -0
  117. package/dist/src/components/modals/state/reducers/modal.d.ts +2 -0
  118. package/dist/src/components/modals/state/reducers/payment.d.ts +2 -0
  119. package/dist/src/components/modals/state/types/common.d.ts +12 -0
  120. package/dist/src/components/modals/state/types/data.d.ts +34 -0
  121. package/dist/src/components/modals/state/types/index.d.ts +8 -0
  122. package/dist/src/components/modals/state/types/modal.d.ts +12 -0
  123. package/dist/src/components/modals/state/types/payment.d.ts +14 -0
  124. package/dist/src/components/modals/state/utils/index.d.ts +37 -0
  125. package/dist/src/context/ModalProvider.d.ts +4 -0
  126. package/dist/src/context/PaymentInfoContext.d.ts +26 -0
  127. package/dist/src/context/PaymentWidgetContext.d.ts +13 -0
  128. package/dist/src/context/modal.d.ts +4 -0
  129. package/dist/src/context/types.d.ts +28 -0
  130. package/dist/src/hooks/types.d.ts +34 -0
  131. package/dist/src/hooks/useModalControl.d.ts +27 -0
  132. package/dist/src/hooks/usePaymentAPI.d.ts +10 -0
  133. package/dist/src/hooks/useShortPolling.d.ts +4 -0
  134. package/dist/src/index.d.ts +2 -0
  135. package/dist/src/services/config/endpoints.d.ts +9 -0
  136. package/dist/src/services/config/error.d.ts +5 -0
  137. package/dist/src/services/index.d.ts +27 -0
  138. package/dist/src/services/payments/index.d.ts +4 -0
  139. package/dist/src/services/payments/types.d.ts +68 -0
  140. package/dist/src/services/products/index.d.ts +1 -0
  141. package/dist/src/services/products/types.d.ts +124 -0
  142. package/dist/src/services/store/index.d.ts +2 -0
  143. package/dist/src/services/store/types.d.ts +57 -0
  144. package/dist/src/services/utils/widgetConfig.d.ts +20 -0
  145. package/dist/src/svg_components/ArrowLeftIcon.d.ts +3 -0
  146. package/dist/src/svg_components/BankTransferIcon.d.ts +2 -0
  147. package/dist/src/svg_components/CancelIcon.d.ts +7 -0
  148. package/dist/src/svg_components/CardIcon.d.ts +2 -0
  149. package/dist/src/svg_components/CloseIcon.d.ts +3 -0
  150. package/dist/src/svg_components/CopyIcon.d.ts +2 -0
  151. package/dist/src/svg_components/EyeCloseIcon.d.ts +5 -0
  152. package/dist/src/svg_components/EyeOpenIcon.d.ts +5 -0
  153. package/dist/src/svg_components/SloudIcon.d.ts +2 -0
  154. package/dist/src/utils/enums/AxiosErrorCodes.d.ts +7 -0
  155. package/dist/src/utils/enums/AxiosMethods.d.ts +7 -0
  156. package/dist/src/utils/helpers/classNames.d.ts +7 -0
  157. package/dist/src/utils/helpers/formatCurrency.d.ts +10 -0
  158. package/dist/src/utils/helpers/phoneDefaults.d.ts +3 -0
  159. package/dist/src/utils/helpers/validatePhone.d.ts +7 -0
  160. package/dist/src/utils/image_utils/index.d.ts +9 -0
  161. package/dist/src/utils/storage/index.d.ts +9 -0
  162. package/dist/src/widget.d.ts +27 -0
  163. package/package.json +87 -0
@@ -0,0 +1,2 @@
1
+ export * from './actionTypes';
2
+ export * from './initialState';
@@ -0,0 +1,36 @@
1
+ import { PaymentStatus } from "../../../../hooks/types";
2
+ export declare const initialPaymentState: {
3
+ paymentStatus: PaymentStatus;
4
+ additionalAmount: number;
5
+ paymentDetails: {
6
+ reference: string;
7
+ account_name: string;
8
+ account_number: string;
9
+ bank: string;
10
+ expiry: string;
11
+ amount: number;
12
+ currency: string;
13
+ };
14
+ };
15
+ export declare const initialModalState: {
16
+ open: boolean;
17
+ currentIndex: number;
18
+ isOpenAboutModal: boolean;
19
+ };
20
+ export declare const initialDataState: {
21
+ data: import("../../../../hooks/types").ProductItem[];
22
+ store: undefined;
23
+ isLoading: boolean;
24
+ deliveryDetails: {
25
+ channel: "pickup";
26
+ first_name: string;
27
+ last_name: string;
28
+ email: string;
29
+ phone_number: string;
30
+ street: string;
31
+ country: string;
32
+ state: string;
33
+ city: string;
34
+ note: string;
35
+ };
36
+ };
@@ -0,0 +1,2 @@
1
+ import { DataState, RootAction } from '../types';
2
+ export declare const dataReducer: (state: DataState | undefined, action: RootAction) => DataState;
@@ -0,0 +1,2 @@
1
+ import { RootAction, RootState } from '../types';
2
+ export declare const rootReducer: (state: RootState, action: RootAction) => RootState;
@@ -0,0 +1,2 @@
1
+ import { ModalState, RootAction } from '../types';
2
+ export declare const modalReducer: (state: ModalState | undefined, action: RootAction) => ModalState;
@@ -0,0 +1,2 @@
1
+ import { PaymentState, RootAction } from "../types";
2
+ export declare const paymentReducer: (state: PaymentState | undefined, action: RootAction) => PaymentState;
@@ -0,0 +1,12 @@
1
+ import { DataState } from './data';
2
+ import { ModalState } from './modal';
3
+ import { PaymentState } from './payment';
4
+ export interface ActionType<Type, Payload = unknown> {
5
+ type: Type;
6
+ payload: Payload;
7
+ }
8
+ export interface RootState {
9
+ payment: PaymentState;
10
+ modal: ModalState;
11
+ data: DataState;
12
+ }
@@ -0,0 +1,34 @@
1
+ import { ProductItem } from '../../../../hooks/types';
2
+ import { IGetStoreData } from '../../../../services';
3
+ import { DATA_ACTIONS } from '../constants/actionTypes';
4
+ import { ActionType } from './common';
5
+ export interface DeliveryDetails {
6
+ channel: 'pickup' | 'delivery';
7
+ first_name: string;
8
+ last_name: string;
9
+ email: string;
10
+ phone_number: string;
11
+ street: string;
12
+ country: string;
13
+ state: string;
14
+ city: string;
15
+ note: string;
16
+ }
17
+ export interface EditItemPayload {
18
+ index: number;
19
+ quantity?: number;
20
+ }
21
+ export interface DataState {
22
+ data: ProductItem[];
23
+ store?: IGetStoreData;
24
+ isLoading: boolean;
25
+ deliveryDetails: DeliveryDetails;
26
+ }
27
+ export type SetDataAction = ActionType<typeof DATA_ACTIONS.SET_DATA, ProductItem[]>;
28
+ export type SetStoreAction = ActionType<typeof DATA_ACTIONS.SET_STORE, IGetStoreData>;
29
+ export type SetLoadingAction = ActionType<typeof DATA_ACTIONS.SET_LOADING, boolean>;
30
+ export type SetDeliveryDetailsAction = ActionType<typeof DATA_ACTIONS.SET_DELIVERY_DETAILS, Partial<DeliveryDetails>>;
31
+ export type EditItemAction = ActionType<typeof DATA_ACTIONS.EDIT_ITEM, EditItemPayload>;
32
+ export type RemoveItemAction = ActionType<typeof DATA_ACTIONS.REMOVE_ITEM, number>;
33
+ export type ResetDataAction = ActionType<typeof DATA_ACTIONS.RESET_DATA>;
34
+ export type DataAction = SetDataAction | SetStoreAction | SetLoadingAction | SetDeliveryDetailsAction | EditItemAction | RemoveItemAction | ResetDataAction;
@@ -0,0 +1,8 @@
1
+ export * from './common';
2
+ export * from './data';
3
+ export * from './modal';
4
+ export * from './payment';
5
+ import { GLOBAL_ACTIONS } from '../constants/actionTypes';
6
+ import { ActionType } from './common';
7
+ export type ResetAllAction = ActionType<typeof GLOBAL_ACTIONS.RESET_ALL>;
8
+ export type RootAction = import('./payment').PaymentAction | import('./modal').ModalAction | import('./data').DataAction | ResetAllAction;
@@ -0,0 +1,12 @@
1
+ import { MODAL_ACTIONS } from '../constants';
2
+ import { ActionType } from './common';
3
+ export interface ModalState {
4
+ open: boolean;
5
+ currentIndex: number;
6
+ isOpenAboutModal: boolean;
7
+ }
8
+ export type SetOpenAction = ActionType<typeof MODAL_ACTIONS.SET_OPEN, boolean>;
9
+ export type SetCurrentIndexAction = ActionType<typeof MODAL_ACTIONS.SET_CURRENT_INDEX, number>;
10
+ export type SetAboutModalAction = ActionType<typeof MODAL_ACTIONS.SET_ABOUT_MODAL, boolean>;
11
+ export type ResetModalAction = ActionType<typeof MODAL_ACTIONS.RESET_MODAL>;
12
+ export type ModalAction = SetOpenAction | SetCurrentIndexAction | SetAboutModalAction | ResetModalAction;
@@ -0,0 +1,14 @@
1
+ import { PaymentStatus } from '../../../../hooks/types';
2
+ import { IPaymentDetails } from '../../../../services/products/types';
3
+ import { PAYMENT_ACTIONS } from '../constants/actionTypes';
4
+ import { ActionType } from './common';
5
+ export interface PaymentState {
6
+ paymentStatus: PaymentStatus;
7
+ additionalAmount: number;
8
+ paymentDetails: IPaymentDetails;
9
+ }
10
+ export type SetPaymentStatusAction = ActionType<typeof PAYMENT_ACTIONS.SET_PAYMENT_STATUS, PaymentStatus>;
11
+ export type SetPaymentDetailsAction = ActionType<typeof PAYMENT_ACTIONS.SET_PAYMENT_DETAILS, IPaymentDetails>;
12
+ export type SetAdditionalAmountAction = ActionType<typeof PAYMENT_ACTIONS.SET_ADDITIONAL_AMOUNT, number>;
13
+ export type ResetPaymentAction = ActionType<typeof PAYMENT_ACTIONS.RESET_PAYMENT>;
14
+ export type PaymentAction = SetPaymentStatusAction | SetPaymentDetailsAction | SetAdditionalAmountAction | ResetPaymentAction;
@@ -0,0 +1,37 @@
1
+ import { DeliveryDetails } from "../types";
2
+ import { ProductItem } from "../../../../hooks/types";
3
+ export declare const calculateTotalPrice: (data: ProductItem[]) => number;
4
+ export declare const formatItemsForOrder: (data: ProductItem[]) => {
5
+ product_id: string;
6
+ discount: number;
7
+ quantity: number;
8
+ variation: string[];
9
+ }[];
10
+ export declare const createOrderPayload: (data: ProductItem[], deliveryDetails: DeliveryDetails, additionalAmount: number) => {
11
+ additional_amount: number;
12
+ discount: number;
13
+ payment_method: string;
14
+ buyer_details: DeliveryDetails;
15
+ channel: "pickup" | "delivery";
16
+ delivery_details: {
17
+ channel: "pickup" | "delivery";
18
+ first_name: string;
19
+ last_name: string;
20
+ email: string;
21
+ phone_number: string;
22
+ street: string;
23
+ country: string;
24
+ state: string;
25
+ city: string;
26
+ note: string;
27
+ };
28
+ items: {
29
+ product_id: string;
30
+ discount: number;
31
+ quantity: number;
32
+ variation: string[];
33
+ }[];
34
+ };
35
+ export declare const loadCartFromStorage: () => ProductItem[];
36
+ export declare const saveCartToStorage: (data: ProductItem[]) => void;
37
+ export declare const clearCartFromStorage: () => void;
@@ -0,0 +1,4 @@
1
+ declare const ModalProvider: ({ children }: {
2
+ children: React.JSX.Element;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default ModalProvider;
@@ -0,0 +1,26 @@
1
+ import React, { ReactNode } from "react";
2
+ interface BankAccount {
3
+ accountName: string;
4
+ accountNumber: string;
5
+ bank: string;
6
+ }
7
+ interface TransactionDetails {
8
+ reference: string;
9
+ amount: number;
10
+ charge: number;
11
+ currency: string;
12
+ expiry: string;
13
+ }
14
+ interface PaymentInfoContextProp {
15
+ collectionAccount: BankAccount;
16
+ transactionDetails: TransactionDetails;
17
+ updateCollectionAccount: (bankAccount: BankAccount) => void;
18
+ updateTransactionDetails: (transactionDetails: TransactionDetails) => void;
19
+ }
20
+ declare const PaymentInfoContext: React.Context<PaymentInfoContextProp | undefined>;
21
+ interface PaymentWidgetProviderProps {
22
+ children: ReactNode;
23
+ }
24
+ export declare const PaymentInfoProvider: React.FC<PaymentWidgetProviderProps>;
25
+ export default PaymentInfoContext;
26
+ export declare const usePaymentInfoContext: () => PaymentInfoContextProp;
@@ -0,0 +1,13 @@
1
+ import React, { ReactNode } from "react";
2
+ import { PaymentWidgetOptions } from "../widget";
3
+ interface PaymentWidgetContextType {
4
+ options: PaymentWidgetOptions;
5
+ }
6
+ declare const PaymentWidgetContext: React.Context<PaymentWidgetContextType | undefined>;
7
+ export declare const usePaymentWidgetContext: () => PaymentWidgetContextType;
8
+ interface PaymentWidgetProviderProps {
9
+ children: ReactNode;
10
+ options: PaymentWidgetOptions;
11
+ }
12
+ export declare const PaymentWidgetProvider: React.FC<PaymentWidgetProviderProps>;
13
+ export default PaymentWidgetContext;
@@ -0,0 +1,4 @@
1
+ import { ModalContextTypes } from "./types";
2
+ declare const ModalContext: import("react").Context<ModalContextTypes | undefined>;
3
+ export declare const useModalContext: () => ModalContextTypes;
4
+ export default ModalContext;
@@ -0,0 +1,28 @@
1
+ import { DeliveryDetails, PaymentStatus, ProductItem } from "../hooks/types";
2
+ import { IGetStoreData } from "../services";
3
+ import { IPaymentDetails } from "../services/products/types";
4
+ export interface ModalContextTypes {
5
+ open: boolean;
6
+ data: ProductItem[];
7
+ totalPrice: number;
8
+ currentModal: string;
9
+ movePrev: () => void;
10
+ moveNext: () => void;
11
+ openModal: () => void;
12
+ closeModal: () => void;
13
+ store: IGetStoreData | undefined;
14
+ editItemQuantity: (index: number, quantity?: number) => void;
15
+ removeItem: (index: number) => void;
16
+ isLoading: boolean;
17
+ paymentStatus: PaymentStatus;
18
+ setPaymentStatus: (status: PaymentStatus) => void;
19
+ deliveryDetails: DeliveryDetails;
20
+ paymentDetails: IPaymentDetails;
21
+ additionalAmount: number;
22
+ setAdditionalAmount: (amount: number) => void;
23
+ setDeliveryDetails: (details: DeliveryDetails) => void;
24
+ setData: (newData: ProductItem[]) => void;
25
+ orderProducts: () => Promise<void>;
26
+ isOpenAboutModal: boolean;
27
+ completeOperation: () => void;
28
+ }
@@ -0,0 +1,34 @@
1
+ export declare enum ModalNames {
2
+ Payment = "Payment",
3
+ PaymentDetails = "PaymentDetails",
4
+ AwaitingPayment = "AwaitingPayment",
5
+ AwaitingPaymentTimeout = "AwaitingPaymentTimeout",
6
+ Success = "Success"
7
+ }
8
+ export interface DeliveryDetails {
9
+ channel: "pickup" | "delivery";
10
+ first_name: string;
11
+ last_name: string;
12
+ email: string;
13
+ phone_number: string;
14
+ street: string;
15
+ country: string;
16
+ state: string;
17
+ city: string;
18
+ note: string;
19
+ }
20
+ export interface ProductItem {
21
+ id: string;
22
+ image_url: string;
23
+ name: string;
24
+ variations: string[];
25
+ quantity: number;
26
+ price: number;
27
+ in_stock: number;
28
+ }
29
+ export declare enum PaymentStatus {
30
+ PENDING = "pending",
31
+ SUCCESS = "success",
32
+ FAILED = "failed",
33
+ CANCELLED = "cancelled"
34
+ }
@@ -0,0 +1,27 @@
1
+ import { DeliveryDetails, ModalNames, PaymentStatus, ProductItem } from "./types";
2
+ declare const useModalControl: () => {
3
+ open: boolean;
4
+ data: ProductItem[];
5
+ store: import("../services").IGetStoreData | undefined;
6
+ currentModal: ModalNames;
7
+ totalPrice: number;
8
+ isLoading: boolean;
9
+ moveNext: () => void;
10
+ movePrev: () => void;
11
+ openModal: () => void;
12
+ closeModal: () => void;
13
+ orderProducts: () => Promise<void>;
14
+ deliveryDetails: import("../components/modals/state/types").DeliveryDetails;
15
+ setDeliveryDetails: (details: DeliveryDetails) => void;
16
+ paymentDetails: import("../services/products/types").IPaymentDetails;
17
+ paymentStatus: PaymentStatus;
18
+ setPaymentStatus: (status: PaymentStatus) => void;
19
+ additionalAmount: number;
20
+ setAdditionalAmount: (amount: number) => void;
21
+ editItemQuantity: (index: number, quantity?: number) => void;
22
+ removeItem: (index: number) => void;
23
+ setData: (newData: ProductItem[]) => void;
24
+ isOpenAboutModal: boolean;
25
+ completeOperation: () => void;
26
+ };
27
+ export default useModalControl;
@@ -0,0 +1,10 @@
1
+ export declare const usePaymentAPI: () => {
2
+ generatePaymentInstrument: () => Promise<void>;
3
+ paymentMethods: Record<string, boolean>;
4
+ publicKey: string;
5
+ isLocalEnv: boolean | undefined;
6
+ isFetchingMethods: boolean;
7
+ isLoading: boolean;
8
+ isSuccess: boolean;
9
+ };
10
+ export default usePaymentAPI;
@@ -0,0 +1,4 @@
1
+ declare const useShortPolling: ({ activate }: {
2
+ activate: boolean;
3
+ }) => void;
4
+ export default useShortPolling;
@@ -0,0 +1,2 @@
1
+ import Widget from "./widget";
2
+ export default Widget;
@@ -0,0 +1,9 @@
1
+ export declare const Endpoints: {
2
+ getPaymentMethods: (public_key: string) => string;
3
+ generatePaymentInstrument: (public_key: string) => string;
4
+ getPaymentStatus: (payment_reference: string) => string;
5
+ };
6
+ export interface BaseAPIResponse {
7
+ status: string;
8
+ message: string;
9
+ }
@@ -0,0 +1,5 @@
1
+ import { AxiosError } from "axios";
2
+ export declare function handleError(error: AxiosError<{
3
+ status: string;
4
+ message: string;
5
+ }>): void;
@@ -0,0 +1,27 @@
1
+ import { AxiosError, InternalAxiosRequestConfig } from "axios";
2
+ export * from "./store/types";
3
+ export interface WidgetOptions {
4
+ public_key: string;
5
+ isLocalEnv?: boolean;
6
+ amount: number;
7
+ first_name: string;
8
+ last_name: string;
9
+ phone_number: string;
10
+ email: string;
11
+ }
12
+ export declare const setWidgetOptions: (options: WidgetOptions) => void;
13
+ export declare const getWidgetOptions: () => WidgetOptions;
14
+ interface APIError {
15
+ status: string;
16
+ message: string;
17
+ }
18
+ export interface IApiResponse<T> {
19
+ response?: T;
20
+ error?: AxiosError<APIError>;
21
+ }
22
+ export type ApiRequest = Pick<InternalAxiosRequestConfig<unknown>, "method" | "url" | "params" | "data">;
23
+ export declare const makeApiCall: <T>(request: ApiRequest) => Promise<IApiResponse<T>>;
24
+ export declare const errors: {
25
+ 403: string;
26
+ 404: string;
27
+ };
@@ -0,0 +1,4 @@
1
+ import { IGeneratePaymentInstrumentPayload, IGetPaymentMethodsResponse, IPaymentInstrumentResponse, IPaymentStatusResponse } from "./types";
2
+ export declare const fetchPaymentMethods: (public_key: string) => Promise<import("..").IApiResponse<IGetPaymentMethodsResponse>>;
3
+ export declare const generatePaymentInstrumentService: (public_key: string, payload: IGeneratePaymentInstrumentPayload) => Promise<import("..").IApiResponse<IPaymentInstrumentResponse>>;
4
+ export declare const fetchPaymentStatusService: (payment_reference: string) => Promise<import("..").IApiResponse<IPaymentStatusResponse>>;
@@ -0,0 +1,68 @@
1
+ import { PaymentStatus } from "../../hooks/types";
2
+ import { BaseAPIResponse } from "../config/endpoints";
3
+ export interface IGetPaymentMethodsResponse extends BaseAPIResponse {
4
+ data: {
5
+ bank_transfer: boolean;
6
+ sloud_wallet: boolean;
7
+ card: boolean;
8
+ };
9
+ }
10
+ export interface IPaymentStatusRequest {
11
+ path: {
12
+ id: string;
13
+ reference: string;
14
+ };
15
+ }
16
+ export interface IGetProductsResponse {
17
+ status: string;
18
+ message: string;
19
+ data: {
20
+ status: PaymentStatus;
21
+ };
22
+ }
23
+ export interface IGeneratePaymentInstrumentPayload {
24
+ amount: number;
25
+ customer: {
26
+ first_name: string;
27
+ last_name: string;
28
+ phone_number: string;
29
+ email: string;
30
+ };
31
+ }
32
+ export interface IPaymentInstrumentResponse extends BaseAPIResponse {
33
+ data: {
34
+ reference: string;
35
+ account_name: string;
36
+ account_number: string;
37
+ bank: string;
38
+ expiry: string;
39
+ amount: number;
40
+ charge: number;
41
+ currency: string;
42
+ };
43
+ }
44
+ export interface IPaymentStatusResponse extends BaseAPIResponse {
45
+ data: {
46
+ reference: string;
47
+ status: string;
48
+ amount: number;
49
+ currency: string;
50
+ updatedAt: string;
51
+ };
52
+ }
53
+ export interface IGetChargePayload {
54
+ amount: number;
55
+ }
56
+ export interface IGetChargeRequest {
57
+ path: {
58
+ slug: string;
59
+ };
60
+ }
61
+ export interface IGetChargeResponse {
62
+ status: string;
63
+ message: string;
64
+ data: {
65
+ charge: number;
66
+ total_amount: number;
67
+ };
68
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,124 @@
1
+ export interface IGetProductsResponse {
2
+ status: string;
3
+ message: string;
4
+ data: IProduct[];
5
+ metadata: IMetadata;
6
+ }
7
+ export interface IProductDetail {
8
+ id: string;
9
+ name: string;
10
+ description: string;
11
+ price: number;
12
+ currency: string;
13
+ image_url: string[];
14
+ variation: Record<string, string[]>;
15
+ discount: number;
16
+ discounted_amount: number;
17
+ availability: string;
18
+ in_stock: number;
19
+ }
20
+ export interface IGetProductResponse {
21
+ status: string;
22
+ message: string;
23
+ data: IProductDetail;
24
+ }
25
+ export interface IPaymentDetails {
26
+ reference?: string;
27
+ account_name?: string;
28
+ account_number?: string;
29
+ bank?: string;
30
+ expiry?: string;
31
+ amount?: number;
32
+ currency?: string;
33
+ }
34
+ export interface IOrderProductResponseData {
35
+ payment_details: IPaymentDetails;
36
+ }
37
+ export interface IOrderProductResponse {
38
+ status: string;
39
+ message: string;
40
+ data: IOrderProductResponseData;
41
+ }
42
+ export interface IMetadata {
43
+ cursor: string;
44
+ beforeCursor: string;
45
+ totalCount: number;
46
+ pageSize: number;
47
+ }
48
+ export interface IProduct {
49
+ id: number;
50
+ name: string;
51
+ category: string;
52
+ amount: number;
53
+ currency: string;
54
+ in_stock: number;
55
+ availability: number;
56
+ image_url: string[];
57
+ discounted_amount: number;
58
+ }
59
+ export interface IGetProductsRequest {
60
+ path: {
61
+ id: string;
62
+ collectionId: string | null;
63
+ };
64
+ params: {
65
+ name: string;
66
+ pageSize: number;
67
+ pageNumber: number;
68
+ cursor?: number;
69
+ beforeCursor?: number;
70
+ };
71
+ }
72
+ export interface IGetProductRequest {
73
+ path: {
74
+ productId: string;
75
+ storeId: string;
76
+ };
77
+ }
78
+ export interface IOrderProductRequest {
79
+ path: {
80
+ slug: string;
81
+ };
82
+ }
83
+ export interface IBuyerDetails {
84
+ first_name: string;
85
+ last_name: string;
86
+ email: string;
87
+ phone_number: string;
88
+ }
89
+ export interface IDeliveryDetails {
90
+ street: string;
91
+ country: string;
92
+ state: string;
93
+ city: string;
94
+ note: string;
95
+ }
96
+ export interface IItem {
97
+ product_id: string;
98
+ discount: number;
99
+ variation: string[];
100
+ quantity: number;
101
+ }
102
+ export interface IOrderProductRequestPayload {
103
+ discount: number;
104
+ additional_amount: number;
105
+ payment_method: string;
106
+ buyer_details: IBuyerDetails;
107
+ channel: 'pickup' | 'delivery';
108
+ delivery_details: IDeliveryDetails;
109
+ items: IItem[];
110
+ }
111
+ export interface IGetProductAvailabilityRequest {
112
+ path: {
113
+ slug: string;
114
+ productId: string;
115
+ };
116
+ }
117
+ export interface IGetProductAvailabilityResponse {
118
+ status: string;
119
+ message: string;
120
+ data: {
121
+ is_available: boolean;
122
+ quantity: number;
123
+ };
124
+ }
@@ -0,0 +1,2 @@
1
+ export declare const getSubdomainClient: () => string;
2
+ export declare const getSubDomain: (host: string) => string;
@@ -0,0 +1,57 @@
1
+ export interface IGetStorePath {
2
+ slug: string;
3
+ }
4
+ export interface IGetStoreResponse {
5
+ status: string;
6
+ message: string;
7
+ data: IGetStoreData;
8
+ }
9
+ export type SocialMediaPlatformTypes = 'Whatsapp' | 'Facebook' | 'Instagram' | 'TikTok' | 'X';
10
+ export interface IGetStoreData {
11
+ id: string;
12
+ banner_url: string;
13
+ avatar_url: string;
14
+ maintenance_mode: boolean;
15
+ preferences?: {
16
+ mode_of_delivery: 'Pickup' | 'Delivery' | 'Delivery/Pickup';
17
+ mode_of_transaction_charge: 'Customer' | 'Merchant';
18
+ };
19
+ social_media: {
20
+ platform: SocialMediaPlatformTypes;
21
+ url: string;
22
+ }[];
23
+ delivery_areas: {
24
+ location: string;
25
+ amount: number;
26
+ }[];
27
+ phone_number: string;
28
+ collections: Collection[];
29
+ best_sellers: Bestseller[];
30
+ metadata: Metadata;
31
+ }
32
+ export interface Metadata {
33
+ description: string;
34
+ author: string;
35
+ store_slug: string;
36
+ address: string;
37
+ business_name: string;
38
+ }
39
+ export interface Bestseller {
40
+ id: number;
41
+ product: string;
42
+ category: string;
43
+ amount: number;
44
+ currency: string;
45
+ in_stock: number;
46
+ availability: number;
47
+ keywords: string[];
48
+ image_url: string[];
49
+ name: string;
50
+ discounted_amount: number;
51
+ }
52
+ export interface Collection {
53
+ id: string;
54
+ name: string;
55
+ description: string;
56
+ cover_image_url: string[];
57
+ }