微信商户号
虚拟类目,单笔限额3000
实物最高5万
1.设置好操作码,API密钥
2.产品管理-申请扫码支付native
扫码不支持长按识别二维码
3.商户号绑定发起申请
官方审核需要1-3个工作日
审核通过之后
4.到对应的公众号中授权APPID授权管理
到165通讯公众号去审核确认
微信支付--商户号管理--待关联商户号(服务商模式)(AppID:wxd8e2cff2bd67f31d)审核通过
已关联商户号
登录公众号
微信支付-商户号管理
如果不通过审核,否则报错如下
<xml> <return_code><![CDATA[FAIL]]></return_code> <return_msg><![CDATA[appid和mch_id不匹配]]></return_msg> </xml>
https://shop.jnlxsm.net/WeChatManage/user_order/payment/30?Tel=17179104520&Price=99
调用扫码支付接口paymentProcess
1 public ActionResult paymentProcess(int? id) 2 { 3 //return Content("{"code":true,"status":true,"msg":"提交成功!","data":{"appid":"wx288f944166a4bdc6","code_url":"weixin://wxpay/bizpayurl?pr=K9tQFgw","mch_id":"1582948931","nonce_str":"gelx5Eej34TWkYjL","prepay_id":"wx18152655644502b82539bf421260374600","result_code":"SUCCESS","return_code":"SUCCESS","return_msg":null,"sign":"4D19F96F050056C904DBD7371D974905","trade_type":"NATIVE","trade_no":"LX-20200418151928103008","payid":"11","wx_query_href":"http://localhost:4066/WeChatManage/user_order/queryWx/11","wx_query_over":"http://localhost:4066/WeChatManage/user_order/paymentFinish/11"}}"); 4 try 5 { 6 OrdersEntity ordersEntity = ordersbll.GetEntity(id); 7 8 var sp_billno = ordersEntity.OrderSn; 9 var nonceStr = TenPayV3Util.GetNoncestr(); 10 11 //商品Id,用户自行定义 12 string productId = ordersEntity.TelphoneID.ToString(); 13 14 //创建请求统一订单接口参数 15 var xmlDataInfo = new TenPayV3UnifiedorderRequestData(WeixinConfig.AppID2, 16 tenPayV3Info.MchId, 17 "支付靓号", 18 sp_billno, 19 Convert.ToInt32(ordersEntity.Price * 100), 20 Request.UserHostAddress, 21 tenPayV3Info.TenPayV3Notify, 22 TenPayV3Type.NATIVE, 23 null, 24 tenPayV3Info.Key, 25 nonceStr, 26 productId: productId); 27 //调用统一订单接口 28 var result = TenPayV3.Unifiedorder(xmlDataInfo); 29 30 LogHelper.AddLog(result.ResultXml);//记录日志 31 32 H5Response root = null; 33 if (result.return_code== "SUCCESS") 34 { 35 H5PayData h5PayData = new H5PayData() 36 { 37 appid = WeixinConfig.AppID2, 38 code_url = result.code_url,//weixin://wxpay/bizpayurl?pr=lixpXgt 39 mch_id = WeixinConfig.MchId, 40 nonce_str = result.nonce_str, 41 prepay_id = result.prepay_id, 42 result_code = result.result_code, 43 return_code = result.return_code, 44 return_msg = result.return_msg, 45 sign = result.sign, 46 trade_type = "NATIVE", 47 trade_no = sp_billno, 48 payid = id.ToString(), 49 wx_query_href = Config.GetValue("Domain2") + "/WeChatManage/user_order/queryWx/" + id, 50 wx_query_over = Config.GetValue("Domain2") + "/WeChatManage/user_order/paymentFinish/" + id 51 }; 52 53 root = new H5Response { code = true, status = true, msg = "u63d0u4ea4u6210u529fuff01", data = h5PayData }; 54 } 55 else 56 { 57 root = new H5Response { code = false, status = false, msg = result.return_msg }; 58 } 59 LogHelper.AddLog(JsonConvert.SerializeObject(root));//记录日志 60 61 return Content(JsonConvert.SerializeObject(root)); 62 } 63 catch (Exception ex) 64 { 65 LogHelper.AddLog(ex.Message);//记录日志 66 throw; 67 } 68 }
发起:统一接口返回报文
<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> <appid><![CDATA[wx8992efd4c27f5f68]]></appid> <mch_id><![CDATA[1578423131]]></mch_id> <nonce_str><![CDATA[LUU62TbfGp6H3swj]]></nonce_str> <sign><![CDATA[FD33FC2620BD64626016B3316371DB53]]></sign> <result_code><![CDATA[SUCCESS]]></result_code> <prepay_id><![CDATA[wx25141532666981e880fbd57f1682195600]]></prepay_id> <trade_type><![CDATA[NATIVE]]></trade_type> <code_url><![CDATA[weixin://wxpay/bizpayurl?pr=PwTt4b7]]></code_url> </xml>
商户号弃用
<xml> <return_code><![CDATA[FAIL]]></return_code> <return_msg><![CDATA[商户号该产品权限处罚中,请前往商户平台>产品中心检查后重试]]></return_msg> </xml>
5.支付回调接口
https://shop.jnlxsm.net/WeChatManage/WeiXinHome/Notify
//微信支付回调地址 public ActionResult Notify() { LogHelper.AddLog("支付回调地址");//记录日志 ResponseHandler rspHandler = new ResponseHandler(null); rspHandler.SetKey(WeixinConfig.Key); LogHelper.AddLog(rspHandler.ParseXML());//记录日志 //SUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查看result_code来判断 SUCCESS string return_code = rspHandler.GetParameter("return_code"); string return_msg = rspHandler.GetParameter("return_msg"); if (rspHandler.IsTenpaySign()) { if (return_code == "SUCCESS") { //订单号 string orderSn = rspHandler.GetParameter("out_trade_no"); OrdersEntity order = ordersbll.GetEntityByOrderSn(orderSn); order.PayDate = DateTime.Now; order.PayStatus = (int)PayStatus.已支付; order.Status = (int)OrderStatus.未发货; ordersbll.SaveForm(order.Id, order); TelphoneLiangEntity tel = tlbll.GetEntityByOrgTel(order.Tel); if (tel != null) { tel.SellMark = 1; tel.SellerName = "砍价活动出售"; } tlbll.SaveForm(tel.TelphoneID,tel); } } string xml = string.Format(@"<xml> <return_code><![CDATA[{0}]]></return_code> <return_msg><![CDATA[{1}]]></return_msg> </xml>", return_code, return_msg); return Content(xml, "text/xml"); }
<?xml version="1.0" encoding="UTF-8"?> <xml> <appid><![CDATA[wx288f944166a4bdc6]]></appid> <bank_type><![CDATA[OTHERS]]></bank_type> <cash_fee>1</cash_fee> <fee_type><![CDATA[CNY]]></fee_type> <is_subscribe><![CDATA[Y]]></is_subscribe> <mch_id><![CDATA[1582948931]]></mch_id> <nonce_str><![CDATA[98BACD18187522A70CBCA35C2562A503]]></nonce_str> <openid><![CDATA[oFY4Qt28aQ6vjUldz9BfvINb2NlM]]></openid> <out_trade_no><![CDATA[LX-20200419203921177452]]></out_trade_no> <result_code><![CDATA[SUCCESS]]></result_code> <return_code><![CDATA[SUCCESS]]></return_code> <sign><![CDATA[2E1D122E06F91E93E8B2705D330241DB]]></sign> <time_end><![CDATA[20200419204028]]></time_end> <total_fee>1</total_fee> <trade_type><![CDATA[NATIVE]]></trade_type> <transaction_id><![CDATA[4200000525202004196668100608]]></transaction_id> </xml>
6.生成二维码扫码
"<img src="/WeChatManage/user_index/getPageqr/?pageurl=weixin%3A%2F%2Fwxpay%2Fbizpayurl%3Fpr%3DK9tQFgw" style="max-100%;" />"
生成二维码代码
1 public ActionResult getPageqr(string pageurl) 2 { 3 BitMatrix bitMatrix; 4 bitMatrix = new MultiFormatWriter().encode(pageurl, BarcodeFormat.QR_CODE, 600, 600); 5 BarcodeWriter bw = new BarcodeWriter(); 6 7 var ms = new MemoryStream(); 8 var bitmap = bw.Write(bitMatrix); 9 bitmap.Save(ms, ImageFormat.Png); 10 //return File(ms, "image/png"); 11 ms.WriteTo(Response.OutputStream); 12 Response.ContentType = "image/png"; 13 return null; 14 }
其它错误
当前交易异常,暂无法完成支付,请注意合法使用支付账户,否则将升级限制。
个人的微信限额,跟商家无关,可联系腾讯客服解封
前一个人扫码支付失败,换另一个微信支付会报错