/stripe-v3-node-demo

A cleaned-up version of the official Stripe v3 QuickStart from https://stripe.com/docs/payments/quickstart

Primary LanguageJavaScriptMozilla Public License 2.0MPL-2.0

stripe-v3-node-demo

A cleaned-up version of the official Stripe v3 QuickStart from https://stripe.com/docs/payments/quickstart.

Live Stream

Everything from perusing the docs to publishing this was recorded live:

Accept a Payment

Build a simple checkout form to collect payment details. Included are some basic build and run scripts you can use to start up the application.

Running the sample

I recommend running this on Digital Ocean (grab $100 off or 60 days free with my link), but you can run it on a localhost domain as well (with https too, thanks to DuckDNS and Caddy).

  1. Register a domain, such as stripe-demo-123 at duckdns.org.
  2. Replace example.duckdns.org with your domain in the Caddyfile.
  3. For localhost
    • set your DuckDNS IP to 127.0.0.1
    • replace /home/app/example.duckdns.org/public with the path absolute path to your public folder
    • replace {env.DUCKDNS_API_TOKEN} with your DuckDNS token in the Caddyfile
    • uncomment the 3 tls lines (including your DuckDNS) token
  4. Install dependencies (node, caddy, watchexec)
    (note: you may need to close and re-open your terminal between steps)
    bash install.sh
    npm ci
  5. Run the server
    # register as a system service (works for macOS and Linux)
    bash register-caddy-service.sh
    bash register-node-service.sh
    # or run as a one-off
    caddy start --config ./Caddyfile
    npm run start
  6. Go to https://example.duckdns.org/ (change to your DuckDNS domain)
  7. View logs
    # linux
    sudo journalctl -xefu stripe-demo
    # mac
    tail -f ~/.local/share/stripe-demo/var/log/stripe-demo.log
    tail -f /var/log/caddy/caddy.log

Uninstall system services

Linux:

sudo systemctl stop caddy
sudo systemctl stop stripe-demo

sudo systemctl disable caddy
sudo systemctl disable stripe-demo

Mac:

launchctl unload -w /Users/aj/Library/LaunchAgents/stripe-demo.plist
sudo launchctl unload -w /Library/LaunchDaemons/caddy.plist