/// <summary> /// 临停缴费 /// </summary> /// <returns></returns> public ActionResult ParkCarPayment(decimal orderId, int source = 0) { if (string.IsNullOrWhiteSpace(AliPayUserId)) { return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取用户信息失败" })); } try { OnlineOrder order = CheckOrder(orderId); if (order.OrderType != OnlineOrderType.ParkFee) { throw new MyException("支付方法不正确"); } string tradeNo = MakeAlipayTradeOrder(order); OnlineOrderServices.UpdatePrepayIdById(tradeNo, order.OrderID); order.PrepayId = tradeNo; ViewBag.MaxWaitTime = DateTime.Now.AddMinutes(WXOtherConfigServices.GetTempParkingWeiXinPayTimeOut(order.CompanyID)).ToString("yyyy-MM-dd HH:mm:ss"); return(View(order)); } catch (MyException ex) { return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = "/QRCodeParkPayment/Index" })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("AliPay_Error", string.Format("支付失败 orderId:{0};AliUserId:{1}", orderId, AliPayUserId), ex, LogFrom.AliPay); return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付失败,请重新支付", returnUrl = "/QRCodeParkPayment/Index" })); } }
private UnifiedPayModel GetUnifiedPayModel(OnlineOrder order, string description, string attach = "") { UnifiedPayModel model = UnifiedPayModel.CreateUnifiedModel(order.CompanyID); if (string.IsNullOrWhiteSpace(order.PrepayId)) { string payNotifyAddress = string.Format("{0}{1}", WXApiConfigServices.QueryWXApiConfig(order.CompanyID).Domain, "/WeiXinPayNotify/Index"); //预支付 string postData = model.CreatePrePayPackage(order.OrderID.ToString(), ((int)(order.Amount * 100)).ToString(), WeiXinOpenId, description, payNotifyAddress, attach); UnifiedPrePayMessage result = PaymentServices.UnifiedPrePay(postData); if (result == null || !result.ReturnSuccess || !result.ResultSuccess || string.IsNullOrEmpty(result.Prepay_Id)) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPayment_Error", "预支付", string.Format("postData:{0}", postData), LogFrom.WeiXin); throw new Exception(string.Format("获取PrepayId 失败,Message:{0}", result.ToXmlString())); } OnlineOrderServices.UpdatePrepayIdById(result.Prepay_Id, order.OrderID); order.PrepayId = result.Prepay_Id; } return(model); }