private static void logPaymentData(string resSettle, string resVerify, string saleReferenceID, string orderID, int resultCode, CartStatus paymentStatus) { var bankData = new BankData { ResCode = resultCode, SaleReferenceID = resultCode == 0 ? saleReferenceID : "-1", SettleCode = resultCode == 0 ? Int32.Parse(resSettle) : -1, VerifyCode = resultCode == 0 ? Int32.Parse(resVerify) : -1 }; string data = Newtonsoft.Json.JsonConvert.SerializeObject(bankData); var paymentLog = new PaymentLog { KeyID = orderID, SettleDate = DateTime.Now, PaymentStatus = paymentStatus, Data = data, LastUpdate = DateTime.Now }; PaymentLogs.UpdateByOrderID(paymentLog); }
public void InsertIntoPaymentLogs(string RefID, Guid OrderID, long?SaleRefrenceID, int ResCode_Request, Nullable <int> ResCode_Payment, Nullable <int> ResCode_Verify, Nullable <int> ResCode_Settle, string ErrorrText, Boolean IsSiccess) { using (MashadCarpetEntities db = new MashadCarpetEntities()) { PaymentLogs a = new PaymentLogs(); a.PaymentLogID = Guid.NewGuid(); a.fk_OrderID = OrderID; a.RefID = RefID; a.SaleReferenceId = SaleRefrenceID; a.ResCode_Request = ResCode_Request; a.ResCode_Payment = ResCode_Payment; a.ResCode_Settle = ResCode_Settle; a.ResCode_Verify = ResCode_Verify; a.ErrorMessage = ErrorrText; a.PaymentDate = DateTime.Now; a.PaymentIP = Request.UserHostName; a.IsSuccess = false; db.PaymentLogs.Add(a); db.SaveChanges(); } }
private Payment Payment_PayPal(TransactionProcessParamsItems requestParams) { var result = _TransactionsService.GetTransactionById(requestParams.TransactionProcess.ID.ToString()); var payment = new Payment(); if (result == null) { return(payment); } payment = _PaypalServices.CreatePayment(requestParams); result.Status = payment.state; result.ReferenceId = payment.id; _TransactionsService.UpdateTransactions(result); var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(payment), Error = "Success", PaymentType = "PAYPAL", FunctionName = "ProcessPayment", TransID = requestParams.TransactionProcess.ID.ToString() }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); return(payment); }
protected override void ShowPage() { pagetitle = "用户控制面板"; if (!IsLogin()) { return; } //获取积分收入日志数 payinlogcount = PaymentLogs.GetPaymentLogInRecordCount(userid); BindItems(payinlogcount); payloglist = PaymentLogs.GetPayLogInList(16, pageid, userid); }
public void InsertIntoPaymentLogs(Guid OrderID, int ResCode, string ErrorrText) { using (MashadCarpetEntities db = new MashadCarpetEntities()) { PaymentLogs a = new PaymentLogs(); a.PaymentLogID = Guid.NewGuid(); a.fk_OrderID = OrderID; a.ResCode_Request = ResCode; //a.PaymentDate = DateTime.Now; a.PaymentIP = Request.UserHostName; a.IsSuccess = false; db.PaymentLogs.Add(a); db.SaveChanges(); } }
private static void logPaymentData(string orderID, int toPay, int cartID) { var now = DateTime.Now; PaymentLog log = new PaymentLog { CartID = cartID, IP = Utilities.GetIP(), BankType = BankType.Mellat, ConnectDate = now, PaymentStatus = CartStatus.InProgress, KeyID = orderID, Price = toPay, LastUpdate = now }; PaymentLogs.Insert(log); }
/// <summary> /// 获取主题价格 /// </summary> /// <param name="topicInfo"></param> /// <returns></returns> private int GetTopicPrice(TopicInfo topicInfo, CredentialInfo creinfo, int ismoder) { int price = 0; if (topicInfo.Special == 0)//普通主题 { //购买帖子操作 //判断是否为购买可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 if (topicInfo.Price > 0 && creinfo.UserID != topicInfo.Posterid && ismoder != 1) { price = topicInfo.Price; //时间乘以-1是因为当Configs.GetMaxChargeSpan()==0时,帖子始终为购买帖 if (PaymentLogs.IsBuyer(topicInfo.Tid, creinfo.UserID) || (Utils.StrDateDiffHours(topicInfo.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0)) //判断当前用户是否已经购买 { price = -1; } } } return(price); }
public Result SaveProcessLogs(PaymentLogs Logs) { try { _Db.PaymentLogs.Add(Logs); _Db.SaveChanges(); return(new Result() { Data = Logs, Message = "SaveProcessLogs", Status = Enums.ResultStatus.OK }); } catch (Exception ex) { return(new Result() { Data = null, Message = "Exception", Status = Enums.ResultStatus.Warning }); } }
protected override void ShowPage() { pagetitle = "用户控制面板"; if (userid == -1) { AddErrLine("你尚未登录"); return; } user = Discuz.Forum.Users.GetUserInfo(userid); //得到当前用户请求的页数 pageid = DNTRequest.GetInt("page", 1); //获取主题总数 payoutlogcount = PaymentLogs.GetPaymentLogOutRecordCount(userid); //获取总页数 pagecount = payoutlogcount % pagesize == 0 ? payoutlogcount / pagesize : payoutlogcount / pagesize + 1; if (pagecount == 0) { pagecount = 1; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } if (pageid > pagecount) { pageid = pagecount; } //获取收入记录并分页显示 payloglist = PaymentLogs.GetPayLogOutList(pagesize, pageid, userid); pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "usercpcreditspayoutlog.aspx", 8); }
public IActionResult RefundPaypal(string TransId) { var trans = _TransactionsService.GetTransactionById(TransId); APIResponseData responseData = new APIResponseData(); responseData.StatusCode = 0; responseData.Message = "Failed."; responseData.Result.Data = new { TransactionId = TransId, Status = "Fail" }; try { var RelatedTrans = _IRelatedTransaction.GetRelatedTransactionDetails(TransId).OrderByDescending(x => x.create_time).FirstOrDefault(); if (RelatedTrans != null) { var refund = _PaypalServices.RefundPayment(RelatedTrans.IdRelatedSale, RelatedTrans.parent_payment); responseData.StatusCode = 1; responseData.Message = "Success"; responseData.Result.Data = new { TransactionId = TransId, Status = refund.state }; var RefundPaypal = new RefundPaypal() { reason = refund.reason, description = refund.description, state = refund.state, parent_payment = refund.parent_payment, RefundID = refund.id, sale_id = refund.sale_id, TransID = TransId }; RefundserviceRepository.InsertRefundPaypal(RefundPaypal); var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(refund), Error = "Success", PaymentType = "PAYPAL", FunctionName = "RefundPaypal", TransID = TransId }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } } catch (Exception ex) { responseData.StatusCode = 0; responseData.Message = "Something went wrong, please try again."; var typeEx = ex.GetType(); if (typeEx.FullName == "PayPal.PayPalException") { dynamic excep = ex.InnerException; dynamic sourceEx = excep.InnerExceptions[0].Response; var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(trans), Error = sourceEx, PaymentType = "PAYPAL", FunctionName = "RefundPaypal", TransID = TransId }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } else { var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(trans), Error = ex.InnerException.Message, PaymentType = "PAYPAL", FunctionName = "RefundPaypal", TransID = TransId }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } EmailHelpers.SendEmail(new Common.DTO.ErrorInfo() { Section = $"AQ RefundPaypal PaymentType: PAYPAL <br /> TransactionID : {TransId}", Exception = ex }); } return(Ok(responseData)); }
public IActionResult ExecutePaymentPayPal(InfoPayment infoPayment) { APIResponseData responseData = new APIResponseData(); responseData.StatusCode = 0; responseData.Message = "Failed."; try { var payment = _PaypalServices.ExecutePayment(infoPayment.PaymentId, infoPayment.PayerId); var result = _TransactionsService.GetTransactionById(infoPayment.TranId); result.PaymentCardToken = infoPayment.PaymentToken; result.StripeCustomerId = infoPayment.PayerId; result.Status = payment.state; result.ModifiedDate = DateTime.Now; _TransactionsService.UpdateTransactions(result); foreach (var tran in payment.transactions) { foreach (var item in tran.related_resources) { var RelatedTrans = new RelatedTransactionDetails() { totalAmount = Convert.ToDecimal(item.sale.amount.total), TransID = result.ID.ToString(), currency = item.sale.amount.currency, IdRelatedSale = item.sale.id, payment_mode = item.sale.payment_mode, state = item.sale.state, protection_eligibility = item.sale.protection_eligibility, protection_eligibility_type = item.sale.protection_eligibility_type, parent_payment = item.sale.parent_payment, }; _IRelatedTransaction.InsertRelatedTransactionDetails(RelatedTrans); foreach (var link in item.sale.links) { var LinksRelated = new LinksRelated() { href = link.href, method = link.method, rel = link.rel, IdRelatedTransaction = RelatedTrans.ID, }; linksRelatedService.InsertLinksRelated(LinksRelated); } } } // Hint: You can save the transaction details to your database using payment/buyer info responseData.StatusCode = 1; responseData.Message = "Success"; responseData.Result.Data = new { TransactionId = infoPayment.TranId, Status = payment.state }; var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(payment), Error = "Success", PaymentType = "PAYPAL", FunctionName = "ExecutePaymentPayPal", TransID = infoPayment.TranId }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } catch (Exception ex) { responseData.StatusCode = 0; responseData.Message = "Something went wrong, please try again."; var typeEx = ex.GetType(); if (typeEx.FullName == "PayPal.PayPalException") { dynamic excep = ex.InnerException; dynamic sourceEx = excep == null ? "" : excep?.InnerExceptions[0]?.Response; var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(infoPayment), Error = sourceEx, PaymentType = "PAYPAL", FunctionName = "ExecutePaymentPayPal", TransID = infoPayment.TranId }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } else { var PaymentLogs = new PaymentLogs() { //Data = Newtonsoft.Json.JsonConvert.SerializeObject(infoPayment), Data = Newtonsoft.Json.JsonConvert.SerializeObject(infoPayment), Error = ex.InnerException.Message, PaymentType = "PAYPAL", FunctionName = "ExecutePaymentPayPal", TransID = infoPayment.TranId }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } EmailHelpers.SendEmail(new Common.DTO.ErrorInfo() { Section = $"ExecutePaymentPayPal <br /> TransactionID : {infoPayment.TranId}", Exception = ex }); } return(Ok(responseData)); }
public IActionResult ProcessPayment([FromBody] TransactionProcessParamsItems request, string PaymentType) { var requestParams = request.TransactionProcess; Transactions model = new Transactions(); model.BackUrl = requestParams.BackUrl; model.Currency = requestParams.Currency; model.Description = requestParams.Description; model.ID = requestParams.ID; model.OrderAmount = requestParams.OrderAmount; model.OrderId = requestParams.OrderId; model.PaymentMethod = requestParams.PaymentMethod; model.PaymentCardToken = requestParams.PaymentCardToken; APIResponseData responseData = new APIResponseData(); responseData.StatusCode = 0; responseData.Message = "Failed."; if (model == null) { responseData.StatusCode = 2; responseData.Message = "Value is required."; goto skipToReturn; } try { var trans = _TransactionsService.GetTransactionById(model.ID.ToString()); if (trans == null) { responseData.Message = "Notfound."; responseData.StatusCode = 2; goto skipToReturn; } #region PAYPAL if (PaymentType.ToUpper() == "PAYPAL") // Paypal { var paypal = Payment_PayPal(request); trans.ModifiedDate = DateTime.Now; trans.PaymentTypeAPI = PaymentType.ToUpper(); _TransactionsService.UpdateTransactions(trans); responseData.Message = "Successfully."; responseData.StatusCode = 1; responseData.Result.Data = new { TransactionId = model.ID, PaymenID = paypal.id, PaymentStatus = paypal.state, FailureMessage = paypal.failed_transactions }; return(Ok(responseData)); //return new JsonResult(paypal); } #endregion #region Stripe else { Stripe.Charge charge = null; //var amount = charge.Amount.ToString(); decimal payAmount = 0; if (trans.PaymentMethod == Common.DTO.PaymentMethod.Full.ToUpper()) { payAmount = model.OrderAmount.Value; charge = StripeHelpers.RequestCharge(model, payAmount, model.Description); trans.Status = charge.Status; trans.ReferenceId = charge.Id; } else { var transactionItems = _TransactionsService.GetTransactionItems(trans.ID).ToList() .Where(x => x.Status == null).OrderBy(x => x.OrderNo).ToList(); var nextPayItem = transactionItems.FirstOrDefault(); payAmount = nextPayItem.PayAmount.Value; string description = string.Format("Charge {0}% of OrderId: {1}. {2}", nextPayItem.PayPercent, model.OrderId, model.Description); charge = StripeHelpers.RequestCharge(model, payAmount, description); nextPayItem.Status = charge.Status; nextPayItem.ReferenceId = charge.Id; _TransactionsService.UpdateTransactionItem(nextPayItem); trans.Status = PaymentStatus.Processing; } trans.ModifiedDate = DateTime.Now; trans.PaymentCardToken = model.PaymentCardToken; trans.StripeCustomerId = charge.CustomerId; trans.OrderAmountRemaining = trans.OrderAmountRemaining.Value - payAmount; trans.PaymentTypeAPI = PaymentType.ToUpper(); _TransactionsService.UpdateTransactions(trans); responseData.Message = "Successfully."; responseData.StatusCode = 1; responseData.Result.Data = new { TransactionId = model.ID, PaymenID = charge.Id, PaymentStatus = charge.Status, FailureMessage = charge.FailureMessage }; var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(charge), Error = "Success", PaymentType = PaymentType, FunctionName = "ProcessPayment", TransID = requestParams.ID.ToString() }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } #endregion } catch (Exception ex) { responseData.Message = "Something went wrong, please try again."; responseData.StatusCode = 0; var typeEx = ex.GetType(); if (typeEx.FullName == "PayPal.PayPalException") { var excep = ex as PayPal.PaymentsException; StringBuilder sb = new StringBuilder(); sb.AppendLine("Error: " + excep.Details.name); sb.AppendLine("Message: " + excep.Details.message); sb.AppendLine("URI: " + excep.Details.information_link); sb.AppendLine("Debug ID: " + excep.Details.debug_id); foreach (var errorDetails in excep.Details.details) { sb.AppendLine("Details: " + errorDetails.field + " -> " + errorDetails.issue); } var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(request), Error = sb.ToString(), PaymentType = PaymentType, FunctionName = "ProcessPayment", TransID = requestParams.ID.ToString() }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } else { var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(request), Error = ex.InnerException != null?Newtonsoft.Json.JsonConvert.SerializeObject(ex.InnerException.Message) : Newtonsoft.Json.JsonConvert.SerializeObject(ex.Message), PaymentType = PaymentType, FunctionName = "ProcessPayment", TransID = requestParams.ID.ToString() }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } EmailHelpers.SendEmail(new Common.DTO.ErrorInfo() { Section = $"AQ ProcessPayment PaymentType: {PaymentType} <br /> TransactionID : {requestParams.ID}", Exception = ex }); } skipToReturn: //label use to force return return(Ok(responseData)); }
public IActionResult RefundStripe(string TransId) { var trans = _TransactionsService.GetTransactionById(TransId); APIResponseData responseData = new APIResponseData(); responseData.StatusCode = 0; responseData.Message = "Failed."; responseData.Result.Data = new { TransactionId = TransId, Status = "Fail" }; try { if (trans != null) { var refund = StripeHelpers.RefundPayment(trans.ReferenceId); responseData.StatusCode = 1; responseData.Message = "Success"; responseData.Result.Data = new { TransactionId = TransId, Status = refund.Status }; var RefundStripe = new RefundStripe() { Reason = refund.Reason, Description = refund.Description, Status = refund.Status, ChargeId = trans.ReferenceId, Amount = refund.Amount, RefundID = refund.Id, FailureReason = refund.FailureReason, Currency = refund.Currency, TransID = TransId }; refundStripeService.InsertRefundStripe(RefundStripe); var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(refund), Error = "Success", PaymentType = "STRIPE", FunctionName = "RefundStripe", TransID = TransId }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); } } catch (Exception ex) { responseData.StatusCode = 0; responseData.Message = "Something went wrong, please try again."; var typeEx = ex.GetType(); var PaymentLogs = new PaymentLogs() { Data = Newtonsoft.Json.JsonConvert.SerializeObject(trans), Error = ex.Message, PaymentType = "STRIPE", FunctionName = "RefundStripe", TransID = TransId }; _PaymentLogsService.InsertPaymentLogs(PaymentLogs); EmailHelpers.SendEmail(new Common.DTO.ErrorInfo() { Section = $"AQ RefundStripe PaymentType: STRIPE <br /> TransactionID : {TransId}", Exception = ex }); } return(Ok(responseData)); }
protected override void ShowPage() { if (!SetTopicInfo()) { topic = new TopicInfo(); forum = new ForumInfo(); return; } pagetitle = topic.Title.Trim(); if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forum.Fid + "password")) { AddErrLine("本版块被管理员设置了密码"); Response.Redirect(string.Format("{0}showforum-{1}{2}", BaseConfigs.GetForumPath, forum.Fid, config.Extname), true); return; } if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); return; } postinfo = Posts.GetTopicPostInfo(topicid); if (postinfo.Message.ToLower().Contains("[free]") || postinfo.Message.ToLower().Contains("[/free]")) { for (Match m = r.Match(postinfo.Message); m.Success; m = m.NextMatch()) { postmessage += "<br /><div class=\"msgheader\">免费内容:</div><div class=\"msgborder\">" + m.Groups[1] + "</div><br />"; } } #region 获取主题售价等相关信息 topicprice = topic.Price; //判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 if (topic.Price > 0) { price = topic.Price; //判断当前用户是否已经购买 if (PaymentLogs.IsBuyer(topicid, userid) || (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0)) { price = -1; } } netamount = topicprice - topicprice * creditstax / 100; if (topicprice > maxincpertopic) { netamount = maxincpertopic - maxincpertopic * creditstax / 100; } if (price != -1) { UserInfo userInfo = Users.GetUserInfo(userid); if (buyit == 1 && !CheckUserExtCredit(userInfo)) { return; } userlastprice = Users.GetUserExtCredit(userInfo, Scoresets.GetTopicAttachCreditsTrans()) - topic.Price; } #endregion if (useradminid != 0) { isModer = Moderators.IsModer(useradminid, userid, forum.Fid) ? 1 : 0; } //如果不是提交... if (!ispost) { buyers = PaymentLogs.GetPaymentLogByTidCount(topic.Tid); //显示购买信息列表 if (showpayments == 1) { //获取总页数 pagecount = buyers % pageSize == 0 ? buyers / pageSize : buyers / pageSize + 1; pagecount = pagecount == 0 ? 1 : pagecount; //修正请求页数中可能的错误 pageid = pageid < 1 ? 1 : pageid; pageid = pageid > pagecount ? pagecount : pageid; //获取收入记录并分页显示 paymentloglist = PaymentLogs.GetPaymentLogByTid(pageSize, pageid, topic.Tid); } //判断是否为回复可见帖, hide=0为非回复可见(正常), hide>0为回复可见, hide=-1为回复可见但当前用户已回复 int hide = (topic.Hide == 1 ? topic.Hide : 0); if (Posts.IsReplier(topicid, userid)) { hide = -1; } lastpostlist = Posts.GetLastPostDataTable(GetPostPramsInfo(hide)); } else { int reval = PaymentLogs.BuyTopic(userid, topic.Tid, topic.Posterid, topic.Price, netamount); if (reval > 0) { SetUrl(base.ShowTopicAspxRewrite(topic.Tid, 0)); SetMetaRefresh(); SetShowBackLink(false); MsgForward("buytopic_succeed"); AddMsgLine("购买主题成功,返回该主题"); return; } else { SetBackLink(base.ShowForumAspxRewrite(topic.Fid, 0)); if (reval == -1) { AddErrLine("对不起,您的账户余额少于交易额,无法进行交易"); } else if (reval == -2) { AddErrLine("您无权购买本主题"); } else { AddErrLine("未知原因,交易无法进行,给您带来的不方便我们很抱歉"); } return; } } }
protected override void ShowPage() { topictitle = ""; forumnav = ""; ////加载帖内广告 //inpostad = Advertisements.GetInPostAd("", fid, templatepath, postlist.Count > ppp ? ppp : postlist.Count); //AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(useradminid); showpayments = DNTRequest.GetInt("showpayments", 0); buyit = DNTRequest.GetInt("buyit", 0); topicid = DNTRequest.GetInt("topicid", -1); // 如果主题ID非数字 if (topicid == -1) { AddErrLine(WRONG_TOPIC); return; } // 获取该主题的信息 TopicInfo topic = Topics.GetTopicInfo(topicid); // 如果该主题不存在 if (topic == null) { AddErrLine(NOT_EXIST_TOPIC); return; } if (topic.Posterid == userid) { HttpContext.Current.Response.Redirect(base.ShowTopicAspxRewrite(topic.Tid, 0)); return; } if (topic.Price <= 0) { HttpContext.Current.Response.Redirect(base.ShowTopicAspxRewrite(topic.Tid, 0)); return; } topictitle = topic.Title.Trim(); topicprice = topic.Price; poster = topic.Poster; posterid = topic.Posterid; pagetitle = topictitle.Trim(); forumid = topic.Fid; ForumInfo forum = Forums.GetForumInfo(forumid); forumname = forum.Name.Trim(); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); //判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 price = 0; if (topic.Price > 0) { price = topic.Price; if (PaymentLogs.IsBuyer(topicid, userid) || (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0))//判断当前用户是否已经购买 { price = -1; } } if (useradminid != 0) { ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0; } if (topic.Readperm > usergroupinfo.Readaccess && topic.Posterid != userid && useradminid != 1 && ismoder != 1) { AddErrLine(string.Format("本主题阅读权限为: {0}, 您当前的身份 \"{1}\" 阅读权限不够", topic.Readperm.ToString(), usergroupinfo.Grouptitle)); return; } if (topic.Displayorder == -1) { AddErrLine("此主题已被删除!"); return; } if (topic.Displayorder == -2) { AddErrLine("此主题未经审核!"); return; } if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { AddErrLine("本版块被管理员设置了密码"); //SetBackLink("showforum-" + forumid.ToString() + config.Extname); HttpContext.Current.Response.Redirect("showforum-" + forumid.ToString() + config.Extname, true); return; } if (!Forums.AllowViewByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限 { if (usergroupinfo.Allowvisit != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限"); return; } } else //当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有浏览该版块的权限"); return; } } } userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetCreditsTrans()); maxincpertopic = Scoresets.GetMaxIncPerTopic(); maxchargespan = Scoresets.GetMaxChargeSpan(); creditstax = Scoresets.GetCreditsTax() * 100; netamount = topicprice - topicprice * creditstax / 100; if (topicprice > maxincpertopic) { netamount = maxincpertopic - maxincpertopic * creditstax / 100; } if (price != -1) { IDataReader reader = Users.GetUserInfoToReader(userid); if (reader == null) { AddErrLine(NO_PERMISSION); return; } if (!reader.Read()) { AddErrLine(NO_PERMISSION); reader.Close(); return; } if (Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0) < topic.Price) { AddErrLine(string.Format(NOT_ENOUGH_MONEY_TO, Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0), topic.Price)); reader.Close(); return; } userlastprice = Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0) - topic.Price; reader.Close(); } //如果不是提交... if (!ispost) { buyers = PaymentLogs.GetPaymentLogByTidCount(topic.Tid); //显示购买信息列表 if (showpayments == 1) { //得到当前用户请求的页数 pageid = DNTRequest.GetInt("page", 1); //获取主题总数 //获取总页数 pagecount = buyers % pagesize == 0 ? buyers / pagesize : buyers / pagesize + 1; if (pagecount == 0) { pagecount = 1; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } if (pageid > pagecount) { pageid = pagecount; } //获取收入记录并分页显示 paymentloglist = PaymentLogs.GetPaymentLogByTid(pagesize, pageid, topic.Tid); } //判断是否为回复可见帖, hide=0为非回复可见(正常), hide>0为回复可见, hide=-1为回复可见但当前用户已回复 int hide = 0; if (topic.Hide == 1) { hide = topic.Hide; if (Posts.IsReplier(topicid, userid)) { hide = -1; } } PostpramsInfo _postpramsinfo = new PostpramsInfo(); _postpramsinfo.Fid = forum.Fid; _postpramsinfo.Tid = topicid; _postpramsinfo.Jammer = forum.Jammer; _postpramsinfo.Pagesize = 5; _postpramsinfo.Pageindex = 1; _postpramsinfo.Getattachperm = forum.Getattachperm; _postpramsinfo.Usergroupid = usergroupid; _postpramsinfo.Attachimgpost = config.Attachimgpost; _postpramsinfo.Showattachmentpath = config.Showattachmentpath; _postpramsinfo.Hide = hide; _postpramsinfo.Price = price; _postpramsinfo.Ubbmode = false; _postpramsinfo.Showimages = forum.Allowimgcode; _postpramsinfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); _postpramsinfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); _postpramsinfo.Smiliesmax = config.Smiliesmax; _postpramsinfo.Bbcodemode = config.Bbcodemode; lastpostlist = Posts.GetLastPostList(_postpramsinfo); } else { int reval = PaymentLogs.BuyTopic(userid, topic.Tid, topic.Posterid, topic.Price, netamount); if (reval > 0) { SetUrl(base.ShowTopicAspxRewrite(topic.Tid, 0)); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine(PURCHASE_SUCCESS); return; } else { SetBackLink(base.ShowForumAspxRewrite(topic.Fid, 0)); if (reval == -1) { AddErrLine(NOT_ENOUGH_MONEY); return; } else if (reval == -2) { AddErrLine(NO_PERMISSION); return; } else { AddErrLine(UNKNOWN_REASON); return; } } } }
public bool UpdatePaymentLogs(PaymentLogs payment) { _unitOfWork.Repository <PaymentLogs>().Update(payment); return(_unitOfWork.Save()); }
public bool InsertPaymentLogs(PaymentLogs payment) { _unitOfWork.Repository <PaymentLogs>().Add(payment); return(_unitOfWork.Save()); }
public showtopic() { // 获取主题ID int topicid = DNTRequest.GetInt("topicid", -1); // 如果主题ID非数字 if (topicid == -1) { ShowMsg("无效的主题ID"); return; } // 获取该主题的信息 TopicInfo topic = Topics.GetTopicInfo(topicid); // 如果该主题不存在 if (topic == null) { ShowMsg("不存在的主题ID"); return; } if (topic.Readperm > usergroupinfo.Readaccess && topic.Posterid != userid) { ShowMsg(string.Format("本主题阅读权限为: {0}, 您当前的身份 \"{1}\" 阅读权限不够", topic.Readperm.ToString(), usergroupinfo.Grouptitle)); return; } ForumInfo forum = Forums.GetForumInfo(topic.Fid); if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限 { if (usergroupinfo.Allowvisit != 1) { ShowMsg("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限"); return; } } else //当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupinfo.Groupid)) { ShowMsg("您没有浏览该版块的权限"); return; } } if (forum.Password != "") { ShowMsg("简洁版本无法浏览设置了密码的版块"); return; } //验证用户是否为本版版主 int ismoder = Moderators.IsModer(useradminid, userid, forum.Fid) ? 1 : 0; //购买帖子操作 //判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 int price = 0; if (topic.Price > 0 && userid != topic.Posterid && ismoder != 1) { price = topic.Price; //时间乘以-1是因为当Configs.GetMaxChargeSpan()==0时,帖子始终为购买帖 if (PaymentLogs.IsBuyer(topicid, userid) || (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0))//判断当前用户是否已经购买 { price = -1; } } if (price > 0) { ShowMsg(string.Format("此帖需转到完整版处购买后才可查看.<a href=\"{0}buytopic.aspx?topicid={1}\">点击购买</a>", "/Forum/", topic.Tid)); return; } // 获取帖子总数 //postcount = Posts.GetPostCount(topicid); int postcount = topic.Replies + 1; int pageid = 1; // 得到Tpp设置 int ppp = 30; //获取总页数 int pagecount = postcount % ppp == 0 ? postcount / ppp : postcount / ppp + 1; if (pagecount == 0) { pagecount = 1; } // 得到当前用户请求的页数 if (DNTRequest.GetString("page").ToLower().Equals("end")) { pageid = pagecount; } else { pageid = DNTRequest.GetInt("page", 1); } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } if (pageid > pagecount) { pageid = pagecount; } int hide = 1; if (topic.Hide == 1 && (Posts.IsReplier(topicid, userid) || ismoder == 1)) { hide = -1; } //获取当前页主题列表 PostpramsInfo postpramsInfo = new PostpramsInfo(); postpramsInfo.Fid = forum.Fid; postpramsInfo.Tid = topicid; postpramsInfo.Jammer = forum.Jammer; postpramsInfo.Pagesize = ppp; postpramsInfo.Pageindex = pageid; postpramsInfo.Getattachperm = forum.Getattachperm; postpramsInfo.Usergroupid = usergroupinfo.Groupid; postpramsInfo.Attachimgpost = config.Attachimgpost; postpramsInfo.Showattachmentpath = config.Showattachmentpath; postpramsInfo.Hide = hide; postpramsInfo.Price = topic.Price; postpramsInfo.Usergroupreadaccess = usergroupinfo.Readaccess; postpramsInfo.CurrentUserid = userid; postpramsInfo.Showimages = forum.Allowimgcode; // 简洁版本中关闭表情符的解析 postpramsInfo.Smileyoff = 1; postpramsInfo.Smiliesmax = 0; postpramsInfo.Smiliesinfo = null; postpramsInfo.Customeditorbuttoninfo = null; postpramsInfo.Bbcodemode = 0; // 简洁版本中关闭ubb转换 postpramsInfo.Bbcodeoff = 1; postpramsInfo.CurrentUserGroup = usergroupinfo; postpramsInfo.Onlinetimeout = config.Onlinetimeout; postlist = Posts.GetPostList(postpramsInfo, out attachmentlist, ismoder == 1); if (postlist.Count <= 0) { ShowMsg("读取信息失败"); return; } ShowTitle(topic.Title); ShowBody(); HttpContext.Current.Response.Write("<h1>" + config.Forumtitle + "</h1>"); HttpContext.Current.Response.Write("<div class=\"forumnav\">"); HttpContext.Current.Response.Write("<a href=\"index.aspx\">首页</a> » "); if (config.Aspxrewrite == 1) { HttpContext.Current.Response.Write(string.Format("{0} » <a href=\"showtopic-{1}{2}\">{3}</a>", ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("</a><", "</a> » <"), topicid.ToString(), config.Extname, topic.Title)); } else { HttpContext.Current.Response.Write(string.Format("{0} » <a href=\"showtopic.aspx?topicid={1}\">{2}</a>", ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), "aspx").Replace("</a><", "</a> » <"), topicid.ToString(), topic.Title)); } HttpContext.Current.Response.Write("</div>\r\n"); foreach (ShowtopicPagePostInfo postinfo in postlist) { HttpContext.Current.Response.Write("<div class=\"postitem\">\r\n"); HttpContext.Current.Response.Write("\t<div class=\"postitemtitle\">\r\n"); HttpContext.Current.Response.Write(Utils.HtmlEncode(postinfo.Poster) + " - " + postinfo.Postdatetime); HttpContext.Current.Response.Write("</div><div class=\"postitemcontent\">"); HttpContext.Current.Response.Write(postinfo.Message); foreach (ShowtopicPageAttachmentInfo attinfo in attachmentlist) { if (attinfo.Pid == postinfo.Pid) { HttpContext.Current.Response.Write(string.Format("<br /><br />附件: <a href=\"../attachment.aspx?attachmentid={0}\">{1}</a>", attinfo.Aid.ToString(), Utils.HtmlEncode(attinfo.Attachment))); } } HttpContext.Current.Response.Write("\t</div>\r\n</div>\r\n"); } //得到页码链接 HttpContext.Current.Response.Write("<div class=\"pagenumbers\">"); if (config.Aspxrewrite == 1) { HttpContext.Current.Response.Write(Utils.GetStaticPageNumbers(pageid, pagecount, "showtopic-" + topicid.ToString(), config.Extname, 8)); } else { HttpContext.Current.Response.Write(Utils.GetPageNumbers(pageid, pagecount, "showtopic.aspx?topicid=" + topicid.ToString(), 8, "page")); } HttpContext.Current.Response.Write("</div>\r\n"); //更新查看次数 //Topics.UpdateTopicViews(topicid); TopicStats.Track(topicid, 1); if (config.Aspxrewrite == 1) { HttpContext.Current.Response.Write(string.Format("<div class=\"fullversion\">查看完整版本: <a href=\"../showtopic-{0}{1}\">{2}</a></div>\r\n", topicid.ToString(), config.Extname, topic.Title)); } else { HttpContext.Current.Response.Write(string.Format("<div class=\"fullversion\">查看完整版本: <a href=\"../showtopic.aspx?topicid={0}\">{1}</a></div>\r\n", topicid.ToString(), topic.Title)); } ShowFooter(); HttpContext.Current.Response.End(); }
public Result ProcessPayment(ProcessPaymentView payment) { try { if (Validations.IsValidateExpiryDate(payment.ExpirationDate)) //Pass MM/yyyy { if (Validations.IsValidateCvv(payment.SecurityCode)) //CVV { if (Validations.ValidateCreditCard(payment.CreditCardNumber)) //check card number is valid { ProcessPayment process = new ProcessPayment(); process.Amount = payment.Amount; process.CardHolder = payment.CardHolder; process.CreditCardNumber = payment.CreditCardNumber; process.SecurityCode = payment.SecurityCode; process.ExpirationDate = payment.ExpirationDate; process.CreatedDate = DateTime.UtcNow; if (payment.Amount < 20) // If the amount to be paid is less than £20, use ICheapPaymentGateway { var save = CheapPayment.CheapPaymentProcess(process); if (save.Status == DBHepler.Core.Enums.ResultStatus.OK) { PaymentLogs paymentLogs = new PaymentLogs(); paymentLogs.ActionID = process.PaymentID; paymentLogs.Action = "Save CheapPaymentProcess"; paymentLogs.CreatedDate = DateTime.UtcNow; paymentLogs.PaymentMethod = save.Message; paymentLogs.Desc = "CheapPaymentProcess Process successfully"; var log = CheapPayment.SaveProcessLogs(paymentLogs); PaymentState state = new PaymentState(); state.NumberOfAttempt = 1; state.PaymentID = process.PaymentID; state.PaymentStates = DBHepler.Core.Enums.PaymentStatus.processed; var states = CheapPayment.SaveProcessState(state, process.CreditCardNumber); if (log.Status == DBHepler.Core.Enums.ResultStatus.OK && states.Status == DBHepler.Core.Enums.ResultStatus.OK) { return(new Result() { Data = "Payment is processed", Message = "OK", Status = DBHepler.Core.Enums.ResultStatus.OK }); } } } else if (payment.Amount > 20 && payment.Amount < 500) //If the amount to be paid is £21 - 500, use IExpensivePaymentGateway if available.Otherwise, retry only once with ICheapPaymentGateway. { var saveexpensive = CheapPayment.ExpensivePaymentProcess(process); if (saveexpensive.Status == DBHepler.Core.Enums.ResultStatus.OK) { PaymentLogs paymentLogs = new PaymentLogs(); paymentLogs.ActionID = process.PaymentID; paymentLogs.Action = "Save ExpensivePaymentProcess"; paymentLogs.CreatedDate = DateTime.UtcNow; paymentLogs.PaymentMethod = saveexpensive.Message; paymentLogs.Desc = "ExpensivePaymentProcess Process successfully"; var log = CheapPayment.SaveProcessLogs(paymentLogs); PaymentState state = new PaymentState(); state.NumberOfAttempt = 1; state.PaymentID = process.PaymentID; state.PaymentStates = DBHepler.Core.Enums.PaymentStatus.processed; var states = CheapPayment.SaveProcessState(state, process.CreditCardNumber); if (log.Status == DBHepler.Core.Enums.ResultStatus.OK && states.Status == DBHepler.Core.Enums.ResultStatus.OK) { return(new Result() { Data = "Payment is processed", Message = "OK", Status = DBHepler.Core.Enums.ResultStatus.OK }); } } else { var savecheap = CheapPayment.CheapPaymentProcess(process); if (savecheap.Status == DBHepler.Core.Enums.ResultStatus.OK) { PaymentLogs paymentLogs = new PaymentLogs(); paymentLogs.ActionID = process.PaymentID; paymentLogs.Action = "Save CheapPaymentProcess"; paymentLogs.CreatedDate = DateTime.UtcNow; paymentLogs.PaymentMethod = savecheap.Message; paymentLogs.Desc = "CheapPaymentProcess Process successfully"; var log = CheapPayment.SaveProcessLogs(paymentLogs); PaymentState state = new PaymentState(); state.NumberOfAttempt = 1; state.PaymentID = process.PaymentID; state.PaymentStates = DBHepler.Core.Enums.PaymentStatus.processed; var states = CheapPayment.SaveProcessState(state, process.CreditCardNumber); if (log.Status == DBHepler.Core.Enums.ResultStatus.OK && states.Status == DBHepler.Core.Enums.ResultStatus.OK) { return(new Result() { Data = "Payment is processed", Message = "OK", Status = DBHepler.Core.Enums.ResultStatus.OK }); } } } } else // If the amount is > £500, try only PremiumPaymentService and retry up to 3 times in case payment does not get processed { TryThree: var State = CheapPayment.GetState(DBHepler.Core.Enums.PaymentStatus.failed, process.CreditCardNumber); var SavePremium = CheapPayment.PremiumPaymentService(process); if (State.Data < 4 && SavePremium.Status == DBHepler.Core.Enums.ResultStatus.OK) { PaymentLogs paymentLogs = new PaymentLogs(); paymentLogs.ActionID = process.PaymentID; paymentLogs.Action = "Save PremiumPaymentService"; paymentLogs.CreatedDate = DateTime.UtcNow; paymentLogs.PaymentMethod = SavePremium.Message; paymentLogs.Desc = "PremiumPaymentService Process successfully"; var log = CheapPayment.SaveProcessLogs(paymentLogs); PaymentState state = new PaymentState(); state.NumberOfAttempt = 1; state.PaymentID = process.PaymentID; state.PaymentStates = DBHepler.Core.Enums.PaymentStatus.processed; var states = CheapPayment.SaveProcessState(state, process.CreditCardNumber); if (log.Status == DBHepler.Core.Enums.ResultStatus.OK && states.Status == DBHepler.Core.Enums.ResultStatus.OK) { return(new Result() { Data = "Payment is processed", Message = "OK", Status = DBHepler.Core.Enums.ResultStatus.OK }); } } else { if (State.Data > 3) { return(new Result() { Data = null, Message = "- The request should be validated before processed.",//- The request should be validated before processed. Status = DBHepler.Core.Enums.ResultStatus.Warning }); } PaymentLogs paymentLogs = new PaymentLogs(); paymentLogs.ActionID = process.PaymentID; paymentLogs.Action = "Save PremiumPaymentService"; paymentLogs.CreatedDate = DateTime.UtcNow; paymentLogs.PaymentMethod = SavePremium.Message; paymentLogs.Desc = "PremiumPaymentService Process successfully"; var log = CheapPayment.SaveProcessLogs(paymentLogs); PaymentState state = new PaymentState(); state.NumberOfAttempt = 1; state.PaymentID = process.PaymentID; state.PaymentStates = DBHepler.Core.Enums.PaymentStatus.failed; var states = CheapPayment.SaveProcessState(state, process.CreditCardNumber); if (log.Status == DBHepler.Core.Enums.ResultStatus.OK && states.Status == DBHepler.Core.Enums.ResultStatus.OK) { goto TryThree; } } } return(new Result() { Data = null, Message = "Your credit card number is invalid", Status = DBHepler.Core.Enums.ResultStatus.Warning }); } else { return(new Result() { Data = null, Message = "Your credit card number is invalid", Status = DBHepler.Core.Enums.ResultStatus.Warning }); } } else { return(new Result() { Data = null, Message = "Your CVV is invalid", Status = DBHepler.Core.Enums.ResultStatus.Warning }); } } else { return(new Result() { Data = null, Message = "Your credit card has been expired", Status = DBHepler.Core.Enums.ResultStatus.Warning }); } } catch (Exception ex) { return(new Result() { Data = null, Message = "Internal Server Error", Status = DBHepler.Core.Enums.ResultStatus.InternalServerError }); } }