Code Monkey home page Code Monkey logo

boilerplate-stripe-nodejs-server's Introduction

Stripe Payments Server boilerplate for NodeJS

This is a boilerplate of a stripe server implementation for NodeJS. This is effectively a fork of this repo, that only features the NodeJS server implementation plus some addiitonal tweaks.

Getting Started with Node

Requirements

You’ll need the following:

  • Node.js >=10.0.0
  • Modern browser that supports ES6 (Chrome to see the Payment Request, and Safari to see Apple Pay).
  • Stripe account to accept payments (sign up for free).

In your Stripe Dashboard, you can enable the payment methods you’d like to test.

Some payment methods require receiving a real-time webhook notification to complete a charge. We're using the Stripe CLI to forward webhook events to our local development server. Additionally this demo is bundled with ngrok, to serve the app locally via HTTPS, which is required for the Payment Request API.

Running the Node Server

Copy the environment variables file from the root of the repository:

cp .env.example .env

Update .env with your own Stripe API keys and any other configuration details. These environment variables are loaded and used in server/node/config.js, where you can review and edit other options such as the app currency and your Stripe account country.

Install dependencies using npm:

npm install

This demo uses the Stripe API as a datastore for products and SKUs, but you can always choose to use your own datastore instead. After npm install has finished the setup script will run to create the product records on your Stripe account.

Next, follow these installation steps to install the Stripe CLI which we'll use for webhook testing.

After the installation has finished, authenticate the CLI with your Stripe account:

stripe login --project-name=stripe-payments-demo

To start the webhook forwarding run:

stripe listen --project-name=stripe-payments-demo --forward-to http://localhost:8000/webhook

Alternatively, you can use the following shorthand command:

npm run webhook

The Stripe CLI will let you know that webhook forwarding is ready and output your webhook signing secret:

> Ready! Your webhook signing secret is whsec_xxx

Please copy the webhook signing secret (whsec_xxx) to your .env file.

In a separate terminal window, start the local server:

npm run start

Lastly, you will see the ngrok URL to serve our app via HTTPS. For example:

https://<example>.ngrok.io

Use this URL in your browser to start the demo.

boilerplate-stripe-nodejs-server's People

Contributors

thorsten-stripe avatar romainhuet avatar adreyfus-stripe avatar gverni-stripe avatar dependabot[bot] avatar romain-stripe avatar willock-stripe avatar rlk-stripe avatar b3none avatar sobel-stripe avatar dng-stripe avatar mikeshaw-stripe avatar barrymcgee avatar zabicki-stripe avatar youssef-stripe avatar wshallum-stripe avatar rgultiano-stripe avatar jhstrauss avatar ryanleecode avatar richardg-stripe avatar quintinadam avatar nati-stripe avatar scherr-stripe avatar perpetual-hydrofoil avatar dougramirez avatar panckreous avatar atrox avatar atty-stripe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.