PHPackages                             cxb/alipay - 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. cxb/alipay

ActiveLibrary

cxb/alipay
==========

Alipay payment library.

00PHP

Since Nov 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/a1109742518/Alipay)[ Packagist](https://packagist.org/packages/cxb/alipay)[ RSS](/packages/cxb-alipay/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

签名方式
====

[](#签名方式)

md5 签名方式

```
use Cxb\Alipay\Signer\MD5Signer;
$md5Signer = new MD5Signer('a2d9bm4jfk0slemvpaq23');
$alipay->addSigner($md5Signer);
```

rsa 签名方式

```
use Cxb\Alipay\Signer\RSASigner;
$rsaSigner = new RSASigner(__DIR__ . '/my_private_key', __DIR__ . '/alipay_pub_key');
$alipay->addSigner($rsaSigner);
```

生成 Alipay 实例

```
use Cxb\Alipay\Alipay;
use Cxb\Alipay\Signer\SignerInterface;

// 生成 Alipay 实例，签名方式包括`md5`和`rsa`，默认`md5`方式签名
$alipay = Alipay::create('2008...', [$md5Signer, $rsaSigner], SignerInterface::TYPE_MD5);
```

### PC网页支付

[](#pc网页支付)

对应支付宝接口服务名 `create_direct_pay_by_user`

```
$webPay = $alipay->createWebPay('out_order_number', 'product_name', '0.01', 'http://www.example.com/payNotify', 'http://www.example.com/payReturn');

// 生成支付宝支付URL
echo $webPay->compose(); // 生成跳转到支付宝的URL

// 设置网银支付银行
$webPay->set('defaultbank', 'CMB');
echo $webPay->compose();

// 以RSA签名方式生成支付URL
echo $webPay->compose(SignerInterface::TYPE_RSA);
```

### WAP网页支付

[](#wap网页支付)

对应支付宝接口服务名 `alipay.wap.create.direct.pay.by.user`

```
$wapPay = $alipay->createWapPay('out_order_number', 'product_name', '0.01', 'http://www.example.com/payNotify', 'http://www.example.com/payReturn');

echo $wapPay->compose(); // 生成支付宝支付URL
```

### 手机客户端支付

[](#手机客户端支付)

对应支付宝接口服务名 `mobile.securitypay.pay`

```
$mobilePay = $alipay->createMobilePay('out_order_number', 'foo', 'body', '0.01', 'http://www.exmaple.com/payNotify');

// 手机客户端只支持 RSA 签名
echo $mobilePay->compose(SignerInterface::TYPE_RSA);
```

### 验证 return 或 notify 通知

[](#验证-return-或-notify-通知)

```
$parameters = $_POST; // $parameters = $_GET;
$verifier = $alipay->createVerifier($parameters);
if ($verifier->verify()) {
    switch ($verifier->getParam('trade_status')) {
        case 'TRADE_FINISHED':
        case 'TRADE_SUCCESS':
            // 支付成功, 处理业务逻辑
            break;
        default:
            // 未能支付成功
            break;
    }
    // 通过验证
} else {
    // 验证失败
}
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2167a39008e53fdbee860e69dbc659e874ad1214939880783ebc7490d9dfb1ad?d=identicon)[chenxiabin](/maintainers/chenxiabin)

---

Top Contributors

[![a1109742518](https://avatars.githubusercontent.com/u/13092875?v=4)](https://github.com/a1109742518 "a1109742518 (3 commits)")

### Embed Badge

![Health badge](/badges/cxb-alipay/health.svg)

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

PHPackages © 2026

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