This module was designed to help making WePay API calls.
WePay(production=True, access_token=None, api_version=None, timeout=30, silent=None, use_requests=None)¶
A full client for the WePay API.
- production (bool) – When
stage.wepay.comAPI server will be used instead of the default production.
- access_token (str) – The access token associated with your application.
- api_version (str) – sets default version of API which will be accepting calls. It is also possible to specify different version per API call, since all calls accept a keyword argument api_version as well. More on API versioning.
- timeout (float) – time in seconds before HTTPS call request will timeout. Also can be changed on per call basis.
- silent (bool) – if set to None (default) will print
WePayWarningif production=True and raise them otherwise. Set it to True to stop parameter validation and suppress all warnings, or False to raise all warnings.
- use_requests (bool) – set to False in order to explicitly turn off requests library usage and fallback to urllib
Instance of this class contains attributes, which correspond to WePay objects and should be used to perform API calls. If a WePay object has a lookup call, corresponding attribute will also be callable. Example:
>>> api = WePay(production=False, access_token=WEPAY_ACCESS_TOKEN) >>> response = api.account.create('Test Account', 'Short Description') >>> api.account(response['account_id'])
Each method that performs an API call accepts all required parameters as positional arguments, optional parameters as keyword arguments, as well as one or more keyword arguments that are used to control behavior of a call. All these methods accept keyword arguments
timeoutand if documented also possible keyword arguments
api_versionwill make sure the call is made to a specified API version (cannot be used together with
timeoutspecifies a connection timeout in seconds for the call (cannot be used together with
access_tokenwill make sure the call is made with this access_token, also use it to set authorization param in
batch_modeinstead of performing an actual call to WePay, a method will return a dictionary that is ready to be added to /batch/create, namely to calls list parameter.
batch_reference_idwill set reference_id param in a batch call, it is an error to use it without
- Batch mode usage example:
>>> api = WePay(production=False, access_token=WEPAY_ACCESS_TOKEN) >>> calls =  >>> calls.append(api.account.create('Test Account', 'Short Description', batch_mode=True, access_token='STAGE_...', batch_reference_id='c1')) >>> calls.append(api.checkout(12345, batch_mode=True)) >>> api.batch.create(CLIENT_ID, CLIENT_SECRET, calls)
call(uri, params=None, access_token=None, api_version=None, timeout=None)¶
paramsand returns the JSON response as a python dict. The optional
access_tokenparameter takes precedence over instance’s
access_tokenif it is set. Essentially this is the place for all api calls.
WePay response as documented per call
Return type: Raises: Raises: Raises:
- production (bool) – When