PHPackages                             kobana/kobana-php-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. kobana/kobana-php-client

ActiveLibrary[API Development](/categories/api)

kobana/kobana-php-client
========================

PHP SDK client for Kobana API - Financial automation platform

00PHPCI passing

Since Dec 28Pushed 6mo agoCompare

[ Source](https://github.com/universokobana/kobana-php-client)[ Packagist](https://packagist.org/packages/kobana/kobana-php-client)[ RSS](/packages/kobana-kobana-php-client/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Kobana PHP Client
=================

[](#kobana-php-client)

PHP SDK client for the Kobana API - Financial automation platform.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Composer

Installation
------------

[](#installation)

```
composer require kobana/kobana-php-client
```

Configuration
-------------

[](#configuration)

### Using Environment Variables

[](#using-environment-variables)

Create a `.env` file (copy from `.env.example`):

```
KOBANA_API_TOKEN=your_api_token_here
KOBANA_ENVIRONMENT=sandbox
KOBANA_DEBUG=false
```

### Global Configuration

[](#global-configuration)

```
use Kobana\Kobana;

Kobana::configure([
    'apiToken' => 'your_api_token',
    'environment' => 'sandbox', // 'sandbox', 'production', or 'development'
    'debug' => false,
]);
```

### Multi-Client Configuration

[](#multi-client-configuration)

```
use Kobana\Client;

$client1 = new Client([
    'apiToken' => 'token_for_client_1',
    'environment' => 'sandbox',
]);

$client2 = new Client([
    'apiToken' => 'token_for_client_2',
    'environment' => 'production',
]);
```

Usage
-----

[](#usage)

### Bank Billets (Boletos)

[](#bank-billets-boletos)

```
use Kobana\Kobana;
use Kobana\Resources\Charge\BankBillet;

// Configure the SDK
Kobana::configure([
    'apiToken' => getenv('KOBANA_API_TOKEN'),
    'environment' => 'sandbox',
]);

// Create a bank billet
$billet = Kobana::charge()->bankBillet()->create([
    'amount' => 100.50,
    'expireAt' => '2025-12-31',
    'customerPersonName' => 'John Doe',
    'customerCnpjCpf' => '12345678901',
    'customerEmail' => 'john@example.com',
    'customerPhoneNumber' => '11999999999',
    'customerState' => 'SP',
    'customerCityName' => 'São Paulo',
    'customerZipcode' => '01310100',
    'customerAddress' => 'Av. Paulista',
    'customerAddressNumber' => '1000',
    'customerNeighborhood' => 'Bela Vista',
]);

echo "Billet created with ID: {$billet->id}\n";
echo "Status: {$billet->status}\n";
echo "Barcode: {$billet->getBarcode()}\n";

// List bank billets
$billets = Kobana::charge()->bankBillet()->all([
    'status' => 'opened',
    'page' => 1,
    'perPage' => 25,
]);

foreach ($billets as $billet) {
    echo "{$billet->id}: {$billet->amount} - {$billet->status}\n";
}

// Find a specific billet
$billet = BankBillet::find(123);

// Check status
if ($billet->isPaid()) {
    echo "Billet is paid!\n";
} elseif ($billet->isOverdue()) {
    echo "Billet is overdue.\n";
}

// Cancel a billet
$billet->cancel();

// Duplicate a billet
$newBillet = $billet->duplicate([
    'expireAt' => '2026-01-31',
    'amount' => 150.00,
]);
```

### PIX Charges

[](#pix-charges)

```
use Kobana\Kobana;
use Kobana\Resources\Charge\Pix;

// Create a PIX charge
$pix = Kobana::charge()->pix()->create([
    'amount' => 50.00,
    'customerPersonName' => 'Jane Doe',
    'customerCnpjCpf' => '98765432100',
    'expireAt' => '2025-12-31T23:59:59Z',
]);

echo "PIX charge created!\n";
echo "QR Code: {$pix->getQrCode()}\n";
echo "QR Code URL: {$pix->getQrCodeUrl()}\n";

// List PIX charges
$charges = Kobana::charge()->pix()->all([
    'status' => 'pending',
]);

// Find a specific PIX charge
$pix = Pix::find(456);

// Check status
if ($pix->isPaid()) {
    echo "Paid at: {$pix->getPaidAt()}\n";
    echo "Amount paid: {$pix->getPaidAmount()}\n";
}

// List commands
$commands = $pix->listCommands();
```

### Bank Billet Accounts (Carteiras de Cobrança)

[](#bank-billet-accounts-carteiras-de-cobrança)

```
use Kobana\Kobana;

// List bank billet accounts
$accounts = Kobana::financial()->bankBilletAccount()->all();

foreach ($accounts as $account) {
    echo "{$account->id}: {$account->getBeneficiaryName()}\n";
    echo "Status: {$account->status}\n";
    echo "Bank: {$account->getBankContractSlug()}\n";
}

// Request homologation
$account->askHomologation();

// Validate account
$account->validate();

// Set as default
$account->setDefault();
```

### Financial Accounts

[](#financial-accounts)

```
use Kobana\Kobana;

// Get current account
$account = Kobana::financial()->account()->current();

echo "Account: {$account->getName()}\n";
echo "Email: {$account->getEmail()}\n";
echo "Available Balance: {$account->getAvailableBalance()}\n";
echo "Blocked Balance: {$account->getBlockedBalance()}\n";
```

Error Handling
--------------

[](#error-handling)

```
use Kobana\Kobana;
use Kobana\Exceptions\ValidationException;
use Kobana\Exceptions\UnauthorizedException;
use Kobana\Exceptions\ResourceNotFoundException;
use Kobana\Exceptions\ApiException;
use Kobana\Exceptions\ConnectionException;

try {
    $billet = Kobana::charge()->bankBillet()->create([
        'amount' => 0, // Invalid amount
    ]);
} catch (ValidationException $e) {
    echo "Validation failed:\n";
    foreach ($e->getErrors() as $field => $messages) {
        echo "  {$field}: " . implode(', ', $messages) . "\n";
    }
} catch (UnauthorizedException $e) {
    echo "Authentication failed: {$e->getMessage()}\n";
} catch (ResourceNotFoundException $e) {
    echo "Resource not found: {$e->getResourceType()} #{$e->getResourceId()}\n";
} catch (ConnectionException $e) {
    echo "Connection error: {$e->getMessage()}\n";
} catch (ApiException $e) {
    echo "API error ({$e->getStatusCode()}): {$e->getMessage()}\n";
}
```

Pagination
----------

[](#pagination)

```
use Kobana\Kobana;

$billets = Kobana::charge()->bankBillet()->all([
    'page' => 1,
    'perPage' => 50,
]);

echo "Page {$billets->getCurrentPage()} of {$billets->getTotalPages()}\n";
echo "Showing {$billets->count()} of {$billets->getTotalItems()} items\n";

if ($billets->hasNextPage()) {
    echo "Next page: {$billets->getNextPage()}\n";
}

// Iterate over items
foreach ($billets as $billet) {
    echo "{$billet->id}: {$billet->amount}\n";
}

// Get first/last
$first = $billets->first();
$last = $billets->last();
```

Development
-----------

[](#development)

### Setup

[](#setup)

```
# Install dependencies
composer install

# Copy environment file and add your API token
cp .env.example .env
```

Edit `.env` and add your Kobana API token:

```
KOBANA_API_TOKEN=your_api_token_here
KOBANA_ENVIRONMENT=sandbox
```

### Running Tests

[](#running-tests)

```
# Run all tests
composer test

# Or using PHPUnit directly
./vendor/bin/phpunit
```

### Unit Tests

[](#unit-tests)

Unit tests don't require API access and test classes in isolation:

```
./vendor/bin/phpunit --testsuite Unit
```

### Integration Tests

[](#integration-tests)

Integration tests make real API calls to the sandbox environment and record responses using [php-vcr](https://github.com/php-vcr/php-vcr):

```
./vendor/bin/phpunit --testsuite Integration
```

**First run:** Tests will call the real API and save responses to `tests/fixtures/`.

**Subsequent runs:** Tests will use recorded responses (no API calls needed).

**Recording new fixtures:** Delete the cassette file in `tests/fixtures/` to re-record.

#### Security

[](#security)

- Authorization headers are automatically filtered from recordings
- Tokens in response bodies are replaced with `[FILTERED]`
- Never commit `.env` files (already in `.gitignore`)

### Running Tests with Coverage

[](#running-tests-with-coverage)

```
composer test:coverage
```

Coverage report will be generated in the `coverage/` directory.

API Environments
----------------

[](#api-environments)

EnvironmentBase URLsandboxproductiondevelopmentResources
---------

[](#resources)

### Charge Module

[](#charge-module)

- **BankBillet** - Bank billets (boletos) management
- **Pix** - PIX charges management

### Financial Module

[](#financial-module)

- **Account** - Financial account information
- **BankBilletAccount** - Bank billet accounts (carteiras) management

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for more information.

Links
-----

[](#links)

- [Kobana Website](https://www.kobana.com.br)
- [API Documentation](https://developers.kobana.com.br)
- [GitHub Repository](https://github.com/universokobana/kobana-php-client)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance47

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f34b3a24de920f868cfb1d80b6e305ed03fd0252ccf8d3862313eb66696f3c67?d=identicon)[kobana\_rafaelp](/maintainers/kobana_rafaelp)

---

Top Contributors

[![rafaelp](https://avatars.githubusercontent.com/u/19240?v=4)](https://github.com/rafaelp "rafaelp (5 commits)")

### Embed Badge

![Health badge](/badges/kobana-kobana-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/kobana-kobana-php-client/health.svg)](https://phpackages.com/packages/kobana-kobana-php-client)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
