/// <summary>
        /// Responsible for creating a
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="description">
        /// The description.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentGatewayMethod"/>.
        /// </returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            var available = ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == gatewayResource.ServiceCode);

            if (available == null)
            {
                var error = new InvalidOperationException("The GatewayResource has already been assigned.");

                LogHelper.Error <SagePayPaymentGatewayProvider>("GatewayResource has alread been assigned", error);

                throw error;
            }

            var attempt = GatewayProviderService.CreatePaymentMethodWithKey(GatewayProviderSettings.Key, name, description, available.ServiceCode);

            if (attempt.Success)
            {
                PaymentMethods = null;

                return(available.ServiceCode == "SagePay Form" ?
                       (IPaymentGatewayMethod) new SagePayFormPaymentGatewayMethod(GatewayProviderService, attempt.Result, GatewayProviderSettings.ExtendedData) :
                       new SagePayDirectPaymentGatewayMethod(GatewayProviderService, attempt.Result, GatewayProviderSettings.ExtendedData));
            }

            LogHelper.Error <SagePayPaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, available.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
        /// <summary>
        /// Creates a <see cref="IPaymentGatewayMethod"/> for this provider.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="description">
        /// The description.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentGatewayMethod"/>.
        /// </returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            var available = this.ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == gatewayResource.ServiceCode);

            if (available == null)
            {
                var error = new InvalidOperationException("The GatewayResource has already been assigned.");

                LogHelper.Error <BraintreePaymentGatewayProvider>("GatewayResource has alread been assigned", error);

                throw error;
            }

            var attempt = this.GatewayProviderService.CreatePaymentMethodWithKey(this.GatewayProviderSettings.Key, name, description, available.ServiceCode);

            if (attempt.Success)
            {
                this.PaymentMethods = null;

                return(GetPaymentGatewayMethodByPaymentCode(available.ServiceCode));
            }

            LogHelper.Error <BraintreePaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, available.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a <see cref="IPaymentGatewayMethod"/> for this provider.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="description">
        /// The description.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentGatewayMethod"/>.
        /// </returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            var available = this.ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == gatewayResource.ServiceCode);

            if (available == null)
            {
                var error = new InvalidOperationException("The GatewayResource has already been assigned.");

                LogHelper.Error<BraintreePaymentGatewayProvider>("GatewayResource has alread been assigned", error);

                throw error;
            }

            var attempt = this.GatewayProviderService.CreatePaymentMethodWithKey(this.GatewayProviderSettings.Key, name, description, available.ServiceCode);

            if (attempt.Success)
            {
                this.PaymentMethods = null;

                return GetPaymentGatewayMethodByPaymentCode(available.ServiceCode);
            }

            LogHelper.Error<BraintreePaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, available.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
        /// <summary>
        /// Responsible for creating a 
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="description">
        /// The description.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentGatewayMethod"/>.
        /// </returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            var available = ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == gatewayResource.ServiceCode);

            if (available == null)
            {
                var error = new InvalidOperationException("The GatewayResource has already been assigned.");

                LogHelper.Error<SagePayPaymentGatewayProvider>("GatewayResource has alread been assigned", error);

                throw error;
            }

            var attempt = GatewayProviderService.CreatePaymentMethodWithKey(GatewayProviderSettings.Key, name, description, available.ServiceCode);

            if (attempt.Success)
            {
                PaymentMethods = null;

                return available.ServiceCode == "SagePay Form" ?
                    (IPaymentGatewayMethod)new SagePayFormPaymentGatewayMethod(GatewayProviderService, attempt.Result, GatewayProviderSettings.ExtendedData) :
                    new SagePayDirectPaymentGatewayMethod(GatewayProviderService, attempt.Result, GatewayProviderSettings.ExtendedData);
            }

            LogHelper.Error<SagePayPaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, available.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
 /// <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;
 }
