razorpay 2.4.1 → 3.0.0

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 (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,445 @@
1
+ ## Register emandate and charge first payment together
2
+
3
+ ```rb
4
+ require "razorpay"
5
+ Razorpay.setup('key_id', 'key_secret')
6
+ ```
7
+
8
+ ### Create customer
9
+
10
+ ```rb
11
+ para_attr = {
12
+ "name": "Gaurav Kumar",
13
+ "contact": 9123456780,
14
+ "email": "gaurav.kumar@example.com",
15
+ "fail_existing": 0,
16
+ "gstin": "29XAbbA4369J1PA",
17
+ "notes": {
18
+ "notes_key_1": "Tea, Earl Grey, Hot",
19
+ "notes_key_2": "Tea, Earl Grey… decaf."
20
+ }
21
+ }
22
+ Razorpay::Customer.create(para_attr)
23
+ ```
24
+ **Parameters:**
25
+
26
+ | Name | Type | Description |
27
+ |---------------|-------------|---------------------------------------------|
28
+ | name* | string | Name of the customer |
29
+ | email | string | Email of the customer |
30
+ | contact | string | Contact number of the customer |
31
+ | fail_existing | string | If a customer with the same details already exists, the request throws an exception by default. Possible value is `0` or `1`|
32
+ | notes | object | A key-value pair |
33
+
34
+ **Response:**
35
+ ```json
36
+ {
37
+ "id": "cust_1Aa00000000003",
38
+ "entity": "customer",
39
+ "name": "Gaurav Kumar",
40
+ "email": "Gaurav.Kumar@example.com",
41
+ "contact": "9000000000",
42
+ "gstin": null,
43
+ "notes": {
44
+ "notes_key_1": "Tea, Earl Grey, Hot",
45
+ "notes_key_2": "Tea, Earl Grey… decaf."
46
+ },
47
+ "created_at": 1582033731
48
+ }
49
+ ```
50
+ -------------------------------------------------------------------------------------------------------
51
+
52
+ ### Create order
53
+
54
+ ```rb
55
+ para_attr = {
56
+ "amount": 100,
57
+ "currency": "INR",
58
+ "method": "emandate",
59
+ "receipt": "Receipt No. 5",
60
+ "notes": {
61
+ "note_key 1": "Beam me up Scotty",
62
+ "note_key 2": "Engage"
63
+ },
64
+ "token": {
65
+ "first_payment_amount": 10000,
66
+ "auth_type": "netbanking",
67
+ "max_amount": 9999900,
68
+ "expire_at": 4102444799,
69
+ "notes": {
70
+ "note_key 1": "Tea, Earl Grey… decaf.",
71
+ "note_key 2": "Tea. Earl Gray. Hot."
72
+ },
73
+ "bank_account": {
74
+ "beneficiary_name": "Gaurav Kumar",
75
+ "account_number": 11214311215411,
76
+ "account_type": "savings",
77
+ "ifsc_code": "HDFC0001233"
78
+ }
79
+ }
80
+ }
81
+ Razorpay::Order.create(para_attr)
82
+ ```
83
+
84
+ **Parameters:**
85
+
86
+ | Name | Type | Description |
87
+ |-----------------|---------|------------------------------------------------------------------------------|
88
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
89
+ | currency* | string | The currency of the payment (defaults to INR) |
90
+ | customerId* | string | The id of the customer to be fetched |
91
+ | method* | string | Payment method used to make the registration transaction. Possible value is `emandate`. |
92
+ | receipt | string | Your system order reference id. |
93
+ | payment_capture | boolean | Indicates whether payment status should be changed to captured automatically or not. Possible values: true - Payments are captured automatically. false - Payments are not captured automatically. |
94
+ | token | object | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#112-create-an-order) are supported |
95
+ | notes | object | A key-value pair |
96
+
97
+ **Response:**
98
+ For create order response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#112-create-an-order)
99
+
100
+ -------------------------------------------------------------------------------------------------------
101
+
102
+ ### Create an Authorization Payment
103
+
104
+ Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#113-create-an-authorization-payment) for authorization payment
105
+
106
+ -----------------------------------------------------------------------------------------------------
107
+
108
+ ### Create registration link
109
+
110
+ ```rb
111
+ para_attr = {
112
+ "customer": {
113
+ "name": "Gaurav Kumar",
114
+ "email": "gaurav.kumar@example.com",
115
+ "contact": 9123456780
116
+ },
117
+ "type": "link",
118
+ "amount": 100,
119
+ "currency": "INR",
120
+ "description": "Registration Link for Gaurav Kumar",
121
+ "subscription_registration": {
122
+ "first_payment_amount": 100,
123
+ "method": "emandate",
124
+ "auth_type": "netbanking",
125
+ "max_amount": 50000,
126
+ "expire_at": 1634215992,
127
+ "bank_account": {
128
+ "beneficiary_name": "Gaurav Kumar",
129
+ "account_number": 11214311215411,
130
+ "account_type": "savings",
131
+ "ifsc_code": "HDFC0001233"
132
+ }
133
+ },
134
+ "receipt": "Receipt No. 5",
135
+ "email_notify": 1,
136
+ "sms_notify": 1,
137
+ "expire_by": 1634215992,
138
+ "notes": {
139
+ "note_key 1": "Beam me up Scotty",
140
+ "note_key 2": "Tea. Earl Gray. Hot."
141
+ }
142
+ }
143
+ Razorpay::SubscriptionRegistration.create(para_attr)
144
+ ```
145
+
146
+ **Parameters:**
147
+
148
+ | Name | Type | Description |
149
+ |-----------------|---------|---------------------------------------------------------------|
150
+ | customer | object | Details of the customer to whom the registration link will be sent. |
151
+ | type* | object | the value is `link`. |
152
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
153
+ | currency* | string | The currency of the payment (defaults to INR) |
154
+ | description* | string | A brief description of the payment. |
155
+ | subscription_registration | object | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#121-create-a-registration-link) are supported |
156
+ | receipt | string | Your system order reference id. |
157
+ | sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
158
+ | email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
159
+ | expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
160
+ | notes | object | A key-value pair |
161
+
162
+ **Response:**
163
+ For create registration link response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#12-using-a-registration-link)
164
+ -------------------------------------------------------------------------------------------------------
165
+
166
+ ## Create an order to charge the customer
167
+
168
+ ```rb
169
+ para_attr ={
170
+ "amount": "100",
171
+ "currency": "INR",
172
+ "receipt": "Receipt No. 1",
173
+ "notes": {
174
+ "key1": "value3",
175
+ "key2": "value2"
176
+ }
177
+ }
178
+ Razorpay::Order.create(para_attr)
179
+ ```
180
+ **Parameters:**
181
+
182
+ | Name | Type | Description |
183
+ |-----------------|---------|------------------------------------------------------------------------------|
184
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
185
+ | currency* | string | The currency of the payment (defaults to INR) |
186
+ | receipt | string | Your system order reference id. |
187
+ | payment_capture | boolean | Indicates whether payment status should be changed to captured automatically or not. Possible values: true - Payments are captured automatically. false - Payments are not captured automatically. |
188
+ | notes | object | A key-value pair |
189
+
190
+ **Response:**
191
+ ```json
192
+ {
193
+ "id":"order_1Aa00000000002",
194
+ "entity":"order",
195
+ "amount":1000,
196
+ "amount_paid":0,
197
+ "amount_due":1000,
198
+ "currency":"INR",
199
+ "receipt":"Receipt No. 1",
200
+ "offer_id":null,
201
+ "status":"created",
202
+ "attempts":0,
203
+ "notes":{
204
+ "notes_key_1":"Tea, Earl Grey, Hot",
205
+ "notes_key_2":"Tea, Earl Grey… decaf."
206
+ },
207
+ "created_at":1579782776
208
+ }
209
+ ```
210
+ -------------------------------------------------------------------------------------------------------
211
+
212
+ ## Create a recurring payment
213
+
214
+ ```rb
215
+ para_attr = {
216
+ "email": "gaurav.kumar@example.com",
217
+ "contact": 9123456789,
218
+ "amount": 1000,
219
+ "currency": "INR",
220
+ "recurring": 1,
221
+ "description": "Creating recurring payment for Gaurav Kumar",
222
+ "notes": {
223
+ "key1": "value3",
224
+ "key2": "value2"
225
+ }
226
+ }
227
+ Razorpay::Payment.createRecurringPayment(para_attr)
228
+ ```
229
+ **Parameters:**
230
+
231
+ | Name | Type | Description |
232
+ |-----------------|---------|------------------------------------------------------------------------------|
233
+ | email* | string | The customer's email address |
234
+ | contact* | string | The customer's phone number |
235
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
236
+ | currency* | string | The currency of the payment (defaults to INR) |
237
+ | orderId* | string | The id of the order to be fetched |
238
+ | customerId* | string | The id of the customer to be fetched |
239
+ | tokenId* | string | The id of the token to be fetched |
240
+ | recurring* | boolean | Possible values is `0` or `1` |
241
+ | description | string | A brief description of the payment. |
242
+ | notes | object | A key-value pair |
243
+
244
+ **Response:**
245
+ ```json
246
+ {
247
+ "razorpay_payment_id" : "pay_1Aa00000000001",
248
+ "razorpay_order_id" : "order_1Aa00000000001",
249
+ "razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
250
+ }
251
+ ```
252
+ -------------------------------------------------------------------------------------------------------
253
+
254
+ ## Send/Resend notifications
255
+
256
+ ```rb
257
+ invoiceId = "inv_JDdNb4xdf4gxQ7"
258
+
259
+ medium = "email"
260
+
261
+ Razorpay::Invoice.notifyBy(invoiceId, medium)
262
+ ```
263
+ **Parameters:**
264
+
265
+ | Name | Type |Description |
266
+ |-----------------|---------|------------------------------------------------------------------------------|
267
+ | invoiceId* | string | The id of the invoice to be fetched |
268
+ | medium* | string | Possible values are `sms` or `email` |
269
+
270
+ **Response:**
271
+ ```json
272
+ {
273
+ "success": true
274
+ }
275
+ ```
276
+ -------------------------------------------------------------------------------------------------------
277
+
278
+ ## Cancel registration link
279
+
280
+ ```rb
281
+ Razorpay::Invoice.cancel(invoiceId);
282
+ ```
283
+ **Parameters:**
284
+
285
+ | Name | Type | Description |
286
+ |-----------------|---------|------------------------------------------------------------------------------|
287
+ | invoiceId* | string | The id of the invoice to be fetched |
288
+
289
+ **Response:**
290
+ ```json
291
+ {
292
+ "id": "inv_FHrfRupD2ouKIt",
293
+ "entity": "invoice",
294
+ "receipt": "Receipt No. 1",
295
+ "invoice_number": "Receipt No. 1",
296
+ "customer_id": "cust_BMB3EwbqnqZ2EI",
297
+ "customer_details": {
298
+ "id": "cust_BMB3EwbqnqZ2EI",
299
+ "name": "Gaurav Kumar",
300
+ "email": "gaurav.kumar@example.com",
301
+ "contact": "9123456780",
302
+ "gstin": null,
303
+ "billing_address": null,
304
+ "shipping_address": null,
305
+ "customer_name": "Gaurav Kumar",
306
+ "customer_email": "gaurav.kumar@example.com",
307
+ "customer_contact": "9123456780"
308
+ },
309
+ "order_id": "order_FHrfRw4TZU5Q2L",
310
+ "line_items": [],
311
+ "payment_id": null,
312
+ "status": "cancelled",
313
+ "expire_by": 4102444799,
314
+ "issued_at": 1595491479,
315
+ "paid_at": null,
316
+ "cancelled_at": 1595491488,
317
+ "expired_at": null,
318
+ "sms_status": "sent",
319
+ "email_status": "sent",
320
+ "date": 1595491479,
321
+ "terms": null,
322
+ "partial_payment": false,
323
+ "gross_amount": 100,
324
+ "tax_amount": 0,
325
+ "taxable_amount": 0,
326
+ "amount": 100,
327
+ "amount_paid": 0,
328
+ "amount_due": 100,
329
+ "currency": "INR",
330
+ "currency_symbol": "₹",
331
+ "description": "Registration Link for Gaurav Kumar",
332
+ "notes": {
333
+ "note_key 1": "Beam me up Scotty",
334
+ "note_key 2": "Tea. Earl Gray. Hot."
335
+ },
336
+ "comment": null,
337
+ "short_url": "https://rzp.io/i/QlfexTj",
338
+ "view_less": true,
339
+ "billing_start": null,
340
+ "billing_end": null,
341
+ "type": "link",
342
+ "group_taxes_discounts": false,
343
+ "created_at": 1595491480,
344
+ "idempotency_key": null
345
+ }
346
+ ```
347
+ -------------------------------------------------------------------------------------------------------
348
+
349
+ ## Fetch token by payment id
350
+
351
+ ```rb
352
+ paymentId = "pay_FHf9a7AO0iXM9I"
353
+
354
+ Razorpay::Payment.fetch(paymentId)
355
+ ```
356
+ **Parameters:**
357
+
358
+ | Name | Type | Description |
359
+ |-----------------|---------|------------------------------------------------------------------------------|
360
+ | paymentId* | string | The id of the payment to be fetched |
361
+
362
+ **Response:**
363
+ For fetch token by payment id response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#21-fetch-token-by-payment-id)
364
+
365
+ -------------------------------------------------------------------------------------------------------
366
+
367
+ ## Fetch tokens by customer id
368
+
369
+ ```rb
370
+ customerId = "cust_1Aa00000000004"
371
+
372
+ Razorpay::Customer.fetchTokens(customerId)
373
+ ```
374
+ **Parameters:**
375
+
376
+ | Name | Type | Description |
377
+ |-----------------|---------|------------------------------------------------------------------------------|
378
+ | customerId* | string | The id of the customer to be fetched |
379
+
380
+ **Response:**
381
+ ```json
382
+ {
383
+ "entity": "collection",
384
+ "count": 1,
385
+ "items": [
386
+ {
387
+ "id": "token_FHf94Uym9tdYFJ",
388
+ "entity": "token",
389
+ "token": "2wDPM7VAlXtjAR",
390
+ "bank": "HDFC",
391
+ "wallet": null,
392
+ "method": "emandate",
393
+ "vpa": null,
394
+ "recurring": true,
395
+ "recurring_details": {
396
+ "status": "confirmed",
397
+ "failure_reason": null
398
+ },
399
+ "auth_type": "netbanking",
400
+ "mrn": null,
401
+ "used_at": 1595447381,
402
+ "created_at": 1595447381,
403
+ "bank_details": {
404
+ "beneficiary_name": "Gaurav Kumar",
405
+ "account_number": "1121431121541121",
406
+ "ifsc": "HDFC0000001",
407
+ "account_type": "savings"
408
+ },
409
+ "max_amount": 9999900,
410
+ "expired_at": 1689971140,
411
+ "dcc_enabled": false
412
+ }
413
+ ]
414
+ }
415
+ ```
416
+ -------------------------------------------------------------------------------------------------------
417
+
418
+ ## Delete tokens
419
+
420
+ ```rb
421
+ customerId = "cust_1Aa00000000004"
422
+
423
+ tokenId = "token_Hxe0skTXLeg9pF"
424
+
425
+ Razorpay::fetch(customerId).deleteToken(tokenId)
426
+ ```
427
+ **Parameters:**
428
+
429
+ | Name | Type | Description |
430
+ |-----------------|---------|------------------------------------------------------------------------------|
431
+ | customerId* | string | The id of the customer to be fetched |
432
+ | tokenId* | string | The id of the token to be fetched |
433
+
434
+ **Response:**
435
+ ```json
436
+ {
437
+ "deleted": true
438
+ }
439
+ ```
440
+ -------------------------------------------------------------------------------------------------------
441
+
442
+ **PN: * indicates mandatory fields**
443
+ <br>
444
+ <br>
445
+ **For reference click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/)**