示例#1
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            var builder = BuildPayContent();
            var request = new AlipayTradeWapPayRequest();

            request.BizContent = JsonConvert.SerializeObject(builder);


            string apiVersion = null;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                apiVersion = request.GetApiVersion();
            }
            else
            {
                apiVersion = "1.0";
            }

            // 添加协议级请求参数
            var txtParams = new AopDictionary(request.GetParameters());

            txtParams.Add("method", request.GetApiName());
            txtParams.Add("version", apiVersion);
            txtParams.Add("app_id", Config.app_id);
            txtParams.Add("format", "json");
            txtParams.Add("timestamp", DateTime.Now);
            txtParams.Add("auth_token", null);
            txtParams.Add("sign_type", Config.sign_type);
            txtParams.Add("terminal_type", request.GetTerminalType());
            txtParams.Add("terminal_info", request.GetTerminalInfo());
            txtParams.Add("prod_code", request.GetProdCode());
            txtParams.Add("charset", Config.charset);


            if (!string.IsNullOrEmpty(request.GetNotifyUrl()))
            {
                txtParams.Add("notify_url", request.GetNotifyUrl());
            }

            // 添加签名参数
            txtParams.Add("sign",
                          AlipaySignature.RSASign(txtParams, Config.merchant_private_key, Config.charset, false, Config.sign_type));

            //建立请求
            var sHtmlText = Submit.BuildRequest(txtParams, "get", "确认");


            return(View("Index", sHtmlText));
        }