Esempio n. 1
0
        /// <summary>
        /// 申请退款完整业务流程逻辑,退款结果(xml格式)
        /// </summary>
        /// <param name="transaction_id">微信订单号(优先使用)</param>
        /// <param name="out_trade_no">商户订单号</param>
        /// <param name="total_fee">订单总金额</param>
        /// <param name="refund_fee">退款金额</param>
        /// <returns></returns>
        public static string Run(string transaction_id, string out_trade_no, string total_fee, string refund_fee)
        {
            Log.Info("Refund", "Refund is processing...");

            WxData data = new WxData();

            if (!string.IsNullOrEmpty(transaction_id))//微信订单号存在的条件下,则已微信订单号为准
            {
                data.SetValue("transaction_id", transaction_id);
            }
            else//微信订单号不存在,才根据商户订单号去退款
            {
                data.SetValue("out_trade_no", out_trade_no);
            }

            data.SetValue("total_fee", int.Parse(total_fee));              //订单总金额
            data.SetValue("refund_fee", int.Parse(refund_fee));            //退款金额
            data.SetValue("out_refund_no", WxPayApi.GenerateOutTradeNo()); //随机生成商户退款单号
            data.SetValue("op_user_id", WxConfig.MCHID);                   //操作员,默认为商户号

            WxData result = WxPayApi.Refund(data);                         //提交退款申请给API,接收返回数据

            Log.Info("Refund", "Refund process complete, result : " + result.ToXml());
            return(result.ToPrintStr());
        }
Esempio n. 2
0
        /// <summary>
        /// 退款查询完整业务流程逻辑,退款查询结果(xml格式)
        /// </summary>
        /// <param name="refund_id">微信退款单号(优先使用)</param>
        /// <param name="out_refund_no">商户退款单号</param>
        /// <param name="transaction_id">微信订单号</param>
        /// <param name="out_trade_no">商户订单号</param>
        /// <returns></returns>
        public static string Run(string refund_id, string out_refund_no, string transaction_id, string out_trade_no)
        {
            Log.Info("RefundQuery", "RefundQuery is processing...");

            WxData data = new WxData();

            if (!string.IsNullOrEmpty(refund_id))
            {
                data.SetValue("refund_id", refund_id);//微信退款单号,优先级最高
            }
            else if (!string.IsNullOrEmpty(out_refund_no))
            {
                data.SetValue("out_refund_no", out_refund_no);//商户退款单号,优先级第二
            }
            else if (!string.IsNullOrEmpty(transaction_id))
            {
                data.SetValue("transaction_id", transaction_id);//微信订单号,优先级第三
            }
            else
            {
                data.SetValue("out_trade_no", out_trade_no);//商户订单号,优先级最低
            }

            WxData result = WxPayApi.RefundQuery(data);//提交退款查询给API,接收返回数据

            Log.Info("RefundQuery", "RefundQuery process complete, result : " + result.ToXml());
            return(result.ToPrintStr());
        }
Esempio n. 3
0
        /// <summary>
        /// 下载对账单完整业务流程逻辑,成功返回对账单结果(xml格式)
        /// </summary>
        /// <param name="bill_date">下载对账单的日期(格式:20140603,一次只能下载一天的对账单)</param>
        /// <param name="bill_type">账单类型(ALL,返回当日所有订单信息,默认值 ;SUCCESS,返回当日成功支付的订单;REFUND,返回当日退款订单;REVOKED,已撤销的订单;)</param>
        /// <returns></returns>
        public static string Run(string bill_date, string bill_type)
        {
            Log.Info("DownloadBill", "DownloadBill is processing...");

            WxData data = new WxData();

            data.SetValue("bill_date", bill_date);            //账单日期
            data.SetValue("bill_type", bill_type);            //账单类型
            WxData result = WxPayApi.DownloadBill(data);      //提交下载对账单请求给API,接收返回结果

            Log.Info("DownloadBill", "DownloadBill process complete, result : " + result.ToXml());
            return(result.ToPrintStr());
        }
Esempio n. 4
0
        /// <summary>
        /// 订单查询完整业务流程逻辑,返回订单查询结果(xml格式)
        /// </summary>
        /// <param name="transaction_id">微信订单号(优先使用)</param>
        /// <param name="out_trade_no">商户订单号</param>
        /// <returns></returns>
        public static string Run(string transaction_id, string out_trade_no)
        {
            Log.Info("OrderQuery", "OrderQuery is processing...");

            WxData data = new WxData();

            if (!string.IsNullOrEmpty(transaction_id))//如果微信订单号存在,则以微信订单号为准
            {
                data.SetValue("transaction_id", transaction_id);
            }
            else//微信订单号不存在,才根据商户订单号去查单
            {
                data.SetValue("out_trade_no", out_trade_no);
            }

            WxData result = WxPayApi.OrderQuery(data);            //提交订单查询请求给API,接收返回数据

            Log.Info("OrderQuery", "OrderQuery process complete, result : " + result.ToXml());
            return(result.ToPrintStr());
        }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Log.Info(this.GetType().ToString(), "page load");
        if (!IsPostBack)
        {
            string openid    = Request.QueryString["openid"];
            string total_fee = Request.QueryString["total_fee"];
            //检测是否给当前页面传递了相关参数
            if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(total_fee))
            {
                Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面传参出错,请返回重试" + "</span>");
                Log.Error(this.GetType().ToString(), "This page have not get params, cannot be inited, exit...");
                submit.Visible = false;
                return;
            }

            //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数
            JsApiPay jsApiPay = new JsApiPay(this);
            jsApiPay.openid    = openid;
            jsApiPay.total_fee = int.Parse(total_fee);

            //JSAPI支付预处理
            try
            {
                WxData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult();
                wxJsApiParam = jsApiPay.GetJsApiParameters();                //获取H5调起JS API参数
                Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                //在页面上显示订单信息
                Response.Write("<span style='color:#00CD00;font-size:20px'>订单详情:</span><br/>");
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + unifiedOrderResult.ToPrintStr() + "</span>");
            }
            catch (Exception ex)
            {
                Response.Write("<span style='color:#FF0000;font-size:20px'>" + "下单失败,请返回重试" + "</span>");
                submit.Visible = false;
            }
        }
    }