The Stripe Event Handler is simple rails application that receives and processes events from Stripe.
- Ruby on Rails api
- Sidekiq for background processing
- Stripe Ruby Library is for webhook events processing
- AASM - Ruby state machines for subscription state management
- Development is fully containerized with Docker
- Makefile has the most common commands to run the project
- Stripe service publish subscription events
- Service webhook endpoint receives them and process in background
- The initial state of the subscription record is "unpaid"
- Paying the first invoice of the subscription changes the state to "paid"
- Canceling a subscription changes the state to “canceled”. Only subscriptions in the state “paid” can be canceled
Setup Stripe listener locally. To do you need to install stripe cli for example using brew:
brew install stripe/stripe-cli/stripeThen login to stripe either through a browser
stripe loginor using api key
stripe config --set test_mode_api_key <test_secret_key>Stripe Event Handler is a containerized application so you can run it using Docker. Install Docker using of the ways from official site: https://docs.docker.com
Application uses rails credentials to store secrets. You need to copy master.key to the /config folder in order to make it work
Stripe Event Handler has a Makefile for easier run the most common development tasks. To start the project run:
make setup
make startRun rspec tests:
make setup
make testRun test webhook events (make sure you are logged in to stripe cli)
make stripe-listenThis will run stripe listener locally that will forward subscription events to the server. Then
make stripe-testThis will send 3 events which will be handled by the server