PHPackages                             anhao/payment-hub-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. [Payment Processing](/categories/payments)
4. /
5. anhao/payment-hub-client

ActiveLibrary[Payment Processing](/categories/payments)

anhao/payment-hub-client
========================

Payment Hub PHP SDK

v0.1.0(today)00MITPHPPHP ^8.1

Since Jun 20Pushed todayCompare

[ Source](https://github.com/anhao/payment-hub-php)[ Packagist](https://packagist.org/packages/anhao/payment-hub-client)[ Docs](https://github.com/anhao/payment-hub-php)[ RSS](/packages/anhao-payment-hub-client/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Payment Hub PHP SDK
===================

[](#payment-hub-php-sdk)

Composer 包名：`anhao/payment-hub-client`

开源仓库：`https://github.com/anhao/payment-hub-php`

许可证：MIT

安装
--

[](#安装)

```
composer require anhao/payment-hub-client
```

本仓库内开发测试：

```
composer dump-autoload
composer test
```

创建收银台支付
-------

[](#创建收银台支付)

```
use Anhao\PaymentHub\Client;

$client = new Client(
    baseUrl: 'https://payhub.alapi.cn',
    appKey: 'your_app_key',
    appSecret: 'your_app_secret',
);

$response = $client->createPayment([
    'out_order_no' => 'WPUSH202606180001',
    'title' => 'WPUSH 年费会员',
    'amount' => 9900,
    'mode' => 'CASHIER',
    // 微信 JSAPI / 小程序收银台支付时传入；普通扫码支付可不传。
    'extra' => Client::wechatPayContext('wx-mini-appid', 'openid-from-miniapp'),
]);

header('Location: '.$response['data']['payment_url']);
```

`Client::wechatPayContext()` 会生成 `extra.pay_context.wechat`，Hub 会用其中的 `appid` 过滤支付账户，并在微信 JSAPI / 小程序下单时传递 `openid`。

直连支付宝当面付
--------

[](#直连支付宝当面付)

```
$response = $client->createPayment([
    'out_order_no' => 'WPUSH202606180002',
    'title' => 'WPUSH 年费会员',
    'amount' => 9900,
    'mode' => 'DIRECT',
    'provider' => 'alipay',
    'method' => 'FACE_TO_FACE',
]);

$codeUrl = $response['data']['code_url'];
```

查询和退款
-----

[](#查询和退款)

```
$payment = $client->getPayment('PH20260618ABC123XYZ0');

$refund = $client->createRefund([
    'payment_no' => 'PH20260618ABC123XYZ0',
    'out_refund_no' => 'WPUSH_REFUND_001',
    'amount' => 9900,
    'reason' => '用户申请退款',
]);
```

Webhook 验签
----------

[](#webhook-验签)

```
use Anhao\PaymentHub\Webhook;

$body = file_get_contents('php://input') ?: '';

if (! Webhook::verifySignature(getallheaders(), $body, 'your_app_secret')) {
    http_response_code(401);
    exit('invalid signature');
}

$payload = json_decode($body, true);

// 幂等处理 payment.success / refund.success ...

echo json_encode(['code' => 0]);
```

支付完成跳转验签
--------

[](#支付完成跳转验签)

```
use Anhao\PaymentHub\Signature;

if (! Signature::verifyReturnUrl($_GET, 'your_app_secret')) {
    http_response_code(401);
    exit('invalid signature');
}

// 仅用于页面展示或定位订单；最终发货仍以 Webhook / 主动查询为准。
$paymentNo = $_GET['payment_no'] ?? '';
```

> 生产环境默认地址：`https://payhub.alapi.cn`

###  Health Score

36

—

LowBetter than 80% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22a45c91e7343a20031eb47d6f02fcb59a5a0d5f37936124242cff4730ca5af5?d=identicon)[Alone88](/maintainers/Alone88)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/anhao-payment-hub-client/health.svg)

```
[![Health](https://phpackages.com/badges/anhao-payment-hub-client/health.svg)](https://phpackages.com/packages/anhao-payment-hub-client)
```

###  Alternatives

[omnipay/coinbase

Coinbase driver for the Omnipay payment processing library

18570.2k1](/packages/omnipay-coinbase)[oxid-esales/amazon-pay-module

AmazonPay module for OXID

1824.3k](/packages/oxid-esales-amazon-pay-module)[yenepay/php-sdk

YenePay SDK for PHP

112.7k](/packages/yenepay-php-sdk)

PHPackages © 2026

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