예제 #1
0
        public static SortedDictionary <string, object> UnifiedOrder(SortedDictionary <string, object> dic, int timeOut = 6)
        {
            dic.Add("appid", WeiXinHelper.appid);
            dic.Add("mch_id", WeiXinHelper.mch_id);
            dic.Add("device_info", WeiXinHelper.device_info);
            dic.Add("sign", WeiXinHelper.GetMakeSign(dic));
            string xml  = WeiXinHelper.WxPayDataToXml(dic);
            string xml2 = WeiXinHelper.Post(xml, WeiXinHelper.orderurl, false, timeOut);

            return(WeiXinHelper.WxPayDataFromXml(xml2));
        }
예제 #2
0
        public static SortedDictionary <string, object> OrderQuery(SortedDictionary <string, object> dic, int timeOut = 6)
        {
            dic.Add("appid", WeiXinHelper.appid);
            dic.Add("mch_id", WeiXinHelper.mch_id);
            dic.Add("nonce_str", WeiXinHelper.GetNonce_str());
            dic.Add("sign", WeiXinHelper.GetMakeSign(dic));
            string xml  = WeiXinHelper.WxPayDataToXml(dic);
            string xml2 = WeiXinHelper.Post(xml, WeiXinHelper.orderquery, false, timeOut);

            return(WeiXinHelper.WxPayDataFromXml(xml2));
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string returnMsg = "<xml> <return_code><![CDATA[{0}]]></return_code> <return_msg><![CDATA[{1}]]></return_msg> </xml>";
            SortedDictionary <string, object> dic = WeiXinHelper.GetReturnData();

            string sign = dic["sign"].ToString();

            if (dic["return_code"].ToString() == "SUCCESS")
            {
                string signLocal = WeiXinHelper.GetMakeSign(dic);

                if (sign == signLocal)
                {
                    decimal amount = Convert.ToDecimal(dic["total_fee"]) / 100M;

                    if (dic["result_code"].ToString() == "SUCCESS")
                    {
                        ShareDetialInfo detailInfo = new ShareDetialInfo();
                        detailInfo.OrderID   = dic["out_trade_no"].ToString();
                        detailInfo.IPAddress = Utility.UserIP;
                        detailInfo.PayAmount = amount;
                        Message umsg = FacadeManage.aideTreasureFacade.FilliedOnline(detailInfo, 0);

                        Response.Write(string.Format(returnMsg, "SUCCESS", "支付成功!"));
                    }
                    else
                    {
                        Response.Write(string.Format(returnMsg, "FAIL", "微信交易失败!"));
                    }
                }
                else
                {
                    Response.Write(string.Format(returnMsg, "FAIL", "签名错误!"));
                }
            }
            else
            {
                Response.Write(string.Format(returnMsg, "FAIL", "微信交易失败!"));
            }
        }
예제 #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string format = "<xml> <return_code><![CDATA[{0}]]></return_code> <return_msg><![CDATA[{1}]]></return_msg> </xml>";
            SortedDictionary <string, object> returnData = WeiXinHelper.GetReturnData();
            string a = returnData["sign"].ToString();

            if (!(returnData["return_code"].ToString() == "SUCCESS"))
            {
                base.Response.Write(string.Format(format, "FAIL", "微信交易失败!"));
            }
            else
            {
                string makeSign = WeiXinHelper.GetMakeSign(returnData);
                if (!(a == makeSign))
                {
                    base.Response.Write(string.Format(format, "FAIL", "签名错误!"));
                }
                else
                {
                    decimal payAmount = System.Convert.ToDecimal(returnData["total_fee"]) / 100m;
                    if (returnData["result_code"].ToString() == "SUCCESS")
                    {
                        ShareDetialInfo shareDetialInfo = new ShareDetialInfo();
                        shareDetialInfo.OrderID   = returnData["out_trade_no"].ToString();
                        shareDetialInfo.IPAddress = Utility.UserIP;
                        shareDetialInfo.PayAmount = payAmount;
                        FacadeManage.aideTreasureFacade.FilliedOnline(shareDetialInfo, 0);
                        base.Response.Write(string.Format(format, "SUCCESS", "支付成功!"));
                    }
                    else
                    {
                        base.Response.Write(string.Format(format, "FAIL", "微信交易失败!"));
                    }
                }
            }
        }