All threads / Email Stripe Receipts

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Email Stripe Receipts

Steve Polito asked in Rails

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

Hey Steve!

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 the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,665+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.