Skip to content

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

@taylorbrooks

Description

@taylorbrooks

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions