So I just created a sandbox account and got my API ID and KEY
I went to the following link and followed it's instrucitons: https://developer.authorize.net/hello_world/
So I installed the python SDK module with:
pip install authorizenet
Then ran the code given verbatim, changing my API ID and KEY of course
from authorizenet import apicontractsv1 from authorizenet.apicontrollers import* from decimal import* merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name ='REPLACED WITH MY ID' merchantAuth.transactionKey ='REPLACED WITH MY KEY' creditCard = apicontractsv1.creditCardType() creditCard.cardNumber ="4111111111111111" creditCard.expirationDate ="2020-12" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType ="authCaptureTransaction" transactionrequest.amount = Decimal ('1.55') transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId ="MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode=="Ok"): print"Transaction ID : %s"% response.transactionResponse.transId else: print"response code: %s"% response.messages.resultCode
But the error I get is:
if (response.messages.resultCode=="Ok"): AttributeError: 'NoneType' object has no attribute 'messages'
This happens no matter what I try to query. Like if I try to get a list of all unsettled transactions, the Library returns Null.
Thanks!
Solved! Go to Solution.
08-09-2017 05:33 PM
You'll definitely need to upgrade that OpenSSL version to be able to connect to our system. In case you weren't aware, PCI-DSS requirements specify that no card transactions use older TLS implementations after next summer. Our sandbox already requires TLS 1.2, and our production systems will require it in February 2018.
From reading that python and OpenSSL version, I'm guessing MacOS X? If so, Apple still ships this old insecure version of OpenSSL, but doesn't update it because some of their components are still linked to it, and newer versions of OpenSSL aren't API compatible. You could try upgrading the system supplied binary in /usr/bin directly, but you'd have to deal with SIP and possibly breaking other components. You're better off leaving it in place and using something like Homebrew to install a newer version (and install a newer Python too to link to the newer version).
If you're not on MacOS X, you'll find similar instructions elsewhere on the net. As crypto libraries evolve and weaknesses are found, every programmer who deals with internet applications will hit this same or similar situation at some point. We call out this exact thing on the readme for our Python SDK, but the "Hello World" page has you installing the SDK without necessarily seeing that.
08-09-2017 08:48 PM
Just for future reference, I'm also on a Mac and am developing in a virtualenv. I got around the problem with this tip:
More specificially, I got the authorize.net python library to work in my code by upgrading requests with the the security argument:
pip install requests[security]
08-12-2017 05:40 PM
08-09-2017 06:18 PM - edited 08-09-2017 06:19 PM
Python 2.7.10
08-09-2017 06:45 PM
Can you also find out what version of the SSL library (like OpenSSL) that you're using?
I suspect your setup doesn't support TLS 1.2, which is required for communication with our sandbox environment, but we can tell for sure with a couple of more tests.
For starters, check the openSSL version:
import ssl ssl.OPENSSL_VERSION
Then actually do a test to a site that will tell you what version of TLS you can connect with:
import json, urllib2 print json.load(urllib2.urlopen('https://www.howsmyssl.com/a/check'))['tls_version']"
08-09-2017 07:03 PM
I see
Here's my OpenSSL Version:
OpenSSL 0.9.8zh 14 Jan 2016
And here's what I get from howsmyssl:
TLS 1.0
08-09-2017 07:14 PM
You'll definitely need to upgrade that OpenSSL version to be able to connect to our system. In case you weren't aware, PCI-DSS requirements specify that no card transactions use older TLS implementations after next summer. Our sandbox already requires TLS 1.2, and our production systems will require it in February 2018.
From reading that python and OpenSSL version, I'm guessing MacOS X? If so, Apple still ships this old insecure version of OpenSSL, but doesn't update it because some of their components are still linked to it, and newer versions of OpenSSL aren't API compatible. You could try upgrading the system supplied binary in /usr/bin directly, but you'd have to deal with SIP and possibly breaking other components. You're better off leaving it in place and using something like Homebrew to install a newer version (and install a newer Python too to link to the newer version).
If you're not on MacOS X, you'll find similar instructions elsewhere on the net. As crypto libraries evolve and weaknesses are found, every programmer who deals with internet applications will hit this same or similar situation at some point. We call out this exact thing on the readme for our Python SDK, but the "Hello World" page has you installing the SDK without necessarily seeing that.
08-09-2017 08:48 PM
Yes I'm on a mac.
I was able to get a newer OpenSSL installation separate from the system's.
It's a complete hack, but it works.
Thanks!!
08-12-2017 11:34 AM
Just for future reference, I'm also on a Mac and am developing in a virtualenv. I got around the problem with this tip:
More specificially, I got the authorize.net python library to work in my code by upgrading requests with the the security argument:
pip install requests[security]
08-12-2017 05:40 PM
I am facing the issue as above. I sent amount, customer profile and the invoice and while I am getting the response it shows an error:
AttributeError: 'exceptions.Exception' object has no attribute 'transactionResponse'
This happens only for one customer profile while others are passing through. PLEASE HELP!!
08-14-2018 02:39 AM
Just got the solution. When the amount that is sent to Authorize via API call has decimals, it has to be in string format.
But the weird thing is that if you give an amount $291.5 or $291.0 in number format, it passes through and does not have any issues. But when the amount has decimals other than .0 and .5, you have to send the request with the amount in string format.
I was making an API call for a particular customer profile which had $291.6 to be billed. The API call was not None but it had a string with error message "type {http://www.w3.org/2001/XMLSchema}decimal cannot be created from: 291.6". The response handling that I had, was not handling this type of error as it was so unexpected and I thought Authorize will handle the decimals. But when I changed the amount format to string it worked and the system was getting the response back from Authorize.
But on a serious note Authorize should handle such type of errors which does not make any sense and not the users.
08-15-2018 11:45 PM