| | |
| | | import org.springblade.common.enums.wxpay.WxNotifyType; |
| | | import org.springblade.common.enums.wxpay.WxRefundStatus; |
| | | import org.springblade.common.enums.wxpay.WxTradeState; |
| | | import org.springblade.common.exception.CustomException; |
| | | import org.springblade.common.utils.HttpUtils; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.common.utils.WechatPay2ValidatorForRequest; |
| | |
| | | @Resource |
| | | private WxPayConfig wxPayConfig; |
| | | |
| | | @Resource |
| | | private CloseableHttpClient wxPayClient; |
| | | // @Resource |
| | | // private CloseableHttpClient wxPayClient; |
| | | |
| | | @Resource |
| | | private IOrderInfoService orderInfoService; |
| | |
| | | httpGet.setHeader("Accept", "application/json"); |
| | | |
| | | //完成签名并执行请求 |
| | | CloseableHttpResponse response = wxPayClient.execute(httpGet); |
| | | CloseableHttpResponse response = null;//wxPayClient.execute(httpGet); |
| | | |
| | | try { |
| | | String bodyAsString = EntityUtils.toString(response.getEntity());//响应体 |
| | |
| | | httpPost.setHeader("Accept", "application/json");//设置响应报文格式 |
| | | |
| | | //完成签名并执行请求,并完成验签 |
| | | CloseableHttpResponse response = wxPayClient.execute(httpPost); |
| | | CloseableHttpResponse response =null;// wxPayClient.execute(httpPost); |
| | | |
| | | try { |
| | | |
| | |
| | | httpGet.setHeader("Accept", "application/json"); |
| | | |
| | | //完成签名并执行请求 |
| | | CloseableHttpResponse response = wxPayClient.execute(httpGet); |
| | | CloseableHttpResponse response = null;//wxPayClient.execute(httpGet); |
| | | |
| | | try { |
| | | String bodyAsString = EntityUtils.toString(response.getEntity()); |
| | |
| | | |
| | | |
| | | @Override |
| | | public Map<String, String> jsapiPay(Long properChargeRecordId) throws Exception { |
| | | public Map<String, String> jsapiPay(Long properChargeRecordId) throws IOException { |
| | | |
| | | String prepayId = ""; |
| | | //生成订单 |
| | | OrderInfoEntity orderInfo = orderInfoService.getOne(Wrappers.<OrderInfoEntity>lambdaQuery().eq(OrderInfoEntity::getProperChargeRecordId, properChargeRecordId)); |
| | | if (orderInfo.getTotalFee() <= 0) { |
| | | throw new Exception("支付金额不能低于等于0元"); |
| | | throw new CustomException("支付金额不能低于等于0元"); |
| | | } |
| | | IUserService userService = SpringUtils.getBean(IUserService.class); |
| | | User serviceOne = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getId, AuthUtil.getUserId())); |
| | |
| | | httpPost.setHeader("Accept", "application/json"); |
| | | |
| | | //完成签名并执行请求 |
| | | CloseableHttpResponse response = wxPayClient.execute(httpPost); |
| | | CloseableHttpResponse response = null;//wxPayClient.execute(httpPost); |
| | | |
| | | try { |
| | | String bodyAsString = EntityUtils.toString(response.getEntity());//响应体 |
| | |
| | | payMap.put("paySign", paySign); |
| | | logger.info("返回参数 ===> {}" + gson.toJson(payMap)); |
| | | return payMap; |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (SignatureException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (InvalidKeyException e) { |
| | | throw new RuntimeException(e); |
| | | } finally { |
| | | response.close(); |
| | | } |
| | |
| | | httpPost.setHeader("Accept", "application/json"); |
| | | |
| | | //完成签名并执行请求 |
| | | CloseableHttpResponse response = wxPayClient.execute(httpPost); |
| | | CloseableHttpResponse response = null;//wxPayClient.execute(httpPost); |
| | | |
| | | try { |
| | | int statusCode = response.getStatusLine().getStatusCode();//响应状态码 |