Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UnicodeDecodeError and check return code #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions wzhifuSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
except ImportError:
pycurl = None

import sys
reload(sys)
sys.setdefaultencoding('utf-8')


class WxPayConf_pub(object):
"""配置账号信息"""
Expand Down Expand Up @@ -367,8 +371,11 @@ def getPrepayId(self):
"""获取prepay_id"""
self.postXml()
self.result = self.xmlToArray(self.response)
prepay_id = self.result["prepay_id"]
return prepay_id
if "return_code" in self.result and self.result["return_code"].upper() == "SUCCESS":
prepay_id = self.result["prepay_id"]
return prepay_id
else:
return None


class OrderQuery_pub(Wxpay_client_pub):
Expand Down Expand Up @@ -607,7 +614,5 @@ def test():
c2 = HttpClient()
assert id(c) == id(c2)



if __name__ == "__main__":
test()