@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.
Files changed (2) hide show
  1. package/README.md +157 -45
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,65 +5,150 @@
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.4-blue.svg)](https://www.typescriptlang.org/)
6
6
  [![Bundle Size](https://img.shields.io/bundlephobia/minzip/@cedros/pay-react)](https://bundlephobia.com/package/@cedros/pay-react)
7
7
  [![Stripe-only: <100KB](https://img.shields.io/badge/stripe--only-%3C100KB-success)]()
8
- [![Tests](https://img.shields.io/badge/tests-55%20passed-brightgreen)](https://github.com/cedros-tech/pay-react)
8
+ [![Tests](https://img.shields.io/badge/tests-55%20passed-brightgreen)](https://github.com/CedrosPay/react)
9
9
 
10
- > **Unified payments for humans and agents from Solana Beach to the web.**
10
+ > **Add crypto to your store without building crypto.**
11
11
 
12
- ## ⚠️ BREAKING CHANGES (v2.0.0+)
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
- **Version 2.0.0 introduces security improvements that require backend updates.**
14
+ ---
15
15
 
16
- ### What Changed
16
+ ## 🎯 What is Cedros Pay?
17
17
 
18
- - **NEW:** API v1 versioning (`/paywall/v1/*` endpoints) for stable API contracts
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
- ## 🌅 Why Cedros Pay?
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
- Built as a nod to **Solana Beach’s Cedros Avenue**, Cedros Pay embodies the connection between **old-world payments and new-world rails** — Stripe’s fiat system and Solana’s instant, decentralized network.
22
+ ### The Problem with Traditional Crypto Payments
26
23
 
27
- Whether you're building a paywalled blog, an agentic API, or a marketplace, Cedros Pay handles both sides:
24
+ Adding crypto to your store traditionally requires:
28
25
 
29
- - Stripe-hosted checkout for credit/debit cards.
30
- - x402-verified USDC payments for instant crypto settlement.
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
- ## 🧩 Architecture
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
- **Frontend**
44
+ **Time:** ~15 minutes | **Risk:** No custody | **Cost:** Less DevOps
45
+
46
+ ---
47
+
48
+ ## 🧩 How It Works (x402)
43
49
 
44
- - React SDK (`@cedros/pay-react`) for drop-in payment buttons.
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
- **Backend**
52
+ **Flow:**
48
53
 
49
- - Go service handling session creation, webhooks, x402 verification, and route protection.
50
- - Deploy standalone or embed into existing backend.
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
- - 🪙 **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
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
- ### Installation
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
- ### Basic Usage
273
+ ### Step 2: Configure Provider
274
+
275
+ Wrap your app with credentials + cluster:
189
276
 
190
277
  ```tsx
191
- import { CedrosPay, CedrosProvider } from "@cedros/pay-react";
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: window.location.origin,
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
- <CedrosPay
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedros/pay-react",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
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",