Ejemplo n.º 1
0
 protected void btnGetGatewayStatus_Click(object sender, EventArgs e)
 {
     try
     {
         txtResults.Text             = "";
         btnGetGatewayStatus.Enabled = false;
         RecurringOrderMgr rmgr = new RecurringOrderMgr();
         btnProcessFile.Visible = true;
         btnProcessFile.Enabled = true;
         String sResults = String.Empty;
         String Status   = rmgr.GetAutoBillStatusFile(RecurringGateway, out sResults);
         if (Status == AppLogic.ro_OK)
         {
             txtInputFile.Text = sResults;
         }
         else
         {
             txtInputFile.Text = Status;
         }
     }
     catch (Exception exception)
     {
         SysLog.LogException(exception, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);
     }
 }
Ejemplo n.º 2
0
        protected void btnStopBilling_Click(Object sender, EventArgs e)
        {
            try
            {
                var originalOrder         = new Order(OriginalRecurringOrderNumber);
                var recurringOrderManager = new RecurringOrderMgr();

                var result = string.Empty;

                if (originalOrder.PaymentMethod == AppLogic.ro_PMPayPalExpress &&
                    PayPalController.GetAppropriateExpressType() == ExpressAPIType.PayPalExpress)
                {
                    result = recurringOrderManager.CancelPPECRecurringOrder(originalOrder.OrderNumber, false);
                }
                else
                {
                    result = recurringOrderManager.CancelRecurringOrder(originalOrder.OrderNumber);
                }

                if (result == AppLogic.ro_OK)
                {
                    AlertMessage.PushAlertMessage("admin.recurringorder.OrderCancelSuccess".StringResource(), AspDotNetStorefrontControls.AlertMessage.AlertType.Success);
                }
                else
                {
                    AlertMessage.PushAlertMessage(result, AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
                }
            }
            catch (Exception ex)
            {
                AlertMessage.PushAlertMessage(ex.Message, AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
            }
        }
Ejemplo n.º 3
0
            public UpdateRecurringOrderResult UpdateRecurringOrder(int recurringOrderId, Address address, CreditCardViewModel creditCard, Customer customer)
            {
                if (creditCard != null && customer.MasterShouldWeStoreCreditCardInfo)
                {
                    address.PaymentMethodLastUsed = AppLogic.ro_PMCreditCard;
                    address.CardName            = creditCard.Name;
                    address.CardType            = creditCard.CardType;
                    address.CardNumber          = creditCard.Number;
                    address.CardExpirationMonth = creditCard.ExpirationMonth.ToString();
                    address.CardExpirationYear  = creditCard.ExpirationYear.ToString();
                    address.CardIssueNumber     = creditCard.CardIssueNumber;
                    address.CardStartDate       = string.Format("{0:00}{1:0000}",
                                                                creditCard.CardStartMonth,
                                                                creditCard.CardStartYear);
                }

                address.UpdateDB();

                var recurringOrderManager = new RecurringOrderMgr();
                var result = recurringOrderManager
                             .ProcessAutoBillAddressUpdate(recurringOrderId, address);

                if (result == AppLogic.ro_OK)
                {
                    return(new UpdateRecurringOrderResult());
                }
                else
                {
                    return(new UpdateRecurringOrderResult(RecurringOrderActionStatus.Failure, result));
                }
            }
Ejemplo n.º 4
0
            public DeleteRecurringOrderResult DeleteRecurringOrder(Order order)
            {
                var recurringOrderManager = new RecurringOrderMgr();
                var expressApiType        = PayPalController.GetAppropriateExpressType();

                var result = string.Empty;

                if (order.PaymentMethod == AppLogic.ro_PMPayPalExpress && expressApiType == ExpressAPIType.PayPalExpress)
                {
                    result = recurringOrderManager.CancelPPECRecurringOrder(order.OrderNumber, false);
                }
                else
                {
                    result = recurringOrderManager.CancelRecurringOrder(order.OrderNumber);
                }

                if (result == AppLogic.ro_OK)
                {
                    return(new DeleteRecurringOrderResult());
                }
                else
                {
                    return(new DeleteRecurringOrderResult(RecurringOrderActionStatus.Failure, result));
                }
            }
Ejemplo n.º 5
0
        protected void btnProcessAll_Click(object sender, EventArgs e)
        {
            var output            = new StringBuilder();
            var recurringOrderMgr = new RecurringOrderMgr();

            using (var connection = new SqlConnection(DB.GetDBConn()))
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "Select distinct(OriginalRecurringOrderNumber) from ShoppingCart where RecurringSubscriptionID='' and CartType = @cartType and NextRecurringShipDate < dateadd(d,1,getDate())";
                    command.Parameters.AddWithValue("@cartType", (int)CartTypeEnum.RecurringCart);

                    connection.Open();
                    using (var reader = command.ExecuteReader())
                        while (reader.Read())
                        {
                            output.AppendFormat(
                                AppLogic.GetString("admin.recurring.ProcessingNextOccurrence"),
                                reader.FieldInt("OriginalRecurringOrderNumber"));
                            output.Append(recurringOrderMgr.ProcessRecurringOrder(reader.FieldInt("OriginalRecurringOrderNumber")));
                            output.Append("...<br/>");
                        }
                }

            AlertMessage.PushAlertMessage(
                output.ToString(),
                AspDotNetStorefrontControls.AlertMessage.AlertType.Info);
        }
Ejemplo n.º 6
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // This file is only implemented for Authorize.net Automated Recurring Billing
            if (CommonLogic.FormCanBeDangerousContent("x_subscription_id").Length != 0)
            {
                String   TxSubID  = CommonLogic.FormCanBeDangerousContent("x_subscription_id");
                String   TxStatus = CommonLogic.FormCanBeDangerousContent("x_response_code");
                String   TxMsg    = CommonLogic.FormCanBeDangerousContent("x_response_reason_text");
                String   TxID     = CommonLogic.FormCanBeDangerousContent("x_trans_id");
                String   TxAmount = CommonLogic.FormCanBeDangerousContent("x_amount");
                DateTime dtTx     = System.DateTime.Now;

                String tmpStatus = String.Empty;

                int OrigOrdNumber = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(TxSubID);

                if (OrigOrdNumber == 0)
                {
                    tmpStatus = "Silent Post: No Original Order Found";
                    if (TxID.Length != 0)
                    {
                        tmpStatus += ", PNREF=" + TxID;
                    }
                    DB.ExecuteSQL("insert into FailedTransaction(CustomerID,OrderNumber,IPAddress,OrderDate,PaymentGateway,PaymentMethod,TransactionCommand,TransactionResult,CustomerEMailed,RecurringSubscriptionID) values(" +
                                  "0,0,'0.0.0.0'," + DB.DateQuote(dtTx) + "," + DB.SQuote("AUTHORIZENET") + "," +
                                  DB.SQuote(AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()) + "," + DB.SQuote(AppLogic.ro_NotApplicable) + "," + DB.SQuote(tmpStatus) + ",0," + DB.SQuote(TxSubID) + ")");
                }
                else
                {
                    if (TxStatus == "1") // Approved
                    {
                        int NewOrderNumber     = 0;
                        RecurringOrderMgr rmgr = new RecurringOrderMgr(AppLogic.MakeEntityHelpers(), null);
                        tmpStatus = rmgr.ProcessAutoBillApproved(OrigOrdNumber, TxID, dtTx, out NewOrderNumber);
                    }
                    else
                    {
                        RecurringOrderMgr rmgr = new RecurringOrderMgr(AppLogic.MakeEntityHelpers(), null);
                        tmpStatus = rmgr.ProcessAutoBillDeclined(OrigOrdNumber, TxID, dtTx, TxSubID, TxMsg);
                    }

                    if (tmpStatus != AppLogic.ro_OK)
                    {
                        int      ProcessCustomerID = Order.GetOrderCustomerID(OrigOrdNumber);
                        Customer ProcessCustomer   = new Customer(ProcessCustomerID, true);

                        if (TxID.Length != 0)
                        {
                            tmpStatus += ", PNREF=" + TxID;
                        }
                        DB.ExecuteSQL("insert into FailedTransaction(CustomerID,OrderNumber,IPAddress,OrderDate,PaymentGateway,PaymentMethod,TransactionCommand,TransactionResult,CustomerEMailed,RecurringSubscriptionID) values(" +
                                      ProcessCustomer.CustomerID.ToString() + "," + OrigOrdNumber.ToString() + "," +
                                      DB.SQuote("0.0.0.0") + "," + DB.DateQuote(dtTx) + "," + DB.SQuote("AUTHORIZENET") + "," +
                                      DB.SQuote(AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()) + "," + DB.SQuote(AppLogic.ro_NotApplicable) + "," + DB.SQuote(tmpStatus) + ",0," + DB.SQuote(TxSubID) + ")");
                    }
                }
            }
            Response.Write("OK");
        }
