cancel
Showing results for 
Search instead for 
Did you mean: 

Error Code: 5/Error message: A valid amount is required.

I set up a test customer profile in my sandbox and ran a few auth/captures with my python code.  When the amount is a multiple of 0.25 the transaction succeeds but any other amounts fail.  Is this expected behavior?

 

>>> charge_customer_profile('500311421', '500535512', Decimal(20.25), 'test000001')

Multiple accepting paths for <class 'authorizenet.apicontractsv1.CTD_ANON_9'>

Multiple accepting paths for <class 'authorizenet.apicontractsv1.CTD_ANON_8'>

Multiple accepting paths for {AnetApi/xml/v1/schema/AnetApiSchema.xsd}customerProfileIdType

Multiple accepting paths for {AnetApi/xml/v1/schema/AnetApiSchema.xsd}transactionResponse

('SUCCESS', 'Successfully created transaction with Transaction ID: 40068028999\nTransaction Response Code: 1\nMessage Code: 1\nDescription: This transaction has been approved.')

>>> charge_customer_profile('500311421', '500535512', Decimal(20.20), 'test000001')

Multiple accepting paths for <class 'authorizenet.apicontractsv1.CTD_ANON_11'>

Multiple accepting paths for <class 'authorizenet.apicontractsv1.CTD_ANON_10'>

Multiple accepting paths for {AnetApi/xml/v1/schema/AnetApiSchema.xsd}transactionResponse

('FAILURE', 'Error Code: 5\nError message: A valid amount is required.')

timwhalen1
Member
1 REPLY 1

fwiw I dug into this issue later and found it can be due to quirkiness in converting floats to Decimals in python and also in my case authorize.net requiring a Decimal value rounded to the penny when my input was in microdollars.  Here's some sample code generating good and bad Decimals.

 

>>> from decimal import Decimal
>>> Decimal(0.25) # good
Decimal('0.25')
>>> Decimal(5.11) # bad
Decimal('5.11000000000000031974423109204508364200592041015625')
>>> Decimal('5.11') # good
Decimal('5.11')
>>> Decimal(str(5.11)) # good
Decimal('5.11')

>>> Decimal('5.115465') # bad
Decimal('5.115465')
>>> Decimal('5.113465').quantize(Decimal('1.00')) # good
Decimal('5.11')

>>> Decimal('5.115465').quantize(Decimal('1.00')) # good
Decimal('5.12')

timwhalen1
Member