New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

next-stripe-helper

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-stripe-helper - npm Package Compare versions

Comparing version 1.1.41 to 1.1.42

45

dist/subscriptions/index.js

@@ -333,20 +333,35 @@ "use strict";

const subscriptionItem = subscription.items.data.find(item => item.price.id === priceId);
if (!subscriptionItem) {
throw new Error('Subscription item not found for the specified price');
}
newQuantity = Number(newQuantity);
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;
if (subscriptionItem) {
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;
}
}
else {
// 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) {
// Create a new subscription item if it doesn't exist and the new quantity is greater than 0
const newSubscriptionItem = await stripe_1.stripe.subscriptionItems.create({
subscription: subscriptionID,
price: priceId,
quantity: newQuantity,
proration_behavior
});
return newSubscriptionItem;
}
else {
// No action needed if the new quantity is 0 and the item doesn't exist on the subscription
return null;
}
}

@@ -353,0 +368,0 @@ }

{
"name": "next-stripe-helper",
"version": "1.1.41",
"version": "1.1.42",
"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",

@@ -390,2 +390,6 @@ # next-stripe-helper

This function will ADD an item to a subscription, or UPDATE the quantity if an item is already present on the subscription.
If the quantity is 0, the item will be DELETED from the subscription.
This will use the current payment method by default.

@@ -392,0 +396,0 @@ Customer must have an existing subscription.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc