-
Notifications
You must be signed in to change notification settings - Fork 47
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::Customer Debit method charging incorrect cards #136
Comments
I assume this has to do with the bug where the default card is being set to something other than the newest when source_uri isn't explicitly set? |
It should use the most recently added card when no explicitly set funding instrument is used. Let me write a script to confirm that this is reproducible locally. In the meantime I recommend that you debit the funding instrument you want to use explicitly. e.g. |
Here's the test script I wrote require 'balanced'
key = Balanced::ApiKey.new.save
Balanced.configure(key.secret)
marketplace = Balanced::Marketplace.new.save
customer = Balanced::Customer.new.save
card1 = Balanced::Card.new(
:card_number => '5105105105105100',
:expiration_month => '12',
:expiration_year => '2020',
:security_code => '123'
).save
card2 = Balanced::Card.new(
:card_number => '5105105105105100',
:expiration_month => '12',
:expiration_year => '2020',
:security_code => '123'
).save
customer.add_card(card1.uri)
customer.add_card(card2.uri)
puts customer.active_card.uri
debit = customer.debit(:amount => 100)
puts debit.source.uri
puts card1.uri
puts card2.uri And it does indeed seem to not work as expected (code snipped for brevity):
|
One of our engineers, @victorlin, diagnosed the issue. What's happening is we are setting the first card_uri as the source when we add the second card and then is causing the first card to be set as the primary funding source. The API is behaving as intended, this is something to do with the way our ruby and python client's are written. To quote Victor: def add_card(self, card_uri):
"""
Associates the `Card` represented by `card_uri` with this `Account`.
"""
self.card_uri = card_uri
self.save()
customer.source_uri = card1.uri
def update_customer(customer, **kwargs):
# ...
if 'source' in kwargs:
customer.default_funding_source = kwargs['source']
The correct solution to fix this is mentioned in #99, the client libraries should keep track of values that are changed on the resource and only send that changed data to the server. |
The 'debit' method for Balanced::Customer is charging cards that were previously added to the list of customer's cards, instead of charging the 'active card'.
The text was updated successfully, but these errors were encountered: