PHPackages                             comfino/sdk-for-magento2 - 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. comfino/sdk-for-magento2

ActiveMagento2-module

comfino/sdk-for-magento2
========================

Comfino PHP SDK adapter for Magento 2 - wires Magento native services to SDK PSR interfaces.

1.0.0(yesterday)04↑2900%1BSD-3-ClausePHP &gt;=8.1

Since Jul 22Compare

[ Source](https://github.com/comfino/sdk-for-magento2)[ Packagist](https://packagist.org/packages/comfino/sdk-for-magento2)[ Docs](https://github.com/comfino/sdk-for-magento2)[ RSS](/packages/comfino-sdk-for-magento2/feed)WikiDiscussions Synced today

READMEChangelog (1)Dependencies (12)Versions (2)Used By (1)

[ ![Comfino](assets/comfino_logo.svg)](https://developers.comfino.pl)Comfino SDK for Magento 2
=========================

[](#comfino-sdk-for-magento-2)

[![Latest Version](https://camo.githubusercontent.com/31444a8ecd656dea19f1018eed147be48872cef14fe9e1083d4a8e12781b2e17/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d312e302e302d626c75652e737667)](https://github.com/comfino/sdk-for-magento2/releases)[![PHP Version](https://camo.githubusercontent.com/6c9318fbe174a5b382412c6c5e8f571e6ca4e3f404f3a38a56cd1f6383442a4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f636f6d66696e6f2f73646b2d666f722d6d6167656e746f322f7068702e737667)](https://packagist.org/packages/comfino/sdk-for-magento2)[![Build Status](https://github.com/comfino/sdk-for-magento2/actions/workflows/tests.yml/badge.svg)](https://github.com/comfino/sdk-for-magento2/actions/workflows/tests.yml)[![Software License](https://camo.githubusercontent.com/ba163b9d6a47bcfeeaeeae8a91d4fa1a8df3d528367d69952295f31f2f770cad/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d425344253230332d2d436c617573652d6f72616e67652e737667)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/832583a276c9b3b53fddd53094919a4b532a53f8f2cc7f8ec322d10fafcfbf6e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6d66696e6f2f73646b2d666f722d6d6167656e746f322e737667)](https://packagist.org/packages/comfino/sdk-for-magento2)[![API Documentation](https://camo.githubusercontent.com/b2e7feb6e6f17d534d0fcadc30e1f4d74bd06681abe353feb46bdb3741ea02b6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4150492d646f63756d656e746174696f6e2d356139653333)](https://developers.comfino.pl)

**Magento 2 adapter layer for the Comfino PHP SDK**

This package wires Magento 2's native services into the PSR interfaces expected by [`comfino/php-sdk`](https://github.com/comfino/php-sdk). It is a thin adapter layer with no business logic — all integration behaviour lives in the upstream SDK.

It is a required dependency of the official [Comfino Magento 2 payment plugin](https://github.com/comfino/Magento-2.3) and is not intended for standalone use.

What it provides
----------------

[](#what-it-provides)

Adapter classMagento servicePSR interface`Comfino\Magento\Http\MagentoHttpClientAdapter``Magento\Framework\HTTP\Client\Curl`PSR-18 `ClientInterface``Comfino\Magento\Cache\MagentoCacheAdapter``Magento\Framework\Cache\FrontendInterface`PSR-6 `CacheItemPoolInterface` + Symfony `TagAwareCacheInterface``Comfino\Magento\Cache\CacheItem`—PSR-6 `CacheItemInterface` + Symfony `ItemInterface``Comfino\Magento\Http\MagentoServerRequestConverter``Magento\Framework\App\Request\Http`PSR-7 `ServerRequestInterface``Comfino\Magento\Bootstrap`Static initializerWires adapters into `comfino/php-sdk` singletonsRequirements
------------

[](#requirements)

- PHP 8.1 or higher
- Magento 2.3 or higher (`magento/framework >= 103.0.4`)
- [`comfino/php-sdk`](https://packagist.org/packages/comfino/php-sdk)
- Composer

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

[](#installation)

```
composer require comfino/sdk-for-magento2
```

This package is pulled in automatically when you install the Comfino Magento 2 payment plugin.

Usage
-----

[](#usage)

Call `Bootstrap::init()` once during Magento DI resolution, typically from the plugin's own observer or bootstrap class injected via `etc/events.xml`:

```
use Comfino\Magento\Bootstrap as SdkBootstrap;
use Comfino\Magento\Cache\MagentoCacheAdapter;
use Comfino\Magento\Http\MagentoHttpClientAdapter;
use Magento\Framework\Cache\FrontendInterface;
use Magento\Framework\HTTP\Client\Curl as MagentoCurl;
use Magento\Framework\Serialize\SerializerInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Log\LoggerInterface;

class BootstrapObserver implements \Magento\Framework\Event\ObserverInterface
{
    private bool $initialized = false;

    public function __construct(
        private readonly MagentoCurl $curl,
        private readonly RequestFactoryInterface $requestFactory,
        private readonly StreamFactoryInterface $streamFactory,
        private readonly FrontendInterface $cache,
        private readonly SerializerInterface $serializer,
        private readonly LoggerInterface $logger,
    ) {}

    public function execute(\Magento\Framework\Event\Observer $observer): void
    {
        if ($this->initialized) {
            return;
        }

        SdkBootstrap::init(
            httpClient: new MagentoHttpClientAdapter($this->curl, $this->requestFactory, $this->streamFactory),
            requestFactory: $this->requestFactory,
            streamFactory: $this->streamFactory,
            cachePool: new MagentoCacheAdapter($this->cache, $this->serializer),
            logger: $this->logger,
        );

        $this->initialized = true;
    }
}
```

After `Bootstrap::init()`, retrieve the wired services for use with `ApiClientFactory`:

```
use Comfino\Backend\Factory\ApiClientFactory;
use Comfino\Magento\Bootstrap as SdkBootstrap;

$client = (new ApiClientFactory())->createClient(
    httpClient: SdkBootstrap::getHttpClient(),
    requestFactory: SdkBootstrap::getRequestFactory(),
    streamFactory: SdkBootstrap::getStreamFactory(),
    apiKey: $config->getApiKey(),
);
```

### Webhook handling

[](#webhook-handling)

Convert an incoming Magento HTTP request to a PSR-7 `ServerRequestInterface` for the SDK's `WebhookManager`:

```
use Comfino\Backend\Webhook\WebhookManager;
use Comfino\Magento\Http\MagentoServerRequestConverter;

class WebhookController extends \Magento\Framework\App\Action\Action
{
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        private readonly MagentoServerRequestConverter $converter,
        private readonly WebhookManager $webhookManager,
    ) {
        parent::__construct($context);
    }

    public function execute(): \Magento\Framework\App\ResponseInterface
    {
        $serverRequest = $this->converter->convert($this->getRequest());
        $this->webhookManager->processRequest('status_notification', $serverRequest);

        return $this->getResponse()->setBody('OK');
    }
}
```

Adapter notes
-------------

[](#adapter-notes)

### HTTP adapter

[](#http-adapter)

`MagentoHttpClientAdapter` wraps `Magento\Framework\HTTP\Client\Curl` as a PSR-18 client. Key behaviours:

- **Response headers** are not forwarded — `Magento\Framework\HTTP\Client\Curl` does not expose them. This is safe because `Comfino\Api\AbstractClient` only sets request headers and never reads response headers.
- **HTTP status 0** (connection timeout or DNS failure) is detected and thrown as `NetworkException` (implements `Psr\Http\Client\NetworkExceptionInterface`), which the SDK's retry executor treats as retryable.
- **Non-standard verbs** (PUT, DELETE, PATCH) are routed via `CURLOPT_CUSTOMREQUEST` since Magento's Curl client exposes only `get()` and `post()` publicly.
- **Timeout escalation** is supported via `TimeoutAwareClientInterface::updateTimeouts()`, called by the SDK's `ExponentialBackoffRetryPolicy` on each retry attempt.

### Cache adapter

[](#cache-adapter)

`MagentoCacheAdapter` wraps `Magento\Framework\Cache\FrontendInterface` as a PSR-6 pool:

- All keys are prefixed with `comfino_` to avoid collisions.
- All entries are tagged with `comfino` for bulk invalidation via `clear()`. Per-item tags set via `CacheItem::setTags()` are merged with the base `comfino` tag on save.
- Values are serialized using the injected `Magento\Framework\Serialize\SerializerInterface`.
- Implements `Symfony\Contracts\Cache\TagAwareCacheInterface`: `invalidateTags()` delegates to Magento's `FrontendInterface::clean(CLEANING_MODE_MATCHING_TAG, …)`.

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

[](#development)

The `bin/` wrappers delegate to a PHP 8.1 Docker container when `docker-compose` is available, or fall back to the host PHP.

```
# Start the development container.
docker-compose up -d

# Install dependencies.
./bin/composer install

# Run all tests.
./bin/phpunit

# Generate HTML coverage report (Xdebug container starts automatically).
./bin/phpunit --coverage-html coverage
```

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

[](#psr-standards)

- **PSR-4** autoloading
- **PSR-6** cache
- **PSR-7** HTTP messages
- **PSR-17** HTTP factories
- **PSR-18** HTTP client
- **PSR-12** coding style

License
-------

[](#license)

BSD 3-Clause License. See [LICENSE](LICENSE) for details.

Support
-------

[](#support)

Bug reports and feature requests: [GitHub issue tracker](https://github.com/comfino/sdk-for-magento2/issues).

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

[](#contributing)

The [GitHub repository](https://github.com/comfino/sdk-for-magento2) is a read-only public mirror that receives automated clean-snapshot releases. Please report bugs and suggest improvements via the [issue tracker](https://github.com/comfino/sdk-for-magento2/issues).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/83001403?v=4)[Artos Rakshasa](/maintainers/akozubskicr)[@akozubskicr](https://github.com/akozubskicr)

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/comfino-sdk-for-magento2/health.svg)

```
[![Health](https://phpackages.com/badges/comfino-sdk-for-magento2/health.svg)](https://phpackages.com/packages/comfino-sdk-for-magento2)
```

###  Alternatives

[mollie/magento2

Mollie Payment Module for Magento 2

1131.9M16](/packages/mollie-magento2)[buckaroo/magento2

Buckaroo Magento 2 extension

32420.3k8](/packages/buckaroo-magento2)[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

68357.9k](/packages/run-as-root-magento2-prometheus-exporter)[amzn/amazon-pay-magento-2-module

Official Magento2 Plugin to integrate with Amazon Pay

108531.2k1](/packages/amzn-amazon-pay-magento-2-module)[loki/magento2-components

Core module for defining Alpine.js components with advanced AJAX features

1011.8k26](/packages/loki-magento2-components)[dotdigital/dotdigital-magento2-extension

Dotdigital for Magento 2

50398.5k20](/packages/dotdigital-dotdigital-magento2-extension)

PHPackages © 2026

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