示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //创建支付应答对象
            ResponseHandler resHandler = new ResponseHandler(Context);
            resHandler.init();
            wx_payment_wxpay payBll = new wx_payment_wxpay();

            //暂未获得wid
            Model.wx_payment_wxpay paymentInfo = payBll.GetModel(1);

            resHandler.setKey(paymentInfo.partnerKey, paymentInfo.paySignKey); //密匙,paysignkey

            //判断签名
            if (resHandler.isWXsignfeedback())
            {
                //回复服务器处理成功
                string AppId = resHandler.getMpParameter("AppId");
                string TimeStamp = resHandler.getMpParameter("TimeStamp");
                string OpenId = resHandler.getMpParameter("OpenId");
                string AppSignature = resHandler.getMpParameter("AppSignature");
                string MsgType = resHandler.getMpParameter("MsgType");
                string FeedBackId = resHandler.getMpParameter("FeedBackId");
                string TransId = resHandler.getMpParameter("TransId");
                string Reason = resHandler.getMpParameter("Reason");
                string Solution = resHandler.getMpParameter("Solution");
                string ExtInfo = resHandler.getMpParameter("ExtInfo");
                string SignMethod = resHandler.getParameter("SignMethod");
                string txt = string.Empty;
                if (MsgType.ToLower().Trim() == "request")
                {
                    //新增维权操作
                }
                else
                {
                    //用户确认处理完毕操作
                }

                //回复服务器处理成功
                Response.Write("OK");
                Response.Write("OK:" + resHandler.getDebugInfo());
            }
            else
            {
                //sha1签名失败
                Response.Write("fail");
                Response.Write("fail:" + resHandler.getDebugInfo());
            }
            Response.End();
        }
示例#2
0
        /// <summary>
        /// 发货
        /// </summary>
        /// <param name="paymentInfo"></param>
        /// <param name="orderEntity"></param>
        /// <returns></returns>
        public Dictionary<string, object> fahuomgr(Model.wx_payment_wxpay paymentInfo, Model.orders orderEntity)
        {
            BLL.wx_logs logBll = new BLL.wx_logs();
            string funName = "发货";
            logBll.AddLog(paymentInfo.wid.Value, "微支付", funName, "开始执行fahuomgr方法[otid:" + orderEntity.id + "]");

            WxPayHelper wxPayHelper = new WxPayHelper();
            wx_payment_wxpay payBll = new wx_payment_wxpay();

            //先设置基本信息
            string partnerId = paymentInfo.partnerId; //"1218574001";
            string appId = paymentInfo.appId;// "wxa9b8e33e48ac5e0f";
            string partnerKey = paymentInfo.partnerKey;// "huyuxianghuyuxianghuyuxiang12345";
            //paysignkey(非appkey)
            string appKey = paymentInfo.paySignKey;// "nwRmqgvSG08pe3vU5qzBLb7Bvih0WOABGzUPvqgFqE0iSkJlJ8wh7JlLYy2cXFgFA3v1bM8eTDm1y1UcyeW9IGq2py2qei7J5xDoVR9lfO3cS6fMjFbMQeeqBRit0bKp";

            wxPayHelper.SetAppId(appId);
            wxPayHelper.SetAppKey(appKey);
            wxPayHelper.SetPartnerKey(partnerKey);
            wxPayHelper.SetSignType("sha1");
            //设置请求package信息

            WeiXinCRMComm wxComm = new WeiXinCRMComm();
            string err="";
            string access_token = wxComm.getAccessToken(paymentInfo.wid.Value, out err);

            string param = wxPayHelper.CreateFaHuoPackage(orderEntity.openid, orderEntity.trade_no, orderEntity.order_no);

            string url = "https://api.weixin.qq.com/pay/delivernotify?access_token=" + access_token;
            string ret = Utils.HttpPost(url, param);
            logBll.AddLog(paymentInfo.wid.Value, "微支付", funName, "ret=" + ret);
            Dictionary<string, object> dict = JsonToDictionary(ret);
            logBll.AddLog(paymentInfo.wid.Value, "微支付", funName, "[otid:" + orderEntity.id + "]发货成功");
            //string errcode = dict["errcode"].ToString();
            //string errmsg = dict["errmsg"].ToString();

            //mxAuthFrame.BLL.wxOrderTmpBLL wot = new mxAuthFrame.BLL.wxOrderTmpBLL();
            //ordertmp.fahuoCode = errcode;
            //ordertmp.fahuoMsg = errmsg;
            //wot.Update(ordertmp);

            //Dictionary<string, string> ret_d = new Dictionary<string, string>();
            //ret_d.Add(errcode, errmsg);
            return dict;
        }