@stripe/stripe-js vs @paypal/react-paypal-js vs @paypal/checkout-server-sdk vs react-payment-inputs
Payment Processing Libraries
@stripe/stripe-js@paypal/react-paypal-js@paypal/checkout-server-sdkreact-payment-inputs
Payment Processing Libraries

Payment processing libraries in web development provide tools and APIs for integrating payment gateways into applications. They facilitate secure transactions, handle payment methods, and ensure compliance with financial regulations. These libraries simplify the process of accepting payments online, whether through credit cards, digital wallets, or other methods. @paypal/checkout-server-sdk is a server-side SDK for integrating PayPal's payment processing, while @paypal/react-paypal-js is a React library for embedding PayPal buttons and handling client-side payments. @stripe/stripe-js is Stripe's official JavaScript library for handling payments, and react-payment-inputs is a React component library for creating customizable payment input fields.

Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
@stripe/stripe-js3,345,891726944 kB710 days agoMIT
@paypal/react-paypal-js202,643308541 kB182 months agoApache-2.0
@paypal/checkout-server-sdk52,262---4 years agoSEE LICENSE IN https://github.com/paypal/Checkout-NodeJS-SDK/blob/master/LICENSE
react-payment-inputs22,224-267 kB-a year agoMIT
Feature Comparison: @stripe/stripe-js vs @paypal/react-paypal-js vs @paypal/checkout-server-sdk vs react-payment-inputs

Integration Type

  • @stripe/stripe-js:

    Client-side library for handling payments, including tokenization of payment information and integration with Stripe's API.

  • @paypal/react-paypal-js:

    Client-side integration for embedding PayPal buttons in React applications, allowing users to complete payments directly on the frontend.

  • @paypal/checkout-server-sdk:

    Server-side integration for processing payments, managing orders, and handling transactions securely.

  • react-payment-inputs:

    Client-side React components for creating customizable payment input fields, such as credit card number, expiration date, and CVV.

Payment Methods

  • @stripe/stripe-js:

    Supports a wide range of payment methods, including credit/debit cards, Apple Pay, Google Pay, and other digital wallets.

  • @paypal/react-paypal-js:

    Supports PayPal payments through embedded buttons, including PayPal Wallet, credit/debit cards, and other funding sources.

  • @paypal/checkout-server-sdk:

    Supports PayPal payments, including PayPal Wallet, credit/debit cards, and other funding sources available through PayPal.

  • react-payment-inputs:

    Focuses on collecting payment information but does not handle payment processing. It can be used with any payment gateway.

Customization

  • @stripe/stripe-js:

    Provides flexibility in designing payment forms and integrating various payment methods, but the actual customization is done on the frontend.

  • @paypal/react-paypal-js:

    Allows customization of PayPal buttons, including style, color, size, and layout, to match the application's design.

  • @paypal/checkout-server-sdk:

    Limited customization as it is a backend SDK, but allows for full control over the payment flow and order management.

  • react-payment-inputs:

    Highly customizable input fields with support for custom styles, validation, and formatting. It allows developers to create a tailored user experience.

Security

  • @stripe/stripe-js:

    Implements PCI compliance by tokenizing payment information on the client side, ensuring sensitive data never touches your servers.

  • @paypal/react-paypal-js:

    Leverages PayPal's secure payment infrastructure, with sensitive data handled by PayPal's servers.

  • @paypal/checkout-server-sdk:

    Handles security on the server side, including fraud detection, PCI compliance, and secure transaction processing.

  • react-payment-inputs:

    Focuses on secure data entry but does not handle payment processing. Security depends on the integration with a payment gateway.

