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. [API Development](/categories/api)
4. /
5. znojil/comgate

ActiveLibrary[API Development](/categories/api)

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

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

v1.2.0(3w ago)01MITPHPPHP ^8.2CI passing

Since Jun 21Pushed 2w agoCompare

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

READMEChangelog (6)Dependencies (5)Versions (5)Used By (0)

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

[](#znojil-comgate)

[![Latest Stable Version](https://camo.githubusercontent.com/21b9c32ec0aac634b8d13f2f96b6711ae224778ec0e4308aae7ff1b06b0ce560/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6e6f6a696c2f636f6d67617465)](https://packagist.org/packages/znojil/comgate)[![PHP Version Require](https://camo.githubusercontent.com/fd53731faf57c7c8c6ff46bd552d6d111f2f81ff318ecf635801b29a67b49b47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7a6e6f6a696c2f636f6d676174652f706870)](https://packagist.org/packages/znojil/comgate)[![License](https://camo.githubusercontent.com/28db211fee31c4c8b9c9b1793fd1a51927bbf0149afeb9fe8308c3b7ed32f3c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a6e6f6a696c2f636f6d67617465)](LICENSE)[![Tests](https://github.com/znojil/comgate/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/znojil/comgate/actions/workflows/tests.yml)

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);
```

Your implementation must honor the `Znojil\Comgate\Http\Option::*` keys passed in `$options` (e.g. `Option::FollowRedirects` — some requests rely on redirects not being followed automatically) and must reject unknown string keys with an exception. Integer keys are raw `CURLOPT_*` constants — non-cURL implementations must reject them with an exception rather than silently ignore them, so that a consumer never ends up with options that silently don't apply.

### 5. Handling Push Notifications

[](#5-handling-push-notifications)

Comgate sends a push notification (HTTP POST) to your server when a payment status changes. Use `Client::accept()` to authenticate and process it:

```
use Znojil\Comgate\ServerRequest\PaymentStatusServerRequest;

$status = $client->accept(new PaymentStatusServerRequest);

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

`accept()` automatically validates the `merchant` and `secret` from the request body against your `Config`. If they do not match, an `InvalidArgumentException` is thrown.

You can also inject a PSR-7 `ServerRequestInterface` manually — useful in frameworks that provide it:

```
$status = $client->accept(new PaymentStatusServerRequest, $psrServerRequest);
```

⚠️ 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\JsonResponseException`: When an API response body is not valid JSON (subtype of `ResponseException`).
- `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)
}
```

> All exceptions thrown by the library implement the `Znojil\Comgate\Exception\Exception` marker interface, so a single catch can cover them all.

📄 License
---------

[](#-license)

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

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance96

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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 ~6 days

Total

4

Last Release

22d ago

### 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 (19 commits)")

---

Tags

api-clientcomgateczechpaymentpayment-gatewayphpsdkapiclientmoneysdkpaymentgatewaycomgateczech

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### 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

[checkout/checkout-sdk-php

Checkout.com SDK for PHP

563.6M16](/packages/checkout-checkout-sdk-php)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47494.5k5](/packages/deepseek-php-deepseek-php-client)[comgate/sdk

Comgate PHP SDK

13388.6k](/packages/comgate-sdk)

PHPackages © 2026

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