@drawbridge/drawbridge-stripe 0.0.4 → 0.0.5
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/index.d.mts +14 -20
- package/dist/index.d.ts +14 -20
- package/dist/index.js +34 -38
- package/dist/index.mjs +15 -19
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
const lib = require( './lib' );
|
|
2
|
+
const stripe = require( 'stripe' )(
|
|
3
|
+
process.env.STRIPE_API_KEY,
|
|
4
|
+
{
|
|
5
|
+
apiVersion : '2026-01-28.preview'
|
|
6
|
+
}
|
|
7
|
+
);
|
|
2
8
|
|
|
3
|
-
module.exports =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
billing : lib.billing({
|
|
14
|
-
apiKey,
|
|
15
|
-
stripe
|
|
16
|
-
}),
|
|
17
|
-
stripe,
|
|
18
|
-
subscription : lib.subscription({
|
|
19
|
-
stripe
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
9
|
+
module.exports = {
|
|
10
|
+
billing : lib.billing({
|
|
11
|
+
stripe
|
|
12
|
+
}),
|
|
13
|
+
stripe,
|
|
14
|
+
subscription : lib.subscription({
|
|
15
|
+
stripe
|
|
16
|
+
})
|
|
23
17
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
const lib = require( './lib' );
|
|
2
|
+
const stripe = require( 'stripe' )(
|
|
3
|
+
process.env.STRIPE_API_KEY,
|
|
4
|
+
{
|
|
5
|
+
apiVersion : '2026-01-28.preview'
|
|
6
|
+
}
|
|
7
|
+
);
|
|
2
8
|
|
|
3
|
-
module.exports =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
billing : lib.billing({
|
|
14
|
-
apiKey,
|
|
15
|
-
stripe
|
|
16
|
-
}),
|
|
17
|
-
stripe,
|
|
18
|
-
subscription : lib.subscription({
|
|
19
|
-
stripe
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
9
|
+
module.exports = {
|
|
10
|
+
billing : lib.billing({
|
|
11
|
+
stripe
|
|
12
|
+
}),
|
|
13
|
+
stripe,
|
|
14
|
+
subscription : lib.subscription({
|
|
15
|
+
stripe
|
|
16
|
+
})
|
|
23
17
|
};
|
package/dist/index.js
CHANGED
|
@@ -9,12 +9,11 @@ var require_billing = __commonJS({
|
|
|
9
9
|
var axios = require("axios");
|
|
10
10
|
var billing = "https://api.stripe.com/v2/billing";
|
|
11
11
|
module2.exports = ({
|
|
12
|
-
|
|
13
|
-
stripe
|
|
12
|
+
stripe: stripe2
|
|
14
13
|
}) => {
|
|
15
14
|
const options = {
|
|
16
15
|
headers: {
|
|
17
|
-
"Authorization": "Bearer " +
|
|
16
|
+
"Authorization": "Bearer " + process.env.STRIPE_API_KEY,
|
|
18
17
|
"Content-Type": "application/json",
|
|
19
18
|
"Stripe-Version": "2026-01-28.preview"
|
|
20
19
|
}
|
|
@@ -77,7 +76,7 @@ var require_billing = __commonJS({
|
|
|
77
76
|
billing + "/intents/" + (intent == null ? void 0 : intent.id) + "/actions",
|
|
78
77
|
options
|
|
79
78
|
);
|
|
80
|
-
const replenish = await
|
|
79
|
+
const replenish = await stripe2.billing.alerts.create({
|
|
81
80
|
alert_type: "credit_balance_threshold",
|
|
82
81
|
credit_balance_threshold: {
|
|
83
82
|
filters: [
|
|
@@ -104,7 +103,7 @@ var require_billing = __commonJS({
|
|
|
104
103
|
},
|
|
105
104
|
title: customer + ".credit_balance_replenish"
|
|
106
105
|
});
|
|
107
|
-
const depleted = await
|
|
106
|
+
const depleted = await stripe2.billing.alerts.create({
|
|
108
107
|
alert_type: "credit_balance_threshold",
|
|
109
108
|
credit_balance_threshold: {
|
|
110
109
|
filters: [
|
|
@@ -190,7 +189,7 @@ var require_billing = __commonJS({
|
|
|
190
189
|
const input = Number(metadata == null ? void 0 : metadata.promptTokenCount);
|
|
191
190
|
const output = parseInt(Number(metadata == null ? void 0 : metadata.totalTokenCount) - input);
|
|
192
191
|
if (input) {
|
|
193
|
-
|
|
192
|
+
stripe2.billing.meterEvents.create({
|
|
194
193
|
event_name,
|
|
195
194
|
payload: {
|
|
196
195
|
model,
|
|
@@ -202,7 +201,7 @@ var require_billing = __commonJS({
|
|
|
202
201
|
}
|
|
203
202
|
;
|
|
204
203
|
if (output) {
|
|
205
|
-
|
|
204
|
+
stripe2.billing.meterEvents.create({
|
|
206
205
|
event_name,
|
|
207
206
|
payload: {
|
|
208
207
|
model,
|
|
@@ -227,14 +226,14 @@ var require_billing = __commonJS({
|
|
|
227
226
|
var require_subscription = __commonJS({
|
|
228
227
|
"lib/subscription.js"(exports2, module2) {
|
|
229
228
|
module2.exports = ({
|
|
230
|
-
stripe
|
|
229
|
+
stripe: stripe2
|
|
231
230
|
}) => {
|
|
232
231
|
const createMeter = async ({
|
|
233
232
|
metadata,
|
|
234
233
|
name
|
|
235
234
|
}) => {
|
|
236
235
|
const usage = (metadata == null ? void 0 : metadata.organization) + "_usage_" + name;
|
|
237
|
-
const meter = await
|
|
236
|
+
const meter = await stripe2.billing.meters.create({
|
|
238
237
|
default_aggregation: {
|
|
239
238
|
formula: "sum"
|
|
240
239
|
},
|
|
@@ -256,12 +255,12 @@ var require_subscription = __commonJS({
|
|
|
256
255
|
overage
|
|
257
256
|
}) => {
|
|
258
257
|
const response = {};
|
|
259
|
-
const product = await
|
|
258
|
+
const product = await stripe2.products.create({
|
|
260
259
|
metadata,
|
|
261
260
|
name
|
|
262
261
|
});
|
|
263
262
|
response["product"] = product == null ? void 0 : product.id;
|
|
264
|
-
const price = await
|
|
263
|
+
const price = await stripe2.prices.create({
|
|
265
264
|
billing_scheme: "tiered",
|
|
266
265
|
currency: currency2,
|
|
267
266
|
metadata,
|
|
@@ -319,7 +318,7 @@ var require_subscription = __commonJS({
|
|
|
319
318
|
response["price"] = price;
|
|
320
319
|
response["product"] = product;
|
|
321
320
|
if (subscription) {
|
|
322
|
-
const { id } = await
|
|
321
|
+
const { id } = await stripe2.subscriptionItems.create({
|
|
323
322
|
metadata,
|
|
324
323
|
price,
|
|
325
324
|
proration_behavior,
|
|
@@ -342,7 +341,7 @@ var require_subscription = __commonJS({
|
|
|
342
341
|
const props = {
|
|
343
342
|
metadata
|
|
344
343
|
};
|
|
345
|
-
const plan = await
|
|
344
|
+
const plan = await stripe2.subscriptionItems.update(
|
|
346
345
|
(_a = items == null ? void 0 : items.plan) == null ? void 0 : _a.id,
|
|
347
346
|
{
|
|
348
347
|
...props,
|
|
@@ -352,7 +351,7 @@ var require_subscription = __commonJS({
|
|
|
352
351
|
);
|
|
353
352
|
let entries = (items == null ? void 0 : items.entries) || {};
|
|
354
353
|
if ((entries == null ? void 0 : entries.id) && (entries == null ? void 0 : entries.price)) {
|
|
355
|
-
({ id: entries["id"] } = await
|
|
354
|
+
({ id: entries["id"] } = await stripe2.subscriptionItems.update(
|
|
356
355
|
entries.id,
|
|
357
356
|
{
|
|
358
357
|
...props,
|
|
@@ -372,7 +371,7 @@ var require_subscription = __commonJS({
|
|
|
372
371
|
subscription: stripeSubscriptionId
|
|
373
372
|
});
|
|
374
373
|
}
|
|
375
|
-
await
|
|
374
|
+
await stripe2.subscriptions.update(
|
|
376
375
|
stripeSubscriptionId,
|
|
377
376
|
{
|
|
378
377
|
metadata
|
|
@@ -410,7 +409,7 @@ var require_subscription = __commonJS({
|
|
|
410
409
|
overage: to.overages.entries,
|
|
411
410
|
proration_behavior: "none"
|
|
412
411
|
});
|
|
413
|
-
const subscription = await
|
|
412
|
+
const subscription = await stripe2.subscriptions.create({
|
|
414
413
|
automatic_tax: {
|
|
415
414
|
enabled: true
|
|
416
415
|
},
|
|
@@ -425,8 +424,8 @@ var require_subscription = __commonJS({
|
|
|
425
424
|
],
|
|
426
425
|
metadata
|
|
427
426
|
});
|
|
428
|
-
const { product } = await
|
|
429
|
-
const plan = await
|
|
427
|
+
const { product } = await stripe2.prices.retrieve(to == null ? void 0 : to.stripePriceId);
|
|
428
|
+
const plan = await stripe2.subscriptionItems.create({
|
|
430
429
|
subscription: subscription == null ? void 0 : subscription.id,
|
|
431
430
|
price: to == null ? void 0 : to.stripePriceId,
|
|
432
431
|
quantity: 1,
|
|
@@ -463,7 +462,7 @@ var require_subscription = __commonJS({
|
|
|
463
462
|
const props = {
|
|
464
463
|
metadata
|
|
465
464
|
};
|
|
466
|
-
const plan = await
|
|
465
|
+
const plan = await stripe2.subscriptionItems.update(
|
|
467
466
|
(_b = (_a = current == null ? void 0 : current.items) == null ? void 0 : _a.plan) == null ? void 0 : _b.id,
|
|
468
467
|
{
|
|
469
468
|
...props,
|
|
@@ -482,7 +481,7 @@ var require_subscription = __commonJS({
|
|
|
482
481
|
name: "entries",
|
|
483
482
|
overage: to.overages.entries
|
|
484
483
|
});
|
|
485
|
-
({ id: entries["id"] } = await
|
|
484
|
+
({ id: entries["id"] } = await stripe2.subscriptionItems.update(
|
|
486
485
|
current.items.entries.id,
|
|
487
486
|
{
|
|
488
487
|
...props,
|
|
@@ -503,7 +502,7 @@ var require_subscription = __commonJS({
|
|
|
503
502
|
});
|
|
504
503
|
}
|
|
505
504
|
;
|
|
506
|
-
await
|
|
505
|
+
await stripe2.subscriptions.update(
|
|
507
506
|
stripeSubscriptionId,
|
|
508
507
|
{
|
|
509
508
|
metadata
|
|
@@ -545,21 +544,18 @@ var require_lib = __commonJS({
|
|
|
545
544
|
|
|
546
545
|
// index.js
|
|
547
546
|
var lib = require_lib();
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
stripe
|
|
561
|
-
|
|
562
|
-
stripe
|
|
563
|
-
})
|
|
564
|
-
};
|
|
547
|
+
var stripe = require("stripe")(
|
|
548
|
+
process.env.STRIPE_API_KEY,
|
|
549
|
+
{
|
|
550
|
+
apiVersion: "2026-01-28.preview"
|
|
551
|
+
}
|
|
552
|
+
);
|
|
553
|
+
module.exports = {
|
|
554
|
+
billing: lib.billing({
|
|
555
|
+
stripe
|
|
556
|
+
}),
|
|
557
|
+
stripe,
|
|
558
|
+
subscription: lib.subscription({
|
|
559
|
+
stripe
|
|
560
|
+
})
|
|
565
561
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -15,12 +15,11 @@ var require_billing = __commonJS({
|
|
|
15
15
|
var axios = __require("axios");
|
|
16
16
|
var billing = "https://api.stripe.com/v2/billing";
|
|
17
17
|
module.exports = ({
|
|
18
|
-
apiKey,
|
|
19
18
|
stripe
|
|
20
19
|
}) => {
|
|
21
20
|
const options = {
|
|
22
21
|
headers: {
|
|
23
|
-
"Authorization": "Bearer " +
|
|
22
|
+
"Authorization": "Bearer " + process.env.STRIPE_API_KEY,
|
|
24
23
|
"Content-Type": "application/json",
|
|
25
24
|
"Stripe-Version": "2026-01-28.preview"
|
|
26
25
|
}
|
|
@@ -553,23 +552,20 @@ var require_lib = __commonJS({
|
|
|
553
552
|
var require_index = __commonJS({
|
|
554
553
|
"index.js"(exports, module) {
|
|
555
554
|
var lib = require_lib();
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
stripe
|
|
569
|
-
|
|
570
|
-
stripe
|
|
571
|
-
})
|
|
572
|
-
};
|
|
555
|
+
var stripe = __require("stripe")(
|
|
556
|
+
process.env.STRIPE_API_KEY,
|
|
557
|
+
{
|
|
558
|
+
apiVersion: "2026-01-28.preview"
|
|
559
|
+
}
|
|
560
|
+
);
|
|
561
|
+
module.exports = {
|
|
562
|
+
billing: lib.billing({
|
|
563
|
+
stripe
|
|
564
|
+
}),
|
|
565
|
+
stripe,
|
|
566
|
+
subscription: lib.subscription({
|
|
567
|
+
stripe
|
|
568
|
+
})
|
|
573
569
|
};
|
|
574
570
|
}
|
|
575
571
|
});
|
package/package.json
CHANGED