PHPackages                             xhat/payjs-laravel - 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. xhat/payjs-laravel

ActiveLibrary[Payment Processing](/categories/payments)

xhat/payjs-laravel
==================

基于 PAYJS 的 API 开发的 Composer Laravel Package，可直接用于生产环境 https://payjs.cn

1.6.0(5y ago)5718.6k—2.9%8MITPHP

Since Sep 17Pushed 5y ago3 watchersCompare

[ Source](https://github.com/xhat/payjs-laravel)[ Packagist](https://packagist.org/packages/xhat/payjs-laravel)[ Fund](https://payjs.cn/sponsor/dajjxz)[ RSS](/packages/xhat-payjs-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)DependenciesVersions (8)Used By (0)

 [![](https://camo.githubusercontent.com/9a6971049b10512b626be6165e3d5dde5112f8db2403317e2746e30538c6da25/68747470733a2f2f7061796a732e636e2f7374617469632f696d616765732f6c6f676f2e706e67)](https://camo.githubusercontent.com/9a6971049b10512b626be6165e3d5dde5112f8db2403317e2746e30538c6da25/68747470733a2f2f7061796a732e636e2f7374617469632f696d616765732f6c6f676f2e706e67)

PAYJS Wechat Payment Laravel Package
------------------------------------

[](#payjs-wechat-payment-laravel-package)

 [ ![Latest Stable Version](https://camo.githubusercontent.com/252bf85a33d4a9161ead8d3915360d41ff37010b04bb12cd92de3f0158c515c1/68747470733a2f2f706f7365722e707567782e6f72672f786861742f7061796a732d6c61726176656c2f762f737461626c652e706e67) ](https://packagist.org/packages/xhat/payjs-laravel) [ ![Total Downloads](https://camo.githubusercontent.com/c68b97013cc6418d2f4c29cea55963cb351ba4b8fecb15b87eac2ee7a2c6a922/68747470733a2f2f706f7365722e707567782e6f72672f786861742f7061796a732d6c61726176656c2f646f776e6c6f6164732e706e67) ](https://packagist.org/packages/xhat/payjs-laravel) [ ![License](https://camo.githubusercontent.com/834b3be792440ac41d64760e8d296cccafd759a46d61afaec270adff43167d4f/68747470733a2f2f706f7365722e707567782e6f72672f786861742f7061796a732d6c61726176656c2f6c6963656e73652e706e67) ](https://packagist.org/packages/xhat/payjs-laravel)

简介
--

[](#简介)

本项目是基于 PAYJS 的 API 开发的 Laravel Package，可直接用于生产环境

PAYJS 针对个人主体提供微信支付接入能力，是经过检验的正规、安全、可靠的微信支付个人开发接口

其它版本: [PAYJS 通用开发包](https://github.com/xhat/payjs)

支持Laravel 5.x、Laravel 6.x、Laravel 7.x、Laravel 8.x

安装
--

[](#安装)

通过 Composer 安装

```
$ composer require xhat/payjs-laravel
```

使用方法
----

[](#使用方法)

### 一、发布并修改配置文件

[](#一发布并修改配置文件)

- 发布配置文件

```
php artisan vendor:publish --provider="Xhat\Payjs\PayjsServiceProvider"
```

- 编辑配置文件 `config/payjs.php` 配置商户号和通信密钥

```
return [
    'mchid' => '', // 填写商户号
    'key'   => '', // 填写通信KEY
];
```

### 二、在业务中使用

[](#二在业务中使用)

首先在业务模块中引入门面

```
use Xhat\Payjs\Facades\Payjs;
```

- 扫码支付

```
// 构造订单基础信息
$data = [
    'body' => '订单测试',                                // 订单标题
    'total_fee' => 2,                                   // 订单标题
    'out_trade_no' => time(),                           // 订单号
    'attach' => 'test_order_attach',                    // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',     // 异步通知地址(可选参数)
];
return Payjs::native($data);
```

- 收银台模式支付（直接在微信浏览器打开）

```
// 构造订单基础信息
$data = [
    'body' => '订单测试',                                    // 订单标题
    'total_fee' => 2,                                       // 订单金额
    'out_trade_no' => time(),                               // 订单号
    'attach' => 'test_order_attach',                        // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',         // 异步通知地址(可选参数)
    'callback_url' => 'https://www.baidu.com/callback',     // 支付后前端跳转地址(可选参数)
];
$url = Payjs::cashier($data);
return redirect($url);
```

- JSAPI模式支付

```
// 构造订单基础信息
$data = [
    'body' => '订单测试',                                    // 订单标题
    'total_fee' => 2,                                       // 订单金额
    'out_trade_no' => time(),                               // 订单号
    'attach' => 'test_order_attach',                        // 订单附加信息(可选参数)
    'openid' => 'xxxxxxxxxxxxxxxxx',                        // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',         // 异步通知地址(可选参数)
];
return Payjs::jsapi($data);
```

- H5支付

```
// 构造订单基础信息
$data = [
    'body' => '订单测试',                                    // 订单标题
    'total_fee' => 2,                                       // 订单金额
    'out_trade_no' => time(),                               // 订单号
    'attach' => 'test_order_attach',                        // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',         // 异步通知地址(可选参数)
    'callback_url' => 'https://www.baidu.com',              // 前端跳转地址(可选参数)
];
return Payjs::mweb($data);
```

- 投诉查询

```
// 构造订单基础信息
$data = [
    'mchid' => '123123',                                    // 商户号
];
return Payjs::complaint($data);
```

- 查询订单

```
// 根据订单号查询订单状态
$payjs_order_id = '****************';
return Payjs::check($payjs_order_id);
```

- 关闭订单

```
// 根据订单号关闭订单
$payjs_order_id = '****************';
return Payjs::close($payjs_order_id);
```

- 退款

```
// 根据订单号退款
$payjs_order_id = '****************';
return Payjs::refund($payjs_order_id);
```

- 获取商户资料

```
// 返回商户基础信息
return Payjs::info();
```

- 获取用户资料

```
// 根据订单信息中的 OPENID 查询用户资料
$openid = '***************';
return Payjs::user($openid);
```

- 查询银行名称

```
// 根据订单信息中的银行编码查询银行中文名称
$bank = '***************';
return Payjs::bank($bank);
```

- 接收异步通知

```
// 接收异步通知,无需关注验签动作,已自动处理
$notify_info = Payjs::notify();
Log::info($notify_info);
```

更新日志
----

[](#更新日志)

Version 1.5.0 增加投诉API、H5支付API

Version 1.4 修正空值参数的过滤问题

安全相关
----

[](#安全相关)

如果您在使用过程中发现各种 bug，请积极反馈，我会尽早修复

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~132 days

Recently: every ~189 days

Total

7

Last Release

1999d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b750c75ae7c1245013b9bb368d7dfb99507ae3fe04e8e4c8000641cf76d38b34?d=identicon)[xhat](/maintainers/xhat)

---

Top Contributors

[![xhat](https://avatars.githubusercontent.com/u/699357?v=4)](https://github.com/xhat "xhat (15 commits)")[![xiaohuilam](https://avatars.githubusercontent.com/u/6964962?v=4)](https://github.com/xiaohuilam "xiaohuilam (1 commits)")

---

Tags

payjspaymentwechatwechatpaywepay

### Embed Badge

![Health badge](/badges/xhat-payjs-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/xhat-payjs-laravel/health.svg)](https://phpackages.com/packages/xhat-payjs-laravel)
```

###  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)