Ejemplo n.º 7
0
        protected void btnProcess_Click(Object sender, EventArgs e)
        {
            if (OriginalRecurringOrderNumber != 0)
            {
                RecurringOrderMgr orderMgr = new RecurringOrderMgr();
                string            message  = orderMgr.ProcessRecurringOrder(OriginalRecurringOrderNumber);

                AlertMessage.PushAlertMessage(message, (message == AppLogic.ro_OK)
                                        ? AspDotNetStorefrontControls.AlertMessage.AlertType.Success
                                        : AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
            }
        }
Ejemplo n.º 8
0
        protected void btnProcessFile_Click(object sender, EventArgs e)
        {
            txtResults.Visible = true;

            if (RecurringGateway == Gateway.ro_GWPAYFLOWPRO)
            {
                btnProcessFile.Enabled = false;
            }

            DateTime dtRun = LastImportDate;

            if (dtRun == System.DateTime.MinValue)
            {
                dtRun = DateTime.Today.AddDays(-1);                 // Defaults to yesterday
            }

            if (dtRun >= DateTime.Today &&
                (RecurringGateway == Gateway.ro_GWPAYFLOWPRO))
            {
                txtInputFile.Text           = AppLogic.GetString("admin.recurringimport.NothingToProcess", SkinID, LocaleSetting);
                btnGetGatewayStatus.Enabled = false;
                return;
            }

            if (txtInputFile.Text.Length == 0)
            {
                txtResults.Text = AppLogic.GetString("admin.recurringimport.NothingToProcessForget", SkinID, LocaleSetting);
            }
            else
            {
                RecurringOrderMgr rmgr     = new RecurringOrderMgr();
                String            sResults = String.Empty;
                String            Status   = rmgr.ProcessAutoBillStatusFile(RecurringGateway, txtInputFile.Text, out sResults);
                if (Status == AppLogic.ro_OK)
                {
                    txtResults.Text = sResults;
                }
                else
                {
                    txtResults.Text = Status;
                }
            }

            btnGetGatewayStatus.Enabled = true;
            AppConfigManager.SetAppConfigValue("Recurring.GatewayLastImportedDate", Localization.ToDBDateTimeString(DateTime.Now));
            LastRunPanel.Visible = true;
            lblLastRun.Text      = String.Format(AppLogic.GetString("admin.recurringimport.LastImport", SkinID, LocaleSetting), Localization.ToThreadCultureShortDateString(dtRun));
            LastImportDate       = dtRun;
        }
        protected String GetGatewayStatus()
        {
            String sResults = String.Empty;

            RecurringOrderMgr rmgr   = new RecurringOrderMgr(AppLogic.MakeEntityHelpers(), null);
            String            Status = rmgr.GetAutoBillStatusFile(m_GW, out sResults);

            if (Status == AppLogic.ro_OK)
            {
                return(sResults);
            }
            else
            {
                return(String.Empty);
            }
        }
Ejemplo n.º 10
0
        public void CreateNewPPECRecurrence()
        {
            int originalOrderNumber = GetPPECOriginalOrderNumber();

            if (originalOrderNumber != 0)
            {
                RecurringOrderMgr manager = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                manager.ProcessPPECRecurringOrder(originalOrderNumber);
            }
            else
            {
                SysLog.LogMessage("A recurring payment notification came from PayPal Express that did not match an existing recurring order.",
                                  "PayerID = " + payerID + ", ProfileID = " + profileID,
                                  MessageTypeEnum.Informational,
                                  MessageSeverityEnum.Alert);
            }
        }
Ejemplo n.º 11
0
        void CreateNewPPECRecurrence(string payerId, string profileId, string subscriptionId)
        {
            var originalOrderNumber = GetPPECOriginalOrderNumber(profileId, subscriptionId);

            if (originalOrderNumber != 0)
            {
                var manager = new RecurringOrderMgr();
                manager.ProcessPPECRecurringOrder(originalOrderNumber);
            }
            else
            {
                SysLog.LogMessage("A recurring payment notification came from PayPal Express that did not match an existing recurring order.",
                                  string.Format("PayerID = {0}, ProfileID = {1}", payerId, profileId),
                                  MessageTypeEnum.Informational,
                                  MessageSeverityEnum.Alert);
            }
        }
        protected String ProcessData(String StatusXML)
        {
            String result = String.Empty;

            DateTime dtRun = dtLastRun;

            if (dtRun == System.DateTime.MinValue)
            {
                dtRun = DateTime.Today.AddDays((double)-1); // Defaults to yesterday
            }
            else
            {
                if (m_GW == Gateway.ro_GWVERISIGN || m_GW == Gateway.ro_GWPAYFLOWPRO)
                {
                    dtRun = DateTime.Today.AddDays((double)-1); // Always runs through yesterday
                }
                else
                {
                    dtRun = dtLastRun.AddDays((double)1.0); // other gateways default to one day period
                }
            }

            if (StatusXML.Length == 0 || !StatusXML.Contains("<TX "))
            {
                result = "Nothing to process... No new data.";
            }
            else
            {
                RecurringOrderMgr rmgr     = new RecurringOrderMgr(AppLogic.MakeEntityHelpers(), null);
                String            sResults = String.Empty;
                String            Status   = rmgr.ProcessAutoBillStatusFile(m_GW, StatusXML, out sResults);
                if (Status == AppLogic.ro_OK)
                {
                    result = sResults;
                }
                else
                {
                    result = Status;
                }
            }

            AppLogic.SetAppConfig("Recurring.GatewayLastImportedDate", Localization.ToDBDateTimeString(dtRun));

            return(result);
        }
Ejemplo n.º 13
0
        protected void btnGetGatewayStatus_Click(object sender, EventArgs e)
        {
            txtResults.Text             = "";
            btnGetGatewayStatus.Enabled = false;
            RecurringOrderMgr rmgr = new RecurringOrderMgr(AppLogic.MakeEntityHelpers(), null);

            btnProcessFile.Visible = true;
            btnProcessFile.Enabled = true;
            String sResults = String.Empty;
            String Status   = rmgr.GetAutoBillStatusFile(m_GW, out sResults);

            if (Status == AppLogic.ro_OK)
            {
                txtInputFile.Text = sResults;
            }
            else
            {
                txtInputFile.Text = Status;
            }
        }
Ejemplo n.º 14
0
        public void CancelPPECRecurringSubscription()
        {
            int originalOrderNumber = GetPPECOriginalOrderNumber();

            if (originalOrderNumber != 0)
            {
                // Cancelling through the API triggers a notification to this page.  Make sure we don't try to cancel the same order repeatedly.
                if (PPECRecurringOrderIsStillActive(originalOrderNumber))
                {
                    RecurringOrderMgr manager = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                    manager.CancelPPECRecurringOrder(originalOrderNumber, true);
                }
            }
            else
            {
                SysLog.LogMessage("A recurring payment cancellation notification came from PayPal Express that did not match an existing recurring order.",
                                  "PayerID = " + payerID + ", ProfileID = " + profileID,
                                  MessageTypeEnum.Informational,
                                  MessageSeverityEnum.Alert);
            }
        }
Ejemplo n.º 15
0
        void CancelPPECRecurringSubscription(string payerId, string profileId, string subscriptionId)
        {
            var originalOrderNumber = GetPPECOriginalOrderNumber(profileId, subscriptionId);

            if (originalOrderNumber != 0)
            {
                // Cancelling through the API triggers a notification to this page.  Make sure we don't try to cancel the same order repeatedly.
                if (PPECRecurringOrderIsStillActive(originalOrderNumber))
                {
                    var manager = new RecurringOrderMgr();
                    manager.CancelPPECRecurringOrder(originalOrderNumber, true);
                }
            }
            else
            {
                SysLog.LogMessage("A recurring payment cancellation notification came from PayPal Express that did not match an existing recurring order.",
                                  string.Format("PayerID = {0}, ProfileID = {1}", payerId, profileId),
                                  MessageTypeEnum.Informational,
                                  MessageSeverityEnum.Alert);
            }
        }
        private void CancelRecurringOrder(Order thisOrder)
        {
            var autoBillStatus   = string.Empty;
            var recurringManager = new RecurringOrderMgr();

            if (thisOrder.ParentOrderNumber == 0)
            {
                autoBillStatus = recurringManager.CancelRecurringOrder(orderNumber);
            }
            else
            {
                autoBillStatus = recurringManager.CancelRecurringOrder(thisOrder.ParentOrderNumber);
            }


            if (autoBillStatus == AppLogic.ro_OK)
            {
                AlertMessageDisplayAutoBillStatus.PushAlertMessage("Cancel Auto-Bill Status: " + autoBillStatus, AlertMessage.AlertType.Success);
            }
            else
            {
                AlertMessageDisplayAutoBillStatus.PushAlertMessage("Cancel Auto-Bill Failed: " + autoBillStatus, AlertMessage.AlertType.Error);
            }
        }
Ejemplo n.º 17
0
        public ActionResult AuthorizeNetSilentPost(FormCollection collection)
        {
            var subscriptionId  = collection["x_subscription_id"] ?? string.Empty;
            var responseCode    = collection["x_response_code"] ?? string.Empty;
            var responseReason  = collection["x_response_reason_text"] ?? string.Empty;
            var transactionId   = collection["x_trans_id"] ?? string.Empty;
            var amount          = collection["x_amount"] ?? string.Empty;
            var transactionDate = DateTime.Now;

            if (string.IsNullOrEmpty(subscriptionId))
            {
                return(Content(string.Empty));
            }

            var originalOrderId = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(subscriptionId);
            var status          = string.Empty;

            if (originalOrderId == 0)
            {
                status = "Silent Post: No Original Order Found";
                if (!string.IsNullOrEmpty(transactionId))
                {
                    status += ", PNREF=" + transactionId;
                }

                DB.ExecuteSQL(@"INSERT INTO FailedTransaction(CustomerID, 
															OrderNumber, 
															IPAddress, 
															OrderDate, 
															PaymentGateway, 
															PaymentMethod, 
															TransactionCommand, 
															TransactionResult, 
															CustomerEMailed, 
															RecurringSubscriptionID) 
								VALUES(0, 0, @ipAddress, @transactionDate, @gateway, @paymentMethod, @command, @status, 0, @subscriptionId)"                                ,
                              new SqlParameter[]
                {
                    new SqlParameter("@ipAddress", "0.0.0.0"),
                    new SqlParameter("@transactionDate", transactionDate),
                    new SqlParameter("@gateway", "AUTHORIZENET"),
                    new SqlParameter("@paymentMethod", AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()),
                    new SqlParameter("@command", AppLogic.ro_NotApplicable),
                    new SqlParameter("@status", status),
                    new SqlParameter("@subscriptionId", subscriptionId),
                }
                              );
            }
            else
            {
                if (responseCode.Equals("1"))                // Approved
                {
                    var newOrderNumber = 0;
                    var manager        = new RecurringOrderMgr();
                    status = manager.ProcessAutoBillApproved(originalOrderId, transactionId, transactionDate, out newOrderNumber);
                }
                else
                {
                    var manager = new RecurringOrderMgr();
                    status = manager.ProcessAutoBillDeclined(originalOrderId, transactionId, transactionDate, subscriptionId, responseReason);
                }

                if (status.Equals(AppLogic.ro_OK, StringComparison.InvariantCultureIgnoreCase))
                {
                    var customerId = Order.GetOrderCustomerID(originalOrderId);
                    var customer   = new Customer(customerId, true);

                    if (!string.IsNullOrEmpty(transactionId))
                    {
                        status += ", PNREF=" + transactionId;
                    }

                    DB.ExecuteSQL(@"INSERT INTO FailedTransaction(CustomerID, 
																	OrderNumber, 
																	IPAddress, 
																	OrderDate, 
																	PaymentGateway, 
																	PaymentMethod, 
																	TransactionCommand, 
																	TransactionResult, 
																	CustomerEMailed, 
																	RecurringSubscriptionID) 
									VALUES(@customerId, @orderId, @ipAddress, @transactionDate, @gateway, @paymentMethod, @command, @status, 0, @subscriptionId)"                                    ,
                                  new SqlParameter[]
                    {
                        new SqlParameter("@customerId", customer.CustomerID),
                        new SqlParameter("@orderId", originalOrderId),
                        new SqlParameter("@ipAddress", "0.0.0.0"),
                        new SqlParameter("@transactionDate", transactionDate),
                        new SqlParameter("@gateway", "AUTHORIZENET"),
                        new SqlParameter("@paymentMethod", AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()),
                        new SqlParameter("@command", AppLogic.ro_NotApplicable),
                        new SqlParameter("@status", status),
                        new SqlParameter("@subscriptionId", subscriptionId),
                    }
                                  );
                }
            }

            return(Content(AppLogic.ro_OK));
        }
