PHPackages                             hyperbolaa/wechatpay - 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. hyperbolaa/wechatpay

ActiveProject[Payment Processing](/categories/payments)

hyperbolaa/wechatpay
====================

微信支付在laravle5中的封装

1.0(9y ago)471.3k20[2 issues](https://github.com/hyperbolaa/Wechatpay/issues)MITPHPPHP &gt;=5.5.0CI failing

Since Apr 11Pushed 6y ago4 watchersCompare

[ Source](https://github.com/hyperbolaa/Wechatpay)[ Packagist](https://packagist.org/packages/hyperbolaa/wechatpay)[ Docs](https://github.com/hyperbolaa/Wechatpay)[ RSS](/packages/hyperbolaa-wechatpay/feed)WikiDiscussions master Synced 1mo ago

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

Wechatpay
=========

[](#wechatpay)

微信支付，laravel, laravel5

#### 安装

[](#安装)

```
composer require hyperbolaa/wechatpay dev-master

```

#### laravel 配置

[](#laravel-配置)

```
 'providers' => [
     // ...
     Hyperbolaa\Wechatpay\WechatpayServiceProvider::class,
 ]

```

#### 生成配置文件

[](#生成配置文件)

```
运行 `php artisan vendor:publish` 命令，
发布配置文件到你的项目中。

```

#### 公众号支付

[](#公众号支付)

```
$wechatpay = app('wechatpay.jsapi');
$wechatpay->setBody('我是测试商品');
$wechatpay->setOutTradeNo(123456789);
$wechatpay->setTotalFee(1);
$wechatpay->setOpenid('ssssssss');//公众号openid获取参考微信网页授权

$result = $wechatpay->prepare();
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
    $prepayId = $result['prepay_id'];
    //WeixinJSBridge
    $json = $wechatpay->configForPayment($prepayId);
    $succ_url = 'xx';//支付成功回调地址
    $fail_url = 'xx';//支付失败回调地址
    $data = $wechatpay->bridgeHandle($json,$succ_url,$fail_url);
    return new Response($data);
}else{
    $msg = '微信回调失败；请求错误信息：'.$result['return_msg'].'；业务错误信息：'.$result['err_code_des'];
    return new Response($msg);
}

```

#### 小程序支付

[](#小程序支付)

```
$wechatpay = app('wechatpay.xcx');
$wechatpay->setBody('我是测试商品');
$wechatpay->setOutTradeNo(123456789);
$wechatpay->setTotalFee(1);
$wechatpay->setOpenid('ssssssss');//微信小程序的openid获取参考wx.login

$result = $wechatpay->prepare();
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
    $prepayId = $result['prepay_id'];
    $data = $wechatpay->configForPayment($prepayId,false);
    return new Response($data);//返回给微信小程序
}else{
    $msg =  '微信回调失败；请求错误信息：'.$result['return_msg'].'；业务错误信息：'.$result['err_code_des'];
    return new Response($msg);
}

```

> 小程序登录获取用户信息拓展
>
> > app('wechatpay.xcx')-&gt;getUserInfo($encrypteddata,$iv,$sessionkey);

#### APP支付

[](#app支付)

```
$wechatpay = app('wechatpay.app');
$wechatpay->setBody('我是测试商品');
$wechatpay->setOutTradeNo(123456789);
$wechatpay->setTotalFee(1);

$result = $wechatpay->prepare();
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
    $prepayId = $result['prepay_id'];
    return $wechatpay->configForPayment($prepayId);
}else{
    return '微信回调失败；请求错误信息：'.$result['return_msg'].'；业务错误信息：'.$result['err_code_des'];
}

```

#### 异步通知

[](#异步通知)

```
public function wechatpayNotify()
{
    // 判断通知类型。
    $response = app('wechatpay.jsapi')->handleNotify(function ($notify, $successful) {
        $out_trade_no   = $notify->out_trade_no;//商户订单号
        $transaction_id = $notify->transaction_id;//微信订单号
        //
        if($successful){
            //todo 处理支付成功，，，
        }
        return true;
    });

    return new Response($response);
}

```

货币单位
----

[](#货币单位)

```
分

```

支付类别
----

[](#支付类别)

```
JSAPI     [公众号,小程序]支付    已接通
APP       APP支付              已接通
NATIVE    扫码支付
MICROPAY  刷卡支付

```

已优化
---

[](#已优化)

```
回复数据格式化处理，支持json,arr
添加日志记录

```

联系&amp;打赏
---------

[](#联系打赏)

如果真心觉得项目帮助到你，为你节省了成本，欢迎鼓励一下。

如果有什么问题，可通过以下方式联系我。提供有偿技术服务。

也希望更多朋友可用提供代码支持。欢迎交流与打赏。

**加入QQ群**：60973229

Related
-------

[](#related)

- [Ylpay](https://github.com/hyperbolaa/Ylpay) 基于laravel5的POS通支付
- [Alipay](https://github.com/hyperbolaa/Alipay) 基于laravel5的支付宝支付
- [Unionpay](https://github.com/hyperbolaa/Unionpay) 基于laravel5的银联支付
- [Alisms](https://github.com/hyperbolaa/Alisms) 基于laravel5的阿里云短信

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3315d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f9d51471cd65ff00a650bdf0bb93893a35d5d1d554ffce46c3a86a31009c587?d=identicon)[hyperbolaa](/maintainers/hyperbolaa)

---

Top Contributors

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

---

Tags

laravel5wechatweixinwechatpaylaravel5.2WxpayWeixinPay

### Embed Badge

![Health badge](/badges/hyperbolaa-wechatpay/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M368](/packages/laravel-zero-framework)[yansongda/laravel-pay

专注 Alipay/WeChat/Unipay 的 laravel 支付扩展包

1.1k353.2k9](/packages/yansongda-laravel-pay)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[fantasystudio/easypay

Wechat and Alipay payment SDK

383.4k](/packages/fantasystudio-easypay)

PHPackages © 2026

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