微信开发者文档

微信H5支付官方文档   请阅读清楚  最起码把所有参数看一遍

这个地方也可以看看

微信案例

http://wxpay.wxutil.com/mch/pay/h5.v2.php,请在微信外浏览器打开。

=========================================================================================================================================================

<button type="button" onclick="pay()">支 付</button>
//判断是否是微信浏览器的函数
function isWeiXin() {
//window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息,这个属性可以用来判断浏览器类型
var ua = window.navigator.userAgent.toLowerCase();
//通过正则表达式匹配ua中是否含有MicroMessenger字符串
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return false;
}
}
 function pay() {
if (isWeiXin()) {
$(".instructions_box").removeClass("dn");
} else {
if ($("#total_fee").val() > 0) {
var postData = {
//自行传参到后台
}; $.ajax({
url: "后台地址",
data: postData,
type: 'post',
success: function (data) {
if (data != null) {
$('.weui-mask').toggleClass('weui-mask--visible');
$('.weui-dialog').toggleClass('weui-dialog--visible');
window.location.href = data;
}
}
})
} else {
$.toast("金额输入有误", "forbidden");
}
}
}
/// <summary>
/// 微信支付
/// </summary>
/// <returns></returns>
public ActionResult WechatPay()
{
int pId = Convert.ToInt32(Request["pid"]);
project p = pManage.GetModel(pId);//获取商品 var url = System.Configuration.ConfigurationManager.AppSettings["url"];
var appId = System.Configuration.ConfigurationManager.AppSettings["AppId"];//公众号id
var mch_id = System.Configuration.ConfigurationManager.AppSettings["mch_id"];//商户号
var nonceStr = WechatPayCommon.CreateNonce_str();//随机字符串
var body = p.name;//商品名称
var detail = p.depict;//商品描述
var out_trade_no = Guid.NewGuid().ToString("N");//商户系统内部的订单号,32个字符内、可包含字母
var total_fee = Math.Round(Convert.ToDecimal(Request["total_fee"]) * , );//收钱总额 分为单位 前台传过来后需要处理成分
var spbill_create_ip = WechatPayCommon.GetWebClientIp();//终端ip
var time_start = DateTime.Now.ToString("yyyyMMddHHmmss");//订单生成时间
var time_expire = DateTime.Now.AddHours().ToString("yyyyMMddHHmmss");//默认1个小时订单过期,开发者可自定义其他超时机制,原则上微信订单超时时间不超过2小时
var notify_url = string.Format("{0}/Pay/Notify", esluo);//接收微信支付异步通知回调地址,不可带参,与下面的Notify对应,开发者可自定义其他url地址
var trade_type = "MWEB";//交易类型H5支付的交易类型为MWEB
var scene_info = "{\"h5_info\": {\"type\":\"Wap\",\"wap_url\": \"" + esluo + "\",\"wap_name\": \"" + body + "\"}}";
var partnerKey = System.Configuration.ConfigurationManager.AppSettings["PartnerKey"];//API密钥 var returnXML = "";
var paramaterXml = "";
var content = WechatPayCommon.UnifiedOrder(
appId, mch_id, nonceStr,
body, detail, out_trade_no, total_fee, spbill_create_ip, time_start, time_expire,
notify_url, trade_type, partnerKey, out returnXML, out paramaterXml); LogWriter.Default.WriteInfo("returnXML:" + returnXML.ToString());//记录请求关键信息到日志中去
LogWriter.Default.WriteInfo("paramaterXml:" + paramaterXml.ToString());//记录请求关键信息到日志中去
LogWriter.Default.WriteInfo("content:" + content);//记录请求关键信息到日志中去 var timestamp = Util.CreateTimestamp();
var prepay_id = content.prepay_id.Value;
var sign = WechatPayCommon.SignPay(appId, timestamp.ToString(), nonceStr, prepay_id, partnerKey);//签名
var isUnifiedOrderSuccess = false;
var return_code = "";
var return_msg = "";
var mweb_url = "";
if (content.return_code.Value == "SUCCESS" && content.result_code.Value == "SUCCESS")
{
trade_type = content.trade_type.Value;
prepay_id = content.prepay_id.Value;
mweb_url = content.mweb_url.Value;
isUnifiedOrderSuccess = true;
}
else
{
return_code = content.return_code.Value;
return_msg = content.return_msg.Value;
isUnifiedOrderSuccess = false;
}
if (!isUnifiedOrderSuccess)
{
return RedirectToAction("Failed", new { msg = return_msg });
} tpay_payrecord c = new tpay_payrecord();//支付记录
c.name = p.name;
c.out_trade_no = out_trade_no;
c.pid = p.id;
c.time_start = DateTime.Now;
c.spbill_create_ip = spbill_create_ip;
c.pay_fee = Convert.ToDecimal(Request["total_fee"]);
c.remark = Request["remark"];
c.state = ;
cManage.Add(c); //=============1.会刷新当前页=================
//return Json(mweb_url, JsonRequestBehavior.AllowGet);
//=============2.带参数据延时=================
var resultUrl = string.Format(mweb_url + "&redirect_url={0}/Pay/Result?no=" + c.out_trade_no, url);
return Json(resultUrl, JsonRequestBehavior.AllowGet);
//=============3.不带参去结果页=================
//var resultUrl = string.Format(mweb_url + "&redirect_url={0}/Pay/Result", url);
//return Json(resultUrl, JsonRequestBehavior.AllowGet);
}
//微信支付帮助类
public class WechatPayCommon
{ private static string[] strs = new string[]
{
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
};
/// <summary>
/// 创建随机字符串
/// </summary>
/// <returns></returns>
public static string CreateNonce_str()
{
Random r = new Random();
var sb = new StringBuilder();
var length = strs.Length;
for (int i = ; i < ; i++)
{
sb.Append(strs[r.Next(length - )]);
}
return sb.ToString();
} /// <summary>
/// 获取终端IP地址
/// </summary>
/// <returns></returns>
public static string GetWebClientIp()
{
string userIP = "";
try
{
if (System.Web.HttpContext.Current == null
|| System.Web.HttpContext.Current.Request == null
|| System.Web.HttpContext.Current.Request.ServerVariables == null)
return "";
string CustomerIP = "";
//CDN加速后取到的IP simone 090805
CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
if (!string.IsNullOrEmpty(CustomerIP))
{
return CustomerIP;
}
CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!String.IsNullOrEmpty(CustomerIP))
{
return CustomerIP;
}
if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
{
CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (CustomerIP == null)
CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
else
{
CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (string.Compare(CustomerIP, "unknown", true) == )
return System.Web.HttpContext.Current.Request.UserHostAddress;
return CustomerIP;
}
catch { }
return userIP;
} /// <summary>
/// 公共API => 统一下单
/// 不需要证书
/// http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=9_1#
/// 应用场景
///除被扫支付场景以外,商户系统先调用该接口在微信支付服务后台生成预支付交易单,返回正确的预支付交易回话标识后再按扫码、JSAPI、APP等不同场景生成交易串调起支付。
/// </summary>
/// <param name="appid">(必填) String(32) 微信分配的公众账号ID</param>
/// <param name="mch_id">(必填) String(32) 微信支付分配的商户号</param>
/// <param name="device_info"> String(32) 微信支付分配的终端设备号,商户自定义</param>
/// <param name="nonce_str">(必填) String(32) 随机字符串,不长于32位</param>
/// <param name="body">(必填) String(32) 商品描述 商品或支付单简要描</param>
/// <param name="detail"> String(8192) 商品详情 商品名称明细列表</param>
/// <param name="attach"> String(127) 附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据</param>
/// <param name="out_trade_no">(必填) String(32) 商家订单ID,32个字符内、可包含字母, 其他说明见第4.2节商户订单号:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_2 </param>
/// <param name="fee_type">符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见第4.2节货币类型: http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_2 </param>
/// <param name="total_fee">(必填) Int 订单总金额,只能为整数,详见第4.2节支付金额:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_2 </param>
/// <param name="spbill_create_ip">(必填) String(32)终端IP APP和网页支付提交用户端IP,Native支付填调用微信支付API的机器IP。</param>
/// <param name="time_start">String(14) 订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。</param>
/// <param name="time_expire">String(14) 订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。</param>
/// <param name="goods_tag">String(32) 商品标记,代金券或立减优惠功能的参数,说明详见第10节代金券或立减优惠:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=10_1 </param>
/// <param name="notify_url">(必填) String(256) 接收微信支付异步通知回调地址 </param>
/// <param name="trade_type">(必填) String(16) 交易类型,取值如下:JSAPI,NATIVE,APP,详细说明见第4.2节参数规定:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_2 </param>
/// <param name="product_id">(trade_type=NATIVE,此参数必传)String(32) 商品ID,trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。 </param>
/// <param name="openid">(trade_type=JSAPI,此参数必传)String(128)用户标识,trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。下单前需要调用【网页授权获取用户信息】接口获取到用户的Openid。 </param>
/// <param name="partnerKey">API密钥</param>
/// <returns>返回json字符串,格式参见:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=9_1 </returns>
public static dynamic UnifiedOrder(string appid, string mch_id,
string nonce_str, string body, string detail,
string out_trade_no, decimal total_fee, string spbill_create_ip, string time_start, string time_expire,
string notify_url, string trade_type, string partnerKey, out string returnMsg, out string xml
)
{
var stringADict = new Dictionary<string, string>();
stringADict.Add("appid", appid);
stringADict.Add("mch_id", mch_id);
stringADict.Add("nonce_str", nonce_str);
stringADict.Add("body", body);
stringADict.Add("out_trade_no", out_trade_no);
stringADict.Add("total_fee", total_fee.ToString());
stringADict.Add("spbill_create_ip", spbill_create_ip);
stringADict.Add("time_start", time_start);
stringADict.Add("time_expire", time_expire);
stringADict.Add("notify_url", notify_url);
stringADict.Add("trade_type", trade_type);
var sign = Sign(stringADict, partnerKey);//生成签名字符串
var postdata = PayUtil.GeneralPostdata(stringADict, sign);
xml = postdata;
var url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
var client = new HttpClient();
var result = client.PostAsync(url, new StringContent(postdata)).Result;
if (!result.IsSuccessStatusCode)
{
returnMsg = "请求失败";
return string.Empty;
}
returnMsg = result.Content.ReadAsStringAsync().Result;
return new DynamicXml(returnMsg);
} /// <summary>
/// 生成签名
/// 签名在线验证工具:
/// http://mch.weixin.qq.com/wiki/tools/signverify/
/// </summary>
/// <param name="stringADict">参与签名生成的参数列表</param>
/// <param name="partnerKey">商家私钥</param>
/// <returns></returns>
public static string Sign(IDictionary<string, string> stringADict, string partnerKey)
{
var sb = new StringBuilder();
foreach (var sA in stringADict.OrderBy(x => x.Key))//参数名ASCII码从小到大排序(字典序);
{
if (string.IsNullOrEmpty(sA.Value)) continue;//参数的值为空不参与签名;
if (string.Compare(sA.Key, "sign", true) == ) continue; // 参数中为签名的项,不参加计算
sb.Append(sA.Key).Append("=").Append(sA.Value).Append("&");
}
var string1 = sb.ToString();
string1 = string1.Remove(string1.Length - , );
sb.Append("key=").Append(partnerKey);//在stringA最后拼接上key=(API密钥的值)得到stringSignTemp字符串
var stringSignTemp = sb.ToString();
var sign = Util.MD5(stringSignTemp, "UTF-8").ToUpper();//对stringSignTemp进行MD5运算,再将得到的字符串所有字符转换为大写,得到sign值signValue。
return sign;
} /// <summary>
/// 创建时间戳
/// </summary>
/// <returns></returns>
public static long CreateTimestamp()
{
return (DateTime.Now.ToUniversalTime().Ticks - ) / ;
} public static string SignPay(string appid, string timeStamp, string nonceStr, string prepayId, string partnerKey)
{
var signDict = new Dictionary<string, string>();
signDict.Add("appId", appid);
signDict.Add("timeStamp", timeStamp);
signDict.Add("nonceStr", nonceStr);
signDict.Add("package", "prepay_id=" + prepayId);
signDict.Add("signType", "MD5");
string buff = "";
foreach (var pair in signDict.OrderBy(x => x.Key))
{
if (pair.Value == null)
{
continue;
} if (pair.Key != "sign" && pair.Value.ToString() != "")
{
buff += pair.Key + "=" + pair.Value + "&";
}
}
buff = buff.Trim('&');
buff += "&key=" + partnerKey;
return Util.MD5(buff, "UTF-8").ToUpper();
} }
/// <summary>
/// 公共API => 支付结果通用通知
/// http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=9_7
/// 微信支付回调,不需要证书
///
/// 应用场景
/// 支付完成后,微信会把相关支付结果和用户信息发送给商户,商户需要接收处理,并返回应答。
/// 对后台通知交互时,如果微信收到商户的应答不是成功或超时,微信认为通知失败,微信会通过一定的策略(如30分钟共8次)定期重新发起通知,尽可能提高通知的成功率,但微信不保证通知最终能成功。
/// 由于存在重新发送后台通知的情况,因此同样的通知可能会多次发送给商户系统。商户系统必须能够正确处理重复的通知。
/// 推荐的做法是,当收到通知进行处理时,首先检查对应业务数据的状态,判断该通知是否已经处理过,如果没有处理过再进行处理,如果处理过直接返回结果成功。在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱。
/// 技术人员可登进微信商户后台扫描加入接口报警群。
/// </summary>
/// <returns></returns>
[AllowAnonymous]
public ActionResult Notify()
{
var doc = XDocument.Load(Request.InputStream);
var sPara = doc.Root.Descendants().ToDictionary(x => x.Name.LocalName, x => x.Value);
if (sPara.Count <= )
{
throw new ArgumentNullException();
} LogWriter.Default.WriteInfo("Notify Parameters:" + sPara.ToString());//记录请求关键信息到日志中去 if (sPara["return_code"] == "SUCCESS" && sPara["result_code"] == "SUCCESS")
{
var sign = sPara["sign"];
var partnerKey = System.Configuration.ConfigurationManager.AppSettings["PartnerKey"];//API密钥
var signValue = WechatPayCommon.Sign(sPara, partnerKey);
bool isVerify = sign == signValue;
LogWriter.Default.WriteInfo("Verify:" + isVerify + "|sign/signValue:" + sign + "," + signValue);
if (isVerify)
{
string out_trade_no = sPara["out_trade_no"];//商户订单ID: 1.注意交易单不要重复处理;2.注意判断返回金额
string transaction_id = sPara["transaction_id"]; //微信支付订单号
string time_end = sPara["time_end"];//支付完成时间
Decimal total_fee = Decimal.Parse(sPara["total_fee"]); //总金额
string bank_type = sPara["bank_type"]; //付款银行 //****************************************************************************************
//TODO 商户处理订单逻辑: 1.注意交易单不要重复处理;2.注意判断返回金额
Model.tpay_payrecord p = cManage.GetModel(" and out_trade_no='" + out_trade_no + "'");
if (p != null && p.state != )
{
p.transaction_id = transaction_id;
p.bank_type = GetBankType(bank_type);
p.time_end = DateTime.ParseExact(time_end, "yyyyMMddHHmmss", CultureInfo.CurrentCulture);
p.total_fee = total_fee / ;
p.state = ; cManage.Update(p);
} LogWriter.Default.WriteInfo("Notify Success, out_trade_no:" + out_trade_no + ",transaction_id" + transaction_id + ",time_end:" + time_end + ",total_fee:" + total_fee + ",bank_type:" + bank_type);
//return Content("<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>"); // ====================================================================
// 通知微信.异步确认成功.必写.不然会一直通知后台.八次之后就认为交易失败了. 这么写回调了三次 应该是达到了通知结果吧 尝试过多种写法 如果你有好的方案 欢迎留言交流
Response.ContentType = "text/xml";
Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>");
Response.End();
return Content("<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>");
}
}
return Content(string.Format("<xml><return_code><![CDATA[{0}]]></return_code></xml>", "FAIL"));
}
/// <summary>
/// 支付结果页
/// </summary>
/// <returns></returns>
public ActionResult Result()
{
if (!string.IsNullOrEmpty(Request["pid"]))
{
int pid = Convert.ToInt32(Request["pid"]);
ViewBag.Payrecord = cManage.GetModel(pid);
}
else
{
ViewBag.Cored = cManage.GetModel(" and out_trade_no='" + Request["no"] + "'");
}
return View();
}
<div class="weui-mask weui-mask--visible"></div>
<div class="weui-dialog weui-dialog--visible doing_dialog_box">
<div class="weui-dialog__hd">
<strong class="weui-dialog__title">请确认微信支付是否已完成</strong>
</div>
<div class="weui-dialog__bd" onclick="javascript:window.location.href='/Pay/Result?pid=@c.id'"><a href="javascript:">已完成支付</a></div>
<div class="weui-dialog__ft" onclick="javascript:window.location.href='/Pay/Index?pid=@c.pid'">
<a class="weui-dialog__btn" href="javascript:">支付遇到问题,重新支付</a>
</div>
</div>

/// <summary>
/// 获取支付银行
/// </summary>
/// <param name="bank_type"></param>
/// <returns></returns>
private string GetBankType(string bank_type)
{
string name = "";
switch (bank_type)
{
case "ICBC_DEBIT":
name = "工商银行(借记卡)";
break;
case "ICBC_CREDIT":
name = "工商银行(信用卡)";
break;
case "ABC_DEBIT":
name = "农业银行(借记卡)";
break;
case "ABC_CREDIT":
name = "农业银行(信用卡)";
break;
case "PSBC_DEBIT":
name = "邮政储蓄银行(借记卡)";
break;
case "PSBC_CREDIT":
name = "邮政储蓄银行(信用卡)";
break;
case "CCB_DEBIT":
name = "建设银行(借记卡)";
break;
case "CCB_CREDIT":
name = "建设银行(信用卡)";
break;
case "CMB_DEBIT":
name = "招商银行(借记卡)";
break;
case "CMB_CREDIT":
name = "招商银行(信用卡)";
break;
case "BOC_DEBIT":
name = "中国银行(借记卡)";
break;
case "BOC_CREDIT":
name = "中国银行(信用卡)";
break;
case "COMM_DEBIT":
name = "交通银行(借记卡)";
break;
case "COMM_CREDIT":
name = "交通银行(信用卡)";
break;
case "SPDB_DEBIT":
name = "浦发银行(借记卡)";
break;
case "SPDB_CREDIT":
name = "浦发银行(信用卡)";
break;
case "GDB_DEBIT":
name = "广发银行(借记卡)";
break;
case "GDB_CREDIT":
name = "广发银行(信用卡)";
break;
case "CMBC_DEBIT":
name = "民生银行(借记卡)";
break;
case "CMBC_CREDIT":
name = "民生银行(信用卡)";
break;
case "PAB_DEBIT":
name = "平安银行(借记卡)";
break;
case "PAB_CREDIT":
name = "平安银行(信用卡)";
break;
case "CEB_DEBIT":
name = "光大银行(借记卡)";
break;
case "CEB_CREDIT":
name = "光大银行(信用卡)";
break;
case "CIB_DEBIT":
name = "兴业银行(借记卡)";
break;
case "CIB_CREDIT":
name = "兴业银行(信用卡)";
break;
case "CITIC_DEBIT":
name = "中信银行(借记卡)";
break;
case "CITIC_CREDIT":
name = "中信银行(信用卡)";
break;
case "BOSH_DEBIT":
name = "上海银行(借记卡)";
break;
case "BOSH_CREDIT":
name = "上海银行(信用卡)";
break;
case "CRB_DEBIT":
name = "华润银行(借记卡)";
break;
case "HZB_DEBIT":
name = "杭州银行(借记卡)";
break;
case "HZB_CREDIT":
name = "杭州银行(信用卡)";
break;
case "BSB_DEBIT":
name = "包商银行(借记卡)";
break;
case "BSB_CREDIT":
name = "包商银行(信用卡)";
break;
case "CQB_DEBIT":
name = "重庆银行(借记卡)";
break;
case "SDEB_DEBIT":
name = "顺德农商行(借记卡)";
break;
case "SZRCB_DEBIT":
name = "深圳农商银行(借记卡)";
break;
case "SZRCB_CREDIT":
name = "深圳农商银行(信用卡)";
break;
case "HRBB_DEBIT":
name = "哈尔滨银行(借记卡)";
break;
case "BOCD_DEBIT":
name = "成都银行(借记卡)";
break;
case "GDNYB_DEBIT":
name = "南粤银行(借记卡)";
break;
case "GDNYB_CREDIT":
name = "南粤银行(信用卡)";
break;
case "GZCB_DEBIT":
name = "广州银行(借记卡)";
break;
case "GZCB_CREDIT":
name = "广州银行(信用卡)";
break;
case "JSB_DEBIT":
name = "江苏银行(借记卡)";
break;
case "JSB_CREDIT":
name = "江苏银行(信用卡)";
break;
case "NBCB_DEBIT":
name = "宁波银行(借记卡)";
break;
case "NBCB_CREDIT":
name = "宁波银行(信用卡)";
break;
case "NJCB_DEBIT":
name = "南京银行(借记卡)";
break;
case "QHNX_DEBIT":
name = "青海农信(借记卡)";
break;
case "ORDOSB_CREDIT":
name = "鄂尔多斯银行(信用卡)";
break;
case "ORDOSB_DEBIT":
name = "鄂尔多斯银行(借记卡)";
break;
case "BJRCB_CREDIT":
name = "北京农商(信用卡)";
break;
case "BHB_DEBIT":
name = "河北银行(借记卡)";
break;
case "BGZB_DEBIT":
name = "贵州银行(借记卡)";
break;
case "BEEB_DEBIT":
name = "鄞州银行(借记卡)";
break;
case "PZHCCB_DEBIT":
name = "攀枝花银行(借记卡)";
break;
case "QDCCB_CREDIT":
name = "青岛银行(信用卡)";
break;
case "QDCCB_DEBIT":
name = "青岛银行(借记卡)";
break;
case "SHINHAN_DEBIT":
name = "新韩银行(借记卡)";
break;
case "QLB_DEBIT":
name = "齐鲁银行(借记卡)";
break;
case "QSB_DEBIT":
name = "齐商银行(借记卡)";
break;
case "ZZB_DEBIT":
name = "郑州银行(借记卡)";
break;
case "CCAB_DEBIT":
name = "长安银行(借记卡)";
break;
case "RZB_DEBIT":
name = "日照银行(借记卡)";
break;
case "SCNX_DEBIT":
name = "四川农信(借记卡)";
break;
case "BEEB_CREDIT":
name = "鄞州银行(信用卡)";
break;
case "SDRCU_DEBIT":
name = "山东农信(借记卡)";
break;
case "BCZ_DEBIT":
name = "沧州银行(借记卡)";
break;
case "SJB_DEBIT":
name = "盛京银行(借记卡)";
break;
case "LNNX_DEBIT":
name = "辽宁农信(借记卡)";
break;
case "JUFENGB_DEBIT":
name = "临朐聚丰村镇银行(借记卡)";
break;
case "ZZB_CREDIT":
name = "郑州银行(信用卡)";
break;
case "JXNXB_DEBIT":
name = "江西农信(借记卡)";
break;
case "JZB_DEBIT":
name = "晋中银行(借记卡)";
break;
case "JZCB_CREDIT":
name = "锦州银行(信用卡)";
break;
case "JZCB_DEBIT":
name = "锦州银行(借记卡)";
break;
case "KLB_DEBIT":
name = "昆仑银行(借记卡)";
break;
case "KRCB_DEBIT":
name = "昆山农商(借记卡)";
break;
case "KUERLECB_DEBIT":
name = "库尔勒市商业银行(借记卡)";
break;
case "LJB_DEBIT":
name = "龙江银行(借记卡)";
break;
case "NYCCB_DEBIT":
name = "南阳村镇银行(借记卡)";
break;
case "LSCCB_DEBIT":
name = "乐山市商业银行(借记卡)";
break;
case "LUZB_DEBIT":
name = "柳州银行(借记卡)";
break;
case "LWB_DEBIT":
name = "莱商银行(借记卡)";
break;
case "LYYHB_DEBIT":
name = "辽阳银行(借记卡)";
break;
case "LZB_DEBIT":
name = "兰州银行(借记卡)";
break;
case "MINTAIB_CREDIT":
name = "民泰银行(信用卡)";
break;
case "MINTAIB_DEBIT":
name = "民泰银行(借记卡)";
break;
case "NCB_DEBIT":
name = "宁波通商银行(借记卡)";
break;
case "NMGNX_DEBIT":
name = "内蒙古农信(借记卡)";
break;
case "XAB_DEBIT":
name = "西安银行(借记卡)";
break;
case "WFB_CREDIT":
name = "潍坊银行(信用卡)";
break;
case "WFB_DEBIT":
name = "潍坊银行(借记卡)";
break;
case "WHB_CREDIT":
name = "威海商业银行(信用卡)";
break;
case "WHB_DEBIT":
name = "威海市商业银行(借记卡)";
break;
case "WHRC_CREDIT":
name = "武汉农商(信用卡)";
break;
case "WHRC_DEBIT":
name = "武汉农商行(借记卡)";
break;
case "WJRCB_DEBIT":
name = "吴江农商行(借记卡)";
break;
case "WLMQB_DEBIT":
name = "乌鲁木齐银行(借记卡)";
break;
case "WRCB_DEBIT":
name = "无锡农商(借记卡)";
break;
case "WZB_DEBIT":
name = "温州银行(借记卡)";
break;
case "XAB_CREDIT":
name = "西安银行(信用卡)";
break;
case "WEB_DEBIT":
name = "微众银行(借记卡)";
break;
case "XIB_DEBIT":
name = "厦门国际银行(借记卡)";
break;
case "XJRCCB_DEBIT":
name = "新疆农信银行(借记卡)";
break;
case "XMCCB_DEBIT":
name = "厦门银行(借记卡)";
break;
case "YNRCCB_DEBIT":
name = "云南农信(借记卡)";
break;
case "YRRCB_CREDIT":
name = "黄河农商银行(信用卡)";
break;
case "YRRCB_DEBIT":
name = "黄河农商银行(借记卡)";
break;
case "YTB_DEBIT":
name = "烟台银行(借记卡)";
break;
case "ZJB_DEBIT":
name = "紫金农商银行(借记卡)";
break;
case "ZJLXRB_DEBIT":
name = "兰溪越商银行(借记卡)";
break;
case "ZJRCUB_CREDIT":
name = "浙江农信(信用卡)";
break;
case "AHRCUB_DEBIT":
name = "安徽省农村信用社联合社(借记卡)";
break;
case "BCZ_CREDIT":
name = "沧州银行(信用卡)";
break;
case "SRB_DEBIT":
name = "上饶银行(借记卡)";
break;
case "ZYB_DEBIT":
name = "中原银行(借记卡)";
break;
case "ZRCB_DEBIT":
name = "张家港农商行(借记卡)";
break;
case "SRCB_CREDIT":
name = "上海农商银行(信用卡)";
break;
case "SRCB_DEBIT":
name = "上海农商银行(借记卡)";
break;
case "ZJTLCB_DEBIT":
name = "浙江泰隆银行(借记卡)";
break;
case "SUZB_DEBIT":
name = "苏州银行(借记卡)";
break;
case "SXNX_DEBIT":
name = "山西农信(借记卡)";
break;
case "SXXH_DEBIT":
name = "陕西信合(借记卡)";
break;
case "ZJRCUB_DEBIT":
name = "浙江农信(借记卡)";
break;
case "AE_CREDIT":
name = "AE(信用卡)";
break;
case "TACCB_CREDIT":
name = "泰安银行(信用卡)";
break;
case "TACCB_DEBIT":
name = "泰安银行(借记卡)";
break;
case "TCRCB_DEBIT":
name = "太仓农商行(借记卡)";
break;
case "TJBHB_CREDIT":
name = "天津滨海农商行(信用卡)";
break;
case "TJBHB_DEBIT":
name = "天津滨海农商行(借记卡)";
break;
case "TJB_DEBIT":
name = "天津银行(借记卡)";
break;
case "TRCB_DEBIT":
name = "天津农商(借记卡)";
break;
case "TZB_DEBIT":
name = "台州银行(借记卡)";
break;
case "URB_DEBIT":
name = "联合村镇银行(借记卡)";
break;
case "DYB_CREDIT":
name = "东营银行(信用卡)";
break;
case "CSRCB_DEBIT":
name = "常熟农商银行(借记卡)";
break;
case "CZB_CREDIT":
name = "浙商银行(信用卡)";
break;
case "CZB_DEBIT":
name = "浙商银行(借记卡)";
break;
case "CZCB_CREDIT":
name = "稠州银行(信用卡)";
break;
case "CZCB_DEBIT":
name = "稠州银行(借记卡)";
break;
case "DANDONGB_CREDIT":
name = "丹东银行(信用卡)";
break;
case "DANDONGB_DEBIT":
name = "丹东银行(借记卡)";
break;
case "DLB_CREDIT":
name = "大连银行(信用卡)";
break;
case "DLB_DEBIT":
name = "大连银行(借记卡)";
break;
case "DRCB_CREDIT":
name = "东莞农商银行(信用卡)";
break;
case "DRCB_DEBIT":
name = "东莞农商银行(借记卡)";
break;
case "CSRCB_CREDIT":
name = "常熟农商银行(信用卡)";
break;
case "DYB_DEBIT":
name = "东营银行(借记卡)";
break;
case "DYCCB_DEBIT":
name = "德阳银行(借记卡)";
break;
case "FBB_DEBIT":
name = "富邦华一银行(借记卡)";
break;
case "FDB_DEBIT":
name = "富滇银行(借记卡)";
break;
case "FJHXB_CREDIT":
name = "福建海峡银行(信用卡)";
break;
case "FJHXB_DEBIT":
name = "福建海峡银行(借记卡)";
break;
case "FJNX_DEBIT":
name = "福建农信银行(借记卡)";
break;
case "FUXINB_DEBIT":
name = "阜新银行(借记卡)";
break;
case "BOCDB_DEBIT":
name = "承德银行(借记卡)";
break;
case "JSNX_DEBIT":
name = "江苏农商行(借记卡)";
break;
case "BOLFB_DEBIT":
name = "廊坊银行(借记卡)";
break;
case "CCAB_CREDIT":
name = "长安银行(信用卡)";
break;
case "CBHB_DEBIT":
name = "渤海银行(借记卡)";
break;
case "CDRCB_DEBIT":
name = "成都农商银行(借记卡)";
break;
case "BYK_DEBIT":
name = "营口银行(借记卡)";
break;
case "BOZ_DEBIT":
name = "张家口市商业银行(借记卡)";
break;
case "CFT":
name = "零钱";
break;
case "BOTSB_DEBIT":
name = "唐山银行(借记卡)";
break;
case "BOSZS_DEBIT":
name = "石嘴山银行(借记卡)";
break;
case "BOSXB_DEBIT":
name = "绍兴银行(借记卡)";
break;
case "BONX_DEBIT":
name = "宁夏银行(借记卡)";
break;
case "BONX_CREDIT":
name = "宁夏银行(信用卡)";
break;
case "GDHX_DEBIT":
name = "广东华兴银行(借记卡)";
break;
case "BOLB_DEBIT":
name = "洛阳银行(借记卡)";
break;
case "BOJX_DEBIT":
name = "嘉兴银行(借记卡)";
break;
case "BOIMCB_DEBIT":
name = "内蒙古银行(借记卡)";
break;
case "BOHN_DEBIT":
name = "海南银行(借记卡)";
break;
case "BOD_DEBIT":
name = "东莞银行(借记卡)";
break;
case "CQRCB_CREDIT":
name = "重庆农商银行(信用卡)";
break;
case "CQRCB_DEBIT":
name = "重庆农商银行(借记卡)";
break;
case "CQTGB_DEBIT":
name = "重庆三峡银行(借记卡)";
break;
case "BOD_CREDIT":
name = "东莞银行(信用卡)";
break;
case "CSCB_DEBIT":
name = "长沙银行(借记卡)";
break;
case "BOB_CREDIT":
name = "北京银行(信用卡)";
break;
case "GDRCU_DEBIT":
name = "广东农信银行(借记卡)";
break;
case "BOB_DEBIT":
name = "北京银行(借记卡)";
break;
case "HRXJB_DEBIT":
name = "华融湘江银行(借记卡)";
break;
case "HSBC_DEBIT":
name = "恒生银行(借记卡)";
break;
case "HSB_CREDIT":
name = "徽商银行(信用卡)";
break;
case "HSB_DEBIT":
name = "徽商银行(借记卡)";
break;
case "HUNNX_DEBIT":
name = "湖南农信(借记卡)";
break;
case "HUSRB_DEBIT":
name = "湖商村镇银行(借记卡)";
break;
case "HXB_CREDIT":
name = "华夏银行(信用卡)";
break;
case "HXB_DEBIT":
name = "华夏银行(借记卡)";
break;
case "HNNX_DEBIT":
name = "河南农信(借记卡)";
break;
case "BNC_DEBIT":
name = "江西银行(借记卡)";
break;
case "BNC_CREDIT":
name = "江西银行(信用卡)";
break;
case "BJRCB_DEBIT":
name = "北京农商行(借记卡)";
break;
case "JCB_DEBIT":
name = "晋城银行(借记卡)";
break;
case "JJCCB_DEBIT":
name = "九江银行(借记卡)";
break;
case "JLB_DEBIT":
name = "吉林银行(借记卡)";
break;
case "JLNX_DEBIT":
name = "吉林农信(借记卡)";
break;
case "JNRCB_DEBIT":
name = "江南农商(借记卡)";
break;
case "JRCB_DEBIT":
name = "江阴农商行(借记卡)";
break;
case "JSHB_DEBIT":
name = "晋商银行(借记卡)";
break;
case "HAINNX_DEBIT":
name = "海南农信(借记卡)";
break;
case "GLB_DEBIT":
name = "桂林银行(借记卡)";
break;
case "GRCB_CREDIT":
name = "广州农商银行(信用卡)";
break;
case "GRCB_DEBIT":
name = "广州农商银行(借记卡)";
break;
case "GSB_DEBIT":
name = "甘肃银行(借记卡)";
break;
case "GSNX_DEBIT":
name = "甘肃农信(借记卡)";
break;
case "GXNX_DEBIT":
name = "广西农信(借记卡)";
break;
case "GYCB_CREDIT":
name = "贵阳银行(信用卡)";
break;
case "GYCB_DEBIT":
name = "贵阳银行(借记卡)";
break;
case "GZNX_DEBIT":
name = "贵州农信(借记卡)";
break;
case "HAINNX_CREDIT":
name = "海南农信(信用卡)";
break;
case "HKB_DEBIT":
name = "汉口银行(借记卡)";
break;
case "HANAB_DEBIT":
name = "韩亚银行(借记卡)";
break;
case "HBCB_CREDIT":
name = "湖北银行(信用卡)";
break;
case "HBCB_DEBIT":
name = "湖北银行(借记卡)";
break;
case "HBNX_CREDIT":
name = "湖北农信(信用卡)";
break;
case "HBNX_DEBIT":
name = "湖北农信(借记卡)";
break;
case "HDCB_DEBIT":
name = "邯郸银行(借记卡)";
break;
case "HEBNX_DEBIT":
name = "河北农信(借记卡)";
break;
case "HFB_DEBIT":
name = "恒丰银行(借记卡)";
break;
case "HKBEA_DEBIT":
name = "东亚银行(借记卡)";
break;
case "JCB_CREDIT":
name = "JCB(信用卡)";
break;
case "MASTERCARD_CREDIT":
name = "MASTERCARD(信用卡)";
break;
case "VISA_CREDIT":
name = "VISA(信用卡)";
break;
case "LQT":
name = "零钱通";
break;
default:
name = "未知银行";
break;
}
return name;
}

说实话还是比较简单的,要细心一点,参数比较多,建议写成配置的,

最主要的地方是  处理8次微信的通知   如果8次没给到微信成功的回复  它会默认你这笔交易是失败的

还有一个需要注意   如果你用微信的redirect_url直接到结果页的话  会出现数据库记录还未更新到支付的情况  需要中间做点处理  可以弹页面  可以做倒计时  反正就是打一个时间差吧

---------------------------------------------------------------------------------------------------------

转载请记得说明作者和出处哦-.-
作者:KingDuDu
原文出处:https://www.cnblogs.com/kingdudu/articles/8795700.html

---------------------------------------------------------------------------------------------------------

【第二十篇】C#微信H5支付 非微信内浏览器H5支付 浏览器微信支付的更多相关文章

