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,539 @@
1
+ ## Invoices
2
+
3
+ ### Create Invoice
4
+
5
+ Request #1
6
+ In this example, an invoice is created using the customer and item details. Here, the customer and item are created while creating the invoice.
7
+ ```rb
8
+ Razorpay::Invoice.create({
9
+ "type": "invoice",
10
+ "description": "Invoice for the month of January 2020",
11
+ "partial_payment": true,
12
+ "customer": {
13
+ "name": "Gaurav Kumar",
14
+ "contact": 9999999999,
15
+ "email": "gaurav.kumar@example.com",
16
+ "billing_address": {
17
+ "line1": "Ground & 1st Floor, SJR Cyber Laskar",
18
+ "line2": "Hosur Road",
19
+ "zipcode": 560068,
20
+ "city": "Bengaluru",
21
+ "state": "Karnataka",
22
+ "country": "in"
23
+ },
24
+ "shipping_address": {
25
+ "line1": "Ground & 1st Floor, SJR Cyber Laskar",
26
+ "line2": "Hosur Road",
27
+ "zipcode": 560068,
28
+ "city": "Bengaluru",
29
+ "state": "Karnataka",
30
+ "country": "in"
31
+ }
32
+ },
33
+ "line_items": [
34
+ {
35
+ "name": "Master Cloud Computing in 30 Days",
36
+ "description": "Book by Ravena Ravenclaw",
37
+ "amount": 399,
38
+ "currency": "USD",
39
+ "quantity": 1
40
+ }
41
+ ],
42
+ "sms_notify": 1,
43
+ "email_notify": 1,
44
+ "currency": "USD",
45
+ "expire_by": 1589765167
46
+ })
47
+ ```
48
+
49
+ Request #2
50
+ In this example, an invoice is created using existing `customer_id` and `item_id`
51
+ ```rb
52
+ Razorpay::Invoice.create({
53
+ "type": "invoice",
54
+ "date": 1589994898,
55
+ "customer_id": "cust_E7q0trFqXgExmT",
56
+ "line_items": [
57
+ {
58
+ "item_id": "item_DRt61i2NnL8oy6"
59
+ }
60
+ ]
61
+ })
62
+ ```
63
+
64
+ **Parameters:**
65
+
66
+ | Name | Type | Description |
67
+ |-----------------|---------|------------------------------------------------------------------------------|
68
+ |type* | string | entity type (here its invoice) |
69
+ |description | string | A brief description of the invoice. |
70
+ |customer_id | string | customer id for which invoice need be raised |
71
+ |draft | string | Invoice is created in draft state when value is set to `1` |
72
+ | customer.name* | object | All parameters listed [here](https://razorpay.com/docs/api/payments/invoices/#create-an-invoice) are supported |
73
+ | line_items | object | All parameters listed [here](https://razorpay.com/docs/api/payments/invoices/#create-an-invoice) are supported |
74
+
75
+ |expire_by | object | Details of the line item that is billed in the invoice. |
76
+ |sms_notify | object | Details of the line item that is billed in the invoice. |
77
+ |email_notify | object | Details of the line item that is billed in the invoice. |
78
+ |partial_payment | boolean | Indicates whether customers can make partial payments on the invoice . Possible values: true - Customer can make partial payments. false (default) - Customer cannot make partial payments. |
79
+ | currency* | string | The currency of the payment (defaults to INR) |
80
+
81
+ **Response:**
82
+ For create invoice response please click [here](https://razorpay.com/docs/api/invoices/#create-an-invoice)
83
+
84
+ -------------------------------------------------------------------------------------------------------
85
+
86
+ ### Fetch all invoices
87
+
88
+ ```rb
89
+ Razorpay::Invoice.all(options)
90
+ ```
91
+
92
+ **Parameters:**
93
+
94
+ | Name | Type | Description |
95
+ |-----------------|---------|------------------------------------------------------------------------------|
96
+ |type | string | entity type (here its invoice) |
97
+ |payment_id | string | The unique identifier of the payment made by the customer against the invoice. |
98
+ |customer_id | string | The unique identifier of the customer. |
99
+ |receipt | string | The unique receipt number that you entered for internal purposes. |
100
+
101
+ **Response:**
102
+ For fetch all invoice response please click [here](https://razorpay.com/docs/api/invoices/#fetch-multiple-invoices)
103
+
104
+ -------------------------------------------------------------------------------------------------------
105
+
106
+ ### Fetch invoice
107
+
108
+ ```rb
109
+ Razorpay::Invoice.fetch(invoiceId)
110
+ ```
111
+
112
+ **Parameters:**
113
+
114
+ | Name | Type | Description |
115
+ |-----------------|---------|------------------------------------------------------------------------------|
116
+ | invoiceId* | string | The id of the invoice to be fetched |
117
+
118
+ **Response:**
119
+ ```json
120
+ {
121
+ "id": "inv_E7q0tqkxBRzdau",
122
+ "entity": "invoice",
123
+ "receipt": null,
124
+ "invoice_number": null,
125
+ "customer_id": "cust_E7q0trFqXgExmT",
126
+ "customer_details": {
127
+ "id": "cust_E7q0trFqXgExmT",
128
+ "name": "Gaurav Kumar",
129
+ "email": "gaurav.kumar@example.com",
130
+ "contact": "9999999999",
131
+ "gstin": null,
132
+ "billing_address": {
133
+ "id": "addr_E7q0ttqh4SGhAC",
134
+ "type": "billing_address",
135
+ "primary": true,
136
+ "line1": "Ground & 1st Floor, SJR Cyber Laskar",
137
+ "line2": "Hosur Road",
138
+ "zipcode": "560068",
139
+ "city": "Bengaluru",
140
+ "state": "Karnataka",
141
+ "country": "in"
142
+ },
143
+ "shipping_address": {
144
+ "id": "addr_E7q0ttKwVA1h2V",
145
+ "type": "shipping_address",
146
+ "primary": true,
147
+ "line1": "Ground & 1st Floor, SJR Cyber Laskar",
148
+ "line2": "Hosur Road",
149
+ "zipcode": "560068",
150
+ "city": "Bengaluru",
151
+ "state": "Karnataka",
152
+ "country": "in"
153
+ },
154
+ "customer_name": "Gaurav Kumar",
155
+ "customer_email": "gaurav.kumar@example.com",
156
+ "customer_contact": "9999999999"
157
+ },
158
+ "order_id": "order_E7q0tvRpC0WJwg",
159
+ "line_items": [
160
+ {
161
+ "id": "li_E7q0tuPNg84VbZ",
162
+ "item_id": null,
163
+ "ref_id": null,
164
+ "ref_type": null,
165
+ "name": "Master Cloud Computing in 30 Days",
166
+ "description": "Book by Ravena Ravenclaw",
167
+ "amount": 399,
168
+ "unit_amount": 399,
169
+ "gross_amount": 399,
170
+ "tax_amount": 0,
171
+ "taxable_amount": 399,
172
+ "net_amount": 399,
173
+ "currency": "INR",
174
+ "type": "invoice",
175
+ "tax_inclusive": false,
176
+ "hsn_code": null,
177
+ "sac_code": null,
178
+ "tax_rate": null,
179
+ "unit": null,
180
+ "quantity": 1,
181
+ "taxes": []
182
+ }
183
+ ],
184
+ "payment_id": null,
185
+ "status": "issued",
186
+ "expire_by": 1589765167,
187
+ "issued_at": 1579765167,
188
+ "paid_at": null,
189
+ "cancelled_at": null,
190
+ "expired_at": null,
191
+ "sms_status": "pending",
192
+ "email_status": "pending",
193
+ "date": 1579765167,
194
+ "terms": null,
195
+ "partial_payment": true,
196
+ "gross_amount": 399,
197
+ "tax_amount": 0,
198
+ "taxable_amount": 399,
199
+ "amount": 399,
200
+ "amount_paid": 0,
201
+ "amount_due": 399,
202
+ "currency": "INR",
203
+ "currency_symbol": "₹",
204
+ "description": "Invoice for the month of January 2020",
205
+ "notes": [],
206
+ "comment": null,
207
+ "short_url": "https://rzp.io/i/2wxV8Xs",
208
+ "view_less": true,
209
+ "billing_start": null,
210
+ "billing_end": null,
211
+ "type": "invoice",
212
+ "group_taxes_discounts": false,
213
+ "created_at": 1579765167
214
+ }
215
+ ```
216
+ -------------------------------------------------------------------------------------------------------
217
+
218
+ ### Update invoice
219
+
220
+ ```rb
221
+ invoiceId = "inv_E7q0tqkxBRzdau"
222
+
223
+ para_attr = {
224
+ "line_items": [
225
+ {
226
+ "id": "li_JDb7pfe5VNwkZD",
227
+ "name": "Book / English August - Updated name and quantity",
228
+ "quantity": 1
229
+ },
230
+ {
231
+ "name": "Book / A Wild Sheep Chase",
232
+ "amount": 200,
233
+ "currency": "INR",
234
+ "quantity": 1
235
+ }
236
+ ],
237
+ "notes": {
238
+ "updated-key": "An updated note. done"
239
+ }
240
+ }
241
+
242
+ Razorpay::Invoice.edit(invoiceId,para_attr)
243
+ ```
244
+
245
+ **Parameters:**
246
+
247
+ | Name | Type | Description |
248
+ |-----------------|---------|------------------------------------------------------------------------------|
249
+ | invoiceId* | string | The id of the invoice to be fetched |
250
+
251
+ **Response:**
252
+ For update invoice response please click [here](https://razorpay.com/docs/api/invoices/#update-an-invoice)
253
+
254
+ -------------------------------------------------------------------------------------------------------
255
+
256
+ ### Issue an invoice
257
+
258
+ ```rb
259
+ Razorpay::Invoice.issue(invoiceId)
260
+ ```
261
+
262
+ **Parameters:**
263
+
264
+ | Name | Type | Description |
265
+ |-----------------|---------|------------------------------------------------------------------------------|
266
+ | invoiceId* | string | The id of the invoice to be issued |
267
+
268
+ **Response:**
269
+ ```json
270
+ {
271
+ "id": "inv_DAweOiQ7amIUVd",
272
+ "entity": "invoice",
273
+ "receipt": "#0961",
274
+ "invoice_number": "#0961",
275
+ "customer_id": "cust_DAtUWmvpktokrT",
276
+ "customer_details": {
277
+ "id": "cust_DAtUWmvpktokrT",
278
+ "name": "Gaurav Kumar",
279
+ "email": "gaurav.kumar@example.com",
280
+ "contact": "9977886633",
281
+ "gstin": null,
282
+ "billing_address": {
283
+ "id": "addr_DAtUWoxgu91obl",
284
+ "type": "billing_address",
285
+ "primary": true,
286
+ "line1": "318 C-Wing, Suyog Co. Housing Society Ltd.",
287
+ "line2": "T.P.S Road, Vazira, Borivali",
288
+ "zipcode": "400092",
289
+ "city": "Mumbai",
290
+ "state": "Maharashtra",
291
+ "country": "in"
292
+ },
293
+ "shipping_address": null,
294
+ "customer_name": "Gaurav Kumar",
295
+ "customer_email": "gaurav.kumar@example.com",
296
+ "customer_contact": "9977886633"
297
+ },
298
+ "order_id": "order_DBG3P8ZgDd1dsG",
299
+ "line_items": [
300
+ {
301
+ "id": "li_DAweOizsysoJU6",
302
+ "item_id": null,
303
+ "name": "Book / English August - Updated name and quantity",
304
+ "description": "150 points in Quidditch",
305
+ "amount": 400,
306
+ "unit_amount": 400,
307
+ "gross_amount": 400,
308
+ "tax_amount": 0,
309
+ "taxable_amount": 400,
310
+ "net_amount": 400,
311
+ "currency": "INR",
312
+ "type": "invoice",
313
+ "tax_inclusive": false,
314
+ "hsn_code": null,
315
+ "sac_code": null,
316
+ "tax_rate": null,
317
+ "unit": null,
318
+ "quantity": 1,
319
+ "taxes": []
320
+ },
321
+ {
322
+ "id": "li_DAwjWQUo07lnjF",
323
+ "item_id": null,
324
+ "name": "Book / A Wild Sheep Chase",
325
+ "description": null,
326
+ "amount": 200,
327
+ "unit_amount": 200,
328
+ "gross_amount": 200,
329
+ "tax_amount": 0,
330
+ "taxable_amount": 200,
331
+ "net_amount": 200,
332
+ "currency": "INR",
333
+ "type": "invoice",
334
+ "tax_inclusive": false,
335
+ "hsn_code": null,
336
+ "sac_code": null,
337
+ "tax_rate": null,
338
+ "unit": null,
339
+ "quantity": 1,
340
+ "taxes": []
341
+ }
342
+ ],
343
+ "payment_id": null,
344
+ "status": "issued",
345
+ "expire_by": 1567103399,
346
+ "issued_at": 1566974805,
347
+ "paid_at": null,
348
+ "cancelled_at": null,
349
+ "expired_at": null,
350
+ "sms_status": null,
351
+ "email_status": null,
352
+ "date": 1566891149,
353
+ "terms": null,
354
+ "partial_payment": false,
355
+ "gross_amount": 600,
356
+ "tax_amount": 0,
357
+ "taxable_amount": 600,
358
+ "amount": 600,
359
+ "amount_paid": 0,
360
+ "amount_due": 600,
361
+ "currency": "INR",
362
+ "currency_symbol": "₹",
363
+ "description": "This is a test invoice.",
364
+ "notes": {
365
+ "updated-key": "An updated note."
366
+ },
367
+ "comment": null,
368
+ "short_url": "https://rzp.io/i/K8Zg72C",
369
+ "view_less": true,
370
+ "billing_start": null,
371
+ "billing_end": null,
372
+ "type": "invoice",
373
+ "group_taxes_discounts": false,
374
+ "created_at": 1566906474,
375
+ "idempotency_key": null
376
+ }
377
+ ```
378
+ -------------------------------------------------------------------------------------------------------
379
+
380
+ ### Delete an invoice
381
+
382
+ ```rb
383
+ Razorpay::Invoice.delete(invoiceId)
384
+ ```
385
+
386
+ **Parameters:**
387
+
388
+ | Name | Type | Description |
389
+ |-----------------|---------|------------------------------------------------------------------------------|
390
+ | invoiceId* | string | The id of the invoice to be deleted |
391
+
392
+ **Response:**
393
+ ```
394
+ []
395
+ ```
396
+ -------------------------------------------------------------------------------------------------------
397
+
398
+ ### Cancel an invoice
399
+
400
+ ```rb
401
+ Razorpay::Invoice.cancel(invoiceId)
402
+ ```
403
+
404
+ **Parameters:**
405
+
406
+ | Name | Type | Description |
407
+ |-----------------|---------|------------------------------------------------------------------------------|
408
+ | invoiceId* | string | The id of the invoice to be cancelled |
409
+
410
+ **Response:**
411
+ ```json
412
+ {
413
+ "id": "inv_E7q0tqkxBRzdau",
414
+ "entity": "invoice",
415
+ "receipt": null,
416
+ "invoice_number": null,
417
+ "customer_id": "cust_E7q0trFqXgExmT",
418
+ "customer_details": {
419
+ "id": "cust_E7q0trFqXgExmT",
420
+ "name": "Gaurav Kumar",
421
+ "email": "gaurav.kumar@example.com",
422
+ "contact": "9972132594",
423
+ "gstin": null,
424
+ "billing_address": {
425
+ "id": "addr_E7q0ttqh4SGhAC",
426
+ "type": "billing_address",
427
+ "primary": true,
428
+ "line1": "Ground & 1st Floor, SJR Cyber Laskar",
429
+ "line2": "Hosur Road",
430
+ "zipcode": "560068",
431
+ "city": "Bengaluru",
432
+ "state": "Karnataka",
433
+ "country": "in"
434
+ },
435
+ "shipping_address": {
436
+ "id": "addr_E7q0ttKwVA1h2V",
437
+ "type": "shipping_address",
438
+ "primary": true,
439
+ "line1": "Ground & 1st Floor, SJR Cyber Laskar",
440
+ "line2": "Hosur Road",
441
+ "zipcode": "560068",
442
+ "city": "Bengaluru",
443
+ "state": "Karnataka",
444
+ "country": "in"
445
+ },
446
+ "customer_name": "Gaurav Kumar",
447
+ "customer_email": "gaurav.kumar@example.com",
448
+ "customer_contact": "9972132594"
449
+ },
450
+ "order_id": "order_E7q0tvRpC0WJwg",
451
+ "line_items": [
452
+ {
453
+ "id": "li_E7q0tuPNg84VbZ",
454
+ "item_id": null,
455
+ "ref_id": null,
456
+ "ref_type": null,
457
+ "name": "Master Cloud Computing in 30 Days",
458
+ "description": "Book by Ravena Ravenclaw",
459
+ "amount": 399,
460
+ "unit_amount": 399,
461
+ "gross_amount": 399,
462
+ "tax_amount": 0,
463
+ "taxable_amount": 399,
464
+ "net_amount": 399,
465
+ "currency": "INR",
466
+ "type": "invoice",
467
+ "tax_inclusive": false,
468
+ "hsn_code": null,
469
+ "sac_code": null,
470
+ "tax_rate": null,
471
+ "unit": null,
472
+ "quantity": 1,
473
+ "taxes": []
474
+ }
475
+ ],
476
+ "payment_id": null,
477
+ "status": "cancelled",
478
+ "expire_by": null,
479
+ "issued_at": 1579765167,
480
+ "paid_at": null,
481
+ "cancelled_at": 1579768206,
482
+ "expired_at": null,
483
+ "sms_status": "sent",
484
+ "email_status": "sent",
485
+ "date": 1579765167,
486
+ "terms": null,
487
+ "partial_payment": false,
488
+ "gross_amount": 399,
489
+ "tax_amount": 0,
490
+ "taxable_amount": 399,
491
+ "amount": 399,
492
+ "amount_paid": 0,
493
+ "amount_due": 399,
494
+ "currency": "INR",
495
+ "currency_symbol": "₹",
496
+ "description": null,
497
+ "notes": [],
498
+ "comment": null,
499
+ "short_url": "https://rzp.io/i/2wxV8Xs",
500
+ "view_less": true,
501
+ "billing_start": null,
502
+ "billing_end": null,
503
+ "type": "invoice",
504
+ "group_taxes_discounts": false,
505
+ "created_at": 1579765167,
506
+ "idempotency_key": null
507
+ }
508
+ ```
509
+ -------------------------------------------------------------------------------------------------------
510
+
511
+ ### Send notification
512
+
513
+ ```rb
514
+ invoiceId = "inv_E7q0tqkxBRzdau"
515
+
516
+ medium = "email"
517
+
518
+ Razorpay::Invoice.notify_by(invoiceId,medium)
519
+ ```
520
+
521
+ **Parameters:**
522
+
523
+ | Name | Type | Description |
524
+ |-----------------|---------|------------------------------------------------------------------------------|
525
+ | invoiceId* | string | The id of the invoice to be notified |
526
+ | medium* | string | `sms`/`email`, Medium through which notification should be sent. |
527
+
528
+ **Response:**
529
+ ```json
530
+ {
531
+ "success": true
532
+ }
533
+ ```
534
+ -------------------------------------------------------------------------------------------------------
535
+
536
+ **PN: * indicates mandatory fields**
537
+ <br>
538
+ <br>
539
+ **For reference click [here](https://razorpay.com/docs/api/invoices)**