GetPayUrl() public method

生成直接支付url,支付url有效期为2小时,模式二
public GetPayUrl ( NativePayData payData ) : JResult
payData Cedar.Foundation.WeChat.WxPay.Business.WxPay.Entity.NativePayData
return Cedar.Framework.Common.BaseClasses.JResult
示例#1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static JResult GetNativePayQrCode(NativePayData data)
        {
            var nativePay = new NativePay();

            //var data = new NativePayData
            //{
            //    Body = "快拍立信拍车定金",//商品描述
            //    Attach = "testAttach",//附加数据
            //    TotalFee = 1,//总金额
            //    ProductId = "prodid",//商品ID
            //    OutTradeNo = WxPayApi.GenerateOutTradeNo(),//订单编号
            //    GoodsTag = "testgood"
            //};

            var result = nativePay.GetPayUrl(data);

            if (result.errcode != 0)
            {
                return result;
            }

            //生成二维码
            var bitmap = BarCodeUtility.CreateBarcode(result.errmsg.ToString(), 240, 240);

            var ran = new Random();
            var key = string.Concat("wxpay", DateTime.Now.ToString("yyyyMMddHHmmss"), ran.Next(999));
            var stream = BarCodeUtility.BitmapToStream(bitmap);
            //上传图片到七牛云
            var qinniu = new QiniuUtility();
            var qrcode = qinniu.Put(stream, "", key);
            return JResult._jResult(0, qrcode);
        }
示例#2
0
        public void WxPayQrCodeTest()
        {
            NativePayData data = new NativePayData();
            data.Body="ccntest";//商品描述
            data.Attach ="ccntest";//附加数据
            data.TotalFee = 1;//总金额
            data.ProductId="123456789";//商品ID

            NativePay nativePay = new NativePay();
            string url2 = nativePay.GetPayUrl(data);

            var bitmap = BarCodeUtility.CreateBarcode(url2, 240, 240);

            var ran = new Random(Guid.NewGuid().GetHashCode());
            var key = string.Concat("wxpay", DateTime.Now.ToString("yyyyMMddHHmmss"), ran.Next(999));

            var stream = BarCodeUtility.BitmapToStream(bitmap);
            //上传图片到七牛云
            var qinniu = new QiniuUtility();
            var qrcode = qinniu.Put(stream,"", key);
            stream.Dispose();
        }