PHPackages                             gavin/chinaums - 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. gavin/chinaums

ActiveLibrary[Payment Processing](/categories/payments)

gavin/chinaums
==============

银商支付相关接口

v1.0.4(11mo ago)1100↓33.3%[1 issues](https://github.com/gavin20150423/chinaums/issues)MITPHPPHP ^7.0

Since Jun 12Pushed 11mo ago2 watchersCompare

[ Source](https://github.com/gavin20150423/chinaums)[ Packagist](https://packagist.org/packages/gavin/chinaums)[ RSS](/packages/gavin-chinaums/feed)WikiDiscussions master Synced 1mo ago

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

ChinaUms for PHP
----------------

[](#chinaums-for-php)

- ChinaUms基于银联商务官方接口文档开发，优化并完善
- 运行最底要求 PHP 版本 7.0 , 建议在 PHP7.2 以上运行以获取最佳性能；
- ChinaUms 针对 access\_token 失效增加了自动刷新机制；
- 获取认证的部分接口需要缓存数据在本地，因此对目录需要有写权限；
- 鼓励大家使用 composer 来管理您的第三方库，方便后期更新操作；

功能描述
----

[](#功能描述)

目前已实现功能：

- 微信支付（小程序、扫码支付）
- - 创建订单、订单查询、订单关闭、申请退款、退款查询

未来将实现：

- 支付宝支付
- 银联云闪付
- 企业网银支付

安装使用
----

[](#安装使用)

1.1 通过 Composer 来管理安装

```
# 首次安装 线上版本（稳定）
composer require gavin/chinaums

# 首次安装 开发版本（开发）
composer require gavin/chinaums dev-master

# 更新 chinaums
composer update gavin/chinaums
```

1.2 如果不使用 Composer， 可以下载 ChinaUms 并解压到项目中

```
# 在项目中加载初始化文件
include "您的目录/ChinaUms/include.php";
```

1.3 如果使用的是thinkphp6，发布配置文件到config

```
php think ums:create
```

1.4 如果遇到缓存没有权限写入，可以执行

```
php think ums:cache -d #将cache目录改为0777
php think ums:cache -u www:www #修改目录所有者为www
```

微信支付
----

[](#微信支付)

```
try {
    include "../vendor/autoload.php";
    // 1. 手动加载入口文件
    include "../include.php";

    // 2. 准备配置参数
    $config = include "../config/config.php";

    //3. 创建接口实例
    $ums = \Gavin\Ums\WePay\Pay::instance($config);

    //4. 组装参数，可以参考官方文档
    $options = [
        'merOrderId' => time(),
        'totalAmount' => '1',
        'subOpenId' => 'xxxxx',
        'attachedData' => '备注',
        'orderDesc' => '测试描述'
    ];
    // 生成预支付码
    $result = $ums->createOrder($options);

    echo '';
    echo "\n--- 创建预支付 ---\n";
    var_export($result);

} catch (Exception $exception) {
    // 出错啦，处理下吧
    echo $exception->getMessage() . PHP_EOL;
}
```

开源协议
----

[](#开源协议)

- gavin/chinaums 基于`MIT`协议发布，任何人可以用在任何地方，不受约束
- gavin/chinaums 部分代码来自互联网，若有异议，可以联系作者进行删除

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Every ~122 days

Total

4

Last Release

339d ago

### Community

Maintainers

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

---

Top Contributors

[![wangjianguo2024](https://avatars.githubusercontent.com/u/172491084?v=4)](https://github.com/wangjianguo2024 "wangjianguo2024 (2 commits)")

### Embed Badge

![Health badge](/badges/gavin-chinaums/health.svg)

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

###  Alternatives

[chargebee/chargebee-php

ChargeBee API client implementation for PHP

768.0M9](/packages/chargebee-chargebee-php)[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[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)[karson/mpesa-php-sdk

172.2k](/packages/karson-mpesa-php-sdk)

PHPackages © 2026

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