Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Log.Info(this.GetType().ToString(), "进入回调页面.....");
            ResultNotify resultNotify = new ResultNotify(this);

            resultNotify.ProcessNotify();
        }
Example #2
0
        public void WeiXinNotify()
        {
            ResultNotify resultNotify = new ResultNotify();
            WxPayData    notifyData   = resultNotify.GetNotifyData();

            LogUtil.Log("微信支付返回接口接收:", notifyData.ToXml());
            if (notifyData.GetValue("return_code") != null && (notifyData.GetValue("return_code").ToString() == "SUCCESS") && notifyData.GetValue("out_trade_no") != null && notifyData.GetValue("transaction_id") != null)
            {
                string           paycode   = notifyData.GetValue("out_trade_no").ToString();
                decimal          fee       = StringUtils.GetDbDecimal(notifyData.GetValue("total_fee")) / 100;
                VWPayOrderEntity payentity = PayOrderBLL.Instance.GetVWPayOrderByPayCode(paycode);
                if (payentity.Id > 0 && payentity.Status == 0)//未支付完成
                {
                    payentity.PayTime      = DateTime.Now;
                    payentity.PayPrice     = fee;
                    payentity.ExternalCode = notifyData.GetValue("transaction_id").ToString();
                    payentity.Status       = 1;
                    //先更新业务网站收款记录
                    if (payentity.SysType == (int)SystemType.B2B || payentity.SysType == (int)SystemType.B2BMobile)
                    {
                        VWOrderEntity _order = OrderBLL.Instance.GetVWOrderByCode(StringUtils.GetDbLong(payentity.SysOrderCode));
                        if (_order.Status == (int)OrderStatus.WaitPay)
                        {
                            if (OrderBLL.Instance.PayFinishedForOrder(StringUtils.GetDbLong(payentity.SysOrderCode), fee) > 0)
                            {
                                ///业务网站状态更新后更新支付总表
                                PayOrderBLL.Instance.RecivedPaySuccess(payentity);
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        public void PayCallBack()
        {
            System.Web.UI.Page page         = new System.Web.UI.Page();
            ResultNotify       resultNotify = new ResultNotify(page);

            resultNotify.ProcessNotify();
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LogHelper.Write("支付中:---------");
            ResultNotify resultNotify = new ResultNotify(this);

            resultNotify.ProcessNotify();
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ResultNotify resultNotify = new ResultNotify(this);

            //扫码回调调用没有参数的
            resultNotify.ProcessNotify();
        }
Example #6
0
        /// <summary>
        /// 支付成功后的回调函数
        /// </summary>
        /// <returns></returns>
        public ActionResult ResultNotify()
        {
            ResultNotify resultNotify = new ResultNotify(Request.InputStream);

            resultNotify.ProcessNotify();

            return(View());
        }
Example #7
0
        public string ProcessNotify(Stream IntpuStream, out WxPayData notifyData)
        {
            var notifyProcessor = new ResultNotify();
            //WxPayData notifyData;
            var responseStr = notifyProcessor.ProcessNotify(IntpuStream, out notifyData);

            return(responseStr);
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            log.Info("==========微信异步回调开始===============");
            ResultNotify resultNotify = new ResultNotify(this);

            resultNotify.ProcessNotify();


            log.Info("==========微信异步回调结束===============");
        }
Example #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         ResultNotify resultNotify = new ResultNotify(this);
         resultNotify.ProcessNotify();
     }
     catch (Exception ex)
     {
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        string orderUUID = Request["OrderUUID"];

        WCFClient.LoggerService.Info("微信回调成功(OrderUUID):" + (string.IsNullOrWhiteSpace(orderUUID) ? string.Empty : orderUUID));

        lock (LockObject.Instance)
        {
            ResultNotify resultNotify = new ResultNotify(this);
            resultNotify.ProcessNotify();
        }
    }
Example #11
0
 /// <summary>
 /// 微信官网通知接口
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         ResultNotify resultNotify = new ResultNotify(this);
         int          pid          = int.Parse(Request.QueryString["pid"].ToString());
         resultNotify.ProcessNotify(pid);
     }
     catch (Exception ex)
     {
         Response.Write("非法访问");
     }
 }
Example #12
0
 /// <summary>
 /// JsApi微信回调
 /// </summary>
 public static void Notify(Action <NotifyModel> action)
 {
     try
     {
         Log.Info("Notify", "微信Notify被回调");
         var          context      = System.Web.HttpContext.Current;
         ResultNotify resultNotify = new ResultNotify(context);
         resultNotify.ProcessNotify(action);
     }
     catch (Exception ex)
     {
         Log.Error("Error", ex.Message);
     }
 }
Example #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PayConfig    payConfig      = new PayConfig();
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            payConfig.AppId            = masterSettings.WeixinAppId;
            payConfig.AppSecret        = masterSettings.WeixinAppSecret;
            payConfig.Key              = masterSettings.WeixinPartnerKey;
            payConfig.MchID            = masterSettings.WeixinPartnerID;
            payConfig.SSLCERT_PATH     = masterSettings.WeixinCertPath;
            payConfig.SSLCERT_PASSWORD = masterSettings.WeixinCertPassword;
            ResultNotify resultNotify = new ResultNotify(this.Page, payConfig);

            resultNotify.ProcessNotify();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     lock (this)
     {
         //try
         //{
         Log.Debug(this.GetType().ToString(), "--进入回调--");
         ResultNotify resultNotify = new ResultNotify(this);
         resultNotify.ProcessNotify();
         //}
         //catch(Exception ex)
         //{
         //    Log.Error(this.GetType().ToString(),ex.Message);
         //}
     }
 }
Example #15
0
        public PayOrder CompletePayOrderAndReback(HttpContext httpContext, out string successStr)
        {
            ResultNotify resultNotify = new ResultNotify(httpContext);
            WxPayData    WxPayData    = resultNotify.ProcessNotify();
            PayOrder     payOrder     = null;

            successStr = "";
            if (WxPayData != null)
            {
                payOrder = CompletePayOrder(WxPayData);
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "SUCCESS");
                res.SetValue("return_msg", "OK");
                // httpContext.Response.WriteAsync();
                successStr = res.ToXml();
            }
            return(payOrder);
        }
Example #16
0
        // GET: Payover
        public ActionResult Index()
        {
            Log.Debug("收到通知:", "收到通知");
            //微信会把付款结果通知到这里
            ResultNotify resultNotify = new ResultNotify(System.Web.HttpContext.Current);
            WxPayData    notifyData   = resultNotify.GetNotifyData();
            //序列化  notifyData
            NotifyModel notify = new NotifyModel();

            notify = JSONHelper.JsonDeserialize <NotifyModel>(notifyData.ToJson());

            //////////这个必须给微信的通知回复收到信息,不然微信会一直发8次 ///////
            WxPayData res = new WxPayData();

            res.SetValue("return_code", "SUCCESS");
            res.SetValue("return_msg", "OK");
            HttpContext.Response.Clear();
            HttpContext.Response.Write(res.ToXml());
            HttpContext.Response.End();
            //////////回复结束//////////////
            Log.Debug("通知结束:", "通知结束");

            if (notify.result_code == "SUCCESS" && notify.return_code == "SUCCESS" && !string.IsNullOrEmpty(notify.out_trade_no) && !string.IsNullOrEmpty(notify.transaction_id))
            {
                //根据后台的充值记录
                // Log.Debug("微信支付结果通知:", "序列化后的openid:" + notify.openid);
                //Log.Debug("微信支付结果通知:", "序列化后的total_fee(该字段返回来的单位是分):" + notify.total_fee);
                //Log.Debug("微信支付结果通知:", "序列化后的out_trade_no:" + notify.out_trade_no);
                //Log.Debug("微信支付结果通知:", "序列化后的transaction_id:" + notify.transaction_id);
                //Log.Debug("微信支付结果通知:", "序列化后的notifyData:" + notifyData.ToJson());

                //OverAddFee(out_trade_no,openid) openid?
                //填写记录
                //using (var balancebLL = new BalanceBLL())
                //{
                //    balancebLL.PayOk(notify.out_trade_no).ConfigureAwait(true);
                //}
            }


            return(View());
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ResultNotify resultNotify = new ResultNotify(this);
        WxPayData    res          = resultNotify.ProcessNotify2();

        if (res.GetValue("return_code").ToString() == "SUCCESS")
        {
            //查询微信订单信息
            string paySignKey = ConfigurationManager.AppSettings["paySignKey"].ToString();
            string mch_id     = ConfigurationManager.AppSettings["mch_id"].ToString();
            string appId      = ConfigurationManager.AppSettings["AppId"].ToString();
            Response.Write(res.ToXml());
            Response.End();
            Server.Transfer("Printui.aspx");
        }


        Response.Write(res.ToXml());
        Response.End();
    }
Example #18
0
        /// <summary>微信支付异步回调
        /// </summary>
        /// <param name="successAction">支付成功委托</param>
        /// <returns></returns>
        public ContentResult NotifyResult(Action <PaymentSuccess> successAction)
        {
            WxPayData resultPayData = new ResultNotify(_context, _appConfig).ProcessNotify();

            if (resultPayData.GetValue("return_code").ToStr() == "SUCCESS")
            {
                PaymentSuccess success = new PaymentSuccess
                {
                    Attach        = resultPayData.GetValue("attach").ToStr(),
                    OrderNum      = resultPayData.GetValue("out_trade_no").ToStr(),
                    TransactionId = resultPayData.GetValue("transaction_id").ToStr(),
                    TotalFee      = resultPayData.GetValue("total_fee").ToInt(),
                    IsSubscribe   = resultPayData.GetValue("is_subscribe").ToBoolean(),
                    Openid        = resultPayData.GetValue("openid").ToStr()
                };

                successAction.Invoke(success);
            }

            return(new ContentResult
            {
                Content = resultPayData.ToXml()
            });
        }
        /// <summary>
        /// 支付结果回调地址
        /// </summary>
        /// <returns></returns>
        public string PayNotifyUrl()
        {
            WxPayData resultInfo = new WxPayData();

            try
            {
                ResultNotify resultNotify       = new ResultNotify();
                WxPayData    notifyData         = resultNotify.GetNotifyData(); //获取微信返回的数据
                string       accessToken        = WeChatTools.GetAccessoken();
                var          userInfoStr        = WeChatTools.ConvertToUserIdByOpenid(accessToken, notifyData.GetValue("openid").ToString());
                var          userInfo           = Common.JsonHelper.JsonToModel <U_WechatUserInfo>(userInfoStr);
                var          userid             = userInfo.userid;
                var          personInfoModel    = _wl.GetUserInfo(userid);   //获取人员表信息
                var          paymentHistoryInfo = new Business_PaymentHistory_Information();
                paymentHistoryInfo.PaymentPersonnel = personInfoModel.Vguid; //付款人vguid
                _weChatRevenueLogic.UpdatePaymentHistory(personInfoModel, paymentHistoryInfo, notifyData);

                if (notifyData.GetValue("return_code").ToString() == "SUCCESS" && notifyData.GetValue("result_code").ToString() == "SUCCESS")
                {
                    resultInfo.SetValue("return_code", "SUCCESS");
                    resultInfo.SetValue("return_msg", "OK");
                }
                else
                {
                    resultInfo.SetValue("return_code", notifyData.GetValue("return_code").ToString());
                    resultInfo.SetValue("return_msg", notifyData.GetValue("return_msg").ToString());
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
                resultInfo.SetValue("return_code", "FAIL");
                resultInfo.SetValue("return_msg", "交易失败");
            }
            return(resultInfo.ToXml());
        }
Example #20
0
        public ActionResult Notify()
        {
            Log.Error(this.GetType().ToString(), "transaction_id===>微信回调开始");
            ResultNotify result       = new ResultNotify(Request.InputStream);
            WxPayData    handlerRes   = result.ProcessNotify();
            string       out_trade_no = handlerRes.GetValue("out_trade_no").ToString();
            string       resXml       = string.Empty;

            Log.Error(this.GetType().ToString(), "transaction_id===>111111");
            //支付成功后处理
            if (handlerRes.GetValue("return_code").ToString() == "SUCCESS")
            {
                resXml = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>"
                         + "<return_msg><![CDATA[OK]]></return_msg>" + "</xml> ";
                string transaction_id = handlerRes.GetValue("transaction_id").ToString();
                Log.Error(this.GetType().ToString(), "transaction_id===>" + transaction_id);
                WxPayData orderCheck = null; //CheckTransactionidPayState(transaction_id, out_trade_no);
                if (true)
                {
                    var status = _rechargeOrderContract.RechargeOrders.Where(x => x.Prepay_Id == transaction_id && x.order_Uid == out_trade_no)
                                 .Select(x => x.pay_status).ToList().FirstOrDefault();
                    if (status != 1)
                    {
                        using (var a = _rechargeOrderContract.GetTransaction())
                        {
                            //status 0 订单生成 1 支付成功 2 支付失败
                            var res = _rechargeOrderContract.PaymentSuccess(transaction_id, 1, out_trade_no);
                            if (res.ResultType == OperationResultType.Error)
                            {
                                a.Rollback();
                            }
                            else
                            {
                                var b = _rechargeOrderContract.RechargeOrders.Where(x => x.order_Uid == out_trade_no)
                                        .Select(x => new MemberDepositDto()
                                {
                                    MemberId           = x.UserId,
                                    Price              = x.RechargeType == 0 ? x.TureAmount : 0,
                                    Score              = x.RechargeType == 1 ? x.TureAmount : 0,
                                    Cash               = x.Amount,
                                    order_Uid          = x.order_Uid,
                                    MemberDepositType  = 2,
                                    MemberActivityType = x.RechargeType
                                }).FirstOrDefault();
                                var updateMember = _memberdepositContract.InsertWx(b);
                                if (updateMember.ResultType == OperationResultType.Error)
                                {
                                    a.Rollback();
                                }
                                else
                                {
                                    //更新成功
                                    a.Commit();
                                }
                            }
                        }
                    }
                }
                else
                {
                    resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>"
                             + "<return_msg><![CDATA[支付失败]]></return_msg>" + "</xml> ";
                }
            }
            else
            {
                resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>"
                         + "<return_msg><![CDATA[支付失败]]></return_msg>" + "</xml> ";
                //支付失败处理
                if (out_trade_no != "")
                {
                    var res = _rechargeOrderContract.PaymentSuccess(null, 2, out_trade_no);
                }
            }
            Response.Write(resXml);
            Response.End();
            return(View());
        }
Example #21
0
        /// <summary>
        /// 回调处理基类
        /// 主要负责接收微信支付后台发送过来的数据,对数据进行签名验证
        /// </summary>
        /// <param name="responseMessage"></param>
        /// <param name="request"></param>
        /// <param name="sceneryDomain"></param>
        public void Notify(HttpResponseMessage responseMessage, HttpRequest request)
        {
            ResultNotify notify = new ResultNotify(responseMessage, request);

            notify.ProcessNotify();
        }
Example #22
0
        /// <summary>
        /// 支付结果回调地址
        /// </summary>
        /// <returns></returns>

        public void PayNotifyUrl()
        {
            ResultNotify resultNotify = new ResultNotify();

            resultNotify.ProcessNotify();
        }
Example #23
0
        public ActionResult <string> GetResultNotify()
        {
            ResultNotify resultNotify = new ResultNotify(_httpContext);

            return(resultNotify.ProcessNotify());
        }
Example #24
0
 /**
  *
  * 支付完成交易通知
  *
  */
 public async Task Nodify()
 {
     ResultNotify resultNotify = new ResultNotify(this.HttpContext);
     await resultNotify.ProcessNotifyAsync();
 }
        // GET: /WeChat/WeChatPay/ResultNotifyPage/
        public void ResultNotifyPage()
        {
            var redirectAction = "";

            var res            = new WxPayData <Qx.Account.Configs.Setting.WxPayConfig.Sports>();
            var appid          = RequstParam["appid"];
            var attach         = RequstParam["attach"];
            var bank_type      = RequstParam["bank_type"];
            var cash_fee       = RequstParam["cash_fee"];
            var fee_type       = RequstParam["fee_type"];
            var is_subscribe   = RequstParam["is_subscribe"];
            var mch_id         = RequstParam["mch_id"];
            var nonce_str      = RequstParam["nonce_str"];
            var openid         = RequstParam["openid"];
            var out_trade_no   = RequstParam["out_trade_no"];
            var result_code    = RequstParam["result_code"];
            var return_code    = RequstParam["return_code"];
            var sign           = RequstParam["sign"];
            var time_end       = RequstParam["time_end"];
            var total_fee      = RequstParam["total_fee"];
            var transaction_id = RequstParam["transaction_id"];

            //检查支付结果中transaction_id是否存在
            if (transaction_id.HasValue() && out_trade_no.HasValue())
            {
                //1.开始处理
                var chargePayOrder = _accountPayService.FindPayOrder(out_trade_no);
                if (chargePayOrder != null)
                {
                    chargePayOrder.ToNextState(transaction_id);
                    _accountPayService.SyncPayOrder(chargePayOrder);

                    if (result_code.ToUpper().Contains("SUCCESS") &&
                        return_code.ToUpper().Contains("SUCCESS") &&
                        chargePayOrder.IsValid(transaction_id))
                    {
                        //防止重复处理
                        if (!chargePayOrder.IsEnd)
                        {
                            chargePayOrder.ToNextState();
                            //2.同步支付订单
                            _accountPayService.SyncPayOrder(chargePayOrder);

                            //3.发送成功通知
                            //var url = "http://wx.52xyj.cn/WeChat/BookTiketWeb/MyWallet";
                            //var acc = _accountPayService.FindAccount(openid);
                            //_wechatServices.Send_Charge_Ok_Msg(openid, url,
                            //    acc.Account.LastUpdateTime.ToStr(),
                            //    (int.Parse(total_fee)/100.0)+"元",
                            //   (acc.Account.Balance/100.0) + "元");
                        }
                        res.SetValue("return_code", "SUCCESS");
                        res.SetValue("return_msg", "OK");
                        //Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
                        redirectAction = "ChargeOK";
                    }
                    else
                    {
                        // chargePayOrder.Failed();
                        // _accountPayService.SyncPayOrder(chargePayOrder);

                        res.SetValue("return_code", "FAIL");
                        res.SetValue("return_msg", "订单查询失败");
                        // Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
                        redirectAction = "ChargeFailed";
                    }
                }
            }
            else
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "支付结果中微信订单号不存在");
                //Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
                redirectAction = "ChargeFailed";
            }
            // Response.Write(res.ToXml());
            // Response.End();
            var resultNotify = new ResultNotify <Qx.Account.Configs.Setting.WxPayConfig.Sports>(HttpContext);

            resultNotify.ProcessNotify();
            // return RedirectToAction(redirectAction, "BookTiketWeb", new { transaction_id = transaction_id });
        }
Example #26
0
        /// <summary>
        /// wx异步返回处理
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public WxPayAPI.ResultNotify.WXPayBack WXJSApi_Notify(HttpContext context)
        {
            ResultNotify resultNotify = new ResultNotify(context);

            return(resultNotify.ProcessNotify());
        }