next-stripe-helper
Advanced tools
Comparing version 1.1.40 to 1.1.41
@@ -337,8 +337,17 @@ "use strict"; | ||
newQuantity = Number(newQuantity); | ||
// Update the quantity of the subscription item | ||
const updatedSubscriptionItem = await stripe_1.stripe.subscriptionItems.update(subscriptionItem.id, { | ||
quantity: newQuantity, | ||
proration_behavior | ||
}); | ||
return updatedSubscriptionItem; | ||
if (newQuantity === 0) { | ||
// Delete the subscription item if the new quantity is 0 | ||
await stripe_1.stripe.subscriptionItems.del(subscriptionItem.id, { | ||
proration_behavior | ||
}); | ||
return null; | ||
} | ||
else { | ||
// Update the quantity of the subscription item | ||
const updatedSubscriptionItem = await stripe_1.stripe.subscriptionItems.update(subscriptionItem.id, { | ||
quantity: newQuantity, | ||
proration_behavior | ||
}); | ||
return updatedSubscriptionItem; | ||
} | ||
} | ||
@@ -345,0 +354,0 @@ catch (error) { |
{ | ||
"name": "next-stripe-helper", | ||
"version": "1.1.40", | ||
"version": "1.1.41", | ||
"description": "Easily add Stripe boilerplate code to Nextjs, like webhook handling, and subscription updates. This package provides a thin wrapper around the Stripe API, and makes integrating Stripe and NextJS a lot faster!", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -259,2 +259,3 @@ # next-stripe-helper | ||
updateItemQuantity, | ||
updateItemQuantityByPriceId, | ||
removeItemsFromSubscription, | ||
@@ -261,0 +262,0 @@ removeItemsByPriceId, |
Sorry, the diff of this file is not supported yet
107119
1161
984