PHP developer in Liverpool

WordPress for businesses in Liverpool, delivered remotely by one developer.

PHP developer

My place in the WordPress community

  • I have had a wordpress.org account since 2006.
  • I contributed to WordPress core for versions 7.0 and 7.1.
  • I maintain 30 plugins on wordpress.org.
  • I organise and speak at WordCamps.
  • I have attended every WordCamp Europe from 2017 to 2026.
  • Local WordPress meetup: WordPress Liverpool

My WordPress.org profile

A shop or bookkeeping tool in Liverpool that files VAT from software connects to HMRC through the VAT (MTD) API. The API is simple to read and strict to use. I am Mariusz Szatkowski, developing from Gdynia remotely and in writing. For a PHP backend I treat the HMRC developer documentation as the specification and I keep the tax and accounting judgement with your accountant. I am not an accountant or a lawyer.

Albert Dock waterfront in Liverpool

Royal Albert Dock, Liverpool. Image: Rodhullandemu, licence CC BY-SA 4.0, via Wikimedia Commons.

#What does the HMRC VAT (MTD) API offer?

The HMRC Developer Hub lists these functions for the VAT (MTD) API: retrieve VAT obligations, submit and view a VAT return, retrieve a VAT liability, retrieve a VAT payment, retrieve VAT penalties, retrieve financial details relating to a penalty, and retrieve information about a VAT customer. The VAT (MTD) end-to-end guide sets the minimum for a product: it must allow the customer to retrieve VAT obligations and to submit a VAT return for a period.

That minimum shapes the first build. A PHP module needs a screen or job that asks HMRC which periods are open, a way to compile the return figures from the ledger or the shop orders, and a submission step that the customer confirms. How the figures are calculated is an accounting question, and the module takes them from the books as your accountant defines them.

#How does a PHP backend get permission?

The VAT API uses user-restricted endpoints, so the business owner grants the software access through OAuth 2.0, the authorization code grant. HMRC documents these steps:

  1. The application sends the user to the /oauth/authorize endpoint with the response type code, the client id, the scopes, a redirect URI and optionally a state value. The client secret never appears here. PKCE is supported and optional.
  2. The user signs in to HMRC, completes 2-step verification and grants the scopes. Production uses www.tax.service.gov.uk and the sandbox uses test-www.tax.service.gov.uk.
  3. The redirect endpoint must accept an HTTP GET and receives a code and the state. The code is single-use and expires after 10 minutes.
  4. The application posts the code to the token endpoint within those 10 minutes, with the client id, the client secret, the redirect URI and the code in the request body, not in headers.
  5. HMRC returns an access token, a refresh token and expires_in of 14400, which is 4 hours.
  6. API calls carry the access token as a bearer token in the Authorization header.

Two details cause bugs in practice. The refresh token is single-use, and refreshing invalidates the previous access token immediately if it has not expired. HMRC warns that concurrent API calls can create race conditions during refresh. In PHP, where requests run in parallel under PHP-FPM, that means a lock around the refresh, for example a database row lock, so two requests do not both try to use the same refresh token. And after 18 months a refresh token stops working, so the user has to authorise again. The data model needs a visible state for that, not a silent failure on the day a return is due.

Tokens and the client secret belong in encrypted storage outside the web root and outside the repository. The user can revoke access at any time through HMRC’s Manage authorised applications service, so a 401 response has to lead to a clear message, not a retry loop.

#What are fraud prevention headers?

HMRC requires fraud prevention header data for the VAT (MTD) and Income Tax Self Assessment (MTD) APIs. The VAT API page puts it plainly: you are required by law to submit header data for this API. HMRC uses the data in transaction monitoring. It says it works with software providers to meet the specification, and that an application which keeps sending incorrect or missing data after discussion may be fined and blocked from HMRC APIs.

The headers depend on the connection method. HMRC lists eight: desktop application direct, desktop application via server, web application via server, mobile application direct, mobile application via server, batch process direct, other direct and other via server. A browser-based bookkeeping tool with a PHP backend is a web application via server. A scheduled script that files without a user present is a batch process, which HMRC lists as a separate connection method, so the method is decided before the code.

#Which 16 headers does a web application send?

For a web application via server HMRC states that all 16 headers are mandatory and that you must submit data for all of them. The value of Gov-Client-Connection-Method is WEB_APP_VIA_SERVER on every request.

HeaderWhat HMRC describesWhere the data comes from
Gov-Client-Browser-JS-User-Agentuser agent string reported by JavaScript on the originating devicebrowser script
Gov-Client-Device-IDidentifier unique to the device, a UUID generated by the application and stored persistently, without expiryapplication
Gov-Client-Multi-Factormulti-factor status of users of your software, with type, timestamp and unique referenceapplication login
Gov-Client-Public-IPpublic IPv4 or IPv6 address of the devicerequest seen by the server
Gov-Client-Public-IP-TimestampUTC time that IP was collectedserver
Gov-Client-Public-Portpublic TCP port the device used, not a server portrequest seen by the server
Gov-Client-Screenswidth, height, scaling factor and colour depthbrowser script
Gov-Client-Timezonelocal timezone as UTC plus or minus hours and minutesbrowser script
Gov-Client-User-IDssign-in identifier and any internal identifierapplication
Gov-Client-Window-Sizebrowser window width and height in pixelsbrowser script
Gov-Vendor-Forwardedhops between TLS-terminating services, each with by and forserver infrastructure
Gov-Vendor-License-IDshashed license keys of the vendor softwareapplication
Gov-Vendor-Product-Nameproduct name marketed to end users, percent encodedapplication
Gov-Vendor-Public-IPpublic IP of the servers the device sent requests toserver infrastructure
Gov-Vendor-Versionversions of your software involved in the request, percent encodedapplication
Gov-Client-Connection-Methodthe value WEB_APP_VIA_SERVERapplication

