<commit_before>VatCalculator
================

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://travis-ci.org/mpociot/vat-calculator.svg)](https://travis-ci.org/mpociot/vat-calculator)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mpociot/vat-calculator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mpociot/vat-calculator/?branch=master)
[![codecov.io](https://codecov.io/github/mpociot/vat-calculator/coverage.svg?branch=master)](https://codecov.io/github/mpociot/vat-calculator?branch=master)
[![StyleCI](https://styleci.io/repos/41703624/shield)](https://styleci.io/repos/41703624)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/adecb98a-8484-48cb-be13-803decc475bc/mini.png)](https://insight.sensiolabs.com/projects/adecb98a-8484-48cb-be13-803decc475bc)

Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.
Can be used with **Laravel 5 / Cashier** &mdash; or **standalone**.

```php
// Easy to use!
$countryCode = VatCalculator::getIPBasedCountry();
VatCalculator::calculate( 24.00, $countryCode );
VatCalculator::calculate( 24.00, $countryCode, $postalCode );
VatCalculator::calculate( 71.00, 'DE', '41352', $isCompany = true );
VatCalculator::getTaxRateForLocation( 'NL' );
// Check validity of a VAT number
VatCalculator::isValidVATNumber('NL123456789B01');
```
## Contents

- [Installation](#installation)
	- [Laravel 5](#installation-laravel5)
	- [Standalone](#installation-standalone)
- [Usage](#usage)
	- [Calculate the gross price](#calculate-the-gross-price)
	- [Receive more information](#receive-more-information)
	- [Validate EU VAT numbers](#validate-eu-vat-numbers)
		- [Laravel Validator extension](#laravel-validator-extension)
	- [Get EU VAT number details](#vat-number-details)
	- [Cashier integration](#cashier-integration)
	- [Get the IP based country of your user](#get-ip-based-country)
	- [Frontend integration - vat_calculator.js](#frontend-integration)
		- [Integrating it in your payment form](#payment-form-integration)
		- [Extra fields](#extra-fields)
		- [Form attributes](#form-attributes)
		- [Form fields](#form-fields)
		- [Advanced usage](#advanced-usage)
		- [Preconfigured routes](#preconfigured-routes)
- [Configuration (optional)](#configuration)
- [Changelog](#changelog)
- [License](#license)

<a name="installation"></a>
## Installation

In order to install the VAT Calculator, just run

```bash
$ composer require mpociot/vat-calculator
```
<a name="installation-laravel5"></a>
### Laravel 5

This package comes with a service provider, to use this package within your Laravel 5 app. Go to your `config/app.php` and add 

    Mpociot\VatCalculator\VatCalculatorServiceProvider::class
    
to the `providers` array.
    
The `VatCalculator` Facade will be installed automatically within the Service Provider, but if you want you can of course add it to the `aliases` array (Useful for the IDE helper).

	'VatCalculator' => Mpociot\VatCalculator\Facades\VatCalculator::class
	
<a name="installation-standalone"></a>
### Standalone

You can also use this package without Laravel. Simply create a new instance of the VAT calculator and use it.
All documentation examples use the Laravel 5 facade code, so make sure not to call the methods as if they were static methods.

Example:

```php
use Mpociot\VatCalculator\VatCalculator;

$vatCalculator = new VatCalculator();
$vatCalculator->setBusinessCountryCode('DE');
$countryCode = $vatCalculator->getIPBasedCountry();<commit_msg>Remove install instructions for Laravel<commit_after>VatCalculator
================

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://travis-ci.org/mpociot/vat-calculator.svg)](https://travis-ci.org/mpociot/vat-calculator)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mpociot/vat-calculator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mpociot/vat-calculator/?branch=master)
[![codecov.io](https://codecov.io/github/mpociot/vat-calculator/coverage.svg?branch=master)](https://codecov.io/github/mpociot/vat-calculator?branch=master)
[![StyleCI](https://styleci.io/repos/41703624/shield)](https://styleci.io/repos/41703624)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/adecb98a-8484-48cb-be13-803decc475bc/mini.png)](https://insight.sensiolabs.com/projects/adecb98a-8484-48cb-be13-803decc475bc)

Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.
Can be used with **Laravel 5 / Cashier** &mdash; or **standalone**.

```php
// Easy to use!
$countryCode = VatCalculator::getIPBasedCountry();
VatCalculator::calculate( 24.00, $countryCode );
VatCalculator::calculate( 24.00, $countryCode, $postalCode );
VatCalculator::calculate( 71.00, 'DE', '41352', $isCompany = true );
VatCalculator::getTaxRateForLocation( 'NL' );
// Check validity of a VAT number
VatCalculator::isValidVATNumber('NL123456789B01');
```
## Contents

- [Installation](#installation)
	- [Standalone](#installation-standalone)
- [Usage](#usage)
	- [Calculate the gross price](#calculate-the-gross-price)
	- [Receive more information](#receive-more-information)
	- [Validate EU VAT numbers](#validate-eu-vat-numbers)
		- [Laravel Validator extension](#laravel-validator-extension)
	- [Get EU VAT number details](#vat-number-details)
	- [Cashier integration](#cashier-integration)
	- [Get the IP based country of your user](#get-ip-based-country)
	- [Frontend integration - vat_calculator.js](#frontend-integration)
		- [Integrating it in your payment form](#payment-form-integration)
		- [Extra fields](#extra-fields)
		- [Form attributes](#form-attributes)
		- [Form fields](#form-fields)
		- [Advanced usage](#advanced-usage)
		- [Preconfigured routes](#preconfigured-routes)
- [Configuration (optional)](#configuration)
- [Changelog](#changelog)
- [License](#license)

<a name="installation"></a>
## Installation

In order to install the VAT Calculator, just run

```bash
$ composer require mpociot/vat-calculator
```
	
<a name="installation-standalone"></a>
### Standalone

You can also use this package without Laravel. Simply create a new instance of the VAT calculator and use it.
All documentation examples use the Laravel 5 facade code, so make sure not to call the methods as if they were static methods.

Example:

```php
use Mpociot\VatCalculator\VatCalculator;

$vatCalculator = new VatCalculator();
$vatCalculator->setBusinessCountryCode('DE');
$countryCode = $vatCalculator->getIPBasedCountry();
{'fraction_non_alphanumeric': 0.15388093443858328, 'fraction_numerical': 0.02426525998492841, 'mean_word_length': 5.820143884892087, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 18, 'https://': 22, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1706590', 'n_tokens_mistral': 2470, 'n_tokens_neox': 2147, 'n_words': 454}