/// <summary> ///退款状态查询"(只支持微信) /// </summary> /// <param name="channel">渠道类型 /// 暂时只能填WX /// </param> /// <param name="refundNo">商户退款单号 /// </param> /// <returns> /// BCRefundStatusQueryResult /// </returns> public static BCRefundStatusQueryResult BCRefundStatusQuery(string channel, string refundNo) { Random random = new Random(); string refundStatusUrl = BCPrivateUtil.mLocalDefaultHosts[random.Next(0, 4)] + BCConstants.version + BCConstants.refundStatusURL; long timestamp = BCUtil.GetTimeStamp(DateTime.Now); JsonData data = new JsonData(); data["app_id"] = BCCache.Instance.appId; data["app_sign"] = BCPrivateUtil.getAppSignature(BCCache.Instance.appId, BCCache.Instance.appSecret, timestamp.ToString()); data["timestamp"] = timestamp; data["channel"] = channel; data["refund_no"] = refundNo; string paraString = data.ToJson(); string url = refundStatusUrl + "?para=" + HttpUtility.UrlEncode(paraString, Encoding.UTF8); try { HttpWebResponse response = BCPrivateUtil.CreateGetHttpResponse(url, BCCache.Instance.networkTimeout, null, null); string respString = BCPrivateUtil.GetResponseString(response); JsonData responseData = JsonMapper.ToObject(respString); BCRefundStatusQueryResult result = new BCRefundStatusQueryResult(); result.resultCode = int.Parse(responseData["result_code"].ToString()); result.resultMsg = responseData["result_msg"].ToString(); if (responseData["result_code"].ToString() == "0") { result.refundStatus = responseData["refund_status"].ToString(); } else { result.errDetail = responseData["err_detail"].ToString(); } return(result); } catch (Exception e) { BCRefundStatusQueryResult result = new BCRefundStatusQueryResult(); result.resultCode = 99; result.resultMsg = e.Message; return(result); } }
private static int getLtt(string host) { string url = host + "/status"; DateTime startTime = DateTime.Now; try { HttpWebResponse response = BCPrivateUtil.CreateGetHttpResponse(url, BCCache.Instance.networkTimeout, null, null); if (response != null && response.StatusCode == HttpStatusCode.OK) { return((DateTime.Now - startTime).Milliseconds); } else { return(BCCache.Instance.networkTimeout); } } catch (Exception e) { return(BCCache.Instance.networkTimeout); } }
/// <summary> /// 退款订单查询 /// </summary> /// <param name="channel">渠道类型 /// 根据不同场景选择不同的支付方式 /// 必填 /// 可以通过enum BCPay.QueryChannel获取 /// channel的参数值含义: /// WX: 微信所有类型支付 /// WX_APP: 微信手机APP支付 /// WX_NATIVE: 微信公众号二维码支付 /// WX_JSAPI: 微信公众号支付 /// ALI: 支付宝所有类型支付 /// ALI_APP: 支付宝APP支付 /// ALI_WEB: 支付宝网页支付 /// ALI_QRCODE: 支付宝内嵌二维码支付 /// UN: 银联所有类型支付 /// UN_APP: 银联APP支付 /// UN_WEB: 银联网页支付</param> /// <param name="billNo">商户订单号 /// </param> /// <param name="refundNo">商户退款单号 /// </param> /// <param name="startTime">起始时间 /// 毫秒时间戳, 13位, 可以使用BCUtil.GetTimeStamp()方法获取 /// 选填</param> /// <param name="endTime">结束时间 /// 毫秒时间戳, 13位, 可以使用BCUtil.GetTimeStamp()方法获取 /// 选填</param> /// <param name="skip">查询起始位置 /// 默认为0。设置为10表示忽略满足条件的前10条数据 /// 选填 /// </param> /// <param name="limit">查询的条数 /// 默认为10,最大为50。设置为10表示只返回满足条件的10条数据 /// 选填 /// </param> /// <returns> /// BCRefundQuerytResult /// </returns> public static BCRefundQuerytResult BCRefundQueryByCondition(string channel, string billNo, string refundNo, long?startTime, long?endTime, int?skip, int?limit) { Random random = new Random(); string payQueryUrl = BCPrivateUtil.mLocalDefaultHosts[random.Next(0, 4)] + BCConstants.version + BCConstants.refundsURL; long timestamp = BCUtil.GetTimeStamp(DateTime.Now); JsonData data = new JsonData(); data["app_id"] = BCCache.Instance.appId; data["app_sign"] = BCPrivateUtil.getAppSignature(BCCache.Instance.appId, BCCache.Instance.appSecret, timestamp.ToString()); data["timestamp"] = timestamp; data["channel"] = channel; data["bill_no"] = billNo; data["refund_no"] = refundNo; data["start_time"] = startTime; data["end_time"] = endTime; data["skip"] = skip; data["limit"] = limit; string paraString = data.ToJson(); try { string url = payQueryUrl + "?para=" + HttpUtility.UrlEncode(paraString, Encoding.UTF8); HttpWebResponse response = BCPrivateUtil.CreateGetHttpResponse(url, BCCache.Instance.networkTimeout, null, null); string respString = BCPrivateUtil.GetResponseString(response); JsonData responseData = JsonMapper.ToObject(respString); BCRefundQuerytResult result = new BCRefundQuerytResult(); result.resultCode = int.Parse(responseData["result_code"].ToString()); result.resultMsg = responseData["result_msg"].ToString(); if (result.resultCode == 0) { result.count = int.Parse(responseData["count"].ToString()); if (responseData["refunds"].IsArray) { List <BCRefund> refunds = new List <BCRefund>(); foreach (JsonData refundData in responseData["refunds"]) { BCRefund refund = new BCRefund(); refund.title = refundData["title"].ToString(); refund.billNo = refundData["bill_no"].ToString(); refund.refundNo = refundData["refund_no"].ToString(); refund.totalFee = int.Parse(refundData["total_fee"].ToString()); refund.refundFee = int.Parse(refundData["refund_fee"].ToString()); refund.channel = refundData["channel"].ToString(); refund.finish = (bool)refundData["finish"]; refund.result = (bool)refundData["result"]; refund.createdTime = BCUtil.GetDateTime((long)refundData["created_time"]); refunds.Add(refund); } result.refunds = refunds; } } else { result.errDetail = responseData["err_detail"].ToString(); } return(result); } catch (Exception e) { BCRefundQuerytResult result = new BCRefundQuerytResult(); result.resultCode = 99; result.resultMsg = e.Message; return(result); } }