The obsolete Auspost API was located at https://auspost.com.au/api, and the new one is at https://digitalapi.auspost.com.au
To update the Fontis Australia Magento extension to use the new Auspost API, there are two files which need to be changed:
- app/code/community/Fontis/Australia/lib/vendor/fontis/auspost-api-php/src/Auspost/Postage/PostageClient.php
- app/code/community/Fontis/Australia/lib/vendor/fontis/auspost-api-php/src/Auspost/Postage/service.json
Changes to PostageClient.php
In the PostageClient.php file, before the line:
Change #1:
public static function factory($config = array()){
add the following:
const API_URL = 'https://digitalapi.auspost.com.au';
This line sets the API URL in one location, making it easier to change in the future.
Change #2:
Locate any instances of the following:
$baseUrl[$developerMode]$config->get('base_url')
and change them to:
self::API_URL
This sets the API URL to the one that was specified in the first change.
Change #3:
Remove the following lines of code:
$baseUrl = array(
'https://auspost.com.au',
'https://test.npe.auspost.com.au'
);
// Ignore unnecessary user-specified configuration values
if ($developerMode) {
unset($config['auth_key']);
}
The test URL is no longer used as it does not resolve.
Changes to service.json
In the service.json file, remove the 'api/' from the start of each uri. For example, the following line:
"uri": "api/postcode/search",
becomes:
"uri": "postcode/search",
Once the above changes have been made, you may need to clear cache (Admin->System->Cache Management). To test if this worked, add an item to the shopping cart and verify that there are Australia Post shipping methods available, either through a postage estimate or on the checkout page.