  1. Python开发【第二十篇】:缓存

    Python开发[第二十篇]:缓存redis&Memcache   点击这里 Python之路[第九篇]:Python操作 RabbitMQ.Redis.Memcache.SQLAlchemy ...

  2. Python之路【第二十篇】:待更新中.....

    Python之路[第二十篇]:待更新中.....

  3. “全栈2019”Java多线程第二十八章:公平锁与非公平锁详解

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java多 ...

  4. Egret入门学习日记 --- 第二十篇(书中 9.1~9.3 节 内容 组件篇)

    第二十篇(书中 9.1~9.3 节 内容 组件篇) 第八章中的内容. 以上都是基本的Js知识,我就不录入了. 直接来看 第9章. 开始 9.1节. 以上内容告诉你,Egret官方舍弃了GUI,使用了E ...

  5. 第二十篇 .NET高级技术之C#中的线程(二) 线程同步基础

    1.同步要领 下面的表格列展了.NET对协调或同步线程动作的可用的工具:                       简易阻止方法 构成 目的 Sleep 阻止给定的时间周期 Join 等待另一个线程 ...

  6. 【Python之路】第二十篇--MySQL(二)

    视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名], 用户使用时只需使用[名称]即可获取结果集,并可以将其当作表来使用. 1.创建视图 --格式:CREATE ...

  7. Python之路【第二十篇】Tornado框架

    Tornado Tornado是使用Python编写的一个强大的.可扩展的Web服务器.它在处理严峻的网络流量时表现得足够强健,但却在创建和编写时有着足够的轻量级,并能够被用在大量的应用和工具中. 我 ...

  8. 第二十篇:在SOUI中使用分层窗口

    从Windows 2K开始,MS为UI开发引入了分层窗口这一窗口风格.使用分层窗口,应用程序的主窗口可以是半透明,也可以是逐点半透明(即每一个像素点的透明度可以不同). 可以说,正是因为有了分层窗口, ...

  9. Python之路(第二十篇) subprocess模块

    一.subprocess模块 subprocess英文意思:子进程 那什么是进程呢? (一)关于进程的相关理论基础知识 进程是对正在运行程序的一个抽象,进程的概念起源于操作系统,是操作系统最核心的概念 ...

