Git Product home page Git Product logo

kevinh811 / stripe-integration Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stripe-archive/stripe-payments-demo

0.0 1.0 0.0 5.31 MB

Sample store accepting universal payments on the web with Stripe Elements, Payment Request, Apple Pay, Google Pay, Microsoft Pay, and the PaymentIntents API. ๐Ÿ’ณ๐ŸŒโœจ

Home Page: https://stripe-payments-demo.appspot.com

License: MIT License

JavaScript 59.73% HTML 14.31% CSS 25.96%

stripe-integration's Introduction

Stripe Integration

This example features a sample e-commerce store that uses Stripe Elements, PaymentIntents for dynamic authentication, and the Sources API to illustrate how to accept card payments on the web.

Overview

The frontend code for the app is in the public/ directory.

The core logic of the Stripe integration is mostly contained within two files:

  1. public/javascripts/payments.js creates the payment experience on the frontend using Stripe Elements.
  2. server/node/routes.js defines the routes on the backend that create Stripe charges and receive webhook events.

Demo on Google ChromeDemo on Safari iPhone X

Environment Setup

Youโ€™ll need the following:

  • Node.js >=10.0.0
  • Modern browser that supports ES6 (Chrome to see the Payment Request)
  • Stripe account to accept payments (sign up for free).
  • Stripe CLI for webhook testing. Follow these installation steps to install the Stripe CLI

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

stripe login --project-name=stripe-integration

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 app is bundled with ngrok, to serve the app locally via HTTPS, which is required for the Payment Request API.

Project Setup

-Fork this repo and then clone locally

-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

To start the webhook forwarding run:

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.

Running the Node Server and accepting card payments

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 app. Use test card numbers to test the implementation. (https://stripe.com/docs/testing)

Credits

stripe-integration's People

Contributors

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

Watchers

James Cloos 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.