mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
catch stripe webhook, send confirmation
This commit is contained in:
parent
d994536017
commit
a631504232
2 changed files with 30 additions and 2 deletions
21
app.rb
21
app.rb
|
@ -708,8 +708,25 @@ post '/contact' do
|
|||
end
|
||||
|
||||
post '/stripe_webhook' do
|
||||
event_json = JSON.parse(request.body.read)
|
||||
puts event_json.inspect
|
||||
event = JSON.parse request.body.read
|
||||
if event['type'] == 'customer.created'
|
||||
username = event['data']['object']['description']
|
||||
email = event['data']['object']['email']
|
||||
plan_name = event['data']['object']['subscriptions']['object']['data'].first['plan']['name']
|
||||
|
||||
site = Site[username: username]
|
||||
halt 200, 'ok' if site.nil?
|
||||
|
||||
EmailWorker.perform_async({
|
||||
from: 'web@neocities.org',
|
||||
reply_to: site.email,
|
||||
to: 'contact@neocities.org',
|
||||
subject: "[NeoCities] You've become a supporter!",
|
||||
body: Tilt.new('./views/templates/email_subscription.erb', pretty: true).render(self)
|
||||
})
|
||||
end
|
||||
|
||||
'ok'
|
||||
end
|
||||
|
||||
post '/api/upload' do
|
||||
|
|
11
views/templates/email_subscription.erb
Normal file
11
views/templates/email_subscription.erb
Normal file
|
@ -0,0 +1,11 @@
|
|||
Hi there!
|
||||
|
||||
We just wanted to email you to confirm your supporter upgrade! You are on the <%= plan_name %> support tier. You now have <%= Site::SUPPORTER_MAXIMUM_IN_MEGABYTES %> MB of space (and we're likely to upgrade this even more soon). We're looking forward to seeing the awesome things you will do with it.
|
||||
|
||||
Thank you very, very much for supporting Neocities. It means a lot to us. It also helps us keep the free tier for others, so your support helps everyone. We'll try our hardest to keep improving the site and stick to our core values (NO MARKETING OR ADVERTISING, EVER).
|
||||
|
||||
If you have any questions or comments, or just want to say hi, feel free to contact us at https://neocities.org/contact. You can also reach us on Twitter at @neocitiesweb.
|
||||
|
||||
From Penelope (the Neocities' cat), the Neocities Team, and on behalf of all our sites, our very best wishes for you (and your awesome web site).
|
||||
|
||||
- The Neocities Team
|
Loading…
Add table
Reference in a new issue