@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.
Files changed (163) hide show
  1. package/README.md +87 -20
  2. package/dist/index.cjs.js +24 -51295
  3. package/dist/index.d.ts +221 -3
  4. package/dist/index.esm.js +30 -51299
  5. package/dist/index.umd.js +24 -51301
  6. package/package.json +5 -4
  7. package/dist/index.cjs.js.map +0 -1
  8. package/dist/index.esm.js.map +0 -1
  9. package/dist/index.umd.js.map +0 -1
  10. package/dist/react/index.esm.js +0 -51440
  11. package/dist/react/index.esm.js.map +0 -1
  12. package/dist/react/rollup.config.d.ts +0 -8
  13. package/dist/react/rollup.config.dts.d.ts +0 -3
  14. package/dist/react/src/components/Button/Button.types.d.ts +0 -6
  15. package/dist/react/src/components/Button/index.d.ts +0 -3
  16. package/dist/react/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +0 -4
  17. package/dist/react/src/components/CopyToClipboardSpan/index.d.ts +0 -3
  18. package/dist/react/src/components/Input/Input.types.d.ts +0 -17
  19. package/dist/react/src/components/Input/index.d.ts +0 -3
  20. package/dist/react/src/components/Skeleton/PaymentOptionSkeletons.d.ts +0 -6
  21. package/dist/react/src/components/TextArea/TextArea.types.d.ts +0 -19
  22. package/dist/react/src/components/TextArea/index.d.ts +0 -3
  23. package/dist/react/src/components/Widget.d.ts +0 -6
  24. package/dist/react/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +0 -2
  25. package/dist/react/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +0 -2
  26. package/dist/react/src/components/modals/Modal.d.ts +0 -10
  27. package/dist/react/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +0 -2
  28. package/dist/react/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +0 -7
  29. package/dist/react/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +0 -2
  30. package/dist/react/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +0 -11
  31. package/dist/react/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +0 -5
  32. package/dist/react/src/components/modals/SuccessModal/SuccessModal.d.ts +0 -2
  33. package/dist/react/src/components/modals/state/actions/data.d.ts +0 -10
  34. package/dist/react/src/components/modals/state/actions/index.d.ts +0 -5
  35. package/dist/react/src/components/modals/state/actions/modal.d.ts +0 -5
  36. package/dist/react/src/components/modals/state/actions/payment.d.ts +0 -7
  37. package/dist/react/src/components/modals/state/constants/actionTypes.d.ts +0 -24
  38. package/dist/react/src/components/modals/state/constants/index.d.ts +0 -2
  39. package/dist/react/src/components/modals/state/constants/initialState.d.ts +0 -36
  40. package/dist/react/src/components/modals/state/reducers/data.d.ts +0 -2
  41. package/dist/react/src/components/modals/state/reducers/index.d.ts +0 -2
  42. package/dist/react/src/components/modals/state/reducers/modal.d.ts +0 -2
  43. package/dist/react/src/components/modals/state/reducers/payment.d.ts +0 -2
  44. package/dist/react/src/components/modals/state/types/common.d.ts +0 -12
  45. package/dist/react/src/components/modals/state/types/data.d.ts +0 -34
  46. package/dist/react/src/components/modals/state/types/index.d.ts +0 -8
  47. package/dist/react/src/components/modals/state/types/modal.d.ts +0 -12
  48. package/dist/react/src/components/modals/state/types/payment.d.ts +0 -14
  49. package/dist/react/src/components/modals/state/utils/index.d.ts +0 -37
  50. package/dist/react/src/context/ModalProvider.d.ts +0 -4
  51. package/dist/react/src/context/PaymentInfoContext.d.ts +0 -26
  52. package/dist/react/src/context/PaymentWidgetContext.d.ts +0 -13
  53. package/dist/react/src/context/modal.d.ts +0 -4
  54. package/dist/react/src/context/types.d.ts +0 -28
  55. package/dist/react/src/hooks/types.d.ts +0 -34
  56. package/dist/react/src/hooks/useModalControl.d.ts +0 -27
  57. package/dist/react/src/hooks/usePaymentAPI.d.ts +0 -10
  58. package/dist/react/src/hooks/useShortPolling.d.ts +0 -4
  59. package/dist/react/src/index.d.ts +0 -2
  60. package/dist/react/src/services/config/endpoints.d.ts +0 -9
  61. package/dist/react/src/services/config/error.d.ts +0 -5
  62. package/dist/react/src/services/index.d.ts +0 -27
  63. package/dist/react/src/services/payments/index.d.ts +0 -4
  64. package/dist/react/src/services/payments/types.d.ts +0 -68
  65. package/dist/react/src/services/products/index.d.ts +0 -1
  66. package/dist/react/src/services/products/types.d.ts +0 -124
  67. package/dist/react/src/services/store/index.d.ts +0 -2
  68. package/dist/react/src/services/store/types.d.ts +0 -57
  69. package/dist/react/src/services/utils/widgetConfig.d.ts +0 -20
  70. package/dist/react/src/svg_components/ArrowLeftIcon.d.ts +0 -3
  71. package/dist/react/src/svg_components/BankTransferIcon.d.ts +0 -2
  72. package/dist/react/src/svg_components/CancelIcon.d.ts +0 -7
  73. package/dist/react/src/svg_components/CardIcon.d.ts +0 -2
  74. package/dist/react/src/svg_components/CloseIcon.d.ts +0 -3
  75. package/dist/react/src/svg_components/CopyIcon.d.ts +0 -2
  76. package/dist/react/src/svg_components/EyeCloseIcon.d.ts +0 -5
  77. package/dist/react/src/svg_components/EyeOpenIcon.d.ts +0 -5
  78. package/dist/react/src/svg_components/SloudIcon.d.ts +0 -2
  79. package/dist/react/src/utils/enums/AxiosErrorCodes.d.ts +0 -7
  80. package/dist/react/src/utils/enums/AxiosMethods.d.ts +0 -7
  81. package/dist/react/src/utils/helpers/classNames.d.ts +0 -7
  82. package/dist/react/src/utils/helpers/formatCurrency.d.ts +0 -10
  83. package/dist/react/src/utils/helpers/phoneDefaults.d.ts +0 -3
  84. package/dist/react/src/utils/helpers/validatePhone.d.ts +0 -7
  85. package/dist/react/src/utils/image_utils/index.d.ts +0 -9
  86. package/dist/react/src/utils/storage/index.d.ts +0 -9
  87. package/dist/react/src/widget.d.ts +0 -27
  88. package/dist/rollup.config.d.ts +0 -8
  89. package/dist/rollup.config.dts.d.ts +0 -3
  90. package/dist/src/components/Button/Button.types.d.ts +0 -6
  91. package/dist/src/components/Button/index.d.ts +0 -3
  92. package/dist/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +0 -4
  93. package/dist/src/components/CopyToClipboardSpan/index.d.ts +0 -3
  94. package/dist/src/components/Input/Input.types.d.ts +0 -17
  95. package/dist/src/components/Input/index.d.ts +0 -3
  96. package/dist/src/components/Skeleton/PaymentOptionSkeletons.d.ts +0 -6
  97. package/dist/src/components/TextArea/TextArea.types.d.ts +0 -19
  98. package/dist/src/components/TextArea/index.d.ts +0 -3
  99. package/dist/src/components/Widget.d.ts +0 -6
  100. package/dist/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +0 -2
  101. package/dist/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +0 -2
  102. package/dist/src/components/modals/Modal.d.ts +0 -10
  103. package/dist/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +0 -2
  104. package/dist/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +0 -7
  105. package/dist/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +0 -2
  106. package/dist/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +0 -11
  107. package/dist/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +0 -5
  108. package/dist/src/components/modals/SuccessModal/SuccessModal.d.ts +0 -2
  109. package/dist/src/components/modals/state/actions/data.d.ts +0 -10
  110. package/dist/src/components/modals/state/actions/index.d.ts +0 -5
  111. package/dist/src/components/modals/state/actions/modal.d.ts +0 -5
  112. package/dist/src/components/modals/state/actions/payment.d.ts +0 -7
  113. package/dist/src/components/modals/state/constants/actionTypes.d.ts +0 -24
  114. package/dist/src/components/modals/state/constants/index.d.ts +0 -2
  115. package/dist/src/components/modals/state/constants/initialState.d.ts +0 -36
  116. package/dist/src/components/modals/state/reducers/data.d.ts +0 -2
  117. package/dist/src/components/modals/state/reducers/index.d.ts +0 -2
  118. package/dist/src/components/modals/state/reducers/modal.d.ts +0 -2
  119. package/dist/src/components/modals/state/reducers/payment.d.ts +0 -2
  120. package/dist/src/components/modals/state/types/common.d.ts +0 -12
  121. package/dist/src/components/modals/state/types/data.d.ts +0 -34
  122. package/dist/src/components/modals/state/types/index.d.ts +0 -8
  123. package/dist/src/components/modals/state/types/modal.d.ts +0 -12
  124. package/dist/src/components/modals/state/types/payment.d.ts +0 -14
  125. package/dist/src/components/modals/state/utils/index.d.ts +0 -37
  126. package/dist/src/context/ModalProvider.d.ts +0 -4
  127. package/dist/src/context/PaymentInfoContext.d.ts +0 -26
  128. package/dist/src/context/PaymentWidgetContext.d.ts +0 -13
  129. package/dist/src/context/modal.d.ts +0 -4
  130. package/dist/src/context/types.d.ts +0 -28
  131. package/dist/src/hooks/types.d.ts +0 -34
  132. package/dist/src/hooks/useModalControl.d.ts +0 -27
  133. package/dist/src/hooks/usePaymentAPI.d.ts +0 -10
  134. package/dist/src/hooks/useShortPolling.d.ts +0 -4
  135. package/dist/src/index.d.ts +0 -2
  136. package/dist/src/services/config/endpoints.d.ts +0 -9
  137. package/dist/src/services/config/error.d.ts +0 -5
  138. package/dist/src/services/index.d.ts +0 -27
  139. package/dist/src/services/payments/index.d.ts +0 -4
  140. package/dist/src/services/payments/types.d.ts +0 -68
  141. package/dist/src/services/products/index.d.ts +0 -1
  142. package/dist/src/services/products/types.d.ts +0 -124
  143. package/dist/src/services/store/index.d.ts +0 -2
  144. package/dist/src/services/store/types.d.ts +0 -57
  145. package/dist/src/services/utils/widgetConfig.d.ts +0 -20
  146. package/dist/src/svg_components/ArrowLeftIcon.d.ts +0 -3
  147. package/dist/src/svg_components/BankTransferIcon.d.ts +0 -2
  148. package/dist/src/svg_components/CancelIcon.d.ts +0 -7
  149. package/dist/src/svg_components/CardIcon.d.ts +0 -2
  150. package/dist/src/svg_components/CloseIcon.d.ts +0 -3
  151. package/dist/src/svg_components/CopyIcon.d.ts +0 -2
  152. package/dist/src/svg_components/EyeCloseIcon.d.ts +0 -5
  153. package/dist/src/svg_components/EyeOpenIcon.d.ts +0 -5
  154. package/dist/src/svg_components/SloudIcon.d.ts +0 -2
  155. package/dist/src/utils/enums/AxiosErrorCodes.d.ts +0 -7
  156. package/dist/src/utils/enums/AxiosMethods.d.ts +0 -7
  157. package/dist/src/utils/helpers/classNames.d.ts +0 -7
  158. package/dist/src/utils/helpers/formatCurrency.d.ts +0 -10
  159. package/dist/src/utils/helpers/phoneDefaults.d.ts +0 -3
  160. package/dist/src/utils/helpers/validatePhone.d.ts +0 -7
  161. package/dist/src/utils/image_utils/index.d.ts +0 -9
  162. package/dist/src/utils/storage/index.d.ts +0 -9
  163. 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 with React (peer dependency required).
11
- - **ESM build format** for modern npm/React apps.
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:** This widget has peer dependencies on React 19.1.1+. Make sure you have React and ReactDOM installed:
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
- # Build production bundles
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
- - Development server serves `dist` and `public` folders at `http://localhost:8080`.
365
- - Includes live reload for fast iteration.
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 # Entry point
375
- │ ├─ widget.ts # Widget class
376
- │ ├─ components/ # React components
377
- │ └─ styles/ # SCSS/CSS files
378
- ├─ dist/ # Bundled output (ESM, CJS, UMD)
379
- ├─ public/ # Dev server HTML
380
- ├─ rollup.config.ts # Rollup configuration
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
- - **ESM/CJS** → externalizes React for React apps.
389
- - **PostCSS** → injects and minifies CSS.
390
- - **Assets** SVG/PNG handled automatically.
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