synapse_pay 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/synapse_pay.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # SynapsePay Ruby bindings
2
- # API Docs are located at http://synapsepay.readme.io/v1.0/docs
2
+ # API Docs are located at http://api.synapsepay.com/v2.0
3
3
  require 'cgi'
4
4
  require 'set'
5
5
  require 'openssl'
@@ -63,11 +63,11 @@ require 'synapse_pay/endpoints/withdrawal_endpoint'
63
63
  require 'synapse_pay/client'
64
64
 
65
65
  module SynapsePay
66
- @api_base = "https://synapsepay.com/api/v2/"
66
+ @api_base = "https://synapsepay.com/api/v2"
67
67
  @api_staging = "https://sandbox.synapsepay.com/api/v2"
68
68
  @api_version = "v2"
69
69
  @support_email = "hello@synapsepay.com"
70
- @docs_url = "http://synapsepay.readme.io/v1.0/docs"
70
+ @docs_url = "http://api.synapsepay.com/v2.0"
71
71
  @api_sandbox = "https://sandbox.synapsepay.com/api/v2"
72
72
 
73
73
  class << self
data/samples.md ADDED
@@ -0,0 +1,626 @@
1
+ # Oauth Client
2
+
3
+ To access most endpoints you need an oauth client that makes requests using an oauth_consumer_key. This is automatically created when you:
4
+
5
+ - Create a user
6
+ - Login as a user
7
+ - Refresh access with a refresh_token
8
+
9
+ But if you ever need to create a new one using an existing oauth_consumer_key you can with the following code:
10
+
11
+ ```ruby
12
+ client = SynapsePay::Client.new("oauth_consumer_key", "refresh_token")
13
+
14
+ # The refresh token is optional, but if you provide it you can refresh with no extra arguments:
15
+ client.refresh_access
16
+ ```
17
+
18
+ # User
19
+
20
+ ## Create a user
21
+
22
+ ```ruby
23
+ # Make sure we are in Sandbox
24
+ SynapsePay.api_base = SynapsePay.api_sandbox
25
+
26
+ SynapsePay.client_id = "client-id"
27
+ SynapsePay.client_secret = "client-secret"
28
+
29
+ # This creates an oauth client for the newly created user.
30
+ client = SynapsePay::User.create({
31
+ :email => "test-user@synapsepay.com",
32
+ :fullname => "Test Account",
33
+ :ip_address => "11.111.11.11",
34
+ :phonenumber => "123456789"
35
+ })
36
+ ```
37
+
38
+ ## Create a user with force_create = "no"
39
+
40
+ This will return an existing user instead of throwing an error if one exists.
41
+
42
+ ```ruby
43
+ # Make sure we are in Sandbox
44
+ SynapsePay.api_base = SynapsePay.api_sandbox
45
+
46
+ SynapsePay.client_id = "client-id"
47
+ SynapsePay.client_secret = "client-secret"
48
+
49
+ # This creates an oauth client for the newly created user.
50
+ client = SynapsePay::User.create({
51
+ :email => "test-user@synapsepay.com",
52
+ :fullname => "Test Account",
53
+ :ip_address => "11.111.11.11",
54
+ :phonenumber => "123456789",
55
+ :force_create => "no"
56
+ })
57
+ ```
58
+
59
+
60
+ ## Login as a user
61
+
62
+ ```ruby
63
+ # Make sure we are in Sandbox
64
+ SynapsePay.api_base = SynapsePay.api_sandbox
65
+
66
+ SynapsePay.client_id = "client-id"
67
+ SynapsePay.client_secret = "client-secret"
68
+
69
+ # Returns an oauth client for this user
70
+ client = SynapsePay::User.login("username", "password")
71
+ ```
72
+
73
+
74
+ ## Refresh access
75
+
76
+ ```ruby
77
+ # Make sure we are in Sandbox
78
+ SynapsePay.api_base = SynapsePay.api_sandbox
79
+
80
+ SynapsePay.client_id = "client-id"
81
+ SynapsePay.client_secret = "client-secret"
82
+
83
+ client = SynapsePay::Client.refresh_access("refresh-token")
84
+
85
+ # Alternatively, if you already have a client:
86
+ client.refresh_access
87
+ ```
88
+
89
+
90
+ ## Update a user
91
+
92
+ ```ruby
93
+ # Make sure we are in Sandbox
94
+ SynapsePay.api_base = SynapsePay.api_sandbox
95
+
96
+ SynapsePay.client_id = "client-id"
97
+ SynapsePay.client_secret = "client-secret"
98
+ client = SynapsePay::User.login("username", "password")
99
+
100
+ user = client.user.update({
101
+ :fullname => "new fullname",
102
+ # :new_password => "new-secret-password",
103
+ :secret_note => "some secret note"
104
+ })
105
+
106
+ # If you already have a user object:
107
+ user.update({
108
+ :fullname => "John Smith"
109
+ })
110
+ ```
111
+
112
+
113
+ ## Retrieve a user
114
+
115
+ ```ruby
116
+ # Make sure we are in Sandbox
117
+ SynapsePay.api_base = SynapsePay.api_sandbox
118
+
119
+ SynapsePay.client_id = "client-id"
120
+ SynapsePay.client_secret = "client-secret"
121
+ client = SynapsePay::User.login("username", "password")
122
+
123
+ user = client.user.retrieve
124
+
125
+ # If you already have a user object, you can refresh:
126
+ user.refresh
127
+ ```
128
+
129
+
130
+ ## Search users
131
+
132
+ ```ruby
133
+ # Make sure we are in Sandbox
134
+ SynapsePay.api_base = SynapsePay.api_sandbox
135
+
136
+ SynapsePay.client_id = "client-id"
137
+ SynapsePay.client_secret = "client-secret"
138
+ client = SynapsePay::User.login("username", "password")
139
+
140
+ users = client.user.search("test")
141
+ ```
142
+
143
+
144
+ # Bank Account
145
+
146
+ ## Link a bank account
147
+
148
+ ```ruby
149
+ # Make sure we are in Sandbox
150
+ SynapsePay.api_base = SynapsePay.api_sandbox
151
+
152
+ SynapsePay.client_id = "client-id"
153
+ SynapsePay.client_secret = "client-secret"
154
+ client = SynapsePay::User.login("username", "password")
155
+
156
+ # Without an MFA
157
+ banks = client.banks.link({
158
+ :username => "synapse_nomfa",
159
+ :password => "test1234",
160
+ :bank => "Bank of America"
161
+ })
162
+ banks # this will be a list of bank accounts
163
+
164
+ # With a device based MFA
165
+ mfa = client.banks.link({
166
+ :username => "synapse_code",
167
+ :password => "test1234",
168
+ :bank => "Bank of America"
169
+ })
170
+ mfa # this will be a SynapsePay::BankMfaDevice instance
171
+ banks = mfa.answer("Bank of America", "test_answer") # this will be a list of bank accounts
172
+
173
+ # With a question based MFA
174
+ mfa = client.banks.link({
175
+ :username => "synapse_good",
176
+ :password => "test1234",
177
+ :bank => "Bank of America"
178
+ })
179
+ mfa # this will be a SynapsePay::BankMfaQuestions instance
180
+ banks = mfa.answer("Bank of America", "test_answer") # this will be a list of bank accounts
181
+
182
+ # Answering an MFA without an MFA instance
183
+ banks = client.bank_mfa_devices.answer("access_token, "bank name", "answer")
184
+ # or
185
+ banks = client.bank_mfa_questions.answer("access_token, "bank name", "answer")
186
+ ```
187
+
188
+
189
+ ## Retrieve a bank account
190
+
191
+ ```ruby
192
+ # Make sure we are in Sandbox
193
+ SynapsePay.api_base = SynapsePay.api_sandbox
194
+
195
+ SynapsePay.client_id = "client-id"
196
+ SynapsePay.client_secret = "client-secret"
197
+ client = SynapsePay::User.login("username", "password")
198
+
199
+ banks = client.banks.retrieve("2174")
200
+ ```
201
+
202
+ ## Add a bank account
203
+
204
+ ```ruby
205
+ # Make sure we are in Sandbox
206
+ SynapsePay.api_base = SynapsePay.api_sandbox
207
+
208
+ SynapsePay.client_id = "client-id"
209
+ SynapsePay.client_secret = "client-secret"
210
+ client = SynapsePay::User.login("username", "password")
211
+
212
+ bank = client.banks.add({
213
+ :fullname => "Jon Smith",
214
+ :account_num => "1111111111",
215
+ :routing_num => "121000358",
216
+ :nickname => "Example bank account",
217
+ :account_type => "1",
218
+ :account_class => "1"
219
+ })
220
+ ```
221
+
222
+
223
+ ## Remove a bank account
224
+
225
+ ```ruby
226
+ # Make sure we are in Sandbox
227
+ SynapsePay.api_base = SynapsePay.api_sandbox
228
+
229
+ SynapsePay.client_id = "client-id"
230
+ SynapsePay.client_secret = "client-secret"
231
+ client = SynapsePay::User.login("username", "password")
232
+
233
+ bank = client.banks.remove("2175")
234
+
235
+ # Or if you have a bank object
236
+ bank.remove
237
+ ```
238
+
239
+
240
+ ## List all bank accounts
241
+
242
+ ```ruby
243
+ # Make sure we are in Sandbox
244
+ SynapsePay.api_base = SynapsePay.api_sandbox
245
+
246
+ SynapsePay.client_id = "client-id"
247
+ SynapsePay.client_secret = "client-secret"
248
+ client = SynapsePay::User.login("username", "password")
249
+
250
+ banks = client.banks.all
251
+ ```
252
+
253
+
254
+ # Orders
255
+
256
+ ## Create an order
257
+
258
+ ```ruby
259
+ # Make sure we are in Sandbox
260
+ SynapsePay.api_base = SynapsePay.api_sandbox
261
+
262
+ SynapsePay.client_id = "client-id"
263
+ SynapsePay.client_secret = "client-secret"
264
+ client = SynapsePay::User.login("username", "password")
265
+
266
+ order = client.orders.create({
267
+ :amount => "100",
268
+ :facilitator_fee => "1",
269
+ :seller_id => 3425,
270
+ :bank_id => 2174
271
+ })
272
+ ```
273
+
274
+ ## Poll an order
275
+
276
+ ```ruby
277
+ # Make sure we are in Sandbox
278
+ SynapsePay.api_base = SynapsePay.api_sandbox
279
+
280
+ SynapsePay.client_id = "client-id"
281
+ SynapsePay.client_secret = "client-secret"
282
+ client = SynapsePay::User.login("username", "password")
283
+
284
+ order = client.orders.poll("903")
285
+ # only the status is set in this order, so access it via order.status
286
+ order.status
287
+ ```
288
+
289
+
290
+ ## Update an order
291
+
292
+ ```ruby
293
+ # Make sure we are in Sandbox
294
+ SynapsePay.api_base = SynapsePay.api_sandbox
295
+
296
+ SynapsePay.client_id = "client-id"
297
+ SynapsePay.client_secret = "client-secret"
298
+ client = SynapsePay::User.login("username", "password")
299
+
300
+ order = client.orders.update("903", { :status => 0 })
301
+ # or if you have an order object
302
+ order.update({ :status => 0 })
303
+ ```
304
+
305
+
306
+ ## Void an order
307
+
308
+ ```ruby
309
+ # Make sure we are in Sandbox
310
+ SynapsePay.api_base = SynapsePay.api_sandbox
311
+
312
+ SynapsePay.client_id = "client-id"
313
+ SynapsePay.client_secret = "client-secret"
314
+ client = SynapsePay::User.login("username", "password")
315
+
316
+ order = client.orders.void("903")
317
+ # or if you have an order object
318
+ order.void
319
+ ```
320
+
321
+
322
+ ## View recent orders
323
+
324
+ ```ruby
325
+ # Make sure we are in Sandbox
326
+ SynapsePay.api_base = SynapsePay.api_sandbox
327
+
328
+ SynapsePay.client_id = "client-id"
329
+ SynapsePay.client_secret = "client-secret"
330
+ client = SynapsePay::User.login("username", "password")
331
+
332
+ orders = client.orders.recent
333
+ ```
334
+
335
+
336
+ # Deposits
337
+
338
+ ## Create a deposit
339
+
340
+ ```ruby
341
+ # Make sure we are in Sandbox
342
+ SynapsePay.api_base = SynapsePay.api_sandbox
343
+
344
+ SynapsePay.client_id = "client-id"
345
+ SynapsePay.client_secret = "client-secret"
346
+ client = SynapsePay::User.login("username", "password")
347
+
348
+ deposit = client.deposits.create({
349
+ :bank_id => "2174",
350
+ :amount => "10"
351
+ })
352
+ ```
353
+
354
+ ## Create micro deposits
355
+
356
+ ```ruby
357
+ # Make sure we are in Sandbox
358
+ SynapsePay.api_base = SynapsePay.api_sandbox
359
+
360
+ SynapsePay.client_id = "client-id"
361
+ SynapsePay.client_secret = "client-secret"
362
+ client = SynapsePay::User.login("username", "password")
363
+
364
+ deposits = client.deposits.micro({
365
+ :bank_id => "2174",
366
+ :amount1 => "0.07",
367
+ :amount2 => "0.25"
368
+ })
369
+ ```
370
+
371
+ ## List all deposits
372
+
373
+ ```ruby
374
+ # Make sure we are in Sandbox
375
+ SynapsePay.api_base = SynapsePay.api_sandbox
376
+
377
+ SynapsePay.client_id = "client-id"
378
+ SynapsePay.client_secret = "client-secret"
379
+ client = SynapsePay::User.login("username", "password")
380
+
381
+ deposits = client.deposits.all
382
+ ```
383
+
384
+
385
+ # Wires
386
+
387
+ ## Create an outgoing wire
388
+
389
+ ```ruby
390
+ # Make sure we are in Sandbox
391
+ SynapsePay.api_base = SynapsePay.api_sandbox
392
+
393
+ SynapsePay.client_id = "client-id"
394
+ SynapsePay.client_secret = "client-secret"
395
+ client = SynapsePay::User.login("username", "password")
396
+
397
+ wire = client.wires.create_outgoing({
398
+ :account_number => "123456790",
399
+ :routing_number => "064000020",
400
+ :amount => "1000"
401
+ })
402
+ ```
403
+
404
+
405
+ ## List all outgoing wires
406
+
407
+ ```ruby
408
+ # Make sure we are in Sandbox
409
+ SynapsePay.api_base = SynapsePay.api_sandbox
410
+
411
+ SynapsePay.client_id = "client-id"
412
+ SynapsePay.client_secret = "client-secret"
413
+ client = SynapsePay::User.login("username", "password")
414
+
415
+ wires = client.wires.all_outgoing
416
+ ```
417
+
418
+
419
+ ## Create an incoming wire
420
+
421
+ ```ruby
422
+ # Make sure we are in Sandbox
423
+ SynapsePay.api_base = SynapsePay.api_sandbox
424
+
425
+ SynapsePay.client_id = "client-id"
426
+ SynapsePay.client_secret = "client-secret"
427
+ client = SynapsePay::User.login("username", "password")
428
+
429
+ wire = client.wires.create_incoming({
430
+ "amount": "10000"
431
+ })
432
+ ```
433
+
434
+
435
+ ## List all incoming wires
436
+
437
+ ```ruby
438
+ # Make sure we are in Sandbox
439
+ SynapsePay.api_base = SynapsePay.api_sandbox
440
+
441
+ SynapsePay.client_id = "client-id"
442
+ SynapsePay.client_secret = "client-secret"
443
+ client = SynapsePay::User.login("username", "password")
444
+
445
+ wires = client.wires.all_incoming
446
+ ```
447
+
448
+
449
+ # Withdrawals
450
+
451
+ ## Create a withdrawal
452
+
453
+ ```ruby
454
+ # Make sure we are in Sandbox
455
+ SynapsePay.api_base = SynapsePay.api_sandbox
456
+
457
+ SynapsePay.client_id = "client-id"
458
+ SynapsePay.client_secret = "client-secret"
459
+ client = SynapsePay::User.login("username", "password")
460
+
461
+ withdrawal = client.withdrawals.create({
462
+ :bank_id => "2174",
463
+ :amount => "15"
464
+ })
465
+ ```
466
+
467
+
468
+ ## List all withdrawals
469
+
470
+ ```ruby
471
+ # Make sure we are in Sandbox
472
+ SynapsePay.api_base = SynapsePay.api_sandbox
473
+
474
+ SynapsePay.client_id = "client-id"
475
+ SynapsePay.client_secret = "client-secret"
476
+ client = SynapsePay::User.login("username", "password")
477
+
478
+ withdrawals = client.withdrawals.all
479
+ ```
480
+
481
+
482
+ # Cards
483
+
484
+ ## Create a card
485
+
486
+ ```ruby
487
+ # Make sure we are in Sandbox
488
+ SynapsePay.api_base = SynapsePay.api_sandbox
489
+
490
+ SynapsePay.client_id = "client-id"
491
+ SynapsePay.client_secret = "client-secret"
492
+ client = SynapsePay::User.login("username", "password")
493
+
494
+ card = client.cards.create({
495
+ :legal_name => "Some Person",
496
+ :account_number => "123456789",
497
+ :routing_number => "123456789",
498
+ :account_class => "1",
499
+ :account_type => "2"
500
+ })
501
+ ```
502
+
503
+ ## Update a card
504
+
505
+ ```ruby
506
+ # Make sure we are in Sandbox
507
+ SynapsePay.api_base = SynapsePay.api_sandbox
508
+
509
+ SynapsePay.client_id = "client-id"
510
+ SynapsePay.client_secret = "client-secret"
511
+ client = SynapsePay::User.login("username", "password")
512
+
513
+ card = client.cards.update("76", {
514
+ :legal_name => "John Smith"
515
+ })
516
+ # Or if you have the card already
517
+ card.update({
518
+ :legal_name => "Jim Halpert"
519
+ })
520
+ ```
521
+
522
+ ## List all cards
523
+
524
+ ```ruby
525
+ # Make sure we are in Sandbox
526
+ SynapsePay.api_base = SynapsePay.api_sandbox
527
+
528
+ SynapsePay.client_id = "client-id"
529
+ SynapsePay.client_secret = "client-secret"
530
+ client = SynapsePay::User.login("username", "password")
531
+
532
+ cards = client.cards.all
533
+ ```
534
+
535
+
536
+ # Mass Pays
537
+
538
+ ## Create a mass pay
539
+
540
+ ```ruby
541
+ # Make sure we are in Sandbox
542
+ SynapsePay.api_base = SynapsePay.api_sandbox
543
+
544
+ SynapsePay.client_id = "client-id"
545
+ SynapsePay.client_secret = "client-secret"
546
+ client = SynapsePay::User.login("username", "password")
547
+
548
+ # Create a mass pay with bank info
549
+ mass_pays = client.mass_pays.create({
550
+ :mass_pays => [
551
+ {
552
+ :legal_name => "Some Person 1",
553
+ :account_number => "888888888",
554
+ :routing_number => "222222222",
555
+ :amount => "10.33",
556
+ :trans_type => "0",
557
+ :account_class => "1",
558
+ :account_type => "2",
559
+ :user_info => {
560
+ :email => "some@email.com",
561
+ :phone_number => "9011234567",
562
+ :ip_address => "some.ip.address",
563
+ :dob => "18/11/1989",
564
+ :risk_score => 10
565
+ }
566
+ },
567
+ {
568
+ :legal_name => "Some Person 2",
569
+ :account_number => "888888888",
570
+ :routing_number => "222222222",
571
+ :amount => "10.33",
572
+ :trans_type => "0",
573
+ :account_class => "1",
574
+ :account_type => "1"
575
+ }
576
+ ]
577
+ })
578
+
579
+
580
+ # Create a mass pay with cards
581
+ mass_pays = client.mass_pays.create({
582
+ :mass_pays => [
583
+ {
584
+ :amount => "20",
585
+ :trans_type => "0",
586
+ :card_id => "77"
587
+ },
588
+ {
589
+ :amount => "20",
590
+ :trans_type => "0",
591
+ :card_id => "76"
592
+ }
593
+ ]
594
+ })
595
+ ```
596
+
597
+
598
+ ## Cancel a mass pay
599
+
600
+ ```ruby
601
+ # Make sure we are in Sandbox
602
+ SynapsePay.api_base = SynapsePay.api_sandbox
603
+
604
+ SynapsePay.client_id = "client-id"
605
+ SynapsePay.client_secret = "client-secret"
606
+ client = SynapsePay::User.login("username", "password")
607
+
608
+ mass_pays = client.mass_pays.cancel("323")
609
+ # mass_pays will be a list of mass pays, even though only one was cancelled.
610
+
611
+ # Or if you already have a mass pay:
612
+ mass_pay.cancel
613
+ ```
614
+
615
+ ## List all mass pays
616
+
617
+ ```ruby
618
+ # Make sure we are in Sandbox
619
+ SynapsePay.api_base = SynapsePay.api_sandbox
620
+
621
+ SynapsePay.client_id = "client-id"
622
+ SynapsePay.client_secret = "client-secret"
623
+ client = SynapsePay::User.login("username", "password")
624
+
625
+ mass_pays = client.mass_pays.all
626
+ ```
data/synapse_pay.gemspec CHANGED
@@ -6,7 +6,7 @@ spec = Gem::Specification.new do |s|
6
6
  s.name = 'synapse_pay'
