@cedros/pay-react 0.1.0 → 1.0.0
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 +157 -45
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,65 +5,150 @@
|
|
|
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
15
|
|
|
16
|
-
|
|
16
|
+
## 🎯 What is Cedros Pay?
|
|
17
17
|
|
|
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)
|
|
18
|
+
**One component, two payment rails.** Stripe for cards, Solana USDC for wallets. No second checkout.
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
Built as a nod to **Solana Beach's Cedros Avenue**, 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.
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
### The Problem with Traditional Crypto Payments
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
Adding crypto to your store traditionally requires:
|
|
28
25
|
|
|
29
|
-
-
|
|
30
|
-
-
|
|
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
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
**Time:** 3-8 weeks | **Risk:** Custody risk | **Cost:** More DevOps
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
### The Cedros Pay Solution
|
|
35
36
|
|
|
37
|
+
```tsx
|
|
38
|
+
<CedrosPay
|
|
39
|
+
resource="your-product-id" // from your DB
|
|
40
|
+
onPaymentSuccess={(txId) => unlockContent(txId)}
|
|
41
|
+
/>
|
|
36
42
|
```
|
|
37
|
-
Frontend (React) → Cedros Server → Stripe & Solana RPC
|
|
38
|
-
| |
|
|
39
|
-
|---- x402 headers ----> |---- Stripe webhooks ----> DB
|
|
40
|
-
```
|
|
41
43
|
|
|
42
|
-
**
|
|
44
|
+
**Time:** ~15 minutes | **Risk:** No custody | **Cost:** Less DevOps
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🧩 How It Works (x402)
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
- Uses wallet adapters for Solana and Stripe JS SDK for fiat.
|
|
50
|
+
x402 makes Solana payments stateless. The client includes a signed transaction with the request. Your backend verifies it on-chain and unlocks the resource.
|
|
46
51
|
|
|
47
|
-
**
|
|
52
|
+
**Flow:**
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
```
|
|
55
|
+
Traditional:
|
|
56
|
+
User → Deposit Wallet (you manage) → Monitor → Sweep → Merchant
|
|
57
|
+
↓
|
|
58
|
+
Store state in DB
|
|
59
|
+
↓
|
|
60
|
+
Custody risk
|
|
61
|
+
|
|
62
|
+
x402:
|
|
63
|
+
User → Sign Transaction → Your Backend → Verify On-Chain → Merchant (Direct)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Three key benefits:**
|
|
67
|
+
|
|
68
|
+
- No deposit wallets
|
|
69
|
+
- No sweeping funds
|
|
70
|
+
- No payment state in your DB
|
|
51
71
|
|
|
52
72
|
---
|
|
53
73
|
|
|
54
74
|
## 💳 Key Features
|
|
55
75
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
### 1. One Component, Two Rails
|
|
77
|
+
|
|
78
|
+
Stripe for cards, Solana USDC for wallets. No second checkout.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<CedrosPay resource="product-1" />
|
|
82
|
+
// Both payment methods work
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 2. Works With Your Products
|
|
86
|
+
|
|
87
|
+
Pass your DB ID. No new schema.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
<CedrosPay resource="existing-product-123" />
|
|
91
|
+
// resource = your database primary key
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3. Real Ecommerce, Not Just a Button
|
|
95
|
+
|
|
96
|
+
Carts, coupons, refunds, metadata.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
<CedrosPay
|
|
100
|
+
items={[{ resource: "item-1", quantity: 2 }]}
|
|
101
|
+
couponCode="LAUNCH50"
|
|
102
|
+
/>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 4. Auto-Detects Wallet
|
|
106
|
+
|
|
107
|
+
No wallet: card only. Wallet: card and crypto.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
// User without wallet sees:
|
|
111
|
+
[Pay with Card] button
|
|
112
|
+
|
|
113
|
+
// User with Phantom sees:
|
|
114
|
+
[Pay with Card] [Pay with Crypto]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 5. Agent-Ready
|
|
118
|
+
|
|
119
|
+
x402 over HTTP; agents pay per request.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
GET /api/premium-data
|
|
123
|
+
X-PAYMENT: <signed-transaction>
|
|
124
|
+
# Agent gets data instantly
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 6. Self-Host or Roll Your Own
|
|
128
|
+
|
|
129
|
+
React UI + Go backend. Open API.
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
<CedrosPay
|
|
133
|
+
resource="item"
|
|
134
|
+
wallets={customWallets}
|
|
135
|
+
renderModal={CustomModal}
|
|
136
|
+
/>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Additional Features:**
|
|
140
|
+
|
|
59
141
|
- 🌍 **Open source** — MIT-licensed and extensible
|
|
142
|
+
- 🔐 **Stateless & secure** — No user accounts or deposit addresses required
|
|
60
143
|
- 🧱 **Minimal integration** — Middleware or proxy for Go APIs
|
|
61
144
|
|
|
62
145
|
---
|
|
63
146
|
|
|
64
|
-
## 🚀 Quick Start
|
|
147
|
+
## 🚀 Quick Start (3 Steps in ~3 Minutes)
|
|
65
148
|
|
|
66
|
-
|
|
149
|
+
If you can wrap a provider, you can ship dual payments.
|
|
150
|
+
|
|
151
|
+
### Step 1: Install
|
|
67
152
|
|
|
68
153
|
**Option 1: Stripe + Crypto (Full Features)**
|
|
69
154
|
|
|
@@ -185,10 +270,12 @@ function App() {
|
|
|
185
270
|
<CedrosPay resource="item-id" display={{ showCrypto: false }} />
|
|
186
271
|
```
|
|
187
272
|
|
|
188
|
-
###
|
|
273
|
+
### Step 2: Configure Provider
|
|
274
|
+
|
|
275
|
+
Wrap your app with credentials + cluster:
|
|
189
276
|
|
|
190
277
|
```tsx
|
|
191
|
-
import {
|
|
278
|
+
import { CedrosProvider } from "@cedros/pay-react";
|
|
192
279
|
import "@cedros/pay-react/style.css";
|
|
193
280
|
|
|
194
281
|
function App() {
|
|
@@ -196,26 +283,49 @@ function App() {
|
|
|
196
283
|
<CedrosProvider
|
|
197
284
|
config={{
|
|
198
285
|
stripePublicKey: "pk_test_...",
|
|
199
|
-
serverUrl:
|
|
286
|
+
serverUrl: "https://your-api.com",
|
|
200
287
|
solanaCluster: "mainnet-beta",
|
|
201
|
-
// serverUrl defaults to window.location.origin
|
|
202
|
-
// Only needed if your backend is on a different domain
|
|
203
288
|
}}
|
|
204
289
|
>
|
|
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
|
-
/>
|
|
290
|
+
<YourApp />
|
|
214
291
|
</CedrosProvider>
|
|
215
292
|
);
|
|
216
293
|
}
|
|
217
294
|
```
|
|
218
295
|
|
|
296
|
+
### Step 3: Drop in the Component
|
|
297
|
+
|
|
298
|
+
On success → fulfill order:
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
import { CedrosPay } from "@cedros/pay-react";
|
|
302
|
+
|
|
303
|
+
function Checkout() {
|
|
304
|
+
return (
|
|
305
|
+
<CedrosPay
|
|
306
|
+
resource="your-product-id"
|
|
307
|
+
callbacks={{
|
|
308
|
+
onPaymentSuccess: (result) => {
|
|
309
|
+
// Unlock content / fulfill order
|
|
310
|
+
unlockContent(result.transactionId);
|
|
311
|
+
},
|
|
312
|
+
}}
|
|
313
|
+
/>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Total time:** ~3 minutes
|
|
319
|
+
|
|
320
|
+
**Backend options:** Use the Go server, or implement the open API.
|
|
321
|
+
|
|
322
|
+
**Links:**
|
|
323
|
+
|
|
324
|
+
- [Backend setup →](https://github.com/CedrosPay/server)
|
|
325
|
+
- [Full docs →](https://github.com/CedrosPay/react)
|
|
326
|
+
- [Example apps →](https://github.com/CedrosPay/react/tree/main/stories)
|
|
327
|
+
- [Storybook →](https://github.com/CedrosPay/react#-storybook-development)
|
|
328
|
+
|
|
219
329
|
**Cross-Domain Backend (Optional):**
|
|
220
330
|
If your backend is on a different domain (e.g., `api.example.com` while your frontend is on `example.com`), explicitly set `serverUrl`:
|
|
221
331
|
|
|
@@ -1679,6 +1789,7 @@ function PaymentButton() {
|
|
|
1679
1789
|
This means `VITE_SOLANA_RPC_URL` or `VITE_STORYBOOK_SOLANA_ENDPOINT` is missing or empty in your `.env` file.
|
|
1680
1790
|
|
|
1681
1791
|
**Fix:**
|
|
1792
|
+
|
|
1682
1793
|
```bash
|
|
1683
1794
|
# Add to .env
|
|
1684
1795
|
VITE_SOLANA_RPC_URL=https://api.devnet.solana.com
|
|
@@ -1691,6 +1802,7 @@ VITE_STORYBOOK_SOLANA_ENDPOINT=https://api.devnet.solana.com
|
|
|
1691
1802
|
The `VITE_SERVER_URL` or `VITE_STORYBOOK_SERVER_URL` is missing.
|
|
1692
1803
|
|
|
1693
1804
|
**Fix:**
|
|
1805
|
+
|
|
1694
1806
|
```bash
|
|
1695
1807
|
# Add to .env
|
|
1696
1808
|
VITE_SERVER_URL=http://localhost:8080
|