/// <summary>
        /// Initializes a new instance of the <see cref="FoaShippingGatewayMethod"/> class.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="shipMethod">
        /// The ship method.
        /// </param>
        /// <param name="shipCountry">
        /// The ship country.
        /// </param>
        /// <param name="gatewayProviderSettings">
        /// The gateway provider settings.
        /// </param>
        public FoaShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, IGatewayProviderSettings gatewayProviderSettings) : 
            base(gatewayResource, shipMethod, shipCountry)
        {
            _processorSettings = gatewayProviderSettings.ExtendedData.GetProcessorSettings();

            _shipMethod = shipMethod;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedRateShippingGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayResource">
 /// The gateway resource.
 /// </param>
 /// <param name="shipMethod">
 /// The ship method.
 /// </param>
 /// <param name="shipCountry">
 /// The ship country.
 /// </param>
 /// <param name="rateTable">
 /// The rate table.
 /// </param>
 public FixedRateShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, IShippingFixedRateTable rateTable)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     RateTable = new ShippingFixedRateTable(shipMethod.Key);
     _quoteType = GatewayResource.ServiceCode == FixedRateShippingGatewayProvider.VaryByWeightPrefix ? QuoteType.VaryByWeight : QuoteType.VaryByPrice;
     RateTable = rateTable;
 }
 public FedExShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, IGatewayProviderSettings gatewayProviderSettings, IRuntimeCacheProvider runtimeCacheProvider)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     _processor = new FedExShippingProcessor(gatewayProviderSettings.ExtendedData.GetProcessorSettings());
     _gatewayProviderSettings = gatewayProviderSettings;
     _shipMethod = shipMethod;
     _runtimeCache = runtimeCacheProvider;
 }
        /// <summary>
        /// Creates an instance of a <see cref="FixedRateShippingGatewayMethod"/>
        /// </summary>
        /// <param name="quoteType">
        /// The quote Type.
        /// </param>
        /// <param name="shipCountry">
        /// The ship Country.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <remarks>
        /// 
        /// This method is really specific to the RateTableShippingGateway due to the odd fact that additional shipmethods can be created 
        /// rather than defined up front.  
        /// 
        /// </remarks>
        /// <returns>
        /// The <see cref="IShippingGatewayMethod"/> created
        /// </returns>
        public IShippingGatewayMethod CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType quoteType, IShipCountry shipCountry, string name)
        {
            var resource = quoteType == FixedRateShippingGatewayMethod.QuoteType.VaryByWeight
                ? AvailableResources.First(x => x.ServiceCode == "VBW")
                : AvailableResources.First(x => x.ServiceCode == "VBP");

            return CreateShippingGatewayMethod(resource, shipCountry, name);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ShippingGatewayMethodBase"/> class.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="shipMethod">
        /// The ship method.
        /// </param>
        /// <param name="shipCountry">
        /// The ship country.
        /// </param>
        protected ShippingGatewayMethodBase(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry)
        {
            Mandate.ParameterNotNull(gatewayResource, "gatewayResource");
            Mandate.ParameterNotNull(shipMethod, "shipMethod");
            Mandate.ParameterNotNull(shipCountry, "shipCountry");

            _gatewayResource = gatewayResource;
            _shipMethod = shipMethod;
            _shipCountry = shipCountry;
        }
        public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry,
            string name)
        {
            var attempt = GatewayProviderService.CreateShipMethodWithKey(GatewayProviderSettings.Key, shipCountry, name,
                gatewayResource.ServiceCode);

            if (!attempt.Success) throw attempt.Exception;

            return new FoaShippingGatewayMethod(gatewayResource, attempt.Result, shipCountry, GatewayProviderSettings);
        }
 public override IEnumerable<IShippingGatewayMethod> GetAllShippingGatewayMethods(IShipCountry shipCountry)
 {
     var methods = GatewayProviderService.GetShipMethodsByShipCountryKey(GatewayProviderSettings.Key, shipCountry.Key);
     return methods
         .Select(
             shipMethod =>
                 new FoaShippingGatewayMethod(
                     GatewayResource,
                     shipMethod, shipCountry, GatewayProviderSettings)
         ).OrderBy(x => x.ShipMethod.Name);
 }
        /// <summary>
        /// Creates an instance of a <see cref="FixedRateShippingGatewayMethod"/>
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// 
        /// GatewayShipMethods (in general) should be unique with respect to <see cref="IShipCountry"/> and <see cref="IGatewayResource"/>.  However, this is a
        /// a provider is sort of a unique case, sense we want to be able to add as many ship methods with rate tables as needed in order to facilitate 
        /// tiered rate tables for various ship methods without requiring a carrier based shipping provider.
        /// 
        /// </remarks>    
        public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry, string name)
        {
            Mandate.ParameterNotNull(gatewayResource, "gatewayResource");
            Mandate.ParameterNotNull(shipCountry, "shipCountry");
            Mandate.ParameterNotNullOrEmpty(name, "name");

            var attempt = GatewayProviderService.CreateShipMethodWithKey(GatewayProvider.Key, shipCountry, name, gatewayResource.ServiceCode + string.Format("-{0}", Guid.NewGuid()));

            if (!attempt.Success) throw attempt.Exception;

            return new FixedRateShippingGatewayMethod(gatewayResource, attempt.Result, shipCountry);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SampleShippingGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayResource">
 /// The gateway resource.
 /// </param>
 /// <param name="shipMethod">
 /// The <see cref="IShipMethod"/>.
 /// </param>
 /// <param name="shipCountry">
 /// The <see cref="IShipCountry"/>.
 /// </param>
 /// <remarks>
 /// IShipMethod should really be named IShipMethodSettings as it is the configuration saved to the
 /// database of for the ShippingGatewayMethod.
 /// </remarks>
 public SampleShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     // this is pretty brittle as it requires the AppSetting be defined
     try
     {
         _isHeavyShippingRate = decimal.Parse(WebConfigurationManager.AppSettings["SampleShipProvider:HeavyShippingCharge"]);
     }
     catch
     {
         _isHeavyShippingRate = 30M;
     }
 }
