PHPackages                             kuangjy/omnipay-qpay - 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. kuangjy/omnipay-qpay

ActiveLibrary[Payment Processing](/categories/payments)

kuangjy/omnipay-qpay
====================

QPay(QQ Wallet) driver for the Omnipay PHP payment processing library

v3.0.2(7y ago)32903MITPHP

Since Oct 10Pushed 6y ago1 watchersCompare

[ Source](https://github.com/kuangjy2/omnipay-qpay)[ Packagist](https://packagist.org/packages/kuangjy/omnipay-qpay)[ RSS](/packages/kuangjy-omnipay-qpay/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

Omnipay: QPay
=============

[](#omnipay-qpay)

**QPay(QQ Wallet) driver for the Omnipay PHP payment processing library**

[![Build Status](https://camo.githubusercontent.com/517ba28924e213bdaeab281e170e4bf3f3860bd2f05a3dd6cb4f0db71bf3b2a7/68747470733a2f2f7472617669732d63692e6f72672f6b75616e676a79322f6f6d6e697061792d717061792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kuangjy2/omnipay-qpay)[![Latest Stable Version](https://camo.githubusercontent.com/ec2f41aed926469f01e5188a8da698dd7019567878aef617c9d6f715708016e3/68747470733a2f2f706f7365722e707567782e6f72672f6b75616e676a792f6f6d6e697061792d717061792f762f737461626c65)](https://packagist.org/packages/kuangjy/omnipay-qpay)[![Latest Unstable Version](https://camo.githubusercontent.com/607e6f99634dab5d03c71d449050e718bf73f2567c43f4756d6fa25129319498/68747470733a2f2f706f7365722e707567782e6f72672f6b75616e676a792f6f6d6e697061792d717061792f762f756e737461626c65)](https://packagist.org/packages/kuangjy/omnipay-qpay)[![License](https://camo.githubusercontent.com/da1cfddc5aefa2a3ad054e41ad60e26fbb8d9243a94e1dad1966cb144198e4c7/68747470733a2f2f706f7365722e707567782e6f72672f6b75616e676a792f6f6d6e697061792d717061792f6c6963656e7365)](https://packagist.org/packages/kuangjy/omnipay-qpay)

[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements QPay support for Omnipay.

Installation
------------

[](#installation)

Omnipay is installed via [Composer](http://getcomposer.org/). To install:

```
composer require kuangjy/omnipay-qpay

```

Basic Usage
-----------

[](#basic-usage)

The following gateways are provided by this package:

- QPay (QPay Common Gateway) QQ钱包支付通用网关
- QPay\_App (QPay App Gateway) QQ钱包APP支付网关
- QPay\_Native (QPay Native Gateway) QQ钱包原生扫码支付网关
- QPay\_Js (QPay Js API/MP Gateway) QQ钱包公众号支付网关
- QPay\_MicroPay (QPay Micro/POS Gateway) QQ钱包付款码支付网关
- QPay\_RedPacket (QPay Red Packet) QQ钱包现金红包网关
- QPay\_Transfer (QPay Transfer) QQ钱包企业付款到余额网关

Usage
-----

[](#usage)

### Create Order [doc](https://qpay.qq.com/buss/wiki/38/1203)

[](#create-order-doc)

```
//gateways: QPay_App, QPay_Native, QPay_Js
$gateway = Omnipay::create('QPay_Native');
$gateway->setAppId('app_id'); //required for QPay_App only
$gateway->setAppKey('app_key'); //required for QPay_App only
$gateway->setMchId('mch_id');
$gateway->setApiKey('api_key');

$order = [
    'out_trade_no' => time() . mt_rand(1000, 9999),
    'body' => 'order information',
    'attach' => 'attached information',
    'total_fee' => '100',
    'spbill_create_ip' => '127.0.0.1',
    'notify_url' => 'http://example.com/notify.php',
];

/**
 * @var Omnipay\QPay\Message\CreateOrderRequest $request
 * @var Omnipay\QPay\Message\CreateOrderResponse $response
 */
$request  = $gateway->purchase($order);
$response = $request->send();

//available methods
$response->isSuccessful();
$response->getData(); //For debug
$response->getPrepayId(); //Prepay ID
$response->getAppData(); //For QPay_App
$response->getJsOrderData(); //For QPay_Js
$response->getCodeUrl(); //For QPay_Native
```

### Create MicroPay Order [doc](https://qpay.qq.com/buss/wiki/1/1122)

[](#create-micropay-order-doc)

```
//gateways: QPay_MicroPay
$gateway = Omnipay::create('QPay_MicroPay');
$gateway->setMchId('mch_id');
$gateway->setApiKey('api_key');

$order = [
    'out_trade_no' => time() . mt_rand(1000, 9999),
    'body' => '商品描述',
    'attach' => '附加信息',
    'total_fee' => '100',
    'spbill_create_ip' => '127.0.0.1',
    'notify_url' => 'http://example.com/notify.php',
    'device_info' => '001',
    'auth_code' => '910783818928826810'
];

/**
 * @var Omnipay\QPay\Message\CreateMicroPayOrderRequest $request
 * @var Omnipay\QPay\Message\CreateMicroPayOrderResponse $response
 */
$request  = $gateway->purchase($order);
$response = $request->send();

//available methods
$response->isSuccessful(); //Get result
$response->getData(); //For debug
```

### Create Transfer [doc](https://qpay.qq.com/buss/wiki/206/1215)

[](#create-transfer-doc)

```
//gateways: QPay_Transfer
$gateway = Omnipay::create('QPay_Transfer');
$gateway->setMchId('mch_id');
$gateway->setApiKey('api_key');
$gateway->setCertPath($certPath);//证书cert路径
$gateway->setKeyPath($keyPath);//证书key路径

$order = [
    'out_trade_no' => time() . mt_rand(1000, 9999),
    'uin' => '123456789',
    'memo' => '转账描述',
    'total_fee' => '100',
    'spbill_create_ip' => '127.0.0.1',
];

/**
 * @var Omnipay\QPay\Message\CreateTransferRequest $request
 * @var Omnipay\QPay\Message\CreateTransferResponse $response
 */
$request  = $gateway->transfer($order);
$response = $request->send();

//available methods
$response->isSuccessful(); //Get result
$response->getData(); //For debug
```

### Create RedPacket [doc](https://qpay.qq.com/buss/wiki/221/1220)

[](#create-redpacket-doc)

```
//gateways: QPay_RedPacket
$gateway = Omnipay::create('QPay_RedPacket');
$gateway->setMchId('mch_id');
$gateway->setApiKey('api_key');
$gateway->setCertPath($certPath);//证书cert路径
$gateway->setKeyPath($keyPath);//证书key路径

$order = [
    'mch_billno' => '1441246101201610101234567890',//组成:mch_id+yyyymmdd+10位一天内不能重复的的数字
    'mch_name' => '测试商户',
    're_openid' => '123456789',
    'total_amount' => '100',
    'total_num' => '10',
    'wishing' => '红包祝福语',
    'act_name' => '活动名称',
    'icon_id' => '23',
    'min_value' => '1',
    'max_value' => '100'
];

/**
 * @var Omnipay\QPay\Message\CreateRedPacketRequest $request
 * @var Omnipay\QPay\Message\CreateRedPacketResponse $response
 */
$request  = $gateway->redPacket($order);
$response = $request->send();

//available methods
$response->isSuccessful(); //Get result
$response->getData(); //For debug
```

### Notify [doc](https://qpay.qq.com/buss/wiki/38/1204)

[](#notify-doc)

```
$gateway = Omnipay::create('QPay');
$gateway->setAppId('app_id');
$gateway->setMchId('mch_id');
$gateway->setApiKey('api_key');

$response = $gateway->completePurchase([
    'request_params' => file_get_contents('php://input')
])->send();

if ($response->isPaid()) {
    //pay success
    var_dump($response->getRequestData());
}else{
    //pay fail
}
```

### Query Order [doc](https://qpay.qq.com/buss/wiki/38/1205)

[](#query-order-doc)

```
$response = $gateway->query([
    'transaction_id' => '1217752501201407033233368018',
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());
```

### Close Order [doc](https://qpay.qq.com/buss/wiki/38/1206)

[](#close-order-doc)

```
$response = $gateway->close([
    'out_trade_no' => '20150806125346',
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());
```

### Refund [doc](https://qpay.qq.com/buss/wiki/38/1207)

[](#refund-doc)

```
$gateway->setCertPath($certPath);
$gateway->setKeyPath($keyPath);

$response = $gateway->refund([
    'transaction_id' => '1353933301461607211903715555',
    'out_refund_no' => $outRefundNo,
    'refund_fee' => 100,
    'op_user_id' => '1900000109',
    'op_user_passwd' => 'e47fefadd66e024bb2b85dfeb5fe86ba'
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());
```

### QueryRefund [doc](https://qpay.qq.com/buss/wiki/38/1208)

[](#queryrefund-doc)

```
$response = $gateway->queryRefund([
    'refund_id' => '1121218133801201611098791376',
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());
```

For general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay)repository.

Related
-------

[](#related)

This project is based on [lokielse/omnipay-wechatpay](https://github.com/lokielse/omnipay-wechatpay). Thanks for [Loki Else's](https://github.com/lokielse) wonderful works.

Support
-------

[](#support)

If you are having general issues with Omnipay, we suggest posting on [Stack Overflow](http://stackoverflow.com/). Be sure to add the [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which you can subscribe to.

If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/lokielse/omnipay-wechatpay/issues), or better yet, fork the library and submit a pull request.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 85.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 ~78 days

Total

3

Last Release

2663d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2821471?v=4)[Jiaye Kuang](/maintainers/kuangjy2)[@kuangjy2](https://github.com/kuangjy2)

---

Top Contributors

[![kuangjy2](https://avatars.githubusercontent.com/u/2821471?v=4)](https://github.com/kuangjy2 "kuangjy2 (24 commits)")[![qfz9527](https://avatars.githubusercontent.com/u/24431828?v=4)](https://github.com/qfz9527 "qfz9527 (2 commits)")[![cmzz](https://avatars.githubusercontent.com/u/6111715?v=4)](https://github.com/cmzz "cmzz (1 commits)")[![tyson239](https://avatars.githubusercontent.com/u/5617150?v=4)](https://github.com/tyson239 "tyson239 (1 commits)")

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/kuangjy-omnipay-qpay/health.svg)

```
[![Health](https://phpackages.com/badges/kuangjy-omnipay-qpay/health.svg)](https://phpackages.com/packages/kuangjy-omnipay-qpay)
```

###  Alternatives

[ignited/laravel-omnipay

Integrates Omnipay with Laravel and provides an easy configuration.

5211.1M12](/packages/ignited-laravel-omnipay)[lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

557422.2k11](/packages/lokielse-omnipay-alipay)[lokielse/omnipay-wechatpay

Wechat gateway for Omnipay payment processing library

314225.4k7](/packages/lokielse-omnipay-wechatpay)[omnipay/mollie

Mollie driver for the Omnipay payment processing library

631.8M10](/packages/omnipay-mollie)[lokielse/omnipay-unionpay

UnionPay gateway for Omnipay payment processing library

11358.3k2](/packages/lokielse-omnipay-unionpay)[silverstripe/silverstripe-omnipay

SilverStripe Omnipay Payment Module

38108.5k17](/packages/silverstripe-silverstripe-omnipay)

PHPackages © 2026

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