Esempio n. 1
0
        public async Task <IActionResult> GetImg()
        {
            var pay    = new NativePay();
            var str    = pay.GetPrePayUrl(Guid.NewGuid().ToString());
            var stream = (MemoryStream)await Task.Run(() => { return(WeAppPayApi.MakeQRCode(str)); });

            //var bytes = new byte[stream.Length];
            //await stream.WriteAsync(bytes, 0, bytes.Length);
            //System.IO.File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "testqrcode2.jpg", bytes);
            var resStream = new MemoryStream(stream.GetBuffer());

            return(new FileStreamResult(resStream, "image/jpeg"));

            //return File(stream, "image/jpeg");
        }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Log.Info(this.GetType().ToString(), "page load");

        NativePay nativePay = new NativePay();

        //生成扫码支付模式一url
        string url1 = nativePay.GetPrePayUrl("123456789");

        //生成扫码支付模式二url
        string url2 = nativePay.GetPayUrl("123456789", 100);

        //将url生成二维码图片
        Image1.ImageUrl = "MakeQRCode.aspx?data=" + HttpUtility.UrlEncode(url1);
        Image2.ImageUrl = "MakeQRCode.aspx?data=" + HttpUtility.UrlEncode(url2);
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            LogHelper.Info(this.GetType().ToString(), "page load");

            NativePay nativePay = new NativePay();

            //生成扫码支付模式一url
            string url1 = nativePay.GetPrePayUrl("123456789");

            //生成扫码支付模式二url
            //TODO 根据productId获取产品信息
            //string url2 = nativePay.GetPayUrl("123456789", "牛肉干", "", "1000", "meet");

            //将url生成二维码图片
            Image1.ImageUrl = "MakeQRCode.aspx?data=" + HttpUtility.UrlEncode(url1);
            //Image2.ImageUrl = "MakeQRCode.aspx?data=" + HttpUtility.UrlEncode(url2);
        }
Esempio n. 4
0
        public ActionResult <string> GetMakeQRCode(string productId, int type)
        {
            NativePay nativePay = new NativePay();
            string    url       = string.Empty;

            if (type == 1)
            {
                //生成扫码支付模式一url
                url = nativePay.GetPrePayUrl(productId);
            }
            else if (type == 2)
            {
                //生成扫码支付模式二url
                url = nativePay.GetPayUrl(productId);
            }

            //将url生成二维码图片
            return(MakeQRCode.GetMakeQRCodeBase64String(HttpUtility.UrlEncode(url)));
        }
Esempio n. 5
0
        /// <summary>微信扫码支付方式1
        /// </summary>
        /// <param name="producId"></param>
        /// <returns></returns>
        public string GetPrePayUrl(string producId)
        {
            NativePay pay = new NativePay(_appConfig);

            return(pay.GetPrePayUrl(producId));
        }