signflow_rescission.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. @esign_run_print_outer
  8. def rescissionUrl():
  9. """
  10. 获取合同解约链接
  11. :return:
  12. """
  13. # 构建请求body体
  14. sign_flowId = "df********grgter" # 声明请求参数
  15. body = {
  16. "rescissionInitiator": {
  17. "orgInitiator": {
  18. "orgId": "0c5bd49248***5648bfbf",
  19. "transactor": {
  20. "psnId": "c7e002947***310541e7"
  21. }
  22. }
  23. },
  24. "signFlowConfig": {
  25. "chargeConfig": {
  26. "chargeMode": 0
  27. },
  28. "noticeConfig": {
  29. "noticeTypes": "1,2"
  30. },
  31. "notifyUrl": "https://xx.xx.xx/callback"
  32. }
  33. } # 构建请求body体
  34. api_path = "/v3/sign-flow/{}/rescission-url".format(sign_flowId) # 拼接请求路径
  35. method = esigntool.httpMethodEnum.POST # 声明请求方法
  36. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
  37. method, api_path) # 签名并构造签名鉴权json请求头
  38. resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
  39. print(resp.text)
  40. return resp
  41. if __name__ == '__main__':
  42. rescissionUrl() # 获取合同解约链接