sdk yandex货币api
yandex-money-sdk的Python项目详细描述
python yandex.money API开发包
要求
- python 2.7或python 3.x
- 点
开始
安装
- 用pip install yandex-money-sdk
安装
- 粘贴from yandex_money.api import Wallet, ExternalPayment到
您的源代码
从Yandex.Money钱包付款
使用yandex.money API需要以下步骤
获取令牌URL并将用户浏览器重定向到yandex.money服务。 注:client_id,redirect_uri,client_secret为 你得到的常数,当 register应用程序输入 Yandex。货币API。
scope=['account-info','operation-history']# etc..auth_url=Wallet.build_obtain_token_url(client_id,redirect_uri,scope)
之后,用户填写yandex.money html表单并重定向用户 回到REDIRECT_URI?code=CODE。
您应该立即将CODE与ACCESS_TOKEN交换。
access_token=Wallet.get_access_token(client_id,code,redirect_uri,client_secret=None)
现在你可以使用yandex.money API了。
account_info=api.account_info()balance=account_info['balance']# and so onrequest_options={"pattern_id":"p2p","to":"410011161616877","amount_due":"0.02","comment":"test payment comment from yandex-money-python","message":"test payment message from yandex-money-python","label":"testPayment","test_payment":true,"test_result":"success"};request_result=api.request(request_options)# check statusprocess_payment=api.process({"request_id":request_result['request_id'],})# check resultifprocess_payment['status']=="success":# show success pageelse:# something went wrong
运行测试
- 克隆此回购协议。
- 使用ACCESS_TOKEN和创建tests/constants.python文件 CLIENT_ID常量。
- 安装tox
- 在repo根目录中运行tox。