PHPackages                             tiderjian/qs-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. tiderjian/qs-pay

ActiveLibrary[Payment Processing](/categories/payments)

tiderjian/qs-pay
================

payment package

v0.2.1(5y ago)28391MITPHP

Since Nov 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/quansitech/qs-pay)[ Packagist](https://packagist.org/packages/tiderjian/qs-pay)[ RSS](/packages/tiderjian-qs-pay/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (9)Used By (0)

qspay
=====

[](#qspay)

[![lincense](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)[![Pull request welcome](https://camo.githubusercontent.com/25f2db1404306d6dc01b1ac6e8c70f5f397ea8043dd9584d8dc4bc31b8bfea59/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70722d77656c636f6d652d677265656e2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/25f2db1404306d6dc01b1ac6e8c70f5f397ea8043dd9584d8dc4bc31b8bfea59/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70722d77656c636f6d652d677265656e2e7376673f7374796c653d666c61742d737175617265)

介绍
--

[](#介绍)

银联、微信、支付宝的H5支付场景的接口封装开发包。简化各种不同支付场景的接入和学习成本，统一化接入流程。

安装
--

[](#安装)

```
composer require tiderjian/qs-pay
```

### 微信支付

[](#微信支付)

#### PC

[](#pc)

```
$config = [
    'app_id'             => **************,
    'mch_id'             => **************,
    'key'                => **************,
    'cert_path'          => ***************,
    'key_path'           => ***************,
    'notify_url'         => *************
];

$pay = Qspay::instance('wepay', $config);

$result = $pay->pay([
    'body' => '测试',
    'out_trade_no' => time(),
    'total_fee' => 1
]);

//PC端的场景返回的$result 是一个wx扫码的地址，可将其转成二维码，放在网页让用户打开微信扫码
```

#### 微信端

[](#微信端)

```
$config = [
    'app_id'             => **************,
    'mch_id'             => **************,
    'key'                => **************,
    'cert_path'          => ***************,
    'key_path'           => ***************,
    'notify_url'         => *************
];

$pay = Qspay::instance('wepay', $config);

$result = $pay->pay([
    'body' => '测试',
    'out_trade_no' => time(),
    'total_fee' => 1,
    'openid' => session('test_openid')
]);

******************************
JS调用代码  ，将上面返回的$result传递给js使用

    function onBridgeReady(){
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {$result},
            function(res){
                if(res.err_msg == "get_brand_wcpay_request:ok" ){
                    alert('支付成功');
                    window.location = '/home/index/wxpaysuccess';
                }
                else{
                    alert('支付失败');
                }
            });
    }
    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
        onBridgeReady();
    }

//
```

#### notify

[](#notify)

```
$config = [
    'app_id'             => **************,
    'mch_id'             => **************,
    'key'                => **************,
    'cert_path'          => ***************,
    'key_path'           => ***************
];

$pay = Qspay::instance('wepay', $config);
$pay->notifyHandle(function($notify_param){
    //处理业务逻辑
    //返回 true 表示处理成功
    //返回 错误字符串表示处理失败
});
```

### 支付宝

[](#支付宝)

#### 新版接口 PC AND WAP

[](#新版接口-pc-and-wap)

程序自动判断PC和WAP的使用场景

```
$config = [
    'interface_type' => Qspay\Alipay::ALIPAY_INTERFACE_TYPE_DONATE_NEW,
    // 沙箱模式
    'debug'       => false,
    // 应用ID
    'appid'       => ***************,
    // 支付宝公钥(1行填写)
    'public_key'  => ***************,
    // 应用私钥(1行填写)
    'private_key' => ********************,
    // 支付成功通知地址
    'notify_url'  => ***************,
    // 支付成功后返回的地址
    'return_url' => **********
];

$pay = Qspay::instance('alipay', $config);

echo $pay->pay([
    'out_trade_no' => time(), // 商户订单号
    'total_amount' => '0.01',    // 支付金额
    'subject'      => '支付订单描述', // 支付订单描述
]);
```

#### 新版接口 notify

[](#新版接口-notify)

```
$config = [
    'interface_type' => Qspay\Alipay::ALIPAY_INTERFACE_TYPE_DONATE_NEW,
    // 沙箱模式
    'debug'       => false,
    // 应用ID
    'appid'       => ***************,
    // 支付宝公钥(1行填写)
    'public_key'  => ***************,
    // 应用私钥(1行填写)
    'private_key' => ********************,
    // 支付成功通知地址
    'notify_url'  => ***************
];

$pay = Qspay::instance('alipay', $config);
$pay->notifyHandle(function($notify_param){
    //处理业务逻辑
    //返回 true 表示处理成功
    //返回 错误字符串表示处理失败
});
```

#### 旧版接口 PC AND WAP

[](#旧版接口-pc-and-wap)

```
$config = [
    'interface_type' => Qspay\Alipay::ALIPAY_INTERFACE_TYPE_DONATEV3,
    //合作伙伴身份(PID)
    'partner' => ***************,
    //MD5密钥
    'key'  => *************,
    // 支付宝登录邮箱
    'seller_email' => ********************,
    //采用传输协议 http or https
    'transport' => ****,
    // 支付成功回调通知地址
    'notify_url'  => ***************,
    // 支付成功返回地址
    'return_url' => **************
];

$pay = Qspay::instance('alipay', $config);

echo $pay->pay([
    'out_trade_no' => time(), // 商户订单号
    'total_amount' => '0.01',    // 支付金额
    'subject'      => '支付订单描述', // 支付订单描述
    'body' => '订单详情', //支付订单详情
]);
```

#### 旧版接口 notify

[](#旧版接口-notify)

```
$config = [
    'interface_type' => Qspay\Alipay::ALIPAY_INTERFACE_TYPE_DONATEV3,
    //合作伙伴身份(PID)
    'partner' => ***************,
    //MD5密钥
    'key'  => *************,
    // 支付宝登录邮箱
    'seller_email' => ********************,
    //采用传输协议 http or https
    'transport' => ****,
    // 支付成功回调通知地址
    'notify_url'  => ***************,
    // 支付成功返回地址
    'return_url' => **************
];

$pay = Qspay::instance('alipay', $config);
$pay->notifyHandle(function($notify_param){
    //处理业务逻辑
    //返回 true 表示处理成功
    //返回 错误字符串表示处理失败
});
```

### 银联

[](#银联)

#### PC AND WAP

[](#pc-and-wap)

```
$config = [
    'merId' => ***********,
    'notifyUrl' => ****************, //后台通知
    'signCertPath' => ***************, //签名证书
    'signCertPwd' => **********,  //签名密码
];

$qspay = Qspay::instance('unionpay', $config);

$order = [];
$order['out_trade_no'] = date('YmdHis');
$order['amount'] = 1;
$order['returnUrl'] = ******; //支付成功返回地址

echo  $qspay->pay($order);
```

#### notify

[](#notify-1)

```
 $config = [
    'merId' => '826440159420001',
    'signCertPath' => ***************, //签名证书
    'signCertPwd' => **********,  //签名密码
    'verifyRootCertPath' => *************, //root证书
    'verifyMiddleCertPath' => *************** //middle证书
];

$qspay = Qspay::instance('unionpay', $config);

$qspay->notifyHandle(function($post_data){
    //处理业务逻辑
    //返回 true 表示处理成功
    //返回 错误字符串表示处理失败
});
```

设置订单超时时间
--------

[](#设置订单超时时间)

#### 支付宝(旧版)

[](#支付宝旧版)

在pay方法参数中加入it\_b\_pay参数，具体参数设置请查看[支付宝API文档](https://opendocs.alipay.com/open/62/104743)

```
$pay->pay([
    'out_trade_no' => time(), // 商户订单号
    'total_amount' => '0.01',    // 支付金额
    'subject'      => '支付订单描述', // 支付订单描述
    'return_url' => '**********',
    'it_b_pay'   => '10m',
]);
```

#### 支付宝(新版)

[](#支付宝新版)

在pay方法参数中加入time\_expire参数，具体参数设置请查看[支付宝API文档](https://opendocs.alipay.com/apis/api_1/alipay.trade.wap.pay)

```
$pay->pay([
    'out_trade_no' => time(), // 商户订单号
    'total_amount' => '0.01',    // 支付金额
    'subject'      => '支付订单描述', // 支付订单描述
    'return_url' => '**********',
    'time_expire'   => '2016-12-31 10:05',
]);
```

#### 微信

[](#微信)

在pay方法参数中加入time\_expire参数，具体参数设置请查看[微信API文档](https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)

```
$pay->pay([
    'body' => '测试',
    'out_trade_no' => time(),
    'total_fee' => 1,
    'openid' => session('test_openid'),
    'time_expire' => '20091227091010',
]);
```

lincense
--------

[](#lincense)

[MIT License](https://github.com/tiderjian/lara-for-tp/blob/master/LICENSE.MIT)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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 ~40 days

Total

8

Last Release

2070d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/15a0610fee78753bdad92fd45c3506455c0fd45ae51924797b1841d260495a3f?d=identicon)[tiderjian](/maintainers/tiderjian)

---

Top Contributors

[![qq958691165](https://avatars.githubusercontent.com/u/13673962?v=4)](https://github.com/qq958691165 "qq958691165 (4 commits)")[![tiderjian](https://avatars.githubusercontent.com/u/1665649?v=4)](https://github.com/tiderjian "tiderjian (3 commits)")

---

Tags

alipayunion-paywe-pay

### Embed Badge

![Health badge](/badges/tiderjian-qs-pay/health.svg)

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

###  Alternatives

[yansongda/pay

可能是我用过的最优雅的 Alipay 和 WeChat 的支付 SDK 扩展包了

5.3k1.2M53](/packages/yansongda-pay)[yansongda/laravel-pay

专注 Alipay/WeChat/Unipay 的 laravel 支付扩展包

1.1k353.2k9](/packages/yansongda-laravel-pay)[lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

587421.0k11](/packages/lokielse-omnipay-alipay)[latrell/alipay

支付宝SDK在Laravel5封装包。

40349.2k](/packages/latrell-alipay)[yansongda/hyperf-pay

可能是基于 hyperf 的最优雅的支付宝、微信、银联支付 SDK 了

8959.8k1](/packages/yansongda-hyperf-pay)[lokielse/omnipay-global-alipay

Alipay global gateway for Omnipay payment processing library

3048.9k](/packages/lokielse-omnipay-global-alipay)

PHPackages © 2026

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