Ease of Use: Code Examples

  • @stripe/stripe-js:

    Stripe payment integration example

    import { loadStripe } from '@stripe/stripe-js';
    const stripePromise = loadStripe('YOUR_PUBLISHABLE_KEY');
    
    async function handlePayment() {
      const stripe = await stripePromise;
      const { error } = await stripe.redirectToCheckout({
        lineItems: [{ price: 'PRICE_ID', quantity: 1 }],
        mode: 'payment',
        successUrl: 'https://your-site.com/success',
        cancelUrl: 'https://your-site.com/cancel',
      });
      if (error) {
        console.error('Error:', error);
      }
    }
    
  • @paypal/react-paypal-js:

    React PayPal button integration example

    import { PayPalButtons, PayPalScriptProvider } from '@paypal/react-paypal-js';
    
    function PayPalCheckout() {
      return (
        <PayPalScriptProvider options={{ 'client-id': 'YOUR_CLIENT_ID' }}>
          <PayPalButtons
            createOrder={(data, actions) => {
              return actions.order.create({
                purchase_units: [{ amount: { value: '100.00' } }],
              });
            }}
            onApprove={(data, actions) => {
              return actions.order.capture().then((details) => {
                alert('Transaction completed by ' + details.payer.name.given_name);
              });
            }}
          />
        </PayPalScriptProvider>
      );
    }
    
  • @paypal/checkout-server-sdk:

    Server-side PayPal integration example

    const paypal = require('@paypal/checkout-server-sdk');
    const environment = new paypal.core.SandboxEnvironment('CLIENT_ID', 'CLIENT_SECRET');
    const client = new paypal.core.PayPalHttpClient(environment);
    
    async function createOrder() {
      const request = new paypal.orders.OrdersCreateRequest();
      request.requestBody({
        intent: 'CAPTURE',
        purchase_units: [{ amount: { currency_code: 'USD', value: '100.00' } }],
      });
      const response = await client.execute(request);
      console.log('Order ID:', response.result.id);
    }
    createOrder();
    
  • react-payment-inputs:

    React payment inputs example

    import { usePaymentInputs } from 'react-payment-inputs';
    import images from 'react-payment-inputs/images';
    
    function PaymentForm() {
      const { getCardNumberProps, getExpiryDateProps, getCVCProps, meta } = usePaymentInputs();
    
      return (
        <form>
          <input {...getCardNumberProps()} placeholder="Card Number" />
          <input {...getExpiryDateProps()} placeholder="Expiry Date" />
          <input {...getCVCProps()} placeholder="CVC" />
          <img src={images.visa} alt="Visa" />
          <img src={images.mastercard} alt="Mastercard" />
        </form>
      );
    }
    
How to Choose: @stripe/stripe-js vs @paypal/react-paypal-js vs @paypal/checkout-server-sdk vs react-payment-inputs
  • @stripe/stripe-js:

    Choose @stripe/stripe-js if you need a comprehensive solution for handling various payment methods, including credit cards, digital wallets, and more. It is suitable for applications that require a flexible and scalable payment processing system.

  • @paypal/react-paypal-js:

    Choose @paypal/react-paypal-js if you are building a React application and want to easily integrate PayPal's payment buttons with minimal setup. It provides a seamless way to add PayPal checkout functionality on the client side.

  • @paypal/checkout-server-sdk:

    Choose @paypal/checkout-server-sdk if you need a robust server-side solution for processing PayPal payments, managing orders, and handling transactions securely. It is ideal for backend integrations where you need full control over the payment flow.

  • react-payment-inputs:

    Choose react-payment-inputs if you need customizable and user-friendly input fields for collecting payment information, such as credit card numbers and expiration dates. It is ideal for applications that want to enhance the user experience during the payment process.

README for @stripe/stripe-js

Stripe.js as a CommonJS module or ES module

This package allows Stripe.js to be imported as a CommonJS module or ES module.

Note: To be PCI compliant, you must load Stripe.js directly from https://js.stripe.com. You cannot include it in a bundle or host it yourself. This package wraps the global Stripe function provided by the Stripe.js script as an ES module.

Calling loadStripe always loads the latest version of Stripe.js, regardless of which version of @stripe/stripe-js you use. Updates for this package only impact tooling around the loadStripe helper itself and the TypeScript type definitions provided for Stripe.js. Updates do not affect runtime availability of features of Stripe.js.

