Evolve a basic webhook handler from the most primitave to one that follows some recommended best practices for handling Stripe webhooks.
Follow these instructions to spin-up a copy of this demo project up on your local machine for development and testing purposes. This is meant to be a guide to show you how to go about evolving a webhook handling system.
- Ruby 2.4.5
- Postgres
- Stripe CLI
- Create a stripe account
- Stripe API Keys
- Download and Install dependencies
git clone [email protected]:stripe-samples/developer-office-hours.git
cd developer-office-hours/2019-10-16-webhooks
bundle install
- Login and start stripe-cli listener
Note: Copy the whsec_xxx
key from the output of the listen command.
stripe login
stripe listen --forward-to localhost:3000/webhook_events/stripe
- Update API keys
EDITOR=vi rails credentials:edit
Add your Stripe API keys to the Rails credentials.
stripe:
pk: pk_your_publishable_key
sk: sk_your_secret_key
wh: whsec_your_webhook_signing_secret
- Update publishable key and SKU for testing in /public/index.html
Create a new product and enable Checkout in your Stripe Dashboard.
- Setup Database
rake db:create db:migrate
- Start rails server
rails server
- Browse to
http://localhost:3000