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

@paypal/react-paypal-js

Package Overview
Dependencies
Maintainers
21
Versions
66
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.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
21
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

FAQs

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