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.35 to 1.1.36

19

dist/subscriptions/index.js

@@ -212,12 +212,14 @@ "use strict";

if (subscriptionItem) {
// If the subscription item exists, update its quantity
// Ensure the quantities are treated as numbers
const currentQuantity = Number(subscriptionItem.quantity);
const newQuantity = currentQuantity + additionalQuantity;
// Update the quantity of the subscription item
const updatedSubscriptionItem = await stripe_1.stripe.subscriptionItems.update(subscriptionItem.id, {
quantity: (subscriptionItem.quantity || 0) + additionalQuantity,
proration_behavior,
quantity: newQuantity,
proration_behavior
});
console.log('Subscription item updated:', updatedSubscriptionItem.id);
return updatedSubscriptionItem;
}
else {
// If the subscription item doesn't exist, create a new subscription item
// Create a new subscription item if it doesn't exist
const newSubscriptionItem = await stripe_1.stripe.subscriptionItems.create({

@@ -229,3 +231,2 @@ subscription: subscriptionId,

});
console.log('Subscription item created:', newSubscriptionItem.id);
return newSubscriptionItem;

@@ -248,4 +249,5 @@ }

}
const currentQuantity = Number(subscriptionItem.quantity);
// Calculate the new quantity
const newQuantity = Math.max(subscriptionItem.quantity - removeQuantity, 0);
const newQuantity = Math.max(currentQuantity - removeQuantity, 0);
if (newQuantity === 0) {

@@ -286,4 +288,5 @@ // If the new quantity is 0, delete the subscription item

}
const currentQuantity = Number(subscriptionItem.quantity);
// Calculate the new quantity
const newQuantity = Math.max(subscriptionItem.quantity - removeQuantity, 0);
const newQuantity = Math.max(currentQuantity - removeQuantity, 0);
if (newQuantity === 0) {

@@ -290,0 +293,0 @@ // If the new quantity is 0, delete the subscription item

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

@@ -363,3 +363,3 @@ # next-stripe-helper

- `priceId` (required): The Stripe Price ID of the item.
- `quantity` (optional): The quantity of the item you are adding. Defaults to 1. Will add to existing quantity.
- `quantity` (optional): The quantity of the item you are adding. Defaults to 1. Will add to existing quantity or add the item to the subsdcription if it doesnt exist.
- `proration_behavior` (optional): Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resetting billing_cycle_anchor=now, or starting a trial), or if an item’s quantity changes. The default value is always_invoice. ('create_prorations', 'none', 'always_invoice')

@@ -366,0 +366,0 @@

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