Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Balanced::Debit.source sometimes returns a Hash #158

Open
taylorbrooks opened this issue Mar 3, 2014 · 5 comments
Open

Balanced::Debit.source sometimes returns a Hash #158

taylorbrooks opened this issue Mar 3, 2014 · 5 comments
Labels

Comments

@taylorbrooks
Copy link

I'm trying to find failed debits originating from a Bank Account. Like so:

failed_debits = Balanced::Debit.where(status: 'failed')
failed_debits.each do |d| 
  if d.source._type == 'bank_account'
    p "#{d.created_at} #{d.amount} #{d.customer.name} #{d.appears_on_statement_as}"
  end
end

The problem here is that the debit source class is sometimes:

Balanced::Card
Balanced::BankAccount
Hash

Why would it return a hash? Shouldn't it always return either a Card or BankAccount object? I'm using 0.7.4 version of the gem.

@mjallday
Copy link
Contributor

mjallday commented Mar 3, 2014

@taylorbrooks that is odd. Can I see the output of the funding instrument that's represented by the hash?

i suspect there's something odd about the bank account/card e.g. it has been deleted and the client library is having trouble figuring out the type.

@mjallday mjallday added the bug label Mar 3, 2014
@taylorbrooks
Copy link
Author

{
    "routing_number"=>"063115194", 
    "bank_name"=>"REGIONS BANK", 
    "_type"=>"bank_account", 
    "name"=>"E***a V**a", 
    "_uris"=>{}, 
    "type"=>"checking", 
    "meta"=>{}, 
    "account_number"=>"xxxxxxxxx0132",
    "fingerprint"=>"a629871d5a4b3788e8f687d4eae10589c4a1bca8826082b3c12b2ca7cef1e3a7",
    "can_debit"=>true
}

@mjallday
Copy link
Contributor

mjallday commented Mar 3, 2014

Thanks. It is indeed a deleted funding instrument.

It looks like the code requires a URI in order to determine the object type.

Balanced needs to return URIs for all resources even if they have been deleted. This needs to be implemented in the API before we can fix it in the client libraries. I suspect the 1.1 revision will not be susceptible to this since it returns resources in a collection so this is only going to effect 1.0 clients.

@taylorbrooks
Copy link
Author

Ok, got it.

  1. Will 1.0 have breaking changes?
  2. When will 1.0 be pushed to RubyGems?

@mjallday
Copy link
Contributor

  1. 1.0 is the current version you're using. There are no breaking changes in that. 1.1 is the new revision and it is largely backwards compatible but not a drop-in replacement. If you're using the deprecated Accounts still you need to switch to customers.
  2. There is a pre-release version. Nothing's going to change as far as I know beyond the removal of the beta tag which is blocking on some last minute documentation changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants