@drawbridge/drawbridge-stripe 0.1.17 → 0.1.18
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.js +28 -0
- package/dist/index.mjs +28 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -324,10 +324,34 @@ var require_subscription = __commonJS({
|
|
|
324
324
|
};
|
|
325
325
|
const createMeter = async ({
|
|
326
326
|
idempotencyKey,
|
|
327
|
+
meter: existing,
|
|
327
328
|
metadata,
|
|
328
329
|
name
|
|
329
330
|
}) => {
|
|
330
331
|
const usage = (metadata == null ? void 0 : metadata.organization) + "_usage_" + name;
|
|
332
|
+
if (existing) {
|
|
333
|
+
const meter2 = await stripe2.billing.meters.retrieve(existing).catch(() => null);
|
|
334
|
+
if ((meter2 == null ? void 0 : meter2.status) === "active" && (meter2 == null ? void 0 : meter2.event_name) === usage) {
|
|
335
|
+
return {
|
|
336
|
+
meter: meter2.id,
|
|
337
|
+
usage
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
;
|
|
341
|
+
}
|
|
342
|
+
;
|
|
343
|
+
for await (const meter2 of stripe2.billing.meters.list({
|
|
344
|
+
status: "active"
|
|
345
|
+
})) {
|
|
346
|
+
if ((meter2 == null ? void 0 : meter2.event_name) === usage) {
|
|
347
|
+
return {
|
|
348
|
+
meter: meter2.id,
|
|
349
|
+
usage
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
;
|
|
353
|
+
}
|
|
354
|
+
;
|
|
331
355
|
const meter = await stripe2.billing.meters.create(
|
|
332
356
|
{
|
|
333
357
|
default_aggregation: {
|
|
@@ -399,6 +423,7 @@ var require_subscription = __commonJS({
|
|
|
399
423
|
idempotencyKey,
|
|
400
424
|
interval,
|
|
401
425
|
limit,
|
|
426
|
+
meter: existing,
|
|
402
427
|
metadata,
|
|
403
428
|
name,
|
|
404
429
|
overage,
|
|
@@ -408,6 +433,7 @@ var require_subscription = __commonJS({
|
|
|
408
433
|
const response = {};
|
|
409
434
|
const { meter, usage } = await createMeter({
|
|
410
435
|
idempotencyKey,
|
|
436
|
+
meter: existing,
|
|
411
437
|
metadata,
|
|
412
438
|
name
|
|
413
439
|
});
|
|
@@ -590,6 +616,7 @@ var require_subscription = __commonJS({
|
|
|
590
616
|
customer,
|
|
591
617
|
discounts = [],
|
|
592
618
|
idempotencyKey,
|
|
619
|
+
meter,
|
|
593
620
|
metadata,
|
|
594
621
|
stripePaymentMethodId,
|
|
595
622
|
to
|
|
@@ -601,6 +628,7 @@ var require_subscription = __commonJS({
|
|
|
601
628
|
idempotencyKey,
|
|
602
629
|
interval: to.interval,
|
|
603
630
|
limit: to.limits.organization.actions,
|
|
631
|
+
meter,
|
|
604
632
|
metadata,
|
|
605
633
|
name: "actions",
|
|
606
634
|
overage: to.overages.actions,
|
package/dist/index.mjs
CHANGED
|
@@ -330,10 +330,34 @@ var require_subscription = __commonJS({
|
|
|
330
330
|
};
|
|
331
331
|
const createMeter = async ({
|
|
332
332
|
idempotencyKey,
|
|
333
|
+
meter: existing,
|
|
333
334
|
metadata,
|
|
334
335
|
name
|
|
335
336
|
}) => {
|
|
336
337
|
const usage = (metadata == null ? void 0 : metadata.organization) + "_usage_" + name;
|
|
338
|
+
if (existing) {
|
|
339
|
+
const meter2 = await stripe.billing.meters.retrieve(existing).catch(() => null);
|
|
340
|
+
if ((meter2 == null ? void 0 : meter2.status) === "active" && (meter2 == null ? void 0 : meter2.event_name) === usage) {
|
|
341
|
+
return {
|
|
342
|
+
meter: meter2.id,
|
|
343
|
+
usage
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
;
|
|
347
|
+
}
|
|
348
|
+
;
|
|
349
|
+
for await (const meter2 of stripe.billing.meters.list({
|
|
350
|
+
status: "active"
|
|
351
|
+
})) {
|
|
352
|
+
if ((meter2 == null ? void 0 : meter2.event_name) === usage) {
|
|
353
|
+
return {
|
|
354
|
+
meter: meter2.id,
|
|
355
|
+
usage
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
;
|
|
359
|
+
}
|
|
360
|
+
;
|
|
337
361
|
const meter = await stripe.billing.meters.create(
|
|
338
362
|
{
|
|
339
363
|
default_aggregation: {
|
|
@@ -405,6 +429,7 @@ var require_subscription = __commonJS({
|
|
|
405
429
|
idempotencyKey,
|
|
406
430
|
interval,
|
|
407
431
|
limit,
|
|
432
|
+
meter: existing,
|
|
408
433
|
metadata,
|
|
409
434
|
name,
|
|
410
435
|
overage,
|
|
@@ -414,6 +439,7 @@ var require_subscription = __commonJS({
|
|
|
414
439
|
const response = {};
|
|
415
440
|
const { meter, usage } = await createMeter({
|
|
416
441
|
idempotencyKey,
|
|
442
|
+
meter: existing,
|
|
417
443
|
metadata,
|
|
418
444
|
name
|
|
419
445
|
});
|
|
@@ -596,6 +622,7 @@ var require_subscription = __commonJS({
|
|
|
596
622
|
customer,
|
|
597
623
|
discounts = [],
|
|
598
624
|
idempotencyKey,
|
|
625
|
+
meter,
|
|
599
626
|
metadata,
|
|
600
627
|
stripePaymentMethodId,
|
|
601
628
|
to
|
|
@@ -607,6 +634,7 @@ var require_subscription = __commonJS({
|
|
|
607
634
|
idempotencyKey,
|
|
608
635
|
interval: to.interval,
|
|
609
636
|
limit: to.limits.organization.actions,
|
|
637
|
+
meter,
|
|
610
638
|
metadata,
|
|
611
639
|
name: "actions",
|
|
612
640
|
overage: to.overages.actions,
|
package/package.json
CHANGED