Pay is a community-maintained payments engine for Ruby on Rails 6.0 and later. It abstracts over Paddle Billing, Stripe, Braintree, and Lemon Squeezy with a single API for customers, subscriptions, charges, and webhooks.
The pay gem is maintained by the pay-rails community, not by Paddle. For support, use the Pay issue tracker.
View source code and report issues on GitHub.
View and install on RubyGems.
See recent releases and changes.
Requirements
- Ruby.
- Rails 7.0 or later.
Install
Add Pay to your Gemfile:
gem "pay", "~> 11.5"gem "paddle", "~> 2.9"Run bundle install and follow the installation guide to generate migrations and configure your User model.
Configure
Pay reads Paddle credentials from environment variables, or the equivalent Rails credentials:
| Variable | Purpose |
|---|---|
PADDLE_BILLING_ENVIRONMENT | sandbox or production. Defaults to production. |
PADDLE_BILLING_API_KEY | API key from Paddle > Developer tools > Authentication. |
PADDLE_BILLING_CLIENT_TOKEN | Client-side token for Paddle.js, created in the same place. |
PADDLE_BILLING_SIGNING_SECRET | Notification destination secret key, used to verify webhook signatures. |
Quick example
Create a Paddle customer for a Pay-enabled model:
user.set_payment_processor :paddle_billinguser.payment_processor.api_recordSubscriptions are created using webhooks. When Paddle sends a subscription.created notification, Pay creates the subscription record automatically. See the subscriptions guide for more.