razorpay 2.4.0 → 3.2.4

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 (185) hide show
  1. checksums.yaml +4 -4
  2. data/.cursorignore +174 -0
  3. data/.github/dependabot.yml +8 -0
  4. data/.github/pull_request_template.md +8 -0
  5. data/.github/workflows/ci.yml +80 -0
  6. data/.github/workflows/ruby.yml +38 -0
  7. data/CHANGELOG.md +85 -1
  8. data/README.md +48 -137
  9. data/documents/Invoice.md +539 -0
  10. data/documents/account.md +449 -0
  11. data/documents/addon.md +191 -0
  12. data/documents/card.md +655 -0
  13. data/documents/customer.md +405 -0
  14. data/documents/dispute.md +301 -0
  15. data/documents/documents.md +65 -0
  16. data/documents/emandate.md +492 -0
  17. data/documents/fund.md +89 -0
  18. data/documents/items.md +208 -0
  19. data/documents/oauth_token.md +142 -0
  20. data/documents/order.md +352 -0
  21. data/documents/papernach.md +738 -0
  22. data/documents/payment.md +1122 -0
  23. data/documents/paymentLink.md +1063 -0
  24. data/documents/paymentVerification.md +79 -0
  25. data/documents/plan.md +184 -0
  26. data/documents/productConfiguration.md +444 -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/stakeholder.md +334 -0
  33. data/documents/subscriptions.md +752 -0
  34. data/documents/tokens.md +407 -0
  35. data/documents/transfers.md +821 -0
  36. data/documents/upi.md +545 -0
  37. data/documents/virtualAccount.md +591 -0
  38. data/documents/webhook.md +224 -0
  39. data/lib/razorpay/account.rb +39 -0
  40. data/lib/razorpay/addon.rb +9 -1
  41. data/lib/razorpay/card.rb +4 -0
  42. data/lib/razorpay/constants.rb +7 -2
  43. data/lib/razorpay/customer.rb +31 -0
  44. data/lib/razorpay/dispute.rb +26 -0
  45. data/lib/razorpay/document.rb +19 -0
  46. data/lib/razorpay/fund_account.rb +19 -0
  47. data/lib/razorpay/iin.rb +15 -0
  48. data/lib/razorpay/invoice.rb +8 -0
  49. data/lib/razorpay/item.rb +34 -0
  50. data/lib/razorpay/oauth_token.rb +109 -0
  51. data/lib/razorpay/order.rb +19 -1
  52. data/lib/razorpay/payload_validator.rb +93 -0
  53. data/lib/razorpay/payment.rb +64 -0
  54. data/lib/razorpay/payment_link.rb +36 -0
  55. data/lib/razorpay/payment_method.rb +17 -0
  56. data/lib/razorpay/product.rb +37 -0
  57. data/lib/razorpay/qr_code.rb +34 -0
  58. data/lib/razorpay/refund.rb +4 -0
  59. data/lib/razorpay/request.rb +50 -26
  60. data/lib/razorpay/settlement.rb +39 -0
  61. data/lib/razorpay/stakeholder.rb +39 -0
  62. data/lib/razorpay/subscription.rb +24 -0
  63. data/lib/razorpay/subscription_registration.rb +16 -0
  64. data/lib/razorpay/token.rb +28 -0
  65. data/lib/razorpay/transfer.rb +39 -0
  66. data/lib/razorpay/utility.rb +41 -6
  67. data/lib/razorpay/validation_config.rb +11 -0
  68. data/lib/razorpay/virtual_account.rb +15 -7
  69. data/lib/razorpay/webhook.rb +50 -0
  70. data/lib/razorpay.rb +24 -1
  71. data/razorpay-ruby.gemspec +2 -1
  72. data/test/fixtures/addon_collection.json +60 -0
  73. data/test/fixtures/create_json_payment.json +13 -0
  74. data/test/fixtures/delete_token.json +3 -0
  75. data/test/fixtures/dispute_collection.json +67 -0
  76. data/test/fixtures/dispute_error.json +10 -0
  77. data/test/fixtures/document_error.json +10 -0
  78. data/test/fixtures/downtimes_collection.json +21 -0
  79. data/test/fixtures/empty.json +2 -0
  80. data/test/fixtures/error_customer.json +10 -0
  81. data/test/fixtures/error_eligibility.json +10 -0
  82. data/test/fixtures/error_eligibility_check.json +10 -0
  83. data/test/fixtures/fake_account.json +78 -0
  84. data/test/fixtures/fake_addon.json +3 -3
  85. data/test/fixtures/fake_bank_account.json +9 -0
  86. data/test/fixtures/fake_card_reference.json +5 -0
  87. data/test/fixtures/fake_create_upi_payment.json +3 -0
  88. data/test/fixtures/fake_direct_transfer.json +32 -0
  89. data/test/fixtures/fake_dispute.json +29 -0
  90. data/test/fixtures/fake_document.json +9 -0
  91. data/test/fixtures/fake_downtime.json +14 -0
  92. data/test/fixtures/fake_eligiblity.json +79 -0
  93. data/test/fixtures/fake_fulfillment.json +10 -0
  94. data/test/fixtures/fake_fund_account.json +18 -0
  95. data/test/fixtures/fake_iin_token.json +23 -0
  96. data/test/fixtures/fake_instant_settlement.json +19 -0
  97. data/test/fixtures/fake_item.json +9 -0
  98. data/test/fixtures/fake_oauth_token.json +8 -0
  99. data/test/fixtures/fake_order_transfers.json +88 -0
  100. data/test/fixtures/fake_otp_generate.json +19 -0
  101. data/test/fixtures/fake_otp_resend.json +7 -0
  102. data/test/fixtures/fake_otp_submit.json +5 -0
  103. data/test/fixtures/fake_payment_expanded_details.json +38 -0
  104. data/test/fixtures/fake_payment_expanded_details_card.json +50 -0
  105. data/test/fixtures/fake_payment_link.json +40 -0
  106. data/test/fixtures/fake_pending_update.json +30 -0
  107. data/test/fixtures/fake_product.json +138 -0
  108. data/test/fixtures/fake_qrcode.json +20 -0
  109. data/test/fixtures/fake_qrcode_close.json +22 -0
  110. data/test/fixtures/fake_recurring.json +5 -0
  111. data/test/fixtures/fake_refund.json +1 -1
  112. data/test/fixtures/fake_revoke_token.json +3 -0
  113. data/test/fixtures/fake_rto.json +15 -0
  114. data/test/fixtures/fake_settlement.json +11 -0
  115. data/test/fixtures/fake_settlement_on_demand.json +39 -0
  116. data/test/fixtures/fake_stakeholder.json +29 -0
  117. data/test/fixtures/fake_subscription_pause.json +19 -0
  118. data/test/fixtures/fake_subscription_registration.json +91 -0
  119. data/test/fixtures/fake_subscription_resume.json +19 -0
  120. data/test/fixtures/fake_token.json +31 -0
  121. data/test/fixtures/fake_tokenise_customer.json +40 -0
  122. data/test/fixtures/fake_transfer.json +18 -0
  123. data/test/fixtures/fake_transfer_reverse.json +15 -0
  124. data/test/fixtures/fake_update_payment.json +39 -0
  125. data/test/fixtures/fake_validate_vpa.json +5 -0
  126. data/test/fixtures/fake_virtual_account_allowed.json +46 -0
  127. data/test/fixtures/fake_virtual_account_receiver.json +46 -0
  128. data/test/fixtures/fake_webhook.json +79 -0
  129. data/test/fixtures/fake_webhook_by_account_id.json +22 -0
  130. data/test/fixtures/fetch_tnc.json +11 -0
  131. data/test/fixtures/fund_collection.json +20 -0
  132. data/test/fixtures/item_collection.json +24 -0
  133. data/test/fixtures/order_error.json +10 -0
  134. data/test/fixtures/payment_collection.json +1 -1
  135. data/test/fixtures/payment_error.json +10 -0
  136. data/test/fixtures/payment_link_collection.json +43 -0
  137. data/test/fixtures/payment_link_response.json +3 -0
  138. data/test/fixtures/payment_methods_collection.json +149 -0
  139. data/test/fixtures/qrcode_collection.json +50 -0
  140. data/test/fixtures/qrcode_payments_collection.json +74 -0
  141. data/test/fixtures/reversals_collection.json +22 -0
  142. data/test/fixtures/settlement_collection.json +26 -0
  143. data/test/fixtures/settlement_instant_collection.json +84 -0
  144. data/test/fixtures/settlement_report_collection.json +117 -0
  145. data/test/fixtures/stakeholder_collection.json +35 -0
  146. data/test/fixtures/success.json +3 -0
  147. data/test/fixtures/tokens_collection.json +36 -0
  148. data/test/fixtures/transfer_error.json +10 -0
  149. data/test/fixtures/transfer_settlements_collection.json +38 -0
  150. data/test/fixtures/transfers_collection.json +41 -0
  151. data/test/fixtures/webhook_by_account_collection.json +35 -0
  152. data/test/fixtures/webhook_collection.json +85 -0
  153. data/test/razorpay/test_account.rb +134 -0
  154. data/test/razorpay/test_addon.rb +19 -15
  155. data/test/razorpay/test_card.rb +6 -0
  156. data/test/razorpay/test_customer.rb +132 -3
  157. data/test/razorpay/test_dispute.rb +98 -0
  158. data/test/razorpay/test_document.rb +27 -0
  159. data/test/razorpay/test_fund_account.rb +42 -0
  160. data/test/razorpay/test_iin.rb +23 -0
  161. data/test/razorpay/test_invoice.rb +15 -2
  162. data/test/razorpay/test_item.rb +66 -0
  163. data/test/razorpay/test_oauth_token.rb +105 -0
  164. data/test/razorpay/test_order.rb +66 -1
  165. data/test/razorpay/test_payload_validator.rb +61 -0
  166. data/test/razorpay/test_payment.rb +251 -9
  167. data/test/razorpay/test_payment_link.rb +83 -0
  168. data/test/razorpay/test_plan.rb +2 -2
  169. data/test/razorpay/test_product.rb +67 -0
  170. data/test/razorpay/test_qr_code.rb +63 -0
  171. data/test/razorpay/test_razorpay.rb +19 -2
  172. data/test/razorpay/test_refund.rb +16 -2
  173. data/test/razorpay/test_settlement.rb +76 -0
  174. data/test/razorpay/test_stakeholder.rb +87 -0
  175. data/test/razorpay/test_subscription.rb +72 -9
  176. data/test/razorpay/test_subscription_registration.rb +58 -0
  177. data/test/razorpay/test_token.rb +66 -0
  178. data/test/razorpay/test_transfer.rb +94 -0
  179. data/test/razorpay/test_utility.rb +72 -4
  180. data/test/razorpay/test_virtual_account.rb +64 -17
  181. data/test/razorpay/test_webhook.rb +132 -0
  182. data/test/test_helper.rb +8 -0
  183. metadata +265 -10
  184. data/.travis.yml +0 -22
  185. data/test/razorpay/test_errors.rb +0 -19
