@drawbridge/drawbridge-stripe 0.1.10 → 0.1.12
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 +45 -0
- package/dist/index.mjs +45 -0
- 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/x-www-form-urlencoded",
|
|
288
|
+
"Stripe-Version": "2026-03-25.preview"
|
|
289
|
+
}
|
|
290
|
+
};
|
|
282
291
|
const createMeter = async ({
|
|
283
292
|
metadata,
|
|
284
293
|
name
|
|
@@ -578,6 +587,42 @@ var require_subscription = __commonJS({
|
|
|
578
587
|
throw error;
|
|
579
588
|
}
|
|
580
589
|
},
|
|
590
|
+
pause: async ({
|
|
591
|
+
stripeSubscriptionId
|
|
592
|
+
}) => {
|
|
593
|
+
try {
|
|
594
|
+
const body = new URLSearchParams();
|
|
595
|
+
body.append("type", "subscription");
|
|
596
|
+
body.append("bill_for[unused_time_from][type]", "now");
|
|
597
|
+
body.append("bill_for[outstanding_usage_through][type]", "now");
|
|
598
|
+
body.append("invoicing_behavior", "pending_invoice_item");
|
|
599
|
+
const { data } = await axios.post(
|
|
600
|
+
subscriptions + "/" + stripeSubscriptionId + "/pause",
|
|
601
|
+
body,
|
|
602
|
+
options
|
|
603
|
+
);
|
|
604
|
+
return data;
|
|
605
|
+
} catch (error) {
|
|
606
|
+
throw error;
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
resume: async ({
|
|
610
|
+
stripeSubscriptionId
|
|
611
|
+
}) => {
|
|
612
|
+
try {
|
|
613
|
+
const body = new URLSearchParams();
|
|
614
|
+
body.append("billing_cycle_anchor", "unchanged");
|
|
615
|
+
body.append("proration_behavior", "create_prorations");
|
|
616
|
+
const { data } = await axios.post(
|
|
617
|
+
subscriptions + "/" + stripeSubscriptionId + "/resume",
|
|
618
|
+
body,
|
|
619
|
+
options
|
|
620
|
+
);
|
|
621
|
+
return data;
|
|
622
|
+
} catch (error) {
|
|
623
|
+
throw error;
|
|
624
|
+
}
|
|
625
|
+
},
|
|
581
626
|
update: async ({
|
|
582
627
|
current,
|
|
583
628
|
direction,
|
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/x-www-form-urlencoded",
|
|
294
|
+
"Stripe-Version": "2026-03-25.preview"
|
|
295
|
+
}
|
|
296
|
+
};
|
|
288
297
|
const createMeter = async ({
|
|
289
298
|
metadata,
|
|
290
299
|
name
|
|
@@ -584,6 +593,42 @@ var require_subscription = __commonJS({
|
|
|
584
593
|
throw error;
|
|
585
594
|
}
|
|
586
595
|
},
|
|
596
|
+
pause: async ({
|
|
597
|
+
stripeSubscriptionId
|
|
598
|
+
}) => {
|
|
599
|
+
try {
|
|
600
|
+
const body = new URLSearchParams();
|
|
601
|
+
body.append("type", "subscription");
|
|
602
|
+
body.append("bill_for[unused_time_from][type]", "now");
|
|
603
|
+
body.append("bill_for[outstanding_usage_through][type]", "now");
|
|
604
|
+
body.append("invoicing_behavior", "pending_invoice_item");
|
|
605
|
+
const { data } = await axios.post(
|
|
606
|
+
subscriptions + "/" + stripeSubscriptionId + "/pause",
|
|
607
|
+
body,
|
|
608
|
+
options
|
|
609
|
+
);
|
|
610
|
+
return data;
|
|
611
|
+
} catch (error) {
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
resume: async ({
|
|
616
|
+
stripeSubscriptionId
|
|
617
|
+
}) => {
|
|
618
|
+
try {
|
|
619
|
+
const body = new URLSearchParams();
|
|
620
|
+
body.append("billing_cycle_anchor", "unchanged");
|
|
621
|
+
body.append("proration_behavior", "create_prorations");
|
|
622
|
+
const { data } = await axios.post(
|
|
623
|
+
subscriptions + "/" + stripeSubscriptionId + "/resume",
|
|
624
|
+
body,
|
|
625
|
+
options
|
|
626
|
+
);
|
|
627
|
+
return data;
|
|
628
|
+
} catch (error) {
|
|
629
|
+
throw error;
|
|
630
|
+
}
|
|
631
|
+
},
|
|
587
632
|
update: async ({
|
|
588
633
|
current,
|
|
589
634
|
direction,
|
package/package.json
CHANGED