rb-instamojo 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.travis.yml +3 -0
- data/Gemfile +5 -0
- data/README.md +565 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/instamojo.gemspec +32 -0
- data/lib/instamojo.rb +22 -0
- data/lib/instamojo/api.rb +128 -0
- data/lib/instamojo/configuration.rb +13 -0
- data/lib/instamojo/version.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fc417f57c0f0b4f7234db1cd29c687132f45bf2
|
4
|
+
data.tar.gz: 90df1cfbd0e4493261716fc2e5c3c641c260dd9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7929eed89f11e047ef0c3f636cac4ffbd5707c5938cd6bd54683de9c0e204956a5e30a673f699cc2db918d4b9590da7d7ea52245f9f40be7f4b7c8dac38f46e7
|
7
|
+
data.tar.gz: 89e0f8464bc56b8b412806245b481d6c2bdbf389ca87a07b48237e613691225fed1c90841649ade3360233c5bc4cda3514c7247e4f4115eaf329b074f5558614
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,565 @@
|
|
1
|
+
# Instamojo
|
2
|
+
|
3
|
+
Will use to integrate instomojo apis with ruby. Will support ruby 2.0 or newver
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'instamojo'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install instamojo
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
add following code to config/intializer/instamojo.rb
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Instamojo.configure do |config|
|
27
|
+
config.client_id = 'XXXX'
|
28
|
+
config.client_secret = 'XXXXXXX'
|
29
|
+
config.mode = :test
|
30
|
+
end
|
31
|
+
|
32
|
+
```
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
### Sign up method
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
options = {
|
40
|
+
username: 'xxx', # manadatory
|
41
|
+
email: 'xxx@xxx.xxx', # manadatory
|
42
|
+
password: 'xxxxx233xxx', # manadatory
|
43
|
+
phone: 'xxxxxxxxx', # manadatory
|
44
|
+
referrer: 'xxxxx'
|
45
|
+
}
|
46
|
+
api.signup(options)
|
47
|
+
```
|
48
|
+
|
49
|
+
|
50
|
+
### Generate User Token
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
options = {
|
54
|
+
username: 'xxx', # manadatory
|
55
|
+
password: 'xxxxx233xxx', # manadatory
|
56
|
+
}
|
57
|
+
api.user_token(options)
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
### Update Bank Details
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
options = {
|
65
|
+
account_holder_name: 'xxx', # manadatory
|
66
|
+
account_number: '998799899', # manadatory
|
67
|
+
ifsc_code: 'JUUJU9889'
|
68
|
+
}
|
69
|
+
|
70
|
+
user_id # manadatory
|
71
|
+
api.inrbankaccount(user_id, options)
|
72
|
+
```
|
73
|
+
|
74
|
+
|
75
|
+
### Create Payment Link
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
options = {
|
79
|
+
'amount': '2500', # mandatory
|
80
|
+
'purpose': 'FIFA 16', # mandatory
|
81
|
+
'buyer_name': 'John Doe', # mandatory
|
82
|
+
'email': 'foo@example.com',
|
83
|
+
'phone': '9999999999',
|
84
|
+
'redirect_url': 'http://www.example.com/redirect/',
|
85
|
+
'send_email': 'True',
|
86
|
+
'send_sms': 'True',
|
87
|
+
'webhook': 'http://www.example.com/webhook/'
|
88
|
+
'allow_repeated_payments': 'False',
|
89
|
+
}
|
90
|
+
api.payment_link(options)
|
91
|
+
```
|
92
|
+
|
93
|
+
### API Doc
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
{
|
97
|
+
"id":"bf9d8993-83e1-5687-3c4a-3b9ac8c25fc1",
|
98
|
+
"name":"auth-flow-integration",
|
99
|
+
"description":"",
|
100
|
+
"order":[
|
101
|
+
"bb1ab458-c149-34fb-9b07-95952eac3f0f",
|
102
|
+
"3fefebf2-9f92-bda5-c6cc-67d4cbc9a2ee",
|
103
|
+
"2229fdf6-6d19-fc9c-510b-1a39f0caba02",
|
104
|
+
"2cda24d7-aab9-fba0-0db7-33dc744e5bc8",
|
105
|
+
"284c2f07-2a18-b340-9114-ffe88d99f425",
|
106
|
+
"3f4938b7-7a0b-8254-19ab-ed553f955151"
|
107
|
+
],
|
108
|
+
"folders":[
|
109
|
+
|
110
|
+
],
|
111
|
+
"timestamp":1444030167485,
|
112
|
+
"owner":"47402",
|
113
|
+
"remoteLink":"",
|
114
|
+
"public":false,
|
115
|
+
"requests":[
|
116
|
+
{
|
117
|
+
"collectionId":"bf9d8993-83e1-5687-3c4a-3b9ac8c25fc1",
|
118
|
+
"id":"2229fdf6-6d19-fc9c-510b-1a39f0caba02",
|
119
|
+
"name":"Get User Token",
|
120
|
+
"description":"### Get User Access Token\n\nUse this to get an User access token. You will need it to modify of a user on Instamojo.\n\nThe expiry time for an user access token is `36000` seconds.\n\nA user token will have a refresh token associated with it. So if a user token expires, you can use the refresh token along with your client_id and client_secret to get a new user access token.\n\n##### Field validations\n1. `grant_type`: `client_credentials`\n2. `username`: Mandatory. Username of the user.\n3. `password`: Mandatory. Password of the user.\n4. `client_id`: Mandatory. You Instamojo client_id.\n5. `client_secret`: Mandatory. Your Instamojo client_secret.\n",
|
121
|
+
"url":"{{AUTH_SERVER}}/oauth2/token/",
|
122
|
+
"method":"POST",
|
123
|
+
"headers":"",
|
124
|
+
"data":[
|
125
|
+
{
|
126
|
+
"key":"grant_type",
|
127
|
+
"value":"password",
|
128
|
+
"type":"text",
|
129
|
+
"enabled":true
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"key":"client_id",
|
133
|
+
"value":"{{CLIENT_ID}}",
|
134
|
+
"type":"text",
|
135
|
+
"enabled":true
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"key":"client_secret",
|
139
|
+
"value":"{{CLIENT_SECRET}}",
|
140
|
+
"type":"text",
|
141
|
+
"enabled":true
|
142
|
+
},
|
143
|
+
{
|
144
|
+
"key":"username",
|
145
|
+
"value":"{{USERNAME}}",
|
146
|
+
"type":"text",
|
147
|
+
"enabled":true
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"key":"password",
|
151
|
+
"value":"{{PASSWORD}}",
|
152
|
+
"type":"text",
|
153
|
+
"enabled":true
|
154
|
+
}
|
155
|
+
],
|
156
|
+
"dataMode":"params",
|
157
|
+
"responses":[
|
158
|
+
|
159
|
+
],
|
160
|
+
"version":2
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"collectionId":"bf9d8993-83e1-5687-3c4a-3b9ac8c25fc1",
|
164
|
+
"id":"284c2f07-2a18-b340-9114-ffe88d99f425",
|
165
|
+
"name":"Update bank details",
|
166
|
+
"description":"## Add / Update the Bank Details\n\n\nPayouts will be sent/processed to this bank account.\n\n#### Field validations\n\n1. `account_holder_name` - Mandatory. Maxlength=100\n2. `account_number` - Mandatory. Maxlength=50, Digits only.\n3. `ifsc_code` - Mandatory, Exact length=11, First 4 alpha, 5th 0, remaining alpha numeric. Ex: `SBIN0123456`",
|
167
|
+
"url":"{{API_SERVER}}/v2/users/{{USER_ID}}/inrbankaccount/",
|
168
|
+
"method":"PUT",
|
169
|
+
"headers":"Authorization: Bearer {{USER_ACCESS_TOKEN}}\n",
|
170
|
+
"data":[
|
171
|
+
{
|
172
|
+
"key":"account_holder_name",
|
173
|
+
"value":"Foo Bar",
|
174
|
+
"type":"text",
|
175
|
+
"enabled":true
|
176
|
+
},
|
177
|
+
{
|
178
|
+
"key":"account_number",
|
179
|
+
"value":"123456789",
|
180
|
+
"type":"text",
|
181
|
+
"enabled":true
|
182
|
+
},
|
183
|
+
{
|
184
|
+
"key":"ifsc_code",
|
185
|
+
"value":"SBIN0123456",
|
186
|
+
"type":"text",
|
187
|
+
"enabled":true
|
188
|
+
}
|
189
|
+
],
|
190
|
+
"dataMode":"params",
|
191
|
+
"responses":[
|
192
|
+
|
193
|
+
],
|
194
|
+
"version":2
|
195
|
+
},
|
196
|
+
{
|
197
|
+
"collectionId":"bf9d8993-83e1-5687-3c4a-3b9ac8c25fc1",
|
198
|
+
"id":"2cda24d7-aab9-fba0-0db7-33dc744e5bc8",
|
199
|
+
"name":"Update Name and Location of a User",
|
200
|
+
"description":"### Update User information\n\n##### Validations\n1. `first_name` - Optional. Maxlength=30\n2. `last_name` - Optional. Maxlength=30\n3. `location` - Optional. Maxlenth=100. Location in text format. Ex: Mumbai, India",
|
201
|
+
"url":"{{API_SERVER}}/v2/users/{{USER_ID}}",
|
202
|
+
"method":"PATCH",
|
203
|
+
"headers":"Authorization: Bearer {{USER_ACCESS_TOKEN}}\n",
|
204
|
+
"data":[
|
205
|
+
{
|
206
|
+
"key":"first_name",
|
207
|
+
"value":"Foo",
|
208
|
+
"type":"text",
|
209
|
+
"enabled":true
|
210
|
+
},
|
211
|
+
{
|
212
|
+
"key":"last_name",
|
213
|
+
"value":"Bar",
|
214
|
+
"type":"text",
|
215
|
+
"enabled":true
|
216
|
+
},
|
217
|
+
{
|
218
|
+
"key":"location",
|
219
|
+
"value":"India",
|
220
|
+
"type":"text",
|
221
|
+
"enabled":true
|
222
|
+
}
|
223
|
+
],
|
224
|
+
"dataMode":"params",
|
225
|
+
"responses":[
|
226
|
+
|
227
|
+
],
|
228
|
+
"version":2
|
229
|
+
},
|
230
|
+
{
|
231
|
+
"collectionId":"bf9d8993-83e1-5687-3c4a-3b9ac8c25fc1",
|
232
|
+
"id":"3f4938b7-7a0b-8254-19ab-ed553f955151",
|
233
|
+
"name":"Get User Token from Refresh Token",
|
234
|
+
"description":"### Get User token from Refresh token\n\nIf you already have a user access token for a specific user, but the token has expired, use this to fetch a fresh access token. \n\nWhen you use this, you wont need the user's credentials again. Send the refresh_token instead. \n\nAlso, note that the `grant_type` in this case is `refresh_token`.\n\n###### Field validations\n1. `grant_type`: `refresh_token`\n2. `refresh_token`: Mandatory. The refresh token.\n3. `client_id`: Mandatory. You Instamojo client_id.\n4. `client_secret`: Mandatory. Your Instamojo client_secret.",
|
235
|
+
"url":"{{AUTH_SERVER}}/oauth2/token/",
|
236
|
+
"method":"POST",
|
237
|
+
"headers":"",
|
238
|
+
"data":[
|
239
|
+
{
|
240
|
+
"key":"grant_type",
|
241
|
+
"value":"refresh_token",
|
242
|
+
"type":"text",
|
243
|
+
"enabled":true
|
244
|
+
},
|
245
|
+
{
|
246
|
+
"key":"client_id",
|
247
|
+
"value":"{{CLIENT_ID}}",
|
248
|
+
"type":"text",
|
249
|
+
"enabled":true
|
250
|
+
},
|
251
|
+
{
|
252
|
+
"key":"client_secret",
|
253
|
+
"value":"{{CLIENT_SECRET}}",
|
254
|
+
"type":"text",
|
255
|
+
"enabled":true
|
256
|
+
},
|
257
|
+
{
|
258
|
+
"key":"refresh_token",
|
259
|
+
"value":"IHbzz97XePGwX3VBGaVlOdGOxfGHWJ",
|
260
|
+
"type":"text",
|
261
|
+
"enabled":true
|
262
|
+
}
|
263
|
+
],
|
264
|
+
"dataMode":"params",
|
265
|
+
"responses":[
|
266
|
+
|
267
|
+
],
|
268
|
+
"version":2
|
269
|
+
},
|
270
|
+
{
|
271
|
+
"collectionId":"bf9d8993-83e1-5687-3c4a-3b9ac8c25fc1",
|
272
|
+
"id":"3fefebf2-9f92-bda5-c6cc-67d4cbc9a2ee",
|
273
|
+
"name":"Signup",
|
274
|
+
"description":"### Sign up users\n\n#####Field Validations\n1. `username`: Mandatory. `Maxlength` = `35 chars`.\n2. `password`: Mandatory.\n3. `email`: Mandatory.\n4. `phone`: Mandatory\n4. `referrer`: `shopo`",
|
275
|
+
"url":"{{API_SERVER}}/v2/users/",
|
276
|
+
"method":"POST",
|
277
|
+
"headers":"Authorization: Bearer {{APP_ACCESS_TOKEN}}\n",
|
278
|
+
"data":[
|
279
|
+
{
|
280
|
+
"key":"username",
|
281
|
+
"value":"dhanush_5oct13",
|
282
|
+
"type":"text"
|
283
|
+
},
|
284
|
+
{
|
285
|
+
"key":"password",
|
286
|
+
"value":"abcd1234",
|
287
|
+
"type":"text"
|
288
|
+
},
|
289
|
+
{
|
290
|
+
"key":"email",
|
291
|
+
"value":"dhanush+5oct13@instamojo.com",
|
292
|
+
"type":"text"
|
293
|
+
},
|
294
|
+
{
|
295
|
+
"key":"phone",
|
296
|
+
"value":"+918748984861",
|
297
|
+
"type":"text"
|
298
|
+
},
|
299
|
+
{
|
300
|
+
"key":"referrer",
|
301
|
+
"value":"shopo",
|
302
|
+
"type":"text"
|
303
|
+
}
|
304
|
+
],
|
305
|
+
"dataMode":"params",
|
306
|
+
"timestamp":0,
|
307
|
+
"version":2,
|
308
|
+
"time":1444116541552
|
309
|
+
},
|
310
|
+
{
|
311
|
+
"collectionId":"bf9d8993-83e1-5687-3c4a-3b9ac8c25fc1",
|
312
|
+
"id":"bb1ab458-c149-34fb-9b07-95952eac3f0f",
|
313
|
+
"name":"Get App Token",
|
314
|
+
"description":"### Get an app access token\n\nUse this to get an App access token. You will need it to sign up users on Instamojo.\n\nThe expiry time for a app access token is `36000` seconds.\n\nAn app token wont have any refresh token associated to it. So if an app access token expires, you will have to resend this request again. \n\n##### Field validations\n1. `grant_type`: `client_credentials`\n2. `client_id`: Mandatory. You Instamojo client_id.\n3. `client_secret`: Mandatory. Your Instamojo client_secret.",
|
315
|
+
"url":"{{AUTH_SERVER}}/oauth2/token/",
|
316
|
+
"method":"POST",
|
317
|
+
"headers":"",
|
318
|
+
"data":[
|
319
|
+
{
|
320
|
+
"key":"grant_type",
|
321
|
+
"value":"client_credentials",
|
322
|
+
"type":"text",
|
323
|
+
"enabled":true
|
324
|
+
},
|
325
|
+
{
|
326
|
+
"key":"client_id",
|
327
|
+
"value":"{{CLIENT_ID}}",
|
328
|
+
"type":"text",
|
329
|
+
"enabled":true
|
330
|
+
},
|
331
|
+
{
|
332
|
+
"key":"client_secret",
|
333
|
+
"value":"{{CLIENT_SECRET}}",
|
334
|
+
"type":"text",
|
335
|
+
"enabled":true
|
336
|
+
}
|
337
|
+
],
|
338
|
+
"dataMode":"params",
|
339
|
+
"responses":[
|
340
|
+
|
341
|
+
],
|
342
|
+
"version":2
|
343
|
+
}
|
344
|
+
]
|
345
|
+
}
|
346
|
+
```
|
347
|
+
|
348
|
+
## Payment API
|
349
|
+
|
350
|
+
```ruby
|
351
|
+
{
|
352
|
+
"id":"cffc6b9e-ab1c-4ba3-411d-fd45c38f671f",
|
353
|
+
"name":"RAP V2",
|
354
|
+
"timestamp":1444044417026,
|
355
|
+
"requests":[
|
356
|
+
{
|
357
|
+
"collectionId":"cffc6b9e-ab1c-4ba3-411d-fd45c38f671f",
|
358
|
+
"id":"40564e31-10c1-0e71-1f2a-e40560b81dcb",
|
359
|
+
"name":"RAP details",
|
360
|
+
"description":"Get the details of a payment request using the payment_request_id",
|
361
|
+
"url":"{{API_SERVER}}/v2/payment_requests/{{PAYMENT_REQUEST_ID}}",
|
362
|
+
"method":"GET",
|
363
|
+
"headers":"Authorization: Bearer {{USER_ACCESS_TOKEN}\n",
|
364
|
+
"data":[
|
365
|
+
{
|
366
|
+
"key":"amount",
|
367
|
+
"value":"2500",
|
368
|
+
"type":"text"
|
369
|
+
},
|
370
|
+
{
|
371
|
+
"key":"purpose",
|
372
|
+
"value":"FIFA 16",
|
373
|
+
"type":"text"
|
374
|
+
},
|
375
|
+
{
|
376
|
+
"key":"send_sms",
|
377
|
+
"value":"True",
|
378
|
+
"type":"text"
|
379
|
+
},
|
380
|
+
{
|
381
|
+
"key":"phone",
|
382
|
+
"value":"9999999999",
|
383
|
+
"type":"text"
|
384
|
+
}
|
385
|
+
],
|
386
|
+
"dataMode":"params",
|
387
|
+
"timestamp":0,
|
388
|
+
"version":2,
|
389
|
+
"time":1444116919416
|
390
|
+
},
|
391
|
+
{
|
392
|
+
"collectionId":"cffc6b9e-ab1c-4ba3-411d-fd45c38f671f",
|
393
|
+
"id":"48d9c02b-6884-3596-2735-6584c181875b",
|
394
|
+
"name":"RAP creation with send_sms",
|
395
|
+
"description":"If 'send_sms' field is passed as True then 'phone' field is compulsory.",
|
396
|
+
"url":"{{API_SERVER}}/v2/payment_requests/",
|
397
|
+
"method":"POST",
|
398
|
+
"headers":"Authorization: Bearer {{USER_ACCESS_TOKEN}\n",
|
399
|
+
"data":[
|
400
|
+
{
|
401
|
+
"key":"amount",
|
402
|
+
"value":"2500",
|
403
|
+
"type":"text"
|
404
|
+
},
|
405
|
+
{
|
406
|
+
"key":"purpose",
|
407
|
+
"value":"FIFA 16",
|
408
|
+
"type":"text"
|
409
|
+
},
|
410
|
+
{
|
411
|
+
"key":"send_sms",
|
412
|
+
"value":"True",
|
413
|
+
"type":"text"
|
414
|
+
},
|
415
|
+
{
|
416
|
+
"key":"phone",
|
417
|
+
"value":"9999999999",
|
418
|
+
"type":"text"
|
419
|
+
}
|
420
|
+
],
|
421
|
+
"dataMode":"params",
|
422
|
+
"timestamp":0,
|
423
|
+
"version":2,
|
424
|
+
"time":1444116914545
|
425
|
+
},
|
426
|
+
{
|
427
|
+
"collectionId":"cffc6b9e-ab1c-4ba3-411d-fd45c38f671f",
|
428
|
+
"id":"69d60626-2572-44ad-daa3-96ee2a6a5f12",
|
429
|
+
"name":"RAP creation minimal data",
|
430
|
+
"description":"Amount and purpose are the only compulsory fields for creating a request payment.",
|
431
|
+
"url":"{{API_SERVER}}/v2/payment_requests/",
|
432
|
+
"method":"POST",
|
433
|
+
"headers":"Authorization: Bearer {{USER_ACCESS_TOKEN}\n",
|
434
|
+
"data":[
|
435
|
+
{
|
436
|
+
"key":"amount",
|
437
|
+
"value":"2500",
|
438
|
+
"type":"text"
|
439
|
+
},
|
440
|
+
{
|
441
|
+
"key":"purpose",
|
442
|
+
"value":"FIFA 16",
|
443
|
+
"type":"text"
|
444
|
+
}
|
445
|
+
],
|
446
|
+
"dataMode":"params",
|
447
|
+
"timestamp":0,
|
448
|
+
"version":2,
|
449
|
+
"time":1444116823741
|
450
|
+
},
|
451
|
+
{
|
452
|
+
"collectionId":"cffc6b9e-ab1c-4ba3-411d-fd45c38f671f",
|
453
|
+
"id":"891e3ec0-9c39-c7c1-c5e8-b0a4f4ea6924",
|
454
|
+
"name":"RAP creation with maximal data",
|
455
|
+
"description":"This request contains all of the fields that we can pass with a payment request creation.",
|
456
|
+
"url":"{{API_SERVER}}/v2/payment_requests/",
|
457
|
+
"method":"POST",
|
458
|
+
"headers":"Authorization: Bearer {{USER_ACCESS_TOKEN}\n",
|
459
|
+
"data":[
|
460
|
+
{
|
461
|
+
"key":"amount",
|
462
|
+
"value":"2500",
|
463
|
+
"type":"text"
|
464
|
+
},
|
465
|
+
{
|
466
|
+
"key":"purpose",
|
467
|
+
"value":"FIFA 16",
|
468
|
+
"type":"text"
|
469
|
+
},
|
470
|
+
{
|
471
|
+
"key":"send_sms",
|
472
|
+
"value":"True",
|
473
|
+
"type":"text"
|
474
|
+
},
|
475
|
+
{
|
476
|
+
"key":"send_email",
|
477
|
+
"value":"True",
|
478
|
+
"type":"text"
|
479
|
+
},
|
480
|
+
{
|
481
|
+
"key":"phone",
|
482
|
+
"value":"9999999999",
|
483
|
+
"type":"text"
|
484
|
+
},
|
485
|
+
{
|
486
|
+
"key":"email",
|
487
|
+
"value":"foo@example.com",
|
488
|
+
"type":"text"
|
489
|
+
},
|
490
|
+
{
|
491
|
+
"key":"buyer_name",
|
492
|
+
"value":"John Doe",
|
493
|
+
"type":"text"
|
494
|
+
},
|
495
|
+
{
|
496
|
+
"key":"redirect_url",
|
497
|
+
"value":"http://www.example.com/redirect/",
|
498
|
+
"type":"text"
|
499
|
+
},
|
500
|
+
{
|
501
|
+
"key":"webhook",
|
502
|
+
"value":"http://www.example.com/webhook/",
|
503
|
+
"type":"text"
|
504
|
+
},
|
505
|
+
{
|
506
|
+
"key":"allow_repeated_payments",
|
507
|
+
"value":"False",
|
508
|
+
"type":"text"
|
509
|
+
}
|
510
|
+
],
|
511
|
+
"dataMode":"params",
|
512
|
+
"timestamp":0,
|
513
|
+
"version":2,
|
514
|
+
"time":1444116905712
|
515
|
+
},
|
516
|
+
{
|
517
|
+
"collectionId":"cffc6b9e-ab1c-4ba3-411d-fd45c38f671f",
|
518
|
+
"id":"ff1f35b0-77d0-6a25-dadc-4fbba09073cf",
|
519
|
+
"name":"RAP creation with send_email",
|
520
|
+
"description":"If 'send_email' field is passed as True then 'email' field is compulsory.",
|
521
|
+
"url":"{{API_SERVER}}/v2/payment_requests/",
|
522
|
+
"method":"POST",
|
523
|
+
"headers":"Authorization: Bearer {{USER_ACCESS_TOKEN}\n",
|
524
|
+
"data":[
|
525
|
+
{
|
526
|
+
"key":"amount",
|
527
|
+
"value":"2500",
|
528
|
+
"type":"text"
|
529
|
+
},
|
530
|
+
{
|
531
|
+
"key":"purpose",
|
532
|
+
"value":"FIFA 16",
|
533
|
+
"type":"text"
|
534
|
+
},
|
535
|
+
{
|
536
|
+
"key":"send_email",
|
537
|
+
"value":"True",
|
538
|
+
"type":"text"
|
539
|
+
},
|
540
|
+
{
|
541
|
+
"key":"email",
|
542
|
+
"value":"foo@example.com",
|
543
|
+
"type":"text"
|
544
|
+
}
|
545
|
+
],
|
546
|
+
"dataMode":"params",
|
547
|
+
"timestamp":0,
|
548
|
+
"version":2,
|
549
|
+
"time":1444116910314
|
550
|
+
}
|
551
|
+
]
|
552
|
+
}
|
553
|
+
```
|
554
|
+
|
555
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
556
|
+
|
557
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
558
|
+
|
559
|
+
## Contributing
|
560
|
+
|
561
|
+
1. Fork it ( https://github.com/zambrevishal/instamojo/fork )
|
562
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
563
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
564
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
565
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "instamojo"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/instamojo.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'instamojo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'rb-instamojo'
|
8
|
+
spec.version = Instamojo::VERSION
|
9
|
+
spec.authors = ['Vishal Zambre']
|
10
|
+
spec.email = ['v.zambre@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Will provide apis for instamojo payment'
|
13
|
+
spec.description = %q(Assists you to programmatically create, edit and delete links on Instamojo.)
|
14
|
+
spec.homepage = 'https://github.com/vishalzambre/instamojo-rb'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
|
+
else
|
21
|
+
fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.3'
|
32
|
+
end
|
data/lib/instamojo.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'instamojo/version'
|
2
|
+
require 'instamojo/configuration'
|
3
|
+
require 'instamojo/api'
|
4
|
+
|
5
|
+
# Instamojo lib
|
6
|
+
module Instamojo
|
7
|
+
class << self
|
8
|
+
attr_accessor :configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configuration
|
12
|
+
@configuration ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.reset
|
16
|
+
@configuration = Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.configure
|
20
|
+
yield(configuration)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
|
5
|
+
module Instamojo
|
6
|
+
# Manage sync call between instamojo
|
7
|
+
class API
|
8
|
+
attr_accessor :config, :access_token, :refresh_token, :header
|
9
|
+
|
10
|
+
TEST_URL = 'https://test.instamojo.com'
|
11
|
+
LIVE_URL = 'https://instamojo.com'
|
12
|
+
|
13
|
+
def initialize(config = Instamojo.configuration)
|
14
|
+
@config = config
|
15
|
+
@header = true
|
16
|
+
end
|
17
|
+
|
18
|
+
# Generate authetication token
|
19
|
+
def auth_token
|
20
|
+
@access_token = nil
|
21
|
+
token(credentials('client_credentials'))
|
22
|
+
end
|
23
|
+
|
24
|
+
# Refresh existing token
|
25
|
+
def refresh_token
|
26
|
+
token(credentials('refresh_token').merge(refresh_token: @refresh_token))
|
27
|
+
end
|
28
|
+
|
29
|
+
# create new account to instamojo
|
30
|
+
def signup(options = {})
|
31
|
+
auth_token unless @access_token
|
32
|
+
options[:referrer] ||= config.referrer
|
33
|
+
@header = true
|
34
|
+
signup_url = "#{url}/v2/users/"
|
35
|
+
post(signup_url, options)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generate user access token
|
39
|
+
def user_token(options = {})
|
40
|
+
token(options.merge(credentials('password')))
|
41
|
+
end
|
42
|
+
|
43
|
+
# Update bank detail to instamojo
|
44
|
+
def inrbankaccount(user_id, options = {})
|
45
|
+
check_token
|
46
|
+
@header = true
|
47
|
+
bank_url = "#{url}/v2/users/#{user_id}/inrbankaccount/"
|
48
|
+
put(bank_url, options)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Create a payment link
|
52
|
+
def payment_link(options = {})
|
53
|
+
check_token
|
54
|
+
@header = true
|
55
|
+
payment_url = "#{url}/v2/payment_requests/"
|
56
|
+
post(payment_url, options)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get detail of payment
|
60
|
+
def payment_details(payment_request_id)
|
61
|
+
check_token
|
62
|
+
payment_url = "#{url}/v2/payment_requests/#{payment_request_id}/"
|
63
|
+
@header = true
|
64
|
+
get(payment_url)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get payment status
|
68
|
+
def payment_status(payment_request_id)
|
69
|
+
check_token
|
70
|
+
payment_url = "#{url}/v2/payments/#{payment_request_id}/"
|
71
|
+
@header = true
|
72
|
+
get(payment_url)
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# Generate token
|
78
|
+
def token(options)
|
79
|
+
@header = false
|
80
|
+
auth_url = "#{url}/oauth2/token/"
|
81
|
+
response = post(auth_url, options)
|
82
|
+
@access_token = response['access_token']
|
83
|
+
@refresh_token = response['refresh_token']
|
84
|
+
response
|
85
|
+
end
|
86
|
+
|
87
|
+
def credentials(grant_type)
|
88
|
+
{
|
89
|
+
grant_type: grant_type,
|
90
|
+
client_id: config.client_id,
|
91
|
+
client_secret: config.client_secret
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
def url
|
96
|
+
config.mode == :test ? TEST_URL : LIVE_URL
|
97
|
+
end
|
98
|
+
|
99
|
+
%w(post put get).each do |method|
|
100
|
+
define_method "#{method}" do |url, options = {}|
|
101
|
+
uri = URI(url)
|
102
|
+
req = "Net::HTTP::#{method.titleize}".constantize.new(uri.path)
|
103
|
+
headers.each do |key, value|
|
104
|
+
req[key] = value
|
105
|
+
end
|
106
|
+
req.set_form_data(options)
|
107
|
+
response =
|
108
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
109
|
+
http.request(req)
|
110
|
+
end
|
111
|
+
JSON.parse(URI.decode(response.body))
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def headers
|
116
|
+
http_header = {
|
117
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
118
|
+
'Accept' => 'application/json'
|
119
|
+
}
|
120
|
+
return http_header unless header || @access_token
|
121
|
+
http_header.merge('Authorization' => "Bearer #{@access_token}")
|
122
|
+
end
|
123
|
+
|
124
|
+
def check_token
|
125
|
+
fail 'Please generate access token' unless @access_token
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rb-instamojo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vishal Zambre
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
description: Assists you to programmatically create, edit and delete links on Instamojo.
|
56
|
+
email:
|
57
|
+
- v.zambre@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- instamojo.gemspec
|
71
|
+
- lib/instamojo.rb
|
72
|
+
- lib/instamojo/api.rb
|
73
|
+
- lib/instamojo/configuration.rb
|
74
|
+
- lib/instamojo/version.rb
|
75
|
+
homepage: https://github.com/vishalzambre/instamojo-rb
|
76
|
+
licenses: []
|
77
|
+
metadata:
|
78
|
+
allowed_push_host: https://rubygems.org
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.6
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Will provide apis for instamojo payment
|
99
|
+
test_files: []
|