synapse_pay_rest 2.2.2 → 2.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ac33ad48e29bfe842ef95fd251245006824f851
4
- data.tar.gz: 56bc587fa28769dd1bb9ccf193fdb44431cfcc7a
3
+ metadata.gz: e6838fb99b9172f2110365b17cbe0958bd35d83f
4
+ data.tar.gz: c1af1430a94a956fbe9391e37d32a8a6adf81e7f
5
5
  SHA512:
6
- metadata.gz: c39cabd30d390cc1e5d0928a783668f1f7295bba049ac86d45021d6a44778e9e7ba5ea19b88114a9fcfa0aecd8b039d5d1a4cbcc31c6a5ddf2c945147e4436da
7
- data.tar.gz: 02d70a8460231e31471b1bdc3381f69ea0c2abd14c40c2fd78be182e9f8180d9fce8380baf33ee717469a5c5459efe6729d22558e06df53c713ac6afa6d486d6
6
+ metadata.gz: 08b62065ca6fc61717a65ac965e1278069bd23065f86feb5a5a4138b88474a63301c12ca54caaf7c984235f31446f602f0918a3f1b732091f61133a0f5a39eee
7
+ data.tar.gz: 132d1b8370e090f87c7041f52744f4164801656fb105131962ca8c9705bd14ef1c238419f48f6ddc61c4b55509587e9ad60e6d11ba775b1473a2c9ab5fb7d140
@@ -27,12 +27,16 @@ module SynapsePayRest
27
27
  # @param log_to [String] (optional) file path to log to file (logging must be true)
28
28
  def initialize(client_id:, client_secret:, ip_address:, fingerprint: nil,
29
29
  development_mode: true, **options)
30
- base_url = 'https://api-qa.synapsefi.com/v3.1'
30
+ base_url = if development_mode
31
+ 'https://sandbox.synapsepay.com/api/3'
32
+ else
33
+ 'https://synapsepay.com/api/3'
34
+ end
31
35
 
32
36
  @http_client = HTTPClient.new(base_url: base_url,
33
- client_id: 'client_id_b8d24e32b6aa11e6bba40242ac110003',
34
- client_secret: 'test1234',
35
- fingerprint: 'e716990e50b67a1177736960b6357524b22090ccab093d068b3d7a18dbde3f4c',
37
+ client_id: client_id,
38
+ client_secret: client_secret,
39
+ fingerprint: fingerprint,
36
40
  ip_address: ip_address,
37
41
  **options)
38
42
  @users = Users.new @http_client
@@ -50,6 +50,9 @@ module SynapsePayRest
50
50
  GatewayTimeout = Class.new(ServerError)
51
51
 
52
52
  # HTTP status code to Error subclass mapping
