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

ActiveLibrary[Payment Processing](/categories/payments)

waymen/alipay
=============

支付宝SDK在Laravel5封装包(包括退款)。

45782PHP

Since Nov 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/liuwm91/Alipay)[ Packagist](https://packagist.org/packages/waymen/alipay)[ RSS](/packages/waymen-alipay/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Alipay
======

[](#alipay)

支付宝SDK在Laravel5封装包。

该拓展包想要达到在Laravel5框架下，便捷使用支付宝的目的。（网页支付未整合进来）

安装
--

[](#安装)

```
composer require waymen/alipay dev-master

```

更新你的依赖包 `composer update` 或者全新安装 `composer install`。

使用
--

[](#使用)

要使用支付宝SDK服务提供者，你必须自己注册服务提供者到Laravel服务提供者列表中。

找到 `config/app.php` 配置文件中，key为 `providers` 的数组，在数组中添加服务提供者。

```
    'providers' => [
        // ...
        'Waymen\Alipay\AlipayServiceProvider',
    ]
```

运行 `php artisan vendor:publish` 命令，发布配置文件到你的项目中。

配置文件 `config/alipay.php` 为支付宝配置信息文件， `config/key` 文件夹下为支付宝需要用到的商户私钥、支付宝公钥、ca证书

例子
--

[](#例子)

### 支付申请

[](#支付申请)

```
	// 创建移动支付单。
	$alipay = app('alipay');
	$alipay->setService('mobile.securitypay.pay');//设置接口名称
	$alipay->setSignType('RSA');//要用RSA签名
	$alipay->setOutTradeNo('order_id');
	$alipay->setTotalFee('order_price');
	$alipay->setSubject('goods_name');
	$alipay->setBody('goods_description');

	// 返回签名后的支付参数给支付宝移动端的SDK。
	return $alipay->getPayPara();
```

### 发起退款

[](#发起退款)

```
    public function postRefund()
    {
        //
        $alipay = app('alipay');
        $alipay->setRefundDate($refund_date);
        $alipay->setBatchNo($batch_no);
        $alipay->setBatchNum($batch_num);
        $alipay->setDetailData($detail_data);
        $alipay->setSellerId($seller_id);
        $alipay->setSellerEmail($seller_email);
        return $alipay->getRefundUrl();  //退款请求url
    }
```

### 结果通知

[](#结果通知)

#### 手机端

[](#手机端)

```
	/**
	 * 支付宝异步通知
	 */
	public function alipayNotify()
	{
		// 验证请求。
		if (! app('alipay')->verify()) {
			Log::notice('Alipay notify post data verification fail.', [
				'data' => Request::instance()->getContent()
			]);
			return 'fail';
		}

		// 判断通知类型。
		switch (Input::get('trade_status')) {
			case 'TRADE_SUCCESS':
			case 'TRADE_FINISHED':
				// TODO: 支付成功，取得订单号进行其它相关操作。
				Log::debug('Alipay notify get data verification success.', [
					'out_trade_no' => Input::get('out_trade_no'),
					'trade_no' => Input::get('trade_no')
				]);
				break;
		}

		return 'success';
	}
```

#### 退款通知

[](#退款通知)

```
	/**
	 * 支付宝退款异步通知
	 */
	public function refundNotity()
	{
        if (! app('alipay')->verify()) {
            Log::notice('Alipay refund notify post data verification fail.', [
                'data' => Request::all()
            ]);
            return 'fail';
        } else {
            Log::info('sucess! The refund notify data', [
                'data' => Request::all(),
            ]);
            return 'sucess';
        }
	}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.5% 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/6e823e1b9d12aa94d733f33cf10f75e2434bc2c59c49e0e1e79f9a476599256f?d=identicon)[waymen](/maintainers/waymen)

---

Top Contributors

[![waymen1](https://avatars.githubusercontent.com/u/12522552?v=4)](https://github.com/waymen1 "waymen1 (16 commits)")[![latrell](https://avatars.githubusercontent.com/u/6267962?v=4)](https://github.com/latrell "latrell (8 commits)")[![daids](https://avatars.githubusercontent.com/u/1639998?v=4)](https://github.com/daids "daids (1 commits)")[![liuwm91](https://avatars.githubusercontent.com/u/6902289?v=4)](https://github.com/liuwm91 "liuwm91 (1 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/waymen-alipay/health.svg)](https://phpackages.com/packages/waymen-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)
