public override void HandleAuthorizationAmountNotification( string requestXml, AuthorizationAmountNotification notification) { GoogleCheckoutLog gLog = new GoogleCheckoutLog(); gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider"; gLog.NotificationType = "AuthorizationAmountNotification"; gLog.RawResponse = requestXml; gLog.SerialNumber = notification.serialnumber; gLog.OrderNumber = notification.googleordernumber; gLog.GTimestamp = notification.timestamp; gLog.AuthAmt = notification.authorizationamount.Value; gLog.AuthExpDate = notification.authorizationexpirationdate; gLog.CvnResponse = notification.cvnresponse; gLog.AvsResponse = notification.avsresponse; gLog.Save(); Guid orderGuid = GoogleCheckoutLog.GetCartGuidFromOrderNumber(notification.googleordernumber); if (orderGuid == Guid.Empty) return; Order order = new Order(orderGuid); if (order.OrderGuid != orderGuid) return; Store store = new Store(order.StoreGuid); if (store.Guid != order.StoreGuid) return; gLog.SiteGuid = store.SiteGuid; gLog.UserGuid = order.UserGuid; gLog.CartGuid = order.OrderGuid; gLog.StoreGuid = order.StoreGuid; gLog.Save(); }
public override bool HandleRequest( WorldPayPaymentResponse wpResponse, PayPalLog worldPayLog, Page page) { bool result = false; if (worldPayLog.SerializedObject.Length == 0) { return result; } Cart cart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), worldPayLog.SerializedObject); Store store = new Store(cart.StoreGuid); //SiteSettings siteSettings = new SiteSettings(store.SiteGuid); config = SiteUtils.GetCommerceConfig(); switch (wpResponse.TransStatus) { case "Y": //success ProcessOrder(cart, store, wpResponse, worldPayLog, page); result = true; break; case "C": // cancelled default: ProcessCancellation(cart, store, wpResponse, worldPayLog, page); break; } return result; }
private void ProcessCancellation( Cart cart, Store store, WorldPayPaymentResponse wpResponse, PayPalLog worldPayLog, Page page) { //string serializedResponse = SerializationHelper.SerializeToString(wpResponse); //log.Info("received cancellation worldpay postback, xml to follow"); //log.Info(serializedResponse); // return an html order cancelled template for use at world pay if (config.WorldPayProduceShopperCancellationResponse) { string htmlTemplate = ResourceHelper.GetMessageTemplate(CultureInfo.CurrentUICulture, config.WorldPayShopperCancellationResponseTemplate); StringBuilder finalOutput = new StringBuilder(); finalOutput.Append(htmlTemplate); finalOutput.Replace("#WorldPayBannerToken", "<WPDISPLAY ITEM=banner>"); //required by worldpay finalOutput.Replace("#CustomerName", wpResponse.Name); finalOutput.Replace("#StoreName", store.Name); string storePageUrl = worldPayLog.RawResponse; finalOutput.Replace("#StorePageLink", "<a href='" + storePageUrl + "'>" + storePageUrl + "</a>"); page.Response.Write(finalOutput.ToString()); page.Response.Flush(); } }
public static bool ApplyDiscount(Store store, Cart cart, string discountCode, out string errorMessage) { if (cart == null) { errorMessage = WebStoreResources.DiscountInvalidCartError; return false; } if (store == null) { errorMessage = WebStoreResources.DiscountInvalidCartError; return false; } if (string.IsNullOrEmpty(discountCode)) { errorMessage = WebStoreResources.DiscountCodeNotProvidedError; return false; } Discount discount = new Discount(store.ModuleGuid, discountCode); if (discount.DiscountGuid == Guid.Empty) { errorMessage = WebStoreResources.DiscountCodeNotFoundError; return false; } if (discount.ValidityEndDate < DateTime.UtcNow) { errorMessage = WebStoreResources.DiscountCodeExpiredError; return false; } if (discount.ValidityStartDate > DateTime.UtcNow) { errorMessage = WebStoreResources.DiscountCodeNotActiveError; return false; } if (!discount.AllowOtherDiscounts) { cart.DiscountCodesCsv = discount.DiscountCode; } if (cart.DiscountCodesCsv.Length == 0) { cart.DiscountCodesCsv = discount.DiscountCode; } else { if (!cart.DiscountCodesCsv.Contains(discount.DiscountCode)) { cart.DiscountCodesCsv += "," + discount.DiscountCode; } } return ValidateAndApplyDiscounts(store, cart, out errorMessage); }
public override void ContentChangedHandler( object sender, ContentChangedEventArgs e) { if (WebConfigSettings.DisableSearchIndex) { return; } if (sender == null) return; if (!(sender is Product)) return; Product product = sender as Product; SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); product.SiteId = siteSettings.SiteId; product.SearchIndexPath = mojoPortal.SearchIndex.IndexHelper.GetSearchIndexPath(siteSettings.SiteId); if (e.IsDeleted) { Store store = new Store(product.StoreGuid); // get list of pages where this module is published List<PageModule> pageModules = PageModule.GetPageModulesByModule(store.ModuleId); foreach (PageModule pageModule in pageModules) { mojoPortal.SearchIndex.IndexHelper.RemoveIndexItem( pageModule.PageId, store.ModuleId, product.Guid.ToString()); } } else { if (ThreadPool.QueueUserWorkItem(new WaitCallback(IndexItem), product)) { if (debugLog) log.Debug("ProductSearchIndexBuilder.IndexItem queued"); } else { log.Error("Failed to queue a thread for ProductSearchIndexBuilder.IndexItem"); } } }
public static Store GetStore() { int pageId = WebUtils.ParseInt32FromQueryString("pageid", -1); int moduleId = WebUtils.ParseInt32FromQueryString("mid", -1); if (moduleId == -1) { PageSettings currentPage = CacheHelper.GetCurrentPage(); if (currentPage != null) moduleId = FindStoreModuleId(currentPage); } if (moduleId == -1) return null; if (pageId == -1) return null; string key = "WebStore" + moduleId.ToString(CultureInfo.InvariantCulture); if (HttpContext.Current.Items[key] != null) { return (Store)HttpContext.Current.Items[key]; } SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if ((siteSettings == null) || (siteSettings.SiteGuid == Guid.Empty)) return null; Module module = new Module(moduleId, pageId); if (module.SiteId != siteSettings.SiteId) return null; if (module.FeatureGuid != new Guid("0cefbf18-56de-11dc-8f36-bac755d89593")) return null; Store store = new Store(siteSettings.SiteGuid, moduleId); if (store.Guid == Guid.Empty) // No store created yet { store = new Store(); store.SiteGuid = siteSettings.SiteGuid; store.ModuleId = moduleId; store.Save(); } HttpContext.Current.Items.Add(key, store); return store; }
public static bool ValidateAndApplyDiscounts(Store store, Cart cart, out string errorMessage) { if (cart == null) { errorMessage = WebStoreResources.DiscountInvalidCartError; return false; } if (store == null) { errorMessage = WebStoreResources.DiscountInvalidCartError; return false; } errorMessage = string.Empty; List<Discount> discountList = Discount.GetValidDiscounts(store.ModuleGuid, cart, cart.DiscountCodesCsv); cart.Discount = 0; cart.RefreshTotals(); cart.DiscountCodesCsv = string.Empty; if (cart.SubTotal <= 0) { cart.Save(); return false; } string comma = string.Empty; bool appliedDiscount = false; foreach (Discount d in discountList) { cart.DiscountCodesCsv += comma + d.DiscountCode; comma = ","; if (d.AbsoluteDiscount > 0) { cart.Discount += d.AbsoluteDiscount; appliedDiscount = true; } if (d.PercentageDiscount > 0) { cart.Discount += (cart.SubTotal * d.PercentageDiscount); appliedDiscount = true; } } cart.RefreshTotals(); if (!appliedDiscount) { errorMessage = WebStoreResources.DiscountInvalidCartError; } return appliedDiscount; }
private void LoadSettings() { commerceConfig = SiteUtils.GetCommerceConfig(); store = StoreHelper.GetStore(); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); if((store != null)&&(offerGuid != Guid.Empty)) { offer = new Offer(offerGuid); offerPrice = offer.Price; } teaserFileBaseUrl = WebUtils.GetSiteRoot() + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/webstoreproductpreviewfiles/"; AddClassToBody("webstore webstoreofferdetail"); }
private static PayPalLog CreatePayPalStandardCheckoutLog( Cart cart, Store store, string siteRoot, int pageId, int moduleId) { PayPalLog payPalLog = new PayPalLog(); payPalLog.ProviderName = "WebStorePayPalHandler"; payPalLog.PDTProviderName = "WebStorePayPalPDTHandlerProvider"; payPalLog.IPNProviderName = "WebStorePayPalIPNHandlerProvider"; payPalLog.ReturnUrl = siteRoot + "/WebStore/OrderDetail.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&orderid=" + cart.CartGuid.ToString(); payPalLog.RequestType = "StandardCheckout"; cart.SerializeCartOffers(); payPalLog.SerializedObject = SerializationHelper.SerializeToString(cart); //Currency currency = new Currency(store.DefaultCurrencyId); payPalLog.CartGuid = cart.CartGuid; //Store store = new Store(cart.StoreGuid); payPalLog.SiteGuid = store.SiteGuid; payPalLog.StoreGuid = store.Guid; payPalLog.UserGuid = cart.UserGuid; payPalLog.CartTotal = cart.OrderTotal; //payPalLog.CurrencyCode = currency.Code; SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); payPalLog.CurrencyCode = siteSettings.GetCurrency().Code; payPalLog.Save(); return payPalLog; }
private void LoadSettings() { pageId = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleId = WebUtils.ParseInt32FromQueryString("mid", true, -1); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); store = StoreHelper.GetStore(); if (store == null) { return; } siteUser = SiteUtils.GetCurrentSiteUser(); productGuid = WebUtils.ParseGuidFromQueryString("prod", productGuid); virtualRoot = WebUtils.GetApplicationRoot(); upLoadPath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/webstoreproductfiles/"; teaserFileBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/webstoreproductpreviewfiles/"; AddClassToBody("webstore webstoreproductedit"); FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider]; if (p == null) { log.Error("Could not load file system provider " + WebConfigSettings.FileSystemProvider); return; } fileSystem = p.GetFileSystem(); if (fileSystem == null) { log.Error("Could not load file system from provider " + WebConfigSettings.FileSystemProvider); return; } if (!fileSystem.FolderExists(upLoadPath)) { fileSystem.CreateFolder(upLoadPath); } if (!fileSystem.FolderExists(teaserFileBasePath)) { fileSystem.CreateFolder(teaserFileBasePath); } if (productGuid == Guid.Empty) { return; } productUploader.ServiceUrl = SiteRoot + "/WebStore/upload.ashx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&prod=" + productGuid.ToString() ; productUploader.UploadButtonClientId = btnUpload.ClientID; productUploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form string refreshFunction = "function refresh" + moduleId.ToInvariantString() + " (data, errorsOccurred) { if(errorsOccurred === false) { $('#" + btnSave.ClientID + "').click(); } } "; productUploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString(); ScriptManager.RegisterClientScriptBlock( this, this.GetType(), "refresh" + moduleId.ToInvariantString(), refreshFunction, true); teaserUploader.ServiceUrl = SiteRoot + "/WebStore/upload.ashx?type=teaser&pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&prod=" + productGuid.ToString(); teaserUploader.UploadButtonClientId = btnUploadTeaser.ClientID; teaserUploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form teaserUploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString(); }
public override void HandleOrderStateChangeNotification( string requestXml, OrderStateChangeNotification notification) { GoogleCheckoutLog gLog = new GoogleCheckoutLog(); Guid orderGuid = GoogleCheckoutLog.GetCartGuidFromOrderNumber(notification.googleordernumber); gLog.RawResponse = requestXml; gLog.NotificationType = "OrderStateChangeNotification"; gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider"; gLog.SerialNumber = notification.serialnumber; gLog.OrderNumber = notification.googleordernumber; gLog.FinanceState = notification.newfinancialorderstate.ToString(); gLog.FullfillState = notification.newfulfillmentorderstate.ToString(); gLog.GTimestamp = notification.timestamp; gLog.AvsResponse = notification.reason; gLog.CartGuid = orderGuid; gLog.Save(); if (orderGuid == Guid.Empty) return; Order order = new Order(orderGuid); if (order.OrderGuid != orderGuid) return; Store store = new Store(order.StoreGuid); if (store.Guid != order.StoreGuid) return; gLog.SiteGuid = store.SiteGuid; gLog.UserGuid = order.UserGuid; gLog.CartGuid = order.OrderGuid; gLog.StoreGuid = order.StoreGuid; gLog.Save(); if (notification.newfinancialorderstate == FinancialOrderState.CHARGED) { order.StatusGuid = OrderStatus.OrderStatusFulfillableGuid; order.Save(); if (!order.HasShippingProducts()) { // order only has download products so tell google the order is fulfilled try { CommerceConfiguration commerceConfig = SiteUtils.GetCommerceConfig(); string gEvironment; if (commerceConfig.GoogleEnvironment == GCheckout.EnvironmentType.Sandbox) { gEvironment = "Sandbox"; } else { gEvironment = "Production"; } GCheckout.OrderProcessing.DeliverOrderRequest fulfillNotification = new GCheckout.OrderProcessing.DeliverOrderRequest( commerceConfig.GoogleMerchantID, commerceConfig.GoogleMerchantKey, gEvironment, notification.googleordernumber); fulfillNotification.Send(); StoreHelper.ConfirmOrder(store, order); PayPalLog.DeleteByCart(order.OrderGuid); log.Info("Sent DeliverOrderRequest to google api for google order " + notification.googleordernumber); } catch (Exception ex) { log.Error(ex); } } } }
public static void EnsureValidDiscounts(Store store, Cart cart) { string errorMessage = string.Empty; ValidateAndApplyDiscounts(store, cart, out errorMessage); }
private void LoadSettings() { PageId = WebUtils.ParseInt32FromQueryString("pageid", -1); ModuleId = WebUtils.ParseInt32FromQueryString("mid", -1); payPalGetExpressCheckoutLogGuid = WebUtils.ParseGuidFromQueryString("plog", payPalGetExpressCheckoutLogGuid); if (payPalGetExpressCheckoutLogGuid == Guid.Empty) { Response.Redirect(SiteUtils.GetCurrentPageUrl()); } checkoutDetailsLog = new PayPalLog(payPalGetExpressCheckoutLogGuid); if (checkoutDetailsLog.RowGuid == Guid.Empty) { Response.Redirect(SiteUtils.GetCurrentPageUrl()); } cart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), checkoutDetailsLog.SerializedObject); if (cart == null) { Response.Redirect(SiteUtils.GetCurrentPageUrl()); } cart.DeSerializeCartOffers(); cart.RefreshTotals(); if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0)) { StoreHelper.EnsureValidDiscounts(store, cart); } siteUser = SiteUtils.GetCurrentSiteUser(); //if (siteUser == null) //{ // Response.Redirect(SiteUtils.GetCurrentPageUrl()); //} if ((siteUser != null)&&(cart.UserGuid == Guid.Empty)) { // user wasn't logged in when express checkout was called cart.UserGuid = siteUser.UserGuid; cart.Save(); //if (checkoutDetailsLog.UserGuid == Guid.Empty) //{ // // we need to make sure we have the user in the log and serialized cart // checkoutDetailsLog.UserGuid = siteUser.UserGuid; // cart.SerializeCartOffers(); // checkoutDetailsLog.SerializedObject = SerializationHelper.SerializeToSoap(cart); // checkoutDetailsLog.Save(); //} } if ((siteUser != null)&&(cart.UserGuid != siteUser.UserGuid)) { Response.Redirect(SiteUtils.GetCurrentPageUrl()); } if (ModuleId == -1) { ModuleId = StoreHelper.FindStoreModuleId(CurrentPage); } store = StoreHelper.GetStore(); commerceConfig = SiteUtils.GetCommerceConfig(); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); if (siteUser != null) { pnlRequireLogin.Visible = false; } else { btnMakePayment.Visible = false; } AddClassToBody("webstore webstoreexpresscheckout"); }
/// <summary> /// This method sends confirmation that the order was received and is being processed by the payment processor, ie PayPal or Google Checkout, but payment has not yet cleared /// </summary> /// <param name="store"></param> /// <param name="order"></param> public static void ConfirmOrderReceived(Store store, Order order) { ConfirmOrderReceived(store, order, false); }
public static void ConfirmOrderReceived(Store store, Order order, bool isEcheck) { CommerceConfiguration commerceConfig = SiteUtils.GetCommerceConfig(); CultureInfo defaultCulture = SiteUtils.GetDefaultUICulture(); SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); CultureInfo currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); string subjectTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, commerceConfig.DefaultOrderReceivedEmailSubjectTemplate); string textBodyTemplate; if (isEcheck) { textBodyTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, commerceConfig.DefaultEcheckOrderReceivedEmailTextBodyTemplate); } else { textBodyTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, commerceConfig.DefaultOrderReceivedEmailTextBodyTemplate); } int pageId = -1; List<PageModule> pageModules = PageModule.GetPageModulesByModule(store.ModuleId); foreach (PageModule pm in pageModules) { // use first pageid found, really a store should only // be on one page pageId = pm.PageId; break; } SendConfirmEmail( defaultCulture, currencyCulture, siteSettings, pageId, commerceConfig, store, order, subjectTemplate, textBodyTemplate); }
public static void ConfirmOrder(Store store, Order order) { if (store == null) { return; } if (order == null) { return; } CommerceConfiguration commerceConfig = SiteUtils.GetCommerceConfig(); CultureInfo defaultCulture = SiteUtils.GetDefaultUICulture(); string subjectTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, commerceConfig.DefaultConfirmationEmailSubjectTemplate); string textBodyTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, commerceConfig.DefaultConfirmationEmailTextBodyTemplate); int pageId = -1; List<PageModule> pageModules = PageModule.GetPageModulesByModule(store.ModuleId); foreach (PageModule pm in pageModules) { // use first pageid found, really a store should only // be on one page pageId = pm.PageId; break; } Module m = new Module(store.ModuleId); Order.EnsureSalesReportData(order.OrderGuid, m.ModuleGuid, pageId, store.ModuleId); SiteUser.UpdateTotalRevenue(order.UserGuid); SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); CultureInfo currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); OrderCompletedEventArgs e = new OrderCompletedEventArgs(order, currencyCulture); foreach (OrderCompletedHandlerProvider p in OrderCompletedHandlerProviderManager.Providers) { try { p.HandelOrderCompleted(e); } catch (Exception ex) { log.Error(ex); } } //TODO: make this asynchronous so if it takes a long time or has a timeout error it does //not prevent the redirect SendConfirmEmail( defaultCulture, currencyCulture, siteSettings, pageId, commerceConfig, store, order, subjectTemplate, textBodyTemplate); }
private static void SendConfirmEmail( CultureInfo defaultCulture, CultureInfo currencyCulture, SiteSettings siteSettings, int pageId, CommerceConfiguration commerceConfig, Store store, Order order, string subjectTemplate, string textBodyTemplate) { if (store == null) { return; } if (order == null) { return; } if(siteSettings == null) { return; } if (!ShouldSendConfirmation(siteSettings.SiteId, order)) { log.Info("confirmation email for order " + order.OrderGuid.ToString() + " not sent due to disabled by configuration"); return; } //SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); //CultureInfo currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); //EmailMessageTask messageTask = new EmailMessageTask(SiteUtils.GetSmtpSettings()); //messageTask.EmailFrom = store.SalesEmail; // TODO: implement from alias for store //messageTask.EmailFromAlias = siteSettings.DefaultFromEmailAlias; string email; if (order.CustomerEmail.Length > 0) { //messageTask.EmailTo = order.CustomerEmail; email = order.CustomerEmail; } else { SiteUser siteUser = new SiteUser(siteSettings, order.UserGuid); //messageTask.EmailTo = siteUser.Email; email = siteUser.Email; } //if (store.OrderBccEmail.Length > 0) //{ // messageTask.EmailBcc = store.OrderBccEmail; //} PageSettings page = new PageSettings(siteSettings.SiteId, pageId); string siteRoot = SiteUtils.GetNavigationSiteRoot(); string storeLink = string.Empty; if (page.Url.StartsWith("~/")) { storeLink = siteRoot + page.Url.Replace("~/", "/"); } else { storeLink = siteRoot; } string orderLink = siteRoot + "/WebStore/OrderDetail.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + store.ModuleId.ToInvariantString() + "&orderid=" + order.OrderGuid.ToString(); StringBuilder orderDetails = new StringBuilder(); DataSet dsOffers = Order.GetOrderOffersAndProducts(store.Guid, order.OrderGuid); foreach (DataRow row in dsOffers.Tables["Offers"].Rows) { string og = row["OfferGuid"].ToString(); orderDetails.Append(row["Name"].ToString() + " "); orderDetails.Append(row["Quantity"].ToString() + " @ "); orderDetails.Append(string.Format(currencyCulture, "{0:c}", Convert.ToDecimal(row["OfferPrice"]))); orderDetails.Append("\r\n"); string whereClause = string.Format("OfferGuid = '{0}'", og); DataView dv = new DataView(dsOffers.Tables["Products"], whereClause, "", DataViewRowState.CurrentRows); if (dv.Count > 1) { foreach (DataRow r in dsOffers.Tables["Products"].Rows) { string pog = r["OfferGuid"].ToString(); if (og == pog) { orderDetails.Append(r["Name"].ToString() + " "); orderDetails.Append(r["Quantity"].ToString() + " \r\n"); } } } } //messageTask.Subject = string.Format( // defaultCulture, // subjectTemplate, // store.Name, // order.OrderGuid.ToString() // ); //messageTask.TextBody = string.Format( // defaultCulture, // textBodyTemplate, // order.CustomerFirstName + " " + order.CustomerLastName, // store.Name, // order.OrderGuid.ToString(), // storeLink, // orderLink, // orderDetails.ToString(), // order.OrderTotal.ToString("c", currencyCulture), // order.ShippingTotal.ToString("c", currencyCulture), // order.TaxTotal.ToString("c", currencyCulture), // order.SubTotal.ToString("c", currencyCulture), // order.Discount.ToString("c", currencyCulture) // ).ToAscii(); //messageTask.SiteGuid = siteSettings.SiteGuid; //messageTask.QueueTask(); //WebTaskManager.StartOrResumeTasks(); string fromAddress = store.EmailFrom; if (fromAddress.Length == 0) { fromAddress = siteSettings.DefaultEmailFromAddress; } Email.Send( SiteUtils.GetSmtpSettings(), fromAddress, string.Empty, string.Empty, email, string.Empty, store.OrderBccEmail, string.Format(defaultCulture, subjectTemplate, store.Name, order.OrderGuid.ToString()), string.Format( defaultCulture, textBodyTemplate, order.CustomerFirstName + " " + order.CustomerLastName, store.Name, order.OrderGuid.ToString(), storeLink, orderLink, orderDetails.ToString(), order.OrderTotal.ToString("c", currencyCulture), order.ShippingTotal.ToString("c", currencyCulture), order.TaxTotal.ToString("c", currencyCulture), order.SubTotal.ToString("c", currencyCulture), order.Discount.ToString("c", currencyCulture) ), false, Email.PriorityNormal); }
// we are using the paypal log with a different request type rather than making a new log specifically for WorldPay private static PayPalLog CreateWorldPayCheckoutLog( Cart cart, Store store, string siteRoot, string storePageUrl, int pageId, int moduleId) { PayPalLog worldPayLog = new PayPalLog(); worldPayLog.ProviderName = "WebStoreWorldPayResponseHandler"; worldPayLog.RequestType = "WorldPay"; worldPayLog.RawResponse = storePageUrl; worldPayLog.ReturnUrl = siteRoot + "/WebStore/OrderDetail.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&orderid=" + cart.CartGuid.ToString(); cart.SerializeCartOffers(); worldPayLog.SerializedObject = SerializationHelper.SerializeToString(cart); worldPayLog.CartGuid = cart.CartGuid; worldPayLog.SiteGuid = store.SiteGuid; worldPayLog.StoreGuid = store.Guid; worldPayLog.UserGuid = cart.UserGuid; worldPayLog.CartTotal = cart.OrderTotal; SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); worldPayLog.CurrencyCode = siteSettings.GetCurrency().Code; worldPayLog.Save(); return worldPayLog; }
private static Cart CreateCartAndSetCookie(Store store) { if (store == null) return null; if (store.Guid == Guid.Empty) return null; string cartKey = "cart" + store.Guid.ToString(); Cart cart = new Cart(); cart.StoreGuid = store.Guid; cart.CreatedFromIP = SiteUtils.GetIP4Address(); if ( (HttpContext.Current != null) && (HttpContext.Current.Request.IsAuthenticated) ) { SiteUser siteUser = SiteUtils.GetCurrentSiteUser(); cart.UserGuid = siteUser.UserGuid; cart.LoadExistingUserCartIfExists(); } cart.Save(); SetCartCookie(store.Guid, cart.CartGuid); HttpContext.Current.Items[cartKey] = cart; return cart; }
/// <summary> /// we are using the paypal log with a different request type rather than making a new log specifically for WorldPay /// /// The goal here is to make sure we always have a PayPalLog with current cart serialized. /// We need to do this because we could transfer the user to WorldPay, then they add more items to the cart, /// then complete the checkout at WorldPay for the previous version of the cart. /// If we were to just use the current cart from the db we might give them more or less than they actually /// bought. By keeping a copy of the cart as it was at time of transfer, we can be sure /// we only give them the products they had at checkout time. /// </summary> public static PayPalLog EnsureWorldPayCheckoutLog( Cart cart, Store store, string siteRoot, string storePageUrl, int pageId, int moduleId) { if (cart == null) return null; if (store == null) return null; PayPalLog worldPayLog = PayPalLog.GetMostRecent(cart.CartGuid, "WorldPay"); if ((worldPayLog == null) || (worldPayLog.SerializedObject.Length == 0)) { return CreateWorldPayCheckoutLog(cart, store, siteRoot, storePageUrl, pageId, moduleId); } Cart worldPayCart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), worldPayLog.SerializedObject); if (worldPayCart.LastModified < cart.LastModified) { // cart has been modified since we last serialized it so create a new one return CreateWorldPayCheckoutLog(cart, store, siteRoot, storePageUrl, pageId, moduleId); } return worldPayLog; }
private static Cart CreateClerkCartAndSetCookie(Store store, string cartKey) { if (store == null) return null; if (store.Guid == Guid.Empty) return null; Cart cart = new Cart(); cart.StoreGuid = store.Guid; cart.CreatedFromIP = SiteUtils.GetIP4Address(); if ( (HttpContext.Current != null) && (HttpContext.Current.Request.IsAuthenticated) ) { SiteUser siteUser = SiteUtils.GetCurrentSiteUser(); cart.ClerkGuid = siteUser.UserGuid; } cart.Save(); CookieHelper.SetPersistentCookie(cartKey, cart.CartGuid.ToString()); HttpContext.Current.Items[cartKey] = cart; return cart; }
/// <summary> /// Creates the URL for PayPal Standard BuyNow button /// </summary> /// <returns></returns> public static string GetBuyNowUrl( Guid payPalLogGuid, Cart cart, Store store, CommerceConfiguration commerceConfig) { //PayPalStandardPaymentGateway gateway = new PayPalStandardPaymentGateway(); //gateway.PayPalStandardUrl = commerceConfig.PayPalStandardUrl; //gateway.BusinessEmail = commerceConfig.PayPalStandardEmailAddress; //gateway.PDTId = commerceConfig.PayPalStandardPDTId; PayPalStandardPaymentGateway gateway = new PayPalStandardPaymentGateway( commerceConfig.PayPalStandardUrl, commerceConfig.PayPalStandardEmailAddress, commerceConfig.PayPalStandardPDTId); gateway.Amount = cart.OrderTotal; gateway.Tax = cart.TaxTotal; gateway.Shipping = cart.ShippingTotal; //Currency currency = new Currency(cart.CurrencyGuid); //gateway.CurrencyCode = store.DefaultCurrency; SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); gateway.CurrencyCode = siteSettings.GetCurrency().Code; gateway.OrderHasShippableProducts = cart.HasShippingProducts(); // TODO: guess we need to split this into first and last gateway.ShippingFirstName = cart.OrderInfo.DeliveryFirstName; gateway.ShippingLastName = cart.OrderInfo.DeliveryLastName; gateway.ShippingAddress1 = cart.OrderInfo.DeliveryAddress1; gateway.ShippingAddress2 = cart.OrderInfo.DeliveryAddress2; gateway.ShippingCity = cart.OrderInfo.DeliveryCity; gateway.ShippingState = cart.OrderInfo.DeliveryState; gateway.ShippingPostalCode = cart.OrderInfo.DeliveryPostalCode; //add the items //foreach (CartOffer offer in cart.CartOffers) //{ // PayPalOrderItem item = new PayPalOrderItem(); // item.Amount = offer.OfferPrice; // item.ItemName = offer.Name; // item.ItemNumber = offer.OfferGuid.ToString(); // item.Quantity = offer.Quantity; // gateway.Items.Add(item); //} gateway.OrderDescription = store.Name + " " + WebStoreResources.OrderHeading; gateway.Custom = payPalLogGuid.ToString(); string siteRoot = SiteUtils.GetNavigationSiteRoot(); string storePageUrl = SiteUtils.GetCurrentPageUrl(); gateway.ReturnUrl = siteRoot + "/Services/PayPalPDTHandler.aspx"; gateway.NotificationUrl = siteRoot + "/Services/PayPalIPNHandler.aspx"; gateway.CancelUrl = storePageUrl; return gateway.GetBuyNowButtonUrl(); }
private void LoadSettings() { store = StoreHelper.GetStore(); if (store == null) { return; } commerceConfig = SiteUtils.GetCommerceConfig(); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); if (Request.IsAuthenticated) { siteUser = SiteUtils.GetCurrentSiteUser(); } if (StoreHelper.UserHasCartCookie(store.Guid)) { cart = StoreHelper.GetCart(); if (cart != null) { cartOffers = cart.GetOffers(); canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart); if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0)) { StoreHelper.EnsureValidDiscounts(store, cart); } if ((cart.UserGuid == Guid.Empty)&&(siteUser != null)) { cart.UserGuid = siteUser.UserGuid; cart.Save(); } cart.RefreshTotals(); } } ConfigureCheckoutButtons(); AddClassToBody("webstore webstorecheckout"); }
public override string HandleRequestAndReturnUrlForRedirect( HttpContext context, string payPalToken, string payPalPayerId, PayPalLog setExpressCheckoutLog) { string redirectUrl = string.Empty; if ((payPalToken == null) || (payPalToken.Length == 0)) { log.Error("WebStorePayPalReturnHandler received empty payPalToken"); return redirectUrl; } if (setExpressCheckoutLog == null) { log.Error("WebStorePayPalReturnHandler received null setExpressCheckoutLog for payPalToken " + payPalToken); return redirectUrl; } if (setExpressCheckoutLog.SerializedObject.Length == 0) { log.Error("WebStorePayPalReturnHandler cart was not previously serialized for payPalToken " + payPalToken); return redirectUrl; } if (setExpressCheckoutLog.CreatedUtc.AddHours(4) < DateTime.UtcNow) { log.Error("payPalToken " + payPalToken + " was more than 4 hours old, it should expire after 3 hours "); return redirectUrl; } CommerceConfiguration commerceConfig = SiteUtils.GetCommerceConfig(); PayPalExpressGateway gateway = new PayPalExpressGateway( commerceConfig.PayPalAPIUsername, commerceConfig.PayPalAPIPassword, commerceConfig.PayPalAPISignature, commerceConfig.PayPalStandardEmailAddress); gateway.UseTestMode = commerceConfig.PaymentGatewayUseTestMode; gateway.PayPalToken = payPalToken; gateway.PayPalPayerId = payPalPayerId; Cart savedCart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), setExpressCheckoutLog.SerializedObject); savedCart.DeSerializeCartOffers(); string siteRoot = SiteUtils.GetNavigationSiteRoot(); gateway.MerchantCartId = savedCart.CartGuid.ToString(); gateway.ChargeTotal = savedCart.OrderTotal; gateway.ReturnUrl = siteRoot + "/Services/PayPalReturnHandler.ashx"; gateway.CancelUrl = siteRoot; //gateway.PayPalPayerId = payPalPayerId; gateway.CallGetExpressCheckoutDetails(); PayPalLog payPalLog = new PayPalLog(); payPalLog.ProviderName = WebStorePayPalReturnHandler.ProviderName; payPalLog.SerializedObject = setExpressCheckoutLog.SerializedObject; payPalLog.ReturnUrl = setExpressCheckoutLog.ReturnUrl; payPalLog.RawResponse = gateway.RawResponse; payPalLog.TransactionId = gateway.TransactionId; payPalLog.CurrencyCode = gateway.CurrencyCode; // TODO: add versions to gateways //log.ApiVersion = gateway. payPalLog.CartGuid = savedCart.CartGuid; Store store = new Store(savedCart.StoreGuid); payPalLog.Token = payPalToken; payPalLog.PayerId = payPalPayerId; payPalLog.RequestType = "GetExpressCheckoutDetails"; payPalLog.SiteGuid = store.SiteGuid; payPalLog.StoreGuid = store.Guid; payPalLog.UserGuid = savedCart.UserGuid; // update the order with customer shipping info savedCart.OrderInfo.DeliveryCompany = gateway.ShipToCompanyName; savedCart.OrderInfo.DeliveryAddress1 = gateway.ShipToAddress; savedCart.OrderInfo.DeliveryAddress2 = gateway.ShipToAddress2; savedCart.OrderInfo.DeliveryCity = gateway.ShipToCity; savedCart.OrderInfo.DeliveryFirstName = gateway.ShipToFirstName; savedCart.OrderInfo.DeliveryLastName = gateway.ShipToLastName; savedCart.OrderInfo.DeliveryPostalCode = gateway.ShipToPostalCode; savedCart.OrderInfo.DeliveryState = gateway.ShipToState; savedCart.OrderInfo.DeliveryCountry = gateway.ShipToCountry; //Note that PayPal only returns a phone number if your Merchant accounts is configured to require the // buyer to provide it. if (gateway.ShipToPhone.Length > 0) { savedCart.OrderInfo.CustomerTelephoneDay = gateway.ShipToPhone; } if (gateway.BuyerEmail.Length > 0) { savedCart.OrderInfo.CustomerEmail = gateway.BuyerEmail; } // if customer and billing aren't populated already, user was anonymous when checkout began, make them the same as shipping //if (savedCart.UserGuid == Guid.Empty) //{ //2013-12-23 since all we get is shipping address this can be considered as the same thing as billing address for paypal purposes so always use it // especially because we may need to calculate tax for express checkout // based on the address provided by paypal savedCart.CopyShippingToBilling(); savedCart.CopyShippingToCustomer(); //} GeoCountry country = new GeoCountry(savedCart.OrderInfo.DeliveryCountry); GeoZone taxZone = GeoZone.GetByCode(country.Guid, savedCart.OrderInfo.DeliveryState); savedCart.OrderInfo.TaxZoneGuid = taxZone.Guid; savedCart.OrderInfo.Save(); // refresh totals to calculate tax or shipping now that we have an address savedCart.RefreshTotals(); savedCart.Save(); savedCart.SerializeCartOffers(); payPalLog.SerializedObject = SerializationHelper.SerializeToString(savedCart); payPalLog.Save(); if (gateway.Response == PaymentGatewayResponse.Error) { redirectUrl = siteRoot + "/WebStore/PayPalGatewayError.aspx?plog=" + payPalLog.RowGuid.ToString(); return redirectUrl; } if (gateway.PayPalPayerId.Length == 0) { redirectUrl = siteRoot + "/WebStore/PayPalGatewayError.aspx?plog=" + payPalLog.RowGuid.ToString(); return redirectUrl; } int pageId = -1; List<PageModule> pageModules = PageModule.GetPageModulesByModule(store.ModuleId); foreach (PageModule pm in pageModules) { // use first pageid found, really a store should only // be on one page pageId = pm.PageId; break; } // after the CallGetExpressCheckoutDetails // we have the option of directing to a final review page before // calling CallDoExpressCheckoutPayment redirectUrl = siteRoot + "/WebStore/PayPalExpressCheckout.aspx?pageid=" + pageId.ToString(CultureInfo.InvariantCulture) + "&mid=" + store.ModuleId.ToString(CultureInfo.InvariantCulture) + "&plog=" + payPalLog.RowGuid.ToString(); return redirectUrl; }
public override void HandleNewOrderNotificationExtended( string requestXml, NewOrderNotificationExtended newOrder, MerchantData merchantData) { //NotificationSerialNumber = newOrder.serialnumber; GoogleCheckoutLog gLog = new GoogleCheckoutLog(); gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider"; gLog.RawResponse = requestXml; gLog.NotificationType = "NewOrderNotification"; gLog.SerialNumber = newOrder.serialnumber; gLog.OrderNumber = newOrder.googleordernumber; gLog.OrderTotal = newOrder.ordertotal.Value; gLog.BuyerId = newOrder.buyerid.ToString(CultureInfo.InvariantCulture); gLog.FullfillState = newOrder.fulfillmentorderstate.ToString(); gLog.FinanceState = newOrder.financialorderstate.ToString(); gLog.ShippingTotal = newOrder.ShippingCost; gLog.TaxTotal = newOrder.orderadjustment.totaltax.Value; //gLog.DiscountTotal = ext.orderadjustment.adjustmenttotal.Value; gLog.EmailListOptIn = newOrder.buyermarketingpreferences.emailallowed; gLog.GTimestamp = newOrder.timestamp; gLog.CartXml = SerializationHelper.RestoreXmlDeclaration(merchantData.SerializedObject); gLog.Save(); Cart gCart = DeserializeCart(merchantData); Guid cartGuid = Guid.Empty; if (gCart != null) cartGuid = gCart.CartGuid; if (cartGuid == Guid.Empty) return; Cart cart = new Cart(cartGuid); if (cart.CartGuid != cartGuid) return; Store store = new Store(gCart.StoreGuid); if (store.Guid != cart.StoreGuid) return; gCart.DeSerializeCartOffers(); gLog.SiteGuid = store.SiteGuid; gLog.UserGuid = gCart.UserGuid; gLog.CartGuid = gCart.CartGuid; gLog.StoreGuid = gCart.StoreGuid; gLog.Save(); gCart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address(); gCart.OrderInfo.Completed = DateTime.UtcNow; if (newOrder.buyerbillingaddress.structuredname != null) { gCart.OrderInfo.CustomerFirstName = newOrder.buyerbillingaddress.structuredname.firstname; gCart.OrderInfo.CustomerLastName = newOrder.buyerbillingaddress.structuredname.lastname; } else { gCart.OrderInfo.CustomerFirstName = newOrder.buyerbillingaddress.contactname; gCart.OrderInfo.CustomerLastName = newOrder.buyerbillingaddress.contactname; } gCart.OrderInfo.CustomerEmail = newOrder.buyerbillingaddress.email; gCart.OrderInfo.CustomerCompany = newOrder.buyerbillingaddress.companyname; gCart.OrderInfo.CustomerAddressLine1 = newOrder.buyerbillingaddress.address1; gCart.OrderInfo.CustomerAddressLine2 = newOrder.buyerbillingaddress.address2; gCart.OrderInfo.CustomerCity = newOrder.buyerbillingaddress.city; gCart.OrderInfo.CustomerState = newOrder.buyerbillingaddress.region; gCart.OrderInfo.CustomerCountry = newOrder.buyerbillingaddress.countrycode; gCart.OrderInfo.CustomerPostalCode = newOrder.buyerbillingaddress.postalcode; gCart.OrderInfo.CustomerTelephoneDay = newOrder.buyerbillingaddress.phone; gCart.CopyCustomerToBilling(); if (newOrder.buyershippingaddress.structuredname != null) { gCart.OrderInfo.DeliveryFirstName = newOrder.buyershippingaddress.structuredname.firstname; gCart.OrderInfo.DeliveryLastName = newOrder.buyershippingaddress.structuredname.lastname; } else { gCart.OrderInfo.DeliveryFirstName = newOrder.buyershippingaddress.contactname; gCart.OrderInfo.DeliveryLastName = newOrder.buyershippingaddress.contactname; } gCart.OrderInfo.DeliveryCompany = newOrder.buyershippingaddress.companyname; gCart.OrderInfo.DeliveryAddress1 = newOrder.buyershippingaddress.address1; gCart.OrderInfo.DeliveryAddress2 = newOrder.buyershippingaddress.address2; gCart.OrderInfo.DeliveryCity = newOrder.buyershippingaddress.city; gCart.OrderInfo.DeliveryState = newOrder.buyershippingaddress.region; gCart.OrderInfo.DeliveryCountry = newOrder.buyershippingaddress.countrycode; gCart.OrderInfo.DeliveryPostalCode = newOrder.buyershippingaddress.postalcode; gCart.TaxTotal = newOrder.orderadjustment.totaltax.Value; if (newOrder.ShippingCost > 0) { gCart.ShippingTotal = newOrder.ShippingCost; } gCart.OrderTotal = newOrder.ordertotal.Value; Guid orderStatusGuid = OrderStatus.OrderStatusReceivedGuid; if ( (newOrder.financialorderstate == FinancialOrderState.CHARGEABLE) || (newOrder.financialorderstate == FinancialOrderState.CHARGED) || (newOrder.financialorderstate == FinancialOrderState.CHARGING) ) { orderStatusGuid = OrderStatus.OrderStatusFulfillableGuid; } StoreHelper.EnsureUserForOrder(gCart); gCart.Save(); //Currency currency = new Currency(store.DefaultCurrencyId); SiteSettings siteSettings = new SiteSettings(store.SiteGuid); Order order = Order.CreateOrder( store, gCart, gLog.RawResponse, gLog.OrderNumber, string.Empty, siteSettings.GetCurrency().Code, "GoogleCheckout", orderStatusGuid); //StoreHelper.ClearCartCookie(cart.StoreGuid); if (orderStatusGuid == OrderStatus.OrderStatusFulfillableGuid) { StoreHelper.ConfirmOrder(store, order); PayPalLog.DeleteByCart(order.OrderGuid); } if (orderStatusGuid == OrderStatus.OrderStatusReceivedGuid) { StoreHelper.ConfirmOrderReceived(store, order); } }
/// <summary> /// Creates hidden form fields for PayPal Standard Cart upload /// </summary> /// <returns></returns> public static string GetCartUploadFormFields( Guid payPalLogGuid, Cart cart, Store store, CommerceConfiguration commerceConfig) { //TODO: PayPal is not seeing discounts? PayPalStandardPaymentGateway gateway = new PayPalStandardPaymentGateway( commerceConfig.PayPalStandardUrl, commerceConfig.PayPalStandardEmailAddress, commerceConfig.PayPalStandardPDTId); gateway.Amount = cart.OrderTotal; gateway.Tax = cart.TaxTotal; gateway.Shipping = cart.ShippingTotal; gateway.CartDiscount = cart.Discount; //Currency currency = new Currency(cart.CurrencyGuid); //if (currency.Guid != Guid.Empty) //{ // gateway.CurrencyCode = currency.Code; //} //gateway.CurrencyCode = store.DefaultCurrency; SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); gateway.CurrencyCode = siteSettings.GetCurrency().Code; gateway.OrderHasShippableProducts = cart.HasShippingProducts(); gateway.ShippingFirstName = cart.OrderInfo.DeliveryFirstName; gateway.ShippingLastName = cart.OrderInfo.DeliveryLastName; gateway.ShippingAddress1 = cart.OrderInfo.DeliveryAddress1; gateway.ShippingAddress2 = cart.OrderInfo.DeliveryAddress2; gateway.ShippingCity = cart.OrderInfo.DeliveryCity; gateway.ShippingState = cart.OrderInfo.DeliveryState; gateway.ShippingPostalCode = cart.OrderInfo.DeliveryPostalCode; //add the items foreach (CartOffer offer in cart.CartOffers) { PayPalOrderItem item = new PayPalOrderItem(); item.Amount = offer.OfferPrice; item.ItemName = offer.Name; item.ItemNumber = offer.OfferGuid.ToString(); item.Quantity = offer.Quantity; item.Tax = offer.Tax; gateway.Items.Add(item); } gateway.OrderDescription = store.Name + " " + WebStoreResources.OrderHeading; gateway.Custom = payPalLogGuid.ToString(); string siteRoot = SiteUtils.GetNavigationSiteRoot(); string storePageUrl = SiteUtils.GetCurrentPageUrl(); gateway.ReturnUrl = siteRoot + "/Services/PayPalPDTHandler.aspx"; gateway.NotificationUrl = siteRoot + "/Services/PayPalIPNHandler.aspx"; gateway.CancelUrl = storePageUrl; return gateway.GetCartUploadFormFields(); }
public override void HandleRiskInformationNotification( string requestXml, RiskInformationNotification notification) { GoogleCheckoutLog gLog = new GoogleCheckoutLog(); gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider"; gLog.RawResponse = requestXml; gLog.NotificationType = "RiskInformationNotification"; gLog.SerialNumber = notification.serialnumber; gLog.OrderNumber = notification.googleordernumber; gLog.GTimestamp = notification.timestamp; gLog.AvsResponse = notification.riskinformation.avsresponse; gLog.CvnResponse = notification.riskinformation.cvnresponse; gLog.BuyerId = notification.riskinformation.ipaddress; gLog.Save(); Guid orderGuid = GoogleCheckoutLog.GetCartGuidFromOrderNumber(notification.googleordernumber); if (orderGuid == Guid.Empty) return; Order order = new Order(orderGuid); if (order.OrderGuid != orderGuid) return; Store store = new Store(order.StoreGuid); if (store.Guid != order.StoreGuid) return; gLog.SiteGuid = store.SiteGuid; gLog.UserGuid = order.UserGuid; gLog.CartGuid = order.OrderGuid; gLog.StoreGuid = order.StoreGuid; gLog.Save(); }
public static Cart GetClerkCart(Store store) { if (HttpContext.Current == null) return null; if (store == null) return null; string cartKey = "clerkcart" + store.Guid.ToString(); if (HttpContext.Current.Items[cartKey] != null) { return (Cart)HttpContext.Current.Items[cartKey]; } if (CookieHelper.CookieExists(cartKey)) { string cartCookie = CookieHelper.GetCookieValue(cartKey); if (cartCookie.Length == 36) { Guid cartGuid = new Guid(cartCookie); Cart cart = new Cart(cartGuid); if (!cart.Exists) { return CreateClerkCartAndSetCookie(store, cartKey); } HttpContext.Current.Items[cartKey] = cart; return cart; } else { // cookie is invalid return CreateClerkCartAndSetCookie(store, cartKey); } } else { return CreateClerkCartAndSetCookie(store, cartKey); } }
public override void HandleChargeAmountNotification( string requestXml, ChargeAmountNotification notification) { GoogleCheckoutLog gLog = new GoogleCheckoutLog(); gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider"; gLog.RawResponse = requestXml; gLog.NotificationType = "ChargeAmountNotification"; gLog.SerialNumber = notification.serialnumber; gLog.OrderNumber = notification.googleordernumber; gLog.GTimestamp = notification.timestamp; gLog.TotalChgAmt = notification.totalchargeamount.Value; gLog.LatestChgAmt = notification.latestchargeamount.Value; gLog.Save(); Guid orderGuid = GoogleCheckoutLog.GetCartGuidFromOrderNumber(notification.googleordernumber); if (orderGuid == Guid.Empty) return; Order order = new Order(orderGuid); if (order.OrderGuid != orderGuid) return; Store store = new Store(order.StoreGuid); if (store.Guid != order.StoreGuid) return; gLog.SiteGuid = store.SiteGuid; gLog.UserGuid = order.UserGuid; gLog.CartGuid = order.OrderGuid; gLog.StoreGuid = order.StoreGuid; gLog.Save(); }
private void LoadSettings() { siteSettings = CacheHelper.GetCurrentSiteSettings(); store = new Store(siteSettings.SiteGuid, moduleId); Settings = ModuleSettings.GetModuleSettings(moduleId); module = GetModule(moduleId); lnkCart.PageID = pageId; lnkCart.ModuleID = moduleId; enableRatingsInProductList = WebUtils.ParseBoolFromHashtable( Settings, "EnableContentRatingInProductListSetting", enableRatingsInProductList); enableRatingComments = WebUtils.ParseBoolFromHashtable( Settings, "EnableRatingCommentsSetting", enableRatingComments); productList1.Store = store; productList1.PageId = pageId; productList1.ModuleId = moduleId; productList1.SiteRoot = SiteRoot; productList1.CurrencyCulture = currencyCulture; productList1.EnableRatings = enableRatingsInProductList; productList1.EnableRatingComments = enableRatingComments; productList1.Settings = Settings; AddClassToBody("webstore webstoreproductlist"); if (WebStoreConfiguration.UseNoIndexFollowMetaOnLists) { SiteUtils.AddNoIndexFollowMeta(Page); } }