🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@paypal/react-paypal-js

Package Overview
Dependencies
Maintainers
23
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paypal/react-paypal-js

React components for the PayPal JS SDK

8.8.3
latest
Source
npm
Version published
Weekly downloads
158K
2.87%
Maintainers
23
Weekly downloads
 
Created

What is @paypal/react-paypal-js?

@paypal/react-paypal-js is a React library that provides a set of components and hooks to easily integrate PayPal's payment services into a React application. It simplifies the process of adding PayPal buttons, handling transactions, and managing the PayPal SDK.

What are @paypal/react-paypal-js's main functionalities?

PayPal Buttons

This feature allows you to add PayPal buttons to your React application. The PayPalButtons component renders the PayPal buttons and handles the payment process.

import { PayPalScriptProvider, PayPalButtons } from '@paypal/react-paypal-js';

function App() {
  return (
    <PayPalScriptProvider options={{ "client-id": "your-client-id" }}>
      <PayPalButtons style={{ layout: 'vertical' }} />
    </PayPalScriptProvider>
  );
}

Custom Button Styles

This feature allows you to customize the appearance of the PayPal buttons. You can change the layout, color, shape, and label of the buttons.

import { PayPalScriptProvider, PayPalButtons } from '@paypal/react-paypal-js';

function App() {
  return (
    <PayPalScriptProvider options={{ "client-id": "your-client-id" }}>
      <PayPalButtons style={{ layout: 'horizontal', color: 'blue', shape: 'pill', label: 'pay' }} />
    </PayPalScriptProvider>
  );
}

Handling Payment Events

This feature allows you to handle payment events such as order creation and approval. You can define custom functions to create orders and handle successful transactions.

import { PayPalScriptProvider, PayPalButtons } from '@paypal/react-paypal-js';

function App() {
  const createOrder = (data, actions) => {
    return actions.order.create({
      purchase_units: [{
        amount: {
          value: '0.01',
        },
      }],
    });
  };

  const onApprove = (data, actions) => {
    return actions.order.capture().then((details) => {
      alert('Transaction completed by ' + details.payer.name.given_name);
    });
  };

  return (
    <PayPalScriptProvider options={{ "client-id": "your-client-id" }}>
      <PayPalButtons createOrder={createOrder} onApprove={onApprove} />
    </PayPalScriptProvider>
  );
}

Other packages similar to @paypal/react-paypal-js

Keywords

react

FAQs

Package last updated on 11 Apr 2025

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