PHPackages                             hedeqiang/yizhifu - 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. hedeqiang/yizhifu

ActiveLibrary[Payment Processing](/categories/payments)

hedeqiang/yizhifu
=================

首信易支付 SDK for PHP

v2.0.4(3y ago)643[2 issues](https://github.com/hedeqiang/yizhifu/issues)MITPHPPHP &gt;=7.1

Since May 27Pushed 3y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (8)Versions (14)Used By (0)

首信易支付 SDK for PHP
=================

[](#首信易支付-sdk-for-php)

[![PHP Version Require](https://camo.githubusercontent.com/b78ce2451929a0d4805399dd4371050f49636a4d473c5d23917c6eadd2edfee5/687474703a2f2f706f7365722e707567782e6f72672f686564657169616e672f706179656173652f726571756972652f706870)](https://packagist.org/packages/hedeqiang/payease)[![Latest Stable Version](https://camo.githubusercontent.com/03acf9dfd4a82898495eedf70698f38b3e3a6e154b88686c48901273466c34dc/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f706179656173652f76)](//packagist.org/packages/hedeqiang/payease)[![Total Downloads](https://camo.githubusercontent.com/2d9593cb3dcbcc3369957a7df56961bd21a9b7d3d3af51b31e3b8965a531fa1e/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f706179656173652f646f776e6c6f616473)](//packagist.org/packages/hedeqiang/payease)[![Latest Unstable Version](https://camo.githubusercontent.com/9765ce50e1db5083f00e2052633d08080cf138800a5a4aad61f2cb34cf583ca5/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f706179656173652f762f756e737461626c65)](//packagist.org/packages/hedeqiang/payease)[![License](https://camo.githubusercontent.com/bcc00995f83ee9e270cbf5182c75378ea90dc5dfef0f37a7607b5dcb44a431a3/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f706179656173652f6c6963656e7365)](//packagist.org/packages/hedeqiang/payease)[![Tests](https://github.com/hedeqiang/payease/actions/workflows/test.yml/badge.svg)](https://github.com/hedeqiang/payease/actions/workflows/test.yml)

参考文档 [首信易支付](https://demo.yizhifubj.com/Development/showdoc-master/web/#/5?page_id=242) 、[首信易支付](https://www.payeasenet.com/)

环境需求
----

[](#环境需求)

- PHP &gt;= 7.1
- [Composer](https://getcomposer.org/) &gt;= 2.0

支持主流框架 `Laravel`、`Hyperf`、`Yii2` 快捷使用，具体使用方法请滑到底部

Installing
----------

[](#installing)

```
$ composer require hedeqiang/payease -vvv
```

Usage
-----

[](#usage)

```
require __DIR__ .'/vendor/autoload.php';
use Hedeqiang\PayEase\Pay;
$app = new Pay([
    'privateKey' => '/parth/client.pfx',
    'publicKey'  => 'path/test.cer',  // 注意： 此公钥为首信易的公钥、并非上传到商户后台的公钥！！！
    'merchantId' => '890000593',
    'password'   => '123456',
]);
```

> 本 SDK 已经处理好 hmac 签名，用户不需要传递此参数，`merchantId` 可传可不传,聚合宝支付时 二级子商户 必须传递 `merchantId` 代表 子商户，`partnerId` 为主商户

### 立即下单

[](#立即下单)

```
$uri = 'onlinePay/order';

$params = [
    "callbackUrl"    => "https://demo.5upay.com/sdk/callback",
    "clientIp"       => "10.101.10.10",
    "hmac"           => null,
    "notifyUrl"      => "https://demo.5upay.com/sdk/onlinepay/notify",
    "orderAmount"    => "1",
    "orderCurrency"  => "CNY",
    "payer"          => new \stdClass(),
//    "payer" => [
//        "bankCardNum" =>"6217000xxxxx",
//        "email" =>"laravel_code@163.com",
//        "idNum" =>"xxxx",
//        "idType" =>"IDCARD",
//        "name" =>"xxx",
//        "phoneNum" =>"xxx"
//    ],
    // "paymentModeCode" =>"BANK_CARD-B2C-ICBC-P2P",
    "productDetails" => [
        [
            "amount"      => "1",
            "description" => "黑色64G",
            "name"        => "IPHONE6",
            "quantity"    => "100",
            "receiver"    => "张三"
        ]
    ],
    "remark"         => "备注",
    "requestId"      => time(),
    "timeout"        => "10"
];
$app->request($uri,$params)
```

#### 立即下单返回示例

[](#立即下单返回示例)

> 客户端 使用 redirectUrl 发起 get 请求即可发起收银台支付

```
{
    "redirectUrl": "https://payment.5upay.com/receipt/index/db50e5bac76e40b18cbd5da1ce238cca",
    "merchantId": "890000593",
    "requestId": "1653644302",
    "hmac": "F9apHKePPFzC3Xp9Dxafd8m0/NhDLuxlwCqxTZtDBqtFyoA31pRlsulOxYDGVXI0o73XUUtzfLpu+ghGo1CQM+r6wqp/vE0UCv7CYWlay5de0A7MmtKpavgDengt7mvht9RL5cmvZS7RkYEsEde84n21LNxscjlRM2kl8AGUupqzDh0nbwgkzfOBeGKPjTvklqFgrjdPkgBhxDP9QZxcQvnD4c4vML27sjqA2FaUxxl2qj9SGPFkzGQ/slX9zMfWbDRWnmvtDF9j0/Uq/LshaBlAa34zUcWumed357Tcmwqe6poIQtThn5clBtBbH9c5ZQBZYkCis5nes+MZVKr5Gw==",
    "paymentOrderId": "db50e5bac76e40b18cbd5da1ce238cca",
    "status": "REDIRECT"
}
```

### 回调通知

[](#回调通知)

```
$result = $app->handleNotify();
// TODO

return 'SUCCESS' ; // retuen 'Fail';
```

#### 回调返回示例

[](#回调返回示例)

> 正常情况下 返回 array，支付成功

```
 array (
  'cardType' => 'CREDIT_CARD',
  'clearingOrg' => 'UNION_PAY',
  'completeDateTime' => '2022-05-27 16:31:31',
  'merchantId' => '890000593',
  'orderAmount' => '1',
  'orderCurrency' => 'CNY',
  'paymentModeAlias' => 'WAP',
  'realBankRequestNumber' => '4itnydmtesuN',
  'realBankSerialNumber' => '862205271630378302598',
  'remark' => '备注',
  'requestId' => '1653640218',
  'serialNumber' => 'c7117326f3ab4d4c94bf5755c38e1793',
  'status' => 'SUCCESS',
  'totalRefundAmount' => '0',
  'totalRefundCount' => '0',
)
```

> ps: 注意未支付、取消支付也是有回调的，也会发到你的回调 URL 地址上

#### 未支付、取消支付回调示例

[](#未支付取消支付回调示例)

```
array (
  'completeDateTime' => '2022-05-27 16:38:34',
  'merchantId' => '890000593',
  'orderAmount' => '1',
  'orderCurrency' => 'CNY',
  'remark' => '备注',
  'requestId' => '1653640093',
  'serialNumber' => '32d0e64a43df4561973e47733ffd9f02',
  'status' => 'CANCEL',
  'totalRefundAmount' => '0',
  'totalRefundCount' => '0',
)
```

### 查询订单

[](#查询订单)

```
$uri = "onlinePay/query";
$params = [
    'merchantId' => '890000593',
    'requestId' => '1653659465'
];

$sreult = $app->request($uri,$params);
```

### 二级商户入网

[](#二级商户入网)

```
$uri = 'serviceprovider/declaration/declare';

$params = [
    'requestId'           => time(),
    'operationType'       => 'CREATE',
    'notifyUrl'           => 'https://www.5upay.com/callback.action?test=test',
    'extendedParameters'  => 'autoReview:FALSE,sendActiveEmail:TRUE',
    'baseInfo'            => [
        'signedType'              => 'BY_SPLIT_BILL',
        'signedName'              => 'xxx',  //签约名
        'registerRole'            => 'NATURAL_PERSON',
        'signedShorthand'         => 'xxx',
        'businessAddressProvince' => '110000', //经营地址省
        'businessAddressCity'     => '110100', //经营地址市
        'businessAddressArea'     => '110106', // 经营地址区
        'businessAddress'         => '北京市', //经营地址
        'contactName'             => 'xxx', // 联系人姓名
        'contactEmail'            => 'xxx@163.com', //联系人邮箱
        'contactPhone'            => 'xxx',// 联系人电话
        //'businessClassification'  => 'INTERNAL_TESTING_01', //业务分类
        'desireAuth'              => 'DESIRE_MOBILEINFO', //开户意愿核实类型

    ],
    'bankCardInfo'        => [
        'accountName'      => 'xxx', // 开户名称
        'bankCardNo'       => 'xxx',
        'provinceCode'     => '130000',
        'cityCode'         => '130100',
        'liquidationType'  => 'SETTLE', //清算方式
        'accountType'      => 'PRIVATE', //结算银行卡属性
        'withdrawRateType' => 'SINGLE',
    ],
    'desireAuthInfo'      => [
        'legalPersonName'    => 'xxx', //法人姓名
        'legalPersonIdNo'    => 'xxx', // 法人身份证号
        'legalPersonPhoneNo' => 'xxx', // 法人手机号
    ],
    'certificateInfo'     => [
        'legalPersonName'         => 'xxx',
        'profession'              => '1',// 法人职业
        'legalPersonIdType'       => 'IDCARD',
        'legalPersonIdNo'         => 'xxx',
        'legalIdCardProsPath'     => '/serviceprovider/TestData/111.jpg', //法人证件人像面路径
        'legalIdCardConsPath'     => '/serviceprovider/TestData/111.jpg', //法人证件国徽面路径
        'holdingIdCardPath'       => '/serviceprovider/TestData/111.jpg', //法人手持证件照
        'legalPersonBankCardPath' => '/serviceprovider/TestData/111.jpg', //法人银行卡图影印件路径
        'legalPersonPhone'        => 'xxx'
    ],
    'certificateContacts' => [
        [
            'name'   => 'xxx',
            'idType' => 'IDCARD',
            'idNo'   => 'xxx',
        ]
    ],
    'contractInfo'        => [
//                'receiverAddress' => 'c',
//                'receiverName'    => 'xxx',
//                'receiverPhone'   => 'xxx',
        'contractType'    => 'ELECTRON',
    ],
//            'paymentProfiles'    => [
//                [
//                    'paymentMode' => 'B2C',
//                    'feeType'     => 'SINGLE',
//                ]
//
//            ],
//

];

return $app->request($uri, $params);
```

在 Laravel 中使用
-------------

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

#### 发布配置文件

[](#发布配置文件)

```
php artisan vendor:publish --tag=payease
or
php artisan vendor:publish --provider="Hedeqiang\PayEase\ServiceProvider"
```

##### 编写 .env 文件

[](#编写-env-文件)

```
PAYEASE_PRIVATIVE_KEY=
PAYEASE_PUBLIC_KEY=
PAYEASE_MERCHAN_ID=
PAYEASE_PASSWORD=

```

### 使用

[](#使用)

#### 服务名访问

[](#服务名访问)

```
public function index()
{
    return app('pay')->request($uri,$params);
}
```

#### Facades 门面使用(可以提示)

[](#facades-门面使用可以提示)

```
use Hedeqiang\PayEase\Facades\Pay;

public function index()
{
   return Pay::pay()->request($uri,$params)
}

public function notify(Request $request)
{
   $result = Pay::pay()->handleNotify();
}
```

在 Hyperf 中使用
------------

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

#### 发布配置文件

[](#发布配置文件-1)

```
php bin/hyperf.php vendor:publish hedeqiang/payease
```

##### 编写 .env 文件

[](#编写-env-文件-1)

```
PAYEASE_PRIVATIVE_KEY=
PAYEASE_PUBLIC_KEY=
PAYEASE_MERCHAN_ID=
PAYEASE_PASSWORD=

```

#### 使用

[](#使用-1)

```
get(Pay::class)->request($uri,$parmas);

// 回调
$response = ApplicationContext::getContainer()->get(Pay::class)->handleNotify();
```

在 Yii2 中使用
----------

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

#### 配置

[](#配置)

在 `Yii2` 配置文件 `config/main.php` 的 `components` 中添加:

```
'components' => [
    // ...
    'pay' => [
        'class' => 'Hedeqiang\PayEase\YiiPay',
        'options' => [
            'privateKey' => '/private.pfx',
            'publicKey' => '//server.cer',
            'merchantId' => '890000593',
            'password' => '123456',
        ],
    ],
    // ...
]
```

#### 使用

[](#使用-2)

```
Yii::$app->response->format = Response::FORMAT_JSON;

// 请求
$results = Yii::$app->pay->getPay()->request($uri,$params);
// 回调
$results = Yii::$app->pay->getPay()->handleNotify();
```

Project supported by JetBrains
------------------------------

[](#project-supported-by-jetbrains)

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

[![](https://camo.githubusercontent.com/3cf726e7cdadba47755b7f7ea4227945a92a2fa48aadf4a2573140ec6501c989/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f6a625f6265616d2e737667)](https://www.jetbrains.com/?from=https://github.com/hedeqiang)

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/hedeqiang/payease/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/hedeqiang/payease/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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 ~2 days

Total

13

Last Release

1412d ago

Major Versions

v1.0.8 → v2.0.02022-06-09

PHP version history (2 changes)v1.0.0PHP &gt;=7.0

v1.0.6PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ac33cc87fe5ba7f0b8791f5b3453501e83b55ec9a5a209728817ff119635a72?d=identicon)[hedeqiang](/maintainers/hedeqiang)

---

Top Contributors

[![hedeqiang](https://avatars.githubusercontent.com/u/31909061?v=4)](https://github.com/hedeqiang "hedeqiang (44 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (4 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hedeqiang-yizhifu/health.svg)

```
[![Health](https://phpackages.com/badges/hedeqiang-yizhifu/health.svg)](https://phpackages.com/packages/hedeqiang-yizhifu)
```

###  Alternatives

[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)

PHPackages © 2026

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