You've already forked FrameTour-BE
配置、记录请求、支付
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.ycwl.basic.utils;
|
||||
|
||||
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import com.wechat.pay.java.core.util.PemUtil;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
@ -8,6 +9,7 @@ import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.*;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
@ -26,7 +28,7 @@ public class WXPayUtil {
|
||||
public static String getSign(String signatureStr,String privateKey) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IOException, URISyntaxException {
|
||||
//replace 根据实际情况,不一定都需要
|
||||
String replace = privateKey.replace("\\n", "\n");
|
||||
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKeyFromPath(replace);
|
||||
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKeyFromString(replace);
|
||||
Signature sign = Signature.getInstance("SHA256withRSA");
|
||||
sign.initSign(merchantPrivateKey);
|
||||
sign.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
||||
@ -46,4 +48,7 @@ public class WXPayUtil {
|
||||
return new String(nonceChars);
|
||||
}
|
||||
|
||||
public static Map<String, Object> xmlToMap(String xmlData) {
|
||||
return XmlUtil.xmlToMap(xmlData);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user