@solvapay/server 1.0.0-preview.19 → 1.0.0-preview.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edge.d.ts +431 -397
- package/dist/edge.js +181 -154
- package/dist/index.cjs +183 -156
- package/dist/index.d.cts +433 -399
- package/dist/index.d.ts +433 -399
- package/dist/index.js +181 -154
- package/package.json +5 -5
package/dist/edge.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
interface components {
|
|
2
2
|
schemas: {
|
|
3
|
-
|
|
3
|
+
UpdateProviderDto: Record<string, never>;
|
|
4
4
|
CreateSecretKey: Record<string, never>;
|
|
5
5
|
CheckName: Record<string, never>;
|
|
6
6
|
CreateAdminAgent: Record<string, never>;
|
|
7
7
|
UpdateAdminAgent: Record<string, never>;
|
|
8
|
-
|
|
8
|
+
Agent: Record<string, never>;
|
|
9
9
|
CreateAgentRequest: Record<string, never>;
|
|
10
10
|
UpdateAgentRequest: Record<string, never>;
|
|
11
11
|
Signup: Record<string, never>;
|
|
@@ -20,80 +20,105 @@ interface components {
|
|
|
20
20
|
UpdatePreferences: Record<string, never>;
|
|
21
21
|
ChangePassword: Record<string, never>;
|
|
22
22
|
RequestEmailChange: Record<string, never>;
|
|
23
|
-
|
|
23
|
+
CreateProductRequest: {
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
25
|
+
* Product name
|
|
26
|
+
* @example AI Writing Assistant
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
name: string;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
30
|
+
* Product description
|
|
31
|
+
* @example AI-powered writing tool
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
description?: string;
|
|
34
|
+
/** URL to the product image */
|
|
35
|
+
imageUrl?: string;
|
|
34
36
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
+
* Free-form product type defined by the provider
|
|
38
|
+
* @example Coding Assistant
|
|
37
39
|
*/
|
|
38
|
-
|
|
40
|
+
productType?: string;
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
42
|
+
* Whether this product uses MCP Pay proxy
|
|
43
|
+
* @default false
|
|
42
44
|
*/
|
|
43
|
-
|
|
45
|
+
isMcpPay: boolean;
|
|
46
|
+
/** Product-specific configuration */
|
|
47
|
+
config?: Record<string, never>;
|
|
48
|
+
/** Arbitrary key-value metadata */
|
|
49
|
+
metadata?: Record<string, never>;
|
|
44
50
|
};
|
|
45
|
-
|
|
51
|
+
SdkProductResponse: {
|
|
46
52
|
/**
|
|
47
|
-
*
|
|
53
|
+
* Product ID
|
|
48
54
|
* @example 507f1f77bcf86cd799439011
|
|
49
55
|
*/
|
|
50
56
|
id: string;
|
|
51
57
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
*/
|
|
55
|
-
sessionId: string;
|
|
56
|
-
/**
|
|
57
|
-
* Amount in cents
|
|
58
|
-
* @example 2999
|
|
58
|
+
* Product reference
|
|
59
|
+
* @example prd_1A2B3C4D
|
|
59
60
|
*/
|
|
60
|
-
|
|
61
|
+
reference: string;
|
|
61
62
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
63
|
+
* Product name
|
|
64
|
+
* @example AI Writing Assistant
|
|
64
65
|
*/
|
|
65
|
-
|
|
66
|
+
name: string;
|
|
67
|
+
/** Product description */
|
|
68
|
+
description?: string;
|
|
69
|
+
/** URL to the product image */
|
|
70
|
+
imageUrl?: string;
|
|
71
|
+
/** Free-form product type */
|
|
72
|
+
productType?: string;
|
|
66
73
|
/**
|
|
67
|
-
*
|
|
74
|
+
* Product status
|
|
68
75
|
* @example active
|
|
69
76
|
*/
|
|
70
77
|
status: string;
|
|
71
78
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
79
|
+
* Product balance in cents
|
|
80
|
+
* @example 0
|
|
74
81
|
*/
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
CancelSubscriptionRequest: {
|
|
82
|
+
balance: number;
|
|
78
83
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
84
|
+
* Total number of transactions
|
|
85
|
+
* @example 0
|
|
81
86
|
*/
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
CreateConnectedAccount: Record<string, never>;
|
|
85
|
-
UpdateConnectedAccount: Record<string, never>;
|
|
86
|
-
CreateCheckoutSessionResponse: {
|
|
87
|
+
totalTransactions: number;
|
|
87
88
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
89
|
+
* Whether this product uses MCP Pay proxy
|
|
90
|
+
* @example false
|
|
90
91
|
*/
|
|
91
|
-
|
|
92
|
+
isMcpPay: boolean;
|
|
93
|
+
/** Product-specific configuration */
|
|
94
|
+
config?: Record<string, never>;
|
|
95
|
+
/** Arbitrary key-value metadata */
|
|
96
|
+
metadata?: Record<string, never>;
|
|
97
|
+
/** Creation timestamp */
|
|
98
|
+
createdAt: string;
|
|
99
|
+
/** Last update timestamp */
|
|
100
|
+
updatedAt: string;
|
|
101
|
+
/** Plans associated with this product */
|
|
102
|
+
plans?: string[];
|
|
103
|
+
};
|
|
104
|
+
UpdateProductRequest: {
|
|
105
|
+
/** Product name */
|
|
106
|
+
name?: string;
|
|
107
|
+
/** Product description */
|
|
108
|
+
description?: string;
|
|
109
|
+
/** URL to the product image */
|
|
110
|
+
imageUrl?: string;
|
|
111
|
+
/** Free-form product type defined by the provider */
|
|
112
|
+
productType?: string;
|
|
92
113
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @
|
|
114
|
+
* Product status
|
|
115
|
+
* @enum {string}
|
|
95
116
|
*/
|
|
96
|
-
|
|
117
|
+
status?: "active" | "inactive" | "suspended";
|
|
118
|
+
/** Product-specific configuration */
|
|
119
|
+
config?: Record<string, never>;
|
|
120
|
+
/** Arbitrary key-value metadata */
|
|
121
|
+
metadata?: Record<string, never>;
|
|
97
122
|
};
|
|
98
123
|
CreatePlanRequest: {
|
|
99
124
|
/**
|
|
@@ -113,7 +138,7 @@ interface components {
|
|
|
113
138
|
*/
|
|
114
139
|
type?: "recurring" | "usage-based" | "hybrid" | "one-time";
|
|
115
140
|
/**
|
|
116
|
-
* Billing cycle
|
|
141
|
+
* Billing cycle (required for recurring/hybrid, optional for post-paid usage-based)
|
|
117
142
|
* @example monthly
|
|
118
143
|
* @enum {string}
|
|
119
144
|
*/
|
|
@@ -144,8 +169,6 @@ interface components {
|
|
|
144
169
|
* @example 100
|
|
145
170
|
*/
|
|
146
171
|
freeUnits?: number;
|
|
147
|
-
/** @description Optional agent ID to associate plan with (not stored on plan, only used for initial association) */
|
|
148
|
-
agentId?: string;
|
|
149
172
|
/**
|
|
150
173
|
* Billing model for usage-based plans
|
|
151
174
|
* @example pre-paid
|
|
@@ -178,16 +201,14 @@ interface components {
|
|
|
178
201
|
*/
|
|
179
202
|
basePrice?: number;
|
|
180
203
|
/**
|
|
181
|
-
* Usage limits
|
|
204
|
+
* Usage limits (shape varies by plan type)
|
|
182
205
|
* @example {
|
|
183
|
-
* "maxTransactions": 1000
|
|
184
|
-
* "maxCalls": 500,
|
|
185
|
-
* "maxHours": 24
|
|
206
|
+
* "maxTransactions": 1000
|
|
186
207
|
* }
|
|
187
208
|
*/
|
|
188
209
|
limits?: Record<string, never>;
|
|
189
210
|
/**
|
|
190
|
-
* Plan features (
|
|
211
|
+
* Plan features (generic key/value, shape is provider-defined)
|
|
191
212
|
* @example {
|
|
192
213
|
* "apiAccess": true,
|
|
193
214
|
* "prioritySupport": false
|
|
@@ -205,10 +226,11 @@ interface components {
|
|
|
205
226
|
*/
|
|
206
227
|
requiresPayment?: boolean;
|
|
207
228
|
/**
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
229
|
+
* Plan status
|
|
230
|
+
* @example active
|
|
231
|
+
* @enum {string}
|
|
210
232
|
*/
|
|
211
|
-
|
|
233
|
+
status?: "active" | "inactive" | "archived";
|
|
212
234
|
/**
|
|
213
235
|
* Maximum number of active users
|
|
214
236
|
* @example 10
|
|
@@ -219,10 +241,8 @@ interface components {
|
|
|
219
241
|
* @example 30
|
|
220
242
|
*/
|
|
221
243
|
accessExpiryDays?: number;
|
|
222
|
-
/**
|
|
244
|
+
/** Additional metadata */
|
|
223
245
|
metadata?: Record<string, never>;
|
|
224
|
-
/** @description Usage tracking (internal use, not validated) */
|
|
225
|
-
customerUsage?: Record<string, never>;
|
|
226
246
|
/**
|
|
227
247
|
* Whether this is the default plan
|
|
228
248
|
* @example false
|
|
@@ -230,7 +250,95 @@ interface components {
|
|
|
230
250
|
default?: boolean;
|
|
231
251
|
};
|
|
232
252
|
UpdatePlanRequest: Record<string, never>;
|
|
233
|
-
|
|
253
|
+
CreateCheckoutSessionRequest: {
|
|
254
|
+
/**
|
|
255
|
+
* Customer reference
|
|
256
|
+
* @example cus_3c4d5e6f7g8h
|
|
257
|
+
*/
|
|
258
|
+
customerReference: string;
|
|
259
|
+
/**
|
|
260
|
+
* Plan reference (optional)
|
|
261
|
+
* @example pln_2b3c4d5e6f7g
|
|
262
|
+
*/
|
|
263
|
+
planRef?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Product reference (required)
|
|
266
|
+
* @example prd_1a2b3c4d5e6f
|
|
267
|
+
*/
|
|
268
|
+
productRef: string;
|
|
269
|
+
};
|
|
270
|
+
CheckoutSessionResponse: {
|
|
271
|
+
/**
|
|
272
|
+
* Checkout session ID
|
|
273
|
+
* @example 507f1f77bcf86cd799439011
|
|
274
|
+
*/
|
|
275
|
+
id: string;
|
|
276
|
+
/**
|
|
277
|
+
* Public session ID used in checkout URL
|
|
278
|
+
* @example a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
|
|
279
|
+
*/
|
|
280
|
+
sessionId: string;
|
|
281
|
+
/**
|
|
282
|
+
* Amount in cents
|
|
283
|
+
* @example 2999
|
|
284
|
+
*/
|
|
285
|
+
amount: number;
|
|
286
|
+
/**
|
|
287
|
+
* Currency code
|
|
288
|
+
* @example USD
|
|
289
|
+
*/
|
|
290
|
+
currency: string;
|
|
291
|
+
/**
|
|
292
|
+
* Session status
|
|
293
|
+
* @example active
|
|
294
|
+
*/
|
|
295
|
+
status: string;
|
|
296
|
+
/**
|
|
297
|
+
* Checkout URL to open the checkout page
|
|
298
|
+
* @example https://solvapay.com/customer/checkout?id=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
|
|
299
|
+
*/
|
|
300
|
+
checkoutUrl: string;
|
|
301
|
+
};
|
|
302
|
+
CancelRenewalRequest: Record<string, never>;
|
|
303
|
+
UpdateConnectedAccount: Record<string, never>;
|
|
304
|
+
CancelPurchaseRequest: {
|
|
305
|
+
/** Reason for cancellation */
|
|
306
|
+
reason?: string;
|
|
307
|
+
};
|
|
308
|
+
CheckLimitRequest: {
|
|
309
|
+
/**
|
|
310
|
+
* Customer reference identifier
|
|
311
|
+
* @example cus_3C4D5E6F
|
|
312
|
+
*/
|
|
313
|
+
customerRef: string;
|
|
314
|
+
/**
|
|
315
|
+
* Product reference identifier
|
|
316
|
+
* @example prd_1A2B3C4D
|
|
317
|
+
*/
|
|
318
|
+
productRef: string;
|
|
319
|
+
};
|
|
320
|
+
LimitResponse: {
|
|
321
|
+
/**
|
|
322
|
+
* Whether the customer is within their usage limits
|
|
323
|
+
* @example true
|
|
324
|
+
*/
|
|
325
|
+
withinLimits: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Remaining usage units before hitting the limit
|
|
328
|
+
* @example 997
|
|
329
|
+
*/
|
|
330
|
+
remaining: number;
|
|
331
|
+
/**
|
|
332
|
+
* Checkout session ID if payment is required
|
|
333
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
334
|
+
*/
|
|
335
|
+
checkoutSessionId?: string;
|
|
336
|
+
/**
|
|
337
|
+
* Checkout URL if payment is required
|
|
338
|
+
* @example https://solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
|
|
339
|
+
*/
|
|
340
|
+
checkoutUrl?: string;
|
|
341
|
+
};
|
|
234
342
|
CreateCustomerSessionRequest: {
|
|
235
343
|
/**
|
|
236
344
|
* Customer reference identifier
|
|
@@ -277,9 +385,9 @@ interface components {
|
|
|
277
385
|
*/
|
|
278
386
|
externalRef?: string;
|
|
279
387
|
};
|
|
280
|
-
|
|
388
|
+
PurchaseInfo: {
|
|
281
389
|
/**
|
|
282
|
-
*
|
|
390
|
+
* Purchase reference
|
|
283
391
|
* @example sub_abc123
|
|
284
392
|
*/
|
|
285
393
|
reference: string;
|
|
@@ -289,12 +397,12 @@ interface components {
|
|
|
289
397
|
*/
|
|
290
398
|
planName: string;
|
|
291
399
|
/**
|
|
292
|
-
*
|
|
293
|
-
* @example
|
|
400
|
+
* Product reference
|
|
401
|
+
* @example prd_abc123
|
|
294
402
|
*/
|
|
295
|
-
|
|
403
|
+
productReference?: string;
|
|
296
404
|
/**
|
|
297
|
-
*
|
|
405
|
+
* Purchase status
|
|
298
406
|
* @example active
|
|
299
407
|
*/
|
|
300
408
|
status: string;
|
|
@@ -314,12 +422,12 @@ interface components {
|
|
|
314
422
|
*/
|
|
315
423
|
currency: string;
|
|
316
424
|
/**
|
|
317
|
-
* End date of
|
|
425
|
+
* End date of purchase
|
|
318
426
|
* @example 2025-11-27T10:00:00Z
|
|
319
427
|
*/
|
|
320
428
|
endDate?: string;
|
|
321
429
|
/**
|
|
322
|
-
* When
|
|
430
|
+
* When purchase was cancelled
|
|
323
431
|
* @example 2025-10-28T10:00:00Z
|
|
324
432
|
*/
|
|
325
433
|
cancelledAt?: string;
|
|
@@ -350,8 +458,8 @@ interface components {
|
|
|
350
458
|
* @example auth_user_12345
|
|
351
459
|
*/
|
|
352
460
|
externalRef?: string;
|
|
353
|
-
/**
|
|
354
|
-
|
|
461
|
+
/** Active purchases */
|
|
462
|
+
purchases?: components["schemas"]["PurchaseInfo"][];
|
|
355
463
|
};
|
|
356
464
|
CreateCustomerSessionResponse: {
|
|
357
465
|
/**
|
|
@@ -387,7 +495,7 @@ interface components {
|
|
|
387
495
|
* @example 2025-01-01T12:00:00.000Z
|
|
388
496
|
*/
|
|
389
497
|
expiresAt: string;
|
|
390
|
-
/**
|
|
498
|
+
/** Customer object from session data */
|
|
391
499
|
customer: components["schemas"]["CustomerResponse"];
|
|
392
500
|
/**
|
|
393
501
|
* Session creation date
|
|
@@ -400,252 +508,173 @@ interface components {
|
|
|
400
508
|
*/
|
|
401
509
|
updatedAt: string;
|
|
402
510
|
};
|
|
403
|
-
|
|
404
|
-
|
|
511
|
+
DynamicClientRegistrationDto: {
|
|
512
|
+
/** @example My AI Agent */
|
|
513
|
+
client_name: string;
|
|
514
|
+
/**
|
|
515
|
+
* @example [
|
|
516
|
+
* "https://agent.example.com/callback"
|
|
517
|
+
* ]
|
|
518
|
+
*/
|
|
519
|
+
redirect_uris: string[];
|
|
520
|
+
/**
|
|
521
|
+
* @example [
|
|
522
|
+
* "authorization_code",
|
|
523
|
+
* "refresh_token"
|
|
524
|
+
* ]
|
|
525
|
+
*/
|
|
526
|
+
grant_types?: string[];
|
|
527
|
+
/**
|
|
528
|
+
* @example [
|
|
529
|
+
* "code"
|
|
530
|
+
* ]
|
|
531
|
+
*/
|
|
532
|
+
response_types?: string[];
|
|
533
|
+
/** @example agent-123 */
|
|
534
|
+
software_id?: string;
|
|
535
|
+
/** @example 1.0.0 */
|
|
536
|
+
software_version?: string;
|
|
537
|
+
/** @example https://example.com/logo.png */
|
|
538
|
+
logo_uri?: string;
|
|
539
|
+
/** @example https://example.com/tos */
|
|
540
|
+
tos_uri?: string;
|
|
541
|
+
/** @example https://example.com/policy */
|
|
542
|
+
policy_uri?: string;
|
|
543
|
+
/** @example https://example.com */
|
|
544
|
+
client_uri?: string;
|
|
545
|
+
};
|
|
546
|
+
DynamicClientRegistrationResponseDto: {
|
|
547
|
+
/** @example client-id-123 */
|
|
548
|
+
client_id: string;
|
|
549
|
+
/** @example client-secret-456 */
|
|
550
|
+
client_secret: string;
|
|
551
|
+
/** @example 1734567890 */
|
|
552
|
+
client_id_issued_at: number;
|
|
553
|
+
/** @example 0 */
|
|
554
|
+
client_secret_expires_at: number;
|
|
555
|
+
/** @example My AI Agent */
|
|
556
|
+
client_name: string;
|
|
557
|
+
/**
|
|
558
|
+
* @example [
|
|
559
|
+
* "https://agent.example.com/callback"
|
|
560
|
+
* ]
|
|
561
|
+
*/
|
|
562
|
+
redirect_uris: string[];
|
|
563
|
+
/**
|
|
564
|
+
* @example [
|
|
565
|
+
* "authorization_code",
|
|
566
|
+
* "refresh_token"
|
|
567
|
+
* ]
|
|
568
|
+
*/
|
|
569
|
+
grant_types: string[];
|
|
570
|
+
/**
|
|
571
|
+
* @example [
|
|
572
|
+
* "code"
|
|
573
|
+
* ]
|
|
574
|
+
*/
|
|
575
|
+
response_types: string[];
|
|
576
|
+
/** @example openid profile email */
|
|
577
|
+
scope: string;
|
|
578
|
+
/** @example client_secret_basic */
|
|
579
|
+
token_endpoint_auth_method: string;
|
|
580
|
+
};
|
|
405
581
|
GoogleLoginDto: {
|
|
406
|
-
/**
|
|
582
|
+
/** The authorization code returned by Google */
|
|
407
583
|
code: string;
|
|
408
|
-
/**
|
|
584
|
+
/** The redirect URI used in the initial authorization request */
|
|
409
585
|
redirect_uri: string;
|
|
410
|
-
/**
|
|
586
|
+
/** The state parameter returned by Google (contains client_id) */
|
|
411
587
|
state: string;
|
|
412
588
|
};
|
|
413
589
|
GithubLoginDto: {
|
|
414
|
-
/**
|
|
590
|
+
/** The authorization code returned by GitHub */
|
|
415
591
|
code: string;
|
|
416
|
-
/**
|
|
592
|
+
/** The redirect URI used in the initial authorization request */
|
|
417
593
|
redirect_uri: string;
|
|
418
|
-
/**
|
|
594
|
+
/** The state parameter returned by GitHub (contains client_id) */
|
|
419
595
|
state: string;
|
|
420
596
|
};
|
|
421
597
|
ExecuteAnalyticsQuery: Record<string, never>;
|
|
422
598
|
ExecuteMultipleQueries: Record<string, never>;
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Subscription reference identifier
|
|
426
|
-
* @example sub_1a2b3c4d5e6f
|
|
427
|
-
*/
|
|
428
|
-
reference: string;
|
|
429
|
-
/**
|
|
430
|
-
* Customer reference identifier
|
|
431
|
-
* @example cus_3c4d5e6f7g8h
|
|
432
|
-
*/
|
|
433
|
-
customerRef: string;
|
|
434
|
-
/**
|
|
435
|
-
* Customer email
|
|
436
|
-
* @example customer@example.com
|
|
437
|
-
*/
|
|
438
|
-
customerEmail: string;
|
|
439
|
-
/**
|
|
440
|
-
* Customer name
|
|
441
|
-
* @example John Doe
|
|
442
|
-
*/
|
|
443
|
-
customerName?: string;
|
|
444
|
-
/**
|
|
445
|
-
* Agent reference identifier
|
|
446
|
-
* @example agt_1a2b3c4d5e6f
|
|
447
|
-
*/
|
|
448
|
-
agentRef: string;
|
|
449
|
-
/**
|
|
450
|
-
* Agent name
|
|
451
|
-
* @example My AI Agent
|
|
452
|
-
*/
|
|
453
|
-
agentName: string;
|
|
454
|
-
/**
|
|
455
|
-
* Plan reference identifier
|
|
456
|
-
* @example pln_1a2b3c4d5e6f
|
|
457
|
-
*/
|
|
458
|
-
planRef: string;
|
|
459
|
-
/**
|
|
460
|
-
* Plan name
|
|
461
|
-
* @example Premium Plan
|
|
462
|
-
*/
|
|
463
|
-
planName: string;
|
|
464
|
-
/**
|
|
465
|
-
* Plan type
|
|
466
|
-
* @example recurring
|
|
467
|
-
* @enum {string}
|
|
468
|
-
*/
|
|
469
|
-
planType: "recurring" | "usage-based" | "one-time" | "hybrid";
|
|
599
|
+
UpdateThemePreferenceDto: {
|
|
470
600
|
/**
|
|
471
|
-
*
|
|
472
|
-
* @example
|
|
601
|
+
* Selected UI theme mode
|
|
602
|
+
* @example dark
|
|
473
603
|
* @enum {string}
|
|
474
604
|
*/
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Amount paid in original currency (in cents)
|
|
478
|
-
* @example 9900
|
|
479
|
-
*/
|
|
480
|
-
amount: number;
|
|
481
|
-
/**
|
|
482
|
-
* Currency code
|
|
483
|
-
* @example USD
|
|
484
|
-
*/
|
|
485
|
-
currency: string;
|
|
486
|
-
/**
|
|
487
|
-
* Start date of subscription
|
|
488
|
-
* @example 2025-01-01T00:00:00.000Z
|
|
489
|
-
*/
|
|
490
|
-
startDate: string;
|
|
491
|
-
/**
|
|
492
|
-
* End date of subscription (if applicable)
|
|
493
|
-
* @example 2025-02-01T00:00:00.000Z
|
|
494
|
-
*/
|
|
495
|
-
endDate?: string;
|
|
496
|
-
/**
|
|
497
|
-
* When payment was confirmed
|
|
498
|
-
* @example 2025-01-01T00:00:00.000Z
|
|
499
|
-
*/
|
|
500
|
-
paidAt?: string;
|
|
501
|
-
/** @description Usage quota information (for usage-based plans) */
|
|
502
|
-
usageQuota?: Record<string, never>;
|
|
503
|
-
/**
|
|
504
|
-
* Whether this is a recurring subscription
|
|
505
|
-
* @example true
|
|
506
|
-
*/
|
|
507
|
-
isRecurring: boolean;
|
|
508
|
-
/**
|
|
509
|
-
* Next billing date (for recurring subscriptions)
|
|
510
|
-
* @example 2025-02-01T00:00:00.000Z
|
|
511
|
-
*/
|
|
512
|
-
nextBillingDate?: string;
|
|
513
|
-
/**
|
|
514
|
-
* When subscription was cancelled (if applicable)
|
|
515
|
-
* @example 2025-01-15T00:00:00.000Z
|
|
516
|
-
*/
|
|
517
|
-
cancelledAt?: string;
|
|
518
|
-
/**
|
|
519
|
-
* Reason for cancellation (if applicable)
|
|
520
|
-
* @example Customer request
|
|
521
|
-
*/
|
|
522
|
-
cancellationReason?: string;
|
|
523
|
-
/**
|
|
524
|
-
* When subscription was created
|
|
525
|
-
* @example 2025-01-01T00:00:00.000Z
|
|
526
|
-
*/
|
|
527
|
-
createdAt: string;
|
|
528
|
-
};
|
|
529
|
-
CheckLimitRequest: {
|
|
530
|
-
/**
|
|
531
|
-
* Customer reference identifier
|
|
532
|
-
* @example cus_3c4d5e6f7g8h
|
|
533
|
-
*/
|
|
534
|
-
customerRef: string;
|
|
535
|
-
/**
|
|
536
|
-
* Agent reference identifier
|
|
537
|
-
* @example agt_1a2b3c4d5e6f
|
|
538
|
-
*/
|
|
539
|
-
agentRef: string;
|
|
540
|
-
};
|
|
541
|
-
LimitResponse: {
|
|
542
|
-
/**
|
|
543
|
-
* Whether the customer is within their usage limits
|
|
544
|
-
* @example true
|
|
545
|
-
*/
|
|
546
|
-
withinLimits: boolean;
|
|
547
|
-
/**
|
|
548
|
-
* Remaining usage units before hitting the limit
|
|
549
|
-
* @example 997
|
|
550
|
-
*/
|
|
551
|
-
remaining: number;
|
|
552
|
-
/**
|
|
553
|
-
* Optional checkout session ID/token if payment is required
|
|
554
|
-
* @example e3f1c2d4b6a89f001122334455667788
|
|
555
|
-
*/
|
|
556
|
-
checkoutSessionId?: string;
|
|
557
|
-
/**
|
|
558
|
-
* Optional full checkout URL if payment is required (based on backend configuration)
|
|
559
|
-
* @example https://app.solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
|
|
560
|
-
*/
|
|
561
|
-
checkoutUrl?: string;
|
|
605
|
+
mode: "light" | "dark";
|
|
562
606
|
};
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Customer reference identifier
|
|
566
|
-
* @example cus_3c4d5e6f7g8h
|
|
567
|
-
*/
|
|
568
|
-
customerRef: string;
|
|
569
|
-
/**
|
|
570
|
-
* Agent reference identifier
|
|
571
|
-
* @example agt_1a2b3c4d5e6f
|
|
572
|
-
*/
|
|
573
|
-
agentRef: string;
|
|
574
|
-
/**
|
|
575
|
-
* Outcome of the action
|
|
576
|
-
* @example success
|
|
577
|
-
* @enum {string}
|
|
578
|
-
*/
|
|
579
|
-
outcome: "success" | "paywall" | "fail";
|
|
607
|
+
ThemeModeColorsDto: {
|
|
580
608
|
/**
|
|
581
|
-
*
|
|
582
|
-
* @example
|
|
609
|
+
* Page background color
|
|
610
|
+
* @example #f7f7f8
|
|
583
611
|
*/
|
|
584
|
-
|
|
612
|
+
background?: string;
|
|
585
613
|
/**
|
|
586
|
-
*
|
|
587
|
-
* @example
|
|
614
|
+
* Card/surface background color
|
|
615
|
+
* @example #ffffff
|
|
588
616
|
*/
|
|
589
|
-
|
|
617
|
+
surface?: string;
|
|
590
618
|
/**
|
|
591
|
-
*
|
|
592
|
-
* @example
|
|
619
|
+
* Primary text color
|
|
620
|
+
* @example #181818
|
|
593
621
|
*/
|
|
594
|
-
|
|
622
|
+
text?: string;
|
|
595
623
|
/**
|
|
596
|
-
*
|
|
597
|
-
* @example
|
|
624
|
+
* Secondary/muted text color
|
|
625
|
+
* @example #5c5c5c
|
|
598
626
|
*/
|
|
599
|
-
|
|
627
|
+
secondary?: string;
|
|
600
628
|
};
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
*/
|
|
607
|
-
mode: "light" | "dark";
|
|
629
|
+
ThemeOverridesDto: {
|
|
630
|
+
/** Light mode color overrides */
|
|
631
|
+
light?: components["schemas"]["ThemeModeColorsDto"];
|
|
632
|
+
/** Dark mode color overrides */
|
|
633
|
+
dark?: components["schemas"]["ThemeModeColorsDto"];
|
|
608
634
|
};
|
|
609
|
-
|
|
610
|
-
/** @description Page identifier */
|
|
611
|
-
id: string;
|
|
612
|
-
/** @description Page display name */
|
|
613
|
-
name: string;
|
|
614
|
-
/** @description Logo URL */
|
|
615
|
-
logo?: string;
|
|
635
|
+
UpdateBrandThemeDto: {
|
|
616
636
|
/**
|
|
617
|
-
*
|
|
618
|
-
* @example
|
|
637
|
+
* Provider's brand name displayed on hosted pages
|
|
638
|
+
* @example Acme Corp
|
|
619
639
|
*/
|
|
620
|
-
|
|
640
|
+
brandName: string;
|
|
621
641
|
/**
|
|
622
|
-
*
|
|
642
|
+
* Primary/accent color in hex format
|
|
623
643
|
* @example #3182ce
|
|
624
644
|
*/
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Left background color in hex format
|
|
628
|
-
* @example #f7fafc
|
|
629
|
-
*/
|
|
630
|
-
leftBackgroundColor: string;
|
|
631
|
-
/**
|
|
632
|
-
* Right background color in hex format
|
|
633
|
-
* @example #ffffff
|
|
634
|
-
*/
|
|
635
|
-
rightBackgroundColor: string;
|
|
645
|
+
primaryColor: string;
|
|
636
646
|
/**
|
|
637
|
-
* Font family
|
|
647
|
+
* Font family for hosted pages
|
|
648
|
+
* @default Inter
|
|
638
649
|
* @example Inter
|
|
639
650
|
*/
|
|
640
651
|
fontFamily: string;
|
|
641
652
|
/**
|
|
642
|
-
*
|
|
653
|
+
* Base font size
|
|
654
|
+
* @default 16px
|
|
643
655
|
* @example 16px
|
|
644
656
|
*/
|
|
645
657
|
fontSize: string;
|
|
658
|
+
/** Per-mode color overrides for light and dark themes */
|
|
659
|
+
themes?: components["schemas"]["ThemeOverridesDto"];
|
|
646
660
|
};
|
|
647
661
|
CreateWebhookEndpointDto: Record<string, never>;
|
|
648
662
|
UpdateWebhookEndpointDto: Record<string, never>;
|
|
663
|
+
CreatePreregistrationDto: {
|
|
664
|
+
/** @example jane@company.com */
|
|
665
|
+
email: string;
|
|
666
|
+
/** @example Jane Smith */
|
|
667
|
+
fullName: string;
|
|
668
|
+
/** @example Acme Corp */
|
|
669
|
+
companyName: string;
|
|
670
|
+
/** @example SaaS */
|
|
671
|
+
businessType?: string;
|
|
672
|
+
/** @example Purchase billing for our platform */
|
|
673
|
+
useCase?: string;
|
|
674
|
+
customFields?: {
|
|
675
|
+
[key: string]: string;
|
|
676
|
+
};
|
|
677
|
+
};
|
|
649
678
|
};
|
|
650
679
|
responses: never;
|
|
651
680
|
parameters: never;
|
|
@@ -669,9 +698,8 @@ type LimitResponseWithPlan = components['schemas']['LimitResponse'] & {
|
|
|
669
698
|
/**
|
|
670
699
|
* Extended CustomerResponse with proper field mapping
|
|
671
700
|
*
|
|
672
|
-
* Note: The backend API
|
|
673
|
-
*
|
|
674
|
-
* These additional fields are preserved in the subscriptions array.
|
|
701
|
+
* Note: The backend API returns purchases as PurchaseInfo objects.
|
|
702
|
+
* Additional fields (paidAt, nextBillingDate) may be present in the response.
|
|
675
703
|
*/
|
|
676
704
|
type CustomerResponseMapped = {
|
|
677
705
|
customerRef: string;
|
|
@@ -679,12 +707,15 @@ type CustomerResponseMapped = {
|
|
|
679
707
|
name?: string;
|
|
680
708
|
externalRef?: string;
|
|
681
709
|
plan?: string;
|
|
682
|
-
|
|
710
|
+
purchases?: Array<components['schemas']['PurchaseInfo'] & {
|
|
711
|
+
paidAt?: string;
|
|
712
|
+
nextBillingDate?: string;
|
|
713
|
+
}>;
|
|
683
714
|
};
|
|
684
715
|
/**
|
|
685
|
-
*
|
|
716
|
+
* One-time purchase information returned from payment processing
|
|
686
717
|
*/
|
|
687
|
-
interface
|
|
718
|
+
interface OneTimePurchaseInfo {
|
|
688
719
|
reference: string;
|
|
689
720
|
productRef?: string;
|
|
690
721
|
amount: number;
|
|
@@ -696,9 +727,9 @@ interface PurchaseInfo {
|
|
|
696
727
|
* Result from processing a payment intent
|
|
697
728
|
*/
|
|
698
729
|
interface ProcessPaymentResult {
|
|
699
|
-
type: '
|
|
700
|
-
|
|
701
|
-
|
|
730
|
+
type: 'recurring' | 'one-time';
|
|
731
|
+
purchase?: components['schemas']['PurchaseInfo'];
|
|
732
|
+
oneTimePurchase?: OneTimePurchaseInfo;
|
|
702
733
|
status: 'completed';
|
|
703
734
|
}
|
|
704
735
|
/**
|
|
@@ -710,8 +741,15 @@ interface ProcessPaymentResult {
|
|
|
710
741
|
*/
|
|
711
742
|
interface SolvaPayClient {
|
|
712
743
|
checkLimits(params: components['schemas']['CheckLimitRequest']): Promise<LimitResponseWithPlan>;
|
|
713
|
-
trackUsage(params:
|
|
744
|
+
trackUsage(params: {
|
|
745
|
+
customerRef: string;
|
|
746
|
+
productRef: string;
|
|
714
747
|
planRef: string;
|
|
748
|
+
outcome: string;
|
|
749
|
+
action?: string;
|
|
750
|
+
requestId?: string;
|
|
751
|
+
actionDuration?: number;
|
|
752
|
+
timestamp?: string;
|
|
715
753
|
}): Promise<void>;
|
|
716
754
|
createCustomer?(params: components['schemas']['CreateCustomerRequest']): Promise<{
|
|
717
755
|
customerRef: string;
|
|
@@ -719,18 +757,21 @@ interface SolvaPayClient {
|
|
|
719
757
|
getCustomer(params: {
|
|
720
758
|
customerRef?: string;
|
|
721
759
|
externalRef?: string;
|
|
760
|
+
email?: string;
|
|
722
761
|
}): Promise<CustomerResponseMapped>;
|
|
723
|
-
|
|
762
|
+
listProducts?(): Promise<Array<{
|
|
724
763
|
reference: string;
|
|
725
764
|
name: string;
|
|
726
765
|
description?: string;
|
|
766
|
+
status?: string;
|
|
727
767
|
}>>;
|
|
728
|
-
|
|
768
|
+
createProduct?(params: components['schemas']['CreateProductRequest']): Promise<{
|
|
729
769
|
reference: string;
|
|
730
770
|
name: string;
|
|
731
771
|
}>;
|
|
732
|
-
|
|
733
|
-
|
|
772
|
+
updateProduct?(productRef: string, params: components['schemas']['UpdateProductRequest']): Promise<components['schemas']['SdkProductResponse']>;
|
|
773
|
+
deleteProduct?(productRef: string): Promise<void>;
|
|
774
|
+
listPlans?(productRef: string): Promise<Array<{
|
|
734
775
|
reference: string;
|
|
735
776
|
name: string;
|
|
736
777
|
description?: string;
|
|
@@ -739,18 +780,18 @@ interface SolvaPayClient {
|
|
|
739
780
|
interval?: string;
|
|
740
781
|
isFreeTier?: boolean;
|
|
741
782
|
freeUnits?: number;
|
|
742
|
-
metadata?: Record<string,
|
|
743
|
-
[key: string]:
|
|
783
|
+
metadata?: Record<string, unknown>;
|
|
784
|
+
[key: string]: unknown;
|
|
744
785
|
}>>;
|
|
745
786
|
createPlan?(params: components['schemas']['CreatePlanRequest'] & {
|
|
746
|
-
|
|
787
|
+
productRef: string;
|
|
747
788
|
}): Promise<{
|
|
748
789
|
reference: string;
|
|
749
790
|
name: string;
|
|
750
791
|
}>;
|
|
751
|
-
deletePlan?(
|
|
792
|
+
deletePlan?(productRef: string, planRef: string): Promise<void>;
|
|
752
793
|
createPaymentIntent?(params: {
|
|
753
|
-
|
|
794
|
+
productRef: string;
|
|
754
795
|
planRef: string;
|
|
755
796
|
customerRef: string;
|
|
756
797
|
idempotencyKey?: string;
|
|
@@ -760,17 +801,17 @@ interface SolvaPayClient {
|
|
|
760
801
|
publishableKey: string;
|
|
761
802
|
accountId?: string;
|
|
762
803
|
}>;
|
|
763
|
-
|
|
764
|
-
|
|
804
|
+
cancelPurchase?(params: {
|
|
805
|
+
purchaseRef: string;
|
|
765
806
|
reason?: string;
|
|
766
|
-
}): Promise<components['schemas']['
|
|
767
|
-
|
|
807
|
+
}): Promise<components['schemas']['PurchaseInfo']>;
|
|
808
|
+
processPaymentIntent?(params: {
|
|
768
809
|
paymentIntentId: string;
|
|
769
|
-
|
|
810
|
+
productRef: string;
|
|
770
811
|
customerRef: string;
|
|
771
812
|
planRef?: string;
|
|
772
813
|
}): Promise<ProcessPaymentResult>;
|
|
773
|
-
createCheckoutSession(params: components['schemas']['CreateCheckoutSessionRequest']): Promise<components['schemas']['
|
|
814
|
+
createCheckoutSession(params: components['schemas']['CreateCheckoutSessionRequest']): Promise<components['schemas']['CheckoutSessionResponse']>;
|
|
774
815
|
createCustomerSession(params: components['schemas']['CreateCustomerSessionRequest']): Promise<components['schemas']['CreateCustomerSessionResponse']>;
|
|
775
816
|
}
|
|
776
817
|
|
|
@@ -783,7 +824,7 @@ interface SolvaPayClient {
|
|
|
783
824
|
* Arguments passed to protected handlers
|
|
784
825
|
*/
|
|
785
826
|
interface PaywallArgs {
|
|
786
|
-
[key: string]:
|
|
827
|
+
[key: string]: unknown;
|
|
787
828
|
auth?: {
|
|
788
829
|
customer_ref?: string;
|
|
789
830
|
};
|
|
@@ -792,7 +833,7 @@ interface PaywallArgs {
|
|
|
792
833
|
* Metadata for configuring paywall protection
|
|
793
834
|
*/
|
|
794
835
|
interface PaywallMetadata {
|
|
795
|
-
|
|
836
|
+
product?: string;
|
|
796
837
|
plan?: string;
|
|
797
838
|
}
|
|
798
839
|
/**
|
|
@@ -800,7 +841,7 @@ interface PaywallMetadata {
|
|
|
800
841
|
*/
|
|
801
842
|
interface PaywallStructuredContent {
|
|
802
843
|
kind: 'payment_required';
|
|
803
|
-
|
|
844
|
+
product: string;
|
|
804
845
|
checkoutUrl: string;
|
|
805
846
|
message: string;
|
|
806
847
|
}
|
|
@@ -862,15 +903,15 @@ interface RetryOptions {
|
|
|
862
903
|
*/
|
|
863
904
|
interface PayableOptions {
|
|
864
905
|
/**
|
|
865
|
-
*
|
|
906
|
+
* Product identifier
|
|
866
907
|
*/
|
|
867
|
-
|
|
908
|
+
product?: string;
|
|
868
909
|
/**
|
|
869
|
-
*
|
|
910
|
+
* Product reference (alias for product, preferred for consistency with backend API)
|
|
870
911
|
*/
|
|
871
|
-
|
|
912
|
+
productRef?: string;
|
|
872
913
|
/**
|
|
873
|
-
* Plan identifier (defaults to
|
|
914
|
+
* Plan identifier (defaults to product name if not provided)
|
|
874
915
|
*/
|
|
875
916
|
plan?: string;
|
|
876
917
|
/**
|
|
@@ -979,7 +1020,7 @@ type ServerClientOptions = {
|
|
|
979
1020
|
* });
|
|
980
1021
|
*
|
|
981
1022
|
* // Use client for custom operations
|
|
982
|
-
* const
|
|
1023
|
+
* const products = await client.listProducts();
|
|
983
1024
|
* ```
|
|
984
1025
|
*
|
|
985
1026
|
* @see {@link createSolvaPay} for the recommended high-level API
|
|
@@ -1036,7 +1077,7 @@ interface CreateSolvaPayConfig {
|
|
|
1036
1077
|
*
|
|
1037
1078
|
* @example
|
|
1038
1079
|
* ```typescript
|
|
1039
|
-
* const payable = solvaPay.payable({
|
|
1080
|
+
* const payable = solvaPay.payable({ product: 'prd_myapi', plan: 'pln_premium' });
|
|
1040
1081
|
*
|
|
1041
1082
|
* // Express.js
|
|
1042
1083
|
* app.post('/tasks', payable.http(createTask));
|
|
@@ -1067,7 +1108,7 @@ interface PayableFunction {
|
|
|
1067
1108
|
* }));
|
|
1068
1109
|
* ```
|
|
1069
1110
|
*/
|
|
1070
|
-
http<T = any>(businessLogic: (args: any) => Promise<T>, options?: HttpAdapterOptions): (req: any, reply: any) => Promise<
|
|
1111
|
+
http<T = any>(businessLogic: (args: any) => Promise<T>, options?: HttpAdapterOptions): (req: any, reply: any) => Promise<unknown>;
|
|
1071
1112
|
/**
|
|
1072
1113
|
* Next.js adapter for App Router API routes.
|
|
1073
1114
|
*
|
|
@@ -1099,7 +1140,7 @@ interface PayableFunction {
|
|
|
1099
1140
|
* });
|
|
1100
1141
|
* ```
|
|
1101
1142
|
*/
|
|
1102
|
-
mcp<T = any>(businessLogic: (args: any) => Promise<T>, options?: McpAdapterOptions): (args:
|
|
1143
|
+
mcp<T = any>(businessLogic: (args: any) => Promise<T>, options?: McpAdapterOptions): (args: Record<string, unknown>) => Promise<unknown>;
|
|
1103
1144
|
/**
|
|
1104
1145
|
* Pure function adapter for direct function protection.
|
|
1105
1146
|
*
|
|
@@ -1134,32 +1175,32 @@ interface PayableFunction {
|
|
|
1134
1175
|
* const solvaPay = createSolvaPay();
|
|
1135
1176
|
*
|
|
1136
1177
|
* // Create payable handlers
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1178
|
+
* const payable = solvaPay.payable({ product: 'prd_myapi', plan: 'pln_premium' });
|
|
1179
|
+
*
|
|
1180
|
+
* // Manage customers
|
|
1181
|
+
* const customerRef = await solvaPay.ensureCustomer('user_123', 'user_123', {
|
|
1182
|
+
* email: 'user@example.com'
|
|
1183
|
+
* });
|
|
1184
|
+
*
|
|
1185
|
+
* // Create payment intents
|
|
1186
|
+
* const intent = await solvaPay.createPaymentIntent({
|
|
1187
|
+
* productRef: 'prd_myapi',
|
|
1188
|
+
* planRef: 'pln_premium',
|
|
1189
|
+
* customerRef: 'user_123'
|
|
1190
|
+
* });
|
|
1150
1191
|
* ```
|
|
1151
1192
|
*/
|
|
1152
1193
|
interface SolvaPay {
|
|
1153
1194
|
/**
|
|
1154
1195
|
* Create a payable handler with explicit adapters for different frameworks.
|
|
1155
1196
|
*
|
|
1156
|
-
* @param options - Payable options including
|
|
1197
|
+
* @param options - Payable options including product and plan references
|
|
1157
1198
|
* @returns PayableFunction with framework-specific adapters
|
|
1158
1199
|
*
|
|
1159
1200
|
* @example
|
|
1160
1201
|
* ```typescript
|
|
1161
1202
|
* const payable = solvaPay.payable({
|
|
1162
|
-
*
|
|
1203
|
+
* product: 'prd_myapi',
|
|
1163
1204
|
* plan: 'pln_premium'
|
|
1164
1205
|
* });
|
|
1165
1206
|
*
|
|
@@ -1201,15 +1242,15 @@ interface SolvaPay {
|
|
|
1201
1242
|
name?: string;
|
|
1202
1243
|
}): Promise<string>;
|
|
1203
1244
|
/**
|
|
1204
|
-
* Create a Stripe payment intent for a customer to
|
|
1245
|
+
* Create a Stripe payment intent for a customer to purchase a plan.
|
|
1205
1246
|
*
|
|
1206
1247
|
* This creates a payment intent that can be confirmed on the client side
|
|
1207
|
-
* using Stripe.js. After confirmation, call `
|
|
1208
|
-
* the
|
|
1248
|
+
* using Stripe.js. After confirmation, call `processPaymentIntent()` to complete
|
|
1249
|
+
* the purchase.
|
|
1209
1250
|
*
|
|
1210
1251
|
* @param params - Payment intent parameters
|
|
1211
|
-
* @param params.
|
|
1212
|
-
* @param params.planRef - Plan reference to
|
|
1252
|
+
* @param params.productRef - Product reference
|
|
1253
|
+
* @param params.planRef - Plan reference to purchase
|
|
1213
1254
|
* @param params.customerRef - Customer reference
|
|
1214
1255
|
* @param params.idempotencyKey - Optional idempotency key for retry safety
|
|
1215
1256
|
* @returns Payment intent with client secret and publishable key
|
|
@@ -1217,7 +1258,7 @@ interface SolvaPay {
|
|
|
1217
1258
|
* @example
|
|
1218
1259
|
* ```typescript
|
|
1219
1260
|
* const intent = await solvaPay.createPaymentIntent({
|
|
1220
|
-
*
|
|
1261
|
+
* productRef: 'prd_myapi',
|
|
1221
1262
|
* planRef: 'pln_premium',
|
|
1222
1263
|
* customerRef: 'user_123',
|
|
1223
1264
|
* idempotencyKey: 'unique-key-123'
|
|
@@ -1227,7 +1268,7 @@ interface SolvaPay {
|
|
|
1227
1268
|
* ```
|
|
1228
1269
|
*/
|
|
1229
1270
|
createPaymentIntent(params: {
|
|
1230
|
-
|
|
1271
|
+
productRef: string;
|
|
1231
1272
|
planRef: string;
|
|
1232
1273
|
customerRef: string;
|
|
1233
1274
|
idempotencyKey?: string;
|
|
@@ -1240,53 +1281,53 @@ interface SolvaPay {
|
|
|
1240
1281
|
/**
|
|
1241
1282
|
* Process a payment intent after client-side Stripe confirmation.
|
|
1242
1283
|
*
|
|
1243
|
-
* Creates
|
|
1284
|
+
* Creates the purchase immediately, eliminating webhook delay.
|
|
1244
1285
|
* Call this after the client has confirmed the payment intent with Stripe.js.
|
|
1245
1286
|
*
|
|
1246
1287
|
* @param params - Payment processing parameters
|
|
1247
1288
|
* @param params.paymentIntentId - Stripe payment intent ID from client confirmation
|
|
1248
|
-
* @param params.
|
|
1289
|
+
* @param params.productRef - Product reference
|
|
1249
1290
|
* @param params.customerRef - Customer reference
|
|
1250
1291
|
* @param params.planRef - Optional plan reference (if not in payment intent)
|
|
1251
|
-
* @returns Payment processing result with
|
|
1292
|
+
* @returns Payment processing result with purchase details
|
|
1252
1293
|
*
|
|
1253
1294
|
* @example
|
|
1254
1295
|
* ```typescript
|
|
1255
1296
|
* // After client confirms payment with Stripe.js
|
|
1256
|
-
* const result = await solvaPay.
|
|
1297
|
+
* const result = await solvaPay.processPaymentIntent({
|
|
1257
1298
|
* paymentIntentId: 'pi_1234567890',
|
|
1258
|
-
*
|
|
1299
|
+
* productRef: 'prd_myapi',
|
|
1259
1300
|
* customerRef: 'user_123',
|
|
1260
1301
|
* planRef: 'pln_premium'
|
|
1261
1302
|
* });
|
|
1262
1303
|
*
|
|
1263
1304
|
* if (result.success) {
|
|
1264
|
-
* console.log('
|
|
1305
|
+
* console.log('Purchase created:', result.purchase);
|
|
1265
1306
|
* }
|
|
1266
1307
|
* ```
|
|
1267
1308
|
*/
|
|
1268
|
-
|
|
1309
|
+
processPaymentIntent(params: {
|
|
1269
1310
|
paymentIntentId: string;
|
|
1270
|
-
|
|
1311
|
+
productRef: string;
|
|
1271
1312
|
customerRef: string;
|
|
1272
1313
|
planRef?: string;
|
|
1273
1314
|
}): Promise<ProcessPaymentResult>;
|
|
1274
1315
|
/**
|
|
1275
|
-
* Check if customer is within usage limits for
|
|
1316
|
+
* Check if customer is within usage limits for a product.
|
|
1276
1317
|
*
|
|
1277
|
-
* This method checks
|
|
1318
|
+
* This method checks purchase status and usage limits without
|
|
1278
1319
|
* executing business logic. Use `payable()` for automatic protection.
|
|
1279
1320
|
*
|
|
1280
1321
|
* @param params - Limit check parameters
|
|
1281
1322
|
* @param params.customerRef - Customer reference
|
|
1282
|
-
* @param params.
|
|
1323
|
+
* @param params.productRef - Product reference
|
|
1283
1324
|
* @returns Limit check result with remaining usage and checkout URL if needed
|
|
1284
1325
|
*
|
|
1285
1326
|
* @example
|
|
1286
1327
|
* ```typescript
|
|
1287
1328
|
* const limits = await solvaPay.checkLimits({
|
|
1288
1329
|
* customerRef: 'user_123',
|
|
1289
|
-
*
|
|
1330
|
+
* productRef: 'prd_myapi'
|
|
1290
1331
|
* });
|
|
1291
1332
|
*
|
|
1292
1333
|
* if (!limits.withinLimits) {
|
|
@@ -1297,7 +1338,7 @@ interface SolvaPay {
|
|
|
1297
1338
|
*/
|
|
1298
1339
|
checkLimits(params: {
|
|
1299
1340
|
customerRef: string;
|
|
1300
|
-
|
|
1341
|
+
productRef: string;
|
|
1301
1342
|
}): Promise<{
|
|
1302
1343
|
withinLimits: boolean;
|
|
1303
1344
|
remaining: number;
|
|
@@ -1312,7 +1353,7 @@ interface SolvaPay {
|
|
|
1312
1353
|
*
|
|
1313
1354
|
* @param params - Usage tracking parameters
|
|
1314
1355
|
* @param params.customerRef - Customer reference
|
|
1315
|
-
* @param params.
|
|
1356
|
+
* @param params.productRef - Product reference
|
|
1316
1357
|
* @param params.planRef - Plan reference
|
|
1317
1358
|
* @param params.outcome - Action outcome ('success', 'paywall', or 'fail')
|
|
1318
1359
|
* @param params.action - Optional action name for analytics
|
|
@@ -1324,7 +1365,7 @@ interface SolvaPay {
|
|
|
1324
1365
|
* ```typescript
|
|
1325
1366
|
* await solvaPay.trackUsage({
|
|
1326
1367
|
* customerRef: 'user_123',
|
|
1327
|
-
*
|
|
1368
|
+
* productRef: 'prd_myapi',
|
|
1328
1369
|
* planRef: 'pln_premium',
|
|
1329
1370
|
* outcome: 'success',
|
|
1330
1371
|
* action: 'api_call',
|
|
@@ -1336,7 +1377,7 @@ interface SolvaPay {
|
|
|
1336
1377
|
*/
|
|
1337
1378
|
trackUsage(params: {
|
|
1338
1379
|
customerRef: string;
|
|
1339
|
-
|
|
1380
|
+
productRef: string;
|
|
1340
1381
|
planRef: string;
|
|
1341
1382
|
outcome: 'success' | 'paywall' | 'fail';
|
|
1342
1383
|
action?: string;
|
|
@@ -1370,15 +1411,15 @@ interface SolvaPay {
|
|
|
1370
1411
|
customerRef: string;
|
|
1371
1412
|
}>;
|
|
1372
1413
|
/**
|
|
1373
|
-
* Get customer details including
|
|
1414
|
+
* Get customer details including purchases and usage.
|
|
1374
1415
|
*
|
|
1375
1416
|
* Returns full customer information from the SolvaPay backend, including
|
|
1376
|
-
* all active
|
|
1417
|
+
* all active purchases, usage history, and customer metadata.
|
|
1377
1418
|
*
|
|
1378
1419
|
* @param params - Customer lookup parameters
|
|
1379
1420
|
* @param params.customerRef - Optional customer reference (SolvaPay ID)
|
|
1380
1421
|
* @param params.externalRef - Optional external reference (e.g., Supabase ID)
|
|
1381
|
-
* @returns Customer details with
|
|
1422
|
+
* @returns Customer details with purchases and metadata
|
|
1382
1423
|
*
|
|
1383
1424
|
* @example
|
|
1384
1425
|
* ```typescript
|
|
@@ -1404,7 +1445,7 @@ interface SolvaPay {
|
|
|
1404
1445
|
* to a hosted payment page. After payment, customer is redirected back.
|
|
1405
1446
|
*
|
|
1406
1447
|
* @param params - Checkout session parameters
|
|
1407
|
-
* @param params.
|
|
1448
|
+
* @param params.productRef - Product reference
|
|
1408
1449
|
* @param params.customerRef - Customer reference
|
|
1409
1450
|
* @param params.planRef - Optional plan reference (if not specified, shows plan selector)
|
|
1410
1451
|
* @param params.returnUrl - URL to redirect to after successful payment
|
|
@@ -1413,7 +1454,7 @@ interface SolvaPay {
|
|
|
1413
1454
|
* @example
|
|
1414
1455
|
* ```typescript
|
|
1415
1456
|
* const session = await solvaPay.createCheckoutSession({
|
|
1416
|
-
*
|
|
1457
|
+
* productRef: 'prd_myapi',
|
|
1417
1458
|
* customerRef: 'user_123',
|
|
1418
1459
|
* planRef: 'pln_premium',
|
|
1419
1460
|
* returnUrl: 'https://myapp.com/success'
|
|
@@ -1424,7 +1465,7 @@ interface SolvaPay {
|
|
|
1424
1465
|
* ```
|
|
1425
1466
|
*/
|
|
1426
1467
|
createCheckoutSession(params: {
|
|
1427
|
-
|
|
1468
|
+
productRef: string;
|
|
1428
1469
|
customerRef: string;
|
|
1429
1470
|
planRef?: string;
|
|
1430
1471
|
returnUrl?: string;
|
|
@@ -1433,10 +1474,10 @@ interface SolvaPay {
|
|
|
1433
1474
|
checkoutUrl: string;
|
|
1434
1475
|
}>;
|
|
1435
1476
|
/**
|
|
1436
|
-
* Create a customer portal session for managing
|
|
1477
|
+
* Create a customer portal session for managing purchases.
|
|
1437
1478
|
*
|
|
1438
1479
|
* This creates a Stripe Customer Portal session that allows customers
|
|
1439
|
-
* to manage their
|
|
1480
|
+
* to manage their purchases, update payment methods, and view invoices.
|
|
1440
1481
|
*
|
|
1441
1482
|
* @param params - Customer session parameters
|
|
1442
1483
|
* @param params.customerRef - Customer reference
|
|
@@ -1462,12 +1503,12 @@ interface SolvaPay {
|
|
|
1462
1503
|
* Direct access to the API client for advanced operations.
|
|
1463
1504
|
*
|
|
1464
1505
|
* Use this for operations not exposed by the SolvaPay interface,
|
|
1465
|
-
* such as
|
|
1506
|
+
* such as product/plan management or custom API calls.
|
|
1466
1507
|
*
|
|
1467
1508
|
* @example
|
|
1468
1509
|
* ```typescript
|
|
1469
1510
|
* // Access API client directly for custom operations
|
|
1470
|
-
* const
|
|
1511
|
+
* const products = await solvaPay.apiClient.listProducts();
|
|
1471
1512
|
* ```
|
|
1472
1513
|
*/
|
|
1473
1514
|
apiClient: SolvaPayClient;
|
|
@@ -1477,7 +1518,7 @@ interface SolvaPay {
|
|
|
1477
1518
|
*
|
|
1478
1519
|
* This factory function creates a SolvaPay instance that can be used to
|
|
1479
1520
|
* protect API endpoints, functions, and MCP tools with usage limits and
|
|
1480
|
-
|
|
1521
|
+
* purchase checks.
|
|
1481
1522
|
*
|
|
1482
1523
|
* @param config - Optional configuration object
|
|
1483
1524
|
* @param config.apiKey - API key for production use (defaults to `SOLVAPAY_SECRET_KEY` env var)
|
|
@@ -1500,9 +1541,9 @@ interface SolvaPay {
|
|
|
1500
1541
|
* apiClient: mockClient
|
|
1501
1542
|
* });
|
|
1502
1543
|
*
|
|
1503
|
-
* // Create payable handlers for your
|
|
1544
|
+
* // Create payable handlers for your product
|
|
1504
1545
|
* const payable = solvaPay.payable({
|
|
1505
|
-
*
|
|
1546
|
+
* product: 'prd_myapi',
|
|
1506
1547
|
* plan: 'pln_premium'
|
|
1507
1548
|
* });
|
|
1508
1549
|
*
|
|
@@ -1528,10 +1569,10 @@ declare function createSolvaPay(config?: CreateSolvaPayConfig): SolvaPay;
|
|
|
1528
1569
|
*/
|
|
1529
1570
|
|
|
1530
1571
|
/**
|
|
1531
|
-
* Error thrown when a paywall is triggered (
|
|
1572
|
+
* Error thrown when a paywall is triggered (purchase required or usage limit exceeded).
|
|
1532
1573
|
*
|
|
1533
1574
|
* This error is automatically thrown by the paywall protection system when:
|
|
1534
|
-
* - Customer doesn't have required
|
|
1575
|
+
* - Customer doesn't have required purchase
|
|
1535
1576
|
* - Customer has exceeded usage limits
|
|
1536
1577
|
* - Customer needs to upgrade their plan
|
|
1537
1578
|
*
|
|
@@ -1750,7 +1791,7 @@ declare function syncCustomerCore(request: Request, options?: {
|
|
|
1750
1791
|
}): Promise<string | ErrorResult>;
|
|
1751
1792
|
|
|
1752
1793
|
/**
|
|
1753
|
-
* Create a Stripe payment intent for a customer to
|
|
1794
|
+
* Create a Stripe payment intent for a customer to purchase a plan.
|
|
1754
1795
|
*
|
|
1755
1796
|
* This is a framework-agnostic helper that:
|
|
1756
1797
|
* 1. Extracts authenticated user from the request
|
|
@@ -1758,12 +1799,12 @@ declare function syncCustomerCore(request: Request, options?: {
|
|
|
1758
1799
|
* 3. Creates a payment intent for the specified plan
|
|
1759
1800
|
*
|
|
1760
1801
|
* The payment intent can then be confirmed on the client side using Stripe.js.
|
|
1761
|
-
* After confirmation, use `
|
|
1802
|
+
* After confirmation, use `processPaymentIntentCore()` to complete the purchase.
|
|
1762
1803
|
*
|
|
1763
1804
|
* @param request - Standard Web API Request object
|
|
1764
1805
|
* @param body - Payment intent parameters
|
|
1765
|
-
* @param body.planRef - Plan reference to
|
|
1766
|
-
* @param body.
|
|
1806
|
+
* @param body.planRef - Plan reference to purchase (required)
|
|
1807
|
+
* @param body.productRef - Product reference (required)
|
|
1767
1808
|
* @param options - Configuration options
|
|
1768
1809
|
* @param options.solvaPay - Optional SolvaPay instance (creates new one if not provided)
|
|
1769
1810
|
* @param options.includeEmail - Whether to include email in customer data (default: true)
|
|
@@ -1785,13 +1826,13 @@ declare function syncCustomerCore(request: Request, options?: {
|
|
|
1785
1826
|
* }
|
|
1786
1827
|
* ```
|
|
1787
1828
|
*
|
|
1788
|
-
* @see {@link
|
|
1829
|
+
* @see {@link processPaymentIntentCore} for processing confirmed payments
|
|
1789
1830
|
* @see {@link ErrorResult} for error handling
|
|
1790
1831
|
* @since 1.0.0
|
|
1791
1832
|
*/
|
|
1792
1833
|
declare function createPaymentIntentCore(request: Request, body: {
|
|
1793
1834
|
planRef: string;
|
|
1794
|
-
|
|
1835
|
+
productRef: string;
|
|
1795
1836
|
}, options?: {
|
|
1796
1837
|
solvaPay?: SolvaPay;
|
|
1797
1838
|
includeEmail?: boolean;
|
|
@@ -1807,7 +1848,7 @@ declare function createPaymentIntentCore(request: Request, body: {
|
|
|
1807
1848
|
* Process a payment intent after client-side Stripe confirmation.
|
|
1808
1849
|
*
|
|
1809
1850
|
* This helper processes a payment intent that has been confirmed on the client
|
|
1810
|
-
* side using Stripe.js. It creates the
|
|
1851
|
+
* side using Stripe.js. It creates the purchase immediately,
|
|
1811
1852
|
* eliminating webhook delay.
|
|
1812
1853
|
*
|
|
1813
1854
|
* Call this after the client has confirmed the payment intent with Stripe.js.
|
|
@@ -1815,27 +1856,23 @@ declare function createPaymentIntentCore(request: Request, body: {
|
|
|
1815
1856
|
* @param request - Standard Web API Request object
|
|
1816
1857
|
* @param body - Payment processing parameters
|
|
1817
1858
|
* @param body.paymentIntentId - Stripe payment intent ID from client confirmation (required)
|
|
1818
|
-
* @param body.
|
|
1859
|
+
* @param body.productRef - Product reference (required)
|
|
1819
1860
|
* @param body.planRef - Optional plan reference (if not in payment intent)
|
|
1820
1861
|
* @param options - Configuration options
|
|
1821
1862
|
* @param options.solvaPay - Optional SolvaPay instance (creates new one if not provided)
|
|
1822
|
-
* @returns Process payment result with
|
|
1863
|
+
* @returns Process payment result with purchase details, or error result
|
|
1823
1864
|
*
|
|
1824
1865
|
* @example
|
|
1825
1866
|
* ```typescript
|
|
1826
1867
|
* // In an API route handler
|
|
1827
1868
|
* export async function POST(request: Request) {
|
|
1828
1869
|
* const body = await request.json();
|
|
1829
|
-
* const result = await
|
|
1870
|
+
* const result = await processPaymentIntentCore(request, body);
|
|
1830
1871
|
*
|
|
1831
1872
|
* if (isErrorResult(result)) {
|
|
1832
1873
|
* return Response.json(result, { status: result.status });
|
|
1833
1874
|
* }
|
|
1834
1875
|
*
|
|
1835
|
-
* if (result.success) {
|
|
1836
|
-
* console.log('Subscription created:', result.subscriptionRef);
|
|
1837
|
-
* }
|
|
1838
|
-
*
|
|
1839
1876
|
* return Response.json(result);
|
|
1840
1877
|
* }
|
|
1841
1878
|
* ```
|
|
@@ -1844,9 +1881,9 @@ declare function createPaymentIntentCore(request: Request, body: {
|
|
|
1844
1881
|
* @see {@link ErrorResult} for error handling
|
|
1845
1882
|
* @since 1.0.0
|
|
1846
1883
|
*/
|
|
1847
|
-
declare function
|
|
1884
|
+
declare function processPaymentIntentCore(request: Request, body: {
|
|
1848
1885
|
paymentIntentId: string;
|
|
1849
|
-
|
|
1886
|
+
productRef: string;
|
|
1850
1887
|
planRef?: string;
|
|
1851
1888
|
}, options?: {
|
|
1852
1889
|
solvaPay?: SolvaPay;
|
|
@@ -1868,7 +1905,7 @@ declare function processPaymentCore(request: Request, body: {
|
|
|
1868
1905
|
* @returns Checkout session response or error result
|
|
1869
1906
|
*/
|
|
1870
1907
|
declare function createCheckoutSessionCore(request: Request, body: {
|
|
1871
|
-
|
|
1908
|
+
productRef: string;
|
|
1872
1909
|
planRef?: string;
|
|
1873
1910
|
returnUrl?: string;
|
|
1874
1911
|
}, options?: {
|
|
@@ -1897,26 +1934,26 @@ declare function createCustomerSessionCore(request: Request, options?: {
|
|
|
1897
1934
|
} | ErrorResult>;
|
|
1898
1935
|
|
|
1899
1936
|
/**
|
|
1900
|
-
*
|
|
1937
|
+
* Purchase Cancellation Helpers (Core)
|
|
1901
1938
|
*
|
|
1902
|
-
* Generic helpers for
|
|
1939
|
+
* Generic helpers for purchase cancellation operations.
|
|
1903
1940
|
* Works with standard Web API Request (works everywhere).
|
|
1904
1941
|
*/
|
|
1905
1942
|
|
|
1906
1943
|
/**
|
|
1907
|
-
* Cancel
|
|
1944
|
+
* Cancel purchase - core implementation
|
|
1908
1945
|
*
|
|
1909
1946
|
* @param request - Standard Web API Request
|
|
1910
1947
|
* @param body - Cancellation parameters
|
|
1911
1948
|
* @param options - Configuration options
|
|
1912
|
-
* @returns Cancelled
|
|
1949
|
+
* @returns Cancelled purchase response or error result
|
|
1913
1950
|
*/
|
|
1914
|
-
declare function
|
|
1915
|
-
|
|
1951
|
+
declare function cancelPurchaseCore(request: Request, body: {
|
|
1952
|
+
purchaseRef: string;
|
|
1916
1953
|
reason?: string;
|
|
1917
1954
|
}, options?: {
|
|
1918
1955
|
solvaPay?: SolvaPay;
|
|
1919
|
-
}): Promise<
|
|
1956
|
+
}): Promise<Record<string, unknown> | ErrorResult>;
|
|
1920
1957
|
|
|
1921
1958
|
/**
|
|
1922
1959
|
* Plans Helper (Core)
|
|
@@ -1928,13 +1965,10 @@ declare function cancelSubscriptionCore(request: Request, body: {
|
|
|
1928
1965
|
|
|
1929
1966
|
/**
|
|
1930
1967
|
* List plans - core implementation
|
|
1931
|
-
*
|
|
1932
|
-
* @param request - Standard Web API Request
|
|
1933
|
-
* @returns Plans response or error result
|
|
1934
1968
|
*/
|
|
1935
1969
|
declare function listPlansCore(request: Request): Promise<{
|
|
1936
|
-
plans:
|
|
1937
|
-
|
|
1970
|
+
plans: Record<string, unknown>[];
|
|
1971
|
+
productRef: string;
|
|
1938
1972
|
} | ErrorResult>;
|
|
1939
1973
|
|
|
1940
1974
|
/**
|
|
@@ -1970,4 +2004,4 @@ declare function verifyWebhook({ body, signature, secret, }: {
|
|
|
1970
2004
|
secret: string;
|
|
1971
2005
|
}): Promise<any>;
|
|
1972
2006
|
|
|
1973
|
-
export { type AuthenticatedUser, type CreateSolvaPayConfig, type ErrorResult, type HttpAdapterOptions, type McpAdapterOptions, type NextAdapterOptions, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type RetryOptions, type ServerClientOptions, type SolvaPay, type SolvaPayClient,
|
|
2007
|
+
export { type AuthenticatedUser, type CreateSolvaPayConfig, type ErrorResult, type HttpAdapterOptions, type McpAdapterOptions, type NextAdapterOptions, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type RetryOptions, type ServerClientOptions, type SolvaPay, type SolvaPayClient, cancelPurchaseCore, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, getAuthenticatedUserCore, handleRouteError, isErrorResult, listPlansCore, processPaymentIntentCore, syncCustomerCore, verifyWebhook, withRetry };
|