53
+ #
54
+ # @todo need to add an error message for various 202 cases (fingerprint, mfa, etc)
55
+ # @todo doesn't do well when there's an html response from nginx for bad gateway/timeout
53
56
  ERRORS = {
54
57
  400 => SynapsePayRest::Error::BadRequest,
55
58
  401 => SynapsePayRest::Error::Unauthorized,
@@ -10,6 +10,7 @@ module SynapsePayRest
10
10
  # @return [String] question or MFA prompt from bank that must be answered
11
11
  # @!attribute [r] mfa_verified
12
12
  # @return [Boolean] whether the node is verified yet
13
+ # @todo should be mfa_verified? in Ruby idiom
13
14
  attr_reader :user, :mfa_access_token, :mfa_message, :mfa_verified
14
15
 
15
16
  def initialize(user:, mfa_access_token:, mfa_message:, mfa_verified:)
@@ -26,6 +27,8 @@ module SynapsePayRest
26
27
  # @raise [SynapsePayRest::Error] if incorrect answer
27
28
  #
28
29
  # @return [Array<SynapsePayRest::AchUsNode>,SynapsePayRest::UnverifiedNode] may contain multiple nodes if successful, else self if new MFA question to answer
30
+ #
31
+ # @todo make a new Error subclass for incorrect MFA
29
32
  def answer_mfa(answer)
30
33
  payload = payload_for_answer_mfa(answer: answer)
31
34
  response = user.client.nodes.post(user_id: user.id, payload: payload)
@@ -33,8 +36,6 @@ module SynapsePayRest
33
36
  handle_answer_mfa_response(response)
34
37
  end
35
38
 
36
- alias_method :mfa_verified?, :mfa_verified
37
-
38
39
  private
39
40
 
40
41
  def payload_for_answer_mfa(answer:)
@@ -46,13 +47,23 @@ module SynapsePayRest
46
47
 
47
48
  # Determines whether the response is successful in verifying the node, has
48
49
  # follow-up MFA questions, or failed with an incorrect answer.
50
+ #
51
+ # @todo Use Error#code instead of parsing the response for the code.
49
52
  def handle_answer_mfa_response(response)
50
53
  if response['error_code'] == '0'
51
54
  # correct answer
52
55
  @mfa_verified = true
53
56
  AchUsNode.multiple_from_response(user, response['nodes'])
57
+ elsif response['error_code'] == '10' && response['mfa']['message'] == mfa_message
58
+ # wrong answer (mfa message the same), retry if allowed
59
+ args = {
60
+ message: 'incorrect bank login mfa answer',
61
+ code: response['http_code'],
62
+ response: response
63
+ }
64
+ raise SynapsePayRest::Error, args
54
65
  elsif response['error_code'] == '10'
55
- # incorrect answer or new MFA question. need to call #answer_mfa with new answer.
66
+ # new additional MFA question. need to call #answer_mfa with new answer
56
67
  @mfa_access_token = response['mfa']['access_token']
57
68
  @mfa_message = response['mfa']['message']
58
69
  self
@@ -114,6 +114,7 @@ module SynapsePayRest
114
114
  #
115
115
  # @note Shouldn't need to call this directly.
116
116
  #
117
+ # @todo convert the nodes and users in response into User/Node objects
117
118
  # @todo rework to handle multiple fees
118
119
  def from_response(node, response)
119
120
  args = {
@@ -207,7 +208,7 @@ module SynapsePayRest
207
208
  trans_id: id,
208
209
  payload: payload
209
210
  )
210
- self.class.from_response(node, response)
211
+ self.class.from_response(node, response['trans'])
211
212
  end
212
213
 
213
214
  # Cancels this transaction if it has not already settled.
@@ -6,7 +6,6 @@ module SynapsePayRest
6
6
  class VirtualDocument < Document
7
7
  # @!attribute [r] question_set
8
8
  # @return [SynapsePayRest::Array<SynapsePayRest::Question>] questions/answer choices returned when document status is MFA|PENDING
9
- # @deprecated
10
9
  attr_reader :question_set
11
10
 
12
11
  class << self
@@ -29,8 +28,6 @@ module SynapsePayRest
29
28
  # @return [SynapsePayRest::VirtualDocument] (self)
30
29
  #
31
30
  # @todo should raise error if any questions aren't answered yet.
32
- #
33
- # @deprecated
34
31
  def submit_kba
35
32
  user = base_document.user
36
33
  user.authenticate()
@@ -41,8 +38,6 @@ module SynapsePayRest
41
38
  end
42
39
 
43
40
  # Maps question set from response to Question objects.
44
- #
45
- # @deprecated
46
41
  def add_question_set(question_set_data)
47
42
  questions = question_set_data['questions'].map do |question_info|
48
43
  # re-map question/answer hash structure
@@ -1,4 +1,4 @@
1
1
  module SynapsePayRest
2
2
  # gem version:
3
- VERSION = '2.2.2'.freeze
3
+ VERSION = '2.2.3'.freeze
4
4
  end
data/samples.md CHANGED
@@ -310,7 +310,7 @@ Returns a collection of `AchUsNode`s associated with the account unless bank req
310
310
 
311
311
  ```ruby
312
312
  login_info = {
313
- bank_name: 'fake',
313
+ bank_name: 'bofa',
314
314
  username: 'synapse_good',
315
315
  password: 'test1234'
316
316
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapse_pay_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Broderick