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

ActiveLibrary[Payment Processing](/categories/payments)

snowlyg/wechatpay-guzzle
========================

微信支付v3接口-商户进件提交，状态查询，以及图片上传

v0.1.1(5y ago)13142↓100%6Apache-2.0PHPPHP &gt;=5.5

Since Apr 13Pushed 4y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

wechatpay-guzzle
================

[](#wechatpay-guzzle)

#### 微信支付v3 接口-特约商户进件提交，状态查询，以及图片上传 , 使用  实现微信签名认证。

[](#微信支付v3-接口-特约商户进件提交状态查询以及图片上传---使用-httpsgithubcomsnowlygwechatpay-guzzle-实现微信签名认证)

环境要求
----

[](#环境要求)

- PHP 5.5+ / PHP 7.0+
- guzzlehttp/guzzle 6.0+

> 注意：PHP &lt; 7.2 需要安装 bcmath 扩展

##### 安装 composer

[](#安装--composer)

```
  composer require snowlyg/wechatpay-guzzle
```

#### 使用方法

[](#使用方法)

参考：

###### 图片数据获取

[](#图片数据获取)

```
     // $filepath 图片地址
     $imginfo     = pathinfo($filepath);
     $picturedata = file_get_contents($filepath);
     $sign        = hash('sha256', $picturedata);
     $meta        = [
          "filename" => $imginfo['basename'],
           "sha256"   => $sign,
      ];

     $filestr = json_encode($meta);

```

###### 图片 body 生成

[](#图片-body-生成)

```
     public function getBody($filestr, array $imginfo, $picturedata)
     {
         $boundarystr = "--{$this->boundary}\r\n";
         $out         = $boundarystr;
         $out         .= 'Content-Disposition: form-data; name="meta";'."\r\n";
         $out         .= 'Content-Type: application/json; charset=UTF-8'."\r\n";
         $out         .= "\r\n";
         $out         .= "".$filestr."\r\n";
         $out         .= $boundarystr;
         $out         .= 'Content-Disposition: form-data; name="file"; filename="'.$imginfo['basename'].'";'."\r\n";
         $out         .= 'Content-Type: image/'.$imginfo['extension'].';'."\r\n";
         $out         .= "\r\n";
         $out         .= $picturedata."\r\n";
         $out         .= "--{$this->boundary}--\r\n";
         return $out;
     }

```

###### 图片签名

[](#图片签名)

```
 // 上传图片
    $resp = $client->request('POST', 'https://api.mch.weixin.qq.com/v3/...', [
        'body' =>\GuzzleHttp\Psr7\stream_for($body),
        // meta的json串 ,签名使用
       "metaJson"     => '{ "filename": "filea.jpg", "sha256": " hjkahkjsjkfsjk78687dhjahdajhk " }',
        'headers' => [
               'Accept'       => 'application/json',
               "Content-Type" => " multipart/form-data;boundary=boundary",
            ]
    ]);

```

###### 进件敏感数据加密

[](#进件敏感数据加密)

```
    public function getEncrypt($str)
    {
        $public_key = file_get_contents($this->wechat_public_cert);
        $encrypted = '';
        if (openssl_public_encrypt($str, $encrypted, $public_key, OPENSSL_PKCS1_OAEP_PADDING)) {
            $sign = base64_encode($encrypted);
        } else {
            throw new Exception('encrypt failed');
        }

        return $sign;
    }

```

#### 开发插曲

[](#开发插曲)

> 写此功能的时候，在微信开放社区找到一个写过次功能的哥们联系方式。本来想向他请教一下，以免自己少走弯路。没想到这哥们直接开口要 300 大洋....
>
> 看来没法偷懒了，只能自己写了。
>
> 在微信开放社区找到很多朋友分享的代码，非常感谢他们。
>
> 还有微信官方文档的微信签名 sdk ,

#### 联系交流

[](#联系交流)

如果你发现了BUG或者有任何疑问、建议，请通过issue进行反馈。

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

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

Total

2

Last Release

2187d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/45a43467392cf3eaac4d4b7071cc983ac64e9483cead19f2ca5bcd656eb0b708?d=identicon)[dreamfishers](/maintainers/dreamfishers)

---

Top Contributors

[![snowlyg](https://avatars.githubusercontent.com/u/45998760?v=4)](https://github.com/snowlyg "snowlyg (5 commits)")

---

Tags

wechatpay

### Embed Badge

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

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

###  Alternatives

[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[glennraya/xendivel

A Laravel package to easily integrate Xendit payment gateway. It supports credit and debit cards, and e-wallet payments and custom invoices, queued notifications, webhook listeners and more.

412.3k](/packages/glennraya-xendivel)[hyperbolaa/wechatpay

微信支付在laravle5中的封装

471.3k](/packages/hyperbolaa-wechatpay)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)

PHPackages © 2026

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