PaymentService.aspx.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. namespace LYFZ.WeixinServers.PaymentService
  8. {
  9. public partial class PaymentService : System.Web.UI.Page
  10. {
  11. string desKey = "Ivz0IC3k";
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. if (!this.IsPostBack)
  15. {
  16. if (this.Request.QueryString["type"] != null)
  17. {
  18. string type = this.Request.QueryString["type"].ToString();
  19. string path = Server.MapPath("/") + "/Payment/pay.txt";
  20. if (System.IO.File.Exists(path))
  21. {
  22. Newtonsoft.Json.Linq.JObject jobject = ( Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(System.IO.File.ReadAllText(path));
  23. if (type == "wx")
  24. {
  25. Newtonsoft.Json.Linq.JObject wxObject = (Newtonsoft.Json.Linq.JObject)jobject.GetValue("wx");
  26. var wxData = new
  27. {
  28. businessNumber = LYFZ.WinAPI.SDKSecurity.DESEncrypt(wxObject.GetValue("MchID").ToString(), desKey),
  29. appid = LYFZ.WinAPI.SDKSecurity.DESEncrypt(wxObject.GetValue("AppID").ToString(), desKey),
  30. key = LYFZ.WinAPI.SDKSecurity.DESEncrypt(wxObject.GetValue("Key").ToString(), desKey)
  31. };
  32. this.Response.Write(ReturnData(-1, "成功", wxData));
  33. }
  34. else if (type == "zfb")
  35. {
  36. Newtonsoft.Json.Linq.JObject zfbObject = (Newtonsoft.Json.Linq.JObject)jobject.GetValue("zfb");
  37. var zfbData = new
  38. {
  39. CompanyPid = LYFZ.WinAPI.SDKSecurity.DESEncrypt(zfbObject.GetValue("MchID").ToString(), desKey)
  40. };
  41. this.Response.Write(ReturnData(-1, "成功", zfbData));
  42. }
  43. else
  44. {
  45. this.Response.Write(ReturnData(-1, "没有找到你请求的数据"));
  46. }
  47. }
  48. else
  49. {
  50. if (type == "wx")
  51. {
  52. var wxData = new
  53. {
  54. businessNumber = LYFZ.WinAPI.SDKSecurity.DESEncrypt("1454966002", desKey),
  55. appid = LYFZ.WinAPI.SDKSecurity.DESEncrypt("wxe30d2c612847beeb", desKey),
  56. key = LYFZ.WinAPI.SDKSecurity.DESEncrypt("wcx420222fdsf7fdsf837f6d484fsghh", desKey)
  57. };
  58. this.Response.Write(ReturnData(-1, "成功", wxData));
  59. }
  60. else if (type == "zfb")
  61. {
  62. var zfbData = new
  63. {
  64. CompanyPid = LYFZ.WinAPI.SDKSecurity.DESEncrypt("2088621649564405", desKey)
  65. };
  66. this.Response.Write(ReturnData(-1, "成功", zfbData));
  67. }
  68. else
  69. {
  70. this.Response.Write(ReturnData(-1, "没有找到你请求的数据"));
  71. }
  72. }
  73. }
  74. else {
  75. this.Response.Write(ReturnData(-1,"参数不正确"));
  76. }
  77. }
  78. }
  79. public string ReturnData(int code,string msg, object data=null)
  80. {
  81. var retData = new {
  82. code=code,
  83. msg=msg,
  84. data=data
  85. };
  86. return Newtonsoft.Json.JsonConvert.SerializeObject(retData);
  87. }
  88. }
  89. }