PHPackages                             comfino/api-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. [HTTP &amp; Networking](/categories/http)
4. /
5. comfino/api-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

comfino/api-client
==================

Standard PHP API client library for the Comfino payment gateway with PSR-18/PSR-7 support.

1.1.2(4mo ago)06BSD-3-ClausePHPPHP &gt;=8.2CI passing

Since Oct 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/comfino/api-client)[ Packagist](https://packagist.org/packages/comfino/api-client)[ Docs](https://github.com/comfino/api-client)[ RSS](/packages/comfino-api-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

Comfino API Client
==================

[](#comfino-api-client)

[![Latest Version](https://camo.githubusercontent.com/ab402dadceff0f110a1494faa0b734104241d7752e921ae4f6ae150ba64b9270/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636f6d66696e6f2f6170692d636c69656e742e737667)](https://github.com/comfino/api-client/releases)[![PHP Version](https://camo.githubusercontent.com/22fea538eaa3d43ec49d07a9deb3fb84dd80cda05ee592de954ed990e25de2b4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f636f6d66696e6f2f6170692d636c69656e742e737667)](https://packagist.org/packages/comfino/api-client)[![Build Status](https://github.com/comfino/api-client/actions/workflows/tests.yml/badge.svg)](https://github.com/comfino/api-client/actions/workflows/tests.yml)[![Software License](https://camo.githubusercontent.com/ba163b9d6a47bcfeeaeeae8a91d4fa1a8df3d528367d69952295f31f2f770cad/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d425344253230332d2d436c617573652d6f72616e67652e737667)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/312e144dc689942d0970e1eb861c16e3cebd0548861d4e05f3c8546651815fc4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6d66696e6f2f6170692d636c69656e742e737667)](https://packagist.org/packages/comfino/api-client)

**Comfino API client library**

Standard PHP API client library for the Comfino payment gateway.

Features
--------

[](#features)

- PSR-18 HTTP Client compatibility
- PSR-7 HTTP Messages support
- Production and sandbox environment support

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

[](#requirements)

- PHP 8.2 or higher
- PSR-18 HTTP Client implementation
- Composer

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

[](#installation)

Install via Composer:

```
composer require comfino/api-client
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

```
use Comfino\Api\Client;

// Initialize the client.
$client = new Client(
    $requestFactory, // PSR-17 Request Factory
    $streamFactory,  // PSR-17 Stream Factory
    $httpClient,     // PSR-18 HTTP Client
    'your-api-key'
);

// Enable sandbox mode for testing.
$client->enableSandboxMode();

// Or disable it for production.
$client->disableSandboxMode();
```

### Making API calls

[](#making-api-calls)

The Client class provides convenience methods for all API operations:

```
use Comfino\Api\Dto\Payment\LoanQueryCriteria;
use Comfino\Shop\Order\OrderInterface;

// Create a loan application.
$order = /* OrderInterface instance */;
$response = $client->createOrder($order);
$applicationUrl = $response->applicationUrl;

// Get order details.
$orderDetails = $client->getOrder($orderId);

// Get available financial products.
$queryCriteria = new LoanQueryCriteria(/* ... */);
$products = $client->getFinancialProducts($queryCriteria);

// Check if shop account is active.
$isActive = $client->isShopAccountActive();

// Cancel an order.
$client->cancelOrder($orderId);
```

Architecture
------------

[](#architecture)

### Core components

[](#core-components)

- **Client class** (`src/Api/Client.php`): Main entry point using dependency injection with PSR-18 HTTP Client interfaces.
- **Request/Response pattern**: Each API operation has dedicated classes using Command pattern.
- **Dual DTO layers**: API layer DTOs (readonly classes) and Shop domain layer (interface-based for flexibility).
- **Environment support**: Configurable API hosts for production and sandbox.

### Key design patterns

[](#key-design-patterns)

- **Abstract base classes**: `Request` and `Response` define common behavior.
- **Strategy pattern**: Pluggable serializers through `SerializerInterface` (default: JSON),
- **Interface contracts**: Shop integration through `OrderInterface`, `CartInterface`, `CustomerInterface`.
- **Trait-based sharing**: Common functionality through traits like `CartTrait`.

### Directory structure

[](#directory-structure)

```
src/
├── Api/          # Core API client, requests, responses, DTOs, exceptions.
├── Shop/         # Domain models for e-commerce integration.
└── Enum.php      # Base enum class for PHP version compatibility.
tests/            # PHPUnit tests with trait-based organization.

```

### Error handling

[](#error-handling)

Exception hierarchy based on HTTP status codes:

- **400**: `RequestValidationError` - Invalid request data.
- **401**: `AuthorizationError` - Authentication failure.
- **402-405**: `AccessDenied` - Permission issues.
- **500+**: `ServiceUnavailable` - Server errors.

All exceptions implement `HttpErrorExceptionInterface` and preserve request/response context for debugging.

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

[](#development)

### Install dependencies

[](#install-dependencies)

```
# Using the wrapper script (Docker or local).
./bin/composer install

# Update dependencies.
./bin/composer update
```

### Running tests

[](#running-tests)

```
# Run all tests.
./bin/composer test

# Or use PHPUnit directly.
./vendor/bin/phpunit

# Run specific test.
./vendor/bin/phpunit tests/Api/ClientTest.php

# Generate coverage report (requires Xdebug).
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html coverage
```

### Docker development

[](#docker-development)

```
# Start development environment.
docker-compose up -d

# Run commands inside container.
docker-compose exec api-client-php composer test
docker-compose exec api-client-php php -v
```

Testing approach
----------------

[](#testing-approach)

- Mock HTTP clients for integration testing.
- Trait-based test organization (`ClientTestTrait`, `ReflectionTrait`).
- Comprehensive coverage of success and error scenarios.
- Validation of request construction, response parsing, and error handling.

PSR standards
-------------

[](#psr-standards)

This library follows PHP Standards Recommendations:

- **PSR-4**: Autoloading
- **PSR-7**: HTTP Messages
- **PSR-18**: HTTP Client

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

This library is licensed under the BSD 3-Clause License. See the [LICENSE](LICENSE) file for details.

Support
-------

[](#support)

For bug reports and feature requests, please use the [GitHub issue tracker](https://github.com/comfino/api-client/issues).

Contributing
------------

[](#contributing)

Contributions are welcome! Please ensure all tests pass before submitting pull requests:

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance82

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~41 days

Total

3

Last Release

124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2b3f240df6319cb5a3b2b52bfdef1b215f99b4b3f713cd30a01061b18fee943?d=identicon)[akozubskicr](/maintainers/akozubskicr)

---

Top Contributors

[![akozubskicr](https://avatars.githubusercontent.com/u/83001403?v=4)](https://github.com/akozubskicr "akozubskicr (97 commits)")

---

Tags

psr-7apiclientpsr-18paymentgatewayinstallmentsbnplpay latercomfinodeferred payments

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/comfino-api-client/health.svg)

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

###  Alternatives

[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[vultr/vultr-php

The Official Vultr API PHP Wrapper.

2243.9k1](/packages/vultr-vultr-php)[amphp/http-client-psr7

PSR-7 adapter for Amp's HTTP client.

1454.7k4](/packages/amphp-http-client-psr7)[chillerlan/php-httpinterface

A PSR-7/17/18 http message/client implementation

1417.1k5](/packages/chillerlan-php-httpinterface)

PHPackages © 2026

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