Welcome to python-wepay’s documentation!

Unofficial, but the most complete Python WePay SDK

Based on official Python Wepay SDK, and designed to be completely compatible with it.

Before using this package get yourself familiar with actual WePay API Documentation.

WePay is a great service, highly recommend it.


pip install python-wepay

Latest build

Forkme on Github: python-wepay

Quickstart Guide

This package suppose to make it easier to construct and send API calls in more Pythonic way rather than building dictionary with parameters and simply sending it to WePay servers.

Just like with official SDK the core of this package is wepay.WePay class, which needs to be instantiated with valid access_token and production arguments of your WePay Application, after which API calls can be made. All methods within WePay object mimic API calls from official Documentation in the way that normally would be expected, call names are directly mapped into functions with same names moreover all required parameters are passed to functions as args and optional ones as kwargs.

Methods that can perform calls on behalf of WePay User accept optionall keyword argument access_token, which will then be used to perform a call instead of one the wepay.WePay class was instantiated with. Methods that can be used in a ‘/batch/create’ call also accept batch_mode keyword argument, which instead of making a call will force it to return a dictionary, which can be used later on to perform a wepay.WePay.batch_create() call. An unrecognized keyword passed to those functions will produce a warning and an actuall error from WePay, if it is in fact an unrecognized parameter.

Quick Example:

>>> WEPAY_CLIENT_ID = 123456
>>> WEPAY_CLIENT_SECRET = '1a2b3c4e5f'
>>> WEPAY_DEFAULT_SCOPE = "manage_accounts,collect_payments,view_balance,view_user,preapprove_payments,send_money"
>>> REDIRECT_URI = 'https://example.com/user/wepay/redirect'
>>> api = WePay(production=False, access_token=WEPAY_ACCESS_TOKEN)
{u'status': u'approved', u'theme_object': .....}
>>> api.oauth2_authorize(WEPAY_CLIENT_ID, REDIRECT_URI, WEPAY_DEFAULT_SCOPE, user_email='lehins@.....ru')
>>> # Get the 'code' from url... (for detailed instructions on how to do it follow WePay documentation)
>>> response = api.oauth2_token(WEPAY_CLIENT_ID, REDIRECT_URI, WEPAY_CLIENT_SECRET, '8c3e4aca23e1ed7.....', callback_uri='https://example.com/wepay/ipn/user')
>>> response
{u'access_token': u'STAGE_f87....', u'token_type': u'BEARER', u'user_id': 87654321}
>>> access_token = response['access_token']
>>> api.account_create("Test Account", "Account will be used to make a lot of money", access_token=access_token)
{u'account_id': 1371765417, u'account_uri': u'https://stage.wepay.com/account/1371765417'}
>>> api.checkout_create(1371765417, "Short description.....

Changes in Releases


  • Added subscription calls:
    • /subscription_plan
    • /subscription
    • /subscription_charge
  • Few bug and spelling fixes.


Initial release

Indices and tables

Project Versions

Table Of Contents

Next topic

wepay.api Module

This Page