Latest commit 7e15ce1 Dec 26, 2016 @akshaybhalotia akshaybhalotia committed on GitHub Merge pull request #17 from razorpay/changelog-patch
Failed to load latest commit information.
.gitignore Initial commit Jan 17, 2015
.simplecov Initial commit Jan 17, 2015
.travis.yml [release] Version bump Nov 23, 2016
LICENSE.txt [docs] Adds documentation for customer/invoice creation Dec 22, 2016
razorpay-ruby.gemspec [ci] Drops bundler from dependencies Feb 25, 2016

Razorpay Ruby bindings

Build Status Gem Version License

This is the base ruby gem for interacting with the Razorpay API. This is primarily meant for merchants who wish to perform interactions with the Razorpay API programatically.


Add this line to your application's Gemfile:

gem 'razorpay'

And then execute:

$ bundle

Or install it yourself as:

$ gem install razorpay


Remember to require razorpay before anything else.

Next, you need to setup your key and secret using the following:

Razorpay.setup("merchant_key_id", "merchant_key_secret")

You can find your API keys at

If you are using rails, the right place to do this might be config/initializers/razorpay.rb.

The most common construct is capturing a payment, which you do via the following:

# Note that the amount should come from your session, so as to verify
# that the purchase was correctly done and not tampered

You can handle refunds using the following constructs:


For other applications (such as fetching payments and refunds), see our online documentation on

Orders API

You can use the orders API using the following constructs:

You can find docs at

order = Razorpay::Order.create amount: 5000, currency: 'INR', receipt: 'TEST'
# = order_50sX9hGHZJvjjI

# Same collection as Refunds or Payments
orders = Razorpay::Order.all

# Fetching an Order
order = Razorpay::Order.fetch('order_50sX9hGHZJvjjI')
puts order.amount

# Fetching payments corresponding to an order
payments = order.payments

# Create a customer
customer = Razorpay::Customer.create email: '', contact: '9876543210'
puts #cust_6vRXClWqnLhV14

# Creating an invoice
invoice = Razorpay::Invoice.create customer_id:, amount: 100, currency: 'INR', description: 'Test description', type: 'link'

You can find invoices API documentation at


  • Everything is namespaced under the Razorpay module
  • We use rubocop for checking style guidelines
  • Rake + MiniTest is using as the testrunner
  • Webmock is used as the request mock framework
  • HTTParty is used for making requests
  • Travis is used for CI
  • Coveralls is used for coverage reports


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Run rake and rubocop after making your changes to make sure you didn't break anything
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request