/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event to initialize the page. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param> protected override void OnInit(EventArgs e) { Label lblBillingInformation = acCheckout.Panes[0].FindControl("lblBillingInformation") as Label; Label lblShippingInformation = acCheckout.Panes[1].FindControl("lblShippingInformation") as Label; Label lblShippingMethod = acCheckout.Panes[2].FindControl("lblShippingMethod") as Label; Label lblCouponInformation = acCheckout.Panes[3].FindControl("lblCouponInformation") as Label; Label lblOrderReview = acCheckout.Panes[4].FindControl("lblOrderReview") as Label; //See if there are any coupons in the system //If not, then don't display the coupon stuff couponCollection = new CouponController().FetchAll(); if (couponCollection.Count == 0) { hasCoupons = false; acpCoupon.Visible = false; pnlCouponInformationDisplayTitle.Visible = false; pnlCouponInformationDisplay.Visible = false; } shippingService = new ShippingService(); if (!shippingService.ShippingServiceSettings.UseShipping) { acCheckout.Panes[1].Visible = false; acCheckout.Panes[2].Visible = false; pnlShippingAddressDisplayTitle.Visible = false; pnlShippingAddressDisplay.Visible = false; pnlShippingMethodDisplayTitle.Visible = false; pnlShippingMethodDisplay.Visible = false; } order = new OrderController().FetchOrder(WebUtility.GetUserName()); if (!Page.IsPostBack) { SetBillingAddressDisplay(); SetShippingAddressDisplay(); SetShippingMethodDisplay(); SetCouponDisplay(); } base.OnInit(e); }
/// <summary> /// Initializes a new instance of the <see cref="T:ShippingService"/> class. /// </summary> public ShippingService() { _shippingServiceSettings = ShippingService.FetchShippingServiceSettings(); _shippingProviderCollection = new ShippingProviderCollection(); LoadProviders(); }
/// <summary> /// Fetches the shipping options. /// </summary> /// <param name="order">The Order</param> /// <returns></returns> public static ShippingOptionCollection FetchShippingOptions(Order order) { ShippingService shippingService = new ShippingService(); ShippingOptionCollection shippingOptionCollection = shippingService.GetShippingOptions(order); return shippingOptionCollection; }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event to initialize the page. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param> protected override void OnInit(EventArgs e) { if (Master.SiteSettings.LoginRequirement == LoginRequirement.Checkout) { if (!User.Identity.IsAuthenticated) { Response.Redirect("login.aspx?ReturnUrl=/checkout.aspx", true); } } PaymentService paymentService = new PaymentService(); if (paymentService.PaymentServiceSettings.DefaultProvider == "PayPalStandardPaymentProvider") { Response.Redirect("~/paypalcheckout.aspx", true); } //Keep these here - the Accordion ViewState is funky and requires things to be set early Label lblBillingInformation = acCheckout.Panes[0].FindControl("lblBillingInformation") as Label; Label lblShippingInformation = acCheckout.Panes[1].FindControl("lblShippingInformation") as Label; Label lblShippingMethod = acCheckout.Panes[2].FindControl("lblShippingMethod") as Label; Label lblCouponInformation = acCheckout.Panes[3].FindControl("lblCouponInformation") as Label; Label lblPaymentInformation = acCheckout.Panes[4].FindControl("lblPaymentInformation") as Label; Label lblOrderReview = acCheckout.Panes[5].FindControl("lblOrderReview") as Label; //See if there are any coupons in the system //If not, then don't display the coupon stuff couponCollection = new CouponController().FetchAll(); if (couponCollection.Count == 0) { hasCoupons = false; acpCoupon.Visible = false; pnlCouponInformationDisplayTitle.Visible = false; pnlCouponInformationDisplay.Visible = false; } shippingService = new ShippingService(); if (!shippingService.ShippingServiceSettings.UseShipping) { acCheckout.Panes[1].Visible = false; acCheckout.Panes[2].Visible = false; pnlShippingAddressDisplayTitle.Visible = false; pnlShippingAddressDisplay.Visible = false; pnlShippingMethodDisplayTitle.Visible = false; pnlShippingMethodDisplay.Visible = false; } //Keep these here - the Accordion ViewState is funky and requires things to be set early order = new OrderController().FetchOrder(WebUtility.GetUserName()); #region PayPal Express Checkout Logic if (!string.IsNullOrEmpty(order.PaymentMethod)) { if (order.PaymentMethod == "PayPal") { string token = Utility.GetParameter("token"); if (!string.IsNullOrEmpty(token)) { pnlCreditCardInformation.Visible = false; pnlCreditCardInfo.Visible = false; lblCreditCardType.Text = order.PaymentMethod; ddlCreditCardType.SelectedValue = "4"; ddlCreditCardType.Enabled = false; PayPalPayer payPalPayer = OrderController.GetExpressCheckout(token); if (order.BillingAddress == null) {//Then they are coming in from the cart.aspx ExpressCheckout button //copy the PayPalPayer ShippingAddress and then flag it as a BillingAddress Address billingAddress = new Address(payPalPayer.ShippingAddress); billingAddress.AddressType = AddressType.BillingAddress; Address duplicateBillingAddress = WebProfile.Current.AddressCollection.Find( addressToFind => addressToFind.ToString() == billingAddress.ToString() && addressToFind.AddressType == AddressType.BillingAddress); if (duplicateBillingAddress == null) { WebProfile.Current.AddressCollection.Add(billingAddress); WebProfile.Current.Save(); } order.BillToAddress = payPalPayer.ShippingAddress.ToXml(); } if (!payPalPayer.ShippingAddress.Equals(order.ShippingAddress)) { Address shippingAddress = new Address(payPalPayer.ShippingAddress); shippingAddress.AddressType = AddressType.ShippingAddress; Address duplicateShippingAddress = WebProfile.Current.AddressCollection.Find( addressToFind => addressToFind.ToString() == shippingAddress.ToString() && addressToFind.AddressType == AddressType.ShippingAddress); if (duplicateShippingAddress == null) { WebProfile.Current.AddressCollection.Add(shippingAddress); WebProfile.Current.Save(); } order.ShipToAddress = payPalPayer.ShippingAddress.ToXml(); } if (order.ExtendedProperties.ContainsKey(PAYPAL_PAYER_ID)) { order.ExtendedProperties.Remove(PAYPAL_PAYER_ID); } if (order.ExtendedProperties.ContainsKey(PAYPAL_TOKEN)) { order.ExtendedProperties.Remove(PAYPAL_TOKEN); } order.ExtendedProperties.Add(PAYPAL_PAYER_ID, payPalPayer.PayPalPayerId); order.ExtendedProperties.Add(PAYPAL_TOKEN, payPalPayer.PayPalToken); order.AdditionalProperties = order.ExtendedProperties.ToXml(); order.Save(WebUtility.GetUserName()); OrderController.CalculateTax(WebUtility.GetUserName()); order = new OrderController().FetchOrder(WebUtility.GetUserName()); } } } #endregion if (!Page.IsPostBack) { SetBillingAddressDisplay(); SetShippingAddressDisplay(); SetShippingMethodDisplay(); SetCouponDisplay(); SetPaymentMethodDisplay(-1, order.CreditCardNumber, DateTime.MinValue); } base.OnInit(e); }
/// <summary> /// Fetches the shipping options. /// </summary> /// <param name="userName">Name of the user.</param> /// <returns></returns> public static ShippingOptionCollection FetchShippingOptions(string userName) { Order order = new OrderController().FetchOrder(userName); ShippingService shippingService = new ShippingService(); ShippingOptionCollection shippingOptionCollection = shippingService.GetShippingOptions(order); return shippingOptionCollection; }