PHPackages                             marcohefti/request-network-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. marcohefti/request-network-api-client

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

marcohefti/request-network-api-client
=====================================

Request Network REST API client for PHP.

v0.6.2(2mo ago)01MITPHPPHP ^8.2CI passing

Since Dec 11Pushed 2mo agoCompare

[ Source](https://github.com/marcohefti/request-network-api-client-php)[ Packagist](https://packagist.org/packages/marcohefti/request-network-api-client)[ Docs](https://github.com/marcohefti/request-network-api-client-php)[ RSS](/packages/marcohefti-request-network-api-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (32)Versions (9)Used By (0)

Request Network API Client (PHP)
================================

[](#request-network-api-client-php)

[![Latest Version](https://camo.githubusercontent.com/145b7e7d8e2f41f74b3dadcedc64c2e26ce4f28609a37bbbaca88f1f4e68e5f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6172636f68656674692f726571756573742d6e6574776f726b2d6170692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marcohefti/request-network-api-client)[![Tests](https://camo.githubusercontent.com/a5303ce0631c430bcf8aedc40d3c4d62cfa20f672ec48433234002c7aed4e229/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6172636f68656674692f726571756573742d6e6574776f726b2d6170692d636c69656e742d7068702f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/marcohefti/request-network-api-client-php/actions/workflows/tests.yml)[![PHP Version](https://camo.githubusercontent.com/710166db50cc2e20850ecece8be66a5f63f14011428c6617850089d2c1061075/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6172636f68656674692f726571756573742d6e6574776f726b2d6170692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marcohefti/request-network-api-client)[![License](https://camo.githubusercontent.com/7dcf46dd525cbb3061dc4787c9ce8befac6ae26099df15e18cd35ed143af2208/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6172636f68656674692f726571756573742d6e6574776f726b2d6170692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/4224f4dbbf594f899fe069cce6ddd9376f9de823bfcc10f5d82f5fd4c6b931b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6172636f68656674692f726571756573742d6e6574776f726b2d6170692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marcohefti/request-network-api-client)

PHP client for the Request Network hosted REST API. It mirrors the TypeScript client's surface so WooCommerce and other PHP runtimes can talk to Request without a Node bridge.

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

[](#installation)

Install via Composer:

```
composer require marcohefti/request-network-api-client
```

Quick start
-----------

[](#quick-start)

Minimal example using the static factory:

```
use RequestSuite\RequestPhpClient\RequestClient;

$client = RequestClient::create([
    'apiKey' => $_ENV['REQUEST_API_KEY'],
]);

// Create a new payment request
$request = $client->requests()->create([
    'amount' => '100',
    'invoiceCurrency' => 'USD',
    'paymentCurrency' => 'ETH-sepolia-sepolia',
    'payee' => '0x0000000000000000000000000000000000000000',
    'reference' => 'order-123',
]);

$requestId = $request['requestId'] ?? null;

// Search for payments
$payments = $client->payments()->search(['requestId' => $requestId]);
```

Why Use This Client?
--------------------

[](#why-use-this-client)

Instead of manually building HTTP requests and handling errors, this client provides:

- **Type Safety**: Strict type hints and PHPDoc throughout (PHPStan level 7 clean)
- **Automatic Retries**: Exponential backoff with jitter for transient failures
- **Schema Validation**: Runtime validation against OpenAPI specs (optional)
- **Webhook Security**: Timing-safe signature verification with secret rotation support
- **Error Handling**: Rich exception hierarchy with correlation IDs and retry headers
- **Logging**: Automatic credential redaction in PSR-3 compatible logs
- **Testing**: Built-in FakeHttpAdapter for easy unit testing

**Before vs After:** See `docs/BEFORE-AFTER.md` for side-by-side code comparisons showing how this client simplifies common Request Network API operations.

Documentation
-------------

[](#documentation)

- **[Architecture](docs/ARCHITECTURE.md)** - System design and internals
- **[Testing](docs/TESTING.md)** - Test strategy, coverage, and validation
- **[HTTP Client](docs/HTTP-CLIENT.md)** - HTTP adapter, retry behavior, error handling
- **[Webhooks](docs/WEBHOOKS.md)** - Signature verification, middleware, event handlers
- **[Before/After](docs/BEFORE-AFTER.md)** - Code comparisons showing client benefits
- **[Troubleshooting](docs/TROUBLESHOOTING.md)** - Common issues and solutions
- **[Publishing](docs/PUBLISHING.md)** - Release checklist

What this client covers
-----------------------

[](#what-this-client-covers)

- PHP-first `RequestClient` with facades for requests (including request listing), payouts, payments, secure payments, payer/compliance (v1+v2), client IDs, currencies (v1+v2), and legacy pay.
- Shared HTTP pipeline with retry, logging, and runtime validation driven by the synced OpenAPI spec.
- Webhook utilities: signature verifier, typed event objects, parser, dispatcher, PSR‑15 middleware, and testing helpers that mirror the TypeScript webhook module.
- Env‑based factory for backend and WooCommerce usage, with PSR‑4 autoloading under `RequestSuite\RequestPhpClient`.

Compatibility
-------------

[](#compatibility)

- **PHP:** &gt;= 8.2
- **Frameworks:** Designed for PSR‑15 stacks (e.g., WooCommerce, Laravel/Symfony via adapters)
- **HTTP Clients:** Any PSR-18 compatible client (Guzzle, Symfony HttpClient, etc.) or built-in cURL adapter

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

[](#development)

Common commands:

- `composer test` – PHPUnit suites.
- `composer stan` – PHPStan analysis.
- `composer cs` / `composer lint` – coding standards (if configured).
- `composer update:spec` – sync OpenAPI + webhook fixtures from the contracts package.

See `docs/TESTING.md` and `docs/ARCHITECTURE.md` for the full testing strategy, spec sync flow, and domain layout.

Webhooks
--------

[](#webhooks)

The webhook module provides secure signature verification, typed event objects, and PSR-15 middleware:

```
use RequestSuite\RequestPhpClient\Webhooks\Events\PaymentConfirmedEvent;
use RequestSuite\RequestPhpClient\Webhooks\WebhookParser;

$parser = new WebhookParser();
$parsed = $parser->parse([
    'rawBody' => (string) $request->getBody(),
    'headers' => $request,
    'secret' => [$_ENV['REQUEST_WEBHOOK_SECRET']],
]);

if ($parsed->event() instanceof PaymentConfirmedEvent) {
    $data = $parsed->event()->data();
    $requestId = $data->string('requestId');
    // Handle payment confirmation
}
```

**Features:**

- Timing-safe signature verification with secret rotation support
- Typed event classes for all webhook types
- PSR-15 middleware for framework integration
- Event dispatcher for handler registration
- Testing helpers for unit tests

See `docs/WEBHOOKS.md` and `examples/webhook-handler-middleware.php` for complete webhook integration examples.

Logging &amp; redaction
-----------------------

[](#logging--redaction)

Pass either a callable `(string $event, array $context) => void` or a PSR-3 `LoggerInterface` via `RequestClient::create(['logger' => ...])` to receive lifecycle events (`request:start`, `request:response`, `request:error`). When you supply a PSR-3 logger, the client automatically wraps it with `Logging\PsrLoggerAdapter`, which redacts sensitive fields (API keys, Authorization headers, webhook signatures) via `Logging\Redactor` before handing context to your logger:

```
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use RequestSuite\RequestPhpClient\RequestClient;

$logger = new Logger('request-network-api-client');
$logger->pushHandler(new StreamHandler('php://stdout'));

$client = RequestClient::create([
    'apiKey' => $_ENV['REQUEST_API_KEY'],
    'logger' => $logger,
    'logLevel' => 'info',
]);
```

`WebhookMiddleware` shares the same logger plumbing and emits `webhook:verified`, `webhook:dispatched`, and `webhook:error` events so you can trace webhook flows without leaking secrets.

Testing harness
---------------

[](#testing-harness)

Unit tests (and downstream consumers) can inject the built-in `Testing\FakeHttpAdapter` to queue responses and assert requests without rolling bespoke stubs:

```
use RequestSuite\RequestPhpClient\Testing\FakeHttpAdapter;

$fake = new FakeHttpAdapter([
    FakeHttpAdapter::jsonResponse(['status' => 'ok']),
]);

$client = RequestClient::create([
    'apiKey' => 'rk_test',
    'httpAdapter' => $fake,
]);

$client->requests()->create([...]);
$fake->assertSent(static fn ($pending) => $pending->method() === 'POST');
```

See `docs/TESTING.md` for the full harness (coverage guard, parity scripts, integration plans).

Composer scripts
----------------

[](#composer-scripts)

- `composer test` - runs PHPUnit using `phpunit.xml.dist`.
- `composer stan` - runs PHPStan static analysis (level 7) using `phpstan.neon.dist`.
- `composer coverage` - prints PHPUnit coverage summary to the terminal.
- `composer cs` - runs PHPCS with PSR-12 + Slevomat rules.
- `composer cs:fix` - auto-fixes code style issues where possible.
- `composer md` - runs PHPMD (codesize/design/unusedcode) with configured thresholds.
- `composer cpd` - runs PHPCPD (copy/paste detection).
- `composer deps:rules` - runs PHPStan dependency rules (architecture contracts).

These are also invoked from the workspace validator (see root `scripts/validate.sh`).

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance94

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Recently: every ~22 days

Total

8

Last Release

60d ago

### Community

Maintainers

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

---

Top Contributors

[![marcohefti](https://avatars.githubusercontent.com/u/30780180?v=4)](https://github.com/marcohefti "marcohefti (31 commits)")

---

Tags

api-clientdefipaymentsphprequest-networkweb3psr-7psr-18paymentsapi clientinvoicingweb3blockchainphp clientcrypto paymentsrequest-network

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marcohefti-request-network-api-client/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[neos/flow

Flow Application Framework

862.0M448](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)[windwalker/framework

The next generation PHP framework.

25639.1k1](/packages/windwalker-framework)[elastic/transport

HTTP transport PHP library for Elastic products

1920.6M7](/packages/elastic-transport)

PHPackages © 2026

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