Esempio n. 1
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (!IsPostBack)
            {
                string     siteCode              = GetSiteCode();
                string     return_code           = string.Empty;
                string     return_msg            = string.Empty;
                WXJSAPIPay pay                   = new WXJSAPIPay(siteCode);
                Dictionary <string, string> dict = GetRequestPost();

                //ExceptionLog log = new ExceptionLog();
                //log.Message = dict.ToArray().ToString();
                //ExceptionLogDAL.InsertExceptionLog(log);

                if (pay.VerifyNotify(dict, dict["sign"]))
                {
                    return_code = "SUCCESS";
                    if (dict["return_code"] == "SUCCESS")
                    {
                        if (dict["result_code"] == "SUCCESS")
                        {
                            WXJSAPIPayNotifyInfo info = new WXJSAPIPayNotifyInfo();
                            if (dict.ContainsKey("openid"))
                            {
                                info.OpenId = dict["openid"];
                            }
                            if (dict.ContainsKey("total_fee"))
                            {
                                info.TotalFee = int.Parse(dict["total_fee"]);
                            }
                            //string trade_type = dict["trade_type"];
                            if (dict.ContainsKey("transaction_id"))
                            {
                                info.TransactionId = dict["transaction_id"];
                            }
                            if (dict.ContainsKey("out_trade_no"))
                            {
                                info.OutTradeNo = dict["out_trade_no"];
                            }
                            if (dict.ContainsKey("attach"))
                            {
                                info.Attach = dict["attach"];
                            }

                            if (!string.IsNullOrEmpty(info.OpenId) &&
                                info.TotalFee > 0 &&
                                !string.IsNullOrEmpty(info.TransactionId) &&
                                !string.IsNullOrEmpty(info.OutTradeNo))
                            {
                                OnPaySucceed(info);
                            }
                            else
                            {
                                return_code = "FAIL";
                                return_msg  = "参数格式校验错误";
                            }
                        }
                    }
                }
                else
                {
                    return_code = "FAIL";
                    return_msg  = "签名失败";
                }
                string returnValue = string.Format("<xml><return_code>{0}</return_code><return_msg>{1}</return_msg></xml>",
                                                   return_code, return_msg);
            }
        }
Esempio n. 2
0
        //public Action<WXJSAPIPayNotifyInfo> OnPaySucceed;

        public abstract void OnPaySucceed(WXJSAPIPayNotifyInfo info);