package com.zcloud.common.alipay;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * 提供支付宝相关的一些对象
 */
@Configuration
public class AliBeanUtils {
    @Autowired
    private AliPayBean aliPayBean;
    //创建支付宝需要的客户端对象
    @Bean
    public AlipayClient alipayClient(){
        return new DefaultAlipayClient(aliPayBean.getAliDomain(),aliPayBean.getAppId(),aliPayBean.getMerchantPrivateKey(),"json","utf-8",
                aliPayBean.getAlipayPublicKey(),"RSA2");
    }
    //创建一个支付宝的请求对象
    @Bean
    public AlipayTradePagePayRequest alipayTradePagePayRequest(){
     return new AlipayTradePagePayRequest();
    }
}
