Beispiel #1
0
        public ActionResult Pay(string productCode, string productName, string productDesc, float price, int num, int paytype /*1-支付宝,2-微信,3-银联*/)
        {
            string orderno = wxPayService.generate_orderno(1, 1);

            #region 保存订单记录,以便接收支付成功消息时更新订单的状态
            /// insert 到order表
            //orders o = new orders();
            //o.orderno = generate_orderno(1, 1);
            //o.product_code = cpcode;
            //o.product_name = cpname;
            //o.product_desc = cpdesc;
            //o.price = price;
            //o.num = num;
            //switch (paytype)
            //{
            //    case 1:
            //        o.paytype = "支付宝";
            //        break;
            //    case 2:
            //        o.paytype = "微信支付";
            //        break;
            //    case 3:
            //        o.paytype = "银联支付";
            //        break;
            //}

            //o.sumittime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            //o.Insert();
            #endregion
            float f         = price * 100.0F * num;
            int   total_fee = (int)f;
            ////LogService.LOG_LEVENL = 3;
            ////LogService.Debug(this.GetType().ToString(), "total_fee=" + f);

            switch (paytype)
            {
            case 1:     //支付宝
                //Response.Redirect(Url.Action("Index", "aliPay") + "?productCode=" + cpcode + "&productName=" + cpname + "&productDesc=" + cpdesc + "&orderno=" + o.orderno + "&total_fee=" + total_fee);
                break;

            case 2:    // 微信支付
                       //    Response.Redirect(Url.Action("Index", "Weixin") + "?productCode=" + cpcode + "&productName=" + cpname + "&productDesc=" + cpdesc + "&orderno=" + orderno + "&total_fee=" + total_fee);
                NativePay nativePay = new NativePay();
                //生成扫码支付模式二url
                string url = StringService.ToHexString(nativePay.GetPayUrl(productCode, productName, productDesc, orderno, total_fee));

                Response.Redirect(Url.Action("ScanQRCodeImage", "Home") + "?url=" + HttpUtility.UrlEncode(url) + "&orderno=" + orderno);

                break;

            case 3:     // 银联
                //Response.Redirect(Url.Action("Index", "Bank") + "?productCode=" + cpcode + "&productName=" + cpname + "&productDesc=" + cpdesc + "&orderno=" + o.orderno + "&total_fee=" + total_fee);
                break;
            }
            return(Content(""));
        }