/// <summary> /// This method adds a flat-rate shipping method to an order. This method /// handles flat-rate shipping methods that have shipping restrictions. /// </summary> /// <param name="Name">The name of the shipping method. This value will be /// displayed on the Google Checkout order review page.</param> /// <param name="Cost">The cost associated with the shipping method.</param> /// <param name="Restrictions">A list of country, state or zip code areas /// where the shipping method is either available or unavailable.</param> public void AddFlatRateShippingMethod(string Name, decimal Cost, ShippingRestrictions Restrictions) { AutoGen.FlatRateShipping Method = new AutoGen.FlatRateShipping(); Method.name = Name; Method.price = new AutoGen.Money(); Method.price.currency = _Currency; Method.price.Value = Cost; if (Restrictions != null) { Method.shippingrestrictions = Restrictions.XmlRestrictions; } AddNewShippingMethod(Method); }
/// <summary> /// This method adds a merchant-calculated shipping method to an order. /// This method handles merchant-calculated shipping methods that have /// shipping restrictions. /// </summary> /// <param name="Name">The name of the shipping method. This value will be /// displayed on the Google Checkout order review page.</param> /// <param name="DefaultCost">The default cost associated with the shipping /// method. This value is the amount that Gogle Checkout will charge for /// shipping if the merchant calculation callback request fails.</param> /// <param name="Restrictions">A list of country, state or zip code areas /// where the shipping method is either available or unavailable.</param> public void AddMerchantCalculatedShippingMethod(string Name, decimal DefaultCost, ShippingRestrictions Restrictions) { AutoGen.MerchantCalculatedShipping Method = new AutoGen.MerchantCalculatedShipping(); Method.name = Name; Method.price = new AutoGen.Money(); Method.price.currency = _Currency; Method.price.Value = DefaultCost; if (Restrictions != null) { Method.shippingrestrictions = Restrictions.XmlRestrictions; } AddNewShippingMethod(Method); }
protected void GCheckoutButton1_Click(object sender, ImageClickEventArgs e) { CheckoutShoppingCartRequest Req = GCheckoutButton1.CreateRequest(); Req.AddItem("Snickers", "Packed with peanuts.", 0.75m, 2); Req.AddItem("Gallon of Milk", "Milk goes great with candy bars!", 2.99m, 1); Req.AddStateTaxRule("CA", 0.0825, true); Req.AddStateTaxRule("IL", 0.0625, false); ShippingRestrictions Only48Lower = new ShippingRestrictions(); // Only48Lower.AddAllowedCountryArea(GCheckout.AutoGen.USAreas.CONTINENTAL_48); Req.AddFlatRateShippingMethod("UPS Ground", 7.05m, Only48Lower); ShippingRestrictions OnlyCA_NV = new ShippingRestrictions(); OnlyCA_NV.AddAllowedStateCode("CA"); OnlyCA_NV.AddAllowedStateCode("NV"); Req.AddFlatRateShippingMethod("California Express", 6.35m, OnlyCA_NV); Req.AddFlatRateShippingMethod("USPS", 3.08m); Req.AddPickupShippingMethod("Pick up in store", 0); Req.ContinueShoppingUrl = "http://www.example.com/continueshopping"; Req.EditCartUrl = "http://www.example.com/editcart"; GCheckoutResponse Resp = Req.Send(); Response.Redirect(Resp.RedirectUrl, true); }
/// <summary> /// This method adds a flat-rate shipping method to an order. This method /// handles flat-rate shipping methods that have shipping restrictions. /// </summary> /// <param name="Name">The name of the shipping method. This value will be /// displayed on the Google Checkout order review page.</param> /// <param name="Cost">The cost associated with the shipping method.</param> /// <param name="Restrictions">A list of country, state or zip code areas /// where the shipping method is either available or unavailable.</param> public void AddFlatRateShippingMethod(string Name, decimal Cost, ShippingRestrictions Restrictions) { Cost = Math.Round(Cost, 2); //no fractional cents AutoGen.FlatRateShipping Method = new AutoGen.FlatRateShipping(); Method.name = Name; Method.price = new AutoGen.FlatRateShippingPrice(); Method.price.currency = _Currency; Method.price.Value = Cost; if (Restrictions != null) { Method.shippingrestrictions = Restrictions.XmlRestrictions; } AddNewShippingMethod(Method); }
/// <summary> /// This method adds a merchant-calculated shipping method to an order. /// This method handles merchant-calculated shipping methods that have /// shipping restrictions. /// </summary> /// <param name="Name">The name of the shipping method. This value will be /// displayed on the Google Checkout order review page.</param> /// <param name="DefaultCost">The default cost associated with the shipping /// method. This value is the amount that Gogle Checkout will charge for /// shipping if the merchant calculation callback request fails.</param> /// <param name="Restrictions">A list of country, state or zip code areas /// where the shipping method is either available or unavailable.</param> /// <param name="AddressFilters">enables you to specify a geographic area /// where a particular merchant-calculated shipping method is available or /// unavailable. Google Checkout applies address filters before sending you /// a <merchantcalculation-callback> request so that you are not asked /// to calculate shipping costs for a shipping method that is not actually /// available.</param> public void AddMerchantCalculatedShippingMethod(string Name, decimal DefaultCost, ShippingRestrictions Restrictions, ShippingRestrictions AddressFilters) { DefaultCost = Math.Round(DefaultCost, 2); //no fractional cents AutoGen.MerchantCalculatedShipping Method = new AutoGen.MerchantCalculatedShipping(); Method.name = Name; Method.price = new AutoGen.MerchantCalculatedShippingPrice(); Method.price.currency = _Currency; Method.price.Value = DefaultCost; if (Restrictions != null) { Method.shippingrestrictions = Restrictions.XmlRestrictions; } if (AddressFilters != null) { Method.addressfilters = AddressFilters.XmlRestrictions; } AddNewShippingMethod(Method); }
/// <summary> /// This method adds a merchant-calculated shipping method to an order. /// This method handles merchant-calculated shipping methods that have /// shipping restrictions. /// </summary> /// <param name="Name">The name of the shipping method. This value will be /// displayed on the Google Checkout order review page.</param> /// <param name="DefaultCost">The default cost associated with the shipping /// method. This value is the amount that Gogle Checkout will charge for /// shipping if the merchant calculation callback request fails.</param> /// <param name="Restrictions">A list of country, state or zip code areas /// where the shipping method is either available or unavailable.</param> public void AddMerchantCalculatedShippingMethod(string Name, decimal DefaultCost, ShippingRestrictions Restrictions) { AddMerchantCalculatedShippingMethod(Name, DefaultCost, Restrictions, null); }
//Google!! protected void GoogleCheckoutButton1_Click(object sender, ImageClickEventArgs e) { //Finding Button GCheckoutButton btn = (GCheckoutButton)LoginView1.FindControl("GCheckoutButton1"); //Request CheckoutShoppingCartRequest req = btn.CreateRequest(); req.EditCartUrl = BuildAbsolute("ViewCart.aspx"); req.ContinueShoppingUrl = BuildAbsolute("Default.aspx"); // adding to the request Cart c = (Cart)Session["ShoppingCart"]; foreach (Prod p in c.Products) { req.AddItem(p.Name, "", p.Price, p.Quantity); } //Optional Requests-- not used. req.AddStateTaxRule("CA", 0.0825, true); req.AddStateTaxRule("UT", 0.0625, false); ShippingRestrictions Only48Lower = new ShippingRestrictions(); Only48Lower.AddAllowedCountryArea(GCheckout.AutoGen.USAreas.CONTINENTAL_48); req.AddFlatRateShippingMethod("UPS Ground", 7.05m, Only48Lower); ShippingRestrictions OnlyCA_NV = new ShippingRestrictions(); OnlyCA_NV.AddAllowedStateCode("CA"); OnlyCA_NV.AddAllowedStateCode("NV"); req.AddFlatRateShippingMethod("California Express", 6.35m, OnlyCA_NV); req.AddFlatRateShippingMethod("USPS", 3.08m); req.AddPickupShippingMethod("Pick up in store", 0); //Request send GCheckoutResponse resp = req.Send(); //If the response reports success, use the CreateOrder method of the Cart object to write the cart contents to the database as an order. //Use the Google checkout serial number as the orderID if (resp.IsGood) { bool ordercreated = c.CreateOrder(resp.SerialNumber, User.Identity.Name); //Shopping cart reset and send to google. Or error. if (ordercreated) { Session["ShoppingCart"] = null; //Redirect Response.Redirect(resp.RedirectUrl, true); } else { lblStatus.Text = "OH NO! Something went horribly wrong! Just kidding, we've had a small error. Try again later."; } } else { lblStatus.Text = "OH NO! Something went horribly wrong! Just kidding, we've had a small error. Try again later."; } }