/// <summary> /// The get taxation by product method. /// </summary> /// <returns> /// The <see cref="ITaxationByProductMethod"/>. /// </returns> /// <exception cref="NullReferenceException"> /// Throws a null reference exception if a provider cannot be resolved /// </exception> private ITaxationByProductMethod GetTaxationByProductMethod() { var taxMethod = GatewayProviderService.GetTaxMethodForProductPricing(); if (taxMethod == null) { LogHelper.Debug <TaxationContext>("Product based pricing is set in settings, but a TaxMethod has not been assigned."); this._taxMethodNotQueried = true; return(null); } var provider = GatewayProviderResolver.GetProviderByKey <TaxationGatewayProviderBase>(taxMethod.ProviderKey); if (provider == null) { var error = new NullReferenceException("Could not reTaxationGatewayProvider for CalculateTaxForProduct could not be resolved"); LogHelper.Error <TaxationContext>("Resolution failure", error); throw error; } var productProvider = provider as ITaxationByProductProvider; if (productProvider != null) { this._taxMethodNotQueried = false; return(productProvider.GetTaxationByProductMethod(taxMethod.Key)); } LogHelper.Debug <TaxationContext>("Resolved provider did not Implement ITaxationByProductProvider returning no tax"); return(null); }