Exemplo n.º 6
0
        /// <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;
        }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
        /// <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;
        }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
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;
        }
         /// <summary>
         /// Creates a <see cref="INotificationGatewayMethod"/>
         /// </summary>
         /// <param name="gatewayResource">The <see cref="IGatewayResource"/> implemented by this method</param>
         /// <param name="name">The name of the notification method</param>
         /// <param name="serviceCode"></param>
         /// <returns></returns>
         public override INotificationGatewayMethod CreateNotificationMethod(IGatewayResource gatewayResource, string name, string serviceCode)
        {
            var attempt = GatewayProviderService.CreateNotificationMethodWithKey(GatewayProviderSettings.Key, name, serviceCode);

            if (attempt.Success) return new SmtpNotificationGatewayMethod(GatewayProviderService, attempt.Result, GatewayProviderSettings.ExtendedData);

            LogHelper.Error<NotificationGatewayProviderBase>(string.Format("Failed to create NotificationGatewayMethod GatewayResource: {0} , {1}", gatewayResource.Name, gatewayResource.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
        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 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>
        /// Creates a <see cref="INotificationGatewayMethod"/>
        /// </summary>
        /// <param name="gatewayResource">The <see cref="IGatewayResource"/> implemented by this method</param>
        /// <param name="name">The name of the notification method</param>
        /// <param name="serviceCode"></param>
        /// <returns></returns>
        public override INotificationGatewayMethod CreateNotificationMethod(IGatewayResource gatewayResource, string name, string serviceCode)
        {
            var attempt = GatewayProviderService.CreateNotificationMethodWithKey(GatewayProviderSettings.Key, name, serviceCode);

            if (attempt.Success)
            {
                return(new SmtpNotificationGatewayMethod(GatewayProviderService, attempt.Result, GatewayProviderSettings.ExtendedData));
            }

            LogHelper.Error <NotificationGatewayProviderBase>(string.Format("Failed to create NotificationGatewayMethod GatewayResource: {0} , {1}", gatewayResource.Name, gatewayResource.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
Exemplo n.º 17
0
 /// <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;
     }
 }
Exemplo n.º 18
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>
 /// 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;
     }
 }
Exemplo n.º 20
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) };
        }
Exemplo n.º 21
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="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(GatewayProviderSettings.Key, shipCountry, name, gatewayResource.ServiceCode + string.Format("-{0}", Guid.NewGuid()));

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

            return(new FixedRateShippingGatewayMethod(gatewayResource, attempt.Result, shipCountry));
        }
