918博天堂

Server : Microsoft-IIS/10.0
System : Windows NT EBS-6136 10.0 build 17763 (Windows Server 2016) i586
User : jxgj ( 0)
PHP Version : 7.0.33
Disable Function : passthru,exec,system,shell_exec,proc_open,popen,pcntl_exec,socket_bind,stream_socket_server
Directory :  D:/tmp_aspnet/root/cae6aa2e/15328683/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : D:/tmp_aspnet/root/cae6aa2e/15328683/App_Code.vywp5zcy.59.cs
?#pragma checksum "D:\wwwroot\anlian2025\wwwroot\App_Code\wxshaoma\Notify.cs" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3FE60C67F16D28D5385FD7F44060F4BE7786F617"

#line 1 "D:\wwwroot\anlian2025\wwwroot\App_Code\wxshaoma\Notify.cs"
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace WxPayAPI
{
    /// <summary>
    /// 回调处置基类
    /// 重要掌管接管微信支付后盾发送过来的数据,对数据进行署名验证
    /// 子类在此类基础上进行派生并沉写自己的回调处置过程
    /// </summary>
    public class Notify
    {
        public Page page {get;set;}
        public Notify(Page page)
        {
            this.page = page;
        }

        /// <summary>
        /// 接管从微信支付后盾发送过来的数据并验证署名
        /// </summary>
        /// <returns>微信支付后盾返回的数据</returns>
        public WxPayData GetNotifyData()
        {
            //接管从微信后盾POST过来的数据
            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()
        {

        }
    }
}

#line default
#line hidden