PHPackages                             znojil/comgate - 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. [Payment Processing](/categories/payments)
4. /
5. znojil/comgate

ActiveLibrary[Payment Processing](/categories/payments)

znojil/comgate
==============

📦 A simple and modern PHP library for communicating with the Comgate API.

00PHPCI passing

Pushed todayCompare

[ Source](https://github.com/znojil/comgate)[ Packagist](https://packagist.org/packages/znojil/comgate)[ RSS](/packages/znojil-comgate/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersionsUsed By (0)

Znojil Comgate
==============

[](#znojil-comgate)

[![Latest Stable Version](https://camo.githubusercontent.com/408fdee8dbfb4183682464b274e487b91763fb1d90905a127f68fdf7d62dcc76/68747470733a2f2f706f7365722e707567782e6f72672f7a6e6f6a696c2f636f6d676174652f762f737461626c65)](https://github.com/znojil/comgate/releases)[![PHP Version Require](https://camo.githubusercontent.com/8a33f0e8ba5644b7becade5869168ce901543d1ff16f534d6cc75c2c9a253049/68747470733a2f2f706f7365722e707567782e6f72672f7a6e6f6a696c2f636f6d676174652f726571756972652f706870)](https://packagist.org/packages/znojil/comgate)[![License](https://camo.githubusercontent.com/6c1bd47721045833d6ff83a7db93cf29206c4c5c27aa740a97638a4deebef1ba/68747470733a2f2f706f7365722e707567782e6f72672f7a6e6f6a696c2f636f6d676174652f6c6963656e7365)](LICENSE)[![Tests](https://github.com/znojil/comgate/actions/workflows/tests.yml/badge.svg)](https://github.com/znojil/comgate/actions)

A simple and modern PHP library for communicating with the [Comgate payment gateway API](https://apidoc.comgate.cz/api/post/).

🚀 Installation
--------------

[](#-installation)

```
composer require znojil/comgate
```

📖 Usage
-------

[](#-usage)

### 1. Client Initialization

[](#1-client-initialization)

```
use Znojil\Comgate\Client;
use Znojil\Comgate\Config;

$config = new Config(
	merchant: 'YOUR_MERCHANT_ID',
	secret: 'YOUR_SECRET',
	test: false // true for test mode
);

$client = new Client($config);
```

### 2. Creating a Payment

[](#2-creating-a-payment)

```
use Znojil\Comgate\DTO\PaymentDTO;
use Znojil\Comgate\Enum\Currency;
use Znojil\Comgate\Request\CreateRequest;

$payment = new PaymentDTO(
	price: 10000, // in cents, 10000 = 100.00 CZK
	curr: Currency::Czk,
	label: 'Order #1234',
	refId: 'order-1234',
	fullName: 'John Doe',
	email: 'john@example.com'
);

$result = $client->send(new CreateRequest($payment));

$result->transId; // AB12-CD34-EF56
$result->redirect; // redirect URL for payment gateway
```

If you prefer to redirect the customer directly to the payment gateway:

```
use Znojil\Comgate\Request\CreateRedirectRequest;

$redirectUrl = $client->send(new CreateRedirectRequest($payment));
// redirect the customer to $redirectUrl
```

### 3. Checking Payment Status

[](#3-checking-payment-status)

```
use Znojil\Comgate\Request\StatusRequest;

$status = $client->send(new StatusRequest('AB12-CD34-EF56'));

$status->transId; // AB12-CD34-EF56
$status->status; // PaymentStatus enum
$status->price; // int (cents)
$status->curr; // Currency enum
```

### 4. Using a Custom HTTP Client

[](#4-using-a-custom-http-client)

You can inject your own HTTP client implementation by passing it as the second argument to the `Client` constructor. Your client must implement the `Znojil\Comgate\Http\Client` interface.

```
use Znojil\Comgate\Client;
use Znojil\Comgate\Http\Client as ComgateHttpClient;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;

class MyCustomHttpClient implements ComgateHttpClient{
	public function send(string $method, string|UriInterface $uri, array $headers = [], mixed $data = null, array $options = []): ResponseInterface{
		// your implementation
	}
}

$client = new Client($config, new MyCustomHttpClient);
```

⚠️ Error Handling
-----------------

[](#️-error-handling)

The client throws exceptions to help you identify the issue:

- `Znojil\Comgate\Exception\ApiException`: For API-level errors returned by Comgate (e.g. invalid parameters). Contains `code` and `message` from the API response.
- `Znojil\Comgate\Exception\ClientException`: For HTTP client-side errors (4xx).
- `Znojil\Comgate\Exception\ServerException`: For HTTP server-side errors (5xx).
- `Znojil\Comgate\Exception\ResponseException`: For other unsuccessful HTTP responses.
- `Znojil\Comgate\Exception\InvalidArgumentException`: For invalid input (e.g. invalid credentials, missing required data).

```
use Znojil\Comgate\Exception\ApiException;
use Znojil\Comgate\Exception\ClientException;
use Znojil\Comgate\Exception\ServerException;

try{
	$result = $client->send(new CreateRequest($payment));
}catch(ApiException $e){
	echo $e->getMessage(); // error message from Comgate
	echo $e->getCode(); // error code from Comgate
}catch(ServerException $e){
	// Comgate server error (5xx)
}catch(ClientException $e){
	// HTTP client error (4xx)
}
```

📄 License
---------

[](#-license)

This library is open-source software licensed under the [MIT license](https://choosealicense.com/licenses/mit/).

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity8

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://avatars.githubusercontent.com/u/6079815?v=4)[Marek Znojil](/maintainers/znojil)[@znojil](https://github.com/znojil)

---

Top Contributors

[![znojil](https://avatars.githubusercontent.com/u/6079815?v=4)](https://github.com/znojil "znojil (1 commits)")

---

Tags

api-clientcomgateczechpaymentpayment-gatewayphpsdk

### Embed Badge

![Health badge](/badges/znojil-comgate/health.svg)

```
[![Health](https://phpackages.com/badges/znojil-comgate/health.svg)](https://phpackages.com/packages/znojil-comgate)
```

###  Alternatives

[omnipay/coinbase

Coinbase driver for the Omnipay payment processing library

18570.2k1](/packages/omnipay-coinbase)[oxid-esales/amazon-pay-module

AmazonPay module for OXID

1824.3k](/packages/oxid-esales-amazon-pay-module)[yenepay/php-sdk

YenePay SDK for PHP

112.7k](/packages/yenepay-php-sdk)

PHPackages © 2026

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