根据官方的支付例子,运行出现问题。开发环境正常,服务器上,运行到构建NativePayService
public static String signleOrder(String subMchid, String outTradeNo,Integer money,Boolean profit_sharing, ContractFeeItem feeItem) {
// 使用自动更新平台证书的RSA配置
// 一个商户号只能初始化一个配置,否则会因为重复的下载任务报错
try {
Config config =
new RSAPublicKeyConfig.Builder()
.merchantId(merchantId)
.privateKeyFromPath(privateKeyPath)
.publicKeyFromPath(publicKeyPath)
.publicKeyId(publickeyId)
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(apiV3Key)
.build();
// 构建service
NativePayService service = new NativePayService.Builder().config(config).build();
// request.setXxx(val)设置所需参数,具体参数可见Request定义
PrepayRequest request = new PrepayRequest();
Amount amount = new Amount();
amount.setTotal(money);
request.setAmount(amount);
request.setSpAppid(PayUtils.appid);
request.setSpMchid(merchantId);//
request.setSubMchid(subMchid);
request.setDescription(feeItem.getFeeName());
request.setNotifyUrl("http://XXXXXXXXXXXXX/wxHt/callBack/singleNativePay/"+feeItem.getId()+"/"+outTradeNo+".html");
request.setOutTradeNo(outTradeNo);
SettleInfo settleInfo=new SettleInfo();
settleInfo.setProfitSharing(profit_sharing);
//request.setSettleInfo(settleInfo);
// 调用下单方法,得到应答\
System.out.println("request=="+request);
PrepayResponse response = service.prepay(request);
System.out.println("response=="+response);
return response.getCodeUrl();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String signleOrder(String subMchid, String outTradeNo,Integer money,Boolean profit_sharing, ContractFeeItem feeItem) {
// 使用自动更新平台证书的RSA配置
// 一个商户号只能初始化一个配置,否则会因为重复的下载任务报错
try {
Config config =
new RSAPublicKeyConfig.Builder()
.merchantId(merchantId)
.privateKeyFromPath(privateKeyPath)
.publicKeyFromPath(publicKeyPath)
.publicKeyId(publickeyId)
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(apiV3Key)
.build();
// 构建service
NativePayService service = new NativePayService.Builder().config(config).build();
// request.setXxx(val)设置所需参数,具体参数可见Request定义
PrepayRequest request = new PrepayRequest();
Amount amount = new Amount();
amount.setTotal(money);
request.setAmount(amount);
request.setSpAppid(PayUtils.appid);
request.setSpMchid(merchantId);//
request.setSubMchid(subMchid);
request.setDescription(feeItem.getFeeName());
request.setNotifyUrl("http://XXXXXXXXXXXXX/wxHt/callBack/singleNativePay/"+feeItem.getId()+"/"+outTradeNo+".html");
request.setOutTradeNo(outTradeNo);
SettleInfo settleInfo=new SettleInfo();
settleInfo.setProfitSharing(profit_sharing);
//request.setSettleInfo(settleInfo);
// 调用下单方法,得到应答\
System.out.println("request=="+request);
PrepayResponse response = service.prepay(request);
System.out.println("response=="+response);
return response.getCodeUrl();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
新商户需要用公钥模式,不会签发平台证书,不能使用RSAAutoCertificateConfig