PHPackages                             naka507/wehelper - 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. naka507/wehelper

ActiveLibrary[Payment Processing](/categories/payments)

naka507/wehelper
================

WeChat, WeMini, WePay, AliPay SDK FOR PHP

v1.6(5y ago)031MITPHPPHP &gt;=5.6

Since Jun 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/naka1205/wehelper)[ Packagist](https://packagist.org/packages/naka507/wehelper)[ RSS](/packages/naka507-wehelper/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (13)Used By (0)

wehelper
========

[](#wehelper)

### 安装

[](#安装)

```
composer require naka507/wehelper

```

### 微信

[](#微信)

```
require __DIR__ . '/vendor/autoload.php';
use WeHelper\WeChat\User;

$config = [
    'token'          => '',
    'appid'          => '',
    'appsecret'      => '',
    'encodingaeskey' => '',
    'mch_id'         => "", // 配置商户支付参数
    'mch_key'        => '',
    // 配置商户支付双向证书目录 （p12 | key,cert 二选一，两者都配置时p12优先）
    'ssl_key'        => 'XXX.pem',
    'ssl_cer'        => 'XXX.pem',
    // 配置缓存目录，需要拥有写权限
    'cache_path'     => '',
];

$wechat = new User($config);
// 获取用户列表
$result = $wechat->getUserList();

// 批量获取用户资料
foreach (array_chunk($result['data']['openid'], 100) as $value) {
    $info = $wechat->getBatchUserInfo($value);
    var_export($info);
}
```

微信网页
----

[](#微信网页)

```
//发起授权
$oauth = new Oauth($config);

$redirect_url = 'https://www.xxx.com/back';
// $scope = 'snsapi_base'; //静默授权 获取openid
$scope = 'snsapi_userinfo'; //主动授权 获取用户信息
$redirect = $oauth->getOauthRedirect($redirect_url,'debug',$scope);

header('Location: ' .$redirect);
```

```
//授权回调
$oauth = new Oauth($config);
//获取 access_token openid
$data = $oauth->getOauthAccessToken();

//主动授权 获取用户信息信息
$access_token = isset($data['access_token']) ? $data['access_token'] : '';
$openid = isset($data['openid']) ? $data['openid'] : '';
$user_info = $oauth->getUserInfo($access_token,$openid);
```

### 微信小程序

[](#微信小程序)

```
use WeHelper\WeMini\Crypt;

$iv = $_POST['iv'];
$code = $_POST['code'];
$encryptedData = $_POST['encryptedData'];

$config = [
    'appid'     => '',
    'appsecret' => '',
];

$mini = new Crypt($config);
$info = $mini->session($code);

$session_key = isset($info['session_key']) ? $info['session_key'] : '';
// 获取用户信息
$userinfo = $wechat->decode($iv, $session_key, $encryptedData);
```

### 微信支付

[](#微信支付)

```
use WeHelper\WeChat\Pay;

$wechat = new Pay($config);

// 参数
$options = [
    'body'             => '测试商品',
    'out_trade_no'     => time(),
    'total_fee'        => '1',
    'openid'           => '',
    'trade_type'       => 'JSAPI',
    'notify_url'       => 'http://www.xxx.com/text.html',
    'spbill_create_ip' => '127.0.0.1',
];

// 生成预支付码
$result = $wechat->createOrder($options);

// 创建JSAPI参数签名
$options = $wechat->createParamsForJsApi($result['prepay_id']);
```

### 支付宝支付

[](#支付宝支付)

```
use WeHelper\AliPay\Wap;

// 参数
$config = [
    'debug'       => true, // 沙箱模式
    'sign_type'   => "RSA2", // 签名类型（RSA|RSA2）
    'appid'       => '', // 应用ID
    'public_key'  => '', // 支付宝公钥
    'private_key' => '', // 支付宝私钥
    'app_cert'    => '', // 应用公钥证书（新版资金类接口转 app_cert_sn）
    'root_cert'   => '', // 支付宝根证书（新版资金类接口转 alipay_root_cert_sn）
    'notify_url'  => '', // 支付成功通知地址
    'return_url'  => '', // 网页支付回跳地址
];

// 参考公共参数  https://docs.open.alipay.com/203/107090/
$config['notify_url'] = 'http://www.xxxx.com/alipay-notify.php';
$config['return_url'] = 'http://www.xxxx.com/alipay-success.php';

$alipay = new Wap($config);

// 参考链接：https://docs.open.alipay.com/api_1/alipay.trade.wap.pay
$result = $alipay->apply([
    'out_trade_no' => time(), // 商户订单号
    'total_amount' => '1', // 支付金额
    'subject'      => '支付订单描述', // 支付订单描述
]);
```

### 企业微信

[](#企业微信)

```
require __DIR__ . '/vendor/autoload.php';
use WeHelper\WeQiye\WeMini;

$config = [
    'token'          => '',
    'appid'          => '',
    'agentid'          => '',
    'appsecret'      => '',
    // 配置缓存目录，需要拥有写权限
    'cache_path'     => '',
];

$wx = new WeMini($config);
// 获取登录凭证
$result = $wx->session($code);

// 获取用户信息
$userInfo = $wx->userInfo($result['userid']);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Every ~22 days

Recently: every ~37 days

Total

12

Last Release

1928d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/31daa787ddfaddc2a730ad5ea28e19f1da17287e45251b4292d64c7feee71531?d=identicon)[naka1205](/maintainers/naka1205)

---

Top Contributors

[![naka1205](https://avatars.githubusercontent.com/u/20264902?v=4)](https://github.com/naka1205 "naka1205 (16 commits)")

### Embed Badge

![Health badge](/badges/naka507-wehelper/health.svg)

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

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