微信开发
微信支付报错提示“商户号该产品权限未开通,请前往商户平台>产品中心检查后重试
时间:2024-01-01
微信开发的时候可能会出现如题问题,这是因为没有在微信商户平台开放对应的产品权限。
一、问题
如下,模拟一个native支付,报出了如题异常
private String appid="";
private String mchId="";
private String native_pay="";
private String notifyurl="";
public String createWxNativeNativeOrder(String orderName,String orderNo,int orderAmount) {
// 请求URL
HttpPost httpPost = new HttpPost(native_pay);
WxNativePayModel wx = new WxNativePayModel();
WxNativePayModelAmount w = new WxNativePayModelAmount();
w.setTotal(orderAmount);
wx.setAmount(w);
wx.setAppid(appid);
wx.setMchid(mchId);
wx.setDescription(orderName);
wx.setNotify_url(notifyurl);
wx.setOut_trade_no(orderNo);
StringEntity entity = new StringEntity(MyUtils.toJson(wx), "utf-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json");
// 完成签名并执行请求
CloseableHttpResponse response = null;
int statusCode=-1;
try {
this.setup();
response = httpClient.execute(httpPost);
statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 200) {
System.out.println("success,return body = " + EntityUtils.toString(response.getEntity()));
} else if (statusCode == 204) {
System.out.println("success");
}
wx.setResult( EntityUtils.toString(response.getEntity()));
} catch (Exception e) {
wx.setResult(e.getMessage());
} finally {
try {
if(MyUtils.isNotNull(response)) {
response.close();
}
if(MyUtils.isNotNull(httpClient)) {
httpClient.close();
}
} catch (IOException e) {
wx.setResult(e.getMessage());
}
}
System.out.println(MyUtils.toJson(wx));
return wx.getResult();
}
二、原因
进入商户平台,找到产品大全,找到对应的支付类型(native是给出二维码,扫码支付),即产品类型,点击开通即可。
注意,如果无法开通,可能是一些权限或认证没有搞定。