Example #1
0
        public ActionResult ChargeAccount(ChargeAccountModel model)
        {
            PaymentManagement payMgr = new PaymentManagement(User.Identity.GetUserId<int>());
            if(model.TransferType==1)
            {
                AlipayConfig config = new AlipayConfig(System.IO.Path.Combine(Request.PhysicalApplicationPath, "Config\\AliPayConfig.xml"));
                Submit submit = new Submit(config);
                BPaymentHistory payment = null;
                try
                {
                    payment = payMgr.CreateChargeAccountPayment(User.Identity.GetUserId<int>(), model.Amount, model.TransferType);
                    if (payment == null)
                    {
                        ViewBag.Message = "充值失败";
                        return View(model);
                    }

                }catch(Exception ex)
                {
                    ViewBag.Message = "充值失败";
                    return View(model);
                }
                
                SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>();
                sParaTemp.Add("partner", config.Partner);
                sParaTemp.Add("seller_email", config.Email);
                sParaTemp.Add("_input_charset", config.Input_charset.ToLower());
                sParaTemp.Add("service", "create_direct_pay_by_user");
                sParaTemp.Add("payment_type", "1");
                sParaTemp.Add("notify_url", config.Notify_Url);
                sParaTemp.Add("return_url", config.Return_Url);
                sParaTemp.Add("out_trade_no", payment.Id.ToString());
                sParaTemp.Add("subject", string.Format("宽迈网络账户充值 {0} 元", model.Amount));
                sParaTemp.Add("total_fee", model.Amount.ToString("0.00"));
                sParaTemp.Add("body", string.Format("宽迈网络账户充值 {0} 元", model.Amount));
                sParaTemp.Add("show_url", "");
                sParaTemp.Add("seller_id", config.Partner);
                //sParaTemp.Add("anti_phishing_key", "");
                //sParaTemp.Add("exter_invoke_ip", "");

                //建立请求
                string sHtmlText = submit.BuildRequest(sParaTemp, "get", "确认");
                //Response.Write("ok");
                Response.Clear();
                Response.Charset = "utf-8";
                Response.Write(sHtmlText);
            }
            return View(model);
        }
Example #2
0
 public ActionResult ChargeAccount()
 {
     ChargeAccountModel model = new ChargeAccountModel() { TransferType = 1 };
     ViewBag.Message = Request["message"];         
     return View(model);
 }