Esempio n. 10
0
        public UspsShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, IGatewayProviderSettings gatewayProviderSettings, IRuntimeCacheProvider runtimeCache) : 
            base(gatewayResource, shipMethod, shipCountry)
        {
            _processorSettings = gatewayProviderSettings.ExtendedData.GetProcessorSettings();
            _shipMethod = shipMethod;
            _runtimeCache = runtimeCache;
            _gatewayProviderSettings = gatewayProviderSettings;

            // Express Mail Hold For Pickup
            ServiceLookup[2] = new[] { new UspsDeliveryOption(2, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Express Mail Flat-Rate Envelope Hold For Pickup
            ServiceLookup[27] = new[] { new UspsDeliveryOption(27, 12.5M, 9.5M, 0.75M, Decimal.MaxValue, 70) };

            // Express Mail
            ServiceLookup[3] = new[] { new UspsDeliveryOption(3, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Express Mail Flat-Rate Envelope
            ServiceLookup[13] = new[] { new UspsDeliveryOption(13, 12.5M, 9.5M, 0.75M, Decimal.MaxValue, 70) };

            // Priority Mail
            ServiceLookup[1] = new[] { new UspsDeliveryOption(1, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Priority Mail Flat-Rate Envelope
            ServiceLookup[16] = new[] { new UspsDeliveryOption(16, 12.5M, 9.5M, 0.75M, Decimal.MaxValue, 70) };

            // Priority Mail Small Flat-Rate Box
            ServiceLookup[28] = new[] { new UspsDeliveryOption(28, 5.375M, 8.625M, 1.675M, Decimal.MaxValue, 70) };

            // Priority Mail Regular/Medium Flat-Rate Boxes
            ServiceLookup[17] = new[]
                                    {
                                        new UspsDeliveryOption(17, 11.875M, 13.625M, 3.375M, Decimal.MaxValue, 70),
                                        new UspsDeliveryOption(17, 11M, 8.5M, 5.5M, Decimal.MaxValue, 70)
                                    };

            // Priority Mail Large Flat-Rate Box
            ServiceLookup[22] = new[] { new UspsDeliveryOption(22, 12, 12, 5.5M, Decimal.MaxValue, 70) };

            // Parcel Post
            ServiceLookup[4] = new[] { new UspsDeliveryOption(4, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Bound Printed Matter
            ServiceLookup[5] = new[] { new UspsDeliveryOption(5, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Media Mail
            ServiceLookup[6] = new[] { new UspsDeliveryOption(6, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Library Mail
            ServiceLookup[7] = new[] { new UspsDeliveryOption(7, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };
        }
        /// <summary>
        /// Creates an instance of a <see cref="UPSShippingGatewayMethod"/>
        /// </summary>     
        /// <remarks>
        /// 
        /// This method is really specific to the RateTableShippingGateway due to the odd fact that additional shipmethods can be created 
        /// rather than defined up front.  
        /// 
        /// </remarks>   
        public IShippingGatewayMethod CreateShipMethod(UPSShippingGatewayMethod.UPSType upsType,
            IShipCountry shipCountry, string name)
        {
            var resource = AvailableResources.First();
            switch (upsType.ToString())
            {
                case UPSShippingGatewayProvider.UPSNextDayAir:
                    resource = AvailableResources.First(x => x.ServiceCode == "01");
                    break;
                case UPSShippingGatewayProvider.UPS2ndDayAir:
                    resource = AvailableResources.First(x => x.ServiceCode == "02");
                    break;
                case UPSShippingGatewayProvider.UPSGround:
                    resource = AvailableResources.First(x => x.ServiceCode == "03");
                    break;
                case UPSShippingGatewayProvider.UPSWorldwideExpress:
                    resource = AvailableResources.First(x => x.ServiceCode == "07");
                    break;
                case UPSShippingGatewayProvider.UPSWorldwideExpidited:
                    resource = AvailableResources.First(x => x.ServiceCode == "08");
                    break;
                case UPSShippingGatewayProvider.UPSStandard:
                    resource = AvailableResources.First(x => x.ServiceCode == "11");
                    break;
                case UPSShippingGatewayProvider.UPS3DaySelect:
                    resource = AvailableResources.First(x => x.ServiceCode == "12");
                    break;
                case UPSShippingGatewayProvider.UPSNextDayAirSaver:
                    resource = AvailableResources.First(x => x.ServiceCode == "13");
                    break;
                case UPSShippingGatewayProvider.UPSNextDayAirEarlyAM:
                    resource = AvailableResources.First(x => x.ServiceCode == "14");
                    break;
                case UPSShippingGatewayProvider.UPSWorldwideExpressPlus:
                    resource = AvailableResources.First(x => x.ServiceCode == "54");
                    break;
                case UPSShippingGatewayProvider.UPS2ndDayAirAM:
                    resource = AvailableResources.First(x => x.ServiceCode == "59");
                    break;
            }

            return CreateShippingGatewayMethod(resource, shipCountry, name);
        }
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            DbPreTestDataWorker.DeleteAllInvoices();
            DbPreTestDataWorker.DeleteAllShipCountries();

            var defaultCatalog = DbPreTestDataWorker.WarehouseService.GetDefaultWarehouse().WarehouseCatalogs.FirstOrDefault();
            if (defaultCatalog == null) Assert.Ignore("Default WarehouseCatalog is null");

            _else = DbPreTestDataWorker.ShipCountryService.GetShipCountryByCountryCode(defaultCatalog.Key, "ELSE");

            var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey;
            var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Current.Gateways.Shipping.CreateInstance(key);
            var gwshipMethod1 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, _else, "Ground (Vary by Price)");
            gwshipMethod1.RateTable.AddRow(0, 10, 25);
            gwshipMethod1.RateTable.AddRow(10, 15, 30);
            gwshipMethod1.RateTable.AddRow(15, 25, 35);
            gwshipMethod1.RateTable.AddRow(25, 60, 40); // total price should be 50M so we should hit this tier
            gwshipMethod1.RateTable.AddRow(25, 10000, 50);
            rateTableProvider.SaveShippingGatewayMethod(gwshipMethod1);
        }
Esempio n. 13
0
        /// <summary>
        /// Creates a <see cref="IShipMethod"/>.  This is useful due to the data constraint
        /// preventing two ShipMethods being created with the same ShipCountry and ServiceCode for any provider.
        /// </summary>
        /// <param name="providerKey">The unique gateway provider key (Guid)</param>
        /// <param name="shipCountry">The <see cref="IShipCountry"/> this ship method is to be associated with</param>
        /// <param name="name">The required name of the <see cref="IShipMethod"/></param>
        /// <param name="serviceCode">The ShipMethods service code</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        internal Attempt<IShipMethod> CreateShipMethodWithKey(Guid providerKey, IShipCountry shipCountry, string name, string serviceCode, bool raiseEvents = true)
        {
            Mandate.ParameterCondition(providerKey != Guid.Empty, "providerKey");
            Mandate.ParameterNotNull(shipCountry, "shipCountry");
            Mandate.ParameterNotNullOrEmpty(name, "name");
            Mandate.ParameterNotNullOrEmpty(serviceCode, "serviceCode");

            if (ShipMethodExists(providerKey, shipCountry.Key, serviceCode)) 
                return Attempt<IShipMethod>.Fail(new ConstraintException("A Shipmethod already exists for this ShipCountry with this ServiceCode"));

            var shipMethod = new ShipMethod(providerKey, shipCountry.Key)
                {
                    Name = name,
                    ServiceCode = serviceCode,
                    Provinces = shipCountry.Provinces.ToShipProvinceCollection()
                };

            if(raiseEvents)
            if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs<IShipMethod>(shipMethod), this))
            {
                shipMethod.WasCancelled = true;
                return Attempt<IShipMethod>.Fail(shipMethod);
            }
            
            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateShipMethodRepository(uow))
                {
                    repository.AddOrUpdate(shipMethod);
                    uow.Commit();
                }
            }

            if(raiseEvents) Created.RaiseEvent(new Events.NewEventArgs<IShipMethod>(shipMethod), this);

            return Attempt<IShipMethod>.Succeed(shipMethod);
        }
 public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry,
     string name)
 {
     throw new System.NotImplementedException();
 }
 /// <summary>
 /// Gets a collection of <see cref="IGatewayProvider"/> by ship country
 /// </summary>
 /// <param name="shipCountry"></param>
 /// <returns></returns>
 public IEnumerable<IGatewayProvider> GetGatewayProvidersByShipCountry(IShipCountry shipCountry)
 {
     using (var repository = _repositoryFactory.CreateGatewayProviderRepository(_uowProvider.GetUnitOfWork()))
     {
         return repository.GetGatewayProvidersByShipCountryKey(shipCountry.Key);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SampleShippingGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayResource">
 /// The gateway resource.
 /// </param>
 /// <param name="shipMethod">
 /// The <see cref="IShipMethod"/>.
 /// </param>
 /// <param name="shipCountry">
 /// The <see cref="IShipCountry"/>.
 /// </param>
 /// <remarks>
 /// IShipMethod should really be named IShipMethodSettings as it is the configuration saved to the
 /// database of for the ShippingGatewayMethod.
 /// </remarks>
 public SampleShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     // this is pretty brittle as it requires the AppSetting be defined
     try
     {
         _isHeavyShippingRate = decimal.Parse(WebConfigurationManager.AppSettings["SampleShipProvider:HeavyShippingCharge"]);
     }
     catch
     {
         _isHeavyShippingRate = 30M;
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedRateShippingGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayResource">
 /// The gateway resource.
 /// </param>
 /// <param name="shipMethod">
 /// The ship method.
 /// </param>
 /// <param name="shipCountry">
 /// The ship country.
 /// </param>
 public FixedRateShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry)
     : this(gatewayResource, shipMethod, shipCountry, new ShippingFixedRateTable(shipMethod.Key))
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedRateShippingGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayResource">
 /// The gateway resource.
 /// </param>
 /// <param name="shipMethod">
 /// The ship method.
 /// </param>
 /// <param name="shipCountry">
 /// The ship country.
 /// </param>
 /// <param name="rateTable">
 /// The rate table.
 /// </param>
 public FixedRateShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, IShippingFixedRateTable rateTable)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     RateTable  = new ShippingFixedRateTable(shipMethod.Key);
     _quoteType = GatewayResource.ServiceCode == FixedRateShippingGatewayProvider.VaryByWeightPrefix ? QuoteType.VaryByWeight : QuoteType.VaryByPrice;
     RateTable  = rateTable;
 }
 internal static ShipCountryDisplay ToShipCountryDisplay(this IShipCountry shipCountry)
 {
     return(AutoMapper.Mapper.Map <ShipCountryDisplay>(shipCountry));
 }
Esempio n. 20
0
        /// <summary>
        /// Returns a collection of ship methods assigned for this specific provider configuration (associated with the ShipCountry)
        /// </summary>
        /// <returns></returns>
        public override IEnumerable <IShippingGatewayMethod> GetAllShippingGatewayMethods(IShipCountry shipCountry)
        {
            var methods = GatewayProviderService.GetShipMethodsByShipCountryKey(GatewayProviderSettings.Key, shipCountry.Key);

            return(methods
                   .Select(
                       shipMethod =>
                       new FedExShippingGatewayMethod(
                           AvailableResources.FirstOrDefault(x => shipMethod.ServiceCode.StartsWith(x.ServiceCode)),
                           shipMethod, shipCountry,
                           GatewayProviderSettings, _runtimeCache)
                       ).OrderBy(x => x.ShipMethod.Name));
        }
 /// <summary>
 /// Creates a <see cref="IShipMethod"/>.  This is useful due to the data constraint
 /// preventing two ShipMethods being created with the same ShipCountry and ServiceCode for any provider.
 /// </summary>
 /// <param name="providerKey">The unique gateway provider key (Guid)</param>
 /// <param name="shipCountry">The <see cref="IShipCountry"/> this ship method is to be associated with</param>
 /// <param name="name">The required name of the <see cref="IShipMethod"/></param>
 /// <param name="serviceCode">The ShipMethods service code</param>
 public Attempt <IShipMethod> CreateShipMethodWithKey(Guid providerKey, IShipCountry shipCountry, string name, string serviceCode)
 {
     return(((ShipMethodService)_shipMethodService).CreateShipMethodWithKey(providerKey, shipCountry, name, serviceCode));
 }
 /// <summary>
 /// Gets a collection of <see cref="IGatewayProviderSettings"/> by ship country
 /// </summary>
 /// <param name="shipCountry"></param>
 /// <returns></returns>
 public IEnumerable <IGatewayProviderSettings> GetGatewayProvidersByShipCountry(IShipCountry shipCountry)
 {
     using (var repository = _repositoryFactory.CreateGatewayProviderRepository(_uowProvider.GetUnitOfWork()))
     {
         return(repository.GetGatewayProvidersByShipCountryKey(shipCountry.Key));
     }
 }
        /// <summary>
        /// Creates a <see cref="ISampleShippingGatewayMethod"/> association with an allowed country.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="shipCountry">
        /// The ship country.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <returns>
        /// The <see cref="IShippingGatewayMethod"/>.
        /// </returns>
        public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry, string name)
        {
            //TODO: uncomment these when move to Umbraco 7.2.x
            //Mandate.ParameterNotNull(gatewayResource, "gatewayResource");
            //Mandate.ParameterNotNull(shipCountry, "shipCountry");
            //Mandate.ParameterNotNullOrEmpty(name, "name");

            var attempt = GatewayProviderService.CreateShipMethodWithKey(GatewayProviderSettings.Key, shipCountry, name, gatewayResource.ServiceCode + string.Format("-{0}", Guid.NewGuid()));

            if (!attempt.Success) throw attempt.Exception;

            return new SampleShippingGatewayMethod(gatewayResource, attempt.Result, shipCountry);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FoaShippingGatewayMethod"/> class.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="shipMethod">
        /// The ship method.
        /// </param>
        /// <param name="shipCountry">
        /// The ship country.
        /// </param>
        /// <param name="gatewayProviderSettings">
        /// The gateway provider settings.
        /// </param>
        public FoaShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, IGatewayProviderSettings gatewayProviderSettings) :
            base(gatewayResource, shipMethod, shipCountry)
        {
            _processorSettings = gatewayProviderSettings.ExtendedData.GetProcessorSettings();

            _shipMethod = shipMethod;
        }
        /// <summary>
        /// Resolves all active shipping gateway providers for a given <see cref="IShipCountry"/>
        /// </summary>
        /// <param name="shipCountry">
        /// The ship Country.
        /// </param>
        /// <returns>
        /// A collection of all active shipping gateway providers
        /// </returns>
        public IEnumerable <ShippingGatewayProviderBase> GetGatewayProvidersByShipCountry(IShipCountry shipCountry)
        {
            var gatewayProviders = GatewayProviderService.GetGatewayProvidersByShipCountry(shipCountry);

            return
                (gatewayProviders.Select(
                     provider => GatewayProviderResolver.GetProviderByKey <ShippingGatewayProviderBase>(provider.Key)));
        }
 public override IEnumerable <IShippingGatewayMethod> GetAllShippingGatewayMethods(IShipCountry shipCountry)
 {
     throw new System.NotImplementedException();
 }
        /// <summary>
        /// Creates an instance of a <see cref="FixedRateShippingGatewayMethod"/>
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway Resource.
        /// </param>
        /// <param name="shipCountry">
        /// The ship Country.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <returns>
        /// The <see cref="IShippingGatewayMethod"/> created
        /// </returns>
        /// <remarks>
        ///
        /// GatewayShipMethods (in general) should be unique with respect to <see cref="IShipCountry"/> and <see cref="IGatewayResource"/>.  However, this is a
        /// a provider is sort of a unique case, sense we want to be able to add as many ship methods with rate tables as needed in order to facilitate
        /// tiered rate tables for various ship methods without requiring a carrier based shipping provider.
        ///
        /// </remarks>
        public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry, string name)
        {
            Mandate.ParameterNotNull(gatewayResource, "gatewayResource");
            Mandate.ParameterNotNull(shipCountry, "shipCountry");
            Mandate.ParameterNotNullOrEmpty(name, "name");

            var attempt = GatewayProviderService.CreateShipMethodWithKey(GatewayProviderSettings.Key, shipCountry, name, gatewayResource.ServiceCode + string.Format("-{0}", Guid.NewGuid()));

            if (!attempt.Success)
            {
                throw attempt.Exception;
            }

            return(new FixedRateShippingGatewayMethod(gatewayResource, attempt.Result, shipCountry));
        }
        /// <summary>
        /// Creates an instance of a <see cref="FedExShippingGatewayMethod"/>
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// 
        /// GatewayShipMethods (in general) should be unique with respect to <see cref="IShipCountry"/> and <see cref="IGatewayResource"/>.  However, this is a
        /// a provider is sort of a unique case, sense we want to be able to add as many ship methods with rate tables as needed in order to facilitate 
        /// tiered rate tables for various ship methods without requiring a carrier based shipping provider.
        /// 
        /// </remarks>    
        public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource,
            IShipCountry shipCountry, string name)
        {

            //Mandate.ParameterNotNull(gatewayResource, "gatewayResource");
            //Mandate.ParameterNotNull(shipCountry, "shipCountry");
            //Mandate.ParameterNotNullOrEmpty(name, "name");

            var attempt = GatewayProviderService.CreateShipMethodWithKey(GatewayProviderSettings.Key, shipCountry, name,
                gatewayResource.ServiceCode);

            if (!attempt.Success) throw attempt.Exception;

            return new FedExShippingGatewayMethod(gatewayResource, attempt.Result, shipCountry, GatewayProviderSettings, _runtimeCache);
        }
Esempio n. 29
0
        /// <summary>
        /// Creates an instance of a <see cref="FedExShippingGatewayMethod"/>
        /// </summary>
        /// <remarks>
        ///
        /// This method is really specific to the RateTableShippingGateway due to the odd fact that additional shipmethods can be created
        /// rather than defined up front.
        ///
        /// </remarks>
        public IShippingGatewayMethod CreateShipMethod(FedExShippingGatewayMethod.FedExType fedExType,
                                                       IShipCountry shipCountry, string name)
        {
            var resource = AvailableResources.First();

            switch (fedExType.ToString())
            {
            case Constants.ExtendedDataKeys.FedEx2DayServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx2DayServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedEx2DayAmServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx2DayAmServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExExpressSaverServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExExpressSaverServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExFirstOvernightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExFirstOvernightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExPriorityOvernightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExPriorityOvernightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExStandardOvernightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExStandardOvernightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedEx1DayFreightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx1DayFreightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedEx2DayFreightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx2DayFreightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedEx3DayFreightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx3DayFreightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExFirstFreightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExFirstFreightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExInternationalDistributionFreightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalDistributionFreightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExEconomyFreightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExEconomyFreightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExInternationalEconomyServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalEconomyServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExInternationalEconomyDistributionServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalEconomyDistributionServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExInternationalFirstServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalFirstServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExInternationalPriorityServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalPriorityServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExInternationalPriorityDistributionServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalPriorityDistributionServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExInternationalPriorityFreightServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalPriorityFreightServiceCode);
                break;

            case Constants.ExtendedDataKeys.FedExEuropeFirstInternationalPriorityServiceCode:
                resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExEuropeFirstInternationalPriorityServiceCode);
                break;
            }

            return(CreateShippingGatewayMethod(resource, shipCountry, name));
        }
        /// <summary>
        /// Creates an instance of a <see cref="FedExShippingGatewayMethod"/>
        /// </summary>     
        /// <remarks>
        /// 
        /// This method is really specific to the RateTableShippingGateway due to the odd fact that additional shipmethods can be created 
        /// rather than defined up front.  
        /// 
        /// </remarks>   
        public IShippingGatewayMethod CreateShipMethod(FedExShippingGatewayMethod.FedExType fedExType,
            IShipCountry shipCountry, string name)
        {
            var resource = AvailableResources.First();
            switch (fedExType.ToString())
            {
                case Constants.ExtendedDataKeys.FedEx2DayServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx2DayServiceCode);
                    break;
                case Constants.ExtendedDataKeys.FedEx2DayAmServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx2DayAmServiceCode);
                    break;
                case Constants.ExtendedDataKeys.FedExExpressSaverServiceCode:
                     resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExExpressSaverServiceCode);        
                    break;
                case Constants.ExtendedDataKeys.FedExFirstOvernightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExFirstOvernightServiceCode);     
                    break;
                case Constants.ExtendedDataKeys.FedExPriorityOvernightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExPriorityOvernightServiceCode);     
                    break;
                case Constants.ExtendedDataKeys.FedExStandardOvernightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExStandardOvernightServiceCode);     
                    break;
                case Constants.ExtendedDataKeys.FedEx1DayFreightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx1DayFreightServiceCode);           
                    break;
                case Constants.ExtendedDataKeys.FedEx2DayFreightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx2DayFreightServiceCode);           
                    break;
                case Constants.ExtendedDataKeys.FedEx3DayFreightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedEx3DayFreightServiceCode);           
                    break;
                case Constants.ExtendedDataKeys.FedExFirstFreightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExFirstFreightServiceCode);          
                    break;
                case Constants.ExtendedDataKeys.FedExInternationalDistributionFreightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalDistributionFreightServiceCode);    
                    break;
                case Constants.ExtendedDataKeys.FedExEconomyFreightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExEconomyFreightServiceCode);                             
                    break;
                case Constants.ExtendedDataKeys.FedExInternationalEconomyServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalEconomyServiceCode);                       
                    break;
                case Constants.ExtendedDataKeys.FedExInternationalEconomyDistributionServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalEconomyDistributionServiceCode);               
                    break;
                case Constants.ExtendedDataKeys.FedExInternationalFirstServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalFirstServiceCode);                   
                    break;
                case Constants.ExtendedDataKeys.FedExInternationalPriorityServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalPriorityServiceCode);                
                    break;
                case Constants.ExtendedDataKeys.FedExInternationalPriorityDistributionServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalPriorityDistributionServiceCode);     
                    break;
                case Constants.ExtendedDataKeys.FedExInternationalPriorityFreightServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExInternationalPriorityFreightServiceCode);       
                    break;
                case Constants.ExtendedDataKeys.FedExEuropeFirstInternationalPriorityServiceCode:
                    resource = AvailableResources.First(x => x.ServiceCode == Constants.ExtendedDataKeys.FedExEuropeFirstInternationalPriorityServiceCode);   
                    break;
            }

            return CreateShippingGatewayMethod(resource, shipCountry, name);
        }
 /// <summary>
 /// Returns a collection of ship methods assigned for this specific provider configuration (associated with the ShipCountry)
 /// </summary>
 /// <param name="shipCountry">
 /// The ship Country.
 /// </param>
 /// <returns>
 /// A collection of all <see cref="IShippingGatewayMethod"/> for shipCountry
 /// </returns>
 public abstract IEnumerable<IShippingGatewayMethod> GetAllShippingGatewayMethods(IShipCountry shipCountry);
 /// <summary>
 /// Creates an instance of a ship method (T) without persisting it to the database
 /// </summary>
 /// <param name="gatewayResource">
 /// The gateway Resource.
 /// </param>
 /// <param name="shipCountry">
 /// The ship Country.
 /// </param>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <returns>
 /// The newly created <see cref="IShippingGatewayMethod"/>
 /// </returns>
 /// <remarks>
 /// 
 /// ShipMethods should be unique with respect to <see cref="IShipCountry"/> and <see cref="IGatewayResource"/>
 /// 
 /// </remarks>
 public abstract IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry, string name);
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedRateShippingGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayResource">
 /// The gateway resource.
 /// </param>
 /// <param name="shipMethod">
 /// The ship method.
 /// </param>
 /// <param name="shipCountry">
 /// The ship country.
 /// </param>
 public FixedRateShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry)
     : this(gatewayResource, shipMethod, shipCountry, new ShippingFixedRateTable(shipMethod.Key))
 {
 }
Esempio n. 34
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            var warehouseService = PreTestDataWorker.WarehouseService;
            _warehouse = warehouseService.GetDefaultWarehouse();

            _warehouseCatalog = _warehouse.DefaultCatalog();

            var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey;
            _fixedRateProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Gateways.Shipping.ResolveByKey(key);

            var shipCountryService = PreTestDataWorker.ShipCountryService;
            _shipCountry = shipCountryService.GetShipCountryByCountryCode(_warehouseCatalog.Key, "US");
        }
Esempio n. 35
0
 /// <summary>
 /// Creates an instance of a ship method (T) without persisting it to the database
 /// </summary>
 /// <returns></returns>
 /// <remarks>
 ///
 /// ShipMethods should be unique with respect to <see cref="IShipCountry"/> and <see cref="IGatewayResource"/>
 ///
 /// </remarks>
 public abstract IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry, string name);
Esempio n. 36
0
        /// <summary>
        /// Deletes a single <see cref="IShipCountry"/> object
        /// </summary>
        /// <param name="shipCountry"></param>
        /// <param name="raiseEvents"></param>
        public void Delete(IShipCountry shipCountry, bool raiseEvents = true)
        {
            if(raiseEvents)
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs<IShipCountry>(shipCountry), this))
            {
                ((ShipCountry) shipCountry).WasCancelled = true;
                return;
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateShipCountryRepository(uow, _storeSettingService))
                {
                    repository.Delete(shipCountry);
                    uow.Commit();
                }
            }
            
            if(raiseEvents) Deleted.RaiseEvent(new DeleteEventArgs<IShipCountry>(shipCountry), this);
        }
