11# Razorpay Ruby bindings
22
3- [ ![ Build Status] ( https://travis-ci.org/razorpay/razorpay-ruby.svg?branch=master )] ( https://travis-ci.org/razorpay/razorpay-ruby ) [ ![ Gem Version] ( https://badge.fury .io/rb/razorpay .svg )] ( http://badge.fury.io/rb/razorpay ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/Razorpay/razorpay-ruby/badge.svg?branch=master )] ( https://coveralls.io/github/Razorpay/razorpay-ruby?branch=master ) [ ![ License] ( http://img.shields.io/:license-mit-blue.svg )] ( http://doge.mit-license.org )
3+ [ ![ Build Status] ( https://travis-ci.org/razorpay/razorpay-ruby.svg?branch=master )] ( https://travis-ci.org/razorpay/razorpay-ruby ) [ ![ Gem Version] ( https://img.shields .io/badge/gem%20version-v3.0.0-dark%20green .svg )] ( http://badge.fury.io/rb/razorpay ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/Razorpay/razorpay-ruby/badge.svg?branch=master )] ( https://coveralls.io/github/Razorpay/razorpay-ruby?branch=master ) [ ![ License] ( http://img.shields.io/:license-mit-blue.svg )] ( http://doge.mit-license.org )
44
55This is the base ruby gem for interacting with the Razorpay API. This is primarily meant for users who wish to perform interactions with the Razorpay API programatically.
66
@@ -20,6 +20,9 @@ Or install it yourself as:
2020
2121 $ gem install razorpay
2222
23+ ## Requirements
24+
25+ Ruby 2.6.8 or later
2326## Usage
2427
2528Remember to ` require 'razorpay' ` before anything else.
@@ -39,131 +42,30 @@ You can find your API keys at <https://dashboard.razorpay.com/#/app/keys>.
3942
4043If you are using rails, the right place to do this might be ` config/initializers/razorpay.rb ` .
4144
42- The most common construct is capturing a payment, which you do via the following:
43-
44- ``` rb
45- Razorpay ::Payment .fetch(" payment_id" ).capture({amount: 500 })
46- # Note that the amount should come from your session, so as to verify
47- # that the purchase was correctly done and not tampered
48- ```
49-
50- You can refund a payment via the following:
51-
52- ``` rb
53- Razorpay ::Payment .fetch(" payment_id" ).refund({amount: 500 })
54- refunds = Razorpay ::Payment .fetch(" payment_id" ).refunds
55- ```
56-
57- A payment can also be refunded without fetching it:
58- ``` rb
59- refund = Razorpay ::Refund .create(payment_id: " payment_id" )
60- Razorpay ::Refund .fetch(refund.id)
61- ```
62-
63- If payment is captured or refunded via ` capture! ` or ` refund! ` , then the calling object is also updated:
64- ``` rb
65- payment = Razorpay ::Payment .fetch(' payment_id' )
66- payment.status
67- # 'authorized'
68- payment.capture!
69- payment.status
70- # 'captured'
71- payment.refund!
72- payment.status
73- # 'refunded'
74- ```
75-
76- For other applications (such as fetching payments and refunds),
77- see our online documentation on < https://docs.razorpay.com >
78-
79- ### Orders API
80-
81- You can use the orders API using the following constructs:
82-
83- You can find docs at < https://docs.razorpay.com/v1/page/orders >
84-
85- ``` rb
86- order = Razorpay ::Order .create amount: 5000 , currency: ' INR' , receipt: ' TEST'
87- # order.id = order_50sX9hGHZJvjjI
88-
89- # Same collection as Refunds or Payments
90- orders = Razorpay ::Order .all
91-
92- # Fetching an Order
93- order = Razorpay ::Order .fetch(' order_50sX9hGHZJvjjI' )
94- puts order.amount
95-
96- # Fetching payments corresponding to an order
97- payments = order.payments
98- ```
99-
100- ### Verification
101- You can use the Utility class to verify the signature received in response to a payment made using Orders API
102- ``` rb
103- puts payment_response
104- # {
105- # :razorpay_order_id => "fake_order_id",
106- # :razorpay_payment_id => "fake_payment_id",
107- # :razorpay_signature => "signature"
108- # }
109- Razorpay ::Utility .verify_payment_signature(payment_response)
110- ```
111- You can also [ verify the signature] ( https://github.com/razorpay/razorpay-ruby/wiki/Webhooks ) received in a webhook:
112- ``` rb
113- Razorpay ::Utility .verify_webhook_signature(webhook_body, webhook_signature, webhook_secret)
114- ```
115-
116- ### Customers
117- ``` rb
118- # Create a customer
119- customer = Razorpay ::Customer .create email: ' test@razorpay.com' , contact: ' 9876543210'
120- puts customer.id # cust_6vRXClWqnLhV14
121- ```
122-
123- ### Cards
124- ``` rb
125- # Fetch a card
126- card = Razorpay ::Card .fetch(' card_7EZLhWkDt05n7V' )
127- puts card.network # VISA
128- ```
129-
130- You can find cards API documentation at < https://docs.razorpay.com/v1/page/cards > .
131-
132- ### Invoices
133- ``` rb
134- # Creating an invoice
135- invoice = Razorpay ::Invoice .create customer_id: customer.id, amount: 100 , currency: ' INR' , description: ' Test description' , type: ' link'
136- ```
137-
138- You can find invoices API documentation at < https://docs.razorpay.com/v1/page/invoices > .
139-
140- ### Plan
141- ``` rb
142- # Creating a plan
143- plan = Razorpay ::Plan .create interval: 1 , period: ' monthly' , item: { name: ' fake_plan' , description: ' fake_desc' , currency: ' INR' , amount: 500 }, notes: { identifier: ' plan_monthly_super' }
144- ```
145-
146- You can find plan API documentation at < https://razorpay.com/docs/subscriptions/api/#plan > .
147-
148- ### Subscription
149- ``` rb
150- # Creating a subscription and starting after 24 hours (24 hours = 60 * 60 * 24)
151- subscription = Razorpay ::Subscription .create plan_id: plan.id, customer_id: customer.id, start_at: (Time .now + (60 * 60 * 24 )).to_i, total_count: 3
152- ```
153-
154- You can find subscription API documentation at < https://razorpay.com/docs/subscriptions/api/#subscription > .
155-
156- ### Addon
157- ``` rb
158- # Creating an addon
159- subscription_addon = Razorpay ::Addon .create subscription.id, item: { name: ' fake_plan' , description: ' fake_desc' , currency: ' INR' , amount: 500 }, quantity: 1
160-
161- # Fetching an addon
162- addon = Razorpay ::Addon .fetch subscription_addon.id
163- ```
164-
165- You can find addon API documentation at < https://razorpay.com/docs/subscriptions/api/#add-on > .
166-
45+ ## Supported Resources
46+ - [ Customer] ( documents/customer.md )
47+ - [ Token] ( documents/tokens.md )
48+ - [ Order] ( documents/order.md )
49+ - [ Payments] ( documents/payment.md )
50+ - [ Settlements] ( documents/settlement.md )
51+ - [ Fund] ( documents/fund.md )
52+ - [ Refunds] ( documents/refund.md )
53+ - [ Invoice] ( documents/Invoice.md )
54+ - [ Plan] ( documents/plan.md )
55+ - [ Item] ( documents/items.md )
56+ - [ Subscriptions] ( documents/subscriptions.md )
57+ - [ Add-on] ( documents/addon.md )
58+ - [ Payment Links] ( documents/paymentLink.md )
59+ - [ Smart Collect] ( documents/virtualAccount.md )
60+ - [ Transfer] ( documents/transfers.md )
61+ - [ QR Code] ( documents/qrcode.md )
62+ - [ Emandate] ( documents/emandate.md )
63+ - [ Cards] ( documents/card.md )
64+ - [ Paper NACH] ( documents/papernach.md )
65+ - [ UPI] ( documents/upi.md )
66+ - [ Register Emandate and Charge First Payment Together] ( documents/registerEmandate.md )
67+ - [ Register NACH and Charge First Payment Together] ( documents/registerNach.md )
68+ - [ Payment Verification] ( documents/paymentVerification.md )
16769## Development
16870
16971- Everything is namespaced under the Razorpay module
@@ -183,19 +85,6 @@ You can find addon API documentation at <https://razorpay.com/docs/subscriptions
183855 . Push to the branch (` git push origin my-new-feature ` )
184866 . Create a new Pull Request
18587
186- ## Supported Versions
187-
188- While we support [ all currently supported versions of Ruby] ( https://www.ruby-lang.org/en/downloads/branches/ )
189- only, the code is tested against the following versions:
190-
191- * 1.9.3
192- * 2.0.0
193- * 2.1.10
194- * 2.3.8
195- * 2.4.6
196- * 2.5.5
197- * 2.6.2
198-
19988## Release
20089
20190Steps to follow for a release:
0 commit comments