The Unofficial Credit Info Tanzania API wrapper for Laravel.
- CreditInfo Tanzania website
- WSDL (requires Basic Auth authentication)
Install via composer
composer require tumainimosha/credit-infoOptional! Publish config file only if you wish to customize the default package config.
php artisan vendor:publish --provider="CreditInfo\ServiceProvider" --tag="config"Configure your api username and password in .env file as follows
CREDIT_INFO_USERNAME=your_api_username
CREDIT_INFO_PASSWORD=your_api_passwordApart from authentication configurations, the following remaining configurations are optional.
For basic usage jump straight to Usage Section
The package config file comes with default API url pointing to production.
CREDIT_INFO_WSDL=https://ws.creditinfo.co.tz/WsReport/v5.39/service.svc?wsdlTo point to test environment set the CREDIT_INFO_WSDL key in your .env file to point to test url given. (See below)
CREDIT_INFO_WSDL=https://wstest.creditinfo.co.tz/WsReport/v5.39/service.svc?wsdlRemember
- The WSDL url should end with a
?wsdlsuffix, don't forget to add this if you haven't already. - You need to first configure correct Authentication details above for your respective environment, as the WSDL url is secured with Basic Auth.
The package by default caches API response from Credit Info to speed up subsequent requests for the same data.
You can control this feature by setting the CREDIT_INFO_CACHE_TTL value in minutes in your .env. (See below)
By default data is cached for 24 hours = 1440 minutes
CREDIT_INFO_CACHE_TTL=1440Set the value to zero(0) to completely disable caching.
Default behaviour of PHP Soap Client is to Cache WSDL files for improved performance.
However, during development you may require for debugging reasons to disable WSDL caching of the soap client.
To do so set the CREDIT_INFO_CACHE_WSDL key in your .env file to false (See below)
Caution: Disabling WSDL caching will significantly slow down performance. Please remember to always revert this option to true after you are done debugging.
CREDIT_INFO_CACHE_WSDL=falseMethod getVehicleReport() queries vehicle information by Vehicle Registration ID
$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getVehicleReport($registration_number);Method getDrivingLicenseReport() queries drivers license information by Driving License Number
$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getDrivingLicenseReport($driving_license_no);Method getNationalIdReport() queries an individual information by National Id Number
$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getNationalIdReport($national_id);The above methods throws the following exceptions
| Exception | Condition |
|---|---|
CreditInfo\Exceptions\Exception |
This is the package's base exception. All exceptions from this library inherit from it. *** This should be caught last as a catch-all statement. |
CreditInfo\Exceptions\InvalidReferenceNumberException |
Thrown if supplied reference number fails validation requirements. |
CreditInfo\Exceptions\DataNotFoundException |
Thrown if no data found for given reference number |
CreditInfo\Exceptions\TimeoutException |
Thrown if request timeouts |
See usage below with exception catching
use CreditInfo\Exceptions\DataNotFoundException;
use CreditInfo\Exceptions\Exception;
use CreditInfo\Exceptions\InvalidReferenceNumberException;
use CreditInfo\Exceptions\TimeoutException;
use CreditInfo\CreditInfo;
...
public function testVehicleInfo() {
$registration = 't100abc';
$creditInfoService = new CreditInfo();
try {
$details = $creditInfoService->getVehicleReport($registration);
}
catch(InvalidReferenceNumberException $ex) {
// Handle case invalid reference number case
throw($ex);
}
catch(TimeoutException $ex) {
// Handle case if request timeout
throw($ex);
}
catch(DataNotFoundException $ex) {
// Handle case if registration number not found
throw($ex);
}
catch(Exception $e) {
// Handle other API errors
throw($e);
}
dd($details);
}
...- Vehicle Report
- Driving license Report
- National ID Report
- TIN Report
If you discover any security related issues, please email Me instead of using the issue tracker.
This package is bootstrapped with the help of melihovv/laravel-package-generator.