@zendfi/sdk 0.8.4 → 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 +45 -437
- package/dist/chunk-DAJL2Q36.mjs +907 -0
- package/dist/express.d.mts +1 -1
- package/dist/express.d.ts +1 -1
- package/dist/helpers/index.d.mts +402 -0
- package/dist/helpers/index.d.ts +402 -0
- package/dist/helpers/index.js +944 -0
- package/dist/helpers/index.mjs +17 -0
- package/dist/index.d.mts +468 -3121
- package/dist/index.d.ts +468 -3121
- package/dist/index.js +421 -4020
- package/dist/index.mjs +1188 -5267
- package/dist/nextjs.d.mts +1 -1
- package/dist/nextjs.d.ts +1 -1
- package/dist/webhook-handler-61UWBtDI.d.mts +339 -0
- package/dist/webhook-handler-61UWBtDI.d.ts +339 -0
- package/package.json +19 -15
- package/README.md.old +0 -326
- package/dist/cache-T5YPC7OK.mjs +0 -9
- package/dist/chunk-5O5NAX65.mjs +0 -366
- package/dist/webhook-handler-CdtQHVU5.d.mts +0 -1130
- package/dist/webhook-handler-CdtQHVU5.d.ts +0 -1130
|
@@ -1,1130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ZendFi SDK Types
|
|
3
|
-
* Complete type definitions for the ZendFi API
|
|
4
|
-
*/
|
|
5
|
-
/** Branded type for type-safe IDs - prevents mixing different ID types */
|
|
6
|
-
type Brand<T, B> = T & {
|
|
7
|
-
__brand: B;
|
|
8
|
-
};
|
|
9
|
-
/** Payment ID (e.g., 'pay_abc123') */
|
|
10
|
-
type PaymentId = Brand<string, 'PaymentId'>;
|
|
11
|
-
/** Session ID (e.g., 'sess_abc123') */
|
|
12
|
-
type SessionId = Brand<string, 'SessionId'>;
|
|
13
|
-
/** Agent Key ID (e.g., 'ak_abc123') */
|
|
14
|
-
type AgentKeyId = Brand<string, 'AgentKeyId'>;
|
|
15
|
-
/** Merchant ID (e.g., 'merch_abc123') */
|
|
16
|
-
type MerchantId = Brand<string, 'MerchantId'>;
|
|
17
|
-
/** Invoice ID (e.g., 'inv_abc123') */
|
|
18
|
-
type InvoiceId = Brand<string, 'InvoiceId'>;
|
|
19
|
-
/** Subscription ID (e.g., 'sub_abc123') */
|
|
20
|
-
type SubscriptionId = Brand<string, 'SubscriptionId'>;
|
|
21
|
-
/** Escrow ID (e.g., 'esc_abc123') */
|
|
22
|
-
type EscrowId = Brand<string, 'EscrowId'>;
|
|
23
|
-
/** Installment Plan ID (e.g., 'inst_abc123') */
|
|
24
|
-
type InstallmentPlanId = Brand<string, 'InstallmentPlanId'>;
|
|
25
|
-
/** Payment Link Code (e.g., 'link_abc123') */
|
|
26
|
-
type PaymentLinkCode = Brand<string, 'PaymentLinkCode'>;
|
|
27
|
-
/** Intent ID (e.g., 'pi_abc123') */
|
|
28
|
-
type IntentId = Brand<string, 'IntentId'>;
|
|
29
|
-
declare const asPaymentId: (id: string) => PaymentId;
|
|
30
|
-
declare const asSessionId: (id: string) => SessionId;
|
|
31
|
-
declare const asAgentKeyId: (id: string) => AgentKeyId;
|
|
32
|
-
declare const asMerchantId: (id: string) => MerchantId;
|
|
33
|
-
declare const asInvoiceId: (id: string) => InvoiceId;
|
|
34
|
-
declare const asSubscriptionId: (id: string) => SubscriptionId;
|
|
35
|
-
declare const asEscrowId: (id: string) => EscrowId;
|
|
36
|
-
declare const asInstallmentPlanId: (id: string) => InstallmentPlanId;
|
|
37
|
-
declare const asPaymentLinkCode: (id: string) => PaymentLinkCode;
|
|
38
|
-
declare const asIntentId: (id: string) => IntentId;
|
|
39
|
-
type Environment = 'development' | 'staging' | 'production';
|
|
40
|
-
type ApiKeyMode = 'test' | 'live';
|
|
41
|
-
type Currency = 'USD' | 'EUR' | 'GBP';
|
|
42
|
-
type PaymentToken = 'SOL' | 'USDC' | 'USDT';
|
|
43
|
-
type PaymentStatus = 'pending' | 'confirmed' | 'failed' | 'expired';
|
|
44
|
-
type SubscriptionStatus = 'active' | 'canceled' | 'past_due' | 'paused';
|
|
45
|
-
type InstallmentPlanStatus = 'active' | 'completed' | 'defaulted' | 'cancelled';
|
|
46
|
-
type EscrowStatus = 'pending' | 'funded' | 'released' | 'refunded' | 'disputed' | 'cancelled';
|
|
47
|
-
type InvoiceStatus = 'draft' | 'sent' | 'paid';
|
|
48
|
-
type SplitStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'refunded';
|
|
49
|
-
type WebhookEvent = 'payment.created' | 'payment.confirmed' | 'payment.failed' | 'payment.expired' | 'subscription.created' | 'subscription.activated' | 'subscription.canceled' | 'subscription.payment_failed' | 'split.completed' | 'split.failed' | 'installment.due' | 'installment.paid' | 'installment.late' | 'escrow.funded' | 'escrow.released' | 'escrow.refunded' | 'escrow.disputed' | 'invoice.sent' | 'invoice.paid';
|
|
50
|
-
interface ZendFiConfig {
|
|
51
|
-
apiKey?: string;
|
|
52
|
-
baseURL?: string;
|
|
53
|
-
environment?: Environment;
|
|
54
|
-
mode?: ApiKeyMode;
|
|
55
|
-
timeout?: number;
|
|
56
|
-
retries?: number;
|
|
57
|
-
idempotencyEnabled?: boolean;
|
|
58
|
-
debug?: boolean;
|
|
59
|
-
}
|
|
60
|
-
interface SplitRecipient {
|
|
61
|
-
recipient_wallet: string;
|
|
62
|
-
recipient_name?: string;
|
|
63
|
-
percentage?: number;
|
|
64
|
-
fixed_amount_usd?: number;
|
|
65
|
-
split_order?: number;
|
|
66
|
-
}
|
|
67
|
-
interface CreatePaymentRequest {
|
|
68
|
-
amount: number;
|
|
69
|
-
currency?: Currency;
|
|
70
|
-
token?: PaymentToken;
|
|
71
|
-
description?: string;
|
|
72
|
-
customer_email?: string;
|
|
73
|
-
redirect_url?: string;
|
|
74
|
-
metadata?: Record<string, any>;
|
|
75
|
-
split_recipients?: SplitRecipient[];
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Payment Link - Shareable checkout links
|
|
79
|
-
*/
|
|
80
|
-
interface CreatePaymentLinkRequest {
|
|
81
|
-
amount: number;
|
|
82
|
-
currency?: string;
|
|
83
|
-
token?: string;
|
|
84
|
-
description?: string;
|
|
85
|
-
max_uses?: number;
|
|
86
|
-
expires_at?: string;
|
|
87
|
-
metadata?: Record<string, any>;
|
|
88
|
-
onramp?: boolean;
|
|
89
|
-
}
|
|
90
|
-
interface PaymentLink {
|
|
91
|
-
link_code: string;
|
|
92
|
-
merchant_id: string;
|
|
93
|
-
title?: string;
|
|
94
|
-
description?: string;
|
|
95
|
-
amount: number;
|
|
96
|
-
currency: string;
|
|
97
|
-
payment_methods?: string[];
|
|
98
|
-
redirect_url?: string;
|
|
99
|
-
expires_at?: string;
|
|
100
|
-
metadata?: Record<string, any>;
|
|
101
|
-
payment_url: string;
|
|
102
|
-
hosted_page_url: string;
|
|
103
|
-
created_at: string;
|
|
104
|
-
updated_at: string;
|
|
105
|
-
url: string;
|
|
106
|
-
id?: string;
|
|
107
|
-
token?: string;
|
|
108
|
-
max_uses?: number;
|
|
109
|
-
uses_count?: number;
|
|
110
|
-
is_active?: boolean;
|
|
111
|
-
onramp?: boolean;
|
|
112
|
-
}
|
|
113
|
-
interface Payment {
|
|
114
|
-
id: string;
|
|
115
|
-
merchant_id: string;
|
|
116
|
-
amount_usd?: number;
|
|
117
|
-
amount?: number;
|
|
118
|
-
currency?: string;
|
|
119
|
-
payment_token?: PaymentToken;
|
|
120
|
-
status: PaymentStatus;
|
|
121
|
-
customer_wallet?: string;
|
|
122
|
-
customer_email?: string;
|
|
123
|
-
description?: string;
|
|
124
|
-
checkout_url?: string;
|
|
125
|
-
payment_url?: string;
|
|
126
|
-
qr_code?: string;
|
|
127
|
-
expires_at: string;
|
|
128
|
-
confirmed_at?: string;
|
|
129
|
-
transaction_signature?: string;
|
|
130
|
-
metadata?: Record<string, any>;
|
|
131
|
-
split_ids?: string[];
|
|
132
|
-
created_at?: string;
|
|
133
|
-
updated_at?: string;
|
|
134
|
-
}
|
|
135
|
-
interface ListPaymentsRequest {
|
|
136
|
-
page?: number;
|
|
137
|
-
limit?: number;
|
|
138
|
-
status?: PaymentStatus;
|
|
139
|
-
from_date?: string;
|
|
140
|
-
to_date?: string;
|
|
141
|
-
}
|
|
142
|
-
interface PaginatedResponse<T> {
|
|
143
|
-
data: T[];
|
|
144
|
-
pagination: {
|
|
145
|
-
page: number;
|
|
146
|
-
limit: number;
|
|
147
|
-
total: number;
|
|
148
|
-
total_pages: number;
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
interface CreateSubscriptionPlanRequest {
|
|
152
|
-
name: string;
|
|
153
|
-
description?: string;
|
|
154
|
-
amount: number;
|
|
155
|
-
currency?: Currency;
|
|
156
|
-
interval: 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
157
|
-
interval_count?: number;
|
|
158
|
-
trial_days?: number;
|
|
159
|
-
metadata?: Record<string, any>;
|
|
160
|
-
}
|
|
161
|
-
interface SubscriptionPlan {
|
|
162
|
-
id: string;
|
|
163
|
-
merchant_id: string;
|
|
164
|
-
name: string;
|
|
165
|
-
description?: string;
|
|
166
|
-
amount: number;
|
|
167
|
-
currency: Currency;
|
|
168
|
-
interval: string;
|
|
169
|
-
interval_count: number;
|
|
170
|
-
trial_days: number;
|
|
171
|
-
is_active: boolean;
|
|
172
|
-
metadata?: Record<string, any>;
|
|
173
|
-
created_at: string;
|
|
174
|
-
updated_at: string;
|
|
175
|
-
}
|
|
176
|
-
interface CreateSubscriptionRequest {
|
|
177
|
-
plan_id: string;
|
|
178
|
-
customer_email: string;
|
|
179
|
-
customer_wallet?: string;
|
|
180
|
-
metadata?: Record<string, any>;
|
|
181
|
-
}
|
|
182
|
-
interface Subscription {
|
|
183
|
-
id: string;
|
|
184
|
-
plan_id: string;
|
|
185
|
-
merchant_id: string;
|
|
186
|
-
customer_email: string;
|
|
187
|
-
customer_wallet?: string;
|
|
188
|
-
status: SubscriptionStatus;
|
|
189
|
-
current_period_start: string;
|
|
190
|
-
current_period_end: string;
|
|
191
|
-
trial_end?: string;
|
|
192
|
-
canceled_at?: string;
|
|
193
|
-
metadata?: Record<string, any>;
|
|
194
|
-
created_at: string;
|
|
195
|
-
updated_at: string;
|
|
196
|
-
}
|
|
197
|
-
interface WebhookPayload {
|
|
198
|
-
event: WebhookEvent;
|
|
199
|
-
timestamp: string;
|
|
200
|
-
merchant_id: string;
|
|
201
|
-
data: Payment | Subscription;
|
|
202
|
-
}
|
|
203
|
-
interface VerifyWebhookRequest {
|
|
204
|
-
payload: string | object;
|
|
205
|
-
signature: string;
|
|
206
|
-
secret: string;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Installment Plans - Pay over time
|
|
210
|
-
*/
|
|
211
|
-
interface InstallmentScheduleItem {
|
|
212
|
-
installment_number: number;
|
|
213
|
-
due_date: string;
|
|
214
|
-
amount: string;
|
|
215
|
-
status: string;
|
|
216
|
-
payment_id?: string;
|
|
217
|
-
paid_at?: string;
|
|
218
|
-
}
|
|
219
|
-
interface CreateInstallmentPlanRequest {
|
|
220
|
-
customer_wallet: string;
|
|
221
|
-
customer_email?: string;
|
|
222
|
-
total_amount: number;
|
|
223
|
-
installment_count: number;
|
|
224
|
-
first_payment_date?: string;
|
|
225
|
-
payment_frequency_days: number;
|
|
226
|
-
description?: string;
|
|
227
|
-
late_fee_amount?: number;
|
|
228
|
-
grace_period_days?: number;
|
|
229
|
-
metadata?: Record<string, any>;
|
|
230
|
-
}
|
|
231
|
-
interface CreateInstallmentPlanResponse {
|
|
232
|
-
plan_id: string;
|
|
233
|
-
status: string;
|
|
234
|
-
}
|
|
235
|
-
interface InstallmentPlan {
|
|
236
|
-
id?: string;
|
|
237
|
-
plan_id?: string;
|
|
238
|
-
merchant_id?: string;
|
|
239
|
-
customer_wallet?: string;
|
|
240
|
-
customer_email?: string;
|
|
241
|
-
total_amount?: string;
|
|
242
|
-
installment_count?: number;
|
|
243
|
-
amount_per_installment?: string;
|
|
244
|
-
payment_schedule?: InstallmentScheduleItem[];
|
|
245
|
-
paid_count?: number;
|
|
246
|
-
status: InstallmentPlanStatus | string;
|
|
247
|
-
description?: string;
|
|
248
|
-
late_fee_amount?: string;
|
|
249
|
-
grace_period_days?: number;
|
|
250
|
-
metadata?: Record<string, any>;
|
|
251
|
-
created_at?: string;
|
|
252
|
-
updated_at?: string;
|
|
253
|
-
completed_at?: string;
|
|
254
|
-
defaulted_at?: string;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Escrow - Secure fund holding
|
|
258
|
-
*/
|
|
259
|
-
interface ReleaseCondition {
|
|
260
|
-
type: 'manual_approval' | 'time_based' | 'confirmation_required' | 'milestone';
|
|
261
|
-
approver?: string;
|
|
262
|
-
approved?: boolean;
|
|
263
|
-
release_after?: string;
|
|
264
|
-
confirmations_needed?: number;
|
|
265
|
-
confirmed_by?: string[];
|
|
266
|
-
description?: string;
|
|
267
|
-
approved_by?: string;
|
|
268
|
-
}
|
|
269
|
-
interface CreateEscrowRequest {
|
|
270
|
-
buyer_wallet: string;
|
|
271
|
-
seller_wallet: string;
|
|
272
|
-
amount: number;
|
|
273
|
-
currency?: Currency;
|
|
274
|
-
token?: PaymentToken;
|
|
275
|
-
description?: string;
|
|
276
|
-
release_conditions: ReleaseCondition;
|
|
277
|
-
metadata?: Record<string, any>;
|
|
278
|
-
}
|
|
279
|
-
interface Escrow {
|
|
280
|
-
id: string;
|
|
281
|
-
payment_id: string;
|
|
282
|
-
merchant_id: string;
|
|
283
|
-
buyer_wallet: string;
|
|
284
|
-
seller_wallet: string;
|
|
285
|
-
escrow_wallet: string;
|
|
286
|
-
amount: number;
|
|
287
|
-
currency: Currency;
|
|
288
|
-
token: PaymentToken;
|
|
289
|
-
release_conditions: ReleaseCondition;
|
|
290
|
-
status: EscrowStatus;
|
|
291
|
-
payment_url?: string;
|
|
292
|
-
qr_code?: string;
|
|
293
|
-
funded_at?: string;
|
|
294
|
-
released_at?: string;
|
|
295
|
-
refunded_at?: string;
|
|
296
|
-
disputed_at?: string;
|
|
297
|
-
dispute_reason?: string;
|
|
298
|
-
release_transaction_signature?: string;
|
|
299
|
-
refund_transaction_signature?: string;
|
|
300
|
-
metadata?: Record<string, any>;
|
|
301
|
-
created_at: string;
|
|
302
|
-
updated_at: string;
|
|
303
|
-
}
|
|
304
|
-
interface ApproveEscrowRequest {
|
|
305
|
-
approver_wallet: string;
|
|
306
|
-
}
|
|
307
|
-
interface RefundEscrowRequest {
|
|
308
|
-
reason: string;
|
|
309
|
-
}
|
|
310
|
-
interface DisputeEscrowRequest {
|
|
311
|
-
reason: string;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Invoices - Professional billing
|
|
315
|
-
*/
|
|
316
|
-
interface InvoiceLineItem {
|
|
317
|
-
description: string;
|
|
318
|
-
quantity: number;
|
|
319
|
-
unit_price: number;
|
|
320
|
-
}
|
|
321
|
-
interface CreateInvoiceRequest {
|
|
322
|
-
customer_email: string;
|
|
323
|
-
customer_name?: string;
|
|
324
|
-
amount: number;
|
|
325
|
-
token?: PaymentToken;
|
|
326
|
-
description: string;
|
|
327
|
-
line_items?: InvoiceLineItem[];
|
|
328
|
-
due_date?: string;
|
|
329
|
-
metadata?: Record<string, any>;
|
|
330
|
-
}
|
|
331
|
-
interface Invoice {
|
|
332
|
-
id: string;
|
|
333
|
-
invoice_number: string;
|
|
334
|
-
merchant_id: string;
|
|
335
|
-
customer_email: string;
|
|
336
|
-
customer_name?: string;
|
|
337
|
-
amount_usd: number;
|
|
338
|
-
token: PaymentToken;
|
|
339
|
-
description: string;
|
|
340
|
-
line_items?: InvoiceLineItem[];
|
|
341
|
-
status: InvoiceStatus;
|
|
342
|
-
payment_url?: string;
|
|
343
|
-
due_date?: string;
|
|
344
|
-
sent_at?: string;
|
|
345
|
-
paid_at?: string;
|
|
346
|
-
metadata?: Record<string, any>;
|
|
347
|
-
created_at: string;
|
|
348
|
-
updated_at: string;
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* API Key Scopes for Agent Keys
|
|
352
|
-
* Controls what operations an agent can perform
|
|
353
|
-
*/
|
|
354
|
-
type ApiKeyScope = 'full' | 'read_only' | 'create_payments' | 'manage_escrow' | 'create_subscriptions' | 'manage_installments' | 'read_analytics';
|
|
355
|
-
/**
|
|
356
|
-
* Agent API Key - Scoped access for AI agents
|
|
357
|
-
* Created via zendfi.agent.createKey()
|
|
358
|
-
*/
|
|
359
|
-
interface AgentApiKey {
|
|
360
|
-
/** Unique identifier (UUID) */
|
|
361
|
-
id: string;
|
|
362
|
-
/** First 12 characters of the key for identification */
|
|
363
|
-
key_prefix: string;
|
|
364
|
-
/** Full API key (only returned on creation, starts with zai_) */
|
|
365
|
-
full_key?: string;
|
|
366
|
-
/** Human-readable name for the agent */
|
|
367
|
-
name: string;
|
|
368
|
-
/** Permissions granted to this key */
|
|
369
|
-
scopes: ApiKeyScope[];
|
|
370
|
-
/** Maximum API calls per hour */
|
|
371
|
-
rate_limit_per_hour: number;
|
|
372
|
-
/** Agent metadata (agent_id, agent_name, etc.) */
|
|
373
|
-
agent_metadata: Record<string, unknown>;
|
|
374
|
-
/** ISO 8601 timestamp */
|
|
375
|
-
created_at: string;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Request to create an agent API key
|
|
379
|
-
*/
|
|
380
|
-
interface CreateAgentApiKeyRequest {
|
|
381
|
-
/** Human-readable name for the agent */
|
|
382
|
-
name: string;
|
|
383
|
-
/** Unique identifier for the agent (e.g., "shopping-assistant-v1") */
|
|
384
|
-
agent_id: string;
|
|
385
|
-
/** Display name for the agent */
|
|
386
|
-
agent_name?: string;
|
|
387
|
-
/** Permissions to grant (defaults to ['create_payments']) */
|
|
388
|
-
scopes?: ApiKeyScope[];
|
|
389
|
-
/** Maximum API calls per hour (defaults to 1000) */
|
|
390
|
-
rate_limit_per_hour?: number;
|
|
391
|
-
/** Additional metadata */
|
|
392
|
-
metadata?: Record<string, unknown>;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Session spending limits for AI agents
|
|
396
|
-
*/
|
|
397
|
-
interface SessionLimits {
|
|
398
|
-
/** Maximum USD per single transaction (default: 1000) */
|
|
399
|
-
max_per_transaction?: number;
|
|
400
|
-
/** Maximum USD per day (default: 5000) */
|
|
401
|
-
max_per_day?: number;
|
|
402
|
-
/** Maximum USD per week (default: 20000) */
|
|
403
|
-
max_per_week?: number;
|
|
404
|
-
/** Maximum USD per month (default: 50000) */
|
|
405
|
-
max_per_month?: number;
|
|
406
|
-
/** Require approval for transactions above this amount (default: 500) */
|
|
407
|
-
require_approval_above?: number;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Agent Session - Time-bounded spending authorization
|
|
411
|
-
*/
|
|
412
|
-
interface AgentSession {
|
|
413
|
-
/** Unique identifier (UUID) */
|
|
414
|
-
id: string;
|
|
415
|
-
/** Session token for API calls (zai_session_...) */
|
|
416
|
-
session_token: string;
|
|
417
|
-
/** Agent identifier */
|
|
418
|
-
agent_id: string;
|
|
419
|
-
/** Display name */
|
|
420
|
-
agent_name?: string;
|
|
421
|
-
/** User's Solana wallet address */
|
|
422
|
-
user_wallet: string;
|
|
423
|
-
/** Spending limits for this session */
|
|
424
|
-
limits: SessionLimits;
|
|
425
|
-
/** Whether the session is active */
|
|
426
|
-
is_active: boolean;
|
|
427
|
-
/** ISO 8601 timestamp */
|
|
428
|
-
created_at: string;
|
|
429
|
-
/** When the session expires (ISO 8601) */
|
|
430
|
-
expires_at: string;
|
|
431
|
-
/** Remaining daily spending allowance */
|
|
432
|
-
remaining_today: number;
|
|
433
|
-
/** Remaining weekly spending allowance */
|
|
434
|
-
remaining_this_week: number;
|
|
435
|
-
/** Remaining monthly spending allowance */
|
|
436
|
-
remaining_this_month: number;
|
|
437
|
-
/** Whether a PKP was minted for on-chain session identity */
|
|
438
|
-
mint_pkp?: boolean;
|
|
439
|
-
/** PKP Ethereum address (if mint_pkp was true) */
|
|
440
|
-
pkp_address?: string;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Request to create an agent session
|
|
444
|
-
*/
|
|
445
|
-
interface CreateAgentSessionRequest {
|
|
446
|
-
/** Unique identifier for the agent */
|
|
447
|
-
agent_id: string;
|
|
448
|
-
/** Display name for the agent */
|
|
449
|
-
agent_name?: string;
|
|
450
|
-
/** User's Solana wallet address */
|
|
451
|
-
user_wallet: string;
|
|
452
|
-
/** Spending limits (uses defaults if not provided) */
|
|
453
|
-
limits?: SessionLimits;
|
|
454
|
-
/** Restrict to specific merchants (UUIDs) */
|
|
455
|
-
allowed_merchants?: string[];
|
|
456
|
-
/** Session duration in hours (default: 24, max: 168) */
|
|
457
|
-
duration_hours?: number;
|
|
458
|
-
/**
|
|
459
|
-
* Mint a PKP for on-chain session identity (audit trail).
|
|
460
|
-
* Creates a blockchain-verified session identity via Lit Protocol.
|
|
461
|
-
* Note: Spending limits are enforced server-side.
|
|
462
|
-
*/
|
|
463
|
-
mint_pkp?: boolean;
|
|
464
|
-
/** Additional metadata */
|
|
465
|
-
metadata?: Record<string, unknown>;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Payment Intent Status
|
|
469
|
-
*/
|
|
470
|
-
type PaymentIntentStatus = 'requires_payment' | 'processing' | 'succeeded' | 'canceled' | 'failed';
|
|
471
|
-
/**
|
|
472
|
-
* Capture method for payment intents
|
|
473
|
-
*/
|
|
474
|
-
type CaptureMethod = 'automatic' | 'manual';
|
|
475
|
-
/**
|
|
476
|
-
* Payment Intent - Two-phase payment flow
|
|
477
|
-
*/
|
|
478
|
-
interface PaymentIntent {
|
|
479
|
-
/** Unique identifier (UUID) */
|
|
480
|
-
id: string;
|
|
481
|
-
/** Secret for confirming the intent (keep secure) */
|
|
482
|
-
client_secret: string;
|
|
483
|
-
/** Amount in USD */
|
|
484
|
-
amount: number;
|
|
485
|
-
/** Currency code */
|
|
486
|
-
currency: string;
|
|
487
|
-
/** Description of the payment */
|
|
488
|
-
description?: string;
|
|
489
|
-
/** Current status */
|
|
490
|
-
status: PaymentIntentStatus;
|
|
491
|
-
/** How to capture the payment */
|
|
492
|
-
capture_method: CaptureMethod;
|
|
493
|
-
/** Agent that created this intent */
|
|
494
|
-
agent_id?: string;
|
|
495
|
-
/** Linked payment ID (after confirmation) */
|
|
496
|
-
payment_id?: string;
|
|
497
|
-
/** ISO 8601 timestamp */
|
|
498
|
-
created_at: string;
|
|
499
|
-
/** When the intent expires (ISO 8601) */
|
|
500
|
-
expires_at: string;
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Request to create a payment intent
|
|
504
|
-
*/
|
|
505
|
-
interface CreatePaymentIntentRequest {
|
|
506
|
-
/** Amount in USD (must be > 0) */
|
|
507
|
-
amount: number;
|
|
508
|
-
/** Currency code (default: "USD") */
|
|
509
|
-
currency?: string;
|
|
510
|
-
/** Description of the payment */
|
|
511
|
-
description?: string;
|
|
512
|
-
/** Capture method (default: "automatic") */
|
|
513
|
-
capture_method?: CaptureMethod;
|
|
514
|
-
/** Agent identifier */
|
|
515
|
-
agent_id?: string;
|
|
516
|
-
/** Agent display name */
|
|
517
|
-
agent_name?: string;
|
|
518
|
-
/** Additional metadata */
|
|
519
|
-
metadata?: Record<string, unknown>;
|
|
520
|
-
/** Time until expiration in seconds (default: 86400 = 24h) */
|
|
521
|
-
expires_in_seconds?: number;
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Request to confirm a payment intent
|
|
525
|
-
*/
|
|
526
|
-
interface ConfirmPaymentIntentRequest {
|
|
527
|
-
/** The client_secret from the payment intent */
|
|
528
|
-
client_secret: string;
|
|
529
|
-
/** Customer's Solana wallet address */
|
|
530
|
-
customer_wallet: string;
|
|
531
|
-
/** Payment type (optional) */
|
|
532
|
-
payment_type?: string;
|
|
533
|
-
/** Enable gasless transaction (optional) */
|
|
534
|
-
auto_gasless?: boolean;
|
|
535
|
-
/** Additional metadata */
|
|
536
|
-
metadata?: Record<string, unknown>;
|
|
537
|
-
/** Session token for spending limit enforcement (optional) */
|
|
538
|
-
session_token?: string;
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Payment Intent Event
|
|
542
|
-
*/
|
|
543
|
-
interface PaymentIntentEvent {
|
|
544
|
-
/** Event ID */
|
|
545
|
-
id: string;
|
|
546
|
-
/** Payment Intent ID */
|
|
547
|
-
payment_intent_id: string;
|
|
548
|
-
/** Event type */
|
|
549
|
-
event_type: string;
|
|
550
|
-
/** Event data */
|
|
551
|
-
data: Record<string, unknown>;
|
|
552
|
-
/** ISO 8601 timestamp */
|
|
553
|
-
created_at: string;
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Purchasing Power Parity factor for a country
|
|
557
|
-
*/
|
|
558
|
-
interface PPPFactor {
|
|
559
|
-
/** ISO country code (e.g., "BR", "NG", "IN") */
|
|
560
|
-
country_code: string;
|
|
561
|
-
/** Full country name */
|
|
562
|
-
country_name: string;
|
|
563
|
-
/** PPP adjustment factor (0.0 - 1.0) */
|
|
564
|
-
ppp_factor: number;
|
|
565
|
-
/** Local currency code */
|
|
566
|
-
currency_code: string;
|
|
567
|
-
/** Suggested discount percentage */
|
|
568
|
-
adjustment_percentage: number;
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* User profile for pricing decisions
|
|
572
|
-
*/
|
|
573
|
-
interface UserProfile {
|
|
574
|
-
/** ISO country code */
|
|
575
|
-
location_country?: string;
|
|
576
|
-
/** Wallet transaction history (for loyalty detection) */
|
|
577
|
-
wallet_history?: Record<string, unknown>;
|
|
578
|
-
/** Context hint (e.g., "first-time", "loyal", "churning") */
|
|
579
|
-
context?: string;
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
* PPP pricing configuration
|
|
583
|
-
*/
|
|
584
|
-
interface PPPConfig {
|
|
585
|
-
/** Enable PPP adjustments (default: true) */
|
|
586
|
-
enabled?: boolean;
|
|
587
|
-
/** Minimum PPP factor to apply */
|
|
588
|
-
min_factor?: number;
|
|
589
|
-
/** Maximum PPP factor to apply */
|
|
590
|
-
max_factor?: number;
|
|
591
|
-
/** Absolute minimum price in USD */
|
|
592
|
-
floor_price?: number;
|
|
593
|
-
/** Absolute maximum price in USD */
|
|
594
|
-
ceiling_price?: number;
|
|
595
|
-
/** Maximum discount percentage */
|
|
596
|
-
max_discount_percent?: number;
|
|
597
|
-
/** Additional discount percentage on top of PPP */
|
|
598
|
-
extra_discount_percent?: number;
|
|
599
|
-
/** Custom reasoning text */
|
|
600
|
-
custom_reasoning?: string;
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* Request for AI-powered pricing suggestion
|
|
604
|
-
*/
|
|
605
|
-
interface PricingSuggestionRequest {
|
|
606
|
-
/** Agent identifier */
|
|
607
|
-
agent_id: string;
|
|
608
|
-
/** Product identifier (optional) */
|
|
609
|
-
product_id?: string;
|
|
610
|
-
/** Base price in USD (must be > 0) */
|
|
611
|
-
base_price: number;
|
|
612
|
-
/** Currency code (default: "USD") */
|
|
613
|
-
currency?: string;
|
|
614
|
-
/** User profile for personalization */
|
|
615
|
-
user_profile?: UserProfile;
|
|
616
|
-
/** PPP configuration overrides */
|
|
617
|
-
ppp_config?: PPPConfig;
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* AI-powered pricing suggestion response
|
|
621
|
-
*/
|
|
622
|
-
interface PricingSuggestion {
|
|
623
|
-
/** Suggested price in USD */
|
|
624
|
-
suggested_amount: number;
|
|
625
|
-
/** Minimum acceptable price */
|
|
626
|
-
min_amount: number;
|
|
627
|
-
/** Maximum suggested price */
|
|
628
|
-
max_amount: number;
|
|
629
|
-
/** Currency code */
|
|
630
|
-
currency: string;
|
|
631
|
-
/** Human-readable explanation */
|
|
632
|
-
reasoning: string;
|
|
633
|
-
/** Whether PPP was applied */
|
|
634
|
-
ppp_adjusted: boolean;
|
|
635
|
-
/** PPP factor used (if applied) */
|
|
636
|
-
adjustment_factor?: number;
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* Autonomous Delegate - Enables agent to sign transactions
|
|
640
|
-
*/
|
|
641
|
-
interface AutonomousDelegate {
|
|
642
|
-
/** Unique identifier (UUID) */
|
|
643
|
-
id: string;
|
|
644
|
-
/** Session key this delegate is attached to */
|
|
645
|
-
session_key_id: string;
|
|
646
|
-
/** Whether the delegate is active */
|
|
647
|
-
is_active: boolean;
|
|
648
|
-
/** Maximum spending in USD */
|
|
649
|
-
max_amount_usd: number;
|
|
650
|
-
/** Amount already spent */
|
|
651
|
-
used_amount_usd: number;
|
|
652
|
-
/** Remaining spending allowance */
|
|
653
|
-
remaining_usd: number;
|
|
654
|
-
/** When the delegate expires (ISO 8601) */
|
|
655
|
-
expires_at: string;
|
|
656
|
-
/** When the delegate was created (ISO 8601) */
|
|
657
|
-
created_at: string;
|
|
658
|
-
/** When the delegate was revoked (if applicable) */
|
|
659
|
-
revoked_at?: string;
|
|
660
|
-
/** Last time the delegate was used */
|
|
661
|
-
last_used_at?: string;
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Request to enable autonomous signing
|
|
665
|
-
*/
|
|
666
|
-
interface EnableAutonomyRequest {
|
|
667
|
-
/** Maximum spending in USD (must be > 0) */
|
|
668
|
-
max_amount_usd: number;
|
|
669
|
-
/** Duration in hours (1-168, max 7 days) */
|
|
670
|
-
duration_hours: number;
|
|
671
|
-
/** Ed25519 delegation signature (base64) */
|
|
672
|
-
delegation_signature: string;
|
|
673
|
-
/** Explicit expiration time (ISO 8601, optional) */
|
|
674
|
-
expires_at?: string;
|
|
675
|
-
/** Lit Protocol encrypted keypair (for device-bound keys) */
|
|
676
|
-
lit_encrypted_keypair?: string;
|
|
677
|
-
/** Hash of Lit Protocol encrypted data */
|
|
678
|
-
lit_data_hash?: string;
|
|
679
|
-
/** Additional metadata */
|
|
680
|
-
metadata?: Record<string, unknown>;
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Response from enabling autonomous signing
|
|
684
|
-
*/
|
|
685
|
-
interface EnableAutonomyResponse {
|
|
686
|
-
/** Delegate ID (UUID) */
|
|
687
|
-
delegate_id: string;
|
|
688
|
-
/** Session key ID (UUID) */
|
|
689
|
-
session_key_id: string;
|
|
690
|
-
/** Maximum spending in USD */
|
|
691
|
-
max_amount_usd: number;
|
|
692
|
-
/** When the delegate expires (ISO 8601) */
|
|
693
|
-
expires_at: string;
|
|
694
|
-
/** Public key of the delegate (base58) */
|
|
695
|
-
delegate_public_key: string;
|
|
696
|
-
/** Confirmation that autonomous mode is enabled */
|
|
697
|
-
autonomous_mode_enabled: boolean;
|
|
698
|
-
/** Whether Lit Protocol is being used */
|
|
699
|
-
lit_protocol_enabled: boolean;
|
|
700
|
-
/** True if device-bound key without Lit (fallback to client signing) */
|
|
701
|
-
requires_lit_for_auto_sign?: boolean;
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* Request to revoke autonomous mode
|
|
705
|
-
*/
|
|
706
|
-
interface RevokeAutonomyRequest {
|
|
707
|
-
/** Reason for revocation (optional) */
|
|
708
|
-
reason?: string;
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Autonomy status response
|
|
712
|
-
*/
|
|
713
|
-
interface AutonomyStatus {
|
|
714
|
-
/** Whether autonomous mode is enabled */
|
|
715
|
-
autonomous_mode_enabled: boolean;
|
|
716
|
-
/** Active delegate (if any) */
|
|
717
|
-
delegate?: AutonomousDelegate;
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* Request for AI-powered smart payment
|
|
721
|
-
*/
|
|
722
|
-
interface SmartPaymentRequest {
|
|
723
|
-
/** Session token for limit enforcement (optional) */
|
|
724
|
-
session_token?: string;
|
|
725
|
-
/** Agent identifier */
|
|
726
|
-
agent_id: string;
|
|
727
|
-
/** User's Solana wallet address */
|
|
728
|
-
user_wallet: string;
|
|
729
|
-
/** Amount in USD (must be > 0) */
|
|
730
|
-
amount_usd: number;
|
|
731
|
-
/** Target merchant ID (optional) */
|
|
732
|
-
merchant_id?: string;
|
|
733
|
-
/** Token to use (default: "USDC") */
|
|
734
|
-
token?: PaymentToken;
|
|
735
|
-
/** Auto-detect if gasless is needed (optional) */
|
|
736
|
-
auto_detect_gasless?: boolean;
|
|
737
|
-
/** Enable instant settlement (optional) */
|
|
738
|
-
instant_settlement?: boolean;
|
|
739
|
-
/** Create escrow for this payment (optional) */
|
|
740
|
-
enable_escrow?: boolean;
|
|
741
|
-
/** Payment description */
|
|
742
|
-
description?: string;
|
|
743
|
-
/** Product details for receipt */
|
|
744
|
-
product_details?: Record<string, unknown>;
|
|
745
|
-
/** Additional metadata */
|
|
746
|
-
metadata?: Record<string, unknown>;
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Smart Payment Status
|
|
750
|
-
*/
|
|
751
|
-
type SmartPaymentStatus = 'pending' | 'confirmed' | 'awaiting_signature' | 'failed';
|
|
752
|
-
/**
|
|
753
|
-
* Response from smart payment
|
|
754
|
-
*/
|
|
755
|
-
interface SmartPaymentResponse {
|
|
756
|
-
/** Payment ID (UUID) */
|
|
757
|
-
payment_id: string;
|
|
758
|
-
/** Current status */
|
|
759
|
-
status: SmartPaymentStatus;
|
|
760
|
-
/** Amount in USD */
|
|
761
|
-
amount_usd: number;
|
|
762
|
-
/** Whether gasless transaction was used */
|
|
763
|
-
gasless_used: boolean;
|
|
764
|
-
/** Whether settlement is complete */
|
|
765
|
-
settlement_complete: boolean;
|
|
766
|
-
/** Escrow ID if escrow was enabled */
|
|
767
|
-
escrow_id?: string;
|
|
768
|
-
/** Base64 encoded transaction (for signing) */
|
|
769
|
-
unsigned_transaction?: string;
|
|
770
|
-
/** Whether client signature is required */
|
|
771
|
-
requires_signature: boolean;
|
|
772
|
-
/** Transaction signature (if auto-signed) */
|
|
773
|
-
transaction_signature?: string;
|
|
774
|
-
/** Confirmation time in milliseconds */
|
|
775
|
-
confirmed_in_ms?: number;
|
|
776
|
-
/** URL to payment receipt */
|
|
777
|
-
receipt_url: string;
|
|
778
|
-
/** NFT receipt address (if minted) */
|
|
779
|
-
receipt_nft?: string;
|
|
780
|
-
/** Human-readable next steps */
|
|
781
|
-
next_steps: string;
|
|
782
|
-
/** URL to submit signed transaction */
|
|
783
|
-
submit_url?: string;
|
|
784
|
-
/** ISO 8601 timestamp */
|
|
785
|
-
created_at: string;
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* Analytics data for an agent
|
|
789
|
-
*/
|
|
790
|
-
interface AgentAnalytics {
|
|
791
|
-
/** Total number of payments */
|
|
792
|
-
total_payments: number;
|
|
793
|
-
/** Total volume in USD */
|
|
794
|
-
total_volume_usd: number;
|
|
795
|
-
/** Average payment amount in USD */
|
|
796
|
-
average_payment_usd: number;
|
|
797
|
-
/** Payment success rate (0-1) */
|
|
798
|
-
success_rate: number;
|
|
799
|
-
/** Number of active sessions */
|
|
800
|
-
active_sessions: number;
|
|
801
|
-
/** Number of active autonomous delegates */
|
|
802
|
-
active_delegates: number;
|
|
803
|
-
/** Total PPP savings in USD */
|
|
804
|
-
ppp_savings_usd: number;
|
|
805
|
-
/** Payments broken down by token */
|
|
806
|
-
payments_by_token: Record<PaymentToken, number>;
|
|
807
|
-
/** Daily payment statistics */
|
|
808
|
-
payments_by_day: Array<{
|
|
809
|
-
date: string;
|
|
810
|
-
count: number;
|
|
811
|
-
volume_usd: number;
|
|
812
|
-
}>;
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* @deprecated Use device-bound session keys via `zendfi.sessionKeys.create()` instead.
|
|
816
|
-
* Custodial session keys are deprecated and will be removed in a future version.
|
|
817
|
-
*/
|
|
818
|
-
interface CreateSessionKeyRequest {
|
|
819
|
-
/** @deprecated */ user_wallet: string;
|
|
820
|
-
/** @deprecated */ agent_id: string;
|
|
821
|
-
/** @deprecated */ agent_name?: string;
|
|
822
|
-
/** @deprecated */ limit_usdc: number;
|
|
823
|
-
/** @deprecated */ duration_days?: number;
|
|
824
|
-
/** @deprecated */ device_fingerprint: string;
|
|
825
|
-
/** @deprecated */ link_session_id?: string;
|
|
826
|
-
/** @deprecated */ link_session_token?: string;
|
|
827
|
-
}
|
|
828
|
-
/**
|
|
829
|
-
* @deprecated Use device-bound session keys instead.
|
|
830
|
-
*/
|
|
831
|
-
interface CreateSessionKeyResponse {
|
|
832
|
-
/** @deprecated */ session_key_id: string;
|
|
833
|
-
/** @deprecated */ user_wallet: string;
|
|
834
|
-
/** @deprecated */ agent_id: string;
|
|
835
|
-
/** @deprecated */ agent_name?: string;
|
|
836
|
-
/** @deprecated */ limit_usdc: number;
|
|
837
|
-
/** @deprecated */ expires_at: string;
|
|
838
|
-
/** @deprecated */ requires_approval: boolean;
|
|
839
|
-
/** @deprecated */ approval_transaction: string;
|
|
840
|
-
/** @deprecated */ cross_app_compatible: boolean;
|
|
841
|
-
/** @deprecated */ instructions: SessionKeyInstructions;
|
|
842
|
-
}
|
|
843
|
-
/** @deprecated */
|
|
844
|
-
interface SessionKeyInstructions {
|
|
845
|
-
step_1: string;
|
|
846
|
-
step_2: string;
|
|
847
|
-
step_3: string;
|
|
848
|
-
wallet_support: string[];
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* Device-bound session key creation request (non-custodial mode)
|
|
852
|
-
* Client generates keypair and encrypts it before sending
|
|
853
|
-
*/
|
|
854
|
-
interface CreateDeviceBoundSessionKeyRequest {
|
|
855
|
-
/** User's main wallet address */
|
|
856
|
-
user_wallet: string;
|
|
857
|
-
/** Agent identifier for cross-app compatibility (e.g., "shopping-assistant-v1") */
|
|
858
|
-
agent_id: string;
|
|
859
|
-
/** Human-readable agent name (e.g., "AI Shopping Assistant") */
|
|
860
|
-
agent_name?: string;
|
|
861
|
-
/** Spending limit in USDC */
|
|
862
|
-
limit_usdc: number;
|
|
863
|
-
/** Duration in days (1-30) */
|
|
864
|
-
duration_days: number;
|
|
865
|
-
/** Client-encrypted session keypair (base64) */
|
|
866
|
-
encrypted_session_key: string;
|
|
867
|
-
/** Encryption nonce (base64, 12 bytes) */
|
|
868
|
-
nonce: string;
|
|
869
|
-
/** Public key of the session keypair */
|
|
870
|
-
session_public_key: string;
|
|
871
|
-
/** Device fingerprint (SHA-256 hex, 64 chars) */
|
|
872
|
-
device_fingerprint: string;
|
|
873
|
-
/** Optional recovery QR data */
|
|
874
|
-
recovery_qr_data?: string;
|
|
875
|
-
}
|
|
876
|
-
/**
|
|
877
|
-
* Device-bound session key creation response
|
|
878
|
-
*/
|
|
879
|
-
interface CreateDeviceBoundSessionKeyResponse {
|
|
880
|
-
/** UUID of the created session key */
|
|
881
|
-
session_key_id: string;
|
|
882
|
-
/** Always "device_bound" */
|
|
883
|
-
mode: string;
|
|
884
|
-
/** Always false for device-bound */
|
|
885
|
-
is_custodial: boolean;
|
|
886
|
-
/** User's main wallet address */
|
|
887
|
-
user_wallet: string;
|
|
888
|
-
/** Agent identifier */
|
|
889
|
-
agent_id: string;
|
|
890
|
-
/** Agent name (if provided) */
|
|
891
|
-
agent_name?: string;
|
|
892
|
-
/** Session wallet public key */
|
|
893
|
-
session_wallet: string;
|
|
894
|
-
/** Spending limit in USDC */
|
|
895
|
-
limit_usdc: number;
|
|
896
|
-
/** Expiration timestamp */
|
|
897
|
-
expires_at: string;
|
|
898
|
-
/** Always true for device-bound */
|
|
899
|
-
requires_client_signing: boolean;
|
|
900
|
-
/** True if this session key works across multiple apps with same agent_id */
|
|
901
|
-
cross_app_compatible: boolean;
|
|
902
|
-
/** Security details */
|
|
903
|
-
security_info: SessionKeySecurityInfo;
|
|
904
|
-
}
|
|
905
|
-
interface SessionKeySecurityInfo {
|
|
906
|
-
encryption_type: string;
|
|
907
|
-
device_bound: boolean;
|
|
908
|
-
backend_can_decrypt: boolean;
|
|
909
|
-
recovery_qr_saved: boolean;
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* Session key status response
|
|
913
|
-
*/
|
|
914
|
-
interface SessionKeyStatus {
|
|
915
|
-
/** UUID of the session key */
|
|
916
|
-
session_key_id: string;
|
|
917
|
-
/** Whether the key is currently active */
|
|
918
|
-
is_active: boolean;
|
|
919
|
-
/** Whether the approval transaction was confirmed */
|
|
920
|
-
is_approved: boolean;
|
|
921
|
-
/** Total spending limit in USDC */
|
|
922
|
-
limit_usdc: number;
|
|
923
|
-
/** Amount already spent in USDC */
|
|
924
|
-
used_amount_usdc: number;
|
|
925
|
-
/** Remaining balance in USDC */
|
|
926
|
-
remaining_usdc: number;
|
|
927
|
-
/** Expiration timestamp */
|
|
928
|
-
expires_at: string;
|
|
929
|
-
/** Days until expiry */
|
|
930
|
-
days_until_expiry: number;
|
|
931
|
-
/** Security status */
|
|
932
|
-
security_status: SecurityStatus;
|
|
933
|
-
/** Linked AI session info (if linked) */
|
|
934
|
-
linked_session?: LinkedSessionInfo;
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* Information about a linked AI session (for policy enforcement)
|
|
938
|
-
*/
|
|
939
|
-
interface LinkedSessionInfo {
|
|
940
|
-
/** Session ID */
|
|
941
|
-
session_id: string;
|
|
942
|
-
/** Agent ID */
|
|
943
|
-
agent_id: string;
|
|
944
|
-
/** Whether the linked session is active */
|
|
945
|
-
is_active: boolean;
|
|
946
|
-
/** Per-transaction limit */
|
|
947
|
-
max_per_transaction?: number;
|
|
948
|
-
/** Daily remaining */
|
|
949
|
-
remaining_today: number;
|
|
950
|
-
/** Weekly remaining */
|
|
951
|
-
remaining_this_week: number;
|
|
952
|
-
/** Monthly remaining */
|
|
953
|
-
remaining_this_month: number;
|
|
954
|
-
/** Effective limit (minimum of session key balance and session limits) */
|
|
955
|
-
effective_limit: number;
|
|
956
|
-
}
|
|
957
|
-
interface SecurityStatus {
|
|
958
|
-
device_fingerprint_matched: boolean;
|
|
959
|
-
recent_security_events: number;
|
|
960
|
-
last_used_at: string | null;
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* Top-up request for adding funds to a session key
|
|
964
|
-
*/
|
|
965
|
-
interface TopUpSessionKeyRequest {
|
|
966
|
-
/** User's main wallet address */
|
|
967
|
-
user_wallet: string;
|
|
968
|
-
/** Amount to add in USDC */
|
|
969
|
-
amount_usdc: number;
|
|
970
|
-
/** Device fingerprint for security */
|
|
971
|
-
device_fingerprint: string;
|
|
972
|
-
}
|
|
973
|
-
/**
|
|
974
|
-
* Top-up response with unsigned transaction
|
|
975
|
-
*/
|
|
976
|
-
interface TopUpSessionKeyResponse {
|
|
977
|
-
/** UUID of the session key */
|
|
978
|
-
session_key_id: string;
|
|
979
|
-
/** Previous limit before top-up */
|
|
980
|
-
previous_limit: number;
|
|
981
|
-
/** New limit after top-up */
|
|
982
|
-
new_limit: number;
|
|
983
|
-
/** Amount being added */
|
|
984
|
-
added_amount: number;
|
|
985
|
-
/** Base64 encoded top-up transaction (user must sign) */
|
|
986
|
-
top_up_transaction: string;
|
|
987
|
-
/** Block height for transaction validity */
|
|
988
|
-
last_valid_block_height: number;
|
|
989
|
-
/** Instructions for the user */
|
|
990
|
-
instructions: string;
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Submit signed transaction request
|
|
994
|
-
*/
|
|
995
|
-
interface SubmitSignedTransactionRequest {
|
|
996
|
-
/** Base64 encoded signed transaction */
|
|
997
|
-
signed_transaction: string;
|
|
998
|
-
/** Optional session key ID (for some endpoints) */
|
|
999
|
-
session_key_id?: string;
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Submit transaction response
|
|
1003
|
-
*/
|
|
1004
|
-
interface SubmitTransactionResponse {
|
|
1005
|
-
success: boolean;
|
|
1006
|
-
signature: string;
|
|
1007
|
-
message: string;
|
|
1008
|
-
/** For top-up submissions */
|
|
1009
|
-
new_limit?: number;
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Session key list response
|
|
1013
|
-
*/
|
|
1014
|
-
interface SessionKeyListResponse {
|
|
1015
|
-
session_keys: SessionKeyStatus[];
|
|
1016
|
-
stats: SessionKeyStats;
|
|
1017
|
-
merchant_id: string;
|
|
1018
|
-
}
|
|
1019
|
-
interface SessionKeyStats {
|
|
1020
|
-
total_keys: number;
|
|
1021
|
-
active_keys: number;
|
|
1022
|
-
total_limit_usdc: number;
|
|
1023
|
-
total_used_usdc: number;
|
|
1024
|
-
}
|
|
1025
|
-
/**
|
|
1026
|
-
* Agent payment request - simplified payment via session
|
|
1027
|
-
*/
|
|
1028
|
-
interface AgentPaymentRequest {
|
|
1029
|
-
/** Session token for spending limit enforcement */
|
|
1030
|
-
session_token: string;
|
|
1031
|
-
/** Amount in USD */
|
|
1032
|
-
amount: number;
|
|
1033
|
-
/** Payment description */
|
|
1034
|
-
description?: string;
|
|
1035
|
-
/** Recipient merchant ID (optional if paying to session owner) */
|
|
1036
|
-
recipient_merchant_id?: string;
|
|
1037
|
-
/** Token to use (default: USDC) */
|
|
1038
|
-
token?: PaymentToken;
|
|
1039
|
-
/** Auto-detect if gasless is needed */
|
|
1040
|
-
auto_gasless?: boolean;
|
|
1041
|
-
/** Additional metadata */
|
|
1042
|
-
metadata?: Record<string, any>;
|
|
1043
|
-
}
|
|
1044
|
-
/**
|
|
1045
|
-
* Agent payment response
|
|
1046
|
-
*/
|
|
1047
|
-
interface AgentPaymentResponse {
|
|
1048
|
-
/** UUID of the created payment */
|
|
1049
|
-
payment_id: string;
|
|
1050
|
-
/** Payment status */
|
|
1051
|
-
status: 'pending' | 'processing' | 'confirmed' | 'failed' | 'awaiting_signature';
|
|
1052
|
-
/** Amount in USD */
|
|
1053
|
-
amount_usd: number;
|
|
1054
|
-
/** Whether gasless mode was used */
|
|
1055
|
-
gasless_used: boolean;
|
|
1056
|
-
/** Transaction signature (if confirmed) */
|
|
1057
|
-
transaction_signature?: string;
|
|
1058
|
-
/** Confirmation time in milliseconds */
|
|
1059
|
-
confirmed_in_ms?: number;
|
|
1060
|
-
/** Receipt URL */
|
|
1061
|
-
receipt_url?: string;
|
|
1062
|
-
/** If true, client must sign the transaction */
|
|
1063
|
-
requires_signature: boolean;
|
|
1064
|
-
/** Base64 encoded unsigned transaction (if requires_signature) */
|
|
1065
|
-
unsigned_transaction?: string;
|
|
1066
|
-
/** URL to submit signed transaction */
|
|
1067
|
-
submit_url?: string;
|
|
1068
|
-
/** Next steps for the client */
|
|
1069
|
-
next_steps: string;
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
/**
|
|
1073
|
-
* ZendFi Webhook Handlers
|
|
1074
|
-
* Type-safe webhook handlers with automatic verification and deduplication
|
|
1075
|
-
*/
|
|
1076
|
-
|
|
1077
|
-
/**
|
|
1078
|
-
* Webhook handler configuration
|
|
1079
|
-
*/
|
|
1080
|
-
interface WebhookHandlerConfig {
|
|
1081
|
-
/** Your webhook secret from ZendFi dashboard */
|
|
1082
|
-
secret: string;
|
|
1083
|
-
/** Optional: Path to store processed webhook IDs (for deduplication) */
|
|
1084
|
-
onProcessed?: (webhookId: string) => Promise<void>;
|
|
1085
|
-
/** Optional: Check if webhook was already processed */
|
|
1086
|
-
isProcessed?: (webhookId: string) => Promise<boolean>;
|
|
1087
|
-
/** Optional: Custom error handler */
|
|
1088
|
-
onError?: (error: Error, event?: WebhookEvent) => void | Promise<void>;
|
|
1089
|
-
}
|
|
1090
|
-
/**
|
|
1091
|
-
* Event handler function type
|
|
1092
|
-
*/
|
|
1093
|
-
type WebhookEventHandler<T = any> = (data: T, event: WebhookPayload) => void | Promise<void>;
|
|
1094
|
-
/**
|
|
1095
|
-
* Webhook handlers map - type-safe event handlers
|
|
1096
|
-
*/
|
|
1097
|
-
type WebhookHandlers = Partial<{
|
|
1098
|
-
'payment.created': WebhookEventHandler;
|
|
1099
|
-
'payment.confirmed': WebhookEventHandler;
|
|
1100
|
-
'payment.failed': WebhookEventHandler;
|
|
1101
|
-
'payment.expired': WebhookEventHandler;
|
|
1102
|
-
'subscription.created': WebhookEventHandler;
|
|
1103
|
-
'subscription.activated': WebhookEventHandler;
|
|
1104
|
-
'subscription.canceled': WebhookEventHandler;
|
|
1105
|
-
'subscription.payment_failed': WebhookEventHandler;
|
|
1106
|
-
'split.completed': WebhookEventHandler;
|
|
1107
|
-
'split.failed': WebhookEventHandler;
|
|
1108
|
-
'installment.due': WebhookEventHandler;
|
|
1109
|
-
'installment.paid': WebhookEventHandler;
|
|
1110
|
-
'installment.late': WebhookEventHandler;
|
|
1111
|
-
'escrow.funded': WebhookEventHandler;
|
|
1112
|
-
'escrow.released': WebhookEventHandler;
|
|
1113
|
-
'escrow.refunded': WebhookEventHandler;
|
|
1114
|
-
'escrow.disputed': WebhookEventHandler;
|
|
1115
|
-
'invoice.sent': WebhookEventHandler;
|
|
1116
|
-
'invoice.paid': WebhookEventHandler;
|
|
1117
|
-
}>;
|
|
1118
|
-
/**
|
|
1119
|
-
* Webhook processing result
|
|
1120
|
-
*/
|
|
1121
|
-
interface WebhookResult {
|
|
1122
|
-
success: boolean;
|
|
1123
|
-
processed: boolean;
|
|
1124
|
-
error?: string;
|
|
1125
|
-
event?: WebhookEvent;
|
|
1126
|
-
statusCode?: number;
|
|
1127
|
-
}
|
|
1128
|
-
declare function processWebhook(a: any, b?: any, c?: any): Promise<WebhookResult>;
|
|
1129
|
-
|
|
1130
|
-
export { type SubscriptionId as $, type AgentApiKey as A, type Escrow as B, type CreateAgentApiKeyRequest as C, type ApproveEscrowRequest as D, type EnableAutonomyRequest as E, type DisputeEscrowRequest as F, type CreateInvoiceRequest as G, type Invoice as H, type InstallmentPlan as I, type WebhookPayload as J, type ApiKeyMode as K, type ListPaymentsRequest as L, processWebhook as M, type WebhookResult as N, type WebhookEventHandler as O, type PaymentIntent as P, type Brand as Q, type RefundEscrowRequest as R, type SmartPaymentRequest as S, type PaymentId as T, type SessionId as U, type VerifyWebhookRequest as V, type WebhookHandlerConfig as W, type AgentKeyId as X, type MerchantId as Y, type ZendFiConfig as Z, type InvoiceId as _, type WebhookHandlers as a, type EscrowId as a0, type InstallmentPlanId as a1, type PaymentLinkCode as a2, type IntentId as a3, asPaymentId as a4, asSessionId as a5, asAgentKeyId as a6, asMerchantId as a7, asInvoiceId as a8, asSubscriptionId as a9, type RevokeAutonomyRequest as aA, type SmartPaymentStatus as aB, type CreateSessionKeyRequest as aC, type CreateSessionKeyResponse as aD, type SessionKeyInstructions as aE, type CreateDeviceBoundSessionKeyRequest as aF, type CreateDeviceBoundSessionKeyResponse as aG, type SessionKeySecurityInfo as aH, type SessionKeyStatus as aI, type LinkedSessionInfo as aJ, type SecurityStatus as aK, type TopUpSessionKeyRequest as aL, type TopUpSessionKeyResponse as aM, type SubmitSignedTransactionRequest as aN, type SubmitTransactionResponse as aO, type SessionKeyListResponse as aP, type SessionKeyStats as aQ, asEscrowId as aa, asInstallmentPlanId as ab, asPaymentLinkCode as ac, asIntentId as ad, type Environment as ae, type Currency as af, type PaymentToken as ag, type PaymentStatus as ah, type SubscriptionStatus as ai, type InstallmentPlanStatus as aj, type EscrowStatus as ak, type InvoiceStatus as al, type SplitStatus as am, type WebhookEvent as an, type SplitRecipient as ao, type InstallmentScheduleItem as ap, type CreateInstallmentPlanResponse as aq, type ReleaseCondition as ar, type InvoiceLineItem as as, type ApiKeyScope as at, type SessionLimits as au, type PaymentIntentStatus as av, type CaptureMethod as aw, type UserProfile as ax, type PPPConfig as ay, type AutonomousDelegate as az, type CreateAgentSessionRequest as b, type AgentSession as c, type AgentPaymentRequest as d, type AgentPaymentResponse as e, type AgentAnalytics as f, type CreatePaymentIntentRequest as g, type ConfirmPaymentIntentRequest as h, type PaymentIntentEvent as i, type PPPFactor as j, type PricingSuggestionRequest as k, type PricingSuggestion as l, type EnableAutonomyResponse as m, type AutonomyStatus as n, type SmartPaymentResponse as o, type CreatePaymentRequest as p, type Payment as q, type PaginatedResponse as r, type CreateSubscriptionPlanRequest as s, type SubscriptionPlan as t, type CreateSubscriptionRequest as u, type Subscription as v, type CreatePaymentLinkRequest as w, type PaymentLink as x, type CreateInstallmentPlanRequest as y, type CreateEscrowRequest as z };
|