Esempio n. 1
0
        /**
         * 调用统一下单,获得下单结果
         * @return 统一下单结果
         * @失败时抛异常WxPayException
         */
        public WxPayData GetUnifiedOrderResult_YJ(string body, string notifyUrl, string OrderNo)
        {
            //统一下单
            WxPayData data = new WxPayData();

            data.SetValue("body", body);
            data.SetValue("attach", "PPWXPay");
            // data.SetValue("out_trade_no", WxPayApi.GenerateOutTradeNo());
            data.SetValue("out_trade_no", OrderNo);
            data.SetValue("total_fee", total_fee);
            data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
            data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
            data.SetValue("goods_tag", "Item");
            data.SetValue("trade_type", "JSAPI");
            data.SetValue("notify_url", notifyUrl);
            data.SetValue("openid", openid);

            WxPayData result = WxPayApi.UnifiedOrder_YJ(data);

            if (!result.IsSet("appid") || !result.IsSet("prepay_id") || result.GetValue("prepay_id").ToString() == "")
            {
                //     Log.Error(this.GetType().ToString(), "UnifiedOrder response error!");
                throw new WxPayException("UnifiedOrder response error!");
            }

            unifiedOrderResult = result;
            return(result);
        }