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
namespace :users do | |
get 'charge' | |
get 'refund' | |
get 'bill' | |
end |
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
charge_users GET /users/charge(.:format) users#charge | |
refund_users GET /users/refund(.:format) users#refund | |
bill_users GET /users/bill(.:format) users#bill |
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
resources :users, only: [] do | |
collection do | |
get 'charge' | |
get 'refund' | |
get 'bill' | |
end | |
end |
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
resources :users, except: [:new, :create, :edit, :update, :destroy] do | |
collection do | |
get 'charge' | |
get 'refund' | |
get 'bill' | |
end | |
end |
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
users GET /users(.:format) users#index | |
POST /users(.:format) users#create | |
new_user GET /users/new(.:format) users#new | |
edit_user GET /users/:id/edit(.:format) users#edit | |
user GET /users/:id(.:format) users#show | |
PUT /users/:id(.:format) users#update | |
DELETE /users/:id(.:format) users#destroy |
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
class UserController < ApplicationController | |
def charge | |
end | |
def refund | |
end | |
def bill | |
end | |
end |
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/refund_event_handler.rb | |
# Stripe event handler for handling webhook | |
module Stripe | |
# This will inherite the eventHandler main class | |
class RefundEventHandler < EventHandler | |
def handle_charge_refund_created(event) | |
# your code goes here | |
end | |
end | |
end |
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/dispute_event_handler.rb | |
# Stripe event handler for handling webhook | |
module Stripe | |
# This will inherite the eventHandler main class | |
class DisputeEventHandler < EventHandler | |
def handle_charge_dispute_created(event) | |
# your code goes here | |
end | |
end | |
end |
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' } |
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
# 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) |
NewerOlder