收藏
回答

根据官方的支付例子,运行出现问题。开发环境正常,服务器上,运行到构建NativePayService

根据官方的支付例子,运行出现问题。开发环境正常,服务器上,运行到构建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;

	    }


最后一次编辑于  11-15
回答关注问题邀请回答
收藏

1 个回答

  • Memory
    Memory
    10-25

    新商户需要用公钥模式,不会签发平台证书,不能使用RSAAutoCertificateConfig

    10-25
    有用
    回复 2
    • 李士尧
      李士尧
      10-25
      有调用例子吗 麻烦帮忙下
      10-25
      回复
    • Memory
      Memory
      10-25回复李士尧
      看readme
      10-25
      回复
登录 后发表内容