微信支付pc端
pc端微信支付流程
导入jar包
<!--微信回调-->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-pay</artifactId>
<version>4.0.0</version>
</dependency>
yml配置(内网穿透为了让微信回调我们接口时可以使用)
上代码
package com.itllc.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.thread.ThreadUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import com.itllc.mode.LlcItems;
import com.itllc.pojo.vo.NativeVO;
import com.itllc.service.LlcItemsService;
import com.itllc.service.LlcOrderService;
import com.itllc.util.OrderUtil;
import com.itllc.util.Result;
import com.itllc.util.WXutil;
import com.itllc.util.ZxingUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.InetAddress;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
/**
* @date 2021/9/24 0024 16:47
*/
@RestController
@RequestMapping("/wx")
@Api(tags = "微信支付回调模块", value = "微信支付回调模块")
public class WXPayController {
@Value("${wx-pay.APP_ID}")
public String APP_ID;
@Value("${wx-pay.MCH_ID}")
public String MCH_ID;
@Value("${wx-pay.MCH_KEY}")
public String MCH_KEY;
@Value("${wx-pay.KEY_PATH}")
public String KEY_PATH;
@Value("${wx-pay.NOTIFY_URL}")
public String NOTIFY_URL;
@Resource
private LlcItemsService llcItemsService;
@Resource
private LlcOrderService llcOrderService;
@PostMapping("/wxpayOld")
@ApiOperation(value = "微信回调地址不可用")
@ResponseBody
public Result<String> getPage(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
ServletInputStream inputStream = httpServletRequest.getInputStream();
byte[] b = new byte[1024];
int len = 0;
while ((len = inputStream.read(b)) != -1) {
String str = new String(b, 0, len);
System.out.println(str);
}
httpServletResponse.getWriter().write