khalesartem/mtls-hmac-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

khalesartem/mtls-hmac-client

最新稳定版本:v1.0.1

Composer 安装命令:

composer require khalesartem/mtls-hmac-client

包简介

PHP 8.2+ payment gateway client with mTLS transport security and HMAC signatures. Supports automatic ENV configuration fallback.

README 文档

README

Install

composer require khalesartem/mtls-hmac-client:dev-main

Usage

use Payment\MtlsHmac\Client\GatewayClient;
use Payment\MtlsHmac\Config\GatewayConfig;

$config = new GatewayConfig(
    hmacSecret: 'my-secret',
    certPath: '/path/client-cert.pem',
    keyPath: '/path/client-key.pem',
    keyPassphrase: 'badssl.com', // optional
    verify: true,
    hmacAlgo: 'sha256',
    signatureHeader: 'X-Signature',
);

$client = new GatewayClient($config);
$response = $client->get('https://client.badssl.com/', [
    'transaction_id' => '12345',
    'amount' => '99.99',
    'currency' => 'USD',
]);

echo $response->getStatusCode();
echo (string) $response->getBody();

Run tests

composer install
./vendor/bin/phpunit

Integration test uses .env (copy from .env.example) and will be skipped if required variables/files are missing.

Environment Variables

Configure these variables in your .env file:

GATEWAY_ENDPOINT=https://your-gateway.com/api
GATEWAY_HMAC_SECRET=your-hmac-secret
GATEWAY_CERT_PATH=/path/to/client-cert.pem
GATEWAY_KEY_PATH=/path/to/client-key.pem
GATEWAY_KEY_PASSPHRASE=optional-passphrase
GATEWAY_VERIFY=true
GATEWAY_HMAC_ALGO=sha256
GATEWAY_SIGNATURE_HEADER=X-Signature

Example Script

Run the included example:

php example.php

This demonstrates both environment-based and manual configuration approaches.

统计信息

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

GitHub 信息

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

其他信息

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