PHPackages                             houzhonghua/weixin - 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. houzhonghua/weixin

ActiveLibrary[Payment Processing](/categories/payments)

houzhonghua/weixin
==================

小程序 APP 微信支付、微信登录、微信回调、微信退款、微信提现

291PHP

Since Oct 27Pushed 4y ago2 watchersCompare

[ Source](https://github.com/h5520/WeixinApi)[ Packagist](https://packagist.org/packages/houzhonghua/weixin)[ RSS](/packages/houzhonghua-weixin/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

使用方式
====

[](#使用方式)

```
composer require houzhonghua/weixin dev-main
```

引入
--

[](#引入)

```
use houzhonghua\weixin\Weixin;
```

自定义配置文件
-------

[](#自定义配置文件)

```
$config = [
    // 小程序appid
    "Applets_Appid" => "1",
    // 小程序appsecret
    "Applets_AppSecret" => "2",
    // 商户号
    "Public_mchid" => "3",
    // 公众号appid
    "Public_Appid" => "",
    // 微信商户 key
    "Public_key" => "",
    // 微信退款证书
    'apiclient_cert' => dirname(__FILE__)."\\cert\\apiclient_cert.pem",
    'apiclient_key' => dirname(__FILE__)."\\cert\\apiclient_key.pem"
];

$query = new Weixin($config);
```

> 或者

```
// 在 config 目录下创建一个 weixin.php 的配置文件
// 把上面的配置信息复制进去，然后用下面的方法调取
$query = new Weixin(Config.get('wexin'));
```

获取 OpenID
---------

[](#获取-openid)

```
$query = new Weixin;
$res = $query->OpenID($jscode);
print_r($res);
```

获取用户手机号
-------

[](#获取用户手机号)

```
$query = new Weixin;
$res = $query->getMobile($sessionKey,$encryptedData,$iv);
print_r($res);
```

创建支付订单
------

[](#创建支付订单)

```
$query = new Weixin();
$data = [
    'out_trade_no' => "123123", # 订单号
    'openid' => "openid", # openid
    'price' => "0.01", # 价格
    'notify' => "test", # 支付界面显示文字
    'attach' => "test", # 额外参数
    'notify_url' => "test", # 回调地址
];
$res = $query->pay($data);
print_r($res);
```

微信退款
----

[](#微信退款)

```
$query = new Weixin();
$out_trade_no = "123123"; # 订单号
$transaction_id = "123123"; # 微信流水号
$total_fee = 0.01; # 当前订单的总支付金额
$refund_fee = 2; # 退款金额
$res = $query->refund($out_trade_no,$transaction_id,$total_fee,$refund_fee);
print_r($res);
```

微信提现
----

[](#微信提现)

```
$query = new Weixin();
$fee = 0.01; # 提现金额
$openid = "123123"; # openid
$out_trade_no = "123123"; # 创建订单号
$act_name = "提现"; # 描述
$res = $query->Cashout($fee,$openid,$act_name);
print_r($res);
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![h5520](https://avatars.githubusercontent.com/u/57217010?v=4)](https://github.com/h5520 "h5520 (27 commits)")

### Embed Badge

![Health badge](/badges/houzhonghua-weixin/health.svg)

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

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