7
7
  s.summary = 'Ruby bindings for SynapsePay API'
8
8
  s.description = 'SynapsePay allows you to integrate bank payments into your applications'
9
- s.homepage = 'http://synapsepay.readme.io/v1.0/docs'
9
+ s.homepage = 'http://api.synapsepay.com/v2.0'
10
10
  s.authors = ['Apibits.com']
11
11
  s.email = ['libraries@apibits.com']
12
12
  s.version = SynapsePay::VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapse_pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apibits.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -174,6 +174,7 @@ files:
174
174
  - lib/synapse_pay/resources/wire.rb
175
175
  - lib/synapse_pay/resources/withdrawal.rb
176
176
  - lib/synapse_pay/version.rb
177
+ - samples.md
177
178
  - synapse_pay.gemspec
178
179
  - test/synapse_pay/api_list_test.rb
179
180
  - test/synapse_pay/api_method_test.rb
@@ -184,7 +185,7 @@ files:
184
185
  - test/synapse_pay/util_test.rb
185
186
  - test/test_data.rb
186
187
  - test/test_helper.rb
187
- homepage: http://synapsepay.readme.io/v1.0/docs
188
+ homepage: http://api.synapsepay.com/v2.0
188
189
  licenses:
189
190
  - MIT
190
191
  metadata: {}
@@ -204,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
205
  version: '0'
205
206
  requirements: []
206
207
  rubyforge_project:
207
- rubygems_version: 2.4.5
208
+ rubygems_version: 2.2.2
208
209
  signing_key:
209
210
  specification_version: 4
210
211
  summary: Ruby bindings for SynapsePay API