@cedros/pay-react 0.1.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 +154 -79
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -5,65 +5,142 @@
|
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
[](https://bundlephobia.com/package/@cedros/pay-react)
|
|
7
7
|
[]()
|
|
8
|
-
[](https://github.com/
|
|
8
|
+
[](https://github.com/CedrosPay/react)
|
|
9
9
|
|
|
10
|
-
> **
|
|
10
|
+
> **Add crypto to your store without building crypto.**
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
One React component for Stripe and Solana USDC. Uses your existing products. No deposit wallets. No monitoring. No custom crypto backend.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## What is Cedros Pay?
|
|
17
|
+
|
|
18
|
+
**One component, two payment rails.** Stripe for cards, Solana USDC for wallets. No second checkout.
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
Cedros Pay connects traditional payments (Stripe) with crypto (Solana x402) using the product IDs you already have. No deposit wallets to manage. No wallet infrastructure to secure. No custody risk.
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
- **NEW:** Generic endpoints (`/paywall/v1/quote`, `/paywall/v1/verify`) prevent resource ID leakage
|
|
20
|
-
- **REMOVED:** Resource-specific endpoints (`/paywall/{resource}`, `/paywall/cart/{id}`)
|
|
21
|
-
- **SECURITY:** Resource IDs now sent in request bodies and X-PAYMENT headers (not URLs)
|
|
22
|
+
### The Problem with Traditional Crypto Payments
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
Adding crypto to your store traditionally requires:
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
- Creating deposit wallets per user
|
|
27
|
+
- Monitoring deposits 24/7
|
|
28
|
+
- Sweeping funds to your merchant wallet
|
|
29
|
+
- Storing wallet state in your database
|
|
30
|
+
- Building Stripe separately
|
|
31
|
+
- Maintaining two systems
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
### The Cedros Pay Solution
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
```tsx
|
|
36
|
+
<CedrosPay
|
|
37
|
+
resource="your-product-id" // from your DB
|
|
38
|
+
onPaymentSuccess={(txId) => unlockContent(txId)}
|
|
39
|
+
/>
|
|
40
|
+
```
|
|
31
41
|
|
|
32
42
|
---
|
|
33
43
|
|
|
34
|
-
##
|
|
44
|
+
## How It Works (x402)
|
|
45
|
+
|
|
46
|
+
x402 makes Solana payments stateless. The client includes a signed transaction with the request. Your backend verifies it on-chain and unlocks the resource.
|
|
47
|
+
|
|
48
|
+
**Flow:**
|
|
35
49
|
|
|
36
50
|
```
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
Traditional:
|
|
52
|
+
User → Deposit Wallet (you manage) → Monitor → Sweep → Merchant
|
|
53
|
+
↓
|
|
54
|
+
Store state in DB
|
|
55
|
+
↓
|
|
56
|
+
Custody risk
|
|
57
|
+
|
|
58
|
+
x402:
|
|
59
|
+
User → Sign Transaction → Your Backend → Verify On-Chain → Merchant (Direct)
|
|
40
60
|
```
|
|
41
61
|
|
|
42
|
-
**
|
|
62
|
+
**Three key benefits:**
|
|
43
63
|
|
|
44
|
-
-
|
|
45
|
-
-
|
|
64
|
+
- No deposit wallets
|
|
65
|
+
- No sweeping funds
|
|
66
|
+
- No payment state in your DB
|
|
46
67
|
|
|
47
|
-
|
|
68
|
+
---
|
|
48
69
|
|
|
49
|
-
|
|
50
|
-
- Deploy standalone or embed into existing backend.
|
|
70
|
+
## Key Features
|
|
51
71
|
|
|
52
|
-
|
|
72
|
+
### 1. One Component, Two Rails
|
|
73
|
+
|
|
74
|
+
Stripe for cards, Solana USDC for wallets. No second checkout.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<CedrosPay resource="product-1" />
|
|
78
|
+
// Both payment methods work
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2. Works With Your Products
|
|
82
|
+
|
|
83
|
+
Pass your DB ID. No new schema.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<CedrosPay resource="existing-product-123" />
|
|
87
|
+
// resource = your database primary key
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 3. Real Ecommerce, Not Just a Button
|
|
91
|
+
|
|
92
|
+
Carts, coupons, refunds, metadata.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<CedrosPay
|
|
96
|
+
items={[{ resource: "item-1", quantity: 2 }]}
|
|
97
|
+
couponCode="LAUNCH50"
|
|
98
|
+
/>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 4. Auto-Detects Wallet
|
|
102
|
+
|
|
103
|
+
No wallet: card only. Wallet: card and crypto.
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
// User without wallet sees:
|
|
107
|
+
[Pay with Card] button
|
|
108
|
+
|
|
109
|
+
// User with Phantom sees:
|
|
110
|
+
[Pay with Card] [Pay with Crypto]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 5. Agent-Ready
|
|
114
|
+
|
|
115
|
+
x402 over HTTP; agents pay per request.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
GET /api/premium-data
|
|
119
|
+
X-PAYMENT: <signed-transaction>
|
|
120
|
+
# Agent gets data instantly
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 6. Self-Host or Roll Your Own
|
|
124
|
+
|
|
125
|
+
React UI + Go backend. Open API.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<CedrosPay resource="item" wallets={customWallets} renderModal={CustomModal} />
|
|
129
|
+
```
|
|
53
130
|
|
|
54
|
-
|
|
131
|
+
**Additional Features:**
|
|
55
132
|
|
|
56
|
-
- 🪙 **Dual payment support** — Card + Crypto
|
|
57
|
-
- ⚡ **Instant agentic payments** — Pay per request via x402
|
|
58
|
-
- 🔐 **Stateless & secure** — No need for user accounts or deposit addresses
|
|
59
133
|
- 🌍 **Open source** — MIT-licensed and extensible
|
|
134
|
+
- 🔐 **Stateless & secure** — No user accounts or deposit addresses required
|
|
60
135
|
- 🧱 **Minimal integration** — Middleware or proxy for Go APIs
|
|
61
136
|
|
|
62
137
|
---
|
|
63
138
|
|
|
64
|
-
##
|
|
139
|
+
## Quick Start (3 Steps in ~3 Minutes)
|
|
140
|
+
|
|
141
|
+
If you can wrap a provider, you can ship dual payments.
|
|
65
142
|
|
|
66
|
-
###
|
|
143
|
+
### Step 1: Install
|
|
67
144
|
|
|
68
145
|
**Option 1: Stripe + Crypto (Full Features)**
|
|
69
146
|
|
|
@@ -104,12 +181,6 @@ function App() {
|
|
|
104
181
|
}
|
|
105
182
|
```
|
|
106
183
|
|
|
107
|
-
**Bundle Size Comparison:**
|
|
108
|
-
|
|
109
|
-
- `@cedros/pay-react` (full): ~100KB + 850KB Solana peer deps
|
|
110
|
-
- `@cedros/pay-react/stripe-only`: ~75KB (no Solana deps)
|
|
111
|
-
- `@cedros/pay-react/crypto-only`: ~100KB + 850KB Solana peer deps
|
|
112
|
-
|
|
113
184
|
### CDN Usage (Optional)
|
|
114
185
|
|
|
115
186
|
For zero-build prototyping or simple sites, you can import directly from a CDN:
|
|
@@ -185,10 +256,12 @@ function App() {
|
|
|
185
256
|
<CedrosPay resource="item-id" display={{ showCrypto: false }} />
|
|
186
257
|
```
|
|
187
258
|
|
|
188
|
-
###
|
|
259
|
+
### Step 2: Configure Provider
|
|
260
|
+
|
|
261
|
+
Wrap your app with credentials + cluster:
|
|
189
262
|
|
|
190
263
|
```tsx
|
|
191
|
-
import {
|
|
264
|
+
import { CedrosProvider } from "@cedros/pay-react";
|
|
192
265
|
import "@cedros/pay-react/style.css";
|
|
193
266
|
|
|
194
267
|
function App() {
|
|
@@ -196,26 +269,46 @@ function App() {
|
|
|
196
269
|
<CedrosProvider
|
|
197
270
|
config={{
|
|
198
271
|
stripePublicKey: "pk_test_...",
|
|
199
|
-
serverUrl:
|
|
272
|
+
serverUrl: "https://your-api.com",
|
|
200
273
|
solanaCluster: "mainnet-beta",
|
|
201
|
-
// serverUrl defaults to window.location.origin
|
|
202
|
-
// Only needed if your backend is on a different domain
|
|
203
274
|
}}
|
|
204
275
|
>
|
|
205
|
-
<
|
|
206
|
-
resource="demo-item-id-1"
|
|
207
|
-
callbacks={{
|
|
208
|
-
onPaymentSuccess: (result) =>
|
|
209
|
-
console.log("Payment successful!", result.transactionId),
|
|
210
|
-
onPaymentError: (error) =>
|
|
211
|
-
console.error("Payment failed:", error.message),
|
|
212
|
-
}}
|
|
213
|
-
/>
|
|
276
|
+
<YourApp />
|
|
214
277
|
</CedrosProvider>
|
|
215
278
|
);
|
|
216
279
|
}
|
|
217
280
|
```
|
|
218
281
|
|
|
282
|
+
### Step 3: Drop in the Component
|
|
283
|
+
|
|
284
|
+
On success → fulfill order:
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
import { CedrosPay } from "@cedros/pay-react";
|
|
288
|
+
|
|
289
|
+
function Checkout() {
|
|
290
|
+
return (
|
|
291
|
+
<CedrosPay
|
|
292
|
+
resource="your-product-id"
|
|
293
|
+
callbacks={{
|
|
294
|
+
onPaymentSuccess: (result) => {
|
|
295
|
+
// Unlock content / fulfill order
|
|
296
|
+
unlockContent(result.transactionId);
|
|
297
|
+
},
|
|
298
|
+
}}
|
|
299
|
+
/>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Backend options:** Use the Go server, or implement the open API.
|
|
305
|
+
|
|
306
|
+
**Links:**
|
|
307
|
+
|
|
308
|
+
- [Backend setup →](https://github.com/CedrosPay/server)
|
|
309
|
+
- [Full docs →](https://docs.cedrospay.com)
|
|
310
|
+
- [Example apps →](https://github.com/CedrosPay/react/tree/main/examples)
|
|
311
|
+
|
|
219
312
|
**Cross-Domain Backend (Optional):**
|
|
220
313
|
If your backend is on a different domain (e.g., `api.example.com` while your frontend is on `example.com`), explicitly set `serverUrl`:
|
|
221
314
|
|
|
@@ -327,7 +420,7 @@ See [Backend Integration](https://github.com/CedrosPay/server) and `@backend-mig
|
|
|
327
420
|
|
|
328
421
|
---
|
|
329
422
|
|
|
330
|
-
##
|
|
423
|
+
## Production Deployment
|
|
331
424
|
|
|
332
425
|
### Content Security Policy (CSP) Headers
|
|
333
426
|
|
|
@@ -685,8 +778,7 @@ const csp = generateCSP({
|
|
|
685
778
|
customRpcProviders: [
|
|
686
779
|
RPC_PROVIDERS.HELIUS, // https://*.helius-rpc.com
|
|
687
780
|
RPC_PROVIDERS.QUICKNODE, // https://*.quicknode.pro
|
|
688
|
-
RPC_PROVIDERS.
|
|
689
|
-
RPC_PROVIDERS.ANKR, // https://rpc.ankr.com
|
|
781
|
+
RPC_PROVIDERS.FLUX, // https://*.fluxrpc.com
|
|
690
782
|
RPC_PROVIDERS.TRITON, // https://*.rpcpool.com
|
|
691
783
|
],
|
|
692
784
|
});
|
|
@@ -942,7 +1034,7 @@ The i18n system:
|
|
|
942
1034
|
|
|
943
1035
|
---
|
|
944
1036
|
|
|
945
|
-
##
|
|
1037
|
+
## Type Versioning Policy
|
|
946
1038
|
|
|
947
1039
|
Cedros Pay uses **semantic versioning for TypeScript types** to prevent breaking changes from affecting your code.
|
|
948
1040
|
|
|
@@ -1188,7 +1280,7 @@ For complete control over styling, use the `unstyled` prop to disable all defaul
|
|
|
1188
1280
|
|
|
1189
1281
|
---
|
|
1190
1282
|
|
|
1191
|
-
##
|
|
1283
|
+
## Props Reference
|
|
1192
1284
|
|
|
1193
1285
|
### CedrosProvider Configuration
|
|
1194
1286
|
|
|
@@ -1467,10 +1559,6 @@ All logs include timestamps and severity levels:
|
|
|
1467
1559
|
|
|
1468
1560
|
---
|
|
1469
1561
|
|
|
1470
|
-
## 🔒 API Stability & Versioning
|
|
1471
|
-
|
|
1472
|
-
Cedros Pay is designed for enterprise use with a strong commitment to API stability.
|
|
1473
|
-
|
|
1474
1562
|
### Semantic Versioning
|
|
1475
1563
|
|
|
1476
1564
|
We follow [Semantic Versioning](https://semver.org/):
|
|
@@ -1542,7 +1630,7 @@ const newReq: v2.X402Requirement = { ... };
|
|
|
1542
1630
|
|
|
1543
1631
|
---
|
|
1544
1632
|
|
|
1545
|
-
##
|
|
1633
|
+
## Error Telemetry (Optional)
|
|
1546
1634
|
|
|
1547
1635
|
Cedros Pay includes **opt-in error telemetry** with correlation IDs for production debugging. Telemetry is **disabled by default** and requires explicit configuration.
|
|
1548
1636
|
|
|
@@ -1619,22 +1707,7 @@ function PaymentButton() {
|
|
|
1619
1707
|
}
|
|
1620
1708
|
```
|
|
1621
1709
|
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
---
|
|
1625
|
-
|
|
1626
|
-
## 🧭 Roadmap
|
|
1627
|
-
|
|
1628
|
-
- Stripe + x402 unified dashboard
|
|
1629
|
-
- Subscription management
|
|
1630
|
-
- Facilitator integrations (PayAI, Kora)
|
|
1631
|
-
- Typed SDKs for Go, Node, and Python agents
|
|
1632
|
-
|
|
1633
|
-
---
|
|
1634
|
-
|
|
1635
|
-
**Cedros Pay** — _rooted in Solana, built for the web._
|
|
1636
|
-
|
|
1637
|
-
## 🎨 Storybook Development
|
|
1710
|
+
## Storybook Development
|
|
1638
1711
|
|
|
1639
1712
|
### Setup
|
|
1640
1713
|
|
|
@@ -1679,6 +1752,7 @@ function PaymentButton() {
|
|
|
1679
1752
|
This means `VITE_SOLANA_RPC_URL` or `VITE_STORYBOOK_SOLANA_ENDPOINT` is missing or empty in your `.env` file.
|
|
1680
1753
|
|
|
1681
1754
|
**Fix:**
|
|
1755
|
+
|
|
1682
1756
|
```bash
|
|
1683
1757
|
# Add to .env
|
|
1684
1758
|
VITE_SOLANA_RPC_URL=https://api.devnet.solana.com
|
|
@@ -1691,6 +1765,7 @@ VITE_STORYBOOK_SOLANA_ENDPOINT=https://api.devnet.solana.com
|
|
|
1691
1765
|
The `VITE_SERVER_URL` or `VITE_STORYBOOK_SERVER_URL` is missing.
|
|
1692
1766
|
|
|
1693
1767
|
**Fix:**
|
|
1768
|
+
|
|
1694
1769
|
```bash
|
|
1695
1770
|
# Add to .env
|
|
1696
1771
|
VITE_SERVER_URL=http://localhost:8080
|
|
@@ -1707,7 +1782,7 @@ VITE_SERVER_URL=http://localhost:8080
|
|
|
1707
1782
|
| `VITE_STORYBOOK_SERVER_URL` | Override server URL for Storybook | Optional |
|
|
1708
1783
|
| `VITE_STORYBOOK_SOLANA_ENDPOINT` | Override RPC for Storybook | Optional |
|
|
1709
1784
|
|
|
1710
|
-
##
|
|
1785
|
+
## Contributing
|
|
1711
1786
|
|
|
1712
1787
|
We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on:
|
|
1713
1788
|
|
|
@@ -1726,6 +1801,6 @@ npm test
|
|
|
1726
1801
|
npm run test:coverage
|
|
1727
1802
|
```
|
|
1728
1803
|
|
|
1729
|
-
##
|
|
1804
|
+
## License
|
|
1730
1805
|
|
|
1731
1806
|
MIT License - see [LICENSE](./LICENSE) for details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedros/pay-react",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "React frontend library for Cedros Pay - unified Stripe and Solana x402 payments",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"solana",
|
|
43
43
|
"x402",
|
|
44
44
|
"crypto",
|
|
45
|
-
"react"
|
|
45
|
+
"react",
|
|
46
|
+
"stablecoins"
|
|
46
47
|
],
|
|
47
48
|
"author": "Cedros Pay Team",
|
|
48
49
|
"license": "MIT",
|