@@ -0,0 +1,208 @@
1
+ ## items
2
+
3
+ ```rb
4
+ require "razorpay"
5
+ Razorpay.setup('key_id', 'key_secret')
6
+ ```
7
+
8
+ ### Create item
9
+
10
+ ```rb
11
+ Razorpay::Item.create({
12
+ "name": "Book / English August",
13
+ "description": "An indian story, Booker prize winner.",
14
+ "amount": 20000,
15
+ "currency": "INR"
16
+ });
17
+ ```
18
+
19
+ **Parameters:**
20
+
21
+ | Name | Type | Description |
22
+ |-----------------|---------|------------------------------------------------------------------------------|
23
+ | name* | string | Name of the item. |
24
+ | description | string | A brief description of the item. |
25
+ | amount | integer | Amount of the order to be paid |
26
+ | currency* | string | Currency of the order. Currently only `INR` is supported. |
27
+
28
+ **Response:**
29
+ ```json
30
+ {
31
+ "id": "item_Jf5MlwKlPMOKBV",
32
+ "active": true,
33
+ "name": "Book / English August",
34
+ "description": "An indian story, Booker prize winner.",
35
+ "amount": 20000,
36
+ "unit_amount": 20000,
37
+ "currency": "INR",
38
+ "type": "invoice",
39
+ "unit": null,
40
+ "tax_inclusive": false,
41
+ "hsn_code": null,
42
+ "sac_code": null,
43
+ "tax_rate": null,
44
+ "tax_id": null,
45
+ "tax_group_id": null,
46
+ "created_at": 1654709890
47
+ }
48
+ ```
49
+
50
+ -------------------------------------------------------------------------------------------------------
51
+
52
+ ### Fetch all items
53
+
54
+ ```rb
55
+ options = {"count":1}
56
+
57
+ Razorpay::Item.all(options)
58
+ ```
59
+ **Parameters:**
60
+
61
+ | Name | Type | Description |
62
+ |-------|-----------|--------------------------------------------------|
63
+ | from | timestamp | timestamp after which the item were created |
64
+ | to | timestamp | timestamp before which the item were created |
65
+ | count | integer | number of item to fetch (default: 10) |
66
+ | skip | integer | number of item to be skipped (default: 0) |
67
+ | name | string | Name of the item. |
68
+ | description | string | A brief description of the item. |
69
+ | amount | integer | Amount of the order to be paid |
70
+ | currency | string | Currency of the order. Currently only `INR` is supported. |
71
+ | active | boolean | Possible values is `0` or `1` |
72
+
73
+ **Response:**
74
+ ```json
75
+ {
76
+ "entity": "collection",
77
+ "count": 1,
78
+ "items": [
79
+ {
80
+ "id": "item_JnjKnSWxjILdWu",
81
+ "active": true,
82
+ "name": "Book / English August",
83
+ "description": "An indian story, Booker prize winner.",
84
+ "amount": 20000,
85
+ "unit_amount": 20000,
86
+ "currency": "INR",
87
+ "type": "invoice",
88
+ "unit": null,
89
+ "tax_inclusive": false,
90
+ "hsn_code": null,
91
+ "sac_code": null,
92
+ "tax_rate": null,
93
+ "tax_id": null,
94
+ "tax_group_id": null,
95
+ "created_at": 1656597363
96
+ }
97
+ ]
98
+ }
99
+ ```
100
+ -------------------------------------------------------------------------------------------------------
101
+ ### Fetch particular item
102
+
103
+ ```rb
104
+ itemId = "item_7Oxp4hmm6T4SCn"
105
+
106
+ Razorpay::Item.fetch(itemId)
107
+ ```
108
+ **Parameters**
109
+
110
+ | Name | Type | Description |
111
+ |----------|--------|-------------------------------------|
112
+ | itemId* | string | The id of the item to be fetched |
113
+
114
+ **Response:**
115
+ ```json
116
+ {
117
+ "id": "item_JnjKnSWxjILdWu",
118
+ "active": true,
119
+ "name": "Book / English August",
120
+ "description": "An indian story, Booker prize winner.",
121
+ "amount": 20000,
122
+ "unit_amount": 20000,
123
+ "currency": "INR",
124
+ "type": "invoice",
125
+ "unit": null,
126
+ "tax_inclusive": false,
127
+ "hsn_code": null,
128
+ "sac_code": null,
129
+ "tax_rate": null,
130
+ "tax_id": null,
131
+ "tax_group_id": null,
132
+ "created_at": 1656597363
133
+ }
134
+ ```
135
+
136
+ -------------------------------------------------------------------------------------------------------
137
+
138
+ ### Update item
139
+
140
+ ```rb
141
+ itemId = "item_JDcbIdX9xojCje"
142
+
143
+ para_attr = {
144
+ "name": "Book / Ignited Minds - Updated name!",
145
+ "description": "New descirption too. :).",
146
+ "amount": 20000,
147
+ "currency": "INR",
148
+ "active": true
149
+ }
150
+
151
+ Razorpay::Item.edit(itemId,para_attr)
152
+ ```
153
+ **Parameters**
154
+
155
+ | Name | Type | Description |
156
+ |----------|--------|-------------------------------------|
157
+ | itemId* | string | The id of the item to be fetched |
158
+ | name | string | Name of the item. |
159
+ | description | string | A brief description of the item. |
160
+ | amount | integer | Amount of the order to be paid |
161
+ | currency | string | Currency of the order. Currently only `INR` is supported. |
162
+ | active | boolean | Possible values is `0` or `1` |
163
+
164
+ **Response:**
165
+ ```json
166
+ {
167
+ "id": "item_JInaSLODeDUQiQ",
168
+ "active": true,
169
+ "name": "Book / Ignited Minds - Updated name!",
170
+ "description": "New descirption too.",
171
+ "amount": 20000,
172
+ "unit_amount": 20000,
173
+ "currency": "INR",
174
+ "type": "invoice",
175
+ "unit": null,
176
+ "tax_inclusive": false,
177
+ "hsn_code": null,
178
+ "sac_code": null,
179
+ "tax_rate": null,
180
+ "tax_id": null,
181
+ "tax_group_id": null,
182
+ "created_at": 1649843796
183
+ }
184
+ ```
185
+ -------------------------------------------------------------------------------------------------------
186
+ ### Delete item
187
+
188
+ ```rb
189
+ itemId = "item_Jc7wDjjQ4x305A"
190
+
191
+ Razorpay::Item.delete(itemId)
192
+ ```
193
+ **Parameters**
194
+
195
+ | Name | Type | Description |
196
+ |----------|--------|-------------------------------------|
197
+ | itemId* | string | The id of the item to be fetched |
198
+
199
+ **Response:**
200
+ ```json
201
+ []
202
+ ```
203
+ -------------------------------------------------------------------------------------------------------
204
+
205
+ **PN: * indicates mandatory fields**
206
+ <br>
207
+ <br>
208
+ **For reference click [here](https://razorpay.com/docs/api/items)**
@@ -0,0 +1,142 @@
1
+ ### OAuthToken
2
+
3
+ ```rb
4
+ require "razorpay"
5
+ ```
6
+
7
+ ### Generate Authorize Url
8
+ ```rb
9
+ body = {
10
+ submerchant_id: '<SUBMERCHANT_MID>',
11
+ timestamp: Time.now.to_i
12
+ }
13
+ onboarding_signature = Razorpay::Utility.generate_onboarding_signature(body, '<YOUR_CLIENT_SECRET>')
14
+
15
+ options = {
16
+ 'client_id' => '<YOUR_CLIENT_ID>',
17
+ 'redirect_uri' => 'https://example.com/razorpay_callback',
18
+ 'scopes' => ["read_write"],
19
+ 'state' => 'NOBYtv8r6c75ex6WZ',
20
+ 'onboarding_signature' => onboarding_signature
21
+ }
22
+ authorize_url = Razorpay::OAuthToken.get_auth_url(options)
23
+ ```
24
+
25
+ **Parameters:**
26
+
27
+ | Name | Type | Description |
28
+ |----------------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
29
+ | client_id* | string | Unique client identifier. |
30
+ | redirect_uri* | string | Callback URL used by Razorpay to redirect after the user approves or denies the authorisation request. The client should whitelist the 'redirect_uri'. |
31
+ | scopes* | array | Defines what access your application is requesting from the user. You can request one or multiple scopes by adding them to an array as indicated above. |
32
+ | state* | string | A random string generated by your service. This parameter helps prevent cross-site request forgery (CSRF) attacks. |
33
+ | onboarding_signature | string | A cryptographic string generated by your service using generateOnboardingSignature method in Utils class. Only applicable for accounts created with pre-fill KYC |
34
+
35
+ **Response:**
36
+ ```
37
+ "https://auth.razorpay.com/authorize?response_type=code&client_id=<YOUR_CLIENT_ID>&redirect_uri=https:%2F%2Fexample.com%2Frazorpay_callback&scope[]=read_only&scope[]=rx_read_write&state=NOBYtv8r6c75ex6WZ&onboarding_signature=<GENERATED_ONBOARDING_SIGNATURE>"
38
+ ```
39
+
40
+ -------------------------------------------------------------------------------------------------------
41
+ ### Get Access token
42
+ ```rb
43
+ options = {
44
+ 'client_id' => '<YOUR_CLIENT_ID>',
45
+ 'client_secret' => '<YOUR_CLIENT_SECRET>',
46
+ 'redirect_uri' => 'https://example.com/razorpay_callback',
47
+ 'grant_type' => 'authorization_code',
48
+ 'code' => '<AUTHORIZATION_CODE>',
49
+ 'mode' => 'test'
50
+ }
51
+ oauth_token = Razorpay::OAuthToken.get_access_token(options)
52
+ ```
53
+
54
+ **Parameters:**
55
+
56
+ | Name | Type | Description |
57
+ |----------------|--------|------------------------------------------------------------------------------------------------------------------------------|
58
+ | client_id* | string | Unique client identifier. |
59
+ | client_secret* | string | Client secret string. |
60
+ | redirect_uri* | string | Specifies the same redirect_uri used in the authorisation request. |
61
+ | grant_type* | string | Defines the grant type for the request. Possible value are:<ul><li>authorization_code</li><li>client_credentials</li></ul> |
62
+ | code* | string | Decoded authorisation code received in the last step. Note: Pass this parameter only when grant_type is 'authorization_code' |
63
+ | mode | string | The type of mode. Possible values: <ul><li>test</li><li>live (default)</li></ul> |
64
+
65
+ **Response:**
66
+ ```json
67
+ {
68
+ "public_token": "rzp_test_oauth_9xu1rkZqoXlClS",
69
+ "token_type": "Bearer",
70
+ "expires_in": 7862400,
71
+ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IkY1Z0NQYkhhRzRjcUpnIn0.eyJhdWQiOiJGNFNNeEgxanMxbkpPZiIsImp0aSI6IkY1Z0NQYkhhRzRjcUpnIiwiaWF0IjoxNTkyODMxMDExLCJuYmYiOjE1OTI4MzEwMTEsInN1YiI6IiIsImV4cCI6MTYwMDc3OTgxMSwidXNlcl9pZCI6IkYycVBpejJEdzRPRVFwIiwibWVyY2hhbnRfaWQiOiJGMnFQaVZ3N0lNV01GSyIsInNjb3BlcyI6WyJyZWFkX29ubHkiXX0.Wwqt5czhoWpVzP5_aoiymKXoGj-ydo-4A_X2jf_7rrSvk4pXdqzbA5BMrHxPdPbeFQWV6vsnsgbf99Q3g-W4kalHyH67LfAzc3qnJ-mkYDkFY93tkeG-MCco6GJW-Jm8xhaV9EPUak7z9J9jcdluu9rNXYMtd5qxD8auyRYhEgs",
72
+ "refresh_token": "def50200f42e07aded65a323f6c53181d802cc797b62cc5e78dd8038d6dff253e5877da9ad32f463a4da0ad895e3de298cbce40e162202170e763754122a6cb97910a1f58e2378ee3492dc295e1525009cccc45635308cce8575bdf373606c453ebb5eb2bec062ca197ac23810cf9d6cf31fbb9fcf5b7d4de9bf524c89a4aa90599b0151c9e4e2fa08acb6d2fe17f30a6cfecdfd671f090787e821f844e5d36f5eacb7dfb33d91e83b18216ad0ebeba2bef7721e10d436c3984daafd8654ed881c581d6be0bdc9ebfaee0dc5f9374d7184d60aae5aa85385690220690e21bc93209fb8a8cc25a6abf1108d8277f7c3d38217b47744d7",
73
+ "razorpay_account_id": "acc_Dhk2qDbmu6FwZH"
74
+ }
75
+ ```
76
+
77
+ -------------------------------------------------------------------------------------------------------
78
+
79
+ ### Get Access token using refresh token
80
+ ```rb
81
+ options = {
82
+ 'client_id' => '<YOUR_CLIENT_ID>',
83
+ 'client_secret' => '<YOUR_CLIENT_SECRET>',
84
+ 'refresh_token' => 'def5020096e1c470c901d34cd60fa53abdaf3662sa0'
85
+ }
86
+ oauth_token = Razorpay::OAuthToken.refresh_token(options)
87
+ ```
88
+
89
+ **Parameters:**
90
+
91
+ | Name | Type | Description |
92
+ |----------------|-----------|--------------------------------------------|
93
+ | client_id* | string | Unique client identifier. |
94
+ | client_secret* | string | Client secret string. |
95
+ | refresh_token* | string | The previously-stored refresh token value. |
96
+
97
+ **Response:**
98
+ ```json
99
+ {
100
+ "public_token": "rzp_test_oauth_9xu1rkZqoXlClS",
101
+ "token_type": "Bearer",
102
+ "expires_in": 7862400,
103
+ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6Ijl4dTF",
104
+ "refresh_token": "def5020096e1c470c901d34cd60fa53abdaf36620e823ffa53"
105
+ }
106
+ ```
107
+
108
+ -------------------------------------------------------------------------------------------------------
109
+
110
+ ### Revoke a token
111
+ ```rb
112
+ options = {
113
+ 'client_id' => '<YOUR_CLIENT_ID>',
114
+ 'client_secret' => '<YOUR_CLIENT_SECRET>',
115
+ 'token' => 'def5020096e1c470c901d34cd60fa53abdaf36620e823ffa53'
116
+ 'token_type_hint' => 'access_token'
117
+ }
118
+ response = Razorpay::OAuthToken.revoke_token(options)
119
+ ```
120
+
121
+ **Parameters:**
122
+
123
+ | Name | Type | Description |
124
+ |------------------|----------|----------------------------------------------------------------------------------------------------------|
125
+ | client_id* | string | Unique client identifier. |
126
+ | client_secret* | string | Client secret string. |
127
+ | token_type_hint* | string | The type of token for the request. Possible values: <ul><li>access_token</li><li>refresh_token</li></ul> |
128
+ | token* | string | The token whose access should be revoked. |
129
+
130
+ **Response:**
131
+ ```json
132
+ {
133
+ "message": "Token Revoked"
134
+ }
135
+ ```
136
+ -------------------------------------------------------------------------------------------------------
137
+
138
+ **PN: * indicates mandatory fields**
139
+ <br>
140
+ <br>
141
+ **For reference click [here](https://razorpay.com/docs/partners/platform/onboard-businesses/integrate-oauth/integration-steps)**
142
+
@@ -0,0 +1,352 @@
1
+ ## Orders
2
+
3
+ ```rb
4
+ require "razorpay"
5
+ Razorpay.setup('key_id', 'key_secret')
6
+ ```
7
+
8
+ ### Create order
9
+
10
+ ```rb
11
+
12
+ para_attr = {
13
+ "amount": 50000,
14
+ "currency": "INR",
15
+ "receipt": "receipt#1",
16
+ "notes": {
17
+ "key1": "value3",
18
+ "key2": "value2"
19
+ }
20
+ }
21
+
22
+ Razorpay::Order.create(para_attr)
23
+ ```
24
+
25
+ **Parameters:**
26
+
27
+ | Name | Type | Description |
28
+ |-----------------|---------|------------------------------------------------------------------------------|
29
+ | amount* | integer | Amount of the order to be paid |
30
+ | currency* | string | Currency of the order. Currently only `INR` is supported. |
31
+ | receipt | string | Your system order reference id. |
32
+ | notes | object | A key-value pair |
33
+
34
+ **Response:**
35
+
36
+ ```json
37
+ {
38
+ "id": "order_EKwxwAgItmmXdp",
39
+ "entity": "order",
40
+ "amount": 50000,
41
+ "amount_paid": 0,
42
+ "amount_due": 50000,
43
+ "currency": "INR",
44
+ "receipt": "receipt#1",
45
+ "offer_id": null,
46
+ "status": "created",
47
+ "attempts": 0,
48
+ "notes": [],
49
+ "created_at": 1582628071
50
+ }
51
+ ```
52
+
53
+ -------------------------------------------------------------------------------------------------------
54
+
55
+ ### Create order (Third party validation)
56
+
57
+ ```rb
58
+ para_attr = {
59
+ "amount": 500,
60
+ "method": "netbanking",
61
+ "receipt": "BILL13375649",
62
+ "currency": "INR",
63
+ "bank_account": {
64
+ "account_number": "765432123456789",
65
+ "name": "Gaurav Kumar",
66
+ "ifsc": "HDFC0000053"
67
+ }
68
+ }
69
+
70
+ Razorpay::Order.create(para_attr)
71
+ ```
72
+
73
+ **Parameters:**
74
+
75
+ | Name | Type | Description |
76
+ |-----------------|---------|------------------------------------------------------------------------------|
77
+ | amount* | integer | Amount of the order to be paid |
78
+ | method | string | The payment method used to make the payment. If this parameter is not passed, customers will be able to make payments using both netbanking and UPI payment methods. Possible values is `netbanking` or `upi`|
79
+ | currency* | string | Currency of the order. Currently only `INR` is supported. |
80
+ | receipt | string | Your system order reference id. |
81
+ |bank_account | array | All keys listed [here](https://razorpay.com/docs/payments/third-party-validation/#step-2-create-an-order) are supported |
82
+ | notes | object | A key-value pair |
83
+
84
+ **Response:**
85
+
86
+ ```json
87
+ {
88
+ "id": "order_GAWN9beXgaqRyO",
89
+ "entity": "order",
90
+ "amount": 500,
91
+ "amount_paid": 0,
92
+ "amount_due": 500,
93
+ "currency": "INR",
94
+ "receipt": "BILL13375649",
95
+ "offer_id": null,
96
+ "status": "created",
97
+ "attempts": 0,
98
+ "notes": [],
99
+ "created_at": 1573044247
100
+ }
101
+ ```
102
+
103
+ -------------------------------------------------------------------------------------------------------
104
+
105
+ ### Fetch all orders
106
+
107
+ ```rb
108
+ option = {"count":1}
109
+
110
+ Razorpay::Order.all(option)
111
+ ```
112
+
113
+ **Parameters**
114
+
115
+ | Name | Type | Description |
116
+ |------------|-----------|--------------------------------------------------------------|
117
+ | from | timestamp | timestamp after which the orders were created |
118
+ | to | timestamp | timestamp before which the orders were created |
119
+ | count | integer | number of orders to fetch (default: 10) |
120
+ | skip | integer | number of orders to be skipped (default: 0) |
121
+ | authorized | boolean | Orders for which orders are currently in authorized state. |
122
+ | receipt | string | Orders with the provided value for receipt. |
123
+ | expand[] | string | Used to retrieve additional information about the payment. Possible value is `payments`,`payments.card`,`transfers` or `virtual_account` |
124
+
125
+ **Response:**
126
+
127
+ ```json
128
+ {
129
+ "entity": "collection",
130
+ "count": 1,
131
+ "items": [
132
+ {
133
+ "id": "order_EKzX2WiEWbMxmx",
134
+ "entity": "order",
135
+ "amount": 1234,
136
+ "amount_paid": 0,
137
+ "amount_due": 1234,
138
+ "currency": "INR",
139
+ "receipt": "Receipt No. 1",
140
+ "offer_id": null,
141
+ "status": "created",
142
+ "attempts": 0,
143
+ "notes": [],
144
+ "created_at": 1582637108
145
+ }
146
+ ]
147
+ }
148
+ ```
149
+ -------------------------------------------------------------------------------------------------------
150
+
151
+ ### Fetch particular order
152
+
153
+ ```rb
154
+ orderId = "order_DaaS6LOUAASb7Y"
155
+
156
+ Razorpay::Order.fetch(orderId)
157
+ ```
158
+ **Parameters**
159
+
160
+ | Name | Type | Description |
161
+ |----------|--------|-------------------------------------|
162
+ | orderId* | string | The id of the order to be fetched |
163
+
164
+ **Response:**
165
+
166
+ ```json
167
+ {
168
+ "id":"order_DaaS6LOUAASb7Y",
169
+ "entity":"order",
170
+ "amount":2200,
171
+ "amount_paid":0,
172
+ "amount_due":2200,
173
+ "currency":"INR",
174
+ "receipt":"Receipt #211",
175
+ "status":"attempted",
176
+ "attempts":1,
177
+ "notes":[],
178
+ "created_at":1572505143
179
+ }
180
+ ```
181
+ -------------------------------------------------------------------------------------------------------
182
+
183
+ ### Fetch payments for an order
184
+
185
+ ```rb
186
+ orderId = "order_DaaS6LOUAASb7Y"
187
+
188
+ Razorpay::Order.fetch("order_JCRhAvzvZQPkwT").payments
189
+ ```
190
+ **Parameters**
191
+
192
+ | Name | Type | Description |
193
+ |----------|--------|-------------------------------------|
194
+ | orderId* | string | The id of the order to be retrieve payment info |
195
+
196
+ **Response:**
197
+ ```json
198
+ {
199
+ "entity":"collection",
200
+ "count":1,
201
+ "items":[
202
+ {
203
+ "id":"pay_DaaSOvhgcOfzgR",
204
+ "entity":"payment",
205
+ "amount":2200,
206
+ "currency":"INR",
207
+ "status":"captured",
208
+ "order_id":"order_DaaS6LOUAASb7Y",
209
+ "invoice_id":null,
210
+ "international":false,
211
+ "method":"card",
212
+ "amount_refunded":0,
213
+ "refund_status":null,
214
+ "captured":true,
215
+ "description":"Beans in every imaginable flavour",
216
+ "card_id":"card_DZon6fd8J3IcA2",
217
+ "bank":null,
218
+ "wallet":null,
219
+ "vpa":null,
220
+ "email":"gaurav.kumar@example.com",
221
+ "contact":"+919999999988",
222
+ "notes":[],
223
+ "fee":44,
224
+ "tax":0,
225
+ "error_code":null,
226
+ "error_description":null,
227
+ "created_at":1572505160
228
+ }
229
+ ]
230
+ }
231
+ ```
232
+ -------------------------------------------------------------------------------------------------------
233
+
234
+ ### Update order
235
+
236
+ ```rb
237
+ orderId = "order_DaaS6LOUAASb7Y"
238
+
239
+ para_attr = {
240
+ "notes": {
241
+ "key1": "value3",
242
+ "key2": "value2"
243
+ }
244
+ }
245
+
246
+ Razorpay::Order.edit(orderId,para_attr)
247
+ ```
248
+ **Parameters**
249
+
250
+ | Name | Type | Description |
251
+ |----------|--------|-------------------------------------|
252
+ | orderId* | string | The id of the order to be retrieve payment info |
253
+ | notes* | object | A key-value pair |
254
+
255
+ **Response:**
256
+ ```json
257
+ {
258
+ "id":"order_DaaS6LOUAASb7Y",
259
+ "entity":"order",
260
+ "amount":2200,
261
+ "amount_paid":0,
262
+ "amount_due":2200,
263
+ "currency":"INR",
264
+ "receipt":"Receipt #211",
265
+ "offer_id":null,
266
+ "status":"attempted",
267
+ "attempts":1,
268
+ "notes":{
269
+ "notes_key_1":"Tea, Earl Grey, Hot",
270
+ "notes_key_2":"Tea, Earl Grey… decaf."
271
+ },
272
+ "created_at":1572505143
273
+ }
274
+ ```
275
+ -------------------------------------------------------------------------------------------------------
276
+
277
+
278
+ ### View RTO/Risk Reasons
279
+
280
+ ```go
281
+ orderId = "order_XXXXXXXXXXXXX1"
282
+
283
+ Razorpay::Order.view_rto(orderId)
284
+ ```
285
+ **Parameters**
286
+
287
+ | Name | Type | Description |
288
+ |----------|--------|------------------------------------- |
289
+ | orderId* | string | The unique identifier of an order to access the fulfillment information. |
290
+
291
+ **Response:**
292
+ ```json
293
+ {
294
+ "risk_tier": "high",
295
+ "rto_reasons": [
296
+ {
297
+ "reason": "short_shipping_address",
298
+ "description": "Short shipping address",
299
+ "bucket": "address"
300
+ },
301
+ {
302
+ "reason": "address_pincode_state_mismatch",
303
+ "description": "Incorrect pincode state entered",
304
+ "bucket": "address"
305
+ }
306
+ ]
307
+ }
308
+ ```
309
+ -------------------------------------------------------------------------------------------------------
310
+
311
+ ### Update the Fulfillment Details
312
+
313
+ ```rb
314
+ order_id = "order_XXXXXXXXXXXXX1"
315
+
316
+ para_attr = {
317
+ "payment_method": "upi",
318
+ "shipping": {
319
+ "waybill": "123456789",
320
+ "status": "rto",
321
+ "provider": "Bluedart"
322
+ }
323
+ }
324
+
325
+ Razorpay::Order.edit_fulfillment(order_id, para_attr)
326
+ ```
327
+ **Parameters**
328
+
329
+ | Name | Type | Description |
330
+ |----------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
331
+ | orderId* | string | The unique identifier of an order to access the fulfillment information. |
332
+ | payment_method | string | Payment Method opted by the customer to complete the payment. Possible values is `upi`, `card`, `wallet`, `netbanking`, `cod`, `emi`, `cardless_emi`, `paylater`, `recurring`, `other`. |
333
+ | shipping | object | Contains the shipping data. [here](https://razorpay.com/docs/payments/magic-checkout/rto-intelligence/#step-3-update-the-fulfillment-details) are supported |
334
+
335
+ **Response:**
336
+ ```json
337
+ {
338
+ "entity": "order.fulfillment",
339
+ "order_id": "EKwxwAgItXXXX",
340
+ "payment_method": "upi",
341
+ "shipping": {
342
+ "waybill": "123456789",
343
+ "status": "rto",
344
+ "provider": "Bluedart"
345
+ }
346
+ }
347
+ ```
348
+ -------------------------------------------------------------------------------------------------------
349
+ **PN: * indicates mandatory fields**
350
+ <br>
351
+ <br>
352
+ **For reference click [here](https://razorpay.com/docs/api/orders/)**