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

ActiveLibrary[Payment Processing](/categories/payments)

kollway/alipay
==============

Alipay payment library.

2.0.1(8y ago)1266MITPHPPHP &gt;=5.4.0

Since May 10Pushed 8y ago2 watchersCompare

[ Source](https://github.com/kollway-app/alipay)[ Packagist](https://packagist.org/packages/kollway/alipay)[ RSS](/packages/kollway-alipay/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

签名方式
====

[](#签名方式)

md5 签名方式

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

rsa 签名方式

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

生成 Alipay 实例

```
use Foccy\Alipay\Alipay;
use Foccy\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

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Recently: every ~148 days

Total

7

Last Release

2969d ago

Major Versions

1.0.4 → 2.0.02018-03-22

### Community

Maintainers

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

---

Top Contributors

[![kollway-app](https://avatars.githubusercontent.com/u/16223088?v=4)](https://github.com/kollway-app "kollway-app (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