随机推荐

  1. 纯js生成验证码

    实现代码: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"& ...

  2. 关于Unity的协程

    协程 认识协程 //协程不是多线程:是一段在主程序之外执行的代码 //协程不受生命周影响 //作用:能够口直代码在特定的时间执行. //1,延时操作 //2,等待某代码执行结束之后执行 /* 特点:1 ...

  3. [译]ASP.NET Core依赖注入深入讨论

    原文链接:ASP.NET Core Dependency Injection Deep Dive - Joonas W's blog 这篇文章我们来深入探讨ASP.NET Core.MVC Core中 ...

  4. 配置CNPM-基础案例

    下面给出一个样例配置: JavaScript module.exports = { enableCluster: true, database: { db: "snpm", use ...

  5. Office远程代码执行漏洞(CVE-2017-11882)复现

    昨晚看到的有复现的文章,一直到今天才去自己复现了一遍,还是例行记录一下. POC: https://github.com/Ridter/CVE-2017-11882/ 一.简单的生成弹计算器的doc文 ...

  6. css3新单位vw、vh的使用详解

    响应式布局的单位我们第一时间会想到通过rem单位来实现适配,但是它还需要内嵌一段脚本去动态计算跟元素大小. 比如: (function (doc, win) { let docEl = doc.doc ...

  7. 格式化JSON数据

    function formatJson(json, options) { var reg = null, formatted = '', pad = 0, PADDING = ' '; options ...

  8. 远程通信的几种选择(RPC,Webservice,RMI,JMS的区别)

    RPC(Remote Procedure Call Protocol) RPC使用C/S方式,采用http协议,发送请求到服务器,等待服务器返回结果.这个请求包括一个参数集和一个文本集,通常形成&qu ...

  9. leaflet简单例子,绘制多边形

    var crs = L.CRS.EPSG900913; var map = L.map('map', { crs: crs, width: '100%', height: '100%', maxZoo ...

  10. Android开发之dip, dp, px, sp区别

    显示单位px和dip以及sp的区别 dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA.HVGA和Q ...