Skip to content

Commit 7725be6

Browse files
author
Amy Egan
committed
Add react-paypal-js
1 parent e144552 commit 7725be6

File tree

3 files changed

+37
-67
lines changed

3 files changed

+37
-67
lines changed

README.md

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,29 @@
11
# Getting Started with Create React App
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4-
5-
## Available Scripts
6-
7-
In the project directory, you can run:
8-
9-
### `yarn start`
10-
11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13-
14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
16-
17-
### `yarn test`
18-
19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21-
22-
### `yarn build`
23-
24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
26-
27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
29-
30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
3+
A sample app demonstrating the use of [react-paypal-js](https://github.com/paypal/react-paypal-js) to add PayPal buttons to a basic React app.
314

32-
### `yarn eject`
33-
34-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35-
36-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37-
38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39-
40-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41-
42-
## Learn More
43-
44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45-
46-
To learn React, check out the [React documentation](https://reactjs.org/).
47-
48-
### Code Splitting
49-
50-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51-
52-
### Analyzing the Bundle Size
5+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
536

54-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
7+
## Get started
558

56-
### Making a Progressive Web App
9+
Install the dependencies...
5710

58-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
11+
```bash
12+
cd react-integration
13+
npm install
14+
```
5915

60-
### Advanced Configuration
16+
...log in to the [developer dashboard](https://www.paypal.com/signin?returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fapplications) 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...
6117

62-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
18+
> 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](https://developer.paypal.com/docs/business/get-started/#get-api-credentials)
6319
64-
### Deployment
20+
...then start:
6521

66-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
22+
```bash
23+
npm run start
24+
```
25+
Navigate to [localhost:3000](http://localhost:3000). You should see the app running.
6726

68-
### `yarn build` fails to minify
27+
## Further help
6928

70-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
29+
For more details and configuration options look at [react-paypal-js usasge](https://github.com/paypal/react-paypal-js#usage) and the [PayPal JavaScript SDK Complete Reference](https://developer.paypal.com/docs/business/javascript-sdk/javascript-sdk-reference/)

src/App.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1+
import { PayPalScriptProvider } from '@paypal/react-paypal-js';
12
import logo from './logo.svg';
23
import './App.css';
4+
import Checkout from './Checkout';
35

46
function App() {
7+
const CLIENT_ID = 'test';
8+
59
return (
10+
<PayPalScriptProvider options={{ "client-id": CLIENT_ID }}>
611
<div className="App">
712
<header className="App-header">
813
<img src={logo} className="App-logo" alt="logo" />
914
<p>
10-
Edit <code>src/App.js</code> and save to reload.
15+
Buy an atom!
1116
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
19-
</a>
17+
<Checkout />
2018
</header>
2119
</div>
20+
</PayPalScriptProvider>
2221
);
2322
}
2423

src/Checkout.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { PayPalButtons } from "@paypal/react-paypal-js";
2+
3+
function Checkout() {
4+
return (
5+
<div style={{ width: "75%", maxWidth: "500px" }}>
6+
<PayPalButtons
7+
style={{ layout: "horizontal", tagline: "false" }} />
8+
</div>
9+
);
10+
}
11+
12+
export default Checkout;

0 commit comments

Comments
 (0)