Stripe Integration with Rails: Pay Gem Tips and Fixes
Update 2024-05-19
I extracted the Pay integration from httpscout.io and packaged it into a Rails app that is available on github.
Default URL Options
I didn’t find a reference to this in the docs. And if not configured the integration will error our with a reasonable error message. But, if you’re new to rails, it may not be so obvious. The integration requires that Rails.application.routes.default_url_options is set and available. I choose to set the value in both config/environments/development.rb and config/environments/production.rb, and used include Rails.application.routes.url_helpers in the class where I generate the checkout url.
Disable Telemetry
By default, the Stripe Ruby gem sends telemetry to Stripe. Disable telemetry if you’re in a resource-starved environment. While configuring Stripe, also set Stripe.api_version—it’s important to be aware of the API version you’re using.
Stripe Webhooks
When you are configuring a webhook endpoint in Stripe, you will be asked to select the events for which you want to receive webhooks. While you can choose to subscribe to all events, if you have limited resources, it is best to only subscribe to the events that you actually need. A list of the events that the Pay gem expects is available in this gist.