mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
declined card check
This commit is contained in:
parent
e551aeb342
commit
1d87b87e62
1 changed files with 3 additions and 1 deletions
|
@ -353,10 +353,12 @@ post '/settings/update_card' do
|
||||||
|
|
||||||
begin
|
begin
|
||||||
customer.sources.create source: params[:stripe_token]
|
customer.sources.create source: params[:stripe_token]
|
||||||
rescue Stripe::InvalidRequestError => e
|
rescue Stripe::InvalidRequestError, Stripe::CardError => e
|
||||||
if e.message.match /cannot use a.+token more than once/
|
if e.message.match /cannot use a.+token more than once/
|
||||||
flash[:error] = 'Card is already being used.'
|
flash[:error] = 'Card is already being used.'
|
||||||
redirect '/settings#billing'
|
redirect '/settings#billing'
|
||||||
|
elsif e.message.match /Your card was declined/
|
||||||
|
flash[:error] = 'The card was declined. Please contact your bank.'
|
||||||
else
|
else
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue