Esempio n. 1
0
 //检测返回结果
 public static bool CheckReturn(WxPayDataTool result)
 {
     if (result != null)
     {
         bool flag1 = (result.IsSet("return_code") && result.GetValue("return_code").ToString().ToUpper() == "SUCCESS");
         bool flag2 = (result.IsSet("result_code") && result.GetValue("result_code").ToString().ToUpper() == "SUCCESS");
         return(flag1 && flag2);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
        public new WxPayDataTool  ProcessNotify()
        {
            WxPayDataTool notifyData = GetNotifyData(_InputStream);

            //检查支付结果中transaction_id是否存在
            if (!notifyData.IsSet("transaction_id"))
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                WxPayDataTool res = new WxPayDataTool();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "支付结果中微信订单号不存在");
                // Util.WriteFile(@"D:\ppp\log\wx.txt", "统一下单支付结果回调出错:" + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }

            string transaction_id = notifyData.GetValue("transaction_id").ToString();
            string out_trade_no   = notifyData.GetValue("out_trade_no").ToString();
            string total          = notifyData.GetValue("total_fee").ToString();
            //查询订单,判断订单真实性
            OrderqueryInfo info = new OrderqueryInfo()
            {
                Transaction_id = transaction_id
            };

            if (!QueryOrder(info))
            {
                //若订单查询失败,则立即返回结果给微信支付后台
                WxPayDataTool res = new WxPayDataTool();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "订单查询失败");
                //Util.WriteFile(@"D:\ppp\log\wx.txt", "订单查询失败:" + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }
            WxPayDataTool result = new WxPayDataTool();

            result.SetValue("transaction_id", transaction_id);
            result.SetValue("out_trade_no", out_trade_no);
            result.SetValue("total_fee", total);
            if (notifyData.IsSet("result_code"))
            {
                result.SetValue("result_code", notifyData.GetValue("result_code").ToString());
            }
            if (notifyData.IsSet("return_code"))
            {
                result.SetValue("return_code", notifyData.GetValue("return_code").ToString());
            }
            return(result);
        }
Esempio n. 3
0
        //H5调起js支付
        public static WxPayDataTool GetJsApiParameters(UnifiedOrderInfo info)
        {
            string        prepay_id = "";
            WxPayDataTool payresult = UnifiedOrder(info);

            if (CheckReturn(payresult))
            //   LogDB.DebugTest("统一下单信息出错:" + payresult.ToJson());
            // else
            {
                if (payresult.IsSet("prepay_id") && (prepay_id = payresult.GetValue("prepay_id").ToString()) != "")
                {
                    WxPayDataTool jsApiParam = new WxPayDataTool();
                    jsApiParam.SetValue("appId", info.AppId);
                    jsApiParam.SetValue("timeStamp", UtilTool.GenerateUnixTime());
                    jsApiParam.SetValue("nonceStr", UtilTool.GenerateCode(15));
                    jsApiParam.SetValue("package", "prepay_id=" + prepay_id);
                    jsApiParam.SetValue("signType", "MD5");
                    jsApiParam.SetValue("paySign", jsApiParam.MakeSign(info.PartnerKey));
                    return(jsApiParam);
                }
            }
            return(new WxPayDataTool());
        }