main.tea 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import EasySDKKernel;
  2. type @kernel = EasySDKKernel
  3. init(kernel: EasySDKKernel) {
  4. @kernel = kernel;
  5. }
  6. model AlipayTradeWapPayResponse {
  7. body: string(name='body', description='订单信息,Form表单形式')
  8. }
  9. function pay(subject: string, outTradeNo: string, totalAmount: string, quitUrl: string, returnUrl: string): AlipayTradeWapPayResponse {
  10. var systemParams: map[string]string = {
  11. method = 'alipay.trade.wap.pay',
  12. app_id = @kernel.getConfig("appId"),
  13. timestamp = @kernel.getTimestamp(),
  14. format = 'json',
  15. version = '1.0',
  16. alipay_sdk = @kernel.getSdkVersion(),
  17. charset = 'UTF-8',
  18. sign_type = @kernel.getConfig("signType"),
  19. app_cert_sn = @kernel.getMerchantCertSN(),
  20. alipay_root_cert_sn = @kernel.getAlipayRootCertSN()
  21. };
  22. var bizParams: map[string]any = {
  23. subject = subject,
  24. out_trade_no = outTradeNo,
  25. total_amount = totalAmount,
  26. quit_url = quitUrl,
  27. product_code = 'QUICK_WAP_WAY'
  28. };
  29. var textParams: map[string]string = {
  30. return_url = returnUrl
  31. };
  32. var sign = @kernel.sign(systemParams, bizParams, textParams, @kernel.getConfig('merchantPrivateKey'));
  33. var response: map[string]string = {
  34. body = @kernel.generatePage('POST', systemParams, bizParams, textParams, sign)
  35. };
  36. return response;
  37. }