Skip to content

Commit e2c7c9e

Browse files
author
Sunny Raj Rathod
authored
Merge pull request #75 from sunnyrajrathod/master
- Fix for issue #65 and #73.
2 parents 73eb482 + f32c8f1 commit e2c7c9e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

authorizenet/apicontrollersbase.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,20 @@ def execute(self):
147147

148148
except Exception as objectifyexception:
149149
logging.error( 'Create Document Exception: %s, %s', type(objectifyexception), objectifyexception.args )
150-
pyxb.GlobalValidationConfig._setForBinding(False)
151-
self._response = apicontractsv1.CreateFromDocument(self._httpResponse)
152-
#objectify code
153-
xmlResponse= self._response.toxml(encoding=constants.xml_encoding, element_name=self.getrequesttype())
154-
xmlResponse = xmlResponse.replace(constants.nsNamespace1, b'')
155-
xmlResponse = xmlResponse.replace(constants.nsNamespace2, b'')
156-
self._mainObject = objectify.fromstring(xmlResponse)
157-
else:
150+
responseString = self._httpResponse
151+
152+
# removing encoding attribute as objectify fails if it is present
153+
responseString = responseString.replace('encoding=\"utf-8\"', '')
154+
self._mainObject = objectify.fromstring(responseString)
155+
else:
156+
domResponse = xml.dom.minidom.parseString(self._httpResponse)
157+
158158
#if type(self.getresponseclass()) == type(self._response):
159159
if type(self.getresponseclass()) != type(self._mainObject):
160160
if self._response.messages.resultCode == "Error":
161161
logging.debug("Response error")
162-
domResponse = xml.dom.minidom.parseString(self._httpResponse)
163-
logging.debug('Received response: %s' % domResponse.toprettyxml())
162+
domResponse = xml.dom.minidom.parseString(self._httpResponse.encode('utf-8').decode('utf-8'))
163+
logging.debug('Received response: %s' % domResponse.toprettyxml(encoding='utf-8'))
164164
else:
165165
#Need to handle ErrorResponse
166166
logging.debug('Error retrieving response for request: %s' % self._request)

tests/testpyxb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def testGetCustomerProfile(self):
171171

172172
logging.error( 'Create Document Exception: %s, %s', type(ex), ex.args )
173173

174-
self.assertEquals(type(getCustomerProfileRequest), type(deserializedObject), "deseriaziedObject does not match original object")
174+
self.assertEqual(type(getCustomerProfileRequest), type(deserializedObject), "deseriaziedObject does not match original object")
175175

176176
try:
177177
#print("starting with element in mid")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy