JAVA全系列 教程
3762个小节阅读:7093.7k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
xxxxxxxxxx
/**
* 支付宝配置
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "alipay")
public class ZfbPayConfig {
// 应用id
private String appId;
// 应用私钥
private String privateKey;
// 支付宝公钥
private String publicKey;
// 网关
private String gateway;
// 回调网址
private String notifyUrl;
// 支付成功回调接口
private String pcNotify;
/**
* 设置支付宝客户端
*/
@Bean
public AlipayClient setAlipayClient() {
return new DefaultAlipayClient(gateway, appId, privateKey, "json", "UTF-8", publicKey, "RSA2");
}
}
public class ZfbVerifierUtils {
/**
* 验证支付宝异步通知签名合法性
*
* @param requestParameterMap 支付宝请求的所有参数
* @param alipayPublicKey 支付宝公钥
* @return
*/
public static boolean isValid(Map<String, String[]> requestParameterMap, String alipayPublicKey) {
// 1. 获取支付宝post发送过来的信息
Map<String, String> resultMap = new HashMap<>();
for (Object v : requestParameterMap.entrySet()) {
Map.Entry<String, String[]> item = (Map.Entry<String, String[]>) v;
resultMap.put(item.getKey(), item.getValue()[0]);
}
try {
return AlipaySignature.rsaCheckV1(resultMap, alipayPublicKey, "UTF-8", "RSA2");
} catch (AlipayApiException e) {
e.printStackTrace();
}
return false;
}
}