WeChat Pay: H5 Calls up Payment API, Directly Says Payment Fails

  java, question
  1. I am using java to develop WeChat’s Wechat Official Account payment function, and I am using Wechat Official Account’s internal payment function.

In the first step, the unified order interface has been adjusted to obtain the prepay_id (code will be posted below), but when the API for payment is adjusted through JS,The direct return is failure, the page has called WeChat Pay window flashing,In fact, the payment control has not been adjusted at all., also don’t know what’s wrong, can only call on the phone to check, also can’t track investigation, alert data directly is a failure, the specific JS code is as follows

function onBridgeReady(){
 
 var param = {};
 param.openid = openid;
 param.orderAmount = 11;
 param.stageid = 2007;
 
 console.log(param);
 
 //Obtain unified single interface parameters through the following interface
 Var url = puburl plus "/wxpay/createOrderinfo";
 var data = ajaxUtil.ajaxJson(url, JSON.stringify(param));
 console.log(data);
 if(data.code !  = 0) {
 console.log(data);
 return false;
 bracket
 
 var result = data.data;
 alert(JSON.stringify(result));
 
 //The above interface has already acquired the data required by the interface.
 //According to demo officially provided by WeChat, parameter assignment is carried out through the following methods
 WeixinJSBridge.invoke(
 'getBrandWCPayRequest', {
 "appId":result.appId,
 "timeStamp":result.timeStamp,
 "nonceStr":result.nonceStr,
 "package":result.prepay_id,
 "signType":result.signType,
 "paySign":result.paySign
 }, function(res){
 
 //But the program has come to this point.
 //the result of printing res.err_msg is directly: get_brand_wcpay_request:fail
 //Debugging can only be performed on the mobile phone, and the specific error reason cannot be viewed.
 alert(res.err_msg);
 //Use the above method to judge the front-end return.
 //WeChat team solemnly warns: res.err_msg will return to ok after the user pays successfully.
 //But there is no guarantee that it is absolutely reliable.
 if(res.err_msg == "get_brand_wcpay_request:ok" ) {
 Alert ("Payment Succeeded!"  )
 } else if(res.err_msg == "get_brand_wcpay_request:cancel") {
 Alert ("Payment Cancelled!"  );
 } else if(res.err_msg == "get_brand_wcpay_request:fail") {
 Alert ("Payment Fails!"  );
 bracket
 bracket
 );
 bracket
 
 if (typeof WeixinJSBridge == "undefined"){
 if( document.addEventListener ){
 document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
 }else if (document.attachEvent){
 document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
 document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
 bracket
 }else{
 onBridgeReady();
 bracket

I hope you great gods can see what’s wrong. If there is no clear description, please point it out and let me explain or paste the code.

Add: The configured payment authorization directory and the path to the payment page are always the same. This has been carefully confirmed and there is no problem!

Dear bosses, it’s out. Sorry, I forgot to close the problem.
It is the problem of inconsistent encryption.
When I used encryption in java, the parameter passed was prepay_id, and package was actually required as the key of the parameter, which resulted in inconsistent encryption results with wechat. wechat was also a big pit and used a keyword such as package.