@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/index.d.cts
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
|
/**
|
|
@@ -978,7 +1019,7 @@ interface CreateSolvaPayConfig {
|
|
|
978
1019
|
*
|
|
979
1020
|
* @example
|
|
980
1021
|
* ```typescript
|
|
981
|
-
* const payable = solvaPay.payable({
|
|
1022
|
+
* const payable = solvaPay.payable({ product: 'prd_myapi', plan: 'pln_premium' });
|
|
982
1023
|
*
|
|
983
1024
|
* // Express.js
|
|
984
1025
|
* app.post('/tasks', payable.http(createTask));
|
|
@@ -1009,7 +1050,7 @@ interface PayableFunction {
|
|
|
1009
1050
|
* }));
|
|
1010
1051
|
* ```
|
|
1011
1052
|
*/
|
|
1012
|
-
http<T = any>(businessLogic: (args: any) => Promise<T>, options?: HttpAdapterOptions): (req: any, reply: any) => Promise<
|
|
1053
|
+
http<T = any>(businessLogic: (args: any) => Promise<T>, options?: HttpAdapterOptions): (req: any, reply: any) => Promise<unknown>;
|
|
1013
1054
|
/**
|
|
1014
1055
|
* Next.js adapter for App Router API routes.
|
|
1015
1056
|
*
|
|
@@ -1041,7 +1082,7 @@ interface PayableFunction {
|
|
|
1041
1082
|
* });
|
|
1042
1083
|
* ```
|
|
1043
1084
|
*/
|
|
1044
|
-
mcp<T = any>(businessLogic: (args: any) => Promise<T>, options?: McpAdapterOptions): (args:
|
|
1085
|
+
mcp<T = any>(businessLogic: (args: any) => Promise<T>, options?: McpAdapterOptions): (args: Record<string, unknown>) => Promise<unknown>;
|
|
1045
1086
|
/**
|
|
1046
1087
|
* Pure function adapter for direct function protection.
|
|
1047
1088
|
*
|
|
@@ -1076,32 +1117,32 @@ interface PayableFunction {
|
|
|
1076
1117
|
* const solvaPay = createSolvaPay();
|
|
1077
1118
|
*
|
|
1078
1119
|
* // Create payable handlers
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1120
|
+
* const payable = solvaPay.payable({ product: 'prd_myapi', plan: 'pln_premium' });
|
|
1121
|
+
*
|
|
1122
|
+
* // Manage customers
|
|
1123
|
+
* const customerRef = await solvaPay.ensureCustomer('user_123', 'user_123', {
|
|
1124
|
+
* email: 'user@example.com'
|
|
1125
|
+
* });
|
|
1126
|
+
*
|
|
1127
|
+
* // Create payment intents
|
|
1128
|
+
* const intent = await solvaPay.createPaymentIntent({
|
|
1129
|
+
* productRef: 'prd_myapi',
|
|
1130
|
+
* planRef: 'pln_premium',
|
|
1131
|
+
* customerRef: 'user_123'
|
|
1132
|
+
* });
|
|
1092
1133
|
* ```
|
|
1093
1134
|
*/
|
|
1094
1135
|
interface SolvaPay {
|
|
1095
1136
|
/**
|
|
1096
1137
|
* Create a payable handler with explicit adapters for different frameworks.
|
|
1097
1138
|
*
|
|
1098
|
-
* @param options - Payable options including
|
|
1139
|
+
* @param options - Payable options including product and plan references
|
|
1099
1140
|
* @returns PayableFunction with framework-specific adapters
|
|
1100
1141
|
*
|
|
1101
1142
|
* @example
|
|
1102
1143
|
* ```typescript
|
|
1103
1144
|
* const payable = solvaPay.payable({
|
|
1104
|
-
*
|
|
1145
|
+
* product: 'prd_myapi',
|
|
1105
1146
|
* plan: 'pln_premium'
|
|
1106
1147
|
* });
|
|
1107
1148
|
*
|
|
@@ -1143,15 +1184,15 @@ interface SolvaPay {
|
|
|
1143
1184
|
name?: string;
|
|
1144
1185
|
}): Promise<string>;
|
|
1145
1186
|
/**
|
|
1146
|
-
* Create a Stripe payment intent for a customer to
|
|
1187
|
+
* Create a Stripe payment intent for a customer to purchase a plan.
|
|
1147
1188
|
*
|
|
1148
1189
|
* This creates a payment intent that can be confirmed on the client side
|
|
1149
|
-
* using Stripe.js. After confirmation, call `
|
|
1150
|
-
* the
|
|
1190
|
+
* using Stripe.js. After confirmation, call `processPaymentIntent()` to complete
|
|
1191
|
+
* the purchase.
|
|
1151
1192
|
*
|
|
1152
1193
|
* @param params - Payment intent parameters
|
|
1153
|
-
* @param params.
|
|
1154
|
-
* @param params.planRef - Plan reference to
|
|
1194
|
+
* @param params.productRef - Product reference
|
|
1195
|
+
* @param params.planRef - Plan reference to purchase
|
|
1155
1196
|
* @param params.customerRef - Customer reference
|
|
1156
1197
|
* @param params.idempotencyKey - Optional idempotency key for retry safety
|
|
1157
1198
|
* @returns Payment intent with client secret and publishable key
|
|
@@ -1159,7 +1200,7 @@ interface SolvaPay {
|
|
|
1159
1200
|
* @example
|
|
1160
1201
|
* ```typescript
|
|
1161
1202
|
* const intent = await solvaPay.createPaymentIntent({
|
|
1162
|
-
*
|
|
1203
|
+
* productRef: 'prd_myapi',
|
|
1163
1204
|
* planRef: 'pln_premium',
|
|
1164
1205
|
* customerRef: 'user_123',
|
|
1165
1206
|
* idempotencyKey: 'unique-key-123'
|
|
@@ -1169,7 +1210,7 @@ interface SolvaPay {
|
|
|
1169
1210
|
* ```
|
|
1170
1211
|
*/
|
|
1171
1212
|
createPaymentIntent(params: {
|
|
1172
|
-
|
|
1213
|
+
productRef: string;
|
|
1173
1214
|
planRef: string;
|
|
1174
1215
|
customerRef: string;
|
|
1175
1216
|
idempotencyKey?: string;
|
|
@@ -1182,53 +1223,53 @@ interface SolvaPay {
|
|
|
1182
1223
|
/**
|
|
1183
1224
|
* Process a payment intent after client-side Stripe confirmation.
|
|
1184
1225
|
*
|
|
1185
|
-
* Creates
|
|
1226
|
+
* Creates the purchase immediately, eliminating webhook delay.
|
|
1186
1227
|
* Call this after the client has confirmed the payment intent with Stripe.js.
|
|
1187
1228
|
*
|
|
1188
1229
|
* @param params - Payment processing parameters
|
|
1189
1230
|
* @param params.paymentIntentId - Stripe payment intent ID from client confirmation
|
|
1190
|
-
* @param params.
|
|
1231
|
+
* @param params.productRef - Product reference
|
|
1191
1232
|
* @param params.customerRef - Customer reference
|
|
1192
1233
|
* @param params.planRef - Optional plan reference (if not in payment intent)
|
|
1193
|
-
* @returns Payment processing result with
|
|
1234
|
+
* @returns Payment processing result with purchase details
|
|
1194
1235
|
*
|
|
1195
1236
|
* @example
|
|
1196
1237
|
* ```typescript
|
|
1197
1238
|
* // After client confirms payment with Stripe.js
|
|
1198
|
-
* const result = await solvaPay.
|
|
1239
|
+
* const result = await solvaPay.processPaymentIntent({
|
|
1199
1240
|
* paymentIntentId: 'pi_1234567890',
|
|
1200
|
-
*
|
|
1241
|
+
* productRef: 'prd_myapi',
|
|
1201
1242
|
* customerRef: 'user_123',
|
|
1202
1243
|
* planRef: 'pln_premium'
|
|
1203
1244
|
* });
|
|
1204
1245
|
*
|
|
1205
1246
|
* if (result.success) {
|
|
1206
|
-
* console.log('
|
|
1247
|
+
* console.log('Purchase created:', result.purchase);
|
|
1207
1248
|
* }
|
|
1208
1249
|
* ```
|
|
1209
1250
|
*/
|
|
1210
|
-
|
|
1251
|
+
processPaymentIntent(params: {
|
|
1211
1252
|
paymentIntentId: string;
|
|
1212
|
-
|
|
1253
|
+
productRef: string;
|
|
1213
1254
|
customerRef: string;
|
|
1214
1255
|
planRef?: string;
|
|
1215
1256
|
}): Promise<ProcessPaymentResult>;
|
|
1216
1257
|
/**
|
|
1217
|
-
* Check if customer is within usage limits for
|
|
1258
|
+
* Check if customer is within usage limits for a product.
|
|
1218
1259
|
*
|
|
1219
|
-
* This method checks
|
|
1260
|
+
* This method checks purchase status and usage limits without
|
|
1220
1261
|
* executing business logic. Use `payable()` for automatic protection.
|
|
1221
1262
|
*
|
|
1222
1263
|
* @param params - Limit check parameters
|
|
1223
1264
|
* @param params.customerRef - Customer reference
|
|
1224
|
-
* @param params.
|
|
1265
|
+
* @param params.productRef - Product reference
|
|
1225
1266
|
* @returns Limit check result with remaining usage and checkout URL if needed
|
|
1226
1267
|
*
|
|
1227
1268
|
* @example
|
|
1228
1269
|
* ```typescript
|
|
1229
1270
|
* const limits = await solvaPay.checkLimits({
|
|
1230
1271
|
* customerRef: 'user_123',
|
|
1231
|
-
*
|
|
1272
|
+
* productRef: 'prd_myapi'
|
|
1232
1273
|
* });
|
|
1233
1274
|
*
|
|
1234
1275
|
* if (!limits.withinLimits) {
|
|
@@ -1239,7 +1280,7 @@ interface SolvaPay {
|
|
|
1239
1280
|
*/
|
|
1240
1281
|
checkLimits(params: {
|
|
1241
1282
|
customerRef: string;
|
|
1242
|
-
|
|
1283
|
+
productRef: string;
|
|
1243
1284
|
}): Promise<{
|
|
1244
1285
|
withinLimits: boolean;
|
|
1245
1286
|
remaining: number;
|
|
@@ -1254,7 +1295,7 @@ interface SolvaPay {
|
|
|
1254
1295
|
*
|
|
1255
1296
|
* @param params - Usage tracking parameters
|
|
1256
1297
|
* @param params.customerRef - Customer reference
|
|
1257
|
-
* @param params.
|
|
1298
|
+
* @param params.productRef - Product reference
|
|
1258
1299
|
* @param params.planRef - Plan reference
|
|
1259
1300
|
* @param params.outcome - Action outcome ('success', 'paywall', or 'fail')
|
|
1260
1301
|
* @param params.action - Optional action name for analytics
|
|
@@ -1266,7 +1307,7 @@ interface SolvaPay {
|
|
|
1266
1307
|
* ```typescript
|
|
1267
1308
|
* await solvaPay.trackUsage({
|
|
1268
1309
|
* customerRef: 'user_123',
|
|
1269
|
-
*
|
|
1310
|
+
* productRef: 'prd_myapi',
|
|
1270
1311
|
* planRef: 'pln_premium',
|
|
1271
1312
|
* outcome: 'success',
|
|
1272
1313
|
* action: 'api_call',
|
|
@@ -1278,7 +1319,7 @@ interface SolvaPay {
|
|
|
1278
1319
|
*/
|
|
1279
1320
|
trackUsage(params: {
|
|
1280
1321
|
customerRef: string;
|
|
1281
|
-
|
|
1322
|
+
productRef: string;
|
|
1282
1323
|
planRef: string;
|
|
1283
1324
|
outcome: 'success' | 'paywall' | 'fail';
|
|
1284
1325
|
action?: string;
|
|
@@ -1312,15 +1353,15 @@ interface SolvaPay {
|
|
|
1312
1353
|
customerRef: string;
|
|
1313
1354
|
}>;
|
|
1314
1355
|
/**
|
|
1315
|
-
* Get customer details including
|
|
1356
|
+
* Get customer details including purchases and usage.
|
|
1316
1357
|
*
|
|
1317
1358
|
* Returns full customer information from the SolvaPay backend, including
|
|
1318
|
-
* all active
|
|
1359
|
+
* all active purchases, usage history, and customer metadata.
|
|
1319
1360
|
*
|
|
1320
1361
|
* @param params - Customer lookup parameters
|
|
1321
1362
|
* @param params.customerRef - Optional customer reference (SolvaPay ID)
|
|
1322
1363
|
* @param params.externalRef - Optional external reference (e.g., Supabase ID)
|
|
1323
|
-
* @returns Customer details with
|
|
1364
|
+
* @returns Customer details with purchases and metadata
|
|
1324
1365
|
*
|
|
1325
1366
|
* @example
|
|
1326
1367
|
* ```typescript
|
|
@@ -1346,7 +1387,7 @@ interface SolvaPay {
|
|
|
1346
1387
|
* to a hosted payment page. After payment, customer is redirected back.
|
|
1347
1388
|
*
|
|
1348
1389
|
* @param params - Checkout session parameters
|
|
1349
|
-
* @param params.
|
|
1390
|
+
* @param params.productRef - Product reference
|
|
1350
1391
|
* @param params.customerRef - Customer reference
|
|
1351
1392
|
* @param params.planRef - Optional plan reference (if not specified, shows plan selector)
|
|
1352
1393
|
* @param params.returnUrl - URL to redirect to after successful payment
|
|
@@ -1355,7 +1396,7 @@ interface SolvaPay {
|
|
|
1355
1396
|
* @example
|
|
1356
1397
|
* ```typescript
|
|
1357
1398
|
* const session = await solvaPay.createCheckoutSession({
|
|
1358
|
-
*
|
|
1399
|
+
* productRef: 'prd_myapi',
|
|
1359
1400
|
* customerRef: 'user_123',
|
|
1360
1401
|
* planRef: 'pln_premium',
|
|
1361
1402
|
* returnUrl: 'https://myapp.com/success'
|
|
@@ -1366,7 +1407,7 @@ interface SolvaPay {
|
|
|
1366
1407
|
* ```
|
|
1367
1408
|
*/
|
|
1368
1409
|
createCheckoutSession(params: {
|
|
1369
|
-
|
|
1410
|
+
productRef: string;
|
|
1370
1411
|
customerRef: string;
|
|
1371
1412
|
planRef?: string;
|
|
1372
1413
|
returnUrl?: string;
|
|
@@ -1375,10 +1416,10 @@ interface SolvaPay {
|
|
|
1375
1416
|
checkoutUrl: string;
|
|
1376
1417
|
}>;
|
|
1377
1418
|
/**
|
|
1378
|
-
* Create a customer portal session for managing
|
|
1419
|
+
* Create a customer portal session for managing purchases.
|
|
1379
1420
|
*
|
|
1380
1421
|
* This creates a Stripe Customer Portal session that allows customers
|
|
1381
|
-
* to manage their
|
|
1422
|
+
* to manage their purchases, update payment methods, and view invoices.
|
|
1382
1423
|
*
|
|
1383
1424
|
* @param params - Customer session parameters
|
|
1384
1425
|
* @param params.customerRef - Customer reference
|
|
@@ -1404,12 +1445,12 @@ interface SolvaPay {
|
|
|
1404
1445
|
* Direct access to the API client for advanced operations.
|
|
1405
1446
|
*
|
|
1406
1447
|
* Use this for operations not exposed by the SolvaPay interface,
|
|
1407
|
-
* such as
|
|
1448
|
+
* such as product/plan management or custom API calls.
|
|
1408
1449
|
*
|
|
1409
1450
|
* @example
|
|
1410
1451
|
* ```typescript
|
|
1411
1452
|
* // Access API client directly for custom operations
|
|
1412
|
-
* const
|
|
1453
|
+
* const products = await solvaPay.apiClient.listProducts();
|
|
1413
1454
|
* ```
|
|
1414
1455
|
*/
|
|
1415
1456
|
apiClient: SolvaPayClient;
|
|
@@ -1419,7 +1460,7 @@ interface SolvaPay {
|
|
|
1419
1460
|
*
|
|
1420
1461
|
* This factory function creates a SolvaPay instance that can be used to
|
|
1421
1462
|
* protect API endpoints, functions, and MCP tools with usage limits and
|
|
1422
|
-
|
|
1463
|
+
* purchase checks.
|
|
1423
1464
|
*
|
|
1424
1465
|
* @param config - Optional configuration object
|
|
1425
1466
|
* @param config.apiKey - API key for production use (defaults to `SOLVAPAY_SECRET_KEY` env var)
|
|
@@ -1442,9 +1483,9 @@ interface SolvaPay {
|
|
|
1442
1483
|
* apiClient: mockClient
|
|
1443
1484
|
* });
|
|
1444
1485
|
*
|
|
1445
|
-
* // Create payable handlers for your
|
|
1486
|
+
* // Create payable handlers for your product
|
|
1446
1487
|
* const payable = solvaPay.payable({
|
|
1447
|
-
*
|
|
1488
|
+
* product: 'prd_myapi',
|
|
1448
1489
|
* plan: 'pln_premium'
|
|
1449
1490
|
* });
|
|
1450
1491
|
*
|
|
@@ -1509,7 +1550,7 @@ type ServerClientOptions = {
|
|
|
1509
1550
|
* });
|
|
1510
1551
|
*
|
|
1511
1552
|
* // Use client for custom operations
|
|
1512
|
-
* const
|
|
1553
|
+
* const products = await client.listProducts();
|
|
1513
1554
|
* ```
|
|
1514
1555
|
*
|
|
1515
1556
|
* @see {@link createSolvaPay} for the recommended high-level API
|
|
@@ -1528,10 +1569,10 @@ declare function createSolvaPayClient(opts: ServerClientOptions): SolvaPayClient
|
|
|
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
|
/**
|
|
@@ -1973,8 +2007,8 @@ declare function listPlansCore(request: Request): Promise<{
|
|
|
1973
2007
|
* });
|
|
1974
2008
|
*
|
|
1975
2009
|
* // Handle webhook event
|
|
1976
|
-
* if (payload.type === '
|
|
1977
|
-
* // Process
|
|
2010
|
+
* if (payload.type === 'purchase.created') {
|
|
2011
|
+
* // Process purchase creation
|
|
1978
2012
|
* }
|
|
1979
2013
|
*
|
|
1980
2014
|
* res.json({ received: true });
|
|
@@ -1993,4 +2027,4 @@ declare function verifyWebhook({ body, signature, secret, }: {
|
|
|
1993
2027
|
secret: string;
|
|
1994
2028
|
}): any;
|
|
1995
2029
|
|
|
1996
|
-
export { type AuthenticatedUser, type CreateSolvaPayConfig, type CustomerResponseMapped, type ErrorResult, type HttpAdapterOptions, type McpAdapterOptions, type NextAdapterOptions, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type ProcessPaymentResult, type
|
|
2030
|
+
export { type AuthenticatedUser, type CreateSolvaPayConfig, type CustomerResponseMapped, type ErrorResult, type HttpAdapterOptions, type McpAdapterOptions, 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, cancelPurchaseCore, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, getAuthenticatedUserCore, handleRouteError, isErrorResult, listPlansCore, processPaymentIntentCore, syncCustomerCore, verifyWebhook, withRetry };
|