razorruby 3.0.1

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 (171) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.editorconfig +12 -0
  4. data/.github/dependabot.yml +8 -0
  5. data/.github/workflows/ruby.yml +38 -0
  6. data/.gitignore +23 -0
  7. data/.rubocop.yml +22 -0
  8. data/.simplecov +3 -0
  9. data/CHANGELOG.md +168 -0
  10. data/Gemfile +4 -0
  11. data/LICENSE.txt +22 -0
  12. data/README.md +102 -0
  13. data/Rakefile +26 -0
  14. data/documents/Invoice.md +539 -0
  15. data/documents/addon.md +191 -0
  16. data/documents/card.md +610 -0
  17. data/documents/customer.md +163 -0
  18. data/documents/emandate.md +492 -0
  19. data/documents/fund.md +89 -0
  20. data/documents/items.md +208 -0
  21. data/documents/order.md +281 -0
  22. data/documents/papernach.md +738 -0
  23. data/documents/payment.md +826 -0
  24. data/documents/paymentLink.md +1063 -0
  25. data/documents/paymentVerification.md +79 -0
  26. data/documents/plan.md +184 -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/subscriptions.md +752 -0
  33. data/documents/tokens.md +262 -0
  34. data/documents/transfers.md +781 -0
  35. data/documents/upi.md +545 -0
  36. data/documents/virtualAccount.md +591 -0
  37. data/lib/ca-bundle.crt +3988 -0
  38. data/lib/extensions/httparty/hash_conversions.rb +44 -0
  39. data/lib/razorpay/addon.rb +32 -0
  40. data/lib/razorpay/card.rb +17 -0
  41. data/lib/razorpay/collection.rb +6 -0
  42. data/lib/razorpay/constants.rb +6 -0
  43. data/lib/razorpay/customer.rb +42 -0
  44. data/lib/razorpay/entity.rb +46 -0
  45. data/lib/razorpay/errors/bad_request_error.rb +14 -0
  46. data/lib/razorpay/errors/gateway_error.rb +7 -0
  47. data/lib/razorpay/errors/razorpay_error.rb +11 -0
  48. data/lib/razorpay/errors/server_error.rb +7 -0
  49. data/lib/razorpay/errors.rb +4 -0
  50. data/lib/razorpay/fund_account.rb +19 -0
  51. data/lib/razorpay/invoice.rb +68 -0
  52. data/lib/razorpay/item.rb +34 -0
  53. data/lib/razorpay/order.rb +39 -0
  54. data/lib/razorpay/payment.rb +116 -0
  55. data/lib/razorpay/payment_link.rb +36 -0
  56. data/lib/razorpay/payment_method.rb +17 -0
  57. data/lib/razorpay/plan.rb +24 -0
  58. data/lib/razorpay/qr_code.rb +34 -0
  59. data/lib/razorpay/refund.rb +27 -0
  60. data/lib/razorpay/request.rb +119 -0
  61. data/lib/razorpay/settlement.rb +39 -0
  62. data/lib/razorpay/subscription.rb +60 -0
  63. data/lib/razorpay/subscription_registration.rb +16 -0
  64. data/lib/razorpay/transfer.rb +35 -0
  65. data/lib/razorpay/utility.rb +57 -0
  66. data/lib/razorpay/virtual_account.rb +49 -0
  67. data/lib/razorpay.rb +37 -0
  68. data/razorpay-ruby.gemspec +36 -0
  69. data/test/fixtures/addon_collection.json +60 -0
  70. data/test/fixtures/bad_request_error.json +7 -0
  71. data/test/fixtures/cancel_invoice.json +44 -0
  72. data/test/fixtures/cancel_subscription.json +20 -0
  73. data/test/fixtures/create_json_payment.json +13 -0
  74. data/test/fixtures/customer_collection.json +22 -0
  75. data/test/fixtures/delete_token.json +3 -0
  76. data/test/fixtures/downtimes_collection.json +21 -0
  77. data/test/fixtures/empty.json +2 -0
  78. data/test/fixtures/fake_addon.json +24 -0
  79. data/test/fixtures/fake_captured_payment.json +13 -0
  80. data/test/fixtures/fake_card.json +9 -0
  81. data/test/fixtures/fake_create_upi_payment.json +3 -0
  82. data/test/fixtures/fake_customer.json +8 -0
  83. data/test/fixtures/fake_customer_edited.json +8 -0
  84. data/test/fixtures/fake_direct_transfer.json +32 -0
  85. data/test/fixtures/fake_downtime.json +14 -0
  86. data/test/fixtures/fake_fund_account.json +18 -0
  87. data/test/fixtures/fake_instant_settlement.json +19 -0
  88. data/test/fixtures/fake_invoice.json +30 -0
  89. data/test/fixtures/fake_item.json +9 -0
  90. data/test/fixtures/fake_order.json +10 -0
  91. data/test/fixtures/fake_order_transfers.json +88 -0
  92. data/test/fixtures/fake_otp_generate.json +19 -0
  93. data/test/fixtures/fake_otp_resend.json +7 -0
  94. data/test/fixtures/fake_otp_submit.json +5 -0
  95. data/test/fixtures/fake_payment.json +14 -0
  96. data/test/fixtures/fake_payment_authorized_webhook.json +40 -0
  97. data/test/fixtures/fake_payment_bank_transfer.json +12 -0
  98. data/test/fixtures/fake_payment_link.json +40 -0
  99. data/test/fixtures/fake_pending_update.json +30 -0
  100. data/test/fixtures/fake_plan.json +26 -0
  101. data/test/fixtures/fake_qrcode.json +20 -0
  102. data/test/fixtures/fake_qrcode_close.json +22 -0
  103. data/test/fixtures/fake_recurring.json +5 -0
  104. data/test/fixtures/fake_refund.json +8 -0
  105. data/test/fixtures/fake_refunded_payment.json +14 -0
  106. data/test/fixtures/fake_settlement.json +11 -0
  107. data/test/fixtures/fake_settlement_on_demand.json +39 -0
  108. data/test/fixtures/fake_subscription.json +20 -0
  109. data/test/fixtures/fake_subscription_pause.json +19 -0
  110. data/test/fixtures/fake_subscription_registration.json +91 -0
  111. data/test/fixtures/fake_subscription_resume.json +19 -0
  112. data/test/fixtures/fake_token.json +31 -0
  113. data/test/fixtures/fake_transfer.json +18 -0
  114. data/test/fixtures/fake_transfer_reverse.json +15 -0
  115. data/test/fixtures/fake_update_payment.json +39 -0
  116. data/test/fixtures/fake_validate_vpa.json +5 -0
  117. data/test/fixtures/fake_virtual_account.json +21 -0
  118. data/test/fixtures/fake_virtual_account_allowed.json +46 -0
  119. data/test/fixtures/fake_virtual_account_closed.json +21 -0
  120. data/test/fixtures/fake_virtual_account_collection.json +48 -0
  121. data/test/fixtures/fake_virtual_account_receiver.json +46 -0
  122. data/test/fixtures/fund_collection.json +20 -0
  123. data/test/fixtures/hello_response.json +3 -0
  124. data/test/fixtures/invoice_collection.json +93 -0
  125. data/test/fixtures/issue_invoice.json +44 -0
  126. data/test/fixtures/item_collection.json +24 -0
  127. data/test/fixtures/order_collection.json +36 -0
  128. data/test/fixtures/order_payments.json +29 -0
  129. data/test/fixtures/payment_collection.json +32 -0
  130. data/test/fixtures/payment_collection_with_one_payment.json +19 -0
  131. data/test/fixtures/payment_link_collection.json +43 -0
  132. data/test/fixtures/payment_link_response.json +3 -0
  133. data/test/fixtures/payment_methods_collection.json +149 -0
  134. data/test/fixtures/plan_collection.json +32 -0
  135. data/test/fixtures/qrcode_collection.json +50 -0
  136. data/test/fixtures/qrcode_payments_collection.json +74 -0
  137. data/test/fixtures/refund_collection.json +30 -0
  138. data/test/fixtures/refund_collection_for_payment.json +22 -0
  139. data/test/fixtures/settlement_collection.json +26 -0
  140. data/test/fixtures/settlement_instant_collection.json +84 -0
  141. data/test/fixtures/settlement_report_collection.json +117 -0
  142. data/test/fixtures/subscription_collection.json +26 -0
  143. data/test/fixtures/success.json +3 -0
  144. data/test/fixtures/tokens_collection.json +36 -0
  145. data/test/fixtures/transfer_settlements_collection.json +38 -0
  146. data/test/fixtures/transfers_collection.json +41 -0
  147. data/test/fixtures/update_invoice.json +44 -0
  148. data/test/fixtures/welcome.json +3 -0
  149. data/test/razorpay/test_addon.rb +76 -0
  150. data/test/razorpay/test_card.rb +23 -0
  151. data/test/razorpay/test_customer.rb +69 -0
  152. data/test/razorpay/test_entity.rb +55 -0
  153. data/test/razorpay/test_fund_account.rb +42 -0
  154. data/test/razorpay/test_invoice.rb +143 -0
  155. data/test/razorpay/test_item.rb +66 -0
  156. data/test/razorpay/test_order.rb +71 -0
  157. data/test/razorpay/test_payment.rb +303 -0
  158. data/test/razorpay/test_payment_link.rb +83 -0
  159. data/test/razorpay/test_plan.rb +65 -0
  160. data/test/razorpay/test_qr_code.rb +63 -0
  161. data/test/razorpay/test_razorpay.rb +53 -0
  162. data/test/razorpay/test_refund.rb +56 -0
  163. data/test/razorpay/test_request.rb +15 -0
  164. data/test/razorpay/test_settlement.rb +76 -0
  165. data/test/razorpay/test_subscription.rb +190 -0
  166. data/test/razorpay/test_subscription_registration.rb +58 -0
  167. data/test/razorpay/test_transfer.rb +77 -0
  168. data/test/razorpay/test_utility.rb +84 -0
  169. data/test/razorpay/test_virtual_account.rb +135 -0
  170. data/test/test_helper.rb +54 -0
  171. metadata +400 -0
