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

ActiveLibrary[Payment Processing](/categories/payments)

wander/alipay
=============

支付宝支付接口--PHP版

v1.0.1(4y ago)326MITPHPPHP &gt;=7.1

Since Aug 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/wanderpub/alipay)[ Packagist](https://packagist.org/packages/wander/alipay)[ Docs](https://github.com/wanderpub/alipay.git)[ RSS](/packages/wander-alipay/feed)WikiDiscussions main Synced 5d ago

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

Alipay
======

[](#alipay)

支付宝支付接口 for PHP
---------------

[](#支付宝支付接口-for-php)

建议在 PHP7.1 上运行以获取最佳性能； Alipay API SDK for PHP

功能描述
----

[](#功能描述)

- 支付宝支付（账单、转账、App支付、刷卡支付、扫码支付、Web支付、Wap支付等）

Alipay 是基于官方API接口封装，在开发前，必需先阅读支付宝官方文档。

- 支付宝官方文档：

安装使用
----

[](#安装使用)

1.1 通过 Composer 来管理安装

```
# 首次安装
composer require wander/alipay

# 更新 Alipay
composer update wander/alipay
```

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

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

支付宝支付配置说明
---------

[](#支付宝支付配置说明)

- 支付参数配置（可用沙箱模式）

```
$config = [
    // 沙箱模式
    'debug'       => true,
    // 签名类型（RSA|RSA2）
    'sign_type'   => "RSA2",
    // 应用ID
    'appid'       => '20160909000000',
    // 支付宝公钥文字内容 (1行填写，特别注意：这里是支付宝公钥，不是应用公钥，最好从开发者中心的网页上去复制)
    'public_key'  => 'MIIBIj0000...',
    // 支付宝私钥文字内容 (1行填写)
    'private_key' => 'MIIEv0000...',
    // 应用公钥证书完整内容（新版资金类接口转 app_cert_sn）
    'app_cert'    => '',
    // 支付宝根证书完整内容（新版资金类接口转 alipay_root_cert_sn）
    'root_cert'   => '',
    // 支付成功通知地址
    'notify_url'  => '',
    // 网页支付回跳地址
    'return_url'  => '',
];
```

- 支付宝发起PC网站支付

```
// 参考公共参数  https://docs.open.alipay.com/203/107090/
$config['notify_url'] = '';//支付回调地址
$config['return_url'] = '';//支付成功返回地址

try {

    // 实例支付对象
    $pay = \Alipay\Web::instance($config);
    // $pay = new \Alipay\Web($config);

    // 参考链接：https://docs.open.alipay.com/api_1/alipay.trade.page.pay
    $result = $pay->apply([
        'out_trade_no' => time(), // 商户订单号
        'total_amount' => '1',    // 支付金额
        'subject'      => '支付订单描述', // 支付订单描述
    ]);

    echo $result; // 直接输出HTML（提交表单跳转)

} catch (Exception $e) {

    // 异常处理
    echo $e->getMessage();

}
```

- 支付宝发起手机网站支付

```
// 参考公共参数  https://docs.open.alipay.com/203/107090/
$config['notify_url'] = '';//支付回调地址
$config['return_url'] = '';//支付成功返回地址

try {

    // 实例支付对象
    $pay = \Alipay\Wap::instance($config);
    // $pay = new \Alipay\Wap($config);

    // 参考链接：https://docs.open.alipay.com/api_1/alipay.trade.wap.pay
    $result = $pay->apply([
        'out_trade_no' => time(), // 商户订单号
        'total_amount' => '1',    // 支付金额
        'subject'      => '支付订单描述', // 支付订单描述
    ]);

    echo $result; // 直接输出HTML（提交表单跳转)

} catch (Exception $e) {

    // 异常处理
    echo $e->getMessage();

}
```

开源协议
----

[](#开源协议)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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 ~0 days

Total

2

Last Release

1722d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15603923?v=4)[wanderpub](/maintainers/wanderpub)[@wanderpub](https://github.com/wanderpub)

---

Top Contributors

[![wander112900](https://avatars.githubusercontent.com/u/3345283?v=4)](https://github.com/wander112900 "wander112900 (12 commits)")[![wanderpub](https://avatars.githubusercontent.com/u/15603923?v=4)](https://github.com/wanderpub "wanderpub (1 commits)")

---

Tags

alipay

### Embed Badge

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

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

###  Alternatives

[yansongda/pay

可能是我用过的最优雅的 Alipay 和 WeChat 的支付 SDK 扩展包了

5.3k1.2M53](/packages/yansongda-pay)[yansongda/laravel-pay

专注 Alipay/WeChat/Unipay 的 laravel 支付扩展包

1.1k353.2k9](/packages/yansongda-laravel-pay)[lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

587421.0k11](/packages/lokielse-omnipay-alipay)[latrell/alipay

支付宝SDK在Laravel5封装包。

40349.2k](/packages/latrell-alipay)[yansongda/hyperf-pay

可能是基于 hyperf 的最优雅的支付宝、微信、银联支付 SDK 了

8959.8k1](/packages/yansongda-hyperf-pay)[lokielse/omnipay-global-alipay

Alipay global gateway for Omnipay payment processing library

3048.9k](/packages/lokielse-omnipay-global-alipay)

PHPackages © 2026

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