@solvapay/server 1.0.0-preview.7 → 1.0.0-preview.9
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 +106 -13
- package/dist/edge.js +38 -0
- package/dist/index.cjs +38 -0
- package/dist/index.d.cts +106 -13
- package/dist/index.d.ts +106 -13
- package/dist/index.js +38 -0
- package/package.json +2 -2
package/dist/edge.d.ts
CHANGED
|
@@ -24,20 +24,25 @@ interface components {
|
|
|
24
24
|
ExecuteMultipleQueries: Record<string, never>;
|
|
25
25
|
CreateCheckoutSessionRequest: {
|
|
26
26
|
/**
|
|
27
|
-
* @description Customer reference
|
|
27
|
+
* @description Customer reference identifier
|
|
28
28
|
* @example cus_3c4d5e6f7g8h
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
customerRef: string;
|
|
31
31
|
/**
|
|
32
|
-
* @description
|
|
32
|
+
* @description Agent reference identifier
|
|
33
|
+
* @example agt_1a2b3c4d5e6f
|
|
34
|
+
*/
|
|
35
|
+
agentRef: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description Plan reference identifier (optional)
|
|
33
38
|
* @example pln_2b3c4d5e6f7g
|
|
34
39
|
*/
|
|
35
40
|
planRef?: string;
|
|
36
41
|
/**
|
|
37
|
-
* @description
|
|
38
|
-
* @example
|
|
42
|
+
* @description URL to redirect to after successful payment (optional)
|
|
43
|
+
* @example https://example.com/payment-success
|
|
39
44
|
*/
|
|
40
|
-
|
|
45
|
+
returnUrl?: string;
|
|
41
46
|
};
|
|
42
47
|
CheckoutSessionResponse: {
|
|
43
48
|
/**
|
|
@@ -67,7 +72,7 @@ interface components {
|
|
|
67
72
|
status: string;
|
|
68
73
|
/**
|
|
69
74
|
* @description Checkout URL to open the checkout page
|
|
70
|
-
* @example
|
|
75
|
+
* @example https://solvapay.com/customer/checkout?id=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
|
|
71
76
|
*/
|
|
72
77
|
checkoutUrl: string;
|
|
73
78
|
};
|
|
@@ -102,15 +107,15 @@ interface components {
|
|
|
102
107
|
*/
|
|
103
108
|
remaining: number;
|
|
104
109
|
/**
|
|
105
|
-
* @description Optional checkout
|
|
106
|
-
* @example https://checkout.solvapay.com/pay_1a2b3c4d
|
|
107
|
-
*/
|
|
108
|
-
checkoutUrl?: string;
|
|
109
|
-
/**
|
|
110
|
-
* @description Optional checkout session ID if payment is required
|
|
110
|
+
* @description Optional checkout session ID/token if payment is required
|
|
111
111
|
* @example e3f1c2d4b6a89f001122334455667788
|
|
112
112
|
*/
|
|
113
113
|
checkoutSessionId?: string;
|
|
114
|
+
/**
|
|
115
|
+
* @description Optional full checkout URL if payment is required (based on backend configuration)
|
|
116
|
+
* @example https://app.solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
|
|
117
|
+
*/
|
|
118
|
+
checkoutUrl?: string;
|
|
114
119
|
};
|
|
115
120
|
UsageEvent: {
|
|
116
121
|
/**
|
|
@@ -218,6 +223,60 @@ interface components {
|
|
|
218
223
|
/** @description Active subscriptions */
|
|
219
224
|
subscriptions?: components["schemas"]["SubscriptionInfo"][];
|
|
220
225
|
};
|
|
226
|
+
CreateCustomerSessionRequest: {
|
|
227
|
+
/**
|
|
228
|
+
* @description Customer reference identifier
|
|
229
|
+
* @example cus_3c4d5e6f7g8h
|
|
230
|
+
*/
|
|
231
|
+
customerRef: string;
|
|
232
|
+
};
|
|
233
|
+
CreateCustomerSessionResponse: {
|
|
234
|
+
/**
|
|
235
|
+
* @description Customer session ID/token
|
|
236
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
237
|
+
*/
|
|
238
|
+
sessionId: string;
|
|
239
|
+
/**
|
|
240
|
+
* @description Full customer URL based on backend configuration (ready to redirect customer)
|
|
241
|
+
* @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
|
|
242
|
+
*/
|
|
243
|
+
customerUrl: string;
|
|
244
|
+
};
|
|
245
|
+
GetCustomerSessionResponse: {
|
|
246
|
+
/**
|
|
247
|
+
* @description Customer session ID/token
|
|
248
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
249
|
+
*/
|
|
250
|
+
sessionId: string;
|
|
251
|
+
/**
|
|
252
|
+
* @description Session status
|
|
253
|
+
* @example active
|
|
254
|
+
* @enum {string}
|
|
255
|
+
*/
|
|
256
|
+
status: "active" | "expired" | "used";
|
|
257
|
+
/**
|
|
258
|
+
* @description Full customer URL based on backend configuration (ready to redirect customer)
|
|
259
|
+
* @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
|
|
260
|
+
*/
|
|
261
|
+
customerUrl: string;
|
|
262
|
+
/**
|
|
263
|
+
* @description Session expiration date
|
|
264
|
+
* @example 2025-01-01T12:00:00.000Z
|
|
265
|
+
*/
|
|
266
|
+
expiresAt: string;
|
|
267
|
+
/** @description Customer object from session data */
|
|
268
|
+
customer: components["schemas"]["CustomerResponse"];
|
|
269
|
+
/**
|
|
270
|
+
* @description Session creation date
|
|
271
|
+
* @example 2025-01-01T11:45:00.000Z
|
|
272
|
+
*/
|
|
273
|
+
createdAt: string;
|
|
274
|
+
/**
|
|
275
|
+
* @description Session last update date
|
|
276
|
+
* @example 2025-01-01T11:45:00.000Z
|
|
277
|
+
*/
|
|
278
|
+
updatedAt: string;
|
|
279
|
+
};
|
|
221
280
|
Agent: Record<string, never>;
|
|
222
281
|
CreateAgentRequest: Record<string, never>;
|
|
223
282
|
UpdateAgentRequest: Record<string, never>;
|
|
@@ -328,6 +387,18 @@ interface components {
|
|
|
328
387
|
*/
|
|
329
388
|
createdAt: string;
|
|
330
389
|
};
|
|
390
|
+
CreateCheckoutSessionResponse: {
|
|
391
|
+
/**
|
|
392
|
+
* @description Checkout session ID/token
|
|
393
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
394
|
+
*/
|
|
395
|
+
sessionId: string;
|
|
396
|
+
/**
|
|
397
|
+
* @description Full checkout URL based on backend configuration (ready to redirect customer)
|
|
398
|
+
* @example https://solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
|
|
399
|
+
*/
|
|
400
|
+
checkoutUrl: string;
|
|
401
|
+
};
|
|
331
402
|
CreatePageSettings: {
|
|
332
403
|
/** @description Page identifier */
|
|
333
404
|
id: string;
|
|
@@ -488,6 +559,8 @@ interface SolvaPayClient {
|
|
|
488
559
|
customerRef: string;
|
|
489
560
|
planRef?: string;
|
|
490
561
|
}): Promise<ProcessPaymentResult>;
|
|
562
|
+
createCheckoutSession(params: components['schemas']['CreateCheckoutSessionRequest']): Promise<components['schemas']['CreateCheckoutSessionResponse']>;
|
|
563
|
+
createCustomerSession(params: components['schemas']['CreateCustomerSessionRequest']): Promise<components['schemas']['CreateCustomerSessionResponse']>;
|
|
491
564
|
}
|
|
492
565
|
|
|
493
566
|
/**
|
|
@@ -822,6 +895,26 @@ interface SolvaPay {
|
|
|
822
895
|
startDate: string;
|
|
823
896
|
}>;
|
|
824
897
|
}>;
|
|
898
|
+
/**
|
|
899
|
+
* Create a checkout session for a customer
|
|
900
|
+
*/
|
|
901
|
+
createCheckoutSession(params: {
|
|
902
|
+
agentRef: string;
|
|
903
|
+
customerRef: string;
|
|
904
|
+
planRef?: string;
|
|
905
|
+
}): Promise<{
|
|
906
|
+
sessionId: string;
|
|
907
|
+
checkoutUrl: string;
|
|
908
|
+
}>;
|
|
909
|
+
/**
|
|
910
|
+
* Create a customer session for accessing customer-specific functionality
|
|
911
|
+
*/
|
|
912
|
+
createCustomerSession(params: {
|
|
913
|
+
customerRef: string;
|
|
914
|
+
}): Promise<{
|
|
915
|
+
sessionId: string;
|
|
916
|
+
customerUrl: string;
|
|
917
|
+
}>;
|
|
825
918
|
/**
|
|
826
919
|
* Direct access to the API client for advanced operations
|
|
827
920
|
* (agent/plan management, etc.)
|
package/dist/edge.js
CHANGED
|
@@ -308,6 +308,38 @@ function createSolvaPayClient(opts) {
|
|
|
308
308
|
throw new SolvaPayError(`Invalid subscription data in cancel subscription response`);
|
|
309
309
|
}
|
|
310
310
|
return result;
|
|
311
|
+
},
|
|
312
|
+
// POST: /v1/sdk/checkout-sessions
|
|
313
|
+
async createCheckoutSession(params) {
|
|
314
|
+
const url = `${base}/v1/sdk/checkout-sessions`;
|
|
315
|
+
const res = await fetch(url, {
|
|
316
|
+
method: "POST",
|
|
317
|
+
headers,
|
|
318
|
+
body: JSON.stringify(params)
|
|
319
|
+
});
|
|
320
|
+
if (!res.ok) {
|
|
321
|
+
const error = await res.text();
|
|
322
|
+
log(`\u274C API Error: ${res.status} - ${error}`);
|
|
323
|
+
throw new SolvaPayError(`Create checkout session failed (${res.status}): ${error}`);
|
|
324
|
+
}
|
|
325
|
+
const result = await res.json();
|
|
326
|
+
return result;
|
|
327
|
+
},
|
|
328
|
+
// POST: /v1/sdk/customers/customer-sessions
|
|
329
|
+
async createCustomerSession(params) {
|
|
330
|
+
const url = `${base}/v1/sdk/customers/customer-sessions`;
|
|
331
|
+
const res = await fetch(url, {
|
|
332
|
+
method: "POST",
|
|
333
|
+
headers,
|
|
334
|
+
body: JSON.stringify(params)
|
|
335
|
+
});
|
|
336
|
+
if (!res.ok) {
|
|
337
|
+
const error = await res.text();
|
|
338
|
+
log(`\u274C API Error: ${res.status} - ${error}`);
|
|
339
|
+
throw new SolvaPayError(`Create customer session failed (${res.status}): ${error}`);
|
|
340
|
+
}
|
|
341
|
+
const result = await res.json();
|
|
342
|
+
return result;
|
|
311
343
|
}
|
|
312
344
|
};
|
|
313
345
|
}
|
|
@@ -984,6 +1016,12 @@ function createSolvaPay(config) {
|
|
|
984
1016
|
}
|
|
985
1017
|
return apiClient.getCustomer(params);
|
|
986
1018
|
},
|
|
1019
|
+
createCheckoutSession(params) {
|
|
1020
|
+
return apiClient.createCheckoutSession(params);
|
|
1021
|
+
},
|
|
1022
|
+
createCustomerSession(params) {
|
|
1023
|
+
return apiClient.createCustomerSession(params);
|
|
1024
|
+
},
|
|
987
1025
|
// Payable API for framework-specific handlers
|
|
988
1026
|
payable(options = {}) {
|
|
989
1027
|
const agent = options.agentRef || options.agent || process.env.SOLVAPAY_AGENT || getPackageJsonName() || "default-agent";
|
package/dist/index.cjs
CHANGED
|
@@ -4567,6 +4567,38 @@ function createSolvaPayClient(opts) {
|
|
|
4567
4567
|
throw new import_core.SolvaPayError(`Invalid subscription data in cancel subscription response`);
|
|
4568
4568
|
}
|
|
4569
4569
|
return result;
|
|
4570
|
+
},
|
|
4571
|
+
// POST: /v1/sdk/checkout-sessions
|
|
4572
|
+
async createCheckoutSession(params) {
|
|
4573
|
+
const url = `${base}/v1/sdk/checkout-sessions`;
|
|
4574
|
+
const res = await fetch(url, {
|
|
4575
|
+
method: "POST",
|
|
4576
|
+
headers,
|
|
4577
|
+
body: JSON.stringify(params)
|
|
4578
|
+
});
|
|
4579
|
+
if (!res.ok) {
|
|
4580
|
+
const error = await res.text();
|
|
4581
|
+
log(`\u274C API Error: ${res.status} - ${error}`);
|
|
4582
|
+
throw new import_core.SolvaPayError(`Create checkout session failed (${res.status}): ${error}`);
|
|
4583
|
+
}
|
|
4584
|
+
const result = await res.json();
|
|
4585
|
+
return result;
|
|
4586
|
+
},
|
|
4587
|
+
// POST: /v1/sdk/customers/customer-sessions
|
|
4588
|
+
async createCustomerSession(params) {
|
|
4589
|
+
const url = `${base}/v1/sdk/customers/customer-sessions`;
|
|
4590
|
+
const res = await fetch(url, {
|
|
4591
|
+
method: "POST",
|
|
4592
|
+
headers,
|
|
4593
|
+
body: JSON.stringify(params)
|
|
4594
|
+
});
|
|
4595
|
+
if (!res.ok) {
|
|
4596
|
+
const error = await res.text();
|
|
4597
|
+
log(`\u274C API Error: ${res.status} - ${error}`);
|
|
4598
|
+
throw new import_core.SolvaPayError(`Create customer session failed (${res.status}): ${error}`);
|
|
4599
|
+
}
|
|
4600
|
+
const result = await res.json();
|
|
4601
|
+
return result;
|
|
4570
4602
|
}
|
|
4571
4603
|
};
|
|
4572
4604
|
}
|
|
@@ -5243,6 +5275,12 @@ function createSolvaPay(config) {
|
|
|
5243
5275
|
}
|
|
5244
5276
|
return apiClient.getCustomer(params);
|
|
5245
5277
|
},
|
|
5278
|
+
createCheckoutSession(params) {
|
|
5279
|
+
return apiClient.createCheckoutSession(params);
|
|
5280
|
+
},
|
|
5281
|
+
createCustomerSession(params) {
|
|
5282
|
+
return apiClient.createCustomerSession(params);
|
|
5283
|
+
},
|
|
5246
5284
|
// Payable API for framework-specific handlers
|
|
5247
5285
|
payable(options = {}) {
|
|
5248
5286
|
const agent = options.agentRef || options.agent || process.env.SOLVAPAY_AGENT || getPackageJsonName() || "default-agent";
|
package/dist/index.d.cts
CHANGED
|
@@ -24,20 +24,25 @@ interface components {
|
|
|
24
24
|
ExecuteMultipleQueries: Record<string, never>;
|
|
25
25
|
CreateCheckoutSessionRequest: {
|
|
26
26
|
/**
|
|
27
|
-
* @description Customer reference
|
|
27
|
+
* @description Customer reference identifier
|
|
28
28
|
* @example cus_3c4d5e6f7g8h
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
customerRef: string;
|
|
31
31
|
/**
|
|
32
|
-
* @description
|
|
32
|
+
* @description Agent reference identifier
|
|
33
|
+
* @example agt_1a2b3c4d5e6f
|
|
34
|
+
*/
|
|
35
|
+
agentRef: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description Plan reference identifier (optional)
|
|
33
38
|
* @example pln_2b3c4d5e6f7g
|
|
34
39
|
*/
|
|
35
40
|
planRef?: string;
|
|
36
41
|
/**
|
|
37
|
-
* @description
|
|
38
|
-
* @example
|
|
42
|
+
* @description URL to redirect to after successful payment (optional)
|
|
43
|
+
* @example https://example.com/payment-success
|
|
39
44
|
*/
|
|
40
|
-
|
|
45
|
+
returnUrl?: string;
|
|
41
46
|
};
|
|
42
47
|
CheckoutSessionResponse: {
|
|
43
48
|
/**
|
|
@@ -67,7 +72,7 @@ interface components {
|
|
|
67
72
|
status: string;
|
|
68
73
|
/**
|
|
69
74
|
* @description Checkout URL to open the checkout page
|
|
70
|
-
* @example
|
|
75
|
+
* @example https://solvapay.com/customer/checkout?id=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
|
|
71
76
|
*/
|
|
72
77
|
checkoutUrl: string;
|
|
73
78
|
};
|
|
@@ -102,15 +107,15 @@ interface components {
|
|
|
102
107
|
*/
|
|
103
108
|
remaining: number;
|
|
104
109
|
/**
|
|
105
|
-
* @description Optional checkout
|
|
106
|
-
* @example https://checkout.solvapay.com/pay_1a2b3c4d
|
|
107
|
-
*/
|
|
108
|
-
checkoutUrl?: string;
|
|
109
|
-
/**
|
|
110
|
-
* @description Optional checkout session ID if payment is required
|
|
110
|
+
* @description Optional checkout session ID/token if payment is required
|
|
111
111
|
* @example e3f1c2d4b6a89f001122334455667788
|
|
112
112
|
*/
|
|
113
113
|
checkoutSessionId?: string;
|
|
114
|
+
/**
|
|
115
|
+
* @description Optional full checkout URL if payment is required (based on backend configuration)
|
|
116
|
+
* @example https://app.solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
|
|
117
|
+
*/
|
|
118
|
+
checkoutUrl?: string;
|
|
114
119
|
};
|
|
115
120
|
UsageEvent: {
|
|
116
121
|
/**
|
|
@@ -218,6 +223,60 @@ interface components {
|
|
|
218
223
|
/** @description Active subscriptions */
|
|
219
224
|
subscriptions?: components["schemas"]["SubscriptionInfo"][];
|
|
220
225
|
};
|
|
226
|
+
CreateCustomerSessionRequest: {
|
|
227
|
+
/**
|
|
228
|
+
* @description Customer reference identifier
|
|
229
|
+
* @example cus_3c4d5e6f7g8h
|
|
230
|
+
*/
|
|
231
|
+
customerRef: string;
|
|
232
|
+
};
|
|
233
|
+
CreateCustomerSessionResponse: {
|
|
234
|
+
/**
|
|
235
|
+
* @description Customer session ID/token
|
|
236
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
237
|
+
*/
|
|
238
|
+
sessionId: string;
|
|
239
|
+
/**
|
|
240
|
+
* @description Full customer URL based on backend configuration (ready to redirect customer)
|
|
241
|
+
* @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
|
|
242
|
+
*/
|
|
243
|
+
customerUrl: string;
|
|
244
|
+
};
|
|
245
|
+
GetCustomerSessionResponse: {
|
|
246
|
+
/**
|
|
247
|
+
* @description Customer session ID/token
|
|
248
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
249
|
+
*/
|
|
250
|
+
sessionId: string;
|
|
251
|
+
/**
|
|
252
|
+
* @description Session status
|
|
253
|
+
* @example active
|
|
254
|
+
* @enum {string}
|
|
255
|
+
*/
|
|
256
|
+
status: "active" | "expired" | "used";
|
|
257
|
+
/**
|
|
258
|
+
* @description Full customer URL based on backend configuration (ready to redirect customer)
|
|
259
|
+
* @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
|
|
260
|
+
*/
|
|
261
|
+
customerUrl: string;
|
|
262
|
+
/**
|
|
263
|
+
* @description Session expiration date
|
|
264
|
+
* @example 2025-01-01T12:00:00.000Z
|
|
265
|
+
*/
|
|
266
|
+
expiresAt: string;
|
|
267
|
+
/** @description Customer object from session data */
|
|
268
|
+
customer: components["schemas"]["CustomerResponse"];
|
|
269
|
+
/**
|
|
270
|
+
* @description Session creation date
|
|
271
|
+
* @example 2025-01-01T11:45:00.000Z
|
|
272
|
+
*/
|
|
273
|
+
createdAt: string;
|
|
274
|
+
/**
|
|
275
|
+
* @description Session last update date
|
|
276
|
+
* @example 2025-01-01T11:45:00.000Z
|
|
277
|
+
*/
|
|
278
|
+
updatedAt: string;
|
|
279
|
+
};
|
|
221
280
|
Agent: Record<string, never>;
|
|
222
281
|
CreateAgentRequest: Record<string, never>;
|
|
223
282
|
UpdateAgentRequest: Record<string, never>;
|
|
@@ -328,6 +387,18 @@ interface components {
|
|
|
328
387
|
*/
|
|
329
388
|
createdAt: string;
|
|
330
389
|
};
|
|
390
|
+
CreateCheckoutSessionResponse: {
|
|
391
|
+
/**
|
|
392
|
+
* @description Checkout session ID/token
|
|
393
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
394
|
+
*/
|
|
395
|
+
sessionId: string;
|
|
396
|
+
/**
|
|
397
|
+
* @description Full checkout URL based on backend configuration (ready to redirect customer)
|
|
398
|
+
* @example https://solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
|
|
399
|
+
*/
|
|
400
|
+
checkoutUrl: string;
|
|
401
|
+
};
|
|
331
402
|
CreatePageSettings: {
|
|
332
403
|
/** @description Page identifier */
|
|
333
404
|
id: string;
|
|
@@ -488,6 +559,8 @@ interface SolvaPayClient {
|
|
|
488
559
|
customerRef: string;
|
|
489
560
|
planRef?: string;
|
|
490
561
|
}): Promise<ProcessPaymentResult>;
|
|
562
|
+
createCheckoutSession(params: components['schemas']['CreateCheckoutSessionRequest']): Promise<components['schemas']['CreateCheckoutSessionResponse']>;
|
|
563
|
+
createCustomerSession(params: components['schemas']['CreateCustomerSessionRequest']): Promise<components['schemas']['CreateCustomerSessionResponse']>;
|
|
491
564
|
}
|
|
492
565
|
|
|
493
566
|
/**
|
|
@@ -782,6 +855,26 @@ interface SolvaPay {
|
|
|
782
855
|
startDate: string;
|
|
783
856
|
}>;
|
|
784
857
|
}>;
|
|
858
|
+
/**
|
|
859
|
+
* Create a checkout session for a customer
|
|
860
|
+
*/
|
|
861
|
+
createCheckoutSession(params: {
|
|
862
|
+
agentRef: string;
|
|
863
|
+
customerRef: string;
|
|
864
|
+
planRef?: string;
|
|
865
|
+
}): Promise<{
|
|
866
|
+
sessionId: string;
|
|
867
|
+
checkoutUrl: string;
|
|
868
|
+
}>;
|
|
869
|
+
/**
|
|
870
|
+
* Create a customer session for accessing customer-specific functionality
|
|
871
|
+
*/
|
|
872
|
+
createCustomerSession(params: {
|
|
873
|
+
customerRef: string;
|
|
874
|
+
}): Promise<{
|
|
875
|
+
sessionId: string;
|
|
876
|
+
customerUrl: string;
|
|
877
|
+
}>;
|
|
785
878
|
/**
|
|
786
879
|
* Direct access to the API client for advanced operations
|
|
787
880
|
* (agent/plan management, etc.)
|
package/dist/index.d.ts
CHANGED
|
@@ -24,20 +24,25 @@ interface components {
|
|
|
24
24
|
ExecuteMultipleQueries: Record<string, never>;
|
|
25
25
|
CreateCheckoutSessionRequest: {
|
|
26
26
|
/**
|
|
27
|
-
* @description Customer reference
|
|
27
|
+
* @description Customer reference identifier
|
|
28
28
|
* @example cus_3c4d5e6f7g8h
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
customerRef: string;
|
|
31
31
|
/**
|
|
32
|
-
* @description
|
|
32
|
+
* @description Agent reference identifier
|
|
33
|
+
* @example agt_1a2b3c4d5e6f
|
|
34
|
+
*/
|
|
35
|
+
agentRef: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description Plan reference identifier (optional)
|
|
33
38
|
* @example pln_2b3c4d5e6f7g
|
|
34
39
|
*/
|
|
35
40
|
planRef?: string;
|
|
36
41
|
/**
|
|
37
|
-
* @description
|
|
38
|
-
* @example
|
|
42
|
+
* @description URL to redirect to after successful payment (optional)
|
|
43
|
+
* @example https://example.com/payment-success
|
|
39
44
|
*/
|
|
40
|
-
|
|
45
|
+
returnUrl?: string;
|
|
41
46
|
};
|
|
42
47
|
CheckoutSessionResponse: {
|
|
43
48
|
/**
|
|
@@ -67,7 +72,7 @@ interface components {
|
|
|
67
72
|
status: string;
|
|
68
73
|
/**
|
|
69
74
|
* @description Checkout URL to open the checkout page
|
|
70
|
-
* @example
|
|
75
|
+
* @example https://solvapay.com/customer/checkout?id=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
|
|
71
76
|
*/
|
|
72
77
|
checkoutUrl: string;
|
|
73
78
|
};
|
|
@@ -102,15 +107,15 @@ interface components {
|
|
|
102
107
|
*/
|
|
103
108
|
remaining: number;
|
|
104
109
|
/**
|
|
105
|
-
* @description Optional checkout
|
|
106
|
-
* @example https://checkout.solvapay.com/pay_1a2b3c4d
|
|
107
|
-
*/
|
|
108
|
-
checkoutUrl?: string;
|
|
109
|
-
/**
|
|
110
|
-
* @description Optional checkout session ID if payment is required
|
|
110
|
+
* @description Optional checkout session ID/token if payment is required
|
|
111
111
|
* @example e3f1c2d4b6a89f001122334455667788
|
|
112
112
|
*/
|
|
113
113
|
checkoutSessionId?: string;
|
|
114
|
+
/**
|
|
115
|
+
* @description Optional full checkout URL if payment is required (based on backend configuration)
|
|
116
|
+
* @example https://app.solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
|
|
117
|
+
*/
|
|
118
|
+
checkoutUrl?: string;
|
|
114
119
|
};
|
|
115
120
|
UsageEvent: {
|
|
116
121
|
/**
|
|
@@ -218,6 +223,60 @@ interface components {
|
|
|
218
223
|
/** @description Active subscriptions */
|
|
219
224
|
subscriptions?: components["schemas"]["SubscriptionInfo"][];
|
|
220
225
|
};
|
|
226
|
+
CreateCustomerSessionRequest: {
|
|
227
|
+
/**
|
|
228
|
+
* @description Customer reference identifier
|
|
229
|
+
* @example cus_3c4d5e6f7g8h
|
|
230
|
+
*/
|
|
231
|
+
customerRef: string;
|
|
232
|
+
};
|
|
233
|
+
CreateCustomerSessionResponse: {
|
|
234
|
+
/**
|
|
235
|
+
* @description Customer session ID/token
|
|
236
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
237
|
+
*/
|
|
238
|
+
sessionId: string;
|
|
239
|
+
/**
|
|
240
|
+
* @description Full customer URL based on backend configuration (ready to redirect customer)
|
|
241
|
+
* @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
|
|
242
|
+
*/
|
|
243
|
+
customerUrl: string;
|
|
244
|
+
};
|
|
245
|
+
GetCustomerSessionResponse: {
|
|
246
|
+
/**
|
|
247
|
+
* @description Customer session ID/token
|
|
248
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
249
|
+
*/
|
|
250
|
+
sessionId: string;
|
|
251
|
+
/**
|
|
252
|
+
* @description Session status
|
|
253
|
+
* @example active
|
|
254
|
+
* @enum {string}
|
|
255
|
+
*/
|
|
256
|
+
status: "active" | "expired" | "used";
|
|
257
|
+
/**
|
|
258
|
+
* @description Full customer URL based on backend configuration (ready to redirect customer)
|
|
259
|
+
* @example https://solvapay.com/customer/manage?id=e3f1c2d4b6a89f001122334455667788
|
|
260
|
+
*/
|
|
261
|
+
customerUrl: string;
|
|
262
|
+
/**
|
|
263
|
+
* @description Session expiration date
|
|
264
|
+
* @example 2025-01-01T12:00:00.000Z
|
|
265
|
+
*/
|
|
266
|
+
expiresAt: string;
|
|
267
|
+
/** @description Customer object from session data */
|
|
268
|
+
customer: components["schemas"]["CustomerResponse"];
|
|
269
|
+
/**
|
|
270
|
+
* @description Session creation date
|
|
271
|
+
* @example 2025-01-01T11:45:00.000Z
|
|
272
|
+
*/
|
|
273
|
+
createdAt: string;
|
|
274
|
+
/**
|
|
275
|
+
* @description Session last update date
|
|
276
|
+
* @example 2025-01-01T11:45:00.000Z
|
|
277
|
+
*/
|
|
278
|
+
updatedAt: string;
|
|
279
|
+
};
|
|
221
280
|
Agent: Record<string, never>;
|
|
222
281
|
CreateAgentRequest: Record<string, never>;
|
|
223
282
|
UpdateAgentRequest: Record<string, never>;
|
|
@@ -328,6 +387,18 @@ interface components {
|
|
|
328
387
|
*/
|
|
329
388
|
createdAt: string;
|
|
330
389
|
};
|
|
390
|
+
CreateCheckoutSessionResponse: {
|
|
391
|
+
/**
|
|
392
|
+
* @description Checkout session ID/token
|
|
393
|
+
* @example e3f1c2d4b6a89f001122334455667788
|
|
394
|
+
*/
|
|
395
|
+
sessionId: string;
|
|
396
|
+
/**
|
|
397
|
+
* @description Full checkout URL based on backend configuration (ready to redirect customer)
|
|
398
|
+
* @example https://solvapay.com/customer/checkout?id=e3f1c2d4b6a89f001122334455667788
|
|
399
|
+
*/
|
|
400
|
+
checkoutUrl: string;
|
|
401
|
+
};
|
|
331
402
|
CreatePageSettings: {
|
|
332
403
|
/** @description Page identifier */
|
|
333
404
|
id: string;
|
|
@@ -488,6 +559,8 @@ interface SolvaPayClient {
|
|
|
488
559
|
customerRef: string;
|
|
489
560
|
planRef?: string;
|
|
490
561
|
}): Promise<ProcessPaymentResult>;
|
|
562
|
+
createCheckoutSession(params: components['schemas']['CreateCheckoutSessionRequest']): Promise<components['schemas']['CreateCheckoutSessionResponse']>;
|
|
563
|
+
createCustomerSession(params: components['schemas']['CreateCustomerSessionRequest']): Promise<components['schemas']['CreateCustomerSessionResponse']>;
|
|
491
564
|
}
|
|
492
565
|
|
|
493
566
|
/**
|
|
@@ -782,6 +855,26 @@ interface SolvaPay {
|
|
|
782
855
|
startDate: string;
|
|
783
856
|
}>;
|
|
784
857
|
}>;
|
|
858
|
+
/**
|
|
859
|
+
* Create a checkout session for a customer
|
|
860
|
+
*/
|
|
861
|
+
createCheckoutSession(params: {
|
|
862
|
+
agentRef: string;
|
|
863
|
+
customerRef: string;
|
|
864
|
+
planRef?: string;
|
|
865
|
+
}): Promise<{
|
|
866
|
+
sessionId: string;
|
|
867
|
+
checkoutUrl: string;
|
|
868
|
+
}>;
|
|
869
|
+
/**
|
|
870
|
+
* Create a customer session for accessing customer-specific functionality
|
|
871
|
+
*/
|
|
872
|
+
createCustomerSession(params: {
|
|
873
|
+
customerRef: string;
|
|
874
|
+
}): Promise<{
|
|
875
|
+
sessionId: string;
|
|
876
|
+
customerUrl: string;
|
|
877
|
+
}>;
|
|
785
878
|
/**
|
|
786
879
|
* Direct access to the API client for advanced operations
|
|
787
880
|
* (agent/plan management, etc.)
|
package/dist/index.js
CHANGED
|
@@ -309,6 +309,38 @@ function createSolvaPayClient(opts) {
|
|
|
309
309
|
throw new SolvaPayError(`Invalid subscription data in cancel subscription response`);
|
|
310
310
|
}
|
|
311
311
|
return result;
|
|
312
|
+
},
|
|
313
|
+
// POST: /v1/sdk/checkout-sessions
|
|
314
|
+
async createCheckoutSession(params) {
|
|
315
|
+
const url = `${base}/v1/sdk/checkout-sessions`;
|
|
316
|
+
const res = await fetch(url, {
|
|
317
|
+
method: "POST",
|
|
318
|
+
headers,
|
|
319
|
+
body: JSON.stringify(params)
|
|
320
|
+
});
|
|
321
|
+
if (!res.ok) {
|
|
322
|
+
const error = await res.text();
|
|
323
|
+
log(`\u274C API Error: ${res.status} - ${error}`);
|
|
324
|
+
throw new SolvaPayError(`Create checkout session failed (${res.status}): ${error}`);
|
|
325
|
+
}
|
|
326
|
+
const result = await res.json();
|
|
327
|
+
return result;
|
|
328
|
+
},
|
|
329
|
+
// POST: /v1/sdk/customers/customer-sessions
|
|
330
|
+
async createCustomerSession(params) {
|
|
331
|
+
const url = `${base}/v1/sdk/customers/customer-sessions`;
|
|
332
|
+
const res = await fetch(url, {
|
|
333
|
+
method: "POST",
|
|
334
|
+
headers,
|
|
335
|
+
body: JSON.stringify(params)
|
|
336
|
+
});
|
|
337
|
+
if (!res.ok) {
|
|
338
|
+
const error = await res.text();
|
|
339
|
+
log(`\u274C API Error: ${res.status} - ${error}`);
|
|
340
|
+
throw new SolvaPayError(`Create customer session failed (${res.status}): ${error}`);
|
|
341
|
+
}
|
|
342
|
+
const result = await res.json();
|
|
343
|
+
return result;
|
|
312
344
|
}
|
|
313
345
|
};
|
|
314
346
|
}
|
|
@@ -985,6 +1017,12 @@ function createSolvaPay(config) {
|
|
|
985
1017
|
}
|
|
986
1018
|
return apiClient.getCustomer(params);
|
|
987
1019
|
},
|
|
1020
|
+
createCheckoutSession(params) {
|
|
1021
|
+
return apiClient.createCheckoutSession(params);
|
|
1022
|
+
},
|
|
1023
|
+
createCustomerSession(params) {
|
|
1024
|
+
return apiClient.createCustomerSession(params);
|
|
1025
|
+
},
|
|
988
1026
|
// Payable API for framework-specific handlers
|
|
989
1027
|
payable(options = {}) {
|
|
990
1028
|
const agent = options.agentRef || options.agent || process.env.SOLVAPAY_AGENT || getPackageJsonName() || "default-agent";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solvapay/server",
|
|
3
|
-
"version": "1.0.0-preview.
|
|
3
|
+
"version": "1.0.0-preview.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@solvapay/core": "1.0.0-preview.
|
|
40
|
+
"@solvapay/core": "1.0.0-preview.9"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"dotenv": "^17.2.3",
|