Google Checkout not charged shipping

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi

I just got my first sale with Google checkout as payment method. NopCommerce has recorded the sale accurately including postage however Google checkout hasn't processed the shipping costs resulting in a loss for me.

Am I missing something? Does NopCommerce not pass on the shipping costs to Google checkout?

Also, I have processed the payment in Google but this hasn't recorded back in my store. Do I have to record payment manually or should the API have recorded it back to my store via the API?

I have SSL installed and everything seemed fine when testing.

I am using V2.1
12 years ago
Just got another sale in google checkout.

It has not recorded in nopCommerce at all and has not charged shipping again. Shipping settings are configured in nop and google.

Can someone help? Am I missing something here?
12 years ago
I'm having the exact same issue!  Using version 1.9.  Google checkout is not charging shipping, so I'm losing money on every order that goes through google checkout.  The order information is also not posting back to my site.  

I have SSL setup on my site, google checkout settings are:
api 2.2
Notification as XML
API callback URL: https://<mysite>/GooglePostHandler.aspx.  
I did notice that the google checkout button is on the entry shopping cart page next to the checkout button, so its before any shipping or billing information is collected and there is no template for it, as apposed to paypal, which shows up on the payment method section/page and does have a template.  

Has anyone found a solution for this, or has ever gotten google checkout to work properly?  Any help/suggestions would be greatly appreciated, as I have scoured the forums and can not find any help on this issue.
12 years ago
Sizzler wrote:
I'm having the exact same issue!  Using version 1.9.  Google checkout is not charging shipping, so I'm losing money on every order that goes through google checkout.  The order information is also not posting back to my site.  

I have SSL setup on my site, google checkout settings are:
api 2.2
Notification as XML
API callback URL: https://<mysite>/GooglePostHandler.aspx.  
I did notice that the google checkout button is on the entry shopping cart page next to the checkout button, so its before any shipping or billing information is collected and there is no template for it, as apposed to paypal, which shows up on the payment method section/page and does have a template.  

Has anyone found a solution for this, or has ever gotten google checkout to work properly?  Any help/suggestions would be greatly appreciated, as I have scoured the forums and can not find any help on this issue.


I still have an open ticket with Google for this one. They just kept saying it was a problem they knew about and they would let me know when it is fixed. Never heard anything back.

Although you can live without Google checkout, the store listing on the left side of google shopping is determined byon reviews from Google checkout and other review sites. So, unless you are subscribed on third party review sites your store will never appear on page in the store list on the left side. Bad for SEO but luckily this doesnt affect the actual search results in the main pane that are based primarily on relevance.
12 years ago
I may be wrong but think I know what the problem is with this one and hope one of the team will take a look?

Google checkout relies on the shipping_weight tag in the Google XML feed. I notice the promotion feed isn't generating this tag despite the shipping weight being configured in the product detail in Nop. This is also a compulsory tag in Google since September 2011.

My theory is that Google checkout assumed the weight is 0 and therefore doesn't charge the customer for shipping.

I would really like to re-enable Google checkout because as well as being a valuable selling channel any reviews received on sales have a direct effect in the sorting order on Google shopping search results.

If my theory is correct, is there a direct code change we can make in the interim to add this field into the generated feed?
11 years ago
Hi,

I've been searching for answers/solutions regarding google checkout not charging shipping by weight. I'm not using real-time shipping but just the regular shipping by weight.The only thing that works is fixed rate shipping method which won't work for me. I can also setup shipping method by weight on the google side. However, the weight for some reason is not posted to google so no shipping charges are calculated as well. Can someone please help which code can I modify to pass the shipping weight to google?
11 years ago
re: "using...  shipping by weight"

I suspect the problem is that no address is being passed to shipping option plugins

       var shippingOptions = _shippingService.GetShippingOptions(cart, null);


They require address

            if (getShippingOptionRequest.ShippingAddress == null)
            {
                response.AddError("Shipping address is not set");
                return response;
            }
11 years ago
I'm not sure if the shipping address is the issue due to the fact that the sales tax is working on the google side. I setup the sales tax to be charged on google side based on my state and it is actually working. That means that google is getting the state in the shopping cart which is normally part of the shipping address. let me know if I'm missing something.

This is a snippet from the plugins...GoogleCheckoutPaymentProcessor.cs. If you look at the last statement, it only adds the name, description, id, unit price and quantity and no shipping weight. I'm not sure how to incorporate the shipping weight in the code. Let me know if I'm in the right track. Thanks.

