PHPackages                             soul-key/smallpay - 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. soul-key/smallpay

ActiveLibrary

soul-key/smallpay
=================

小微支付配套PHP库

v2.0.0(4y ago)09MITPHPPHP &gt;=7.1.0

Since Dec 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/soul-key/smallpay)[ Packagist](https://packagist.org/packages/soul-key/smallpay)[ RSS](/packages/soul-key-smallpay/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (3)Used By (0)

SmallPay
========

[](#smallpay)

#### 小微支付的PHP版本SDK

[](#小微支付的php版本sdk)

---

一、安装
====

[](#一安装)

- 使用Composer v2安装，仓库 `https://github.com/soul-key/smallpay`

```
composer require soul-key/smallpay
```

- #### 发起支付示例

    [](#发起支付示例)

```
/**
 * 发起支付示例
 */
require __DIR__ . '/../vendor/autoload.php';

use SmallPay\Payment;

//支付地址
$payUrl = "http://api.weituma.cn/api/pay/go";
//应用ID
$appId = "10000002";
//应用秘钥
$appKey = "de872154ffbf91a5dcc0e539dd2d5106";

//设置支付相关
$client = new Payment($appId, $appKey);
$client->SetPayCode(2001);//设置支付能力
$client->SetOutTradeNo("IMD".time());//设置商户订单号
$client->SetMoney(1);
$client->SetGoodsName("测试商品");
$client->SetNotifyUrl("http://www.baidu.com");
$client->SetReturnUrl("http://www.baidu.com");
//发送支付请求(正常返回json格式数据)
$res = $client->Send($payUrl);

$res = json_decode($res, true);
if (isset($res['data']['url'])) {
    //返回的支付url 经过了 urlencode 转码，故此处要解码
    $pay_url = urldecode($res['data']['url']);
    header("location:" . $pay_url);
} else {
    var_dump($res);
}
die;
```

- #### 支付异步通知示例

    [](#支付异步通知示例)

```
/**
 * 支付异步通知示例
 */
require __DIR__ . '/../vendor/autoload.php';

use SmallPay\Payment;

//应用ID
$appId = "10000002";
//应用秘钥
$appKey = "de872154ffbf91a5dcc0e539dd2d5106";

$client = new Payment($appId, $appKey);
//验签
$check = $client->VerifySign($_POST);
if ($check) {
    //执行商户的逻辑

    //处理完成返回如下 json
    echo json_encode(['state'=>"SUCCESS"]);
}else {
    //验签失败
    echo json_encode(['state' => "FAIL"]);
    exit();
}
```

- ### 退款示例

    [](#退款示例)

```
/**
 * 退款示例
 */
require __DIR__ . '/../vendor/autoload.php';

use SmallPay\Refund;

$notifyUrl = "http://api.weituma.cn/api/pay/refund";
//应用ID
$appId = "10000002";
//应用秘钥
$appKey = "de872154ffbf91a5dcc0e539dd2d5106";

$client = new Refund($appId, $appKey);
$client->SetOutTradeNo("IMD121545112545");
$res = $client->Send($notifyUrl);
var_dump($res);
//{"code":1,"msg":"订单无效","data":""}
//{"code":0,"msg":"申请成功","data":""}
exit();
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

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

2

Last Release

1613d ago

PHP version history (2 changes)v2.0.0PHP &gt;=7.1.0

v1.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fafe1fe8eb8b0011498f00eb5f7181d8ceb8703b7e6e1f609d89a89137351755?d=identicon)[soul-key](/maintainers/soul-key)

### Embed Badge

![Health badge](/badges/soul-key-smallpay/health.svg)

```
[![Health](https://phpackages.com/badges/soul-key-smallpay/health.svg)](https://phpackages.com/packages/soul-key-smallpay)
```

PHPackages © 2026

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