order_buy.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- coding: UTF-8 -*-
  2. import esigntool
  3. import requests
  4. from esigntool import esign_run_print_outer
  5. # 套餐服务API - 套餐购买 - 购买类
  6. config = esigntool.Config() # 初始化配置类
  7. # 获取购买e签宝套餐链接
  8. @esign_run_print_outer
  9. def getBuyOrgOrderUrl(orgId, PsnId):
  10. """
  11. :param orgId:购买方企业账号
  12. :param PsnId:购买方企业经办人账号
  13. :return:请求响应
  14. """
  15. api_path = "/v3/orders/org-place-order-url"
  16. method = esigntool.httpMethodEnum.POST
  17. body = {
  18. "orgId": orgId, # 机构账号ID(购买方orgId)
  19. "transactorPsnId": PsnId, # 经办人个人账号ID(购买操作个人psnId)
  20. "redirectUrl": "https://www.baidu.com",
  21. "notifyUrl": "https://www.esign.cn/1",
  22. "customBizNum": "1111111" # 自定义编号
  23. }
  24. if orgId == "" or PsnId == "":
  25. print("请设置企业账号ID和经办人账号ID")
  26. exit()
  27. # 签名并构造签名鉴权json请求头
  28. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert, method, api_path, body=body)
  29. # 发起请求
  30. resp = requests.request(method, config.host + api_path, json=body, headers=json_headers)
  31. print(resp.text)
  32. return resp.text
  33. if __name__ == '__main__':
  34. if config.appId == "" or config.scert == "":
  35. print("请设置应用Appid和应用Secret")
  36. exit()
  37. orgId = "" # 请输入企业帐号ID
  38. PsnId = "" # 请输入个人帐号ID
  39. getBuyOrgOrderUrl(orgId, PsnId) # 获取购买e签宝套餐链接