PHP Creditonline

PHP package to interact with the CreditOnline API

PHP Creditonline

PHP Creditonline

PHP1.x

PHP package to interact with the CreditOnline API

Install

composer require omisai/php-creditonline

Features

  • Object-oriented design for easy integration
  • Comprehensive test suite with Pest
  • Clear documentation for developers

Requirements

  • PHP 8.1 or higher

Installation

Install the package via Composer:

composer require omisai/php-creditonline

Configuration

The Configuration class controls the API client behaviour. By default, it connects to the production API.

use Omisai\CreditOnline\Configuration;

$config = new Configuration();

// Use the test environment
$config->setTestHost();
// or
$config->setHost('https://api-test.creditonline.hu/v3');


// Enable debug mode (logs to stdout)
$config->setDebug(true);

// Set a custom user agent
$config->setUserAgent('MyApp/1.0');

// mTLS authentication
$config->setCertFile('/path/to/cert.pem');
$config->setKeyFile('/path/to/key.pem');

Usage

Host selection via index

Each API class constructor accepts a $hostIndex (default 0 = production). Use 1 for the test environment:

$api = new GetDataByIdService(config: $config, hostIndex: 1);

Or set it after construction:

$api->setHostIndex(1);

Custom Guzzle client

You can inject a custom GuzzleHttp\ClientInterface for custom HTTP behaviour (proxies, retry middleware, etc.):

$client = new \GuzzleHttp\Client(['timeout' => 30]);
$api = new AuthenticationService(client: $client);

API Endpoints

1. Token Generation — AuthenticationService

Generates a session token required by all other endpoints. The token is valid for 24 hours and is returned in the response headers.

use Omisai\CreditOnline\Api\AuthenticationService;

$api = new AuthenticationService();

// Simple call (returns void — token is set server-side)
$api->getToken('your-api-key');

// To retrieve the token, use the WithHttpInfo variant:
list($body, $statusCode, $headers) = $api->getTokenWithHttpInfo('your-api-key');

// Optionally specify format and language:
// $api->getToken('your-api-key', 'json', 'hu');
ParameterTypeRequiredDefaultDescription
$api_keystringYesSubscriber API key
$formatstringNo'json'Response format
$languagestringNo'hu'Data language

Return: void


2. Company Data — GetDataByIdService

Retrieves company data by registration number or tax number.

use Omisai\CreditOnline\Api\GetDataByIdService;
use Omisai\CreditOnline\Model\ApiResult;

$api = new GetDataByIdService();

// By registration number
$result = $api->getData($token, regnumber: '01-09-562111');

// By tax number (use "EV_" prefix for sole proprietors)
$result = $api->getData($token, taxnumber: '12345678-2-41');

// $result is an ApiResult object
var_dump($result->getLimitReached()); // bool
foreach ($result->getCompanies() as $company) {
    echo $company->getName();
    echo $company->getTaxnumber();
    echo $company->getRating();
}
ParameterTypeRequiredDefaultDescription
$tokenstringYesSession token
$regnumberstringNonullRegistration number ("EV_" prefix for sole proprietors)
$taxnumberstringNonullTax number ("EV_" prefix for sole proprietors)

At least one of $regnumber or $taxnumber must be provided.

Return: Omisai\CreditOnline\Model\ApiResult


3. Daily Monitoring — GetDailyMonitoringService

Fetches monitoring events (changes) for a given date.

use Omisai\CreditOnline\Api\GetDailyMonitoringService;

$api = new GetDailyMonitoringService();

$events = $api->getDailyMonitoring($token, new \DateTime('2025-01-15'));

foreach ($events as $event) {
    echo $event->getName();       // Company name
    echo $event->getTaxnumber();  // Tax number
    echo $event->getCategory();   // Event category
    echo $event->getLink();       // Detail link
}
ParameterTypeRequiredDefaultDescription
$tokenstringYesSession token
$date\DateTimeYesDate to query

Return: Omisai\CreditOnline\Model\Event[]


4. Subscriber Profile — GetProfileAndTrafficDataService

Retrieves subscriber profile information including usage quotas.

use Omisai\CreditOnline\Api\GetProfileAndTrafficDataService;

$api = new GetProfileAndTrafficDataService();

$profile = $api->getProfile($token);

echo $profile->getCompanyName();
echo $profile->getActualFormat();
echo $profile->getActualLanguage();

foreach ($profile->getActualUsages() as $usage) {
    echo $usage->getType();   // Usage type
    echo $usage->getLimit();  // Limit
    echo $usage->getIds();    // IDs
}
ParameterTypeRequiredDefaultDescription
$tokenstringYesSession token

Return: Omisai\CreditOnline\Model\Profile

Models

