mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
update 支付宝登录
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package com.jsowell.alipay.config;
|
||||
|
||||
import com.alipay.api.*;
|
||||
|
||||
import com.alipay.easysdk.factory.Factory;
|
||||
import com.alipay.easysdk.kernel.Config;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -31,47 +31,31 @@ public class AliPayConfig implements CommandLineRunner {
|
||||
@Value("${alipay.encryptKey}")
|
||||
private String encryptKey;
|
||||
|
||||
// @Override
|
||||
// public void run(String... args) throws Exception {
|
||||
// log.info(">>>>>>>>>>>>>>>服务启动执行,执行加载数据等操作 AliPayConfig order 2 <<<<<<<<<<<<<");
|
||||
// // 设置参数(全局只需设置一次)
|
||||
// Config config = new Config();
|
||||
// config.protocol = Constants.HTTPS;
|
||||
// config.gatewayHost = gatewayHost;
|
||||
// config.signType = Constants.RSA2;
|
||||
// config.appId = appId;
|
||||
//
|
||||
// // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
|
||||
// config.merchantPrivateKey = merchantPrivateKey;
|
||||
//
|
||||
// // 注:证书文件路径支持设置为文件系统中的路径或CLASS_PATH中的路径,优先从文件系统中加载,加载失败后会继续尝试从CLASS_PATH中加载
|
||||
// // config.merchantCertPath = "<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->";
|
||||
// // config.alipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->";
|
||||
// // config.alipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt -->";
|
||||
//
|
||||
// // 注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
|
||||
// config.alipayPublicKey = alipayPublicKey;
|
||||
// // 可设置异步通知接收服务地址(可选)
|
||||
// // config.notifyUrl = "<-- 请填写您的支付类接口异步通知接收服务地址,例如:https://www.test.com/callback -->";
|
||||
//
|
||||
// // 可设置AES密钥,调用AES加解密相关接口时需要(可选)
|
||||
// config.encryptKey = encryptKey;
|
||||
// Factory.setOptions(config);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
log.info(">>>>>>>>>>>>>>>服务启动执行,执行加载数据等操作 AliPayConfig order 2 <<<<<<<<<<<<<");
|
||||
// 设置参数(全局只需设置一次)
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
||||
}
|
||||
Config config = new Config();
|
||||
config.protocol = Constants.HTTPS;
|
||||
config.gatewayHost = gatewayHost;
|
||||
config.signType = Constants.RSA2;
|
||||
config.appId = appId;
|
||||
|
||||
private AlipayConfig getAlipayConfig() {
|
||||
AlipayConfig alipayConfig = new AlipayConfig();
|
||||
alipayConfig.setServerUrl(gatewayHost);
|
||||
alipayConfig.setAppId(appId);
|
||||
alipayConfig.setPrivateKey(merchantPrivateKey);
|
||||
alipayConfig.setAlipayPublicKey(alipayPublicKey);
|
||||
return alipayConfig;
|
||||
// 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
|
||||
config.merchantPrivateKey = merchantPrivateKey;
|
||||
|
||||
// 注:证书文件路径支持设置为文件系统中的路径或CLASS_PATH中的路径,优先从文件系统中加载,加载失败后会继续尝试从CLASS_PATH中加载
|
||||
// config.merchantCertPath = "<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->";
|
||||
// config.alipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->";
|
||||
// config.alipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt -->";
|
||||
|
||||
// 注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
|
||||
config.alipayPublicKey = alipayPublicKey;
|
||||
// 可设置异步通知接收服务地址(可选)
|
||||
// config.notifyUrl = "<-- 请填写您的支付类接口异步通知接收服务地址,例如:https://www.test.com/callback -->";
|
||||
|
||||
// 可设置AES密钥,调用AES加解密相关接口时需要(可选)
|
||||
config.encryptKey = encryptKey;
|
||||
Factory.setOptions(config);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user