razorpay 2.4.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +8 -0
  3. data/.github/workflows/ruby.yml +38 -0
  4. data/CHANGELOG.md +19 -0
  5. data/README.md +29 -140
  6. data/documents/Invoice.md +531 -0
  7. data/documents/addon.md +169 -0
  8. data/documents/card.md +611 -0
  9. data/documents/customer.md +161 -0
  10. data/documents/emandate.md +484 -0
  11. data/documents/fund.md +87 -0
  12. data/documents/items.md +184 -0
  13. data/documents/order.md +230 -0
  14. data/documents/papernach.md +718 -0
  15. data/documents/payment.md +636 -0
  16. data/documents/paymentLink.md +1045 -0
  17. data/documents/paymentVerification.md +79 -0
  18. data/documents/plan.md +184 -0
  19. data/documents/qrcode.md +441 -0
  20. data/documents/refund.md +324 -0
  21. data/documents/registerEmandate.md +445 -0
  22. data/documents/registerNach.md +661 -0
  23. data/documents/settlement.md +477 -0
  24. data/documents/subscriptions.md +750 -0
  25. data/documents/tokens.md +208 -0
  26. data/documents/transfers.md +684 -0
  27. data/documents/upi.md +548 -0
  28. data/documents/virtualAccount.md +586 -0
  29. data/lib/razorpay/addon.rb +4 -0
  30. data/lib/razorpay/constants.rb +1 -1
  31. data/lib/razorpay/customer.rb +15 -0
  32. data/lib/razorpay/fund_account.rb +19 -0
  33. data/lib/razorpay/invoice.rb +8 -0
  34. data/lib/razorpay/item.rb +34 -0
  35. data/lib/razorpay/order.rb +10 -0
  36. data/lib/razorpay/payment.rb +52 -0
  37. data/lib/razorpay/payment_link.rb +36 -0
  38. data/lib/razorpay/qr_code.rb +34 -0
  39. data/lib/razorpay/refund.rb +4 -0
  40. data/lib/razorpay/request.rb +13 -6
  41. data/lib/razorpay/settlement.rb +39 -0
  42. data/lib/razorpay/subscription.rb +24 -0
  43. data/lib/razorpay/subscription_registration.rb +16 -0
  44. data/lib/razorpay/transfer.rb +35 -0
  45. data/lib/razorpay/utility.rb +7 -2
  46. data/lib/razorpay/virtual_account.rb +14 -6
  47. data/lib/razorpay.rb +7 -0
  48. data/test/fixtures/addon_collection.json +60 -0
  49. data/test/fixtures/create_json_payment.json +13 -0
  50. data/test/fixtures/delete_token.json +3 -0
  51. data/test/fixtures/downtimes_collection.json +21 -0
  52. data/test/fixtures/empty.json +2 -0
  53. data/test/fixtures/fake_addon.json +3 -3
  54. data/test/fixtures/fake_direct_transfer.json +32 -0
  55. data/test/fixtures/fake_downtime.json +14 -0
  56. data/test/fixtures/fake_fund_account.json +18 -0
  57. data/test/fixtures/fake_instant_settlement.json +19 -0
  58. data/test/fixtures/fake_item.json +9 -0
  59. data/test/fixtures/fake_order_transfers.json +88 -0
  60. data/test/fixtures/fake_otp_generate.json +19 -0
  61. data/test/fixtures/fake_otp_resend.json +7 -0
  62. data/test/fixtures/fake_otp_submit.json +5 -0
  63. data/test/fixtures/fake_payment_link.json +40 -0
  64. data/test/fixtures/fake_pending_update.json +30 -0
  65. data/test/fixtures/fake_qrcode.json +20 -0
  66. data/test/fixtures/fake_qrcode_close.json +22 -0
  67. data/test/fixtures/fake_recurring.json +5 -0
  68. data/test/fixtures/fake_refund.json +1 -1
  69. data/test/fixtures/fake_settlement.json +11 -0
  70. data/test/fixtures/fake_settlement_on_demand.json +39 -0
  71. data/test/fixtures/fake_subscription_pause.json +19 -0
  72. data/test/fixtures/fake_subscription_registration.json +91 -0
  73. data/test/fixtures/fake_subscription_resume.json +19 -0
  74. data/test/fixtures/fake_token.json +31 -0
  75. data/test/fixtures/fake_transfer.json +18 -0
  76. data/test/fixtures/fake_transfer_reverse.json +15 -0
  77. data/test/fixtures/fake_update_payment.json +39 -0
  78. data/test/fixtures/fake_virtual_account_allowed.json +46 -0
  79. data/test/fixtures/fake_virtual_account_receiver.json +46 -0
  80. data/test/fixtures/fund_collection.json +20 -0
  81. data/test/fixtures/item_collection.json +24 -0
  82. data/test/fixtures/payment_collection.json +1 -1
  83. data/test/fixtures/payment_link_collection.json +43 -0
  84. data/test/fixtures/payment_link_response.json +3 -0
  85. data/test/fixtures/qrcode_collection.json +50 -0
  86. data/test/fixtures/qrcode_payments_collection.json +74 -0
  87. data/test/fixtures/settlement_collection.json +26 -0
  88. data/test/fixtures/settlement_instant_collection.json +84 -0
  89. data/test/fixtures/settlement_report_collection.json +117 -0
  90. data/test/fixtures/success.json +3 -0
  91. data/test/fixtures/tokens_collection.json +36 -0
  92. data/test/fixtures/transfer_settlements_collection.json +38 -0
  93. data/test/fixtures/transfers_collection.json +41 -0
  94. data/test/razorpay/test_addon.rb +15 -15
  95. data/test/razorpay/test_customer.rb +27 -3
  96. data/test/razorpay/test_fund_account.rb +42 -0
  97. data/test/razorpay/test_invoice.rb +15 -2
  98. data/test/razorpay/test_item.rb +66 -0
  99. data/test/razorpay/test_order.rb +24 -1
  100. data/test/razorpay/test_payment.rb +184 -8
  101. data/test/razorpay/test_payment_link.rb +83 -0
  102. data/test/razorpay/test_plan.rb +2 -2
  103. data/test/razorpay/test_qr_code.rb +63 -0
  104. data/test/razorpay/test_refund.rb +16 -2
  105. data/test/razorpay/test_settlement.rb +76 -0
  106. data/test/razorpay/test_subscription.rb +72 -9
  107. data/test/razorpay/test_subscription_registration.rb +58 -0
  108. data/test/razorpay/test_transfer.rb +77 -0
  109. data/test/razorpay/test_utility.rb +32 -0
  110. data/test/razorpay/test_virtual_account.rb +64 -17
  111. data/test/test_helper.rb +6 -0
  112. metadata +138 -9
  113. data/.travis.yml +0 -22
  114. data/test/razorpay/test_errors.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bfaf6eed8197ba96d0e861fc499da1b7bf502602330f005d32edda91971fcb6
