微信支付

This commit is contained in:
2025-12-22 17:18:09 +08:00
parent f3f674dac4
commit 5b6c371df2
2 changed files with 22 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
package com.czg.service.market.service.impl;
import com.czg.constants.ParamCodeCst;
import com.czg.service.RedisService;
import com.czg.system.service.SysParamsService;
import com.ijpay.core.kit.RsaKit;
@@ -30,20 +31,20 @@ public class AppWxServiceImpl extends BaseWx {
@PostConstruct
public void init() {
// 小程序id
config.appId = paramsService.getSysParamValue("wx_mini_app_id");
config.appId = paramsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
log.info("小程序id:{}", config.appId);
// 小程序secrete
config.appSecret = paramsService.getSysParamValue("wx_mini_secrete");
config.appSecret = paramsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_SECRETE);
log.info("小程序secrete:{}", config.appSecret);
config.certPath = "";
// 微信支付公钥
config.pubKey = paramsService.getSysParamValue("wx_pub_key");
config.pubKey = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_PUB_KEY);
log.info("微信支付公钥:{}", config.pubKey);
// api支付证书私钥
config.apiCertKey = paramsService.getSysParamValue("wx_apiclient_key");
config.apiCertKey = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_KEY);
log.info("api支付证书私钥:{}", config.apiCertKey);
// api支付证书公钥
config.apiCert = paramsService.getSysParamValue("wx_apiclient_cert");
config.apiCert = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_CERT);
log.info("api支付证书公钥:{}", config.apiCert);
try {
config.privateKey = RsaKit.loadPrivateKey(config.apiCertKey);
@@ -55,17 +56,17 @@ public class AppWxServiceImpl extends BaseWx {
// 平台证书编号
config.platformCertNo = "";
// 商户号
config.mchId = paramsService.getSysParamValue("wx_mch_id");
config.mchId = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_MCH_ID);
log.info("商户号:{}", config.mchId);
// v3密钥
config.apiV3Key = paramsService.getSysParamValue("wx_v3_key");
config.apiV3Key = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_V3_KEY);
log.info("v3密钥:{}", config.apiV3Key);
config.apiV2Key = "";
// 回调地址
config.notifyUrl = paramsService.getSysParamValue("native_notify_url") + "/wx/pay";
config.notifyUrl = paramsService.getSysParamValue(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/pay";
log.info("回调地址:{}", config.notifyUrl);
config.refundNotifyUrl = "";
config.transferNotifyUrl = paramsService.getSysParamValue("native_notify_url") + "/wx/transfer";
config.transferNotifyUrl = paramsService.getSysParamValue(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/transfer";
log.info("转账回调地址:{}", config.transferNotifyUrl);
}

View File

@@ -1,5 +1,6 @@
package com.czg.service.market.service.impl;
import com.czg.constants.ParamCodeCst;
import com.czg.service.RedisService;
import com.czg.system.service.SysParamsService;
import com.ijpay.core.kit.RsaKit;
@@ -32,16 +33,18 @@ public class WxServiceImpl extends BaseWx {
@PostConstruct
public void init() {
// 小程序id
config.appId = paramsService.getSysParamValue("shop_wx_appid");
config.appId = paramsService.getSysParamValue(ParamCodeCst.Wechat.Mini.SHOP_WX_APP_ID);
// 小程序secrete
config.appSecret = paramsService.getSysParamValue("shop_wx_secrete");
config.appSecret = paramsService.getSysParamValue(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
config.certPath = "";
// 微信支付公钥
config.pubKey = paramsService.getSysParamValue("wx_pub_key");
config.pubKey = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_PUB_KEY);
// api支付证书私钥
config.apiCertKey = paramsService.getSysParamValue("wx_apiclient_key");
config.apiCertKey = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_KEY);
// api支付证书公钥
config.apiCert = paramsService.getSysParamValue("wx_apiclient_cert");
config.apiCert = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_CERT);
try {
config.privateKey = RsaKit.loadPrivateKey(config.apiCertKey);
} catch (Exception e) {
@@ -52,14 +55,14 @@ public class WxServiceImpl extends BaseWx {
// 平台证书编号
config.platformCertNo = "";
// 商户号
config.mchId = paramsService.getSysParamValue("wx_mch_id");
config.mchId = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_MCH_ID);
// v3密钥
config.apiV3Key = paramsService.getSysParamValue("wx_v3_key");
config.apiV3Key = paramsService.getSysParamValue(ParamCodeCst.Wechat.Pay.WX_V3_KEY);
config.apiV2Key = "";
// 回调地址
config.notifyUrl = paramsService.getSysParamValue("native_notify_url") + "/wx/pay";
config.notifyUrl = paramsService.getSysParamValue(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/pay";
config.refundNotifyUrl = "";
config.transferNotifyUrl = paramsService.getSysParamValue("native_notify_url") + "/wx/transfer";
config.transferNotifyUrl = paramsService.getSysParamValue(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/transfer";
}
public BaseWx getAppService() {