veem python sdk提供了调用veem全球支付api的接口(https://www.veem.com)。
veem的Python项目详细描述
Veem Python软件开发工具包
veem python sdk提供了一个接口,使调用Veem Global Payments APIs更加容易。
版本信息
- 最新的sdk版本:
3.0.0
- 最新支持的API终结点版本:
v1.1
文档
系统要求
- sdk可以在python 2.7、python 3.4及更高版本上工作。
- 一个developer帐户
- 一个application with a customer account 以及相关的客户端ID和机密(授权流/客户端 凭证流)
首次使用说明
- pypi安装命令:
pip install veem
- 将包导入您的python
或
- 将github repo克隆到您的计算机上。
- 使用命令
python setup.py install
运行安装
- 将包导入python脚本
配置yaml
veem python sdk利用配置yaml文件来管理sdk凭据。 以下是示例内容:
client_id: VeemTester-1234abcd
client_secret: 8djduf8e-d798-3534-afe3-123sdc3r4fe
url: https://sandbox-api.veem.com/
authorizationCode: VeemAbckeieifh
redirectUrl: http://your-veem-redirct.yourbusiness.com
测试代码
要在本地测试代码,请执行以下步骤:
- CD到项目目录
- 客户端可以与授权流或客户端凭据流集成;
- 对于授权流,请填写
clientId
,clientSecret
,authorizationCode
,和redirectUrl
(可选)在配置yaml中。 - 对于客户端凭据流,请填写
clientId
,和clientSecret
你的配置。 - 要使用所有Veem全球支付API,请填写从 配置yaml的步骤3或4。
- 将配置yaml保存到可读位置或传递 yaml文件作为yaml可加载字符串。
获取OAuth令牌
以便从开发人员门户获取访问令牌;
使用veem登录-登录developer Portal 。
创建应用程序-通过提供Name
、OAuth2 Redirection URLs
和Payment Status Webhooks
来创建新的应用程序。
创建客户-通过提供Business Name
、Country
和Primary Email
来创建新客户
get credentials-转到应用程序并选择Customer
,然后复制Access Token
。
要以编程方式获取access token
,请获取客户机id、客户机机密(授权流的可选重定向url)。
from veem.configuration import ConfigLoader
from veem.client.authentication import AuthenticationClient
# loading SDK configuration from your yaml file
config = ConfigLoader(yaml_file='/path/to/your/configuration.yaml')
# login to Veem server with client credentials
tokenResponse= AuthenticationClient(config).getTokenFromClientCredentials()
发票客户示例
下面的示例是使用Invoice Client
from veem.client.veem import VeemClient
from veem.client.requests.invoice import InvoiceRequest
# define a VeemClient Context Manager with yaml+file and auto login.
with VeemClient(yaml_file='/path/to/your/configuration.yaml',
useClientCredentials=True) as veem:
# define an InvoiceRequest
invoice = InvoiceRequest(payer=dict(type='Business',
email='username@yourbusiness.com',
firstName='Joe',
lastName='Doe',
businessName='Your Business Inc.',
countryCode='US',
phoneCountryCode='1',
phone='02222222222'),
amount=dict(number=50, currency='USD'))
# create an invoice
sentInvoice = veem.inoviceClient.create(invoice)
更多示例可在examples文件夹下找到