1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Text;
- namespace LYFZ.WxPayAPI
- {
-
-
-
-
-
- public class Notify
- {
- public Page page {get;set;}
- public Notify(Page page)
- {
- this.page = page;
- }
-
-
-
-
- public WxPayData GetNotifyData()
- {
-
- System.IO.Stream s = page.Request.InputStream;
- int count = 0;
- byte[] buffer = new byte[1024];
- StringBuilder builder = new StringBuilder();
- while ((count = s.Read(buffer, 0, 1024)) > 0)
- {
- builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
- }
- s.Flush();
- s.Close();
- s.Dispose();
- Log.Info(this.GetType().ToString(), "Receive data from WeChat : " + builder.ToString());
-
- WxPayData data = new WxPayData();
- try
- {
- data.FromXml(builder.ToString());
- }
- catch(WxPayException ex)
- {
-
- WxPayData res = new WxPayData();
- res.SetValue("return_code", "FAIL");
- res.SetValue("return_msg", ex.Message);
- Log.Error(this.GetType().ToString(), "Sign check error : " + res.ToXml());
- page.Response.Write(res.ToXml());
- page.Response.End();
- }
- Log.Info(this.GetType().ToString(), "Check sign success");
- return data;
- }
-
- public virtual void ProcessNotify()
- {
- }
- }
- }
|