微信开放平台链接:Native下单_Native支付|微信支付商户文档中心
导入依赖:
<dependency> <groupId>com.github.wechatpay-apiv3</groupId> <artifactId>wechatpay-java</artifactId> <version>0.2.15</version> </dependency>
配置yml
wx:
pay:
appId: #微信公众号或者小程序等的appid
mchId: #微信支付商户号
apiV3key: #APIv3密钥
serialNo: #商户证书序列号
privateKeyPath: #p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头) 商户私钥
privateCertPath: #p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头)商户私钥
notifyUrl: #支付回调通知地址
refundNotifyUrl: #退款回调地址
publicKeyPath: #公钥证书路径
publicKeyId:#公钥的id
创建一个配置类:
@Data @ConfigurationProperties(prefix = "wx.pay") public class WxPayProperties { /** * 设置微信公众号或者小程序等的appid */ private String appId; /** * 微信支付商户号 */ private String mchId; /** * APIv3密钥 */ private String apiV3key; /** * p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头) 商户私钥 */ private String privateKeyPath; /** * 同上,apiclient_cert.pem证书文件 */ private String privateCertPath; /** * 商户证书序列号 */ private String serialNo; /** * 支付回调通知地址 */ private String notifyUrl; /** * 退款回调通知地址 */ private String refundNotifyUrl; /** * 商家端的支付回调通知地址 */ private String merchantNotifyUrl; /** * 商家端的退款回调通知地址 */ private String merchantRefundNotifyUrl; /** * 公钥证书路径 */ private String publicKeyPath; /** * 公钥的id */ private String publicKeyId; }
微信Native支付下单:
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.wechat.pay.java.core.Config; import com.wechat.pay.java.core.RSAPublicKeyConfig; import com.wechat.pay.java.service.pa