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.23 to 1.1.24

26

dist/webhooks/handleCheckoutSessionCompleted.js

@@ -24,16 +24,16 @@ "use strict";

const setupIntent = await stripe_1.stripe.setupIntents.retrieve(checkoutSession.setup_intent);
if (setupIntent.payment_method) {
// Assuming payment_method is either a string or a PaymentMethod object,
// we check its type and handle accordingly.
const paymentMethodId = typeof setupIntent.payment_method === 'string'
? setupIntent.payment_method
: setupIntent.payment_method.id;
// Set the payment method as the default for the customer
await stripe_1.stripe.customers.update(checkoutSession.customer, {
invoice_settings: {
default_payment_method: paymentMethodId,
},
});
await manageCustomerDetailsChange(checkoutSession.customer, paymentMethodId, client_reference_id);
// Ensure the customer ID and payment method are valid
if (!checkoutSession.customer || typeof checkoutSession.customer !== 'string') {
throw new Error('Invalid customer ID');
}
if (!setupIntent.payment_method || typeof setupIntent.payment_method !== 'string') {
throw new Error('Invalid payment method ID');
}
// Set the payment method as the default for the customer
await stripe_1.stripe.customers.update(checkoutSession.customer, {
invoice_settings: {
default_payment_method: setupIntent.payment_method,
},
});
await manageCustomerDetailsChange(checkoutSession.customer, setupIntent.payment_method, client_reference_id);
}

@@ -40,0 +40,0 @@ catch (error) {

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

@@ -41,22 +41,24 @@ import Stripe from 'stripe';

);
if (setupIntent.payment_method) {
// Assuming payment_method is either a string or a PaymentMethod object,
// we check its type and handle accordingly.
const paymentMethodId = typeof setupIntent.payment_method === 'string'
? setupIntent.payment_method
: setupIntent.payment_method.id;
// Set the payment method as the default for the customer
await stripe.customers.update(checkoutSession.customer as string, {
invoice_settings: {
default_payment_method: paymentMethodId,
},
});
await manageCustomerDetailsChange(
checkoutSession.customer as string,
paymentMethodId,
client_reference_id
);
// Ensure the customer ID and payment method are valid
if (!checkoutSession.customer || typeof checkoutSession.customer !== 'string') {
throw new Error('Invalid customer ID');
}
if (!setupIntent.payment_method || typeof setupIntent.payment_method !== 'string') {
throw new Error('Invalid payment method ID');
}
// Set the payment method as the default for the customer
await stripe.customers.update(checkoutSession.customer, {
invoice_settings: {
default_payment_method: setupIntent.payment_method,
},
});
await manageCustomerDetailsChange(
checkoutSession.customer,
setupIntent.payment_method,
client_reference_id
);
} catch (error) {

@@ -66,3 +68,4 @@ console.error("Failed to update customer's default payment method:", error);

}
}
}

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