mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32: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
|
||||
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/
|
||||
flash[:error] = 'Card is already being used.'
|
||||
redirect '/settings#billing'
|
||||
elsif e.message.match /Your card was declined/
|
||||
flash[:error] = 'The card was declined. Please contact your bank.'
|
||||
else
|
||||
raise e
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue