Client.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // This file is auto-generated, don't edit it. Thanks.
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Threading.Tasks;
  7. using Tea;
  8. using Tea.Utils;
  9. using Alipay.EasySDK.Payment.Wap.Models;
  10. namespace Alipay.EasySDK.Payment.Wap
  11. {
  12. public class Client
  13. {
  14. protected Alipay.EasySDK.Kernel.Client _kernel;
  15. public Client(Alipay.EasySDK.Kernel.Client kernel)
  16. {
  17. this._kernel = kernel;
  18. }
  19. public AlipayTradeWapPayResponse Pay(string subject, string outTradeNo, string totalAmount, string quitUrl, string returnUrl)
  20. {
  21. Dictionary<string, string> systemParams = new Dictionary<string, string>
  22. {
  23. {"method", "alipay.trade.wap.pay"},
  24. {"app_id", this._kernel.GetConfig("appId")},
  25. {"timestamp", this._kernel.GetTimestamp()},
  26. {"format", "json"},
  27. {"version", "1.0"},
  28. {"alipay_sdk", this._kernel.GetSdkVersion()},
  29. {"charset", "UTF-8"},
  30. {"sign_type", this._kernel.GetConfig("signType")},
  31. {"app_cert_sn", this._kernel.GetMerchantCertSN()},
  32. {"alipay_root_cert_sn", this._kernel.GetAlipayRootCertSN()},
  33. };
  34. Dictionary<string, object> bizParams = new Dictionary<string, object>
  35. {
  36. {"subject", subject},
  37. {"out_trade_no", outTradeNo},
  38. {"total_amount", totalAmount},
  39. {"quit_url", quitUrl},
  40. {"product_code", "QUICK_WAP_WAY"},
  41. };
  42. Dictionary<string, string> textParams = new Dictionary<string, string>
  43. {
  44. {"return_url", returnUrl},
  45. };
  46. string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
  47. Dictionary<string, string> response = new Dictionary<string, string>
  48. {
  49. {"body", this._kernel.GeneratePage("POST", systemParams, bizParams, textParams, sign)},
  50. };
  51. return TeaModel.ToObject<AlipayTradeWapPayResponse>(response);
  52. }
  53. /// <summary>
  54. /// ISV代商户代用,指定appAuthToken
  55. /// </summary>
  56. /// <param name="appAuthToken">代调用token</param>
  57. /// <returns>本客户端,便于链式调用</returns>
  58. public Client Agent(string appAuthToken)
  59. {
  60. _kernel.InjectTextParam("app_auth_token", appAuthToken);
  61. return this;
  62. }
  63. /// <summary>
  64. /// 用户授权调用,指定authToken
  65. /// </summary>
  66. /// <param name="authToken">用户授权token</param>
  67. /// <returns>本客户端,便于链式调用</returns>
  68. public Client Auth(string authToken)
  69. {
  70. _kernel.InjectTextParam("auth_token", authToken);
  71. return this;
  72. }
  73. /// <summary>
  74. /// 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
  75. /// </summary>
  76. /// <param name="url">异步通知回调地址,例如:https://www.test.com/callback </param>
  77. /// <returns>本客户端,便于链式调用</returns>
  78. public Client AsyncNotify(string url)
  79. {
  80. _kernel.InjectTextParam("notify_url", url);
  81. return this;
  82. }
  83. /// <summary>
  84. /// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
  85. /// </summary>
  86. /// <param name="testUrl">后端系统测试地址</param>
  87. /// <returns>本客户端,便于链式调用</returns>
  88. public Client Route(string testUrl)
  89. {
  90. _kernel.InjectTextParam("ws_service_url", testUrl);
  91. return this;
  92. }
  93. /// <summary>
  94. /// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
  95. /// </summary>
  96. /// <param name="key">业务请求参数名称(biz_content下的字段名,比如timeout_express)</param>
  97. /// <param name="value">
  98. /// 业务请求参数的值,一个可以序列化成JSON的对象
  99. /// 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用string储存
  100. /// 如果该字段是一个数值型类型(比如:Number),请使用long储存
  101. /// 如果该字段是一个复杂类型,请使用嵌套的Dictionary指定各下级字段的值
  102. /// 如果该字段是一个数组,请使用List储存各个值
  103. /// 对于更复杂的情况,也支持Dictionary和List的各种组合嵌套,比如参数是值是个List,List中的每种类型是一个复杂对象
  104. /// </param>
  105. /// <returns>本客户端,便于链式调用</returns>
  106. public Client Optional(string key, object value)
  107. {
  108. _kernel.InjectBizParam(key, value);
  109. return this;
  110. }
  111. /// <summary>
  112. /// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
  113. /// optional方法的批量版本
  114. /// </summary>
  115. /// <param name="optionalArgs">可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释</param>
  116. /// <returns>本客户端,便于链式调用</returns>
  117. public Client BatchOptional(Dictionary<string, object> optionalArgs)
  118. {
  119. foreach (var pair in optionalArgs)
  120. {
  121. _kernel.InjectBizParam(pair.Key, pair.Value);
  122. }
  123. return this;
  124. }
  125. }
  126. }