| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- # -*- coding: UTF-8 -*-
- import esigntool
- import requests
- from esigntool import esign_run_print_outer
- # EP订单场景:需要联系交付顾问协助配置商品信息,沙箱环境获取到商品购买链接后,可以购买测试套餐进行业务测试
- config = esigntool.config() # 初始化配置类
- @esign_run_print_outer
- def getBuyOrgOrderUrl(orgId,transactorPsnId):
- """
- 获取购买e签宝套餐链接
- :return:请求响应
- """
- api_path = "/v3/orders/org-place-order-url"
- method = esigntool.httpMethodEnum.POST
- body = {
- "orgId": orgId, # 机构账号ID(购买方orgId)
- "transactorPsnId": transactorPsnId, # 经办人个人账号ID(购买操作个人psnId)
- "redirectUrl": "https://www.baidu.com",
- "notifyUrl": "https://www.esign.cn/1",
- "customBizNum": "1111111" # 自定义编号
- }
- if orgId == "" or transactorPsnId == "":
- print("请设置企业账号ID和经办人账号ID")
- exit()
- # 签名并构造签名鉴权json请求头
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert, method, api_path, body=body)
- # 发起请求
- resp = requests.request(method, config.host + api_path, json=body, headers=json_headers)
- print(resp.text)
- return resp.text
- @esign_run_print_outer
- def findOrderQuantity(orgId):
- """
- 查询e签宝套餐余量
- :return:请求响应
- """
- api_path = "/v3/orders/remaining-quantity?orgId={}&distributor=true".format(orgId)
- method = esigntool.httpMethodEnum.GET
- if orgId == "":
- print("请设置实名企业账号ID")
- exit()
- # 签名并构造签名鉴权json请求头
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert, method, esigntool.apiPathSort(api_path))
- # 发起请求
- resp = requests.request(method, config.host + api_path, json=None, headers=json_headers)
- print(resp.text)
- return resp.text
- @esign_run_print_outer
- def findOrderList(orgId):
- """
- 查询套餐订单列表
- :return:请求响应
- """
- api_path = "/v3/orders/order-list?orgId={}&distributor=true".format(orgId)
- method = esigntool.httpMethodEnum.GET
- if orgId == "":
- print("请设置实名企业账号ID")
- exit()
- # 签名并构造签名鉴权json请求头
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert, method, esigntool.apiPathSort(api_path))
- # 发起请求
- resp = requests.request(method, config.host + api_path, json=None, headers=json_headers)
- print(resp.text)
- return resp.text
- @esign_run_print_outer
- def getOrderListUrl(orgId, transactorPsnId):
- """
- 查询套餐订单列表(页面版)
- :return:请求响应
- """
- api_path = "/v3/orders/org-order-manage-url"
- method = esigntool.httpMethodEnum.POST
- body = {
- "orgId": orgId, # 机构账号ID(购买方orgId)
- "transactorPsnId": transactorPsnId,
- "distributor": 'true'
- }
- if orgId == "" or transactorPsnId == "":
- print("请设置实名企业账号ID和经办人账号ID")
- exit()
- # 签名并构造签名鉴权json请求头
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert, method, api_path, body=body)
- # 发起请求
- resp = requests.request(method, config.host + api_path, json=body, headers=json_headers)
- print(resp.text)
- return resp.text
- if __name__ == '__main__':
- orgId = "32367*********f9f18d5" # 购买方orgId,需要先通过实名接口,获取购买方企业orgId
- transactorPsnId = "2cc69e5*********ce1d3c" # 购买操作个人psnId,需要先通过实名接口,获取购买方企业psnId
- getBuyOrgOrderUrl(orgId, transactorPsnId) # 获取购买e签宝套餐链接
- findOrderQuantity(orgId) # 查询e签宝套餐余量
- findOrderList(orgId) # 查询套餐订单列表
- getOrderListUrl(orgId, transactorPsnId) # 查询套餐订单列表(页面版)
|