Esempio n. 37
0
 /// <summary>
 /// Returns a collection of ship methods assigned for this specific provider configuration (associated with the ShipCountry)
 /// </summary>
 /// <returns></returns>
 public abstract IEnumerable <IShippingGatewayMethod> GetAllShippingGatewayMethods(IShipCountry shipCountry);
 public UPSShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, IGatewayProviderSettings gatewayProviderSettings, IRuntimeCacheProvider runtimeCache)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     _processorSettings       = gatewayProviderSettings.ExtendedData.GetProcessorSettings();
     _gatewayProviderSettings = gatewayProviderSettings;
     _shipMethod   = shipMethod;
     _runtimeCache = runtimeCache;
     _shipMethod   = shipMethod;
 }
 /// <summary>
 /// Returns a collection of ship methods assigned for this specific provider configuration (associated with the ShipCountry)
 /// </summary>
 /// <returns></returns>
 public override IEnumerable<IShippingGatewayMethod> GetAllShippingGatewayMethods(IShipCountry shipCountry)
 {
     var methods = GatewayProviderService.GetShipMethodsByShipCountryKey(GatewayProviderSettings.Key, shipCountry.Key);
     return methods
         .Select(
             shipMethod =>
                 new FedExShippingGatewayMethod(
                     AvailableResources.FirstOrDefault(x => shipMethod.ServiceCode.StartsWith(x.ServiceCode)),
                     shipMethod, shipCountry,
                     GatewayProviderSettings, _runtimeCache)
         ).OrderBy(x => x.ShipMethod.Name);
 }
