protected void SubmitCaptureButton_Click(object sender, EventArgs e) { int paymentId = AlwaysConvert.ToInt(HiddenPaymentId.Value); Payment payment = PaymentDataSource.Load(paymentId); if (payment != null) { //GET THE CAPTURE AMOUNT decimal captureAmount = AlwaysConvert.ToDecimal(CaptureAmount.Text); bool finalCapture = NoAdditionalCapture.Checked; if (captureAmount > 0) { payment.Capture(captureAmount, finalCapture, false); if (!string.IsNullOrEmpty(CustomerNote.Text)) { OrderNote note = new OrderNote(payment.Order.Id, AbleContext.Current.UserId, DateTime.UtcNow, CustomerNote.Text, NoteType.Public); note.Save(); } } // UPDATE THE GRID CapturePopup.Hide(); PaymentGrid.DataBind(); SearchResultAjax.Update(); } }
protected void SubmitCaptureButton_Click(object sender, EventArgs e) { //GET THE CAPTURE AMOUNT decimal rem = _Payment.Transactions.GetRemainingAuthorized(); decimal bal = _Order.GetBalance(false); string originalCaptureAmount = string.Format("{0:F2}", rem > bal ? bal : rem); decimal captureAmount = AlwaysConvert.ToDecimal(CaptureAmount.Text); // AC8-2854: IF amount is not changed by merchant then // to avoid rounding issues, restore the original amount upto 4 decimal digits if (originalCaptureAmount == CaptureAmount.Text) { captureAmount = rem > bal ? bal : rem; } bool finalCapture = NoAdditionalCapture.Checked; if (captureAmount > 0) { _Payment.Capture(captureAmount, finalCapture, false); if (!string.IsNullOrEmpty(CustomerNote.Text)) { OrderNote note = new OrderNote(_Order.Id, AbleContext.Current.UserId, DateTime.UtcNow, CustomerNote.Text, NoteType.Public); note.Save(); } } Response.Redirect("Default.aspx?OrderNumber=" + _Order.OrderNumber.ToString()); }
protected void SubmitVoidButton_Click(object sender, EventArgs e) { _Payment.Void(); if (!string.IsNullOrEmpty(CustomerNote.Text)) { OrderNote note = new OrderNote(_Order.Id, AbleContext.Current.UserId, DateTime.UtcNow, CustomerNote.Text, NoteType.Public); note.Save(); } Response.Redirect("Default.aspx?OrderNumber=" + _Order.OrderNumber.ToString()); }
protected void EditButton_Click(object sender, EventArgs e) { int orderNoteId = AlwaysConvert.ToInt(EditId.Value); OrderNote n = OrderNoteDataSource.Load(orderNoteId); if (n != null && !string.IsNullOrEmpty(EditComment.Text)) { n.Comment = EditComment.Text; n.NoteType = EditIsPrivate.Checked ? NoteType.Private : NoteType.Public; n.IsRead = EditIsRead.Checked; n.Save(); BindOrderNotes(); } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { if(!string.IsNullOrEmpty(txtNote.Text)) { try { OrderNote orderNote = new OrderNote(); orderNote.OrderId = orderId; orderNote.Note = txtNote.Text.Trim(); orderNote.Save(WebUtility.GetUserName()); LoadOrderNotes(); txtNote.Text = string.Empty; base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblOrderNoteSaved")); } catch(Exception ex) { Logger.Error(typeof(notes).Name + ".btnSave_Click", ex); base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message); } } }
protected void btnAddNote_Click1(object sender, EventArgs e) { if (txtAddNote.Text.Trim().Length > 0) { try { OrderNote note = new OrderNote(); note.OrderID = int.Parse(lblOrderID.Text); note.OrderStatus = ddlStatusID.SelectedItem.Text; note.Note = txtAddNote.Text; note.Save(Utility.GetUserName()); LoadOrder(); txtAddNote.Text = string.Empty; } catch (Exception ex) { uResult.ShowFail(ex.Message); } } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtNote.Text)) { try { OrderNote orderNote = new OrderNote(); orderNote.OrderId = orderId; orderNote.Note = txtNote.Text.Trim(); orderNote.Save(WebUtility.GetUserName()); LoadOrderNotes(); txtNote.Text = string.Empty; base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblOrderNoteSaved")); } catch (Exception ex) { Logger.Error(typeof(notes).Name + ".btnSave_Click", ex); base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message); } } }
protected void SubmitRefundButton_Click(object sender, EventArgs e) { //GET THE REFUND AMOUNT string originalRefundAmount = string.Format("{0:F2}", _Payment.Amount); decimal refundAmount = AlwaysConvert.ToDecimal(RefundAmount.Text); // AC8-2854, AC8-3117: IF amount is not changed by merchant then // to avoid rounding issues, restore the original amount upto 4 decimal digits if (originalRefundAmount == RefundAmount.Text) { refundAmount = _Payment.Amount; } if (refundAmount > 0 && _Payment.PaymentStatus == PaymentStatus.Captured) { RefundTransactionRequest refundRequest = new RefundTransactionRequest(_Payment, Request.UserHostAddress); if (CreditCardFields.Visible) { SetRequestForCreditCard(refundRequest); } else if (CheckFields.Visible) { SetRequestForCheck(refundRequest); } refundRequest.Amount = refundAmount; PaymentEngine.DoRefund(refundRequest); //_Payment.Refund(refundRequest); if (!string.IsNullOrEmpty(CustomerNote.Text)) { OrderNote note = new OrderNote(_Order.Id, AbleContext.Current.UserId, DateTime.UtcNow, CustomerNote.Text, NoteType.Public); note.Save(); } } Response.Redirect("Default.aspx?OrderNumber=" + _Order.OrderNumber.ToString()); }
public void Insert(int OrderId,string Note,string CreatedBy,DateTime CreatedOn,string ModifiedBy,DateTime ModifiedOn) { OrderNote item = new OrderNote(); item.OrderId = OrderId; item.Note = Note; item.CreatedBy = CreatedBy; item.CreatedOn = CreatedOn; item.ModifiedBy = ModifiedBy; item.ModifiedOn = ModifiedOn; item.Save(UserName); }
/// <summary> /// Charges the specified order. /// </summary> /// <param name="order">The order.</param> /// <param name="userName">Name of the user.</param> /// <returns></returns> public static Transaction Charge(Order order, string userName) { //update the order with IP order.IPAddress = HttpContext.Current.Request.UserHostAddress; PaymentService paymentService = new PaymentService(); Transaction transaction = paymentService.Charge(order); order.OrderStatusDescriptorId = (int)OrderStatus.ReceivedPaymentProcessingOrder; order.OrderTypeId = (int)OrderType.Purchase; order.Save(userName); Guid userGuid = new Guid(Membership.GetUser(userName).ProviderUserKey.ToString()); try { //Add an OrderNote OrderNote orderNote = new OrderNote(); orderNote.OrderId = order.OrderId; orderNote.Note = Strings.ResourceManager.GetString(ORDER_CHARGED); orderNote.Save(userName); Sku sku; DownloadCollection downloadCollection; DownloadAccessControlCollection downloadAccessControlCollection; DownloadAccessControl downloadAccessControl; foreach (OrderItem orderItem in order.OrderItemCollection) { //Adjust the Inventory sku = new Sku(SKU, orderItem.Sku); sku.Inventory = sku.Inventory - orderItem.Quantity; sku.Save(SYSTEM); ProductCache.RemoveSKUFromCache(orderItem.Sku); //Add access control for orderitems downloadCollection = new ProductController().FetchAssociatedDownloadsByProductIdAndForPurchase(orderItem.ProductId); if (downloadCollection.Count > 0) { foreach (Download download in downloadCollection) { Query query = new Query(DownloadAccessControl.Schema). AddWhere(DownloadAccessControl.Columns.UserId, Comparison.Equals, userGuid). AddWhere(DownloadAccessControl.Columns.DownloadId, Comparison.Equals, download.DownloadId); downloadAccessControlCollection = new DownloadAccessControlController().FetchByQuery(query); if (downloadAccessControlCollection.Count == 0) { downloadAccessControl = new DownloadAccessControl(); downloadAccessControl.DownloadId = download.DownloadId; downloadAccessControl.UserId = userGuid; downloadAccessControl.Save(SYSTEM); } } } } //Send out the messages //Send these last in case something happens with the email MessageService messageService = new MessageService(); messageService.SendOrderReceivedNotificationToCustomer(order); messageService.SendOrderReceivedNotificationToMerchant(order); } catch (Exception ex) { //swallow the exception here because the transaction is saved //and, while this is an inconvenience, it's not critical Logger.Error(typeof(OrderController).Name + ".Charge", ex); } return transaction; }
/// <summary> /// Refunds the specified transaction. /// </summary> /// <param name="transaction">The transaction.</param> /// <param name="refundedOrder">The refunded order.</param> /// <param name="userName">Name of the user.</param> public static void RefundStandard(Transaction transaction, Order refundedOrder, string userName) { Order order = new Order(transaction.OrderId); Transaction refundTransaction = new Transaction(); //refundTransaction.OrderId = transaction.OrderId; refundTransaction.TransactionTypeDescriptorId = (int)TransactionType.Refund; refundTransaction.PaymentMethod = PAYPAL; refundTransaction.GatewayName = PAYPAL_STANDARD; refundTransaction.GatewayResponse = SUCCESS; refundTransaction.GatewayTransactionId = CoreUtility.GenerateRandomString(16); refundTransaction.GrossAmount = refundedOrder.Total; refundTransaction.NetAmount = 0.00M; refundTransaction.FeeAmount = 0.00M; refundTransaction.TransactionDate = DateTime.Now; //refundTransaction.Save(userName); refundedOrder.Save(userName); //set the orderid for the refund foreach(OrderItem orderItem in refundedOrder.OrderItemCollection) { orderItem.OrderId = refundedOrder.OrderId; } refundedOrder.OrderItemCollection.SaveAll(userName); //set the orderId to the refunded orderId refundTransaction.OrderId = refundedOrder.OrderId; refundTransaction.Save(userName); Guid userGuid = new Guid(Membership.GetUser(order.UserName).ProviderUserKey.ToString()); DownloadCollection downloadCollection; foreach(OrderItem orderItem in refundedOrder.OrderItemCollection) { //put the stock back Sku sku = new Sku(Sku.Columns.SkuX, orderItem.Sku); sku.Inventory = sku.Inventory + orderItem.Quantity; sku.Save(userName); ProductCache.RemoveSKUFromCache(orderItem.Sku); //remove the access control downloadCollection = new ProductController().FetchAssociatedDownloadsByProductIdAndForPurchase(orderItem.ProductId); if (downloadCollection.Count > 0) { foreach (Download download in downloadCollection) { new DownloadAccessControlController().Delete(userGuid, download.DownloadId); } } } if(refundedOrder.Total == order.Total) { order.OrderStatusDescriptorId = (int)OrderStatus.OrderFullyRefunded; } else { order.OrderStatusDescriptorId = (int)OrderStatus.OrderPartiallyRefunded; } order.Save(userName); //Add an OrderNote OrderNote orderNote = new OrderNote(); orderNote.OrderId = order.OrderId; orderNote.Note = Strings.ResourceManager.GetString(ORDER_REFUNDED); orderNote.Save(userName); //send off the notifications MessageService messageService = new MessageService(); messageService.SendOrderRefundToCustomer(refundedOrder); }
/// <summary> /// Refunds the specified transaction. /// </summary> /// <param name="transaction">The transaction.</param> /// <param name="refundedOrder">The order the refund should be applied to.</param> /// <param name="userName">Name of the user.</param> public static void Refund(Transaction transaction, Order refundedOrder, string userName) { Order order = new Order(transaction.OrderId); PaymentService paymentService = new PaymentService(); Transaction refundTransaction = paymentService.Refund(transaction, refundedOrder); refundedOrder.Save(userName); //set the orderid for the refund foreach(OrderItem orderItem in refundedOrder.OrderItemCollection) { orderItem.OrderId = refundedOrder.OrderId; } refundedOrder.OrderItemCollection.SaveAll(userName); //set the orderId to the refunded orderId refundTransaction.OrderId = refundedOrder.OrderId; refundTransaction.Save(userName); Guid userGuid = new Guid(Membership.GetUser(order.UserName).ProviderUserKey.ToString()); foreach(OrderItem orderItem in refundedOrder.OrderItemCollection) { new Product(orderItem.ProductId); //put the stock back Sku sku = new Sku(Sku.Columns.SkuX, orderItem.Sku); sku.Inventory = sku.Inventory + orderItem.Quantity; sku.Save(userName); ProductCache.RemoveSKUFromCache(orderItem.Sku); //remove the access control DownloadCollection downloadCollection = new ProductController().FetchAssociatedDownloadsByProductIdAndForPurchase(orderItem.ProductId); if (downloadCollection.Count > 0) { foreach (Download download in downloadCollection) { new DownloadAccessControlController().Delete(userGuid, download.DownloadId); } } } if(refundedOrder.Total == order.Total) { order.OrderStatusDescriptorId = (int)OrderStatus.OrderFullyRefunded; } else { order.OrderStatusDescriptorId = (int)OrderStatus.OrderPartiallyRefunded; } order.Save(userName); //Add an OrderNote OrderNote orderNote = new OrderNote(); orderNote.OrderId = order.OrderId; orderNote.Note = Strings.ResourceManager.GetString(ORDER_REFUNDED); orderNote.Save(userName); //send off the notifications MessageService messageService = new MessageService(); messageService.SendOrderRefundToCustomer(refundedOrder); }