PHPackages                             mishagodovanuk/payment\_gateway - 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. mishagodovanuk/payment\_gateway

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

mishagodovanuk/payment\_gateway
===============================

Framework-agnostic mTLS HTTP client with HMAC-signed GET requests for payment gateway integrations

v1.1.0(1mo ago)01↓100%MITPHPPHP ^8.2

Since Apr 5Pushed 1mo agoCompare

[ Source](https://github.com/mishagodovanuk/payment_gateway)[ Packagist](https://packagist.org/packages/mishagodovanuk/payment_gateway)[ Docs](https://github.com/mishagodovanuk/payment_gateway)[ RSS](/packages/mishagodovanuk-payment-gateway/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (11)Versions (3)Used By (0)

Payment gateway mTLS + HMAC client
==================================

[](#payment-gateway-mtls--hmac-client)

PHP library for **mutual TLS** (client certificate) HTTP **GET** requests with **HMAC** integrity signatures on the query string. Suited for payment-style APIs that require transport security and request signing.

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

[](#requirements)

- PHP 8.2+
- Extensions: `json`, `openssl`
- Composer

Install
-------

[](#install)

```
composer require mishagodovanuk/payment_gateway
```

PHP namespace remains `Mihod\PaymentGateway\` (Composer package name is `mishagodovanuk/payment_gateway`).

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

[](#configuration)

Copy `.env.example` to `.env` and set certificate paths, key passphrase, and `HMAC_SECRET`. For BadSSL demos, use [badssl.com/download](https://badssl.com/download/) (private key passphrase: `badssl.com`).

Environment variables override values from the `.env` file when both are present.

### Optional HTTP client settings (Guzzle)

[](#optional-http-client-settings-guzzle)

These are optional and have sane defaults:

- `HTTP_ERRORS`: `true|false` (default `true`). When enabled, Guzzle throws exceptions on non-2xx responses.
- `HTTP_TIMEOUT_SECONDS`: float seconds (default `30`).
- `HTTP_CONNECT_TIMEOUT_SECONDS`: float seconds (default `10`).

Design (interfaces &amp; DTOs)
------------------------------

[](#design-interfaces--dtos)

- **`Mihod\PaymentGateway\Signature\SignerInterface`** — canonical query string + MAC signature (`HmacSigner` is the default).
- **`Mihod\PaymentGateway\Http\MtlsTransportInterface`** — GET over mTLS (`GuzzleMtlsTransport` via `GuzzleClientFactory`).
- **`Mihod\PaymentGateway\Dto\SignedHttpResponse`** — immutable result DTO for successful calls (status, body, headers).
- **`Mihod\PaymentGateway\SignedMtlsClientFactory`** — default wiring (Guzzle + HMAC signer).

`SignedMtlsClient` depends on these abstractions so you can swap implementations in tests or wire custom signers/transports in DI (Laravel, Symfony, Yii2, PHP-DI, etc.).

Usage
-----

[](#usage)

### Manual / direct usage (no framework)

[](#manual--direct-usage-no-framework)

Use this when you run plain PHP (CLI script, cron, small tool) and you do not use Laravel, Symfony, or Yii.

**1. Install the package**

```
composer require mishagodovanuk/payment_gateway
```

**2. Configure environment**

Copy `.env.example` to `.env` next to your script (or anywhere you prefer). Set absolute paths to your PEM files, `HMAC_SECRET`, and optional `SIGNATURE_HEADER_NAME` / `SIGNATURE_HASH_ALGO`.

**3. Call the client from a PHP file**

Bootstrap Composer autoload, then either load config from that file or build it in code.

**Option A — read settings from a `.env` file path** (library parses the file; process `$_ENV` is merged so exported variables override the file):

```
