承接 marcohefti/request-network-api-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

marcohefti/request-network-api-client

Composer 安装命令:

composer require marcohefti/request-network-api-client

包简介

Request Network REST API client for PHP.

README 文档

README

Latest Version Tests PHP Version License Total Downloads

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

Install via Composer:

composer require marcohefti/request-network-api-client

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?

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

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

  • PHP: >= 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

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

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

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 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).

marcohefti/request-network-api-client 适用场景与选型建议

marcohefti/request-network-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「payments」 「API-Client」 「blockchain」 「invoicing」 「psr-7」 「php-client」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 marcohefti/request-network-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 marcohefti/request-network-api-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 marcohefti/request-network-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 22
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-11