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,661 @@
1
+ ## Register nach and charge first payment together
2
+
3
+ ### Create customer
4
+ ```rb
5
+ para_attr = {
6
+ "name": "Gaurav Kumar",
7
+ "contact": 9123456780,
8
+ "email": "gaurav.kumar@example.com",
9
+ "fail_existing": 0,
10
+ "gstin": "29XAbbA4369J1PA",
11
+ "notes": {
12
+ "notes_key_1": "Tea, Earl Grey, Hot",
13
+ "notes_key_2": "Tea, Earl Grey… decaf."
14
+ }
15
+ }
16
+ Razorpay::Customer.create(para_attr)
17
+ ```
18
+
19
+ **Parameters:**
20
+
21
+ | Name | Type | Description |
22
+ |---------------|-------------|---------------------------------------------|
23
+ | name* | string | Name of the customer |
24
+ | email | string | Email of the customer |
25
+ | contact | string | Contact number of the customer |
26
+ | 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`|
27
+ | notes | object | A key-value pair |
28
+
29
+ **Response:**
30
+ ```json
31
+ {
32
+ "id": "cust_1Aa00000000003",
33
+ "entity": "customer",
34
+ "name": "Gaurav Kumar",
35
+ "email": "Gaurav.Kumar@example.com",
36
+ "contact": "9000000000",
37
+ "gstin": null,
38
+ "notes": {
39
+ "notes_key_1": "Tea, Earl Grey, Hot",
40
+ "notes_key_2": "Tea, Earl Grey… decaf."
41
+ },
42
+ "created_at": 1582033731
43
+ }
44
+ ```
45
+ -------------------------------------------------------------------------------------------------------
46
+
47
+ ### Create Order
48
+
49
+ ```rb
50
+ para_attr = {
51
+ "amount": 100,
52
+ "currency": "INR",
53
+ "method": "nach",
54
+ "receipt": "Receipt No. 5",
55
+ "notes": {
56
+ "note_key 1": "Beam me up Scotty",
57
+ "note_key 2": "Tea. Earl Gray. Hot."
58
+ },
59
+ "token": {
60
+ "first_payment_amount": 10000,
61
+ "auth_type": "physical",
62
+ "max_amount": 50000,
63
+ "expire_at": 1634215992,
64
+ "notes": {
65
+ "note_key 1": "Tea, Earl Grey… decaf.",
66
+ "note_key 2": "Tea. Earl Gray. Hot."
67
+ },
68
+ "bank_account": {
69
+ "beneficiary_name": "Gaurav Kumar",
70
+ "account_number": 11214311215411,
71
+ "account_type": "savings",
72
+ "ifsc_code": "HDFC0001233"
73
+ },
74
+ "nach": {
75
+ "form_reference1": "Recurring Payment for Gaurav Kumar",
76
+ "form_reference2": "Method Paper NACH",
77
+ "description": "Paper NACH Gaurav Kumar"
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 `nach`. |
92
+ | receipt | string | Your system order reference id. |
93
+ | token.auth_type* | string | Possible value is `physical`|
94
+ | token.max_amount | integer | Use to set the maximum amount per debit request. The value can range from `500` - `1000000000` (1cr, default value) |
95
+ | token.expire_at | integer | The timestamp, in Unix format, till when the registration link should expire |
96
+ | token.notes | object | A key-value pair |
97
+ | bank.account_number* | string | Customer's bank account number. |
98
+ | bank.ifsc_code* | string | Customer's bank IFSC |
99
+ | bank.beneficiary_name* | string | Customer's name |
100
+ | bank.account_type* | string | Customer's bank account. Possible value is `saving`(default), `current`, `cc`, `nre`, `nro` |
101
+ | nach.form_reference1 | string | A user-entered reference that appears on the NACH form |
102
+ | nach.form_reference2 | string | A user-entered reference that appears on the NACH form |
103
+ | nach.description | string | All keys listed |
104
+ | notes | object | A key-value pair |
105
+
106
+ **Response:**
107
+ ```json
108
+ {
109
+ "id":"order_1Aa00000000001",
110
+ "entity":"order",
111
+ "amount":0,
112
+ "amount_paid":0,
113
+ "amount_due":0,
114
+ "currency":"INR",
115
+ "receipt":"rcptid #10",
116
+ "offer_id":null,
117
+ "offers":{
118
+ "entity":"collection",
119
+ "count":0,
120
+ "items":[]
121
+ },
122
+ "status":"created",
123
+ "attempts":0,
124
+ "notes": {
125
+ "notes_key_1": "Beam me up Scotty",
126
+ "notes_key_2": "Engage"
127
+ },
128
+ "created_at":1579775420,
129
+ "token":{
130
+ "method":"nach",
131
+ "notes": {
132
+ "notes_key_1": "Tea, Earl Grey, Hot",
133
+ "notes_key_2": "Tea, Earl Grey… decaf."
134
+ },
135
+ "recurring_status":null,
136
+ "failure_reason":null,
137
+ "currency":"INR",
138
+ "max_amount":10000000,
139
+ "auth_type":"physical",
140
+ "expire_at":1580480689,
141
+ "nach":{
142
+ "create_form":true,
143
+ "form_reference1":"Recurring Payment for Gaurav Kumar",
144
+ "form_reference2":"Method Paper NACH",
145
+ "prefilled_form":"https://rzp.io/i/bitw",
146
+ "upload_form_url":"https://rzp.io/i/gts",
147
+ "description":"Paper NACH Gaurav Kumar"
148
+ },
149
+ "bank_account":{
150
+ "ifsc":"HDFC0000001",
151
+ "bank_name":"HDFC Bank",
152
+ "name":"Gaurav Kumar",
153
+ "account_number":"11214311215411",
154
+ "account_type":"savings",
155
+ "beneficiary_email":"gaurav.kumar@example.com",
156
+ "beneficiary_mobile":"9876543210"
157
+ },
158
+ "first_payment_amount":10000
159
+ }
160
+ }
161
+ ```
162
+ -------------------------------------------------------------------------------------------------------
163
+
164
+ ### Create an Authorization Payment
165
+
166
+ Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/paper-nach/auto-debit/#113-create-an-authorization-payment) for authorization payment
167
+
168
+ -----------------------------------------------------------------------------------------------------
169
+
170
+ ### Create registration link
171
+
172
+ ```rb
173
+ para_attr = {
174
+ "customer": {
175
+ "name": "Gaurav Kumar",
176
+ "email": "gaurav.kumar@example.com",
177
+ "contact": 9123456780
178
+ },
179
+ "amount": 100,
180
+ "type": "link",
181
+ "currency": "INR",
182
+ "description": "Registration Link for Gaurav Kumar",
183
+ "subscription_registration": {
184
+ "first_payment_amount": 100,
185
+ "method": "nach",
186
+ "auth_type": "physical",
187
+ "max_amount": 50000,
188
+ "expire_at": 1634215992,
189
+ "bank_account": {
190
+ "beneficiary_name": "Gaurav Kumar",
191
+ "account_number": 11214311215411,
192
+ "account_type": "savings",
193
+ "ifsc_code": "HDFC0001233"
194
+ },
195
+ "nach": {
196
+ "form_reference1": "Recurring Payment for Gaurav Kumar",
197
+ "form_reference2": "Method Paper NACH"
198
+ }
199
+ },
200
+ "receipt": "Receipt No. 5",
201
+ "email_notify": 1,
202
+ "sms_notify": 1,
203
+ "expire_by": 1634215992,
204
+ "notes": {
205
+ "note_key 1": "Beam me up Scotty",
206
+ "note_key 2": "Tea. Earl Gray. Hot."
207
+ }
208
+ }
209
+ Razorpay::SubscriptionRegistration.create(para_attr)
210
+ ```
211
+
212
+ **Parameters:**
213
+
214
+ | Name | Type | Description |
215
+ |-----------------|---------|---------------------------------------------------------------|
216
+ | customer | object | Details of the customer to whom the registration link will be sent. |
217
+ | type* | object | the value is `link`. |
218
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
219
+ | currency* | string | The currency of the payment (defaults to INR) |
220
+ | description* | string | A brief description of the payment. |
221
+ | subscription_registration | object | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/paper-nach/auto-debit/#121-create-a-registration-link) are supported |
222
+ | receipt | string | Your system order reference id. |
223
+ | sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
224
+ | email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
225
+ | expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
226
+ | notes | object | A key-value pair |
227
+
228
+ **Response:**
229
+ ```json
230
+ {
231
+ "id": "inv_FHrZiAubEzDdaq",
232
+ "entity": "invoice",
233
+ "receipt": "Receipt No. 27",
234
+ "invoice_number": "Receipt No. 27",
235
+ "customer_id": "cust_BMB3EwbqnqZ2EI",
236
+ "customer_details": {
237
+ "id": "cust_BMB3EwbqnqZ2EI",
238
+ "name": "Gaurav Kumar",
239
+ "email": "gaurav.kumar@example.com",
240
+ "contact": "9123456780",
241
+ "gstin": null,
242
+ "billing_address": null,
243
+ "shipping_address": null,
244
+ "customer_name": "Gaurav Kumar",
245
+ "customer_email": "gaurav.kumar@example.com",
246
+ "customer_contact": "9123456780"
247
+ },
248
+ "order_id": "order_FHrZiBOkWHZPOp",
249
+ "line_items": [],
250
+ "payment_id": null,
251
+ "status": "issued",
252
+ "expire_by": 1647483647,
253
+ "issued_at": 1595491154,
254
+ "paid_at": null,
255
+ "cancelled_at": null,
256
+ "expired_at": null,
257
+ "sms_status": "sent",
258
+ "email_status": "sent",
259
+ "date": 1595491154,
260
+ "terms": null,
261
+ "partial_payment": false,
262
+ "gross_amount": 0,
263
+ "tax_amount": 0,
264
+ "taxable_amount": 0,
265
+ "amount": 0,
266
+ "amount_paid": 0,
267
+ "amount_due": 0,
268
+ "currency": "INR",
269
+ "currency_symbol": "₹",
270
+ "description": "12 p.m. Meals",
271
+ "notes": {
272
+ "note_key 1": "Beam me up Scotty",
273
+ "note_key 2": "Tea. Earl Gray. Hot."
274
+ },
275
+ "comment": null,
276
+ "short_url": "https://rzp.io/i/bzDYbNg",
277
+ "view_less": true,
278
+ "billing_start": null,
279
+ "billing_end": null,
280
+ "type": "link",
281
+ "group_taxes_discounts": false,
282
+ "created_at": 1595491154,
283
+ "idempotency_key": null,
284
+ "token": {
285
+ "method": "nach",
286
+ "notes": {
287
+ "note_key 1": "Beam me up Scotty",
288
+ "note_key 2": "Tea. Earl Gray. Hot."
289
+ },
290
+ "recurring_status": null,
291
+ "failure_reason": null,
292
+ "currency": "INR",
293
+ "max_amount": 50000,
294
+ "auth_type": "physical",
295
+ "expire_at": 1947483647,
296
+ "nach": {
297
+ "create_form": true,
298
+ "form_reference1": "Recurring Payment for Gaurav Kumar",
299
+ "form_reference2": "Method Paper NACH",
300
+ "prefilled_form": "https://rzp.io/i/exdIzYN",
301
+ "upload_form_url": "https://rzp.io/i/bzDYbNg",
302
+ "description": "12 p.m. Meals"
303
+ },
304
+ "bank_account": {
305
+ "ifsc": "HDFC0001233",
306
+ "bank_name": "HDFC Bank",
307
+ "name": "Gaurav Kumar",
308
+ "account_number": "11214311215411",
309
+ "account_type": "savings",
310
+ "beneficiary_email": "gaurav.kumar@example.com",
311
+ "beneficiary_mobile": "9123456780"
312
+ },
313
+ "first_payment_amount": 0
314
+ },
315
+ "nach_form_url": "https://rzp.io/i/exdIzYN"
316
+ }
317
+ ```
318
+ -------------------------------------------------------------------------------------------------------
319
+
320
+ ## Create an order to charge the customer
321
+
322
+ ```rb
323
+ param_attr = {
324
+ "amount": 100,
325
+ "currency": "INR",
326
+ "payment_capture": true,
327
+ "receipt": "Receipt No. 1",
328
+ "notes": {
329
+ "key1": "value3",
330
+ "key2": "value2"
331
+ }
332
+ }
333
+ Razorpay::Order.create(para_attr)
334
+ ```
335
+ **Parameters:**
336
+
337
+ | Name | Type | Description |
338
+ |-----------------|---------|------------------------------------------------------------------------------|
339
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
340
+ | currency* | string | The currency of the payment (defaults to INR) |
341
+ | receipt | string | Your system order reference id. |
342
+ | notes | object | A key-value pair |
343
+ | 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. |
344
+
345
+ **Response:**
346
+ ```json
347
+ {
348
+ "id":"order_1Aa00000000002",
349
+ "entity":"order",
350
+ "amount":1000,
351
+ "amount_paid":0,
352
+ "amount_due":1000,
353
+ "currency":"INR",
354
+ "receipt":"Receipt No. 1",
355
+ "offer_id":null,
356
+ "status":"created",
357
+ "attempts":0,
358
+ "notes":{
359
+ "notes_key_1":"Tea, Earl Grey, Hot",
360
+ "notes_key_2":"Tea, Earl Grey… decaf."
361
+ },
362
+ "created_at":1579782776
363
+ }
364
+ ```
365
+ -------------------------------------------------------------------------------------------------------
366
+
367
+ ## Create a recurring payment
368
+
369
+ ```rb
370
+ para_attr = {
371
+ "email": "gaurav.kumar@example.com",
372
+ "contact": "9123456789",
373
+ "amount": 1000,
374
+ "currency": "INR",
375
+ "recurring": "1",
376
+ "description": "Creating recurring payment for Gaurav Kumar",
377
+ "notes": {
378
+ "key1": "value3",
379
+ "key2": "value2"
380
+ }
381
+ }
382
+ Razorpay::Payment.createRecurringPayment(para_attr)
383
+ ```
384
+ **Parameters:**
385
+
386
+ | Name | Type | Description |
387
+ |-----------------|---------|------------------------------------------------------------------------------|
388
+ | email* | string | The customer's email address |
389
+ | contact* | string | The customer's phone number |
390
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
391
+ | currency* | string | The currency of the payment (defaults to INR) |
392
+ | orderId* | string | The id of the order to be fetched |
393
+ | customerId* | string | The id of the customer to be fetched |
394
+ | tokenId* | string | The id of the token to be fetched |
395
+ | recurring* | boolean | Possible values is `0` or `1` |
396
+ | description | string | A brief description of the payment. |
397
+ | notes | object | A key-value pair |
398
+
399
+ **Response:**
400
+ ```json
401
+ {
402
+ "razorpay_payment_id" : "pay_1Aa00000000001",
403
+ "razorpay_order_id" : "order_1Aa00000000001",
404
+ "razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
405
+ }
406
+ ```
407
+ -------------------------------------------------------------------------------------------------------
408
+
409
+ ## Send/Resend notifications
410
+
411
+ ```rb
412
+ invoiceId = "inv_JDdNb4xdf4gxQ7"
413
+
414
+ medium = "email"
415
+
416
+ Razorpay::Invoice.notifyBy(invoiceId, medium)
417
+ ```
418
+ **Parameters:**
419
+
420
+ | Name | Type |Description |
421
+ |-----------------|---------|------------------------------------------------------------------------------|
422
+ | invoiceId* | string | The id of the invoice to be fetched |
423
+ | medium* | string | Possible values are `sms` or `email` |
424
+
425
+ **Response:**
426
+ ```json
427
+ {
428
+ "success": true
429
+ }
430
+ ```
431
+
432
+ -------------------------------------------------------------------------------------------------------
433
+
434
+ ## Cancel registration link
435
+
436
+ ```rb
437
+ Razorpay::Invoice.cancel(invoiceId);
438
+ ```
439
+ **Parameters:**
440
+
441
+ | Name | Type | Description |
442
+ |-----------------|---------|------------------------------------------------------------------------------|
443
+ | invoiceId* | string | The id of the invoice to be fetched |
444
+
445
+ **Response:**
446
+ ```json
447
+ {
448
+ "id": "inv_FHrZiAubEzDdaq",
449
+ "entity": "invoice",
450
+ "receipt": "Receipt No. 27",
451
+ "invoice_number": "Receipt No. 27",
452
+ "customer_id": "cust_BMB3EwbqnqZ2EI",
453
+ "customer_details": {
454
+ "id": "cust_BMB3EwbqnqZ2EI",
455
+ "name": "Gaurav Kumar",
456
+ "email": "gaurav.kumar@example.com",
457
+ "contact": "9123456780",
458
+ "gstin": null,
459
+ "billing_address": null,
460
+ "shipping_address": null,
461
+ "customer_name": "Gaurav Kumar",
462
+ "customer_email": "gaurav.kumar@example.com",
463
+ "customer_contact": "9123456780"
464
+ },
465
+ "order_id": "order_FHrZiBOkWHZPOp",
466
+ "line_items": [],
467
+ "payment_id": null,
468
+ "status": "cancelled",
469
+ "expire_by": 1647483647,
470
+ "issued_at": 1595491154,
471
+ "paid_at": null,
472
+ "cancelled_at": 1595491339,
473
+ "expired_at": null,
474
+ "sms_status": "sent",
475
+ "email_status": "sent",
476
+ "date": 1595491154,
477
+ "terms": null,
478
+ "partial_payment": false,
479
+ "gross_amount": 0,
480
+ "tax_amount": 0,
481
+ "taxable_amount": 0,
482
+ "amount": 0,
483
+ "amount_paid": 0,
484
+ "amount_due": 0,
485
+ "currency": "INR",
486
+ "currency_symbol": "₹",
487
+ "description": "12 p.m. Meals",
488
+ "notes": {
489
+ "note_key 1": "Beam me up Scotty",
490
+ "note_key 2": "Tea. Earl Gray. Hot."
491
+ },
492
+ "comment": null,
493
+ "short_url": "https://rzp.io/i/bzDYbNg",
494
+ "view_less": true,
495
+ "billing_start": null,
496
+ "billing_end": null,
497
+ "type": "link",
498
+ "group_taxes_discounts": false,
499
+ "created_at": 1595491154,
500
+ "idempotency_key": null,
501
+ "token": {
502
+ "method": "nach",
503
+ "notes": {
504
+ "note_key 1": "Beam me up Scotty",
505
+ "note_key 2": "Tea. Earl Gray. Hot."
506
+ },
507
+ "recurring_status": null,
508
+ "failure_reason": null,
509
+ "currency": "INR",
510
+ "max_amount": 50000,
511
+ "auth_type": "physical",
512
+ "expire_at": 1947483647,
513
+ "nach": {
514
+ "create_form": true,
515
+ "form_reference1": "Recurring Payment for Gaurav Kumar",
516
+ "form_reference2": "Method Paper NACH",
517
+ "prefilled_form": "https://rzp.io/i/tSYd5aV",
518
+ "upload_form_url": "https://rzp.io/i/bzDYbNg",
519
+ "description": "12 p.m. Meals"
520
+ },
521
+ "bank_account": {
522
+ "ifsc": "HDFC0001233",
523
+ "bank_name": "HDFC Bank",
524
+ "name": "Gaurav Kumar",
525
+ "account_number": "11214311215411",
526
+ "account_type": "savings",
527
+ "beneficiary_email": "gaurav.kumar@example.com",
528
+ "beneficiary_mobile": "9123456780"
529
+ },
530
+ "first_payment_amount": 0
531
+ },
532
+ "nach_form_url": "https://rzp.io/i/tSYd5aV"
533
+ }
534
+ ```
535
+ -------------------------------------------------------------------------------------------------------
536
+
537
+ ## Fetch token by payment id
538
+
539
+ ```rb
540
+ customerId = "cust_1Aa00000000004"
541
+
542
+ Razorpay::Customer.fetchTokens(customerId)
543
+ ```
544
+ **Parameters:**
545
+
546
+ | Name | Type | Description |
547
+ |-----------------|---------|------------------------------------------------------------------------------|
548
+ | paymentId* | string | The id of the payment to be fetched |
549
+
550
+ **Response:**
551
+ ```json
552
+ {
553
+ "id": "pay_EnLNTjINiPkMEZ",
554
+ "entity": "payment",
555
+ "amount": 0,
556
+ "currency": "INR",
557
+ "status": "captured",
558
+ "order_id": "order_EnLLfglmKksr4K",
559
+ "invoice_id": "inv_EnLLfgCzRfcMuh",
560
+ "international": false,
561
+ "method": "nach",
562
+ "amount_refunded": 0,
563
+ "refund_status": null,
564
+ "captured": true,
565
+ "description": "Invoice #inv_EnLLfgCzRfcMuh",
566
+ "card_id": null,
567
+ "bank": "UTIB",
568
+ "wallet": null,
569
+ "vpa": null,
570
+ "email": "gaurav.kumar@example.com",
571
+ "contact": "+919876543210",
572
+ "customer_id": "cust_DtHaBuooGHTuyZ",
573
+ "token_id": "token_EnLNTnn7uyRg5V",
574
+ "notes": {
575
+ "note_key 1": "Beam me up Scotty",
576
+ "note_key 2": "Tea. Earl Gray. Hot."
577
+ },
578
+ "fee": 0,
579
+ "tax": 0,
580
+ "error_code": null,
581
+ "error_description": null,
582
+ "error_source": null,
583
+ "error_step": null,
584
+ "error_reason": null,
585
+ "acquirer_data": {},
586
+ "created_at": 1588827564
587
+ }
588
+ ```
589
+ -------------------------------------------------------------------------------------------------------
590
+
591
+ ## Fetch tokens by customer id
592
+
593
+ ```rb
594
+ customerId = "cust_1Aa00000000004"
595
+
596
+ Razorpay::Customer.fetchTokens(customerId)
597
+ ```
598
+ **Parameters:**
599
+
600
+ | Name | Type | Description |
601
+ |-----------------|---------|------------------------------------------------------------------------------|
602
+ | customerId* | string | The id of the customer to be fetched |
603
+
604
+ **Response:**
605
+ ```json
606
+ {
607
+ "entity": "collection",
608
+ "count": 1,
609
+ "items": [
610
+ {
611
+ "id": "token_EhYgIE3pOyMQpD",
612
+ "entity": "token",
613
+ "token": "3mQ5Czc6APNppI",
614
+ "bank": "HDFC",
615
+ "wallet": null,
616
+ "method": "nach",
617
+ "vpa": null,
618
+ "recurring": true,
619
+ "recurring_details": {
620
+ "status": "confirmed",
621
+ "failure_reason": null
622
+ },
623
+ "auth_type": "physical",
624
+ "mrn": null,
625
+ "used_at": 1587564373,
626
+ "created_at": 1587564373,
627
+ "dcc_enabled": false
628
+ }
629
+ ]
630
+ }
631
+ ```
632
+ -------------------------------------------------------------------------------------------------------
633
+
634
+ ## Delete tokens
635
+
636
+ ```rb
637
+ customerId = "cust_1Aa00000000004"
638
+
639
+ tokenId = "token_Hxe0skTXLeg9pF"
640
+
641
+ Razorpay::fetch(customerId).deleteToken(tokenId)
642
+ ```
643
+ **Parameters:**
644
+
645
+ | Name | Type | Description |
646
+ |-----------------|---------|------------------------------------------------------------------------------|
647
+ | customerId* | string | The id of the customer to be fetched |
648
+ | tokenId* | string | The id of the token to be fetched |
649
+
650
+ **Response:**
651
+ ```json
652
+ {
653
+ "deleted": true
654
+ }
655
+ ```
656
+ -------------------------------------------------------------------------------------------------------
657
+
658
+ **PN: * indicates mandatory fields**
659
+ <br>
660
+ <br>
661
+ **For reference click [here](https://razorpay.com/docs/api/recurring-payments/paper-nach/auto-debit/)**