Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Rob Smith 34 posts 165 karma points
    Jul 07, 2014 @ 19:33
    Rob Smith
    0

    Ucommerce not passing shipping cost to payment provider (SagePay)

    Umbraco v6.1.5

    uCommerce 3.6.5.13233

    Based on uCommerce Demo Store - Razor 1.0.3.13143

    Ucommerce is not adding the shipping cost in when the payment goes off to sagepay, if a user gets to sagepay, cancels the payment, comes back and runs through the process again going through the address action a second time it works.

    The 3 main pages for the process are: Cart -> Address -> Preview -> Sagepay

    Cart is as per the demo store

    Address saves the shipping and billing address, works out the shipping based on a field in the product and sets the cost

    Preview shows the basket and how much it will cost THE SHIPPING COST IS SHOWN HERE EVEN THOUGH IT IS NOT PASSED TO SAGEPAY

    Any ideas why?

    Address .cshtml

    @using UCommerce.EntitiesV2
    @using UCommerce.Api
    @{
    var request = HttpContext.Current.Request;
    var basket = TransactionLibrary.GetBasket(true).PurchaseOrder;
    
    if (request.HttpMethod == "POST" && request.Form.AllKeys.Any(x => x == "update-addresses"))
    {
    
      TransactionLibrary.EditBillingInformation(
          request.Form["billing-firstname"],
          request.Form["billing-lastname"],
          request.Form["billing-email"],
          request.Form["billing-phone"],
          request.Form["billing-mobile"],
          request.Form["billing-company"],
          request.Form["billing-line1"],
          request.Form["billing-line2"],
          request.Form["billing-postcode"],
          request.Form["billing-city"],
          "",
          request.Form["billing-attention"],
          int.Parse(request.Form["billing-country"])
      );
    
      TransactionLibrary.EditShipmentInformation(
          request.Form["shipping-firstname"],
          request.Form["shipping-lastname"],
          request.Form["shipping-email"],
          request.Form["shipping-phone"],
          request.Form["shipping-mobile"],
          request.Form["shipping-company"],
          request.Form["shipping-line1"],
          request.Form["shipping-line2"],
          request.Form["shipping-postcode"],
          request.Form["shipping-city"],
          "",
          request.Form["shipping-attention"],
          int.Parse(request.Form["shipping-country"])
      );
    
      float shipCalc = 0;
      float maxShip = 0;
      float maxShipVAT = 0;
      float variantShipCalc = 0;             
    
        foreach (var lineItem in basket.OrderLines)    
        {
        var product2 = @CatalogLibrary.GetProduct(lineItem.Sku);
        var ShippingCost = product2["Shipping"].Value.AsFloat();
        var variant2 = product2.Variants.Single(x => x.VariantSku == lineItem.VariantSku); 
        shipCalc = shipCalc + ShippingCost;
    
        <!-- -->
    
            if(ShippingCost>maxShip) {
                maxShip = ShippingCost;
                maxShipVAT = ShippingCost * 1.2F;
                maxShipVAT = maxShipVAT-ShippingCost;
            }
    
        } 
    
        if (maxShip == 0.00) {
        TransactionLibrary.CreateShipment(11, overwriteExisting: true);
        } else if (maxShip == 5.00) { 
            TransactionLibrary.CreateShipment(16, overwriteExisting: true);
        } else if (maxShip == 30.00) { 
            TransactionLibrary.CreateShipment(24, overwriteExisting: true);
        } else {
        TransactionLibrary.CreateShipment(9, overwriteExisting: true);
        }   
    
      @*======== Set the payment method to sagepay ============*@
      TransactionLibrary.CreatePayment(8, requestPayment:false);
    
      @*======== Recalculate everything ============*@
      TransactionLibrary.ExecuteBasketPipeline();
    
      @*======== NOW WE REDIRECT========*@
      HttpContext.Current.Response.Redirect("Preview.aspx");
    
    }
    
  • Morten Skjoldager 440 posts 1499 karma points
    Jul 08, 2014 @ 09:29
    Morten Skjoldager
    0

    The OrderTotal are sent to SagePay. OrderTotal are calculated based on the shipment cost calculated in the associated ShippingMethodService. Have you implemented a shipping method service and registered it to calculate the shipping costs based on the Shipping parameter on your products? Or does the shipping the costs come from shippingmethods 11,16,24 or 9? Are the values saved on the shipping method service? 

  • Rob Smith 34 posts 165 karma points
    Jul 08, 2014 @ 11:09
    Rob Smith
    0

    Hi Morten,

    The amount for shipping comes from shippingmethods 11,16,24 or 9.

    Shipping costs are calculated on a Shipping parameter on the products, the basket is looped through to work out what the highest amount of shipping is (one of 4 options) and then calls the correct TransactionLibrary.CreateShipment to set the amount etc ie.

    TransactionLibrary.CreateShipment(24, overwriteExisting: true);

    I've implemented a workaround which adds an additional page so it now goes:

    Cart -> Address -> Shipping -> Preview -> Sagepay

    Shipping is never actually shown though it is just the payment calculation logic as above which seems to have fixed it though I have no idea why?

Please Sign in or register to post replies

Write your reply to:

Draft