微信和支付宝集成封装的sdk 需要自己拉代码到本地进行打包
https://github.com/sunuping/jm-pay-spring-boot-starter.git
pom.xml
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.39.40.ALL</version>
</dependency>
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-java</artifactId>
<version>0.2.12</version>
</dependency>
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.4.9</version>
</dependency>
<dependency>
<groupId>org.jm</groupId>
<artifactId>jm-pay-spring-boot-starter</artifactId>
<version>4.0.2</version>
</dependency>
application.yml 配置支付宝和微信支付配置
jm:
ali:
appid: xxx
rsa-privateKey: xxx
notify-url: https://xxx/pay/callback
return-url: https://xxx
gateway-url: https://openapi.alipay.com/gateway.do
charset: UTF-8
format: json
alipay-publicKey: xxx
sign-type: RSA2
wx:
api-v3-key: xxx
private-key-path: E:\xxxx\apiclient_key.pem
private-key: xxxx
mch-id: xxx
appid: xxx
mch-serial-number: xxx
notify-url: https://xxxx/pay/callback
调用支付
package org.jm.pay.constant;
public class JmAlipayTypeConstant {
public static final String ALIPAY_H5 = "alipay_h5";
public static final String ALIPAY_PC = "alipay_pc";
public static final String ALIPAY_APP = "alipay_app";
}
package org.jm.pay.constant;
public class JmWxPayTypeConstant {
public static final String WX_H5 = "wx_h5";
public static final String WX_PC = "wx_pc";
public static final String WX_NATIVE = "wx_native";
}
调用支付
private final JmAlipayApp jmAlipayApp;
@Autowired
public AppRedServiceImpl(JmAlipayApp jmAlipayApp) {
this.jmAlipayApp = jmAlipayApp;
}
JmPayParam jmPayParam = new JmPayParam();
jmPayParam.setDesc("充值");
jmPayParam.setAmount(param.getRedTotalMoney());
jmPayParam.setOrderName("充值");
jmPayParam.setOrderNo(orderId);
JmPayVO jmPayVO = this.jmAlipayApp.pay(jmPayParam);