Skip to content

chuvayva/stripe_event_handler

Repository files navigation

Stripe Event Handler

The Stripe Event Handler is simple rails application that receives and processes events from Stripe.

Technologies Used

  • Ruby on Rails api
  • Sidekiq for background processing

What Is Special About Me

How Does This Work?

  • 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

How Run Locally

Stripe

Setup Stripe listener locally. To do you need to install stripe cli for example using brew:

brew install stripe/stripe-cli/stripe

Then login to stripe either through a browser

stripe login

or using api key

stripe config --set test_mode_api_key <test_secret_key>

Docker

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

Master Key

Application uses rails credentials to store secrets. You need to copy master.key to the /config folder in order to make it work

Application

Stripe Event Handler has a Makefile for easier run the most common development tasks. To start the project run:

make setup
make start

How Test Locally

Run rspec tests:

make setup
make test

Run test webhook events (make sure you are logged in to stripe cli)

make stripe-listen

This will run stripe listener locally that will forward subscription events to the server. Then

make stripe-test

This will send 3 events which will be handled by the server

About

A simple rails application that receives and processes events from Stripe

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •