kylewest / DotNetShipping

UPS, FedEx, USPS shipping rate calculators for .NET
MIT License
80 stars 66 forks source link

Fedex provides shows different rates every time that it runs #33

Closed rlamunoz closed 8 years ago

rlamunoz commented 8 years ago

image

When I ran my code with this package:

packages.Add(new Package(12, 12, 12, 35, 150));

the same address and my FedEx account I received each time different rates it is not consistent each time.

kylewest commented 8 years ago

Can you share the code you are using? make sure to leave your account info out of it.

rlamunoz commented 8 years ago

Sure! few minutes ago I ran this code 2 times and in one it display "FedEx Standard Overnight" and the next time it did not display that value. Thanks you!

using System;
using System.Collections.Generic;
using System.Configuration;
using DotNetShipping.ShippingProviders;

namespace DotNetShipping.SampleApp
{
    internal class Program
    {
        private static void Main()
        {
            var appSettings = ConfigurationManager.AppSettings;

            //// You will need a license #, userid and password to utilize the UPS provider.
            //var upsLicenseNumber = appSettings["UPSLicenseNumber"];
            //var upsUserId = appSettings["UPSUserId"];
            //var upsPassword = appSettings["UPSPassword"];

            // You will need an account # and meter # to utilize the FedEx provider.
            var fedexKey = appSettings["FedExKey"];
            var fedexPassword = appSettings["FedExPassword"];
            var fedexAccountNumber = appSettings["FedExAccountNumber"];
            var fedexMeterNumber = appSettings["FedExMeterNumber"];

            // You will need a userId to use the USPS provider. Your account will also need access to the production servers.
            //var uspsUserId = appSettings["USPSUserId"];

            // Setup package and destination/origin addresses
            var packages = new List<Package>();
            packages.Add(new Package(12, 12, 12, 35, 150));
            //packages.Add(new Package(4, 4, 6, 15, 250));

            var origin = new Address("Saint Petersburg", "FL", "33712", "US");
            var destination = new Address("Austin", "TX", "78759", "US"); // US Address
            //var destination = new Address("", "", "00907", "PR"); // Puerto Rico Address
            //var destination = new Address("", "", "L4W 1S2", "CA"); // Canada Address
            //var destination = new Address("", "", "SW1E 5JL", "GB"); // UK Address

            // Create RateManager
            var rateManager = new RateManager();

            // Add desired DotNetShippingProviders
            //rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword) {UseProduction = false});
            rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber,false));
            //rateManager.AddProvider(new USPSProvider(uspsUserId));
            //rateManager.AddProvider(new USPSInternationalProvider(uspsUserId));

            // (Optional) Add RateAdjusters
            //rateManager.AddRateAdjuster(new PercentageRateAdjuster(.9M));

            // Call GetRates()
            var shipment = rateManager.GetRates(origin, destination, packages);

            // Iterate through the rates returned
            foreach (var rate in shipment.Rates)
            {
                Console.WriteLine(rate);
            }

            Console.ReadLine();
        }
    }
}
kylewest commented 8 years ago

@rlamunoz have you been able to reproduce this? I ran your code about a dozen times and got the same results each time. only difference would be our FedEx account numbers. I'm going to close this for now. Please reopen if you can reproduce the conflicting rates.

screen shot 2015-11-30 at 1 23 17 pm