红袖支付: http://www.redxiu.com.cn/home.asp
/// <summary> /// 红袖支付(速邦)(随行付) /// </summary> public class HXPayHelper { /// <summary> /// 支付 /// </summary> /// <param name="merchatNO">商户号</param> /// <param name="terminalID">终端号</param> /// <param name="accessToken">令牌</param> /// <param name="terminalTrace">订单号</param> /// <param name="authNO">付款码(扫码盒扫描微信二维码得到的字符串)</param> /// <param name="amount">金额(分)</param> /// <returns></returns> public string Pay(string merchatNO, string terminalID, string accessToken, string terminalTrace, string authNO, int amount) { HXPayReq req = new HXPayReq() { pay_ver = "100", pay_type = "000", service_id = "010", merchant_no = merchatNO, terminal_id = terminalID, terminal_trace = terminalTrace, terminal_time = DateTime.Now.ToString("yyyyMMddHHmmss"), auth_no = authNO, total_fee = amount.ToString() }; req.SetSign(accessToken); string postStr = JsonConvert.SerializeObject(req); string url = "http://pay.redxiu.com.cn/pay/110/barcodepay"; return HttpPost(url, postStr); } /// <summary> /// 查询(微信金额大于1000时需要输入密码,可以不断调此接口去查询支付结果) /// </summary> /// <param name="merchatNO">商户号</param> /// <param name="terminalID">终端号</param> /// <param name="accessToken">令牌</param> /// <param name="terminalTrace">订单号</param> /// <param name="outTradeNO">红袖订单号</param> /// <returns></returns> public string Query(string merchatNO, string terminalID, string accessToken, string terminalTrace, string outTradeNO) { HXPayQueryReq req = new HXPayQueryReq() { pay_ver = "100", pay_type = "000", service_id = "010", merchant_no = merchatNO, terminal_id = terminalID, terminal_trace = terminalTrace, terminal_time = DateTime.Now.ToString("yyyyMMddHHmmss"), out_trade_no = outTradeNO }; req.SetSign(accessToken); string postStr = JsonConvert.SerializeObject(req); string url = "http://pay.redxiu.com.cn/pay/110/query"; return HttpPost(url, postStr); } /// <summary> /// 退款 /// </summary> /// <param name="merchatNO">商户号</param> /// <param name="terminalID">终端号</param> /// <param name="accessToken">令牌</param> /// <param name="terminalTrace">订单号</param> /// <param name="outTradeNO">红袖订单号</param> /// <param name="amount">金额(建议全额退款)</param> /// <returns></returns> public string Refund(string merchatNO, string terminalID, string accessToken, string terminalTrace, string outTradeNO, int amount) { HXRefundReq req = new HXRefundReq() { pay_ver = "100", pay_type = "000", service_id = "010", merchant_no = merchatNO, terminal_id = terminalID, terminal_trace = terminalTrace, terminal_time = DateTime.Now.ToString("yyyyMMddHHmmss"), out_trade_no = outTradeNO, refund_fee = amount.ToString() }; req.SetSign(accessToken); string postStr = JsonConvert.SerializeObject(req); string url = "http://pay.redxiu.com.cn/pay/110/refund"; return HttpPost(url, postStr); } /// <summary> /// 退款查询 /// </summary> /// <param name="merchatNO">商户号</param> /// <param name="terminalID">终端号</param> /// <param name="accessToken">令牌</param> /// <param name="terminalTrace">订单号</param> /// <param name="outTradeNO">红袖订单号</param> /// <returns></returns> public string RefundQuery(string merchatNO, string terminalID, string accessToken, string terminalTrace, string outTradeNO) { HXRefundQueryReq req = new HXRefundQueryReq() { pay_ver = "100", pay_type = "000", service_id = "010", merchant_no = merchatNO, terminal_id = terminalID, terminal_trace = terminalTrace, terminal_time = DateTime.Now.ToString("yyyyMMddHHmmss"), out_refund_no = outTradeNO }; req.SetSign(accessToken); string postStr = JsonConvert.SerializeObject(req); string url = "http://pay.redxiu.com.cn/pay/110/refundQuery"; return HttpPost(url, postStr); } private string HttpPost(string url, string data) { using (HttpClient client = new HttpClient()) { using (HttpContent httpContent = new StringContent(data, Encoding.UTF8, "application/json")) { HttpResponseMessage response = client.PostAsync(url, httpContent).Result; return response.Content.ReadAsStringAsync().Result; } } } public static string MD5(string str) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(str))); t2 = t2.Replace("-", ""); return t2; } /// <summary> /// 支付请求 /// </summary> public class HXPayReq { /// <summary> /// 版本号 100 /// </summary> public string pay_ver { get; set; } /// <summary> /// 请求类型:000自动识别微信支付宝等 /// </summary> public string pay_type { get; set; } /// <summary> /// 接口类型010 /// </summary> public string service_id { get; set; } /// <summary> /// 商户号 /// </summary> public string merchant_no { get; set; } /// <summary> /// 终端号 /// </summary> public string terminal_id { get; set; } /// <summary> /// 终端流水号 /// </summary> public string terminal_trace { get; set; } /// <summary> /// 终端交易时间 /// </summary> public string terminal_time { get; set; } /// <summary> /// 授权码 二维码 /// </summary> public string auth_no { get; set; } /// <summary> /// 金额 分 /// </summary> public string total_fee { get; set; } /// <summary> /// 按字典序排列参数+access_token utf8 32位大写md5加密 /// </summary> public string key_sign { get; set; } /// <summary> /// 签名 /// </summary> /// <param name="accessToken"></param> public void SetSign(string accessToken) { string str = ""; str += "auth_no=" + this.auth_no + "&"; str += "merchant_no=" + this.merchant_no + "&"; str += "pay_type=" + this.pay_type + "&"; str += "pay_ver=" + this.pay_ver + "&"; str += "service_id=" + this.service_id + "&"; str += "terminal_id=" + this.terminal_id + "&"; str += "terminal_time=" + this.terminal_time + "&"; str += "terminal_trace=" + this.terminal_trace + "&"; str += "total_fee=" + this.total_fee + "&"; str += "access_token=" + accessToken; this.key_sign = HXPayHelper.MD5(str); } } /// <summary> /// 查询订单 /// </summary> public class HXPayQueryReq { /// <summary> /// 版本号 100 /// </summary> public string pay_ver { get; set; } /// <summary> /// 请求类型:000自动识别微信支付宝等 /// </summary> public string pay_type { get; set; } /// <summary> /// 接口类型010 /// </summary> public string service_id { get; set; } /// <summary> /// 商户号 /// </summary> public string merchant_no { get; set; } /// <summary> /// 终端号 /// </summary> public string terminal_id { get; set; } /// <summary> /// 终端流水号 /// </summary> public string terminal_trace { get; set; } /// <summary> /// 终端交易时间 /// </summary> public string terminal_time { get; set; } /// <summary> /// 订单号,查询凭据 /// </summary> public string out_trade_no { get; set; } /// <summary> /// 按字典序排列参数+access_token utf8 32位大写md5加密 /// </summary> public string key_sign { get; set; } public void SetSign(string accessToken) { string str = ""; str += "merchant_no=" + this.merchant_no + "&"; str += "out_trade_no=" + this.out_trade_no + "&"; str += "pay_type=" + this.pay_type + "&"; str += "pay_ver=" + this.pay_ver + "&"; str += "service_id=" + this.service_id + "&"; str += "terminal_id=" + this.terminal_id + "&"; str += "terminal_time=" + this.terminal_time + "&"; str += "terminal_trace=" + this.terminal_trace + "&"; str += "access_token=" + accessToken; this.key_sign = HXPayHelper.MD5(str); } } /// <summary> /// 退款申请 /// </summary> public class HXRefundReq { /// <summary> /// 版本号 100 /// </summary> public string pay_ver { get; set; } /// <summary> /// 请求类型:000自动识别微信支付宝等 /// </summary> public string pay_type { get; set; } /// <summary> /// 接口类型010 /// </summary> public string service_id { get; set; } /// <summary> /// 商户号 /// </summary> public string merchant_no { get; set; } /// <summary> /// 终端号 /// </summary> public string terminal_id { get; set; } /// <summary> /// 终端流水号 /// </summary> public string terminal_trace { get; set; } /// <summary> /// 终端交易时间 /// </summary> public string terminal_time { get; set; } /// <summary> /// 退款金额 /// </summary> public string refund_fee { get; set; } /// <summary> /// 订单号,查询凭据 /// </summary> public string out_trade_no { get; set; } /// <summary> /// 按字典序排列参数+access_token utf8 32位大写md5加密 /// </summary> public string key_sign { get; set; } public void SetSign(string accessToken) { string str = ""; str += "merchant_no=" + this.merchant_no + "&"; str += "out_trade_no=" + this.out_trade_no + "&"; str += "pay_type=" + this.pay_type + "&"; str += "pay_ver=" + this.pay_ver + "&"; str += "refund_fee=" + this.refund_fee + "&"; str += "service_id=" + this.service_id + "&"; str += "terminal_id=" + this.terminal_id + "&"; str += "terminal_time=" + this.terminal_time + "&"; str += "terminal_trace=" + this.terminal_trace + "&"; str += "access_token=" + accessToken; this.key_sign = HXPayHelper.MD5(str); } } /// <summary> /// 退款查询 /// </summary> public class HXRefundQueryReq { /// <summary> /// 版本号 100 /// </summary> public string pay_ver { get; set; } /// <summary> /// 请求类型:000自动识别微信支付宝等 /// </summary> public string pay_type { get; set; } /// <summary> /// 接口类型010 /// </summary> public string service_id { get; set; } /// <summary> /// 商户号 /// </summary> public string merchant_no { get; set; } /// <summary> /// 终端号 /// </summary> public string terminal_id { get; set; } /// <summary> /// 终端流水号 /// </summary> public string terminal_trace { get; set; } /// <summary> /// 终端交易时间 /// </summary> public string terminal_time { get; set; } /// <summary> /// 订单号,查询凭据 /// </summary> public string out_refund_no { get; set; } /// <summary> /// 按字典序排列参数+access_token utf8 32位大写md5加密 /// </summary> public string key_sign { get; set; } public void SetSign(string accessToken) { string str = ""; str += "merchant_no=" + this.merchant_no + "&"; str += "out_refund_no=" + this.out_refund_no + "&"; str += "pay_type=" + this.pay_type + "&"; str += "pay_ver=" + this.pay_ver + "&"; str += "service_id=" + this.service_id + "&"; str += "terminal_id=" + this.terminal_id + "&"; str += "terminal_time=" + this.terminal_time + "&"; str += "terminal_trace=" + this.terminal_trace + "&"; str += "access_token=" + accessToken; this.key_sign = HXPayHelper.MD5(str); } } }