Ejemplo n.º 18
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (ThisCustomer.IsAdminUser || AppLogic.AppConfigBool("UseStrongPwd"))
            {
                ctrlAccount.PasswordNote = AppLogic.GetString("account.strongPassword", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }
            RequireSecurePage();
            Checkout = CommonLogic.QueryStringBool("checkout");
            RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            SectionTitle = AppLogic.GetString("account.aspx.56", SkinID, ThisCustomer.LocaleSetting);
            ctrlAccount.Attributes.Add("Disabled", "");
            if (Checkout)
            {
                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                if (checkoutByAmazon.IsCheckingOut)
                {
                    pnlCBAAddressWidget.Visible         = true;
                    litCBAAddressWidget.Text            = checkoutByAmazon.RenderAddressWidgetWithRedirect("CBAAddressWidgetContainer", Server.UrlEncode("account.aspx?checkout=true"), new Guid(ThisCustomer.CustomerGUID), 300, 200);
                    litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();

                    pnlAddress.Visible = false;
                }

                ThisCustomer.RequireCustomerRecord();
                CheckoutSteps.Visible = true;
            }
            else
            {
                CheckoutSteps.Visible = false;
            }

            lblErrorMessage.Text  = String.Empty;
            pnlErrorMsg.Visible   = false;
            lblAcctUpdateMsg.Text = String.Empty;

            var status = new StringBuilder();

            bool newAccount = CommonLogic.QueryStringBool("newaccount");

            if (newAccount)
            {
                lblErrorMessage.Text = AppLogic.GetString("createaccount.aspx.86", SkinID, ThisCustomer.LocaleSetting);
                pnlErrorMsg.Visible  = true;
            }

            ThisCustomer.ValidatePrimaryAddresses();

            bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout");

            if (!AllowShipToDifferentThanBillTo)
            {
                pnlShipping.Visible = false;
            }

            //If there is a DeleteID remove it from the cart
            int DeleteID = CommonLogic.QueryStringUSInt("DeleteID");

            if (DeleteID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, DeleteID))
            {
                Order             originalOrder = new Order(DeleteID);
                RecurringOrderMgr rmgr          = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);

                ExpressAPIType expressApiType = PayPalController.GetAppropriateExpressType();

                if (originalOrder.PaymentMethod == AppLogic.ro_PMPayPalExpress && expressApiType == ExpressAPIType.PayPalExpress)
                {
                    status.Append(rmgr.CancelPPECRecurringOrder(DeleteID, false));
                }
                else
                {
                    status.Append(rmgr.CancelRecurringOrder(DeleteID));
                }
            }

            //If there is a FullRefundID refund it
            int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID");

            if (FullRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, FullRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                status.Append(rmgr.ProcessAutoBillFullRefund(FullRefundID));
            }

            //If there is a PartialRefundID refund it
            int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID");

            if (PartialRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, PartialRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                status.Append(rmgr.ProcessAutoBillPartialRefund(PartialRefundID));
            }

            //do not display an error message saying OK
            lblErrorMessage.Text = status.ToString() != AppLogic.ro_OK ? status.ToString() : String.Empty;
            pnlErrorMsg.Visible  = lblErrorMessage.Text.Length > 0;

            if (!this.IsPostBack)
            {
                RefreshPage();
                SetAccountFields();
                if (ThisCustomer.IsRegistered)
                {
                    this.hdnCustomerLevel1.Text = ThisCustomer.CustomerLevelID.ToString();
                }
                else
                {
                    hdnCustomerLevel1.Text = "-1";
                }
            }
        }
Ejemplo n.º 19
0
        private void ProcessForm(bool UseValidationService, int AddressID)
        {
            string ResidenceType = ddlResidenceType.SelectedValue;
            bool   valid         = true;
            string errormsg      = string.Empty;

            bool CardIncluded = false;

            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardName")))
            {
                valid     = false;
                errormsg += "&bull;Card Name is required";
            }

            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardType")))
            {
                valid     = false;
                errormsg += "&bull;Card Type is required";
            }

            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardNumber")))
            {
                valid     = false;
                errormsg += "&bull;Card Number is required";
            }
            else
            {
                CardIncluded = true;
            }

            int    iexpMonth = 0;
            int    iexpYear  = 0;
            string expMonth  = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
            string expYear   = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");

            if (string.IsNullOrEmpty(expMonth) ||
                !int.TryParse(expMonth, out iexpMonth) ||
                !(iexpMonth > 0))
            {
                valid     = false;
                errormsg += "&bull;Please select the Card Expiration Month";
            }
            else
            {
                CardIncluded = true;
            }

            if (string.IsNullOrEmpty(expYear) ||
                !int.TryParse(expYear, out iexpYear) ||
                !(iexpYear > 0))
            {
                valid     = false;
                errormsg += "&bull;Please select the Card Expiration Year";
            }
            else
            {
                CardIncluded = true;
            }

            if (!CardIncluded)
            {
                valid = true;
            }

            if (!Page.IsValid || !valid)
            {
                ErrorMsgLabel.Text = "" + AppLogic.GetString("editaddress.aspx.15", SkinID, ThisCustomer.LocaleSetting) + "";
                foreach (IValidator aValidator in this.Validators)
                {
                    if (!aValidator.IsValid)
                    {
                        ErrorMsgLabel.Text += "&bull; " + aValidator.ErrorMessage + "";
                    }
                }
                ErrorMsgLabel.Text += "";
                ErrorMsgLabel.Text += errormsg;
                InitializePageContent();
                return;
            }
            else
            {
                ErrorMsgLabel.Text = String.Empty;
            }

            theAddress.AddressType = AddressTypes.Billing;
            theAddress.NickName    = txtAddressNickName.Text;
            theAddress.FirstName   = txtFirstName.Text;
            theAddress.LastName    = txtLastName.Text;
            theAddress.Company     = txtCompany.Text;
            theAddress.Address1    = txtAddress1.Text;
            theAddress.Address2    = txtAddress2.Text;
            theAddress.Suite       = txtSuite.Text;
            theAddress.City        = txtCity.Text;
            theAddress.State       = ddlState.SelectedValue;
            theAddress.Zip         = txtZip.Text;
            theAddress.Country     = ddlCountry.SelectedValue;
            theAddress.Phone       = txtPhone.Text;
            if (ResidenceType == "2")
            {
                theAddress.ResidenceType = ResidenceTypes.Commercial;
            }
            else if (ResidenceType == "1")
            {
                theAddress.ResidenceType = ResidenceTypes.Residential;
            }
            else
            {
                theAddress.ResidenceType = ResidenceTypes.Unknown;
            }

            if (CardIncluded)
            {
                theAddress.PaymentMethodLastUsed = AppLogic.ro_PMCreditCard;
                theAddress.CardName = CommonLogic.FormCanBeDangerousContent("CardName");
                theAddress.CardType = CommonLogic.FormCanBeDangerousContent("CardType");

                string tmpS = CommonLogic.FormCanBeDangerousContent("CardNumber");
                if (!tmpS.StartsWith("*"))
                {
                    theAddress.CardNumber = tmpS;
                }
                theAddress.CardExpirationMonth = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
                theAddress.CardExpirationYear  = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");
            }

            theAddress.UpdateDB();

            litCCForm.Text = theAddress.InputCardHTML(ThisCustomer, false, false);

            RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);

            errormsg           = rmgr.ProcessAutoBillAddressUpdate(OriginalRecurringOrderNumber, theAddress);
            ErrorMsgLabel.Text = errormsg != AppLogic.ro_OK ? errormsg : String.Empty;
            if (!ThisCustomer.MasterShouldWeStoreCreditCardInfo)
            {
                theAddress.ClearCCInfo();
                theAddress.UpdateDB();
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            StringBuilder writer = new StringBuilder();

            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            /****************************************************************************/
            // * WARNING TO DEVELOPERS
            // * The redirect below is a SAFETY feature.  Removing the redirect will not
            // * enable ML-only features on a lower version of AspDotNetStorefront.
            // * Attempting to do so can very easily result in a partially implemented
            // * feature, invalid or incomplete data in your DB, and other serious
            // * conditions that will cause your store to be non-functional.
            // *
            // * If you break your store attempting to enable ML-only features in PRO or
            // * Standard, our staff cannot help you fix it, and it will also invalidate
            // * your AspDotNetStorefront License.
            /***************************************************************************/

            if (!AppLogic.m_ProductIsML())
            {
                Response.Redirect(AppLogic.AdminLinkUrl("restrictedfeature.aspx"));
            }

            Customer ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer;

            writer.Append("<div align=\"left\">");

            if (!ThisCustomer.IsAdminUser) // safety check
            {
                writer.Append("<b><font color=red>PERMISSION DENIED</b></font>");
            }
            else
            {
                int   ONX = CommonLogic.QueryStringUSInt("OrderNumber");
                Order ord = new Order(ONX, ThisCustomer.LocaleSetting);

                writer.Append("<b>CANCEL AUTO-BILL AND FULLY REFUND ORDER: " + ONX.ToString() + "</b><br/><br/>");
                if (CommonLogic.FormCanBeDangerousContent("IsSubmit") == "true")
                {
                    String RefundReason = CommonLogic.FormCanBeDangerousContent("RefundReason");
                    String Status       = Gateway.OrderManagement_DoFullRefund(ord, ThisCustomer.LocaleSetting, RefundReason);
                    writer.Append("Refund Status: " + Status);
                    if (Status == AppLogic.ro_OK)
                    {
                        RecurringOrderMgr rmgr = new RecurringOrderMgr(null, null);
                        if (ord.ParentOrderNumber == 0)
                        {
                            Status = rmgr.CancelRecurringOrder(ONX);
                        }
                        else
                        {
                            Status = rmgr.CancelRecurringOrder(ord.ParentOrderNumber);
                        }
                        writer.Append("<p>Cancel Auto-Bill Status: " + Status + "</p>");

                        if (Status == AppLogic.ro_OK)
                        {
                            writer.Append("<script type=\"text/javascript\">\n");
                            writer.Append("opener.window.location.reload();");
                            writer.Append("</script>\n");
                        }
                    }
                    writer.Append("<p align=\"center\"><a href=\"javascript:self.close();\">Close</a></p>");
                }
                else
                {
                    writer.Append("<form method=\"POST\" action=\"" + AppLogic.AdminLinkUrl("recurringrefundcancel.aspx") + "?ordernumber=" + ONX.ToString() + "&confirm=yes\" id=\"RefundOrderForm\" name=\"RefundOrderForm\">");
                    writer.Append("<input type=\"hidden\" name=\"IsSubmit\" value=\"true\">");
                    writer.Append("<p align=\"center\">Are you sure you want to stop future billing and refund this order?<br/><br/></p>");
                    writer.Append("<p align=\"center\">Reason: <input type=\"text\" size=\"50\" maxlength=\"100\" name=\"RefundReason\"></p>");
                    writer.Append("<p align=\"center\"><input type=\"submit\" name=\"submit\" value=\"&nbsp;&nbsp;Yes&nbsp;&nbsp;\">");
                    writer.Append("<img src=\"" + AppLogic.LocateImageURL("~/App_Themes/Admin_Default/images/spacer.gif") + "\" width=\"100\" height=\"1\">");
                    writer.Append("<input type=\"button\" name=\"cancel\" value=\"&nbsp;&nbsp;No&nbsp;&nbsp;\" onClick=\"javascript:self.close();\">");
                    writer.Append("</p>");
                    writer.Append("</form>");
                }
            }

            writer.Append("</div>");
            ltContent.Text = writer.ToString();
        }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            StringBuilder writer = new StringBuilder();

            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            Customer ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer;

            writer.Append("<div align=\"left\">");

            if (!ThisCustomer.IsAdminUser) // safety check
            {
                writer.Append("<b><font color=red>PERMISSION DENIED</b></font>");
            }
            else
            {
                int   ONX = CommonLogic.QueryStringUSInt("OrderNumber");
                Order ord = new Order(ONX, ThisCustomer.LocaleSetting);

                writer.Append("<b>CANCEL AUTO-BILL AND FULLY REFUND ORDER: " + ONX.ToString() + "</b><br/><br/>");
                if (CommonLogic.FormCanBeDangerousContent("IsSubmit") == "true")
                {
                    String RefundReason = CommonLogic.FormCanBeDangerousContent("RefundReason");
                    String Status       = Gateway.OrderManagement_DoFullRefund(ord, ThisCustomer.LocaleSetting, RefundReason);
                    writer.Append("Refund Status: " + Status);
                    if (Status == AppLogic.ro_OK)
                    {
                        RecurringOrderMgr rmgr = new RecurringOrderMgr(null, null);
                        if (ord.ParentOrderNumber == 0)
                        {
                            Status = rmgr.CancelRecurringOrder(ONX);
                        }
                        else
                        {
                            Status = rmgr.CancelRecurringOrder(ord.ParentOrderNumber);
                        }
                        writer.Append("<p>Cancel Auto-Bill Status: " + Status + "</p>");

                        if (Status == AppLogic.ro_OK)
                        {
                            writer.Append("<script type=\"text/javascript\">\n");
                            writer.Append("opener.window.location.reload();");
                            writer.Append("</script>\n");
                        }
                    }
                    writer.Append("<p align=\"center\"><a href=\"javascript:self.close();\">Close</a></p>");
                }
                else
                {
                    writer.Append("<form method=\"POST\" action=\"" + AppLogic.AdminLinkUrl("recurringrefundcancel.aspx") + "?ordernumber=" + ONX.ToString() + "&confirm=yes\" id=\"RefundOrderForm\" name=\"RefundOrderForm\">");
                    writer.Append("<input type=\"hidden\" name=\"IsSubmit\" value=\"true\">");
                    writer.Append("<p align=\"center\">Are you sure you want to stop future billing and refund this order?<br/><br/></p>");
                    writer.Append("<p align=\"center\">Reason: <input type=\"text\" size=\"50\" maxlength=\"100\" name=\"RefundReason\"></p>");
                    writer.Append("<p align=\"center\"><input type=\"submit\" name=\"submit\" value=\"&nbsp;&nbsp;Yes&nbsp;&nbsp;\">");
                    writer.Append("<img src=\"" + AppLogic.LocateImageURL("~/App_Themes/Admin_Default/images/spacer.gif") + "\" width=\"100\" height=\"1\">");
                    writer.Append("<input type=\"button\" name=\"cancel\" value=\"&nbsp;&nbsp;No&nbsp;&nbsp;\" onClick=\"javascript:self.close();\">");
                    writer.Append("</p>");
                    writer.Append("</form>");
                }
            }

            writer.Append("</div>");
            ltContent.Text = writer.ToString();
        }
