wepay / python-sdk Goto Github PK
View Code? Open in Web Editor NEWA Python SDK for our WePay API
Home Page: https://www.wepay.com/developer
License: MIT License
A Python SDK for our WePay API
Home Page: https://www.wepay.com/developer
License: MIT License
It'd be nice to have this on PyPI just to simplify installation, esp for automated deployments.
This definitely needs a license with it before too many begin to use the module.
There is no indication regarding Python 2/3 support. Could be included in setup.py and/or README.
The exception handling in api.py lines 68..75 contains a potential error, if the post throws an exception then 'response' in the except will be undefined. This results in the following error.
local variable 'response' referenced before assignment
When reconciling we noticed these errors during the 3/14 maintenance window.
This does not really affect the function (it has failed either way) but the error reported is confusing.
Also this should probably always throw an exception regardless of the status_code.
try:
response = self.requests.post(
url, data=params, headers=headers,
timeout=self.request_timeout)
return response.json()
except:
if 400 <= response.status_code <= 599:
raise Exception('Unknown error. Please contact [email protected]')
in call function if param is None it should stay None instead of json encoding an empty dictionary.
Example is '/user' API call doesn't require any arguments, and therefore gives an Exception.
Oauth2: using the getToken method, basically following this tutorial: https://www.wepay.com/developer/overview/build-a-crowdfunding-site
Okay weird title, but hopefully this will help break it down...
I was (stupidly) using an incorrect client ID/secret, and when wepay/api.py, in the get_token function was returning, I was getting a key error on line 126, where it checks to set the self.access_token.
What I'm finding, is that, if there's an error returned by the previous line (self.call), it will not do anything with that error because the code will error out on the response['access_token'] because 'access_token' won't be set when the code errors out.
Here are a couple screenshots because I'm not great at explaining: http://imgur.com/a/oKcnJ/all
Swapping that line to: self.access_token = response.get('access_token', None)
clears the keyerror, but doesn't do much in terms of helping you know wthat there's a problem. BUT the error is at least there in the response.
So.. yeah. Just some thoughts. I can make a PR for that if you want, or you can just try it out and test it ourself.
Line 65 in 660a5ae
In the event of some other errors, the exception is just swallowed. For example, a network error. You should list the exceptions that you want to catch.
And I think the code expects that an exception will be raised if the status code is 4xx/5xx, but, as far as I know, it's not the case.
After python 3 urlcode is now at parse.urlencode() ref: https://stackoverflow.com/questions/28906859/module-has-no-attribute-urlencode
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.