Пример #1
0
        public ActionResult InitCheckout(string shippingMethod)
        {
            try
            {
                List <ShoppingCartProduct> ShoppingCartList = SiteContext.ShoppingCartProductList;

                SettingGroup PayPalSettings = SettingGroupDAO.LoadSettingGroupByName(SettingGroupKeys.PAYPAL_PURCHASE_SETTINGS);

                //create auth header obj
                AuthHeader PayPalAuthHeader = Chimera.Core.PurchaseOrders.PayPalAuthHeader.GetAuthHeaderFromSetting(PayPalSettings);

                //create authorization obj
                Authorization PayPalAuthorization = new Authorization();

                string BaseWebsiteURL = CM.AppSettings["BaseWebsiteURL"];

                PayPalAuthorization.StoreImageURL   = PayPalSettings.GetSettingVal(PayPalSettingKeys.PayPal_HDRIMG);
                PayPalAuthorization.SuccessOrderURL = BaseWebsiteURL + "Order/PayPalSuccess";
                PayPalAuthorization.CancelOrderURL  = BaseWebsiteURL + "Order/PayPalCancel";

                //create purchase order details obj
                PurchaseOrderDetails PurchaseOrder = new PurchaseOrderDetails(shippingMethod, ShoppingCartList, Helpers.ShippingMethod.GetGlobalShippingMethodDictionary(null, PayPalSettings)[shippingMethod], PayPalSettings.GetSettingVal(PayPalSettingKeys.GlobalTaxAmount));

                //call paypal API to get new order details
                OrderDetails AuthOrderDetails = CompanyCommons.Ecommerce.PayPal.Functions.Execute.Authorization(PayPalAuthHeader, PayPalAuthorization, PurchaseOrder.PayPalOrderDetails, PurchaseOrder.CreatePayPalItemDescriptions());

                if (AuthOrderDetails != null)
                {
                    //store purchase order object into session
                    PurchaseOrder.PayPalOrderDetails = AuthOrderDetails;

                    //add updated info to session
                    SiteContext.PayPalPurchaseOrder = PurchaseOrder;

                    //redirect to paypal
                    return(Redirect(CompanyCommons.Ecommerce.PayPal.Functions.Execute.GetAuthorizationRedirectURL(PayPalSettings.GetSettingVal(PayPalSettingKeys.PayPal_REDIRECT), AuthOrderDetails)));
                }

                //if we got this far the call the paypal's API failed
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Controllers.OrderController.InitCheckout() " + e.Message);
            }

            //TODO: return 404 page instead?
            return(RedirectToAction("Index", "Home"));
        }
Пример #2
0
        public ActionResult Index(string friendlyURL, string previewPageData)
        {
            friendlyURL = string.IsNullOrWhiteSpace(friendlyURL) ? "Index" : friendlyURL;

            if (friendlyURL.ToUpper().Equals("ADMIN"))
            {
                return(RedirectToRoute("Admin_Default"));
            }

            Models.PageModel PageModel = new Models.PageModel();

            if (!string.IsNullOrWhiteSpace(previewPageData))
            {
                ViewBag.PreviewPageData = previewPageData;
                PageModel.InEditMode    = true;
            }
            else
            {
                PageModel = new Models.PageModel(friendlyURL, Request);
            }

            if (!string.IsNullOrWhiteSpace(PageModel.Page.Id) || PageModel.InEditMode)
            {
                ViewBag.PageModel = PageModel;

                return(View("Index", String.Format("~/Templates/{0}/Views/Shared/Template.Master", Models.ChimeraTemplate.TemplateName)));
            }

            //if we got this far this is a 404

            SettingGroup SettingGroup = SettingGroupDAO.LoadSettingGroupByName(SettingGroupKeys.TEMPLATE_CUSTOM_SETTINGS);

            ViewBag.ViewType = SettingGroup.GetSettingVal("PageNotFoundPage");

            return(View("PageNotFound", String.Format("~/Templates/{0}/Views/Shared/Template.Master", Models.ChimeraTemplate.TemplateName)));
        }
Пример #3
0
        public ActionResult CapturePayment(string id)
        {
            try
            {
                PurchaseOrderDetails PurchaseOrderDetail = PurchaseOrderDetailsDAO.LoadByBsonId(id);

                SettingGroup PayPalSettings = SettingGroupDAO.LoadSettingGroupByName(SettingGroupKeys.PAYPAL_PURCHASE_SETTINGS);

                //create auth header obj
                AuthHeader PayPalAuthHeader = Chimera.Core.PurchaseOrders.PayPalAuthHeader.GetAuthHeaderFromSetting(PayPalSettings);

                OrderDetails CapturedOrderDetails = CompanyCommons.Ecommerce.PayPal.Functions.Execute.CapturePayment(PayPalAuthHeader, PurchaseOrderDetail.PayPalOrderDetails);

                if (CapturedOrderDetails != null)
                {
                    PurchaseOrderDetail.PayPalOrderDetails = CapturedOrderDetails;

                    if (PurchaseOrderDetailsDAO.Save(PurchaseOrderDetail))
                    {
                        Chimera.Core.Notifications.PurchaseOrder.ProcessPurchaseOrderPaymentCaptured(PurchaseOrderDetail);

                        AddWebUserMessageToSession(Request, String.Format("PayPal payment successfully captured!"), SUCCESS_MESSAGE_TYPE);
                    }
                    else
                    {
                        AddWebUserMessageToSession(Request, String.Format("Unable to capture PayPal payment at this time."), FAILED_MESSAGE_TYPE);
                    }
                }
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PurchaseOrdersController.CapturePayment()" + e.Message);
            }

            return(RedirectToAction("Search", "PurchaseOrders"));
        }