forked from PingPlusPlus/pingpp-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
agreement.py
55 lines (47 loc) · 1.23 KB
/
agreement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
import pingpp
import os
app_id = 'app_1Gqj58ynP0mHeX1q'
# 设置 API Key
pingpp.api_key = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC"
pingpp.private_key_path = os.path.join(
os.path.dirname(__file__), 'your_rsa_private_key.pem')
"""
创建 agreement 对象,查询 agreement 对象,查询 agreement 对象列表
"""
agreement = pingpp.Agreement.create(
app=app_id, # App ID
contract_no='2018123456789', # 签约协议号
channel='qpay', # 签约渠道
extra={
'display_account': '测试商户名称'
}, # 附加信息
metadata={}, # metadata 元数据
)
print("创建 agreement 对象:")
try:
print(agreement)
except Exception as e:
print(e)
print("获取 Agreement 对象:")
try:
agreement = pingpp.Agreement.retrieve('agr_19EEDSHUw3jXRF')
print(agreement.to_str())
except Exception as e:
print(e)
print("解约 agreement :")
try:
agreement = pingpp.Agreement.cancel('agr_19EEDSHUw3jXRF')
print(agreement.to_str())
except Exception as e:
print(e)
print("获取 Agreement 对象列表:")
try:
params = {
'app': app_id,
'per_page': 10,
}
charges = pingpp.Agreement.list(**params)
print(charges)
except Exception as e:
print(e)