Exemplo n.º 23
0
        /// <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));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Creates a <see cref="IPaymentGatewayMethod"/>
        /// </summary>
        /// <param name="gatewayResource">The <see cref="IGatewayResource"/> implemented by this method</param>
        /// <param name="name">The name of the payment method</param>
        /// <param name="description">The description of the payment method</param>
        /// <returns>A <see cref="IPaymentGatewayMethod"/></returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            var paymentCode = gatewayResource.ServiceCode + "-" + Guid.NewGuid();

            var attempt = GatewayProviderService.CreatePaymentMethodWithKey(GatewayProviderSettings.Key, name, description, paymentCode);

            if (attempt.Success)
            {
                PaymentMethods = null;

                return(new CashPaymentGatewayMethod(GatewayProviderService, attempt.Result));
            }

            LogHelper.Error <CashPaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, paymentCode), attempt.Exception);

            throw attempt.Exception;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Creates a <see cref="IPaymentGatewayMethod"/>
        /// </summary>
        /// <param name="gatewayResource">The <see cref="IGatewayResource"/> implemented by this method</param>
        /// <param name="name">The name of the payment method</param>
        /// <param name="description">The description of the payment method</param>
        /// <returns>A <see cref="IPaymentGatewayMethod"/></returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            var paymentCode = gatewayResource.ServiceCode + "-" + Guid.NewGuid();

            var attempt = GatewayProviderService.CreatePaymentMethodWithKey(GatewayProviderSettings.Key, name, description, paymentCode);

            if (attempt.Success)
            {
                PaymentMethods = null;

                return new CashPaymentGatewayMethod(GatewayProviderService, attempt.Result);
            }

            MultiLogHelper.Error<CashPaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, paymentCode), attempt.Exception);

            throw attempt.Exception;
        }
        /// <summary>
        /// Creates a <see cref="IPaymentGatewayMethod"/>
        /// </summary>
        /// <param name="gatewayResource"></param>
        /// <param name="name">The name of the payment method</param>
        /// <param name="description">The description of the payment method</param>
        /// <returns>A <see cref="IPaymentGatewayMethod"/></returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            // assert gateway resource is still available
              var available = ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == gatewayResource.ServiceCode);
              if (available == null) throw new InvalidOperationException("GatewayResource has already been assigned");

              var attempt = GatewayProviderService.CreatePaymentMethodWithKey(GatewayProviderSettings.Key, name, description, available.ServiceCode);

              if (attempt.Success) {
            PaymentMethods = null;

            return new QuickPayPaymentGatewayMethod(GatewayProviderService, attempt.Result, GatewayProviderSettings.ExtendedData);
              }

              LogHelper.Error<QuickPayPaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, available.ServiceCode), attempt.Exception);

              throw attempt.Exception;
        }
        /// <summary>
        /// Creates a <see cref="IPaymentGatewayMethod"/>
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway Resource.
        /// </param>
        /// <param name="name">
        /// The name of the payment method
        /// </param>
        /// <param name="description">
        /// The description of the payment method
        /// </param>
        /// <returns>
        /// A <see cref="IPaymentGatewayMethod"/>
        /// </returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            // assert gateway resource is still available
            var available = ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == gatewayResource.ServiceCode);

            if (available == null)
            {
                throw new InvalidOperationException("GatewayResource has already been assigned");
            }

            var attempt = GatewayProviderService.CreatePaymentMethodWithKey(GatewayProviderSettings.Key, name, description, available.ServiceCode);

            if (attempt.Success)
            {
                PaymentMethods = null;

                return(new AuthorizeNetPaymentGatewayMethod(GatewayProviderService, attempt.Result, GatewayProviderSettings.ExtendedData));
            }

            LogHelper.Error <AuthorizeNetPaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, available.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
        /// <summary>
        /// Creates a <see cref="IPaymentGatewayMethod"/> for this provider.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="description">
        /// The description.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentGatewayMethod"/>.
        /// </returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            var available = ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == gatewayResource.ServiceCode);

            if (available == null)
            {
                var error = new InvalidOperationException("The GatewayResource has already been assigned.");

                LogHelper.Error<BraintreePaymentGatewayProvider>("GatewayResource has alread been assigned", error);

                throw error;
            }

            var attempt = GatewayProviderService.CreatePaymentMethodWithKey(GatewayProviderSettings.Key, name, description, available.ServiceCode);

            if (attempt.Success)
            {
                PaymentMethods = null;

                switch (available.ServiceCode)
                {
                    case Constants.PaymentCodes.VaultTransaction:
                        return new BraintreeVaultTransactionPaymentGatewayMethod(this.GatewayProviderService, attempt.Result, this.GetBraintreeApiService());
                    
                    case Constants.PaymentCodes.RecordSubscriptionTransaction:
                        return new BraintreeSubscriptionRecordPaymentMethod(GatewayProviderService, attempt.Result, this.GetBraintreeApiService());

                    default:
                        return new BraintreeStandardTransactionPaymentGatewayMethod(GatewayProviderService, attempt.Result, this.GetBraintreeApiService());
                }   
            }

            LogHelper.Error<BraintreePaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, available.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
