@solvapay/server 1.0.0-preview.9 → 1.0.1-preview.2

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/dist/edge.d.ts CHANGED
@@ -1,441 +1,1820 @@
1
+ type WebhookEventType = 'payment.succeeded' | 'payment.failed' | 'payment.refunded' | 'payment.refund_failed' | 'purchase.created' | 'purchase.updated' | 'purchase.cancelled' | 'purchase.expired' | 'purchase.suspended' | 'customer.created' | 'customer.updated' | 'customer.deleted';
2
+ interface WebhookEvent {
3
+ id: string;
4
+ type: WebhookEventType;
5
+ created: number;
6
+ api_version: string;
7
+ data: {
8
+ object: Record<string, any>;
9
+ previous_attributes: Record<string, any> | null;
10
+ };
11
+ livemode: boolean;
12
+ request: {
13
+ id: string | null;
14
+ idempotency_key: string | null;
15
+ };
16
+ }
17
+
1
18
  interface components {
2
19
  schemas: {
20
+ UpdateProviderDto: {
21
+ /** @description Legal entity information */
22
+ legalEntity?: Record<string, never>;
23
+ /**
24
+ * Provider description
25
+ * @example My business
26
+ */
27
+ description?: string;
28
+ /**
29
+ * Business website URL
30
+ * @example https://example.com
31
+ */
32
+ website?: string;
33
+ /**
34
+ * Business type
35
+ * @example individual
36
+ * @enum {string}
37
+ */
38
+ businessType?: "individual" | "company";
39
+ /**
40
+ * Business email address
41
+ * @example business@example.com
42
+ */
43
+ businessEmail?: string;
44
+ /**
45
+ * Support email address
46
+ * @example support@example.com
47
+ */
48
+ supportEmail?: string;
49
+ /**
50
+ * Business telephone number
51
+ * @example +1234567890
52
+ */
53
+ telephone?: string;
54
+ /**
55
+ * Support telephone number
56
+ * @example +1234567890
57
+ */
58
+ supportTelephone?: string;
59
+ /**
60
+ * Default currency code
61
+ * @example usd
62
+ */
63
+ defaultCurrency?: string;
64
+ /** @description Arbitrary metadata */
65
+ metadata?: Record<string, never>;
66
+ /** @description Terms of Service acceptance */
67
+ tosAcceptance?: Record<string, never>;
68
+ };
3
69
  CreateSecretKey: Record<string, never>;
4
- CheckName: Record<string, never>;
5
- CreateAdminAgent: Record<string, never>;
6
- UpdateAdminAgent: Record<string, never>;
7
- Signup: Record<string, never>;
8
- AuthResponse: Record<string, never>;
9
- Login: Record<string, never>;
10
- ForgotPassword: Record<string, never>;
11
- ResetPassword: Record<string, never>;
12
- VerifyEmail: Record<string, never>;
13
70
  CreateUser: Record<string, never>;
14
71
  UpdateUser: Record<string, never>;
15
72
  UpdateProfile: Record<string, never>;
16
73
  UpdatePreferences: Record<string, never>;
17
- ChangePassword: Record<string, never>;
18
- RequestEmailChange: Record<string, never>;
19
- CreateConnectedAccount: Record<string, never>;
20
- UpdateConnectedAccount: Record<string, never>;
21
- CreatePlanRequest: Record<string, never>;
22
- UpdatePlanRequest: Record<string, never>;
23
- ExecuteAnalyticsQuery: Record<string, never>;
24
- ExecuteMultipleQueries: Record<string, never>;
74
+ RequestEmailChange: {
75
+ newEmail: string;
76
+ };
77
+ VerifyEmailChange: {
78
+ code: string;
79
+ };
25
80
  CreateCheckoutSessionRequest: {
26
81
  /**
27
- * @description Customer reference identifier
82
+ * Customer reference
28
83
  * @example cus_3c4d5e6f7g8h
29
84
  */
30
- customerRef: string;
31
- /**
32
- * @description Agent reference identifier
33
- * @example agt_1a2b3c4d5e6f
34
- */
35
- agentRef: string;
85
+ customerReference: string;
36
86
  /**
37
- * @description Plan reference identifier (optional)
87
+ * Plan reference (optional)
38
88
  * @example pln_2b3c4d5e6f7g
39
89
  */
40
90
  planRef?: string;
41
91
  /**
42
- * @description URL to redirect to after successful payment (optional)
43
- * @example https://example.com/payment-success
92
+ * Product reference (required)
93
+ * @example prd_1a2b3c4d5e6f
44
94
  */
45
- returnUrl?: string;
95
+ productRef: string;
46
96
  };
47
97
  CheckoutSessionResponse: {
48
98
  /**
49
- * @description Checkout session ID
99
+ * Checkout session ID
50
100
  * @example 507f1f77bcf86cd799439011
51
101
  */
52
102
  id: string;
53
103
  /**
54
- * @description Public session ID used in checkout URL
104
+ * Public session ID used in checkout URL
55
105
  * @example a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
56
106
  */
57
107
  sessionId: string;
58
108
  /**
59
- * @description Amount in cents
109
+ * Amount in cents
60
110
  * @example 2999
61
111
  */
62
112
  amount: number;
63
113
  /**
64
- * @description Currency code
114
+ * Currency code
65
115
  * @example USD
66
116
  */
67
117
  currency: string;
68
118
  /**
69
- * @description Session status
119
+ * Session status
70
120
  * @example active
71
121
  */
72
122
  status: string;
73
123
  /**
74
- * @description Checkout URL to open the checkout page
124
+ * Checkout URL to open the checkout page
75
125
  * @example https://solvapay.com/customer/checkout?id=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
76
126
  */
77
127
  checkoutUrl: string;
78
128
  };
79
- CancelSubscriptionRequest: {
129
+ SelectCustomerSessionProductRequest: {
80
130
  /**
81
- * @description Reason for cancellation
82
- * @example Customer request
131
+ * Product reference or ID to scope the customer manage session
132
+ * @example prd_1a2b3c4d5e6f
83
133
  */
134
+ productRef: string;
135
+ };
136
+ CancelRenewalRequest: {
137
+ /** @description Reason for cancelling renewal */
84
138
  reason?: string;
85
139
  };
86
- CheckLimitRequest: {
140
+ ExternalAccount: {
87
141
  /**
88
- * @description Customer reference identifier
89
- * @example cus_3c4d5e6f7g8h
142
+ * Country code
143
+ * @example US
90
144
  */
91
- customerRef: string;
145
+ country: string;
146
+ /**
147
+ * Currency code
148
+ * @example usd
149
+ */
150
+ currency: string;
151
+ /**
152
+ * Account holder name
153
+ * @example John Doe
154
+ */
155
+ accountHolderName: string;
156
+ /**
157
+ * Account holder type
158
+ * @example individual
159
+ * @enum {string}
160
+ */
161
+ accountHolderType: "individual" | "company";
162
+ /**
163
+ * Routing number
164
+ * @example 110000000
165
+ */
166
+ routingNumber: string;
92
167
  /**
93
- * @description Agent reference identifier
94
- * @example agt_1a2b3c4d5e6f
168
+ * Account number
169
+ * @example 000123456789
95
170
  */
96
- agentRef: string;
171
+ accountNumber: string;
97
172
  };
98
- LimitResponse: {
173
+ TosAcceptance: {
174
+ /**
175
+ * IP address of user accepting ToS
176
+ * @example 192.168.1.1
177
+ */
178
+ ip: string;
179
+ };
180
+ UpdateConnectedAccount: {
181
+ /**
182
+ * Business website URL
183
+ * @example https://example.com
184
+ */
185
+ website?: string;
186
+ /** @description External bank account */
187
+ externalAccount?: components["schemas"]["ExternalAccount"];
188
+ /** @description Terms of Service acceptance */
189
+ tosAcceptance?: components["schemas"]["TosAcceptance"];
190
+ };
191
+ Signup: {
192
+ name: string;
193
+ email: string;
194
+ /** @enum {string} */
195
+ type?: "provider" | "admin" | "super_admin";
196
+ };
197
+ AuthUserDto: {
198
+ id: string;
199
+ name: string;
200
+ email: string;
201
+ /** @enum {string} */
202
+ type: "provider" | "admin" | "super_admin";
203
+ emailVerified: boolean;
204
+ /** @enum {string} */
205
+ authProvider: "local" | "google" | "github" | "facebook";
206
+ providerId?: string;
207
+ providerRole?: string;
208
+ preferences?: Record<string, never>;
209
+ };
210
+ AuthResponse: {
211
+ user: components["schemas"]["AuthUserDto"];
212
+ accessToken?: string;
213
+ refreshToken?: string;
214
+ expiresIn?: number;
215
+ message?: string;
216
+ requiresMfa?: boolean;
217
+ requiresMfaSetup?: boolean;
218
+ };
219
+ Login: {
220
+ /** @description Email to send a 6-digit login code to */
221
+ email: string;
222
+ };
223
+ VerifyLoginCode: {
224
+ email: string;
225
+ /** @description 6-digit login code sent to email */
226
+ code: string;
227
+ };
228
+ VerifyEmail: {
229
+ emailVerificationCode: string;
230
+ };
231
+ DynamicClientRegistrationDto: {
232
+ /** @example My AI Agent */
233
+ client_name: string;
234
+ /**
235
+ * @example [
236
+ * "https://agent.example.com/callback"
237
+ * ]
238
+ */
239
+ redirect_uris: string[];
240
+ /**
241
+ * @example [
242
+ * "authorization_code",
243
+ * "refresh_token"
244
+ * ]
245
+ */
246
+ grant_types?: string[];
247
+ /**
248
+ * @example [
249
+ * "code"
250
+ * ]
251
+ */
252
+ response_types?: string[];
253
+ /** @example agent-123 */
254
+ software_id?: string;
255
+ /** @example 1.0.0 */
256
+ software_version?: string;
257
+ /** @example https://example.com/logo.png */
258
+ logo_uri?: string;
259
+ /** @example https://example.com/tos */
260
+ tos_uri?: string;
261
+ /** @example https://example.com/policy */
262
+ policy_uri?: string;
263
+ /** @example https://example.com */
264
+ client_uri?: string;
265
+ };
266
+ DynamicClientRegistrationResponseDto: {
267
+ /** @example client-id-123 */
268
+ client_id: string;
269
+ /** @example client-secret-456 */
270
+ client_secret: string;
271
+ /** @example 1734567890 */
272
+ client_id_issued_at: number;
273
+ /** @example 0 */
274
+ client_secret_expires_at: number;
275
+ /** @example My AI Agent */
276
+ client_name: string;
277
+ /**
278
+ * @example [
279
+ * "https://agent.example.com/callback"
280
+ * ]
281
+ */
282
+ redirect_uris: string[];
283
+ /**
284
+ * @example [
285
+ * "authorization_code",
286
+ * "refresh_token"
287
+ * ]
288
+ */
289
+ grant_types: string[];
290
+ /**
291
+ * @example [
292
+ * "code"
293
+ * ]
294
+ */
295
+ response_types: string[];
296
+ /** @example openid profile email */
297
+ scope: string;
298
+ /** @example client_secret_basic */
299
+ token_endpoint_auth_method: string;
300
+ };
301
+ GoogleLoginDto: {
302
+ /** @description The authorization code returned by Google */
303
+ code: string;
304
+ /** @description The redirect URI used in the initial authorization request */
305
+ redirect_uri: string;
306
+ /** @description The state parameter returned by Google (contains client_id) */
307
+ state: string;
308
+ };
309
+ GithubLoginDto: {
310
+ /** @description The authorization code returned by GitHub */
311
+ code: string;
312
+ /** @description The redirect URI used in the initial authorization request */
313
+ redirect_uri: string;
314
+ /** @description The state parameter returned by GitHub (contains client_id) */
315
+ state: string;
316
+ };
317
+ CreateOAuthClientDto: Record<string, never>;
318
+ UpdateOAuthClientDto: Record<string, never>;
319
+ Plan: {
320
+ /**
321
+ * Plan type exposed in SDK
322
+ * @example recurring
323
+ * @enum {string}
324
+ */
325
+ type: "recurring" | "one-time";
326
+ /**
327
+ * Plan ID
328
+ * @example 507f1f77bcf86cd799439011
329
+ */
330
+ id: string;
331
+ /**
332
+ * Plan reference
333
+ * @example pln_1A2B3C4D
334
+ */
335
+ reference: string;
336
+ /**
337
+ * Plan price in cents
338
+ * @example 2999
339
+ */
340
+ price: number;
341
+ /**
342
+ * Currency code (ISO 4217)
343
+ * @example USD
344
+ */
345
+ currency: string;
346
+ /**
347
+ * Currency symbol (derived from currency)
348
+ * @example $
349
+ */
350
+ currencySymbol?: string;
351
+ /**
352
+ * Number of free units included
353
+ * @example 100
354
+ */
355
+ freeUnits?: number;
356
+ /**
357
+ * One-time setup fee
358
+ * @example 500
359
+ */
360
+ setupFee?: number;
361
+ /**
362
+ * Free trial period in days
363
+ * @example 14
364
+ */
365
+ trialDays?: number;
366
+ /**
367
+ * Billing cycle
368
+ * @example monthly
369
+ */
370
+ billingCycle?: string;
371
+ /**
372
+ * Billing model
373
+ * @example pre-paid
374
+ * @enum {string}
375
+ */
376
+ billingModel?: "pre-paid" | "post-paid";
377
+ /**
378
+ * Price per usage unit
379
+ * @example 0.01
380
+ */
381
+ pricePerUnit?: number;
99
382
  /**
100
- * @description Whether the customer is within their usage limits
383
+ * What the plan measures for usage tracking
384
+ * @example requests
385
+ */
386
+ measures?: string;
387
+ /**
388
+ * Usage limit for the meter
389
+ * @example 10000
390
+ */
391
+ limit?: number;
392
+ /**
393
+ * Whether unused units roll over to next period
394
+ * @example false
395
+ */
396
+ rolloverUnusedUnits?: boolean;
397
+ /** @description Usage limits */
398
+ limits?: {
399
+ [key: string]: unknown;
400
+ };
401
+ /** @description Plan features */
402
+ features?: {
403
+ [key: string]: unknown;
404
+ };
405
+ /**
406
+ * Whether this is a free tier plan
407
+ * @example false
408
+ */
409
+ isFreeTier: boolean;
410
+ /**
411
+ * Whether payment is required
101
412
  * @example true
102
413
  */
103
- withinLimits: boolean;
414
+ requiresPayment: boolean;
104
415
  /**
105
- * @description Remaining usage units before hitting the limit
106
- * @example 997
416
+ * Whether the plan is active (derived from status)
417
+ * @example true
107
418
  */
108
- remaining: number;
419
+ isActive: boolean;
420
+ /** @description Maximum number of active users */
421
+ maxActiveUsers?: number;
422
+ /** @description Access expiry in days */
423
+ accessExpiryDays?: number;
109
424
  /**
110
- * @description Optional checkout session ID/token if payment is required
111
- * @example e3f1c2d4b6a89f001122334455667788
425
+ * Plan status
426
+ * @example active
112
427
  */
113
- checkoutSessionId?: string;
428
+ status: string;
429
+ /** @description Creation timestamp */
430
+ createdAt: string;
431
+ /** @description Last update timestamp */
432
+ updatedAt: string;
433
+ };
434
+ CreatePlanRequest: {
114
435
  /**
115
- * @description Optional full checkout URL if payment is required (based on backend configuration)
116
- * @example https://app.solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
436
+ * Plan type exposed in SDK
437
+ * @example recurring
438
+ * @enum {string}
117
439
  */
118
- checkoutUrl?: string;
440
+ type?: "recurring" | "one-time";
441
+ /**
442
+ * Billing cycle (required for recurring/hybrid, optional for post-paid usage-based)
443
+ * @example monthly
444
+ * @enum {string}
445
+ */
446
+ billingCycle?: "weekly" | "monthly" | "quarterly" | "yearly" | "custom";
447
+ /**
448
+ * Plan price in cents
449
+ * @example 2999
450
+ */
451
+ price?: number;
452
+ /**
453
+ * Currency code (ISO 4217)
454
+ * @example USD
455
+ * @enum {string}
456
+ */
457
+ currency?: "USD" | "EUR" | "GBP" | "SEK" | "NOK" | "DKK" | "CAD" | "AUD" | "JPY" | "CHF" | "PLN" | "CZK" | "HUF" | "RON" | "BGN" | "HRK" | "RSD" | "MKD" | "BAM" | "ALL" | "ISK" | "TRY" | "RUB" | "UAH" | "BYN" | "MDL" | "GEL" | "AMD" | "AZN" | "KZT" | "KGS" | "TJS" | "TMT" | "UZS" | "MNT" | "CNY" | "KRW" | "THB" | "VND" | "IDR" | "MYR" | "SGD" | "PHP" | "INR" | "PKR" | "BDT" | "LKR" | "NPR" | "AFN" | "IRR" | "IQD" | "JOD" | "KWD" | "LBP" | "OMR" | "QAR" | "SAR" | "SYP" | "AED" | "YER" | "ILS" | "EGP" | "MAD" | "TND" | "DZD" | "LYD" | "SDG" | "ETB" | "KES" | "TZS" | "UGX" | "RWF" | "BIF" | "DJF" | "SOS" | "ERN" | "SLL" | "GMD" | "GNF" | "CVE" | "STN" | "AOA" | "ZAR" | "BWP" | "SZL" | "LSL" | "NAD" | "ZMW" | "ZWL" | "MZN" | "MWK" | "MGA" | "MUR" | "SCR" | "KMF" | "MVR";
458
+ /**
459
+ * Number of free units included
460
+ * @example 100
461
+ */
462
+ freeUnits?: number;
463
+ /**
464
+ * Usage limit for the meter
465
+ * @example 10000
466
+ */
467
+ limit?: number;
468
+ /**
469
+ * Usage limits (shape varies by plan type)
470
+ * @example {
471
+ * "maxTransactions": 1000
472
+ * }
473
+ */
474
+ limits?: {
475
+ [key: string]: unknown;
476
+ };
477
+ /**
478
+ * Plan features (generic key/value, shape is provider-defined)
479
+ * @example {
480
+ * "apiAccess": true,
481
+ * "prioritySupport": false
482
+ * }
483
+ */
484
+ features?: {
485
+ [key: string]: unknown;
486
+ };
487
+ /**
488
+ * Whether this is a free tier plan
489
+ * @example false
490
+ */
491
+ isFreeTier?: boolean;
492
+ /**
493
+ * Whether payment is required
494
+ * @example true
495
+ */
496
+ requiresPayment?: boolean;
497
+ /**
498
+ * Plan status
499
+ * @example active
500
+ * @enum {string}
501
+ */
502
+ status?: "active" | "inactive" | "archived";
503
+ /**
504
+ * Maximum number of active users
505
+ * @example 10
506
+ */
507
+ maxActiveUsers?: number;
508
+ /**
509
+ * Access expiry in days
510
+ * @example 30
511
+ */
512
+ accessExpiryDays?: number;
513
+ /** @description Additional metadata */
514
+ metadata?: {
515
+ [key: string]: unknown;
516
+ };
517
+ /**
518
+ * Whether this is the default plan
519
+ * @example false
520
+ */
521
+ default?: boolean;
119
522
  };
120
- UsageEvent: {
523
+ UpdatePlanRequest: {
121
524
  /**
122
- * @description Customer reference identifier
123
- * @example cus_3c4d5e6f7g8h
525
+ * Billing cycle
526
+ * @example monthly
527
+ * @enum {string}
124
528
  */
125
- customerRef: string;
529
+ billingCycle?: "weekly" | "monthly" | "quarterly" | "yearly" | "custom";
530
+ /**
531
+ * Plan price in cents
532
+ * @example 2999
533
+ */
534
+ price?: number;
535
+ /**
536
+ * Currency code (ISO 4217)
537
+ * @example USD
538
+ */
539
+ currency?: string;
540
+ /**
541
+ * Number of free units included
542
+ * @example 100
543
+ */
544
+ freeUnits?: number;
545
+ /**
546
+ * Usage limit for the meter
547
+ * @example 10000
548
+ */
549
+ limit?: number;
550
+ /**
551
+ * Usage limits (shape varies by plan type)
552
+ * @example {
553
+ * "maxTransactions": 1000
554
+ * }
555
+ */
556
+ limits?: {
557
+ [key: string]: unknown;
558
+ };
559
+ /**
560
+ * Plan features (generic key/value, shape is provider-defined)
561
+ * @example {
562
+ * "apiAccess": true,
563
+ * "prioritySupport": false
564
+ * }
565
+ */
566
+ features?: {
567
+ [key: string]: unknown;
568
+ };
569
+ /**
570
+ * Whether this is a free tier plan
571
+ * @example false
572
+ */
573
+ isFreeTier?: boolean;
574
+ /**
575
+ * Whether payment is required
576
+ * @example true
577
+ */
578
+ requiresPayment?: boolean;
579
+ /**
580
+ * Plan status
581
+ * @example active
582
+ * @enum {string}
583
+ */
584
+ status?: "active" | "inactive" | "archived";
585
+ /**
586
+ * Maximum number of active users
587
+ * @example 10
588
+ */
589
+ maxActiveUsers?: number;
590
+ /**
591
+ * Access expiry in days
592
+ * @example 30
593
+ */
594
+ accessExpiryDays?: number;
595
+ /** @description Additional metadata */
596
+ metadata?: {
597
+ [key: string]: unknown;
598
+ };
599
+ /**
600
+ * Whether this is the default plan
601
+ * @example false
602
+ */
603
+ default?: boolean;
604
+ };
605
+ ProductConfigDto: {
606
+ /**
607
+ * Fulfillment type
608
+ * @example digital
609
+ */
610
+ fulfillmentType?: string;
611
+ /**
612
+ * Validity period in days
613
+ * @example 30
614
+ */
615
+ validityPeriod?: number;
616
+ /**
617
+ * Delivery method
618
+ * @example api
619
+ */
620
+ deliveryMethod?: string;
621
+ };
622
+ CreateProductRequest: {
623
+ /**
624
+ * Product name
625
+ * @example AI Writing Assistant
626
+ */
627
+ name: string;
628
+ /**
629
+ * Product description
630
+ * @example AI-powered writing tool
631
+ */
632
+ description?: string;
633
+ /** @description URL to the product image */
634
+ imageUrl?: string;
635
+ /**
636
+ * Free-form product type defined by the provider
637
+ * @example Coding Assistant
638
+ */
639
+ productType?: string;
640
+ /**
641
+ * Whether this product uses MCP Pay proxy
642
+ * @default false
643
+ */
644
+ isMcpPay: boolean;
645
+ /** @description Product-specific configuration */
646
+ config?: components["schemas"]["ProductConfigDto"];
647
+ /** @description Arbitrary key-value metadata */
648
+ metadata?: {
649
+ [key: string]: unknown;
650
+ };
651
+ };
652
+ SdkPlanResponse: {
653
+ /**
654
+ * Plan ID
655
+ * @example 507f1f77bcf86cd799439011
656
+ */
657
+ id: string;
658
+ /**
659
+ * Plan reference
660
+ * @example pln_1A2B3C4D
661
+ */
662
+ reference: string;
663
+ /**
664
+ * Plan price in cents
665
+ * @example 2999
666
+ */
667
+ price: number;
668
+ /**
669
+ * Currency code (ISO 4217)
670
+ * @example USD
671
+ */
672
+ currency: string;
673
+ /**
674
+ * Currency symbol
675
+ * @example $
676
+ */
677
+ currencySymbol?: string;
678
+ /**
679
+ * One-time setup fee
680
+ * @example 500
681
+ */
682
+ setupFee?: number;
683
+ /**
684
+ * Free trial period in days
685
+ * @example 14
686
+ */
687
+ trialDays?: number;
688
+ /**
689
+ * Billing cycle
690
+ * @example monthly
691
+ */
692
+ billingCycle?: string;
693
+ /**
694
+ * Billing model
695
+ * @example pre-paid
696
+ */
697
+ billingModel?: string;
698
+ /**
699
+ * Price per unit in cents
700
+ * @example 10
701
+ */
702
+ pricePerUnit?: number;
703
+ /**
704
+ * What the plan measures for usage tracking
705
+ * @example requests
706
+ */
707
+ measures?: string;
708
+ /**
709
+ * Usage limit for the meter
710
+ * @example 10000
711
+ */
712
+ limit?: number;
713
+ /**
714
+ * Whether unused units roll over to next period
715
+ * @example false
716
+ */
717
+ rolloverUnusedUnits?: boolean;
718
+ /**
719
+ * Included free units
720
+ * @example 1000
721
+ */
722
+ freeUnits?: number;
723
+ /** @description Usage limits */
724
+ limits?: {
725
+ [key: string]: unknown;
726
+ };
727
+ /** @description Plan features */
728
+ features?: {
729
+ [key: string]: unknown;
730
+ };
731
+ /**
732
+ * Whether this is a free tier plan
733
+ * @example false
734
+ */
735
+ isFreeTier: boolean;
736
+ /**
737
+ * Whether payment is required
738
+ * @example true
739
+ */
740
+ requiresPayment: boolean;
741
+ /**
742
+ * Whether the plan is active
743
+ * @example true
744
+ */
745
+ isActive: boolean;
746
+ /**
747
+ * Plan status
748
+ * @example active
749
+ */
750
+ status: string;
751
+ /** @description Creation timestamp */
752
+ createdAt: string;
753
+ /** @description Last update timestamp */
754
+ updatedAt: string;
755
+ };
756
+ SdkProductResponse: {
757
+ /**
758
+ * Product ID
759
+ * @example 507f1f77bcf86cd799439011
760
+ */
761
+ id: string;
762
+ /**
763
+ * Product reference
764
+ * @example prd_1A2B3C4D
765
+ */
766
+ reference: string;
767
+ /**
768
+ * Product name
769
+ * @example AI Writing Assistant
770
+ */
771
+ name: string;
772
+ /** @description Product description */
773
+ description?: string;
774
+ /** @description URL to the product image */
775
+ imageUrl?: string;
776
+ /** @description Free-form product type */
777
+ productType?: string;
778
+ /**
779
+ * Product status
780
+ * @example active
781
+ */
782
+ status: string;
783
+ /**
784
+ * Product balance in cents
785
+ * @example 0
786
+ */
787
+ balance: number;
788
+ /**
789
+ * Total number of transactions
790
+ * @example 0
791
+ */
792
+ totalTransactions: number;
793
+ /**
794
+ * Whether this product uses MCP Pay proxy
795
+ * @example false
796
+ */
797
+ isMcpPay: boolean;
798
+ /** @description Product-specific configuration */
799
+ config?: components["schemas"]["ProductConfigDto"];
800
+ /** @description Arbitrary key-value metadata */
801
+ metadata?: {
802
+ [key: string]: unknown;
803
+ };
804
+ /** @description Creation timestamp */
805
+ createdAt: string;
806
+ /** @description Last update timestamp */
807
+ updatedAt: string;
808
+ /** @description Plans associated with this product */
809
+ plans?: components["schemas"]["SdkPlanResponse"][];
810
+ /**
811
+ * MCP linkage details for MCP-enabled products
812
+ * @example {
813
+ * "mcpServerId": "67f90f1f1b1c9c0b8df0f111",
814
+ * "mcpServerReference": "mcp_ABC123",
815
+ * "mcpSubdomain": "acme-docs",
816
+ * "mcpProxyUrl": "https://acme-docs.mcp.solvapay.com/mcp",
817
+ * "originUrl": "https://origin.example.com/mcp",
818
+ * "defaultPlanId": "67f90f1f1b1c9c0b8df0f001"
819
+ * }
820
+ */
821
+ mcp?: {
822
+ [key: string]: unknown;
823
+ };
824
+ };
825
+ UpdateProductRequest: {
826
+ /** @description Product name */
827
+ name?: string;
828
+ /** @description Product description */
829
+ description?: string;
830
+ /** @description URL to the product image */
831
+ imageUrl?: string;
832
+ /** @description Free-form product type defined by the provider */
833
+ productType?: string;
834
+ /**
835
+ * Product status
836
+ * @enum {string}
837
+ */
838
+ status?: "active" | "inactive" | "suspended";
839
+ /** @description Product-specific configuration */
840
+ config?: components["schemas"]["ProductConfigDto"];
841
+ /** @description Arbitrary key-value metadata */
842
+ metadata?: {
843
+ [key: string]: unknown;
844
+ };
845
+ };
846
+ McpBootstrapFreePlanConfig: {
847
+ /**
848
+ * Free plan display name override
849
+ * @example Starter
850
+ */
851
+ name?: string;
852
+ /**
853
+ * Included free units (default 1000)
854
+ * @example 500
855
+ */
856
+ freeUnits?: number;
857
+ };
858
+ McpBootstrapPaidPlanInput: {
859
+ /**
860
+ * Logical plan key (must not be "free")
861
+ * @example pro
862
+ */
863
+ key: string;
864
+ /**
865
+ * Plan display name
866
+ * @example Pro
867
+ */
868
+ name: string;
869
+ /**
870
+ * Plan price in cents (must be > 0)
871
+ * @example 2000
872
+ */
873
+ price: number;
874
+ /**
875
+ * Currency code (ISO 4217)
876
+ * @example USD
877
+ */
878
+ currency: string;
879
+ /**
880
+ * Billing cycle for recurring plans
881
+ * @example monthly
882
+ * @enum {string}
883
+ */
884
+ billingCycle?: "weekly" | "monthly" | "quarterly" | "yearly" | "custom";
885
+ /**
886
+ * Plan type
887
+ * @example recurring
888
+ * @enum {string}
889
+ */
890
+ type?: "recurring" | "one-time";
891
+ /**
892
+ * Included free units
893
+ * @example 1000
894
+ */
895
+ freeUnits?: number;
896
+ /**
897
+ * Meter id for usage tracking
898
+ * @example 67f90f1f1b1c9c0b8df0f001
899
+ */
900
+ meterId?: string;
901
+ /**
902
+ * Plan usage limit
903
+ * @example 10000
904
+ */
905
+ limit?: number;
906
+ /** @description Plan features */
907
+ features?: {
908
+ [key: string]: unknown;
909
+ };
910
+ };
911
+ McpBootstrapToolInput: {
912
+ /**
913
+ * Tool name
914
+ * @example search_docs
915
+ */
916
+ name: string;
917
+ /**
918
+ * Tool description
919
+ * @example Search indexed documents
920
+ */
921
+ description?: string;
922
+ /**
923
+ * If true, tool is publicly available without a plan
924
+ * @example false
925
+ */
926
+ noPlan?: boolean;
927
+ /**
928
+ * Direct plan IDs allowed for this tool
929
+ * @example [
930
+ * "67f90f1f1b1c9c0b8df0f001"
931
+ * ]
932
+ */
933
+ planIds?: string[];
934
+ /**
935
+ * Plan references allowed for this tool
936
+ * @example [
937
+ * "pln_ABC123"
938
+ * ]
939
+ */
940
+ planRefs?: string[];
941
+ /**
942
+ * Bootstrap plan keys allowed for this tool (for example free or starter_paid)
943
+ * @example [
944
+ * "free"
945
+ * ]
946
+ */
947
+ planKeys?: string[];
948
+ };
949
+ McpBootstrapRequest: {
950
+ /**
951
+ * Product name (optional when derivable from origin MCP metadata)
952
+ * @example Acme MCP Toolkit
953
+ */
954
+ name?: string;
955
+ /**
956
+ * Product description
957
+ * @example MCP toolkit with tiered access
958
+ */
959
+ description?: string;
960
+ /** @description Product image URL */
961
+ imageUrl?: string;
962
+ /**
963
+ * Free-form product type
964
+ * @example MCP Server
965
+ */
966
+ productType?: string;
967
+ /**
968
+ * Origin MCP server URL (must be https)
969
+ * @example https://origin.example.com/mcp
970
+ */
971
+ originUrl: string;
972
+ /**
973
+ * Optional final MCP subdomain override (for example, value returned by bootstrap-subdomain-checks)
974
+ * @example acme-docs
975
+ */
976
+ mcpDomain?: string;
126
977
  /**
127
- * @description Agent reference identifier
128
- * @example agt_1a2b3c4d5e6f
978
+ * Optional auth header name forwarded to origin server
979
+ * @example X-API-Key
129
980
  */
130
- agentRef: string;
981
+ authHeaderName?: string;
982
+ /**
983
+ * Optional auth API key forwarded to origin server
984
+ * @example sk-origin-123
985
+ */
986
+ authApiKey?: string;
987
+ /** @description Free plan config overrides. A free plan is always created; this just customizes name/freeUnits. */
988
+ freePlan?: components["schemas"]["McpBootstrapFreePlanConfig"];
989
+ /** @description Paid plan definitions requiring price + currency */
990
+ paidPlans?: components["schemas"]["McpBootstrapPaidPlanInput"][];
991
+ /** @description Tool to plan mapping configuration */
992
+ tools?: components["schemas"]["McpBootstrapToolInput"][];
993
+ /** @description Arbitrary product metadata */
994
+ metadata?: {
995
+ [key: string]: unknown;
996
+ };
997
+ };
998
+ McpBootstrapResult: {
999
+ /** @description Created product */
1000
+ product: components["schemas"]["SdkProductResponse"];
1001
+ /**
1002
+ * Created or updated MCP server identity
1003
+ * @example {
1004
+ * "id": "67f90f1f1b1c9c0b8df0f111",
1005
+ * "reference": "mcp_ABC123",
1006
+ * "subdomain": "acme-docs",
1007
+ * "mcpProxyUrl": "https://acme-docs.mcp.solvapay.com/mcp",
1008
+ * "url": "https://origin.example.com/mcp",
1009
+ * "defaultPlanId": "67f90f1f1b1c9c0b8df0f001"
1010
+ * }
1011
+ */
1012
+ mcpServer: {
1013
+ [key: string]: unknown;
1014
+ };
1015
+ /**
1016
+ * Resolved plan mapping by bootstrap key
1017
+ * @example {
1018
+ * "free": {
1019
+ * "id": "67f90f1f1b1c9c0b8df0f001",
1020
+ * "reference": "pln_FREE123",
1021
+ * "name": "Free"
1022
+ * }
1023
+ * }
1024
+ */
1025
+ planMap: {
1026
+ [key: string]: unknown;
1027
+ };
1028
+ /**
1029
+ * True when tools were auto-discovered from origin because the request omitted tools
1030
+ * @example true
1031
+ */
1032
+ toolsAutoMapped?: boolean;
1033
+ /** @description Auto-discovered tools used during bootstrap */
1034
+ autoMappedTools?: {
1035
+ name?: string;
1036
+ description?: string;
1037
+ }[];
1038
+ };
1039
+ McpBootstrapPreviewResult: {
1040
+ /** @description Discovered tools from the origin MCP server */
1041
+ discoveredTools: {
1042
+ name?: string;
1043
+ description?: string;
1044
+ }[];
1045
+ /** @description Validation status for the provided bootstrap payload */
1046
+ validation: {
1047
+ valid?: boolean;
1048
+ errors?: components["schemas"]["McpBootstrapPreviewValidationError"][];
1049
+ };
1050
+ /**
1051
+ * Product name derived from origin MCP metadata or hostname fallback
1052
+ * @example acme-origin-mcp
1053
+ */
1054
+ derivedName?: string;
1055
+ /**
1056
+ * Product description derived from origin server instructions
1057
+ * @example MCP toolkit for document retrieval and summarization.
1058
+ */
1059
+ derivedDescription?: string;
1060
+ /** @description Source of derived metadata */
1061
+ metadataSource: {
1062
+ /** @enum {string} */
1063
+ name?: "request" | "origin" | "hostname";
1064
+ /** @enum {string} */
1065
+ description?: "request" | "instructions" | "none";
1066
+ };
1067
+ /** @description Suggested default tool-to-plan mapping for UI review */
1068
+ suggestedMapping: {
1069
+ name?: string;
1070
+ description?: string;
1071
+ planKey?: string;
1072
+ }[];
1073
+ };
1074
+ RecordMeterEventDto: {
1075
+ /**
1076
+ * Meter name to record against
1077
+ * @example requests
1078
+ */
1079
+ meterName: string;
1080
+ /**
1081
+ * Customer reference
1082
+ * @example cus_ABC123
1083
+ */
1084
+ customerId: string;
1085
+ /**
1086
+ * Numeric value (default 1)
1087
+ * @default 1
1088
+ * @example 1
1089
+ */
1090
+ value: number;
1091
+ /**
1092
+ * Arbitrary key-value tags
1093
+ * @example {
1094
+ * "endpoint": "/api/v1/search",
1095
+ * "region": "us-east-1"
1096
+ * }
1097
+ */
1098
+ properties?: {
1099
+ [key: string]: unknown;
1100
+ };
1101
+ /** @description Product ID to scope the usage event to */
1102
+ productId?: string;
1103
+ /** @description Product reference to scope the usage event to */
1104
+ productReference?: string;
1105
+ /** @description ISO 8601 timestamp (defaults to now) */
1106
+ timestamp?: string;
1107
+ };
1108
+ RecordBulkMeterEventsDto: {
1109
+ /** @description Array of events to record */
1110
+ events: components["schemas"]["RecordMeterEventDto"][];
1111
+ };
1112
+ CreateCustomerSessionRequest: {
1113
+ /**
1114
+ * Customer reference identifier
1115
+ * @example cus_3c4d5e6f7g8h
1116
+ */
1117
+ customerRef: string;
131
1118
  /**
132
- * @description Outcome of the action
133
- * @example success
134
- * @enum {string}
1119
+ * Optional product reference or ID to scope the customer manage page to a single product.
1120
+ * @example prd_1a2b3c4d5e6f
135
1121
  */
136
- outcome: "success" | "paywall" | "fail";
1122
+ productRef?: string;
1123
+ };
1124
+ CustomerSessionResponse: {
137
1125
  /**
138
- * @description Optional action identifier
139
- * @example generate_text
1126
+ * Customer session ID
1127
+ * @example 507f1f77bcf86cd799439011
140
1128
  */
141
- action?: string;
1129
+ id: string;
142
1130
  /**
143
- * @description Unique request identifier matching the limits check
144
- * @example req_1a2b3c4d5e6f
1131
+ * Public session ID used in customer URL
1132
+ * @example e3f1c2d4b6a89f001122334455667788
145
1133
  */
146
- requestId: string;
1134
+ sessionId: string;
147
1135
  /**
148
- * @description Duration of the action in milliseconds
149
- * @example 1250
1136
+ * Session status
1137
+ * @example active
150
1138
  */
151
- actionDuration: number;
1139
+ status: string;
152
1140
  /**
153
- * @description ISO 8601 timestamp of when the action occurred
154
- * @example 2025-10-21T10:30:00.000Z
1141
+ * Customer URL to open the customer page
1142
+ * @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
155
1143
  */
156
- timestamp: string;
1144
+ customerUrl: string;
157
1145
  };
158
1146
  CreateCustomerRequest: {
159
1147
  /**
160
- * @description Customer email address (required)
1148
+ * Customer email address (required)
161
1149
  * @example customer@example.com
162
1150
  */
163
1151
  email: string;
164
1152
  /**
165
- * @description Customer full name (optional)
1153
+ * Customer full name (optional)
166
1154
  * @example John Doe
167
1155
  */
168
1156
  name?: string;
169
1157
  /**
170
- * @description External reference ID from your auth system to map this customer to an auth user (optional)
1158
+ * External reference ID from your auth system to map this customer to an auth user (optional)
171
1159
  * @example auth_user_12345
172
1160
  */
173
1161
  externalRef?: string;
174
1162
  };
175
- SubscriptionInfo: {
1163
+ PurchaseInfo: {
176
1164
  /**
177
- * @description Subscription reference
178
- * @example sub_abc123
1165
+ * Purchase reference
1166
+ * @example pur_1A2B3C4D
179
1167
  */
180
1168
  reference: string;
181
1169
  /**
182
- * @description Plan name
183
- * @example Pro Plan
1170
+ * Product name
1171
+ * @example API Gateway Manager
184
1172
  */
185
- planName: string;
1173
+ productName: string;
186
1174
  /**
187
- * @description Agent name
188
- * @example AI Assistant
1175
+ * Product reference
1176
+ * @example prd_abc123
189
1177
  */
190
- agentName: string;
1178
+ productReference?: string;
191
1179
  /**
192
- * @description Subscription status
1180
+ * Purchase status
193
1181
  * @example active
194
1182
  */
195
1183
  status: string;
196
1184
  /**
197
- * @description Start date
1185
+ * Start date
198
1186
  * @example 2025-10-27T10:00:00Z
199
1187
  */
200
1188
  startDate: string;
1189
+ /**
1190
+ * Amount paid in original currency (in cents)
1191
+ * @example 9900
1192
+ */
1193
+ amount: number;
1194
+ /**
1195
+ * Currency code
1196
+ * @example USD
1197
+ */
1198
+ currency: string;
1199
+ /**
1200
+ * End date of purchase
1201
+ * @example 2025-11-27T10:00:00Z
1202
+ */
1203
+ endDate?: string;
1204
+ /**
1205
+ * When purchase was cancelled
1206
+ * @example 2025-10-28T10:00:00Z
1207
+ */
1208
+ cancelledAt?: string;
1209
+ /**
1210
+ * Reason for cancellation
1211
+ * @example Customer request
1212
+ */
1213
+ cancellationReason?: string;
1214
+ /** @description Snapshot of the plan at time of purchase */
1215
+ planSnapshot?: Record<string, never>;
201
1216
  };
202
1217
  CustomerResponse: {
203
1218
  /**
204
- * @description Customer reference identifier
1219
+ * Customer reference identifier
205
1220
  * @example cus_3c4d5e6f7g8h
206
1221
  */
207
1222
  reference: string;
208
1223
  /**
209
- * @description Customer full name
1224
+ * Customer full name
210
1225
  * @example John Doe
211
1226
  */
212
1227
  name: string;
213
1228
  /**
214
- * @description Customer email address
1229
+ * Customer email address
215
1230
  * @example customer@example.com
216
1231
  */
217
1232
  email: string;
218
1233
  /**
219
- * @description External reference ID from your auth system (if set during creation or update)
1234
+ * External reference ID from your auth system (if set during creation or update)
220
1235
  * @example auth_user_12345
221
1236
  */
222
1237
  externalRef?: string;
223
- /** @description Active subscriptions */
224
- subscriptions?: components["schemas"]["SubscriptionInfo"][];
225
- };
226
- CreateCustomerSessionRequest: {
227
- /**
228
- * @description Customer reference identifier
229
- * @example cus_3c4d5e6f7g8h
230
- */
231
- customerRef: string;
1238
+ /** @description Active purchases */
1239
+ purchases?: components["schemas"]["PurchaseInfo"][];
232
1240
  };
233
1241
  CreateCustomerSessionResponse: {
234
1242
  /**
235
- * @description Customer session ID/token
1243
+ * Customer session ID/token
236
1244
  * @example e3f1c2d4b6a89f001122334455667788
237
1245
  */
238
1246
  sessionId: string;
239
1247
  /**
240
- * @description Full customer URL based on backend configuration (ready to redirect customer)
1248
+ * Full customer URL based on backend configuration (ready to redirect customer)
241
1249
  * @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
242
1250
  */
243
1251
  customerUrl: string;
244
1252
  };
245
1253
  GetCustomerSessionResponse: {
246
1254
  /**
247
- * @description Customer session ID/token
1255
+ * Customer session ID/token
248
1256
  * @example e3f1c2d4b6a89f001122334455667788
249
1257
  */
250
1258
  sessionId: string;
251
1259
  /**
252
- * @description Session status
1260
+ * Session status
253
1261
  * @example active
254
1262
  * @enum {string}
255
1263
  */
256
1264
  status: "active" | "expired" | "used";
257
1265
  /**
258
- * @description Full customer URL based on backend configuration (ready to redirect customer)
1266
+ * Full customer URL based on backend configuration (ready to redirect customer)
259
1267
  * @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
260
1268
  */
261
1269
  customerUrl: string;
262
1270
  /**
263
- * @description Session expiration date
1271
+ * Session expiration date
264
1272
  * @example 2025-01-01T12:00:00.000Z
265
1273
  */
266
1274
  expiresAt: string;
267
1275
  /** @description Customer object from session data */
268
1276
  customer: components["schemas"]["CustomerResponse"];
269
1277
  /**
270
- * @description Session creation date
1278
+ * Session creation date
271
1279
  * @example 2025-01-01T11:45:00.000Z
272
1280
  */
273
1281
  createdAt: string;
274
1282
  /**
275
- * @description Session last update date
1283
+ * Session last update date
276
1284
  * @example 2025-01-01T11:45:00.000Z
277
1285
  */
278
1286
  updatedAt: string;
279
1287
  };
280
- Agent: Record<string, never>;
281
- CreateAgentRequest: Record<string, never>;
282
- UpdateAgentRequest: Record<string, never>;
283
- BasePlan: Record<string, never>;
284
- SubscriptionResponse: {
1288
+ UserInfoRequest: {
1289
+ /**
1290
+ * Customer reference
1291
+ * @example cus_3C4D5E6F
1292
+ */
1293
+ customerRef: string;
285
1294
  /**
286
- * @description Subscription reference identifier
287
- * @example sub_1a2b3c4d5e6f
1295
+ * Product reference
1296
+ * @example prd_1A2B3C4D
288
1297
  */
1298
+ productRef: string;
1299
+ };
1300
+ UserInfoUserDto: {
1301
+ /** @example cus_3C4D5E6F */
289
1302
  reference: string;
1303
+ /** @example John Doe */
1304
+ name?: string | null;
1305
+ /** @example john@example.com */
1306
+ email: string;
1307
+ /** @example auth_user_12345 */
1308
+ externalRef?: string | null;
1309
+ };
1310
+ UserInfoUsageDto: {
1311
+ /** @example 1000 */
1312
+ total: number;
1313
+ /** @example 250 */
1314
+ used: number;
1315
+ /** @example 750 */
1316
+ remaining: number;
290
1317
  /**
291
- * @description Customer reference identifier
292
- * @example cus_3c4d5e6f7g8h
1318
+ * Meter ObjectId reference
1319
+ * @example 507f1f77bcf86cd799439011
293
1320
  */
294
- customerRef: string;
1321
+ meterId?: string;
1322
+ /** @example 25 */
1323
+ percentUsed?: number | null;
1324
+ };
1325
+ UserInfoPlanDto: {
1326
+ /** @example pln_2B3C4D5E */
1327
+ reference: string;
295
1328
  /**
296
- * @description Customer email
297
- * @example customer@example.com
1329
+ * Price in minor currency units (e.g. cents)
1330
+ * @example 2999
298
1331
  */
299
- customerEmail: string;
1332
+ price: number;
1333
+ /** @example USD */
1334
+ currency: string;
1335
+ /** @example recurring */
1336
+ type: string;
1337
+ /** @example monthly */
1338
+ billingCycle?: string | null;
1339
+ features?: string[] | null;
1340
+ limits?: {
1341
+ [key: string]: unknown;
1342
+ } | null;
1343
+ };
1344
+ UserInfoPurchaseDto: {
1345
+ /** @example pur_1A2B3C4D */
1346
+ reference: string;
1347
+ /** @example active */
1348
+ status: string;
1349
+ /** @example My API Product */
1350
+ productName: string;
1351
+ /** @example recurring */
1352
+ planType: string;
1353
+ /** @example 2025-10-27T10:00:00Z */
1354
+ startDate?: string | null;
1355
+ /** @example 2025-11-27T10:00:00Z */
1356
+ endDate?: string | null;
1357
+ usage?: components["schemas"]["UserInfoUsageDto"];
1358
+ plan?: components["schemas"]["UserInfoPlanDto"];
1359
+ };
1360
+ UserInfoResponse: {
300
1361
  /**
301
- * @description Customer name
302
- * @example John Doe
1362
+ * Human-readable status summary
1363
+ * @example Active subscription: My API Product (25% usage consumed)
1364
+ */
1365
+ status: string;
1366
+ /**
1367
+ * Customer portal session URL
1368
+ * @example https://solvapay.com/customer/manage?id=abc123
303
1369
  */
304
- customerName?: string;
1370
+ verifyUrl?: string | null;
1371
+ user?: components["schemas"]["UserInfoUserDto"];
1372
+ purchase?: components["schemas"]["UserInfoPurchaseDto"];
1373
+ };
1374
+ McpToolDto: {
305
1375
  /**
306
- * @description Agent reference identifier
307
- * @example agt_1a2b3c4d5e6f
1376
+ * Tool name
1377
+ * @example search_documents
308
1378
  */
309
- agentRef: string;
1379
+ name: string;
310
1380
  /**
311
- * @description Agent name
312
- * @example My AI Agent
1381
+ * Plan IDs that grant access to this tool
1382
+ * @example [
1383
+ * "pln_abc123"
1384
+ * ]
313
1385
  */
314
- agentName: string;
1386
+ planIds?: string[];
315
1387
  /**
316
- * @description Plan reference identifier
317
- * @example pln_1a2b3c4d5e6f
1388
+ * If true, the tool is unprotected (no purchase check or usage tracking)
1389
+ * @example false
318
1390
  */
319
- planRef: string;
1391
+ noPlan?: boolean;
320
1392
  /**
321
- * @description Plan name
322
- * @example Premium Plan
1393
+ * Human-readable tool description
1394
+ * @example Search indexed documents
323
1395
  */
324
- planName: string;
1396
+ description?: string;
325
1397
  /**
326
- * @description Plan type
327
- * @example recurring
328
- * @enum {string}
1398
+ * Whether this is a virtual platform tool handled by SolvaPay
1399
+ * @example false
1400
+ */
1401
+ isVirtual?: boolean;
1402
+ };
1403
+ McpServerDto: {
1404
+ /**
1405
+ * Server ID
1406
+ * @example 507f1f77bcf86cd799439011
1407
+ */
1408
+ id?: string;
1409
+ /**
1410
+ * Unique server reference
1411
+ * @example mcp_abc123
1412
+ */
1413
+ reference?: string;
1414
+ /**
1415
+ * Domain slug used to derive the MCP endpoint subdomain
1416
+ * @example my-mcp-server
1417
+ */
1418
+ name: string;
1419
+ /**
1420
+ * URL-safe subdomain derived from name
1421
+ * @example my-mcp-server
1422
+ */
1423
+ subdomain: string;
1424
+ /**
1425
+ * SolvaPay proxy URL that MCP clients connect to
1426
+ * @example https://mytelescope.mcp.solvapay.com/mcp
1427
+ */
1428
+ mcpProxyUrl?: string;
1429
+ /**
1430
+ * Origin URL of the actual MCP server
1431
+ * @example https://origin.example.com/mcp
1432
+ */
1433
+ url: string;
1434
+ /**
1435
+ * Avatar image URL
1436
+ * @example https://example.com/avatar.png
1437
+ */
1438
+ avatarUrl?: string;
1439
+ /** @description Registered tools for this server */
1440
+ tools?: components["schemas"]["McpToolDto"][];
1441
+ /**
1442
+ * Default plan ID for tool access gating. Must belong to the linked product and be a free-tier plan (isFreeTier=true or price=0).
1443
+ * @example pln_default
1444
+ */
1445
+ defaultPlanId?: string;
1446
+ /**
1447
+ * Associated product ID
1448
+ * @example 507f1f77bcf86cd799439011
329
1449
  */
330
- planType: "recurring" | "usage-based" | "one-time" | "hybrid";
1450
+ productId?: string;
331
1451
  /**
332
- * @description Subscription status
1452
+ * Server status
333
1453
  * @example active
334
1454
  * @enum {string}
335
1455
  */
336
- status: "pending" | "active" | "expired" | "cancelled" | "suspended" | "refunded";
1456
+ status?: "active" | "inactive" | "suspended";
337
1457
  /**
338
- * @description Amount paid in original currency (in cents)
339
- * @example 9900
1458
+ * Provider ID that owns this server
1459
+ * @example 507f1f77bcf86cd799439011
340
1460
  */
341
- amount: number;
1461
+ providerId: string;
1462
+ /**
1463
+ * Custom auth header name for origin requests
1464
+ * @example X-API-Key
1465
+ */
1466
+ authHeaderName?: string;
1467
+ /**
1468
+ * Whether an auth API key is configured
1469
+ * @example true
1470
+ */
1471
+ hasAuthApiKey?: boolean;
1472
+ /**
1473
+ * Total number of tool-call transactions
1474
+ * @example 42
1475
+ */
1476
+ totalTransactions?: number;
1477
+ /**
1478
+ * Current balance in cents
1479
+ * @example 1500
1480
+ */
1481
+ balance?: number;
1482
+ };
1483
+ PlanSnapshotDto: {
1484
+ /**
1485
+ * Plan reference
1486
+ * @example pln_1A2B3C4D
1487
+ */
1488
+ reference?: string;
1489
+ /**
1490
+ * Plan price in cents
1491
+ * @example 2999
1492
+ */
1493
+ price: number;
342
1494
  /**
343
- * @description Currency code
1495
+ * Currency code
344
1496
  * @example USD
345
1497
  */
346
1498
  currency: string;
347
1499
  /**
348
- * @description Start date of subscription
349
- * @example 2025-01-01T00:00:00.000Z
1500
+ * Plan type
1501
+ * @example recurring
350
1502
  */
351
- startDate: string;
1503
+ planType: string;
352
1504
  /**
353
- * @description End date of subscription (if applicable)
354
- * @example 2025-02-01T00:00:00.000Z
1505
+ * Billing cycle
1506
+ * @example monthly
355
1507
  */
356
- endDate?: string;
1508
+ billingCycle?: string | null;
1509
+ /** @description Plan features */
1510
+ features?: {
1511
+ [key: string]: unknown;
1512
+ } | null;
1513
+ /** @description Usage limits */
1514
+ limits?: {
1515
+ [key: string]: unknown;
1516
+ } | null;
1517
+ /**
1518
+ * Meter ObjectId reference
1519
+ * @example 507f1f77bcf86cd799439011
1520
+ */
1521
+ meterId?: string;
1522
+ /**
1523
+ * Usage limit for the meter
1524
+ * @example 5000
1525
+ */
1526
+ limit?: number;
1527
+ /**
1528
+ * Number of free units included
1529
+ * @example 100
1530
+ */
1531
+ freeUnits?: number;
1532
+ /**
1533
+ * Price per usage unit in cents
1534
+ * @example 10
1535
+ */
1536
+ pricePerUnit?: number;
1537
+ };
1538
+ UsageBillingDto: {
1539
+ /**
1540
+ * Units consumed in current period
1541
+ * @example 150
1542
+ */
1543
+ used: number;
1544
+ /**
1545
+ * Units exceeding the plan limit
1546
+ * @example 0
1547
+ */
1548
+ overageUnits: number;
1549
+ /**
1550
+ * Overage cost in cents
1551
+ * @example 0
1552
+ */
1553
+ overageCost: number;
1554
+ /**
1555
+ * Period start date
1556
+ * @example 2025-10-01T00:00:00Z
1557
+ */
1558
+ periodStart?: string;
1559
+ /**
1560
+ * Period end date
1561
+ * @example 2025-11-01T00:00:00Z
1562
+ */
1563
+ periodEnd?: string;
1564
+ };
1565
+ PurchaseResponse: {
1566
+ /**
1567
+ * Purchase ID
1568
+ * @example 507f1f77bcf86cd799439011
1569
+ */
1570
+ id: string;
1571
+ /**
1572
+ * Purchase reference
1573
+ * @example pur_1A2B3C4D
1574
+ */
1575
+ reference: string;
1576
+ /**
1577
+ * Customer reference
1578
+ * @example cus_3C4D5E6F
1579
+ */
1580
+ customerRef: string;
1581
+ /**
1582
+ * Customer email
1583
+ * @example customer@example.com
1584
+ */
1585
+ customerEmail: string;
1586
+ /**
1587
+ * Product reference
1588
+ * @example prd_1A2B3C4D
1589
+ */
1590
+ productRef: string;
1591
+ /**
1592
+ * Product ID
1593
+ * @example 507f1f77bcf86cd799439012
1594
+ */
1595
+ productId?: string;
357
1596
  /**
358
- * @description When payment was confirmed
359
- * @example 2025-01-01T00:00:00.000Z
1597
+ * Product name
1598
+ * @example API Gateway Manager
360
1599
  */
1600
+ productName?: string;
1601
+ /** @description Plan snapshot at time of purchase */
1602
+ planSnapshot: components["schemas"]["PlanSnapshotDto"];
1603
+ /**
1604
+ * Purchase status
1605
+ * @example active
1606
+ */
1607
+ status: string;
1608
+ /**
1609
+ * Amount in cents
1610
+ * @example 9900
1611
+ */
1612
+ amount: number;
1613
+ /**
1614
+ * Currency code
1615
+ * @example USD
1616
+ */
1617
+ currency: string;
1618
+ /** @description Start date */
1619
+ startDate: string;
1620
+ /** @description End date */
1621
+ endDate?: string;
1622
+ /** @description Paid at timestamp */
361
1623
  paidAt?: string;
362
- /** @description Usage quota information (for usage-based plans) */
363
- usageQuota?: Record<string, never>;
1624
+ /** @description Usage billing state for usage-based plans */
1625
+ usage?: components["schemas"]["UsageBillingDto"];
364
1626
  /**
365
- * @description Whether this is a recurring subscription
1627
+ * Is recurring
366
1628
  * @example true
367
1629
  */
368
1630
  isRecurring: boolean;
369
1631
  /**
370
- * @description Next billing date (for recurring subscriptions)
371
- * @example 2025-02-01T00:00:00.000Z
1632
+ * Billing cycle
1633
+ * @enum {string}
372
1634
  */
1635
+ billingCycle?: "weekly" | "monthly" | "quarterly" | "yearly";
1636
+ /** @description Next billing date */
373
1637
  nextBillingDate?: string;
1638
+ /** @description Auto-renew enabled */
1639
+ autoRenew?: boolean;
1640
+ /** @description Whether this is a free tier purchase */
1641
+ isFreeTier?: boolean;
1642
+ /** @description Cancelled at */
1643
+ cancelledAt?: string;
1644
+ /** @description Cancellation reason */
1645
+ cancellationReason?: string;
1646
+ /** @description Created at */
1647
+ createdAt: string;
1648
+ };
1649
+ CancelPurchaseRequest: {
1650
+ /** @description Reason for cancellation */
1651
+ reason?: string;
1652
+ };
1653
+ CheckLimitRequest: {
374
1654
  /**
375
- * @description When subscription was cancelled (if applicable)
376
- * @example 2025-01-15T00:00:00.000Z
1655
+ * Customer reference identifier
1656
+ * @example cus_3C4D5E6F
377
1657
  */
378
- cancelledAt?: string;
1658
+ customerRef: string;
379
1659
  /**
380
- * @description Reason for cancellation (if applicable)
381
- * @example Customer request
1660
+ * Product reference identifier
1661
+ * @example prd_1A2B3C4D
382
1662
  */
383
- cancellationReason?: string;
1663
+ productRef: string;
384
1664
  /**
385
- * @description When subscription was created
386
- * @example 2025-01-01T00:00:00.000Z
1665
+ * Plan reference to pre-select when creating a checkout session. If provided and the customer needs to purchase, the checkout page skips plan selection and shows the payment form directly.
1666
+ * @example pln_2B3C4D5E
387
1667
  */
388
- createdAt: string;
1668
+ planRef?: string;
1669
+ /**
1670
+ * Canonical usage meter name used for limit checks (for example: requests, tokens).
1671
+ * @example requests
1672
+ */
1673
+ meterName?: string;
1674
+ /**
1675
+ * Usage type alias for meterName. If both are provided, meterName takes precedence.
1676
+ * @example requests
1677
+ */
1678
+ usageType?: string;
389
1679
  };
390
- CreateCheckoutSessionResponse: {
1680
+ LimitResponse: {
1681
+ /**
1682
+ * Whether the customer is within their usage limits
1683
+ * @example true
1684
+ */
1685
+ withinLimits: boolean;
1686
+ /**
1687
+ * Remaining usage units before hitting the limit
1688
+ * @example 997
1689
+ */
1690
+ remaining: number;
391
1691
  /**
392
- * @description Checkout session ID/token
1692
+ * Checkout session ID if payment is required
393
1693
  * @example e3f1c2d4b6a89f001122334455667788
394
1694
  */
395
- sessionId: string;
1695
+ checkoutSessionId?: string;
396
1696
  /**
397
- * @description Full checkout URL based on backend configuration (ready to redirect customer)
1697
+ * Checkout URL if payment is required
398
1698
  * @example https://solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
399
1699
  */
400
- checkoutUrl: string;
1700
+ checkoutUrl?: string;
1701
+ /**
1702
+ * The meter name to use when tracking usage events
1703
+ * @example requests
1704
+ */
1705
+ meterName?: string;
401
1706
  };
402
- CreatePageSettings: {
403
- /** @description Page identifier */
404
- id: string;
405
- /** @description Page display name */
406
- name: string;
407
- /** @description Logo URL */
408
- logo?: string;
1707
+ ExecuteAnalyticsQuery: Record<string, never>;
1708
+ ExecuteMultipleQueries: Record<string, never>;
1709
+ CreateWebhookEndpointDto: {
409
1710
  /**
410
- * @description Text color in hex format
411
- * @example #2d3748
1711
+ * Webhook endpoint URL
1712
+ * @example https://example.com/webhook
412
1713
  */
413
- textColor: string;
1714
+ url: string;
414
1715
  /**
415
- * @description Button color in hex format
416
- * @example #3182ce
1716
+ * Webhook endpoint description
1717
+ * @example Production webhook
1718
+ */
1719
+ description?: string;
1720
+ };
1721
+ UpdateWebhookEndpointDto: {
1722
+ /**
1723
+ * Webhook endpoint URL
1724
+ * @example https://example.com/webhook
417
1725
  */
418
- buttonColor: string;
1726
+ url?: string;
419
1727
  /**
420
- * @description Left background color in hex format
421
- * @example #f7fafc
1728
+ * Webhook endpoint description
1729
+ * @example Updated webhook
422
1730
  */
423
- leftBackgroundColor: string;
1731
+ description?: string;
1732
+ };
1733
+ UpdateThemePreferenceDto: {
1734
+ /**
1735
+ * Selected UI theme mode
1736
+ * @example dark
1737
+ * @enum {string}
1738
+ */
1739
+ mode: "light" | "dark";
1740
+ };
1741
+ ThemeModeColorsDto: {
1742
+ /**
1743
+ * Page background color
1744
+ * @example #f7f7f8
1745
+ */
1746
+ background?: string;
424
1747
  /**
425
- * @description Right background color in hex format
1748
+ * Card/surface background color
426
1749
  * @example #ffffff
427
1750
  */
428
- rightBackgroundColor: string;
1751
+ surface?: string;
1752
+ /**
1753
+ * Primary text color
1754
+ * @example #181818
1755
+ */
1756
+ text?: string;
1757
+ /**
1758
+ * Secondary/muted text color
1759
+ * @example #5c5c5c
1760
+ */
1761
+ secondary?: string;
1762
+ };
1763
+ ThemeOverridesDto: {
1764
+ /** @description Light mode color overrides */
1765
+ light?: components["schemas"]["ThemeModeColorsDto"];
1766
+ /** @description Dark mode color overrides */
1767
+ dark?: components["schemas"]["ThemeModeColorsDto"];
1768
+ };
1769
+ UpdateBrandThemeDto: {
1770
+ /**
1771
+ * Logo image URL displayed in hosted page headers
1772
+ * @example /ui/files/download/provider-assets/provider-123/logos/logo.png
1773
+ */
1774
+ logo?: string;
1775
+ /**
1776
+ * Provider's brand name displayed on hosted pages
1777
+ * @example Acme Corp
1778
+ */
1779
+ brandName: string;
1780
+ /**
1781
+ * Primary/accent color in hex format
1782
+ * @example #3182ce
1783
+ */
1784
+ primaryColor: string;
429
1785
  /**
430
- * @description Font family
1786
+ * Font family for hosted pages
1787
+ * @default Inter
431
1788
  * @example Inter
432
1789
  */
433
1790
  fontFamily: string;
434
1791
  /**
435
- * @description Font size
1792
+ * Base font size
1793
+ * @default 16px
436
1794
  * @example 16px
437
1795
  */
438
1796
  fontSize: string;
1797
+ /** @description Per-mode color overrides for light and dark themes */
1798
+ themes?: components["schemas"]["ThemeOverridesDto"];
1799
+ };
1800
+ CreatePreregistrationDto: {
1801
+ /** @example jane@company.com */
1802
+ email: string;
1803
+ /** @example Jane Smith */
1804
+ fullName: string;
1805
+ /** @example Acme Corp */
1806
+ companyName: string;
1807
+ /** @example SaaS */
1808
+ businessType?: string;
1809
+ /** @example Purchase billing for our platform */
1810
+ useCase?: string;
1811
+ customFields?: {
1812
+ [key: string]: string;
1813
+ };
1814
+ };
1815
+ /** @description Auto-generated fallback schema for unresolved reference: McpBootstrapPreviewValidationError */
1816
+ McpBootstrapPreviewValidationError: {
1817
+ [key: string]: unknown;
439
1818
  };
440
1819
  };
441
1820
  responses: never;
@@ -451,14 +1830,23 @@ interface components {
451
1830
  * Types related to the SolvaPay API client and backend communication.
452
1831
  */
453
1832
 
1833
+ type UsageMeterType = 'requests' | 'tokens';
1834
+ type CheckLimitsRequest = components['schemas']['CheckLimitRequest'] & {
1835
+ meterName?: string;
1836
+ usageType?: UsageMeterType;
1837
+ };
454
1838
  /**
455
1839
  * Extended LimitResponse with plan field
456
1840
  */
457
1841
  type LimitResponseWithPlan = components['schemas']['LimitResponse'] & {
458
1842
  plan: string;
1843
+ meterName?: string;
459
1844
  };
460
1845
  /**
461
1846
  * Extended CustomerResponse with proper field mapping
1847
+ *
1848
+ * Note: The backend API returns purchases as PurchaseInfo objects.
1849
+ * Additional fields (paidAt, nextBillingDate) may be present in the response.
462
1850
  */
463
1851
  type CustomerResponseMapped = {
464
1852
  customerRef: string;
@@ -466,12 +1854,15 @@ type CustomerResponseMapped = {
466
1854
  name?: string;
467
1855
  externalRef?: string;
468
1856
  plan?: string;
469
- subscriptions?: components['schemas']['SubscriptionInfo'][];
1857
+ purchases?: Array<components['schemas']['PurchaseInfo'] & {
1858
+ paidAt?: string;
1859
+ nextBillingDate?: string;
1860
+ }>;
470
1861
  };
471
1862
  /**
472
- * Purchase information returned from payment processing
1863
+ * One-time purchase information returned from payment processing
473
1864
  */
474
- interface PurchaseInfo {
1865
+ interface OneTimePurchaseInfo {
475
1866
  reference: string;
476
1867
  productRef?: string;
477
1868
  amount: number;
@@ -483,11 +1874,72 @@ interface PurchaseInfo {
483
1874
  * Result from processing a payment intent
484
1875
  */
485
1876
  interface ProcessPaymentResult {
486
- type: 'subscription' | 'purchase';
487
- subscription?: components['schemas']['SubscriptionInfo'];
488
- purchase?: PurchaseInfo;
1877
+ type: 'recurring' | 'one-time';
1878
+ purchase?: components['schemas']['PurchaseInfo'];
1879
+ oneTimePurchase?: OneTimePurchaseInfo;
489
1880
  status: 'completed';
490
1881
  }
1882
+ interface McpBootstrapFreePlanConfig {
1883
+ name?: string;
1884
+ freeUnits?: number;
1885
+ }
1886
+ interface McpBootstrapPaidPlanInput {
1887
+ key: string;
1888
+ name: string;
1889
+ /** Price in cents (e.g. 2000 = $20.00) */
1890
+ price: number;
1891
+ currency: string;
1892
+ billingCycle?: 'weekly' | 'monthly' | 'quarterly' | 'yearly' | 'custom';
1893
+ type?: 'recurring' | 'one-time';
1894
+ freeUnits?: number;
1895
+ meterId?: string;
1896
+ limit?: number;
1897
+ features?: Record<string, unknown>;
1898
+ }
1899
+ interface ToolPlanMappingInput {
1900
+ name: string;
1901
+ description?: string;
1902
+ noPlan?: boolean;
1903
+ planIds?: string[];
1904
+ planRefs?: string[];
1905
+ planKeys?: string[];
1906
+ }
1907
+ interface McpBootstrapRequest {
1908
+ name?: string;
1909
+ description?: string;
1910
+ imageUrl?: string;
1911
+ productType?: string;
1912
+ originUrl: string;
1913
+ /** Optional token combined with provider name to derive the final MCP subdomain. */
1914
+ mcpDomain?: string;
1915
+ authHeaderName?: string;
1916
+ authApiKey?: string;
1917
+ freePlan?: McpBootstrapFreePlanConfig;
1918
+ paidPlans?: McpBootstrapPaidPlanInput[];
1919
+ tools?: ToolPlanMappingInput[];
1920
+ metadata?: Record<string, unknown>;
1921
+ }
1922
+ interface McpBootstrapResponse {
1923
+ product: components['schemas']['SdkProductResponse'];
1924
+ mcpServer: {
1925
+ id?: string;
1926
+ reference?: string;
1927
+ subdomain?: string;
1928
+ mcpProxyUrl?: string;
1929
+ url: string;
1930
+ defaultPlanId?: string;
1931
+ };
1932
+ planMap: Record<string, {
1933
+ id: string;
1934
+ reference: string;
1935
+ name?: string;
1936
+ }>;
1937
+ toolsAutoMapped?: boolean;
1938
+ autoMappedTools?: Array<{
1939
+ name: string;
1940
+ description?: string;
1941
+ }>;
1942
+ }
491
1943
  /**
492
1944
  * SolvaPay API Client Interface
493
1945
  *
@@ -496,50 +1948,73 @@ interface ProcessPaymentResult {
496
1948
  * You can provide your own implementation or use the default createSolvaPayClient().
497
1949
  */
498
1950
  interface SolvaPayClient {
499
- checkLimits(params: components['schemas']['CheckLimitRequest']): Promise<LimitResponseWithPlan>;
500
- trackUsage(params: components['schemas']['UsageEvent'] & {
501
- planRef: string;
1951
+ checkLimits(params: CheckLimitsRequest): Promise<LimitResponseWithPlan>;
1952
+ trackUsage(params: {
1953
+ customerRef: string;
1954
+ actionType?: 'transaction' | 'api_call' | 'hour' | 'email' | 'storage' | 'custom';
1955
+ units?: number;
1956
+ outcome?: 'success' | 'paywall' | 'fail';
1957
+ productReference?: string;
1958
+ purchaseReference?: string;
1959
+ description?: string;
1960
+ metadata?: Record<string, unknown>;
1961
+ duration?: number;
1962
+ timestamp?: string;
1963
+ idempotencyKey?: string;
502
1964
  }): Promise<void>;
503
1965
  createCustomer?(params: components['schemas']['CreateCustomerRequest']): Promise<{
504
1966
  customerRef: string;
505
1967
  }>;
506
- getCustomer?(params: {
507
- customerRef: string;
508
- }): Promise<CustomerResponseMapped>;
509
- getCustomerByExternalRef?(params: {
510
- externalRef: string;
1968
+ getCustomer(params: {
1969
+ customerRef?: string;
1970
+ externalRef?: string;
1971
+ email?: string;
511
1972
  }): Promise<CustomerResponseMapped>;
512
- listAgents?(): Promise<Array<{
1973
+ listProducts?(): Promise<Array<{
513
1974
  reference: string;
514
1975
  name: string;
515
1976
  description?: string;
1977
+ status?: string;
516
1978
  }>>;
517
- createAgent?(params: components['schemas']['CreateAgentRequest']): Promise<{
1979
+ createProduct?(params: components['schemas']['CreateProductRequest']): Promise<{
518
1980
  reference: string;
519
1981
  name: string;
520
1982
  }>;
521
- deleteAgent?(agentRef: string): Promise<void>;
522
- listPlans?(agentRef: string): Promise<Array<{
1983
+ bootstrapMcpProduct?(params: McpBootstrapRequest): Promise<McpBootstrapResponse>;
1984
+ updateProduct?(productRef: string, params: components['schemas']['UpdateProductRequest']): Promise<components['schemas']['SdkProductResponse']>;
1985
+ deleteProduct?(productRef: string): Promise<void>;
1986
+ cloneProduct?(productRef: string, overrides?: {
1987
+ name?: string;
1988
+ }): Promise<{
523
1989
  reference: string;
524
1990
  name: string;
525
- description?: string;
1991
+ }>;
1992
+ listPlans?(productRef: string): Promise<Array<{
1993
+ reference: string;
526
1994
  price?: number;
527
1995
  currency?: string;
528
1996
  interval?: string;
529
1997
  isFreeTier?: boolean;
530
1998
  freeUnits?: number;
531
- metadata?: Record<string, any>;
532
- [key: string]: any;
1999
+ measures?: string;
2000
+ limit?: number;
2001
+ pricePerUnit?: number;
2002
+ billingModel?: string;
2003
+ metadata?: Record<string, unknown>;
2004
+ [key: string]: unknown;
533
2005
  }>>;
534
2006
  createPlan?(params: components['schemas']['CreatePlanRequest'] & {
535
- agentRef: string;
2007
+ productRef: string;
536
2008
  }): Promise<{
537
2009
  reference: string;
538
- name: string;
539
2010
  }>;
540
- deletePlan?(agentRef: string, planRef: string): Promise<void>;
2011
+ updatePlan?(productRef: string, planRef: string, params: Partial<components['schemas']['CreatePlanRequest']>): Promise<{
2012
+ reference: string;
2013
+ [key: string]: unknown;
2014
+ }>;
2015
+ deletePlan?(productRef: string, planRef: string): Promise<void>;
541
2016
  createPaymentIntent?(params: {
542
- agentRef: string;
2017
+ productRef: string;
543
2018
  planRef: string;
544
2019
  customerRef: string;
545
2020
  idempotencyKey?: string;
@@ -549,17 +2024,21 @@ interface SolvaPayClient {
549
2024
  publishableKey: string;
550
2025
  accountId?: string;
551
2026
  }>;
552
- cancelSubscription?(params: {
553
- subscriptionRef: string;
2027
+ cancelPurchase?(params: {
2028
+ purchaseRef: string;
554
2029
  reason?: string;
555
- }): Promise<components['schemas']['SubscriptionResponse']>;
556
- processPayment?(params: {
2030
+ }): Promise<components['schemas']['PurchaseInfo']>;
2031
+ processPaymentIntent?(params: {
557
2032
  paymentIntentId: string;
558
- agentRef: string;
2033
+ productRef: string;
559
2034
  customerRef: string;
560
2035
  planRef?: string;
561
2036
  }): Promise<ProcessPaymentResult>;
562
- createCheckoutSession(params: components['schemas']['CreateCheckoutSessionRequest']): Promise<components['schemas']['CreateCheckoutSessionResponse']>;
2037
+ getUserInfo?(params: {
2038
+ customerRef: string;
2039
+ productRef: string;
2040
+ }): Promise<components['schemas']['UserInfoResponse']>;
2041
+ createCheckoutSession(params: components['schemas']['CreateCheckoutSessionRequest']): Promise<components['schemas']['CheckoutSessionResponse']>;
563
2042
  createCustomerSession(params: components['schemas']['CreateCustomerSessionRequest']): Promise<components['schemas']['CreateCustomerSessionResponse']>;
564
2043
  }
565
2044
 
@@ -572,7 +2051,7 @@ interface SolvaPayClient {
572
2051
  * Arguments passed to protected handlers
573
2052
  */
574
2053
  interface PaywallArgs {
575
- [key: string]: any;
2054
+ [key: string]: unknown;
576
2055
  auth?: {
577
2056
  customer_ref?: string;
578
2057
  };
@@ -581,15 +2060,16 @@ interface PaywallArgs {
581
2060
  * Metadata for configuring paywall protection
582
2061
  */
583
2062
  interface PaywallMetadata {
584
- agent?: string;
2063
+ product?: string;
585
2064
  plan?: string;
2065
+ usageType?: 'requests' | 'tokens';
586
2066
  }
587
2067
  /**
588
2068
  * Structured content for paywall errors
589
2069
  */
590
2070
  interface PaywallStructuredContent {
591
2071
  kind: 'payment_required';
592
- agent: string;
2072
+ product: string;
593
2073
  checkoutUrl: string;
594
2074
  message: string;
595
2075
  }
@@ -651,21 +2131,25 @@ interface RetryOptions {
651
2131
  */
652
2132
  interface PayableOptions {
653
2133
  /**
654
- * Agent identifier (auto-detected from package.json if not provided)
2134
+ * Product identifier
655
2135
  */
656
- agent?: string;
2136
+ product?: string;
657
2137
  /**
658
- * Agent reference (alias for agent, preferred for consistency with backend API)
2138
+ * Product reference (alias for product, preferred for consistency with backend API)
659
2139
  */
660
- agentRef?: string;
2140
+ productRef?: string;
661
2141
  /**
662
- * Plan identifier (defaults to agent name if not provided)
2142
+ * Plan identifier (defaults to product name if not provided)
663
2143
  */
664
2144
  plan?: string;
665
2145
  /**
666
2146
  * Plan reference (alias for plan, preferred for consistency with backend API)
667
2147
  */
668
2148
  planRef?: string;
2149
+ /**
2150
+ * Usage meter type to charge against (defaults to 'requests')
2151
+ */
2152
+ usageType?: 'requests' | 'tokens';
669
2153
  /**
670
2154
  * Optional function to extract customer reference from context
671
2155
  */
@@ -737,93 +2221,325 @@ type ServerClientOptions = {
737
2221
  apiKey: string;
738
2222
  /**
739
2223
  * Base URL for the SolvaPay API (optional)
740
- * Defaults to https://api-dev.solvapay.com
2224
+ * Defaults to https://api.solvapay.com
741
2225
  */
742
2226
  apiBaseUrl?: string;
743
2227
  };
744
2228
  /**
745
- * Creates a SolvaPay API client that implements the full SolvaPayClient
746
- * for server-side paywall and usage tracking operations.
2229
+ * Creates a SolvaPay API client that implements the full SolvaPayClient interface.
747
2230
  *
748
- * @param opts - Configuration options including API key and optional base URL
2231
+ * This function creates a low-level API client for direct communication with the
2232
+ * SolvaPay backend. For most use cases, use `createSolvaPay()` instead, which
2233
+ * provides a higher-level API with paywall protection.
2234
+ *
2235
+ * Use this function when you need:
2236
+ * - Direct API access for custom operations
2237
+ * - Testing with custom client implementations
2238
+ * - Advanced use cases not covered by the main API
2239
+ *
2240
+ * @param opts - Configuration options
2241
+ * @param opts.apiKey - Your SolvaPay API key (required)
2242
+ * @param opts.apiBaseUrl - Optional API base URL override
749
2243
  * @returns A fully configured SolvaPayClient instance
750
2244
  * @throws {SolvaPayError} If API key is missing
751
2245
  *
752
2246
  * @example
753
2247
  * ```typescript
2248
+ * // Create API client directly
754
2249
  * const client = createSolvaPayClient({
755
2250
  * apiKey: process.env.SOLVAPAY_SECRET_KEY!,
756
2251
  * apiBaseUrl: 'https://api.solvapay.com' // optional
757
2252
  * });
2253
+ *
2254
+ * // Use client for custom operations
2255
+ * const products = await client.listProducts();
758
2256
  * ```
2257
+ *
2258
+ * @see {@link createSolvaPay} for the recommended high-level API
2259
+ * @see {@link ServerClientOptions} for configuration options
2260
+ * @since 1.0.0
759
2261
  */
760
2262
  declare function createSolvaPayClient(opts: ServerClientOptions): SolvaPayClient;
761
2263
 
762
2264
  /**
763
- * Configuration for creating a SolvaPay instance
2265
+ * Virtual Tools for MCP Server Monetization
2266
+ *
2267
+ * Provides the same self-service tools (get_user_info, upgrade, manage_account)
2268
+ * that hosted MCP Pay servers get automatically, but for SDK-integrated servers.
2269
+ * These tools are NOT usage-tracked and bypass the paywall.
2270
+ */
2271
+
2272
+ interface VirtualToolsOptions {
2273
+ /** Product reference (required) */
2274
+ product: string;
2275
+ /** Extract customer reference from MCP tool args */
2276
+ getCustomerRef: (args: Record<string, unknown>) => string;
2277
+ /** Tool names to exclude from registration (optional) */
2278
+ exclude?: string[];
2279
+ }
2280
+ interface VirtualToolDefinition {
2281
+ name: string;
2282
+ description: string;
2283
+ inputSchema: {
2284
+ type: 'object';
2285
+ properties: Record<string, object>;
2286
+ required: string[];
2287
+ };
2288
+ handler: (args: Record<string, unknown>) => Promise<{
2289
+ content: Array<{
2290
+ type: string;
2291
+ text: string;
2292
+ }>;
2293
+ isError?: boolean;
2294
+ }>;
2295
+ }
2296
+
2297
+ /**
2298
+ * Configuration for creating a SolvaPay instance.
2299
+ *
2300
+ * You can provide either an `apiKey` (for production) or an `apiClient` (for testing).
2301
+ * If neither is provided, the SDK will attempt to read `SOLVAPAY_SECRET_KEY` from
2302
+ * environment variables. If no API key is found, the SDK runs in stub mode.
2303
+ *
2304
+ * @example
2305
+ * ```typescript
2306
+ * // Production: Use API key
2307
+ * const config: CreateSolvaPayConfig = {
2308
+ * apiKey: process.env.SOLVAPAY_SECRET_KEY
2309
+ * };
2310
+ *
2311
+ * // Testing: Use mock client
2312
+ * const config: CreateSolvaPayConfig = {
2313
+ * apiClient: mockClient
2314
+ * };
2315
+ * ```
764
2316
  */
765
2317
  interface CreateSolvaPayConfig {
766
2318
  /**
767
- * API key for production use (creates client automatically)
2319
+ * API key for production use (creates client automatically).
2320
+ * Defaults to `SOLVAPAY_SECRET_KEY` environment variable if not provided.
768
2321
  */
769
2322
  apiKey?: string;
770
2323
  /**
771
- * API client for testing or custom implementations
2324
+ * API client for testing or custom implementations.
2325
+ * Use this for stub mode, testing, or custom client implementations.
772
2326
  */
773
2327
  apiClient?: SolvaPayClient;
774
2328
  /**
775
- * Optional API base URL (only used with apiKey)
2329
+ * Optional API base URL override (only used with apiKey).
2330
+ * Defaults to production API URL if not provided.
776
2331
  */
777
2332
  apiBaseUrl?: string;
2333
+ /**
2334
+ * TTL in ms for the checkLimits cache (default 10 000).
2335
+ * Positive results are cached and optimistically decremented to avoid
2336
+ * redundant API calls during tool-call bursts.
2337
+ */
2338
+ limitsCacheTTL?: number;
778
2339
  }
779
2340
  /**
780
- * Payable function that provides explicit adapters
2341
+ * Payable function that provides explicit adapters for different frameworks.
2342
+ *
2343
+ * Use the appropriate adapter method for your framework:
2344
+ * - `http()` - Express.js, Fastify, and other HTTP frameworks
2345
+ * - `next()` - Next.js App Router API routes
2346
+ * - `mcp()` - Model Context Protocol servers
2347
+ * - `function()` - Pure functions, background jobs, or testing
2348
+ *
2349
+ * @example
2350
+ * ```typescript
2351
+ * const payable = solvaPay.payable({ product: 'prd_myapi', plan: 'pln_premium' });
2352
+ *
2353
+ * // Express.js
2354
+ * app.post('/tasks', payable.http(createTask));
2355
+ *
2356
+ * // Next.js
2357
+ * export const POST = payable.next(createTask);
2358
+ *
2359
+ * // MCP Server
2360
+ * const handler = payable.mcp(createTask);
2361
+ *
2362
+ * // Pure function
2363
+ * const protectedFn = await payable.function(createTask);
2364
+ * ```
781
2365
  */
782
2366
  interface PayableFunction {
783
2367
  /**
784
- * HTTP adapter for Express/Fastify
2368
+ * HTTP adapter for Express.js, Fastify, and other HTTP frameworks.
2369
+ *
2370
+ * @param businessLogic - Your business logic function
2371
+ * @param options - Optional adapter configuration
2372
+ * @returns HTTP route handler function
2373
+ *
2374
+ * @example
2375
+ * ```typescript
2376
+ * app.post('/tasks', payable.http(async (req) => {
2377
+ * const { title } = req.body;
2378
+ * return { success: true, task: { title } };
2379
+ * }));
2380
+ * ```
785
2381
  */
786
- http<T = any>(businessLogic: (args: any) => Promise<T>, options?: HttpAdapterOptions): (req: any, reply: any) => Promise<any>;
2382
+ http<T = any>(businessLogic: (args: any) => Promise<T>, options?: HttpAdapterOptions): (req: any, reply: any) => Promise<unknown>;
787
2383
  /**
788
- * Next.js adapter for App Router
2384
+ * Next.js adapter for App Router API routes.
2385
+ *
2386
+ * @param businessLogic - Your business logic function
2387
+ * @param options - Optional adapter configuration
2388
+ * @returns Next.js route handler function
2389
+ *
2390
+ * @example
2391
+ * ```typescript
2392
+ * // app/api/tasks/route.ts
2393
+ * export const POST = payable.next(async (request) => {
2394
+ * const body = await request.json();
2395
+ * return Response.json({ success: true });
2396
+ * });
2397
+ * ```
789
2398
  */
790
2399
  next<T = any>(businessLogic: (args: any) => Promise<T>, options?: NextAdapterOptions): (request: Request, context?: any) => Promise<Response>;
791
2400
  /**
792
- * MCP adapter for Model Context Protocol servers
2401
+ * MCP adapter for Model Context Protocol servers.
2402
+ *
2403
+ * @param businessLogic - Your tool implementation function
2404
+ * @param options - Optional adapter configuration
2405
+ * @returns MCP tool handler function
2406
+ *
2407
+ * @example
2408
+ * ```typescript
2409
+ * const handler = payable.mcp(async (args) => {
2410
+ * return { success: true, result: 'tool output' };
2411
+ * });
2412
+ * ```
793
2413
  */
794
- mcp<T = any>(businessLogic: (args: any) => Promise<T>, options?: McpAdapterOptions): (args: any) => Promise<any>;
2414
+ mcp<T = any>(businessLogic: (args: any) => Promise<T>, options?: McpAdapterOptions): (args: Record<string, unknown>) => Promise<unknown>;
795
2415
  /**
796
- * Pure function adapter for direct function protection
797
- * Use this for testing, background jobs, or non-framework contexts
2416
+ * Pure function adapter for direct function protection.
2417
+ *
2418
+ * Use this for testing, background jobs, or non-framework contexts.
2419
+ *
2420
+ * @param businessLogic - Your business logic function
2421
+ * @returns Protected function that requires customer reference in args
2422
+ *
2423
+ * @example
2424
+ * ```typescript
2425
+ * const protectedFn = await payable.function(async (args) => {
2426
+ * return { result: 'processed' };
2427
+ * });
2428
+ *
2429
+ * // Call with customer reference
2430
+ * const result = await protectedFn({
2431
+ * auth: { customer_ref: 'user_123' },
2432
+ * // ... other args
2433
+ * });
2434
+ * ```
798
2435
  */
799
2436
  function<T = any>(businessLogic: (args: any) => Promise<T>): Promise<(args: any) => Promise<T>>;
800
2437
  }
801
2438
  /**
802
- * SolvaPay instance with payable method and common API methods
2439
+ * SolvaPay instance with payable method and common API methods.
2440
+ *
2441
+ * This interface provides the main API for interacting with SolvaPay.
2442
+ * Use `createSolvaPay()` to create an instance.
2443
+ *
2444
+ * @example
2445
+ * ```typescript
2446
+ * const solvaPay = createSolvaPay();
2447
+ *
2448
+ * // Create payable handlers
2449
+ * const payable = solvaPay.payable({ product: 'prd_myapi', plan: 'pln_premium' });
2450
+ *
2451
+ * // Manage customers
2452
+ * const customerRef = await solvaPay.ensureCustomer('user_123', 'user_123', {
2453
+ * email: 'user@example.com'
2454
+ * });
2455
+ *
2456
+ * // Create payment intents
2457
+ * const intent = await solvaPay.createPaymentIntent({
2458
+ * productRef: 'prd_myapi',
2459
+ * planRef: 'pln_premium',
2460
+ * customerRef: 'user_123'
2461
+ * });
2462
+ * ```
803
2463
  */
804
2464
  interface SolvaPay {
805
2465
  /**
806
- * Create a payable handler with explicit adapters
2466
+ * Create a payable handler with explicit adapters for different frameworks.
2467
+ *
2468
+ * @param options - Payable options including product and plan references
2469
+ * @returns PayableFunction with framework-specific adapters
2470
+ *
2471
+ * @example
2472
+ * ```typescript
2473
+ * const payable = solvaPay.payable({
2474
+ * product: 'prd_myapi',
2475
+ * plan: 'pln_premium'
2476
+ * });
2477
+ *
2478
+ * app.post('/tasks', payable.http(createTask));
2479
+ * ```
807
2480
  */
808
2481
  payable(options?: PayableOptions): PayableFunction;
809
2482
  /**
810
- * Ensure customer exists (for testing/setup)
811
- * Only attempts creation once per customer (idempotent).
2483
+ * Ensure customer exists in SolvaPay backend (idempotent).
812
2484
  *
813
- * @param customerRef - The customer reference (e.g., Supabase user ID)
814
- * @param externalRef - Optional external reference for backend lookup (e.g., Supabase user ID)
815
- * If provided, will lookup existing customer by externalRef before creating new one
816
- * @param options - Optional customer details (email, name) for customer creation
2485
+ * Creates a customer if they don't exist, or returns existing customer reference.
2486
+ * This is automatically called by the paywall system, but you can call it
2487
+ * explicitly for setup or testing.
2488
+ *
2489
+ * @param customerRef - The customer reference used as a cache key (e.g., Supabase user ID)
2490
+ * @param externalRef - Optional external reference for backend lookup (e.g., Supabase user ID).
2491
+ * If provided, will lookup existing customer by externalRef before creating new one.
2492
+ * The externalRef is stored on the SolvaPay backend for customer lookup.
2493
+ * @param options - Optional customer details for customer creation
2494
+ * @param options.email - Customer email address
2495
+ * @param options.name - Customer name
2496
+ * @returns Customer reference (backend customer ID)
2497
+ *
2498
+ * @example
2499
+ * ```typescript
2500
+ * // Ensure customer exists before processing payment
2501
+ * const customerRef = await solvaPay.ensureCustomer(
2502
+ * 'user_123', // customerRef (your user ID)
2503
+ * 'user_123', // externalRef (same or different)
2504
+ * {
2505
+ * email: 'user@example.com',
2506
+ * name: 'John Doe'
2507
+ * }
2508
+ * );
2509
+ * ```
817
2510
  */
818
2511
  ensureCustomer(customerRef: string, externalRef?: string, options?: {
819
2512
  email?: string;
820
2513
  name?: string;
821
2514
  }): Promise<string>;
822
2515
  /**
823
- * Create a payment intent for a customer to subscribe to a plan
2516
+ * Create a Stripe payment intent for a customer to purchase a plan.
2517
+ *
2518
+ * This creates a payment intent that can be confirmed on the client side
2519
+ * using Stripe.js. After confirmation, call `processPaymentIntent()` to complete
2520
+ * the purchase.
2521
+ *
2522
+ * @param params - Payment intent parameters
2523
+ * @param params.productRef - Product reference
2524
+ * @param params.planRef - Plan reference to purchase
2525
+ * @param params.customerRef - Customer reference
2526
+ * @param params.idempotencyKey - Optional idempotency key for retry safety
2527
+ * @returns Payment intent with client secret and publishable key
2528
+ *
2529
+ * @example
2530
+ * ```typescript
2531
+ * const intent = await solvaPay.createPaymentIntent({
2532
+ * productRef: 'prd_myapi',
2533
+ * planRef: 'pln_premium',
2534
+ * customerRef: 'user_123',
2535
+ * idempotencyKey: 'unique-key-123'
2536
+ * });
2537
+ *
2538
+ * // Use intent.clientSecret with Stripe.js on client
2539
+ * ```
824
2540
  */
825
2541
  createPaymentIntent(params: {
826
- agentRef: string;
2542
+ productRef: string;
827
2543
  planRef: string;
828
2544
  customerRef: string;
829
2545
  idempotencyKey?: string;
@@ -834,42 +2550,135 @@ interface SolvaPay {
834
2550
  accountId?: string;
835
2551
  }>;
836
2552
  /**
837
- * Process a payment intent after client-side confirmation
838
- * Creates subscription or purchase immediately, eliminating webhook delay
2553
+ * Process a payment intent after client-side Stripe confirmation.
2554
+ *
2555
+ * Creates the purchase immediately, eliminating webhook delay.
2556
+ * Call this after the client has confirmed the payment intent with Stripe.js.
2557
+ *
2558
+ * @param params - Payment processing parameters
2559
+ * @param params.paymentIntentId - Stripe payment intent ID from client confirmation
2560
+ * @param params.productRef - Product reference
2561
+ * @param params.customerRef - Customer reference
2562
+ * @param params.planRef - Optional plan reference (if not in payment intent)
2563
+ * @returns Payment processing result with purchase details
2564
+ *
2565
+ * @example
2566
+ * ```typescript
2567
+ * // After client confirms payment with Stripe.js
2568
+ * const result = await solvaPay.processPaymentIntent({
2569
+ * paymentIntentId: 'pi_1234567890',
2570
+ * productRef: 'prd_myapi',
2571
+ * customerRef: 'user_123',
2572
+ * planRef: 'pln_premium'
2573
+ * });
2574
+ *
2575
+ * if (result.success) {
2576
+ * console.log('Purchase created:', result.purchase);
2577
+ * }
2578
+ * ```
839
2579
  */
840
- processPayment(params: {
2580
+ processPaymentIntent(params: {
841
2581
  paymentIntentId: string;
842
- agentRef: string;
2582
+ productRef: string;
843
2583
  customerRef: string;
844
2584
  planRef?: string;
845
2585
  }): Promise<ProcessPaymentResult>;
846
2586
  /**
847
- * Check if customer is within usage limits
2587
+ * Check if customer is within usage limits for a product.
2588
+ *
2589
+ * This method checks purchase status and usage limits without
2590
+ * executing business logic. Use `payable()` for automatic protection.
2591
+ *
2592
+ * @param params - Limit check parameters
2593
+ * @param params.customerRef - Customer reference
2594
+ * @param params.productRef - Product reference
2595
+ * @returns Limit check result with remaining usage and checkout URL if needed
2596
+ *
2597
+ * @example
2598
+ * ```typescript
2599
+ * const limits = await solvaPay.checkLimits({
2600
+ * customerRef: 'user_123',
2601
+ * productRef: 'prd_myapi',
2602
+ * planRef: 'pln_premium'
2603
+ * });
2604
+ *
2605
+ * if (!limits.withinLimits) {
2606
+ * // Redirect to checkout
2607
+ * window.location.href = limits.checkoutUrl;
2608
+ * }
2609
+ * ```
848
2610
  */
849
2611
  checkLimits(params: {
850
2612
  customerRef: string;
851
- agentRef: string;
2613
+ productRef: string;
2614
+ planRef?: string;
2615
+ meterName?: 'requests' | 'tokens';
2616
+ usageType?: 'requests' | 'tokens';
852
2617
  }): Promise<{
853
2618
  withinLimits: boolean;
854
2619
  remaining: number;
855
2620
  plan: string;
856
2621
  checkoutUrl?: string;
2622
+ meterName?: string;
857
2623
  }>;
858
2624
  /**
859
- * Track usage for a customer action
2625
+ * Track usage for a customer action.
2626
+ *
2627
+ * This is automatically called by the paywall system. You typically
2628
+ * don't need to call this manually unless implementing custom tracking.
2629
+ *
2630
+ * @param params - Usage tracking parameters
2631
+ * @param params.customerRef - Customer reference
2632
+ * @param params.productRef - Product reference
2633
+ * @param params.planRef - Plan reference
2634
+ * @param params.outcome - Action outcome ('success', 'paywall', or 'fail')
2635
+ * @param params.action - Optional action name for analytics
2636
+ * @param params.requestId - Unique request ID
2637
+ * @param params.actionDuration - Action duration in milliseconds
2638
+ * @param params.timestamp - ISO timestamp of the action
2639
+ *
2640
+ * @example
2641
+ * ```typescript
2642
+ * await solvaPay.trackUsage({
2643
+ * customerRef: 'cus_3C4D5E6F',
2644
+ * actionType: 'api_call',
2645
+ * units: 1,
2646
+ * outcome: 'success',
2647
+ * metadata: { toolName: 'search', endpoint: '/search' },
2648
+ * });
2649
+ * ```
860
2650
  */
861
2651
  trackUsage(params: {
862
2652
  customerRef: string;
863
- agentRef: string;
864
- planRef: string;
865
- outcome: 'success' | 'paywall' | 'fail';
866
- action?: string;
867
- requestId: string;
868
- actionDuration: number;
869
- timestamp: string;
2653
+ actionType?: 'transaction' | 'api_call' | 'hour' | 'email' | 'storage' | 'custom';
2654
+ units?: number;
2655
+ outcome?: 'success' | 'paywall' | 'fail';
2656
+ productReference?: string;
2657
+ purchaseReference?: string;
2658
+ description?: string;
2659
+ metadata?: Record<string, unknown>;
2660
+ duration?: number;
2661
+ timestamp?: string;
2662
+ idempotencyKey?: string;
870
2663
  }): Promise<void>;
871
2664
  /**
872
- * Create a new customer
2665
+ * Create a new customer in SolvaPay backend.
2666
+ *
2667
+ * Note: `ensureCustomer()` is usually preferred as it's idempotent.
2668
+ * Use this only if you need explicit control over customer creation.
2669
+ *
2670
+ * @param params - Customer creation parameters
2671
+ * @param params.email - Customer email address (required)
2672
+ * @param params.name - Optional customer name
2673
+ * @returns Created customer reference
2674
+ *
2675
+ * @example
2676
+ * ```typescript
2677
+ * const { customerRef } = await solvaPay.createCustomer({
2678
+ * email: 'user@example.com',
2679
+ * name: 'John Doe'
2680
+ * });
2681
+ * ```
873
2682
  */
874
2683
  createCustomer(params: {
875
2684
  email: string;
@@ -878,58 +2687,162 @@ interface SolvaPay {
878
2687
  customerRef: string;
879
2688
  }>;
880
2689
  /**
881
- * Get customer details
2690
+ * Get customer details including purchases and usage.
2691
+ *
2692
+ * Returns full customer information from the SolvaPay backend, including
2693
+ * all active purchases, usage history, and customer metadata.
2694
+ *
2695
+ * @param params - Customer lookup parameters
2696
+ * @param params.customerRef - Optional customer reference (SolvaPay ID)
2697
+ * @param params.externalRef - Optional external reference (e.g., Supabase ID)
2698
+ * @returns Customer details with purchases and metadata
2699
+ *
2700
+ * @example
2701
+ * ```typescript
2702
+ * // Lookup by SolvaPay customer ID
2703
+ * const customer = await solvaPay.getCustomer({
2704
+ * customerRef: 'cust_123'
2705
+ * });
2706
+ *
2707
+ * // Lookup by external ID (e.g. Supabase user ID)
2708
+ * const customer = await solvaPay.getCustomer({
2709
+ * externalRef: 'user_123'
2710
+ * });
2711
+ * ```
882
2712
  */
883
2713
  getCustomer(params: {
884
- customerRef: string;
885
- }): Promise<{
886
- customerRef: string;
887
- email?: string;
888
- name?: string;
889
- plan?: string;
890
- subscriptions?: Array<{
891
- reference: string;
892
- planName: string;
893
- agentName: string;
894
- status: string;
895
- startDate: string;
896
- }>;
897
- }>;
2714
+ customerRef?: string;
2715
+ externalRef?: string;
2716
+ }): Promise<CustomerResponseMapped>;
898
2717
  /**
899
- * Create a checkout session for a customer
2718
+ * Create a hosted checkout session for a customer.
2719
+ *
2720
+ * This creates a Stripe Checkout session that redirects the customer
2721
+ * to a hosted payment page. After payment, customer is redirected back.
2722
+ *
2723
+ * @param params - Checkout session parameters
2724
+ * @param params.productRef - Product reference
2725
+ * @param params.customerRef - Customer reference
2726
+ * @param params.planRef - Optional plan reference (if not specified, shows plan selector)
2727
+ * @param params.returnUrl - URL to redirect to after successful payment
2728
+ * @returns Checkout session with redirect URL
2729
+ *
2730
+ * @example
2731
+ * ```typescript
2732
+ * const session = await solvaPay.createCheckoutSession({
2733
+ * productRef: 'prd_myapi',
2734
+ * customerRef: 'user_123',
2735
+ * planRef: 'pln_premium',
2736
+ * returnUrl: 'https://myapp.com/success'
2737
+ * });
2738
+ *
2739
+ * // Redirect customer to checkout
2740
+ * window.location.href = session.checkoutUrl;
2741
+ * ```
900
2742
  */
901
2743
  createCheckoutSession(params: {
902
- agentRef: string;
2744
+ productRef: string;
903
2745
  customerRef: string;
904
2746
  planRef?: string;
2747
+ returnUrl?: string;
905
2748
  }): Promise<{
906
2749
  sessionId: string;
907
2750
  checkoutUrl: string;
908
2751
  }>;
909
2752
  /**
910
- * Create a customer session for accessing customer-specific functionality
2753
+ * Create a customer portal session for managing purchases.
2754
+ *
2755
+ * This creates a Stripe Customer Portal session that allows customers
2756
+ * to manage their purchases, update payment methods, and view invoices.
2757
+ *
2758
+ * @param params - Customer session parameters
2759
+ * @param params.customerRef - Customer reference
2760
+ * @param params.productRef - Optional product reference for scoping portal view
2761
+ * @returns Customer portal session with redirect URL
2762
+ *
2763
+ * @example
2764
+ * ```typescript
2765
+ * const session = await solvaPay.createCustomerSession({
2766
+ * customerRef: 'user_123'
2767
+ * });
2768
+ *
2769
+ * // Redirect customer to portal
2770
+ * window.location.href = session.customerUrl;
2771
+ * ```
911
2772
  */
912
2773
  createCustomerSession(params: {
913
2774
  customerRef: string;
2775
+ productRef?: string;
914
2776
  }): Promise<{
915
2777
  sessionId: string;
916
2778
  customerUrl: string;
917
2779
  }>;
918
2780
  /**
919
- * Direct access to the API client for advanced operations
920
- * (agent/plan management, etc.)
2781
+ * Bootstrap an MCP-enabled product with plans and tool mappings.
2782
+ *
2783
+ * This helper wraps the backend orchestration endpoint and is intended for
2784
+ * fast setup flows where you want one call for product + plans + MCP config.
2785
+ */
2786
+ bootstrapMcpProduct(params: McpBootstrapRequest): Promise<McpBootstrapResponse>;
2787
+ /**
2788
+ * Get virtual tool definitions with bound handlers for MCP server integration.
2789
+ *
2790
+ * Returns an array of tool objects (name, description, inputSchema, handler)
2791
+ * that provide self-service capabilities: user info, upgrade, and account management.
2792
+ * These tools bypass the paywall and are not usage-tracked.
2793
+ *
2794
+ * Register the returned tools on your MCP server alongside your own tools.
2795
+ *
2796
+ * @param options - Virtual tools configuration
2797
+ * @param options.product - Product reference (required)
2798
+ * @param options.getCustomerRef - Function to extract customer ref from tool args
2799
+ * @param options.exclude - Optional list of tool names to exclude
2800
+ * @returns Array of virtual tool definitions with handlers
2801
+ *
2802
+ * @example
2803
+ * ```typescript
2804
+ * const virtualTools = solvaPay.getVirtualTools({
2805
+ * product: 'prd_myapi',
2806
+ * getCustomerRef: args => args._auth?.customer_ref || 'anonymous',
2807
+ * });
2808
+ *
2809
+ * // Register on your MCP server
2810
+ * for (const tool of virtualTools) {
2811
+ * // Add to tools/list and tools/call handlers
2812
+ * }
2813
+ * ```
2814
+ */
2815
+ getVirtualTools(options: VirtualToolsOptions): VirtualToolDefinition[];
2816
+ /**
2817
+ * Direct access to the API client for advanced operations.
2818
+ *
2819
+ * Use this for operations not exposed by the SolvaPay interface,
2820
+ * such as product/plan management or custom API calls.
2821
+ *
2822
+ * @example
2823
+ * ```typescript
2824
+ * // Access API client directly for custom operations
2825
+ * const products = await solvaPay.apiClient.listProducts();
2826
+ * ```
921
2827
  */
922
2828
  apiClient: SolvaPayClient;
923
2829
  }
924
2830
  /**
925
- * Create a SolvaPay instance
2831
+ * Create a SolvaPay instance with paywall protection capabilities.
2832
+ *
2833
+ * This factory function creates a SolvaPay instance that can be used to
2834
+ * protect API endpoints, functions, and MCP tools with usage limits and
2835
+ * purchase checks.
926
2836
  *
927
- * @param config - Optional configuration with either apiKey or apiClient. If not provided, reads from environment variables.
928
- * @returns SolvaPay instance with payable() method
2837
+ * @param config - Optional configuration object
2838
+ * @param config.apiKey - API key for production use (defaults to `SOLVAPAY_SECRET_KEY` env var)
2839
+ * @param config.apiClient - Custom API client for testing or advanced use cases
2840
+ * @param config.apiBaseUrl - Optional API base URL override
2841
+ * @returns SolvaPay instance with payable() method and API client access
929
2842
  *
930
2843
  * @example
931
2844
  * ```typescript
932
- * // Production: Read from environment variables (recommended)
2845
+ * // Production: Use environment variable (recommended)
933
2846
  * const solvaPay = createSolvaPay();
934
2847
  *
935
2848
  * // Production: Pass API key explicitly
@@ -937,16 +2850,26 @@ interface SolvaPay {
937
2850
  * apiKey: process.env.SOLVAPAY_SECRET_KEY
938
2851
  * });
939
2852
  *
940
- * // Testing: Pass mock client
2853
+ * // Testing: Use mock client
941
2854
  * const solvaPay = createSolvaPay({
942
2855
  * apiClient: mockClient
943
2856
  * });
944
2857
  *
945
- * // Create payable handlers
946
- * const payable = solvaPay.payable({ agent: 'my-api' });
947
- * app.post('/tasks', payable.http(createTask));
948
- * export const POST = payable.next(createTask);
2858
+ * // Create payable handlers for your product
2859
+ * const payable = solvaPay.payable({
2860
+ * product: 'prd_myapi',
2861
+ * plan: 'pln_premium'
2862
+ * });
2863
+ *
2864
+ * // Protect endpoints with framework-specific adapters
2865
+ * app.post('/tasks', payable.http(createTask)); // Express/Fastify
2866
+ * export const POST = payable.next(createTask); // Next.js App Router
2867
+ * const handler = payable.mcp(createTask); // MCP servers
949
2868
  * ```
2869
+ *
2870
+ * @see {@link SolvaPay} for the returned instance interface
2871
+ * @see {@link CreateSolvaPayConfig} for configuration options
2872
+ * @since 1.0.0
950
2873
  */
951
2874
  declare function createSolvaPay(config?: CreateSolvaPayConfig): SolvaPay;
952
2875
 
@@ -959,8 +2882,48 @@ declare function createSolvaPay(config?: CreateSolvaPayConfig): SolvaPay;
959
2882
  * - Class-based and functional programming
960
2883
  */
961
2884
 
2885
+ /**
2886
+ * Error thrown when a paywall is triggered (purchase required or usage limit exceeded).
2887
+ *
2888
+ * This error is automatically thrown by the paywall protection system when:
2889
+ * - Customer doesn't have required purchase
2890
+ * - Customer has exceeded usage limits
2891
+ * - Customer needs to upgrade their plan
2892
+ *
2893
+ * The error includes structured content with checkout URLs and metadata for
2894
+ * building custom paywall UIs.
2895
+ *
2896
+ * @example
2897
+ * ```typescript
2898
+ * import { PaywallError } from '@solvapay/server';
2899
+ *
2900
+ * try {
2901
+ * const result = await payable.http(createTask)(req, res);
2902
+ * return result;
2903
+ * } catch (error) {
2904
+ * if (error instanceof PaywallError) {
2905
+ * // Custom paywall handling
2906
+ * return res.status(402).json({
2907
+ * error: error.message,
2908
+ * checkoutUrl: error.structuredContent.checkoutUrl,
2909
+ * // Additional metadata available in error.structuredContent
2910
+ * });
2911
+ * }
2912
+ * throw error;
2913
+ * }
2914
+ * ```
2915
+ *
2916
+ * @see {@link PaywallStructuredContent} for the structured content format
2917
+ * @since 1.0.0
2918
+ */
962
2919
  declare class PaywallError extends Error {
963
2920
  structuredContent: PaywallStructuredContent;
2921
+ /**
2922
+ * Creates a new PaywallError instance.
2923
+ *
2924
+ * @param message - Error message
2925
+ * @param structuredContent - Structured content with checkout URLs and metadata
2926
+ */
964
2927
  constructor(message: string, structuredContent: PaywallStructuredContent);
965
2928
  }
966
2929
 
@@ -969,19 +2932,28 @@ declare class PaywallError extends Error {
969
2932
  */
970
2933
 
971
2934
  /**
972
- * Executes an async function with automatic retry logic
2935
+ * Execute an async function with automatic retry logic.
2936
+ *
2937
+ * This utility function provides configurable retry logic with exponential backoff,
2938
+ * conditional retry logic, and retry callbacks. Useful for handling transient
2939
+ * network errors or rate limiting.
973
2940
  *
974
2941
  * @template T The return type of the async function
975
2942
  * @param fn The async function to execute
976
2943
  * @param options Retry configuration options
2944
+ * @param options.maxRetries - Maximum number of retry attempts (default: 2)
2945
+ * @param options.initialDelay - Initial delay in milliseconds before first retry (default: 500)
2946
+ * @param options.backoffStrategy - Backoff strategy: 'fixed', 'linear', or 'exponential' (default: 'fixed')
2947
+ * @param options.shouldRetry - Optional function to determine if error should be retried
2948
+ * @param options.onRetry - Optional callback called before each retry attempt
977
2949
  * @returns A promise that resolves with the function result or rejects with the last error
978
2950
  *
979
2951
  * @example
980
2952
  * ```typescript
981
- * // Simple retry with defaults
2953
+ * // Simple retry with defaults (2 retries, 500ms delay)
982
2954
  * const result = await withRetry(() => apiCall());
983
2955
  *
984
- * // Custom retry with conditional logic
2956
+ * // Custom retry with exponential backoff
985
2957
  * const result = await withRetry(
986
2958
  * () => apiCall(),
987
2959
  * {
@@ -993,40 +2965,337 @@ declare class PaywallError extends Error {
993
2965
  * }
994
2966
  * );
995
2967
  * ```
2968
+ *
2969
+ * @since 1.0.0
996
2970
  */
997
2971
  declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
998
2972
 
999
2973
  /**
1000
- * SolvaPay Server SDK - Edge Runtime Entry Point
2974
+ * Helper Types
1001
2975
  *
1002
- * This module provides edge runtime-compatible exports using Web Crypto API.
1003
- * Automatically selected when running in edge runtimes (Vercel Edge, Cloudflare Workers, Deno, etc.)
2976
+ * Shared types for route helpers
2977
+ */
2978
+ /**
2979
+ * Error result returned by core helpers
2980
+ */
2981
+ interface ErrorResult {
2982
+ error: string;
2983
+ status: number;
2984
+ details?: string;
2985
+ }
2986
+ /**
2987
+ * Authenticated user information
2988
+ */
2989
+ interface AuthenticatedUser {
2990
+ userId: string;
2991
+ email?: string | null;
2992
+ name?: string | null;
2993
+ }
2994
+
2995
+ /**
2996
+ * Error Handling Helper
2997
+ *
2998
+ * Generic error handling utilities for route helpers
2999
+ */
3000
+
3001
+ /**
3002
+ * Check if a result is an error result
3003
+ */
3004
+ declare function isErrorResult(result: unknown): result is ErrorResult;
3005
+ /**
3006
+ * Handle route errors and convert to ErrorResult
3007
+ */
3008
+ declare function handleRouteError(error: unknown, operationName: string, defaultMessage?: string): ErrorResult;
3009
+
3010
+ /**
3011
+ * Authentication Helper (Core)
3012
+ *
3013
+ * Generic helper for extracting authenticated user information from requests.
3014
+ * Works with standard Web API Request (works everywhere).
3015
+ */
3016
+
3017
+ /**
3018
+ * Extract authenticated user information from a standard Web API Request.
3019
+ *
3020
+ * This is a generic, framework-agnostic helper that extracts user ID, email,
3021
+ * and name from authenticated requests. Works with any framework that uses
3022
+ * the standard Web API Request (Express, Fastify, Next.js, Edge Functions, etc.).
3023
+ *
3024
+ * Uses dynamic imports to avoid requiring @solvapay/auth at build time,
3025
+ * making it suitable for edge runtime environments.
3026
+ *
3027
+ * @param request - Standard Web API Request object
3028
+ * @param options - Configuration options
3029
+ * @param options.includeEmail - Whether to extract email from JWT token (default: true)
3030
+ * @param options.includeName - Whether to extract name from JWT token (default: true)
3031
+ * @returns Authenticated user info or error result
3032
+ *
3033
+ * @example
3034
+ * ```typescript
3035
+ * // In an API route handler
3036
+ * export async function GET(request: Request) {
3037
+ * const userResult = await getAuthenticatedUserCore(request);
3038
+ *
3039
+ * if (isErrorResult(userResult)) {
3040
+ * return Response.json(userResult, { status: userResult.status });
3041
+ * }
3042
+ *
3043
+ * const { userId, email, name } = userResult;
3044
+ * // Use user info...
3045
+ * }
3046
+ * ```
3047
+ *
3048
+ * @see {@link AuthenticatedUser} for the return type
3049
+ * @see {@link ErrorResult} for error handling
3050
+ * @since 1.0.0
3051
+ */
3052
+ declare function getAuthenticatedUserCore(request: Request, options?: {
3053
+ includeEmail?: boolean;
3054
+ includeName?: boolean;
3055
+ }): Promise<AuthenticatedUser | ErrorResult>;
3056
+
3057
+ /**
3058
+ * Customer Helper (Core)
3059
+ *
3060
+ * Generic helper for syncing customers with SolvaPay backend.
3061
+ * Works with standard Web API Request (works everywhere).
3062
+ */
3063
+
3064
+ /**
3065
+ * Sync customer with SolvaPay backend (ensure customer exists).
3066
+ *
3067
+ * This helper ensures a customer exists in the SolvaPay backend by:
3068
+ * 1. Extracting authenticated user information from the request
3069
+ * 2. Creating or retrieving the customer using the user ID as external reference
3070
+ * 3. Syncing customer data (email, name) if provided
3071
+ *
3072
+ * Uses `externalRef` for consistent lookup and prevents duplicate customers.
3073
+ * The returned customer reference is the SolvaPay backend customer ID.
3074
+ *
3075
+ * @param request - Standard Web API Request object
3076
+ * @param options - Configuration options
3077
+ * @param options.solvaPay - Optional SolvaPay instance (creates new one if not provided)
3078
+ * @param options.includeEmail - Whether to include email in customer data (default: true)
3079
+ * @param options.includeName - Whether to include name in customer data (default: true)
3080
+ * @returns Customer reference (backend customer ID) or error result
3081
+ *
3082
+ * @example
3083
+ * ```typescript
3084
+ * // In an API route handler
3085
+ * export async function POST(request: Request) {
3086
+ * const customerResult = await syncCustomerCore(request);
3087
+ *
3088
+ * if (isErrorResult(customerResult)) {
3089
+ * return Response.json(customerResult, { status: customerResult.status });
3090
+ * }
3091
+ *
3092
+ * const customerRef = customerResult;
3093
+ * // Use customer reference...
3094
+ * }
3095
+ * ```
3096
+ *
3097
+ * @see {@link getAuthenticatedUserCore} for user extraction
3098
+ * @see {@link ErrorResult} for error handling
3099
+ * @since 1.0.0
1004
3100
  */
3101
+ declare function syncCustomerCore(request: Request, options?: {
3102
+ solvaPay?: SolvaPay;
3103
+ includeEmail?: boolean;
3104
+ includeName?: boolean;
3105
+ }): Promise<string | ErrorResult>;
1005
3106
 
1006
3107
  /**
1007
- * Verify webhook signature using edge-compatible Web Crypto API
1008
- * Works in: Vercel Edge Functions, Cloudflare Workers, Deno, Supabase Edge Functions
3108
+ * Create a Stripe payment intent for a customer to purchase a plan.
3109
+ *
3110
+ * This is a framework-agnostic helper that:
3111
+ * 1. Extracts authenticated user from the request
3112
+ * 2. Syncs customer with SolvaPay backend
3113
+ * 3. Creates a payment intent for the specified plan
3114
+ *
3115
+ * The payment intent can then be confirmed on the client side using Stripe.js.
3116
+ * After confirmation, use `processPaymentIntentCore()` to complete the purchase.
3117
+ *
3118
+ * @param request - Standard Web API Request object
3119
+ * @param body - Payment intent parameters
3120
+ * @param body.planRef - Plan reference to purchase (required)
3121
+ * @param body.productRef - Product reference (required)
3122
+ * @param options - Configuration options
3123
+ * @param options.solvaPay - Optional SolvaPay instance (creates new one if not provided)
3124
+ * @param options.includeEmail - Whether to include email in customer data (default: true)
3125
+ * @param options.includeName - Whether to include name in customer data (default: true)
3126
+ * @returns Payment intent response with client secret and customer reference, or error result
3127
+ *
3128
+ * @example
3129
+ * ```typescript
3130
+ * // In an API route handler
3131
+ * export async function POST(request: Request) {
3132
+ * const body = await request.json();
3133
+ * const result = await createPaymentIntentCore(request, body);
3134
+ *
3135
+ * if (isErrorResult(result)) {
3136
+ * return Response.json(result, { status: result.status });
3137
+ * }
3138
+ *
3139
+ * return Response.json(result);
3140
+ * }
3141
+ * ```
3142
+ *
3143
+ * @see {@link processPaymentIntentCore} for processing confirmed payments
3144
+ * @see {@link ErrorResult} for error handling
3145
+ * @since 1.0.0
3146
+ */
3147
+ declare function createPaymentIntentCore(request: Request, body: {
3148
+ planRef: string;
3149
+ productRef: string;
3150
+ }, options?: {
3151
+ solvaPay?: SolvaPay;
3152
+ includeEmail?: boolean;
3153
+ includeName?: boolean;
3154
+ }): Promise<{
3155
+ id: string;
3156
+ clientSecret: string;
3157
+ publishableKey: string;
3158
+ accountId?: string;
3159
+ customerRef: string;
3160
+ } | ErrorResult>;
3161
+ /**
3162
+ * Process a payment intent after client-side Stripe confirmation.
3163
+ *
3164
+ * This helper processes a payment intent that has been confirmed on the client
3165
+ * side using Stripe.js. It creates the purchase immediately,
3166
+ * eliminating webhook delay.
3167
+ *
3168
+ * Call this after the client has confirmed the payment intent with Stripe.js.
1009
3169
  *
1010
- * @param body - The raw webhook request body (string)
1011
- * @param signature - The signature from x-solvapay-signature header
1012
- * @param secret - Your webhook secret key
1013
- * @returns Parsed webhook event object
1014
- * @throws {SolvaPayError} If signature verification fails
3170
+ * @param request - Standard Web API Request object
3171
+ * @param body - Payment processing parameters
3172
+ * @param body.paymentIntentId - Stripe payment intent ID from client confirmation (required)
3173
+ * @param body.productRef - Product reference (required)
3174
+ * @param body.planRef - Optional plan reference (if not in payment intent)
3175
+ * @param options - Configuration options
3176
+ * @param options.solvaPay - Optional SolvaPay instance (creates new one if not provided)
3177
+ * @returns Process payment result with purchase details, or error result
1015
3178
  *
1016
3179
  * @example
1017
3180
  * ```typescript
1018
- * // Supabase Edge Function
1019
- * import { verifyWebhook } from '@solvapay/server';
3181
+ * // In an API route handler
3182
+ * export async function POST(request: Request) {
3183
+ * const body = await request.json();
3184
+ * const result = await processPaymentIntentCore(request, body);
1020
3185
  *
1021
- * const signature = req.headers.get('x-solvapay-signature');
1022
- * const body = await req.text();
1023
- * const event = await verifyWebhook({ body, signature, secret });
3186
+ * if (isErrorResult(result)) {
3187
+ * return Response.json(result, { status: result.status });
3188
+ * }
3189
+ *
3190
+ * return Response.json(result);
3191
+ * }
1024
3192
  * ```
3193
+ *
3194
+ * @see {@link createPaymentIntentCore} for creating payment intents
3195
+ * @see {@link ErrorResult} for error handling
3196
+ * @since 1.0.0
3197
+ */
3198
+ declare function processPaymentIntentCore(request: Request, body: {
3199
+ paymentIntentId: string;
3200
+ productRef: string;
3201
+ planRef?: string;
3202
+ }, options?: {
3203
+ solvaPay?: SolvaPay;
3204
+ }): Promise<ProcessPaymentResult | ErrorResult>;
3205
+
3206
+ /**
3207
+ * Checkout Helpers (Core)
3208
+ *
3209
+ * Generic helpers for checkout session operations.
3210
+ * Works with standard Web API Request (works everywhere).
1025
3211
  */
1026
- declare function verifyWebhook({ body, signature, secret }: {
3212
+
3213
+ /**
3214
+ * Create checkout session - core implementation
3215
+ *
3216
+ * @param request - Standard Web API Request
3217
+ * @param body - Checkout session parameters
3218
+ * @param options - Configuration options
3219
+ * @returns Checkout session response or error result
3220
+ */
3221
+ declare function createCheckoutSessionCore(request: Request, body: {
3222
+ productRef: string;
3223
+ planRef?: string;
3224
+ returnUrl?: string;
3225
+ }, options?: {
3226
+ solvaPay?: SolvaPay;
3227
+ includeEmail?: boolean;
3228
+ includeName?: boolean;
3229
+ returnUrl?: string;
3230
+ }): Promise<{
3231
+ sessionId: string;
3232
+ checkoutUrl: string;
3233
+ } | ErrorResult>;
3234
+ /**
3235
+ * Create customer session - core implementation
3236
+ *
3237
+ * @param request - Standard Web API Request
3238
+ * @param options - Configuration options
3239
+ * @returns Customer session response or error result
3240
+ */
3241
+ declare function createCustomerSessionCore(request: Request, options?: {
3242
+ solvaPay?: SolvaPay;
3243
+ includeEmail?: boolean;
3244
+ includeName?: boolean;
3245
+ }): Promise<{
3246
+ sessionId: string;
3247
+ customerUrl: string;
3248
+ } | ErrorResult>;
3249
+
3250
+ /**
3251
+ * Purchase Cancellation Helpers (Core)
3252
+ *
3253
+ * Generic helpers for purchase cancellation operations.
3254
+ * Works with standard Web API Request (works everywhere).
3255
+ */
3256
+
3257
+ /**
3258
+ * Cancel purchase - core implementation
3259
+ *
3260
+ * @param request - Standard Web API Request
3261
+ * @param body - Cancellation parameters
3262
+ * @param options - Configuration options
3263
+ * @returns Cancelled purchase response or error result
3264
+ */
3265
+ declare function cancelPurchaseCore(request: Request, body: {
3266
+ purchaseRef: string;
3267
+ reason?: string;
3268
+ }, options?: {
3269
+ solvaPay?: SolvaPay;
3270
+ }): Promise<Record<string, unknown> | ErrorResult>;
3271
+
3272
+ /**
3273
+ * Plans Helper (Core)
3274
+ *
3275
+ * Generic helper for listing plans.
3276
+ * Works with standard Web API Request (works everywhere).
3277
+ * This is a public route - no authentication required.
3278
+ */
3279
+
3280
+ /**
3281
+ * List plans - core implementation
3282
+ */
3283
+ declare function listPlansCore(request: Request): Promise<{
3284
+ plans: Record<string, unknown>[];
3285
+ productRef: string;
3286
+ } | ErrorResult>;
3287
+
3288
+ /**
3289
+ * SolvaPay Server SDK - Edge Runtime Entry Point
3290
+ *
3291
+ * This module provides edge runtime-compatible exports using Web Crypto API.
3292
+ * Automatically selected when running in edge runtimes (Vercel Edge, Cloudflare Workers, Deno, etc.)
3293
+ */
3294
+
3295
+ declare function verifyWebhook({ body, signature, secret, }: {
1027
3296
  body: string;
1028
3297
  signature: string;
1029
3298
  secret: string;
1030
- }): Promise<any>;
3299
+ }): Promise<WebhookEvent>;
1031
3300
 
1032
- export { type CreateSolvaPayConfig, type HttpAdapterOptions, type McpAdapterOptions, type NextAdapterOptions, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type RetryOptions, type ServerClientOptions, type SolvaPay, type SolvaPayClient, createSolvaPay, createSolvaPayClient, verifyWebhook, withRetry };
3301
+ export { type AuthenticatedUser, type CreateSolvaPayConfig, type ErrorResult, type HttpAdapterOptions, type McpAdapterOptions, type NextAdapterOptions, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type RetryOptions, type ServerClientOptions, type SolvaPay, type SolvaPayClient, type WebhookEvent, type WebhookEventType, cancelPurchaseCore, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, getAuthenticatedUserCore, handleRouteError, isErrorResult, listPlansCore, processPaymentIntentCore, syncCustomerCore, verifyWebhook, withRetry };