Access_token


#1

It appears the code is flawed, and uses the wrong access_token

# download the Python SDK at https://github.com/wepay/Python-SDK
from wepay import WePay
wepay = WePay()
wepay = WePay(access_token='STAGE_df1684a1c7b91f0de51b72e5890891b92d34e47fb3cb48d4dbd8d2a89fa253cc')
response = wepay.call('/checkout/create', {
    'account_id': 161624111,
	'short_description': 'A brand new soccer ball',
	'type': 'GOODS',
	'amount': '24.95'
})

print response

This returns:

Traceback (most recent call last):
  File "python", line 9, in <module>
WePayError: You are trying to use an access_token from stage on production

I'm guessing the reason is because the wepay library that is imported makes calls to production instead of stage?


#2

access tokens are like temporary passwords. they expire after a set time. you can always visit https://stage.wepay.com/developer for new token to practise.
Had a few hitches but worked fine.


#3

first thing, there are two instances of wepay.the first instance which is the third line (wepay = WePay()) should be removed. then instantiate wepay using the "production=False" argument because we are using stage not production. leaving the arguments empty or not using "production=False" would by default use the production stage. instead, instantiate it as shown below:
wepay = WePay(production=False, access_token=USERS_ACCESS_TOKEN)
the access_token doesn't work anymore so you would have to sign up on wepay to get your own access_token(use the stage sign up).