razorpay 3.0.1 → 3.2.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/CHANGELOG.md +17 -0
- data/README.md +6 -0
- data/documents/account.md +449 -0
- data/documents/card.md +45 -0
- data/documents/generic.md +150 -0
- data/documents/payment.md +44 -1
- data/documents/productConfiguration.md +444 -0
- data/documents/stakeholder.md +334 -0
- data/documents/tokens.md +146 -1
- data/documents/webhook.md +224 -0
- data/lib/razorpay/account.rb +39 -0
- data/lib/razorpay/addon.rb +1 -1
- data/lib/razorpay/card.rb +4 -0
- data/lib/razorpay/constants.rb +28 -2
- data/lib/razorpay/generic.rb +39 -0
- data/lib/razorpay/iin.rb +15 -0
- data/lib/razorpay/order.rb +1 -1
- data/lib/razorpay/product.rb +37 -0
- data/lib/razorpay/request.rb +22 -16
- data/lib/razorpay/stakeholder.rb +39 -0
- data/lib/razorpay/token.rb +28 -0
- data/lib/razorpay/virtual_account.rb +1 -1
- data/lib/razorpay/webhook.rb +50 -0
- data/lib/razorpay.rb +7 -0
- data/test/fixtures/fake_account.json +78 -0
- data/test/fixtures/fake_card_reference.json +5 -0
- data/test/fixtures/fake_iin_token.json +23 -0
- data/test/fixtures/fake_product.json +138 -0
- data/test/fixtures/fake_stakeholder.json +29 -0
- data/test/fixtures/fake_tokenise_customer.json +40 -0
- data/test/fixtures/fake_webhook.json +79 -0
- data/test/fixtures/fake_webhook_by_account_id.json +22 -0
- data/test/fixtures/fetch_tnc.json +11 -0
- data/test/fixtures/stakeholder_collection.json +35 -0
- data/test/fixtures/webhook_by_account_collection.json +35 -0
- data/test/fixtures/webhook_collection.json +85 -0
- data/test/razorpay/test_account.rb +134 -0
- data/test/razorpay/test_card.rb +6 -0
- data/test/razorpay/test_customer.rb +8 -8
- data/test/razorpay/test_generic.rb +112 -0
- data/test/razorpay/test_iin.rb +23 -0
- data/test/razorpay/test_order.rb +1 -1
- data/test/razorpay/test_product.rb +67 -0
- data/test/razorpay/test_settlement.rb +1 -1
- data/test/razorpay/test_stakeholder.rb +87 -0
- data/test/razorpay/test_token.rb +66 -0
- data/test/razorpay/test_transfer.rb +1 -1
- data/test/razorpay/test_webhook.rb +132 -0
- metadata +52 -2
@@ -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
|
data/lib/razorpay/addon.rb
CHANGED
@@ -22,7 +22,7 @@ module Razorpay
|
|
22
22
|
# POST /addons is not supported
|
23
23
|
# Addon creation endpoint is:
|
24
24
|
# POST subscriptions/{sub_id}/addons
|
25
|
-
r.request :post, "/subscriptions/#{subscription_id}/addons", options
|
25
|
+
r.request :post, "/v1/subscriptions/#{subscription_id}/addons", options
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.delete(id)
|
data/lib/razorpay/card.rb
CHANGED
data/lib/razorpay/constants.rb
CHANGED
@@ -1,6 +1,32 @@
|
|
1
1
|
# Version and other constants are defined here
|
2
2
|
module Razorpay
|
3
|
-
BASE_URI = 'https://api.razorpay.com
|
3
|
+
BASE_URI = 'https://api.razorpay.com'.freeze
|
4
4
|
TEST_URL = 'https://api.razorpay.com/'.freeze
|
5
|
-
VERSION = '3.0
|
5
|
+
VERSION = '3.2.0'.freeze
|
6
|
+
ENTITIES_LIST = {
|
7
|
+
"cards" => "card",
|
8
|
+
"invoices" => "invoice",
|
9
|
+
"refunds" => "refund",
|
10
|
+
"orders" => "order",
|
11
|
+
"payments" => "payment",
|
12
|
+
"customers" => "customer",
|
13
|
+
"plans" => "plan",
|
14
|
+
"virtual_accounts" => "virtualAccount",
|
15
|
+
"addons" => "addon",
|
16
|
+
"subscriptions" => "subscriptions",
|
17
|
+
"subscription_registrations" => "subscription_registrations",
|
18
|
+
"transfers" => "transfers",
|
19
|
+
"payment_links" => "payment_links",
|
20
|
+
"settlements" => "settlements",
|
21
|
+
"qr_codes" => "qr_codes",
|
22
|
+
"items" => "items",
|
23
|
+
"fund_accounts" => "fund_accounts",
|
24
|
+
"webhooks" => "webhook",
|
25
|
+
"payment_methods" => "payment_methods",
|
26
|
+
"products" => "products",
|
27
|
+
"tokens" => "tokens",
|
28
|
+
"iins" => "iins",
|
29
|
+
"stakeholders" => "stakeholders",
|
30
|
+
"accounts" => "accounts"
|
31
|
+
}
|
6
32
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
class Generic
|
6
|
+
def initialize(entity)
|
7
|
+
@entity = entity
|
8
|
+
end
|
9
|
+
|
10
|
+
def request()
|
11
|
+
Razorpay::Request.new(@entity)
|
12
|
+
end
|
13
|
+
|
14
|
+
def do(url="", method="Get", options={}, version="v1")
|
15
|
+
r = self.request
|
16
|
+
r.doesEntityExist(@entity)
|
17
|
+
|
18
|
+
case method
|
19
|
+
when "Get"
|
20
|
+
r.get url, options, version
|
21
|
+
|
22
|
+
when "Post"
|
23
|
+
r.post url, options, version
|
24
|
+
|
25
|
+
when "Patch"
|
26
|
+
r.patch url, options, version
|
27
|
+
|
28
|
+
when "Put"
|
29
|
+
r.put url, options, version
|
30
|
+
|
31
|
+
when "Delete"
|
32
|
+
r.delete url, version
|
33
|
+
|
34
|
+
else
|
35
|
+
warn("Unsupported method or error occurred")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/razorpay/iin.rb
ADDED
@@ -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
|
data/lib/razorpay/order.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
# Product API allows you to enable sub-merchants request for a product.
|
6
|
+
class Product < Entity
|
7
|
+
|
8
|
+
@@versions = "v2"
|
9
|
+
|
10
|
+
def self.request
|
11
|
+
Razorpay::Request.new('accounts')
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.request_product_configuration(account_id, options)
|
15
|
+
if(!options.is_a?(String) && options.key?(:tnc_accepted))
|
16
|
+
options[:tnc_accepted] = (options[:tnc_accepted] ? 1 : 0)
|
17
|
+
end
|
18
|
+
request.post "#{account_id}/products", options, @@versions
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.fetch(account_id, id)
|
22
|
+
request.fetch "#{account_id}/products/#{id}", @@versions
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.edit(account_id, id, options = {})
|
26
|
+
if(!options.is_a?(String) && options.key?(:tnc_accepted))
|
27
|
+
options[:tnc_accepted] = (options[:tnc_accepted] ? 1 : 0)
|
28
|
+
end
|
29
|
+
request.patch "#{account_id}/products/#{id}", options, @@versions
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.fetch_tnc(productName)
|
33
|
+
r = request
|
34
|
+
r.request :get, "/#{@@versions}/products/#{productName}/tnc", {}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/razorpay/request.rb
CHANGED
@@ -27,36 +27,36 @@ module Razorpay
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
-
def fetch(id)
|
31
|
-
request :get, "/#{@entity_name}/#{id}"
|
30
|
+
def fetch(id, version="v1")
|
31
|
+
request :get, "/#{version}/#{@entity_name}/#{id}"
|
32
32
|
end
|
33
33
|
|
34
|
-
def all(options)
|
35
|
-
request :get, "/#{@entity_name}", options
|
34
|
+
def all(options, version="v1")
|
35
|
+
request :get, "/#{version}/#{@entity_name}", options
|
36
36
|
end
|
37
37
|
|
38
|
-
def post(url, data = {})
|
39
|
-
request :post, "/#{@entity_name}/#{url}", data
|
38
|
+
def post(url, data = {}, version="v1")
|
39
|
+
request :post, "/#{version}/#{@entity_name}/#{url}", data
|
40
40
|
end
|
41
41
|
|
42
|
-
def get(url, data = {})
|
43
|
-
request :get, "/#{@entity_name}/#{url}", data
|
42
|
+
def get(url, data = {}, version="v1")
|
43
|
+
request :get, "/#{version}/#{@entity_name}/#{url}", data
|
44
44
|
end
|
45
45
|
|
46
|
-
def delete(url)
|
47
|
-
request :delete, "/#{@entity_name}/#{url}"
|
46
|
+
def delete(url, version="v1")
|
47
|
+
request :delete, "/#{version}/#{@entity_name}/#{url}"
|
48
48
|
end
|
49
49
|
|
50
|
-
def put(id, data = {})
|
51
|
-
request :put, "/#{@entity_name}/#{id}", data
|
50
|
+
def put(id, data = {}, version="v1")
|
51
|
+
request :put, "/#{version}/#{@entity_name}/#{id}", data
|
52
52
|
end
|
53
53
|
|
54
|
-
def patch(id, data = {})
|
55
|
-
request :patch, "/#{@entity_name}/#{id}", data
|
54
|
+
def patch(id, data = {}, version="v1")
|
55
|
+
request :patch, "/#{version}/#{@entity_name}/#{id}", data
|
56
56
|
end
|
57
57
|
|
58
|
-
def create(data)
|
59
|
-
request :post, "/#{@entity_name}", data
|
58
|
+
def create(data, version="v1")
|
59
|
+
request :post, "/#{version}/#{@entity_name}", data
|
60
60
|
end
|
61
61
|
|
62
62
|
def request(method, url, data = {})
|
@@ -115,5 +115,11 @@ module Razorpay
|
|
115
115
|
# We got an unknown error, cast it to Error for now
|
116
116
|
raise Razorpay::Error.new, 'Unknown Error'
|
117
117
|
end
|
118
|
+
|
119
|
+
def doesEntityExist(entity)
|
120
|
+
if (Razorpay::ENTITIES_LIST.include?(entity))
|
121
|
+
warn("Warning: The entity already has a specific function. Consider using it instead.")
|
122
|
+
end
|
123
|
+
end
|
118
124
|
end
|
119
125
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
# Stakeholder API allows you to add stakeholders for an account.
|
6
|
+
class Stakeholder < Entity
|
7
|
+
|
8
|
+
@@versions = "v2"
|
9
|
+
|
10
|
+
def self.request
|
11
|
+
Razorpay::Request.new('accounts')
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create(account_id, options)
|
15
|
+
request.post "#{account_id}/stakeholders", options, @@versions
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.fetch(account_id, id)
|
19
|
+
request.fetch "#{account_id}/stakeholders/#{id}", @@versions
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.all(account_id)
|
23
|
+
request.get "#{account_id}/stakeholders",{}, @@versions
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.edit(account_id, id, options = {})
|
27
|
+
request.patch "#{account_id}/stakeholders/#{id}", options, @@versions
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.upload_stakeholder_doc(account_id, id,options)
|
31
|
+
r = request
|
32
|
+
r.request :post, "/#{@@versions}/accounts/#{account_id}/stakeholders/#{id}/documents", options
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.fetch_stakeholder_doc(account_id, id)
|
36
|
+
request.fetch "#{account_id}/stakeholders/#{id}/documents", @@versions
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
|
6
|
+
class Token < Entity
|
7
|
+
|
8
|
+
def self.request
|
9
|
+
Razorpay::Request.new('tokens')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.create(options)
|
13
|
+
request.create options
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.fetch(options)
|
17
|
+
request.post "fetch", options
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.delete(options)
|
21
|
+
request.post "delete", options
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.process_payment_on_alternate_pa_or_pg(options)
|
25
|
+
request.post "service_provider_tokens/token_transactional_data", options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
# Webhook API allows you create, fetch, update and delete
|
6
|
+
class Webhook < Entity
|
7
|
+
|
8
|
+
@@versions = "v2"
|
9
|
+
|
10
|
+
def self.request
|
11
|
+
Razorpay::Request.new('accounts')
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create(options, account_id = nil)
|
15
|
+
if(account_id)
|
16
|
+
return request.post "#{account_id}/webhooks", options, @@versions
|
17
|
+
end
|
18
|
+
|
19
|
+
r = request
|
20
|
+
return r.request :post, "/v1/webhooks", options
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.all(options = {}, account_id = nil)
|
24
|
+
if(account_id)
|
25
|
+
return request.get "#{account_id}/webhooks" , options , @@versions
|
26
|
+
end
|
27
|
+
|
28
|
+
r = request
|
29
|
+
return r.request :get, "/v1/webhooks", options
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.fetch(id, account_id)
|
33
|
+
request.fetch "#{account_id}/webhooks/#{id}", @@versions
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.edit(options, id, account_id = nil)
|
37
|
+
if(account_id)
|
38
|
+
return request.patch "#{account_id}/webhooks/#{id}", options, @@versions
|
39
|
+
end
|
40
|
+
|
41
|
+
r = request
|
42
|
+
return r.request :put, "/v1/webhooks/#{id}" , options
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.delete(id, account_id)
|
46
|
+
request.delete "#{account_id}/webhooks/#{id}", @@versions
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
data/lib/razorpay.rb
CHANGED
@@ -20,6 +20,13 @@ require 'razorpay/fund_account'
|
|
20
20
|
require 'razorpay/item'
|
21
21
|
require 'razorpay/qr_code'
|
22
22
|
require 'razorpay/payment_method'
|
23
|
+
require 'razorpay/webhook'
|
24
|
+
require 'razorpay/iin'
|
25
|
+
require 'razorpay/token'
|
26
|
+
require 'razorpay/product'
|
27
|
+
require 'razorpay/stakeholder'
|
28
|
+
require 'razorpay/account'
|
29
|
+
require 'razorpay/generic'
|
23
30
|
|
24
31
|
# Base Razorpay module
|
25
32
|
module Razorpay
|