1

I am adding Balanced Payments (-v 0.6.0) to an existing system to enable marketplace features, and am running into an issues with the cleanup (invalidation) of a stored Bank Account when a new Bank Account is added/stored to a Customer Account (we only want sellers in marketplace to have at most one Bank Account active, to reduce complexity).

to make my question simple, here is a simple version of the what we are attempting, and the log response (error)

if (!params[:balanced_uri].blank?)
      begin
          @balanced_acctresponse = Balanced::Account.find(params[:balanced_uri])

          bankaccts = Balanced::BankAccount.find(@balanced_acctresponse.bank_accounts_uri)

          bankaccts.invalidate  
      rescue => e
          logger.debug("Balanced Bank Account error :: #{e}")
      end 

this is generating the following exception

Balanced Bank Account error :: Balanced::BadRequest(400)::Bad Request:: POST https://api.balancedpayments.com/v1/marketplaces/xxxxxx/accounts/xxxxxx/bank_accounts?limit=10&offset=0: request: Missing required field [name]

I'm confused as to what name field is missing. As defined here http://rubydoc.info/gems/balanced/0.6.0/Balanced/BankAccount there is no name param required for invalidate

1 Answer 1

2

I suggest you upgrade to the latest version of balanced-ruby (0.7.4). I recommend you then try something like:

begin
  @account = Balanced::Account.find(current_user.balanced_account_uri)

  @account.bank_accounts.each do |ba|
    ba.invalidate
  end 
rescue => e
  logger.debug("Balanced Bank Account error :: #{e}")
end

This will find the Account instance in Balanced, loop through its bank accounts and invalidate each of them.

NOTE: Account was deprecated about 9 months ago, superseded by Customer. Account will not be in the next API revision.

If you have any other questions, feel free to also drop by #balanced on Freenode IRC. There you can get assistance directly from developers.

2
  • Very appreciative of your comments, I'll make the switch to 0.7.4 and then reattempt
    – kaylab
    Jan 28, 2014 at 5:39
  • I can confirm that after the change to 0.7.4, I can properly call invalidate on the Bank_Accounts objs, again thanks for the assistance
    – kaylab
    Jan 28, 2014 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.