tumainimosha/credit-info

This package is abandoned and no longer maintained. No replacement package was suggested.

A Laravel package for integration with Credit Info (Tanzania) API

0.10.0 2020-12-20 15:14 UTC

This package is auto-updated.

Last update: 2023-10-23 15:37:35 UTC


README

Credit Info (TZ) API Wrapper for Laravel

Latest Stable Version License Total Downloads

The Unofficial Credit Info Tanzania API wrapper for Laravel.

Installation

Install via composer

composer require tumainimosha/credit-info

Publish Configuration File

Optional! Publish config file only if you wish to customize the default package config.

php artisan vendor:publish --provider="CreditInfo\ServiceProvider" --tag="config"

Configuration

Authentication

Configure your api username and password in .env file as follows

CREDIT_INFO_USERNAME=your_api_username
CREDIT_INFO_PASSWORD=your_api_password

Apart from authentication configurations, the following remaining configurations are optional.

For basic usage jump straight to Usage Section

URL

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?wsdl

To 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?wsdl

Remember

  • The WSDL url should end with a ?wsdl suffix, 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.

Response Caching

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=1440

Set the value to zero(0) to completely disable caching.

WSDL 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=false

Usage

  1. Vehicle Report
  2. Driving License Report
  3. National Id Report
  4. Exception Handling

Vehicle Report

Method getVehicleReport() queries vehicle information by Vehicle Registration ID

$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getVehicleReport($registration_number);

Driving License Report

Method getDrivingLicenseReport() queries drivers license information by Driving License Number

$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getDrivingLicenseReport($driving_license_no);

National Id Report

Method getNationalIdReport() queries an individual information by National Id Number

$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getNationalIdReport($national_id);

Exception Handling

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);
    
}
...

TODO

  • Vehicle Report
  • Driving license Report
  • National ID Report
  • TIN Report

Security

If you discover any security related issues, please email Me instead of using the issue tracker.

Credits

This package is bootstrapped with the help of melihovv/laravel-package-generator.