/// <summary>
 /// Fetch by order id and transaction type id.
 /// </summary>
 /// <param name="orderId">The order id.</param>
 /// <param name="transactionTypeId">The transaction type id.</param>
 /// <returns></returns>
 public Transaction FetchByOrderIdAndTransactionTypeId(int orderId, int transactionTypeId)
 {
     Transaction transaction = null;
       Query query = new Query(Transaction.Schema).
     AddWhere(Transaction.Columns.OrderId, orderId).
     AddWhere(Transaction.Columns.TransactionTypeDescriptorId, transactionTypeId);
       TransactionCollection transactionCollection = new TransactionController().FetchByQuery(query);
       if(transactionCollection.Count > 1) {
     throw new InvalidOperationException(TOO_MANY_TRANSACTIONS);
       }
       if(transactionCollection.Count > 0) {
     transaction = transactionCollection[0];
       }
       return transaction;
 }
 /// <summary>
 /// Handles the Load event of the Page 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 Page_Load(object sender, EventArgs e)
 {
     try {
     orderId = Utility.GetIntParameter("orderId");
     view = Utility.GetParameter("view");
     if(orderId > 0 && view == "t") {
       SetTransactionProperties();
       TransactionCollection transactionCollection = new TransactionController().FetchByOrderId(orderId);
       rptrTransactions.DataSource = transactionCollection;
       rptrTransactions.ItemDataBound += new RepeaterItemEventHandler(rptrTransactions_ItemDataBound);
       rptrTransactions.DataBind();
     }
       }
       catch(Exception ex) {
     Logger.Error(typeof(transaction).Name + ".Page_Load", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Example #3
0
        /// <summary>
        /// Fetch by order id and transaction type id.
        /// </summary>
        /// <param name="orderId">The order id.</param>
        /// <param name="transactionTypeId">The transaction type id.</param>
        /// <returns></returns>
        public Transaction FetchByOrderIdAndTransactionTypeId(int orderId, int transactionTypeId)
        {
            Transaction transaction = null;
            Query       query       = new Query(Transaction.Schema).
                                      AddWhere(Transaction.Columns.OrderId, orderId).
                                      AddWhere(Transaction.Columns.TransactionTypeDescriptorId, transactionTypeId);
            TransactionCollection transactionCollection = new TransactionController().FetchByQuery(query);

            if (transactionCollection.Count > 1)
            {
                throw new InvalidOperationException(TOO_MANY_TRANSACTIONS);
            }
            if (transactionCollection.Count > 0)
            {
                transaction = transactionCollection[0];
            }
            return(transaction);
        }
Example #4
0
        /// <summary>
        /// Handles the Load event of the Page 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 Page_Load(object sender, EventArgs e)
        {
            try {
            orderId = Utility.GetIntParameter("orderId");
            view = Utility.GetParameter("view");
            if(orderId > 0 && view == "a") {
              SetActionsProperties();
              if(!Page.IsPostBack) {
            Order order = new Order(orderId);
            ds = new OrderController().FetchRefundedOrderItems(orderId);
            Transaction transaction = new TransactionController().FetchByOrderIdAndTransactionTypeId(orderId, (int)TransactionType.Charge);

            if(transaction.GatewayName == "PayPal Standard") {
              lblActionMessage.Text = LocalizationUtility.GetText("lblPayPalStandardRefundInstructions");
            }

            if(order.OrderStatusDescriptorId == (int)OrderStatus.OrderFullyRefunded) {
              btnRefundTransaction.Visible = false;
              lblAdditionalRefundAmount.Visible = false;
              txtAdditionalRefundAmount.Visible = false;
              dgOrderItems.Visible = false;
            }
            else {
              dgOrderItems.DataSource = order.OrderItemCollection;
              dgOrderItems.ItemDataBound += new DataGridItemEventHandler(dgOrderItems_ItemDataBound);
              dgOrderItems.Columns[1].HeaderText = LocalizationUtility.GetText("hdrRefund");
              dgOrderItems.Columns[2].HeaderText = LocalizationUtility.GetText("hdrSku");
              dgOrderItems.Columns[3].HeaderText = LocalizationUtility.GetText("hdrQuantityRemaining");
              dgOrderItems.Columns[4].HeaderText = LocalizationUtility.GetText("hdrName");
              dgOrderItems.Columns[5].HeaderText = LocalizationUtility.GetText("hdrPricePaid");
              dgOrderItems.Columns[6].HeaderText = LocalizationUtility.GetText("hdrItemTax");
              dgOrderItems.Columns[7].HeaderText = LocalizationUtility.GetText("hdrDiscountAmount");
              dgOrderItems.DataBind();
            }

            OrderStatusDescriptorCollection orderStatusDescriptorCollection = new OrderStatusDescriptorController().FetchAll();
            ddlOrderStatus.DataSource = orderStatusDescriptorCollection;
            ddlOrderStatus.DataValueField = "OrderStatusDescriptorId";
            ddlOrderStatus.DataTextField = "Name";
            ddlOrderStatus.DataBind();

            ddlOrderStatus.SelectedValue = order.OrderStatusDescriptorId.ToString();
              }
            }
              }
              catch(Exception ex) {
            Logger.Error(typeof(actions).Name + ".Page_Load", ex);
            base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
              }
        }
Example #5
0
 /// <summary>
 /// Handles the Click event of the btnRefundTransaction 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 btnRefundTransaction_Click(object sender, EventArgs e)
 {
     try {
     if (Page.IsValid) {
       TextBox txtRefundQuantity = null;
       Order order = new Order(orderId);
       OrderItem orderItem = null;
       OrderItem refundedOrderItem = null;
       Order refundOrder = new Order(order, WebUtility.GetUserName());
       foreach (DataGridItem item in dgOrderItems.Items) {
     txtRefundQuantity = item.Cells[0].FindControl("txtRefundQuantity") as TextBox;
     if (txtRefundQuantity != null) {
       int quantity = 0;
       bool isParsed = int.TryParse(txtRefundQuantity.Text, out quantity);
       if (isParsed) {
         orderItem = new OrderItem(item.Cells[0].Text);
         refundedOrderItem = new OrderItem();
         //refundedOrderItem.OrderId = orderItem.OrderId;
         refundedOrderItem.ProductId = orderItem.ProductId;
         refundedOrderItem.Name = orderItem.Name;
         refundedOrderItem.Sku = orderItem.Sku;
         refundedOrderItem.Quantity = quantity;
         refundedOrderItem.PricePaid = orderItem.PricePaid;
         refundedOrderItem.Attributes = orderItem.Attributes;
         refundedOrderItem.Weight = orderItem.Weight;
         refundedOrderItem.ItemTax = orderItem.ItemTax;
         refundedOrderItem.DiscountAmount = orderItem.DiscountAmount;
         refundOrder.OrderItemCollection.Add(refundedOrderItem);
       }
     }
       }
       decimal additionalRefundAmount = 0;
       decimal.TryParse(txtAdditionalRefundAmount.Text, out additionalRefundAmount);
       refundOrder.ShippingAmount = additionalRefundAmount;
       Transaction transaction = new TransactionController().FetchByOrderIdAndTransactionTypeId(orderId, (int)TransactionType.Charge);
       if (transaction.GatewayName == "PayPal Standard") {
     OrderController.RefundStandard(transaction, refundOrder, WebUtility.GetUserName());
       }
       else {
     OrderController.Refund(transaction, refundOrder, WebUtility.GetUserName());
       }
       base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblOrderRefunded"));
     }
       }
       catch (PaymentServiceException pse) {
     Logger.Error(typeof(actions).Name + ".btnRefundTransaction_Click", pse);
     base.MasterPage.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetPaymentProviderErrorText(pse.Message));
       }
       catch (Exception ex) {
     Logger.Error(typeof(actions).Name + ".btnRefundTransaction_Click", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }