razorpay 2.4.0 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/.cursorignore +174 -0
  3. data/.github/dependabot.yml +8 -0
  4. data/.github/pull_request_template.md +8 -0
  5. data/.github/workflows/ci.yml +80 -0
  6. data/.github/workflows/ruby.yml +38 -0
  7. data/CHANGELOG.md +85 -1
  8. data/README.md +48 -137
  9. data/documents/Invoice.md +539 -0
  10. data/documents/account.md +449 -0
  11. data/documents/addon.md +191 -0
  12. data/documents/card.md +655 -0
  13. data/documents/customer.md +405 -0
  14. data/documents/dispute.md +301 -0
  15. data/documents/documents.md +65 -0
  16. data/documents/emandate.md +492 -0
  17. data/documents/fund.md +89 -0
  18. data/documents/items.md +208 -0
  19. data/documents/oauth_token.md +142 -0
  20. data/documents/order.md +352 -0
  21. data/documents/papernach.md +738 -0
  22. data/documents/payment.md +1122 -0
  23. data/documents/paymentLink.md +1063 -0
  24. data/documents/paymentVerification.md +79 -0
  25. data/documents/plan.md +184 -0
  26. data/documents/productConfiguration.md +444 -0
  27. data/documents/qrcode.md +439 -0
  28. data/documents/refund.md +325 -0
  29. data/documents/registerEmandate.md +452 -0
  30. data/documents/registerNach.md +653 -0
  31. data/documents/settlement.md +478 -0
  32. data/documents/stakeholder.md +334 -0
  33. data/documents/subscriptions.md +752 -0
  34. data/documents/tokens.md +407 -0
  35. data/documents/transfers.md +821 -0
  36. data/documents/upi.md +545 -0
  37. data/documents/virtualAccount.md +591 -0
  38. data/documents/webhook.md +224 -0
  39. data/lib/razorpay/account.rb +39 -0
  40. data/lib/razorpay/addon.rb +9 -1
  41. data/lib/razorpay/card.rb +4 -0
  42. data/lib/razorpay/constants.rb +7 -2
  43. data/lib/razorpay/customer.rb +31 -0
  44. data/lib/razorpay/dispute.rb +26 -0
  45. data/lib/razorpay/document.rb +19 -0
  46. data/lib/razorpay/fund_account.rb +19 -0
  47. data/lib/razorpay/iin.rb +15 -0
  48. data/lib/razorpay/invoice.rb +8 -0
  49. data/lib/razorpay/item.rb +34 -0
  50. data/lib/razorpay/oauth_token.rb +109 -0
  51. data/lib/razorpay/order.rb +19 -1
  52. data/lib/razorpay/payload_validator.rb +93 -0
  53. data/lib/razorpay/payment.rb +64 -0
  54. data/lib/razorpay/payment_link.rb +36 -0
  55. data/lib/razorpay/payment_method.rb +17 -0
  56. data/lib/razorpay/product.rb +37 -0
  57. data/lib/razorpay/qr_code.rb +34 -0
  58. data/lib/razorpay/refund.rb +4 -0
  59. data/lib/razorpay/request.rb +50 -26
  60. data/lib/razorpay/settlement.rb +39 -0
  61. data/lib/razorpay/stakeholder.rb +39 -0
  62. data/lib/razorpay/subscription.rb +24 -0
  63. data/lib/razorpay/subscription_registration.rb +16 -0
  64. data/lib/razorpay/token.rb +28 -0
  65. data/lib/razorpay/transfer.rb +39 -0
  66. data/lib/razorpay/utility.rb +41 -6
  67. data/lib/razorpay/validation_config.rb +11 -0
  68. data/lib/razorpay/virtual_account.rb +15 -7
  69. data/lib/razorpay/webhook.rb +50 -0
  70. data/lib/razorpay.rb +24 -1
  71. data/razorpay-ruby.gemspec +2 -1
  72. data/test/fixtures/addon_collection.json +60 -0
  73. data/test/fixtures/create_json_payment.json +13 -0
  74. data/test/fixtures/delete_token.json +3 -0
  75. data/test/fixtures/dispute_collection.json +67 -0
  76. data/test/fixtures/dispute_error.json +10 -0
  77. data/test/fixtures/document_error.json +10 -0
  78. data/test/fixtures/downtimes_collection.json +21 -0
  79. data/test/fixtures/empty.json +2 -0
  80. data/test/fixtures/error_customer.json +10 -0
  81. data/test/fixtures/error_eligibility.json +10 -0
  82. data/test/fixtures/error_eligibility_check.json +10 -0
  83. data/test/fixtures/fake_account.json +78 -0
  84. data/test/fixtures/fake_addon.json +3 -3
  85. data/test/fixtures/fake_bank_account.json +9 -0
  86. data/test/fixtures/fake_card_reference.json +5 -0
  87. data/test/fixtures/fake_create_upi_payment.json +3 -0
  88. data/test/fixtures/fake_direct_transfer.json +32 -0
  89. data/test/fixtures/fake_dispute.json +29 -0
  90. data/test/fixtures/fake_document.json +9 -0
  91. data/test/fixtures/fake_downtime.json +14 -0
  92. data/test/fixtures/fake_eligiblity.json +79 -0
  93. data/test/fixtures/fake_fulfillment.json +10 -0
  94. data/test/fixtures/fake_fund_account.json +18 -0
  95. data/test/fixtures/fake_iin_token.json +23 -0
  96. data/test/fixtures/fake_instant_settlement.json +19 -0
  97. data/test/fixtures/fake_item.json +9 -0
  98. data/test/fixtures/fake_oauth_token.json +8 -0
  99. data/test/fixtures/fake_order_transfers.json +88 -0
  100. data/test/fixtures/fake_otp_generate.json +19 -0
  101. data/test/fixtures/fake_otp_resend.json +7 -0
  102. data/test/fixtures/fake_otp_submit.json +5 -0
  103. data/test/fixtures/fake_payment_expanded_details.json +38 -0
  104. data/test/fixtures/fake_payment_expanded_details_card.json +50 -0
  105. data/test/fixtures/fake_payment_link.json +40 -0
  106. data/test/fixtures/fake_pending_update.json +30 -0
  107. data/test/fixtures/fake_product.json +138 -0
  108. data/test/fixtures/fake_qrcode.json +20 -0
  109. data/test/fixtures/fake_qrcode_close.json +22 -0
  110. data/test/fixtures/fake_recurring.json +5 -0
  111. data/test/fixtures/fake_refund.json +1 -1
  112. data/test/fixtures/fake_revoke_token.json +3 -0
  113. data/test/fixtures/fake_rto.json +15 -0
  114. data/test/fixtures/fake_settlement.json +11 -0
  115. data/test/fixtures/fake_settlement_on_demand.json +39 -0
  116. data/test/fixtures/fake_stakeholder.json +29 -0
  117. data/test/fixtures/fake_subscription_pause.json +19 -0
  118. data/test/fixtures/fake_subscription_registration.json +91 -0
  119. data/test/fixtures/fake_subscription_resume.json +19 -0
  120. data/test/fixtures/fake_token.json +31 -0
  121. data/test/fixtures/fake_tokenise_customer.json +40 -0
  122. data/test/fixtures/fake_transfer.json +18 -0
  123. data/test/fixtures/fake_transfer_reverse.json +15 -0
  124. data/test/fixtures/fake_update_payment.json +39 -0
  125. data/test/fixtures/fake_validate_vpa.json +5 -0
  126. data/test/fixtures/fake_virtual_account_allowed.json +46 -0
  127. data/test/fixtures/fake_virtual_account_receiver.json +46 -0
  128. data/test/fixtures/fake_webhook.json +79 -0
  129. data/test/fixtures/fake_webhook_by_account_id.json +22 -0
  130. data/test/fixtures/fetch_tnc.json +11 -0
  131. data/test/fixtures/fund_collection.json +20 -0
  132. data/test/fixtures/item_collection.json +24 -0
  133. data/test/fixtures/order_error.json +10 -0
  134. data/test/fixtures/payment_collection.json +1 -1
  135. data/test/fixtures/payment_error.json +10 -0
  136. data/test/fixtures/payment_link_collection.json +43 -0
  137. data/test/fixtures/payment_link_response.json +3 -0
  138. data/test/fixtures/payment_methods_collection.json +149 -0
  139. data/test/fixtures/qrcode_collection.json +50 -0
  140. data/test/fixtures/qrcode_payments_collection.json +74 -0
  141. data/test/fixtures/reversals_collection.json +22 -0
  142. data/test/fixtures/settlement_collection.json +26 -0
  143. data/test/fixtures/settlement_instant_collection.json +84 -0
  144. data/test/fixtures/settlement_report_collection.json +117 -0
  145. data/test/fixtures/stakeholder_collection.json +35 -0
  146. data/test/fixtures/success.json +3 -0
  147. data/test/fixtures/tokens_collection.json +36 -0
  148. data/test/fixtures/transfer_error.json +10 -0
  149. data/test/fixtures/transfer_settlements_collection.json +38 -0
  150. data/test/fixtures/transfers_collection.json +41 -0
  151. data/test/fixtures/webhook_by_account_collection.json +35 -0
  152. data/test/fixtures/webhook_collection.json +85 -0
  153. data/test/razorpay/test_account.rb +134 -0
  154. data/test/razorpay/test_addon.rb +19 -15
  155. data/test/razorpay/test_card.rb +6 -0
  156. data/test/razorpay/test_customer.rb +132 -3
  157. data/test/razorpay/test_dispute.rb +98 -0
  158. data/test/razorpay/test_document.rb +27 -0
  159. data/test/razorpay/test_fund_account.rb +42 -0
  160. data/test/razorpay/test_iin.rb +23 -0
  161. data/test/razorpay/test_invoice.rb +15 -2
  162. data/test/razorpay/test_item.rb +66 -0
  163. data/test/razorpay/test_oauth_token.rb +105 -0
  164. data/test/razorpay/test_order.rb +66 -1
  165. data/test/razorpay/test_payload_validator.rb +61 -0
  166. data/test/razorpay/test_payment.rb +251 -9
  167. data/test/razorpay/test_payment_link.rb +83 -0
  168. data/test/razorpay/test_plan.rb +2 -2
  169. data/test/razorpay/test_product.rb +67 -0
  170. data/test/razorpay/test_qr_code.rb +63 -0
  171. data/test/razorpay/test_razorpay.rb +19 -2
  172. data/test/razorpay/test_refund.rb +16 -2
  173. data/test/razorpay/test_settlement.rb +76 -0
  174. data/test/razorpay/test_stakeholder.rb +87 -0
  175. data/test/razorpay/test_subscription.rb +72 -9
  176. data/test/razorpay/test_subscription_registration.rb +58 -0
  177. data/test/razorpay/test_token.rb +66 -0
  178. data/test/razorpay/test_transfer.rb +94 -0
  179. data/test/razorpay/test_utility.rb +72 -4
  180. data/test/razorpay/test_virtual_account.rb +64 -17
  181. data/test/razorpay/test_webhook.rb +132 -0
  182. data/test/test_helper.rb +8 -0
  183. metadata +265 -10
  184. data/.travis.yml +0 -22
  185. data/test/razorpay/test_errors.rb +0 -19