@@ -0,0 +1,452 @@
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": 0,
57
+ "currency": "INR",
58
+ "method": "emandate",
59
+ "customer_id": "cust_1Aa00000000001",
60
+ "receipt": "Receipt No. 1",
61
+ "notes": {
62
+ "notes_key_1": "Beam me up Scotty",
63
+ "notes_key_2": "Engage"
64
+ },
65
+ "token": {
66
+ "first_payment_amount": 100,
67
+ "auth_type": "netbanking",
68
+ "max_amount": 9999900,
69
+ "expire_at": 4102444799,
70
+ "notes": {
71
+ "notes_key_1": "Tea, Earl Grey, Hot",
72
+ "notes_key_2": "Tea, Earl Grey… decaf."
73
+ },
74
+ "bank_account": {
75
+ "beneficiary_name": "Gaurav Kumar",
76
+ "account_number": "1121431121541121",
77
+ "account_type": "savings",
78
+ "ifsc_code": "HDFC0000001"
79
+ }
80
+ }
81
+ }
82
+
83
+ Razorpay::Order.create(para_attr)
84
+ ```
85
+
86
+ **Parameters:**
87
+
88
+ | Name | Type | Description |
89
+ |-----------------|---------|------------------------------------------------------------------------------|
90
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
91
+ | currency* | string | The currency of the payment (defaults to INR) |
92
+ | customerId* | string | The id of the customer to be fetched |
93
+ | method* | string | Payment method used to make the registration transaction. Possible value is `emandate`. |
94
+ | receipt | string | Your system order reference id. |
95
+ | 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. |
96
+ | token | object | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#112-create-an-order) are supported |
97
+ | notes | object | A key-value pair |
98
+
99
+ **Response:**
100
+ For create order response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#112-create-an-order)
101
+
102
+ -------------------------------------------------------------------------------------------------------
103
+
104
+ ### Create an Authorization Payment
105
+
106
+ Please refer this [doc](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#113-create-an-authorization-payment) for authorization payment
107
+
108
+ -----------------------------------------------------------------------------------------------------
109
+
110
+ ### Create registration link
111
+
112
+ ```rb
113
+ para_attr = {
114
+ "customer": {
115
+ "name": "Gaurav Kumar",
116
+ "email": "gaurav.kumar@example.com",
117
+ "contact": 9123456780
118
+ },
119
+ "type": "link",
120
+ "amount": 100,
121
+ "currency": "INR",
122
+ "description": "Registration Link for Gaurav Kumar",
123
+ "subscription_registration": {
124
+ "first_payment_amount": 100,
125
+ "method": "emandate",
126
+ "auth_type": "netbanking",
127
+ "max_amount": 50000,
128
+ "expire_at": 1634215992,
129
+ "bank_account": {
130
+ "beneficiary_name": "Gaurav Kumar",
131
+ "account_number": 11214311215411,
132
+ "account_type": "savings",
133
+ "ifsc_code": "HDFC0001233"
134
+ }
135
+ },
136
+ "receipt": "Receipt No. 5",
137
+ "email_notify": 1,
138
+ "sms_notify": 1,
139
+ "expire_by": 1634215992,
140
+ "notes": {
141
+ "note_key 1": "Beam me up Scotty",
142
+ "note_key 2": "Tea. Earl Gray. Hot."
143
+ }
144
+ }
145
+ Razorpay::SubscriptionRegistration.create(para_attr)
146
+ ```
147
+
148
+ **Parameters:**
149
+
150
+ | Name | Type | Description |
151
+ |-----------------|---------|---------------------------------------------------------------|
152
+ | customer | object | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#12-using-a-registration-link) are supported |
153
+ | type* | object | the value is `link`. |
154
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
155
+ | currency* | string | The currency of the payment (defaults to INR) |
156
+ | description* | string | A brief description of the payment. |
157
+ | subscription_registration | object | All keys listed [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#121-create-a-registration-link) are supported |
158
+ | receipt | string | Your system order reference id. |
159
+ | sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
160
+ | email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
161
+ | expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
162
+ | notes | object | A key-value pair |
163
+
164
+ **Response:**
165
+ For create registration link response please click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/#12-using-a-registration-link)
166
+
167
+ -------------------------------------------------------------------------------------------------------
168
+
169
+ ## Create an order to charge the customer
170
+
171
+ ```rb
172
+ para_attr ={
173
+ "amount": "100",
174
+ "currency": "INR",
175
+ "receipt": "Receipt No. 1",
176
+ "payment_capture": true,
177
+ "notes": {
178
+ "key1": "value3",
179
+ "key2": "value2"
180
+ }
181
+ }
182
+ Razorpay::Order.create(para_attr)
183
+ ```
184
+ **Parameters:**
185
+
186
+ | Name | Type | Description |
187
+ |-----------------|---------|------------------------------------------------------------------------------|
188
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
189
+ | currency* | string | The currency of the payment (defaults to INR) |
190
+ | receipt | string | Your system order reference id. |
191
+ | 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. |
192
+ | notes | object | A key-value pair |
193
+
194
+ **Response:**
195
+ ```json
196
+ {
197
+ "id":"order_1Aa00000000002",
198
+ "entity":"order",
199
+ "amount":1000,
200
+ "amount_paid":0,
201
+ "amount_due":1000,
202
+ "currency":"INR",
203
+ "receipt":"Receipt No. 1",
204
+ "offer_id":null,
205
+ "status":"created",
206
+ "attempts":0,
207
+ "notes":{
208
+ "notes_key_1":"Tea, Earl Grey, Hot",
209
+ "notes_key_2":"Tea, Earl Grey… decaf."
210
+ },
211
+ "created_at":1579782776
212
+ }
213
+ ```
214
+ -------------------------------------------------------------------------------------------------------
215
+
216
+ ## Create a recurring payment
217
+
218
+ ```rb
219
+ para_attr = {
220
+ "email": "gaurav.kumar@example.com",
221
+ "contact": "9123456789",
222
+ "amount": 1000,
223
+ "currency": "INR",
224
+ "order_id": "order_1Aa00000000002",
225
+ "customer_id": "cust_1Aa00000000001",
226
+ "token": "token_1Aa00000000001",
227
+ "recurring": "1",
228
+ "description": "Creating recurring payment for Gaurav Kumar",
229
+ "notes": {
230
+ "note_key 1": "Beam me up Scotty",
231
+ "note_key 2": "Tea. Earl Gray. Hot."
232
+ }
233
+ }
234
+ Razorpay::Payment.create_recurring_payment(para_attr)
235
+ ```
236
+ **Parameters:**
237
+
238
+ | Name | Type | Description |
239
+ |-----------------|---------|------------------------------------------------------------------------------|
240
+ | email* | string | The customer's email address |
241
+ | contact* | string | The customer's phone number |
242
+ | amount* | integer | The amount to be captured (should be equal to the authorized amount, in paise) |
243
+ | currency* | string | The currency of the payment (defaults to INR) |
244
+ | orderId* | string | The id of the order to be fetched |
245
+ | customerId* | string | The id of the customer to be fetched |
246
+ | tokenId* | string | The id of the token to be fetched |
247
+ | recurring* | boolean | Possible values is `0` or `1` |
248
+ | description | string | A brief description of the payment. |
249
+ | notes | object | A key-value pair |
250
+
251
+ **Response:**
252
+ ```json
253
+ {
254
+ "razorpay_payment_id" : "pay_1Aa00000000001",
255
+ "razorpay_order_id" : "order_1Aa00000000001",
256
+ "razorpay_signature" : "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
257
+ }
258
+ ```
259
+ -------------------------------------------------------------------------------------------------------
260
+
261
+ ## Send/Resend notifications
262
+
263
+ ```rb
264
+ invoiceId = "inv_JDdNb4xdf4gxQ7"
265
+
266
+ medium = "email"
267
+
268
+ Razorpay::Invoice.notify_by(invoiceId, medium)
269
+ ```
270
+ **Parameters:**
271
+
272
+ | Name | Type |Description |
273
+ |-----------------|---------|------------------------------------------------------------------------------|
274
+ | invoiceId* | string | The id of the invoice to be fetched |
275
+ | medium* | string | Possible values are `sms` or `email` |
276
+
277
+ **Response:**
278
+ ```json
279
+ {
280
+ "success": true
281
+ }
282
+ ```
283
+ -------------------------------------------------------------------------------------------------------
284
+
285
+ ## Cancel registration link
286
+
287
+ ```rb
288
+ Razorpay::Invoice.cancel(invoiceId);
289
+ ```
290
+ **Parameters:**
291
+
292
+ | Name | Type | Description |
293
+ |-----------------|---------|------------------------------------------------------------------------------|
294
+ | invoiceId* | string | The id of the invoice to be fetched |
295
+
296
+ **Response:**
297
+ ```json
298
+ {
299
+ "id": "inv_FHrfRupD2ouKIt",
300
+ "entity": "invoice",
301
+ "receipt": "Receipt No. 1",
302
+ "invoice_number": "Receipt No. 1",
303
+ "customer_id": "cust_BMB3EwbqnqZ2EI",
304
+ "customer_details": {
305
+ "id": "cust_BMB3EwbqnqZ2EI",
306
+ "name": "Gaurav Kumar",
307
+ "email": "gaurav.kumar@example.com",
308
+ "contact": "9123456780",
309
+ "gstin": null,
310
+ "billing_address": null,
311
+ "shipping_address": null,
312
+ "customer_name": "Gaurav Kumar",
313
+ "customer_email": "gaurav.kumar@example.com",
314
+ "customer_contact": "9123456780"
315
+ },
316
+ "order_id": "order_FHrfRw4TZU5Q2L",
317
+ "line_items": [],
318
+ "payment_id": null,
319
+ "status": "cancelled",
320
+ "expire_by": 4102444799,
321
+ "issued_at": 1595491479,
322
+ "paid_at": null,
323
+ "cancelled_at": 1595491488,
324
+ "expired_at": null,
325
+ "sms_status": "sent",
326
+ "email_status": "sent",
327
+ "date": 1595491479,
328
+ "terms": null,
329
+ "partial_payment": false,
330
+ "gross_amount": 100,
331
+ "tax_amount": 0,
332
+ "taxable_amount": 0,
333
+ "amount": 100,
334
+ "amount_paid": 0,
335
+ "amount_due": 100,
336
+ "currency": "INR",
337
+ "currency_symbol": "₹",
338
+ "description": "Registration Link for Gaurav Kumar",
339
+ "notes": {
340
+ "note_key 1": "Beam me up Scotty",
341
+ "note_key 2": "Tea. Earl Gray. Hot."
342
+ },
343
+ "comment": null,
344
+ "short_url": "https://rzp.io/i/QlfexTj",
345
+ "view_less": true,
346
+ "billing_start": null,
347
+ "billing_end": null,
348
+ "type": "link",
349
+ "group_taxes_discounts": false,
350
+ "created_at": 1595491480,
351
+ "idempotency_key": null
352
+ }
353
+ ```
354
+ -------------------------------------------------------------------------------------------------------
355
+
356
+ ## Fetch token by payment id
357
+
358
+ ```rb
359
+ paymentId = "pay_FHf9a7AO0iXM9I"
360
+
361
+ Razorpay::Payment.fetch(paymentId)
362
+ ```
363
+ **Parameters:**
364
+
365
+ | Name | Type | Description |
366
+ |-----------------|---------|------------------------------------------------------------------------------|
367
+ | paymentId* | string | The id of the payment to be fetched |
368
+
369
+ **Response:**
370
+ 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)
371
+
372
+ -------------------------------------------------------------------------------------------------------
373
+
374
+ ## Fetch tokens by customer id
375
+
376
+ ```rb
377
+ customerId = "cust_1Aa00000000004"
378
+
379
+ Razorpay::Customer.fetch(customerId).fetchTokens
380
+ ```
381
+ **Parameters:**
382
+
383
+ | Name | Type | Description |
384
+ |-----------------|---------|------------------------------------------------------------------------------|
385
+ | customerId* | string | The id of the customer to be fetched |
386
+
387
+ **Response:**
388
+ ```json
389
+ {
390
+ "entity": "collection",
391
+ "count": 1,
392
+ "items": [
393
+ {
394
+ "id": "token_FHf94Uym9tdYFJ",
395
+ "entity": "token",
396
+ "token": "2wDPM7VAlXtjAR",
397
+ "bank": "HDFC",
398
+ "wallet": null,
399
+ "method": "emandate",
400
+ "vpa": null,
401
+ "recurring": true,
402
+ "recurring_details": {
403
+ "status": "confirmed",
404
+ "failure_reason": null
405
+ },
406
+ "auth_type": "netbanking",
407
+ "mrn": null,
408
+ "used_at": 1595447381,
409
+ "created_at": 1595447381,
410
+ "bank_details": {
411
+ "beneficiary_name": "Gaurav Kumar",
412
+ "account_number": "1121431121541121",
413
+ "ifsc": "HDFC0000001",
414
+ "account_type": "savings"
415
+ },
416
+ "max_amount": 9999900,
417
+ "expired_at": 1689971140,
418
+ "dcc_enabled": false
419
+ }
420
+ ]
421
+ }
422
+ ```
423
+ -------------------------------------------------------------------------------------------------------
424
+
425
+ ## Delete tokens
426
+
427
+ ```rb
428
+ customerId = "cust_1Aa00000000004"
429
+
430
+ tokenId = "token_Hxe0skTXLeg9pF"
431
+
432
+ Razorpay::Customer.fetch(customerId).deleteToken(tokenId)
433
+ ```
434
+ **Parameters:**
435
+
436
+ | Name | Type | Description |
437
+ |-----------------|---------|------------------------------------------------------------------------------|
438
+ | customerId* | string | The id of the customer to be fetched |
439
+ | tokenId* | string | The id of the token to be fetched |
440
+
441
+ **Response:**
442
+ ```json
443
+ {
444
+ "deleted": true
445
+ }
446
+ ```
447
+ -------------------------------------------------------------------------------------------------------
448
+
449
+ **PN: * indicates mandatory fields**
450
+ <br>
451
+ <br>
452
+ **For reference click [here](https://razorpay.com/docs/api/recurring-payments/emandate/auto-debit/)**