Firstly, thanks for the great Stripe tutorials! I just finished implimenting basic subscriptions on my rails app. However, I do have a few questions regarding emails.
Will Stripe automatically email a receipt to the customer upon each
charge.succeeded event? Or, do I need to impliment this on my end via Webhooks?
If I need to do this via Webhooks, would I do something like the following?
class RecordCharges def call(event) ... SubscriptionMailer.charge_succeeded.deliver_now ... end end StripeEvent.configure do |events| events.subscribe 'charge.succeeded', RecordCharges.new end
Stripe has their own receipts that you can enable but they're very basic. You'll probably want to turn those off and send your own emails here.
Your code for this is exactly right. You'll want to pass in the charge / user information into the Mailer so that it has access to that to print it all out, but that's the only other thing you should really need to setup. I also added the PDF as an attachment to the email receipts for GoRails as well which has been nice. Might also consider doing that if you've got PDF receipts.
Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.