JAVA SpringBoot整合 微信支付V3-JSAPI下单(支付/退款)

流程概要

添加Maven依赖

<dependency>
     <groupId>com.github.javen205</groupId>
     <artifactId>IJPay-All</artifactId>
     <version>2.7.4</version>
</dependency>

平台证书的生成

平台证书是必须的,生成方法:

创建通用参数文件 weChatPay.properties

文件存放路径:srcmain esources

创建通用参数类 WxPay

将properties文件中属性的值赋值到WxPay类中
@Data
@Component
@PropertySource("classpath:weChatPay.properties")
@ConfigurationProperties(prefix = "v3")
public class WxPay {
          
   

    private String keyPath;
    private String certPath;
    private String certP12Path;
    private String platformCertPath;
    private String mchId;
    private String apiKey;
    private String apiKey3;
    private String domain;
    private String AppId;
    private String AppSecret;


}

编写控制层代码

编写服务层代码

略过service层方法接口,展示的是方法的实现

退款接口的控制层代码

退款接口的服务层代码

经验分享 程序员 微信小程序 职场和发展