public GCheckoutResponse PostCartToGoogle(CheckoutShoppingCartRequest req,
            IList<Core.Domain.Orders.ShoppingCartItem> cart)
        {
            //there's no need to round prices (Math.Round(,2)) because GCheckout library does it for us
            //items
            foreach (Core.Domain.Orders.ShoppingCartItem sci in cart)
            {
                var productVariant = sci.ProductVariant;
                if (productVariant != null)
                {
                    decimal taxRate = decimal.Zero;
                    string description = _productAttributeFormatter.FormatAttributes(productVariant,
                        sci.AttributesXml, _workContext.CurrentCustomer,
                        ", ", false, true, true, true, false);
                    string fullName = "";
                    if (!String.IsNullOrEmpty(sci.ProductVariant.GetLocalized(x => x.Name)))
                        fullName = string.Format("{0} ({1})", sci.ProductVariant.Product.GetLocalized(x => x.Name), sci.ProductVariant.GetLocalized(x => x.Name));
                    else
                        fullName = sci.ProductVariant.Product.GetLocalized(x => x.Name);
                    decimal unitPrice = _taxService.GetProductPrice(sci.ProductVariant, _priceCalculationService.GetUnitPrice(sci, true), out taxRate);
                    req.AddItem(fullName, description, sci.Id.ToString(), unitPrice, sci.Quantity);
                }
            }
11 years ago
As per your snippet above, tax is being added to unitPrice:
decimal unitPrice = _taxService.GetProductPrice(...

The GC AddItem method does not appear to have an overload that includes Weight param.  But, Weight is a property of ShoppingCartItem.  So, use right-click 'Go To Definition' to see what properties ShoppingCartItem has, construct one, and then use this AddItem overload
public ShoppingCartItem AddItem(ShoppingCartItem item);

e.g.

req.AddItem( new ShoppingCartItem() {
    field = value,
    ...
    });
11 years ago
Hi,

Thank you! I also found out that the GooglecheckoutPaymentProcessor.cs code passes the Flat Rate Shipping charges configured in admin even if you set your shipping by weight and have that enabled, it would still pass the flat rate shipping charges. Please look at the bottom code marked in "bold". There's a FlatRateShippingAdjustment namespace/object I'm not sure what it is. But I got a red squiggly mark on my visual studio saying that the type or namespace cannot be found..are you missing an assembly reference? so I'm not sure how to correct the code to maybe pass the type/object for the shipping by weight table definition in the admin. Thanks.

private void ProcessNewOrderNotification(string xmlData)
        {
            try
            {
                var newOrderNotification = (NewOrderNotification)EncodeHelper.Deserialize(xmlData, typeof(NewOrderNotification));
                string googleOrderNumber = newOrderNotification.googleordernumber;

                XmlNode customerInfo = newOrderNotification.shoppingcart.merchantprivatedata.Any[0];
                int customerId = Convert.ToInt32(customerInfo.Attributes["CustomerID"].Value);
                //int customerLanguageId = Convert.ToInt32(customerInfo.Attributes["CustomerLanguageID"].Value);
                //int customerCurrencyId = Convert.ToInt32(customerInfo.Attributes["CustomerCurrencyID"].Value);
                var customer = _customerService.GetCustomerById(customerId);

                if (customer == null)
                {
                    LogMessage("Could not load a customer");
                    return;
                }

                var cart = customer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList();

                _workContext.CurrentCustomer = customer;

                if (cart.Count == 0)
                {
                    LogMessage("Cart is empty");
                    return;
                }

                //validate cart
                foreach (var sci in cart)
                {
                    bool ok = false;
                    foreach (Item item in newOrderNotification.shoppingcart.items)
                    {
                        if (!String.IsNullOrEmpty(item.merchantitemid))
                        {
                            if ((Convert.ToInt32(item.merchantitemid) == sci.Id) && (item.quantity == sci.Quantity))
                            {
                                ok = true;
                                break;
                            }
                        }
                    }

                    if (!ok)
                    {
                        LogMessage(string.Format("Shopping Cart item has been changed. {0}. {1}", sci.Id, sci.Quantity));
                        return;
                    }
                }


                string[] billingFullname = newOrderNotification.buyerbillingaddress.contactname.Trim().Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
                string billingFirstName = billingFullname[0];
                string billingLastName = string.Empty;
                if (billingFullname.Length > 1)
                    billingLastName = billingFullname[1];
                string billingEmail = newOrderNotification.buyerbillingaddress.email.Trim();
                string billingAddress1 = newOrderNotification.buyerbillingaddress.address1.Trim();
                string billingAddress2 = newOrderNotification.buyerbillingaddress.address2.Trim();
                string billingPhoneNumber = newOrderNotification.buyerbillingaddress.phone.Trim();
                string billingCity = newOrderNotification.buyerbillingaddress.city.Trim();
                int? billingStateProvinceId = null;
                var billingStateProvince = _stateProvinceService.GetStateProvinceByAbbreviation(newOrderNotification.buyerbillingaddress.region.Trim());
                if (billingStateProvince != null)
                    billingStateProvinceId = billingStateProvince.Id;
                string billingZipPostalCode = newOrderNotification.buyerbillingaddress.postalcode.Trim();
                int? billingCountryId = null;
                var billingCountry = _countryService.GetCountryByTwoLetterIsoCode(newOrderNotification.buyerbillingaddress.countrycode.Trim());
                if (billingCountry != null)
                    billingCountryId = billingCountry.Id;

                var billingAddress = customer.Addresses.ToList().FindAddress(
                    billingFirstName, billingLastName, billingPhoneNumber,
                    billingEmail, string.Empty, string.Empty, billingAddress1, billingAddress2, billingCity,
                    billingStateProvinceId, billingZipPostalCode, billingCountryId);

                if (billingAddress == null)
                {
                    billingAddress = new Core.Domain.Common.Address()
                    {
                        FirstName = billingFirstName,
                        LastName = billingLastName,
                        PhoneNumber = billingPhoneNumber,
                        Email = billingEmail,
                        Address1 = billingAddress1,
                        Address2 = billingAddress2,
                        City = billingCity,
                        StateProvinceId = billingStateProvinceId,
                        ZipPostalCode = billingZipPostalCode,
                        CountryId = billingCountryId,
                        CreatedOnUtc = DateTime.UtcNow,
                    };
                    customer.Addresses.Add(billingAddress);
                }
                //set default billing address
                customer.BillingAddress = billingAddress;
                _customerService.UpdateCustomer(customer);

                _genericAttributeService.SaveAttribute<ShippingOption>(customer, SystemCustomerAttributeNames.LastShippingOption, null);

                bool shoppingCartRequiresShipping = cart.RequiresShipping();
                if (shoppingCartRequiresShipping)
                {
                    string[] shippingFullname = newOrderNotification.buyershippingaddress.contactname.Trim().Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
                    string shippingFirstName = shippingFullname[0];
                    string shippingLastName = string.Empty;
                    if (shippingFullname.Length > 1)
                        shippingLastName = shippingFullname[1];
                    string shippingEmail = newOrderNotification.buyershippingaddress.email.Trim();
                    string shippingAddress1 = newOrderNotification.buyershippingaddress.address1.Trim();
                    string shippingAddress2 = newOrderNotification.buyershippingaddress.address2.Trim();
                    string shippingPhoneNumber = newOrderNotification.buyershippingaddress.phone.Trim();
                    string shippingCity = newOrderNotification.buyershippingaddress.city.Trim();
                    int? shippingStateProvinceId = null;
                    var shippingStateProvince = _stateProvinceService.GetStateProvinceByAbbreviation(newOrderNotification.buyershippingaddress.region.Trim());
                    if (shippingStateProvince != null)
                        shippingStateProvinceId = shippingStateProvince.Id;
                    int? shippingCountryId = null;
                    string shippingZipPostalCode = newOrderNotification.buyershippingaddress.postalcode.Trim();
                    var shippingCountry = _countryService.GetCountryByTwoLetterIsoCode(newOrderNotification.buyershippingaddress.countrycode.Trim());
                    if (shippingCountry != null)
                        shippingCountryId = shippingCountry.Id;

                    var shippingAddress = customer.Addresses.ToList().FindAddress(
                        shippingFirstName, shippingLastName, shippingPhoneNumber,
                        shippingEmail, string.Empty, string.Empty,
                        shippingAddress1, shippingAddress2, shippingCity,
                        shippingStateProvinceId, shippingZipPostalCode, shippingCountryId);
                    if (shippingAddress == null)
                    {
                        shippingAddress = new Core.Domain.Common.Address()
                        {
                            FirstName = shippingFirstName,
                            LastName = shippingLastName,
                            PhoneNumber = shippingPhoneNumber,
                            Email = shippingEmail,
                            Address1 = shippingAddress1,
                            Address2 = shippingAddress2,
                            City = shippingCity,
                            StateProvinceId = shippingStateProvinceId,
                            ZipPostalCode = shippingZipPostalCode,
                            CountryId = shippingCountryId,
                            CreatedOnUtc = DateTime.UtcNow,
                        };
                        customer.Addresses.Add(shippingAddress);
                    }
                    //set default shipping address
                    customer.ShippingAddress = shippingAddress;
                    _customerService.UpdateCustomer(customer);

                    if (newOrderNotification.orderadjustment != null &&
                        newOrderNotification.orderadjustment.shipping != null &&
                        newOrderNotification.orderadjustment.shipping.Item != null)
                    {
                        var shippingMethod = (FlatRateShippingAdjustment)newOrderNotification.orderadjustment.shipping.Item;
                        var shippingOption = new ShippingOption();
                        shippingOption.Name = shippingMethod.shippingname;
                        shippingOption.Rate = shippingMethod.shippingcost.Value;
                        _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.LastShippingOption, shippingOption);
                    }
                }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.