Created
August 25, 2019 16:39
-
-
Save MittalPatel-BTC/a33563b92c0b93bd70bf042cba2984fa to your computer and use it in GitHub Desktop.
Stripe event handler service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/services/stripe/event_handler.rb | |
# Stripe module | |
module Stripe | |
# stripe main class EventHandler | |
class EventHandler | |
def call(event) | |
method = 'handle_' + event.type.tr('.', '_') | |
send method, event | |
rescue JSON::ParserError => e | |
render json: { status: 400, error: 'Invalid payload' } | |
Raven.capture_exception(e) | |
rescue Stripe::SignatureVerificationError => e | |
render json: { status: 400, error: 'Invalid signature' } | |
Raven.capture_exception(e) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment