send email for new customers, closes #103

This commit is contained in:
Kyle Drake 2015-03-13 09:58:10 -05:00
parent 0f958023d0
commit 4e0ff8a7ca

View file

@ -1,8 +1,15 @@
post '/stripe_webhook' do
event = JSON.parse request.body.read
if event['type'] == 'customer.created'
username = event['data']['object']['description']
username = event['data']['object']['description'].split(' - ').first
email = event['data']['object']['email']
EmailWorker.perform_async({
from: 'web@neocities.org',
to: 'contact@neocities.org',
subject: "[Neocities] New customer: #{username}",
body: "#{username}\n#{email}\n#{Site[username: username].uri}"
})
end
'ok'
end