recurly/recurly-client-python — Issue #21: Transactions fail with validation error for users with a positive balance
Author: jordanorelli
Created: 2012-02-09 18:51:26+00:00
State: open

Here's a snippet that succeeds when the user has no account balance, but fails when they have an account balance and you submit a transaction for an amount smaller than their available balance:

account = recurly.Account(account_code='jordan+oTAHmuzG@prehype.com')
transaction = recurly.Transaction(amount_in_cents=1200, currency='USD', account=account)
transaction.save()

In this example, I'm charging the user $12. If their account has a current balance of $11 (or anything else less than $12), this call will succeed. If their account has a balance of $13 (or anything greater than $12), this call will fail with a ValidationError.