|
@@ -29,7 +29,6 @@ import jakarta.servlet.http.HttpServletRequest;
|
|
|
import jline.internal.Log;
|
|
import jline.internal.Log;
|
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.jetbrains.annotations.NotNull;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -128,7 +127,16 @@ public class WxPaymentService extends SuperService {
|
|
|
request.setPayer(payer);
|
|
request.setPayer(payer);
|
|
|
PrepayResponse response = service.prepay(request);
|
|
PrepayResponse response = service.prepay(request);
|
|
|
|
|
|
|
|
- PrePayModel prePayModel = buildPrepayResultModel(response);
|
|
|
|
|
|
|
+ PrePayModel prePayModel = new PrePayModel();
|
|
|
|
|
+ prePayModel.setNonceStr(NonceUtil.createNonce(10));
|
|
|
|
|
+ prePayModel.setPackAge("prepay_id=" + response.getPrepayId());
|
|
|
|
|
+ prePayModel.setSignType("RSA");
|
|
|
|
|
+ long timeStamp = System.currentTimeMillis() / 1000;
|
|
|
|
|
+ prePayModel.setTimeStamp(Long.toString(timeStamp));
|
|
|
|
|
+
|
|
|
|
|
+ String sign = buildMessage(WxV3PayConfig.APP_ID, timeStamp, prePayModel.getNonceStr(), prePayModel.getPackAge());
|
|
|
|
|
+ String signature = sign(WxV3PayConfig.privateKeyPath, sign.getBytes("utf-8"));
|
|
|
|
|
+ prePayModel.setPaySign(signature);
|
|
|
return ResultContent.buildContent(prePayModel);
|
|
return ResultContent.buildContent(prePayModel);
|
|
|
} catch (HttpException e) { // 发送HTTP请求失败
|
|
} catch (HttpException e) { // 发送HTTP请求失败
|
|
|
// 调用e.getHttpRequest()获取请求打印日志或上报监控,更多方法见HttpException定义
|
|
// 调用e.getHttpRequest()获取请求打印日志或上报监控,更多方法见HttpException定义
|
|
@@ -148,21 +156,6 @@ public class WxPaymentService extends SuperService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @NotNull
|
|
|
|
|
- private PrePayModel buildPrepayResultModel(PrepayResponse response) throws UnsupportedEncodingException {
|
|
|
|
|
- PrePayModel prePayModel = new PrePayModel();
|
|
|
|
|
- prePayModel.setNonceStr(NonceUtil.createNonce(10));
|
|
|
|
|
- prePayModel.setPackAge("prepay_id=" + response.getPrepayId());
|
|
|
|
|
- prePayModel.setSignType("RSA");
|
|
|
|
|
- long timeStamp = System.currentTimeMillis() / 1000;
|
|
|
|
|
- prePayModel.setTimeStamp(Long.toString(timeStamp));
|
|
|
|
|
-
|
|
|
|
|
- String sign = buildMessage(WxV3PayConfig.APP_ID, timeStamp, prePayModel.getNonceStr(), prePayModel.getPackAge());
|
|
|
|
|
- String signature = sign(WxV3PayConfig.privateKeyPath, sign.getBytes("utf-8"));
|
|
|
|
|
- prePayModel.setPaySign(signature);
|
|
|
|
|
- return prePayModel;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
public String sign(String privateKeyPath, byte[] message){
|
|
public String sign(String privateKeyPath, byte[] message){
|
|
|
Signature sign = Signature.getInstance("SHA256withRSA");
|
|
Signature sign = Signature.getInstance("SHA256withRSA");
|