package com.fzm.mall.server.front.repo.alipay;


import com.alipay.easysdk.kernel.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliPayConfig {
    // 商户appid
    @Value("${alipay.appid}")
    private String APPID;
    // 私钥 pkcs8格式的
    @Value("${alipay.rsa-private-key}")
    private String RSA_PRIVATE_KEY;
    // 服务器异步通知页面路径 需http://或者https://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    @Value("${alipay.notify-url}")
    private String NOTIFY_URL;
    // 请求网关地址
    @Value("${alipay.url}")
    private String URL;
    //    public static String DEV_URL = "openapi.alipaydev.com";
    // 支付宝公钥
    @Value("${alipay.alipay-public-key}")
    private String ALIPAY_PUBLIC_KEY;
    @Value("${alipay.sign-type}")
    private String SIGN_TYPE;
    @Value("${alipay.protocl}")
    private String PROTOCOL;

    @Bean
    public Config getOptions() {
        Config config = new Config();
        config.protocol = PROTOCOL;
        config.gatewayHost = URL;
        config.signType = SIGN_TYPE;
        config.appId = APPID;
        config.merchantPrivateKey = RSA_PRIVATE_KEY;
        config.alipayPublicKey = ALIPAY_PUBLIC_KEY;
        config.notifyUrl = NOTIFY_URL;

        return config;
    }
}
