Many of the Australian businesses we work with often have the need to lookup Australian Business Numbers (ABN) or Australian Company Numbers (ACN). We plan on writing a quick WordPress plugin in the next few weeks that'll integrate form validation and lookup functionality into a WordPress website, and we expect that we'll initially provide the plugin to our Mortgage Broker mailing list as a giveaway before building it into a more generic product for download on our website. The PHP functions provided in this article provides you with enough information to integrate the ABN/ACN number validation or lookup service on your own website.
If you're unfamiliar with our website mantra, we know that having resources and tools on your website will attract repeat visitation and increase the trust your visitors have in your online presence... and this is an area where the finance industry generally performs very poorly.
The entire ABN database may be downloaded from Data.gov.au at any time although the size makes it virtually unusable for most small-scale applications, and the frequency of updates means that there's always a portion of numbers that aren't available. However, Business.gov.au does provide an API that returns data in various formats via POST and GET requests. While JSON support is limited, it's the a JSON function we've provided below (our plugin uses the XML-style response since it supports more search options ).
To use the API you'll need to register for access. While it' said that your GUID (or Globally Unique Identifier) will be made available within five working days, we've found that it rarely takes more than a few hours.
Validating the Australian Business and Company Numbers
The method to validate the Aussie ABN and ACN is detailed below and can be used independently of our primary function. It's a necessary feature of our plugin to validate the supplied number server-side so as to avoid making an unnecessary request to the API.
Australian Company Number
The method for validating the ACN is detailed on the ASIC website . The PHP function returns either true or false.
Australian Business Number
The method for validating the ACN is detailed on the Business.gov.au webiste. The PHP function returns either true or false.
PHP ABN/ACN Function
The JSON API we're using returns JSONP. To convert it back to naked JSON the following hacky function works (if you're planning on using the callback for cross-domain requests you obviously don't need it).
To make the call to the API, we first determine if the request only includes numeric characters. If so, we strip white spaces and make either an ABN or ACN request based on length (9 digits for the ACN and 11 for an ABN). If neither condition is true or the number doesn't validate we'll return false. If the string contains permitted characters as detailed on the ASIC website we'll make a name search request. If no case is satisfied we'll return false.
Usage
The $abn
is either the ABN, ACN, or search term. You'll need to close the pre
tags to print the example array.
Note that the JSON API doesn't include pagination so it might be best to request a large number of results, cache the resulting array, and then chop it up page-by-page.
The Result
Searching the ABN for Coca-Cola (68 076 594 119) returns the following array:
An ACN for Qantas (009 661 901) will return the following array.
A free-text name search for 'Virgin' returns the following (we've limited the number of results and removed some identifying data).
Considerations
- If you would like a copy of our plugin, ensure you subscribe to our mailing list (below). Our finance mailing list can expect a download link to the plug-and-play addition to their website within a couple of weeks.