mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-09 04:25:54 +08:00
微信支付请求头增加商户公钥ID
This commit is contained in:
@@ -22,6 +22,10 @@ public abstract class BasePayConfigStorage implements PayConfigStorage {
|
||||
*/
|
||||
private String keyPrivate;
|
||||
|
||||
/**
|
||||
* 支付平台公钥Id(签名校验使用)
|
||||
*/
|
||||
private String keyPublicId;
|
||||
/**
|
||||
* 支付平台公钥(签名校验使用)
|
||||
*/
|
||||
@@ -95,6 +99,14 @@ public abstract class BasePayConfigStorage implements PayConfigStorage {
|
||||
this.keyPrivate = keyPrivate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyPublicId() {
|
||||
return keyPublicId;
|
||||
}
|
||||
|
||||
public void setKeyPublicId(String keyPublicId) {
|
||||
this.keyPublicId = keyPublicId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyPublic() {
|
||||
|
||||
@@ -88,6 +88,13 @@ public interface PayConfigStorage extends Attrs {
|
||||
*/
|
||||
String getInputCharset();
|
||||
|
||||
/**
|
||||
* 支付平台公钥ID(签名校验使用)
|
||||
*
|
||||
* @return 公钥
|
||||
*/
|
||||
String getKeyPublicId();
|
||||
|
||||
/**
|
||||
* 支付平台公钥(签名校验使用)
|
||||
*
|
||||
|
||||
@@ -58,6 +58,7 @@ public class WxV3PayController {
|
||||
wxPayConfigStorage.setV3ApiKey("9bd8f0e7af4841299d782406b7774f57");
|
||||
//验签、转账等接口使用,9月份开始不允许获取证书方式了,直接通过公钥字符来做,
|
||||
wxPayConfigStorage.setKeyPublic("支付平台公钥(原为自动获取的证书)");
|
||||
wxPayConfigStorage.setKeyPublicId("支付平台公钥ID");
|
||||
wxPayConfigStorage.setNotifyUrl("http://sailinmu.iok.la/wxV3/payBack.json");
|
||||
wxPayConfigStorage.setReturnUrl("http://sailinmu.iok.la/wxV3/payBack.json");
|
||||
wxPayConfigStorage.setInputCharset("utf-8");
|
||||
|
||||
@@ -350,7 +350,13 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
*/
|
||||
@Override
|
||||
public HttpStringEntity hookHttpEntity(HttpStringEntity entity) {
|
||||
entity.addHeader(new BasicHeader(WxConst.WECHATPAY_SERIAL, payConfigStorage.getCertEnvironment().getPlatformSerialNumber()));
|
||||
if (StringUtils.isNotEmpty(payConfigStorage.getKeyPublic())) {
|
||||
// 商户上送敏感信息时使用`微信支付平台公钥`加密
|
||||
entity.addHeader(new BasicHeader(WxConst.WECHATPAY_SERIAL, payConfigStorage.getKeyPublicId()));
|
||||
}
|
||||
else{
|
||||
entity.addHeader(new BasicHeader(WxConst.WECHATPAY_SERIAL, payConfigStorage.getCertEnvironment().getPlatformSerialNumber()));
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user