@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/index.d.cts 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;
85
+ customerReference: string;
86
+ /**
87
+ * Plan reference (optional)
88
+ * @example pln_2b3c4d5e6f7g
89
+ */
90
+ planRef?: string;
91
+ /**
92
+ * Product reference (required)
93
+ * @example prd_1a2b3c4d5e6f
94
+ */
95
+ productRef: string;
96
+ };
97
+ CheckoutSessionResponse: {
98
+ /**
99
+ * Checkout session ID
100
+ * @example 507f1f77bcf86cd799439011
101
+ */
102
+ id: string;
103
+ /**
104
+ * Public session ID used in checkout URL
105
+ * @example a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
106
+ */
107
+ sessionId: string;
108
+ /**
109
+ * Amount in cents
110
+ * @example 2999
111
+ */
112
+ amount: number;
113
+ /**
114
+ * Currency code
115
+ * @example USD
116
+ */
117
+ currency: string;
118
+ /**
119
+ * Session status
120
+ * @example active
121
+ */
122
+ status: string;
123
+ /**
124
+ * Checkout URL to open the checkout page
125
+ * @example https://solvapay.com/customer/checkout?id=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
126
+ */
127
+ checkoutUrl: string;
128
+ };
129
+ SelectCustomerSessionProductRequest: {
130
+ /**
131
+ * Product reference or ID to scope the customer manage session
132
+ * @example prd_1a2b3c4d5e6f
133
+ */
134
+ productRef: string;
135
+ };
136
+ CancelRenewalRequest: {
137
+ /** @description Reason for cancelling renewal */
138
+ reason?: string;
139
+ };
140
+ ExternalAccount: {
141
+ /**
142
+ * Country code
143
+ * @example US
144
+ */
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;
167
+ /**
168
+ * Account number
169
+ * @example 000123456789
170
+ */
171
+ accountNumber: string;
172
+ };
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;
382
+ /**
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
412
+ * @example true
413
+ */
414
+ requiresPayment: boolean;
415
+ /**
416
+ * Whether the plan is active (derived from status)
417
+ * @example true
418
+ */
419
+ isActive: boolean;
420
+ /** @description Maximum number of active users */
421
+ maxActiveUsers?: number;
422
+ /** @description Access expiry in days */
423
+ accessExpiryDays?: number;
424
+ /**
425
+ * Plan status
426
+ * @example active
427
+ */
428
+ status: string;
429
+ /** @description Creation timestamp */
430
+ createdAt: string;
431
+ /** @description Last update timestamp */
432
+ updatedAt: string;
433
+ };
434
+ CreatePlanRequest: {
435
+ /**
436
+ * Plan type exposed in SDK
437
+ * @example recurring
438
+ * @enum {string}
439
+ */
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;
522
+ };
523
+ UpdatePlanRequest: {
524
+ /**
525
+ * Billing cycle
526
+ * @example monthly
527
+ * @enum {string}
528
+ */
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;
977
+ /**
978
+ * Optional auth header name forwarded to origin server
979
+ * @example X-API-Key
980
+ */
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;
1118
+ /**
1119
+ * Optional product reference or ID to scope the customer manage page to a single product.
1120
+ * @example prd_1a2b3c4d5e6f
1121
+ */
1122
+ productRef?: string;
1123
+ };
1124
+ CustomerSessionResponse: {
1125
+ /**
1126
+ * Customer session ID
1127
+ * @example 507f1f77bcf86cd799439011
1128
+ */
1129
+ id: string;
1130
+ /**
1131
+ * Public session ID used in customer URL
1132
+ * @example e3f1c2d4b6a89f001122334455667788
1133
+ */
1134
+ sessionId: string;
1135
+ /**
1136
+ * Session status
1137
+ * @example active
1138
+ */
1139
+ status: string;
1140
+ /**
1141
+ * Customer URL to open the customer page
1142
+ * @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
1143
+ */
1144
+ customerUrl: string;
1145
+ };
1146
+ CreateCustomerRequest: {
1147
+ /**
1148
+ * Customer email address (required)
1149
+ * @example customer@example.com
1150
+ */
1151
+ email: string;
1152
+ /**
1153
+ * Customer full name (optional)
1154
+ * @example John Doe
1155
+ */
1156
+ name?: string;
1157
+ /**
1158
+ * External reference ID from your auth system to map this customer to an auth user (optional)
1159
+ * @example auth_user_12345
1160
+ */
1161
+ externalRef?: string;
1162
+ };
1163
+ PurchaseInfo: {
1164
+ /**
1165
+ * Purchase reference
1166
+ * @example pur_1A2B3C4D
1167
+ */
1168
+ reference: string;
1169
+ /**
1170
+ * Product name
1171
+ * @example API Gateway Manager
1172
+ */
1173
+ productName: string;
1174
+ /**
1175
+ * Product reference
1176
+ * @example prd_abc123
1177
+ */
1178
+ productReference?: string;
1179
+ /**
1180
+ * Purchase status
1181
+ * @example active
1182
+ */
1183
+ status: string;
1184
+ /**
1185
+ * Start date
1186
+ * @example 2025-10-27T10:00:00Z
1187
+ */
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>;
1216
+ };
1217
+ CustomerResponse: {
1218
+ /**
1219
+ * Customer reference identifier
1220
+ * @example cus_3c4d5e6f7g8h
1221
+ */
1222
+ reference: string;
1223
+ /**
1224
+ * Customer full name
1225
+ * @example John Doe
1226
+ */
1227
+ name: string;
1228
+ /**
1229
+ * Customer email address
1230
+ * @example customer@example.com
1231
+ */
1232
+ email: string;
1233
+ /**
1234
+ * External reference ID from your auth system (if set during creation or update)
1235
+ * @example auth_user_12345
1236
+ */
1237
+ externalRef?: string;
1238
+ /** @description Active purchases */
1239
+ purchases?: components["schemas"]["PurchaseInfo"][];
1240
+ };
1241
+ CreateCustomerSessionResponse: {
1242
+ /**
1243
+ * Customer session ID/token
1244
+ * @example e3f1c2d4b6a89f001122334455667788
1245
+ */
1246
+ sessionId: string;
1247
+ /**
1248
+ * Full customer URL based on backend configuration (ready to redirect customer)
1249
+ * @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
1250
+ */
1251
+ customerUrl: string;
1252
+ };
1253
+ GetCustomerSessionResponse: {
1254
+ /**
1255
+ * Customer session ID/token
1256
+ * @example e3f1c2d4b6a89f001122334455667788
1257
+ */
1258
+ sessionId: string;
1259
+ /**
1260
+ * Session status
1261
+ * @example active
1262
+ * @enum {string}
1263
+ */
1264
+ status: "active" | "expired" | "used";
1265
+ /**
1266
+ * Full customer URL based on backend configuration (ready to redirect customer)
1267
+ * @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
1268
+ */
1269
+ customerUrl: string;
1270
+ /**
1271
+ * Session expiration date
1272
+ * @example 2025-01-01T12:00:00.000Z
1273
+ */
1274
+ expiresAt: string;
1275
+ /** @description Customer object from session data */
1276
+ customer: components["schemas"]["CustomerResponse"];
1277
+ /**
1278
+ * Session creation date
1279
+ * @example 2025-01-01T11:45:00.000Z
1280
+ */
1281
+ createdAt: string;
31
1282
  /**
32
- * @description Agent reference identifier
33
- * @example agt_1a2b3c4d5e6f
1283
+ * Session last update date
1284
+ * @example 2025-01-01T11:45:00.000Z
34
1285
  */
35
- agentRef: string;
1286
+ updatedAt: string;
1287
+ };
1288
+ UserInfoRequest: {
36
1289
  /**
37
- * @description Plan reference identifier (optional)
38
- * @example pln_2b3c4d5e6f7g
1290
+ * Customer reference
1291
+ * @example cus_3C4D5E6F
39
1292
  */
40
- planRef?: string;
1293
+ customerRef: string;
41
1294
  /**
42
- * @description URL to redirect to after successful payment (optional)
43
- * @example https://example.com/payment-success
1295
+ * Product reference
1296
+ * @example prd_1A2B3C4D
44
1297
  */
45
- returnUrl?: string;
1298
+ productRef: string;
46
1299
  };
