PHPackages                             ledc/easywechat - 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. [API Development](/categories/api)
4. /
5. ledc/easywechat

ActiveLibrary[API Development](/categories/api)

ledc/easywechat
===============

Webman plugin ledc/easywechat

v8.3.38(6mo ago)989MITPHPPHP &gt;=8.3

Since Oct 15Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/ledccn/ledc-easywechat)[ Packagist](https://packagist.org/packages/ledc/easywechat)[ RSS](/packages/ledc-easywechat/feed)WikiDiscussions master Synced 1mo ago

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

基于EasyWechat的webman支付插件
=======================

[](#基于easywechat的webman支付插件)

安装
--

[](#安装)

`composer require ledc/easywechat`

使用
--

[](#使用)

开箱即用，只需要传入一个配置即可：

```
use Ledc\EasyWechat\PayConfigManager;
use Ledc\EasyWechat\Enums\TerminalEnum;

// 可在Bootstrap，全局注入配置
PayConfigManager::set(function (TerminalEnum $terminalEnum) {
    // TODO... 从数据库读取配置，然后返回
    return [];
});
```

在创建实例后，所有的方法都可以有IDE自动补全；例如：

```
use Ledc\EasyWechat\Enums\TerminalEnum;
use Ledc\EasyWechat\PayService;

// 用户支付终端
$terminal = $request->post('terminal');
$terminalEnum = TerminalEnum::from((int)$terminal);

$payService = new PayService($terminalEnum);

$attach = '业务附加数据（微信支付成功后，原样返回）';
// 待支付的订单数据（可以看微信官方文档或跟踪进pay方法查看参数，按实际需要的传）
$order = [
    'description' => '购买会员',
    'out_trade_no' => uniqid(),
    'amount' => 1,
];

// 统一支付
$result = $payService->pay($attach, $order);
```

微信支付回调URL
---------

[](#微信支付回调url)

`https://您的域名/wechat/pay/callback`

具体处理逻辑在：

`\Ledc\EasyWechat\PayNotifyService::handle`

### 处理支付回调的最佳实践：

[](#处理支付回调的最佳实践)

注册webman事件，监听 `\Ledc\EasyWechat\Enums\EventEnum` 的三个事件即可；

修改 `config/event.php` ，加入：

```
use Ledc\EasyWechat\Enums\EventEnum;

return [
    // 微信支付回调通知：所有事件消息
    EventEnum::wechat_pay_any->value => [],
    // 微信支付回调通知：支付成功事件
    EventEnum::wechat_pay_success->value => [
        [WechatPaySuccessListener::class, 'handle'],
    ],
    // 微信支付回调通知：退款成功事件
    EventEnum::wechat_pay_refunded->value => [],
];
```

微信公众号消息回调URL
------------

[](#微信公众号消息回调url)

`https://您的域名/wechat/account/callback`

具体处理逻辑在：

`\Ledc\EasyWechat\WechatService::handle`

微信公众号网页授权登录授权完成后，重定向URL
-----------------------

[](#微信公众号网页授权登录授权完成后重定向url)

`https://您的域名/wechat/account/oauth/redirect`

具体处理逻辑在：

`\Ledc\EasyWechat\OfficialAccount\OauthMiddleware::redirect`

注：使用微信公众号网页授权时，请在中间件配置中，添加此中间件

`\Ledc\EasyWechat\OfficialAccount\OauthMiddleware::class`

二次开发
----

[](#二次开发)

捐赠
--

[](#捐赠)

[![reward](reward.png)](reward.png)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance66

Regular maintenance activity

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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

Every ~10 days

Recently: every ~3 days

Total

37

Last Release

201d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4af14254189bc74029cc40f4206f8006872b0cd092c680201f204a85a490f143?d=identicon)[ledccn](/maintainers/ledccn)

---

Top Contributors

[![ledccn](https://avatars.githubusercontent.com/u/53997080?v=4)](https://github.com/ledccn "ledccn (39 commits)")

### Embed Badge

![Health badge](/badges/ledc-easywechat/health.svg)

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

###  Alternatives

[overtrue/laravel-wechat

微信 SDK for Laravel

3.0k1.8M53](/packages/overtrue-laravel-wechat)[googleads/googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP

67410.3M25](/packages/googleads-googleads-php-lib)[googleads/google-ads-php

Google Ads API client for PHP

3497.6M9](/packages/googleads-google-ads-php)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k379.4k24](/packages/team-reflex-discord-php)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)

PHPackages © 2026

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