donation error handling
This commit is contained in:
parent
3b609052d5
commit
dc582e5980
1 changed files with 14 additions and 3 deletions
|
@ -1,9 +1,20 @@
|
||||||
class DonationsController < ApplicationController
|
class DonationsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@campaign = Campaign.current
|
@campaign = Campaign.current
|
||||||
@donation = Donation.create_from_charge(
|
begin
|
||||||
@campaign, current_user, params[:donation])
|
@donation = Donation.create_from_charge(
|
||||||
redirect_to @donation
|
@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
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
Loading…
Reference in a new issue