|
@@ -14,7 +14,6 @@ import com.llisoft.pay.vo.ApiPayWxJsApiResponseVo;
|
|
import com.wechat.pay.java.core.Config;
|
|
import com.wechat.pay.java.core.Config;
|
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
|
import com.wechat.pay.java.core.notification.NotificationConfig;
|
|
import com.wechat.pay.java.core.notification.NotificationConfig;
|
|
-import com.wechat.pay.java.core.notification.NotificationParser;
|
|
|
|
import com.wechat.pay.java.core.notification.RequestParam;
|
|
import com.wechat.pay.java.core.notification.RequestParam;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -41,34 +40,20 @@ public class PayWxV3Service {
|
|
private static String apiKeyQinggu = "POIUYTREWQAS1q2w3e4r5t6y7u8i9o0p";
|
|
private static String apiKeyQinggu = "POIUYTREWQAS1q2w3e4r5t6y7u8i9o0p";
|
|
// 使用自动更新平台证书的RSA配置
|
|
// 使用自动更新平台证书的RSA配置
|
|
// 一个商户号只能初始化一个配置,否则会因为重复的下载任务报错
|
|
// 一个商户号只能初始化一个配置,否则会因为重复的下载任务报错
|
|
- private static Config configDongke;
|
|
|
|
- private static Config configQinggu;
|
|
|
|
- private Config getConfigDongke() {
|
|
|
|
|
|
+ private static RSAAutoCertificateConfig configDongke;
|
|
|
|
+ private static RSAAutoCertificateConfig configQinggu;
|
|
|
|
+ private RSAAutoCertificateConfig getConfigDongke() {
|
|
return Objects.nonNull(configDongke) ? configDongke : (configDongke = new RSAAutoCertificateConfig.Builder()
|
|
return Objects.nonNull(configDongke) ? configDongke : (configDongke = new RSAAutoCertificateConfig.Builder()
|
|
.merchantId(mchidDongke).privateKeyFromPath(keyPathDongke)
|
|
.merchantId(mchidDongke).privateKeyFromPath(keyPathDongke)
|
|
.merchantSerialNumber(keyNumberDongke)
|
|
.merchantSerialNumber(keyNumberDongke)
|
|
.apiV3Key(apiKeyDongke).build());
|
|
.apiV3Key(apiKeyDongke).build());
|
|
}
|
|
}
|
|
- private Config getConfigQinggu() {
|
|
|
|
|
|
+ private RSAAutoCertificateConfig getConfigQinggu() {
|
|
return Objects.nonNull(configQinggu) ? configQinggu : (configQinggu = new RSAAutoCertificateConfig.Builder()
|
|
return Objects.nonNull(configQinggu) ? configQinggu : (configQinggu = new RSAAutoCertificateConfig.Builder()
|
|
.merchantId(mchidQinggu).privateKeyFromPath(keyPathQinggu)
|
|
.merchantId(mchidQinggu).privateKeyFromPath(keyPathQinggu)
|
|
.merchantSerialNumber(keyNumberQinggu)
|
|
.merchantSerialNumber(keyNumberQinggu)
|
|
.apiV3Key(apiKeyQinggu).build());
|
|
.apiV3Key(apiKeyQinggu).build());
|
|
}
|
|
}
|
|
- private static NotificationConfig notificationConfigDongke;
|
|
|
|
- private static NotificationConfig notificationConfigQinggu;
|
|
|
|
- private NotificationConfig getNotificationConfigDongke() {
|
|
|
|
- return Objects.nonNull(notificationConfigDongke) ? notificationConfigDongke : (notificationConfigDongke = new RSAAutoCertificateConfig.Builder()
|
|
|
|
- .merchantId(mchidDongke).privateKeyFromPath(keyPathDongke)
|
|
|
|
- .merchantSerialNumber(keyNumberDongke)
|
|
|
|
- .apiV3Key(apiKeyDongke).build());
|
|
|
|
- }
|
|
|
|
- private NotificationConfig getNotificationConfigQinggu() {
|
|
|
|
- return Objects.nonNull(notificationConfigQinggu) ? notificationConfigQinggu : (notificationConfigQinggu = new RSAAutoCertificateConfig.Builder()
|
|
|
|
- .merchantId(mchidQinggu).privateKeyFromPath(keyPathQinggu)
|
|
|
|
- .merchantSerialNumber(keyNumberQinggu)
|
|
|
|
- .apiV3Key(apiKeyQinggu).build());
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -259,7 +244,7 @@ public class PayWxV3Service {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public boolean notifyDongke(RequestParam requestParam) {
|
|
public boolean notifyDongke(RequestParam requestParam) {
|
|
- return this.notify(this.getNotificationConfigDongke(), requestParam);
|
|
|
|
|
|
+ return this.notify(this.getConfigDongke(), requestParam);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -268,7 +253,7 @@ public class PayWxV3Service {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public boolean notifyQinggu(RequestParam requestParam) {
|
|
public boolean notifyQinggu(RequestParam requestParam) {
|
|
- return this.notify(this.getNotificationConfigQinggu(), requestParam);
|
|
|
|
|
|
+ return this.notify(this.getConfigQinggu(), requestParam);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -277,9 +262,9 @@ public class PayWxV3Service {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private boolean notify(NotificationConfig config, RequestParam requestParam) {
|
|
private boolean notify(NotificationConfig config, RequestParam requestParam) {
|
|
- NotificationParser parser = new NotificationParser(config);
|
|
|
|
|
|
+ com.wechat.pay.java.core.notification.NotificationParser notificationParser = new com.wechat.pay.java.core.notification.NotificationParser(config);
|
|
try { // 以支付通知回调为例,验签、解密并转换成 Transaction
|
|
try { // 以支付通知回调为例,验签、解密并转换成 Transaction
|
|
- com.wechat.pay.java.service.payments.model.Transaction transaction = parser.parse(requestParam, com.wechat.pay.java.service.payments.model.Transaction.class);
|
|
|
|
|
|
+ com.wechat.pay.java.service.payments.model.Transaction transaction = notificationParser.parse(requestParam, com.wechat.pay.java.service.payments.model.Transaction.class);
|
|
return transaction.getTradeState() == com.wechat.pay.java.service.payments.model.Transaction.TradeStateEnum.SUCCESS;
|
|
return transaction.getTradeState() == com.wechat.pay.java.service.payments.model.Transaction.TradeStateEnum.SUCCESS;
|
|
} catch (Exception exception) {
|
|
} catch (Exception exception) {
|
|
logger.error("处理微信支付异步通知失败", exception);
|
|
logger.error("处理微信支付异步通知失败", exception);
|