@drawbridge/drawbridge-stripe 0.1.9 → 0.1.11
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 +79 -14
- package/dist/index.mjs +79 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -276,9 +276,18 @@ var require_billing = __commonJS({
|
|
|
276
276
|
// lib/subscription.js
|
|
277
277
|
var require_subscription = __commonJS({
|
|
278
278
|
"lib/subscription.js"(exports2, module2) {
|
|
279
|
+
var axios = require("axios");
|
|
280
|
+
var subscriptions = "https://api.stripe.com/v1/subscriptions";
|
|
279
281
|
module2.exports = ({
|
|
280
282
|
stripe: stripe2
|
|
281
283
|
}) => {
|
|
284
|
+
const options = {
|
|
285
|
+
headers: {
|
|
286
|
+
"Authorization": "Bearer " + process.env.STRIPE_API_KEY,
|
|
287
|
+
"Content-Type": "application/json",
|
|
288
|
+
"Stripe-Version": "2026-01-28.preview"
|
|
289
|
+
}
|
|
290
|
+
};
|
|
282
291
|
const createMeter = async ({
|
|
283
292
|
metadata,
|
|
284
293
|
name
|
|
@@ -438,13 +447,20 @@ var require_subscription = __commonJS({
|
|
|
438
447
|
const schedule = await stripe2.subscriptionSchedules.create({
|
|
439
448
|
from_subscription: stripeSubscriptionId
|
|
440
449
|
});
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
450
|
+
try {
|
|
451
|
+
await stripe2.subscriptionSchedules.update(
|
|
452
|
+
schedule.id,
|
|
453
|
+
{
|
|
454
|
+
end_behavior: "release",
|
|
455
|
+
phases
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
} catch (error) {
|
|
459
|
+
await stripe2.subscriptionSchedules.release(schedule.id).catch(() => {
|
|
460
|
+
});
|
|
461
|
+
throw error;
|
|
462
|
+
}
|
|
463
|
+
;
|
|
448
464
|
return {
|
|
449
465
|
items,
|
|
450
466
|
pending: {
|
|
@@ -571,6 +587,48 @@ var require_subscription = __commonJS({
|
|
|
571
587
|
throw error;
|
|
572
588
|
}
|
|
573
589
|
},
|
|
590
|
+
pause: async ({
|
|
591
|
+
stripeSubscriptionId
|
|
592
|
+
}) => {
|
|
593
|
+
try {
|
|
594
|
+
const { data } = await axios.post(
|
|
595
|
+
subscriptions + "/" + stripeSubscriptionId + "/pause",
|
|
596
|
+
{
|
|
597
|
+
type: "subscription",
|
|
598
|
+
bill_for: {
|
|
599
|
+
unused_time_from: {
|
|
600
|
+
type: "now"
|
|
601
|
+
},
|
|
602
|
+
outstanding_usage_through: {
|
|
603
|
+
type: "now"
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
invoicing_behavior: "pending_invoice_item"
|
|
607
|
+
},
|
|
608
|
+
options
|
|
609
|
+
);
|
|
610
|
+
return data;
|
|
611
|
+
} catch (error) {
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
resume: async ({
|
|
616
|
+
stripeSubscriptionId
|
|
617
|
+
}) => {
|
|
618
|
+
try {
|
|
619
|
+
const { data } = await axios.post(
|
|
620
|
+
subscriptions + "/" + stripeSubscriptionId + "/resume",
|
|
621
|
+
{
|
|
622
|
+
billing_cycle_anchor: "unchanged",
|
|
623
|
+
proration_behavior: "create_prorations"
|
|
624
|
+
},
|
|
625
|
+
options
|
|
626
|
+
);
|
|
627
|
+
return data;
|
|
628
|
+
} catch (error) {
|
|
629
|
+
throw error;
|
|
630
|
+
}
|
|
631
|
+
},
|
|
574
632
|
update: async ({
|
|
575
633
|
current,
|
|
576
634
|
direction,
|
|
@@ -652,13 +710,20 @@ var require_subscription = __commonJS({
|
|
|
652
710
|
const schedule = await stripe2.subscriptionSchedules.create({
|
|
653
711
|
from_subscription: stripeSubscriptionId
|
|
654
712
|
});
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
713
|
+
try {
|
|
714
|
+
await stripe2.subscriptionSchedules.update(
|
|
715
|
+
schedule.id,
|
|
716
|
+
{
|
|
717
|
+
end_behavior: "release",
|
|
718
|
+
phases
|
|
719
|
+
}
|
|
720
|
+
);
|
|
721
|
+
} catch (error) {
|
|
722
|
+
await stripe2.subscriptionSchedules.release(schedule.id).catch(() => {
|
|
723
|
+
});
|
|
724
|
+
throw error;
|
|
725
|
+
}
|
|
726
|
+
;
|
|
662
727
|
return {
|
|
663
728
|
items: {
|
|
664
729
|
plan: {
|
package/dist/index.mjs
CHANGED
|
@@ -282,9 +282,18 @@ var require_billing = __commonJS({
|
|
|
282
282
|
// lib/subscription.js
|
|
283
283
|
var require_subscription = __commonJS({
|
|
284
284
|
"lib/subscription.js"(exports, module) {
|
|
285
|
+
var axios = __require("axios");
|
|
286
|
+
var subscriptions = "https://api.stripe.com/v1/subscriptions";
|
|
285
287
|
module.exports = ({
|
|
286
288
|
stripe
|
|
287
289
|
}) => {
|
|
290
|
+
const options = {
|
|
291
|
+
headers: {
|
|
292
|
+
"Authorization": "Bearer " + process.env.STRIPE_API_KEY,
|
|
293
|
+
"Content-Type": "application/json",
|
|
294
|
+
"Stripe-Version": "2026-01-28.preview"
|
|
295
|
+
}
|
|
296
|
+
};
|
|
288
297
|
const createMeter = async ({
|
|
289
298
|
metadata,
|
|
290
299
|
name
|
|
@@ -444,13 +453,20 @@ var require_subscription = __commonJS({
|
|
|
444
453
|
const schedule = await stripe.subscriptionSchedules.create({
|
|
445
454
|
from_subscription: stripeSubscriptionId
|
|
446
455
|
});
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
456
|
+
try {
|
|
457
|
+
await stripe.subscriptionSchedules.update(
|
|
458
|
+
schedule.id,
|
|
459
|
+
{
|
|
460
|
+
end_behavior: "release",
|
|
461
|
+
phases
|
|
462
|
+
}
|
|
463
|
+
);
|
|
464
|
+
} catch (error) {
|
|
465
|
+
await stripe.subscriptionSchedules.release(schedule.id).catch(() => {
|
|
466
|
+
});
|
|
467
|
+
throw error;
|
|
468
|
+
}
|
|
469
|
+
;
|
|
454
470
|
return {
|
|
455
471
|
items,
|
|
456
472
|
pending: {
|
|
@@ -577,6 +593,48 @@ var require_subscription = __commonJS({
|
|
|
577
593
|
throw error;
|
|
578
594
|
}
|
|
579
595
|
},
|
|
596
|
+
pause: async ({
|
|
597
|
+
stripeSubscriptionId
|
|
598
|
+
}) => {
|
|
599
|
+
try {
|
|
600
|
+
const { data } = await axios.post(
|
|
601
|
+
subscriptions + "/" + stripeSubscriptionId + "/pause",
|
|
602
|
+
{
|
|
603
|
+
type: "subscription",
|
|
604
|
+
bill_for: {
|
|
605
|
+
unused_time_from: {
|
|
606
|
+
type: "now"
|
|
607
|
+
},
|
|
608
|
+
outstanding_usage_through: {
|
|
609
|
+
type: "now"
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
invoicing_behavior: "pending_invoice_item"
|
|
613
|
+
},
|
|
614
|
+
options
|
|
615
|
+
);
|
|
616
|
+
return data;
|
|
617
|
+
} catch (error) {
|
|
618
|
+
throw error;
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
resume: async ({
|
|
622
|
+
stripeSubscriptionId
|
|
623
|
+
}) => {
|
|
624
|
+
try {
|
|
625
|
+
const { data } = await axios.post(
|
|
626
|
+
subscriptions + "/" + stripeSubscriptionId + "/resume",
|
|
627
|
+
{
|
|
628
|
+
billing_cycle_anchor: "unchanged",
|
|
629
|
+
proration_behavior: "create_prorations"
|
|
630
|
+
},
|
|
631
|
+
options
|
|
632
|
+
);
|
|
633
|
+
return data;
|
|
634
|
+
} catch (error) {
|
|
635
|
+
throw error;
|
|
636
|
+
}
|
|
637
|
+
},
|
|
580
638
|
update: async ({
|
|
581
639
|
current,
|
|
582
640
|
direction,
|
|
@@ -658,13 +716,20 @@ var require_subscription = __commonJS({
|
|
|
658
716
|
const schedule = await stripe.subscriptionSchedules.create({
|
|
659
717
|
from_subscription: stripeSubscriptionId
|
|
660
718
|
});
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
719
|
+
try {
|
|
720
|
+
await stripe.subscriptionSchedules.update(
|
|
721
|
+
schedule.id,
|
|
722
|
+
{
|
|
723
|
+
end_behavior: "release",
|
|
724
|
+
phases
|
|
725
|
+
}
|
|
726
|
+
);
|
|
727
|
+
} catch (error) {
|
|
728
|
+
await stripe.subscriptionSchedules.release(schedule.id).catch(() => {
|
|
729
|
+
});
|
|
730
|
+
throw error;
|
|
731
|
+
}
|
|
732
|
+
;
|
|
668
733
|
return {
|
|
669
734
|
items: {
|
|
670
735
|
plan: {
|
package/package.json
CHANGED