public void PrepareBookingPaymnent() { var bookingEntity = new BookingEntity { Guid = Guid.NewGuid(), Cost = 500 }; var settings = new Mock <IOptions <PayServiceSettings> >(); settings.Setup(x => x.Value).Returns(new PayServiceSettings { YandexId = "yandexid" }); var service = new PayService(null, null, null, settings.Object, new DateService()); var result = service.PrepareBookingPaymnent(bookingEntity); Assert.AreEqual(8, result.Form.Count()); Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Url)); Assert.AreEqual("yandexid", result.Form.First(x => x.Name == "receiver").Value); Assert.AreEqual(bookingEntity.Guid.ToString(), result.Form.First(x => x.Name == "label").Value); Assert.AreEqual(bookingEntity.Cost.ToString(CultureInfo.InvariantCulture), result.Form.First(x => x.Name == "sum").Value); Assert.AreEqual("small", result.Form.First(x => x.Name == "quickpay-form").Value); Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Form.First(x => x.Name == "short-dest").Value)); Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Form.First(x => x.Name == "paymentType").Value)); Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Form.First(x => x.Name == "formcomment").Value)); Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Form.First(x => x.Name == "targets").Value)); }
private PayOrder CreateOrder(Request10001 request, Merchant merchant, PayService payProduct, PayChannel payChannel, MerchantPayService merchantPayService) { PayOrder order = new PayOrder(); order.OrderId = Guid.NewGuid().ToString(); order.OrderNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(1000, 9999); order.AgentNo = merchant.AgentNo; order.ChannelId = payChannel.ChannelId; order.ChannelName = payChannel.ChannelName; order.ChannelType = payChannel.ChannelType; order.CreateTime = DateTime.Now; order.DeviceType = request.DeviceType; order.ExtendField = request.ExtendField; order.FeeMode = payChannel.SettleMode.ToString(); order.SettleMode = payChannel.SettleMode.ToStr(); order.Ip = request.Ip; order.MemberInfo = "test"; order.MerchantId = merchant.MerchantId; order.MerchantOrderNo = request.MerchantOrderNo; order.MerchantOrderTime = request.MerchantOrderTime.TryDateTime(DateTime.Now).Value; order.NotifyUrl = request.NotifyUrl; order.OrderAmount = request.OrderAmount.TryDecimal(0).Value; order.OrderDescription = request.OrderDescription; order.PayStatus = (int)Max.Models.Payment.Common.Enums.PayStatus.未支付; order.PayTime = DateTime.Now; order.PreorderAmount = order.OrderAmount; order.ServiceFee = order.OrderAmount * merchantPayService.MerchantFeeRate; order.ServiceRate = merchantPayService.MerchantFeeRate; order.TransAmount = order.OrderAmount - order.ServiceFee; order.ServiceId = payProduct.ServiceId; this._payOrderService.Add(order); return(order); }
/// <summary> /// 查询列表 /// </summary> /// <param name="page"></param> /// <param name="limit"></param> /// <param name="condition"></param> /// <param name="tradeType"></param> /// <param name="type"></param> /// <param name="beginTime"></param> /// <param name="endTime"></param> /// <returns></returns> public JsonResult GetPayLimit(int?page, string limit, string condition, int?tradeType, int?type, string beginTime, string endTime) { int count = 0; if (condition != null && condition.Contains("[add]")) { condition = condition.Replace("[add]", "+"); } if (condition != null && condition.Contains("[reduce]")) { condition = condition.Replace("[reduce]", "-"); } IList <PaysDetail> list = PayService.GetPayPageLimit(page.Value, limit, condition, tradeType.HasValue ? tradeType.Value : 0, type.HasValue ? type.Value : 0, beginTime, endTime); JsonArrayResult <PaysDetail> jsonArrayResult = new JsonArrayResult <PaysDetail>(0, list); if (condition.IsEmpty() && beginTime.IsEmpty() && endTime.IsEmpty() && (type == 0)) { count = PayService.GetCount(); } else { count = PayService.GetPaysPageLimitCount(condition, tradeType.HasValue ? tradeType.Value : 0, type.HasValue ? type.Value : 0, beginTime, endTime); } jsonArrayResult.count = count; return(Json(jsonArrayResult)); }
// // GET: /QRPay/ /// <summary> /// /// </summary> /// <returns></returns> public ActionResult QROrder(int mch_id = 0, string store_id = "") { var paySvc = new PayService(); var smodel = paySvc.GetMerchStore(mch_id, store_id); return(View(smodel)); }
async Task GetPayLinkRequest(int?id, decimal sum) { if (Xamarin.Essentials.Connectivity.NetworkAccess != Xamarin.Essentials.NetworkAccess.Internet) { Device.BeginInvokeOnMainThread(async() => await DisplayAlert(AppResources.ErrorTitle, AppResources.ErrorNoInternet, "OK")); return; } Configurations.LoadingConfig = new LoadingConfig { IndicatorColor = (Color)Application.Current.Resources["MainColor"], OverlayColor = Color.Black, Opacity = 0.8, DefaultMessage = AppResources.Loading, }; await Loading.Instance.StartAsync(async progress => { PayService payLink = await server.GetPayLink(id, sum); if (payLink.payLink != null) { webView.Source = payLink.payLink; } else { await DisplayAlert(AppResources.ErrorTitle, payLink.Error, "OK"); try { _ = await Navigation.PopAsync(); } catch { } } }); }
public bool WxPayManualRetry(int pkid, string user) { var result = false; var remarks = string.Empty; try { var info = SelectRebateConfigByPKID(pkid); if (info != null) { var pay = PayService.QueryWxPayStatus("途虎朋友圈点赞返现", "WX_QIYEFUKUAN", new List <string> { info.OrderId.ToString() }); if (pay != null && pay.Any()) { using (var client = new PayClient()) { var getResult = client.WxPayManualRetry(new[] { pay.FirstOrDefault().WxPayOrderNo }); remarks = $"WxPayOrderNo:{pay.FirstOrDefault().WxPayOrderNo},RetryResult:{JsonConvert.SerializeObject(getResult)}"; if (getResult.Success) { result = dbScopeManager.Execute(conn => DALRebateConfig.UpdateStatusForCompleteV2(conn, pkid)) > 0; } } } } } catch (Exception ex) { logger.Error(ex); } InsertLog(pkid.ToString(), "WxPayManualRetry", result ? "重试成功" : "重试失败", remarks, string.Empty, string.Empty, user); return(result); }
public ActionResult AddForAjax(PayService model) { model.ServiceId = Guid.NewGuid().ToString(); model.CreateBy = CurrentSysUser.UserName; model.CreateTime = DateTime.Now; return(Json(this._payProductService.Add(model))); }
/// <summary> /// 【微信商户平台】账号支付查询。 /// </summary> /// <param name="drawlogid"></param> /// <param name="mch_billno">商户订单号</param> /// <returns></returns> public int WeChatAccountPayQuery(int drawlogid, string mch_billno) { // 把请求参数打包成数组 var sParaTemp = new SortedDictionary <string, string>(StringComparer.Ordinal) { { "nonce_str", Guid.NewGuid().ToString("N").Substring(0, 30) }, { "mch_id", Env.MchId }, { "mch_billno", mch_billno }, { "appid", Env.AppId }, { "bill_type", "MCHT" } }; // 建立请求. var content = PayService.BuildRequest(sParaTemp, Env.RedPackQueryUrl); if (string.IsNullOrEmpty(content)) { return(0); } var result = AnalyticXmlDataOfPayQuery(content); if (string.IsNullOrEmpty(result.return_code) || string.IsNullOrEmpty(result.result_code) || string.IsNullOrEmpty(result.mch_billno)) { return(0); } if (result.return_code != "SUCCESS" || result.result_code != "SUCCESS") { return(0); } // 此处省略:可以根据微信支付查询返回的结果,更新提现记录的状态:update return(0); }
public List <RebateConfigModel> SelectRebateConfig(Status status, string orderId, string phone, string wxId, string remarks, string timeType, DateTime?startTime, DateTime?endTime, string wxName, string principalPerson, string rebateMoney, string source, int pageIndex, int pageSize) { var result = new List <RebateConfigModel>(); try { dbScopeReadManager.Execute(conn => { result = DALRebateConfig.GetRebateConfig(conn, status, orderId ?? string.Empty, phone, wxId, remarks, timeType, startTime, endTime, wxName, principalPerson, rebateMoney, source, pageIndex, pageSize); if (result != null && result.Any() && pageSize != 9999999) { var pay = PayService.QueryWxPayStatus("途虎朋友圈点赞返现", "WX_QIYEFUKUAN", result.Select(x => x.OrderId.ToString()).ToList()); foreach (var item in result) { var payInfo = pay?.Where(x => String.Equals(x.OrderNo, item.OrderId.ToString()))?.FirstOrDefault(); item.PayStatus = payInfo?.PayStatus ?? 0; item.RedOutbizNo = payInfo?.WxPayOrderNo ?? string.Empty; item.Reason = payInfo?.Reason ?? string.Empty; item.UserPhone = item.UserPhone.Substring(0, 3) + "****" + item.UserPhone.Substring(item.UserPhone.Length - 4, 4); item.ImgList = DALRebateConfig.GetRebateApplyImageConfig(conn, item.PKID, ImgSource.UserImg); } } }); } catch (Exception ex) { logger.Error(ex); } return(result); }
public TakeCourseModel(CourseExploreService _exploreService, CoursePayService _coursePayService, CouseOrderService _couseOrderService, PayService _payService) { exploreService = _exploreService; coursePayService = _coursePayService; couseOrderService = _couseOrderService; payService = _payService; }
public CartController(TransacionRepository transacionRepository, PayService payService, AccountGameRepository accountGameRepository) { _transacionRepository = transacionRepository; _payService = payService; _accountGameRepository = accountGameRepository; }
public ServiceResult Update(PayService model) { var result = new ServiceResult(); this._payServiceReps.Update(model); return(result.IsSucceed("编辑支付产品成功")); }
public ServiceResult Add(PayService model) { var result = new ServiceResult(); this._payServiceReps.Add(model); return(result.IsSucceed("新增支付产品成功")); }
public PaymentController(TransacionRepository transacionRepository, PayService payService, UserAccountGameRepository userAccountGameRepository, AccountGameRepository accountGameRepository) { _transacionRepository = transacionRepository; _payService = payService; _userAccountGameRepository = userAccountGameRepository; _accountGameRepository = accountGameRepository; }
public PayController() { servicePay = new PayService(db); serviceOrder = new OrderService(db); serviceRecharge = new RechargeService(db); serviceUser = new UserService(db); serviceMoney = new MoneyService(db); userTicket = new UserTicketDetailService(db); }
//实例化 public OrderController() { serviceOrder = new OrderService(db); serviceDetail = new OrderDetailService(db); serviceRoom = new RoomService(db); serviceMoney = new MoneyService(db); serviceFlow = new FlowService(db); serviceDiscount = new DiscountService(db); servicePay = new PayService(db); UserTicketDetail = new UserTicketDetailService(db); }
public ActionResult Payment(int type, string security, string products) { if (security == null || security.IsEmpty() || security.Length < 5) { return(Json(new HttpResp(1, "请输入支付密码"))); } if (products == null) { return(Json(new HttpResp(1, "商品清单是空的哦~"))); } var session = SessionInfo.GetSession(); var user = UserService.GetUserById(session.Uid); // 1.安全验证 var cause = string.Empty; bool checkResult = PayService.CheckSecurityPassword(user, security, ref cause); if (!checkResult) { return(Json(new HttpResp(1, cause))); } // 2.判断支付类型(0=钱包支付, ^=站外支付平台) if (type == 1) { return(Redirect("/payment/toPay?type=1")); } // 3.生成记录 var productList = products.Split(',').ToList(); IList <Orders> orderses = new List <Orders>(); productList.ForEach(p => { orderses.Add(new Orders() { Pid = Convert.ToInt32(p), Uid = session.Uid, TradeType = type }); }); var placeOrder = OrderFacade.PlaceOrder(orderses); if (placeOrder) { return(Json(new HttpResp("支付成功"))); } return(Json(new HttpResp(1, "支付失败"))); }
/// <summary> /// 初始化接口服务 /// </summary> private void InitializeWeChatService() { CommonService = new CommonService(_client, _config.AppId, _config.AppSecret); CommentService = new CommentService(_client); CustomService = new CustomService(_client); FileService = new FileService(_client); MenuService = new MenuService(_client); MessageAllService = new MessageAllService(_client); TemplateMessageService = new TemplateMessageService(_client); UserService = new UserService(_client); PayService = new PayService(_client, _config); }
public void ConfirmBooking_NoBookingWithSuchGuid() { var guid = Guid.NewGuid(); var repoMock = new Mock <IRepository <BookingEntity> >(); repoMock.Setup(x => x.GetAll()).Returns(new List <BookingEntity>().AsQueryable()); var settings = Mock.Of <IOptions <PayServiceSettings> >(); var service = new PayService(repoMock.Object, null, null, settings, new DateService()); service.ConfirmBooking(guid, 0); }
/// <summary> /// 获取扫描支付的二维码地址 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult GetPayUrl(string id) { var order = new PayService().GetOrderByOrderNo(id); PrePayInfo info = new PrePayInfo(); info.OrderNo = order.No; info.PrePayNo = FCake.Core.Common.DataHelper.GetSystemID(); info.NeedPay = int.Parse(order.NeedPay.ToString().Split('.')[0]) * 100; info.LogingTime = DateTime.Now; new PrePayInfoService().AddPayInfo(info); WxPayData data = new WxPayData(); data.SetValue("body", "Fancake-蛋糕"); //商品描述 data.SetValue("attach", "Fancake"); //附加数据 data.SetValue("out_trade_no", info.PrePayNo); //订单号 data.SetValue("total_fee", Convert.ToInt32((order.NeedPay * 100).ToString().Split('.')[0])); //总金额(order.NeedPay * 100).ToString().Split('.')[0] data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); //交易起始时间 data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss")); //交易结束时间 data.SetValue("goods_tag", "Fancake"); //商品标记 data.SetValue("trade_type", "NATIVE"); //交易类型 data.SetValue("product_id", order.Id); //商品ID WxPayData result = WxPayApi.UnifiedOrder(data); //调用统一下单接口 string temp = result.GetValue("code_url").ToString(); //获得统一下单接口返回的二维码链接 //temp = HttpUtility.UrlEncode(temp); //生成二维码 //初始化二维码生成工具 QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; qrCodeEncoder.QRCodeVersion = 0; qrCodeEncoder.QRCodeScale = 4; //将字符串生成二维码图片 Bitmap image = qrCodeEncoder.Encode(temp, Encoding.Default); //end MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); string strUrl = "data:image/png;base64," + Convert.ToBase64String(ms.ToArray()); image.Dispose(); ViewBag.src = strUrl; //return File(ms.ToArray(), "png"); return(View()); }
public CreateOrderModel(CourseExploreService _exploreService, CouseOrderService _courseOrderService, CoursePayService _coursePayService, ILogger <CreateOrderModel> _logger, PayService _payService) { logger = _logger; courseOrderService = _courseOrderService; coursePayService = _coursePayService; exploreService = _exploreService; payService = _payService; }
public bool Post([FromBody] int meetingId) { PayService payService = new PayService(_moneyRepository, _meetingsRepository); if (payService.MakePay(meetingId, User.Identity.Name)) { return(true); } else { return(false); } }
public ActionResult EditForAjax(PayService model) { return(Json(this._payProductService.Update(c => c.ServiceId == model.ServiceId, c => new PayService() { ServiceName = model.ServiceName, ServiceCode = model.ServiceCode, Remark = model.Remark, ServiceType = model.ServiceType, Status = model.Status, UpdateBy = CurrentSysUser.UserName, UpdateTime = DateTime.Now }))); }
public ResultObj <PayStateModel> GetWeixinJsConfig(string clientId) { var log = LogManager.GetLogger("FycnApi", "wechat"); string url = string.Empty; PayStateModel payState = new PayStateModel(); //KeyJsonModel keyJsonInfo = PayHelper.AnalizeKey(k); try { IPay _ipay = new PayService(); WxPayConfig payConfig = _ipay.GenerateConfigModelWByClientId(clientId); if (string.IsNullOrEmpty(payConfig.APPID)) { payState.RequestState = "2"; payState.ProductJson = ""; payState.RequestData = ""; return(Content(payState)); } RedisHelper rh = new RedisHelper(4); string ticket = rh.StringGet(clientId + "-ticket"); if (string.IsNullOrEmpty(ticket)) { string urlAcess = string.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", payConfig.APPID, payConfig.APPSECRET); string jsonResult = HttpService.Get(urlAcess); log.Info("access_token:" + jsonResult); Dictionary <string, string> dicAcess = JsonHandler.GetObjectFromJson <Dictionary <string, string> >(jsonResult); string urlTicket = string.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token={0}", dicAcess["access_token"]); string jsonTicket = HttpService.Get(urlTicket); log.Info("ticket:" + jsonTicket); Dictionary <string, string> dicTicket = JsonHandler.GetObjectFromJson <Dictionary <string, string> >(jsonTicket); if (dicTicket["errmsg"] == "ok") { ticket = dicTicket["ticket"]; rh.StringSet(clientId + "-ticket", dicTicket["ticket"], new TimeSpan(1, 50, 50)); } } payState.RequestState = "1"; payState.ProductJson = ""; string retJson = MakeJsSign(payConfig.APPID, ticket); log.Info("result:" + retJson); payState.RequestData = retJson; } catch (Exception ex) { } return(Content(payState)); }
/// <summary> /// 【微信商户平台】账号支付。 /// </summary> /// <param name="drawlogid">提现id</param> /// <param name="openid"></param> /// <param name="money">提现金额</param> /// <param name="pubIp">公网ip</param> /// <returns>返回成功状态</returns> public int WeChatAccountPay(int drawlogid, string openid, float money, string pubIp) { // 商户号. var mch_id = Env.MchId; // 商户订单号(每个订单号必须唯一)组成:mch_id+yyyymmdd+10位一天内不能重复的数字。 . var mch_billno = string.Format("{0}{1}{2}{3}", mch_id, DateTime.Now.ToString("yyyyMMdd") , DateTime.Now.ToString("HHmmss"), new Random().Next(1000, 9999)); // 此处省略:可以根据生成的商户订单号在自己的数据库插入(或更新)一条提现记录:insert or update //////////////////////////////////////////////////////////////////////////////////////////////// // 把请求参数打包成数组 var sParaTemp = new SortedDictionary <string, string>(StringComparer.Ordinal) { { "nonce_str", Guid.NewGuid().ToString("N").Substring(0, 30) }, { "mch_id", mch_id }, { "mch_billno", mch_billno }, { "wxappid", Env.AppId }, { "send_name", "XX提现" }, { "re_openid", openid }, { "total_amount", Convert.ToInt32(money * 100).ToString(CultureInfo.InvariantCulture) }, { "total_num", "1" }, { "wishing", "感谢您的参与" }, { "client_ip", pubIp }, { "act_name", "XX提现申请" }, { "remark", "点击消息拆开红包即可获得现金" } }; // 建立请求. var content = PayService.BuildRequest(sParaTemp, Env.RedPackUrl); if (string.IsNullOrEmpty(content)) { return(0); } var result = AnalyticXmlDataOfPay(content); if (result == null || string.IsNullOrEmpty(result.mch_billno) || string.IsNullOrEmpty(result.re_openid) || string.IsNullOrEmpty(result.total_amount)) { return(0); } // 此处省略:可以根据微信支付返回的结果,更新提现记录的状态:update return(0); }
public void ConfirmBooking_AmountDiffTooBig() { var guid = Guid.NewGuid(); var bookEntity = new BookingEntity { Guid = guid, Cost = 100 }; var repoMock = new Mock <IRepository <BookingEntity> >(); repoMock.Setup(x => x.GetAll()) .Returns(new List <BookingEntity> { new BookingEntity(), bookEntity, new BookingEntity() }.AsQueryable()); var notificationMock = new Mock <INotificationService>(); var settings = new Mock <IOptions <PayServiceSettings> >(); var loggerMock = new Mock <ILogger <PayService> >(); var service = new PayService(repoMock.Object, notificationMock.Object, loggerMock.Object, settings.Object, new DateService()); service.ConfirmBooking(guid, 102); }
public Result Notify([FromBody] OrderDTO entity) { var result = new Result() { }; LogHelper.Log.Debug("Notify:" + entity.ToJson()); // 校验Key var key = EncryptHelper.Md5To32(EncryptHelper.Md5To32(entity.Order_QRPrice + entity.Order_Type) + AliPayConfig.secret_key); if (key != entity.Order_Sign) { result.Message = "处理订单失败,客户端密匙有误!"; return(result); } var order = PayService.GetOrder(entity.Order_QRPrice); if (order == null) { result.Message = "处理订单失败,未找到记录"; return(result); } else { order.Order_Status = "Finished"; CacheHelper.RemoveCache(order.Order_OutTradeNO); CacheHelper.SetCacheValue(order.Order_OutTradeNO, order, 24 * 60); result.IsSucc = true; result.Datas = order; result.Message = "收款处理成功"; } return(result); }
public Result SaveOrder([FromBody] OrderDTO entity) { var result = new Result() { }; // 如果有重复记录,默认递减 entity.Order_QRPrice = entity.Order_Price; while (PayService.GetOrder(entity.Order_QRPrice) != null) { entity.Order_QRPrice = (Convert.ToDouble(entity.Order_QRPrice) - 0.01).ToString(); } if (Convert.ToDouble(entity.Order_QRPrice) <= 0) { result.Message = "系统火爆,请过1-3分钟后付款!"; return(result); } entity.Order_QRUrl = PayService.GetAlipayQRUrl(entity); entity.Order_Status = "Created"; CacheHelper.SetCacheValue(entity.Order_OutTradeNO, entity, AliPayConfig.time_expire_min); result.IsSucc = true; result.Datas = entity; return(result); }
public NotifyController() { servicePay = new PayService(db); }
/// <summary> /// 初始化构造函数 /// </summary> public BasePayBuilder() { PaySvc = new PayService(); LogEngine = new LogEngine(); }