4
- data.tar.gz: 59e845994a4d2865e3832709d5aa6afc7bbc038f4655033e5e445843f1bad13d
3
+ metadata.gz: 16358451a0774ffe1eee29516c7a196315c9b224169fb28aa0faa07664041e14
4
+ data.tar.gz: 841f735f70da6e8b54b8d0370005ddbdad26ee393960133eb08505869dd04d6f
5
5
  SHA512:
6
- metadata.gz: 35657de03884f8dd1fd50e038f318586ac8520653c9f75bb66dae4363c1a558122362a21f0f843cb1d7d685612c4a47c9c465bb5485e43b4a2fe4b6dd5dd84ea
7
- data.tar.gz: d753fdf647555ac0084b4341e6e27a9bf998b9b9d32e2e6ffab9976fa1ab51b79c11653ad6ef36d8ea7f4afa53ccfaa64f47878e15fb95966d9d2a3e56309ba4
6
+ metadata.gz: ffd3b0c1f38c5debb4a6b8a15fdfa00df1ca7b5f3f7d72b1d64227681923ec7307ae39d0e060346660c3270e143bbf7ac88185e664331390a52e7103a53a868e
7
+ data.tar.gz: e6048a8c9abfb4169d1f5e69203d9abb5824c13b8655a85cc53648497cfb38103887073562f3188297b8437fd6a823219456cfd72db67876e50f8409e06888ea
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "04:00"
8
+ timezone: Asia/Calcutta
@@ -0,0 +1,38 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby-version: ['2.6', '2.7', '3.0']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - name: Set up Ruby
30
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
+ # uses: ruby/setup-ruby@v1
33
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
34
+ with:
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
+ - name: Run tests
38
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ Changelog for Razorpay-Ruby SDK.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## [3.0.0] - 2022-06-03
8
+
9
+ ### Added
10
+
11
+ - QR code end point API
12
+ - Settlement end point API
13
+ - Fund Account end point API
14
+ - PaymentLinks end point API
15
+ - Item end point API
16
+ - New APIs for Invoices (Delete, Send/resend)
17
+ - New API for Customers (Fetch Tokens, Delete Token)
18
+ - New APIs for Subscriptions (Update, Pause, Resume, Pending update, Delete offer)
19
+ - New API for Addons (Fetch all Addons)
20
+ - New API for Refund (Update refund)
21
+ - New APIs for Payments (Update, Create recurring, Create Json, Payment downtime details, refunds of a payment, Otp generate, Otp submit, Otp resend)
22
+ - New APIs for Virtual Account (Add receiver, add an allowed payer account, delete an allowed payer account)
23
+ - Updated Testcases
24
+ - Updated Readme
25
+
7
26
  ## [2.4.1] - 2019-04-09
8
27
 
9
28
  ### Fixed
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Razorpay Ruby bindings
2
2
 
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)
4
4
 
5
5
  This 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.
6
6
 
@@ -20,9 +20,12 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install razorpay
22
22
 
23
+ ## Requirements
24
+
25
+ Ruby 2.6.8 or later
23
26
  ## Usage
24
27
 
25
- Remember to `require razorpay` before anything else.
28
+ Remember to `require 'razorpay'` before anything else.
26
29
 
27
30
  Next, you need to setup your key and secret using the following:
28
31
 
@@ -39,131 +42,30 @@ You can find your API keys at <https://dashboard.razorpay.com/#/app/keys>.
39
42
 
40
43
  If you are using rails, the right place to do this might be `config/initializers/razorpay.rb`.
41
44
 
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)
167
69
  ## Development
168
70
 
169
71
  - Everything is namespaced under the Razorpay module
@@ -183,19 +85,6 @@ You can find addon API documentation at <https://razorpay.com/docs/subscriptions
183
85
  5. Push to the branch (`git push origin my-new-feature`)
184
86
  6. Create a new Pull Request
185
87
 
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
-
199
88
  ## Release
200
89
 
201
90
  Steps to follow for a release: