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