/// <summary>
        /// Initializes a new instance of the <see cref="SagePayApiController"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The <see cref="IMerchelloContext"/>.
        /// </param>
        public SagePayApiController(IMerchelloContext merchelloContext)
        {
            if (merchelloContext == null) throw new ArgumentNullException("merchelloContext");

            var providerKey = new Guid(Constants.GatewayProviderSettingsKey);
            var provider =
                (SagePayPaymentGatewayProvider) merchelloContext.Gateways.Payment.GetProviderByKey(providerKey);

            if (provider == null)
            {
                var ex =
                    new NullReferenceException(
                        "The SagePayPaymentGatewayProvider could not be resolved.  The provider must be activiated");
                LogHelper.Error<SagePayApiController>("SagePayPaymentGatewayProvider not activated.", ex);
                throw ex;
            }

            _merchelloContext = merchelloContext;
            _formProcessor = new SagePayFormPaymentProcessor(provider.ExtendedData.GetProcessorSettings());
            _directProcessor = new SagePayDirectPaymentProcessor(provider.ExtendedData.GetProcessorSettings());
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SagePayApiController"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The <see cref="IMerchelloContext"/>.
        /// </param>
        public SagePayApiController(IMerchelloContext merchelloContext)
        {
            if (merchelloContext == null)
            {
                throw new ArgumentNullException("merchelloContext");
            }

            var providerKey = new Guid(Constants.GatewayProviderSettingsKey);
            var provider    =
                (SagePayPaymentGatewayProvider)merchelloContext.Gateways.Payment.GetProviderByKey(providerKey);

            if (provider == null)
            {
                var ex =
                    new NullReferenceException(
                        "The SagePayPaymentGatewayProvider could not be resolved.  The provider must be activiated");
                LogHelper.Error <SagePayApiController>("SagePayPaymentGatewayProvider not activated.", ex);
                throw ex;
            }

            _merchelloContext = merchelloContext;
            _formProcessor    = new SagePayFormPaymentProcessor(provider.ExtendedData.GetProcessorSettings());
            _directProcessor  = new SagePayDirectPaymentProcessor(provider.ExtendedData.GetProcessorSettings());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SagePayFormPaymentGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The <see cref="GatewayProviderService"/>.
 /// </param>
 /// <param name="paymentMethod">
 /// The <see cref="IPaymentMethod"/>.
 /// </param>
 /// <param name="extendedData">
 /// The SagePay providers <see cref="ExtendedDataCollection"/>
 /// </param>
 public SagePayFormPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, ExtendedDataCollection extendedData)
     : base(gatewayProviderService, paymentMethod, extendedData)
 {
     // New instance of the SagePay payment processor
     _processor = new SagePayFormPaymentProcessor(extendedData.GetProcessorSettings());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SagePayFormPaymentGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The <see cref="GatewayProviderService"/>.
 /// </param>
 /// <param name="paymentMethod">
 /// The <see cref="IPaymentMethod"/>.
 /// </param>
 /// <param name="extendedData">
 /// The SagePay providers <see cref="ExtendedDataCollection"/>
 /// </param>
 public SagePayFormPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, ExtendedDataCollection extendedData)
     : base(gatewayProviderService, paymentMethod, extendedData)
 {
     // New instance of the SagePay payment processor
     _processor = new SagePayFormPaymentProcessor(extendedData.GetProcessorSettings());
 }