Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stripe

Package Overview
Dependencies
Maintainers
1
Versions
663
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stripe

Stripe API wrapper

  • 17.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4M
increased by4.74%
Maintainers
1
Weekly downloads
 
Created

What is stripe?

The Stripe npm package is a library that provides a powerful and easy-to-use interface to the Stripe API, allowing developers to integrate payment processing into their Node.js applications. It supports a wide range of payment operations, from charging credit cards to managing subscriptions and handling disputes.

What are stripe's main functionalities?

Charging a Credit Card

This feature allows you to create a charge on a credit card. The amount is specified in the smallest currency unit (e.g., cents for USD).

stripe.charges.create({
  amount: 2000,
  currency: 'usd',
  source: 'tok_amex',
  description: 'Charge for jenny.rosen@example.com'
}).then(function(charge) {
  // asynchronously called
});

Creating a Customer

This feature enables you to create a new customer object, which can be used for recurring charges and tracking multiple charges that are associated with the same customer.

stripe.customers.create({
  email: 'customer@example.com'
}).then(function(customer) {
  // asynchronously called
});

Managing Subscriptions

This feature allows you to create and manage subscriptions for recurring payments. You can specify the plan and customer to associate with the subscription.

stripe.subscriptions.create({
  customer: 'cus_4fdAW5ftNQow1a',
  items: [{
    plan: 'plan_CBXbz9i7AIOTzr'
  }]
}).then(function(subscription) {
  // asynchronously called
});

Handling Webhooks

This feature is for setting up a webhook endpoint to listen for events from Stripe. This is useful for receiving notifications about various events, such as successful payments or subscription cancellations.

const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.post('/webhook', bodyParser.raw({type: 'application/json'}), (request, response) => {
  let event;
  try {
    event = JSON.parse(request.body);
  } catch (err) {
    response.status(400).send(`Webhook Error: ${err.message}`);
    return;
  }
  // Handle the event
  switch (event.type) {
    case 'payment_intent.succeeded':
      const paymentIntent = event.data.object;
      console.log(`PaymentIntent was successful!`);
      break;
    // ... handle other event types
    default:
      console.log(`Unhandled event type ${event.type}`);
  }
  response.status(200).end();
});
app.listen(8000, () => {
  console.log('Running on port 8000');
});

Other packages similar to stripe

Keywords

FAQs

Package last updated on 20 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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