main.tea 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. import EasySDKKernel;
  2. type @kernel = EasySDKKernel
  3. init(kernel: EasySDKKernel) {
  4. @kernel = kernel;
  5. }
  6. model RefundRoyaltyResult{
  7. refundAmount: string(name='refund_amount'),
  8. royaltyType: string(name='royalty_type'),
  9. resultCode: string(name='result_code'),
  10. transOut: string(name='trans_out'),
  11. transOutEmail: string(name='trans_out_email'),
  12. transIn: string(name='trans_in'),
  13. transInEmail: string(name='trans_in_email'),
  14. }
  15. model TradeFundBill {
  16. fundChannel: string(name='fund_channel'),
  17. bankCode: string(name='bank_code'),
  18. amount: string(name='amount'),
  19. realAmount: string(name='real_amount'),
  20. fundType: string(name='fund_type')
  21. }
  22. model TradeSettleDetail {
  23. operationType: string(name='operation_type'),
  24. operationSerial_no: string(name='operation_serial_no'),
  25. operationDt: string(name='operation_dt'),
  26. transOut: string(name='trans_out'),
  27. transIn: string(name='trans_in'),
  28. amount: string(name='amount')
  29. }
  30. model TradeSettleInfo {
  31. tradeSettleDetailList: [ TradeSettleDetail ](name='trade_settle_detail_list')
  32. }
  33. model PresetPayToolInfo {
  34. amount: [ string ](name='amount'),
  35. assertTypeCode: string(name='assert_type_code')
  36. }
  37. model AlipayTradeCreateResponse {
  38. httpBody: string(name='http_body', description='响应原始字符串'),
  39. code: string(name='code'),
  40. msg: string(name='msg'),
  41. subCode: string(name='sub_code'),
  42. subMsg: string(name='sub_msg'),
  43. outTradeNo: string(name='out_trade_no'),
  44. tradeNo: string(name='trade_no')
  45. }
  46. model AlipayTradeQueryResponse {
  47. httpBody: string(name='http_body', description='响应原始字符串'),
  48. code: string(name='code'),
  49. msg: string(name='msg'),
  50. subCode: string(name='sub_code'),
  51. subMsg: string(name='sub_msg'),
  52. tradeNo: string(name='trade_no'),
  53. outTradeNo: string(name='out_trade_no'),
  54. buyerLogonId: string(name='buyer_logon_id'),
  55. tradeStatus: string(name='trade_status'),
  56. totalAmount: string(name='total_amount'),
  57. transCurrency: string(name='trans_currency'),
  58. settleCurrency: string(name='settle_currency'),
  59. settleAmount: string(name='settle_amount'),
  60. payCurrency: string(name='pay_currency'),
  61. payAmount: string(name='pay_amount'),
  62. settleTransRate: string(name='settle_trans_rate'),
  63. transPayRate: string(name='trans_pay_rate'),
  64. buyerPayAmount: string(name='buyer_pay_amount'),
  65. pointAmount: string(name='point_amount'),
  66. invoiceAmount: string(name='invoice_amount'),
  67. sendPayDate: string(name='send_pay_date'),
  68. receiptAmount: string(name='receipt_amount'),
  69. storeId: string(name='store_id'),
  70. terminalId: string(name='terminal_id'),
  71. fundBillList: [ TradeFundBill ](name='fund_bill_list'),
  72. storeName: string(name='store_name'),
  73. buyerUserId: string(name='buyer_user_id'),
  74. chargeAmount: string(name='charge_amount'),
  75. chargeFlags: string(name='charge_flags'),
  76. settlementId: string(name='settlement_id'),
  77. tradeSettleInfo: [ TradeSettleInfo ](name='trade_settle_info'),
  78. authTradePayMode: string(name='auth_trade_pay_mode'),
  79. buyerUserType: string(name='buyer_user_type'),
  80. mdiscountAmount: string(name='mdiscount_amount'),
  81. discountAmount: string(name='discount_amount'),
  82. buyerUserName: string(name='buyer_user_name'),
  83. subject: string(name='subject'),
  84. body: string(name='body'),
  85. alipaySubMerchantId: string(name='alipay_sub_merchant_id'),
  86. extInfos: string(name='ext_infos')
  87. }
  88. model AlipayTradeRefundResponse {
  89. httpBody: string(name='http_body', description='响应原始字符串'),
  90. code: string(name='code'),
  91. msg: string(name='msg'),
  92. subCode: string(name='sub_code'),
  93. subMsg: string(name='sub_msg'),
  94. tradeNo: string(name='trade_no'),
  95. outTradeNo: string(name='out_trade_no'),
  96. buyerLogonId: string(name='buyer_logon_id'),
  97. fundChange: string(name='fund_change'),
  98. refundFee: string(name='refund_fee'),
  99. refundCurrency: string(name='refund_currency'),
  100. gmtRefundPay: string(name='gmt_refund_pay'),
  101. refundDetailItemList: [ TradeFundBill ](name='refund_detail_item_list'),
  102. storeName: string(name='store_name'),
  103. buyerUserId: string(name='buyer_user_id'),
  104. refundPresetPaytoolList: [ PresetPayToolInfo ](name='refund_preset_paytool_list'),
  105. refundSettlementId: string(name='refund_settlement_id'),
  106. presentRefundBuyerAmount: string(name='present_refund_buyer_amount'),
  107. presentRefundDiscountAmount: string(name='present_refund_discount_amount'),
  108. presentRefundMdiscountAmount: string(name='present_refund_mdiscount_amount'),
  109. }
  110. model AlipayTradeCloseResponse {
  111. httpBody: string(name='http_body', description='响应原始字符串'),
  112. code: string(name='code'),
  113. msg: string(name='msg'),
  114. subCode: string(name='sub_code'),
  115. subMsg: string(name='sub_msg'),
  116. tradeNo: string(name='trade_no'),
  117. outTradeNo: string(name='out_trade_no')
  118. }
  119. model AlipayTradeCancelResponse {
  120. httpBody: string(name='http_body', description='响应原始字符串'),
  121. code: string(name='code'),
  122. msg: string(name='msg'),
  123. subCode: string(name='sub_code'),
  124. subMsg: string(name='sub_msg'),
  125. tradeNo: string(name='trade_no'),
  126. outTradeNo: string(name='out_trade_no'),
  127. retryFlag: string(name='retry_flag'),
  128. action: string(name='action'),
  129. gmtRefundPay: string(name='gmt_refund_pay'),
  130. refundSettlementId: string(name='refund_settlement_id')
  131. }
  132. model AlipayTradeFastpayRefundQueryResponse {
  133. httpBody: string(name='http_body', description='响应原始字符串'),
  134. code: string(name='code'),
  135. msg: string(name='msg'),
  136. subCode: string(name='sub_code'),
  137. subMsg: string(name='sub_msg'),
  138. errorCode: string(name='error_code'),
  139. gmtRefundPay: string(name='gmt_refund_pay'),
  140. industrySepcDetail: string(name='industry_sepc_detail'),
  141. outRequestNo: string(name='out_request_no'),
  142. outTradeNo: string(name='out_trade_no'),
  143. presentRefundBuyerAmount: string(name='present_refund_buyer_amount'),
  144. presentRefundDiscountAmount: string(name='present_refund_discount_amount'),
  145. presentRefundMdiscountAmount: string(name='present_refund_mdiscount_amount'),
  146. refundAmount: string(name='refund_amount'),
  147. refundChargeAmount: string(name='refund_charge_amount'),
  148. refundDetailItemList: [ TradeFundBill ](name='refund_detail_item_list'),
  149. refundReason: string(name='refund_reason'),
  150. refundRoyaltys: [ RefundRoyaltyResult ](name='refund_royaltys'),
  151. refundSettlementId: string(name='refund_settlement_id'),
  152. refundStatus: string(name='refund_status'),
  153. sendBackFee: string(name='send_back_fee'),
  154. totalAmount: string(name='total_amount'),
  155. tradeNo: string(name='trade_no')
  156. }
  157. model AlipayDataDataserviceBillDownloadurlQueryResponse{
  158. httpBody: string(name='http_body', description='响应原始字符串'),
  159. code: string(name='code'),
  160. msg: string(name='msg'),
  161. subCode: string(name='sub_code'),
  162. subMsg: string(name='sub_msg'),
  163. billDownloadUrl: string(name='bill_download_url'),
  164. }
  165. api create(subject: string, outTradeNo: string, totalAmount: string, buyerId: string): AlipayTradeCreateResponse {
  166. var systemParams: map[string]string = {
  167. method = 'alipay.trade.create',
  168. app_id = @kernel.getConfig("appId"),
  169. timestamp = @kernel.getTimestamp(),
  170. format = 'json',
  171. version = '1.0',
  172. alipay_sdk = @kernel.getSdkVersion(),
  173. charset = 'UTF-8',
  174. sign_type = @kernel.getConfig("signType"),
  175. app_cert_sn = @kernel.getMerchantCertSN(),
  176. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  177. };
  178. var bizParams: map[string]any = {
  179. subject = subject,
  180. out_trade_no = outTradeNo,
  181. total_amount = totalAmount,
  182. buyer_id = buyerId
  183. };
  184. var textParams: map[string]string = {
  185. };
  186. __request.protocol = @kernel.getConfig("protocol");
  187. __request.method = 'POST';
  188. __request.pathname = '/gateway.do';
  189. __request.headers = {
  190. host = @kernel.getConfig("gatewayHost"),
  191. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  192. };
  193. __request.query = @kernel.sortMap({
  194. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  195. ... systemParams,
  196. ... textParams
  197. });
  198. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  199. } returns {
  200. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.trade.create");
  201. if (@kernel.isCertMode()) {
  202. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  203. return @kernel.toRespModel(respMap);
  204. }
  205. } else {
  206. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  207. return @kernel.toRespModel(respMap);
  208. }
  209. }
  210. throw {
  211. message = '验签失败,请检查支付宝公钥设置是否正确。'
  212. }
  213. } runtime {
  214. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  215. httpProxy = @kernel.getConfig("httpProxy"),
  216. connectTimeout = 15000,
  217. readTimeout = 15000,
  218. retry = {
  219. maxAttempts = 0
  220. }
  221. }
  222. api query(outTradeNo: string): AlipayTradeQueryResponse {
  223. var systemParams: map[string]string = {
  224. method = 'alipay.trade.query',
  225. app_id = @kernel.getConfig("appId"),
  226. timestamp = @kernel.getTimestamp(),
  227. format = 'json',
  228. version = '1.0',
  229. alipay_sdk = @kernel.getSdkVersion(),
  230. charset = 'UTF-8',
  231. sign_type = @kernel.getConfig("signType"),
  232. app_cert_sn = @kernel.getMerchantCertSN(),
  233. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  234. };
  235. var bizParams: map[string]any = {
  236. out_trade_no = outTradeNo
  237. };
  238. var textParams: map[string]string = {
  239. };
  240. __request.protocol = @kernel.getConfig("protocol");
  241. __request.method = 'POST';
  242. __request.pathname = '/gateway.do';
  243. __request.headers = {
  244. host = @kernel.getConfig("gatewayHost"),
  245. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  246. };
  247. __request.query = @kernel.sortMap({
  248. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  249. ... systemParams,
  250. ... textParams
  251. });
  252. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  253. } returns {
  254. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.trade.query");
  255. if (@kernel.isCertMode()) {
  256. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  257. return @kernel.toRespModel(respMap);
  258. }
  259. } else {
  260. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  261. return @kernel.toRespModel(respMap);
  262. }
  263. }
  264. throw {
  265. message = '验签失败,请检查支付宝公钥设置是否正确。'
  266. }
  267. } runtime {
  268. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  269. httpProxy = @kernel.getConfig("httpProxy"),
  270. connectTimeout = 15000,
  271. readTimeout = 15000,
  272. retry = {
  273. maxAttempts = 0
  274. }
  275. }
  276. api refund(outTradeNo: string, refundAmount: string): AlipayTradeRefundResponse {
  277. var systemParams: map[string]string = {
  278. method = 'alipay.trade.refund',
  279. app_id = @kernel.getConfig("appId"),
  280. timestamp = @kernel.getTimestamp(),
  281. format = 'json',
  282. version = '1.0',
  283. alipay_sdk = @kernel.getSdkVersion(),
  284. charset = 'UTF-8',
  285. sign_type = @kernel.getConfig("signType"),
  286. app_cert_sn = @kernel.getMerchantCertSN(),
  287. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  288. };
  289. var bizParams: map[string]any = {
  290. out_trade_no = outTradeNo,
  291. refund_amount = refundAmount
  292. };
  293. var textParams: map[string]string = {
  294. };
  295. __request.protocol = @kernel.getConfig("protocol");
  296. __request.method = 'POST';
  297. __request.pathname = '/gateway.do';
  298. __request.headers = {
  299. host = @kernel.getConfig("gatewayHost"),
  300. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  301. };
  302. __request.query = @kernel.sortMap({
  303. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  304. ... systemParams,
  305. ... textParams
  306. });
  307. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  308. } returns {
  309. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.trade.refund");
  310. if (@kernel.isCertMode()) {
  311. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  312. return @kernel.toRespModel(respMap);
  313. }
  314. } else {
  315. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  316. return @kernel.toRespModel(respMap);
  317. }
  318. }
  319. throw {
  320. message = '验签失败,请检查支付宝公钥设置是否正确。'
  321. }
  322. } runtime {
  323. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  324. httpProxy = @kernel.getConfig("httpProxy"),
  325. connectTimeout = 15000,
  326. readTimeout = 15000,
  327. retry = {
  328. maxAttempts = 0
  329. }
  330. }
  331. api close(outTradeNo: string): AlipayTradeCloseResponse {
  332. var systemParams: map[string]string = {
  333. method = 'alipay.trade.close',
  334. app_id = @kernel.getConfig("appId"),
  335. timestamp = @kernel.getTimestamp(),
  336. format = 'json',
  337. version = '1.0',
  338. alipay_sdk = @kernel.getSdkVersion(),
  339. charset = 'UTF-8',
  340. sign_type = @kernel.getConfig("signType"),
  341. app_cert_sn = @kernel.getMerchantCertSN(),
  342. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  343. };
  344. var bizParams: map[string]any = {
  345. out_trade_no = outTradeNo
  346. };
  347. var textParams: map[string]string = {
  348. };
  349. __request.protocol = @kernel.getConfig("protocol");
  350. __request.method = 'POST';
  351. __request.pathname = '/gateway.do';
  352. __request.headers = {
  353. host = @kernel.getConfig("gatewayHost"),
  354. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  355. };
  356. __request.query = @kernel.sortMap({
  357. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  358. ... systemParams,
  359. ... textParams
  360. });
  361. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  362. } returns {
  363. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.trade.close");
  364. if (@kernel.isCertMode()) {
  365. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  366. return @kernel.toRespModel(respMap);
  367. }
  368. } else {
  369. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  370. return @kernel.toRespModel(respMap);
  371. }
  372. }
  373. throw {
  374. message = '验签失败,请检查支付宝公钥设置是否正确。'
  375. }
  376. } runtime {
  377. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  378. httpProxy = @kernel.getConfig("httpProxy"),
  379. connectTimeout = 15000,
  380. readTimeout = 15000,
  381. retry = {
  382. maxAttempts = 0
  383. }
  384. }
  385. api cancel(outTradeNo: string): AlipayTradeCancelResponse {
  386. var systemParams: map[string]string = {
  387. method = 'alipay.trade.cancel',
  388. app_id = @kernel.getConfig("appId"),
  389. timestamp = @kernel.getTimestamp(),
  390. format = 'json',
  391. version = '1.0',
  392. alipay_sdk = @kernel.getSdkVersion(),
  393. charset = 'UTF-8',
  394. sign_type = @kernel.getConfig("signType"),
  395. app_cert_sn = @kernel.getMerchantCertSN(),
  396. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  397. };
  398. var bizParams: map[string]any = {
  399. out_trade_no = outTradeNo
  400. };
  401. var textParams: map[string]string = {
  402. };
  403. __request.protocol = @kernel.getConfig("protocol");
  404. __request.method = 'POST';
  405. __request.pathname = '/gateway.do';
  406. __request.headers = {
  407. host = @kernel.getConfig("gatewayHost"),
  408. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  409. };
  410. __request.query = @kernel.sortMap({
  411. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  412. ... systemParams,
  413. ... textParams
  414. });
  415. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  416. } returns {
  417. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.trade.cancel");
  418. if (@kernel.isCertMode()) {
  419. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  420. return @kernel.toRespModel(respMap);
  421. }
  422. } else {
  423. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  424. return @kernel.toRespModel(respMap);
  425. }
  426. }
  427. throw {
  428. message = '验签失败,请检查支付宝公钥设置是否正确。'
  429. }
  430. } runtime {
  431. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  432. httpProxy = @kernel.getConfig("httpProxy"),
  433. connectTimeout = 15000,
  434. readTimeout = 15000,
  435. retry = {
  436. maxAttempts = 0
  437. }
  438. }
  439. api queryRefund(outTradeNo: string, outRequestNo: string): AlipayTradeFastpayRefundQueryResponse {
  440. var systemParams: map[string]string = {
  441. method = 'alipay.trade.fastpay.refund.query',
  442. app_id = @kernel.getConfig("appId"),
  443. timestamp = @kernel.getTimestamp(),
  444. format = 'json',
  445. version = '1.0',
  446. alipay_sdk = @kernel.getSdkVersion(),
  447. charset = 'UTF-8',
  448. sign_type = @kernel.getConfig("signType"),
  449. app_cert_sn = @kernel.getMerchantCertSN(),
  450. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  451. };
  452. var bizParams: map[string]any = {
  453. out_trade_no = outTradeNo,
  454. out_request_no = outRequestNo
  455. };
  456. var textParams: map[string]string = {
  457. };
  458. __request.protocol = @kernel.getConfig("protocol");
  459. __request.method = 'POST';
  460. __request.pathname = '/gateway.do';
  461. __request.headers = {
  462. host = @kernel.getConfig("gatewayHost"),
  463. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  464. };
  465. __request.query = @kernel.sortMap({
  466. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  467. ... systemParams,
  468. ... textParams
  469. });
  470. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  471. } returns {
  472. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.trade.fastpay.refund.query");
  473. if (@kernel.isCertMode()) {
  474. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  475. return @kernel.toRespModel(respMap);
  476. }
  477. } else {
  478. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  479. return @kernel.toRespModel(respMap);
  480. }
  481. }
  482. throw {
  483. message = '验签失败,请检查支付宝公钥设置是否正确。'
  484. }
  485. } runtime {
  486. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  487. httpProxy = @kernel.getConfig("httpProxy"),
  488. connectTimeout = 15000,
  489. readTimeout = 15000,
  490. retry = {
  491. maxAttempts = 0
  492. }
  493. }
  494. api downloadBill(billType: string, billDate: string): AlipayDataDataserviceBillDownloadurlQueryResponse {
  495. var systemParams: map[string]string = {
  496. method = 'alipay.data.dataservice.bill.downloadurl.query',
  497. app_id = @kernel.getConfig("appId"),
  498. timestamp = @kernel.getTimestamp(),
  499. format = 'json',
  500. version = '1.0',
  501. alipay_sdk = @kernel.getSdkVersion(),
  502. charset = 'UTF-8',
  503. sign_type = @kernel.getConfig("signType"),
  504. app_cert_sn = @kernel.getMerchantCertSN(),
  505. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  506. };
  507. var bizParams: map[string]any = {
  508. bill_type = billType,
  509. bill_date = billDate
  510. };
  511. var textParams: map[string]string = {
  512. };
  513. __request.protocol = @kernel.getConfig("protocol");
  514. __request.method = 'POST';
  515. __request.pathname = '/gateway.do';
  516. __request.headers = {
  517. host = @kernel.getConfig("gatewayHost"),
  518. content-type = 'application/x-www-form-urlencoded;charset=utf-8'
  519. };
  520. __request.query = @kernel.sortMap({
  521. sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig("merchantPrivateKey")),
  522. ... systemParams,
  523. ... textParams
  524. });
  525. __request.body = @kernel.toUrlEncodedRequestBody(bizParams);
  526. } returns {
  527. var respMap: map[string]any = @kernel.readAsJson(__response, "alipay.data.dataservice.bill.downloadurl.query");
  528. if (@kernel.isCertMode()) {
  529. if (@kernel.verify(respMap, @kernel.extractAlipayPublicKey(@kernel.getAlipayCertSN(respMap)))) {
  530. return @kernel.toRespModel(respMap);
  531. }
  532. } else {
  533. if (@kernel.verify(respMap, @kernel.getConfig("alipayPublicKey"))) {
  534. return @kernel.toRespModel(respMap);
  535. }
  536. }
  537. throw {
  538. message = '验签失败,请检查支付宝公钥设置是否正确。'
  539. }
  540. } runtime {
  541. ignoreSSL = @kernel.getConfig("ignoreSSL"),
  542. httpProxy = @kernel.getConfig("httpProxy"),
  543. connectTimeout = 15000,
  544. readTimeout = 15000,
  545. retry = {
  546. maxAttempts = 0
  547. }
  548. }
  549. function verifyNotify(parameters: map[string]string): boolean {
  550. if (@kernel.isCertMode()) {
  551. return @kernel.verifyParams(parameters, @kernel.extractAlipayPublicKey(''));
  552. } else {
  553. return @kernel.verifyParams(parameters, @kernel.getConfig('alipayPublicKey'));
  554. }
  555. }