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,224 @@
1
+ ## Webhook
2
+
3
+ ### Create a Webhook
4
+ ```rb
5
+ accountId = "acc_GP4lfNA0iIMn5B"
6
+
7
+ Razorpay::Webhook.create({
8
+ "url": "https://google.com",
9
+ "alert_email": "gaurav.kumar@example.com",
10
+ "secret": "12345",
11
+ "events": [
12
+ "payment.authorized",
13
+ "payment.failed",
14
+ "payment.captured",
15
+ "payment.dispute.created",
16
+ "refund.failed",
17
+ "refund.created"
18
+ ]
19
+ }, accountId)
20
+ ```
21
+
22
+ **Parameters:**
23
+
24
+ | Name | Type | Description |
25
+ |---------------|-------------|---------------------------------------------|
26
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
27
+ | url* | string | The URL where you receive the webhook payload when an event is triggered. The maximum length is 255 characters. |
28
+ | alert_email | string | This is the email address to which notifications must be sent in case of webhook failure. |
29
+ | secret | string | A secret for the webhook endpoint that is used to validate that the webhook is from Razorpay. |
30
+ | events | string | The required events from the list of Active Events. For example `payment.authorized`, `payment.captured`, `payment.failed`, `payment.dispute.created`, `refund.failed`, `refund.created` and so on. |
31
+
32
+ **Response:**
33
+ ```json
34
+ {
35
+ "id": "JebiXkKGYwua5L",
36
+ "created_at": 1654605478,
37
+ "updated_at": 1654605478,
38
+ "service": "beta-api-live",
39
+ "owner_id": "JOGUdtKu3dB03d",
40
+ "owner_type": "merchant",
41
+ "context": [],
42
+ "disabled_at": 0,
43
+ "url": "https://google.com",
44
+ "alert_email": "gaurav.kumar@example.com",
45
+ "secret_exists": true,
46
+ "entity": "webhook",
47
+ "active": true,
48
+ "events": [
49
+ "payment.authorized",
50
+ "payment.failed",
51
+ "payment.captured",
52
+ "payment.dispute.created",
53
+ "refund.failed",
54
+ "refund.created"
55
+ ]
56
+ }
57
+ ```
58
+
59
+ -------------------------------------------------------------------------------------------------------
60
+
61
+ ### Edit Webhook
62
+ ```rb
63
+ webhookId = "HK890egfiItP3H"
64
+
65
+ accountId = "acc_GP4lfNA0iIMn5B"
66
+
67
+ Razorpay::Webhook.edit({
68
+ "url": "https://www.linkedin.com",
69
+ "events": [
70
+ "refund.created"
71
+ ]
72
+ }, webhookId, accountId)
73
+ ```
74
+
75
+ **Parameters:**
76
+
77
+ | Name | Type | Description |
78
+ |---------------|-------------|---------------------------------------------|
79
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
80
+ | webhookId* | string | The unique identifier of the webhook whose details are to be updated |
81
+ | url | string | The URL where you receive the webhook payload when an event is triggered. The maximum length is 255 characters. |
82
+ | events | string | The required events from the list of Active Events. For example `payment.authorized`, `payment.captured`, `payment.failed`, `payment.dispute.created`, `refund.failed`, `refund.created` and so on. |
83
+
84
+ **Response:**
85
+ ```json
86
+ {
87
+ "id": "HK890egfiItP3H",
88
+ "created_at": 1623060358,
89
+ "updated_at": 1623067148,
90
+ "service": "beta-api-test",
91
+ "owner_id": "H3kYHQ635sBwXG",
92
+ "owner_type": "merchant",
93
+ "context": [],
94
+ "disabled_at": 0,
95
+ "url": "https://www.linkedin.com",
96
+ "alert_email": "gaurav.kumar@example.com",
97
+ "secret_exists": true,
98
+ "entity": "webhook",
99
+ "active": true,
100
+ "events": [
101
+ "refund.created"
102
+ ]
103
+ }
104
+ ```
105
+ -------------------------------------------------------------------------------------------------------
106
+
107
+ ### Delete an account
108
+ ```rb
109
+ accountId = "acc_GP4lfNA0iIMn5B"
110
+
111
+ webhookId = "HK890egfiItP3H"
112
+
113
+ Razorpay::Webhook.delete(webhookId, accountId)
114
+ ```
115
+
116
+ **Parameters:**
117
+
118
+ | Name | Type | Description |
119
+ |---------------|-------------|---------------------------------------------|
120
+ | accountId* | string | The unique identifier of a sub-merchant account that must be deleted. |
121
+ | webhookId* | string | The unique identifier of the webhook whose details are to be updated |
122
+
123
+ **Response:**
124
+ ```json
125
+ []
126
+ ```
127
+
128
+ -------------------------------------------------------------------------------------------------------
129
+
130
+ ### Fetch a webhook
131
+ ```rb
132
+ accountId = "acc_GP4lfNA0iIMn5B";
133
+
134
+ webhookId = "HK890egfiItP3H";
135
+
136
+ Razorpay::Webhook.fetch(webhookId, accountId);
137
+ ```
138
+
139
+ **Parameters:**
140
+
141
+ | Name | Type | Description |
142
+ |-------------|-------------|---------------------------------------------|
143
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
144
+ | webhookId* | string | The unique identifier of the webhook whose details are to be updated |
145
+
146
+ **Response:**
147
+ ```json
148
+ {
149
+ "id": "HK890egfiItP3H",
150
+ "created_at": 1623060358,
151
+ "updated_at": 1623060358,
152
+ "owner_id": "H3kYHQ635sBwXG",
153
+ "owner_type": "merchant",
154
+ "context": [],
155
+ "disabled_at": 0,
156
+ "url": "https://en1mwkqo5ioct.x.pipedream.net",
157
+ "alert_email": "gaurav.kumar@example.com",
158
+ "secret_exists": true,
159
+ "entity": "webhook",
160
+ "active": true,
161
+ "events": [
162
+ "payment.authorized",
163
+ "payment.failed",
164
+ "payment.captured",
165
+ "payment.dispute.created",
166
+ "refund.failed",
167
+ "refund.created"
168
+ ]
169
+ }
170
+ ```
171
+
172
+ -------------------------------------------------------------------------------------------------------
173
+
174
+ ### Fetch all Webhooks
175
+ ```rb
176
+ accountId = "acc_GP4lfNA0iIMn5B";
177
+
178
+ Razorpay::Webhook.all({
179
+ "count": 1
180
+ }, accountId);
181
+ ```
182
+
183
+ **Parameters:**
184
+
185
+ | Name | Type | Description |
186
+ |-------------|-------------|---------------------------------------------|
187
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
188
+ | from | integer | Timestamp, in seconds, from when the webhooks are to be fetched. |
189
+ | to | integer | Timestamp, in seconds, till when the webhooks are to be fetched. |
190
+ | count | integer | Number of webhooks to be fetched. The default value is `10` and the maximum value is `100`. This can be used for pagination, in combination with `skip`. |
191
+ | skip | integer | Number of records to be skipped while fetching the webhooks. This can be used for pagination, in combination with `count`. |
192
+
193
+ **Response:**
194
+ ```json
195
+ {
196
+ "id": "HK890egfiItP3H",
197
+ "created_at": 1623060358,
198
+ "updated_at": 1623060358,
199
+ "owner_id": "H3kYHQ635sBwXG",
200
+ "owner_type": "merchant",
201
+ "context": [],
202
+ "disabled_at": 0,
203
+ "url": "https://en1mwkqo5ioct.x.pipedream.net",
204
+ "alert_email": "gaurav.kumar@example.com",
205
+ "secret_exists": true,
206
+ "entity": "webhook",
207
+ "active": true,
208
+ "events": [
209
+ "payment.authorized",
210
+ "payment.failed",
211
+ "payment.captured",
212
+ "payment.dispute.created",
213
+ "refund.failed",
214
+ "refund.created"
215
+ ]
216
+ }
217
+ ```
218
+
219
+ -------------------------------------------------------------------------------------------------------
220
+
221
+ **PN: * indicates mandatory fields**
222
+ <br>
223
+ <br>
224
+ **For reference click [here](https://razorpay.com/docs/api/partners/webhooks)**
@@ -0,0 +1,39 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Account API allows you to create a sub-merchant account.
6
+ class Account < Entity
7
+
8
+ @@versions = "v2"
9
+
10
+ def self.request
11
+ Razorpay::Request.new('accounts')
12
+ end
13
+
14
+ def self.create(options)
15
+ request.create options, @@versions
16
+ end
17
+
18
+ def self.fetch(id)
19
+ request.fetch id, @@versions
20
+ end
21
+
22
+ def self.edit(id, options = {})
23
+ request.patch id, options, @@versions
24
+ end
25
+
26
+ def self.delete(id)
27
+ request.delete "#{id}", @@versions
28
+ end
29
+
30
+ def self.upload_account_doc(id,options)
31
+ r = request
32
+ r.request :post, "/#{@@versions}/accounts/#{id}/documents", options
33
+ end
34
+
35
+ def self.fetch_account_doc(id)
36
+ request.fetch "#{id}/documents", @@versions
37
+ end
38
+ end
39
+ end
@@ -13,12 +13,20 @@ module Razorpay
13
13
  request.fetch id
14
14
  end
15
15
 
16
+ def self.all(options = {})
17
+ request.all options
18
+ end
19
+
16
20
  def self.create(subscription_id, options)
17
21
  r = request
18
22
  # POST /addons is not supported
19
23
  # Addon creation endpoint is:
20
24
  # POST subscriptions/{sub_id}/addons
21
- r.request :post, "/subscriptions/#{subscription_id}/addons", options
25
+ r.request :post, "/v1/subscriptions/#{subscription_id}/addons", options
26
+ end
27
+
28
+ def self.delete(id)
29
+ request.delete id
22
30
  end
23
31
  end
24
32
  end
data/lib/razorpay/card.rb CHANGED
@@ -13,5 +13,9 @@ module Razorpay
13
13
  def self.fetch(id)
14
14
  request.fetch id
15
15
  end
16
+
17
+ def self.request_card_reference(options)
18
+ request.post 'fingerprints', options
19
+ end
16
20
  end
17
21
  end
@@ -1,6 +1,11 @@
1
1
  # Version and other constants are defined here
2
2
  module Razorpay
3
- BASE_URI = 'https://api.razorpay.com/v1/'.freeze
3
+ BASE_URI = 'https://api.razorpay.com'.freeze
4
4
  TEST_URL = 'https://api.razorpay.com/'.freeze
5
- VERSION = '2.4.0'.freeze
5
+ VERSION = '3.2.4'.freeze
6
+ AUTH_URL = 'https://auth.razorpay.com'.freeze
7
+ API_HOST = 'API'.freeze
8
+ AUTH_HOST = 'AUTH'.freeze
9
+ PRIVATE_AUTH = 'Private'.freeze
10
+ OAUTH = 'OAuth'.freeze
6
11
  end
@@ -23,5 +23,36 @@ module Razorpay
23
23
  def self.all(options = {})
24
24
  request.all options
25
25
  end
26
+
27
+ # Fetch token by customerId
28
+ # https://razorpay.com/docs/api/recurring-payments/upi/tokens/#22-fetch-tokens-by-customer-id
29
+ def fetchTokens
30
+ self.class.request.get "#{id}/tokens"
31
+ end
32
+
33
+ # Fetch specific token
34
+ def fetchToken(tokenId)
35
+ self.class.request.get "#{id}/tokens/#{tokenId}"
36
+ end
37
+
38
+ def deleteToken(tokenId)
39
+ self.class.request.delete "#{id}/tokens/#{tokenId}"
40
+ end
41
+
42
+ def self.add_bank_account(id, options = {})
43
+ request.post "#{id}/bank_account", options
44
+ end
45
+
46
+ def self.delete_bank_account(id, bankAccountId)
47
+ request.delete "#{id}/bank_account/#{bankAccountId}"
48
+ end
49
+
50
+ def self.request_eligibility_check(options = {})
51
+ request.post "eligibility", options
52
+ end
53
+
54
+ def self.fetch_eligibility(eligibilityId)
55
+ request.get "eligibility/#{eligibilityId}"
56
+ end
26
57
  end
27
58
  end
@@ -0,0 +1,26 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ class Dispute < Entity
6
+ def self.request
7
+ Razorpay::Request.new('disputes')
8
+ end
9
+
10
+ def self.fetch(id)
11
+ request.fetch id
12
+ end
13
+
14
+ def self.all(options = {})
15
+ request.all options
16
+ end
17
+
18
+ def self.accept(id, options={})
19
+ request.post "#{id}/accept", options
20
+ end
21
+
22
+ def self.contest(id, options)
23
+ request.patch "#{id}/contest", options
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Document API allows you to create and fetch document on Razorpay
6
+ class Document < Entity
7
+ def self.request
8
+ Razorpay::Request.new('documents')
9
+ end
10
+
11
+ def self.create(options)
12
+ request.create options
13
+ end
14
+
15
+ def self.fetch(id)
16
+ request.fetch id
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # FundAccount API allows you to create and fetch a fund account for a customer.
6
+ class FundAccount < Entity
7
+ def self.request
8
+ Razorpay::Request.new('fund_accounts')
9
+ end
10
+
11
+ def self.create(options)
12
+ request.create options
13
+ end
14
+
15
+ def self.all(data = {})
16
+ request.all data
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # IIN API allows you to fetch card properties using token IIN.
6
+ class Iin < Entity
7
+ def self.request
8
+ Razorpay::Request.new('iins')
9
+ end
10
+
11
+ def self.fetch(id)
12
+ request.fetch id
13
+ end
14
+ end
15
+ end
@@ -56,5 +56,13 @@ module Razorpay
56
56
  def cancel!
57
57
  with_a_bang { cancel }
58
58
  end
59
+
60
+ def self.notify_by(id, medium)
61
+ request.post "#{id}/notify_by/#{medium}"
62
+ end
63
+
64
+ def self.delete(id)
65
+ request.delete "#{id}"
66
+ end
59
67
  end
60
68
  end
@@ -0,0 +1,34 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Item API allows you to create and fetch customers on Razorpay
6
+ class Item < Entity
7
+ def self.request
8
+ Razorpay::Request.new('items')
9
+ end
10
+
11
+ def self.create(options)
12
+ request.create options
13
+ end
14
+
15
+ def self.fetch(id)
16
+ request.fetch id
17
+ end
18
+
19
+ def self.edit(id, options = {})
20
+ if(!options.is_a?(String) && options.key?(:active))
21
+ options[:active] = (options[:active] ? 1 : 0)
22
+ end
23
+ request.patch id, options
24
+ end
25
+
26
+ def self.all(options = {})
27
+ request.all options
28
+ end
29
+
30
+ def self.delete(id)
31
+ request.delete id
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,109 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+ require 'razorpay/payload_validator'
4
+ require 'razorpay/validation_config'
5
+
6
+ module Razorpay
7
+ # OAuth APIs allow to you create and manage access tokens
8
+ class OAuthToken < Entity
9
+ def self.request
10
+ Razorpay::Request.new('token', Razorpay::AUTH_HOST)
11
+ end
12
+
13
+ def self.get_auth_url(options)
14
+ validate_auth_url_request(options)
15
+ uri = URI.join(Razorpay::AUTH_URL, '/authorize')
16
+
17
+ query_params = {
18
+ 'response_type' => 'code',
19
+ 'client_id' => options['client_id'],
20
+ 'redirect_uri' => options['redirect_uri'],
21
+ 'state' => options['state']
22
+ }
23
+
24
+ options['scopes'].each { |scope| query_params["scope[]"] = scope }
25
+
26
+ if options.has_key?('onboarding_signature')
27
+ query_params['onboarding_signature'] = options['onboarding_signature']
28
+ end
29
+ uri.query = URI.encode_www_form(query_params)
30
+ uri.to_s
31
+ end
32
+
33
+ def self.get_access_token(options)
34
+ validate_access_token_request(options)
35
+ r = request
36
+ r.request :post, "/token", options
37
+ end
38
+
39
+ def self.refresh_token(options)
40
+ options['grant_type'] = 'refresh_token'
41
+ validate_refresh_token_request(options)
42
+ r = request
43
+ r.request :post, "/token", options
44
+ end
45
+
46
+ def self.revoke_token(options)
47
+ validate_revoke_token_request(options)
48
+ r = request
49
+ r.request :post, "/revoke", options
50
+ end
51
+
52
+ class << self
53
+
54
+ private
55
+
56
+ def validate_auth_url_request(options)
57
+ Razorpay::PayloadValidator.validate(options, get_validations_for_auth_request_url)
58
+ end
59
+
60
+ def validate_access_token_request(options)
61
+ Razorpay::PayloadValidator.validate(options, get_validations_for_access_token_request)
62
+ end
63
+
64
+ def validate_refresh_token_request(options)
65
+ Razorpay::PayloadValidator.validate(options, get_validations_for_refresh_token_request)
66
+ end
67
+
68
+ def validate_revoke_token_request(options)
69
+ Razorpay::PayloadValidator.validate(options, get_validations_for_revoke_token_request)
70
+ end
71
+
72
+ def get_validations_for_auth_request_url
73
+ [
74
+ Razorpay::ValidationConfig.new('client_id', [:id]),
75
+ Razorpay::ValidationConfig.new('redirect_uri', [:non_empty_string, :url]),
76
+ Razorpay::ValidationConfig.new('scopes', [:non_null]),
77
+ Razorpay::ValidationConfig.new('state', [:non_empty_string])
78
+ ]
79
+ end
80
+
81
+ def get_validations_for_access_token_request
82
+ [
83
+ Razorpay::ValidationConfig.new('client_id', [:id]),
84
+ Razorpay::ValidationConfig.new('client_secret', [:non_empty_string]),
85
+ Razorpay::ValidationConfig.new('redirect_uri', [:non_empty_string, :url]),
86
+ Razorpay::ValidationConfig.new('grant_type', [:token_grant])
87
+ ]
88
+ end
89
+
90
+ def get_validations_for_refresh_token_request
91
+ [
92
+ Razorpay::ValidationConfig.new('client_id', [:id]),
93
+ Razorpay::ValidationConfig.new('client_secret', [:non_empty_string]),
94
+ Razorpay::ValidationConfig.new('refresh_token', [:non_empty_string]),
95
+ Razorpay::ValidationConfig.new('grant_type', [:token_grant])
96
+ ]
97
+ end
98
+
99
+ def get_validations_for_revoke_token_request
100
+ [
101
+ Razorpay::ValidationConfig.new('client_id', [:id]),
102
+ Razorpay::ValidationConfig.new('client_secret', [:non_empty_string]),
103
+ Razorpay::ValidationConfig.new('token', [:non_empty_string]),
104
+ Razorpay::ValidationConfig.new('token_type_hint', [:non_empty_string])
105
+ ]
106
+ end
107
+ end
108
+ end
109
+ end
@@ -23,7 +23,25 @@ module Razorpay
23
23
 
24
24
  def payments(options = {})
25
25
  r = self.class.request
26
- r.request :get, "/orders/#{id}/payments", options
26
+ r.request :get, "/v1/orders/#{id}/payments", options
27
+ end
28
+
29
+ def self.edit(id, options = {})
30
+ request.patch id, options
31
+ end
32
+
33
+ def self.fetch_transfer_order(id)
34
+ # Fetch Transfer for an Order
35
+ # Docs: https://razorpay.com/docs/api/payments/route/#fetch-transfer-for-an-order
36
+ request.get "#{id}/?expand[]=transfers&status"
37
+ end
38
+
39
+ def self.view_rto(id)
40
+ request.post "#{id}/rto_review"
41
+ end
42
+
43
+ def self.edit_fulfillment(id, options = {})
44
+ request.post "#{id}/fulfillment", options
27
45
  end
28
46
  end
29
47
  end