package com.izouma.nineth.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.AllArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@AllArgsConstructor
@Configuration
@EnableConfigurationProperties({AlipayProperties.class, AlipayProperties.class})
public class AlipayConfig {
    private final AlipayProperties properties;

    @Bean
    public AlipayClient alipayClient() {
        return new DefaultAlipayClient(properties.getGateway(), properties.getAppId(), properties.getPrivateKey(),
                "json", "UTF-8", properties.getAliPublicKey(), "RSA2");
    }
}