Ejemplo n.º 22
0
        public ActionResult AuthorizeNetSilentPost(FormCollection collection)
        {
            SysLog.LogMessage(
                message: "Received a recurring payment notification from Authorize.Net.",
                details: Gateway.ListFormCollectionKeyValuePairs(collection),
                messageType: MessageTypeEnum.Informational,
                messageSeverity: MessageSeverityEnum.Alert);

            var subscriptionId  = collection["x_subscription_id"] ?? string.Empty;
            var responseCode    = collection["x_response_code"] ?? string.Empty;
            var responseReason  = collection["x_response_reason_text"] ?? string.Empty;
            var transactionId   = collection["x_trans_id"] ?? string.Empty;
            var amount          = collection["x_amount"] ?? string.Empty;
            var transactionDate = DateTime.Now;

            if (string.IsNullOrEmpty(subscriptionId))
            {
                return(Content(string.Empty));
            }

            var originalOrderId = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(subscriptionId);
            var status          = string.Empty;

            if (originalOrderId == 0)
            {
                status = "Silent Post: No Original Order Found";
                if (!string.IsNullOrEmpty(transactionId))
                {
                    status += ", PNREF=" + transactionId;
                }

                DB.ExecuteSQL(@"
					insert into FailedTransaction(CustomerID, 
						OrderNumber, 
						IPAddress, 
						OrderDate, 
						PaymentGateway, 
						PaymentMethod, 
						TransactionCommand, 
						TransactionResult, 
						CustomerEMailed, 
						RecurringSubscriptionID) 
					values(
						0, 
						0, 
						@ipAddress, 
						@transactionDate, 
						@gateway, 
						@paymentMethod, 
						@command, 
						@status, 
						0, 
						@subscriptionId)"                        ,
                              new SqlParameter[]
                {
                    new SqlParameter("@ipAddress", "0.0.0.0"),
                    new SqlParameter("@transactionDate", transactionDate),
                    new SqlParameter("@gateway", "AUTHORIZENET"),
                    new SqlParameter("@paymentMethod", AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()),
                    new SqlParameter("@command", AppLogic.ro_NotApplicable),
                    new SqlParameter("@status", status),
                    new SqlParameter("@subscriptionId", subscriptionId),
                }
                              );
            }
            else
            {
                if (responseCode.Equals("1"))                // Approved
                {
                    var newOrderNumber = 0;
                    var manager        = new RecurringOrderMgr();
                    status = manager.ProcessAutoBillApproved(originalOrderId, transactionId, transactionDate, out newOrderNumber);
                }
                else
                {
                    var manager = new RecurringOrderMgr();
                    status = manager.ProcessAutoBillDeclined(originalOrderId, transactionId, transactionDate, subscriptionId, responseReason);
                }

                if (!StringComparer.OrdinalIgnoreCase.Equals(status, AppLogic.ro_OK))
                {
                    var customerId = Order.GetOrderCustomerID(originalOrderId);
                    var customer   = new Customer(customerId, true);

                    if (!string.IsNullOrEmpty(transactionId))
                    {
                        status += ", PNREF=" + transactionId;
                    }

                    DB.ExecuteSQL(@"
						insert into FailedTransaction(
							CustomerID, 
							OrderNumber, 
							IPAddress, 
							OrderDate, 
							PaymentGateway, 
							PaymentMethod, 
							TransactionCommand, 
							TransactionResult, 
							CustomerEMailed, 
							RecurringSubscriptionID)
						values(
							@customerId, 
							@orderId, 
							@ipAddress, 
							@transactionDate, 
							@gateway, 
							@paymentMethod, 
							@command, 
							@status, 
							0, 
							@subscriptionId)"                            ,
                                  new SqlParameter[]
                    {
                        new SqlParameter("@customerId", customer.CustomerID),
                        new SqlParameter("@orderId", originalOrderId),
                        new SqlParameter("@ipAddress", "0.0.0.0"),
                        new SqlParameter("@transactionDate", transactionDate),
                        new SqlParameter("@gateway", "AUTHORIZENET"),
                        new SqlParameter("@paymentMethod", AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()),
                        new SqlParameter("@command", AppLogic.ro_NotApplicable),
                        new SqlParameter("@status", status),
                        new SqlParameter("@subscriptionId", subscriptionId),
                    }
                                  );
                }
            }

            return(Content(AppLogic.ro_OK));
        }
Ejemplo n.º 23
0
        protected void btnProcessFile_Click(object sender, EventArgs e)
        {
            txtResults.Visible = true;

            if (m_GW == Gateway.ro_GWVERISIGN || m_GW == Gateway.ro_GWPAYFLOWPRO)
            {
                btnProcessFile.Enabled = false;
            }

            dtLastRun = Localization.ParseDBDateTime(AppLogic.AppConfig("Recurring.GatewayLastImportedDate"));
            DateTime dtRun = dtLastRun;

            if (dtRun == System.DateTime.MinValue)
            {
                dtRun = DateTime.Today.AddDays((double)-1); // Defaults to yesterday
            }
            else
            {
                if (m_GW == Gateway.ro_GWVERISIGN || m_GW == Gateway.ro_GWPAYFLOWPRO)
                {
                    dtRun = DateTime.Today.AddDays((double)-1); // Always runs through yesterday
                }
                else
                {
                    dtRun = DateTime.Today.AddDays((double)-1); // Flag for yesterday
                }
            }

            if (dtRun >= DateTime.Today &&
                (m_GW == Gateway.ro_GWVERISIGN || m_GW == Gateway.ro_GWPAYFLOWPRO))
            {
                txtInputFile.Text           = AppLogic.GetString("admin.recurringimport.NothingToProcess", SkinID, LocaleSetting);
                btnGetGatewayStatus.Enabled = false;
                return;
            }


            if (txtInputFile.Text.Length == 0)
            {
                txtResults.Text = AppLogic.GetString("admin.recurringimport.NothingToProcessForget", SkinID, LocaleSetting);
            }
            else
            {
                RecurringOrderMgr rmgr     = new RecurringOrderMgr(AppLogic.MakeEntityHelpers(), null);
                String            sResults = String.Empty;
                String            Status   = rmgr.ProcessAutoBillStatusFile(m_GW, txtInputFile.Text, out sResults);
                if (Status == AppLogic.ro_OK)
                {
                    txtResults.Text = sResults;
                }
                else
                {
                    txtResults.Text = Status;
                }
            }

            btnGetGatewayStatus.Enabled = true;
            AppLogic.SetAppConfig("Recurring.GatewayLastImportedDate", Localization.ToDBDateTimeString(dtRun));
            lblLastRun.Text = String.Format(AppLogic.GetString("admin.recurringimport.LastImport", SkinID, LocaleSetting), Localization.ToThreadCultureShortDateString(dtRun));
            dtLastRun       = dtRun;
        }
