1. Go to this page and download the library: Download mpociot/vat-calculator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mpociot / vat-calculator example snippets
// Easy to use!
VatCalculator::calculate(24.00, $countryCode = 'DE');
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');
use Mpociot\VatCalculator\VatCalculator;
$vatCalculator = new VatCalculator();
$vatCalculator->setBusinessCountryCode('DE');
$grossPrice = $vatCalculator->calculate(49.99, $countryCode = 'LU');
if (VatCalculator::shouldCollectVAT('DE')) {
// This country code
try {
$validVAT = VatCalculator::isValidVATNumber('NL 123456789 B01');
} catch (VATCheckUnavailableException $e) {
// The VAT check API is unavailable...
}
// This check will return false because no connection to VIES could be made...
$validVAT = VatCalculator::isValidVATNumber('NL 123456789 B01');
// This check will return true because only the format is checked...
$validVAT = VatCalculator::isValidVatNumberFormat('NL 123456789 B01');
try {
$vat_details = VatCalculator::getVATDetails('NL 123456789 B01');
print_r($vat_details);
/* Outputs
stdClass Object
(
[countryCode] => NL
[vatNumber] => 123456789B01
[requestDate] => 2017-04-06+02:00
[valid] => false
[name] => Name of the company
[address] => Address of the company
)
*/
} catch (VATCheckUnavailableException $e) {
// The VAT check API is unavailable...
}
use Mpociot\VatCalculator\Rules\ValidVatNumber;
$validator = Validator::make(Input::all(), [
'first_name' => ')) {
// Input is correct...
}
use Laravel\Cashier\Billable;
use Mpociot\VatCalculator\Traits\BillableWithinTheEU;
use Laravel\Cashier\Contracts\Billable as BillableContract;
class User extends Model implements BillableContract
{
use Billable, BillableWithinTheEU {
BillableWithinTheEU::taxPercentage insteadof Billable;
}
protected $dates = ['trial_ends_at', 'subscription_ends_at'];
}
$user = User::find(1);
// For individuals use:
$user->useTaxFrom('NL');
// For business customers with a valid VAT ID, use:
$user->useTaxFrom('NL')->asBusiness();
$user->subscription('monthly')->create($creditCardToken);