protected virtual PaymentResponse SubmitPayment(PaymentStatus requiredStatus) { var gw = CreateGateway(); var card = this.GetMagicCard(requiredStatus); var merchantReference = this.GenerateMerchantReference(); return (gw.Purchase(merchantReference, new Money(123.45m, new Currency("GBP")), card)); }
public IEnumerable<TimeWrapper> GetTaskTimeByFilter(int projectid, bool myProjects, int? milestone, bool myMilestones, int tag, Guid departament, Guid participant, ApiDateTime createdStart, ApiDateTime createdStop, int lastId, PaymentStatus? status) { var taskFilter = new TaskFilter { DepartmentId = departament, UserId = participant, FromDate = createdStart, ToDate = createdStop, SortBy = _context.SortBy, SortOrder = !_context.SortDescending, SearchText = _context.FilterValue, TagId = tag, Offset = _context.StartIndex, Max = _context.Count, LastId = lastId, MyProjects = myProjects, MyMilestones = myMilestones, Milestone = milestone }; if (projectid != 0) taskFilter.ProjectIds.Add(projectid); if (status.HasValue) taskFilter.PaymentStatuses.Add(status.Value); _context.SetDataPaginated(); _context.SetDataFiltered(); _context.SetDataSorted(); return EngineFactory.GetTimeTrackingEngine().GetByFilter(taskFilter).NotFoundIfNull().Select(r => new TimeWrapper(r)).ToSmartList(); }
public void LogPayment(int orderId, string paymentMethodClass, PaymentStatus status, decimal? amount, string notes) { Order order = db.Orders.Find(orderId); var paymentMethodId = db.PaymentMethods.First(p => p.ClassName == paymentMethodClass).Id; if (order != null) { var payment = new Payment { Date = DateTime.Now, Amount = amount ?? order.Total, OrderId = order.Id, PaymentMethodId = paymentMethodId, Status = status, Notes = notes, UserId = order.UserId }; db.Payments.Add(payment); db.SaveChanges(); if (status == PaymentStatus.Completed) { // Clear shopping cart if (amount == null || amount == order.Total) { orderHelper.OrderPaid(orderId); } else { orderHelper.OrderPaidPartially(orderId); } } } }
/// <summary> /// Get best customers /// </summary> /// <param name="createdFromUtc">Order created date from (UTC); null to load all records</param> /// <param name="createdToUtc">Order created date to (UTC); null to load all records</param> /// <param name="os">Order status; null to load all records</param> /// <param name="ps">Order payment status; null to load all records</param> /// <param name="ss">Order shipment status; null to load all records</param> /// <param name="orderBy">1 - order by order total, 2 - order by number of orders</param> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <returns>Report</returns> public virtual IPagedList<BestCustomerReportLine> GetBestCustomersReport(DateTime? createdFromUtc, DateTime? createdToUtc, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, int orderBy, int pageIndex = 0, int pageSize = 214748364) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query1 = from c in _customerRepository.Table join o in _orderRepository.Table on c.Id equals o.CustomerId where (!createdFromUtc.HasValue || createdFromUtc.Value <= o.CreatedOnUtc) && (!createdToUtc.HasValue || createdToUtc.Value >= o.CreatedOnUtc) && (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) && (!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) && (!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) && (!o.Deleted) && (!c.Deleted) select new { c, o }; var query2 = from co in query1 group co by co.c.Id into g select new { CustomerId = g.Key, OrderTotal = g.Sum(x => x.o.OrderTotal), OrderCount = g.Count() }; switch (orderBy) { case 1: { query2 = query2.OrderByDescending(x => x.OrderTotal); } break; case 2: { query2 = query2.OrderByDescending(x => x.OrderCount); } break; default: throw new ArgumentException("Wrong orderBy parameter", "orderBy"); } var tmp = new PagedList<dynamic>(query2, pageIndex, pageSize); return new PagedList<BestCustomerReportLine>(tmp.Select(x => new BestCustomerReportLine { CustomerId = x.CustomerId, OrderTotal = x.OrderTotal, OrderCount = x.OrderCount }), tmp.PageIndex, tmp.PageSize, tmp.TotalCount); }
public PaymentStatusChanged(Payment payment, PaymentStatus? oldStatus, PaymentStatus newStatus) { OrderId = payment.OrderId; PaymentId = payment.Id; Amount = payment.Amount; OldStatus = oldStatus; NewStatus = newStatus; PaymentMethodId = payment.PaymentMethodId; }
private void Verify_Sagepay_Status_Code(string sagePayStatus, PaymentStatus expectedStatus) { var http = new Mock<IHttpPostTransport>(); http .Setup(h => h.Post(It.IsAny<Uri>(), It.IsAny<string>())) .Returns(this.MakePostResponse(sagePayStatus)); var gw = new SagePayPaymentGateway(http.Object, VENDOR_NAME, VPS_PROTOCOL, GatewayMode.Simulator); var card = new PaymentCard("I M LOADED", "123412341234134", "1212", "123", CardType.Visa); var response = gw.Purchase("123456", new Money(123.45m, new Currency("GBP")), card); Assert.Equal(expectedStatus, response.Status); }
public void ChangeStatus(Payment payment, PaymentStatus newStatus) { if (payment.Status != newStatus) { var oldStatus = payment.Status; payment.Status = newStatus; _repository.Database.SaveChanges(); Event.Raise(new PaymentStatusChanged(payment, oldStatus, newStatus), _instance); } }
protected override Payments.PaymentCard GetMagicCard(PaymentStatus status) { switch(status) { case PaymentStatus.Ok: return (new PaymentCard("I M LOADED", "4929000000006", EXPIRY_DATE, "123", CardType.Visa)); case PaymentStatus.Declined: return (new PaymentCard("I M BUSTED", "4408041234567893", EXPIRY_DATE, "123", CardType.Visa)); case PaymentStatus.Invalid: return (new PaymentCard("1234123412341324", "I M STUPID", EXPIRY_DATE, "123", CardType.Visa)); } throw new ArgumentOutOfRangeException("status"); }
/// <summary> /// Get "order by country" report /// </summary> /// <param name="storeId">Store identifier</param> /// <param name="os">Order status</param> /// <param name="ps">Payment status</param> /// <param name="ss">Shipping status</param> /// <param name="startTimeUtc">Start date</param> /// <param name="endTimeUtc">End date</param> /// <returns>Result</returns> public virtual IList<OrderByCountryReportLine> GetCountryReport(int storeId, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, DateTime? startTimeUtc, DateTime? endTimeUtc) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query = _orderRepository.Table; query = query.Where(o => !o.Deleted); if (storeId > 0) query = query.Where(o => o.StoreId == storeId); if (orderStatusId.HasValue) query = query.Where(o => o.OrderStatusId == orderStatusId.Value); if (paymentStatusId.HasValue) query = query.Where(o => o.PaymentStatusId == paymentStatusId.Value); if (shippingStatusId.HasValue) query = query.Where(o => o.ShippingStatusId == shippingStatusId.Value); if (startTimeUtc.HasValue) query = query.Where(o => startTimeUtc.Value <= o.CreatedOnUtc); if (endTimeUtc.HasValue) query = query.Where(o => endTimeUtc.Value >= o.CreatedOnUtc); var report = (from oq in query group oq by oq.BillingAddress.CountryId into result select new { CountryId = result.Key, TotalOrders = result.Count(), SumOrders = result.Sum(o => o.OrderTotal) } ) .OrderByDescending(x => x.SumOrders) .Select(r => new OrderByCountryReportLine { CountryId = r.CountryId, TotalOrders = r.TotalOrders, SumOrders = r.SumOrders }) .ToList(); return report; }
protected override Payments.PaymentCard GetMagicCard(PaymentStatus status) { // See DataCash magic cards reference at https://testserver.datacash.com/software/download.cgi?show=magicnumbers switch(status) { case PaymentStatus.Undefined: break; case PaymentStatus.Ok: return (new PaymentCard("I M LOADED", "1000189853512019", EXPIRY_DATE, "123", CardType.Visa)); case PaymentStatus.Declined: return (new PaymentCard("I M SKINT", "100063000000007", EXPIRY_DATE, "123", CardType.Visa)); case PaymentStatus.Invalid: return (new PaymentCard("1234123412341234", "I M STUPID", EXPIRY_DATE, "123", CardType.Visa)); case PaymentStatus.Referred: return (new PaymentCard("I M DODGY", "1000350000000122", EXPIRY_DATE, "123", CardType.MasterCard)); } throw new ArgumentOutOfRangeException("status"); }
public IPagedList<BestCustomerReportLine> GetBestCustomersReport(DateTime? createdFromUtc, DateTime? createdToUtc, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, int orderBy, int pageIndex = 0, int pageSize = int.MaxValue) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query1 = from c in _customerRepository.Table join o in _orderRepository.Table on c.Id equals o.CustomerId where !c.Deleted && !o.Deleted && (!createdFromUtc.HasValue || o.CreatedOnUtc >= createdFromUtc.Value) && (!createdToUtc.HasValue || o.CreatedOnUtc <= createdToUtc.Value) && (!orderStatusId.HasValue || o.OrderStatusId == orderStatusId.Value) && (!paymentStatusId.HasValue || o.PaymentStatusId == paymentStatusId.Value) && (!shippingStatusId.HasValue || o.ShippingStatusId == shippingStatusId.Value) select new { c, o }; var query = from co in query1 group co by co.c.Id into g select new BestCustomerReportLine // khác chỗ này { CustomerId = g.Key, OrderTotal = g.Sum(x => x.o.OrderTotal), OrderCount = g.Count() }; switch(orderBy) { case 1: query = query.OrderByDescending(p => p.OrderTotal); break; case 2: query = query.OrderByDescending(p => p.OrderCount); break; default: throw new ArgumentException("Wrong orderBy parameter", "orderBy"); } var result = new PagedList<BestCustomerReportLine>(query, pageIndex, pageSize); return result; }
/// <summary> /// Get order average report /// </summary> /// <param name="os">Order status</param> /// <param name="ps">Payment status</param> /// <param name="ss">Shipping status</param> /// <param name="startTimeUtc">Start date</param> /// <param name="endTimeUtc">End date</param> /// <param name="billingEmail">Billing email. Leave empty to load all records.</param> /// <param name="ignoreCancelledOrders">A value indicating whether to ignore cancelled orders</param> /// <returns>Result</returns> public virtual OrderAverageReportLine GetOrderAverageReportLine(OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, DateTime? startTimeUtc, DateTime? endTimeUtc, string billingEmail, bool ignoreCancelledOrders = false) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query = _orderRepository.Table; query = query.Where(o => !o.Deleted); if (ignoreCancelledOrders) { int cancelledOrderStatusId = (int)OrderStatus.Cancelled; query = query.Where(o => o.OrderStatusId != cancelledOrderStatusId); } if (orderStatusId.HasValue) query = query.Where(o => o.OrderStatusId == orderStatusId.Value); if (paymentStatusId.HasValue) query = query.Where(o => o.PaymentStatusId == paymentStatusId.Value); if (shippingStatusId.HasValue) query = query.Where(o => o.ShippingStatusId == shippingStatusId.Value); if (startTimeUtc.HasValue) query = query.Where(o => startTimeUtc.Value <= o.CreatedOnUtc); if (endTimeUtc.HasValue) query = query.Where(o => endTimeUtc.Value >= o.CreatedOnUtc); if (!String.IsNullOrEmpty(billingEmail)) query = query.Where(o => o.BillingAddress != null && !String.IsNullOrEmpty(o.BillingAddress.Email) && o.BillingAddress.Email.Contains(billingEmail)); var item = (from oq in query group oq by 1 into result select new { OrderCount = result.Count(), OrderTaxSum = result.Sum(o => o.OrderTax), OrderTotalSum = result.Sum(o => o.OrderTotal) } ).Select(r => new OrderAverageReportLine(){ SumTax = r.OrderTaxSum, CountOrders=r.OrderCount, SumOrders = r.OrderTotalSum}).FirstOrDefault(); item = item ?? new OrderAverageReportLine() { CountOrders = 0, SumOrders = decimal.Zero, SumTax = decimal.Zero }; return item; }
public static void SavePaymentAttempt(string orderId, PaymentStatus status) { // .. save it to your favorite database }
/// <summary> /// Get order average report /// </summary> /// <param name="os">Order status</param> /// <param name="ps">Payment status</param> /// <param name="ss">Shipping status</param> /// <param name="startTimeUtc">Start date</param> /// <param name="endTimeUtc">End date</param> /// <param name="ignoreCancelledOrders">A value indicating whether to ignore cancelled orders</param> /// <returns>Result</returns> public virtual OrderAverageReportLine GetOrderAverageReportLine(OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, DateTime? startTimeUtc, DateTime? endTimeUtc, bool ignoreCancelledOrders = false) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query = _orderRepository.Table; query = query.Where(o => !o.Deleted); if (ignoreCancelledOrders) { int cancelledOrderStatusId = (int)OrderStatus.Cancelled; query = query.Where(o => o.OrderStatusId != cancelledOrderStatusId); } if (orderStatusId.HasValue) query = query.Where(o => o.OrderStatusId == orderStatusId.Value); if (paymentStatusId.HasValue) query = query.Where(o => o.PaymentStatusId == paymentStatusId.Value); if (shippingStatusId.HasValue) query = query.Where(o => o.ShippingStatusId == shippingStatusId.Value); if (startTimeUtc.HasValue) query = query.Where(o => startTimeUtc.Value <= o.CreatedOnUtc); if (endTimeUtc.HasValue) query = query.Where(o => endTimeUtc.Value >= o.CreatedOnUtc); var item = new OrderAverageReportLine(); item.SumOrders = Convert.ToDecimal(query.Sum(o => (decimal?)o.OrderTotal)); item.CountOrders = query.Count(); return item; }
public void Insert(int PaymentStatusKey,string PaymentStatusDescription,string PaymentStatusAdmindescription) { PaymentStatus item = new PaymentStatus(); item.PaymentStatusKey = PaymentStatusKey; item.PaymentStatusDescription = PaymentStatusDescription; item.PaymentStatusAdmindescription = PaymentStatusAdmindescription; item.Save(UserName); }
private async Task ChangePaymentStatusAsync(int reservationId, string userId, PaymentStatus status) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentException("Изберете потребител, на който принадлежи резервацията"); } var reservationToEdit = await unitOfWork.ReservationsRepository .Where(r => r.ReservationId == reservationId && r.ClientUserId == userId) .FirstOrDefaultAsync() ?? throw new ContentNotFoundException("Резервацията не е намерена"); if (reservationToEdit.PaymentStatus == PaymentStatus.FullPayed) { throw new InvalidReservationException("Не може да промените платена резервация!"); } if (reservationToEdit.PaymentStatus == PaymentStatus.CaparoPayed && status == PaymentStatus.Pending) { throw new InvalidReservationException("Не може резервация с платено капаро да бъде на изчакване!"); } reservationToEdit.PaymentStatus = status; unitOfWork.ReservationsRepository.Edit(reservationToEdit); await unitOfWork.SaveAsync(); }
public CreatePaymentResponse(Guid paymentId, PaymentStatus paymentStatus) { PaymentId = paymentId; PaymentStatus = paymentStatus; }
public List<TimeWrapper> UpdateTimes(int[] timeids, PaymentStatus status) { var timeTrackingEngine = EngineFactory.GetTimeTrackingEngine(); var times = new List<TimeWrapper>(); foreach (var timeid in timeids) { var time = timeTrackingEngine.GetByID(timeid).NotFoundIfNull(); timeTrackingEngine.ChangePaymentStatus(time, status); times.Add(new TimeWrapper(time)); } MessageService.Send(_context, MessageAction.TaskTimesUpdatedStatus, times.Select(t => t.Note), LocalizedEnumConverter.ConvertToString(status)); return times; }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private WhereCondition GetWhereCondition() { // Orders from current site var where = new WhereCondition() .WhereEquals("OrderSiteID", SiteContext.CurrentSiteID); // Order status filter var status = OrderStatusInfoProvider.GetOrderStatusInfo(OrderStatus, SiteContext.CurrentSiteName); if (status != null) { where.WhereEquals("OrderStatusID", status.StatusID); } // Customer or company like filter if (!string.IsNullOrEmpty(CustomerOrCompany)) { where.WhereIn("OrderCustomerID", new IDQuery <CustomerInfo>() .Where("CustomerFirstName + ' ' + CustomerLastName + ' ' + CustomerFirstName LIKE N'%" + SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(CustomerOrCompany)) + "%'") .Or() .WhereContains("CustomerCompany", CustomerOrCompany)); } // Filter for orders with note if (HasNote) { where.WhereNotEmpty("OrderNote"); } // Payment method filter var payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(PaymentMethod, SiteContext.CurrentSiteName); if (payment != null) { where.WhereEquals("OrderPaymentOptionID", payment.PaymentOptionID); } // Payment status filter switch (PaymentStatus.ToLowerCSafe()) { case PAY_STATUS_NOT_PAID: where.Where(new WhereCondition().WhereFalse("OrderIsPaid").Or().WhereNull("OrderIsPaid")); break; case PAY_STATUS_PAID: where.WhereTrue("OrderIsPaid"); break; } // Currency filter var currencyObj = CurrencyInfoProvider.GetCurrencyInfo(Currency, SiteContext.CurrentSiteName); if (currencyObj != null) { where.WhereEquals("OrderCurrencyID", currencyObj.CurrencyID); } // Min price in main currency filter if (MinPriceInMainCurrency > 0) { where.Where("OrderTotalPriceInMainCurrency", QueryOperator.LargerOrEquals, MinPriceInMainCurrency); } // Max price in main currency filter if (MaxPriceInMainCurrency > 0) { where.Where("OrderTotalPriceInMainCurrency", QueryOperator.LessOrEquals, MaxPriceInMainCurrency); } // Shipping option filter var shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(ShippingOption, SiteContext.CurrentSiteName); if (shipping != null) { where.WhereEquals("OrderShippingOptionID", shipping.ShippingOptionID); } // Shipping country filter if (!string.IsNullOrEmpty(ShippingCountry) && ShippingCountry != "0") { AddCountryWhereCondition(where); } // Date filter AddDateWhereCondition(where); return(where); }
public IQueryable <payment> GetPayments(PaymentMethodType method, PaymentStatus status) { return(db.payments.Where(x => x.method == method.ToString() && x.status == status.ToString())); }
public CohortBuilder WithApprenticeshipPaymentStatus(PaymentStatus status, DateTime?approvalDate = null) { PaymentStatus = status; AgreedOnDate = approvalDate.HasValue ? approvalDate.Value : default(DateTime?); return(this); }
public void MarkAsPaid() { PaidAt = DateTime.Now; Status = PaymentStatus.Paid; AddDomainEvent(new PaymentAuthorizedEvent(Id)); }
public void SetPaymentStatus(PaymentStatus paymentStatus) { PaymentStatus = paymentStatus; }
public void WhenPaymentIsValid_SuccessReturned(decimal due, decimal payment, PaymentStatus expected) { var result = _service.RemitPayment(due, payment); Assert.That(result.PaymentStatus, Is.EqualTo(expected)); }
private void Send(string connectionId, PaymentStatus message) { _hubContext.Clients.Client(connectionId).SendAsync("UpdateStatus", message); }
public override void ProcessCallback(Payment payment) { if (payment.PaymentStatus.PaymentStatusId != (int)PaymentStatusCode.PendingAuthorization) { return; } var request = HttpContext.Current.Request; string callbackPwFromConfiguration = payment.PaymentMethod.DynamicProperty <string>().CallbackPW; string key = payment.PaymentMethod.DynamicProperty <string>().Key; bool instantCapture = payment.PaymentMethod.DynamicProperty <bool>().InstantCapture; string acceptUrl = payment.PaymentMethod.DynamicProperty <string>().AcceptUrl; string declineUrl = payment.PaymentMethod.DynamicProperty <string>().DeclineUrl; if (!string.IsNullOrEmpty(callbackPwFromConfiguration)) { var callbackPwFromRequest = request["callbackPW"]; if (string.IsNullOrEmpty(callbackPwFromRequest)) { throw new NullReferenceException("callbackPW from the HttpRequest is null."); } if (!callbackPwFromRequest.Equals(callbackPwFromConfiguration, StringComparison.OrdinalIgnoreCase)) { throw new SecurityException(string.Format("Callback password does not match. From configuration: {0}, From server callback: {1}.", callbackPwFromConfiguration, callbackPwFromRequest)); } } var hash = request["MC_hash"]; if (string.IsNullOrEmpty(hash)) { throw new SecurityException("MC_hash is empty."); } var s = Md5Computer.GetHash(payment.Amount, payment.ReferenceId, payment.PurchaseOrder.BillingCurrency.ISOCode, key); if (!hash.Equals(s, StringComparison.OrdinalIgnoreCase)) { throw new SecurityException("Hashes do not match, message tampered with."); } string transStatus = request["transStatus"]; if (string.IsNullOrEmpty(transStatus)) { throw new NullReferenceException("transStatus was null or empty."); } if (transStatus[0] == 'Y') //A value of Y indicates that the transaction has been authorised { // the authorisation mode is incorrect string transactParameter = request["transId"]; if (string.IsNullOrEmpty(transactParameter)) { throw new ArgumentException(@"transId must be present in query string."); } payment.TransactionId = transactParameter; if (instantCapture) { payment.PaymentStatus = PaymentStatus.Get((int)PaymentStatusCode.Acquired); } else { payment.PaymentStatus = PaymentStatus.Get((int)PaymentStatusCode.Authorized); } ProcessPaymentRequest(new PaymentRequest(payment.PurchaseOrder, payment)); if (!string.IsNullOrEmpty(acceptUrl)) { HttpContext.Current.Response.Write( DownloadPageContent( new Uri(_absoluteUrlService.GetAbsoluteUrl(acceptUrl)).AddOrderGuidParameter(payment.PurchaseOrder))); } } else if (transStatus[0] == 'C') // a value of C means that the transaction was cancelled { if (!string.IsNullOrEmpty(declineUrl)) { HttpContext.Current.Response.Write(DownloadPageContent(new Uri(_absoluteUrlService.GetAbsoluteUrl(declineUrl)).AddOrderGuidParameter(payment.PurchaseOrder))); } } else { throw new NotSupportedException("transStatus should have a status of either 'Y' or 'C'."); } }
public tbl_Orders UpdateOrderPaymentStatus(int orderID, PaymentStatus status, string currency = null) { if (orderID == 0) // || status == PaymentStatus.Initialized) <-- why not saving Status.Initialized? return null; var order = OrdersRepository.UpdateOrderPaymentStatus(orderID, status, currency); if (order == null) return null; if (order.DependentOrders.Count > 0) { foreach (var dOrder in order.DependentOrders) { OrdersRepository.UpdateOrderPaymentStatus(dOrder.OrderID, status, currency); } } if (status == PaymentStatus.Paid && order != null) { DeleteReferencedBasket(order.OrderID); } return order; }
/// <summary> /// Mark payment as successful /// </summary> public void Succeed() { Status = PaymentStatus.Successful; }
/// <summary> /// Search orders /// </summary> /// <param name="startTime">Order start time; null to load all orders</param> /// <param name="endTime">Order end time; null to load all orders</param> /// <param name="os">Order status; null to load all orders</param> /// <param name="ps">Order payment status; null to load all orders</param> /// <param name="ss">Order shippment status; null to load all orders</param> /// <param name="billingEmail">Billing email. Leave empty to load all records.</param> /// <param name="orderGuid">Search by order GUID (Global unique identifier) or part of GUID. Leave empty to load all orders.</param> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <returns>Order collection</returns> public virtual IPagedList<Order> SearchOrders(DateTime? startTime, DateTime? endTime, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, string billingEmail, string orderGuid, int pageIndex, int pageSize) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query = _orderRepository.Table; if (startTime.HasValue) query = query.Where(o => startTime.Value <= o.CreatedOnUtc); if (endTime.HasValue) query = query.Where(o => endTime.Value >= o.CreatedOnUtc); if (orderStatusId.HasValue) query = query.Where(o => orderStatusId.Value == o.OrderStatusId); if (paymentStatusId.HasValue) query = query.Where(o => paymentStatusId.Value == o.PaymentStatusId); if (shippingStatusId.HasValue) query = query.Where(o => shippingStatusId.Value == o.ShippingStatusId); if (!String.IsNullOrEmpty(billingEmail)) query = query.Where(o => o.BillingAddress != null && !String.IsNullOrEmpty(o.BillingAddress.Email) && o.BillingAddress.Email.Contains(billingEmail)); query = query.Where(o => !o.Deleted); query = query.OrderByDescending(o => o.CreatedOnUtc); var orders = query.ToList(); //filter by GUID. Filter in BLL because EF doesn't support casting of GUID to string if (!String.IsNullOrEmpty(orderGuid)) orders = orders.FindAll(o => o.OrderGuid.ToString().ToLowerInvariant().Contains(orderGuid.ToLowerInvariant())); return new PagedList<Order>(orders, pageIndex, pageSize); }
/// <summary> /// Mark payment as failed /// </summary> public void Fail() { Status = PaymentStatus.Failed; }
/// <summary> /// Get best sellers report /// </summary> /// <param name="storeId">Store identifier; 0 to load all records</param> /// <param name="vendorId">Vendor identifier; 0 to load all records</param> /// <param name="createdFromUtc">Order created date from (UTC); null to load all records</param> /// <param name="createdToUtc">Order created date to (UTC); null to load all records</param> /// <param name="os">Order status; null to load all records</param> /// <param name="ps">Order payment status; null to load all records</param> /// <param name="ss">Shipping status; null to load all records</param> /// <param name="billingCountryId">Billing country identifier; 0 to load all records</param> /// <param name="orderBy">1 - order by quantity, 2 - order by total amount</param> /// <param name="groupBy">1 - group by product variants, 2 - group by products</param> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Result</returns> public virtual IPagedList<BestsellersReportLine> BestSellersReport(int storeId = 0, int vendorId = 0, DateTime? createdFromUtc = null, DateTime? createdToUtc = null, OrderStatus? os = null, PaymentStatus? ps = null, ShippingStatus? ss = null, int billingCountryId = 0, int orderBy = 1, int groupBy = 1, int pageIndex = 0, int pageSize = 2147483647, bool showHidden = false) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query1 = from opv in _opvRepository.Table join o in _orderRepository.Table on opv.OrderId equals o.Id join pv in _productVariantRepository.Table on opv.ProductVariantId equals pv.Id join p in _productRepository.Table on pv.ProductId equals p.Id where (storeId == 0 || storeId == o.StoreId) && (!createdFromUtc.HasValue || createdFromUtc.Value <= o.CreatedOnUtc) && (!createdToUtc.HasValue || createdToUtc.Value >= o.CreatedOnUtc) && (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) && (!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) && (!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) && (!o.Deleted) && (!p.Deleted) && (vendorId == 0 || p.VendorId == vendorId) && (!pv.Deleted) && (billingCountryId == 0 || o.BillingAddress.CountryId == billingCountryId) && (showHidden || p.Published) && (showHidden || pv.Published) select opv; IQueryable<BestsellersReportLine> query2 = groupBy == 1 ? //group by product variants from opv in query1 group opv by opv.ProductVariantId into g select new BestsellersReportLine() { EntityId = g.Key, TotalAmount = g.Sum(x => x.PriceExclTax), TotalQuantity = g.Sum(x => x.Quantity), } : //group by products from opv in query1 group opv by opv.ProductVariant.ProductId into g select new BestsellersReportLine() { EntityId = g.Key, TotalAmount = g.Sum(x => x.PriceExclTax), TotalQuantity = g.Sum(x => x.Quantity), } ; switch (orderBy) { case 1: { query2 = query2.OrderByDescending(x => x.TotalQuantity); } break; case 2: { query2 = query2.OrderByDescending(x => x.TotalAmount); } break; default: throw new ArgumentException("Wrong orderBy parameter", "orderBy"); } var result = new PagedList<BestsellersReportLine>(query2, pageIndex, pageSize); return result; }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private string GetWhereCondition() { // Orders from current site string where = "OrderSiteID = " + CMSContext.CurrentSiteID; // Order status filter OrderStatusInfo status = OrderStatusInfoProvider.GetOrderStatusInfo(OrderStatus, SiteContext.CurrentSiteName); if (status != null) { where = SqlHelper.AddWhereCondition(where, "OrderStatusID = " + status.StatusID); } // Customer or company like filter if (!string.IsNullOrEmpty(CustomerOrCompany)) { string safeQueryStr = SecurityHelper.GetSafeQueryString(CustomerOrCompany); where = SqlHelper.AddWhereCondition(where, "OrderCustomerID IN (SELECT CustomerID FROM COM_Customer WHERE ((CustomerFirstName + ' ' + CustomerLastName + ' ' + CustomerFirstName) LIKE N'%" + safeQueryStr + "%') OR (CustomerCompany LIKE N'%" + safeQueryStr + "%'))"); } // Filter for orders with note if (HasNote) { where = SqlHelper.AddWhereCondition(where, "(OrderNote != '') AND (OrderNote IS NOT NULL)"); } // Payment method filter PaymentOptionInfo payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(PaymentMethod, SiteContext.CurrentSiteName); if (payment != null) { where = SqlHelper.AddWhereCondition(where, "OrderPaymentOptionID = " + payment.PaymentOptionID); } // Payment status filter switch (PaymentStatus.ToLowerCSafe()) { case PAY_STATUS_NOT_PAID: where = SqlHelper.AddWhereCondition(where, "(OrderIsPaid = 0) OR (OrderIsPaid IS NULL)"); break; case PAY_STATUS_PAID: where = SqlHelper.AddWhereCondition(where, "OrderIsPaid = 1"); break; } // Currency filter CurrencyInfo currencyObj = CurrencyInfoProvider.GetCurrencyInfo(Currency, SiteContext.CurrentSiteName); if (currencyObj != null) { where = SqlHelper.AddWhereCondition(where, "OrderCurrencyID = " + currencyObj.CurrencyID); } // Min price in main currency filter if (MinPriceInMainCurrency > 0) { where = SqlHelper.AddWhereCondition(where, "OrderTotalPriceInMainCurrency >= " + MinPriceInMainCurrency); } // Max price in main currency filter if (MaxPriceInMainCurrency > 0) { where = SqlHelper.AddWhereCondition(where, "OrderTotalPriceInMainCurrency <= " + MaxPriceInMainCurrency); } // Shipping option filter ShippingOptionInfo shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(ShippingOption, SiteContext.CurrentSiteName); if (shipping != null) { where = SqlHelper.AddWhereCondition(where, "OrderShippingOptionID = " + shipping.ShippingOptionID); } // Shipping country filter where = SqlHelper.AddWhereCondition(where, GetCountryWhereCondition()); // Date filter where = SqlHelper.AddWhereCondition(where, GetDateWhereCondition()); return(where); }
public async Task UpdatePaymentStatus(PaymentStatus paymentStatus) { await _connection.UpdateAsync(paymentStatus); }
public override string RedirectForPayment(OrderData orderData) { var appliedtotal = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedsubtotal"); var alreadypaid = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/alreadypaid"); var info = ProviderUtils.GetProviderSettings("DnnCMolliepayment"); var cartDesc = info.GetXmlProperty("genxml/textbox/cartdescription"); var testMode = info.GetXmlPropertyBool("genxml/checkbox/testmode"); var testApiKey = info.GetXmlProperty("genxml/textbox/testapikey"); var liveApiKey = info.GetXmlProperty("genxml/textbox/liveapikey"); var notifyUrl = Utils.ToAbsoluteUrl("/DesktopModules/NBright/DnnCMollie/notify.ashx"); var returnUrl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, ""); var ItemId = orderData.PurchaseInfo.ItemID.ToString(""); var nbi = new NBrightInfo(); nbi.XMLData = orderData.payselectionXml; var paymentMethod = nbi.GetXmlProperty("genxml/textbox/paymentmethod"); var paymentBank = nbi.GetXmlProperty("genxml/textbox/paymentbank"); var apiKey = testApiKey; if (!testMode) { apiKey = liveApiKey; } MollieClient mollieClient = new MollieClient(); mollieClient.setApiKey(apiKey); Payment payment = new Payment() { amount = decimal.Parse((appliedtotal - alreadypaid).ToString("0.00", CultureInfo.InvariantCulture)), //99.99M, description = cartDesc, redirectUrl = returnUrl + "/orderid/" + ItemId, method = (Method)Enum.Parse(typeof(Method), paymentMethod, true), issuer = paymentBank, metadata = ItemId, webhookUrl = notifyUrl, }; PaymentStatus paymentStatus = mollieClient.StartPayment(payment); orderData.OrderStatus = "020"; orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", ""); orderData.PurchaseInfo.SetXmlProperty("genxml/posturl", paymentStatus.links.paymentUrl); orderData.PurchaseInfo.Lang = Utils.GetCurrentCulture(); orderData.SavePurchaseData(); try { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(ProviderUtils.GetBankRemotePost(orderData)); } catch (Exception ex) { // rollback transaction orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "<div>ERROR: Invalid payment data </div><div>" + ex + "</div>"); orderData.PaymentFail(); var param = new string[3]; param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); param[1] = "status=0"; return(Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param)); } try { HttpContext.Current.Response.End(); } catch (Exception ex) { // this try/catch to avoid sending error 'ThreadAbortException' } return(""); }
public Payment(string ccNumber, double amount) { CcNumber = ccNumber; Amount = amount; PaymentStatus = PaymentStatus.VALIDATED; }
private void Apply(PaymentTimedOut @event) { Version++; Status = PaymentStatus.Failed; }
/// <summary> /// Get best sellers report /// </summary> /// <param name="storeId">Store identifier (orders placed in a specific store); 0 to load all records</param> /// <param name="vendorId">Vendor identifier; 0 to load all records</param> /// <param name="categoryId">Category identifier; 0 to load all records</param> /// <param name="manufacturerId">Manufacturer identifier; 0 to load all records</param> /// <param name="createdFromUtc">Order created date from (UTC); null to load all records</param> /// <param name="createdToUtc">Order created date to (UTC); null to load all records</param> /// <param name="os">Order status; null to load all records</param> /// <param name="ps">Order payment status; null to load all records</param> /// <param name="ss">Shipping status; null to load all records</param> /// <param name="billingCountryId">Billing country identifier; 0 to load all records</param> /// <param name="orderBy">1 - order by quantity, 2 - order by total amount</param> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Result</returns> public virtual IPagedList<BestsellersReportLine> BestSellersReport( int categoryId = 0, int manufacturerId = 0, int storeId = 0, int vendorId = 0, DateTime? createdFromUtc = null, DateTime? createdToUtc = null, OrderStatus? os = null, PaymentStatus? ps = null, ShippingStatus? ss = null, int billingCountryId = 0, int orderBy = 1, int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query1 = from orderItem in _orderItemRepository.Table join o in _orderRepository.Table on orderItem.OrderId equals o.Id join p in _productRepository.Table on orderItem.ProductId equals p.Id //join pc in _productCategoryRepository.Table on p.Id equals pc.ProductId into p_pc from pc in p_pc.DefaultIfEmpty() //join pm in _productManufacturerRepository.Table on p.Id equals pm.ProductId into p_pm from pm in p_pm.DefaultIfEmpty() where (storeId == 0 || storeId == o.StoreId) && (!createdFromUtc.HasValue || createdFromUtc.Value <= o.CreatedOnUtc) && (!createdToUtc.HasValue || createdToUtc.Value >= o.CreatedOnUtc) && (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) && (!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) && (!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) && (!o.Deleted) && (!p.Deleted) && (vendorId == 0 || p.VendorId == vendorId) && //(categoryId == 0 || pc.CategoryId == categoryId) && //(manufacturerId == 0 || pm.ManufacturerId == manufacturerId) && (categoryId == 0 || p.ProductCategories.Count(pc => pc.CategoryId == categoryId) > 0) && (manufacturerId == 0 || p.ProductManufacturers.Count(pm => pm.ManufacturerId == manufacturerId) > 0) && (billingCountryId == 0 || o.BillingAddress.CountryId == billingCountryId) && (showHidden || p.Published) select orderItem; IQueryable<BestsellersReportLine> query2 = //group by products from orderItem in query1 group orderItem by orderItem.ProductId into g select new BestsellersReportLine { ProductId = g.Key, TotalAmount = g.Sum(x => x.PriceExclTax), TotalQuantity = g.Sum(x => x.Quantity), } ; switch (orderBy) { case 1: { query2 = query2.OrderByDescending(x => x.TotalQuantity); } break; case 2: { query2 = query2.OrderByDescending(x => x.TotalAmount); } break; default: throw new ArgumentException("Wrong orderBy parameter", "orderBy"); } var result = new PagedList<BestsellersReportLine>(query2, pageIndex, pageSize); return result; }
/// <summary> /// Search orders /// </summary> /// <param name="startTime">Order start time; null to load all orders</param> /// <param name="endTime">Order end time; null to load all orders</param> /// <param name="os">Order status; null to load all orders</param> /// <param name="ps">Order payment status; null to load all orders</param> /// <param name="ss">Order shippment status; null to load all orders</param> /// <param name="billingEmail">Billing email. Leave empty to load all records.</param> /// <param name="orderGuid">Search by order GUID (Global unique identifier) or part of GUID. Leave empty to load all orders.</param> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <param name="storId">vendor id</param> /// <returns>Order collection</returns> public virtual IPagedList<Order> SearchOrders(DateTime? startTime, DateTime? endTime, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, string billingEmail, string orderGuid, int pageIndex, int pageSize, int vendorId) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query = _orderRepository.Table; //add by hz if (vendorId > 0) { query = (from o in _orderRepository.Table join opv in _opvRepository.Table on o.Id equals opv.OrderId join pv in _pvRepository.Table on opv.ProductVariantId equals pv.Id join p in _productRepository.Table on pv.ProductId equals p.Id join pvendor in _productVendorRepository.Table on p.Id equals pvendor.ProductId where pvendor.VendorId == vendorId select o).Distinct() ; } //end by hz if (startTime.HasValue) query = query.Where(o => startTime.Value <= o.CreatedOnUtc); if (endTime.HasValue) query = query.Where(o => endTime.Value >= o.CreatedOnUtc); if (orderStatusId.HasValue) query = query.Where(o => orderStatusId.Value == o.OrderStatusId); if (paymentStatusId.HasValue) query = query.Where(o => paymentStatusId.Value == o.PaymentStatusId); if (shippingStatusId.HasValue) query = query.Where(o => shippingStatusId.Value == o.ShippingStatusId); if (!String.IsNullOrEmpty(billingEmail)) query = query.Where(o => o.BillingAddress != null && !String.IsNullOrEmpty(o.BillingAddress.Email) && o.BillingAddress.Email.Contains(billingEmail)); query = query.Where(o => !o.Deleted); query = query.OrderByDescending(o => o.CreatedOnUtc); var orders = query.ToList(); //filter by GUID. Filter in BLL because EF doesn't support casting of GUID to string if (!String.IsNullOrEmpty(orderGuid)) orders = orders.FindAll(o => o.OrderGuid.ToString().ToLowerInvariant().Contains(orderGuid.ToLowerInvariant())); return new PagedList<Order>(orders, pageIndex, pageSize); }
public void Update(int PaymentStatusKey,string PaymentStatusDescription,string PaymentStatusAdmindescription) { PaymentStatus item = new PaymentStatus(); item.MarkOld(); item.IsLoaded = true; item.PaymentStatusKey = PaymentStatusKey; item.PaymentStatusDescription = PaymentStatusDescription; item.PaymentStatusAdmindescription = PaymentStatusAdmindescription; item.Save(UserName); }
/// <summary> /// Get profit report /// </summary> /// <param name="startTimeUtc">Start date</param> /// <param name="endTimeUtc">End date</param> /// <param name="os">Order status; null to load all records</param> /// <param name="ps">Order payment status; null to load all records</param> /// <param name="ss">Shipping status; null to load all records</param> /// <param name="billingEmail">Billing email. Leave empty to load all records.</param> /// <returns>Result</returns> public virtual decimal ProfitReport(OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, DateTime? startTimeUtc, DateTime? endTimeUtc, string billingEmail) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; //We cannot use String.IsNullOrEmpty(billingEmail) in SQL Compact bool dontSearchEmail = String.IsNullOrEmpty(billingEmail); var query = from opv in _opvRepository.Table join o in _orderRepository.Table on opv.OrderId equals o.Id join pv in _productVariantRepository.Table on opv.ProductVariantId equals pv.Id join p in _productRepository.Table on pv.ProductId equals p.Id where (!startTimeUtc.HasValue || startTimeUtc.Value <= o.CreatedOnUtc) && (!endTimeUtc.HasValue || endTimeUtc.Value >= o.CreatedOnUtc) && (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) && (!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) && (!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) && (!o.Deleted) && (!p.Deleted) && (!pv.Deleted) && (dontSearchEmail || (o.BillingAddress != null && !String.IsNullOrEmpty(o.BillingAddress.Email) && o.BillingAddress.Email.Contains(billingEmail))) select new { opv, pv }; var opvPrices = Convert.ToDecimal(query.Sum(o => (decimal?)o.opv.PriceExclTax)); var productCost = Convert.ToDecimal(query.Sum(o => (decimal?) o.pv.ProductCost * o.opv.Quantity)); var profit = opvPrices - productCost; return profit; }
private void Apply(PaymentCompleted @event) { Version++; Status = PaymentStatus.Completed; }
/// <summary> /// Returns true if Transaction instances are equal /// </summary> /// <param name="other">Instance of Transaction to be compared</param> /// <returns>Boolean</returns> public bool Equals(Transaction other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( TransactionID == other.TransactionID || TransactionID != null && TransactionID.Equals(other.TransactionID) ) && ( BuyerFirstName == other.BuyerFirstName || BuyerFirstName != null && BuyerFirstName.Equals(other.BuyerFirstName) ) && ( BuyerLastName == other.BuyerLastName || BuyerLastName != null && BuyerLastName.Equals(other.BuyerLastName) ) && ( BuyerAddress == other.BuyerAddress || BuyerAddress != null && BuyerAddress.Equals(other.BuyerAddress) ) && ( BuyerCity == other.BuyerCity || BuyerCity != null && BuyerCity.Equals(other.BuyerCity) ) && ( BuyerEmail == other.BuyerEmail || BuyerEmail != null && BuyerEmail.Equals(other.BuyerEmail) ) && ( BuyerUserId == other.BuyerUserId || BuyerUserId != null && BuyerUserId.Equals(other.BuyerUserId) ) && ( PaymentStatus == other.PaymentStatus || PaymentStatus != null && PaymentStatus.Equals(other.PaymentStatus) ) && ( PaymentReferenceId == other.PaymentReferenceId || PaymentReferenceId != null && PaymentReferenceId.Equals(other.PaymentReferenceId) ) && ( TotalAmount == other.TotalAmount || TotalAmount != null && TotalAmount.Equals(other.TotalAmount) )); }
/// <summary> /// Get best sellers report /// </summary> /// <param name="startTime">Order start time; null to load all</param> /// <param name="endTime">Order end time; null to load all</param> /// <param name="os">Order status; null to load all records</param> /// <param name="ps">Order payment status; null to load all records</param> /// <param name="ss">Shipping status; null to load all records</param> /// <param name="recordsToReturn">Records to return</param> /// <param name="orderBy">1 - order by quantity, 2 - order by total amount</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Result</returns> public virtual IList<BestsellersReportLine> BestSellersReport(DateTime? startTime, DateTime? endTime, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, int recordsToReturn = 5, int orderBy = 1, bool showHidden = false) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query1 = from opv in _opvRepository.Table join o in _orderRepository.Table on opv.OrderId equals o.Id join pv in _productVariantRepository.Table on opv.ProductVariantId equals pv.Id join p in _productRepository.Table on pv.ProductId equals p.Id where (!startTime.HasValue || startTime.Value <= o.CreatedOnUtc) && (!endTime.HasValue || endTime.Value >= o.CreatedOnUtc) && (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) && (!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) && (!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) && (!o.Deleted) && (!p.Deleted) && (!pv.Deleted) && (showHidden || p.Published) && (showHidden || pv.Published) select opv; var query2 = from opv in query1 group opv by opv.ProductVariantId into g select new { ProductVariantId = g.Key, TotalAmount = g.Sum(x => x.PriceExclTax), TotalQuantity = g.Sum(x => x.Quantity), }; switch (orderBy) { case 1: { query2 = query2.OrderByDescending(x => x.TotalQuantity); } break; case 2: { query2 = query2.OrderByDescending(x => x.TotalAmount); } break; default: throw new ArgumentException("Wrong orderBy parameter", "orderBy"); } if (recordsToReturn != 0 && recordsToReturn != int.MaxValue) query2 = query2.Take(recordsToReturn); var result = query2.ToList().Select(x => { return new BestsellersReportLine() { ProductVariantId = x.ProductVariantId, TotalAmount = x.TotalAmount, TotalQuantity = x.TotalQuantity }; }).ToList(); return result; }
private void Apply(PaymentDiscarded @event) { Version++; Status = PaymentStatus.Failed; }
static string EncodePriceAndStatusIntoTransaction(decimal price, PaymentStatus status) { return string.Format("{0};{1};{2}", Guid.NewGuid(), price, status); }
/// <summary> /// Get best customers /// </summary> /// <param name="createdFromUtc">Order created date from (UTC); null to load all records</param> /// <param name="createdToUtc">Order created date to (UTC); null to load all records</param> /// <param name="os">Order status; null to load all records</param> /// <param name="ps">Order payment status; null to load all records</param> /// <param name="ss">Order shippment status; null to load all records</param> /// <param name="orderBy">1 - order by order total, 2 - order by number of orders</param> /// <returns>Report</returns> public virtual IList<BestCustomerReportLine> GetBestCustomersReport(DateTime? createdFromUtc, DateTime? createdToUtc, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, int orderBy) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query1 = from c in _customerRepository.Table join o in _orderRepository.Table on c.Id equals o.CustomerId where (!createdFromUtc.HasValue || createdFromUtc.Value <= o.CreatedOnUtc) && (!createdToUtc.HasValue || createdToUtc.Value >= o.CreatedOnUtc) && (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) && (!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) && (!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) && (!o.Deleted) && (!c.Deleted) select new { c, o }; var query2 = from co in query1 group co by co.c.Id into g select new { CustomerId = g.Key, OrderTotal = g.Sum(x => x.o.OrderTotal), OrderCount = g.Count() }; switch (orderBy) { case 1: { query2 = query2.OrderByDescending(x => x.OrderTotal); } break; case 2: { query2 = query2.OrderByDescending(x => x.OrderCount); } break; default: throw new ArgumentException("Wrong orderBy parameter", "orderBy"); } //load 20 customers query2 = query2.Take(20); var result = query2.ToList().Select(x => { return new BestCustomerReportLine() { CustomerId = x.CustomerId, OrderTotal = x.OrderTotal, OrderCount = x.OrderCount }; }).ToList(); return result; }
public void OnPaymentStatusChange(PaymentStatus p0) { System.Diagnostics.Debug.WriteLine($"*** OnPaymentStatusChange {p0} ***"); }
public async Task DeletePaymentStatus(PaymentStatus paymentStatus) { await _connection.DeleteAsync(paymentStatus); }
public float GetTotalTaskTimeByFilter( int projectid, bool myProjects, int? milestone, bool myMilestones, int tag, Guid departament, Guid participant, ApiDateTime createdStart, ApiDateTime createdStop, int lastId, PaymentStatus? status) { var taskFilter = new TaskFilter { DepartmentId = departament, UserId = participant, FromDate = createdStart, ToDate = createdStop, SortBy = _context.SortBy, SortOrder = !_context.SortDescending, SearchText = _context.FilterValue, TagId = tag, LastId = lastId, MyProjects = myProjects, MyMilestones = myMilestones, Milestone = milestone }; if (projectid != 0) { taskFilter.ProjectIds.Add(projectid); } if (status.HasValue) { taskFilter.PaymentStatuses.Add(status.Value); } _context.SetDataPaginated(); _context.SetDataFiltered(); _context.SetDataSorted(); return EngineFactory.GetTimeTrackingEngine().GetByFilterTotal(taskFilter); }
protected virtual void ProcessPayment(string orderNumber, string ipnInfo, PaymentStatus newPaymentStatus, decimal mcGross, string transactionId) { Guid orderNumberGuid; try { orderNumberGuid = new Guid(orderNumber); } catch { orderNumberGuid = Guid.Empty; } var order = _orderService.GetOrderByGuid(orderNumberGuid); if (order == null) { _logger.Error("PayPal IPN. Order is not found", new NopException(ipnInfo)); return; } //order note _orderService.InsertOrderNote(new OrderNote { OrderId = order.Id, Note = ipnInfo, DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); //validate order total if ((newPaymentStatus == PaymentStatus.Authorized || newPaymentStatus == PaymentStatus.Paid) && !Math.Round(mcGross, 2).Equals(Math.Round(order.OrderTotal, 2))) { var errorStr = $"PayPal IPN. Returned order total {mcGross} doesn't equal order total {order.OrderTotal}. Order# {order.Id}."; //log _logger.Error(errorStr); //order note _orderService.InsertOrderNote(new OrderNote { OrderId = order.Id, Note = errorStr, DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); return; } switch (newPaymentStatus) { case PaymentStatus.Authorized: if (_orderProcessingService.CanMarkOrderAsAuthorized(order)) { _orderProcessingService.MarkAsAuthorized(order); } break; case PaymentStatus.Paid: if (_orderProcessingService.CanMarkOrderAsPaid(order)) { order.AuthorizationTransactionId = transactionId; _orderService.UpdateOrder(order); _orderProcessingService.MarkOrderAsPaid(order); } break; case PaymentStatus.Refunded: var totalToRefund = Math.Abs(mcGross); if (totalToRefund > 0 && Math.Round(totalToRefund, 2).Equals(Math.Round(order.OrderTotal, 2))) { //refund if (_orderProcessingService.CanRefundOffline(order)) { _orderProcessingService.RefundOffline(order); } } else { //partial refund if (_orderProcessingService.CanPartiallyRefundOffline(order, totalToRefund)) { _orderProcessingService.PartiallyRefundOffline(order, totalToRefund); } } break; case PaymentStatus.Voided: if (_orderProcessingService.CanVoidOffline(order)) { _orderProcessingService.VoidOffline(order); } break; } }
/// <summary> /// Get profit report /// </summary> /// <param name="storeId">Store identifier</param> /// <param name="vendorId">Vendor identifier</param> /// <param name="startTimeUtc">Start date</param> /// <param name="endTimeUtc">End date</param> /// <param name="os">Order status; null to load all records</param> /// <param name="ps">Order payment status; null to load all records</param> /// <param name="ss">Shipping status; null to load all records</param> /// <param name="billingEmail">Billing email. Leave empty to load all records.</param> /// <returns>Result</returns> public virtual decimal ProfitReport(int storeId, int vendorId, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, DateTime? startTimeUtc, DateTime? endTimeUtc, string billingEmail) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; //We cannot use String.IsNullOrEmpty(billingEmail) in SQL Compact bool dontSearchEmail = String.IsNullOrEmpty(billingEmail); var query = from opv in _opvRepository.Table join o in _orderRepository.Table on opv.OrderId equals o.Id join pv in _productVariantRepository.Table on opv.ProductVariantId equals pv.Id join p in _productRepository.Table on pv.ProductId equals p.Id where (storeId == 0 || storeId == o.StoreId) && (!startTimeUtc.HasValue || startTimeUtc.Value <= o.CreatedOnUtc) && (!endTimeUtc.HasValue || endTimeUtc.Value >= o.CreatedOnUtc) && (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) && (!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) && (!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) && (!o.Deleted) && (vendorId == 0 || opv.ProductVariant.Product.VendorId == vendorId) && //we do not ignore deleted products when calculating order reports //(!p.Deleted) && //(!pv.Deleted) && (dontSearchEmail || (o.BillingAddress != null && !String.IsNullOrEmpty(o.BillingAddress.Email) && o.BillingAddress.Email.Contains(billingEmail))) select new { opv, pv }; var productCost = Convert.ToDecimal(query.Sum(o => (decimal?) o.pv.ProductCost * o.opv.Quantity)); var reportSummary = GetOrderAverageReportLine(storeId, vendorId, os, ps, ss, startTimeUtc, endTimeUtc, billingEmail); var profit = reportSummary.SumOrders - reportSummary.SumTax - productCost; return profit; }
protected virtual void ProcessRecurringPayment(string invoiceId, PaymentStatus newPaymentStatus, string transactionId, string ipnInfo) { Guid orderNumberGuid; try { orderNumberGuid = new Guid(invoiceId); } catch { orderNumberGuid = Guid.Empty; } var order = _orderService.GetOrderByGuid(orderNumberGuid); if (order == null) { _logger.Error("PayPal IPN. Order is not found", new NopException(ipnInfo)); return; } var recurringPayments = _orderService.SearchRecurringPayments(initialOrderId: order.Id); foreach (var rp in recurringPayments) { switch (newPaymentStatus) { case PaymentStatus.Authorized: case PaymentStatus.Paid: { var recurringPaymentHistory = _orderService.GetRecurringPaymentHistory(rp); if (!recurringPaymentHistory.Any()) { _orderService.InsertRecurringPaymentHistory(new RecurringPaymentHistory { RecurringPaymentId = rp.Id, OrderId = order.Id, CreatedOnUtc = DateTime.UtcNow }); } else { //next payments var processPaymentResult = new ProcessPaymentResult { NewPaymentStatus = newPaymentStatus }; if (newPaymentStatus == PaymentStatus.Authorized) { processPaymentResult.AuthorizationTransactionId = transactionId; } else { processPaymentResult.CaptureTransactionId = transactionId; } _orderProcessingService.ProcessNextRecurringPayment(rp, processPaymentResult); } } break; case PaymentStatus.Voided: //failed payment var failedPaymentResult = new ProcessPaymentResult { Errors = new[] { $"PayPal IPN. Recurring payment is {nameof(PaymentStatus.Voided).ToLower()} ." }, RecurringPaymentFailed = true }; _orderProcessingService.ProcessNextRecurringPayment(rp, failedPaymentResult); break; } } //OrderService.InsertOrderNote(newOrder.OrderId, sb.ToString(), DateTime.UtcNow); _logger.Information("PayPal IPN. Recurring info", new NopException(ipnInfo)); }
/// <summary>Return a set of <see cref="PaymentCard" /> values that will return the /// specified response type when submitted to this provider's test gateway.</summary> protected abstract PaymentCard GetMagicCard(PaymentStatus status);
public async Task AddPaymentStatus(PaymentStatus paymentStatus) { await _connection.InsertAsync(paymentStatus); }
/// <summary> /// Initializes a new instance of the <see cref="CheckoutPaymentGatewayModelsPaymentResponse" /> class. /// </summary> /// <param name="id">Unique Identifier of the payment (required).</param> /// <param name="currencyCode">The currency code the transaction is made in (required).</param> /// <param name="amount">The amount of the transaction (required).</param> /// <param name="cvc">The cvc customers card (required).</param> /// <param name="cardNumber">The CardNumber for the transaction (required).</param> /// <param name="fullName">The FullName of the customer as shown on the card (required).</param> /// <param name="cardExpiryDate">The expiry date of the customers card (required).</param> /// <param name="requestDate">The date the transaction was initilised (required).</param> /// <param name="isSuccessful">Descibes whether the payment was succesful or not (required) (default to false).</param> /// <param name="message">Shows any further information if required (i.e. useful error messages).</param> public CheckoutPaymentGatewayModelsPaymentResponse(Guid?id = default(Guid?), string currencyCode = default(string), double?amount = default(double?), int?cvc = default(int?), string cardNumber = default(string), string fullName = default(string), DateTime?cardExpiryDate = default(DateTime?), DateTime?requestDate = default(DateTime?), bool?isSuccessful = false, string message = default(string), PaymentStatus status = default(PaymentStatus)) { // to ensure "id" is required (not null) if (id == null) { throw new InvalidDataException("id is a required property for CheckoutPaymentGatewayModelsPaymentResponse and cannot be null"); } else { this.Id = id; } // to ensure "currencyCode" is required (not null) if (currencyCode == null) { throw new InvalidDataException("currencyCode is a required property for CheckoutPaymentGatewayModelsPaymentResponse and cannot be null"); } else { this.CurrencyCode = currencyCode; } // to ensure "amount" is required (not null) if (amount == null) { throw new InvalidDataException("amount is a required property for CheckoutPaymentGatewayModelsPaymentResponse and cannot be null"); } else { this.Amount = amount; } // to ensure "fullName" is required (not null) if (fullName == null) { throw new InvalidDataException("fullName is a required property for CheckoutPaymentGatewayModelsPaymentResponse and cannot be null"); } else { this.FullName = fullName; } // to ensure "requestDate" is required (not null) if (requestDate == null) { throw new InvalidDataException("requestDate is a required property for CheckoutPaymentGatewayModelsPaymentResponse and cannot be null"); } else { this.RequestDate = requestDate; } // to ensure "isSuccessful" is required (not null) if (isSuccessful == null) { throw new InvalidDataException("isSuccessful is a required property for CheckoutPaymentGatewayModelsPaymentResponse and cannot be null"); } else { this.IsSuccessful = isSuccessful; } this.Cvc = cvc; this.CardNumber = cardNumber; this.CardExpiryDate = cardExpiryDate; this.Message = message; this.Status = status; }
/// <inheritdoc/> public void SetStatus(Payment payment, PaymentStatus status) => payment.Status = status;
/// <summary> /// Search orders /// </summary> /// <param name="storeId">Store identifier; 0 to load all orders</param> /// <param name="vendorId">Vendor identifier; null to load all orders</param> /// <param name="customerId">Customer identifier; 0 to load all orders</param> /// <param name="productId">Product identifier which was purchased in an order; 0 to load all orders</param> /// <param name="affiliateId">Affiliate identifier; 0 to load all orders</param> /// <param name="warehouseId">Warehouse identifier, only orders with products from a specified warehouse will be loaded; 0 to load all orders</param> /// <param name="createdFromUtc">Created date from (UTC); null to load all records</param> /// <param name="createdToUtc">Created date to (UTC); null to load all records</param> /// <param name="os">Order status; null to load all orders</param> /// <param name="ps">Order payment status; null to load all orders</param> /// <param name="ss">Order shipment status; null to load all orders</param> /// <param name="billingEmail">Billing email. Leave empty to load all records.</param> /// <param name="orderGuid">Search by order GUID (Global unique identifier) or part of GUID. Leave empty to load all orders.</param> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <returns>Order collection</returns> public virtual IPagedList<Order> SearchOrders(int storeId = 0, int vendorId = 0, int customerId = 0, int productId = 0, int affiliateId = 0, int warehouseId = 0, DateTime? createdFromUtc = null, DateTime? createdToUtc = null, OrderStatus? os = null, PaymentStatus? ps = null, ShippingStatus? ss = null, string billingEmail = null, string orderGuid = null, int pageIndex = 0, int pageSize = int.MaxValue) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query = _orderRepository.Table; if (storeId > 0) query = query.Where(o => o.StoreId == storeId); if (vendorId > 0) { query = query .Where(o => o.OrderItems .Any(orderItem => orderItem.Product.VendorId == vendorId)); } if (customerId > 0) query = query.Where(o => o.CustomerId == customerId); if (productId > 0) { query = query .Where(o => o.OrderItems .Any(orderItem => orderItem.Product.Id == productId)); } if (warehouseId > 0) { query = query .Where(o => o.OrderItems .Any(orderItem => orderItem.Product.WarehouseId == warehouseId)); } if (affiliateId > 0) query = query.Where(o => o.AffiliateId == affiliateId); if (createdFromUtc.HasValue) query = query.Where(o => createdFromUtc.Value <= o.CreatedOnUtc); if (createdToUtc.HasValue) query = query.Where(o => createdToUtc.Value >= o.CreatedOnUtc); if (orderStatusId.HasValue) query = query.Where(o => orderStatusId.Value == o.OrderStatusId); if (paymentStatusId.HasValue) query = query.Where(o => paymentStatusId.Value == o.PaymentStatusId); if (shippingStatusId.HasValue) query = query.Where(o => shippingStatusId.Value == o.ShippingStatusId); if (!String.IsNullOrEmpty(billingEmail)) query = query.Where(o => o.BillingAddress != null && !String.IsNullOrEmpty(o.BillingAddress.Email) && o.BillingAddress.Email.Contains(billingEmail)); query = query.Where(o => !o.Deleted); query = query.OrderByDescending(o => o.CreatedOnUtc); if (!String.IsNullOrEmpty(orderGuid)) { //filter by GUID. Filter in BLL because EF doesn't support casting of GUID to string var orders = query.ToList(); orders = orders.FindAll(o => o.OrderGuid.ToString().ToLowerInvariant().Contains(orderGuid.ToLowerInvariant())); return new PagedList<Order>(orders, pageIndex, pageSize); } else { //database layer paging return new PagedList<Order>(query, pageIndex, pageSize); } }
private PaymentStatus VerifyPayment(SystempayIPNParameters ipn) { bool restoreStock = false; PaymentStatus status = PaymentStatus.Invalid; // Default Alert Reason string alertReason = Localization.GetString("InvalidIPN", LocalResourceFile, _portalLanguage); // Security cheking: Validate signature with the current certificate if (ipn.IsValid) { // Security checking: is this request come from right Systempay account ID if (IsFromSite(ipn.vads_site_id)) { // Security checking: compares some Systempay fields with order fields alertReason = Localization.GetString("WrongOrderInfos", LocalResourceFile, _portalLanguage); OrderController orderController = new OrderController(); OrderInfo order = orderController.GetOrder(PortalSettings.PortalId, ipn.vads_order_id); // If this order exist if (order != null) { // Currency MUST BE the same! if (_settings.Currency == ipn.vads_currency) { // Everything looks good, validate the transaction! switch (ipn.vads_trans_status.ToLower()) { case "abandoned": restoreStock = true; status = PaymentStatus.Abandoned; break; case "authorised": case "authorised_to_validate": // Grand Total MUST BE the same! if (Math.Round(order.GrandTotal, 2, MidpointRounding.AwayFromZero) == ipn.vads_amount) { status = PaymentStatus.Authorised; } break; case "canceled": restoreStock = true; status = PaymentStatus.Canceled; break; case "captured": // Grand Total MUST BE the same! if (Math.Round(order.GrandTotal, 2, MidpointRounding.AwayFromZero) == ipn.vads_amount) { status = PaymentStatus.Captured; } break; case "expired": restoreStock = true; status = PaymentStatus.Expired; break; case "refused": restoreStock = true; status = PaymentStatus.Refused; break; case "under_verification": case "waiting_authorisation": case "waiting_authorisation_to_validate": // Grand Total MUST BE the same! if (Math.Round(order.GrandTotal, 2, MidpointRounding.AwayFromZero) == ipn.vads_amount) { status = PaymentStatus.Pending; } break; default: status = PaymentStatus.Unattended; break; } if (restoreStock) { List <OrderDetailInfo> orderDetails = orderController.GetOrderDetails(order.OrderID); if (orderDetails != null) { foreach (OrderDetailInfo detail in orderDetails) { orderController.UpdateStockQuantity(detail.ProductID, detail.Quantity); } ProductController productController = new ProductController(); productController.ClearAllCaches(); } } } } } else { alertReason = Localization.GetString("DifferentReceiverEmail", LocalResourceFile, _portalLanguage); } } // If the transaction is invalid if ((status == PaymentStatus.Invalid) || (status == PaymentStatus.Unattended)) { // Add an Admin Alert to the DNN Log string systempayGateway = Localization.GetString("StoreSystempayGateway", LocalResourceFile, _portalLanguage); string adminAlert = Localization.GetString("SecurityAlert", LocalResourceFile, _portalLanguage); LogProperties properties = new LogProperties { new LogDetailInfo(systempayGateway, adminAlert), new LogDetailInfo(Localization.GetString("AlertReason", LocalResourceFile, _portalLanguage), alertReason), new LogDetailInfo(Localization.GetString("FromIP", LocalResourceFile, _portalLanguage), Request.UserHostAddress), new LogDetailInfo(Localization.GetString("IPNPayload", LocalResourceFile, _portalLanguage), ipn.Payload) }; AddEventLog(EventLogController.EventLogType.ADMIN_ALERT.ToString(), properties, true); // Send an email to the store admin SendEmailToAdmin(systempayGateway + " " + adminAlert, Localization.GetString("EmailAlert", LocalResourceFile, _portalLanguage) + "\r\n\r\n" + alertReason); } return(status); }
/// <summary> /// Gets all Order items /// </summary> /// <param name="orderId">Order identifier; null to load all records</param> /// <param name="customerId">Customer identifier; null to load all records</param> /// <param name="startTime">Order start time; null to load all records</param> /// <param name="endTime">Order end time; null to load all records</param> /// <param name="os">Order status; null to load all records</param> /// <param name="ps">Order payment status; null to load all records</param> /// <param name="ss">Order shippment status; null to load all records</param> /// <param name="loadDownloableProductsOnly">Value indicating whether to load downloadable products only</param> /// <returns>Order collection</returns> public virtual IList<OrderItem> GetAllOrderItems(int? orderId, int? customerId, DateTime? startTime, DateTime? endTime, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, bool loadDownloableProductsOnly) { int? orderStatusId = null; if (os.HasValue) orderStatusId = (int)os.Value; int? paymentStatusId = null; if (ps.HasValue) paymentStatusId = (int)ps.Value; int? shippingStatusId = null; if (ss.HasValue) shippingStatusId = (int)ss.Value; var query = from orderItem in _orderItemRepository.Table join o in _orderRepository.Table on orderItem.OrderId equals o.Id join p in _productRepository.Table on orderItem.ProductId equals p.Id where (!orderId.HasValue || orderId.Value == 0 || orderId == o.Id) && (!customerId.HasValue || customerId.Value == 0 || customerId == o.CustomerId) && (!startTime.HasValue || startTime.Value <= o.CreatedOnUtc) && (!endTime.HasValue || endTime.Value >= o.CreatedOnUtc) && (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) && (!paymentStatusId.HasValue || paymentStatusId.Value == o.PaymentStatusId) && (!shippingStatusId.HasValue || shippingStatusId.Value == o.ShippingStatusId) && (!loadDownloableProductsOnly || p.IsDownload) && !o.Deleted orderby o.CreatedOnUtc descending, orderItem.Id select orderItem; var orderItems = query.ToList(); return orderItems; }
protected void Page_Load(object sender, EventArgs e) { _portalLanguage = PortalSettings.DefaultLanguage; string subject = Localization.GetString("StoreSystempayGateway", LocalResourceFile, _portalLanguage) + Localization.GetString("IPNInfo", LocalResourceFile, _portalLanguage);; string reason = string.Empty; bool sendEmail = false; _settings = new SystempaySettings(StoreSettings.GatewaySettings); SystempayIPNParameters ipn = new SystempayIPNParameters(Request.Form, _settings.Certificate); // Verify payment with Systempay certificate PaymentStatus status = VerifyPayment(ipn); // What's the user language? _userLanguage = Request.QueryString["language"]; switch (status) { case PaymentStatus.Abandoned: case PaymentStatus.Canceled: case PaymentStatus.Captured: break; case PaymentStatus.Authorised: int portalId = PortalSettings.PortalId; // Set order status to "Paid"... OrderInfo order = UpdateOrderStatus(ipn.vads_order_id, OrderInfo.OrderStatusList.Paid, _userLanguage); // Add User to Product Roles OrderController orderController = new OrderController(); orderController.AddUserToRoles(portalId, order); // Add User to Order Role StoreInfo storeSetting = StoreController.GetStoreInfo(portalId); if (storeSetting.OnOrderPaidRoleID != Null.NullInteger) { orderController.AddUserToPaidOrderRole(portalId, order.CustomerID, storeSetting.OnOrderPaidRoleID); } // Special case request validation if (ipn.vads_trans_status == "AUTHORISED_TO_VALIDATE") { sendEmail = true; } break; case PaymentStatus.Expired: case PaymentStatus.Refused: case PaymentStatus.Pending: // Inform Store Admin sendEmail = true; break; case PaymentStatus.Unattended: // Alert Store Admin subject = Localization.GetString("StoreSystempayGateway", LocalResourceFile, _portalLanguage) + Localization.GetString("IPNAlert", LocalResourceFile, _portalLanguage); sendEmail = true; break; default: break; } // Do we need to send an email to the store admin? if (sendEmail) { string paymentStatus = Localization.GetString("PaymentStatus_" + ipn.vads_trans_status, LocalResourceFile, _portalLanguage); if (string.IsNullOrEmpty(paymentStatus)) { paymentStatus = ipn.vads_trans_status; } string emailIPN = Localization.GetString("EmailIPN", LocalResourceFile, _portalLanguage); string body = string.Format(emailIPN, ipn.vads_order_id, ipn.vads_trans_id, ipn.vads_page_action, paymentStatus, ipn.vads_auth_result, ipn.vads_payment_error); SendEmailToAdmin(subject, body); } }