Exemplo n.º 29
0
        /// <summary>
        /// Creates a <see cref="IPaymentGatewayMethod"/> for this provider.
        /// </summary>
        /// <param name="gatewayResource">
        /// The gateway resource.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="description">
        /// The description.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentGatewayMethod"/>.
        /// </returns>
        public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
        {
            var available = ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == gatewayResource.ServiceCode);

            if (available == null)
            {
                var error = new InvalidOperationException("The GatewayResource has already been assigned.");

                LogHelper.Error <BraintreePaymentGatewayProvider>("GatewayResource has alread been assigned", error);

                throw error;
            }

            var attempt = GatewayProviderService.CreatePaymentMethodWithKey(GatewayProviderSettings.Key, name, description, available.ServiceCode);

            if (attempt.Success)
            {
                PaymentMethods = null;

                switch (available.ServiceCode)
                {
                case Constants.PaymentCodes.VaultTransaction:
                    return(new BraintreeVaultTransactionPaymentGatewayMethod(this.GatewayProviderService, attempt.Result, this.GetBraintreeApiService()));

                case Constants.PaymentCodes.RecordSubscriptionTransaction:
                    return(new BraintreeSubscriptionRecordPaymentMethod(GatewayProviderService, attempt.Result, this.GetBraintreeApiService()));

                default:
                    return(new BraintreeStandardTransactionPaymentGatewayMethod(GatewayProviderService, attempt.Result, this.GetBraintreeApiService()));
                }
            }

            LogHelper.Error <BraintreePaymentGatewayProvider>(string.Format("Failed to create a payment method name: {0}, description {1}, paymentCode {2}", name, description, available.ServiceCode), attempt.Exception);

            throw attempt.Exception;
        }
 /// <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>
 /// Creates a <see cref="INotificationGatewayMethod"/>
 /// </summary>
 /// <param name="gatewayResource">The <see cref="IGatewayResource"/> implemented by this method</param>
 /// <param name="name">The name of the notification method</param>
 /// <param name="serviceCode">The description of the notification method</param>        
 /// <returns>The <see cref="INotificationGatewayMethod"/> created</returns>
 public abstract INotificationGatewayMethod CreateNotificationMethod(IGatewayResource gatewayResource, string name, string serviceCode);
 /// <summary>
 /// Creates a <see cref="INotificationGatewayMethod"/>
 /// </summary>
 /// <param name="gatewayResource">The <see cref="IGatewayResource"/> implemented by this method</param>
 /// <param name="name">The name of the notification method</param>
 /// <param name="serviceCode">The description of the notification method</param>
 /// <returns>The <see cref="INotificationGatewayMethod"/> created</returns>
 public abstract INotificationGatewayMethod CreateNotificationMethod(IGatewayResource gatewayResource, string name, string serviceCode);
Exemplo n.º 33
0
 public UPSShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, ExtendedDataCollection providerExtendedData)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     _processor = new UpsShippingProcessor(providerExtendedData.GetProcessorSettings());
     _shipMethod = shipMethod;
 }
        /// <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);
        }
 public GatewayController(IGatewayResource gatewayResource)
 {
     _gatewayResource = gatewayResource ?? throw new ArgumentNullException(nameof(gatewayResource));
 }
Exemplo n.º 36
0
        /// <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);
        }
 /// <summary>
 /// Creates a <see cref="IPaymentGatewayMethod"/>
 /// </summary>
 /// <param name="gatewayResource">The <see cref="IGatewayResource"/> implemented by this method</param>
 /// <param name="name">The name of the payment method</param>
 /// <param name="description">The description of the payment method</param>
 /// <returns>A <see cref="IPaymentGatewayMethod"/></returns>
 public abstract IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description);
 /// <summary>
 /// Creates a <see cref="IPaymentGatewayMethod"/>
 /// </summary>
 /// <param name="gatewayResource">The <see cref="IGatewayResource"/> implemented by this method</param>
 /// <param name="name">The name of the payment method</param>
 /// <param name="description">The description of the payment method</param>
 /// <returns>A <see cref="IPaymentGatewayMethod"/></returns>
 public abstract IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description);
 public UPSShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry, ExtendedDataCollection providerExtendedData)
     : base(gatewayResource, shipMethod, shipCountry)
 {
     _processor  = new UpsShippingProcessor(providerExtendedData.GetProcessorSettings());
     _shipMethod = shipMethod;
 }
 public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry,
                                                                    string name)
 {
     throw new System.NotImplementedException();
 }
 internal static GatewayResourceDisplay ToGatewayResourceDisplay(this IGatewayResource gatewayResource)
 {
     return(AutoMapper.Mapper.Map <GatewayResourceDisplay>(gatewayResource));
 }
Exemplo n.º 42
0
 public FixedRateShippingGatewayMethod(IGatewayResource gatewayResource, IShipMethod shipMethod, IShipCountry shipCountry)
     : this(gatewayResource, shipMethod, shipCountry, new ShippingFixedRateTable(shipMethod.Key))
 {
 }
Exemplo n.º 43
0
 /// <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))
 {
 }
 public override IShippingGatewayMethod CreateShippingGatewayMethod(IGatewayResource gatewayResource, IShipCountry shipCountry,
     string name)
 {
     throw new System.NotImplementedException();
 }
 public override IPaymentGatewayMethod CreatePaymentMethod(IGatewayResource gatewayResource, string name, string description)
 {
     throw new NotImplementedException();
 }