• This repository has been archived on 19/Apr/2022
  • Stars
    star
    1,471
  • Rank 31,964 (Top 0.7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

This project is inactive and is no longer being maintained.

Stripe Payments Demo

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

If youโ€™re running a compatible browser, this demo also showcases the Payment Request API, Apple Pay, Google Pay, and Microsoft Pay for a seamless payment experience.

You can see this demo app running in test mode on stripe-payments-demo.appspot.com.

๏ธโš ๏ธ ๏ธPaymentIntents is the recommended integration path for 3D Secure authentication. It lets you benefit from dynamic authentication to maximize conversion and prepare for regulations like Strong Customer Authentication in Europe.

Overview

Demo on Google ChromeDemo on Safari iPhone X

This demo provides an all-in-one example for integrating with Stripe on the web:

Features
โœจ Beautiful UI components for card payments. This demo uses pre-built Stripe components customized to fit the app design, including the Card Element which provides real-time validation, formatting, and autofill.
๐Ÿ’ณ Card payments with Payment Request, Apple Pay, Google Pay, and Microsoft Pay. The app offers frictionless card payment experiences with a single integration using the Payment Request Button Element.
๐ŸŒ Payment methods for Europe and Asia. A dozen redirect-based payment methods are supported through the Sources API, from iDEAL to WeChat Pay.
๐ŸŽฉ Automatic payment methods suggestion. Picking a country will automatically show relevant payment methods. For example, selecting โ€œGermanyโ€ will suggest SOFORT, Giropay, and SEPA Debit.
๐Ÿ” Dynamic 3D Secure for Visa and Mastercard. The app automatically handles the correct flow to complete card payments with 3D Secure, whether itโ€™s required by the card or encoded in one of your 3D Secure Radar rules.
๐Ÿ“ฒ QR code generation for WeChat Pay. During the payment process for WeChat Pay, a QR code is generated for the WeChat Pay URL to authorize the payment in the WeChat app.
๐Ÿš€ Built-in proxy for local HTTPS and webhooks. Card payments require HTTPS and asynchronous payment methods with redirects rely on webhooks to complete transactionsโ€”ngrok is integrated so the app is served locally over HTTPS. The Stripe CLI is used to forward webhook events to the local server.
๐Ÿ”ง Webhook signing. We allow for webhook signature verification, which is a recommended security practice.
๐Ÿ“ฑ Responsive design. The checkout experience works on all screen sizes. Apple Pay works on Safari for iPhone and iPad if the Wallet is enabled, and Payment Request works on Chrome for Android.
๐Ÿ“ฆ No datastore required. Products, and SKUs are stored using the Stripe API, which you can replace with your own database to keep track of products and inventory.

Payments Integration

The frontend code for the demo 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.

Card Payments with Stripe Elements

Stripe Elements let you quickly support cards, Apple Pay, Google Pay, and the new Payment Request API.

Stripe Elements are rich, pre-built UI components that create optimized checkout flows across desktop and mobile. Elements can accept any CSS property to perfectly match the look-and-feel of your app. They simplify the time-consuming parts when building payment forms, e.g. input validation, formatting, localization, and cross-browser support.

This demo uses both the Card Element and the Payment Request Button, which provides a single integration for Apple Pay, Google Pay, and the Payment Request APIโ€”a new browser standard that allows your customers to quickly provide payment and address information theyโ€™ve stored with their browser.

Payment Request on Chrome

Beyond Cards: Payment Methods for Europe and Asia

This demo also shows how to reach customers in Europe and Asia by supporting their preferred way to pay online. It supports payment methods such as ACH credit transfers, Alipay, Bancontact, iDEAL, Giropay, SEPA Direct Debit, SOFORT, and WeChat Pay.

The app also supports both Multibanco and EPS which are currently in Public Beta on Stripe.

WeChat Pay with the Sources API

Getting Started with Node

Instructions for running the Node.js server in server/node are below. You can find alternative server implementations in the server directory:

All servers have the same endpoints to handle requests from the frontend and interact with the Stripe libraries.

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.

Deploy

Credits

More Repositories

1

jquery.payment

[DEPRECATED] A general purpose library for building credit card forms, validating inputs and formatting numbers.
CoffeeScript
3,538
star
2

react-stripe-elements

Moved to stripe/react-stripe-js.
JavaScript
3,026
star
3

mosql

MongoDB โ†’ PostgreSQL streaming replication
Ruby
1,629
star
4

shop

Single-page shop
CSS
1,126
star
5

flow-to-typescript-codemod

Codemod Stripe used to migrate 6.5m+ lines of code from Flow to TypeScript
TypeScript
675
star
6

safesql

Static analysis tool for Golang that protects against SQL injections
Go
563
star
7

PaymentKit

Easily accept payments on iOS
Objective-C
470
star
8

brushfire

Distributed decision tree ensemble learning in Scala
Scala
391
star
9

stripe-webhook-monitor

Stripe Webhook Monitor provides a real-time feed and graph of Stripe events received via webhooks. ๐Ÿ“ˆโœจ
JavaScript
366
star
10

accept-a-card-payment

Learn how to accept a basic card payment on web, iOS, Android
Java
351
star
11

jquery.mobilePhoneNumber

[DEPRECATED] A general purpose library for validating and formatting mobile phone numbers.
CoffeeScript
331
star
12

nextjs-typescript-react-stripe-js

Full-stack TypeScript example using Next.js, react-stripe-js, and stripe-node.
TypeScript
329
star
13

topmodel

Standard evaluations for binary classifiers so you don't have to
Python
316
star
14

gaps

Easy management of your Google Groups subscriptions.
Ruby
284
star
15

developer-office-hours

A collection of Stripe Developer Office Hours demos ๐ŸŽฌ
Ruby
245
star
16

ApplePayStubs

Test your Apple Pay integration without Apple Pay
Objective-C
193
star
17

timberlake

Timberlake is a Job Tracker for Hadoop.
Go
177
star
18

wilde-things

A tutorial integrating Stripe in PHP
PHP
175
star
19

sequins

A key/value store for serving static batch data
Go
174
star
20

checkout-subscription-and-add-on

Uses Stripe Checkout to create a payment page that starts a subscription for a new customer.
CSS
162
star
21

mongoriver

A library for writing MongoDB oplog tailers.
Ruby
153
star
22

stripe-demo-connect-kavholm-marketplace

Demo app for Global Marketplace using Stripe Connect
JavaScript
139
star
23

herringbone

Tools for working with parquet, impala, and hive
Thrift
135
star
24

pd2pg

Import PagerDuty data into Postgres for analysis
Ruby
110
star
25

payment-form-modal

How to implement Stripe Elements within a modal dialog.
JavaScript
106
star
26

datadog-checks

Checks for the Datadog Agent that Stripe finds useful.
Python
99
star
27

set-up-subscriptions

Getting started with Stripe Elements and Stripe Billing to charge a customer for a monthly subscription.
CSS
96
star
28

macgyver

A Chrome extension which duct tapes an SSH agent to the platformKey API
Go
90
star
29

react-elements-card-payment

Learn how to build a checkout form with React
CSS
87
star
30

chalk-log

Chalk::Log adds a logger object to any class, which can be used for unstructured or semi-structured logging.
Ruby
72
star
31

agate

Scoring ONNX models on the JVM in scala
Scala
68
star
32

sbt-bazel

Easily convert SBT projects to Bazel workspaces
Scala
54
star
33

charging-for-multiple-plan-subscriptions

Getting started with Stripe Elements and Stripe Billing to charge a customer for a monthly subscription with multiple items.
JavaScript
54
star
34

checkout-remember-me-with-twilio-verify

Use Stripe Checkout to collect payment details for future payments and Twilio Verify to authenticate the customer via SMS code and charge their stored card.
JavaScript
50
star
35

firebase-mobile-payments

Firebase Cloud Functions to create payments in native Android and iOS applications.
Kotlin
49
star
36

identity-verification

Securely collect and verify identity documents
JavaScript
44
star
37

falconer

High throughout, unsampled tracing span buffer with streaming search
Go
40
star
38

web-elements-sepa-debit-payment

Collect SEPA Debit mandates and payments.
Objective-C
37
star
39

payment-tag

CoffeeScript
34
star
40

stripe-stdlib-demo

Sample store accepting universal payments built with @Stripe and @StdLib.
JavaScript
33
star
41

chalk-config

Maps on-disk config files into a loaded global configatron instance, taking into account your current environment.
Ruby
28
star
42

go-einhorn

Talk to einhorn from your Go worker
Go
25
star
43

sample-terminal-ios-app

Learn how to take in-person payments with a physical reader and Terminal in your iOS app
Swift
19
star
44

adding-sales-tax

Learn how to use PaymentIntents to build a simple checkout flow
CSS
18
star
45

javascript-style

Javascript linter with rules for Stripe projects
JavaScript
16
star
46

scrooge-shapes

Shapeless generic instances for Scrooge types
Scala
14
star
47

datadog-cli-tools

CLI tools we find useful for Datadog
Ruby
13
star
48

submigrate

Combine multiple subscriptions into a single subscription with multiple items
Go
12
star
49

web-elements-fpx-payment

Accept Malaysian online bank transfers with the Stripe FPX Element.
JavaScript
12
star
50

siv-go

A pure Go implementation of the SIV AEAD.
Go
11
star
51

au-becs-debit-payment

Collecting AU BECS Direct Debit mandates and payments.
Java
10
star
52

oxxo-payment

Learn how to accept OXXO and card payments
JavaScript
10
star
53

round-up-and-donate

Build a round up and donate feature with Connect
CSS
10
star
54

random

A collection of random utilities
Shell
9
star
55

web-elements-card-payment

Learn how to accept a basic card payment on the web
JavaScript
7
star
56

grabpay-payment

Accept GrabPay Payments with Stripe, a popular digital wallet in Southeast Asia.
CSS
5
star
57

yard-sorbet

Types are documentation
Ruby
5
star
58

terraform-provider-confidant

A terraform provider for confidant. See https://github.com/terraform-providers
Go
5
star
59

simple-powershell-dsc

Simple Powershell DSC pull server in Go
Go
4
star
60

stripe-magento1-releases

4
star
61

pb

Lint protocol buffers
Go
2
star
62

mobile-elements-card-payment

Learn how to accept a basic card payment on iOS & Android
Java
2
star
63

bazel-bloop-exporter

This proof of concept exports a bazel project to bloop. The motivation is to allow the use of any tooling that already has a bloop integration, such as the metals language server.
Starlark
2
star
64

sentry-restricted-github

Python
2
star
65

time-utils

Ruby
1
star