Client.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.Page.Models;
  10. namespace Alipay.EasySDK.Payment.Page
  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 AlipayTradePagePayResponse Pay(string subject, string outTradeNo, string totalAmount, string returnUrl)
  20. {
  21. Dictionary<string, string> systemParams = new Dictionary<string, string>
  22. {
  23. {"method", "alipay.trade.page.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. {"product_code", "FAST_INSTANT_TRADE_PAY"},
  40. };
  41. Dictionary<string, string> textParams = new Dictionary<string, string>
  42. {
  43. {"return_url", returnUrl},
  44. };
  45. string sign = this._kernel.Sign(systemParams, bizParams, textParams, this._kernel.GetConfig("merchantPrivateKey"));
  46. Dictionary<string, string> response = new Dictionary<string, string>
  47. {
  48. {"body", this._kernel.GeneratePage("POST", systemParams, bizParams, textParams, sign)},
  49. };
  50. return TeaModel.ToObject<AlipayTradePagePayResponse>(response);
  51. }
  52. /// <summary>
  53. /// ISV代商户代用,指定appAuthToken
  54. /// </summary>
  55. /// <param name="appAuthToken">代调用token</param>
  56. /// <returns>本客户端,便于链式调用</returns>
  57. public Client Agent(string appAuthToken)
  58. {
  59. _kernel.InjectTextParam("app_auth_token", appAuthToken);
  60. return this;
  61. }
  62. /// <summary>
  63. /// 用户授权调用,指定authToken
  64. /// </summary>
  65. /// <param name="authToken">用户授权token</param>
  66. /// <returns>本客户端,便于链式调用</returns>
  67. public Client Auth(string authToken)
  68. {
  69. _kernel.InjectTextParam("auth_token", authToken);
  70. return this;
  71. }
  72. /// <summary>
  73. /// 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
  74. /// </summary>
  75. /// <param name="url">异步通知回调地址,例如:https://www.test.com/callback </param>
  76. /// <returns>本客户端,便于链式调用</returns>
  77. public Client AsyncNotify(string url)
  78. {
  79. _kernel.InjectTextParam("notify_url", url);
  80. return this;
  81. }
  82. /// <summary>
  83. /// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
  84. /// </summary>
  85. /// <param name="testUrl">后端系统测试地址</param>
  86. /// <returns>本客户端,便于链式调用</returns>
  87. public Client Route(string testUrl)
  88. {
  89. _kernel.InjectTextParam("ws_service_url", testUrl);
  90. return this;
  91. }
  92. /// <summary>
  93. /// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
  94. /// </summary>
  95. /// <param name="key">业务请求参数名称(biz_content下的字段名,比如timeout_express)</param>
  96. /// <param name="value">
  97. /// 业务请求参数的值,一个可以序列化成JSON的对象
  98. /// 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用string储存
  99. /// 如果该字段是一个数值型类型(比如:Number),请使用long储存
  100. /// 如果该字段是一个复杂类型,请使用嵌套的Dictionary指定各下级字段的值
  101. /// 如果该字段是一个数组,请使用List储存各个值
  102. /// 对于更复杂的情况,也支持Dictionary和List的各种组合嵌套,比如参数是值是个List,List中的每种类型是一个复杂对象
  103. /// </param>
  104. /// <returns>本客户端,便于链式调用</returns>
  105. public Client Optional(string key, object value)
  106. {
  107. _kernel.InjectBizParam(key, value);
  108. return this;
  109. }
  110. /// <summary>
  111. /// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
  112. /// optional方法的批量版本
  113. /// </summary>
  114. /// <param name="optionalArgs">可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释</param>
  115. /// <returns>本客户端,便于链式调用</returns>
  116. public Client BatchOptional(Dictionary<string, object> optionalArgs)
  117. {
  118. foreach (var pair in optionalArgs)
  119. {
  120. _kernel.InjectBizParam(pair.Key, pair.Value);
  121. }
  122. return this;
  123. }
  124. }
  125. }