/// <summary>
        /// Initializes a new instance of the <see cref="AvaTaxTaxationGatewayMethod"/> class.
        /// </summary>
        /// <param name="taxMethod">
        /// The tax method.
        /// </param>
        /// <param name="extendedData">
        /// The extended Data collection from the provider.
        /// </param>
        public AvaTaxTaxationGatewayMethod(ITaxMethod taxMethod, ExtendedDataCollection extendedData) 
            : base(taxMethod)
        {            
            _settings = extendedData.GetAvaTaxProviderSettings();

            _avaTaxService = new AvaTaxService(_settings);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AvaTaxTaxationGatewayMethod"/> class.
        /// </summary>
        /// <param name="taxMethod">
        /// The tax method.
        /// </param>
        /// <param name="extendedData">
        /// The extended Data collection from the provider.
        /// </param>
        public AvaTaxTaxationGatewayMethod(ITaxMethod taxMethod, ExtendedDataCollection extendedData)
            : base(taxMethod)
        {
            _settings = extendedData.GetAvaTaxProviderSettings();

            _avaTaxService = new AvaTaxService(_settings);
        }
Esempio n. 3
0
        public void Can_Ping_The_Tax_Api()
        {
            //// Arrange

            //// Act
            var result = AvaTaxService.Ping();

            //// Assert
            Assert.NotNull(result);
            Assert.AreEqual(result.ResultCode, SeverityLevel.Success);
            Assert.IsTrue(result.TaxDetails.Any());
        }
Esempio n. 4
0
        public void Can_Get_TaxResult_With_Deserialized_Example_Json()
        {
            //// Arrange
            var taxRequest = JsonConvert.DeserializeObject <TaxRequest>(JSON);

            taxRequest.DocCode = "INV-O1";
            //// Act
            var result = AvaTaxService.GetTax(taxRequest);

            //// Assert
            Assert.NotNull(result);

            Assert.AreEqual(result.ResultCode, SeverityLevel.Success);
        }
Esempio n. 5
0
        public void Can_Estimate_Tax_Based_On_Geo_Data()
        {
            //// Arrange
            // Mindfly lat/long
            var latitude   = 48.751413M;
            var longitude  = -122.478071M;
            var salesPrice = 10;

            //// Act
            var result = AvaTaxService.EstimateTax(latitude, longitude, salesPrice);

            //// Assert
            Assert.NotNull(result);
            Assert.AreEqual(result.ResultCode, SeverityLevel.Success);
            Assert.IsTrue(result.TaxDetails.Any());
        }
Esempio n. 6
0
        public void Can_Validate_Shipping_Address_From_Invoice_Line_Item()
        {
            //// Arrange
            var shippableItems = Invoice.ShippingLineItems();
            var shipment       = shippableItems.FirstOrDefault().ExtendedData.GetShipment <OrderLineItem>();
            var origin         = shipment.GetOriginAddress();
            var destination    = shipment.GetDestinationAddress();

            //// Act
            var resultOrigin      = AvaTaxService.ValidateTaxAddress(origin.ToValidatableAddress());
            var resultDestination = AvaTaxService.ValidateTaxAddress(destination.ToValidatableAddress());

            //// Assert
            Assert.NotNull(resultOrigin);
            Assert.IsTrue(resultOrigin.ResultCode == SeverityLevel.Success);
            Assert.NotNull(resultDestination);
            Assert.IsTrue(resultDestination.ResultCode == SeverityLevel.Success);
        }
Esempio n. 7
0
        public void Can_Get_Tax_Result_With_IInvoice_Data()
        {
            //// Arrange
            var storeAddress = new Address()
            {
                Name        = "Mindfly, Inc.",
                Address1    = "114 W. Magnolia St. Suite 300",
                Locality    = "Bellingham",
                Region      = "WA",
                PostalCode  = "98225",
                CountryCode = "US"
            };

            var taxRequest = Invoice.AsTaxRequest(storeAddress.ToTaxAddress());

            taxRequest.DocCode = "INV-DT-" + Guid.NewGuid().ToString();
            Assert.NotNull(taxRequest);

            var result = AvaTaxService.GetTax(taxRequest);

            //// Assert
            Assert.NotNull(result);

            if (result.ResultCode != SeverityLevel.Success)
            {
                if (result.Messages.Any())
                {
                    foreach (var message in result.Messages)
                    {
                        Console.WriteLine(message.Details);
                    }
                }
            }

            Assert.AreEqual(result.ResultCode, SeverityLevel.Success);
        }