malek83/polish-vat-payer

Library using Polish Ministry of Finance WebService to validate if given VAT Number is registered as VAT Tax Payer in Poland

3.0.0 2019-07-31 17:18 UTC

This package is not auto-updated.

Last update: 2024-04-18 15:18:23 UTC


README

Build Status

Polish VAT Payer

Simple library using Polish Ministry of Finance WebService to validate if given VAT Number is registered as VAT Tax Payer in Poland.

Contents

Installation

This library is available on Packagist:

$ composer require malek83/polish-vat-payer

Usage

There are two easy ways to use this library:

to get the boolean result of verification

use Malek83\PolishVatPayer\Builder\PolishVatPayerBuilder;
use Malek83\PolishVatPayer\PolishVatPayer;

/** @var PolishVatPayer $validator */
$validator = PolishVatPayerBuilder::builder()->build();

$bool = $validator->isValid('1568255600'); //returns boolean

to get the Full Response Object, containing all needed information

use Malek83\PolishVatPayer\Builder\PolishVatPayerBuilder;
use Malek83\PolishVatPayer\PolishVatPayer;

/** @var PolishVatPayer $validator */
$validator = PolishVatPayerBuilder::builder()->build();

/** @var \Malek83\PolishVatPayer\Result\PolishVatNumberVerificationResult $result */
$result = $validator->validate('1234567890');

var_dump($result->isValid()); // gives boolean, true if company is VAT Payer, otherwise false
var_dump($result->getVatNumber()); //gives string, the verificated VAT number
var_dump($result->getMessage()); //gives string, the human readable message

Request cache

Request cache can be used if necessary. Any PSR-16 Compatible component can be used (i.e. symfony/cache)

By default cache is turned off. To use cache call the setter method during building the facade

use Malek83\PolishVatPayer\Builder\PolishVatPayerBuilder;
use Malek83\PolishVatPayer\PolishVatPayer;

/** @var PolishVatPayer $validator */
$validator = PolishVatPayerBuilder::builder()
    ->setCache(new AnyPsr16CompatibleCache())
    ->setTtl(new DateInterval('PT1H'))
    ->build();

Default TTL is 1 hour. It can be also overriden while during the build process.

Request Log

Request log can be defined also. It's PSR-3 Compatible (i.e. Monolog)

By default it's turned off, to turn it on simply call setLogger while building:

use Malek83\PolishVatPayer\Builder\PolishVatPayerBuilder;
use Malek83\PolishVatPayer\PolishVatPayer;

/** @var PolishVatPayer $validator */
$validator = PolishVatPayerBuilder::builder()
    ->setLogger(new AnyPsr3CompatibleLogger())
    ->build();

Roadmap

All future features are listed in Roadmap GitHub project.

Changelog

Please see CHANGELOG file for more information what has changed recently.

Local environment for development & testing

$ docker build -t polish-vat-payer ./docker/

$ docker run -d --name polish-vat-payer --volume ${PWD}:/source polish-vat-payer

License

The MIT License (MIT). Please see License for more information.