元气优淘服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
youtao/service/src/main/java/com/hfkj/common/alipay/AlipayUtils.java

49 lines
3.4 KiB

package com.hfkj.common.alipay;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
/**
* 支付宝配置
* @className: AlipayConfig
* @author: HuRui
* @date: 2023/2/13
**/
public class AlipayUtils {
private final static String serverUrl = "https://openapi.alipay.com/gateway.do";
private final static String appId = "2021004176645906";
private final static String APP_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCWaLQdwl6E5QVo2RUWquJ1Et4oLRsbfLULQyYT3o6Fs+2ZWOHjjMf6Jg5yVuM3rPa1GNB4+6cBU84gaLQ8WZl9tdQAOhQlnvjOsJA0twb+Lq1Luaa+cOOgp3t3+PuD0nRP9vuPAW3aqrFyjTeDx0vOAzulrWWwS+zLWkUmv96Db5MjlR8gK/pLOszQsk+K3uu06KoyLrCn0K/AIrhJClcEvy/umDfC/P8PnYEgTppNgZ/IBkKp5P9JZzyYEgR7rgD/Z8aWKQ5a8bO0VxC/7FDpCcWNRPdwcHEN8A0ltoO5MNuleZz2q9hrW627qiQNEoaDyqbh/PNFXXLCK5nBWzWPAgMBAAECggEAHC9ouT7oKW0lU12CpynEn/22Jb82GjOHVaHyq7yD5qgt+RN/2P1TqBujj2ea0p8V6B/LSTCXPhdvRAF67Og5bCY7oQNBLT+aDlll3IsDw3QJw2v5xCwxa7SW3YeJ0k0IwMdeopC4/kYIVJgD9CzPlr5iWgyhRqUjrYOv+6/uyaA+XLJjF/eUG0UEnkyuCPW6ClX+ulpI6Tk7ycB9HJFGpLNoYBUSs7mgiUOOKI9AA9S5aDG2QYBxkUK8WF4gtYt6SLKAWw5GSMCeK5zjhRZw0GqIIouIUDSigdK5VzKth/OXiA9B6uXh21fS1GQPhcfo4ZbKml6p8JB9pvQRPIXpiQKBgQD3u4ph5RMv4lvUvk/q6f1fyATcRlaCGiiPrUj8IFq4vjxIHfB+nb0YTHkEHClWsGbc4I/l2UQE+wzR89ZcFE2h+v4c7dswMW/QPX9TyFZQIRs2nvAbPKMdg40zdLDiUj3dknSrWx9OqnTXghhK8O2Ah1qNLdCVPD9eFehfTADsIwKBgQCbbbI8G7X2RWkiJtPItrtWWhOJ4BEQG9bBendeirvZmfQilpzeC7UWdVintGzK+xSGDwYqDWtyIWeT/wu2VdIl2yTJ/2HfRDD4E0jnbed32g9bcRReOCjnwuSGZUp845nZKilxuBHD0tXS0pi/6VCje2myaZVmXnLlOE57FkuhpQKBgGJl9GZD5eYcI9uRqA6n2EMmIIAZ1ByjJT9EVfwHIeHFdg4zDiZMoyI2pc6zHNxY/tJ2w9FJBhJwYTw3fQpf6iIPnsWA2JIA4Oe2tY9iwJ3dOIDuinJXGHcNnJU2oVeT0QzkMkEp1XqajARZoSqLHdryaE4xR2svXgAR9ZV8i9U/AoGBAI67tios6HU4WMvcDDEOXgt2vOqosgKxDg6vgF951/iEwQXiejwPVEVDjh60OhRNbxONSIPlvv4YXx4x4XeYaFwLW0WFGUQHQ1ENpK2i6CXQQroepi3ANRBgkaw56KW3/djINzcPaoECZQouC8hxYnQ/KVmGTIStx6Voh+nRF7NhAoGAa2KOWIWkElc3q8E7DP7bJ19fEkn1XUJZ2wjgX3DuFTXAgSkRws2dwM+3PryyqUKdrHMZR5xCU+0636SWb7vBLAp8W5nSc8eghgMYyRVd6ssaBcA6FyPzCloBOeZ6NgJaWF+UoafBIhSsFu9KMt0LEHUm3/rjnj82DV43M0fL7hs=";
private final static String APP_CERT_PATH = "/home/project/youtao/cert/alipay/appCertPublicKey_2021004176645906.crt";
private final static String ALIPAY_CERT_PATH = "/home/project/youtao/cert/alipay/alipayCertPublicKey_RSA2.crt";
private final static String ALIPAY_ROOT_CERT_PATH = "/home/project/youtao/cert/alipay/alipayRootCert.crt";
/**
* 初始化客户端请求
* @return
*/
public static AlipayClient initClient() throws Exception {
AlipayConfig alipayConfig = new AlipayConfig();
// 设置网关地址
alipayConfig.setServerUrl(serverUrl);
// 设置应用APPID
alipayConfig.setAppId(appId);
// 设置应用私钥
alipayConfig.setPrivateKey(APP_PRIVATE_KEY);
// 设置应用公钥证书路径
alipayConfig.setAppCertPath(APP_CERT_PATH);
// 设置支付宝公钥证书路径
alipayConfig.setAlipayPublicCertPath(ALIPAY_CERT_PATH);
// 设置支付宝根证书路径
alipayConfig.setRootCertPath(ALIPAY_ROOT_CERT_PATH);
// 设置请求格式,固定值json
alipayConfig.setFormat("json");
// 设置字符集
alipayConfig.setCharset("utf-8");
// 设置签名类型
alipayConfig.setSignType("RSA2");
return new DefaultAlipayClient(alipayConfig);
}
}