sdk yandex货币api

yandex-money-sdk的Python项目详细描述


Build StatusCoverage Status

python yandex.money API开发包

要求

  1. python 2.7或python 3.x

开始

安装
  1. pip install yandex-money-sdk
  2. 安装
  3. 粘贴from yandex_money.api import Wallet, ExternalPayment到 您的源代码

从Yandex.Money钱包付款

使用yandex.money API需要以下步骤

  1. 获取令牌URL并将用户浏览器重定向到yandex.money服务。 注:client_idredirect_uriclient_secret为 你得到的常数,当 register应用程序输入 Yandex。货币API。

    scope=['account-info','operation-history']# etc..auth_url=Wallet.build_obtain_token_url(client_id,redirect_uri,scope)
  2. 之后,用户填写yandex.money html表单并重定向用户 回到REDIRECT_URI?code=CODE

  3. 您应该立即将CODEACCESS_TOKEN交换。

    access_token=Wallet.get_access_token(client_id,code,redirect_uri,client_secret=None)
  4. 现在你可以使用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

未经授权使用银行卡付款
  1. 获取instantce id(通常每个客户机只获取一次。你可以储存 结果为分贝)。

    response=ExternalPayment.get_instance_id(client_id)ifreponse.status=="success":instance_id=response.instance_id;else:# throw exception with reponse->error message
  2. 请求付款

    # make instanceexternal_payment=ExternalPayment(instance_id);payment_options={# pattern_id, etc..}response=external_payment.request(payment_options)ifresponse.status=="success":request_id=response.request_idelse:# throw exception with response->message
  3. 使用“处理付款”处理请求。

    process_options={"request_id":request_id# other params..}result=external_payment.process(process_options)# process result according to docs

运行测试

  1. 克隆此回购协议。
  2. 使用ACCESS_TOKEN和创建tests/constants.python文件 CLIENT_ID常量。
  3. 安装tox
  4. 在repo根目录中运行tox

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
内存Java分配:从预先存在/分配的池中分配对象   java使超级方法停止实现的方法   java需要算法帮助吗   Java中Eratosthenes的素数筛:一个谜题和一些优化   Json反序列化中的java错误   java编组具有对象字段的对象   java Android 2.2 SDK Droid X摄像头活动未正确完成   java匹配模式,除非匹配为空字符串   本地Java小程序被阻止   java试图从数据库中检索值并使用用户输入进行验证   Java继承:跨包的受保护访问   java多战争到Azure Web应用程序   如何将数组(而不是列表)从groovy传递到java方法中?   如果调用“saveAndFlush”方法,则使用@QueryHints的java JPA缓存不起作用   Android在激活和未激活时通过Java更改EditText重音的颜色