mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
catch card errors on supporter signup
This commit is contained in:
parent
2448b51d61
commit
623dfd05fc
1 changed files with 11 additions and 6 deletions
|
@ -47,12 +47,17 @@ post '/supporter/update' do
|
||||||
site.stripe_subscription_id = subscription.id
|
site.stripe_subscription_id = subscription.id
|
||||||
site.save_changes validate: false
|
site.save_changes validate: false
|
||||||
else
|
else
|
||||||
customer = Stripe::Customer.create(
|
begin
|
||||||
source: params[:stripe_token],
|
customer = Stripe::Customer.create(
|
||||||
description: "#{site.username} - #{site.id}",
|
source: params[:stripe_token],
|
||||||
email: site.email,
|
description: "#{site.username} - #{site.id}",
|
||||||
plan: plan_type
|
email: site.email,
|
||||||
)
|
plan: plan_type
|
||||||
|
)
|
||||||
|
rescue Stripe::CardError => e
|
||||||
|
flash[:error] = "Error: #{Rack::Utils.escape_html e.message}"
|
||||||
|
redirect '/supporter'
|
||||||
|
end
|
||||||
|
|
||||||
site.stripe_customer_id = customer.id
|
site.stripe_customer_id = customer.id
|
||||||
site.stripe_subscription_id = customer.subscriptions.first.id
|
site.stripe_subscription_id = customer.subscriptions.first.id
|
||||||
|
|
Loading…
Add table
Reference in a new issue