47
- CheckoutSessionResponse: {
1300
+ UserInfoUserDto: {
1301
+ /** @example cus_3C4D5E6F */
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;
48
1317
  /**
49
- * @description Checkout session ID
1318
+ * Meter ObjectId reference
50
1319
  * @example 507f1f77bcf86cd799439011
51
1320
  */
52
- id: string;
53
- /**
54
- * @description Public session ID used in checkout URL
55
- * @example a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
56
- */
57
- sessionId: string;
1321
+ meterId?: string;
1322
+ /** @example 25 */
1323
+ percentUsed?: number | null;
1324
+ };
1325
+ UserInfoPlanDto: {
1326
+ /** @example pln_2B3C4D5E */
1327
+ reference: string;
58
1328
  /**
59
- * @description Amount in cents
1329
+ * Price in minor currency units (e.g. cents)
60
1330
  * @example 2999
61
1331
  */
62
- amount: number;
63
- /**
64
- * @description Currency code
65
- * @example USD
66
- */
1332
+ price: number;
1333
+ /** @example USD */
67
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: {
68
1361
  /**
69
- * @description Session status
70
- * @example active
1362
+ * Human-readable status summary
1363
+ * @example Active subscription: My API Product (25% usage consumed)
71
1364
  */
72
1365
  status: string;
73
1366
  /**
74
- * @description Checkout URL to open the checkout page
75
- * @example https://solvapay.com/customer/checkout?id=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
1367
+ * Customer portal session URL
1368
+ * @example https://solvapay.com/customer/manage?id=abc123
76
1369
  */
77
- checkoutUrl: string;
1370
+ verifyUrl?: string | null;
1371
+ user?: components["schemas"]["UserInfoUserDto"];
1372
+ purchase?: components["schemas"]["UserInfoPurchaseDto"];
78
1373
  };
79
- CancelSubscriptionRequest: {
1374
+ McpToolDto: {
80
1375
  /**
81
- * @description Reason for cancellation
82
- * @example Customer request
1376
+ * Tool name
1377
+ * @example search_documents
83
1378
  */
84
- reason?: string;
85
- };
86
- CheckLimitRequest: {
1379
+ name: string;
87
1380
  /**
88
- * @description Customer reference identifier
89
- * @example cus_3c4d5e6f7g8h
1381
+ * Plan IDs that grant access to this tool
1382
+ * @example [
1383
+ * "pln_abc123"
1384
+ * ]
90
1385
  */
91
- customerRef: string;
1386
+ planIds?: string[];
92
1387
  /**
93
- * @description Agent reference identifier
94
- * @example agt_1a2b3c4d5e6f
1388
+ * If true, the tool is unprotected (no purchase check or usage tracking)
1389
+ * @example false
95
1390
  */
96
- agentRef: string;
97
- };
98
- LimitResponse: {
1391
+ noPlan?: boolean;
99
1392
  /**
100
- * @description Whether the customer is within their usage limits
101
- * @example true
1393
+ * Human-readable tool description
1394
+ * @example Search indexed documents
102
1395
  */
103
- withinLimits: boolean;
1396
+ description?: string;
104
1397
  /**
105
- * @description Remaining usage units before hitting the limit
106
- * @example 997
1398
+ * Whether this is a virtual platform tool handled by SolvaPay
1399
+ * @example false
107
1400
  */
108
- remaining: number;
1401
+ isVirtual?: boolean;
1402
+ };
1403
+ McpServerDto: {
109
1404
  /**
110
- * @description Optional checkout session ID/token if payment is required
111
- * @example e3f1c2d4b6a89f001122334455667788
1405
+ * Server ID
1406
+ * @example 507f1f77bcf86cd799439011
112
1407
  */
113
- checkoutSessionId?: string;
1408
+ id?: string;
114
1409
  /**
115
- * @description Optional full checkout URL if payment is required (based on backend configuration)
116
- * @example https://app.solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
1410
+ * Unique server reference
1411
+ * @example mcp_abc123
117
1412
  */
118
- checkoutUrl?: string;
119
- };
120
- UsageEvent: {
1413
+ reference?: string;
121
1414
  /**
122
- * @description Customer reference identifier
123
- * @example cus_3c4d5e6f7g8h
1415
+ * Domain slug used to derive the MCP endpoint subdomain
1416
+ * @example my-mcp-server
124
1417
  */
125
- customerRef: string;
1418
+ name: string;
126
1419
  /**
127
- * @description Agent reference identifier
128
- * @example agt_1a2b3c4d5e6f
1420
+ * URL-safe subdomain derived from name
1421
+ * @example my-mcp-server
129
1422
  */
130
- agentRef: string;
1423
+ subdomain: string;
131
1424
  /**
132
- * @description Outcome of the action
133
- * @example success
134
- * @enum {string}
1425
+ * SolvaPay proxy URL that MCP clients connect to
1426
+ * @example https://mytelescope.mcp.solvapay.com/mcp
135
1427
  */
136
- outcome: "success" | "paywall" | "fail";
1428
+ mcpProxyUrl?: string;
137
1429
  /**
138
- * @description Optional action identifier
139
- * @example generate_text
1430
+ * Origin URL of the actual MCP server
1431
+ * @example https://origin.example.com/mcp
140
1432
  */
141
- action?: string;
1433
+ url: string;
142
1434
  /**
143
- * @description Unique request identifier matching the limits check
144
- * @example req_1a2b3c4d5e6f
1435
+ * Avatar image URL
1436
+ * @example https://example.com/avatar.png
145
1437
  */
146
- requestId: string;
1438
+ avatarUrl?: string;
1439
+ /** @description Registered tools for this server */
1440
+ tools?: components["schemas"]["McpToolDto"][];
147
1441
  /**
148
- * @description Duration of the action in milliseconds
149
- * @example 1250
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
150
1444
  */
151
- actionDuration: number;
1445
+ defaultPlanId?: string;
152
1446
  /**
153
- * @description ISO 8601 timestamp of when the action occurred
154
- * @example 2025-10-21T10:30:00.000Z
1447
+ * Associated product ID
1448
+ * @example 507f1f77bcf86cd799439011
155
1449
  */
156
- timestamp: string;
157
- };
158
- CreateCustomerRequest: {
1450
+ productId?: string;
159
1451
  /**
160
- * @description Customer email address (required)
161
- * @example customer@example.com
1452
+ * Server status
1453
+ * @example active
1454
+ * @enum {string}
162
1455
  */
163
- email: string;
1456
+ status?: "active" | "inactive" | "suspended";
164
1457
  /**
165
- * @description Customer full name (optional)
166
- * @example John Doe
1458
+ * Provider ID that owns this server
1459
+ * @example 507f1f77bcf86cd799439011
167
1460
  */
168
- name?: string;
1461
+ providerId: string;
169
1462
  /**
170
- * @description External reference ID from your auth system to map this customer to an auth user (optional)
171
- * @example auth_user_12345
1463
+ * Custom auth header name for origin requests
1464
+ * @example X-API-Key
172
1465
  */
173
- externalRef?: string;
174
- };
175
- SubscriptionInfo: {
1466
+ authHeaderName?: string;
176
1467
  /**
177
- * @description Subscription reference
178
- * @example sub_abc123
1468
+ * Whether an auth API key is configured
1469
+ * @example true
179
1470
  */
180
- reference: string;
1471
+ hasAuthApiKey?: boolean;
181
1472
  /**
182
- * @description Plan name
183
- * @example Pro Plan
1473
+ * Total number of tool-call transactions
1474
+ * @example 42
184
1475
  */
185
- planName: string;
1476
+ totalTransactions?: number;
186
1477
  /**
187
- * @description Agent name
188
- * @example AI Assistant
1478
+ * Current balance in cents
1479
+ * @example 1500
189
1480
  */
190
- agentName: string;
1481
+ balance?: number;
1482
+ };
1483
+ PlanSnapshotDto: {
191
1484
  /**
192
- * @description Subscription status
193
- * @example active
1485
+ * Plan reference
1486
+ * @example pln_1A2B3C4D
194
1487
  */
195
- status: string;
1488
+ reference?: string;
196
1489
  /**
197
- * @description Start date
198
- * @example 2025-10-27T10:00:00Z
1490
+ * Plan price in cents
1491
+ * @example 2999
199
1492
  */
200
- startDate: string;
201
- };
202
- CustomerResponse: {
1493
+ price: number;
203
1494
  /**
204
- * @description Customer reference identifier
205
- * @example cus_3c4d5e6f7g8h
1495
+ * Currency code
1496
+ * @example USD
206
1497
  */
207
- reference: string;
1498
+ currency: string;
208
1499
  /**
209
- * @description Customer full name
210
- * @example John Doe
1500
+ * Plan type
1501
+ * @example recurring
211
1502
  */
212
- name: string;
1503
+ planType: string;
213
1504
  /**
214
- * @description Customer email address
215
- * @example customer@example.com
1505
+ * Billing cycle
1506
+ * @example monthly
216
1507
  */
217
- email: 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;
218
1517
  /**
219
- * @description External reference ID from your auth system (if set during creation or update)
220
- * @example auth_user_12345
1518
+ * Meter ObjectId reference
1519
+ * @example 507f1f77bcf86cd799439011
221
1520
  */
222
- externalRef?: string;
223
- /** @description Active subscriptions */
224
- subscriptions?: components["schemas"]["SubscriptionInfo"][];
225
- };
226
- CreateCustomerSessionRequest: {
1521
+ meterId?: string;
227
1522
  /**
228
- * @description Customer reference identifier
229
- * @example cus_3c4d5e6f7g8h
1523
+ * Usage limit for the meter
1524
+ * @example 5000
230
1525
  */
231
- customerRef: string;
232
- };
233
- CreateCustomerSessionResponse: {
1526
+ limit?: number;
234
1527
  /**
235
- * @description Customer session ID/token
236
- * @example e3f1c2d4b6a89f001122334455667788
1528
+ * Number of free units included
1529
+ * @example 100
237
1530
  */
238
- sessionId: string;
1531
+ freeUnits?: number;
239
1532
  /**
240
- * @description Full customer URL based on backend configuration (ready to redirect customer)
241
- * @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
1533
+ * Price per usage unit in cents
1534
+ * @example 10
242
1535
  */
243
- customerUrl: string;
1536
+ pricePerUnit?: number;
244
1537
  };
245
- GetCustomerSessionResponse: {
1538
+ UsageBillingDto: {
246
1539
  /**
247
- * @description Customer session ID/token
248
- * @example e3f1c2d4b6a89f001122334455667788
1540
+ * Units consumed in current period
1541
+ * @example 150
249
1542
  */
250
- sessionId: string;
1543
+ used: number;
251
1544
  /**
252
- * @description Session status
253
- * @example active
254
- * @enum {string}
1545
+ * Units exceeding the plan limit
1546
+ * @example 0
255
1547
  */
256
- status: "active" | "expired" | "used";
1548
+ overageUnits: number;
257
1549
  /**
258
- * @description Full customer URL based on backend configuration (ready to redirect customer)
259
- * @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
1550
+ * Overage cost in cents
1551
+ * @example 0
260
1552
  */
261
- customerUrl: string;
1553
+ overageCost: number;
262
1554
  /**
263
- * @description Session expiration date
264
- * @example 2025-01-01T12:00:00.000Z
1555
+ * Period start date
1556
+ * @example 2025-10-01T00:00:00Z
265
1557
  */
266
- expiresAt: string;
267
- /** @description Customer object from session data */
268
- customer: components["schemas"]["CustomerResponse"];
1558
+ periodStart?: string;
269
1559
  /**
270
- * @description Session creation date
271
- * @example 2025-01-01T11:45:00.000Z
1560
+ * Period end date
1561
+ * @example 2025-11-01T00:00:00Z
272
1562
  */
273
- createdAt: string;
1563
+ periodEnd?: string;
1564
+ };
1565
+ PurchaseResponse: {
274
1566
  /**
275
- * @description Session last update date
276
- * @example 2025-01-01T11:45:00.000Z
1567
+ * Purchase ID
1568
+ * @example 507f1f77bcf86cd799439011
277
1569
  */
278
- updatedAt: string;
279
- };
280
- Agent: Record<string, never>;
281
- CreateAgentRequest: Record<string, never>;
282
- UpdateAgentRequest: Record<string, never>;
283
- BasePlan: Record<string, never>;
284
- SubscriptionResponse: {
1570
+ id: string;
285
1571
  /**
286
- * @description Subscription reference identifier
287
- * @example sub_1a2b3c4d5e6f
1572
+ * Purchase reference
1573
+ * @example pur_1A2B3C4D
288
1574
  */
289
1575
  reference: string;
290
1576
  /**
291
- * @description Customer reference identifier
292
- * @example cus_3c4d5e6f7g8h
1577
+ * Customer reference
1578
+ * @example cus_3C4D5E6F
293
1579
  */
294
1580
  customerRef: string;
295
1581
  /**
296
- * @description Customer email
1582
+ * Customer email
297
1583
  * @example customer@example.com
298
1584
  */
299
1585
  customerEmail: string;
300
1586
  /**
301
- * @description Customer name
302
- * @example John Doe
1587
+ * Product reference
1588
+ * @example prd_1A2B3C4D
303
1589
  */
304
- customerName?: string;
1590
+ productRef: string;
305
1591
  /**
306
- * @description Agent reference identifier
307
- * @example agt_1a2b3c4d5e6f
1592
+ * Product ID
1593
+ * @example 507f1f77bcf86cd799439012
308
1594
  */
309
- agentRef: string;
1595
+ productId?: string;
310
1596
  /**
311
- * @description Agent name
312
- * @example My AI Agent
1597
+ * Product name
1598
+ * @example API Gateway Manager
313
1599
  */
314
- agentName: string;
1600
+ productName?: string;
1601
+ /** @description Plan snapshot at time of purchase */
1602
+ planSnapshot: components["schemas"]["PlanSnapshotDto"];
315
1603
  /**
316
- * @description Plan reference identifier
317
- * @example pln_1a2b3c4d5e6f
1604
+ * Purchase status
1605
+ * @example active
318
1606
  */
319
- planRef: string;
1607
+ status: string;
320
1608
  /**
321
- * @description Plan name
322
- * @example Premium Plan
1609
+ * Amount in cents
1610
+ * @example 9900
323
1611
  */
324
- planName: string;
1612
+ amount: number;
325
1613
  /**
326
- * @description Plan type
327
- * @example recurring
328
- * @enum {string}
1614
+ * Currency code
1615
+ * @example USD
329
1616
  */
330
- planType: "recurring" | "usage-based" | "one-time" | "hybrid";
1617
+ currency: string;
1618
+ /** @description Start date */
1619
+ startDate: string;
1620
+ /** @description End date */
1621
+ endDate?: string;
1622
+ /** @description Paid at timestamp */
1623
+ paidAt?: string;
1624
+ /** @description Usage billing state for usage-based plans */
1625
+ usage?: components["schemas"]["UsageBillingDto"];
331
1626
  /**
332
- * @description Subscription status
333
- * @example active
1627
+ * Is recurring
1628
+ * @example true
1629
+ */
1630
+ isRecurring: boolean;
1631
+ /**
1632
+ * Billing cycle
334
1633
  * @enum {string}
335
1634
  */
336
- status: "pending" | "active" | "expired" | "cancelled" | "suspended" | "refunded";
1635
+ billingCycle?: "weekly" | "monthly" | "quarterly" | "yearly";
1636
+ /** @description Next billing date */
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: {
337
1654
  /**
338
- * @description Amount paid in original currency (in cents)
339
- * @example 9900
1655
+ * Customer reference identifier
1656
+ * @example cus_3C4D5E6F
340
1657
  */
341
- amount: number;
1658
+ customerRef: string;
342
1659
  /**
343
- * @description Currency code
344
- * @example USD
1660
+ * Product reference identifier
1661
+ * @example prd_1A2B3C4D
345
1662
  */
346
- currency: string;
1663
+ productRef: string;
347
1664
  /**
348
- * @description Start date of subscription
349
- * @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
350
1667
  */
351
- startDate: string;
1668
+ planRef?: string;
352
1669
  /**
353
- * @description End date of subscription (if applicable)
354
- * @example 2025-02-01T00:00:00.000Z
1670
+ * Canonical usage meter name used for limit checks (for example: requests, tokens).
1671
+ * @example requests
355
1672
  */
356
- endDate?: string;
1673
+ meterName?: string;
357
1674
  /**
358
- * @description When payment was confirmed
359
- * @example 2025-01-01T00:00:00.000Z
1675
+ * Usage type alias for meterName. If both are provided, meterName takes precedence.
1676
+ * @example requests
360
1677
  */
361
- paidAt?: string;
362
- /** @description Usage quota information (for usage-based plans) */
363
- usageQuota?: Record<string, never>;
1678
+ usageType?: string;
1679
+ };
1680
+ LimitResponse: {
364
1681
  /**
365
- * @description Whether this is a recurring subscription
1682
+ * Whether the customer is within their usage limits
366
1683
  * @example true
367
1684
  */
368
- isRecurring: boolean;
1685
+ withinLimits: boolean;
369
1686
  /**
370
- * @description Next billing date (for recurring subscriptions)
371
- * @example 2025-02-01T00:00:00.000Z
1687
+ * Remaining usage units before hitting the limit
1688
+ * @example 997
372
1689
  */
373
- nextBillingDate?: string;
1690
+ remaining: number;
374
1691
  /**
375
- * @description When subscription was cancelled (if applicable)
376
- * @example 2025-01-15T00:00:00.000Z
1692
+ * Checkout session ID if payment is required
1693
+ * @example e3f1c2d4b6a89f001122334455667788
377
1694
  */
378
- cancelledAt?: string;
1695
+ checkoutSessionId?: string;
379
1696
  /**
380
- * @description Reason for cancellation (if applicable)
381
- * @example Customer request
1697
+ * Checkout URL if payment is required
1698
+ * @example https://solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
382
1699
  */
383
- cancellationReason?: string;
1700
+ checkoutUrl?: string;
384
1701
  /**
385
- * @description When subscription was created
386
- * @example 2025-01-01T00:00:00.000Z
1702
+ * The meter name to use when tracking usage events
1703
+ * @example requests
387
1704
  */
388
- createdAt: string;
1705
+ meterName?: string;
389
1706
  };
390
- CreateCheckoutSessionResponse: {
1707
+ ExecuteAnalyticsQuery: Record<string, never>;
1708
+ ExecuteMultipleQueries: Record<string, never>;
1709
+ CreateWebhookEndpointDto: {
391
1710
  /**
392
- * @description Checkout session ID/token
393
- * @example e3f1c2d4b6a89f001122334455667788
1711
+ * Webhook endpoint URL
1712
+ * @example https://example.com/webhook
394
1713
  */
395
- sessionId: string;
1714
+ url: string;
396
1715
  /**
397
- * @description Full checkout URL based on backend configuration (ready to redirect customer)
398
- * @example https://solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
1716
+ * Webhook endpoint description
1717
+ * @example Production webhook
399
1718
  */
400
- checkoutUrl: string;
1719
+ description?: string;
401
1720
  };
402
- CreatePageSettings: {
403
- /** @description Page identifier */
404
- id: string;
405
- /** @description Page display name */
406
- name: string;
407
- /** @description Logo URL */
408
- logo?: string;
1721
+ UpdateWebhookEndpointDto: {
409
1722
  /**
410
- * @description Text color in hex format
411
- * @example #2d3748
1723
+ * Webhook endpoint URL
1724
+ * @example https://example.com/webhook
412
1725
  */
413
- textColor: string;
1726
+ url?: string;
414
1727
  /**
415
- * @description Button color in hex format
416
- * @example #3182ce
1728
+ * Webhook endpoint description
1729
+ * @example Updated webhook
1730
+ */
1731
+ description?: string;
1732
+ };
1733
+ UpdateThemePreferenceDto: {
1734
+ /**
1735
+ * Selected UI theme mode
1736
+ * @example dark
1737
+ * @enum {string}
417
1738
  */
418
- buttonColor: string;
1739
+ mode: "light" | "dark";
1740
+ };
1741
+ ThemeModeColorsDto: {
419
1742
  /**
420
- * @description Left background color in hex format
421
- * @example #f7fafc
1743
+ * Page background color
1744
+ * @example #f7f7f8
422
1745
  */
423
- leftBackgroundColor: string;
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
  */
@@ -720,70 +2204,294 @@ interface McpAdapterOptions {
720
2204
  }
721
2205
 
722
2206
  /**
723
- * Configuration for creating a SolvaPay instance
2207
+ * Virtual Tools for MCP Server Monetization
2208
+ *
2209
+ * Provides the same self-service tools (get_user_info, upgrade, manage_account)
2210
+ * that hosted MCP Pay servers get automatically, but for SDK-integrated servers.
2211
+ * These tools are NOT usage-tracked and bypass the paywall.
2212
+ */
2213
+
2214
+ interface VirtualToolsOptions {
2215
+ /** Product reference (required) */
2216
+ product: string;
2217
+ /** Extract customer reference from MCP tool args */
2218
+ getCustomerRef: (args: Record<string, unknown>) => string;
2219
+ /** Tool names to exclude from registration (optional) */
2220
+ exclude?: string[];
2221
+ }
2222
+ interface VirtualToolDefinition {
2223
+ name: string;
2224
+ description: string;
2225
+ inputSchema: {
2226
+ type: 'object';
2227
+ properties: Record<string, object>;
2228
+ required: string[];
2229
+ };
2230
+ handler: (args: Record<string, unknown>) => Promise<{
2231
+ content: Array<{
2232
+ type: string;
2233
+ text: string;
2234
+ }>;
2235
+ isError?: boolean;
2236
+ }>;
2237
+ }
2238
+ declare const VIRTUAL_TOOL_DEFINITIONS: {
2239
+ name: string;
2240
+ description: string;
2241
+ inputSchema: {
2242
+ type: "object";
2243
+ properties: Record<string, object>;
2244
+ required: string[];
2245
+ };
2246
+ }[];
2247
+ declare function createVirtualTools(apiClient: SolvaPayClient, options: VirtualToolsOptions): VirtualToolDefinition[];
2248
+
2249
+ /**
2250
+ * Configuration for creating a SolvaPay instance.
2251
+ *
2252
+ * You can provide either an `apiKey` (for production) or an `apiClient` (for testing).
2253
+ * If neither is provided, the SDK will attempt to read `SOLVAPAY_SECRET_KEY` from
2254
+ * environment variables. If no API key is found, the SDK runs in stub mode.
2255
+ *
2256
+ * @example
2257
+ * ```typescript
2258
+ * // Production: Use API key
2259
+ * const config: CreateSolvaPayConfig = {
2260
+ * apiKey: process.env.SOLVAPAY_SECRET_KEY
2261
+ * };
2262
+ *
2263
+ * // Testing: Use mock client
2264
+ * const config: CreateSolvaPayConfig = {
2265
+ * apiClient: mockClient
2266
+ * };
2267
+ * ```
724
2268
  */
725
2269
  interface CreateSolvaPayConfig {
726
2270
  /**
727
- * API key for production use (creates client automatically)
2271
+ * API key for production use (creates client automatically).
2272
+ * Defaults to `SOLVAPAY_SECRET_KEY` environment variable if not provided.
728
2273
  */
729
2274
  apiKey?: string;
730
2275
  /**
731
- * API client for testing or custom implementations
2276
+ * API client for testing or custom implementations.
2277
+ * Use this for stub mode, testing, or custom client implementations.
732
2278
  */
733
2279
  apiClient?: SolvaPayClient;
734
2280
  /**
735
- * Optional API base URL (only used with apiKey)
2281
+ * Optional API base URL override (only used with apiKey).
2282
+ * Defaults to production API URL if not provided.
736
2283
  */
737
2284
  apiBaseUrl?: string;
2285
+ /**
2286
+ * TTL in ms for the checkLimits cache (default 10 000).
2287
+ * Positive results are cached and optimistically decremented to avoid
2288
+ * redundant API calls during tool-call bursts.
2289
+ */
2290
+ limitsCacheTTL?: number;
738
2291
  }
739
2292
  /**
740
- * Payable function that provides explicit adapters
2293
+ * Payable function that provides explicit adapters for different frameworks.
2294
+ *
2295
+ * Use the appropriate adapter method for your framework:
2296
+ * - `http()` - Express.js, Fastify, and other HTTP frameworks
2297
+ * - `next()` - Next.js App Router API routes
2298
+ * - `mcp()` - Model Context Protocol servers
2299
+ * - `function()` - Pure functions, background jobs, or testing
2300
+ *
2301
+ * @example
2302
+ * ```typescript
2303
+ * const payable = solvaPay.payable({ product: 'prd_myapi', plan: 'pln_premium' });
2304
+ *
2305
+ * // Express.js
2306
+ * app.post('/tasks', payable.http(createTask));
2307
+ *
2308
+ * // Next.js
2309
+ * export const POST = payable.next(createTask);
2310
+ *
2311
+ * // MCP Server
2312
+ * const handler = payable.mcp(createTask);
2313
+ *
2314
+ * // Pure function
2315
+ * const protectedFn = await payable.function(createTask);
2316
+ * ```
741
2317
  */
742
2318
  interface PayableFunction {
743
2319
  /**
744
- * HTTP adapter for Express/Fastify
2320
+ * HTTP adapter for Express.js, Fastify, and other HTTP frameworks.
2321
+ *
2322
+ * @param businessLogic - Your business logic function
2323
+ * @param options - Optional adapter configuration
2324
+ * @returns HTTP route handler function
2325
+ *
2326
+ * @example
2327
+ * ```typescript
2328
+ * app.post('/tasks', payable.http(async (req) => {
2329
+ * const { title } = req.body;
2330
+ * return { success: true, task: { title } };
2331
+ * }));
2332
+ * ```
745
2333
  */
746
- http<T = any>(businessLogic: (args: any) => Promise<T>, options?: HttpAdapterOptions): (req: any, reply: any) => Promise<any>;
2334
+ http<T = any>(businessLogic: (args: any) => Promise<T>, options?: HttpAdapterOptions): (req: any, reply: any) => Promise<unknown>;
747
2335
  /**
748
- * Next.js adapter for App Router
2336
+ * Next.js adapter for App Router API routes.
2337
+ *
2338
+ * @param businessLogic - Your business logic function
2339
+ * @param options - Optional adapter configuration
2340
+ * @returns Next.js route handler function
2341
+ *
2342
+ * @example
2343
+ * ```typescript
2344
+ * // app/api/tasks/route.ts
2345
+ * export const POST = payable.next(async (request) => {
2346
+ * const body = await request.json();
2347
+ * return Response.json({ success: true });
2348
+ * });
2349
+ * ```
749
2350
  */
750
2351
  next<T = any>(businessLogic: (args: any) => Promise<T>, options?: NextAdapterOptions): (request: Request, context?: any) => Promise<Response>;
751
2352
  /**
752
- * MCP adapter for Model Context Protocol servers
2353
+ * MCP adapter for Model Context Protocol servers.
2354
+ *
2355
+ * @param businessLogic - Your tool implementation function
2356
+ * @param options - Optional adapter configuration
2357
+ * @returns MCP tool handler function
2358
+ *
2359
+ * @example
2360
+ * ```typescript
2361
+ * const handler = payable.mcp(async (args) => {
2362
+ * return { success: true, result: 'tool output' };
2363
+ * });
2364
+ * ```
753
2365
  */
754
- mcp<T = any>(businessLogic: (args: any) => Promise<T>, options?: McpAdapterOptions): (args: any) => Promise<any>;
2366
+ mcp<T = any>(businessLogic: (args: any) => Promise<T>, options?: McpAdapterOptions): (args: Record<string, unknown>) => Promise<unknown>;
755
2367
  /**
756
- * Pure function adapter for direct function protection
757
- * Use this for testing, background jobs, or non-framework contexts
2368
+ * Pure function adapter for direct function protection.
2369
+ *
2370
+ * Use this for testing, background jobs, or non-framework contexts.
2371
+ *
2372
+ * @param businessLogic - Your business logic function
2373
+ * @returns Protected function that requires customer reference in args
2374
+ *
2375
+ * @example
2376
+ * ```typescript
2377
+ * const protectedFn = await payable.function(async (args) => {
2378
+ * return { result: 'processed' };
2379
+ * });
2380
+ *
2381
+ * // Call with customer reference
2382
+ * const result = await protectedFn({
2383
+ * auth: { customer_ref: 'user_123' },
2384
+ * // ... other args
2385
+ * });
2386
+ * ```
758
2387
  */
759
2388
  function<T = any>(businessLogic: (args: any) => Promise<T>): Promise<(args: any) => Promise<T>>;
760
2389
  }
761
2390
  /**
762
- * SolvaPay instance with payable method and common API methods
2391
+ * SolvaPay instance with payable method and common API methods.
2392
+ *
2393
+ * This interface provides the main API for interacting with SolvaPay.
2394
+ * Use `createSolvaPay()` to create an instance.
2395
+ *
2396
+ * @example
2397
+ * ```typescript
2398
+ * const solvaPay = createSolvaPay();
2399
+ *
2400
+ * // Create payable handlers
2401
+ * const payable = solvaPay.payable({ product: 'prd_myapi', plan: 'pln_premium' });
2402
+ *
2403
+ * // Manage customers
2404
+ * const customerRef = await solvaPay.ensureCustomer('user_123', 'user_123', {
2405
+ * email: 'user@example.com'
2406
+ * });
2407
+ *
2408
+ * // Create payment intents
2409
+ * const intent = await solvaPay.createPaymentIntent({
2410
+ * productRef: 'prd_myapi',
2411
+ * planRef: 'pln_premium',
2412
+ * customerRef: 'user_123'
2413
+ * });
2414
+ * ```
763
2415
  */
764
2416
  interface SolvaPay {
765
2417
  /**
766
- * Create a payable handler with explicit adapters
2418
+ * Create a payable handler with explicit adapters for different frameworks.
2419
+ *
2420
+ * @param options - Payable options including product and plan references
2421
+ * @returns PayableFunction with framework-specific adapters
2422
+ *
2423
+ * @example
2424
+ * ```typescript
2425
+ * const payable = solvaPay.payable({
2426
+ * product: 'prd_myapi',
2427
+ * plan: 'pln_premium'
2428
+ * });
2429
+ *
2430
+ * app.post('/tasks', payable.http(createTask));
2431
+ * ```
767
2432
  */
768
2433
  payable(options?: PayableOptions): PayableFunction;
769
2434
  /**
770
- * Ensure customer exists (for testing/setup)
771
- * Only attempts creation once per customer (idempotent).
2435
+ * Ensure customer exists in SolvaPay backend (idempotent).
2436
+ *
2437
+ * Creates a customer if they don't exist, or returns existing customer reference.
2438
+ * This is automatically called by the paywall system, but you can call it
2439
+ * explicitly for setup or testing.
2440
+ *
2441
+ * @param customerRef - The customer reference used as a cache key (e.g., Supabase user ID)
2442
+ * @param externalRef - Optional external reference for backend lookup (e.g., Supabase user ID).
2443
+ * If provided, will lookup existing customer by externalRef before creating new one.
2444
+ * The externalRef is stored on the SolvaPay backend for customer lookup.
2445
+ * @param options - Optional customer details for customer creation
2446
+ * @param options.email - Customer email address
2447
+ * @param options.name - Customer name
2448
+ * @returns Customer reference (backend customer ID)
772
2449
  *
773
- * @param customerRef - The customer reference (e.g., Supabase user ID)
774
- * @param externalRef - Optional external reference for backend lookup (e.g., Supabase user ID)
775
- * If provided, will lookup existing customer by externalRef before creating new one
776
- * @param options - Optional customer details (email, name) for customer creation
2450
+ * @example
2451
+ * ```typescript
2452
+ * // Ensure customer exists before processing payment
2453
+ * const customerRef = await solvaPay.ensureCustomer(
2454
+ * 'user_123', // customerRef (your user ID)
2455
+ * 'user_123', // externalRef (same or different)
2456
+ * {
2457
+ * email: 'user@example.com',
2458
+ * name: 'John Doe'
2459
+ * }
2460
+ * );
2461
+ * ```
777
2462
  */
778
2463
  ensureCustomer(customerRef: string, externalRef?: string, options?: {
779
2464
  email?: string;
780
2465
  name?: string;
781
2466
  }): Promise<string>;
782
2467
  /**
783
- * Create a payment intent for a customer to subscribe to a plan
2468
+ * Create a Stripe payment intent for a customer to purchase a plan.
2469
+ *
2470
+ * This creates a payment intent that can be confirmed on the client side
2471
+ * using Stripe.js. After confirmation, call `processPaymentIntent()` to complete
2472
+ * the purchase.
2473
+ *
2474
+ * @param params - Payment intent parameters
2475
+ * @param params.productRef - Product reference
2476
+ * @param params.planRef - Plan reference to purchase
2477
+ * @param params.customerRef - Customer reference
2478
+ * @param params.idempotencyKey - Optional idempotency key for retry safety
2479
+ * @returns Payment intent with client secret and publishable key
2480
+ *
2481
+ * @example
2482
+ * ```typescript
2483
+ * const intent = await solvaPay.createPaymentIntent({
2484
+ * productRef: 'prd_myapi',
2485
+ * planRef: 'pln_premium',
2486
+ * customerRef: 'user_123',
2487
+ * idempotencyKey: 'unique-key-123'
2488
+ * });
2489
+ *
2490
+ * // Use intent.clientSecret with Stripe.js on client
2491
+ * ```
784
2492
  */
785
2493
  createPaymentIntent(params: {
786
- agentRef: string;
2494
+ productRef: string;
787
2495
  planRef: string;
788
2496
  customerRef: string;
789
2497
  idempotencyKey?: string;
@@ -794,42 +2502,135 @@ interface SolvaPay {
794
2502
  accountId?: string;
795
2503
  }>;
796
2504
  /**
797
- * Process a payment intent after client-side confirmation
798
- * Creates subscription or purchase immediately, eliminating webhook delay
2505
+ * Process a payment intent after client-side Stripe confirmation.
2506
+ *
2507
+ * Creates the purchase immediately, eliminating webhook delay.
2508
+ * Call this after the client has confirmed the payment intent with Stripe.js.
2509
+ *
2510
+ * @param params - Payment processing parameters
2511
+ * @param params.paymentIntentId - Stripe payment intent ID from client confirmation
2512
+ * @param params.productRef - Product reference
2513
+ * @param params.customerRef - Customer reference
2514
+ * @param params.planRef - Optional plan reference (if not in payment intent)
2515
+ * @returns Payment processing result with purchase details
2516
+ *
2517
+ * @example
2518
+ * ```typescript
2519
+ * // After client confirms payment with Stripe.js
2520
+ * const result = await solvaPay.processPaymentIntent({
2521
+ * paymentIntentId: 'pi_1234567890',
2522
+ * productRef: 'prd_myapi',
2523
+ * customerRef: 'user_123',
2524
+ * planRef: 'pln_premium'
2525
+ * });
2526
+ *
2527
+ * if (result.success) {
2528
+ * console.log('Purchase created:', result.purchase);
2529
+ * }
2530
+ * ```
799
2531
  */
800
- processPayment(params: {
2532
+ processPaymentIntent(params: {
801
2533
  paymentIntentId: string;
802
- agentRef: string;
2534
+ productRef: string;
803
2535
  customerRef: string;
804
2536
  planRef?: string;
805
2537
  }): Promise<ProcessPaymentResult>;
806
2538
  /**
807
- * Check if customer is within usage limits
2539
+ * Check if customer is within usage limits for a product.
2540
+ *
2541
+ * This method checks purchase status and usage limits without
2542
+ * executing business logic. Use `payable()` for automatic protection.
2543
+ *
2544
+ * @param params - Limit check parameters
2545
+ * @param params.customerRef - Customer reference
2546
+ * @param params.productRef - Product reference
2547
+ * @returns Limit check result with remaining usage and checkout URL if needed
2548
+ *
2549
+ * @example
2550
+ * ```typescript
2551
+ * const limits = await solvaPay.checkLimits({
2552
+ * customerRef: 'user_123',
2553
+ * productRef: 'prd_myapi',
2554
+ * planRef: 'pln_premium'
2555
+ * });
2556
+ *
2557
+ * if (!limits.withinLimits) {
2558
+ * // Redirect to checkout
2559
+ * window.location.href = limits.checkoutUrl;
2560
+ * }
2561
+ * ```
808
2562
  */
809
2563
  checkLimits(params: {
810
2564
  customerRef: string;
811
- agentRef: string;
2565
+ productRef: string;
2566
+ planRef?: string;
2567
+ meterName?: 'requests' | 'tokens';
2568
+ usageType?: 'requests' | 'tokens';
812
2569
  }): Promise<{
813
2570
  withinLimits: boolean;
814
2571
  remaining: number;
815
2572
  plan: string;
816
2573
  checkoutUrl?: string;
2574
+ meterName?: string;
817
2575
  }>;
818
2576
  /**
819
- * Track usage for a customer action
2577
+ * Track usage for a customer action.
2578
+ *
2579
+ * This is automatically called by the paywall system. You typically
2580
+ * don't need to call this manually unless implementing custom tracking.
2581
+ *
2582
+ * @param params - Usage tracking parameters
2583
+ * @param params.customerRef - Customer reference
2584
+ * @param params.productRef - Product reference
2585
+ * @param params.planRef - Plan reference
2586
+ * @param params.outcome - Action outcome ('success', 'paywall', or 'fail')
2587
+ * @param params.action - Optional action name for analytics
2588
+ * @param params.requestId - Unique request ID
2589
+ * @param params.actionDuration - Action duration in milliseconds
2590
+ * @param params.timestamp - ISO timestamp of the action
2591
+ *
2592
+ * @example
2593
+ * ```typescript
2594
+ * await solvaPay.trackUsage({
2595
+ * customerRef: 'cus_3C4D5E6F',
2596
+ * actionType: 'api_call',
2597
+ * units: 1,
2598
+ * outcome: 'success',
2599
+ * metadata: { toolName: 'search', endpoint: '/search' },
2600
+ * });
2601
+ * ```
820
2602
  */
821
2603
  trackUsage(params: {
822
2604
  customerRef: string;
823
- agentRef: string;
824
- planRef: string;
825
- outcome: 'success' | 'paywall' | 'fail';
826
- action?: string;
827
- requestId: string;
828
- actionDuration: number;
829
- timestamp: string;
2605
+ actionType?: 'transaction' | 'api_call' | 'hour' | 'email' | 'storage' | 'custom';
2606
+ units?: number;
2607
+ outcome?: 'success' | 'paywall' | 'fail';
2608
+ productReference?: string;
2609
+ purchaseReference?: string;
2610
+ description?: string;
2611
+ metadata?: Record<string, unknown>;
2612
+ duration?: number;
2613
+ timestamp?: string;
2614
+ idempotencyKey?: string;
830
2615
  }): Promise<void>;
831
2616
  /**
832
- * Create a new customer
2617
+ * Create a new customer in SolvaPay backend.
2618
+ *
2619
+ * Note: `ensureCustomer()` is usually preferred as it's idempotent.
2620
+ * Use this only if you need explicit control over customer creation.
2621
+ *
2622
+ * @param params - Customer creation parameters
2623
+ * @param params.email - Customer email address (required)
2624
+ * @param params.name - Optional customer name
2625
+ * @returns Created customer reference
2626
+ *
2627
+ * @example
2628
+ * ```typescript
2629
+ * const { customerRef } = await solvaPay.createCustomer({
2630
+ * email: 'user@example.com',
2631
+ * name: 'John Doe'
2632
+ * });
2633
+ * ```
833
2634
  */
834
2635
  createCustomer(params: {
835
2636
  email: string;
@@ -838,58 +2639,162 @@ interface SolvaPay {
838
2639
  customerRef: string;
839
2640
  }>;
840
2641
  /**
841
- * Get customer details
2642
+ * Get customer details including purchases and usage.
2643
+ *
2644
+ * Returns full customer information from the SolvaPay backend, including
2645
+ * all active purchases, usage history, and customer metadata.
2646
+ *
2647
+ * @param params - Customer lookup parameters
2648
+ * @param params.customerRef - Optional customer reference (SolvaPay ID)
2649
+ * @param params.externalRef - Optional external reference (e.g., Supabase ID)
2650
+ * @returns Customer details with purchases and metadata
2651
+ *
2652
+ * @example
2653
+ * ```typescript
2654
+ * // Lookup by SolvaPay customer ID
2655
+ * const customer = await solvaPay.getCustomer({
2656
+ * customerRef: 'cust_123'
2657
+ * });
2658
+ *
2659
+ * // Lookup by external ID (e.g. Supabase user ID)
2660
+ * const customer = await solvaPay.getCustomer({
2661
+ * externalRef: 'user_123'
2662
+ * });
2663
+ * ```
842
2664
  */
843
2665
  getCustomer(params: {
844
- customerRef: string;
845
- }): Promise<{
846
- customerRef: string;
847
- email?: string;
848
- name?: string;
849
- plan?: string;
850
- subscriptions?: Array<{
851
- reference: string;
852
- planName: string;
853
- agentName: string;
854
- status: string;
855
- startDate: string;
856
- }>;
857
- }>;
2666
+ customerRef?: string;
2667
+ externalRef?: string;
2668
+ }): Promise<CustomerResponseMapped>;
858
2669
  /**
859
- * Create a checkout session for a customer
2670
+ * Create a hosted checkout session for a customer.
2671
+ *
2672
+ * This creates a Stripe Checkout session that redirects the customer
2673
+ * to a hosted payment page. After payment, customer is redirected back.
2674
+ *
2675
+ * @param params - Checkout session parameters
2676
+ * @param params.productRef - Product reference
2677
+ * @param params.customerRef - Customer reference
2678
+ * @param params.planRef - Optional plan reference (if not specified, shows plan selector)
2679
+ * @param params.returnUrl - URL to redirect to after successful payment
2680
+ * @returns Checkout session with redirect URL
2681
+ *
2682
+ * @example
2683
+ * ```typescript
2684
+ * const session = await solvaPay.createCheckoutSession({
2685
+ * productRef: 'prd_myapi',
2686
+ * customerRef: 'user_123',
2687
+ * planRef: 'pln_premium',
2688
+ * returnUrl: 'https://myapp.com/success'
2689
+ * });
2690
+ *
2691
+ * // Redirect customer to checkout
2692
+ * window.location.href = session.checkoutUrl;
2693
+ * ```
860
2694
  */
861
2695
  createCheckoutSession(params: {
862
- agentRef: string;
2696
+ productRef: string;
863
2697
  customerRef: string;
864
2698
  planRef?: string;
2699
+ returnUrl?: string;
865
2700
  }): Promise<{
866
2701
  sessionId: string;
867
2702
  checkoutUrl: string;
868
2703
  }>;
869
2704
  /**
870
- * Create a customer session for accessing customer-specific functionality
2705
+ * Create a customer portal session for managing purchases.
2706
+ *
2707
+ * This creates a Stripe Customer Portal session that allows customers
2708
+ * to manage their purchases, update payment methods, and view invoices.
2709
+ *
2710
+ * @param params - Customer session parameters
2711
+ * @param params.customerRef - Customer reference
2712
+ * @param params.productRef - Optional product reference for scoping portal view
2713
+ * @returns Customer portal session with redirect URL
2714
+ *
2715
+ * @example
2716
+ * ```typescript
2717
+ * const session = await solvaPay.createCustomerSession({
2718
+ * customerRef: 'user_123'
2719
+ * });
2720
+ *
2721
+ * // Redirect customer to portal
2722
+ * window.location.href = session.customerUrl;
2723
+ * ```
871
2724
  */
872
2725
  createCustomerSession(params: {
873
2726
  customerRef: string;
2727
+ productRef?: string;
874
2728
  }): Promise<{
875
2729
  sessionId: string;
876
2730
  customerUrl: string;
877
2731
  }>;
878
2732
  /**
879
- * Direct access to the API client for advanced operations
880
- * (agent/plan management, etc.)
2733
+ * Bootstrap an MCP-enabled product with plans and tool mappings.
2734
+ *
2735
+ * This helper wraps the backend orchestration endpoint and is intended for
2736
+ * fast setup flows where you want one call for product + plans + MCP config.
2737
+ */
2738
+ bootstrapMcpProduct(params: McpBootstrapRequest): Promise<McpBootstrapResponse>;
2739
+ /**
2740
+ * Get virtual tool definitions with bound handlers for MCP server integration.
2741
+ *
2742
+ * Returns an array of tool objects (name, description, inputSchema, handler)
2743
+ * that provide self-service capabilities: user info, upgrade, and account management.
2744
+ * These tools bypass the paywall and are not usage-tracked.
2745
+ *
2746
+ * Register the returned tools on your MCP server alongside your own tools.
2747
+ *
2748
+ * @param options - Virtual tools configuration
2749
+ * @param options.product - Product reference (required)
2750
+ * @param options.getCustomerRef - Function to extract customer ref from tool args
2751
+ * @param options.exclude - Optional list of tool names to exclude
2752
+ * @returns Array of virtual tool definitions with handlers
2753
+ *
2754
+ * @example
2755
+ * ```typescript
2756
+ * const virtualTools = solvaPay.getVirtualTools({
2757
+ * product: 'prd_myapi',
2758
+ * getCustomerRef: args => args._auth?.customer_ref || 'anonymous',
2759
+ * });
2760
+ *
2761
+ * // Register on your MCP server
2762
+ * for (const tool of virtualTools) {
2763
+ * // Add to tools/list and tools/call handlers
2764
+ * }
2765
+ * ```
2766
+ */
2767
+ getVirtualTools(options: VirtualToolsOptions): VirtualToolDefinition[];
2768
+ /**
2769
+ * Direct access to the API client for advanced operations.
2770
+ *
2771
+ * Use this for operations not exposed by the SolvaPay interface,
2772
+ * such as product/plan management or custom API calls.
2773
+ *
2774
+ * @example
2775
+ * ```typescript
2776
+ * // Access API client directly for custom operations
2777
+ * const products = await solvaPay.apiClient.listProducts();
2778
+ * ```
881
2779
  */
882
2780
  apiClient: SolvaPayClient;
883
2781
  }
884
2782
  /**
885
- * Create a SolvaPay instance
2783
+ * Create a SolvaPay instance with paywall protection capabilities.
2784
+ *
2785
+ * This factory function creates a SolvaPay instance that can be used to
2786
+ * protect API endpoints, functions, and MCP tools with usage limits and
2787
+ * purchase checks.
886
2788
  *
887
- * @param config - Optional configuration with either apiKey or apiClient. If not provided, reads from environment variables.
888
- * @returns SolvaPay instance with payable() method
2789
+ * @param config - Optional configuration object
2790
+ * @param config.apiKey - API key for production use (defaults to `SOLVAPAY_SECRET_KEY` env var)
2791
+ * @param config.apiClient - Custom API client for testing or advanced use cases
2792
+ * @param config.apiBaseUrl - Optional API base URL override
2793
+ * @returns SolvaPay instance with payable() method and API client access
889
2794
  *
890
2795
  * @example
891
2796
  * ```typescript
892
- * // Production: Read from environment variables (recommended)
2797
+ * // Production: Use environment variable (recommended)
893
2798
  * const solvaPay = createSolvaPay();
894
2799
  *
895
2800
  * // Production: Pass API key explicitly
@@ -897,16 +2802,26 @@ interface SolvaPay {
897
2802
  * apiKey: process.env.SOLVAPAY_SECRET_KEY
898
2803
  * });
899
2804
  *
900
- * // Testing: Pass mock client
2805
+ * // Testing: Use mock client
901
2806
  * const solvaPay = createSolvaPay({
902
2807
  * apiClient: mockClient
903
2808
  * });
904
2809
  *
905
- * // Create payable handlers
906
- * const payable = solvaPay.payable({ agent: 'my-api' });
907
- * app.post('/tasks', payable.http(createTask));
908
- * export const POST = payable.next(createTask);
2810
+ * // Create payable handlers for your product
2811
+ * const payable = solvaPay.payable({
2812
+ * product: 'prd_myapi',
2813
+ * plan: 'pln_premium'
2814
+ * });
2815
+ *
2816
+ * // Protect endpoints with framework-specific adapters
2817
+ * app.post('/tasks', payable.http(createTask)); // Express/Fastify
2818
+ * export const POST = payable.next(createTask); // Next.js App Router
2819
+ * const handler = payable.mcp(createTask); // MCP servers
909
2820
  * ```
2821
+ *
2822
+ * @see {@link SolvaPay} for the returned instance interface
2823
+ * @see {@link CreateSolvaPayConfig} for configuration options
2824
+ * @since 1.0.0
910
2825
  */
911
2826
  declare function createSolvaPay(config?: CreateSolvaPayConfig): SolvaPay;
912
2827
 
@@ -928,25 +2843,43 @@ type ServerClientOptions = {
928
2843
  apiKey: string;
929
2844
  /**
930
2845
  * Base URL for the SolvaPay API (optional)
931
- * Defaults to https://api-dev.solvapay.com
2846
+ * Defaults to https://api.solvapay.com
932
2847
  */
933
2848
  apiBaseUrl?: string;
934
2849
  };
935
2850
  /**
936
- * Creates a SolvaPay API client that implements the full SolvaPayClient
937
- * for server-side paywall and usage tracking operations.
2851
+ * Creates a SolvaPay API client that implements the full SolvaPayClient interface.
938
2852
  *
939
- * @param opts - Configuration options including API key and optional base URL
2853
+ * This function creates a low-level API client for direct communication with the
2854
+ * SolvaPay backend. For most use cases, use `createSolvaPay()` instead, which
2855
+ * provides a higher-level API with paywall protection.
2856
+ *
2857
+ * Use this function when you need:
2858
+ * - Direct API access for custom operations
2859
+ * - Testing with custom client implementations
2860
+ * - Advanced use cases not covered by the main API
2861
+ *
2862
+ * @param opts - Configuration options
2863
+ * @param opts.apiKey - Your SolvaPay API key (required)
2864
+ * @param opts.apiBaseUrl - Optional API base URL override
940
2865
  * @returns A fully configured SolvaPayClient instance
941
2866
  * @throws {SolvaPayError} If API key is missing
942
2867
  *
943
2868
  * @example
944
2869
  * ```typescript
2870
+ * // Create API client directly
945
2871
  * const client = createSolvaPayClient({
946
2872
  * apiKey: process.env.SOLVAPAY_SECRET_KEY!,
947
2873
  * apiBaseUrl: 'https://api.solvapay.com' // optional
948
2874
  * });
2875
+ *
2876
+ * // Use client for custom operations
2877
+ * const products = await client.listProducts();
949
2878
  * ```
2879
+ *
2880
+ * @see {@link createSolvaPay} for the recommended high-level API
2881
+ * @see {@link ServerClientOptions} for configuration options
2882
+ * @since 1.0.0
950
2883
  */
951
2884
  declare function createSolvaPayClient(opts: ServerClientOptions): SolvaPayClient;
952
2885
 
@@ -959,8 +2892,48 @@ declare function createSolvaPayClient(opts: ServerClientOptions): SolvaPayClient
959
2892
  * - Class-based and functional programming
960
2893
  */
961
2894
 
2895
+ /**
2896
+ * Error thrown when a paywall is triggered (purchase required or usage limit exceeded).
2897
+ *
2898
+ * This error is automatically thrown by the paywall protection system when:
2899
+ * - Customer doesn't have required purchase
2900
+ * - Customer has exceeded usage limits
2901
+ * - Customer needs to upgrade their plan
2902
+ *
2903
+ * The error includes structured content with checkout URLs and metadata for
2904
+ * building custom paywall UIs.
2905
+ *
2906
+ * @example
2907
+ * ```typescript
2908
+ * import { PaywallError } from '@solvapay/server';
2909
+ *
2910
+ * try {
2911
+ * const result = await payable.http(createTask)(req, res);
2912
+ * return result;
2913
+ * } catch (error) {
2914
+ * if (error instanceof PaywallError) {
2915
+ * // Custom paywall handling
2916
+ * return res.status(402).json({
2917
+ * error: error.message,
2918
+ * checkoutUrl: error.structuredContent.checkoutUrl,
2919
+ * // Additional metadata available in error.structuredContent
2920
+ * });
2921
+ * }
2922
+ * throw error;
2923
+ * }
2924
+ * ```
2925
+ *
2926
+ * @see {@link PaywallStructuredContent} for the structured content format
2927
+ * @since 1.0.0
2928
+ */
962
2929
  declare class PaywallError extends Error {
963
2930
  structuredContent: PaywallStructuredContent;
2931
+ /**
2932
+ * Creates a new PaywallError instance.
2933
+ *
2934
+ * @param message - Error message
2935
+ * @param structuredContent - Structured content with checkout URLs and metadata
2936
+ */
964
2937
  constructor(message: string, structuredContent: PaywallStructuredContent);
965
2938
  }
966
2939
 
@@ -969,19 +2942,28 @@ declare class PaywallError extends Error {
969
2942
  */
970
2943
 
971
2944
  /**
972
- * Executes an async function with automatic retry logic
2945
+ * Execute an async function with automatic retry logic.
2946
+ *
2947
+ * This utility function provides configurable retry logic with exponential backoff,
2948
+ * conditional retry logic, and retry callbacks. Useful for handling transient
2949
+ * network errors or rate limiting.
973
2950
  *
974
2951
  * @template T The return type of the async function
975
2952
  * @param fn The async function to execute
976
2953
  * @param options Retry configuration options
2954
+ * @param options.maxRetries - Maximum number of retry attempts (default: 2)
2955
+ * @param options.initialDelay - Initial delay in milliseconds before first retry (default: 500)
2956
+ * @param options.backoffStrategy - Backoff strategy: 'fixed', 'linear', or 'exponential' (default: 'fixed')
2957
+ * @param options.shouldRetry - Optional function to determine if error should be retried
2958
+ * @param options.onRetry - Optional callback called before each retry attempt
977
2959
  * @returns A promise that resolves with the function result or rejects with the last error
978
2960
  *
979
2961
  * @example
980
2962
  * ```typescript
981
- * // Simple retry with defaults
2963
+ * // Simple retry with defaults (2 retries, 500ms delay)
982
2964
  * const result = await withRetry(() => apiCall());
983
2965
  *
984
- * // Custom retry with conditional logic
2966
+ * // Custom retry with exponential backoff
985
2967
  * const result = await withRetry(
986
2968
  * () => apiCall(),
987
2969
  * {
@@ -993,9 +2975,343 @@ declare class PaywallError extends Error {
993
2975
  * }
994
2976
  * );
995
2977
  * ```
2978
+ *
2979
+ * @since 1.0.0
996
2980
  */
997
2981
  declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
998
2982
 
2983
+ /**
2984
+ * MCP OAuth helper utilities.
2985
+ *
2986
+ * These helpers are intentionally lightweight and do not verify JWT signatures.
2987
+ * Use them after token validation (for example via /v1/customer/auth/userinfo).
2988
+ */
2989
+ declare class McpBearerAuthError extends Error {
2990
+ constructor(message: string);
2991
+ }
2992
+ type McpBearerCustomerRefOptions = {
2993
+ claimPriority?: string[];
2994
+ };
2995
+ declare function extractBearerToken(authorization?: string | null): string | null;
2996
+ declare function decodeJwtPayload(token: string): Record<string, unknown>;
2997
+ declare function getCustomerRefFromJwtPayload(payload: Record<string, unknown>, options?: McpBearerCustomerRefOptions): string;
2998
+ declare function getCustomerRefFromBearerAuthHeader(authorization?: string | null, options?: McpBearerCustomerRefOptions): string;
2999
+
3000
+ /**
3001
+ * Helper Types
3002
+ *
3003
+ * Shared types for route helpers
3004
+ */
3005
+ /**
3006
+ * Error result returned by core helpers
3007
+ */
3008
+ interface ErrorResult {
3009
+ error: string;
3010
+ status: number;
3011
+ details?: string;
3012
+ }
3013
+ /**
3014
+ * Authenticated user information
3015
+ */
3016
+ interface AuthenticatedUser {
3017
+ userId: string;
3018
+ email?: string | null;
3019
+ name?: string | null;
3020
+ }
3021
+
3022
+ /**
3023
+ * Error Handling Helper
3024
+ *
3025
+ * Generic error handling utilities for route helpers
3026
+ */
3027
+
3028
+ /**
3029
+ * Check if a result is an error result
3030
+ */
3031
+ declare function isErrorResult(result: unknown): result is ErrorResult;
3032
+ /**
3033
+ * Handle route errors and convert to ErrorResult
3034
+ */
3035
+ declare function handleRouteError(error: unknown, operationName: string, defaultMessage?: string): ErrorResult;
3036
+
3037
+ /**
3038
+ * Authentication Helper (Core)
3039
+ *
3040
+ * Generic helper for extracting authenticated user information from requests.
3041
+ * Works with standard Web API Request (works everywhere).
3042
+ */
3043
+
3044
+ /**
3045
+ * Extract authenticated user information from a standard Web API Request.
3046
+ *
3047
+ * This is a generic, framework-agnostic helper that extracts user ID, email,
3048
+ * and name from authenticated requests. Works with any framework that uses
3049
+ * the standard Web API Request (Express, Fastify, Next.js, Edge Functions, etc.).
3050
+ *
3051
+ * Uses dynamic imports to avoid requiring @solvapay/auth at build time,
3052
+ * making it suitable for edge runtime environments.
3053
+ *
3054
+ * @param request - Standard Web API Request object
3055
+ * @param options - Configuration options
3056
+ * @param options.includeEmail - Whether to extract email from JWT token (default: true)
3057
+ * @param options.includeName - Whether to extract name from JWT token (default: true)
3058
+ * @returns Authenticated user info or error result
3059
+ *
3060
+ * @example
3061
+ * ```typescript
3062
+ * // In an API route handler
3063
+ * export async function GET(request: Request) {
3064
+ * const userResult = await getAuthenticatedUserCore(request);
3065
+ *
3066
+ * if (isErrorResult(userResult)) {
3067
+ * return Response.json(userResult, { status: userResult.status });
3068
+ * }
3069
+ *
3070
+ * const { userId, email, name } = userResult;
3071
+ * // Use user info...
3072
+ * }
3073
+ * ```
3074
+ *
3075
+ * @see {@link AuthenticatedUser} for the return type
3076
+ * @see {@link ErrorResult} for error handling
3077
+ * @since 1.0.0
3078
+ */
3079
+ declare function getAuthenticatedUserCore(request: Request, options?: {
3080
+ includeEmail?: boolean;
3081
+ includeName?: boolean;
3082
+ }): Promise<AuthenticatedUser | ErrorResult>;
3083
+
3084
+ /**
3085
+ * Customer Helper (Core)
3086
+ *
3087
+ * Generic helper for syncing customers with SolvaPay backend.
3088
+ * Works with standard Web API Request (works everywhere).
3089
+ */
3090
+
3091
+ /**
3092
+ * Sync customer with SolvaPay backend (ensure customer exists).
3093
+ *
3094
+ * This helper ensures a customer exists in the SolvaPay backend by:
3095
+ * 1. Extracting authenticated user information from the request
3096
+ * 2. Creating or retrieving the customer using the user ID as external reference
3097
+ * 3. Syncing customer data (email, name) if provided
3098
+ *
3099
+ * Uses `externalRef` for consistent lookup and prevents duplicate customers.
3100
+ * The returned customer reference is the SolvaPay backend customer ID.
3101
+ *
3102
+ * @param request - Standard Web API Request object
3103
+ * @param options - Configuration options
3104
+ * @param options.solvaPay - Optional SolvaPay instance (creates new one if not provided)
3105
+ * @param options.includeEmail - Whether to include email in customer data (default: true)
3106
+ * @param options.includeName - Whether to include name in customer data (default: true)
3107
+ * @returns Customer reference (backend customer ID) or error result
3108
+ *
3109
+ * @example
3110
+ * ```typescript
3111
+ * // In an API route handler
3112
+ * export async function POST(request: Request) {
3113
+ * const customerResult = await syncCustomerCore(request);
3114
+ *
3115
+ * if (isErrorResult(customerResult)) {
3116
+ * return Response.json(customerResult, { status: customerResult.status });
3117
+ * }
3118
+ *
3119
+ * const customerRef = customerResult;
3120
+ * // Use customer reference...
3121
+ * }
3122
+ * ```
3123
+ *
3124
+ * @see {@link getAuthenticatedUserCore} for user extraction
3125
+ * @see {@link ErrorResult} for error handling
3126
+ * @since 1.0.0
3127
+ */
3128
+ declare function syncCustomerCore(request: Request, options?: {
3129
+ solvaPay?: SolvaPay;
3130
+ includeEmail?: boolean;
3131
+ includeName?: boolean;
3132
+ }): Promise<string | ErrorResult>;
3133
+
3134
+ /**
3135
+ * Create a Stripe payment intent for a customer to purchase a plan.
3136
+ *
3137
+ * This is a framework-agnostic helper that:
3138
+ * 1. Extracts authenticated user from the request
3139
+ * 2. Syncs customer with SolvaPay backend
3140
+ * 3. Creates a payment intent for the specified plan
3141
+ *
3142
+ * The payment intent can then be confirmed on the client side using Stripe.js.
3143
+ * After confirmation, use `processPaymentIntentCore()` to complete the purchase.
3144
+ *
3145
+ * @param request - Standard Web API Request object
3146
+ * @param body - Payment intent parameters
3147
+ * @param body.planRef - Plan reference to purchase (required)
3148
+ * @param body.productRef - Product reference (required)
3149
+ * @param options - Configuration options
3150
+ * @param options.solvaPay - Optional SolvaPay instance (creates new one if not provided)
3151
+ * @param options.includeEmail - Whether to include email in customer data (default: true)
3152
+ * @param options.includeName - Whether to include name in customer data (default: true)
3153
+ * @returns Payment intent response with client secret and customer reference, or error result
3154
+ *
3155
+ * @example
3156
+ * ```typescript
3157
+ * // In an API route handler
3158
+ * export async function POST(request: Request) {
3159
+ * const body = await request.json();
3160
+ * const result = await createPaymentIntentCore(request, body);
3161
+ *
3162
+ * if (isErrorResult(result)) {
3163
+ * return Response.json(result, { status: result.status });
3164
+ * }
3165
+ *
3166
+ * return Response.json(result);
3167
+ * }
3168
+ * ```
3169
+ *
3170
+ * @see {@link processPaymentIntentCore} for processing confirmed payments
3171
+ * @see {@link ErrorResult} for error handling
3172
+ * @since 1.0.0
3173
+ */
3174
+ declare function createPaymentIntentCore(request: Request, body: {
3175
+ planRef: string;
3176
+ productRef: string;
3177
+ }, options?: {
3178
+ solvaPay?: SolvaPay;
3179
+ includeEmail?: boolean;
3180
+ includeName?: boolean;
3181
+ }): Promise<{
3182
+ id: string;
3183
+ clientSecret: string;
3184
+ publishableKey: string;
3185
+ accountId?: string;
3186
+ customerRef: string;
3187
+ } | ErrorResult>;
3188
+ /**
3189
+ * Process a payment intent after client-side Stripe confirmation.
3190
+ *
3191
+ * This helper processes a payment intent that has been confirmed on the client
3192
+ * side using Stripe.js. It creates the purchase immediately,
3193
+ * eliminating webhook delay.
3194
+ *
3195
+ * Call this after the client has confirmed the payment intent with Stripe.js.
3196
+ *
3197
+ * @param request - Standard Web API Request object
3198
+ * @param body - Payment processing parameters
3199
+ * @param body.paymentIntentId - Stripe payment intent ID from client confirmation (required)
3200
+ * @param body.productRef - Product reference (required)
3201
+ * @param body.planRef - Optional plan reference (if not in payment intent)
3202
+ * @param options - Configuration options
3203
+ * @param options.solvaPay - Optional SolvaPay instance (creates new one if not provided)
3204
+ * @returns Process payment result with purchase details, or error result
3205
+ *
3206
+ * @example
3207
+ * ```typescript
3208
+ * // In an API route handler
3209
+ * export async function POST(request: Request) {
3210
+ * const body = await request.json();
3211
+ * const result = await processPaymentIntentCore(request, body);
3212
+ *
3213
+ * if (isErrorResult(result)) {
3214
+ * return Response.json(result, { status: result.status });
3215
+ * }
3216
+ *
3217
+ * return Response.json(result);
3218
+ * }
3219
+ * ```
3220
+ *
3221
+ * @see {@link createPaymentIntentCore} for creating payment intents
3222
+ * @see {@link ErrorResult} for error handling
3223
+ * @since 1.0.0
3224
+ */
3225
+ declare function processPaymentIntentCore(request: Request, body: {
3226
+ paymentIntentId: string;
3227
+ productRef: string;
3228
+ planRef?: string;
3229
+ }, options?: {
3230
+ solvaPay?: SolvaPay;
3231
+ }): Promise<ProcessPaymentResult | ErrorResult>;
3232
+
3233
+ /**
3234
+ * Checkout Helpers (Core)
3235
+ *
3236
+ * Generic helpers for checkout session operations.
3237
+ * Works with standard Web API Request (works everywhere).
3238
+ */
3239
+
3240
+ /**
3241
+ * Create checkout session - core implementation
3242
+ *
3243
+ * @param request - Standard Web API Request
3244
+ * @param body - Checkout session parameters
3245
+ * @param options - Configuration options
3246
+ * @returns Checkout session response or error result
3247
+ */
3248
+ declare function createCheckoutSessionCore(request: Request, body: {
3249
+ productRef: string;
3250
+ planRef?: string;
3251
+ returnUrl?: string;
3252
+ }, options?: {
3253
+ solvaPay?: SolvaPay;
3254
+ includeEmail?: boolean;
3255
+ includeName?: boolean;
3256
+ returnUrl?: string;
3257
+ }): Promise<{
3258
+ sessionId: string;
3259
+ checkoutUrl: string;
3260
+ } | ErrorResult>;
3261
+ /**
3262
+ * Create customer session - core implementation
3263
+ *
3264
+ * @param request - Standard Web API Request
3265
+ * @param options - Configuration options
3266
+ * @returns Customer session response or error result
3267
+ */
3268
+ declare function createCustomerSessionCore(request: Request, options?: {
3269
+ solvaPay?: SolvaPay;
3270
+ includeEmail?: boolean;
3271
+ includeName?: boolean;
3272
+ }): Promise<{
3273
+ sessionId: string;
3274
+ customerUrl: string;
3275
+ } | ErrorResult>;
3276
+
3277
+ /**
3278
+ * Purchase Cancellation Helpers (Core)
3279
+ *
3280
+ * Generic helpers for purchase cancellation operations.
3281
+ * Works with standard Web API Request (works everywhere).
3282
+ */
3283
+
3284
+ /**
3285
+ * Cancel purchase - core implementation
3286
+ *
3287
+ * @param request - Standard Web API Request
3288
+ * @param body - Cancellation parameters
3289
+ * @param options - Configuration options
3290
+ * @returns Cancelled purchase response or error result
3291
+ */
3292
+ declare function cancelPurchaseCore(request: Request, body: {
3293
+ purchaseRef: string;
3294
+ reason?: string;
3295
+ }, options?: {
3296
+ solvaPay?: SolvaPay;
3297
+ }): Promise<Record<string, unknown> | ErrorResult>;
3298
+
3299
+ /**
3300
+ * Plans Helper (Core)
3301
+ *
3302
+ * Generic helper for listing plans.
3303
+ * Works with standard Web API Request (works everywhere).
3304
+ * This is a public route - no authentication required.
3305
+ */
3306
+
3307
+ /**
3308
+ * List plans - core implementation
3309
+ */
3310
+ declare function listPlansCore(request: Request): Promise<{
3311
+ plans: Record<string, unknown>[];
3312
+ productRef: string;
3313
+ } | ErrorResult>;
3314
+
999
3315
  /**
1000
3316
  * SolvaPay Server SDK
1001
3317
  *
@@ -1003,10 +3319,52 @@ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Pro
1003
3319
  * Provides unified payable API with explicit adapters for all frameworks.
1004
3320
  */
1005
3321
 
1006
- declare function verifyWebhook({ body, signature, secret }: {
3322
+ /**
3323
+ * Verify webhook signature from SolvaPay backend.
3324
+ *
3325
+ * The backend sends an `SV-Signature` header in the format `t={timestamp},v1={hmac}`.
3326
+ * The HMAC is SHA-256 over `"{timestamp}.{rawBody}"` keyed by the full webhook secret
3327
+ * (including the `whsec_` prefix). Signatures older than 5 minutes are rejected to
3328
+ * prevent replay attacks.
3329
+ *
3330
+ * @param params - Webhook verification parameters
3331
+ * @param params.body - Raw request body as string (must be exactly as received)
3332
+ * @param params.signature - Value of the `SV-Signature` header
3333
+ * @param params.secret - Webhook signing secret from SolvaPay dashboard (`whsec_…`)
3334
+ * @returns Parsed and typed {@link WebhookEvent} object
3335
+ * @throws {SolvaPayError} If signature is missing, malformed, expired, or invalid
3336
+ *
3337
+ * @example
3338
+ * ```typescript
3339
+ * import { verifyWebhook } from '@solvapay/server';
3340
+ *
3341
+ * // Express.js — use express.raw() so the body is not parsed
3342
+ * app.post('/webhooks/solvapay', express.raw({ type: 'application/json' }), (req, res) => {
3343
+ * try {
3344
+ * const event = verifyWebhook({
3345
+ * body: req.body.toString(),
3346
+ * signature: req.headers['sv-signature'] as string,
3347
+ * secret: process.env.SOLVAPAY_WEBHOOK_SECRET!,
3348
+ * });
3349
+ *
3350
+ * if (event.type === 'purchase.created') {
3351
+ * // …
3352
+ * }
3353
+ *
3354
+ * res.json({ received: true });
3355
+ * } catch (error) {
3356
+ * res.status(401).json({ error: 'Invalid signature' });
3357
+ * }
3358
+ * });
3359
+ * ```
3360
+ *
3361
+ * @see [Webhook Guide](../../../docs/guides/webhooks.md) for complete webhook handling examples
3362
+ * @since 1.0.0
3363
+ */
3364
+ declare function verifyWebhook({ body, signature, secret, }: {
1007
3365
  body: string;
1008
3366
  signature: string;
1009
3367
  secret: string;
1010
- }): any;
3368
+ }): WebhookEvent;
1011
3369
 
1012
- export { type CreateSolvaPayConfig, type CustomerResponseMapped, type HttpAdapterOptions, type McpAdapterOptions, type NextAdapterOptions, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type ProcessPaymentResult, type PurchaseInfo, type RetryOptions, type ServerClientOptions, type SolvaPay, type SolvaPayClient, createSolvaPay, createSolvaPayClient, verifyWebhook, withRetry };
3370
+ export { type AuthenticatedUser, type CreateSolvaPayConfig, type CustomerResponseMapped, type ErrorResult, type HttpAdapterOptions, type McpAdapterOptions, McpBearerAuthError, type McpBootstrapFreePlanConfig, type McpBootstrapPaidPlanInput, type McpBootstrapRequest, type McpBootstrapResponse, type NextAdapterOptions, type OneTimePurchaseInfo, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type ProcessPaymentResult, type RetryOptions, type ServerClientOptions, type SolvaPay, type SolvaPayClient, type ToolPlanMappingInput, VIRTUAL_TOOL_DEFINITIONS, type VirtualToolDefinition, type VirtualToolsOptions, type WebhookEvent, type WebhookEventType, cancelPurchaseCore, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createVirtualTools, decodeJwtPayload, extractBearerToken, getAuthenticatedUserCore, getCustomerRefFromBearerAuthHeader, getCustomerRefFromJwtPayload, handleRouteError, isErrorResult, listPlansCore, processPaymentIntentCore, syncCustomerCore, verifyWebhook, withRetry };