Ejemplo n.º 1
0
        public FileContentResult getQRImage()
        {
            Hashtable aHT = Authorizes.GetAuthorizeCache(Request);

            if (aHT != null)
            {
                string channel = Request.QueryString["c"];
                string payId   = Request.QueryString["p"];
                if (channel == "qrway" && double.TryParse(Request["a"], out double amount) && amount > 0)
                {
                    // 得到接口数据并解析其对应的支付接口逻辑。
                    Hashtable htPayment = PaymentUtil.GetPaymethod2Hashtable(channel, payId);
                    if (htPayment != null)
                    {
                        UriUtil uriUtil = null;
                        try
                        {
                            uriUtil = new UriUtil(PickParam(htPayment).GetValueAsString("PAYLINK"));
                        }
                        catch (Exception)
                        {
                        }

                        if (uriUtil != null)
                        {
                            ParamUtil paramUtil = PickParam(Request.QueryString).Merge(htPayment).SetCmd(uriUtil.GetQueryItem(ActionUtil.Cmd)).ExecuteCmd(uriUtil.GetActionInstance(GetControl()));
                            if (paramUtil.IsOK())
                            {
                                return(File(paramUtil.GetValue <byte[]>(), paramUtil.GetValueAsString("content-type")));
                            }
                        }
                    }
                }
            }

            // 返回默认二维码图片
            using (Image image = Image.FromFile(Server.MapPath("~/content/images/noimage.png")))
            {
                using (MemoryStream ms1 = new MemoryStream())
                {
                    image.Save(ms1, System.Drawing.Imaging.ImageFormat.Png);

                    return(File(ms1.ToArray(), "image/png"));
                }
            }
        }