This project works with Stripe api on Nodejs and on the client representation as well. Go to Stripe for more information
- community mongodb installed locally or cloud version
- node.js
- account on Stripe.js (for your test purchases)
- connect-mongo
- express cookie
- nodemon
- morgan
Current app implementation doesn't have a UI for adding new products, but you can run script with migrations to add some products into DB and receive it from the application's UI. Make sure MongoDB is installed and running first.
npm run migration:write
Before running the app, you should create your own .env
file in the root with the following variables:
PORT=<place your port here>
STRIPE_SECRET_KEY=<your stripe secret test key for server>
MONGO_DB_URL='mongodb://127.0.0.1:27017' or remote mongo address
Note: make sure to add publc stripe key to public/javascripts/checkout.js
in order to configure both server and client parts of Stripe.
const stripePublishableTestKey = null;
// your public key should be here for proper Stripe work
// otherwise app generates en error with alert message
if (!stripePublishableTestKey) {
const error = 'Please add a Stripe.js public key';
alert(error);
throw new Error(error);
}
Stripe.setPublishableKey(stripePublishableTestKey);
- npm install
- add stripe test key to ENV file and to
checkout.js
(publishable not secret key for sender identification) - npm start
- open browser at specified PORT env variables