synapse_pay_rest 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/synapse_pay_rest.rb +3 -1
- data/lib/synapse_pay_rest/error.rb +1 -0
- data/lib/synapse_pay_rest/http_client.rb +2 -0
- data/lib/synapse_pay_rest/models/node/ach_us_node.rb +11 -19
- data/lib/synapse_pay_rest/models/node/base_node.rb +88 -17
- data/lib/synapse_pay_rest/models/node/eft_ind_node.rb +7 -6
- data/lib/synapse_pay_rest/models/node/eft_np_node.rb +3 -4
- data/lib/synapse_pay_rest/models/node/iou_node.rb +6 -15
- data/lib/synapse_pay_rest/models/node/node.rb +18 -17
- data/lib/synapse_pay_rest/models/node/reserve_us_node.rb +5 -11
- data/lib/synapse_pay_rest/models/node/synapse_ind_node.rb +4 -8
- data/lib/synapse_pay_rest/models/node/synapse_np_node.rb +2 -8
- data/lib/synapse_pay_rest/models/node/synapse_us_node.rb +2 -8
- data/lib/synapse_pay_rest/models/node/triumph_subaccount_us_node.rb +17 -0
- data/lib/synapse_pay_rest/models/node/unverified_node.rb +1 -1
- data/lib/synapse_pay_rest/models/node/wire_int_node.rb +3 -4
- data/lib/synapse_pay_rest/models/node/wire_us_node.rb +1 -2
- data/lib/synapse_pay_rest/models/transaction/transaction.rb +9 -9
- data/lib/synapse_pay_rest/models/user/base_document.rb +12 -16
- data/lib/synapse_pay_rest/models/user/document.rb +2 -2
- data/lib/synapse_pay_rest/models/user/physical_document.rb +58 -17
- data/lib/synapse_pay_rest/models/user/user.rb +27 -10
- data/lib/synapse_pay_rest/models/user/virtual_document.rb +7 -8
- data/lib/synapse_pay_rest/version.rb +1 -1
- data/samples.md +41 -60
- data/synapse_pay_rest.gemspec +8 -8
- metadata +4 -6
- data/lib/synapse_pay_rest/models/node/eft_node.rb +0 -27
- data/lib/synapse_pay_rest/models/node/synapse_node.rb +0 -25
- data/lib/synapse_pay_rest/models/node/wire_node.rb +0 -38
@@ -10,10 +10,9 @@ module SynapsePayRest
|
|
10
10
|
|
11
11
|
class << self
|
12
12
|
# @note Do not call this method directly.
|
13
|
-
def
|
13
|
+
def from_response(data)
|
14
14
|
virtual_doc = super(data)
|
15
|
-
|
16
|
-
virtual_doc.add_question_set(data['meta']['question_set']) if data['meta']
|
15
|
+
virtual_doc.add_question_set(data['meta']['question_set']) if data['status'] == 'SUBMITTED|MFA_PENDING'
|
17
16
|
virtual_doc
|
18
17
|
end
|
19
18
|
end
|
@@ -30,11 +29,11 @@ module SynapsePayRest
|
|
30
29
|
#
|
31
30
|
# @todo should raise error if any questions aren't answered yet.
|
32
31
|
def submit_kba
|
33
|
-
user
|
34
|
-
response
|
35
|
-
user
|
36
|
-
base_doc
|
37
|
-
ssn_doc
|
32
|
+
user = base_document.user
|
33
|
+
response = user.client.users.update(payload: payload_for_kba)
|
34
|
+
user = User.from_response(user.client, response)
|
35
|
+
base_doc = user.base_documents.find { |doc| doc.id == base_document.id }
|
36
|
+
ssn_doc = base_doc.virtual_documents.find { |doc| doc.id == id }
|
38
37
|
end
|
39
38
|
|
40
39
|
# Maps question set from response to Question objects.
|
data/samples.md
CHANGED
@@ -22,7 +22,6 @@ args = {
|
|
22
22
|
|
23
23
|
client = SynapsePayRest::Client.new(args)
|
24
24
|
# => #<SynapsePayRest::Client>
|
25
|
-
|
26
25
|
```
|
27
26
|
|
28
27
|
## User Methods
|
@@ -30,7 +29,6 @@ client = SynapsePayRest::Client.new(args)
|
|
30
29
|
#### All Users
|
31
30
|
|
32
31
|
```ruby
|
33
|
-
|
34
32
|
args = {
|
35
33
|
client: client,
|
36
34
|
# (optional) uses API default unless specified
|
@@ -43,31 +41,25 @@ args = {
|
|
43
41
|
|
44
42
|
users = SynapsePayRest::User.all(args)
|
45
43
|
# => [#<SynapsePayRest::User>, #<SynapsePayRest::User>, ...]
|
46
|
-
|
47
44
|
```
|
48
45
|
|
49
46
|
#### Find a User by User ID
|
50
47
|
|
51
48
|
```ruby
|
52
|
-
|
53
49
|
user = SynapsePayRest::User.find(client: client, id: '57e97ab786c2737f4ccd4dc1')
|
54
50
|
# => #<SynapsePayRest::User>
|
55
|
-
|
56
51
|
```
|
57
52
|
|
58
53
|
#### Search for a User by Name/Email
|
59
54
|
|
60
55
|
```ruby
|
61
|
-
|
62
56
|
users = SynapsePayRest::User.search(client: client, query: 'Steven')
|
63
57
|
# => [#<SynapsePayRest::User>, #<SynapsePayRest::User>, ...]
|
64
|
-
|
65
58
|
```
|
66
59
|
|
67
60
|
#### Create User
|
68
61
|
|
69
62
|
```ruby
|
70
|
-
|
71
63
|
user_create_settings = {
|
72
64
|
client: client,
|
73
65
|
logins: [{email: 'steven@synapsepay.com'}],
|
@@ -77,7 +69,6 @@ user_create_settings = {
|
|
77
69
|
|
78
70
|
user = SynapsePayRest::User.create(user_create_settings)
|
79
71
|
# => #<SynapsePayRest::User>
|
80
|
-
|
81
72
|
```
|
82
73
|
|
83
74
|
#### Update a User's Personal Info
|
@@ -85,7 +76,6 @@ user = SynapsePayRest::User.create(user_create_settings)
|
|
85
76
|
Note: this returns a new instance, so remember to reassign the user variable to the method output.
|
86
77
|
|
87
78
|
```ruby
|
88
|
-
|
89
79
|
user_update_settings = {
|
90
80
|
login: {email: 'newemail@gmail.com'}, # add a login email
|
91
81
|
phone_number: '415-555-5555', # add a phone number
|
@@ -97,7 +87,6 @@ user_update_settings = {
|
|
97
87
|
# reassign user to the output because it returns a new instance
|
98
88
|
user = user.update(args)
|
99
89
|
# => #<SynapsePayRest::User>
|
100
|
-
|
101
90
|
```
|
102
91
|
|
103
92
|
#### Add CIP Base Document to a User
|
@@ -105,7 +94,6 @@ user = user.update(args)
|
|
105
94
|
##### a) User#create_base_document
|
106
95
|
|
107
96
|
```ruby
|
108
|
-
|
109
97
|
args = {
|
110
98
|
email: 'steven@synapsepay.com',
|
111
99
|
phone_number: '415-555-5555',
|
@@ -127,13 +115,11 @@ args = {
|
|
127
115
|
# reassign user to the output because it returns a new instance
|
128
116
|
base_document = user.create_base_document(args)
|
129
117
|
# => #<SynapsePayRest::BaseDocument>
|
130
|
-
|
131
118
|
```
|
132
119
|
|
133
120
|
##### b) BaseDocument#create
|
134
121
|
|
135
122
|
```ruby
|
136
|
-
|
137
123
|
args = {
|
138
124
|
user: user,
|
139
125
|
email: 'steven@synapsepay.com',
|
@@ -159,13 +145,11 @@ base_doc = SynapsePayRest::BaseDocument.create(args)
|
|
159
145
|
|
160
146
|
# reassign user to this if you need the updated user
|
161
147
|
user = base_doc.user
|
162
|
-
|
163
148
|
```
|
164
149
|
|
165
150
|
#### Update User's Existing Base Document
|
166
151
|
|
167
152
|
```ruby
|
168
|
-
|
169
153
|
things_to_update = {
|
170
154
|
entity_scope: 'Lawyer',
|
171
155
|
birth_day: 22
|
@@ -173,28 +157,64 @@ things_to_update = {
|
|
173
157
|
|
174
158
|
base_doc = base_doc.update(things_to_update)
|
175
159
|
# => #<SynapsePayRest::BaseDocument>
|
160
|
+
```
|
161
|
+
|
162
|
+
#### Add a Physical Document to a CIP Base Document using image file path
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
physical_doc = SynapsePayRest::PhysicalDocument.create(
|
166
|
+
type: 'GOVT_ID',
|
167
|
+
file_path: '/path/to/file.png'
|
168
|
+
)
|
176
169
|
|
170
|
+
# reassign base_doc to the output because it returns a new instance
|
171
|
+
base_doc = base_doc.add_physical_documents(physical_doc)
|
172
|
+
# => #<SynapsePayRest::BaseDocument>
|
177
173
|
```
|
178
174
|
|
179
|
-
#### Add a Physical Document to a CIP Base Document
|
175
|
+
#### Add a Physical Document to a CIP Base Document using image URL
|
180
176
|
|
181
177
|
```ruby
|
178
|
+
physical_doc = SynapsePayRest::PhysicalDocument.create(
|
179
|
+
type: 'GOVT_ID',
|
180
|
+
url: 'https://cdn.synapsepay.com/static_assets/logo@2x.png'
|
181
|
+
)
|
182
|
+
|
183
|
+
# reassign base_doc to the output because it returns a new instance
|
184
|
+
base_doc = base_doc.add_physical_documents(physical_doc)
|
185
|
+
# => #<SynapsePayRest::BaseDocument>
|
186
|
+
```
|
182
187
|
|
188
|
+
#### Add a Physical Document to a CIP Base Document using byte stream
|
189
|
+
|
190
|
+
```ruby
|
183
191
|
physical_doc = SynapsePayRest::PhysicalDocument.create(
|
184
192
|
type: 'GOVT_ID',
|
185
|
-
|
193
|
+
byte_stream: '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00...',
|
194
|
+
mime_type: 'image/png'
|
186
195
|
)
|
187
196
|
|
188
197
|
# reassign base_doc to the output because it returns a new instance
|
189
|
-
base_doc = base_doc.add_physical_documents(
|
198
|
+
base_doc = base_doc.add_physical_documents(physical_doc)
|
190
199
|
# => #<SynapsePayRest::BaseDocument>
|
200
|
+
```
|
201
|
+
|
202
|
+
#### Add a Physical Document to a CIP Base Document using base64
|
203
|
+
|
204
|
+
```ruby
|
205
|
+
physical_doc = SynapsePayRest::PhysicalDocument.create(
|
206
|
+
type: 'GOVT_ID',
|
207
|
+
value: 'data:image/png;base64,SUQs=='
|
208
|
+
)
|
191
209
|
|
210
|
+
# reassign base_doc to the output because it returns a new instance
|
211
|
+
base_doc = base_doc.add_physical_documents(physical_doc)
|
212
|
+
# => #<SynapsePayRest::BaseDocument>
|
192
213
|
```
|
193
214
|
|
194
215
|
#### Add a Social Document to a CIP Base Document
|
195
216
|
|
196
217
|
```ruby
|
197
|
-
|
198
218
|
social_doc = SynapsePayRest::SocialDocument.create(
|
199
219
|
type: 'FACEBOOK',
|
200
220
|
value: 'facebook.com/sankaet'
|
@@ -203,13 +223,11 @@ social_doc = SynapsePayRest::SocialDocument.create(
|
|
203
223
|
# reassign base_doc to the output because it returns a new instance
|
204
224
|
base_doc = base_doc.add_social_documents([social_doc])
|
205
225
|
# => #<SynapsePayRest::BaseDocument>
|
206
|
-
|
207
226
|
```
|
208
227
|
|
209
228
|
#### Add a Virtual Document to a CIP Base Document
|
210
229
|
|
211
230
|
```ruby
|
212
|
-
|
213
231
|
virtual_doc = SynapsePayRest::VirtualDocument.create(
|
214
232
|
type: 'SSN',
|
215
233
|
value: '3333'
|
@@ -218,15 +236,13 @@ virtual_doc = SynapsePayRest::VirtualDocument.create(
|
|
218
236
|
# reassign base_doc to the output because it returns a new instance
|
219
237
|
base_doc = base_doc.add_virtual_documents([virtual_doc])
|
220
238
|
# => #<SynapsePayRest::BaseDocument>
|
221
|
-
|
222
239
|
```
|
223
240
|
|
224
241
|
##### Answer KBA Questions for Virtual Document
|
225
242
|
|
226
|
-
If a Virtual Document is returned with status **
|
243
|
+
If a Virtual Document is returned with status **SUBMITTED|MFA_PENDING**, you will need to have the user answer some questions:
|
227
244
|
|
228
245
|
```ruby
|
229
|
-
|
230
246
|
# check for any virtual docs with SUBMITTED|MFA_PENDING status
|
231
247
|
virtual_doc = base_doc.virtual_documents.find do |doc|
|
232
248
|
doc.status == 'SUBMITTED|MFA_PENDING'
|
@@ -251,7 +267,6 @@ virtual_doc = virtual_doc.submit_kba
|
|
251
267
|
|
252
268
|
# reassign this if you need the updated base doc
|
253
269
|
base_doc = virtual_doc.base_document
|
254
|
-
|
255
270
|
```
|
256
271
|
|
257
272
|
|
@@ -262,19 +277,15 @@ base_doc = virtual_doc.base_document
|
|
262
277
|
##### a) User#nodes
|
263
278
|
|
264
279
|
```ruby
|
265
|
-
|
266
280
|
nodes = user.nodes(page: 2, per_page: 5, type: 'ACH-US')
|
267
281
|
# => [#<SynapsePayRest::AchUsNode>, #<SynapsePayRest::AchUsNode>, ...]
|
268
|
-
|
269
282
|
```
|
270
283
|
|
271
284
|
##### b) Node#all
|
272
285
|
|
273
286
|
```ruby
|
274
|
-
|
275
287
|
nodes = SynapsePayRest::Node.all(user: user, page: 2, per_page: 5)
|
276
288
|
# => [#<SynapsePayRest::AchUsNode>, #<SynapsePayRest::SynapseUsNode>, ...]
|
277
|
-
|
278
289
|
```
|
279
290
|
|
280
291
|
#### Find a User's Node by Node ID
|
@@ -282,19 +293,15 @@ nodes = SynapsePayRest::Node.all(user: user, page: 2, per_page: 5)
|
|
282
293
|
##### a) User#find_node
|
283
294
|
|
284
295
|
```ruby
|
285
|
-
|
286
296
|
node = user.find_node(id: '1a3efa1231as2f')
|
287
297
|
# => #<SynapsePayRest::EftNpNode>
|
288
|
-
|
289
298
|
```
|
290
299
|
|
291
300
|
##### b) Node#find
|
292
301
|
|
293
302
|
```ruby
|
294
|
-
|
295
303
|
node = SynapsePayRest::Node.find(user: user, id: '1a3efa1231as2f')
|
296
304
|
# => #<SynapsePayRest::EftNpNode>
|
297
|
-
|
298
305
|
```
|
299
306
|
|
300
307
|
#### Create ACH-US Node(s) via Bank Login
|
@@ -302,7 +309,6 @@ node = SynapsePayRest::Node.find(user: user, id: '1a3efa1231as2f')
|
|
302
309
|
Returns a collection of `AchUsNode`s associated with the account unless bank requires MFA. Can also use `AchUsNode.create_via_bank_login` with the addition of a `user` argument.
|
303
310
|
|
304
311
|
```ruby
|
305
|
-
|
306
312
|
login_info = {
|
307
313
|
bank_name: 'bofa',
|
308
314
|
username: 'synapse_good',
|
@@ -312,7 +318,6 @@ login_info = {
|
|
312
318
|
nodes = user.create_ach_us_nodes_via_bank_login(login_info)
|
313
319
|
# => [#<SynapsePayRest::AchUsNode>, ...] if no MFA
|
314
320
|
# => SynapsePayRest::UnverifiedNode if MFA
|
315
|
-
|
316
321
|
```
|
317
322
|
|
318
323
|
##### Verify Bank Login MFA
|
@@ -320,7 +325,6 @@ nodes = user.create_ach_us_nodes_via_bank_login(login_info)
|
|
320
325
|
If the bank requires MFA, you will need to resolve the MFA question(s):
|
321
326
|
|
322
327
|
```ruby
|
323
|
-
|
324
328
|
nodes.mfa_verified
|
325
329
|
# => false
|
326
330
|
|
@@ -334,7 +338,6 @@ nodes = nodes.answer_mfa('test_answer')
|
|
334
338
|
|
335
339
|
nodes.mfa_verified
|
336
340
|
# => true
|
337
|
-
|
338
341
|
```
|
339
342
|
|
340
343
|
#### Create ACH-US Node via Account/Routing Number
|
@@ -342,7 +345,6 @@ nodes.mfa_verified
|
|
342
345
|
Can also use `AchUsNode.create` with the addition of a `user` argument.
|
343
346
|
|
344
347
|
```ruby
|
345
|
-
|
346
348
|
account_info = {
|
347
349
|
nickname: 'Primary Joint Checking',
|
348
350
|
account_number: '2222222222',
|
@@ -353,7 +355,6 @@ account_info = {
|
|
353
355
|
|
354
356
|
node = user.create_ach_us_node(account_info)
|
355
357
|
# => #<SynapsePayRest::AchUsNode>
|
356
|
-
|
357
358
|
```
|
358
359
|
|
359
360
|
##### Verify Microdeposits
|
@@ -361,10 +362,8 @@ node = user.create_ach_us_node(account_info)
|
|
361
362
|
`ACH-US Node`s added by account/routing must be verified with microdeposits:
|
362
363
|
|
363
364
|
```ruby
|
364
|
-
|
365
365
|
node = node.verify_microdeposits(amount1: 0.1, amount2: 0.1)
|
366
366
|
# => #<SynapsePayRest::AchUsNode>
|
367
|
-
|
368
367
|
```
|
369
368
|
|
370
369
|
#### Deactivate a Node
|
@@ -372,10 +371,8 @@ node = node.verify_microdeposits(amount1: 0.1, amount2: 0.1)
|
|
372
371
|
This deactivates the node. It does not automatically cancel any transactions already underway.
|
373
372
|
|
374
373
|
```ruby
|
375
|
-
|
376
374
|
node.deactivate
|
377
375
|
# => :success
|
378
|
-
|
379
376
|
```
|
380
377
|
|
381
378
|
|
@@ -386,19 +383,15 @@ node.deactivate
|
|
386
383
|
##### a) Node#transactions
|
387
384
|
|
388
385
|
```ruby
|
389
|
-
|
390
386
|
transactions = node.transactions(page: 1, per_page: 15)
|
391
387
|
# => [#<SynapsePayRest::Transaction>, #<SynapsePayRest::Transaction>, ...]
|
392
|
-
|
393
388
|
```
|
394
389
|
|
395
390
|
##### b) Transaction#all
|
396
391
|
|
397
392
|
```ruby
|
398
|
-
|
399
393
|
transactions = SynapsePayRest::Transaction.all(node: node, page: 1, per_page: 15)
|
400
394
|
# => [#<SynapsePayRest::Transaction>, #<SynapsePayRest::Transaction>, ...]
|
401
|
-
|
402
395
|
```
|
403
396
|
|
404
397
|
#### Find a Node's Transaction by ID
|
@@ -406,19 +399,15 @@ transactions = SynapsePayRest::Transaction.all(node: node, page: 1, per_page: 15
|
|
406
399
|
##### a) Node#find_transaction
|
407
400
|
|
408
401
|
```ruby
|
409
|
-
|
410
402
|
transaction = node.find_transaction(id: '167e11516')
|
411
403
|
# => #<SynapsePayRest::Transaction>
|
412
|
-
|
413
404
|
```
|
414
405
|
|
415
406
|
##### b) Transaction#find
|
416
407
|
|
417
408
|
```ruby
|
418
|
-
|
419
409
|
transaction = SynapsePayRest::Transaction.find(node: node, id: '57fab7d186c2733525dd7eac')
|
420
410
|
# => #<SynapsePayRest::Transaction>
|
421
|
-
|
422
411
|
```
|
423
412
|
|
424
413
|
#### Create a Transaction
|
@@ -426,7 +415,6 @@ transaction = SynapsePayRest::Transaction.find(node: node, id: '57fab7d186c27335
|
|
426
415
|
##### a) Node#create_transaction
|
427
416
|
|
428
417
|
```ruby
|
429
|
-
|
430
418
|
transaction_settings = {
|
431
419
|
to_type: 'ACH-US',
|
432
420
|
to_id: '57fab4b286c2732210c73486',
|
@@ -437,13 +425,11 @@ transaction_settings = {
|
|
437
425
|
|
438
426
|
transaction = node.create_transaction(transaction_settings)
|
439
427
|
# => #<SynapsePayRest::Transaction>
|
440
|
-
|
441
428
|
```
|
442
429
|
|
443
430
|
##### b) Transaction#create
|
444
431
|
|
445
432
|
```ruby
|
446
|
-
|
447
433
|
transaction_settings = {
|
448
434
|
node: node,
|
449
435
|
to_type: 'ACH-US',
|
@@ -455,23 +441,18 @@ transaction_settings = {
|
|
455
441
|
|
456
442
|
transaction = SynapsePayRest::Transaction.create(transaction_settings)
|
457
443
|
# => #<SynapsePayRest::Transaction>
|
458
|
-
|
459
444
|
```
|
460
445
|
|
461
446
|
#### Add a Comment to a Transaction's Status
|
462
447
|
|
463
448
|
```ruby
|
464
|
-
|
465
449
|
transaction = transaction.add_comment('this is my favorite transaction')
|
466
450
|
# => #<SynapsePayRest::Transaction>
|
467
|
-
|
468
451
|
```
|
469
452
|
|
470
453
|
#### Cancel a Transaction
|
471
454
|
|
472
455
|
```ruby
|
473
|
-
|
474
456
|
transaction = transaction.cancel
|
475
457
|
# => #<SynapsePayRest::Transaction>
|
476
|
-
|
477
458
|
```
|
data/synapse_pay_rest.gemspec
CHANGED
@@ -3,14 +3,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require 'synapse_pay_rest/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
8
|
-
s.date
|
9
|
-
s.authors
|
10
|
-
s.email
|
11
|
-
s.summary
|
12
|
-
s.homepage
|
13
|
-
s.license
|
6
|
+
s.name = 'synapse_pay_rest'
|
7
|
+
s.version = SynapsePayRest::VERSION
|
8
|
+
s.date = Date.today.to_s
|
9
|
+
s.authors = ['Steven Broderick', 'Thomas Hipps']
|
10
|
+
s.email = 'help@synapsepay.com'
|
11
|
+
s.summary = 'SynapsePay v3 Rest Native API Library'
|
12
|
+
s.homepage = 'https://rubygems.org/gems/synapse_pay_rest'
|
13
|
+
s.license = 'MIT'
|
14
14
|
|
15
15
|
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
s.bindir = 'exe'
|