@payai/x402-solana-react 1.0.3 → 2.0.0-canary.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 +154 -57
- package/dist/components/WalletSection.d.ts.map +1 -1
- package/dist/components/X402Paywall.d.ts +1 -1
- package/dist/components/X402Paywall.d.ts.map +1 -1
- package/dist/demo/App.d.ts +0 -1
- package/dist/demo/App.d.ts.map +1 -1
- package/dist/demo/main.d.ts +0 -1
- package/dist/hooks/useX402Payment.d.ts +6 -2
- package/dist/hooks/useX402Payment.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2768 -1799
- package/dist/index.mjs.map +1 -1
- package/dist/lib/balance.d.ts +0 -1
- package/dist/lib/utils.d.ts +0 -1
- package/dist/style.css +1 -1
- package/dist/types/paywall.d.ts +2 -3
- package/dist/types/paywall.d.ts.map +1 -1
- package/dist/types/theme.d.ts +1 -2
- package/dist/types/theme.d.ts.map +1 -1
- package/package.json +37 -32
package/README.md
CHANGED
|
@@ -2,12 +2,85 @@
|
|
|
2
2
|
|
|
3
3
|
A reusable React component library that provides drop-in paywall functionality for Solana-based applications using the x402 payment protocol.
|
|
4
4
|
|
|
5
|
+
## Classic theme
|
|
6
|
+
|
|
7
|
+
<table>
|
|
8
|
+
<tr>
|
|
9
|
+
<td width="50%">
|
|
10
|
+
|
|
11
|
+
<img src="./example-images/light.png" alt="Classic Light Theme Preview" style="width: 100%; height: auto;">
|
|
12
|
+
|
|
13
|
+
</td>
|
|
14
|
+
<td width="50%">
|
|
15
|
+
|
|
16
|
+
<img src="./example-images/dark.png" alt="Classic Dark Theme Preview" style="width: 100%; height: auto;">
|
|
17
|
+
|
|
18
|
+
</td>
|
|
19
|
+
</tr>
|
|
20
|
+
</table>
|
|
21
|
+
|
|
22
|
+
## Solana theme
|
|
23
|
+
|
|
24
|
+
<table>
|
|
25
|
+
<tr>
|
|
26
|
+
<td width="50%">
|
|
27
|
+
|
|
28
|
+
<img src="./example-images/solana-light.png" alt="Solana Light Theme Preview" style="width: 100%; height: auto;">
|
|
29
|
+
|
|
30
|
+
</td>
|
|
31
|
+
<td width="50%">
|
|
32
|
+
|
|
33
|
+
<img src="./example-images/solana-dark.png" alt="Solana Dark Theme Preview" style="width: 100%; height: auto;">
|
|
34
|
+
|
|
35
|
+
</td>
|
|
36
|
+
</tr>
|
|
37
|
+
</table>
|
|
38
|
+
|
|
39
|
+
## Seeker theme
|
|
40
|
+
|
|
41
|
+
<table>
|
|
42
|
+
<tr>
|
|
43
|
+
<td width="33.33%">
|
|
44
|
+
|
|
45
|
+
<img src="./example-images/seeker-light.png" alt="Seeker Light Theme Preview" style="width: 100%; height: auto;">
|
|
46
|
+
|
|
47
|
+
</td>
|
|
48
|
+
<td width="33.33%">
|
|
49
|
+
|
|
50
|
+
<img src="./example-images/seeker.png" alt="Seeker Theme Preview" style="width: 100%; height: auto;">
|
|
51
|
+
|
|
52
|
+
</td>
|
|
53
|
+
<td width="33.33%">
|
|
54
|
+
|
|
55
|
+
<img src="./example-images/seeker-2.png" alt="Seeker-2 Theme Preview" style="width: 100%; height: auto;">
|
|
56
|
+
|
|
57
|
+
</td>
|
|
58
|
+
</tr>
|
|
59
|
+
</table>
|
|
60
|
+
|
|
61
|
+
## Terminal theme
|
|
62
|
+
|
|
63
|
+
<table>
|
|
64
|
+
<tr>
|
|
65
|
+
<td width="50%">
|
|
66
|
+
|
|
67
|
+
<img src="./example-images/terminal-light.png" alt="Terminal Light Theme Preview" style="width: 100%; height: auto;">
|
|
68
|
+
|
|
69
|
+
</td>
|
|
70
|
+
<td width="50%">
|
|
71
|
+
|
|
72
|
+
<img src="./example-images/terminal-dark.png" alt="Terminal Dark Theme Preview" style="width: 100%; height: auto;">
|
|
73
|
+
|
|
74
|
+
</td>
|
|
75
|
+
</tr>
|
|
76
|
+
</table>
|
|
77
|
+
|
|
5
78
|
## 🚀 Features
|
|
6
79
|
|
|
7
80
|
- ✅ **Drop-in React Components**: Easy integration with existing apps
|
|
8
81
|
- ✅ **Auto-Setup Providers**: Automatically configures wallet providers (or use your own)
|
|
9
82
|
- ✅ **Solana Native**: Built specifically for Solana blockchain
|
|
10
|
-
- ✅ **Multi-Wallet Support**: Works with Phantom, Solflare, and more
|
|
83
|
+
- ✅ **Multi-Wallet Support**: Works with Phantom, Solflare, and more
|
|
11
84
|
- ✅ **Multiple Themes**: Light, Dark, Solana, Seeker, Terminal themes
|
|
12
85
|
- ✅ **Tailwind CSS**: Utility-first styling with customization
|
|
13
86
|
- ✅ **shadcn/ui**: Accessible, beautiful components
|
|
@@ -27,7 +100,7 @@ A reusable React component library that provides drop-in paywall functionality f
|
|
|
27
100
|
npm install @payai/x402-solana-react
|
|
28
101
|
# or
|
|
29
102
|
yarn add @payai/x402-solana-react
|
|
30
|
-
# or
|
|
103
|
+
# or
|
|
31
104
|
pnpm add @payai/x402-solana-react
|
|
32
105
|
```
|
|
33
106
|
|
|
@@ -46,18 +119,31 @@ npm install @solana/wallet-adapter-react @solana/wallet-adapter-react-ui @solana
|
|
|
46
119
|
Import the required styles in your main file (e.g., `main.tsx` or `App.tsx`):
|
|
47
120
|
|
|
48
121
|
```tsx
|
|
49
|
-
import
|
|
50
|
-
import
|
|
122
|
+
import "@payai/x402-solana-react/styles";
|
|
123
|
+
import "@solana/wallet-adapter-react-ui/styles.css";
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 2. Environment Variables (Optional - Recommended for Production)
|
|
127
|
+
|
|
128
|
+
For production use, configure a custom RPC endpoint to avoid rate limiting on public RPCs:
|
|
129
|
+
|
|
130
|
+
Create a `.env` file (you can copy from the included `.env.example`) and set your RPC URL:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
# Your Helius/QuickNode/Alchemy RPC URL
|
|
134
|
+
VITE_SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key=your_api_key_here
|
|
51
135
|
```
|
|
52
136
|
|
|
53
|
-
|
|
137
|
+
Restart the dev server after changing `.env` so Vite picks up updates.
|
|
138
|
+
|
|
139
|
+
### 3. Wallet Provider Setup (Optional)
|
|
54
140
|
|
|
55
141
|
**Option A: Auto-Setup (Recommended)** 🎉
|
|
56
142
|
|
|
57
143
|
The component automatically sets up wallet providers for you! Just use it directly:
|
|
58
144
|
|
|
59
145
|
```tsx
|
|
60
|
-
import { X402Paywall } from
|
|
146
|
+
import { X402Paywall } from "@payai/x402-solana-react";
|
|
61
147
|
|
|
62
148
|
function App() {
|
|
63
149
|
return (
|
|
@@ -77,19 +163,22 @@ function App() {
|
|
|
77
163
|
Wrap your app with Solana wallet providers:
|
|
78
164
|
|
|
79
165
|
```tsx
|
|
80
|
-
import { WalletAdapterNetwork } from
|
|
81
|
-
import {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
166
|
+
import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
|
|
167
|
+
import {
|
|
168
|
+
ConnectionProvider,
|
|
169
|
+
WalletProvider,
|
|
170
|
+
} from "@solana/wallet-adapter-react";
|
|
171
|
+
import { WalletModalProvider } from "@solana/wallet-adapter-react-ui";
|
|
172
|
+
import {
|
|
173
|
+
PhantomWalletAdapter,
|
|
174
|
+
SolflareWalletAdapter,
|
|
175
|
+
} from "@solana/wallet-adapter-wallets";
|
|
176
|
+
import { clusterApiUrl } from "@solana/web3.js";
|
|
85
177
|
|
|
86
178
|
function App() {
|
|
87
179
|
const network = WalletAdapterNetwork.Mainnet;
|
|
88
180
|
const endpoint = clusterApiUrl(network);
|
|
89
|
-
const wallets = [
|
|
90
|
-
new PhantomWalletAdapter(),
|
|
91
|
-
new SolflareWalletAdapter(),
|
|
92
|
-
];
|
|
181
|
+
const wallets = [new PhantomWalletAdapter(), new SolflareWalletAdapter()];
|
|
93
182
|
|
|
94
183
|
return (
|
|
95
184
|
<ConnectionProvider endpoint={endpoint}>
|
|
@@ -115,9 +204,9 @@ function App() {
|
|
|
115
204
|
### Simplest Example (Auto-Setup)
|
|
116
205
|
|
|
117
206
|
```tsx
|
|
118
|
-
import { X402Paywall } from
|
|
119
|
-
import
|
|
120
|
-
import
|
|
207
|
+
import { X402Paywall } from "@payai/x402-solana-react";
|
|
208
|
+
import "@payai/x402-solana-react/styles";
|
|
209
|
+
import "@solana/wallet-adapter-react-ui/styles.css";
|
|
121
210
|
|
|
122
211
|
function PremiumPage() {
|
|
123
212
|
return (
|
|
@@ -125,7 +214,7 @@ function PremiumPage() {
|
|
|
125
214
|
amount={0.02}
|
|
126
215
|
description="Premium AI Chat Access"
|
|
127
216
|
network="solana" // Use 'solana' for mainnet, 'solana-devnet' for testing
|
|
128
|
-
onPaymentSuccess={(txId) => console.log(
|
|
217
|
+
onPaymentSuccess={(txId) => console.log("Payment successful!", txId)}
|
|
129
218
|
>
|
|
130
219
|
<PremiumContent />
|
|
131
220
|
</X402Paywall>
|
|
@@ -136,7 +225,7 @@ function PremiumPage() {
|
|
|
136
225
|
### With Custom RPC (Recommended for Production)
|
|
137
226
|
|
|
138
227
|
```tsx
|
|
139
|
-
import { X402Paywall } from
|
|
228
|
+
import { X402Paywall } from "@payai/x402-solana-react";
|
|
140
229
|
|
|
141
230
|
function PremiumPage() {
|
|
142
231
|
// Set via environment variable: VITE_SOLANA_RPC_URL
|
|
@@ -149,11 +238,11 @@ function PremiumPage() {
|
|
|
149
238
|
network="solana"
|
|
150
239
|
rpcUrl={rpcUrl} // Avoids rate limiting on public RPCs
|
|
151
240
|
onPaymentSuccess={(txId) => {
|
|
152
|
-
console.log(
|
|
241
|
+
console.log("Payment successful!", txId);
|
|
153
242
|
// Update your backend, show success message, etc.
|
|
154
243
|
}}
|
|
155
244
|
onPaymentError={(error) => {
|
|
156
|
-
console.error(
|
|
245
|
+
console.error("Payment failed:", error);
|
|
157
246
|
}}
|
|
158
247
|
>
|
|
159
248
|
<PremiumContent />
|
|
@@ -179,11 +268,11 @@ The component comes with multiple built-in themes:
|
|
|
179
268
|
### Theme Example
|
|
180
269
|
|
|
181
270
|
```tsx
|
|
182
|
-
import { X402Paywall } from
|
|
183
|
-
import { useState } from
|
|
271
|
+
import { X402Paywall } from "@payai/x402-solana-react";
|
|
272
|
+
import { useState } from "react";
|
|
184
273
|
|
|
185
274
|
function PremiumPage() {
|
|
186
|
-
const [theme, setTheme] = useState(
|
|
275
|
+
const [theme, setTheme] = useState("light");
|
|
187
276
|
|
|
188
277
|
return (
|
|
189
278
|
<X402Paywall
|
|
@@ -191,7 +280,7 @@ function PremiumPage() {
|
|
|
191
280
|
description="Premium Features"
|
|
192
281
|
network="solana"
|
|
193
282
|
theme={theme} // Try: 'light', 'dark', 'solana-light', 'solana-dark', etc.
|
|
194
|
-
onPaymentSuccess={(txId) => console.log(
|
|
283
|
+
onPaymentSuccess={(txId) => console.log("Paid!", txId)}
|
|
195
284
|
>
|
|
196
285
|
<AdvancedFeatures />
|
|
197
286
|
</X402Paywall>
|
|
@@ -205,16 +294,16 @@ You can customize further using `classNames` and `customStyles` props:
|
|
|
205
294
|
|
|
206
295
|
```tsx
|
|
207
296
|
<X402Paywall
|
|
208
|
-
amount={5.
|
|
297
|
+
amount={5.0}
|
|
209
298
|
description="Premium Features"
|
|
210
299
|
network="solana"
|
|
211
300
|
theme="dark"
|
|
212
301
|
classNames={{
|
|
213
302
|
container: "bg-gradient-to-r from-purple-600 to-blue-600",
|
|
214
|
-
button: "bg-white text-purple-600 hover:bg-gray-50 font-bold"
|
|
303
|
+
button: "bg-white text-purple-600 hover:bg-gray-50 font-bold",
|
|
215
304
|
}}
|
|
216
305
|
customStyles={{
|
|
217
|
-
button: { boxShadow:
|
|
306
|
+
button: { boxShadow: "0 10px 30px rgba(153, 69, 255, 0.4)" },
|
|
218
307
|
}}
|
|
219
308
|
>
|
|
220
309
|
<AdvancedFeatures />
|
|
@@ -225,31 +314,32 @@ You can customize further using `classNames` and `customStyles` props:
|
|
|
225
314
|
|
|
226
315
|
### X402Paywall Props
|
|
227
316
|
|
|
228
|
-
| Prop
|
|
229
|
-
|
|
230
|
-
| `amount`
|
|
231
|
-
| `description`
|
|
232
|
-
| `children`
|
|
233
|
-
| `network`
|
|
234
|
-
| `wallet`
|
|
235
|
-
| `rpcUrl`
|
|
236
|
-
| `autoSetupProviders` | `boolean`
|
|
237
|
-
| `providerNetwork`
|
|
238
|
-
| `providerEndpoint`
|
|
239
|
-
| `
|
|
240
|
-
| `facilitatorUrl`
|
|
241
|
-
| `theme`
|
|
242
|
-
| `
|
|
243
|
-
| `
|
|
244
|
-
| `
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
| `
|
|
250
|
-
| `
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
317
|
+
| Prop | Type | Required | Default | Description |
|
|
318
|
+
| -------------------- | ----------------------------- | -------- | ----------------- | ----------------------------------------------------------- |
|
|
319
|
+
| `amount` | `number` | ✅ | - | Payment amount in USDC |
|
|
320
|
+
| `description` | `string` | ✅ | - | Payment description |
|
|
321
|
+
| `children` | `ReactNode` | ✅ | - | Protected content to show after payment |
|
|
322
|
+
| `network` | `'solana' \| 'solana-devnet'` | ❌ | `'solana-devnet'` | Solana network to use |
|
|
323
|
+
| `wallet` | `WalletAdapter` | ❌ | - | Optional wallet adapter (auto-uses context if not provided) |
|
|
324
|
+
| `rpcUrl` | `string` | ❌ | - | Custom RPC URL (recommended to avoid rate limits) |
|
|
325
|
+
| `autoSetupProviders` | `boolean` | ❌ | `true` | Automatically setup wallet providers |
|
|
326
|
+
| `providerNetwork` | `WalletAdapterNetwork` | ❌ | Auto-detected | Network for auto-setup providers |
|
|
327
|
+
| `providerEndpoint` | `string` | ❌ | - | Custom endpoint for auto-setup providers |
|
|
328
|
+
| `apiEndpoint` | `string` | ❌ | `https://x402.payai.network/api/solana/paid-content` | Custom API endpoint |
|
|
329
|
+
| `facilitatorUrl` | `string` | ❌ | - | Custom facilitator URL |
|
|
330
|
+
| `theme` | `ThemePreset` | ❌ | `'solana-light'` | Visual theme (see Themes section) |
|
|
331
|
+
| `logoUrl` | `string` | ❌ | - | Custom logo URL to display |
|
|
332
|
+
| `showBalance` | `boolean` | ❌ | `true` | Show wallet USDC balance |
|
|
333
|
+
| `showNetworkInfo` | `boolean` | ❌ | `true` | Show network information |
|
|
334
|
+
| `showPaymentDetails` | `boolean` | ❌ | `true` | Show payment details section |
|
|
335
|
+
| `maxPaymentAmount` | `number` | ❌ | - | Maximum allowed payment amount |
|
|
336
|
+
| `classNames` | `ComponentClassNames` | ❌ | - | Custom CSS classes for components |
|
|
337
|
+
| `customStyles` | `ComponentStyles` | ❌ | - | Custom inline styles for components |
|
|
338
|
+
| `onPaymentStart` | `() => void` | ❌ | - | Callback when payment starts |
|
|
339
|
+
| `onPaymentSuccess` | `(txId: string) => void` | ❌ | - | Callback on successful payment |
|
|
340
|
+
| `onPaymentError` | `(error: Error) => void` | ❌ | - | Callback on payment error |
|
|
341
|
+
| `onWalletConnect` | `(publicKey: string) => void` | ❌ | - | Callback when wallet connects |
|
|
342
|
+
| `onDisconnect` | `() => void` | ❌ | - | Callback when wallet disconnects |
|
|
253
343
|
|
|
254
344
|
See [full API documentation](./docs/API_REFERENCE.md) for complete reference.
|
|
255
345
|
|
|
@@ -292,36 +382,42 @@ npm run lint
|
|
|
292
382
|
### Common Issues
|
|
293
383
|
|
|
294
384
|
**"Wallet not connected"**
|
|
385
|
+
|
|
295
386
|
- Ensure wallet provider is properly configured
|
|
296
387
|
- Check that wallet extension is installed and unlocked
|
|
297
388
|
- Verify network matches (mainnet vs devnet)
|
|
298
389
|
|
|
299
390
|
**"Insufficient USDC balance"**
|
|
391
|
+
|
|
300
392
|
- Check wallet has enough USDC for payment + gas
|
|
301
393
|
- On devnet: Use [Solana Faucet](https://faucet.solana.com/) for SOL
|
|
302
394
|
- Get devnet USDC from test token faucets like [Circle](https://faucet.circle.com/)
|
|
303
395
|
|
|
304
396
|
**"RPC rate limit exceeded"**
|
|
397
|
+
|
|
305
398
|
- Use a custom RPC provider (Helius, QuickNode, Alchemy)
|
|
306
399
|
- Set `VITE_SOLANA_RPC_URL` in `.env` file
|
|
307
400
|
- Pass via `rpcUrl` prop: `rpcUrl={import.meta.env.VITE_SOLANA_RPC_URL}`
|
|
308
401
|
- For production, always use a paid RPC endpoint
|
|
309
402
|
|
|
310
403
|
**"Transaction failed"**
|
|
404
|
+
|
|
311
405
|
- Verify network connectivity
|
|
312
406
|
- Check Solana network status
|
|
313
407
|
- Ensure sufficient SOL for transaction fees
|
|
314
408
|
|
|
315
409
|
**Styling not working**
|
|
410
|
+
|
|
316
411
|
- Make sure you imported both required stylesheets:
|
|
317
412
|
```tsx
|
|
318
|
-
import
|
|
319
|
-
import
|
|
413
|
+
import "@payai/x402-solana-react/styles";
|
|
414
|
+
import "@solana/wallet-adapter-react-ui/styles.css";
|
|
320
415
|
```
|
|
321
416
|
- Check browser console for CSS loading errors
|
|
322
417
|
- Verify Tailwind CSS is configured if using custom classes
|
|
323
418
|
|
|
324
419
|
**"process is not defined" error**
|
|
420
|
+
|
|
325
421
|
- Use Vite's `import.meta.env` instead of `process.env`
|
|
326
422
|
- Example: `import.meta.env.VITE_SOLANA_RPC_URL`
|
|
327
423
|
|
|
@@ -330,6 +426,7 @@ npm run lint
|
|
|
330
426
|
**Ready for Production** - Fully functional x402 paywall components with PayAI facilitator integration.
|
|
331
427
|
|
|
332
428
|
### Features Complete
|
|
429
|
+
|
|
333
430
|
- ✅ Core paywall component with Solana integration
|
|
334
431
|
- ✅ Payment processing via x402 protocol
|
|
335
432
|
- ✅ Multi-wallet support (Phantom, Solflare, etc.)
|
|
@@ -354,4 +451,4 @@ MIT License
|
|
|
354
451
|
|
|
355
452
|
---
|
|
356
453
|
|
|
357
|
-
Built with ❤️ for the Solana ecosystem
|
|
454
|
+
Built with ❤️ for the Solana ecosystem
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WalletSection.d.ts","sourceRoot":"","sources":["../../src/components/WalletSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"WalletSection.d.ts","sourceRoot":"","sources":["../../src/components/WalletSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAqMtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"X402Paywall.d.ts","sourceRoot":"","sources":["../../src/components/X402Paywall.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"X402Paywall.d.ts","sourceRoot":"","sources":["../../src/components/X402Paywall.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,EAAE,gBAAgB,EAA8B,MAAM,SAAS,CAAC;AA20EvE,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkClD,CAAC"}
|
package/dist/demo/App.d.ts
CHANGED
package/dist/demo/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/demo/App.tsx"],"names":[],"mappings":"AAYA,OAAO,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/demo/App.tsx"],"names":[],"mappings":"AAYA,OAAO,4CAA4C,CAAC;AA8HpD,iBAAS,GAAG,4CAEX;AAED,eAAe,GAAG,CAAC"}
|
package/dist/demo/main.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { WalletAdapter, SolanaNetwork, PaymentStatus } from '../types';
|
|
2
|
-
|
|
3
2
|
export interface PaymentConfig {
|
|
4
3
|
wallet: WalletAdapter;
|
|
5
4
|
network: SolanaNetwork;
|
|
6
5
|
rpcUrl?: string;
|
|
7
6
|
apiEndpoint?: string;
|
|
8
|
-
treasuryAddress?: string;
|
|
9
7
|
facilitatorUrl?: string;
|
|
10
8
|
maxPaymentAmount?: number;
|
|
9
|
+
/** Enable verbose logging for debugging (default: false) */
|
|
10
|
+
verbose?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface PaymentResult {
|
|
13
13
|
transactionId: string | null;
|
|
14
14
|
status: PaymentStatus;
|
|
15
15
|
error: Error | null;
|
|
16
|
+
/** The response content from the server (HTML or JSON) */
|
|
17
|
+
responseContent: string | null;
|
|
16
18
|
}
|
|
17
19
|
export interface UseX402PaymentReturn {
|
|
18
20
|
pay: (amount: number, description: string) => Promise<string | null>;
|
|
@@ -20,6 +22,8 @@ export interface UseX402PaymentReturn {
|
|
|
20
22
|
status: PaymentStatus;
|
|
21
23
|
error: Error | null;
|
|
22
24
|
transactionId: string | null;
|
|
25
|
+
/** The response content from the server (HTML or JSON) */
|
|
26
|
+
responseContent: string | null;
|
|
23
27
|
reset: () => void;
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useX402Payment.d.ts","sourceRoot":"","sources":["../../src/hooks/useX402Payment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEtE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"useX402Payment.d.ts","sourceRoot":"","sources":["../../src/hooks/useX402Payment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEtE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,0DAA0D;IAC1D,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrE,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0DAA0D;IAC1D,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,oBAAoB,CA6J1E"}
|