@vindhq/sloud-payment-sdk 1.0.0 → 1.0.1
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 +87 -20
- package/dist/index.cjs.js +24 -51295
- package/dist/index.d.ts +221 -3
- package/dist/index.esm.js +30 -51299
- package/dist/index.umd.js +24 -51301
- package/package.json +5 -4
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js.map +0 -1
- package/dist/index.umd.js.map +0 -1
- package/dist/react/index.esm.js +0 -51440
- package/dist/react/index.esm.js.map +0 -1
- package/dist/react/rollup.config.d.ts +0 -8
- package/dist/react/rollup.config.dts.d.ts +0 -3
- package/dist/react/src/components/Button/Button.types.d.ts +0 -6
- package/dist/react/src/components/Button/index.d.ts +0 -3
- package/dist/react/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +0 -4
- package/dist/react/src/components/CopyToClipboardSpan/index.d.ts +0 -3
- package/dist/react/src/components/Input/Input.types.d.ts +0 -17
- package/dist/react/src/components/Input/index.d.ts +0 -3
- package/dist/react/src/components/Skeleton/PaymentOptionSkeletons.d.ts +0 -6
- package/dist/react/src/components/TextArea/TextArea.types.d.ts +0 -19
- package/dist/react/src/components/TextArea/index.d.ts +0 -3
- package/dist/react/src/components/Widget.d.ts +0 -6
- package/dist/react/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +0 -2
- package/dist/react/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +0 -2
- package/dist/react/src/components/modals/Modal.d.ts +0 -10
- package/dist/react/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +0 -2
- package/dist/react/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +0 -7
- package/dist/react/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +0 -2
- package/dist/react/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +0 -11
- package/dist/react/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +0 -5
- package/dist/react/src/components/modals/SuccessModal/SuccessModal.d.ts +0 -2
- package/dist/react/src/components/modals/state/actions/data.d.ts +0 -10
- package/dist/react/src/components/modals/state/actions/index.d.ts +0 -5
- package/dist/react/src/components/modals/state/actions/modal.d.ts +0 -5
- package/dist/react/src/components/modals/state/actions/payment.d.ts +0 -7
- package/dist/react/src/components/modals/state/constants/actionTypes.d.ts +0 -24
- package/dist/react/src/components/modals/state/constants/index.d.ts +0 -2
- package/dist/react/src/components/modals/state/constants/initialState.d.ts +0 -36
- package/dist/react/src/components/modals/state/reducers/data.d.ts +0 -2
- package/dist/react/src/components/modals/state/reducers/index.d.ts +0 -2
- package/dist/react/src/components/modals/state/reducers/modal.d.ts +0 -2
- package/dist/react/src/components/modals/state/reducers/payment.d.ts +0 -2
- package/dist/react/src/components/modals/state/types/common.d.ts +0 -12
- package/dist/react/src/components/modals/state/types/data.d.ts +0 -34
- package/dist/react/src/components/modals/state/types/index.d.ts +0 -8
- package/dist/react/src/components/modals/state/types/modal.d.ts +0 -12
- package/dist/react/src/components/modals/state/types/payment.d.ts +0 -14
- package/dist/react/src/components/modals/state/utils/index.d.ts +0 -37
- package/dist/react/src/context/ModalProvider.d.ts +0 -4
- package/dist/react/src/context/PaymentInfoContext.d.ts +0 -26
- package/dist/react/src/context/PaymentWidgetContext.d.ts +0 -13
- package/dist/react/src/context/modal.d.ts +0 -4
- package/dist/react/src/context/types.d.ts +0 -28
- package/dist/react/src/hooks/types.d.ts +0 -34
- package/dist/react/src/hooks/useModalControl.d.ts +0 -27
- package/dist/react/src/hooks/usePaymentAPI.d.ts +0 -10
- package/dist/react/src/hooks/useShortPolling.d.ts +0 -4
- package/dist/react/src/index.d.ts +0 -2
- package/dist/react/src/services/config/endpoints.d.ts +0 -9
- package/dist/react/src/services/config/error.d.ts +0 -5
- package/dist/react/src/services/index.d.ts +0 -27
- package/dist/react/src/services/payments/index.d.ts +0 -4
- package/dist/react/src/services/payments/types.d.ts +0 -68
- package/dist/react/src/services/products/index.d.ts +0 -1
- package/dist/react/src/services/products/types.d.ts +0 -124
- package/dist/react/src/services/store/index.d.ts +0 -2
- package/dist/react/src/services/store/types.d.ts +0 -57
- package/dist/react/src/services/utils/widgetConfig.d.ts +0 -20
- package/dist/react/src/svg_components/ArrowLeftIcon.d.ts +0 -3
- package/dist/react/src/svg_components/BankTransferIcon.d.ts +0 -2
- package/dist/react/src/svg_components/CancelIcon.d.ts +0 -7
- package/dist/react/src/svg_components/CardIcon.d.ts +0 -2
- package/dist/react/src/svg_components/CloseIcon.d.ts +0 -3
- package/dist/react/src/svg_components/CopyIcon.d.ts +0 -2
- package/dist/react/src/svg_components/EyeCloseIcon.d.ts +0 -5
- package/dist/react/src/svg_components/EyeOpenIcon.d.ts +0 -5
- package/dist/react/src/svg_components/SloudIcon.d.ts +0 -2
- package/dist/react/src/utils/enums/AxiosErrorCodes.d.ts +0 -7
- package/dist/react/src/utils/enums/AxiosMethods.d.ts +0 -7
- package/dist/react/src/utils/helpers/classNames.d.ts +0 -7
- package/dist/react/src/utils/helpers/formatCurrency.d.ts +0 -10
- package/dist/react/src/utils/helpers/phoneDefaults.d.ts +0 -3
- package/dist/react/src/utils/helpers/validatePhone.d.ts +0 -7
- package/dist/react/src/utils/image_utils/index.d.ts +0 -9
- package/dist/react/src/utils/storage/index.d.ts +0 -9
- package/dist/react/src/widget.d.ts +0 -27
- package/dist/rollup.config.d.ts +0 -8
- package/dist/rollup.config.dts.d.ts +0 -3
- package/dist/src/components/Button/Button.types.d.ts +0 -6
- package/dist/src/components/Button/index.d.ts +0 -3
- package/dist/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +0 -4
- package/dist/src/components/CopyToClipboardSpan/index.d.ts +0 -3
- package/dist/src/components/Input/Input.types.d.ts +0 -17
- package/dist/src/components/Input/index.d.ts +0 -3
- package/dist/src/components/Skeleton/PaymentOptionSkeletons.d.ts +0 -6
- package/dist/src/components/TextArea/TextArea.types.d.ts +0 -19
- package/dist/src/components/TextArea/index.d.ts +0 -3
- package/dist/src/components/Widget.d.ts +0 -6
- package/dist/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +0 -2
- package/dist/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +0 -2
- package/dist/src/components/modals/Modal.d.ts +0 -10
- package/dist/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +0 -2
- package/dist/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +0 -7
- package/dist/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +0 -2
- package/dist/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +0 -11
- package/dist/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +0 -5
- package/dist/src/components/modals/SuccessModal/SuccessModal.d.ts +0 -2
- package/dist/src/components/modals/state/actions/data.d.ts +0 -10
- package/dist/src/components/modals/state/actions/index.d.ts +0 -5
- package/dist/src/components/modals/state/actions/modal.d.ts +0 -5
- package/dist/src/components/modals/state/actions/payment.d.ts +0 -7
- package/dist/src/components/modals/state/constants/actionTypes.d.ts +0 -24
- package/dist/src/components/modals/state/constants/index.d.ts +0 -2
- package/dist/src/components/modals/state/constants/initialState.d.ts +0 -36
- package/dist/src/components/modals/state/reducers/data.d.ts +0 -2
- package/dist/src/components/modals/state/reducers/index.d.ts +0 -2
- package/dist/src/components/modals/state/reducers/modal.d.ts +0 -2
- package/dist/src/components/modals/state/reducers/payment.d.ts +0 -2
- package/dist/src/components/modals/state/types/common.d.ts +0 -12
- package/dist/src/components/modals/state/types/data.d.ts +0 -34
- package/dist/src/components/modals/state/types/index.d.ts +0 -8
- package/dist/src/components/modals/state/types/modal.d.ts +0 -12
- package/dist/src/components/modals/state/types/payment.d.ts +0 -14
- package/dist/src/components/modals/state/utils/index.d.ts +0 -37
- package/dist/src/context/ModalProvider.d.ts +0 -4
- package/dist/src/context/PaymentInfoContext.d.ts +0 -26
- package/dist/src/context/PaymentWidgetContext.d.ts +0 -13
- package/dist/src/context/modal.d.ts +0 -4
- package/dist/src/context/types.d.ts +0 -28
- package/dist/src/hooks/types.d.ts +0 -34
- package/dist/src/hooks/useModalControl.d.ts +0 -27
- package/dist/src/hooks/usePaymentAPI.d.ts +0 -10
- package/dist/src/hooks/useShortPolling.d.ts +0 -4
- package/dist/src/index.d.ts +0 -2
- package/dist/src/services/config/endpoints.d.ts +0 -9
- package/dist/src/services/config/error.d.ts +0 -5
- package/dist/src/services/index.d.ts +0 -27
- package/dist/src/services/payments/index.d.ts +0 -4
- package/dist/src/services/payments/types.d.ts +0 -68
- package/dist/src/services/products/index.d.ts +0 -1
- package/dist/src/services/products/types.d.ts +0 -124
- package/dist/src/services/store/index.d.ts +0 -2
- package/dist/src/services/store/types.d.ts +0 -57
- package/dist/src/services/utils/widgetConfig.d.ts +0 -20
- package/dist/src/svg_components/ArrowLeftIcon.d.ts +0 -3
- package/dist/src/svg_components/BankTransferIcon.d.ts +0 -2
- package/dist/src/svg_components/CancelIcon.d.ts +0 -7
- package/dist/src/svg_components/CardIcon.d.ts +0 -2
- package/dist/src/svg_components/CloseIcon.d.ts +0 -3
- package/dist/src/svg_components/CopyIcon.d.ts +0 -2
- package/dist/src/svg_components/EyeCloseIcon.d.ts +0 -5
- package/dist/src/svg_components/EyeOpenIcon.d.ts +0 -5
- package/dist/src/svg_components/SloudIcon.d.ts +0 -2
- package/dist/src/utils/enums/AxiosErrorCodes.d.ts +0 -7
- package/dist/src/utils/enums/AxiosMethods.d.ts +0 -7
- package/dist/src/utils/helpers/classNames.d.ts +0 -7
- package/dist/src/utils/helpers/formatCurrency.d.ts +0 -10
- package/dist/src/utils/helpers/phoneDefaults.d.ts +0 -3
- package/dist/src/utils/helpers/validatePhone.d.ts +0 -7
- package/dist/src/utils/image_utils/index.d.ts +0 -9
- package/dist/src/utils/storage/index.d.ts +0 -9
- package/dist/src/widget.d.ts +0 -27
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Sloud Payment SDK
|
|
2
2
|
|
|
3
|
-
A secure, embeddable payment widget built in React, usable in **any JavaScript application** (React, Angular, Vue, or vanilla JS). Ships with **ESM builds** for easy integration.
|
|
3
|
+
A secure, embeddable payment widget built in React, usable in **any JavaScript application** (React, Angular, Vue, or vanilla JS). Ships with **ESM, CJS, and UMD builds** for easy integration in any environment.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Developer-friendly**: authored in React for easy maintenance and composability.
|
|
10
|
-
- **Framework-agnostic**: works
|
|
11
|
-
- **
|
|
10
|
+
- **Framework-agnostic**: works in any JavaScript environment.
|
|
11
|
+
- **Multiple build formats**: ESM and CJS for npm/React apps, UMD for browser usage.
|
|
12
12
|
- **Bundled CSS** via PostCSS.
|
|
13
13
|
- **Asset support** (SVG icons) included in the build.
|
|
14
14
|
- **Built-in validation** using Formik and Yup.
|
|
@@ -18,26 +18,64 @@ A secure, embeddable payment widget built in React, usable in **any JavaScript a
|
|
|
18
18
|
|
|
19
19
|
## Installation
|
|
20
20
|
|
|
21
|
+
### For npm/React Projects
|
|
22
|
+
|
|
21
23
|
```bash
|
|
22
24
|
# Using npm
|
|
23
|
-
npm install sloud-payment-sdk
|
|
25
|
+
npm install @vindhq/sloud-payment-sdk
|
|
24
26
|
|
|
25
27
|
# Using yarn
|
|
26
|
-
yarn add sloud-payment-sdk
|
|
28
|
+
yarn add @vindhq/sloud-payment-sdk
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
**Note:**
|
|
31
|
+
**Note:** For npm projects, this widget has peer dependencies on React 18+. Make sure you have React and ReactDOM installed:
|
|
30
32
|
|
|
31
33
|
```bash
|
|
32
34
|
npm install react react-dom
|
|
33
35
|
```
|
|
34
36
|
|
|
37
|
+
### For Browser Usage (No Bundler)
|
|
38
|
+
|
|
39
|
+
For direct browser usage without a bundler, use the UMD build which includes React bundled:
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<!DOCTYPE html>
|
|
43
|
+
<html>
|
|
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
|
+
</html>
|
|
69
|
+
```
|
|
70
|
+
|
|
35
71
|
---
|
|
36
72
|
|
|
37
73
|
## Usage
|
|
38
74
|
|
|
39
75
|
The payment widget supports three payment types: **external**, **storefront**, and **sloudfront**. Each type has its own set of required fields.
|
|
40
76
|
|
|
77
|
+
> **Note**: When using the UMD build in the browser (via script tag), access the widget via `PaymentWidget.default`. For npm/ES module imports, use the standard `import PaymentWidget from "sloud-payment-sdk"`.
|
|
78
|
+
|
|
41
79
|
### External Payment (Simple Payments)
|
|
42
80
|
|
|
43
81
|
For straightforward payments with customer details:
|
|
@@ -354,15 +392,27 @@ const options: StorefrontPaymentWidgetOptions = {
|
|
|
354
392
|
# Install dependencies
|
|
355
393
|
yarn install
|
|
356
394
|
|
|
357
|
-
# Run dev server with live reload
|
|
395
|
+
# Run dev server with live reload (UMD build for browser testing)
|
|
358
396
|
yarn dev
|
|
359
397
|
|
|
360
|
-
#
|
|
398
|
+
# Run dev server for library development (ESM/CJS builds)
|
|
399
|
+
yarn dev:lib
|
|
400
|
+
|
|
401
|
+
# Build all production bundles (ESM, CJS, UMD, and type definitions)
|
|
361
402
|
yarn build
|
|
362
403
|
```
|
|
363
404
|
|
|
364
|
-
|
|
365
|
-
|
|
405
|
+
### Development Server
|
|
406
|
+
|
|
407
|
+
- **`yarn dev`**: Starts development server with UMD build at `http://localhost:3000`
|
|
408
|
+
- Bundles React for standalone browser testing
|
|
409
|
+
- Live reload enabled
|
|
410
|
+
- Serves `dist` and `public` folders
|
|
411
|
+
- Use `public/index.html` to test the widget
|
|
412
|
+
|
|
413
|
+
- **`yarn dev:lib`**: Starts development server with ESM/CJS builds
|
|
414
|
+
- Externalizes React (for library development)
|
|
415
|
+
- Watch mode for rapid iteration
|
|
366
416
|
|
|
367
417
|
---
|
|
368
418
|
|
|
@@ -371,13 +421,19 @@ yarn build
|
|
|
371
421
|
```
|
|
372
422
|
Payment-Widget/
|
|
373
423
|
├─ src/
|
|
374
|
-
│ ├─ index.ts
|
|
375
|
-
│ ├─ widget.
|
|
376
|
-
│ ├─ components/
|
|
377
|
-
│ └─ styles/
|
|
378
|
-
├─ dist/
|
|
379
|
-
├─
|
|
380
|
-
├─
|
|
424
|
+
│ ├─ index.ts # Entry point
|
|
425
|
+
│ ├─ widget.tsx # Widget class
|
|
426
|
+
│ ├─ components/ # React components
|
|
427
|
+
│ └─ styles/ # SCSS/CSS files
|
|
428
|
+
├─ dist/ # Bundled output
|
|
429
|
+
│ ├─ index.esm.js # ES Module build
|
|
430
|
+
│ ├─ index.cjs.js # CommonJS build
|
|
431
|
+
│ ├─ index.umd.js # UMD browser build
|
|
432
|
+
│ └─ index.d.ts # Type definitions
|
|
433
|
+
├─ public/ # Dev server HTML for testing
|
|
434
|
+
├─ rollup.config.ts # ESM/CJS build config
|
|
435
|
+
├─ rollup.config.umd.ts # UMD build config
|
|
436
|
+
├─ rollup.config.dts.ts # Type definitions config
|
|
381
437
|
└─ package.json
|
|
382
438
|
```
|
|
383
439
|
|
|
@@ -385,9 +441,20 @@ Payment-Widget/
|
|
|
385
441
|
|
|
386
442
|
## Build Details
|
|
387
443
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
-
|
|
444
|
+
### Output Files
|
|
445
|
+
|
|
446
|
+
- **`dist/index.esm.js`** - ES Module build (externalizes React)
|
|
447
|
+
- **`dist/index.cjs.js`** - CommonJS build (externalizes React)
|
|
448
|
+
- **`dist/index.umd.js`** - UMD build for browsers (bundles React, ~2MB)
|
|
449
|
+
- **`dist/index.d.ts`** - TypeScript type definitions
|
|
450
|
+
|
|
451
|
+
### Build Configuration
|
|
452
|
+
|
|
453
|
+
- **ESM/CJS** → Externalizes React as peer dependency for React apps
|
|
454
|
+
- **UMD** → Bundles React for standalone browser usage
|
|
455
|
+
- **PostCSS** → Injects and minifies CSS into JS bundle
|
|
456
|
+
- **Assets** → SVG/PNG files handled automatically
|
|
457
|
+
- **TypeScript** → Full type definitions included
|
|
391
458
|
|
|
392
459
|
---
|
|
393
460
|
|