2017 © Pedro Peláez
 

symfony-bundle vatin-bundle

Symfony bundle for the VATIN library

image

ddeboer/vatin-bundle

Symfony bundle for the VATIN library

  • Monday, January 15, 2018
  • by ddeboer
  • Repository
  • 3 Watchers
  • 10 Stars
  • 48,362 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 5 Versions
  • 18 % Grown

The README.md

VATIN bundle

Latest Stable Version, (*1)

A Symfony bundle for the VATIN library., (*2)

Installation

This library is available on Packagist:, (*3)

composer require ddeboer/vatin-bundle

Then add the bundle to your application:, (*4)

// app/AppKernel.php
public function registerBundles()
{
    return [
        ...
        new Ddeboer\VatinBundle\DdeboerVatinBundle(),
        ...
    ];
}

Usage

Validate number format

Use the validator to validate a property on your models. For instance using annotations:, (*5)

use Ddeboer\VatinBundle\Validator\Constraints\Vatin;

class Company
{
    /**
     * @Vatin
     */
    protected $vatNumber;

Symfony’s validator will now check whether $vatNumber has a valid VAT number format. For more information, see Symfony’s documentation., (*6)

Validate number existence

Additionally, you can check whether the VAT number is in use:, (*7)

    use Ddeboer\VatinBundle\Validator\Constraints\Vatin;

    /**
     * @Vatin(checkExistence=true)
     */
    protected $vatNumber;

The validator will now check the VAT number against the VAT Information Exchange System (VIES) SOAP web service. This service’s availability is rather unreliable, so it’s a good idea to catch the case where it’s unreachable:, (*8)

use Symfony\Component\Validator\Exception\ValidatorException;

try {
    if ($validator->isValid()) {
        // Happy flow
    }
} catch (ValidatorException $e) {
    // VAT could not be validated because VIES service is unreachable
}

Using the services directly

You can also use this bundle’s services directly. Validate a VAT number’s format:, (*9)

$validator = $container->get('ddeboer_vatin.vatin_validator');
$bool = $validator->isValid('NL123456789B01');

Additionally, check whether the VAT number is in use:, (*10)

$bool = $validator->isValid('NL123456789B01', true);

To interact with the VIES webservice:, (*11)

$vies = $container->get('ddeboer_vatin.vies.client');
$checkVatResponse = $vies->checkVat('NL', '123456789B01');

More information

For more information, see the VATIN library’s documentation., (*12)

The Versions

25/01 2017
21/01 2017

1.1.0

1.1.0.0

Symfony2 bundle for the VATIN library

  Sources   Download

MIT

The Requires

 

The Development Requires

vat tax btw

26/09 2013

1.0

1.0.0.0

Symfony2 bundle for the VATIN library

  Sources   Download

MIT

The Requires

 

The Development Requires

vat tax btw