mirror of
https://github.com/neocities/neocities.git
synced 2025-08-06 01:24:56 +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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue