@lavapayments/nodejs 6.1.0 → 8.0.0
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/README.md +4 -4
- package/dist/index.d.mts +190 -122
- package/dist/index.d.ts +190 -122
- package/dist/index.js +103 -85
- package/dist/index.mjs +103 -85
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,8 +38,8 @@ console.log(checkoutSession.checkout_session_token);
|
|
|
38
38
|
```typescript
|
|
39
39
|
// Generate a forward token
|
|
40
40
|
const forwardToken = lava.generateForwardToken({
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
connection_id: 'connection_id',
|
|
42
|
+
meter_slug: 'meter_slug',
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
// Use the token to make an API request through Lava
|
|
@@ -65,11 +65,11 @@ const data = await response.json();
|
|
|
65
65
|
console.log(data);
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
### Check a connection's
|
|
68
|
+
### Check a connection's credit status
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
71
|
const connection = await lava.connections.retrieve('connection_id');
|
|
72
|
-
console.log('
|
|
72
|
+
console.log('Has credit balance:', connection.has_lava_credit_balance);
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
### Get connection requests
|
package/dist/index.d.mts
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
1
|
interface CreateCheckoutSessionParams {
|
|
2
2
|
checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
|
|
3
3
|
origin_url: string;
|
|
4
|
-
reference_id?: string;
|
|
5
4
|
connection_id?: string;
|
|
6
5
|
subscription_config_id?: string;
|
|
7
6
|
credit_bundle_id?: string;
|
|
8
7
|
}
|
|
9
|
-
interface CheckoutSessionsListParams {
|
|
10
|
-
cursor?: string;
|
|
11
|
-
limit?: number;
|
|
12
|
-
reference_id?: string;
|
|
13
|
-
}
|
|
14
8
|
interface ConnectionsListParams {
|
|
15
9
|
cursor?: string;
|
|
16
10
|
limit?: number;
|
|
17
|
-
reference_id?: string;
|
|
18
11
|
}
|
|
19
12
|
interface RequestsListParams {
|
|
20
13
|
cursor?: string;
|
|
21
14
|
limit?: number;
|
|
22
15
|
connection_id?: string;
|
|
23
|
-
|
|
16
|
+
meter_id?: string;
|
|
24
17
|
metadata_filters?: Record<string, string>;
|
|
25
18
|
}
|
|
26
19
|
interface CreateRequestParams {
|
|
27
20
|
request_id: string;
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
connection_id: string;
|
|
22
|
+
meter_slug: string;
|
|
30
23
|
metadata?: Record<string, string>;
|
|
31
24
|
input_tokens?: number;
|
|
32
25
|
output_tokens?: number;
|
|
@@ -44,7 +37,7 @@ interface UsageParams {
|
|
|
44
37
|
start: string;
|
|
45
38
|
end?: string;
|
|
46
39
|
connection_id?: string;
|
|
47
|
-
|
|
40
|
+
meter_id?: string;
|
|
48
41
|
metadata_filters?: Record<string, string>;
|
|
49
42
|
}
|
|
50
43
|
interface ListResponse<T> {
|
|
@@ -52,79 +45,66 @@ interface ListResponse<T> {
|
|
|
52
45
|
has_more: boolean;
|
|
53
46
|
next_cursor?: string;
|
|
54
47
|
}
|
|
55
|
-
interface CreateSubscriptionConfigParams {
|
|
56
|
-
name: string;
|
|
57
|
-
period_amount: string;
|
|
58
|
-
rollover_type: 'full' | 'none';
|
|
59
|
-
}
|
|
60
|
-
interface UpdateSubscriptionConfigParams {
|
|
61
|
-
name?: string;
|
|
62
|
-
period_amount?: string;
|
|
63
|
-
rollover_type?: 'full' | 'none';
|
|
64
|
-
}
|
|
65
48
|
type RestCheckoutSession = {
|
|
66
49
|
checkout_session_id: string;
|
|
67
50
|
checkout_session_token: string;
|
|
68
51
|
checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
|
|
69
52
|
origin_url: string;
|
|
70
53
|
connection_id?: string;
|
|
71
|
-
reference_id?: string;
|
|
72
54
|
subscription_config_id?: string;
|
|
73
55
|
created_at: string;
|
|
74
56
|
completed_at?: string;
|
|
75
57
|
};
|
|
76
|
-
type
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
balance: string;
|
|
82
|
-
phone: string;
|
|
83
|
-
email: string;
|
|
84
|
-
first_name: string;
|
|
85
|
-
last_name: string;
|
|
86
|
-
autopay_enabled: boolean;
|
|
87
|
-
};
|
|
88
|
-
next_usage_reset: string;
|
|
89
|
-
previous_usage_reset: string;
|
|
90
|
-
created_at: string;
|
|
91
|
-
};
|
|
92
|
-
type RestConnectionSubscriptionCredits = {
|
|
93
|
-
total_remaining: string;
|
|
94
|
-
cycle_remaining: string;
|
|
95
|
-
bundle_remaining: string;
|
|
96
|
-
cycle_rollover: 'full' | 'none';
|
|
97
|
-
bundle_rollover: 'full' | 'none';
|
|
98
|
-
};
|
|
99
|
-
type RestConnectionSubscriptionPendingChange = {
|
|
100
|
-
type: 'cancellation' | 'downgrade';
|
|
101
|
-
effective_at: string | null;
|
|
102
|
-
subscription_config_id?: string;
|
|
103
|
-
name?: string;
|
|
104
|
-
period_amount?: string;
|
|
105
|
-
included_credit?: string;
|
|
58
|
+
type RestConnectionCustomer = {
|
|
59
|
+
phone: string;
|
|
60
|
+
email: string;
|
|
61
|
+
first_name: string;
|
|
62
|
+
last_name: string;
|
|
106
63
|
};
|
|
107
|
-
|
|
108
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Simple subscription summary included in connection responses.
|
|
66
|
+
* For full subscription details, use getSubscription().
|
|
67
|
+
*/
|
|
68
|
+
type RestConnectionSubscription = {
|
|
69
|
+
subscription_id: string;
|
|
109
70
|
subscription_config_id: string;
|
|
110
71
|
name: string;
|
|
111
72
|
status: 'active' | 'cancelled';
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Base subscription shape shared between endpoints.
|
|
76
|
+
* Used directly by GET /v1/connections/:id/subscription
|
|
77
|
+
*/
|
|
78
|
+
type RestSubscriptionBase = {
|
|
79
|
+
subscription_id: string;
|
|
80
|
+
subscription_config_id: string;
|
|
81
|
+
status: 'active' | 'cancelled';
|
|
82
|
+
started_at: string;
|
|
83
|
+
cancelled_at: string | null;
|
|
115
84
|
cycle_start_at: string | null;
|
|
116
85
|
cycle_end_at: string | null;
|
|
117
|
-
|
|
118
|
-
|
|
86
|
+
plan: RestSubscriptionPlan;
|
|
87
|
+
credits: RestSubscriptionCredits;
|
|
88
|
+
pending_change: RestPendingChange | null;
|
|
119
89
|
};
|
|
120
|
-
|
|
121
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Response shape for getSubscription() method.
|
|
92
|
+
*/
|
|
93
|
+
type RestConnectionSubscriptionResponse = {
|
|
94
|
+
subscription: RestSubscriptionBase | null;
|
|
95
|
+
};
|
|
96
|
+
type RestConnection = {
|
|
97
|
+
connection_id: string;
|
|
98
|
+
has_lava_credit_balance: boolean;
|
|
99
|
+
customer: RestConnectionCustomer;
|
|
100
|
+
subscription: RestConnectionSubscription | null;
|
|
101
|
+
created_at: string;
|
|
122
102
|
};
|
|
123
103
|
type RestRequest = {
|
|
124
104
|
request_id: string;
|
|
125
105
|
status: 'pending' | 'completed' | 'error';
|
|
126
106
|
connection_id?: string;
|
|
127
|
-
|
|
107
|
+
meter_id?: string;
|
|
128
108
|
provider: string;
|
|
129
109
|
provider_key_type: 'managed' | 'unmanaged';
|
|
130
110
|
model?: string;
|
|
@@ -201,35 +181,91 @@ type RestUsage = {
|
|
|
201
181
|
total_net_volume: string;
|
|
202
182
|
};
|
|
203
183
|
};
|
|
184
|
+
type RestSubscriptionConfigLinkedMeter = {
|
|
185
|
+
meter_id: string;
|
|
186
|
+
name: string;
|
|
187
|
+
};
|
|
188
|
+
type RestSubscriptionConfigCreditBundle = {
|
|
189
|
+
credit_bundle_id: string;
|
|
190
|
+
name: string;
|
|
191
|
+
cost: string;
|
|
192
|
+
credit_amount: string;
|
|
193
|
+
};
|
|
204
194
|
type RestSubscriptionConfig = {
|
|
205
195
|
subscription_config_id: string;
|
|
206
196
|
merchant_id: string;
|
|
207
197
|
name: string;
|
|
208
198
|
period_amount: string;
|
|
199
|
+
included_credit: string;
|
|
200
|
+
billing_interval: 'day' | 'week' | 'month' | 'year';
|
|
209
201
|
rollover_type: 'full' | 'none';
|
|
210
202
|
bundle_rollover_type: 'full' | 'none';
|
|
203
|
+
linked_meters: RestSubscriptionConfigLinkedMeter[];
|
|
204
|
+
credit_bundles: RestSubscriptionConfigCreditBundle[];
|
|
211
205
|
created_at: string;
|
|
212
206
|
};
|
|
213
|
-
type
|
|
214
|
-
|
|
215
|
-
|
|
207
|
+
type RestPendingChange = {
|
|
208
|
+
type: 'cancellation' | 'downgrade';
|
|
209
|
+
effective_at: string | null;
|
|
210
|
+
subscription_config_id?: string;
|
|
211
|
+
name?: string;
|
|
212
|
+
period_amount?: string;
|
|
213
|
+
included_credit?: string;
|
|
214
|
+
};
|
|
215
|
+
type RestSubscriptionPlan = {
|
|
216
|
+
name: string;
|
|
217
|
+
period_amount: string;
|
|
218
|
+
included_credit: string;
|
|
219
|
+
billing_interval: 'day' | 'week' | 'month' | 'year';
|
|
220
|
+
rollover_type: 'full' | 'none';
|
|
221
|
+
bundle_rollover_type: 'full' | 'none';
|
|
222
|
+
};
|
|
223
|
+
type RestSubscriptionCredits = {
|
|
224
|
+
total_remaining: string;
|
|
225
|
+
cycle_remaining: string;
|
|
226
|
+
bundle_remaining: string;
|
|
227
|
+
};
|
|
228
|
+
type RestSubscriptionCustomer = {
|
|
229
|
+
phone: string;
|
|
230
|
+
email?: string;
|
|
231
|
+
first_name?: string;
|
|
232
|
+
last_name?: string;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Extended subscription shape for list endpoint.
|
|
236
|
+
* Adds connection_id and customer since endpoint spans connections.
|
|
237
|
+
*/
|
|
238
|
+
type RestSubscription = RestSubscriptionBase & {
|
|
239
|
+
connection_id: string;
|
|
240
|
+
customer: RestSubscriptionCustomer;
|
|
241
|
+
};
|
|
242
|
+
/** @deprecated Use RestSubscription instead */
|
|
243
|
+
type RestActiveSubscription = RestSubscription;
|
|
244
|
+
/** @deprecated Use RestSubscriptionPlan instead */
|
|
245
|
+
type RestSubscriptionPlanDetails = RestSubscriptionPlan;
|
|
246
|
+
type RestMeterTier = {
|
|
247
|
+
start: number;
|
|
248
|
+
rate: string;
|
|
249
|
+
type: 'tokens_1m' | 'characters_1m' | 'minutes' | 'requests';
|
|
250
|
+
};
|
|
251
|
+
type RestMeter = {
|
|
252
|
+
meter_id: string;
|
|
253
|
+
meter_slug: string;
|
|
254
|
+
name: string;
|
|
255
|
+
rate_type: 'fixed' | 'percentage';
|
|
256
|
+
token_basis: 'input+output' | 'output';
|
|
257
|
+
base_cost_payer: 'merchant' | 'wallet';
|
|
258
|
+
service_charge_payer: 'merchant' | 'wallet';
|
|
259
|
+
tiers: RestMeterTier[];
|
|
260
|
+
created_at: string;
|
|
261
|
+
};
|
|
262
|
+
type RestCreditBundle = {
|
|
263
|
+
credit_bundle_id: string;
|
|
216
264
|
subscription_config_id: string;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
scheduled_cancellation_at: string | null;
|
|
221
|
-
status: 'active' | 'cancelled';
|
|
265
|
+
name: string;
|
|
266
|
+
cost: string;
|
|
267
|
+
credit_amount: string;
|
|
222
268
|
created_at: string;
|
|
223
|
-
subscription_config: RestSubscriptionConfig;
|
|
224
|
-
wallet: {
|
|
225
|
-
wallet_id: string;
|
|
226
|
-
phone: string;
|
|
227
|
-
email?: string;
|
|
228
|
-
first_name?: string;
|
|
229
|
-
last_name?: string;
|
|
230
|
-
active_balance: string;
|
|
231
|
-
created_at: string;
|
|
232
|
-
};
|
|
233
269
|
};
|
|
234
270
|
|
|
235
271
|
/** biome-ignore-all lint/style/noNamespace: package uses namespace */
|
|
@@ -249,18 +285,6 @@ declare namespace Resources {
|
|
|
249
285
|
* @returns Created checkout session
|
|
250
286
|
*/
|
|
251
287
|
create(params: CreateCheckoutSessionParams): Promise<RestCheckoutSession>;
|
|
252
|
-
/**
|
|
253
|
-
* List checkout sessions
|
|
254
|
-
* @param params List parameters
|
|
255
|
-
* @returns Paginated list of checkout sessions
|
|
256
|
-
*/
|
|
257
|
-
list(params?: CheckoutSessionsListParams): Promise<ListResponse<RestCheckoutSession>>;
|
|
258
|
-
/**
|
|
259
|
-
* Retrieve a checkout session
|
|
260
|
-
* @param checkoutSessionId Checkout session ID
|
|
261
|
-
* @returns Checkout session details
|
|
262
|
-
*/
|
|
263
|
-
retrieve(checkoutSessionId: string): Promise<RestCheckoutSession>;
|
|
264
288
|
}
|
|
265
289
|
/**
|
|
266
290
|
* Connection related endpoints
|
|
@@ -284,7 +308,7 @@ declare namespace Resources {
|
|
|
284
308
|
* @param connectionId Connection ID
|
|
285
309
|
* @returns Subscription details or null if no active subscription
|
|
286
310
|
*/
|
|
287
|
-
getSubscription(connectionId: string): Promise<
|
|
311
|
+
getSubscription(connectionId: string): Promise<RestConnectionSubscriptionResponse>;
|
|
288
312
|
/**
|
|
289
313
|
* Delete a connection
|
|
290
314
|
* @param connectionId Connection ID
|
|
@@ -328,44 +352,80 @@ declare namespace Resources {
|
|
|
328
352
|
*/
|
|
329
353
|
retrieve(params: UsageParams): Promise<RestUsage>;
|
|
330
354
|
}
|
|
331
|
-
|
|
355
|
+
/**
|
|
356
|
+
* Meter related endpoints
|
|
357
|
+
*/
|
|
358
|
+
export class MetersResource extends BaseResource {
|
|
332
359
|
/**
|
|
333
|
-
* List
|
|
334
|
-
* @
|
|
360
|
+
* List meters
|
|
361
|
+
* @param params Optional pagination parameters
|
|
362
|
+
* @returns Paginated list of meters
|
|
363
|
+
*/
|
|
364
|
+
list(params?: {
|
|
365
|
+
cursor?: string;
|
|
366
|
+
limit?: number;
|
|
367
|
+
}): Promise<ListResponse<RestMeter>>;
|
|
368
|
+
/**
|
|
369
|
+
* Retrieve a meter
|
|
370
|
+
* @param id Meter ID
|
|
371
|
+
* @returns Meter details
|
|
335
372
|
*/
|
|
336
|
-
|
|
373
|
+
retrieve(id: string): Promise<RestMeter>;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Credit bundle related endpoints
|
|
377
|
+
*/
|
|
378
|
+
export class CreditBundlesResource extends BaseResource {
|
|
337
379
|
/**
|
|
338
|
-
*
|
|
339
|
-
* @param params
|
|
340
|
-
* @returns
|
|
380
|
+
* List credit bundles
|
|
381
|
+
* @param params Optional filter and pagination parameters
|
|
382
|
+
* @returns Paginated list of credit bundles
|
|
341
383
|
*/
|
|
342
|
-
|
|
384
|
+
list(params?: {
|
|
385
|
+
subscription_config_id?: string;
|
|
386
|
+
cursor?: string;
|
|
387
|
+
limit?: number;
|
|
388
|
+
}): Promise<ListResponse<RestCreditBundle>>;
|
|
343
389
|
/**
|
|
344
|
-
*
|
|
345
|
-
* @param id
|
|
346
|
-
* @
|
|
347
|
-
|
|
390
|
+
* Retrieve a credit bundle
|
|
391
|
+
* @param id Credit bundle ID
|
|
392
|
+
* @returns Credit bundle details
|
|
393
|
+
*/
|
|
394
|
+
retrieve(id: string): Promise<RestCreditBundle>;
|
|
395
|
+
}
|
|
396
|
+
export class SubscriptionsResource extends BaseResource {
|
|
397
|
+
/**
|
|
398
|
+
* List subscription configurations
|
|
399
|
+
* @param params Optional pagination parameters
|
|
400
|
+
* @returns Paginated list of subscription configurations
|
|
348
401
|
*/
|
|
349
|
-
|
|
402
|
+
listConfigs(params?: {
|
|
403
|
+
cursor?: string;
|
|
404
|
+
limit?: number;
|
|
405
|
+
}): Promise<ListResponse<RestSubscriptionConfig>>;
|
|
350
406
|
/**
|
|
351
|
-
*
|
|
407
|
+
* Retrieve a subscription configuration
|
|
352
408
|
* @param id Subscription configuration ID
|
|
353
|
-
* @returns
|
|
409
|
+
* @returns Subscription configuration details
|
|
354
410
|
*/
|
|
355
|
-
|
|
356
|
-
success: boolean;
|
|
357
|
-
}>;
|
|
411
|
+
retrieveConfig(id: string): Promise<RestSubscriptionConfig>;
|
|
358
412
|
/**
|
|
359
|
-
* List
|
|
360
|
-
* @
|
|
413
|
+
* List subscriptions for a merchant
|
|
414
|
+
* @param params Optional filter and pagination parameters
|
|
415
|
+
* @returns Paginated list of subscriptions
|
|
361
416
|
*/
|
|
362
|
-
|
|
417
|
+
list(params?: {
|
|
418
|
+
status?: 'active' | 'cancelled' | 'all';
|
|
419
|
+
connection_id?: string;
|
|
420
|
+
cursor?: string;
|
|
421
|
+
limit?: number;
|
|
422
|
+
}): Promise<ListResponse<RestSubscription>>;
|
|
363
423
|
/**
|
|
364
|
-
* Cancel
|
|
365
|
-
* @param id
|
|
424
|
+
* Cancel a subscription
|
|
425
|
+
* @param id Subscription ID
|
|
366
426
|
* @returns Success response
|
|
367
427
|
*/
|
|
368
|
-
|
|
428
|
+
cancel(id: string): Promise<{
|
|
369
429
|
success: boolean;
|
|
370
430
|
}>;
|
|
371
431
|
}
|
|
@@ -382,12 +442,12 @@ interface Config {
|
|
|
382
442
|
baseUrl?: string;
|
|
383
443
|
}
|
|
384
444
|
type ForwardTokenOptions = {
|
|
385
|
-
|
|
386
|
-
|
|
445
|
+
connection_id: string;
|
|
446
|
+
meter_slug: string;
|
|
387
447
|
provider_key?: string;
|
|
388
448
|
} | {
|
|
389
|
-
|
|
390
|
-
|
|
449
|
+
connection_id: null;
|
|
450
|
+
meter_slug: null;
|
|
391
451
|
provider_key: string;
|
|
392
452
|
};
|
|
393
453
|
declare class Lava {
|
|
@@ -414,6 +474,14 @@ declare class Lava {
|
|
|
414
474
|
* The subscriptions resource
|
|
415
475
|
*/
|
|
416
476
|
readonly subscriptions: Resources.SubscriptionsResource;
|
|
477
|
+
/**
|
|
478
|
+
* The meters resource
|
|
479
|
+
*/
|
|
480
|
+
readonly meters: Resources.MetersResource;
|
|
481
|
+
/**
|
|
482
|
+
* The credit bundles resource
|
|
483
|
+
*/
|
|
484
|
+
readonly creditBundles: Resources.CreditBundlesResource;
|
|
417
485
|
/**
|
|
418
486
|
* Provider URLs for convenience
|
|
419
487
|
*/
|
|
@@ -471,4 +539,4 @@ declare class Lava {
|
|
|
471
539
|
generateForwardToken(options: ForwardTokenOptions): string;
|
|
472
540
|
}
|
|
473
541
|
|
|
474
|
-
export { type ApiVersion, type
|
|
542
|
+
export { type ApiVersion, type Config, type ConnectionsListParams, type CreateCheckoutSessionParams, type CreateRequestParams, type ForwardTokenOptions, Lava, type ListResponse, type RequestsListParams, type RequestsListResponse, Resources, type RestActiveSubscription, type RestCheckoutSession, type RestConnection, type RestConnectionCustomer, type RestConnectionSubscription, type RestConnectionSubscriptionResponse, type RestCreditBundle, type RestMeter, type RestMeterTier, type RestPendingChange, type RestRequest, type RestSubscription, type RestSubscriptionBase, type RestSubscriptionConfig, type RestSubscriptionConfigCreditBundle, type RestSubscriptionConfigLinkedMeter, type RestSubscriptionCredits, type RestSubscriptionCustomer, type RestSubscriptionPlan, type RestSubscriptionPlanDetails, type RestUsage, type UsageParams };
|