mirror of
https://github.com/neocities/neocities.git
synced 2025-07-25 20:08:27 +02:00
Email invoice support
This commit is contained in:
parent
ea760fc849
commit
68352e3d8f
3 changed files with 37 additions and 1 deletions
|
@ -102,6 +102,29 @@ post '/webhooks/stripe' do
|
|||
})
|
||||
end
|
||||
|
||||
if event['type'] == 'invoice.payment_succeeded'
|
||||
site = stripe_get_site_from_event event
|
||||
|
||||
if site.email_invoice && site.stripe_paying_supporter?
|
||||
invoice_obj = event['data']['object']
|
||||
|
||||
EmailWorker.perform_async({
|
||||
from: 'web@neocities.org',
|
||||
to: site.email,
|
||||
subject: "[Neocities] Invoice",
|
||||
body: Tilt.new('./views/templates/email/invoice.erb', pretty: true).render(
|
||||
self,
|
||||
site: site,
|
||||
amount: invoice_obj['amount_due'],
|
||||
period_start: Time.at(invoice_obj['period_start']),
|
||||
period_end: Time.at(invoice_obj['period_end']),
|
||||
date: Time.at(invoice_obj['date'])
|
||||
)
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
'ok'
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue