@Test(expectedExceptions = {WxErrorException.class}) public void testGetPaidUnionId() throws WxErrorException { final String unionId = this.wxService.getPaidUnionId("1", null, "3", "4"); assertThat(unionId).isNotEmpty(); }
@Override public String getPaidUnionId(String openid, String transactionId, String mchId, String outTradeNo) throws WxErrorException { Map<String, String> params = new HashMap<>(8); params.put("openid", openid); if (StringUtils.isNotEmpty(transactionId)) { params.put("transaction_id", transactionId); } if (StringUtils.isNotEmpty(mchId)) { params.put("mch_id", mchId); } if (StringUtils.isNotEmpty(outTradeNo)) { params.put("out_trade_no", outTradeNo); } String responseContent = this.get(GET_PAID_UNION_ID_URL, Joiner.on("&").withKeyValueSeparator("=").join(params)); WxError error = WxError.fromJson(responseContent, WxType.MiniApp); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(responseContent).getAsJsonObject().get("unionid").getAsString(); }
WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpClient, HttpHost> { @Override public String getPaidUnionId(String openid, String transactionId, String mchId, String outTradeNo) throws WxErrorException { Map<String, String> params = new HashMap<>(8); params.put("openid", openid); if (StringUtils.isNotEmpty(transactionId)) { params.put("transaction_id", transactionId); } if (StringUtils.isNotEmpty(mchId)) { params.put("mch_id", mchId); } if (StringUtils.isNotEmpty(outTradeNo)) { params.put("out_trade_no", outTradeNo); } String responseContent = this.get(GET_PAID_UNION_ID_URL, Joiner.on("&").withKeyValueSeparator("=").join(params)); WxError error = WxError.fromJson(responseContent, WxType.MiniApp); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(responseContent).getAsJsonObject().get("unionid").getAsString(); } }
WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpClient, HttpHost> { @Override public String getPaidUnionId(String openid, String transactionId, String mchId, String outTradeNo) throws WxErrorException { Map<String, String> params = new HashMap<>(8); params.put("openid", openid); if (StringUtils.isNotEmpty(transactionId)) { params.put("transaction_id", transactionId); } if (StringUtils.isNotEmpty(mchId)) { params.put("mch_id", mchId); } if (StringUtils.isNotEmpty(outTradeNo)) { params.put("out_trade_no", outTradeNo); } String responseContent = this.get(GET_PAID_UNION_ID_URL, Joiner.on("&").withKeyValueSeparator("=").join(params)); WxError error = WxError.fromJson(responseContent, WxType.MiniApp); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(responseContent).getAsJsonObject().get("unionid").getAsString(); }  }
WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpClient, HttpHost> { @Override public String getPaidUnionId(String openid, String transactionId, String mchId, String outTradeNo) throws WxErrorException { Map<String, String> params = new HashMap<>(8); params.put("openid", openid); if (StringUtils.isNotEmpty(transactionId)) { params.put("transaction_id", transactionId); } if (StringUtils.isNotEmpty(mchId)) { params.put("mch_id", mchId); } if (StringUtils.isNotEmpty(outTradeNo)) { params.put("out_trade_no", outTradeNo); } String responseContent = this.get(GET_PAID_UNION_ID_URL, Joiner.on("&").withKeyValueSeparator("=").join(params)); WxError error = WxError.fromJson(responseContent, WxType.MiniApp); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(responseContent).getAsJsonObject().get("unionid").getAsString(); }  @Override CloseableHttpClient getRequestHttpClient(); @Override HttpHost getRequestHttpProxy(); @Override HttpType getRequestType(); @Override void initHttp(); @Override RequestHttp getRequestHttp(); @Override String getAccessToken(boolean forceRefresh); @Override String getPaidUnionId(String openid, String transactionId, String mchId, String outTradeNo); @Override WxMaJscode2SessionResult jsCode2SessionInfo(String jsCode); @Override boolean checkSignature(String timestamp, String nonce, String signature); @Override String getAccessToken(); @Override String get(String url, String queryParam); @Override String post(String url, String postData); @Override T execute(RequestExecutor<T, E> executor, String uri, E data); @Override WxMaConfig getWxMaConfig(); @Override void setWxMaConfig(WxMaConfig wxConfigProvider); @Override void setRetrySleepMillis(int retrySleepMillis); @Override void setMaxRetryTimes(int maxRetryTimes); @Override WxMaMsgService getMsgService(); @Override WxMaMediaService getMediaService(); @Override WxMaUserService getUserService(); @Override WxMaQrcodeService getQrcodeService(); @Override WxMaTemplateService getTemplateService(); @Override WxMaAnalysisService getAnalysisService(); @Override WxMaCodeService getCodeService(); @Override WxMaJsapiService getJsapiService(); @Override WxMaSettingService getSettingService(); @Override WxMaShareService getShareService(); @Override WxMaRunService getRunService(); @Override WxMaSecCheckService getSecCheckService(); }
WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpClient, HttpHost> { @Override public String getPaidUnionId(String openid, String transactionId, String mchId, String outTradeNo) throws WxErrorException { Map<String, String> params = new HashMap<>(8); params.put("openid", openid); if (StringUtils.isNotEmpty(transactionId)) { params.put("transaction_id", transactionId); } if (StringUtils.isNotEmpty(mchId)) { params.put("mch_id", mchId); } if (StringUtils.isNotEmpty(outTradeNo)) { params.put("out_trade_no", outTradeNo); } String responseContent = this.get(GET_PAID_UNION_ID_URL, Joiner.on("&").withKeyValueSeparator("=").join(params)); WxError error = WxError.fromJson(responseContent, WxType.MiniApp); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(responseContent).getAsJsonObject().get("unionid").getAsString(); }  @Override CloseableHttpClient getRequestHttpClient(); @Override HttpHost getRequestHttpProxy(); @Override HttpType getRequestType(); @Override void initHttp(); @Override RequestHttp getRequestHttp(); @Override String getAccessToken(boolean forceRefresh); @Override String getPaidUnionId(String openid, String transactionId, String mchId, String outTradeNo); @Override WxMaJscode2SessionResult jsCode2SessionInfo(String jsCode); @Override boolean checkSignature(String timestamp, String nonce, String signature); @Override String getAccessToken(); @Override String get(String url, String queryParam); @Override String post(String url, String postData); @Override T execute(RequestExecutor<T, E> executor, String uri, E data); @Override WxMaConfig getWxMaConfig(); @Override void setWxMaConfig(WxMaConfig wxConfigProvider); @Override void setRetrySleepMillis(int retrySleepMillis); @Override void setMaxRetryTimes(int maxRetryTimes); @Override WxMaMsgService getMsgService(); @Override WxMaMediaService getMediaService(); @Override WxMaUserService getUserService(); @Override WxMaQrcodeService getQrcodeService(); @Override WxMaTemplateService getTemplateService(); @Override WxMaAnalysisService getAnalysisService(); @Override WxMaCodeService getCodeService(); @Override WxMaJsapiService getJsapiService(); @Override WxMaSettingService getSettingService(); @Override WxMaShareService getShareService(); @Override WxMaRunService getRunService(); @Override WxMaSecCheckService getSecCheckService();  }