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.
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.
- Install react-paypal-js by running
npm install @paypal/react-paypal-js
- Import
PayPalScriptProvider
into src/App.js and wrap the main app component with the<PayPalScriptProvider options={{ "client-id": CLIENT_ID }}>
tag. - Import
PayPalButtons
into src/Checkout.js and include style, payment, and other desired props on<PayPalButton/>
For more details and configuration options look at react-paypal-js usasge and the PayPal JavaScript SDK Complete Reference