PHPackages                             vochina/heepay-customer - 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. vochina/heepay-customer

ActiveLibrary[Payment Processing](/categories/payments)

vochina/heepay-customer
=======================

汇付宝支付-商户入驻资料-国密SM2签名PHP扩展

0.0.2(2y ago)069MITPHP

Since Jun 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vochina/heepay-customer)[ Packagist](https://packagist.org/packages/vochina/heepay-customer)[ RSS](/packages/vochina-heepay-customer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Heepay Customer
===============

[](#heepay-customer)

汇付宝支付商户入驻资料国密SM2签名和验签PHP扩展

安装
--

[](#安装)

```
$ composer require vochina/heepay-customer -vvv
```

配置
--

[](#配置)

在使用本扩展之前，请自己生成国密SM2私钥和公钥，可以使用[支付宝开放平台开发助手](https://opendocs.alipay.com/open/02kipl?pathHash=c5b1c31d)一键生成，生成的格式Tests文件夹有示例

使用
--

[](#使用)

```
use Vochina\HeepayCustomer\HeepayCustomer;

$sm2PrivateKeyPath = __DIR__ . '/test_sm2_private_key.pem';
$sm2publicKeyPath = __DIR__ . '/test_sm2_public_key.pem';
$handler = new HeepayCustomer($sm2PrivateKeyPath, $sm2publicKeyPath);
```

### 签名方法 (注意：汇付宝要求签名前把请求参数格式化，请调用parameterText方法格式化后再签名)

[](#签名方法-注意汇付宝要求签名前把请求参数格式化请调用parametertext方法格式化后再签名)

```
$result = $handler->sign('This is the string that needs to be signed!');
```

示例：

```
签名结果： nUjieZmUOhuEc6+rjy5EqetXRSlM9Nk3nZgv1Dz6P6CLrEt72TsOSLrWT/HIvFwBmsxgc5tHydUyEXXqeSobjA==

```

### 验证签名

[](#验证签名)

```
$verify_result = $handler->verifySign($sign_content, $sign);
```

示例：

```
验证签名结果： bool(true)

```

### 请求参数格式化

[](#请求参数格式化)

```
$data = [
   "app_id" => "100000000000000",
        "method" => "customer.entry.apply",
        "version" => "1.0",
        "charset" => "utf-8",
        "format" => "json",
        "timestamp" => date('Y-m-d H:i:s'),
        "notify_url" => "https://www.google.com",
        "sign_type" => "SM2",
        "biz_content" => [
             "apply_no" => "1233231212212",
        ],
   ];
$sm2PrivateKeyPath = __DIR__ . '/test_sm2_private_key.pem';
$sm2publicKeyPath = __DIR__ . '/test_sm2_public_key.pem';
$handler = new HeepayCustomer($sm2PrivateKeyPath, $sm2publicKeyPath);
$sign_text = $handler->parameterText($data, '&', true, null);
var_dump($sign_text);
```

### 在 Laravel 中使用

[](#在-laravel-中使用)

在 Laravel 中使用也是同样的安装方式，配置写在 `config/services.php` 中：

```
    .
    .
    .
     'heepay-customer' => [
        'sm2PrivateKeyPath' => storage_path('cert/sm2_private_key.pem'),
        'sm2publicKeyPath' => storage_path('cert/sm2_public_key.pem'),
    ],
```

然后把key文件复制到相应的文件夹下

可以用两种方式来获取 `Vochina\HeepayCustomer\HeepayCustomer` 实例：

#### 方法参数注入

[](#方法参数注入)

```
    .
    .
    .
    public function edit(HeepayCustomer $HeepayCustomer)
    {
        $response = $HeepayCustomer->sign('This is the string that needs to be signed!');
    }
    .
    .
    .
```

#### 服务名访问

[](#服务名访问)

```
    .
    .
    .
    public function edit()
    {
        $response = app('heepay-customer')->sign('This is the string that needs to be signed!');
    }
    .
    .
    .
```

### 测试

[](#测试)

```
./vendor/bin/phpunit --filter verifySign
```

License
-------

[](#license)

MIT

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

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

Every ~65 days

Total

2

Last Release

1003d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/70c8139357803b0d0209d53e4f2e0d73dcc77b5d6df8aea2102c1be1e8e83913?d=identicon)[vochina](/maintainers/vochina)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vochina-heepay-customer/health.svg)

```
[![Health](https://phpackages.com/badges/vochina-heepay-customer/health.svg)](https://phpackages.com/packages/vochina-heepay-customer)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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