using Alipay.AopSdk.Core;
using Alipay.AopSdk.Core.Domain;
using Alipay.AopSdk.Core.Request;
using Hncore.Infrastructure.Common;
using Hncore.Infrastructure.Serializer;
using Hncore.Pass.PaymentCenter.Model;
using Hncore.Pass.PaymentCenter.WxPay.WechatJsPay;
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace Hncore.Pass.PaymentCenter.Pay.AliPay
{
    public class AliPayClient
    {
        public static readonly string url = "https://api.mch.weixin.qq.com";
        IHttpClientFactory m_HttpClientFactory;
        public AliPayClient(IHttpClientFactory _HttpClientFactory)
        {
            m_HttpClientFactory = _HttpClientFactory;
        }

        public async Task<string> PcPayCreateOrderAsync(WxJsPayCreateOrderRequest request, MchInfo mchInfo)
        {

            var APP_ID = "";
            var APP_PRIVATE_KEY = "";
            var CHARSET = "";
            var ALIPAY_PUBLIC_KEY = "";

            // 组装业务参数model
            
            
            AlipayTradePagePayModel model = new AlipayTradePagePayModel
            {
                Body = request.Body,
                Subject = request.Body,
                TotalAmount = request.TotalFee.ToString(),
                OutTradeNo = "",
                ProductCode = "FAST_INSTANT_TRADE_PAY"//QUICK_WAP_PAY
            };

            AlipayTradePagePayRequest aliRequest = new AlipayTradePagePayRequest();
            // 设置同步回调地址
          //  aliRequest.SetReturnUrl($"http://{Request.Host}/Pay/Callback");
            // 设置异步通知接收地址
            aliRequest.SetNotifyUrl("");
            // 将业务model载入到request
            aliRequest.SetBizModel(model);

            var _aopClient = new DefaultAopClient("https://openapi.alipay.com/gateway.do", APP_ID, APP_PRIVATE_KEY);

            var response = _aopClient.PageExecute(aliRequest);

            return "";
        }


        public async Task<string> H5PayCreateOrderAsync(WxH5PayCreateOrderRequest request, MchInfo mchInfo)
        {
            //AlipayTradeWapPayModel

            return "";
        }
    }
}