HMRC marks some headers as not collectable in defined cases: no multi-factor data when the software uses only a username and password, no public IP or port over a private network, no license IDs when there are none. The guide has a section on how to handle missing data, and each case gets a documented decision.

#How do the headers reach the PHP server?

Half of the data exists only in the browser: user agent, screen size, window size, timezone. A script in the page collects it and sends it to the PHP backend with the user’s request, and the backend stores it with the session and passes it on in each HMRC call. The server adds what only it knows: the time the IP was collected, the vendor’s public IP, the product name and version, and the forwarding hops.

In PHP the manual describes REMOTE_ADDR as the address from which the user is viewing the page and REMOTE_PORT as the port on the user’s machine. The same manual notes that values behind a proxy or load balancer may not describe the original connection, and that HTTP_ entries are built from request headers. A backend behind a load balancer, which is normal for production, needs a deliberate decision about which hop supplies the client address. That decision also feeds Gov-Vendor-Forwarded.

A device identifier can be generated with random_bytes(), which the manual describes as returning cryptographically secure random bytes. HMRC wants a UUID that does not expire, stored persistently:

<?php
function device_id(): string
{
    $b = random_bytes(16);
    $b[6] = chr((ord($b[6]) & 0x0f) | 0x40);
    $b[8] = chr((ord($b[8]) & 0x3f) | 0x80);
    $h = bin2hex($b);

    return sprintf('%s-%s-%s-%s-%s',
        substr($h, 0, 8), substr($h, 8, 4), substr($h, 12, 4),
        substr($h, 16, 4), substr($h, 20, 12));
}

The value is generated once per device, saved in a long-lived cookie or local storage, and sent from then on. It is an identifier of a device, so the privacy notice of your product needs to mention it.

#How does testing work?

HMRC provides a sandbox at test-api.service.hmrc.gov.uk, against the production host api.service.hmrc.gov.uk. Test users come from the Create Test User API or its frontend service. The Gov-Test-Scenario header simulates scenarios, and each endpoint page lists the values it accepts. HMRC also offers a Test Fraud Prevention Headers API for checking header data during development, which is the quickest way to find a header with the wrong format before approval.

In a PHP project I keep the base URLs, client id and secret in environment configuration, and one HTTP client class that adds the bearer token and the headers to every request. Nothing else in the code calls HMRC. That gives one place to log requests, with the care that HMRC responses and header values can carry personal data.

#What does production approval involve?

The VAT (MTD) end-to-end guide describes the route. HMRC requires fraud prevention header information for all its APIs before approval can be granted and production credentials issued, and the terms of use must be accepted first. The guide says to contact HMRC’s software developer support team within two weeks of completing API testing, and that HMRC then needs 10 working days to give the outcome. After production access, HMRC asks for a live submission before the software can be listed as compatible.

The wording matters for marketing. Production credentials are not an endorsement, and I do not describe any software as HMRC approved. The accurate statement is that it connects to HMRC through the API and, once listed, that HMRC lists it as compatible.

#Checklist for a Liverpool VAT integration

  • Decide the connection method: web application via server, or batch process direct for unattended filing.
  • Register the application in the Developer Hub, and build against the sandbox first.
  • Implement the authorization code flow, with a lock around token refresh.
  • Plan for the 18-month refresh token limit with a visible re-authorisation state.
  • Collect browser data in the page, and decide which server hop supplies the client IP and port.
  • Send all 16 headers on every VAT call, and check them with the Test Fraud Prevention Headers API.
  • Support the minimum functions: obligations and return submission.
  • Complete testing, contact HMRC within two weeks, and plan the live submission.

#How does a project run?

  1. You send the product description, the connection method, how return figures are produced today and your deadline. I reply by email, in writing.
  2. I write the scope and the assumptions, with questions for your accountant on the figures and for your hosting provider on proxies.
  3. I build the integration on a staging copy against the HMRC sandbox. You check obligations and test submissions with test users.
  4. After your written sign-off, I deploy and support the production approval steps. A maintenance plan keeps a WordPress or WooCommerce front end updated alongside.

I need access to the repository or the plugin code, to staging, and to the Developer Hub application. The wider offer is on the PHP developer page.

#Send me your VAT workflow

If your Liverpool business wants software to file VAT, send the details through the contact form: where the figures live, whether a person or a scheduled job submits, and the filing date you are working toward. The first written estimate is free, and it states the connection method and the header plan I would start from. Your accountant keeps the tax judgement.

Need this service: PHP developer in Liverpool?

Describe your project by e-mail. I reply within 24 hours.

Describe your project

Latest PHP developer articles

Dec 2, 2026

Laravel Rust: what does it mean for PHP apps?

On 1 December 2026 Taylor Otwell shipped the Laravel Rust beta, and Laravel Go followed a day later. What the framework contains, what the 18x benchmark really measures, what happens to Laravel PHP and WordPress, and when a rewrite makes sense.

Explore other WordPress services and knowledge base