amyegan / react-integration

Example app demonstrating Smart Payment Buttons integration in React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React App PayPal Integration

A sample app demonstrating the use of react-paypal-js to add PayPal buttons to a basic React app.

This project was bootstrapped with Create React App.

Get Started

Install the dependencies...

cd react-integration
npm install

...log in to the developer dashboard and get your client ID from your default application. Change const CLIENT_ID = 'test'; in src/App.js so CLIENT_ID matches your sandbox client ID...

If you need help setting up your developer dashboard or finding your client ID, follow the first step in the getting started documentation to get API credentials

...then start:

npm run start

Navigate to localhost:3000. You should see the app running.

How It Works

  1. Install react-paypal-js by running npm install @paypal/react-paypal-js
  2. Import PayPalScriptProvider into src/App.js and wrap the main app component with the <PayPalScriptProvider options={{ "client-id": CLIENT_ID }}> tag.
  3. Import PayPalButtons into src/Checkout.js and include style, payment, and other desired props on <PayPalButton/>

Further help

For more details and configuration options look at react-paypal-js usasge and the PayPal JavaScript SDK Complete Reference

About

Example app demonstrating Smart Payment Buttons integration in React


Languages

Language:JavaScript 45.0%Language:HTML 35.7%Language:CSS 19.3%