Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/christianrich/paypal-node
Node.js Paypal integration example
https://github.com/christianrich/paypal-node
es6 nodejs paypal
Last synced: 9 days ago
JSON representation
Node.js Paypal integration example
- Host: GitHub
- URL: https://github.com/christianrich/paypal-node
- Owner: ChristianRich
- License: mit
- Created: 2018-07-17T05:53:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-23T04:37:56.000Z (over 6 years ago)
- Last Synced: 2024-11-07T19:34:15.605Z (2 months ago)
- Topics: es6, nodejs, paypal
- Language: JavaScript
- Size: 66.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Paypal server-side implementation with Node.js
Example of Paypal client-side / server-side integration flow.
Essentially this is a full implementation of https://developer.paypal.com/demo/checkout/#/pattern/serverI have kept the files organised making the code portable.
## Tooling
* Node.js es6
* Target version Node v8.9.4
* Using Babel to transpile to es5## Prerequisites and configuration
* Go to https://developer.paypal.com/
* Create an account (sandbox)
* Create an app under "My Apps & Credentials"
* Copy the client ID / secret into `.env-sample`
* Rename `.env-sample` to `.env`## Start the app
```
npm i
npm start
```
Go to http://localhost:3001 and click the "Paypal Checkout" button. This will start the payment flow.
Open your console to see the req / res flow.## Paypal SDK
This project uses the Node.js [Paypal REST SDK](https://www.npmjs.com/package/paypal-rest-sdk) which under the hood makes HTTP requests to the [Paypal API](https://developer.paypal.com/docs/api/payments/v1/).The benefit of using the SDK means you don't need to authorise each request, that is all done for you.
## Sample payloads
The folder `/test/mock` contains mock request / response payloads for the SDK. Useful for testing / debugging or just gaining an understanding of how it works.## File tree
.
├── LICENSE
├── README.md
├── logs
│ └── 2018-07-18.log
├── package-lock.json
├── package.json
├── public
│ └── index.html
├── src
│ ├── controllers
│ │ ├── pages.js
│ │ └── paypal.js
│ ├── domain
│ │ ├── order.js
│ │ └── paypal-authorisation.js
│ ├── index.js
│ └── services
│ ├── logger.js
│ └── paypal.js
└── test
└── mock
├── authorise.request.json
├── authorise.response.json
├── execute.request.json
├── execute.response.json
└── sale.response.json