balanced / balanced-ruby

Balanced API library in ruby.
MIT License
111 stars 47 forks source link

setting :appears_on_statement_as when making a Balanced::Credit doesn't save the value #59

Closed seansu4you87 closed 11 years ago

seansu4you87 commented 11 years ago
account = Balanced::Account.find(account_uri)
credit = account.credit(
      amount: amount, # in cents
      description: "Payout to #{a.name}",
      appears_on_statement_as: "Ivy Payments"
)
puts credit.attributes['appears_on_statement_as'] # returns nil

checking the logs in the dashboard, I see that the request contains :appears_on_statement_as but the response does not.

Thanks!

seansu4you87 commented 11 years ago

BTW, since appears_on_statement_as seems to be coming in correctly in the dashboard logs, it seems that this would be an internal server error instead of a Ruby client error. Ya never know though, maybe the Ruby client is incorrectly parsing data from the server

mjallday commented 11 years ago

Check how you're passing through those arguments, use symbols instead of strings, :appears_on_statement_as => "test" as opposed to appears_on_statement_as: "test". Note the leading :. :)

require 'balanced'

Balanced.configure('473154884ae511e28f34026ba7cd33d0')

account = Balanced::Account.new()
card = Balanced::Card.new(
  :expiration_month => '12',
  :security_code => '123',
  :card_number => '5105105105105100',
  :expiration_year => '2020',
).save

account.add_card(card.uri)

debit = account.debit(
    :amount => 100,
    :appears_on_statement_as => 'test test test'
)

puts debit.appears_on_statement_as
seansu4you87 commented 11 years ago

starting in Ruby 1.9 a new hash syntax was introduced:

:key => "value"

is equivalent to

key: "value"

I think the bug still exists, if it was closed on the basis of the hash syntax

mahmoudimus commented 11 years ago

Re-opening.

mjallday commented 11 years ago

It still seems to work for me

require 'balanced'

Balanced.configure('473154884ae511e28f34026ba7cd33d0')

account = Balanced::Account.new()
card = Balanced::Card.new(
  :expiration_month => '12',
  :security_code => '123',
  :card_number => '5105105105105100',
  :expiration_year => '2020',
).save

account.add_card(card.uri)

debit = account.debit(
    amount: 100,
    appears_on_statement_as: 'test test test'
)

raise Exception if debit.appears_on_statement_as != Balanced::Debit.find(debit.uri).appears_on_statement_as
raise Exception if debit.appears_on_statement_as != 'test test test'
puts debit.appears_on_statement_as

@seansu4you87 can you please provide us the request ID of the request that's failing? If you take the above script and configure a logger like this

require 'balanced'

logger = Logger.new(STDOUT)
Balanced.configure('473154884ae511e28f34026ba7cd33d0', :logger => logger)

you will get the headers for each response, please give us the header that looks like "x-balanced-guru"="OHM620493c864b311e29813026ba7d31e6f" and we'll debug the response in our server logs.

balanced-rss-bot commented 11 years ago

I believe it's on the credit not the debit

--Sent from my iPhone

On Jan 22, 2013, at 8:49 AM, Marshall Jones notifications@github.com wrote:

It still seems to work for me

require 'balanced'

Balanced.configure('473154884ae511e28f34026ba7cd33d0')

account = Balanced::Account.new() card = Balanced::Card.new( :expiration_month => '12', :security_code => '123', :card_number => '5105105105105100', :expiration_year => '2020', ).save

account.add_card(card.uri)

debit = account.debit( amount: 100, appears_on_statement_as: 'test test test' )

raise Exception if debit.appears_on_statement_as != Balanced::Debit.find(debit.uri).appears_on_statement_as raise Exception if debit.appears_on_statement_as != 'test test test' puts debit.appears_on_statement_as @seansu4you87 can you please provide us the request ID of the request that's failing? If you take the above script and configure a logger like this

require 'balanced'

logger = Logger.new(STDOUT) Balanced.configure('473154884ae511e28f34026ba7cd33d0', :logger => logger) you will get the headers for each response, please give us the header that looks like "x-balanced-guru"="OHM620493c864b311e29813026ba7d31e6f" and we'll debug the response in our server logs.

— Reply to this email directly or view it on GitHub.

seansu4you87 commented 11 years ago

Yes, the code fails on credits, not debits. Here's the request id of one of the credit requests: OHM7e924f02640011e2adf5026ba7cd33d0

The request body is:

{
    "destination_uri": null,
    "appears_on_statement_as": "Ivy Payments",
    "amount": 7000,
    "meta": null,
    "description": "Payout to Raymond Davidson"
}

and the response body does not include "appears_on_statement_as".

Thanks!

mjallday commented 11 years ago

Doh, totally got the method wrong. You're absolutely right, I'll create an issue for this since it appears to be the API, not the ruby client at fault here:

require 'balanced'

Balanced.configure('473154884ae511e28f34026ba7cd33d0')

account = Balanced::Account.new()
card = Balanced::Card.new(
  :expiration_month => '12',
  :security_code => '123',
  :card_number => '5105105105105100',
  :expiration_year => '2020',
).save

account.add_card(card.uri)

debit = account.debit(
    amount: 100,
    appears_on_statement_as: 'test test test'
)

bank_account = Balanced::BankAccount.new(
  :routing_number => '121000358',
  :type => 'checking',
  :name => 'Johann Bernoulli',
  :account_number => '9900000001'
).save

account.add_bank_account(bank_account.uri)

credit = account.credit(
    amount: 100, # in cents
    appears_on_statement_as: "test test test"
)

raise Exception if credit.appears_on_statement_as != Balanced::Credit.find(credit.uri).appears_on_statement_as
mjallday commented 11 years ago

@seansu4you87, We've created an issue where you can track progress of this, thanks for bringing it to our attention

seansu4you87 commented 11 years ago

Thanks @mjallday !

mahmoudimus commented 11 years ago

This has now been fixed!