https://github.com/nealfennimore/stripe-api-node-express
Express server for stripe api
https://github.com/nealfennimore/stripe-api-node-express
express json-web-token nodejs stripe-api
Last synced: 2 months ago
JSON representation
Express server for stripe api
- Host: GitHub
- URL: https://github.com/nealfennimore/stripe-api-node-express
- Owner: nealfennimore
- Created: 2017-03-17T03:48:19.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-18T23:24:08.000Z (almost 8 years ago)
- Last Synced: 2025-12-04T10:53:50.506Z (6 months ago)
- Topics: express, json-web-token, nodejs, stripe-api
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Stripe API Express Server
A simple express api server for creating Stripe charges.
## Installation
```sh
npm install
npm install -g foreman # Install foreman globally
```
### .env File Example
Update your `.env` file to look similar.
```js
{
"server": {
"ip": "0.0.0.0",
"port": 3000
},
"auth": {
"secret": "",
"algorithm": "HS256"
},
"stripe": {
"publishable_key": "",
"secret_key": ""
}
}
```
### Generate Keys
We'll use a either a secret key or RSA public key for verifying using JSON Web Tokens for certain API requests.
Generate a private and public key using the below commands for RS256.
```sh
# RS256 key
openssl genrsa -out keys/priv.pem 1024
openssl rsa -pubout -in keys/priv.pem -out keys/pub.pem
```
## Get Access Token
Generate an access token and use it for authenticated API requests.
```js
# RS256
const privateKey = fs.readFileSync('keys/priv.pem');
const RS_256_ACCESS_TOKEN = jwt.sign({}, privateKey, { algorithm: 'RS256'})
# HS256
const HS256_ACCESS_TOKEN = jwt.sign({}, AUTH_SECRET);
```
The token should be in the `Authorization` Header.
```js
// Authorization: Bearer
req.headers['authorization'];
```
## Starting API Server
```sh
npm run start
npm run develop # With nodemon
```