public static List <GeoCountry> GetPage( int pageNumber, int pageSize, out int totalPages) { List <GeoCountry> geoCountryCollection = new List <GeoCountry>(); using (IDataReader reader = DBGeoCountry.GetPage(pageNumber, pageSize, out totalPages)) { while (reader.Read()) { GeoCountry geoCountry = new GeoCountry(); geoCountry.guid = new Guid(reader["Guid"].ToString()); geoCountry.name = reader["Name"].ToString(); geoCountry.iSOCode2 = reader["ISOCode2"].ToString(); geoCountry.iSOCode3 = reader["ISOCode3"].ToString(); geoCountryCollection.Add(geoCountry); //totalPages = Convert.ToInt32(reader["TotalPages"]); } } return(geoCountryCollection); }
private void grdCountry_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridView grid = (GridView)sender; Guid guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString()); TextBox txtName = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtName"); TextBox txtISOCode2 = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtISOCode2"); TextBox txtISOCode3 = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtISOCode3"); GeoCountry country; if (guid == Guid.Empty) { country = new GeoCountry(); } else { country = new GeoCountry(guid); } country.Name = txtName.Text; country.IsoCode2 = txtISOCode2.Text; country.IsoCode3 = txtISOCode3.Text; country.Save(); WebUtils.SetupRedirect(this, Request.RawUrl); }
private void BindGeoZoneList() { if ((ddCountry.SelectedIndex > -1) && (ddCountry.SelectedValue.Length > 0) ) { currentCountry = new GeoCountry(ddCountry.SelectedValue); currentCountryGuid = currentCountry.Guid; using (IDataReader reader = GeoZone.GetByCountry(currentCountryGuid)) { ddGeoZone.DataSource = reader; ddGeoZone.DataBind(); } if (setState.Length > 0) { ListItem item = ddGeoZone.Items.FindByValue(setState); if (item != null) { ddGeoZone.ClearSelection(); item.Selected = true; } } } }
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 static int CompareByName(GeoCountry country1, GeoCountry country2) { return country1.Name.CompareTo(country2.Name); }
public static int CompareByIsoCode3(GeoCountry country1, GeoCountry country2) { return country1.IsoCode3.CompareTo(country2.IsoCode3); }
public static List<GeoCountry> GetPage( int pageNumber, int pageSize, out int totalPages) { List<GeoCountry> geoCountryCollection = new List<GeoCountry>(); using (IDataReader reader = DBGeoCountry.GetPage(pageNumber, pageSize, out totalPages)) { while (reader.Read()) { GeoCountry geoCountry = new GeoCountry(); geoCountry.guid = new Guid(reader["Guid"].ToString()); geoCountry.name = reader["Name"].ToString(); geoCountry.iSOCode2 = reader["ISOCode2"].ToString(); geoCountry.iSOCode3 = reader["ISOCode3"].ToString(); geoCountryCollection.Add(geoCountry); //totalPages = Convert.ToInt32(reader["TotalPages"]); } } return geoCountryCollection; }
private void SaveCartDetail() { if (cart == null) { return; } GeoCountry country; GeoZone taxZone; cart.OrderInfo.CustomerFirstName = txtCustomerFirstName.Text; cart.OrderInfo.CustomerLastName = txtCustomerLastName.Text; cart.OrderInfo.CustomerCompany = txtCustomerCompany.Text; cart.OrderInfo.CustomerAddressLine1 = txtCustomerAddressLine1.Text; cart.OrderInfo.CustomerAddressLine2 = txtCustomerAddressLine2.Text; cart.OrderInfo.CustomerSuburb = txtCustomerSuburb.Text; cart.OrderInfo.CustomerCity = txtCustomerCity.Text; cart.OrderInfo.CustomerPostalCode = txtCustomerPostalCode.Text; if (ddCustomerGeoZone.SelectedIndex > -1) { cart.OrderInfo.CustomerState = ddCustomerGeoZone.SelectedItem.Value; } else { cart.OrderInfo.CustomerState = string.Empty; } cart.OrderInfo.CustomerCountry = ddCustomerCountry.SelectedItem.Value; cart.OrderInfo.CustomerTelephoneDay = txtCustomerTelephoneDay.Text; cart.OrderInfo.CustomerTelephoneNight = txtCustomerTelephoneNight.Text; cart.OrderInfo.CustomerEmail = txtCustomerEmail.Text; if (ddCustomerGeoZone.SelectedIndex > -1) { country = new GeoCountry(cart.OrderInfo.CustomerCountry); taxZone = GeoZone.GetByCode(country.Guid, ddCustomerGeoZone.SelectedValue); cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } if (pnlShipping.Visible) { cart.OrderInfo.DeliveryFirstName = txtDeliveryFirstName.Text; cart.OrderInfo.DeliveryLastName = txtDeliveryLastName.Text; cart.OrderInfo.DeliveryCompany = txtDeliveryCompany.Text; cart.OrderInfo.DeliveryAddress1 = txtDeliveryAddress1.Text; cart.OrderInfo.DeliveryAddress2 = txtDeliveryAddress2.Text; cart.OrderInfo.DeliverySuburb = txtDeliverySuburb.Text; cart.OrderInfo.DeliveryCity = txtDeliveryCity.Text; cart.OrderInfo.DeliveryPostalCode = txtDeliveryPostalCode.Text; if (ddDeliveryGeoZone.SelectedIndex > -1) { cart.OrderInfo.DeliveryState = ddDeliveryGeoZone.SelectedItem.Value; } else { cart.OrderInfo.DeliveryState = string.Empty; } cart.OrderInfo.DeliveryCountry = ddDeliveryCountry.SelectedItem.Value; if (ddDeliveryGeoZone.SelectedIndex > -1) { country = new GeoCountry(cart.OrderInfo.DeliveryCountry); taxZone = GeoZone.GetByCode(country.Guid, ddDeliveryGeoZone.SelectedValue); cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } } else { cart.CopyCustomerToShipping(); } cart.CopyCustomerToBilling(); cart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address(); cart.OrderInfo.Save(); cart.RefreshTotals(); }
private void LoadSettings() { ScriptConfig.IncludeColorBox = true; storeCountry = new GeoCountry(siteSettings.DefaultCountryGuid); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); commerceConfig = SiteUtils.GetCommerceConfig(); store = StoreHelper.GetStore(); if (store == null) { return; } cart = StoreHelper.GetClerkCart(store); tblCountryList = GeoCountry.GetList(); if (WebUser.IsInRoles(siteSettings.RolesThatCanLookupUsers)) { SetupSelectUserScript(); //lnkUserLookup.Visible = true; lnkUserSearch.Visible = true; } AddClassToBody("webstore admincheckout"); }
private void BindShippingGeoZoneList() { if ((ddDeliveryCountry.SelectedIndex > -1) && (ddDeliveryCountry.SelectedValue.Length > 0) ) { GeoCountry country = new GeoCountry(ddDeliveryCountry.SelectedValue); if (country.Guid == Guid.Empty) return; using (IDataReader reader = GeoZone.GetByCountry(country.Guid)) { ddDeliveryGeoZone.DataSource = reader; ddDeliveryGeoZone.DataBind(); } divShippingState.Visible = (ddDeliveryGeoZone.Items.Count > 0); } }
public static int CompareByIsoCode3(GeoCountry country1, GeoCountry country2) { return(country1.IsoCode3.CompareTo(country2.IsoCode3)); }
public static int CompareByName(GeoCountry country1, GeoCountry country2) { return(country1.Name.CompareTo(country2.Name)); }
private void LoadSettings() { store = StoreHelper.GetStore(); if (store == null) { return; } commerceConfig = SiteUtils.GetCommerceConfig(); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); storeCountry = new GeoCountry(siteSettings.DefaultCountryGuid); if (Request.IsAuthenticated) { siteUser = SiteUtils.GetCurrentSiteUser(); } if (StoreHelper.UserHasCartCookie(store.Guid)) { cart = StoreHelper.GetCart(); if (cart != null) { if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0)) { StoreHelper.EnsureValidDiscounts(store, cart); } if (siteUser != null) { if (cart.UserGuid == Guid.Empty) { // take ownership of anonymous cart cart.UserGuid = siteUser.UserGuid; cart.Save(); StoreHelper.InitializeOrderInfo(cart, siteUser); } else { // cart already has a user guid but // check if it matches the current user // cart cookie could have been left behind by a previous user // on shared computers // if cart user guid doesn't match reset billing shipping info // and any other identifiers // but leave items in cart if (cart.UserGuid != siteUser.UserGuid) { cart.ResetUserInfo(); cart.UserGuid = siteUser.UserGuid; cart.Save(); StoreHelper.InitializeOrderInfo(cart, siteUser); } } } if (WebStoreConfiguration.IsDemo) { LoadDemoCustomer(); } canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart); // disable till I finish //canCheckoutWithoutAuthentication = false; } AddClassToBody("webstore webstoreconfirmorder"); } pnlRequireLogin.Visible = !Request.IsAuthenticated; if ((canCheckoutWithoutAuthentication)||(Request.IsAuthenticated)) { pnlOrderDetail.Visible = commerceConfig.CanProcessStandardCards || (commerceConfig.WorldPayInstallationId.Length > 0); pnlRequireLogin.Visible = true; pnlShippingTotal.Visible = false; pnlTaxTotal.Visible = false; pnlOrderTotal.Visible = false; } if ((cart != null) && (cart.SubTotal == 0) && (cart.CartOffers.Count > 0)) { // free checkout pnlOrderDetail.Visible = true; } if (pnlOrderDetail.Visible) { tblCountryList = GeoCountry.GetList(); } ConfigureCheckoutButtons(); //if (!Page.IsPostBack) //{ // if ((commerceConfig.PayPalIsEnabled) && (commerceConfig.PayPalUsePayPalStandard)) // { // if (Request.IsAuthenticated) // { // SetupPayPalStandardForm(); // } // else // { // // we need the user to be signed in before we send them to paypal if using PayPal Standard // // because we want to return them to their order summary and that requires login // // so we need to know who the user is before sending them to PayPal // litOr.Visible = false; // btnPayPal.Visible = false; // btnGoogleCheckout.Visible = false; // } // } //} //if (!Request.IsAuthenticated) //{ // pnlOrderDetail.Visible = false; // pnlRequireLogin.Visible = true; // pnlShippingTotal.Visible = false; // pnlTaxTotal.Visible = false; // pnlOrderTotal.Visible = false; // if (commerceConfig.GoogleCheckoutIsEnabled) // { // if ( // (!commerceConfig.Is503TaxExempt) // && ((cart != null) && (cart.HasDonations())) // ) // { // //btnGoogleCheckout.Visible = false; // lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage; // lblGoogleMessage.Visible = true; // PaymentAcceptanceMark mark = (PaymentAcceptanceMark)pam1; // mark.SuppressGoogleCheckout = true; // mark = (PaymentAcceptanceMark)PaymentAcceptanceMark1; // mark.SuppressGoogleCheckout = true; // btnGoogleCheckout.Visible = true; // btnGoogleCheckout.Enabled = false; // } // } //} //else //{ // if ( // (!commerceConfig.Is503TaxExempt) // && ((cart != null)&& (cart.HasDonations())) // && (commerceConfig.GoogleCheckoutIsEnabled) // ) // { // btnGoogleCheckout.Visible = true; // btnGoogleCheckout.Enabled = false; // lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage; // lblGoogleMessage.Visible = true; // } //} }
private void LoadDemoCustomer() { // this is for the demo site so users don't have to fill out customer info to try the store if (cart.OrderInfo.CustomerFirstName.Length > 0) { return; } //data already initialized GeoCountry country; GeoZone taxZone; cart.OrderInfo.CustomerFirstName = "John"; cart.OrderInfo.CustomerLastName = "Doe"; cart.OrderInfo.CustomerEmail = "*****@*****.**"; cart.OrderInfo.CustomerAddressLine1 = "123 Any St."; cart.OrderInfo.CustomerCity = "Anytown"; cart.OrderInfo.CustomerPostalCode = "12345"; cart.OrderInfo.CustomerState = "NC"; cart.OrderInfo.CustomerCountry = "US"; cart.OrderInfo.CustomerTelephoneDay = "123-234-3456"; if (cart.OrderInfo.CustomerState.Length > 0) { country = new GeoCountry(cart.OrderInfo.CustomerCountry); taxZone = GeoZone.GetByCode(country.Guid, cart.OrderInfo.CustomerState); if (taxZone != null) { cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } } cart.CopyCustomerToShipping(); cart.CopyCustomerToBilling(); cart.OrderInfo.Save(); cart.RefreshTotals(); }
public void CalculateTax(Cart cart) { // TODO: this doesn't take into account discounts decimal taxAmount = 0; if(cart.OrderInfo.TaxZoneGuid == Guid.Empty) { GeoCountry country = new GeoCountry(cart.OrderInfo.BillingCountry); GeoZone taxZone = GeoZone.GetByCode(country.Guid, cart.OrderInfo.BillingState); if (taxZone != null) { cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } } if (cart.OrderInfo.TaxZoneGuid != Guid.Empty) { Collection<TaxRate> taxRates = TaxRate.GetTaxRates(this.SiteGuid, cart.OrderInfo.TaxZoneGuid); if (taxRates.Count > 0) { foreach (CartOffer offer in cart.CartOffers) { offer.Tax = 0; foreach (TaxRate taxRate in taxRates) { if (offer.TaxClassGuid == taxRate.TaxClassGuid) { offer.Tax += (taxRate.Rate * (offer.OfferPrice * offer.Quantity)); offer.Save(); taxAmount += offer.Tax; //break; } } } } } cart.TaxTotal = Math.Round(taxAmount, this.RoundingDecimalPlaces, this.RoundingMode); if (cart.TaxTotal < 0) { cart.TaxTotal = 0; } cart.Save(); }