PHPackages                             arraypress/vat-sense - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. arraypress/vat-sense

ActiveLibrary[API Development](/categories/api)

arraypress/vat-sense
====================

A PHP library for integrating with the VAT Sense API in WordPress, providing VAT validation, tax rate information, and currency conversion. Features WordPress transient caching and WP\_Error support.

00PHP

Since Apr 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/arraypress/vat-sense)[ Packagist](https://packagist.org/packages/arraypress/vat-sense)[ RSS](/packages/arraypress-vat-sense/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

VAT Sense API Client Library for WordPress
==========================================

[](#vat-sense-api-client-library-for-wordpress)

A comprehensive PHP library for integrating with the VAT Sense API in WordPress applications.

Features
--------

[](#features)

- **VAT Number Validation**: Validate VAT numbers against EU, UK, and other supported countries
- **EORI Number Validation**: Validate Economic Operators Registration and Identification numbers
- **Tax Rate Information**: Get tax rates for specific countries, including standard, reduced, and zero rates
- **Currency Conversion**: Convert between currencies using official exchange rates
- **VAT Price Calculation**: Calculate VAT-inclusive and VAT-exclusive prices
- **Invoice Creation and Management**: Create, retrieve, update, and delete VAT-compliant invoices
- **WordPress Integration**: Built-in transient caching and WP\_Error support
- **Complete API Coverage**: All VAT Sense API endpoints supported

Installation
------------

[](#installation)

Install via Composer:

```
composer require arraypress/vat-sense
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

```
use ArrayPress\VAT\Sense\Client;

// Initialize the client with your VAT Sense API key
$client = new Client('your_vat_sense_api_key_here');

// Optionally, configure caching
$client->set_cache_enabled(true);
$client->set_cache_expiration(HOUR_IN_SECONDS * 12); // 12 hours
```

### VAT Number Validation

[](#vat-number-validation)

```
// Validate a VAT number
$response = $client->validate_vat('GB123456789');

if (is_wp_error($response)) {
    echo "Error: " . $response->get_error_message();
} else {
    if ($response->is_vat_valid()) {
        echo "VAT number is valid!";
        echo "Company name: " . $response->get_company_name();
        echo "Company address: " . $response->get_company_address();
        echo "Country code: " . $response->get_country_code();
    } else {
        echo "VAT number is not valid.";
    }
}
```

### Get Tax Rates

[](#get-tax-rates)

```
// Get tax rates for a country
$response = $client->get_rates_filtered('DE');

if (!is_wp_error($response)) {
    $standard_rate = $response->get_standard_rate_percentage();
    echo "Standard VAT rate: {$standard_rate}%";

    // Get reduced rates if available
    $reduced_rates = $response->get_reduced_rates();
    if ($reduced_rates) {
        foreach ($reduced_rates as $rate) {
            echo "Reduced rate: {$rate['rate']}%";
        }
    }
}

// Find a tax rate for a specific product type
$response = $client->find_tax_rate('FR', '', 'ebooks');
```

### Calculate VAT Prices

[](#calculate-vat-prices)

```
// Calculate VAT on a price
$response = $client->calculate_vat_price(100.00, 20.0, 'excl');

if (!is_wp_error($response)) {
    $price_excl_vat = $response->get_price_excl_vat();
    $price_incl_vat = $response->get_price_incl_vat();
    $vat_amount = $response->get_vat_amount();

    echo "Price (excl. VAT): {$price_excl_vat}";
    echo "VAT amount: {$vat_amount}";
    echo "Price (incl. VAT): {$price_incl_vat}";
}
```

### Currency Conversion

[](#currency-conversion)

```
// Convert currency
$response = $client->convert_currency('USD', 'EUR', 50.00);

if (!is_wp_error($response)) {
    $converted_amount = $response->get_converted_amount();
    $exchange_rate = $response->get_exchange_rate();

    echo "50.00 USD = {$converted_amount} EUR (rate: {$exchange_rate})";
}
```

### Create and Manage Invoices

[](#create-and-manage-invoices)

```
// Create an invoice
$invoice_data = [
    'date' => date('Y-m-d H:i:s'),
    'tax_point' => date('Y-m-d H:i:s'),
    'type' => 'sale',
    'tax_type' => 'incl',
    'currency_code' => 'EUR',
    'business' => [
        'name' => 'My Company',
        'address' => "123 Business Street\nLondon\nSW1 1AA\nUnited Kingdom",
        'vat_number' => 'GB123456789',
        'company_number' => '12345678'
    ],
    'customer' => [
        'name' => 'Client Company',
        'address' => "456 Client Avenue\nBerlin\n10115\nGermany",
        'vat_number' => 'DE987654321'
    ],
    'items' => [
        [
            'item' => 'Professional services',
            'quantity' => 1,
            'price_each' => 500.00,
            'vat_rate' => 19.0
        ]
    ]
];

$response = $client->create_invoice($invoice_data);

if (!is_wp_error($response)) {
    $invoice_id = $response->get_invoice_id();
    $invoice_url = $response->get_invoice_url();
    $invoice_pdf_url = $response->get_invoice_url(true);

    echo "Invoice created successfully!";
    echo "Invoice ID: {$invoice_id}";
    echo "Invoice URL: {$invoice_url}";
    echo "Invoice PDF URL: {$invoice_pdf_url}";
}
```

### Check API Usage

[](#check-api-usage)

```
// Check API usage
$response = $client->get_usage();

if (!is_wp_error($response)) {
    $total = $response->get_total_requests();
    $used = $response->get_used_requests();
    $remaining = $response->get_remaining_requests();

    echo "API Usage:";
    echo "Total allowed: {$total}";
    echo "Used: {$used}";
    echo "Remaining: {$remaining}";
}
```

Cache Management
----------------

[](#cache-management)

The library includes built-in caching using WordPress transients:

```
// Enable or disable caching
$client->set_cache_enabled(true);

// Set cache expiration time (in seconds)
$client->set_cache_expiration(DAY_IN_SECONDS);

// Clear all cached data
$client->clear_cache();

// Clear specific cached data
$client->clear_cache('vat_validate_GB123456789');
```

API Documentation
-----------------

[](#api-documentation)

For detailed API documentation, visit the [VAT Sense API Reference](https://vatsense.com/documentation).

Requirements
------------

[](#requirements)

- PHP 7.4 or later
- WordPress 5.0 or later

License
-------

[](#license)

This library is licensed under the GPL v2 or later.

Credits
-------

[](#credits)

Developed by [ArrayPress](https://arraypress.com)

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6eb8aff0903d87eb674d1ba3c5f3653899c0d7661504eb0deb7798ed86b643?d=identicon)[arraypress](/maintainers/arraypress)

---

Top Contributors

[![arraypress](https://avatars.githubusercontent.com/u/22668877?v=4)](https://github.com/arraypress "arraypress (1 commits)")

### Embed Badge

![Health badge](/badges/arraypress-vat-sense/health.svg)

```
[![Health](https://phpackages.com/badges/arraypress-vat-sense/health.svg)](https://phpackages.com/packages/arraypress-vat-sense)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