@@ -0,0 +1,325 @@
1
+ ## Refunds
2
+
3
+ ```rb
4
+ require "razorpay"
5
+
6
+ Razorpay.setup('key_id', 'key_secret')
7
+ ```
8
+
9
+ ### Create a normal refund
10
+
11
+ ```rb
12
+ paymentId = "pay_Ir1SV9FgF8pxxG"
13
+
14
+ para_attr = {
15
+ "amount": "100",
16
+ "speed": "normal",
17
+ "notes": {
18
+ "notes_key_1": "Beam me up Scotty.",
19
+ "notes_key_2": "Engage"
20
+ },
21
+ "receipt": "Receipt No. 31"
22
+ }
23
+
24
+ Razorpay::Payment.fetch(paymentId).refund(para_attr)
25
+ ```
26
+
27
+ **Parameters:**
28
+
29
+ | Name | Type | Description |
30
+ |---------------|-------------|---------------------------------------------|
31
+ | paymentId* | string | The id of the payment |
32
+ | amount | integer | The amount to be captured (should be equal to the authorized amount, in paise) | |
33
+ | speed | string | Here, it must be normal |
34
+ | notes | object | A key-value pair |
35
+ | receipt | string | A unique identifier provided by you for your internal reference. |
36
+
37
+ **Response:**
38
+ ```json
39
+ {
40
+ "id": "rfnd_FP8QHiV938haTz",
41
+ "entity": "refund",
42
+ "amount": 500100,
43
+ "receipt": "Receipt No. 31",
44
+ "currency": "INR",
45
+ "payment_id": "pay_FCXKPFtYfPXJPy",
46
+ "notes": [],
47
+ "acquirer_data": {
48
+ "arn": null
49
+ },
50
+ "created_at": 1597078866,
51
+ "batch_id": null,
52
+ "status": "processed",
53
+ "speed_processed": "normal",
54
+ "speed_requested": "normal"
55
+ }
56
+ ```
57
+ -------------------------------------------------------------------------------------------------------
58
+
59
+ ### Create an instant refund
60
+
61
+ ```rb
62
+ paymentId = "pay_Ir1SV9FgF8pxxG"
63
+
64
+ para_attr = {
65
+ "amount": "100",
66
+ "speed": "optimum",
67
+ "receipt": "Receipt No. 31"
68
+ }
69
+ Razorpay::Payment.fetch(paymentId).refund(para_attr)
70
+ ```
71
+
72
+ **Parameters:**
73
+
74
+ | Name | Type | Description |
75
+ |---------------|-------------|---------------------------------------------|
76
+ | paymentId* | string | The id of the payment |
77
+ | amount | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
78
+ | speed* | string | Here, it must be optimum |
79
+ | receipt | string | A unique identifier provided by you for your internal reference. |
80
+
81
+ **Response:**
82
+ ```json
83
+ {
84
+ "id": "rfnd_FP8R8EGjGbPkVb",
85
+ "entity": "refund",
86
+ "amount": 500100,
87
+ "currency": "INR",
88
+ "payment_id": "pay_FC8MmhMBZPKDHF",
89
+ "notes": {
90
+ "notes_key_1": "Tea, Earl Grey, Hot",
91
+ "notes_key_2": "Tea, Earl Grey… decaf."
92
+ },
93
+ "receipt": "Receipt No. 31",
94
+ "acquirer_data": {
95
+ "arn": null
96
+ },
97
+ "created_at": 1597078914,
98
+ "batch_id": null,
99
+ "status": "processed",
100
+ "speed_requested": "optimum"
101
+ }
102
+ ```
103
+ -------------------------------------------------------------------------------------------------------
104
+
105
+ ### Fetch multiple refunds for a payment
106
+
107
+ ```rb
108
+ paymentId = "pay_FIKOnlyii5QGNx"
109
+
110
+ option = {"count":1}
111
+
112
+ Razorpay::Payment.fetch_multiple_refund(paymentId,option)
113
+ ```
114
+
115
+ **Parameters:**
116
+
117
+ | Name | Type | Description |
118
+ |-------|-----------|--------------------------------------------------|
119
+ | paymentId* | string | The id of the payment for which refund has been requested. |
120
+ | from | timestamp | UNIX timestamp at which the refunds were created. |
121
+ | to | timestamp | UNIX timestamp till which the refunds were created. |
122
+ | count | integer | The number of refunds to fetch for the payment. |
123
+ | skip | integer | The number of refunds to be skipped for the payment. |
124
+
125
+ **Refund:**
126
+ ```json
127
+ {
128
+ "entity": "collection",
129
+ "count": 1,
130
+ "items": [
131
+ {
132
+ "id": "rfnd_FP8DDKxqJif6ca",
133
+ "entity": "refund",
134
+ "amount": 300100,
135
+ "currency": "INR",
136
+ "payment_id": "pay_FIKOnlyii5QGNx",
137
+ "notes": {
138
+ "comment": "Comment for refund"
139
+ },
140
+ "receipt": null,
141
+ "acquirer_data": {
142
+ "arn": "10000000000000"
143
+ },
144
+ "created_at": 1597078124,
145
+ "batch_id": null,
146
+ "status": "processed",
147
+ "speed_processed": "normal",
148
+ "speed_requested": "optimum"
149
+ }
150
+ ]
151
+ }
152
+ ```
153
+ -------------------------------------------------------------------------------------------------------
154
+
155
+ ### Fetch a specific refund for a payment
156
+ ```rb
157
+ paymentId = "pay_FIKOnlyii5QGNx"
158
+
159
+ refundId = "rfnd_FP8DDKxqJif6ca"
160
+
161
+ Razorpay::Payment.fetch(paymentId).fetch_refund(refundId)
162
+ ```
163
+
164
+ **Parameters:**
165
+
166
+ | Name | Type | Description |
167
+ |---------------|-------------|---------------------------------------------|
168
+ | paymentId* | string | Unique identifier of the payment for which the refund has been made.|
169
+ | refundId* | string | Unique identifier of the refund to be retrieved. |
170
+
171
+ **Response:**
172
+ ```json
173
+ {
174
+ "id": "rfnd_FP8DDKxqJif6ca",
175
+ "entity": "refund",
176
+ "amount": 300100,
177
+ "currency": "INR",
178
+ "payment_id": "pay_FIKOnlyii5QGNx",
179
+ "notes": {
180
+ "comment": "Comment for refund"
181
+ },
182
+ "receipt": null,
183
+ "acquirer_data": {
184
+ "arn": "10000000000000"
185
+ },
186
+ "created_at": 1597078124,
187
+ "batch_id": null,
188
+ "status": "processed",
189
+ "speed_processed": "normal",
190
+ "speed_requested": "optimum"
191
+ }
192
+ ```
193
+ -------------------------------------------------------------------------------------------------------
194
+
195
+ ### Fetch all refunds
196
+ ```rb
197
+ options = {"count":1}
198
+
199
+ Razorpay::Refund.all(options)
200
+ ```
201
+
202
+ **Parameters:**
203
+
204
+ | Name | Type | Description |
205
+ |-------|-----------|--------------------------------------------------|
206
+ | from | timestamp | timestamp after which the payments were created |
207
+ | to | timestamp | timestamp before which the payments were created |
208
+ | count | integer | number of payments to fetch (default: 10) |
209
+ | skip | integer | number of payments to be skipped (default: 0) |
210
+
211
+ **Response:**
212
+ ```json
213
+ {
214
+ "entity": "collection",
215
+ "count": 2,
216
+ "items": [
217
+ {
218
+ "id": "rfnd_FFX6AnnIN3puqW",
219
+ "entity": "refund",
220
+ "amount": 88800,
221
+ "currency": "INR",
222
+ "payment_id": "pay_FFX5FdEYx8jPwA",
223
+ "notes": {
224
+ "comment": "Issuing an instant refund"
225
+ },
226
+ "receipt": null,
227
+ "acquirer_data": {},
228
+ "created_at": 1594982363,
229
+ "batch_id": null,
230
+ "status": "processed",
231
+ "speed_processed": "optimum",
232
+ "speed_requested": "optimum"
233
+ }
234
+ ]
235
+ }
236
+ ```
237
+ -------------------------------------------------------------------------------------------------------
238
+
239
+ ### Fetch particular refund
240
+ ```rb
241
+ refundId = "rfnd_FFX6AnnIN3puqW"
242
+
243
+ Razorpay::Refund.fetch(refundId)
244
+ ```
245
+
246
+ **Parameters:**
247
+
248
+ | Name | Type | Description |
249
+ |---------------|-------------|---------------------------------------------|
250
+ | refundId* | string | The id of the refund to be fetched |
251
+
252
+ **Response:**
253
+ ```json
254
+ {
255
+ "id": "rfnd_EqWThTE7dd7utf",
256
+ "entity": "refund",
257
+ "amount": 6000,
258
+ "currency": "INR",
259
+ "payment_id": "pay_EpkFDYRirena0f",
260
+ "notes": {
261
+ "comment": "Issuing an instant refund"
262
+ },
263
+ "receipt": null,
264
+ "acquirer_data": {
265
+ "arn": "10000000000000"
266
+ },
267
+ "created_at": 1589521675,
268
+ "batch_id": null,
269
+ "status": "processed",
270
+ "speed_processed": "optimum",
271
+ "speed_requested": "optimum"
272
+ }
273
+ ```
274
+ -------------------------------------------------------------------------------------------------------
275
+
276
+ ### Update the refund
277
+ ```rb
278
+ refundId = "rfnd_FP8DDKxqJif6ca"
279
+
280
+ para_attr = {
281
+ "notes": {
282
+ "notes_key_1": "Beam me up Scotty.",
283
+ "notes_key_2": "Engage"
284
+ }
285
+ }
286
+
287
+ Razorpay::Refund.fetch(refundId).edit(para_attr)
288
+ ```
289
+
290
+ **Parameters:**
291
+
292
+ | Name | Type | Description |
293
+ |-------|-----------|--------------------------------------------------|
294
+ | refundId* | string | The id of the refund to be fetched |
295
+ | notes* | object | A key-value pair |
296
+
297
+ **Response:**
298
+ ```json
299
+ {
300
+ "id": "rfnd_FP8DDKxqJif6ca",
301
+ "entity": "refund",
302
+ "amount": 300100,
303
+ "currency": "INR",
304
+ "payment_id": "pay_FIKOnlyii5QGNx",
305
+ "notes": {
306
+ "notes_key_1": "Beam me up Scotty.",
307
+ "notes_key_2": "Engage"
308
+ },
309
+ "receipt": null,
310
+ "acquirer_data": {
311
+ "arn": "10000000000000"
312
+ },
313
+ "created_at": 1597078124,
314
+ "batch_id": null,
315
+ "status": "processed",
316
+ "speed_processed": "normal",
317
+ "speed_requested": "optimum"
318
+ }
319
+ ```
320
+ -------------------------------------------------------------------------------------------------------
321
+
322
+ **PN: * indicates mandatory fields**
323
+ <br>
324
+ <br>
325
+ **For reference click [here](https://razorpay.com/docs/api/refunds/)**