main.tea 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. import EasySDKKernel;
  2. type @kernel = EasySDKKernel
  3. init(kernel: EasySDKKernel) {
  4. @kernel = kernel;
  5. }
  6. model AlipayPassTemplateAddResponse {
  7. httpBody: string(name='http_body', description='响应原始字符串'),
  8. code: string(name='code'),
  9. msg: string(name='msg'),
  10. subCode: string(name='sub_code'),
  11. subMsg: string(name='sub_msg'),
  12. success: boolean(name='success'),
  13. result: string(name='result')
  14. }
  15. model AlipayPassTemplateUpdateResponse {
  16. httpBody: string(name='http_body', description='响应原始字符串'),
  17. code: string(name='code'),
  18. msg: string(name='msg'),
  19. subCode: string(name='sub_code'),
  20. subMsg: string(name='sub_msg'),
  21. success: boolean(name='success'),
  22. result: string(name='result')
  23. }
  24. model AlipayPassInstanceAddResponse {
  25. httpBody: string(name='http_body', description='响应原始字符串'),
  26. code: string(name='code'),
  27. msg: string(name='msg'),
  28. subCode: string(name='sub_code'),
  29. subMsg: string(name='sub_msg'),
  30. success: boolean(name='success'),
  31. result: string(name='result')
  32. }
  33. model AlipayPassInstanceUpdateResponse {
  34. httpBody: string(name='http_body', description='响应原始字符串'),
  35. code: string(name='code'),
  36. msg: string(name='msg'),
  37. subCode: string(name='sub_code'),
  38. subMsg: string(name='sub_msg'),
  39. success: boolean(name='success'),
  40. result: string(name='result')
  41. }
  42. api createTemplate(uniqueId: string, tplContent: string): AlipayPassTemplateAddResponse {
  43. var systemParams: map[string]string = {
  44. method = 'alipay.pass.template.add',
  45. app_id = @kernel.getConfig("appId"),
  46. timestamp = @kernel.getTimestamp(),
  47. format = 'json',
  48. version = '1.0',
  49. alipay_sdk = @kernel.getSdkVersion(),
  50. charset = 'UTF-8',
  51. sign_type = @kernel.getConfig("signType"),
  52. app_cert_sn = @kernel.getMerchantCertSN(),
  53. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  54. };
  55. var bizParams: map[string]any = {
  56. unique_id = uniqueId,
  57. tpl_content = tplContent
  58. };
  59. var textParams: map[string]string = {
  60. };
  61. __request.protocol = @kernel.getConfig("protocol");
  62. __request.method = 'POST';
  63. __request.pathname = '/gateway.do';
  64. __request.headers = {
  65. host = @kernel.getConfig("gatewayHost"),
  66. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  67. };
  68. __request.query = @kernel.sortMap({
  69. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  70. ... systemParams,
  71. ... textParams
  72. });
  73. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  74. } returns {
  75. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.pass.template.add");
  76. if (@kernel.isCertMode()) {
  77. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  78. return @kernel.toRespModel(respMap);
  79. }
  80. } else {
  81. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  82. return @kernel.toRespModel(respMap);
  83. }
  84. }
  85. throw {
  86. message = '验签失败,请检查支付宝公钥设置是否正确。'
  87. }
  88. } runtime {
  89. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  90. httpProxy = @kernel.getConfig("httpProxy"),
  91. connectTimeout = 15000,
  92. readTimeout = 15000,
  93. retry = {
  94. maxAttempts = 0
  95. }
  96. }
  97. api updateTemplate(tplId: string, tplContent: string): AlipayPassTemplateUpdateResponse {
  98. var systemParams: map[string]string = {
  99. method = 'alipay.pass.template.update',
  100. app_id = @kernel.getConfig("appId"),
  101. timestamp = @kernel.getTimestamp(),
  102. format = 'json',
  103. version = '1.0',
  104. alipay_sdk = @kernel.getSdkVersion(),
  105. charset = 'UTF-8',
  106. sign_type = @kernel.getConfig("signType"),
  107. app_cert_sn = @kernel.getMerchantCertSN(),
  108. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  109. };
  110. var bizParams: map[string]any = {
  111. tpl_id = tplId,
  112. tpl_content = tplContent
  113. };
  114. var textParams: map[string]string = {
  115. };
  116. __request.protocol = @kernel.getConfig("protocol");
  117. __request.method = 'POST';
  118. __request.pathname = '/gateway.do';
  119. __request.headers = {
  120. host = @kernel.getConfig("gatewayHost"),
  121. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  122. };
  123. __request.query = @kernel.sortMap({
  124. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  125. ... systemParams,
  126. ... textParams
  127. });
  128. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  129. } returns {
  130. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.pass.template.update");
  131. if (@kernel.isCertMode()) {
  132. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  133. return @kernel.toRespModel(respMap);
  134. }
  135. } else {
  136. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  137. return @kernel.toRespModel(respMap);
  138. }
  139. }
  140. throw {
  141. message = '验签失败,请检查支付宝公钥设置是否正确。'
  142. }
  143. } runtime {
  144. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  145. httpProxy = @kernel.getConfig("httpProxy"),
  146. connectTimeout = 15000,
  147. readTimeout = 15000,
  148. retry = {
  149. maxAttempts = 0
  150. }
  151. }
  152. api addInstance(tplId: string, tplParams: string, recognitionType: string, recognitionInfo: string): AlipayPassInstanceAddResponse {
  153. var systemParams: map[string]string = {
  154. method = 'alipay.pass.instance.add',
  155. app_id = @kernel.getConfig("appId"),
  156. timestamp = @kernel.getTimestamp(),
  157. format = 'json',
  158. version = '1.0',
  159. alipay_sdk = @kernel.getSdkVersion(),
  160. charset = 'UTF-8',
  161. sign_type = @kernel.getConfig("signType"),
  162. app_cert_sn = @kernel.getMerchantCertSN(),
  163. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  164. };
  165. var bizParams: map[string]any = {
  166. tpl_id = tplId,
  167. tpl_params = tplParams,
  168. recognition_type = recognitionType,
  169. recognition_info = recognitionInfo
  170. };
  171. var textParams: map[string]string = {
  172. };
  173. __request.protocol = @kernel.getConfig("protocol");
  174. __request.method = 'POST';
  175. __request.pathname = '/gateway.do';
  176. __request.headers = {
  177. host = @kernel.getConfig("gatewayHost"),
  178. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  179. };
  180. __request.query = @kernel.sortMap({
  181. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  182. ... systemParams,
  183. ... textParams
  184. });
  185. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  186. } returns {
  187. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.pass.instance.add");
  188. if (@kernel.isCertMode()) {
  189. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  190. return @kernel.toRespModel(respMap);
  191. }
  192. } else {
  193. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  194. return @kernel.toRespModel(respMap);
  195. }
  196. }
  197. throw {
  198. message = '验签失败,请检查支付宝公钥设置是否正确。'
  199. }
  200. } runtime {
  201. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  202. httpProxy = @kernel.getConfig("httpProxy"),
  203. connectTimeout = 15000,
  204. readTimeout = 15000,
  205. retry = {
  206. maxAttempts = 0
  207. }
  208. }
  209. api updateInstance(serialNumber: string, channelId: string, tplParams: string, status: string, verifyCode: string, verifyType: string): AlipayPassInstanceUpdateResponse {
  210. var systemParams: map[string]string = {
  211. method = 'alipay.pass.instance.update',
  212. app_id = @kernel.getConfig("appId"),
  213. timestamp = @kernel.getTimestamp(),
  214. format = 'json',
  215. version = '1.0',
  216. alipay_sdk = @kernel.getSdkVersion(),
  217. charset = 'UTF-8',
  218. sign_type = @kernel.getConfig("signType"),
  219. app_cert_sn = @kernel.getMerchantCertSN(),
  220. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  221. };
  222. var bizParams: map[string]any = {
  223. serial_number = serialNumber,
  224. channel_id = channelId,
  225. tpl_params = tplParams,
  226. status = status,
  227. verify_code = verifyCode,
  228. verify_type = verifyType
  229. };
  230. var textParams: map[string]string = {
  231. };
  232. __request.protocol = @kernel.getConfig("protocol");
  233. __request.method = 'POST';
  234. __request.pathname = '/gateway.do';
  235. __request.headers = {
  236. host = @kernel.getConfig("gatewayHost"),
  237. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  238. };
  239. __request.query = @kernel.sortMap({
  240. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  241. ... systemParams,
  242. ... textParams
  243. });
  244. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  245. } returns {
  246. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.pass.instance.update");
  247. if (@kernel.isCertMode()) {
  248. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  249. return @kernel.toRespModel(respMap);
  250. }
  251. } else {
  252. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  253. return @kernel.toRespModel(respMap);
  254. }
  255. }
  256. throw {
  257. message = '验签失败,请检查支付宝公钥设置是否正确。'
  258. }
  259. } runtime {
  260. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  261. httpProxy = @kernel.getConfig("httpProxy"),
  262. connectTimeout = 15000,
  263. readTimeout = 15000,
  264. retry = {
  265. maxAttempts = 0
  266. }
  267. }