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
@@ -0,0 +1,324 @@
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 | array | 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
+ }
55
+ ```
56
+ -------------------------------------------------------------------------------------------------------
57
+
58
+ ### Create an instant refund
59
+
60
+ ```rb
61
+ paymentId = "pay_Ir1SV9FgF8pxxG"
62
+
63
+ para_attr = {
64
+ "amount": "100",
65
+ "speed": "optimum",
66
+ "receipt": "Receipt No. 31"
67
+ }
68
+ Razorpay::Payment.fetch(paymentId).refund(para_attr)
69
+ ```
70
+
71
+ **Parameters:**
72
+
73
+ | Name | Type | Description |
74
+ |---------------|-------------|---------------------------------------------|
75
+ | paymentId* | string | The id of the payment |
76
+ | amount | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
77
+ | speed* | string | Here, it must be optimum |
78
+ | receipt | string | A unique identifier provided by you for your internal reference. |
79
+
80
+ **Response:**
81
+ ```json
82
+ {
83
+ "id": "rfnd_FP8R8EGjGbPkVb",
84
+ "entity": "refund",
85
+ "amount": 500100,
86
+ "currency": "INR",
87
+ "payment_id": "pay_FC8MmhMBZPKDHF",
88
+ "notes": {
89
+ "notes_key_1": "Tea, Earl Grey, Hot",
90
+ "notes_key_2": "Tea, Earl Grey… decaf."
91
+ },
92
+ "receipt": "Receipt No. 31",
93
+ "acquirer_data": {
94
+ "arn": null
95
+ },
96
+ "created_at": 1597078914,
97
+ "batch_id": null,
98
+ "status": "processed",
99
+ "speed_requested": "optimum"
100
+ }
101
+ ```
102
+ -------------------------------------------------------------------------------------------------------
103
+
104
+ ### Fetch multiple refunds for a payment
105
+
106
+ ```rb
107
+ paymentId = "pay_FIKOnlyii5QGNx"
108
+
109
+ option = {"count":1}
110
+
111
+ Razorpay::Payment.fetch_multiple_refund(paymentId,option)
112
+ ```
113
+
114
+ **Parameters:**
115
+
116
+ | Name | Type | Description |
117
+ |-------|-----------|--------------------------------------------------|
118
+ | paymentId* | string | The id of the payment |
119
+ | from | timestamp | timestamp after which the payments were created |
120
+ | to | timestamp | timestamp before which the payments were created |
121
+ | count | integer | number of payments to fetch (default: 10) |
122
+ | skip | integer | number of payments to be skipped (default: 0) |
123
+
124
+ **Refund:**
125
+ ```json
126
+ {
127
+ "entity": "collection",
128
+ "count": 1,
129
+ "items": [
130
+ {
131
+ "id": "rfnd_FP8DDKxqJif6ca",
132
+ "entity": "refund",
133
+ "amount": 300100,
134
+ "currency": "INR",
135
+ "payment_id": "pay_FIKOnlyii5QGNx",
136
+ "notes": {
137
+ "comment": "Comment for refund"
138
+ },
139
+ "receipt": null,
140
+ "acquirer_data": {
141
+ "arn": "10000000000000"
142
+ },
143
+ "created_at": 1597078124,
144
+ "batch_id": null,
145
+ "status": "processed",
146
+ "speed_processed": "normal",
147
+ "speed_requested": "optimum"
148
+ }
149
+ ]
150
+ }
151
+ ```
152
+ -------------------------------------------------------------------------------------------------------
153
+
154
+ ### Fetch a specific refund for a payment
155
+ ```rb
156
+ paymentId = "pay_FIKOnlyii5QGNx"
157
+
158
+ refundId = "rfnd_FP8DDKxqJif6ca"
159
+
160
+ Razorpay::Payment.fetch(paymentId).fetch_refund(refundId)
161
+ ```
162
+
163
+ **Parameters:**
164
+
165
+ | Name | Type | Description |
166
+ |---------------|-------------|---------------------------------------------|
167
+ | paymentId* | string | The id of the payment to be fetched |
168
+ | refundId* | string | The id of the refund to be fetched |
169
+
170
+ **Response:**
171
+ ```json
172
+ {
173
+ "id": "rfnd_FP8DDKxqJif6ca",
174
+ "entity": "refund",
175
+ "amount": 300100,
176
+ "currency": "INR",
177
+ "payment_id": "pay_FIKOnlyii5QGNx",
178
+ "notes": {
179
+ "comment": "Comment for refund"
180
+ },
181
+ "receipt": null,
182
+ "acquirer_data": {
183
+ "arn": "10000000000000"
184
+ },
185
+ "created_at": 1597078124,
186
+ "batch_id": null,
187
+ "status": "processed",
188
+ "speed_processed": "normal",
189
+ "speed_requested": "optimum"
190
+ }
191
+ ```
192
+ -------------------------------------------------------------------------------------------------------
193
+
194
+ ### Fetch all refunds
195
+ ```rb
196
+ options = {"count":1}
197
+
198
+ Razorpay::Refund.all(options)
199
+ ```
200
+
201
+ **Parameters:**
202
+
203
+ | Name | Type | Description |
204
+ |-------|-----------|--------------------------------------------------|
205
+ | from | timestamp | timestamp after which the payments were created |
206
+ | to | timestamp | timestamp before which the payments were created |
207
+ | count | integer | number of payments to fetch (default: 10) |
208
+ | skip | integer | number of payments to be skipped (default: 0) |
209
+
210
+ **Response:**
211
+ ```json
212
+ {
213
+ "entity": "collection",
214
+ "count": 2,
215
+ "items": [
216
+ {
217
+ "id": "rfnd_FFX6AnnIN3puqW",
218
+ "entity": "refund",
219
+ "amount": 88800,
220
+ "currency": "INR",
221
+ "payment_id": "pay_FFX5FdEYx8jPwA",
222
+ "notes": {
223
+ "comment": "Issuing an instant refund"
224
+ },
225
+ "receipt": null,
226
+ "acquirer_data": {},
227
+ "created_at": 1594982363,
228
+ "batch_id": null,
229
+ "status": "processed",
230
+ "speed_processed": "optimum",
231
+ "speed_requested": "optimum"
232
+ }
233
+ ]
234
+ }
235
+ ```
236
+ -------------------------------------------------------------------------------------------------------
237
+
238
+ ### Fetch particular refund
239
+ ```rb
240
+ refundId = "rfnd_FFX6AnnIN3puqW"
241
+
242
+ Razorpay::Refund.fetch(refundId)
243
+ ```
244
+
245
+ **Parameters:**
246
+
247
+ | Name | Type | Description |
248
+ |---------------|-------------|---------------------------------------------|
249
+ | refundId* | string | The id of the refund to be fetched |
250
+
251
+ **Response:**
252
+ ```json
253
+ {
254
+ "id": "rfnd_EqWThTE7dd7utf",
255
+ "entity": "refund",
256
+ "amount": 6000,
257
+ "currency": "INR",
258
+ "payment_id": "pay_EpkFDYRirena0f",
259
+ "notes": {
260
+ "comment": "Issuing an instant refund"
261
+ },
262
+ "receipt": null,
263
+ "acquirer_data": {
264
+ "arn": "10000000000000"
265
+ },
266
+ "created_at": 1589521675,
267
+ "batch_id": null,
268
+ "status": "processed",
269
+ "speed_processed": "optimum",
270
+ "speed_requested": "optimum"
271
+ }
272
+ ```
273
+ -------------------------------------------------------------------------------------------------------
274
+
275
+ ### Update the refund
276
+ ```rb
277
+ refundId = "rfnd_FP8DDKxqJif6ca"
278
+
279
+ para_attr = {
280
+ "notes": {
281
+ "notes_key_1": "Beam me up Scotty.",
282
+ "notes_key_2": "Engage"
283
+ }
284
+ }
285
+
286
+ Razorpay::Refund.fetch(refundId).edit(para_attr)
287
+ ```
288
+
289
+ **Parameters:**
290
+
291
+ | Name | Type | Description |
292
+ |-------|-----------|--------------------------------------------------|
293
+ | refundId* | string | The id of the refund to be fetched |
294
+ | notes* | array | A key-value pair |
295
+
296
+ **Response:**
297
+ ```json
298
+ {
299
+ "id": "rfnd_FP8DDKxqJif6ca",
300
+ "entity": "refund",
301
+ "amount": 300100,
302
+ "currency": "INR",
303
+ "payment_id": "pay_FIKOnlyii5QGNx",
304
+ "notes": {
305
+ "notes_key_1": "Beam me up Scotty.",
306
+ "notes_key_2": "Engage"
307
+ },
308
+ "receipt": null,
309
+ "acquirer_data": {
310
+ "arn": "10000000000000"
311
+ },
312
+ "created_at": 1597078124,
313
+ "batch_id": null,
314
+ "status": "processed",
315
+ "speed_processed": "normal",
316
+ "speed_requested": "optimum"
317
+ }
318
+ ```
319
+ -------------------------------------------------------------------------------------------------------
320
+
321
+ **PN: * indicates mandatory fields**
322
+ <br>
323
+ <br>
324
+ **For reference click [here](https://razorpay.com/docs/api/refunds/)**