@vindhq/sloud-payment-sdk 1.0.3 → 1.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/README.md +74 -37
- package/dist/index.cjs.js +51295 -24
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +3 -258
- package/dist/index.esm.js +51293 -24
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +51301 -24
- package/dist/index.umd.js.map +1 -0
- package/dist/react/index.esm.js +51440 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/react/rollup.config.d.ts +8 -0
- package/dist/react/rollup.config.dts.d.ts +3 -0
- package/dist/react/src/components/Button/Button.types.d.ts +6 -0
- package/dist/react/src/components/Button/index.d.ts +3 -0
- package/dist/react/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +4 -0
- package/dist/react/src/components/CopyToClipboardSpan/index.d.ts +3 -0
- package/dist/react/src/components/Input/Input.types.d.ts +17 -0
- package/dist/react/src/components/Input/index.d.ts +3 -0
- package/dist/react/src/components/Skeleton/PaymentOptionSkeletons.d.ts +6 -0
- package/dist/react/src/components/TextArea/TextArea.types.d.ts +19 -0
- package/dist/react/src/components/TextArea/index.d.ts +3 -0
- package/dist/react/src/components/Widget.d.ts +6 -0
- package/dist/react/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +2 -0
- package/dist/react/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +2 -0
- package/dist/react/src/components/modals/Modal.d.ts +10 -0
- package/dist/react/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +2 -0
- package/dist/react/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +7 -0
- package/dist/react/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +2 -0
- package/dist/react/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +11 -0
- package/dist/react/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +5 -0
- package/dist/react/src/components/modals/SuccessModal/SuccessModal.d.ts +2 -0
- package/dist/react/src/components/modals/state/actions/data.d.ts +10 -0
- package/dist/react/src/components/modals/state/actions/index.d.ts +5 -0
- package/dist/react/src/components/modals/state/actions/modal.d.ts +5 -0
- package/dist/react/src/components/modals/state/actions/payment.d.ts +7 -0
- package/dist/react/src/components/modals/state/constants/actionTypes.d.ts +24 -0
- package/dist/react/src/components/modals/state/constants/index.d.ts +2 -0
- package/dist/react/src/components/modals/state/constants/initialState.d.ts +36 -0
- package/dist/react/src/components/modals/state/reducers/data.d.ts +2 -0
- package/dist/react/src/components/modals/state/reducers/index.d.ts +2 -0
- package/dist/react/src/components/modals/state/reducers/modal.d.ts +2 -0
- package/dist/react/src/components/modals/state/reducers/payment.d.ts +2 -0
- package/dist/react/src/components/modals/state/types/common.d.ts +12 -0
- package/dist/react/src/components/modals/state/types/data.d.ts +34 -0
- package/dist/react/src/components/modals/state/types/index.d.ts +8 -0
- package/dist/react/src/components/modals/state/types/modal.d.ts +12 -0
- package/dist/react/src/components/modals/state/types/payment.d.ts +14 -0
- package/dist/react/src/components/modals/state/utils/index.d.ts +37 -0
- package/dist/react/src/context/ModalProvider.d.ts +4 -0
- package/dist/react/src/context/PaymentInfoContext.d.ts +26 -0
- package/dist/react/src/context/PaymentWidgetContext.d.ts +13 -0
- package/dist/react/src/context/modal.d.ts +4 -0
- package/dist/react/src/context/types.d.ts +28 -0
- package/dist/react/src/hooks/types.d.ts +34 -0
- package/dist/react/src/hooks/useModalControl.d.ts +27 -0
- package/dist/react/src/hooks/usePaymentAPI.d.ts +10 -0
- package/dist/react/src/hooks/useShortPolling.d.ts +4 -0
- package/dist/react/src/index.d.ts +2 -0
- package/dist/react/src/services/config/endpoints.d.ts +9 -0
- package/dist/react/src/services/config/error.d.ts +5 -0
- package/dist/react/src/services/index.d.ts +27 -0
- package/dist/react/src/services/payments/index.d.ts +4 -0
- package/dist/react/src/services/payments/types.d.ts +68 -0
- package/dist/react/src/services/products/index.d.ts +1 -0
- package/dist/react/src/services/products/types.d.ts +124 -0
- package/dist/react/src/services/store/index.d.ts +2 -0
- package/dist/react/src/services/store/types.d.ts +57 -0
- package/dist/react/src/services/utils/widgetConfig.d.ts +20 -0
- package/dist/react/src/svg_components/ArrowLeftIcon.d.ts +3 -0
- package/dist/react/src/svg_components/BankTransferIcon.d.ts +2 -0
- package/dist/react/src/svg_components/CancelIcon.d.ts +7 -0
- package/dist/react/src/svg_components/CardIcon.d.ts +2 -0
- package/dist/react/src/svg_components/CloseIcon.d.ts +3 -0
- package/dist/react/src/svg_components/CopyIcon.d.ts +2 -0
- package/dist/react/src/svg_components/EyeCloseIcon.d.ts +5 -0
- package/dist/react/src/svg_components/EyeOpenIcon.d.ts +5 -0
- package/dist/react/src/svg_components/SloudIcon.d.ts +2 -0
- package/dist/react/src/utils/enums/AxiosErrorCodes.d.ts +7 -0
- package/dist/react/src/utils/enums/AxiosMethods.d.ts +7 -0
- package/dist/react/src/utils/helpers/classNames.d.ts +7 -0
- package/dist/react/src/utils/helpers/formatCurrency.d.ts +10 -0
- package/dist/react/src/utils/helpers/phoneDefaults.d.ts +3 -0
- package/dist/react/src/utils/helpers/validatePhone.d.ts +7 -0
- package/dist/react/src/utils/image_utils/index.d.ts +9 -0
- package/dist/react/src/utils/storage/index.d.ts +9 -0
- package/dist/react/src/widget.d.ts +27 -0
- package/dist/rollup.config.d.ts +8 -0
- package/dist/rollup.config.dts.d.ts +3 -0
- package/dist/src/components/Button/Button.types.d.ts +6 -0
- package/dist/src/components/Button/index.d.ts +3 -0
- package/dist/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +4 -0
- package/dist/src/components/CopyToClipboardSpan/index.d.ts +3 -0
- package/dist/src/components/Input/Input.types.d.ts +17 -0
- package/dist/src/components/Input/index.d.ts +3 -0
- package/dist/src/components/Skeleton/PaymentOptionSkeletons.d.ts +6 -0
- package/dist/src/components/TextArea/TextArea.types.d.ts +19 -0
- package/dist/src/components/TextArea/index.d.ts +3 -0
- package/dist/src/components/Widget.d.ts +6 -0
- package/dist/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +2 -0
- package/dist/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +2 -0
- package/dist/src/components/modals/Modal.d.ts +10 -0
- package/dist/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +2 -0
- package/dist/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +7 -0
- package/dist/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +2 -0
- package/dist/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +11 -0
- package/dist/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +5 -0
- package/dist/src/components/modals/SuccessModal/SuccessModal.d.ts +2 -0
- package/dist/src/components/modals/state/actions/data.d.ts +10 -0
- package/dist/src/components/modals/state/actions/index.d.ts +5 -0
- package/dist/src/components/modals/state/actions/modal.d.ts +5 -0
- package/dist/src/components/modals/state/actions/payment.d.ts +7 -0
- package/dist/src/components/modals/state/constants/actionTypes.d.ts +24 -0
- package/dist/src/components/modals/state/constants/index.d.ts +2 -0
- package/dist/src/components/modals/state/constants/initialState.d.ts +36 -0
- package/dist/src/components/modals/state/reducers/data.d.ts +2 -0
- package/dist/src/components/modals/state/reducers/index.d.ts +2 -0
- package/dist/src/components/modals/state/reducers/modal.d.ts +2 -0
- package/dist/src/components/modals/state/reducers/payment.d.ts +2 -0
- package/dist/src/components/modals/state/types/common.d.ts +12 -0
- package/dist/src/components/modals/state/types/data.d.ts +34 -0
- package/dist/src/components/modals/state/types/index.d.ts +8 -0
- package/dist/src/components/modals/state/types/modal.d.ts +12 -0
- package/dist/src/components/modals/state/types/payment.d.ts +14 -0
- package/dist/src/components/modals/state/utils/index.d.ts +37 -0
- package/dist/src/context/ModalProvider.d.ts +4 -0
- package/dist/src/context/PaymentInfoContext.d.ts +26 -0
- package/dist/src/context/PaymentWidgetContext.d.ts +13 -0
- package/dist/src/context/modal.d.ts +4 -0
- package/dist/src/context/types.d.ts +28 -0
- package/dist/src/hooks/types.d.ts +34 -0
- package/dist/src/hooks/useModalControl.d.ts +27 -0
- package/dist/src/hooks/usePaymentAPI.d.ts +10 -0
- package/dist/src/hooks/useShortPolling.d.ts +4 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/services/config/endpoints.d.ts +9 -0
- package/dist/src/services/config/error.d.ts +5 -0
- package/dist/src/services/index.d.ts +27 -0
- package/dist/src/services/payments/index.d.ts +4 -0
- package/dist/src/services/payments/types.d.ts +68 -0
- package/dist/src/services/products/index.d.ts +1 -0
- package/dist/src/services/products/types.d.ts +124 -0
- package/dist/src/services/store/index.d.ts +2 -0
- package/dist/src/services/store/types.d.ts +57 -0
- package/dist/src/services/utils/widgetConfig.d.ts +20 -0
- package/dist/src/svg_components/ArrowLeftIcon.d.ts +3 -0
- package/dist/src/svg_components/BankTransferIcon.d.ts +2 -0
- package/dist/src/svg_components/CancelIcon.d.ts +7 -0
- package/dist/src/svg_components/CardIcon.d.ts +2 -0
- package/dist/src/svg_components/CloseIcon.d.ts +3 -0
- package/dist/src/svg_components/CopyIcon.d.ts +2 -0
- package/dist/src/svg_components/EyeCloseIcon.d.ts +5 -0
- package/dist/src/svg_components/EyeOpenIcon.d.ts +5 -0
- package/dist/src/svg_components/SloudIcon.d.ts +2 -0
- package/dist/src/utils/enums/AxiosErrorCodes.d.ts +7 -0
- package/dist/src/utils/enums/AxiosMethods.d.ts +7 -0
- package/dist/src/utils/helpers/classNames.d.ts +7 -0
- package/dist/src/utils/helpers/formatCurrency.d.ts +10 -0
- package/dist/src/utils/helpers/phoneDefaults.d.ts +3 -0
- package/dist/src/utils/helpers/validatePhone.d.ts +7 -0
- package/dist/src/utils/image_utils/index.d.ts +9 -0
- package/dist/src/utils/storage/index.d.ts +9 -0
- package/dist/src/widget.d.ts +27 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,30 +41,30 @@ For direct browser usage without a bundler, use the UMD build which includes Rea
|
|
|
41
41
|
```html
|
|
42
42
|
<!DOCTYPE html>
|
|
43
43
|
<html>
|
|
44
|
-
<head>
|
|
45
|
-
|
|
46
|
-
</head>
|
|
47
|
-
<body>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</body>
|
|
44
|
+
<head>
|
|
45
|
+
<title>Payment Widget</title>
|
|
46
|
+
</head>
|
|
47
|
+
<body>
|
|
48
|
+
<!-- Load the UMD bundle (includes React) -->
|
|
49
|
+
<script src="https://unpkg.com/@vindhq/sloud-payment-sdk@latest/dist/index.umd.js"></script>
|
|
50
|
+
|
|
51
|
+
<script>
|
|
52
|
+
// Access via PaymentWidget.default for UMD builds
|
|
53
|
+
const widget = new PaymentWidget.default({
|
|
54
|
+
type: "external",
|
|
55
|
+
public_key: "your-public-api-key",
|
|
56
|
+
amount: 10000,
|
|
57
|
+
customer: {
|
|
58
|
+
first_name: "John",
|
|
59
|
+
last_name: "Doe",
|
|
60
|
+
phone_number: "+2348012345678",
|
|
61
|
+
email: "john.doe@example.com",
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
widget.showPopup();
|
|
66
|
+
</script>
|
|
67
|
+
</body>
|
|
68
68
|
</html>
|
|
69
69
|
```
|
|
70
70
|
|
|
@@ -90,11 +90,40 @@ const widget = new PaymentWidget({
|
|
|
90
90
|
email: "john.doe@example.com",
|
|
91
91
|
},
|
|
92
92
|
isLocalEnv: false, // Optional: set to true for local development
|
|
93
|
+
onSuccess: () => {
|
|
94
|
+
console.log("Payment successful!");
|
|
95
|
+
// Navigate to a confirmation page, update your UI, etc.
|
|
96
|
+
},
|
|
93
97
|
});
|
|
94
98
|
|
|
95
99
|
widget.showPopup();
|
|
96
100
|
```
|
|
97
101
|
|
|
102
|
+
### Handling Payment Success
|
|
103
|
+
|
|
104
|
+
Use the `onSuccess` callback to be notified when a payment completes successfully:
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
import PaymentWidget from "@vindhq/sloud-payment-sdk";
|
|
108
|
+
|
|
109
|
+
const widget = new PaymentWidget({
|
|
110
|
+
type: "external",
|
|
111
|
+
public_key: "your-public-api-key",
|
|
112
|
+
amount: 10000,
|
|
113
|
+
customer: {
|
|
114
|
+
first_name: "John",
|
|
115
|
+
last_name: "Doe",
|
|
116
|
+
phone_number: "+2348012345678",
|
|
117
|
+
email: "john.doe@example.com",
|
|
118
|
+
},
|
|
119
|
+
onSuccess: () => {
|
|
120
|
+
console.log("Payment successful!");
|
|
121
|
+
// Navigate to a confirmation page, update your UI, etc.
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
widget.showPopup();
|
|
126
|
+
```
|
|
98
127
|
|
|
99
128
|
---
|
|
100
129
|
|
|
@@ -106,19 +135,19 @@ Creates a new payment widget instance.
|
|
|
106
135
|
|
|
107
136
|
#### Payment Widget Options
|
|
108
137
|
|
|
109
|
-
| Parameter
|
|
110
|
-
|
|
|
111
|
-
| `type`
|
|
112
|
-
| `public_key` | `string`
|
|
113
|
-
| `amount`
|
|
114
|
-
| `customer`
|
|
115
|
-
| `isLocalEnv` | `boolean`
|
|
116
|
-
|
|
117
|
-
|
|
138
|
+
| Parameter | Type | Required | Description |
|
|
139
|
+
| ------------ | ------------------------------------ | -------- | ----------------------------------------------- |
|
|
140
|
+
| `type` | `"external"` | Yes | Payment type (must be `"external"`) |
|
|
141
|
+
| `public_key` | `string` | Yes | Your public API key for secure payments |
|
|
142
|
+
| `amount` | `number` | Yes | Payment amount in smallest currency unit |
|
|
143
|
+
| `customer` | `Customer` | Yes | Customer information object |
|
|
144
|
+
| `isLocalEnv` | `boolean` | No | Set to `true` for local development environment |
|
|
145
|
+
| `onSuccess` | `(data: PaymentSuccessData) => void` | No | Callback invoked after a successful payment |
|
|
118
146
|
|
|
119
147
|
#### Type Definitions
|
|
120
148
|
|
|
121
149
|
**Customer**
|
|
150
|
+
|
|
122
151
|
```ts
|
|
123
152
|
interface Customer {
|
|
124
153
|
first_name: string;
|
|
@@ -128,6 +157,15 @@ interface Customer {
|
|
|
128
157
|
}
|
|
129
158
|
```
|
|
130
159
|
|
|
160
|
+
**PaymentSuccessData**
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
interface PaymentSuccessData {
|
|
164
|
+
reference: string;
|
|
165
|
+
amount: number;
|
|
166
|
+
currency: string;
|
|
167
|
+
}
|
|
168
|
+
```
|
|
131
169
|
|
|
132
170
|
#### Methods
|
|
133
171
|
|
|
@@ -192,9 +230,7 @@ try {
|
|
|
192
230
|
The SDK uses a builder pattern for payment payloads:
|
|
193
231
|
|
|
194
232
|
```ts
|
|
195
|
-
import {
|
|
196
|
-
buildPaymentInstrumentPayload,
|
|
197
|
-
} from "@vindhq/sloud-payment-sdk";
|
|
233
|
+
import { buildPaymentInstrumentPayload } from "@vindhq/sloud-payment-sdk";
|
|
198
234
|
|
|
199
235
|
// Build payload from options
|
|
200
236
|
const payload = buildPaymentInstrumentPayload({
|
|
@@ -217,6 +253,7 @@ The SDK is written in TypeScript and provides full type definitions:
|
|
|
217
253
|
```ts
|
|
218
254
|
import type {
|
|
219
255
|
PaymentWidgetOptions,
|
|
256
|
+
PaymentSuccessData,
|
|
220
257
|
Customer,
|
|
221
258
|
} from "@vindhq/sloud-payment-sdk";
|
|
222
259
|
|
|
@@ -292,7 +329,7 @@ Payment-Widget/
|
|
|
292
329
|
### Output Files
|
|
293
330
|
|
|
294
331
|
- **`dist/index.esm.js`** - ES Module build (externalizes React)
|
|
295
|
-
- **`dist/index.cjs.js`** - CommonJS build (externalizes React)
|
|
332
|
+
- **`dist/index.cjs.js`** - CommonJS build (externalizes React)
|
|
296
333
|
- **`dist/index.umd.js`** - UMD build for browsers (bundles React, ~2MB)
|
|
297
334
|
- **`dist/index.d.ts`** - TypeScript type definitions
|
|
298
335
|
|