@kwespay/widget 1.0.6 → 1.0.7

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 ADDED
@@ -0,0 +1,159 @@
1
+ # @kwespay/widget
2
+
3
+ > Accept crypto payments in 3 lines of code — drop-in JavaScript widget for EVM chains.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@kwespay/widget)](https://www.npmjs.com/package/@kwespay/widget)
6
+ [![license](https://img.shields.io/npm/l/@kwespay/widget)](LICENSE)
7
+
8
+ ---
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @kwespay/widget
14
+ ```
15
+
16
+ Or load via CDN (no bundler required):
17
+
18
+ ```html
19
+ <script src="https://unpkg.com/@kwespay/widget/dist/kwespay-widget.min.js"></script>
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Quick Start
25
+
26
+ ```js
27
+ import KwesPayWidget from "@kwespay/widget";
28
+
29
+ const widget = new KwesPayWidget({
30
+ apiKey: "your_api_key",
31
+ vendorId: "your_vendor_id",
32
+ amount: 10.0,
33
+ currency: "USD",
34
+ });
35
+
36
+ widget.open();
37
+ ```
38
+
39
+ That's it. The widget handles wallet connection, network switching, token selection, transaction signing, and success/error states.
40
+
41
+ ---
42
+
43
+ ## Configuration
44
+
45
+ ```js
46
+ const widget = new KwesPayWidget({
47
+ apiKey: "your_api_key", // Required — your KwesPay API key
48
+ vendorId: "your_vendor_id", // Required — your merchant identifier
49
+ amount: 25.0, // Required — fiat amount to charge
50
+ currency: "USD", // Optional — "USD" (default) or "GHS"
51
+ acceptedTokens: ["USDT", "USDC"], // Optional — restrict tokens. Pass "stablecoins" to allow all stables
52
+ });
53
+ ```
54
+
55
+ ### `acceptedTokens`
56
+
57
+ | Value | Behaviour |
58
+ | ------------------ | ------------------------------------ |
59
+ | `undefined` | All tokens on all supported networks |
60
+ | `"stablecoins"` | USDT, USDC, DAI, BUSD, USDc |
61
+ | `["USDT", "USDC"]` | Only the listed tokens |
62
+
63
+ Tokens are also scoped by your API key's network/token permissions set in the KwesPay dashboard.
64
+
65
+ ---
66
+
67
+ ## Supported Networks
68
+
69
+ | Network | Chain ID | Type |
70
+ | ------------ | -------- | ------- |
71
+ | Ethereum | 1 | Mainnet |
72
+ | Polygon | 137 | Mainnet |
73
+ | Base | 8453 | Mainnet |
74
+ | Lisk | 1135 | Mainnet |
75
+ | Sepolia | 11155111 | Testnet |
76
+ | Polygon Amoy | 80002 | Testnet |
77
+ | Base Sepolia | 84532 | Testnet |
78
+ | Lisk Sepolia | 4202 | Testnet |
79
+
80
+ Network and token availability in the widget is automatically filtered by your API key's permitted scope.
81
+
82
+ ---
83
+
84
+ ## Methods
85
+
86
+ ```js
87
+ widget.open(); // Opens the payment widget
88
+ widget.close(); // Closes the widget
89
+ widget.isOpen(); // Returns boolean
90
+ widget.updateAmount(15.0, "USD"); // Update amount without re-creating the widget
91
+ widget.getState(); // Returns current widget + config state
92
+ widget.destroy(); // Removes widget from DOM and cleans up
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Events
98
+
99
+ Listen for widget lifecycle and payment events on the `window`:
100
+
101
+ ```js
102
+ window.addEventListener("kwespay:paymentSuccess", (e) => {
103
+ const {
104
+ transactionHash,
105
+ transactionReference,
106
+ paymentIdBytes32,
107
+ fiatAmount,
108
+ currency,
109
+ token,
110
+ network,
111
+ } = e.detail;
112
+ // Fulfil the order
113
+ });
114
+
115
+ window.addEventListener("kwespay:paymentError", (e) => {
116
+ console.error(e.detail.error, e.detail.errorType);
117
+ });
118
+
119
+ window.addEventListener("kwespay:paymentCancelled", (e) => {
120
+ console.log(e.detail.reason); // "user_cancelled_review" | "user_started_over"
121
+ });
122
+
123
+ window.addEventListener("kwespay:widgetOpened", () => {});
124
+ window.addEventListener("kwespay:widgetClosed", (e) => {
125
+ console.log(e.detail.completedPayment); // boolean
126
+ });
127
+
128
+ window.addEventListener("kwespay:apiKeyValidated", (e) => {
129
+ console.log(e.detail.vendorInfo);
130
+ });
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Wallet Support
136
+
137
+ - **Injected wallets** (MetaMask, Coinbase Wallet, Rabby, etc.) via EIP-6963
138
+ - **Mobile wallets** via WalletConnect v2 (QR code + deep link)
139
+
140
+ ---
141
+
142
+ ## Examples
143
+
144
+ | Example | Stack |
145
+ | -------------------------------------------------------------------- | --------------------- |
146
+ | [Static HTML demo](https://github.com/kwespay/widget-example-static) | Vanilla JS, unpkg CDN |
147
+ | [Next.js demo](https://github.com/kwespay/widget-example-nextjs) | React, npm |
148
+
149
+ ---
150
+
151
+ ## Fee Model
152
+
153
+ KwesPay uses a **customer-pays-fee** architecture. The fee is calculated by the backend and signed into the payment payload — the merchant always receives the exact `amount` specified. Fee details are shown to the customer before they confirm the transaction.
154
+
155
+ ---
156
+
157
+ ## License
158
+
159
+ MIT © KwesPay