Ejemplo n.º 24
0
        private void RenderHtml()
        {
            StringBuilder writer = new StringBuilder();

            if (authorized)
            {
                //If there is a DeleteID remove it from the cart
                int    DeleteRecurringOrderNumber = CommonLogic.QueryStringUSInt("DeleteID");
                String DeleteRecurringOrderResult = String.Empty;
                if (DeleteRecurringOrderNumber != 0)
                {
                    Order             originalOrder = new Order(DeleteRecurringOrderNumber);
                    RecurringOrderMgr rmgr          = new RecurringOrderMgr();

                    ExpressAPIType expressApiType = PayPalController.GetAppropriateExpressType();

                    if (originalOrder.PaymentMethod == AppLogic.ro_PMPayPalExpress && expressApiType == ExpressAPIType.PayPalExpress)
                    {
                        DeleteRecurringOrderResult = rmgr.CancelPPECRecurringOrder(DeleteRecurringOrderNumber, false);
                    }
                    else
                    {
                        DeleteRecurringOrderResult = rmgr.CancelRecurringOrder(DeleteRecurringOrderNumber);
                    }
                }

                //If there is a FullRefundID refund it
                int    FullRefundID     = CommonLogic.QueryStringUSInt("FullRefundID");
                String FullRefundResult = String.Empty;
                if (FullRefundID != 0)
                {
                    RecurringOrderMgr rmgr = new RecurringOrderMgr();
                    FullRefundResult = rmgr.ProcessAutoBillFullRefund(FullRefundID);
                }

                //If there is a PartialRefundID refund it
                int    PartialRefundID     = CommonLogic.QueryStringUSInt("PartialRefundID");
                String PartialRefundResult = String.Empty;
                if (PartialRefundID != 0)
                {
                    RecurringOrderMgr rmgr = new RecurringOrderMgr();
                    PartialRefundResult = rmgr.ProcessAutoBillPartialRefund(PartialRefundID);
                }

                //If there is a retrypaymentid, retry it
                int    RetryPaymentID     = CommonLogic.QueryStringUSInt("retrypaymentid");
                String RetryPaymentResult = String.Empty;
                if (RetryPaymentID != 0)
                {
                    RecurringOrderMgr rmgr = new RecurringOrderMgr();
                    RetryPaymentResult = rmgr.ProcessAutoBillRetryPayment(RetryPaymentID);
                }

                //If there is a restartid, restart it
                int    RestartPaymentID     = CommonLogic.QueryStringUSInt("restartid");
                String RestartPaymentResult = String.Empty;
                if (RestartPaymentID != 0)
                {
                    RecurringOrderMgr rmgr = new RecurringOrderMgr();
                    RestartPaymentResult = rmgr.ProcessAutoBillRestartPayment(RestartPaymentID);
                }

                if (AppLogic.AppConfigBool("AuditLog.Enabled"))
                {
                    writer.Append("<p><a href=\"" + AppLogic.AdminLinkUrl("auditlog.aspx") + "?CustomerID=" + TargetCustomer.CustomerID.ToString() + "\">View Customer Activity Log</a></p>\n");
                }

                if (ShoppingCart.NumItems(TargetCustomer.CustomerID, CartTypeEnum.RecurringCart) != 0)
                {
                    writer.Append("<p align=\"left\"><b>" + AppLogic.GetString("admin.common.CstMsg9", SkinID, LocaleSetting) + "</b></p>\n");

                    // build JS code to show/hide address update block:
                    StringBuilder tmpS = new StringBuilder(4096);
                    tmpS.Append("<script type=\"text/javascript\">\n");
                    tmpS.Append("function toggleLayer(DivID)\n");
                    tmpS.Append("{\n");
                    tmpS.Append("	var elem;\n");
                    tmpS.Append("	var vis;\n");
                    tmpS.Append("	if(document.getElementById)\n");
                    tmpS.Append("	{\n");
                    tmpS.Append("		// standards\n");
                    tmpS.Append("		elem = document.getElementById(DivID);\n");
                    tmpS.Append("	}\n");
                    tmpS.Append("	else if(document.all)\n");
                    tmpS.Append("	{\n");
                    tmpS.Append("		// old msie versions\n");
                    tmpS.Append("		elem = document.all[DivID];\n");
                    tmpS.Append("	}\n");
                    tmpS.Append("	else if(document.layers)\n");
                    tmpS.Append("	{\n");
                    tmpS.Append("		// nn4\n");
                    tmpS.Append("		elem = document.layers[DivID];\n");
                    tmpS.Append("	}\n");
                    tmpS.Append("	vis = elem.style;\n");
                    tmpS.Append("	if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)\n");
                    tmpS.Append("	{\n");
                    tmpS.Append("		vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';\n");
                    tmpS.Append("	}\n");
                    tmpS.Append("	vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block' ;\n");
                    tmpS.Append("}\n");
                    tmpS.Append("</script>\n");
                    tmpS.Append("\n");
                    tmpS.Append("<style type=\"text/css\">\n");
                    tmpS.Append("	.addressBlockDiv { margin: 0px 20px 0px 20px;  display: none;}\n");
                    tmpS.Append("</style>\n");
                    writer.Append(tmpS.ToString());

                    var parser = new Parser();

                    using (var dbconn = DB.dbConn())
                    {
                        dbconn.Open();
                        using (var rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber from ShoppingCart   with (NOLOCK)  where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and CustomerID=" + TargetCustomer.CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", dbconn))
                        {
                            while (rsr.Read())
                            {
                                bool   ShowCancelButton  = true;
                                bool   ShowRetryButton   = false;
                                bool   ShowRestartButton = false;
                                String GatewayStatus     = String.Empty;

                                RecurringOrderMgr rmgr1 = new RecurringOrderMgr();
                                rmgr1.ProcessAutoBillGetAdminButtons(DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), out ShowCancelButton, out ShowRetryButton, out ShowRestartButton, out GatewayStatus);

                                if (DeleteRecurringOrderNumber == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"))
                                {
                                    writer.Append("<table class=\"table\">\n");
                                    writer.Append("<tr><td>\n");
                                    writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.StopBillingResult", SkinID, LocaleSetting) + " " + DeleteRecurringOrderResult + "</span>\n");
                                    writer.Append("</td></tr>\n");
                                    writer.Append("</table>\n");
                                }

                                if (FullRefundID == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"))
                                {
                                    writer.Append("<table class=\"table\">\n");
                                    writer.Append("<tr><td>\n");
                                    writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.FullRefundResult", SkinID, LocaleSetting) + " " + FullRefundResult + "</span>\n");
                                    writer.Append("</td></tr>\n");
                                    writer.Append("</table>\n");
                                }

                                if (PartialRefundID == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"))
                                {
                                    writer.Append("<table class=\"table\">\n");
                                    writer.Append("<tr><td>\n");
                                    writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.PartialRefundResult", SkinID, LocaleSetting) + " " + PartialRefundResult + "</span>\n");
                                    writer.Append("</td></tr>\n");
                                    writer.Append("</table>\n");
                                }

                                if (RetryPaymentID == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"))
                                {
                                    writer.Append("<table class=\"table\">\n");
                                    writer.Append("<tr><td>\n");
                                    writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.RetryPaymentResult", SkinID, LocaleSetting) + " " + RetryPaymentResult + "</span>\n");
                                    writer.Append("</td></tr>\n");
                                    writer.Append("</table>\n");
                                }

                                if (RestartPaymentID == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"))
                                {
                                    writer.Append("<table class=\"table\">\n");
                                    writer.Append("<tr><td>\n");
                                    writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.RestartPaymentResult", SkinID, LocaleSetting) + " " + RestartPaymentResult + "</span>\n");
                                    writer.Append("</td></tr>\n");
                                    writer.Append("</table>\n");
                                }

                                writer.Append(AppLogic.GetRecurringCart(parser, TargetCustomer, DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false, ShowCancelButton, ShowRetryButton, ShowRestartButton, GatewayStatus));
                            }
                        }
                    }
                }

                writer.Append("<div class=\"admin-module\">\n");
                writer.Append("<h3>" + AppLogic.GetString("admin.orderframe.OrderHistory", SkinID, LocaleSetting) + "</h3>\n");

                int N = 0;

                writer.Append("<table class=\"table\">\n");
                writer.Append("<tr>\n");
                writer.Append("<td><b>" + AppLogic.GetString("admin.common.OrderNumber", SkinID, LocaleSetting) + "</b></td>\n");
                writer.Append("<td><b>" + AppLogic.GetString("admin.common.OrderDate", SkinID, LocaleSetting) + "</b></td>\n");
                writer.Append("<td><b>" + AppLogic.GetString("admin.cst_history.PaymentStatus", SkinID, LocaleSetting) + "</b></td>\n");
                writer.Append("<td><b>" + AppLogic.GetString("admin.common.ShippingStatus", SkinID, LocaleSetting) + "</b></td>\n");
                writer.Append("<td><b>" + AppLogic.GetString("admin.common.OrderTotal", SkinID, LocaleSetting) + "</b></td>\n");
                if (AppLogic.AppConfigBool("ShowCustomerServiceNotesInReceipts"))
                {
                    writer.Append("<td><b>" + AppLogic.GetString("admin.cst_history.CustomerServiceNotes", SkinID, LocaleSetting) + "</b></td>\n");
                }
                writer.Append("</tr>\n");

                using (var dbconn = DB.dbConn())
                {
                    dbconn.Open();
                    using (var rs = DB.GetRS("Select '' Failed, PaymentGateway, PaymentMethod, ShippedOn, ShippedVIA, ShippingTrackingNumber, OrderNumber, OrderDate, OrderTotal, cast(CustomerServiceNotes as nvarchar(4000)) CustomerServiceNotes, TransactionState, DownloadEMailSentOn, CustomerID, RecurringSubscriptionID from orders  with (NOLOCK)  where CustomerID=" + TargetCustomer.CustomerID.ToString()
                                             + " union select 'Failed' Failed, PaymentGateway, PaymentMethod, null ShippedOn, null ShippedVIA, null ShippingTrackingNumber, OrderNumber, OrderDate, null OrderTotal, cast(TransactionResult as nvarchar(4000)) CustomerServiceNotes, null TransactionState, null DownloadEMailSentOn, CustomerID, RecurringSubscriptionID  from FailedTransaction  with (NOLOCK)  where CustomerID=" + TargetCustomer.CustomerID.ToString()
                                             + " order by OrderDate desc", dbconn))
                    {
                        while (rs.Read())
                        {
                            String PaymentStatus = String.Empty;
                            if (DB.RSField(rs, "PaymentMethod").Length != 0)
                            {
                                PaymentStatus = AppLogic.GetString("admin.order.PaymentMethod", SkinID, LocaleSetting) + " " + DB.RSField(rs, "PaymentMethod") + "<br/>";
                            }
                            else
                            {
                                PaymentStatus = AppLogic.GetString("admin.order.PaymentMethod", SkinID, LocaleSetting) + " " + CommonLogic.IIF(DB.RSField(rs, "CardNumber").StartsWith(AppLogic.ro_PMPayPal, StringComparison.InvariantCultureIgnoreCase), AppLogic.ro_PMPayPal, "Credit Card") + "<br/>";
                            }

                            if (DB.RSField(rs, "RecurringSubscriptionID").Length > 0 && DB.RSField(rs, "PaymentGateway") == AspDotNetStorefrontGateways.Gateway.ro_GWPAYFLOWPRO)
                            {                             // include link to recurringgatewaydetails.aspx for live gateway status
                                PaymentStatus += "Subscription ID: <a href=\"" + AppLogic.AdminLinkUrl("recurringgatewaydetails.aspx") + "?RecurringSubscriptionID=" + DB.RSField(rs, "RecurringSubscriptionID") + "\">" + DB.RSField(rs, "RecurringSubscriptionID") + "</a><br/>";
                            }

                            String ShippingStatus = String.Empty;
                            if (AppLogic.OrderHasShippableComponents(DB.RSFieldInt(rs, "OrderNumber")))
                            {
                                if (DB.RSFieldDateTime(rs, "ShippedOn") != System.DateTime.MinValue)
                                {
                                    ShippingStatus = "Shipped";
                                    if (DB.RSField(rs, "ShippedVIA").Length != 0)
                                    {
                                        ShippingStatus += " via " + DB.RSField(rs, "ShippedVIA");
                                    }
                                    ShippingStatus += " on " + Localization.ToThreadCultureShortDateString(DB.RSFieldDateTime(rs, "ShippedOn")) + ".";
                                    if (DB.RSField(rs, "ShippingTrackingNumber").Length != 0)
                                    {
                                        ShippingStatus += " " + AppLogic.GetString("admin.orderframe.TrackingNumber", SkinID, LocaleSetting) + " ";

                                        String TrackURL = Shipping.GetTrackingURL(DB.RSField(rs, "ShippingTrackingNumber"));
                                        if (TrackURL.Length != 0)
                                        {
                                            ShippingStatus += "<a href=\"" + TrackURL + "\" target=\"_blank\">" + DB.RSField(rs, "ShippingTrackingNumber") + "</a>";
                                        }
                                        else
                                        {
                                            ShippingStatus += DB.RSField(rs, "ShippingTrackingNumber");
                                        }
                                    }
                                }
                                else
                                {
                                    ShippingStatus = AppLogic.GetString("admin.cst_history.NotYetShipped", SkinID, LocaleSetting);
                                }
                            }
                            if (AppLogic.OrderHasDownloadComponents(DB.RSFieldInt(rs, "OrderNumber"), true))
                            {
                                if (DB.RSField(rs, "TransactionState") == AppLogic.ro_TXStateCaptured && DB.RSFieldDateTime(rs, "DownloadEMailSentOn") != System.DateTime.MinValue)
                                {
                                    if (ShippingStatus.Length != 0)
                                    {
                                        ShippingStatus += "<hr size=\"1\"/>";
                                    }
                                }
                                else
                                {
                                    if (ShippingStatus.Length == 0)
                                    {
                                        ShippingStatus += AppLogic.GetString("admin.cst_history.DownloadListPendingPayment", SkinID, LocaleSetting);
                                    }
                                }
                            }
                            writer.Append("<tr>\n");
                            writer.Append("<td>");
                            writer.Append("<a href=\"" + AppLogic.AdminLinkUrl("order.aspx") + "?ordernumber=" + DB.RSFieldInt(rs, "OrderNumber").ToString() + "\">" + DB.RSFieldInt(rs, "OrderNumber").ToString() + "</a>");
                            writer.Append("<br/><br/>");
                            if (string.IsNullOrEmpty(DB.RSField(rs, "Failed")))
                            {
                                var urlHelper = DependencyResolver.Current.GetService <UrlHelper>();
                                writer.AppendFormat(@"<a href=""{0}"" target=""_blank"">{1}</a>",
                                                    urlHelper.Action(
                                                        actionName: ActionNames.Index,
                                                        controllerName: ControllerNames.Receipt,
                                                        routeValues: new
                                {
                                    OrderNumber = DB.RSFieldInt(rs, "OrderNumber")
                                }),
                                                    AppLogic.GetString("admin.cst_history.PrintableReceipt", SkinID, LocaleSetting));
                            }
                            else
                            {
                                writer.Append("<font color=\"red\">" + DB.RSField(rs, "Failed") + "</font>");
                            }
                            writer.Append("</td>");
                            writer.Append("<td>" + Localization.ToNativeDateTimeString(DB.RSFieldDateTime(rs, "OrderDate")));
                            writer.Append("</td>");
                            writer.Append("<td>" + PaymentStatus + "&nbsp;" + "</td>");
                            writer.Append("<td>" + ShippingStatus + "&nbsp;" + "</td>");
                            writer.Append("<td>" + ThisCustomer.CurrencyString(DB.RSFieldDecimal(rs, "OrderTotal")) + "</td>");
                            if (AppLogic.AppConfigBool("ShowCustomerServiceNotesInReceipts"))
                            {
                                if (DB.RSField(rs, "CustomerServiceNotes").Length > 110)
                                {
                                    writer.Append("<td><textarea READONLY rows=\"10\" cols=\"50\">" + DB.RSField(rs, "CustomerServiceNotes") + "</textarea></td>");
                                }
                                else
                                {
                                    writer.Append("<td>" + CommonLogic.IIF(DB.RSField(rs, "CustomerServiceNotes").Length == 0, "None", DB.RSField(rs, "CustomerServiceNotes")) + "</td>");
                                }
                            }
                            else
                            {
                                writer.Append("&nbsp;");
                            }
                            writer.Append("</tr>\n");
                            N++;
                        }
                    }
                }
                writer.Append("</table>\n");
                if (N == 0)
                {
                    writer.Append("<p align=\"left\">" + AppLogic.GetString("admin.common.NoOrdersFound", SkinID, LocaleSetting) + "</p>\n");
                }
            }
            ltContent.Text = writer.ToString();
        }
Ejemplo n.º 25
0
        private void RenderMarkup()
        {
            StringBuilder output = new StringBuilder();

            if (CommonLogic.QueryStringBool("ProcessAll"))
            {
                using (SqlConnection conn = DB.dbConn())
                {
                    conn.Open();
                    using (IDataReader rsp = DB.GetRS("Select distinct(OriginalRecurringOrderNumber) from ShoppingCart where RecurringSubscriptionID='' and CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and NextRecurringShipDate<" + DB.SQuote(Localization.ToDBShortDateString(System.DateTime.Now.AddDays(1))), conn))
                    {
                        RecurringOrderMgr rmgr = new RecurringOrderMgr(EntityHelpers, GetParser);
                        while (rsp.Read())
                        {
                            output.Append(String.Format(AppLogic.GetString("admin.recurring.ProcessingNextOccurrence", SkinID, LocaleSetting), DB.RSFieldInt(rsp, "OriginalRecurringOrderNumber").ToString()));
                            output.Append(rmgr.ProcessRecurringOrder(DB.RSFieldInt(rsp, "OriginalRecurringOrderNumber")));
                            output.Append("...<br/>");
                        }
                    }
                }
            }

            int OriginalRecurringOrderNumber = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber");
            int ProcessCustomerID            = CommonLogic.QueryStringUSInt("ProcessCustomerID");

            if (ProcessCustomerID != 0 && OriginalRecurringOrderNumber != 0)
            {
                output.Append(String.Format(AppLogic.GetString("admin.recurring.ProcessingNextOccurrence", SkinID, LocaleSetting), OriginalRecurringOrderNumber.ToString()));
                RecurringOrderMgr rmgr = new RecurringOrderMgr(EntityHelpers, GetParser);
                output.Append(rmgr.ProcessRecurringOrder(OriginalRecurringOrderNumber));
                output.Append("...<br/>");
            }

            output.Append("<br/><ul>");
            bool PendingOnly = (!CommonLogic.QueryStringCanBeDangerousContent("Show").Equals("ALL", StringComparison.InvariantCultureIgnoreCase));

            if (PendingOnly)
            {
                if (DB.GetSqlN("Select count(*) as N from ShoppingCart   with (NOLOCK)  where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and NextRecurringShipDate<" + DB.SQuote(Localization.ToDBDateTimeString(System.DateTime.Now.AddDays(1)))) > 0)
                {
                    output.Append("<li><b><a href=\"" + AppLogic.AdminLinkUrl("recurring.aspx") + "?processall=true\">" + AppLogic.GetString("admin.recurring.ProcessChargesAll", SkinID, LocaleSetting) + "</a></b> " + AppLogic.GetString("admin.recurring.ProcessChargesSingle", SkinID, LocaleSetting) + "</li>");
                }
                else
                {
                    output.Append("<li><b>" + AppLogic.GetString("admin.recurring.NoRecurringShipmentsDueToday", SkinID, LocaleSetting) + "</b></li>");
                }
            }
            else
            {
                if (DB.GetSqlN("Select count(*) as N from ShoppingCart   with (NOLOCK)  where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString()) == 0)
                {
                    output.Append("<li><b>" + AppLogic.GetString("admin.recurring.NoActiveRecurringOrdersFound", SkinID, LocaleSetting) + "</b></li>");
                }
            }
            if (AppLogic.AppConfigBool("Recurring.UseGatewayInternalBilling"))
            {
                output.Append("<li><b>" + AppLogic.GetString("admin.recurring.NoteAutobillGatewayOrders", SkinID, LocaleSetting) + "</b></li>");
            }
            output.Append("</ul>");

            using (SqlConnection conn2 = DB.dbConn())
            {
                conn2.Open();
                using (IDataReader rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber, CustomerID from ShoppingCart  with (NOLOCK)  where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + CommonLogic.IIF(PendingOnly, " and NextRecurringShipDate<" + DB.SQuote(Localization.ToDBShortDateString(System.DateTime.Now.AddDays(1))), "") + " order by OriginalRecurringOrderNumber desc", conn2))
                {
                    while (rsr.Read())
                    {
                        output.Append(AppLogic.GetRecurringCart(EntityHelpers, GetParser, new Customer(DB.RSFieldInt(rsr, "CustomerID")), DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false));
                    }
                }
            }

            ltContent.Text = output.ToString();
        }
Ejemplo n.º 26
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("UseStringPwd"))
            {
                ctrlAccount.PasswordNote = AppLogic.GetString("account.stringPassword", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }
            RequireSecurePage();
            RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            SectionTitle = AppLogic.GetString("account.aspx.56", SkinID, ThisCustomer.LocaleSetting);
            Checkout     = CommonLogic.QueryStringBool("checkout");
            if (Checkout)
            {
                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                if (checkoutByAmazon.IsCheckingOut)
                {
                    pnlCBAAddressWidget.Visible         = true;
                    litCBAAddressWidget.Text            = checkoutByAmazon.RenderAddressWidgetWithRedirect("CBAAddressWidgetContainer", Server.UrlEncode("account.aspx?checkout=true"), new Guid(ThisCustomer.CustomerGUID), 300, 200);
                    litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();

                    tblAccount.Visible = false;
                }

                ThisCustomer.RequireCustomerRecord();
            }

            ErrorMsgLabel.Text    = "";
            lblAcctUpdateMsg.Text = "";

            bool newAccount = CommonLogic.QueryStringBool("newaccount");

            if (newAccount)
            {
                ErrorMsgLabel.Text = "<b><center>" + AppLogic.GetString("createaccount.aspx.86", SkinID, ThisCustomer.LocaleSetting) + "</center></b>";
            }

            ThisCustomer.ValidatePrimaryAddresses();

            bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout");

            if (!AllowShipToDifferentThanBillTo)
            {
                pnlShipping.Visible = pnlShipping2.Visible = false;
            }

            //If there is a DeleteID remove it from the cart
            int DeleteID = CommonLogic.QueryStringUSInt("DeleteID");

            if (DeleteID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, DeleteID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.CancelRecurringOrder(DeleteID);
            }

            //If there is a FullRefundID refund it
            int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID");

            if (FullRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, FullRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.ProcessAutoBillFullRefund(FullRefundID);
            }

            //If there is a PartialRefundID refund it
            int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID");

            if (PartialRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, PartialRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.ProcessAutoBillPartialRefund(PartialRefundID);
            }

            //SkinImagePath = "~/App_Themes/skin_" + SkinID.ToString() + "/images/";

            if (!this.IsPostBack)
            {
                ctrlAccount.FirstName         = ThisCustomer.FirstName;
                ctrlAccount.LastName          = ThisCustomer.LastName;
                ctrlAccount.Email             = ThisCustomer.EMail.ToLowerInvariant().Trim();
                ctrlAccount.Password          = String.Empty;
                ctrlAccount.PasswordConfirm   = String.Empty;
                ctrlAccount.Phone             = ThisCustomer.Phone;
                ctrlAccount.SaveCC            = ThisCustomer.MasterShouldWeStoreCreditCardInfo || ThisCustomer.SecureNetVaultMasterShouldWeStoreCreditCardInfo;
                ctrlAccount.Over13            = ThisCustomer.IsOver13;
                ctrlAccount.VATRegistrationID = ThisCustomer.VATRegistrationID;
                if (ThisCustomer.OKToEMail)
                {
                    ctrlAccount.OKToEmailYes = true;
                }
                else
                {
                    ctrlAccount.OKToEmailNo = true;
                }

                RefreshPage();
            }
        }
        private void ProcessForm(bool UseValidationService, int AddressID)
        {
            string ResidenceType = ddlResidenceType.SelectedValue;
            bool   valid         = true;
            string errormsg      = string.Empty;
            bool   CardIncluded  = false;

            errormsg += "<ul>";

            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardName")))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardNameIsRequired", SkinID, LocaleSetting) + "</li>";
            }
            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardType")))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardTypeIsRequired", SkinID, LocaleSetting) + "</li>";
            }
            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardNumber")))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardNumberIsRequired", SkinID, LocaleSetting) + "</li>";
            }
            else
            {
                CardIncluded = true;
            }

            int    iexpMonth = 0;
            int    iexpYear  = 0;
            string expMonth  = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
            string expYear   = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");

            if (string.IsNullOrEmpty(expMonth) ||
                !int.TryParse(expMonth, out iexpMonth) ||
                !(iexpMonth > 0))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardExpirationMonthNotification", SkinID, LocaleSetting) + "</li>";
            }
            else
            {
                CardIncluded = true;
            }

            if (string.IsNullOrEmpty(expYear) ||
                !int.TryParse(expYear, out iexpYear) ||
                !(iexpYear > 0))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardExpirationYearNotification", SkinID, LocaleSetting) + "</li>";
            }
            else
            {
                CardIncluded = true;
            }

            if (!CardIncluded)
            {
                valid = true;
            }

            if (!valid)
            {
                errormsg           += "</ul>";
                ErrorMsgLabel.Text += errormsg;
                InitializePageContent();
                return;
            }
            else
            {
                ErrorMsgLabel.Text = String.Empty;
            }

            theAddress.AddressType = AddressTypes.Billing;
            theAddress.NickName    = txtAddressNickName.Text;
            theAddress.FirstName   = txtFirstName.Text;
            theAddress.LastName    = txtLastName.Text;
            theAddress.Company     = txtCompany.Text;
            theAddress.Address1    = txtAddress1.Text;
            theAddress.Address2    = txtAddress2.Text;
            theAddress.Suite       = txtSuite.Text;
            theAddress.City        = txtCity.Text;
            theAddress.State       = ddlState.SelectedValue;
            theAddress.Zip         = txtZip.Text;
            theAddress.Country     = ddlCountry.SelectedValue;
            theAddress.Phone       = txtPhone.Text;
            if (ResidenceType == "2")
            {
                theAddress.ResidenceType = ResidenceTypes.Commercial;
            }
            else if (ResidenceType == "1")
            {
                theAddress.ResidenceType = ResidenceTypes.Residential;
            }
            else
            {
                theAddress.ResidenceType = ResidenceTypes.Unknown;
            }

            if (CardIncluded)
            {
                theAddress.PaymentMethodLastUsed = AppLogic.ro_PMCreditCard;
                theAddress.CardName = CommonLogic.FormCanBeDangerousContent("CardName");
                theAddress.CardType = CommonLogic.FormCanBeDangerousContent("CardType");

                string tmpS = CommonLogic.FormCanBeDangerousContent("CardNumber");
                if (!tmpS.StartsWith("*"))
                {
                    theAddress.CardNumber = tmpS;
                }
                theAddress.CardExpirationMonth = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
                theAddress.CardExpirationYear  = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");
            }

            theAddress.UpdateDB();

            SetupCreditCardForm();

            RecurringOrderMgr rmgr = new RecurringOrderMgr();

            errormsg           = rmgr.ProcessAutoBillAddressUpdate(OriginalRecurringOrderNumber, theAddress);
            ErrorMsgLabel.Text = errormsg != AppLogic.ro_OK ? errormsg : String.Empty;
            if (!AddressCustomer.MasterShouldWeStoreCreditCardInfo)
            {
                theAddress.ClearCCInfo();
                theAddress.UpdateDB();
            }
        }
