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

@stripe/stripe-js

Package Overview
Dependencies
Maintainers
19
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stripe/stripe-js

Stripe.js loading utility

  • 5.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9M
decreased by-2.94%
Maintainers
19
Weekly downloads
 
Created

What is @stripe/stripe-js?

The @stripe/stripe-js package is a JavaScript library that allows developers to integrate Stripe's payment processing capabilities into their web applications. It provides a set of tools to create and manage payment elements, handle payment intents, and securely collect payment information.

What are @stripe/stripe-js's main functionalities?

Loading Stripe.js

This code sample demonstrates how to asynchronously load the Stripe.js library using the provided publishable key. The `loadStripe` function returns a Promise that resolves with the Stripe object.

import { loadStripe } from '@stripe/stripe-js';

const stripePromise = loadStripe('pk_test_TYooMQauvdEDq54NiTphI7jx');

Creating a Payment Element

This code sample shows how to use the `Elements` provider to inject the Stripe object into the React component tree and create a `CardElement` that collects the user's card details.

import { Elements } from '@stripe/react-stripe-js';
import { CardElement } from '@stripe/react-stripe-js';

const stripePromise = loadStripe('pk_test_TYooMQauvdEDq54NiTphI7jx');

const CheckoutForm = () => {
  return (
    <Elements stripe={stripePromise}>
      <CardElement />
    </Elements>
  );
};

Handling Payment Intents

This code sample illustrates how to confirm a card payment using a PaymentIntent's client secret. It uses the `confirmCardPayment` method to handle the payment process.

const stripe = await loadStripe('pk_test_TYooMQauvdEDq54NiTphI7jx');

const {error, paymentIntent} = await stripe.confirmCardPayment('{CLIENT_SECRET}', {
  payment_method: {
    card: cardElement,
    billing_details: {
      name: 'Jenny Rosen'
    }
  }
});

Other packages similar to @stripe/stripe-js

Keywords

FAQs

Package last updated on 19 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