@zendfi/sdk 0.5.6 → 0.5.8

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 +139 -61
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,28 +1,64 @@
1
1
  # @zendfi/sdk
2
2
 
3
- > Zero-config TypeScript SDK for accepting crypto payments with ZendFi
3
+ > The only crypto payment API built for the AI era
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@zendfi/sdk.svg)](https://www.npmjs.com/package/@zendfi/sdk)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
- Accept **SOL, USDC, and USDT** payments in your app with just a few lines of code. Built for developers who want to integrate crypto payments without the complexity.
8
+ Accept **SOL, USDC, and USDT** payments in 7 lines of code. Built for e-commerce. Ready for AI agents.
9
+
10
+ ```typescript
11
+ import { zendfi } from '@zendfi/sdk';
12
+
13
+ const payment = await zendfi.createPayment({
14
+ amount: 50,
15
+ description: 'Premium subscription',
16
+ });
17
+
18
+ console.log(payment.payment_url); // Send customer here
19
+ ```
20
+
21
+ **That's it.** Works for traditional payments AND AI agents. Same API.
22
+
23
+ ---
24
+
25
+ ## Why ZendFi?
26
+
27
+ | Feature | Stripe | PayPal | **ZendFi** |
28
+ |---------|--------|--------|------------|
29
+ | **Fees** | 2.9% + $0.30 | 3.5% + $0.49 | **0.6% flat** ✨ |
30
+ | **Settlement** | 7 days | 3-5 days | **Instant** ✨ |
31
+ | **Crypto Native** | Via 3rd party | Via 3rd party | **Built-in** ✨ |
32
+ | **AI Agent Ready** | ❌ | ❌ | **✅ Native** ✨ |
33
+ | **Setup Time** | 30 min | 30 min | **5 min** ✨ |
34
+
35
+ **Save 81% on fees.** Get paid instantly. Scale to AI when ready.
9
36
 
10
37
  ---
11
38
 
12
39
  ## Features
13
40
 
14
- - **All-Inclusive Pricing** — 0.6% platform fee covers everything (network fees included!)
15
- - **Zero Configuration** — Auto-detects environment from your API key
16
- - **Type-Safe** — Full TypeScript support with auto-completion
17
- - **Auto-Retry** — Built-in exponential backoff for network errors
18
- - **Idempotency** — Automatic duplicate prevention for safe retries
19
- - **Webhook Helpers** — Auto-verified handlers for Next.js, Express, and more
41
+ ### 🚀 **Core Payments** (Start Here)
42
+ - **Simple Payments** — QR codes, payment links, instant settlements
43
+ - **Payment Links** — Reusable checkout pages for social/email
44
+ - **Webhooks** — Real-time notifications with auto-verification
20
45
  - **Test Mode** — Free devnet testing with no real money
21
- - **Multi-Network** — Automatic routing to devnet or mainnet
22
- - **Agentic Intent Protocol** — AI agent payment capabilities with scoped API keys
23
- - **Session Keys** On-chain funded wallets for autonomous agent payments
24
- - **PPP Pricing** — Purchasing Power Parity for global reach (27+ countries)
25
- - **Payment Intents** — Two-phase commit pattern for reliable checkout
46
+ - **Type-Safe** — Full TypeScript support with auto-completion
47
+
48
+ ### 💼 **Scale Up** (When You Grow)
49
+ - **Subscriptions** — Recurring billing with trials
50
+ - **Installments** — Buy now, pay later flows
51
+ - **Invoices** — Professional invoicing with email
52
+ - **Payment Splits** — Revenue sharing for marketplaces
53
+
54
+ ### 🤖 **AI-Ready** (Optional Advanced)
55
+ - **Agent Keys** — Scoped API keys for AI with spending limits
56
+ - **Session Keys** — Pre-funded wallets for autonomous payments
57
+ - **Payment Intents** — Two-phase commit for reliable checkout
58
+ - **PPP Pricing** — Auto-adjust prices for 27+ countries
59
+ - **Smart Payments** — AI-optimized payment routing
60
+
61
+ Don't need AI features? **Ignore them.** The SDK works perfectly for traditional payments.
26
62
 
27
63
  ---
28
64
 
@@ -42,7 +78,7 @@ yarn add @zendfi/sdk
42
78
 
43
79
  ### 1. Get your API key
44
80
 
45
- Sign up at [zendfi.tech](https://zendfi.tech) and grab your API keys from the dashboard.
81
+ Sign up at [zendfi.tech](https://zendfi.tech) to get your API keys.
46
82
 
47
83
  ### 2. Set environment variables
48
84
 
@@ -106,6 +142,9 @@ For devnet testing:
106
142
  1. Use your `zfi_test_` API key
107
143
  2. Get free SOL from [sol-faucet.com](https://www.sol-faucet.com/)
108
144
  3. All transactions use test tokens (zero value)
145
+ 4. Devnet SOL is NOT real SOL (zero value)
146
+ 6. Use devnet-compatible wallets (Phantom, Solflare support devnet)
147
+ 7. Switch network in wallet: Settings → Developer Settings → Change Network → Devnet
109
148
 
110
149
  ### Going Live
111
150
 
@@ -133,47 +172,90 @@ This covers:
133
172
 
134
173
  ---
135
174
 
136
- ## Agentic Intent Protocol
175
+ ## 🤖 AI-Ready Features (Optional Advanced)
137
176
 
138
- Enable AI agents to make payments autonomously with scoped permissions and spending limits.
177
+ Building AI agents? ZendFi has native support for autonomous payments with cryptographic security and spending limits.
139
178
 
140
- ### Namespaced APIs
179
+ ### When Do I Need This?
180
+
181
+ **Use traditional payments if:**
182
+ - Building e-commerce, SaaS, or creator tools
183
+ - User clicks "Pay" button for each transaction
184
+ - Standard checkout flow
185
+
186
+ **Use AI features if:**
187
+ - Building AI agents that make purchases
188
+ - Need autonomous payments without per-transaction approval
189
+ - Want spending limits and scoped permissions
190
+
191
+ ### Quick Example: AI Agent Payment
192
+
193
+ ```typescript
194
+ import { zendfi } from '@zendfi/sdk';
141
195
 
142
- The SDK provides namespaced APIs for agentic capabilities:
196
+ // 1. Create agent key with limited permissions
197
+ const agentKey = await zendfi.agent.createKey({
198
+ name: 'Shopping Assistant',
199
+ agent_id: 'shopping-assistant-v1',
200
+ scopes: ['create_payments'],
201
+ rate_limit_per_hour: 100,
202
+ });
203
+
204
+ // 2. User approves spending session (one-time)
205
+ const session = await zendfi.agent.createSession({
206
+ agent_id: 'shopping-assistant-v1',
207
+ user_wallet: 'Hx7B...abc',
208
+ limits: {
209
+ max_per_transaction: 50, // $50 max per payment
210
+ max_per_day: 200, // $200 daily cap
211
+ },
212
+ duration_hours: 24,
213
+ });
214
+
215
+ // 3. AI agent makes payments autonomously (within limits)
216
+ const payment = await zendfi.agent.pay({
217
+ session_token: session.session_token,
218
+ amount: 25.00,
219
+ description: 'Coffee order',
220
+ });
221
+
222
+ // Done! User approved once, AI pays within limits
223
+ ```
224
+
225
+ **Learn more:** [AI Payments Documentation](https://docs.zendfi.tech/agentic)
226
+
227
+ ---
228
+
229
+ ## 📚 Core API Reference
230
+
231
+ ### Namespaced APIs
143
232
 
144
233
  ```typescript
145
234
  import { zendfi } from '@zendfi/sdk';
146
235
 
147
- // Agent API - Manage agent keys and sessions
148
- zendfi.agent.createKey(...)
149
- zendfi.agent.createSession(...)
150
- zendfi.agent.pay(...) // Make payments via sessions
151
-
152
- // Payment Intents - Two-phase payment flow
153
- zendfi.intents.create(...)
154
- zendfi.intents.confirm(...)
155
-
156
- // Pricing - PPP and AI pricing
157
- zendfi.pricing.getPPPFactor(...)
158
- zendfi.pricing.getSuggestion(...)
159
-
160
- // Autonomy - Autonomous delegation
161
- zendfi.autonomy.enable(...)
162
- zendfi.autonomy.getStatus(...)
163
-
164
- // Smart Payments - AI-powered routing
165
- zendfi.smart.execute(...)
166
- zendfi.smart.submitSigned(...) // For device-bound flows
167
-
168
- // Session Keys - On-chain funded wallets with PKP identity
169
- zendfi.sessionKeys.create(...)
170
- zendfi.sessionKeys.submitApproval(...)
171
- zendfi.sessionKeys.getStatus(...)
172
- zendfi.sessionKeys.topUp(...)
173
- zendfi.sessionKeys.revoke(...)
236
+ // Traditional Payments (Most Common)
237
+ zendfi.createPayment(...)
238
+ zendfi.getPayment(...)
239
+ zendfi.listPayments(...)
240
+
241
+ // Payment Links
242
+ zendfi.createPaymentLink(...)
243
+
244
+ // Subscriptions
245
+ zendfi.createSubscription(...)
246
+ zendfi.cancelSubscription(...)
247
+
248
+ // AI Features (Optional)
249
+ zendfi.agent.createKey(...) // Scoped API keys
250
+ zendfi.agent.createSession(...) // Spending limits
251
+ zendfi.agent.pay(...) // Autonomous payments
252
+ zendfi.intents.create(...) // Two-phase checkout
253
+ zendfi.sessionKeys.create(...) // Pre-funded wallets
254
+ zendfi.autonomy.enable(...) // User-granted delegation
255
+ zendfi.pricing.getPPPFactor(...) // Global pricing
174
256
  ```
175
257
 
176
- ### Agent API Keys
258
+ ### Core Payments
177
259
 
178
260
  Create scoped API keys for AI agents with limited permissions:
179
261
 
@@ -323,13 +405,10 @@ Enable agents to make payments without per-transaction approval:
323
405
 
324
406
  ```typescript
325
407
  // Enable autonomous mode for a wallet
326
- const delegate = await zendfi.autonomy.enable({
327
- wallet_address: 'Hx7B...abc',
328
- agent_id: 'shopping-assistant',
329
- max_per_day_usd: 100,
330
- max_per_transaction_usd: 25,
331
- duration_hours: 24,
332
- allowed_categories: ['subscriptions', 'digital_goods'],
408
+ await zendfi.autonomy.enable(sessionKeyId, {
409
+ max_amount_usd: 100, // Total amount, not per-day
410
+ duration_hours: 24, // Duration
411
+ delegation_signature: sig, // Required signature
333
412
  });
334
413
 
335
414
  // Check autonomy status
@@ -352,17 +431,16 @@ Session keys are pre-funded wallets with spending limits that enable AI agents t
352
431
  ```typescript
353
432
  // Step 1: Create a session key
354
433
  const key = await zendfi.sessionKeys.create({
355
- agent_id: 'shopping-assistant',
356
434
  user_wallet: 'Hx7B...abc',
357
- max_amount: 100, // $100 spending limit
358
- expiry_hours: 24, // Valid for 24 hours
359
- token: 'USDC',
435
+ limit_usdc: 100,
436
+ duration_days: 7,
437
+ device_fingerprint: await generateFingerprint(),
360
438
  });
361
439
 
362
440
  // key.session_key_id - Unique identifier
363
441
  // key.approval_transaction - Transaction for user to sign
364
- // key.session_key_address - The funded wallet address
365
- // key.pkp_public_key - Lit Protocol PKP public key
442
+ // key.session_wallet - The funded wallet address
443
+ // key.pkp_public_key - Lit Protocol PKP public key NB: This only exists if mint_pkp is set to true in sessions
366
444
 
367
445
  // Step 2: User signs the approval transaction (one-time)
368
446
  const signedTx = await wallet.signTransaction(key.approval_transaction);
@@ -373,8 +451,8 @@ await zendfi.sessionKeys.submitApproval(key.session_key_id, {
373
451
  // Step 3: Check status and make payments
374
452
  const status = await zendfi.sessionKeys.getStatus(key.session_key_id);
375
453
  console.log(`Status: ${status.status}`); // "active"
376
- console.log(`Remaining: $${status.remaining_amount}`);
377
- console.log(`Spent: $${status.spent_amount}`);
454
+ console.log(`Remaining: $${status.remaining_usdc}`);
455
+ console.log(`Spent: $${status.used_amount_usdc}`);
378
456
  console.log(`Transactions: ${status.transaction_count}`);
379
457
 
380
458
  // Step 4: Top-up if needed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendfi/sdk",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "Zero-config TypeScript SDK for ZendFi crypto payments",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",