@drawbridge/drawbridge-stripe 0.1.8 → 0.1.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/index.js CHANGED
@@ -404,6 +404,8 @@ var require_subscription = __commonJS({
404
404
  return ((_b2 = (_a2 = item == null ? void 0 : item.price) == null ? void 0 : _a2.recurring) == null ? void 0 : _b2.usage_type) === "metered";
405
405
  }
406
406
  );
407
+ const currentPeriodStart = currentPlanItem == null ? void 0 : currentPlanItem.current_period_start;
408
+ const currentPeriodEnd = currentPlanItem == null ? void 0 : currentPlanItem.current_period_end;
407
409
  const phases = [
408
410
  {
409
411
  items: [
@@ -415,8 +417,8 @@ var require_subscription = __commonJS({
415
417
  price: (_b = currentActionsItem == null ? void 0 : currentActionsItem.price) == null ? void 0 : _b.id
416
418
  }
417
419
  ],
418
- start_date: live.current_period_start,
419
- end_date: live.current_period_end,
420
+ start_date: currentPeriodStart,
421
+ end_date: currentPeriodEnd,
420
422
  proration_behavior: "none"
421
423
  },
422
424
  {
@@ -447,7 +449,7 @@ var require_subscription = __commonJS({
447
449
  items,
448
450
  pending: {
449
451
  scheduleId: schedule.id,
450
- effectiveAt: new Date(live.current_period_end * 1e3)
452
+ effectiveAt: new Date(currentPeriodEnd * 1e3)
451
453
  }
452
454
  };
453
455
  }
@@ -610,6 +612,14 @@ var require_subscription = __commonJS({
610
612
  }
611
613
  ;
612
614
  const product = await stripe2.prices.retrieve(to == null ? void 0 : to.stripePriceId);
615
+ const livePlanItem = live.items.data.find(
616
+ (item) => {
617
+ var _a2, _b2;
618
+ return ((_b2 = (_a2 = item == null ? void 0 : item.price) == null ? void 0 : _a2.recurring) == null ? void 0 : _b2.usage_type) !== "metered";
619
+ }
620
+ );
621
+ const currentPeriodStart = livePlanItem == null ? void 0 : livePlanItem.current_period_start;
622
+ const currentPeriodEnd = livePlanItem == null ? void 0 : livePlanItem.current_period_end;
613
623
  const phases = [
614
624
  {
615
625
  items: [
@@ -621,8 +631,8 @@ var require_subscription = __commonJS({
621
631
  price: (_f = (_e = current == null ? void 0 : current.items) == null ? void 0 : _e.actions) == null ? void 0 : _f.price
622
632
  }
623
633
  ],
624
- start_date: live.current_period_start,
625
- end_date: live.current_period_end,
634
+ start_date: currentPeriodStart,
635
+ end_date: currentPeriodEnd,
626
636
  proration_behavior: "none"
627
637
  },
628
638
  {
@@ -659,7 +669,7 @@ var require_subscription = __commonJS({
659
669
  },
660
670
  pending: {
661
671
  scheduleId: schedule.id,
662
- effectiveAt: new Date(live.current_period_end * 1e3)
672
+ effectiveAt: new Date(currentPeriodEnd * 1e3)
663
673
  }
664
674
  };
665
675
  }
package/dist/index.mjs CHANGED
@@ -410,6 +410,8 @@ var require_subscription = __commonJS({
410
410
  return ((_b2 = (_a2 = item == null ? void 0 : item.price) == null ? void 0 : _a2.recurring) == null ? void 0 : _b2.usage_type) === "metered";
411
411
  }
412
412
  );
413
+ const currentPeriodStart = currentPlanItem == null ? void 0 : currentPlanItem.current_period_start;
414
+ const currentPeriodEnd = currentPlanItem == null ? void 0 : currentPlanItem.current_period_end;
413
415
  const phases = [
414
416
  {
415
417
  items: [
@@ -421,8 +423,8 @@ var require_subscription = __commonJS({
421
423
  price: (_b = currentActionsItem == null ? void 0 : currentActionsItem.price) == null ? void 0 : _b.id
422
424
  }
423
425
  ],
424
- start_date: live.current_period_start,
425
- end_date: live.current_period_end,
426
+ start_date: currentPeriodStart,
427
+ end_date: currentPeriodEnd,
426
428
  proration_behavior: "none"
427
429
  },
428
430
  {
@@ -453,7 +455,7 @@ var require_subscription = __commonJS({
453
455
  items,
454
456
  pending: {
455
457
  scheduleId: schedule.id,
456
- effectiveAt: new Date(live.current_period_end * 1e3)
458
+ effectiveAt: new Date(currentPeriodEnd * 1e3)
457
459
  }
458
460
  };
459
461
  }
@@ -616,6 +618,14 @@ var require_subscription = __commonJS({
616
618
  }
617
619
  ;
618
620
  const product = await stripe.prices.retrieve(to == null ? void 0 : to.stripePriceId);
621
+ const livePlanItem = live.items.data.find(
622
+ (item) => {
623
+ var _a2, _b2;
624
+ return ((_b2 = (_a2 = item == null ? void 0 : item.price) == null ? void 0 : _a2.recurring) == null ? void 0 : _b2.usage_type) !== "metered";
625
+ }
626
+ );
627
+ const currentPeriodStart = livePlanItem == null ? void 0 : livePlanItem.current_period_start;
628
+ const currentPeriodEnd = livePlanItem == null ? void 0 : livePlanItem.current_period_end;
619
629
  const phases = [
620
630
  {
621
631
  items: [
@@ -627,8 +637,8 @@ var require_subscription = __commonJS({
627
637
  price: (_f = (_e = current == null ? void 0 : current.items) == null ? void 0 : _e.actions) == null ? void 0 : _f.price
628
638
  }
629
639
  ],
630
- start_date: live.current_period_start,
631
- end_date: live.current_period_end,
640
+ start_date: currentPeriodStart,
641
+ end_date: currentPeriodEnd,
632
642
  proration_behavior: "none"
633
643
  },
634
644
  {
@@ -665,7 +675,7 @@ var require_subscription = __commonJS({
665
675
  },
666
676
  pending: {
667
677
  scheduleId: schedule.id,
668
- effectiveAt: new Date(live.current_period_end * 1e3)
678
+ effectiveAt: new Date(currentPeriodEnd * 1e3)
669
679
  }
670
680
  };
671
681
  }
package/package.json CHANGED
@@ -24,5 +24,5 @@
24
24
  "build": "tsup ./index.js && npm publish"
25
25
  },
26
26
  "types": "dist/index.d.ts",
27
- "version": "0.1.8"
27
+ "version": "0.1.9"
28
28
  }