donation error handling
This commit is contained in:
parent
3b609052d5
commit
dc582e5980
1 changed files with 14 additions and 3 deletions
|
@ -1,10 +1,21 @@
|
|||
class DonationsController < ApplicationController
|
||||
def create
|
||||
@campaign = Campaign.current
|
||||
begin
|
||||
@donation = Donation.create_from_charge(
|
||||
@campaign, current_user, params[:donation])
|
||||
rescue Stripe::CardError => e
|
||||
flash[:alert] = "We couldn't process your donation: #{e.message}"
|
||||
redirect_to :donate
|
||||
rescue => e
|
||||
flash[:alert] =
|
||||
"We couldn't process your donation: #{e.message} " +
|
||||
"Please try again later!"
|
||||
redirect_to :donate
|
||||
else
|
||||
redirect_to @donation
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@donation = Donation.from_param(params[:id])
|
||||
|
|
Loading…
Reference in a new issue