@settlr/sdk 0.6.7 โ†’ 0.6.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 +194 -537
  2. package/package.json +22 -30
package/README.md CHANGED
@@ -4,233 +4,109 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dm/@settlr/sdk.svg)](https://www.npmjs.com/package/@settlr/sdk)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
- > **Accept crypto payments without wallets.** Customers pay with email. You get USDC instantly.
7
+ > **Global payout infrastructure for platforms.** Pay anyone, anywhere, with just their email. One API call sends USDC โ€” recipient claims it with any Solana wallet.
8
8
 
9
- ๐ŸŒ **Website:** [settlr.dev](https://settlr.dev)
10
- ๐Ÿ“– **Docs:** [settlr.dev/docs](https://settlr.dev/docs)
11
- ๐ŸŽฎ **Demo:** [settlr.dev/demo](https://settlr.dev/demo)
12
- ๐Ÿ’ป **GitHub:** [github.com/ABFX15/x402-hack-payment](https://github.com/ABFX15/x402-hack-payment)
9
+ ๐ŸŒ [settlr.dev](https://settlr.dev) ยท ๐Ÿ“– [Docs](https://settlr.dev/docs) ยท ๐Ÿ’ป [GitHub](https://github.com/ABFX15/x402-hack-payment)
13
10
 
14
- ## Why Settlr?
11
+ ## Install
15
12
 
16
- - โœ… **No wallet required** - Customers pay with just an email
17
- - โœ… **Zero gas fees** - No SOL needed, ever (Kora gasless)
18
- - โœ… **Pay from any chain** - Accept USDC from Ethereum, Base, Arbitrum, Polygon, Optimism (Mayan)
19
- - โœ… **Instant settlement** - USDC direct to your Solana wallet
20
- - โœ… **One component** - Drop-in React `<BuyButton>`
21
- - โœ… **Privacy-preserving** - FHE-encrypted receipts via Inco Lightning
22
- - โœ… **One-click payments** - Returning customers pay instantly โญ NEW
23
- - โœ… **2% flat fee** - No hidden costs
13
+ ```bash
14
+ npm install @settlr/sdk
15
+ ```
24
16
 
25
- ## โšก One-Click Payments (NEW)
17
+ ## Payout API โ€” Send Money by Email
26
18
 
27
- Enable frictionless repeat purchases for returning customers:
19
+ The core product. Send USDC to anyone with just their email address. No bank details, no forms, no delays.
28
20
 
29
- ```typescript
30
- import { createOneClickClient } from "@settlr/sdk";
21
+ ### Quick Start
31
22
 
32
- const oneClick = createOneClickClient("https://settlr.dev");
23
+ ```typescript
24
+ import { PayoutClient } from "@settlr/sdk";
33
25
 
34
- // Step 1: Customer approves a spending limit (once)
35
- await oneClick.approve({
36
- customerWallet: "Ac52MM...",
37
- merchantWallet: "DjLFeM...",
38
- spendingLimit: 100, // $100 max
39
- expiresInDays: 30,
40
- });
26
+ const payouts = new PayoutClient({ apiKey: "sk_live_xxxxxxxxxxxx" });
41
27
 
42
- // Step 2: Merchant charges customer later (no popups!)
43
- const result = await oneClick.charge({
44
- customerWallet: "Ac52MM...",
45
- merchantWallet: "DjLFeM...",
46
- amount: 25,
47
- memo: "Premium content",
28
+ // Send a payout โ€” recipient gets an email with a claim link
29
+ const payout = await payouts.create({
30
+ email: "alice@example.com",
31
+ amount: 250.0,
32
+ memo: "March data labeling โ€” 500 tasks",
48
33
  });
49
34
 
50
- console.log(result.txSignature); // Payment completed instantly!
51
- console.log(result.remainingLimit); // $75 left
35
+ console.log(payout.id); // "po_abc123"
36
+ console.log(payout.status); // "sent"
37
+ console.log(payout.claimUrl); // "https://settlr.dev/claim/..."
52
38
  ```
53
39
 
54
- **Use cases:**
55
-
56
- - Gaming: Buy in-game items without interrupting gameplay
57
- - Subscriptions: Charge monthly without re-authentication
58
- - Microtransactions: Seamless small purchases
59
-
60
- ## ๐Ÿ”’ Privacy Features (Inco Lightning)
40
+ ### Batch Payouts
61
41
 
62
- Settlr now supports **private payment receipts** using Inco Lightning's Fully Homomorphic Encryption:
63
-
64
- - **Private on-chain** - Payment amounts are encrypted, competitors can't see your revenue
65
- - **Compliant off-chain** - Merchants can still decrypt for accounting/tax (CSV export works!)
66
- - **Selective disclosure** - Only customer + merchant can view the actual amount
67
- - **Trustless decryption** - Inco covalidator network ensures no single point of trust
42
+ Send up to 500 payouts in a single call:
68
43
 
69
44
  ```typescript
70
- import {
71
- findPrivateReceiptPda,
72
- buildPrivateReceiptAccounts,
73
- encryptAmount,
74
- PrivacyFeatures,
75
- } from "@settlr/sdk";
76
-
77
- // Check privacy capabilities
78
- console.log(PrivacyFeatures);
79
- // {
80
- // ENCRYPTED_AMOUNTS: true,
81
- // ACCESS_CONTROL: true,
82
- // ACCOUNTING_COMPATIBLE: true,
83
- // TRUSTLESS_DECRYPTION: true
84
- // }
85
-
86
- // Derive PDA for a private receipt
87
- const [receiptPda] = findPrivateReceiptPda("payment_123");
88
-
89
- // Build accounts for issuing private receipt
90
- const accounts = await buildPrivateReceiptAccounts({
91
- paymentId: "payment_123",
92
- amount: 99.99,
93
- customer: customerWallet,
94
- merchant: merchantWallet,
95
- });
45
+ const batch = await payouts.createBatch([
46
+ { email: "alice@example.com", amount: 250.0, memo: "March" },
47
+ { email: "bob@example.com", amount: 180.0, memo: "March" },
48
+ { email: "carol@example.com", amount: 320.0, memo: "March" },
49
+ ]);
50
+
51
+ console.log(batch.total); // 750.00
52
+ console.log(batch.count); // 3
96
53
  ```
97
54
 
98
- > **Private on-chain. Compliant off-chain.** Your competitors can't see your revenue, but your accountant can.
99
-
100
- ## ๐Ÿ›ก๏ธ Wallet Security (Range)
101
-
102
- Settlr integrates Range Security to screen wallets before processing payments:
55
+ ### Check Status
103
56
 
104
57
  ```typescript
105
- import { screenWallet, isWalletBlocked, RiskLevel } from "@settlr/sdk";
106
-
107
- // Screen a wallet for sanctions, fraud, mixers, etc.
108
- const result = await screenWallet("SomeWalletAddress...");
109
-
110
- if (result.riskLevel === RiskLevel.SEVERE || result.isSanctioned) {
111
- console.log("Wallet is blocked:", result.categories);
112
- // Don't process payment
113
- }
114
-
115
- // Quick check
116
- const blocked = await isWalletBlocked("SuspiciousWallet...");
117
- if (blocked) {
118
- return { error: "Payment blocked for compliance" };
119
- }
58
+ const payout = await payouts.get("po_abc123");
59
+ console.log(payout.status); // "claimed"
60
+ console.log(payout.claimedAt); // "2026-02-15T14:30:00Z"
61
+ console.log(payout.txSignature); // "5KtP..."
120
62
  ```
121
63
 
122
- **What Range screens for:**
123
-
124
- - ๐Ÿšซ **Sanctions** - OFAC, EU sanctions lists
125
- - ๐Ÿ•ต๏ธ **Fraud** - Known scam wallets
126
- - ๐ŸŒ€ **Mixers** - Tornado Cash, etc.
127
- - ๐ŸŒ‘ **Darknet** - Illicit marketplace activity
128
- - ๐Ÿ’€ **Ransomware** - Known attack wallets
129
- - ๐ŸŽฐ **Gambling** - Unlicensed gambling (configurable)
130
-
131
- ## ๐Ÿ’ธ Private Payouts (Privacy Cash)
132
-
133
- Enable ZK-shielded payments for privacy-conscious merchants:
64
+ ### List Payouts
134
65
 
135
66
  ```typescript
136
- import {
137
- createPrivacyCashClient,
138
- shieldPayment,
139
- privateTransfer,
140
- } from "@settlr/sdk";
141
-
142
- // Initialize Privacy Cash
143
- const privacy = createPrivacyCashClient({
144
- connection,
145
- wallet,
146
- network: "mainnet-beta",
147
- });
148
-
149
- // Shield funds (move to private pool)
150
- const shieldTx = await shieldPayment(privacy, 100); // $100 USDC
151
- console.log("Shielded:", shieldTx);
152
-
153
- // Private transfer (ZK-shielded, amount hidden)
154
- const transferTx = await privateTransfer(privacy, "RecipientWallet...", 50);
155
- console.log("Private transfer:", transferTx);
67
+ const result = await payouts.list({ status: "claimed", limit: 50 });
68
+ result.data.forEach((p) => console.log(p.email, p.amount, p.status));
156
69
  ```
157
70
 
158
- **Privacy Cash features:**
159
-
160
- - ๐Ÿ” ZK-shielded transactions
161
- - ๐Ÿ‘๏ธ Amount hidden from on-chain observers
162
- - โšก Fast finality on Solana
163
- - ๐Ÿ’ฐ Supports USDC and SOL
164
-
165
- ## Installation
71
+ ### How It Works
166
72
 
167
- ```bash
168
- npm install @settlr/sdk
169
73
  ```
170
-
171
- ## Quick Start
172
-
173
- ### 1. Get Your API Key
174
-
175
- Sign up at [settlr.dev/onboarding](https://settlr.dev/onboarding) to register your business and get an API key. Your wallet address is linked to your API key automatically.
176
-
177
- ### 2. Create a Payment Link
178
-
179
- ```typescript
180
- import { Settlr } from "@settlr/sdk";
181
-
182
- const settlr = new Settlr({
183
- apiKey: "sk_live_xxxxxxxxxxxx", // Your API key from dashboard
184
- merchant: {
185
- name: "My Store",
186
- // walletAddress is optional - automatically fetched from your API key
187
- },
188
- });
189
-
190
- const payment = await settlr.createPayment({
191
- amount: 29.99,
192
- memo: "Premium subscription",
193
- });
194
-
195
- // Redirect customer to checkout
196
- window.location.href = payment.checkoutUrl;
74
+ Platform calls POST /api/payouts
75
+ โ†“
76
+ Recipient gets email with claim link
77
+ โ†“
78
+ Recipient enters any Solana wallet address
79
+ โ†“
80
+ USDC transferred on-chain instantly
81
+ โ†“
82
+ Platform gets webhook with tx signature
197
83
  ```
198
84
 
199
- > **Note:** When you register at [settlr.dev/onboarding](https://settlr.dev/onboarding), your wallet address is linked to your API key. The SDK automatically fetches it - no need to include it in your code!
85
+ ---
86
+
87
+ ## Checkout SDK โ€” Accept Inbound Payments
200
88
 
201
- ### 3. Drop-in Buy Button โญ NEW
89
+ Drop-in React components for accepting USDC payments. Customers pay with email โ€” no wallet setup needed.
202
90
 
203
- The easiest way to accept payments - just drop in a button:
91
+ ### BuyButton
204
92
 
205
93
  ```tsx
206
94
  import { SettlrProvider, BuyButton } from "@settlr/sdk";
207
95
 
208
- function App() {
209
- return (
210
- <SettlrProvider
211
- config={{
212
- apiKey: "sk_live_xxxxxxxxxxxx",
213
- merchant: { name: "GameStore" }, // Wallet fetched from API key
214
- }}
215
- >
216
- <BuyButton
217
- amount={49.99}
218
- memo="Premium Game Bundle"
219
- onSuccess={(result) => {
220
- console.log("Payment successful!", result.signature);
221
- unlockContent();
222
- }}
223
- >
224
- Buy Now - $49.99
225
- </BuyButton>
226
- </SettlrProvider>
227
- );
228
- }
96
+ <SettlrProvider
97
+ config={{ apiKey: "sk_live_xxx", merchant: { name: "My Store" } }}
98
+ >
99
+ <BuyButton
100
+ amount={49.99}
101
+ memo="Premium Game Bundle"
102
+ onSuccess={(result) => console.log("Paid!", result.signature)}
103
+ >
104
+ Buy Now โ€” $49.99
105
+ </BuyButton>
106
+ </SettlrProvider>;
229
107
  ```
230
108
 
231
- ### 4. Checkout Widget โญ NEW
232
-
233
- Full embeddable checkout with product info:
109
+ ### CheckoutWidget
234
110
 
235
111
  ```tsx
236
112
  import { CheckoutWidget } from "@settlr/sdk";
@@ -239,402 +115,199 @@ import { CheckoutWidget } from "@settlr/sdk";
239
115
  amount={149.99}
240
116
  productName="Annual Subscription"
241
117
  productDescription="Full access to all premium features"
242
- productImage="/subscription.png"
243
118
  onSuccess={(result) => router.push("/success")}
244
- onError={(error) => console.error(error)}
119
+ theme="dark"
245
120
  />;
246
121
  ```
247
122
 
248
- ### How It Works
249
-
250
- Settlr checkout handles authentication via Privy:
251
-
252
- - **Email login** โ†’ Creates embedded Solana wallet automatically
253
- - **Wallet login** โ†’ Connects Phantom, Solflare, or Backpack
254
-
255
- No wallet-adapter setup needed. Just redirect to checkout.
123
+ ### Checkout Session (Server-Side)
256
124
 
257
- ### Multichain Payments
125
+ ```typescript
126
+ import { Settlr } from "@settlr/sdk";
258
127
 
259
- Customers can pay with USDC from any supported chain. Settlr automatically bridges funds to your Solana wallet via Mayan:
128
+ const settlr = new Settlr({
129
+ apiKey: "sk_live_xxxxxxxxxxxx",
130
+ merchant: { name: "My Store" },
131
+ });
260
132
 
261
- | Source Chain | Bridge Time | Gas Cost |
262
- | ------------ | ----------- | -------------- |
263
- | Solana | Instant | Free (gasless) |
264
- | Base | ~1-2 min | ~$0.01 |
265
- | Arbitrum | ~1-2 min | ~$0.01 |
266
- | Optimism | ~1-2 min | ~$0.01 |
267
- | Polygon | ~1-2 min | ~$0.01 |
268
- | Ethereum | ~1-3 min | ~$1-5 |
133
+ const payment = await settlr.createPayment({
134
+ amount: 29.99,
135
+ memo: "Premium subscription",
136
+ successUrl: "https://mystore.com/success",
137
+ });
269
138
 
270
- **You only need a Solana wallet** - cross-chain bridging is automatic.
139
+ // Redirect to hosted checkout
140
+ window.location.href = payment.checkoutUrl;
141
+ ```
271
142
 
272
143
  ### React Hook
273
144
 
274
145
  ```tsx
275
146
  import { SettlrProvider, useSettlr } from "@settlr/sdk";
276
147
 
277
- function App() {
278
- return (
279
- <SettlrProvider
280
- config={{
281
- apiKey: "sk_live_xxxxxxxxxxxx",
282
- merchant: {
283
- name: "My Game",
284
- // walletAddress optional - linked to your API key
285
- },
286
- }}
287
- >
288
- <YourApp />
289
- </SettlrProvider>
290
- );
291
- }
292
-
293
- // In your component
294
148
  function CheckoutButton() {
295
149
  const { getCheckoutUrl } = useSettlr();
296
-
297
- const handlePay = () => {
298
- const url = getCheckoutUrl({ amount: 29.99, memo: "Premium Pack" });
299
- window.location.href = url;
300
- };
301
-
302
- return <button onClick={handlePay}>Pay $29.99</button>;
303
- }
304
- ```
305
-
306
- ### Payment Link Generator Hook
307
-
308
- Generate shareable payment links programmatically:
309
-
310
- ```tsx
311
- import { useSettlr } from "@settlr/sdk";
312
-
313
- function InvoicePage() {
314
- const { getCheckoutUrl } = useSettlr();
315
-
316
- const link = getCheckoutUrl({
317
- amount: 500,
318
- memo: "Invoice #1234",
319
- orderId: "inv_1234",
320
- });
321
- // โ†’ https://settlr.app/checkout?amount=500&merchant=My+Game&...
150
+ const url = getCheckoutUrl({ amount: 29.99, memo: "Premium Pack" });
151
+ return <a href={url}>Pay $29.99</a>;
322
152
  }
323
153
  ```
324
154
 
325
- ## React Components
326
-
327
- ### `<BuyButton>`
328
-
329
- Drop-in payment button component.
330
-
331
- ```tsx
332
- <BuyButton
333
- amount={49.99} // Required: amount in USDC
334
- memo="Order description" // Optional
335
- orderId="order_123" // Optional: your order ID
336
- onSuccess={(result) => {}} // Called on successful payment
337
- onError={(error) => {}} // Called on payment failure
338
- onProcessing={() => {}} // Called when payment starts
339
- useRedirect={false} // Use redirect flow instead of direct payment
340
- successUrl="https://..." // Redirect URL (if useRedirect=true)
341
- cancelUrl="https://..." // Cancel URL (if useRedirect=true)
342
- variant="primary" // "primary" | "secondary" | "outline"
343
- size="md" // "sm" | "md" | "lg"
344
- disabled={false}
345
- className=""
346
- style={{}}
347
- >
348
- Buy Now - $49.99
349
- </BuyButton>
350
- ```
351
-
352
- ### `<CheckoutWidget>`
353
-
354
- Full checkout UI component with product info.
355
-
356
- ```tsx
357
- <CheckoutWidget
358
- amount={149.99} // Required
359
- productName="Annual Subscription" // Required
360
- productDescription="Description" // Optional
361
- productImage="/image.png" // Optional
362
- merchantName="My Store" // Optional (uses config)
363
- memo="Transaction memo" // Optional
364
- orderId="order_123" // Optional
365
- onSuccess={(result) => {}} // Called on success
366
- onError={(error) => {}} // Called on error
367
- onCancel={() => {}} // Called on cancel
368
- theme="dark" // "dark" | "light"
369
- showBranding={true} // Show "Powered by Settlr"
370
- className=""
371
- style={{}}
372
- />
373
- ```
374
-
375
- ## API Keys
376
-
377
- ### Types of Keys
378
-
379
- | Key Type | Prefix | Use Case |
380
- | -------- | ---------- | ----------------------------------- |
381
- | Live | `sk_live_` | Production payments |
382
- | Test | `sk_test_` | Development/testing (no validation) |
383
-
384
- ### Rate Limits
385
-
386
- | Tier | Requests/min | Platform Fee |
387
- | ---------- | ------------ | ------------ |
388
- | Free | 60 | 2% |
389
- | Pro | 300 | 1.5% |
390
- | Enterprise | 1000 | 1% |
391
-
392
- ### Get Your API Key
393
-
394
- 1. Go to [settlr.app/dashboard](https://settlr.app/dashboard)
395
- 2. Connect your wallet
396
- 3. Click "Create API Key"
397
- 4. Save the key securely (only shown once!)
398
-
399
- ## API Reference
155
+ ---
400
156
 
401
- ### `Settlr`
157
+ ## Webhooks
402
158
 
403
- Main client class.
404
-
405
- #### Constructor Options
159
+ Handle payout and payment events:
406
160
 
407
161
  ```typescript
408
- interface SettlrConfig {
409
- apiKey: string; // Required: your API key from dashboard
410
- merchant: {
411
- name: string;
412
- walletAddress?: string; // Optional: auto-fetched from API key
413
- logoUrl?: string;
414
- webhookUrl?: string;
415
- };
416
- network?: "devnet" | "mainnet-beta"; // default: 'devnet'
417
- rpcEndpoint?: string;
418
- testMode?: boolean;
419
- }
420
- ```
421
-
422
- > **Tip:** When you register at [settlr.dev/onboarding](https://settlr.dev/onboarding), your wallet address is linked to your API key. You don't need to specify it in the config!
423
-
424
- #### Methods
425
-
426
- ##### `createPayment(options)`
427
-
428
- Create a payment link.
162
+ import { createWebhookHandler } from "@settlr/sdk";
429
163
 
430
- ```typescript
431
- const payment = await settlr.createPayment({
432
- amount: 29.99, // Required: amount in USDC
433
- memo: 'Order #123', // Optional: description
434
- orderId: 'order_123', // Optional: your order ID
435
- successUrl: 'https://...', // Optional: redirect after success
436
- cancelUrl: 'https://...', // Optional: redirect on cancel
437
- expiresIn: 3600, // Optional: expiry in seconds (default: 1 hour)
164
+ // Next.js App Router
165
+ export const POST = createWebhookHandler({
166
+ secret: process.env.SETTLR_WEBHOOK_SECRET!,
167
+ handlers: {
168
+ "payout.claimed": async (event) => {
169
+ console.log("Payout claimed:", event.payment.id);
170
+ await markPaid(event.payment.id);
171
+ },
172
+ "payout.expired": async (event) => {
173
+ await resendPayout(event.payment.id);
174
+ },
175
+ "payment.completed": async (event) => {
176
+ await fulfillOrder(event.payment.orderId);
177
+ },
178
+ },
438
179
  });
439
-
440
- // Returns
441
- {
442
- id: 'pay_abc123',
443
- amount: 29.99,
444
- status: 'pending',
445
- checkoutUrl: 'https://settlr.app/checkout?...',
446
- qrCode: 'data:image/svg+xml,...',
447
- createdAt: Date,
448
- expiresAt: Date,
449
- }
450
180
  ```
451
181
 
452
- ##### `buildTransaction(options)`
182
+ ### Events
183
+
184
+ | Event | Description |
185
+ | ------------------------ | --------------------------------------------- |
186
+ | `payout.created` | Payout created, claim email sent |
187
+ | `payout.sent` | Email delivered |
188
+ | `payout.claimed` | Recipient claimed โ€” USDC transferred on-chain |
189
+ | `payout.expired` | Claim link expired (7 days) |
190
+ | `payout.failed` | On-chain transfer failed |
191
+ | `payment.created` | Checkout payment link created |
192
+ | `payment.completed` | Payment confirmed on-chain |
193
+ | `payment.failed` | Payment failed |
194
+ | `payment.refunded` | Payment refunded |
195
+ | `subscription.created` | Subscription started |
196
+ | `subscription.renewed` | Subscription charge succeeded |
197
+ | `subscription.cancelled` | Subscription cancelled |
453
198
 
454
- Build a transaction for signing.
199
+ ### Manual Verification
455
200
 
456
201
  ```typescript
457
- const tx = await settlr.buildTransaction({
458
- payerPublicKey: wallet.publicKey,
459
- amount: 29.99,
460
- memo: "Order #123",
461
- });
202
+ import { verifyWebhookSignature } from "@settlr/sdk";
462
203
 
463
- // Sign and send
464
- const signature = await wallet.sendTransaction(tx, connection);
204
+ const isValid = verifyWebhookSignature(body, signature, secret);
465
205
  ```
466
206
 
467
- ##### `pay(options)`
468
-
469
- Execute a direct payment.
207
+ ---
470
208
 
471
- ```typescript
472
- const result = await settlr.pay({
473
- wallet: {
474
- publicKey: wallet.publicKey,
475
- signTransaction: wallet.signTransaction,
476
- },
477
- amount: 29.99,
478
- memo: 'Order #123',
479
- });
480
-
481
- // Returns
482
- {
483
- success: true,
484
- signature: '5KtP...',
485
- amount: 29.99,
486
- merchantAddress: '...',
487
- }
488
- ```
209
+ ## Subscriptions
489
210
 
490
- ##### `getPaymentStatus(signature)`
491
-
492
- Check payment status.
211
+ Recurring USDC payments:
493
212
 
494
213
  ```typescript
495
- const status = await settlr.getPaymentStatus("5KtP...");
496
- // Returns: 'pending' | 'completed' | 'failed'
497
- ```
498
-
499
- ##### `createCheckoutSession(options)` โญ NEW
214
+ import { createSubscriptionClient } from "@settlr/sdk";
500
215
 
501
- Create a hosted checkout session (like Stripe Checkout).
216
+ const subs = createSubscriptionClient({ apiKey: "sk_live_xxx" });
502
217
 
503
- ```typescript
504
- const session = await settlr.createCheckoutSession({
218
+ // Create a plan
219
+ const plan = await subs.createPlan({
220
+ name: "Pro",
505
221
  amount: 29.99,
506
- description: 'Premium Plan',
507
- successUrl: 'https://mystore.com/success?session_id={CHECKOUT_SESSION_ID}',
508
- cancelUrl: 'https://mystore.com/cancel',
509
- webhookUrl: 'https://mystore.com/api/webhooks/settlr', // Optional
510
- metadata: { orderId: 'order_123' }, // Optional
222
+ interval: "monthly",
511
223
  });
512
224
 
513
- // Redirect to hosted checkout
514
- window.location.href = session.url;
515
-
516
- // Returns
517
- {
518
- id: 'cs_abc123...',
519
- url: 'https://settlr.app/checkout/cs_abc123...',
520
- expiresAt: 1702659600000, // 30 min expiry
521
- }
225
+ // Subscribe a customer
226
+ const subscription = await subs.subscribe({
227
+ planId: plan.id,
228
+ customerWallet: "7xKX...",
229
+ customerEmail: "user@example.com",
230
+ });
522
231
  ```
523
232
 
524
- ## Webhooks โญ UPDATED
233
+ ---
525
234
 
526
- Get notified when payments complete to fulfill orders automatically.
235
+ ## One-Click Payments
527
236
 
528
- ### Quick Setup (Next.js)
237
+ Pre-approved spending for returning customers:
529
238
 
530
239
  ```typescript
531
- // app/api/webhooks/settlr/route.ts
532
- import { createWebhookHandler } from "@settlr/sdk";
240
+ import { createOneClickClient } from "@settlr/sdk";
533
241
 
534
- export const POST = createWebhookHandler({
535
- secret: process.env.SETTLR_WEBHOOK_SECRET!,
536
- handlers: {
537
- "payment.completed": async (event) => {
538
- console.log("Payment completed!", event.payment.id);
539
- await fulfillOrder(event.payment.orderId);
540
- await sendConfirmationEmail(event.payment);
541
- },
542
- "payment.failed": async (event) => {
543
- await notifyCustomer(event.payment.orderId);
544
- },
545
- },
242
+ const oneClick = createOneClickClient();
243
+
244
+ // Customer approves once
245
+ await oneClick.approve({
246
+ customerWallet: "...",
247
+ merchantWallet: "...",
248
+ spendingLimit: 100,
249
+ });
250
+
251
+ // Merchant charges later โ€” no popups
252
+ const result = await oneClick.charge({
253
+ customerWallet: "...",
254
+ merchantWallet: "...",
255
+ amount: 25,
546
256
  });
547
257
  ```
548
258
 
549
- ### Express.js
259
+ ---
550
260
 
551
- ```typescript
552
- import express from "express";
553
- import { createWebhookHandler } from "@settlr/sdk";
261
+ ## API Keys
554
262
 
555
- const app = express();
556
-
557
- app.post(
558
- "/webhooks/settlr",
559
- express.raw({ type: "application/json" }),
560
- createWebhookHandler({
561
- secret: process.env.SETTLR_WEBHOOK_SECRET!,
562
- handlers: {
563
- "payment.completed": async (event) => {
564
- await fulfillOrder(event.payment.orderId);
565
- },
566
- },
567
- }),
568
- );
569
- ```
263
+ | Type | Prefix | Use |
264
+ | ---- | ---------- | ----------- |
265
+ | Live | `sk_live_` | Production |
266
+ | Test | `sk_test_` | Development |
570
267
 
571
- ### Manual Verification
268
+ | Tier | Rate Limit | Fee |
269
+ | ---------- | ---------- | ---- |
270
+ | Free | 60/min | 2% |
271
+ | Pro | 300/min | 1.5% |
272
+ | Enterprise | 1000/min | 1% |
572
273
 
573
- ```typescript
574
- import { verifyWebhookSignature, parseWebhookPayload } from "@settlr/sdk";
274
+ Get yours at [settlr.dev/onboarding](https://settlr.dev/onboarding).
575
275
 
576
- export async function POST(request: Request) {
577
- const signature = request.headers.get("x-settlr-signature")!;
578
- const body = await request.text();
276
+ ---
579
277
 
580
- // Verify signature
581
- if (!verifyWebhookSignature(body, signature, process.env.WEBHOOK_SECRET!)) {
582
- return new Response("Invalid signature", { status: 401 });
583
- }
278
+ ## Multichain Support
584
279
 
585
- const event = JSON.parse(body);
280
+ Checkout accepts USDC from any major EVM chain โ€” automatically bridged to Solana via Mayan:
586
281
 
587
- if (event.type === "payment.completed") {
588
- await fulfillOrder(event.payment.orderId);
589
- }
282
+ | Chain | Bridge Time | Gas Cost |
283
+ | -------- | ----------- | -------------- |
284
+ | Solana | Instant | Free (gasless) |
285
+ | Base | ~1-2 min | ~$0.01 |
286
+ | Arbitrum | ~1-2 min | ~$0.01 |
287
+ | Ethereum | ~1-3 min | ~$1-5 |
590
288
 
591
- return new Response("OK", { status: 200 });
592
- }
593
- ```
289
+ ---
594
290
 
595
- ### Webhook Events
596
-
597
- | Event | Description |
598
- | ------------------------ | -------------------------- |
599
- | `payment.created` | Payment link was created |
600
- | `payment.completed` | Payment confirmed on-chain |
601
- | `payment.failed` | Payment failed |
602
- | `payment.expired` | Payment link expired |
603
- | `payment.refunded` | Payment was refunded |
604
- | `subscription.created` | Subscription was created |
605
- | `subscription.renewed` | Subscription was renewed |
606
- | `subscription.cancelled` | Subscription was cancelled |
607
- | `subscription.expired` | Subscription expired |
608
-
609
- ### Webhook Payload
610
-
611
- ```json
612
- {
613
- "id": "evt_abc123",
614
- "type": "payment.completed",
615
- "payment": {
616
- "id": "pay_xyz789",
617
- "amount": 29.99,
618
- "status": "completed",
619
- "orderId": "order_123",
620
- "memo": "Premium subscription",
621
- "txSignature": "5KtP...",
622
- "payerAddress": "7xKX...3mPq",
623
- "merchantAddress": "4dGo...7Ywd"
624
- },
625
- "timestamp": "2025-12-17T10:30:00.000Z",
626
- "signature": "hmac_sha256_signature"
627
- }
628
- ```
291
+ ## Full API Reference
629
292
 
630
- ##### `getMerchantBalance()`
293
+ ### PayoutClient
631
294
 
632
- Get merchant's USDC balance.
295
+ | Method | Description |
296
+ | ---------------------- | ------------------------- |
297
+ | `create(options)` | Send payout by email |
298
+ | `createBatch(payouts)` | Batch send (up to 500) |
299
+ | `get(id)` | Get payout by ID |
300
+ | `list(options?)` | List payouts with filters |
633
301
 
634
- ```typescript
635
- const balance = await settlr.getMerchantBalance();
636
- console.log(`Balance: $${balance} USDC`);
637
- ```
302
+ ### Settlr (Checkout)
303
+
304
+ | Method | Description |
305
+ | --------------------------- | ---------------------- |
306
+ | `createPayment(options)` | Create payment link |
307
+ | `buildTransaction(options)` | Build tx for signing |
308
+ | `pay(options)` | Execute direct payment |
309
+ | `getPaymentStatus(sig)` | Check payment status |
310
+ | `getMerchantBalance()` | Get USDC balance |
638
311
 
639
312
  ### Utilities
640
313
 
@@ -646,23 +319,7 @@ parseUSDC(29.99); // 29990000n
646
319
  shortenAddress("ABC...XYZ"); // "ABC...XYZ"
647
320
  ```
648
321
 
649
- ## Networks
650
-
651
- | Network | USDC Mint | USDT Mint |
652
- | ------- | ---------------------------------------------- | ---------------------------------------------- |
653
- | Devnet | `4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU` | `EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS` |
654
- | Mainnet | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` |
655
-
656
- ## Supported Tokens
657
-
658
- ```typescript
659
- import { SUPPORTED_TOKENS, getTokenMint, getTokenDecimals } from "@settlr/sdk";
660
-
661
- // Get token info
662
- const usdcMint = getTokenMint("USDC", "mainnet-beta");
663
- const usdtMint = getTokenMint("USDT", "mainnet-beta");
664
- const decimals = getTokenDecimals("USDC"); // 6
665
- ```
322
+ ---
666
323
 
667
324
  ## License
668
325
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@settlr/sdk",
3
- "version": "0.6.7",
4
- "description": "Settlr SDK - Accept Solana USDC payments with privacy. Email checkout, gasless transactions, FHE-encrypted receipts. Private on-chain, compliant off-chain.",
3
+ "version": "0.6.8",
4
+ "description": "Settlr SDK โ€” Global payout infrastructure. Pay anyone, anywhere, with just their email. One API call sends USDC, recipient claims with any Solana wallet. Batch payouts, webhooks, hosted claim page.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -26,38 +26,30 @@
26
26
  },
27
27
  "keywords": [
28
28
  "settlr",
29
- "settlr-sdk",
30
- "settlr.dev",
29
+ "payout-api",
30
+ "payout-infrastructure",
31
+ "global-payouts",
32
+ "pay-by-email",
33
+ "usdc-payouts",
34
+ "batch-payouts",
31
35
  "solana",
32
36
  "solana-payments",
33
37
  "usdc",
34
- "usdc-payments",
35
- "crypto-payments",
36
- "web3",
37
- "web3-payments",
38
- "stablecoin",
39
- "gasless",
40
- "gasless-transactions",
41
- "payment-gateway",
42
- "checkout",
43
- "gaming-payments",
44
- "game-monetization",
45
- "in-app-purchases",
46
- "react",
38
+ "stablecoin-payouts",
39
+ "cross-border-payments",
40
+ "international-payouts",
41
+ "contractor-payments",
42
+ "creator-payouts",
43
+ "data-labeling-payouts",
44
+ "freelancer-payments",
45
+ "crypto-payouts",
47
46
  "typescript",
48
- "email-checkout",
49
- "no-wallet",
50
- "privy",
51
- "inco-lightning",
52
- "fhe",
53
- "homomorphic-encryption",
54
- "private-receipts",
55
- "privacy-cash",
56
- "zk-payments",
57
- "range-security",
58
- "compliance",
59
- "sanctions-screening",
60
- "one-click-payments"
47
+ "react",
48
+ "checkout-sdk",
49
+ "payment-gateway",
50
+ "webhooks",
51
+ "gasless",
52
+ "web3"
61
53
  ],
62
54
  "author": "Settlr <hello@settlr.dev> (https://settlr.dev)",
63
55
  "license": "MIT",