Exemplo n.º 1
0
        public static void Main(String[] args)
        {
            try
            {
                WxPayHelper wxPayHelper = new WxPayHelper();
                //先设置基本信息
                wxPayHelper.SetAppId("wxf8b4f85f3a794e77");
                wxPayHelper.SetAppKey("2Wozy2aksie1puXUBpWD8oZxiD1DfQuEaiC7KcRATv1Ino3mdopKaPGQQ7TtkNySuAmCaDCrw4xhPY5qKTBl7Fzm0RgR3c0WaVYIXZARsxzHV2x7iwPPzOz94dnwPWSn");
                wxPayHelper.SetPartnerKey("8934e7d15453e97507ef794cf7b0519d");
                wxPayHelper.SetSignType("sha1");
                //设置请求package信息
                wxPayHelper.SetParameter("bank_type", "WX");
                wxPayHelper.SetParameter("body", "test");
                wxPayHelper.SetParameter("partner", "1900000109");
                wxPayHelper.SetParameter("out_trade_no", CommonUtil.CreateNoncestr());
                wxPayHelper.SetParameter("total_fee", "1");
                wxPayHelper.SetParameter("fee_type", "1");
                wxPayHelper.SetParameter("notify_url", "htttp://www.baidu.com");
                wxPayHelper.SetParameter("spbill_create_ip", "127.0.0.1");
                wxPayHelper.SetParameter("input_charset", "GBK");

                System.Console.Out.WriteLine("生成app支付package:");
                System.Console.Out.WriteLine(wxPayHelper.CreateAppPackage("test"));
                System.Console.Out.WriteLine("生成jsapi支付package:");
                System.Console.Out.WriteLine(wxPayHelper.CreateBizPackage());
                System.Console.Out.WriteLine("生成原生支付url:");
                System.Console.Out.WriteLine(wxPayHelper.CreateNativeUrl("abc"));
                System.Console.Out.WriteLine("生成原生支付package:");
                System.Console.Out.WriteLine(wxPayHelper.CreateNativePackage("0", "ok"));
            }
            catch (Exception e)
            {
                System.Console.Out.WriteLine(e.Message);
            }
        }
Exemplo n.º 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);
        }