Class: SynapsePayRest::AchUsNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/synapse_pay_rest/models/node/ach_us_node.rb

Overview

Represents a US bank account for processing ACH payments. Can be added by account/routing number or via bank login for selected banks (recommended).

Instance Attribute Summary

Attributes inherited from BaseNode

#access_token, #account_class, #account_id, #account_number, #account_type, #address, #address_city, #address_country_code, #address_postal_code, #address_street, #address_subdivision, #allow_foreign_transactions, #atm_withdrawal_limit, #balance, #bank_id, #bank_long_name, #bank_name, #bank_pw, #card_hash, #card_style_id, #card_type, #correspondent_address, #correspondent_bank_name, #correspondent_routing_number, #correspondent_swift, #currency, #document_id, #email_match, #gateway_restricted, #id, #ifsc, #interchange_type, #is_active, #is_international, #max_pin_attempts, #monthly_withdrawals_remaining, #name_match, #name_on_account, #network, #nickname, #other, #payee_address, #payee_name, #permission, #phonenumber_match, #portfolio_BTC, #portfolio_ETH, #pos_withdrawal_limit, #routing_number, #security_alerts, #supp_id, #swift, #type, #user

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseNode

#==, all, create, #create_subnet, #create_transaction, #deactivate, #find_subnet, #find_transaction, from_response, #get_statement, #initialize, multiple_from_response, #subnets, #transactions

Constructor Details

This class inherits a constructor from SynapsePayRest::BaseNode

Class Method Details

.create_via_bank_login(user:, bank_name:, username:, password:) ⇒ Array<SynapsePayRest::AchUsNode>

Creates an ACH-US node via bank login, belonging to user supplied.

Parameters:

  • user (SynapsePayRest::User)

    the user to whom the node belongs

  • bank_name (String)
  • username (String)

    user’s bank login username

  • password (String)

    user’s bank login password

Returns:

Raises:

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/synapse_pay_rest/models/node/ach_us_node.rb', line 20

def (user:, bank_name:, username:, password:)
  raise ArgumentError, 'user must be a User object' unless user.is_a?(User)
  raise ArgumentError, 'bank_name must be a String' unless bank_name.is_a?(String)
  raise ArgumentError, 'username must be a String' unless username.is_a?(String)
  raise ArgumentError, 'password must be a String' unless password.is_a?(String)

  payload = (bank_name: bank_name, username: username, password: password)
  response = user.client.nodes.add(user_id: user.id, payload: payload)
  # MFA questions
  if response['mfa']
    create_unverified_node(user, response)
  else
    multiple_from_response(user, response['nodes'])
  end
end

.create_via_bank_login_mfa(user:, access_token:) ⇒ <SynapsePayRest::UnverifiedNode>

Creates an Unverified Node Class node via access token, belonging to this user

Parameters:

  • user (SynapsePayRest::User)

    the user to whom the node belongs

  • access_token (String)

    user’s access token

Returns:

Raises:



44
45
46
47
48
49
# File 'lib/synapse_pay_rest/models/node/ach_us_node.rb', line 44

def (user:, access_token:)
  raise ArgumentError, 'user must be a User object' unless user.is_a?(User)
  raise ArgumentError, 'access_token must be a String' unless access_token.is_a?(String)
  payload = (access_token: access_token)
  create_unverified_node(user, payload)
end

Instance Method Details

#resend_microSynapsePayRest::AchUsNode

Reinitiates microdeposits on a node

Returns:

Raises:



125
126
127
128
# File 'lib/synapse_pay_rest/models/node/ach_us_node.rb', line 125

def resend_micro()
  response = user.client.nodes.resend_micro(user_id: user.id, node_id: id)
  self.class.from_response(user, response)
end

#verify_microdeposits(amount1:, amount2:) ⇒ SynapsePayRest::AchUsNode

Verifies the microdeposit amounts sent to the user’s account to verify a node added by account and routing number. Node will be locked if max tries exceeded.

Parameters:

  • amount1 (Float)
  • amount2 (Float)

Returns:

Raises:



109
110
111
112
113
114
115
116
117
# File 'lib/synapse_pay_rest/models/node/ach_us_node.rb', line 109

def verify_microdeposits(amount1:, amount2:)
  [amount1, amount2].each do |arg|
    raise ArgumentError, "#{arg} must be float" unless arg.is_a?(Float)
  end

  payload = verify_microdeposits_payload(amount1: amount1, amount2: amount2)
  response = user.client.nodes.patch(user_id: user.id, node_id: id, payload: payload)
  self.class.from_response(user, response)
end