mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
Add more catches for stripe events
This commit is contained in:
parent
4e0ff8a7ca
commit
d085a99ddc
3 changed files with 49 additions and 0 deletions
|
@ -11,5 +11,33 @@ post '/stripe_webhook' do
|
||||||
body: "#{username}\n#{email}\n#{Site[username: username].uri}"
|
body: "#{username}\n#{email}\n#{Site[username: username].uri}"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if event['type'] == 'charge.failed'
|
||||||
|
site_id = event['data']['object']['description'].split(' - ').last
|
||||||
|
site = Site[site_id]
|
||||||
|
|
||||||
|
EmailWorker.perform_async({
|
||||||
|
from: 'web@neocities.org',
|
||||||
|
to: site.email,
|
||||||
|
subject: "[Neocities] There was an issue charging your card",
|
||||||
|
body: Tilt.new('./views/templates/email/charge_failure.erb', pretty: true).render(self)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if event['type'] == 'customer.subscription.deleted'
|
||||||
|
site_id = event['data']['object']['description'].split(' - ').last
|
||||||
|
site = Site[site_id]
|
||||||
|
site.stripe_subscription_id = nil
|
||||||
|
site.plan_type = nil
|
||||||
|
site.save_changes validate: false
|
||||||
|
|
||||||
|
EmailWorker.perform_async({
|
||||||
|
from: 'web@neocities.org',
|
||||||
|
to: site.email,
|
||||||
|
subject: "[Neocities] Supporter plan has ended",
|
||||||
|
body: Tilt.new('./views/templates/email/supporter_ended.erb', pretty: true).render(self)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
'ok'
|
'ok'
|
||||||
end
|
end
|
||||||
|
|
10
views/templates/email/charge_failure.erb
Normal file
10
views/templates/email/charge_failure.erb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Hello,
|
||||||
|
|
||||||
|
We're writing to let you know that Neocities has had an issue charging your card. We will try again automatically in a few days, but we just wanted to give you a heads up in case something is wrong with your card.
|
||||||
|
|
||||||
|
We will retry over the next few weeks. If we can't make a successful charge, your account will be downgraded from supporter to the free plan.
|
||||||
|
|
||||||
|
If you need to change the card on file, you can do so on the settings page. If you run into any issues, please contact us at https://neocities.org/contact.
|
||||||
|
|
||||||
|
Regards,
|
||||||
|
- The Neocities Team
|
11
views/templates/email/supporter_ended.erb
Normal file
11
views/templates/email/supporter_ended.erb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Hi there,
|
||||||
|
|
||||||
|
We're just emailing to let you know that your supporter plan has ended.
|
||||||
|
|
||||||
|
If you feel this is in error, please re-register for a supporter account on Neocities, or contact us at https://neocities.org/contact and we'll take a look.
|
||||||
|
|
||||||
|
We're sorry to see you go, but we understand. Thanks for helping us out (it means a lot), and our best wishes to you!
|
||||||
|
|
||||||
|
Regards,
|
||||||
|
|
||||||
|
- The Neocities Team
|
Loading…
Add table
Reference in a new issue