PHPackages                             hahadu/wechat-pay - 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. hahadu/wechat-pay

ActiveLibrary

hahadu/wechat-pay
=================

微信支付,基于官方SDK

v1.1.2(5y ago)0121Apache-2.0PHPPHP &gt;=5.6

Since Oct 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/hahadu/wechat-pay)[ Packagist](https://packagist.org/packages/hahadu/wechat-pay)[ RSS](/packages/hahadu-wechat-pay/feed)WikiDiscussions main Synced today

READMEChangelog (2)DependenciesVersions (5)Used By (1)

wechat-pay
==========

[](#wechat-pay)

\###微信支付（基于官方SDK做PSR4支持）

- 安装：composer require hahadu/wechat-pay

命名空间对应：

```
Hahadu\WechatPay\Kernel\WxPayData  => lib/WxPay.Data.php
Hahadu\WechatPay\Kernel\WxPayApi   => lib/WxPay.Api.php
Hahadu\WechatPay\Kernel\WxPayException => lib/WxPay.Exception.php
Hahadu\WechatPay\Kernel\WxPayNotify    => lib/WxPay.Notify.php
Hahadu\WechatPay\Kernel\config\WxPayConfigInterface => lib/WxPay.Config.Interface.php
```

使用

```
use Hahadu\WechatPay\Kernel\config\Config;
Hahadu\WechatPay\Kernel\config\WxPayConfig
//传入配置:

        $options = new Config();
        $options->AppId = ‘’; //appid
        $options->MerchantId = ''; //MerchantId
        $options->NotifyUrl = ''; //NotifyUrl
        $options->Key =  ''; //key
        $options->AppSecret = ''; //AppSecret
       // $options->SignType = ''; // SingType 默认值HMAC-SHA256
       // $options->sandbox = true;  //开启沙箱模式（微信支付仿真系统sandboxnew）
        $wechatConfig = new WxPayConfig($options);

```

扫码支付：

```
use Hahadu\WechatPay\Library\WechatNativePay;
use Hahadu\WechatPay\Kernel\WxPayData\WxPayUnifiedOrder;

        $notify = new WechatNativePay($wechatConfig);
        $input = new WxPayUnifiedOrder();
        $input->SetBody("test");
        $input->SetOut_trade_no("sdkphp123456789".date("YmdHis"));
        $input->SetTotal_fee("1");
        $input->SetTime_start(date("YmdHis"));
        $input->SetTime_expire(date("YmdHis", time() + 600));
        $input->SetGoods_tag("test");
        $input->SetTrade_type("NATIVE");
        $input->SetProduct_id("123456789");
        $result = $notify->GetPayUrl($input);
        $result["code_url"]; //微信支付二维码信息 示例weixin://wxpay/bizpayurl/up?pr=NwY5Mz9&groupid=00
```

JSAPI支付

```
use Hahadu\WechatPay\Library\WechatJsApiPay;
use Hahadu\WechatPay\Kernel\WxPayData\WxPayUnifiedOrder;
use Hahadu\WechatPay\Kernel\WxPayApi;
        $tools = new WechatJsApiPay($wechatConfig);
        $openId = $tools->GetOpenid(); //获取微信OpenID
        //②、统一下单
        $input = new WxPayUnifiedOrder();
        $input->SetBody("test"); //订单标题
        $input->SetOut_trade_no("sdkphp".date("YmdHis")); //商户订单号
        $input->SetTotal_fee("1"); //订单金额
        $input->SetTime_start(date("YmdHis")); //订单创建时间
        $input->SetTrade_type("JSAPI"); //支付方式
        $input->SetOpenid($openId);
        $order = WxPayApi::unifiedOrder($this->wechatConfig, $input);
        $jsApiParameters = $tools->GetJsApiParameters($order);

        //获取共享收货地址js函数参数
        $editAddress = $tools->GetEditAddressParameters();

        $result= [
            'jsApiParameters' =>$jsApiParameters,
            'editAddress' => $editAddress,
            'order' => $order,
        ];
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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 ~0 days

Total

4

Last Release

2033d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8803f4b62a77e88a2b14f57d7d68a5bacaa69fd8c58b17101e89044fab8abb27?d=identicon)[hahadu](/maintainers/hahadu)

---

Top Contributors

[![hahadu](https://avatars.githubusercontent.com/u/38153732?v=4)](https://github.com/hahadu "hahadu (15 commits)")

### Embed Badge

![Health badge](/badges/hahadu-wechat-pay/health.svg)

```
[![Health](https://phpackages.com/badges/hahadu-wechat-pay/health.svg)](https://phpackages.com/packages/hahadu-wechat-pay)
```

PHPackages © 2026

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