tumainimosha/credit-info 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tumainimosha/credit-info

最新稳定版本:0.10.0

Composer 安装命令:

composer require tumainimosha/credit-info

包简介

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

README 文档

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.

统计信息

  • 总下载量: 1.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固