cancel
Showing results for 
Search instead for 
Did you mean: 

Expected Timeframe for Upgrading PYXB To A Version Compatible With Python > 3.9?

Hello everyone,
 
I am a developer that is leveraging Authorize.Net for purchases on my application. My application requires usage of Python 3.10 and above.
When I tried to use your ‘authorizenet' Python package in my application, I received the following error: 
 
AttributeError: module 'collections' has no attribute ‘MutableSequence'
 
This is due to the developers of Python moving MutableSequence into ‘collections.abc’. The correct path should now be ‘collections.abc.MutableSequence’ on Python versions greater than 3.9.
 
Now to the meat of the issue:
 
This error in your ‘authorizenet’ Python package is originating from within 'apicontractsv1.py’, specifically from its usage of the external package ‘pyxb’. Pyxb has reached end of life, and is unfortunately no longer compatible with modern versions of Python.
 
I would appreciate it if you updated your Python package to be compatible with python 3.10 and above!
 
 
Recommendations:
 
Here is a package I found that could quickly and easily fix the issue: https://github.com/renalreg/PyXB-X
 
It is a port of pyxb intended for modern versions of Python. All you would need to do is utilize that package instead and regenerate the corresponding bindings.
faugermire1
Member
1 REPLY 1

Hey faugermire1.  I was frustrated with this issue as well.  With the age of the package, I decided to just use requests to make the calls.  Fundamentally they are using requests.post of an xml object.  I am using constants.SANDBOX to get the dev environment url and constants.PRODUCTION to get the production environment url.  With the url I'm making a call to requests.post.  I'm using a json object instead of xml for readability and so I could test with the Live API call json objects.

Ex:

def get_portal_token(self, amount, profile, line_items):
if Config.get('PAYMENT_PORTAL', 'dev'):
url = constants.SANDBOX
else:
url = constants.PRODUCTION

r = requests.post(url, json={
"getHostedPaymentPageRequest": {
"merchantAuthentication": self.get_merchant_auth(),
"transactionRequest": self.get_transaction_request(amount, profile, line_items),
"hostedPaymentSettings": {
"setting": self.get_portal_settings()
}
}
})
return json.loads(r.text[1:])
jrussell
Member