Ejemplo n.º 28
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MobileHelper.RedirectPageWhenMobileIsDisabled("~/account.aspx", ThisCustomer);

            if (ThisCustomer.IsAdminUser || AppLogic.AppConfigBool("UseStrongPwd"))
            {
                ctrlAccount.PasswordNote = AppLogic.GetString("account.strongPassword", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }
            RequireSecurePage();
            RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            SectionTitle = AppLogic.GetString("account.aspx.56", SkinID, ThisCustomer.LocaleSetting);
            Checkout     = CommonLogic.QueryStringBool("checkout");
            if (Checkout)
            {
                ThisCustomer.RequireCustomerRecord();
                pnlAccountInfoMP.Visible  = false;
                pnlOrderHistoryMP.Visible = false;
            }

            ErrorMsgLabel.Text    = "";
            lblAcctUpdateMsg.Text = "";

            bool newAccount = CommonLogic.QueryStringBool("newaccount");

            if (newAccount)
            {
                ErrorMsgLabel.Text = "<b><center>" + AppLogic.GetString("createaccount.aspx.86", SkinID, ThisCustomer.LocaleSetting) + "</center></b>";
            }

            ThisCustomer.ValidatePrimaryAddresses();

            //If there is a DeleteID remove it from the cart
            int DeleteID = CommonLogic.QueryStringUSInt("DeleteID");

            if (DeleteID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, DeleteID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.CancelRecurringOrder(DeleteID);
            }

            //If there is a FullRefundID refund it
            int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID");

            if (FullRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, FullRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.ProcessAutoBillFullRefund(FullRefundID);
            }

            //If there is a PartialRefundID refund it
            int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID");

            if (PartialRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, PartialRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.ProcessAutoBillPartialRefund(PartialRefundID);
            }

            if (!this.IsPostBack)
            {
                ctrlAccount.FirstName         = ThisCustomer.FirstName;
                ctrlAccount.LastName          = ThisCustomer.LastName;
                ctrlAccount.Email             = ThisCustomer.EMail.ToLowerInvariant().Trim();
                ctrlAccount.Password          = String.Empty;
                ctrlAccount.PasswordConfirm   = String.Empty;
                ctrlAccount.Phone             = ThisCustomer.Phone;
                ctrlAccount.SaveCC            = ThisCustomer.MasterShouldWeStoreCreditCardInfo || ThisCustomer.SecureNetVaultMasterShouldWeStoreCreditCardInfo;
                ctrlAccount.Over13            = ThisCustomer.IsOver13;
                ctrlAccount.VATRegistrationID = ThisCustomer.VATRegistrationID;
                if (ThisCustomer.OKToEMail)
                {
                    ctrlAccount.OKToEmailYes = true;
                }
                else
                {
                    ctrlAccount.OKToEmailNo = true;
                }

                RefreshPage();
            }

            //If email address confirmation is on, prefill the box so they don't have to populate it to change other things
            TextBox txtReEnterEmail = (TextBox)ctrlAccount.FindControl("txtReEnterEmail");

            if (txtReEnterEmail != null)
            {
                txtReEnterEmail.Text = ThisCustomer.EMail.ToLowerInvariant().Trim();
            }
        }