PHPackages                             simple-pay/simple-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. [Payment Processing](/categories/payments)
4. /
5. simple-pay/simple-pay

ActiveLibrary[Payment Processing](/categories/payments)

simple-pay/simple-pay
=====================

0.0.1(6y ago)281Apache-2.0PHPPHP &gt;=7.0

Since Aug 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/keep-on-moving/simplePay)[ Packagist](https://packagist.org/packages/simple-pay/simple-pay)[ RSS](/packages/simple-pay-simple-pay/feed)WikiDiscussions master Synced 3d ago

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

simplePay
=========

[](#simplepay)

基于tp5.1的简单支付（包含微信和支付宝）

\#composer 安装

`composer require simple-pay/simple-pay`

\#使用方法

- 引入微信包

```
use Payment\Wechat;

$wechat = new Wechat('自己的APPid', '商户号', 'key', 'appsecret');

```

- Jsapi支付前获取微信公众号的基本配置

```
$jsApiConfig = $wechat->getJsApiConfig();
/**  返回示例：
Array(
    [appId] => wxc593a8ebd05
    [nonceStr] => KtDFZk6OiJzNC4aA
    [timestamp] => 1566198080
    [url] => http://
    [signature] => bdbf2662b06c6f1e89480af1f38571ad126425fa
    [rawString] => jsapi_ticket=HoagFKDcsGMVCIY2vOjf9jz92X0lEpl4qscVOAj0yMzD1v4a
    pgH53sBtVGRhWvDTXJGtchYzMnFr6CSqRnpaVQ&noncestr=KtDFZk6OiJzNC4aA&timestamp=15661
    98080&url=http://
)
 */

```

- jsapi下订单

```
$data = array(
    'appid' => '公众号APPID',
    'mch_id' => trim('商户号'),
    'nonce_str' => md5(rand(100000,999999)),//随机串
    'sign_type' => 'MD5',
    'body' => '这是商品描述',//商品描述
    'out_trade_no' => getOrderNum(),//订单号
    'total_fee' => 1,//总金额(金额计数单位为：分)
    'spbill_create_ip' => '127.0.0.1',//终端ip
    'notify_url' => 'http://'.$_SERVER['HTTP_HOST'].'/api/v2/payment/wechatNotify',//回到地址
    'trade_type' => 'JSAPI',//下订单类型
    'openid' => 'oH1nC1MgvPDgxlrht_BUGOGKwgGk'//微信openID
);

$jsApiPayData = $wechat->jsApiOrder($data);
/**  返回示例
Array
(
    [code] => 200
    [msg] => 请求成功
    [data] => Array
        (
            [appId] => aaaaaaaaaaaaa
            [timeStamp] => 1566195877
            [nonceStr] => MCW5QQJbynatFkDG
            [package] => prepay_id=wx19142453170181d742e42f8e1703803700
            [signType] => MD5
            [sign] => 18EB52B78EF7D2EE9B34BD80153FC530
        )
)
 */

```

- app内微信下单

```
$data = array(
    'appid' => 'wx2decb75684523216',
    'mch_id' => trim('15012329821'),
    'nonce_str' => md5(rand(100000,999999)),//随机串
    'sign_type' => 'MD5',
    'body' => '这是商品描述',//商品描述
    'out_trade_no' => getOrderNum(),//订单号
    'total_fee' => 1,//总金额(金额计数单位为：分)
    'spbill_create_ip' => '127.0.0.1',//终端ip
    'notify_url' => 'http://'.$_SERVER['HTTP_HOST'].'/api/v2/payment/wechatNotify',//回到地址
    'trade_type' => 'APP',//下订单类型
);

$appPayData = $wechat->appOrder($data);
/** 返回示例：
Array
(
    [code] => 200
    [msg] => 请求成功
    [data] => Array
        (
            [appid] => wx2decb75232533316
            [partnerid] => 1501389821
            [prepayid] => wx19151434358615bb561723f21570864400
            [package] => Sign=WXPay
            [noncestr] => 8hmmnF9rfVML5xCR
            [timestamp] => 1566198858
        )

)
 */

```

- 微信回调(包含jsapi和APP)

```
$testxml  = file_get_contents("php://input");  //接收微信发送的支付成功信息
$result = XMLDataParse($testxml);
/** 数据示例
$result = array(
    "appid" => "wx2421b63211370ec43b",
    "attach" =>  "支付测试",
    "bank_type" =>"CFT",
    "fee_type" =>  "CNY",
    "is_subscribe" =>  "Y",
    "mch_id" =>  "100099100",
    "nonce_str" => "5d2b6c2a8db53831f7eda20af46e531c",
    "openid" =>  "oUpF8uMEb4qRXf22hE3X68TekukE",
    "out_trade_no" =>  "s129929113168",//外部订单号（即自己平台的订单号）
    "result_code" =>  "SUCCESS",
    "return_code" => "SUCCESS",
    "sign" =>  "B552ED6B279343CB493C5DD0D78AB241",
    "sub_mch_id" =>  "10000100",
    "time_end" =>  "20140903131540",
    "total_fee" =>  "1",
    "coupon_fee" =>  "10",
    "coupon_count" =>  "1",
    "coupon_type" => "CASH",
    "coupon_id" => "10000",
    "coupon_fee_0" =>  "100",
    "trade_type" =>  "JSAPI",
    "transaction_id" => "1004400740201409030005092168",//流水号
);*/
if($result['trade_type'] == 'jsapi'){
    $wechat = new Wechat('jsapi的APPID', 'jsapi的mchid', 'jsapi的key', 'jsapi的appsecret');
}else{
    $wechat = new Wechat('app绑定微信的APPID', 'app绑定微信的mchid', 'app绑定微信的key', 'app绑定微信的appsecret');
}
$data = $wechat->notify($result);
if($data['code'] == 200){
    //todo  继续逻辑
}else{
    //todo 回调异常处理
}

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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

2460d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/252ab5a69eb5d979bd42bd67b8700b888e787d8c999d35bd4b035a54e70e1999?d=identicon)[secondtie](/maintainers/secondtie)

---

Top Contributors

[![keep-on-moving](https://avatars.githubusercontent.com/u/19165411?v=4)](https://github.com/keep-on-moving "keep-on-moving (15 commits)")[![heyanlong](https://avatars.githubusercontent.com/u/3367958?v=4)](https://github.com/heyanlong "heyanlong (1 commits)")

---

Tags

php7

### Embed Badge

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

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

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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