ModelKey GettersDescription
ApiResultgetLimitReached(), getCompanies()Top-level data query response
CompanygetRegnumber(), getTaxnumber(), getName(), getLongName(), getHeadquarter(), getStatus(), getFoundation(), getFunds(), getEmployees(), getLastTurnover(), getMainActivityCode(), getRating(), getCreditLimit(), getIndustry(), getType(), getKshNumber(), getEuTaxnumber(), getLink(), getBankAccounts(), getPhones(), getEmails(), getWebpages(), getNegativeInfo(), getPositiveInfo(), getFinancialSummaries(), getSigners(), getMembers(), getAuditors(), getSites(), getHasDeletedTaxNumber(), getHasActivePositiveInfo(), getHasActiveNegativeInfo(), getIsKoztartozasmentes(), getIsMegbizhatoAdozo(), getHasProhibitedMember(), getSignerChangeIn12Months(), getMemberChangeIn12Months(), getHeadquarterChangeIn12Months()Full company profile
AddressgetCountryCode(), getZip(), getCity(), getStreet(), getPlaceType(), getHouseNumber()Postal address
EventgetTaxnumber(), getName(), getCategory(), getLink()Daily monitoring event
ProfilegetCompanyName(), getActualFormat(), getActualLanguage(), getActualUsages()Subscriber profile
ActualUsagegetIds(), getLimit(), getType()Usage quota entry
FinancialSummaryFinancial data for a fiscal year
NegativeInfogetType(), getCaseNumber(), getStart(), getEnd()Negative credit information
PositiveInfoPositive credit information
SignerCompany signer/representative
MemberCompany owner/member
AuditorCompany auditor

All models implement \ArrayAccess and \JsonSerializable.

Error Handling

All API methods throw Omisai\CreditOnline\ApiException on non-2xx responses or connection failures.

use Omisai\CreditOnline\ApiException;

try {
    $result = $api->getData($token, regnumber: '01-09-562111');
} catch (ApiException $e) {
    echo 'HTTP Status: ' . $e->getCode();
    echo 'Message: ' . $e->getMessage();
    // $e->getResponseHeaders() returns response headers (nullable)
    // $e->getResponseBody() returns response body as string (nullable)
}

Advanced

Async methods

All endpoints provide async variants returning Guzzle promises:

$promise = $api->getDataAsync($token, regnumber: '01-09-562111');
$promise->then(function (ApiResult $result) {
    foreach ($result->getCompanies() as $company) {
        echo $company->getName();
    }
});

*WithHttpInfo() methods

Each endpoint has a *WithHttpInfo() variant that returns an array of [$response, $statusCode, $headers] instead of just the response body:

[$result, $statusCode, $headers] = $api->getDataWithHttpInfo($token, regnumber: '01-09-562111');

Async *WithHttpInfo() variants are also available:

$promise = $api->getDataAsyncWithHttpInfo($token, regnumber: '01-09-562111');

Full Example

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Omisai\CreditOnline\Api\AuthenticationService;
use Omisai\CreditOnline\Api\GetDataByIdService;
use Omisai\CreditOnline\Api\GetDailyMonitoringService;
use Omisai\CreditOnline\Api\GetProfileAndTrafficDataService;
use Omisai\CreditOnline\Configuration;

$apiKey = 'your-api-key';

// Use test environment
$config = new Configuration();
$config->setHost('https://api-test.creditonline.hu/v3');

// 1. Generate token
$tokenApi = new AuthenticationService($config);
list(, , $headers) = $tokenApi->getTokenWithHttpInfo($apiKey);
$token = $headers['Token'][0] ?? null; // Token returned in response headers

// 2. Look up a company by registration number
$dataApi = new GetDataByIdService($config);
$result = $dataApi->getData($token, regnumber: '01-09-562111');

echo 'Limit reached: ' . ($result->getLimitReached() ? 'Yes' : 'No') . "\n\n";

foreach ($result->getCompanies() as $company) {
    echo 'Company: ' . $company->getName() . "\n";
    echo 'Tax number: ' . $company->getTaxnumber() . "\n";
    echo 'Rating: ' . $company->getRating() . "\n";
    echo 'Credit limit: ' . $company->getCreditLimit() . "\n\n";
}

// 3. Fetch daily monitoring events
$monitoringApi = new GetDailyMonitoringService($config);
$events = $monitoringApi->getDailyMonitoring($token, new \DateTime('yesterday'));

foreach ($events as $event) {
    echo $event->getName() . ' — ' . $event->getCategory() . "\n";
}

// 4. Check profile usage
$profileApi = new GetProfileAndTrafficDataService($config);
$profile = $profileApi->getProfile($token);

echo 'Profile: ' . $profile->getCompanyName() . "\n";
foreach ($profile->getActualUsages() as $usage) {
    echo '  ' . $usage->getType() . ': ' . $usage->getIds() . ' / ' . $usage->getLimit() . "\n";
}

Testing

Run the test suite using Pest:

composer test

Contributing

Please see CONTRIBUTING.md for details on how to contribute to this project.

Security

Please see SECURITY.md for details on reporting security vulnerabilities.

License

This package is open-sourced software licensed under the MIT license.

Sponsoring

If you find this package useful, please consider sponsoring the development: Sponsoring on GitHub

Your support helps us maintain and improve this open-source project!

Acknowledgments