Esempio n. 40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShippingGatewayMethodBase"/> class.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="shipMethod">
        /// The ship method.
        /// </param>
        /// <param name="shipCountry">
        /// The ship country.
        /// </param>
        protected ShippingGatewayMethodBase(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry)
        {
            Mandate.ParameterNotNull(gatewayResource, "gatewayResource");
            Mandate.ParameterNotNull(shipMethod, "shipMethod");
            Mandate.ParameterNotNull(shipCountry, "shipCountry");

            _gatewayResource = gatewayResource;
            _shipMethod      = shipMethod;
            _shipCountry     = shipCountry;
        }
Esempio n. 41
0
 public UPSShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, ExtendedDataCollection providerExtendedData)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     _processor = new UpsShippingProcessor(providerExtendedData.GetProcessorSettings());
     _shipMethod = shipMethod;
 }
Esempio n. 42
0
        public UspsShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, IGatewayProviderSettings gatewayProviderSettings, IRuntimeCacheProvider runtimeCache) :
            base(gatewayResource, shipMethod, shipCountry)
        {
            _processorSettings       = gatewayProviderSettings.ExtendedData.GetProcessorSettings();
            _shipMethod              = shipMethod;
            _runtimeCache            = runtimeCache;
            _gatewayProviderSettings = gatewayProviderSettings;

            // Express Mail Hold For Pickup
            ServiceLookup[2] = new[] { new UspsDeliveryOption(2, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Express Mail Flat-Rate Envelope Hold For Pickup
            ServiceLookup[27] = new[] { new UspsDeliveryOption(27, 12.5M, 9.5M, 0.75M, Decimal.MaxValue, 70) };

            // Express Mail
            ServiceLookup[3] = new[] { new UspsDeliveryOption(3, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Express Mail Flat-Rate Envelope
            ServiceLookup[13] = new[] { new UspsDeliveryOption(13, 12.5M, 9.5M, 0.75M, Decimal.MaxValue, 70) };

            // Priority Mail
            ServiceLookup[1] = new[] { new UspsDeliveryOption(1, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Priority Mail Flat-Rate Envelope
            ServiceLookup[16] = new[] { new UspsDeliveryOption(16, 12.5M, 9.5M, 0.75M, Decimal.MaxValue, 70) };

            // Priority Mail Small Flat-Rate Box
            ServiceLookup[28] = new[] { new UspsDeliveryOption(28, 5.375M, 8.625M, 1.675M, Decimal.MaxValue, 70) };

            // Priority Mail Regular/Medium Flat-Rate Boxes
            ServiceLookup[17] = new[]
            {
                new UspsDeliveryOption(17, 11.875M, 13.625M, 3.375M, Decimal.MaxValue, 70),
                new UspsDeliveryOption(17, 11M, 8.5M, 5.5M, Decimal.MaxValue, 70)
            };

            // Priority Mail Large Flat-Rate Box
            ServiceLookup[22] = new[] { new UspsDeliveryOption(22, 12, 12, 5.5M, Decimal.MaxValue, 70) };

            // Parcel Post
            ServiceLookup[4] = new[] { new UspsDeliveryOption(4, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Bound Printed Matter
            ServiceLookup[5] = new[] { new UspsDeliveryOption(5, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Media Mail
            ServiceLookup[6] = new[] { new UspsDeliveryOption(6, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };

            // Library Mail
            ServiceLookup[7] = new[] { new UspsDeliveryOption(7, Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue, 108, 70) };
        }
 /// <summary>
 /// Deletes all active shipMethods
 /// </summary>
 /// <param name="shipCountry">
 /// The ship Country.
 /// </param>
 /// <remarks>
 /// Used for testing
 /// </remarks>
 internal virtual void DeleteAllActiveShipMethods(IShipCountry shipCountry)
 {
     foreach (var gatewayShipMethod in GetAllShippingGatewayMethods(shipCountry))
     {
         DeleteShippingGatewayMethod(gatewayShipMethod);
     }
 }
        internal static IShipCountry ToShipCountry(this ShipCountryDisplay shipCountryDisplay, IShipCountry destination)
        {
            // May not be any mapping

            return(destination);
        }
        public void Init()
        {
            _destination = new Address()
            {
                Name = "Mindfly Web Design Studio",
                Address1 = "114 W. Magnolia St.  Suite 504",
                Locality = "Bellingham",
                Region = "WA",
                PostalCode = "98225",
                CountryCode = "US"
            };

            PreTestDataWorker.DeleteAllItemCaches();
            PreTestDataWorker.DeleteAllInvoices();
            _customer = PreTestDataWorker.MakeExistingAnonymousCustomer();
            _basket = Basket.GetBasket(MerchelloContext, _customer);

            for (var i = 0; i < ProductCount; i++) _basket.AddItem(PreTestDataWorker.MakeExistingProduct(true, WeightPerProduct, PricePerProduct));

            Basket.Save(MerchelloContext, _basket);

            _shipCountry = ShipCountryService.GetShipCountryByCountryCode(Catalog.Key, "US");
        }
Esempio n. 46
0
        public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry,
                                                                           string name)
        {
            var attempt = GatewayProviderService.CreateShipMethodWithKey(GatewayProviderSettings.Key, shipCountry, name,
                                                                         gatewayResource.ServiceCode);

            if (!attempt.Success)
            {
                throw attempt.Exception;
            }

            return(new FoaShippingGatewayMethod(gatewayResource, attempt.Result, shipCountry, GatewayProviderSettings));
        }
 /// <summary>
 /// Creates a <see cref="IShipMethod"/>.  This is useful due to the data constraint
 /// preventing two ShipMethods being created with the same ShipCountry and ServiceCode for any provider.
 /// </summary>
 /// <param name="providerKey">The unique gateway provider key (Guid)</param>
 /// <param name="shipCountry">The <see cref="IShipCountry"/> this ship method is to be associated with</param>
 /// <param name="name">The required name of the <see cref="IShipMethod"/></param>
 /// <param name="serviceCode">The ShipMethods service code</param>
 public Attempt<IShipMethod> CreateShipMethodWithKey(Guid providerKey, IShipCountry shipCountry, string name, string serviceCode)
 {
     return ((ShipMethodService)_shipMethodService).CreateShipMethodWithKey(providerKey, shipCountry, name, serviceCode);
 }
Esempio n. 48
0
        public override IEnumerable <IShippingGatewayMethod> GetAllShippingGatewayMethods(IShipCountry shipCountry)
        {
            var methods = GatewayProviderService.GetShipMethodsByShipCountryKey(GatewayProviderSettings.Key, shipCountry.Key);

            return(methods
                   .Select(
                       shipMethod =>
                       new FoaShippingGatewayMethod(
                           GatewayResource,
                           shipMethod, shipCountry, GatewayProviderSettings)
                       ).OrderBy(x => x.ShipMethod.Name));
        }
        internal static IShipCountry ToShipCountry(this ShipCountryDisplay shipCountryDisplay, IShipCountry destination)
        {
            // May not be any mapping

            return destination;
        }
        /// <summary>
        /// Creates an instance of a <see cref="FixedRateShippingGatewayMethod"/>
        /// </summary>
        /// <param name="quoteType">
        /// The quote Type.
        /// </param>
        /// <param name="shipCountry">
        /// The ship Country.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <remarks>
        ///
        /// This method is really specific to the RateTableShippingGateway due to the odd fact that additional shipmethods can be created
        /// rather than defined up front.
        ///
        /// </remarks>
        /// <returns>
        /// The <see cref="IShippingGatewayMethod"/> created
        /// </returns>
        public IShippingGatewayMethod CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType quoteType, IShipCountry shipCountry, string name)
        {
            var resource = quoteType == FixedRateShippingGatewayMethod.QuoteType.VaryByWeight
                ? AvailableResources.First(x => x.ServiceCode == "VBW")
                : AvailableResources.First(x => x.ServiceCode == "VBP");

            return(CreateShippingGatewayMethod(resource, shipCountry, name));
        }
 public override IEnumerable<IShippingGatewayMethod> GetAllShippingGatewayMethods(IShipCountry shipCountry)
 {
     throw new System.NotImplementedException();
 }
 public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry,
                                                                    string name)
 {
     throw new System.NotImplementedException();
 }