PHPackages                             vartruexuan/yii-pay - 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. vartruexuan/yii-pay

ActiveLibrary[Payment Processing](/categories/payments)

vartruexuan/yii-pay
===================

yii版本支付拓展包(alipay、wechat..)

v1.0.0(1y ago)244MITPHPPHP ^7.4||^8.0

Since Oct 23Pushed 8mo agoCompare

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

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

yii-pay
=======

[](#yii-pay)

[![php](https://camo.githubusercontent.com/4ca5ffd1591ad666f8827baba359ea084cb3d9cf4a7262c4be08c11cc23418fc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e34253743253545382e302d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://github.com/php/php-src)[![Latest Stable Version](https://camo.githubusercontent.com/9a066e5815097b256ad64012d6b851e7bb96904331db88d4fc3be8bd39318b84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766172747275657875616e2f7969692d706179)](https://packagist.org/packages/vartruexuan/yii-pay)[![License](https://camo.githubusercontent.com/1efd7281c3602aa38e8c48675e936e128151846ebd2f4609f410eebb3615745b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f766172747275657875616e2f7969692d706179)](https://github.com/vartruexuan/yii-pay)

概述
==

[](#概述)

yii版支付组件

- 基于组件 [yansongda/pay](https://github.com/yansongda/pay)

组件能力
----

[](#组件能力)

- 支付宝支付
- 微信支付
- 银联支付
- 抖音支付 (&gt;=3.7.9)
- 江苏银行e融支付 (&gt;=3.7.7)

安装
==

[](#安装)

- 安装组件

```
composer require vartruexuan/yii-pay
```

使用
--

[](#使用)

```
\Yii::$app->pay->wechat(); // 微信
\Yii::$app->pay->alipay();// 支付宝
\Yii::$app->pay->unipay();// 银联
\Yii::$app->pay->jsb();// 江苏银行e融支付 (>=3.7.7)
\Yii::$app->pay->douyin();// 抖音(>=3.7.9)
// 微信
\Yii::$app->pay->wechat()->scan($order); // 微信扫码支付
\Yii::$app->pay->wechat()->app($order); // app支付
\Yii::$app->pay->wechat()->mini($order); // 小程序支付
\Yii::$app->pay->wechat()->mp($order); // 公众号支付

\Yii::$app->pay->wechat()->wap($order); // H5支付
\Yii::$app->pay->wechat()->h5($order); // H5支付 (>=3.6.0)
```

- 单例模式

```
\vartruexuan\pay\Pay::instance()->setConfig($config)->wechat();
// ...
```

### 配置

[](#配置)

- 配置组件 `components`

```
[
    'components' => [
        // 支付组件
        'pay' => [
            'class' => 'vartruexuan\pay\Pay',
            'config' => [
                'wechat' => [
                    'default' => [
                        // 必填-商户号，服务商模式下为服务商商户号
                        // 可在 https://pay.weixin.qq.com/ 账户中心->商户信息 查看
                        'mch_id' => '',
                        // 选填-v2商户私钥
                        'mch_secret_key_v2' => '',
                        // 必填-v3 商户秘钥
                        // 即 API v3 密钥(32字节，形如md5值)，可在 账户中心->API安全 中设置
                        'mch_secret_key' => '',
                        // 必填-商户私钥 字符串或路径
                        // 即 API证书 PRIVATE KEY，可在 账户中心->API安全->申请API证书 里获得
                        // 文件名形如：apiclient_key.pem
                        'mch_secret_cert' => '',
                        // 必填-商户公钥证书路径
                        // 即 API证书 CERTIFICATE，可在 账户中心->API安全->申请API证书 里获得
                        // 文件名形如：apiclient_cert.pem
                        'mch_public_cert_path' => '',
                        // 必填-微信回调url
                        // 不能有参数，如?号，空格等，否则会无法正确回调
                        'notify_url' => 'https://yansongda.cn/wechat/notify',
                        // 选填-公众号 的 app_id
                        // 可在 mp.weixin.qq.com 设置与开发->基本配置->开发者ID(AppID) 查看
                        'mp_app_id' => '2016082000291234',
                        // 选填-小程序 的 app_id
                        'mini_app_id' => '',
                        // 选填-app 的 app_id
                        'app_id' => '',
                        // 选填-服务商模式下，子公众号 的 app_id
                        'sub_mp_app_id' => '',
                        // 选填-服务商模式下，子 app 的 app_id
                        'sub_app_id' => '',
                        // 选填-服务商模式下，子小程序 的 app_id
                        'sub_mini_app_id' => '',
                        // 选填-服务商模式下，子商户id
                        'sub_mch_id' => '',
                        // 选填-微信平台公钥证书路径, optional，强烈建议 php-fpm 模式下配置此参数
                        'wechat_public_cert_path' => [
                            '45F59D4DABF31918AFCEC556D5D2C6E376675D57' => __DIR__ . '/Cert/wechatPublicKey.crt',
                        ],
                        // 选填-默认为正常模式。可选为： MODE_NORMAL, MODE_SERVICE
                        'mode' => Pay::MODE_NORMAL,
                    ]
                ],
            ],

        ],
    ]
];
```

### 日志

[](#日志)

```
[
    'components'=>[
    'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'info', 'warning'],
                /*'categories' => [
                    // 过滤指定分类
                    'vartruexuan*',
                ],*/
                // $_GET，$_POST，$_FILES，$_COOKIE，$_SESSION 和 $_SERVER
                'logVars' => [],
            ],
           ]
    ]
]
```

### 具体文档版本差异参考 [yansongda/pay](https://pay.yansongda.cn/docs/v3/)

[](#具体文档版本差异参考-yansongdapay)

License
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance49

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

567d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9845d441ce163b641f66e392752a334a733c14697303da398bb02437c3a9d1b2?d=identicon)[vartruexuan](/maintainers/vartruexuan)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vartruexuan-yii-pay/health.svg)

```
[![Health](https://phpackages.com/badges/vartruexuan-yii-pay/health.svg)](https://phpackages.com/packages/vartruexuan-yii-pay)
```

###  Alternatives

[dnetix/redirection

Library to connect with PlacetoPay Checkout service

17123.3k2](/packages/dnetix-redirection)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[amazonpaymentservices/aps-php-sdk

Amazon Payment Services PHP SDK

3114.6k](/packages/amazonpaymentservices-aps-php-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)