npm version

Minimum requirements

  • Node.js: v12.16
  • TypeScript: v.3.1.1

Installation

Use npm to install the Stripe.js module:

npm install @stripe/stripe-js

Versioning

Each @stripe/stripe-js version is pinned to a specific Stripe.js version. The pinned versions are as follows:

@stripe/stripe-jsStripe.js
<6v3
v6acacia
v7basil
v8clover

Usage

loadStripe

This function returns a Promise that resolves with a newly created Stripe object once Stripe.js has loaded. It takes the same parameters passed when directly initializing a Stripe instance. If necessary, it will load Stripe.js for you by inserting the Stripe.js script tag. If you call loadStripe in a server environment it will resolve to null.

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

const stripe = await loadStripe('pk_test_TYooMQauvdEDq54NiTphI7jx');

We’ve placed a random API key in this example. Replace it with your actual publishable API keys to test this code through your Stripe account.

For more information on how to use Stripe.js, please refer to the Stripe.js API reference or learn to accept a payment with Stripe.

If you have deployed a Content Security Policy, make sure to include Stripe.js in your directives.

TypeScript support

This package includes TypeScript declarations for Stripe.js. We support projects using TypeScript versions >= 3.1.

Some methods in Stripe.js accept and return objects from the Stripe API. The type declarations in @stripe/stripe-js for these objects in will always track the latest version of the Stripe API. If you would like to use these types but are using an older version of the Stripe API, we recommend updating to the latest version, or ignoring and overriding the type definitions as necessary.

Note that we may release new minor and patch versions of @stripe/stripe-js with small but backwards-incompatible fixes to the type declarations. These changes will not affect Stripe.js itself.

Ensuring Stripe.js is available everywhere

To best leverage Stripe’s advanced fraud functionality, ensure that Stripe.js is loaded on every page, not just your checkout page. This allows Stripe to detect suspicious behavior that may be indicative of fraud as customers browse your website.

By default, this module will insert a <script> tag that loads Stripe.js from https://js.stripe.com. This happens as a side effect immediately upon importing this module. If you utilize code splitting or only include your JavaScript app on your checkout page, the Stripe.js script will only be available in parts of your site. To ensure Stripe.js is available everywhere, you can perform either of the following steps:

Import as a side effect

Import @stripe/stripe-js as a side effect in code that will be included throughout your site (e.g. your root module). This will make sure the Stripe.js script tag is inserted immediately upon page load.

import '@stripe/stripe-js';

Manually include the script tag

Manually add the Stripe.js script tag to the <head> of each page on your site. If an existing script tag is already present, this module will not insert a new one. When you call loadStripe, it will use the existing script tag.

<!-- Somewhere in your site's <head> -->
<script src="https://js.stripe.com/clover/stripe.js" async></script>

Importing loadStripe without side effects

If you would like to use loadStripe in your application, but defer loading the Stripe.js script until loadStripe is first called, use the alternative @stripe/stripe-js/pure import module:

// CommonJS module import
const {loadStripe} = require('@stripe/stripe-js/pure');
// ES module import
import {loadStripe} from '@stripe/stripe-js/pure';

// Stripe.js will not be loaded until `loadStripe` is called
const stripe = await loadStripe('pk_test_TYooMQauvdEDq54NiTphI7jx');

Disabling advanced fraud detection signals

If you would like to disable advanced fraud detection altogether, use loadStripe.setLoadParameters:

// CommonJS module import
const {loadStripe} = require('@stripe/stripe-js/pure');
// ES module import
import {loadStripe} from '@stripe/stripe-js/pure';

loadStripe.setLoadParameters({advancedFraudSignals: false});
const stripe = await loadStripe('pk_test_TYooMQauvdEDq54NiTphI7jx');

The loadStripe.setLoadParameters function is only available when importing loadStripe from @stripe/stripe-js/pure.

Stripe.js Documentation