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

ActiveLibrary

laravel-alipay/alipay
=====================

支付宝SDK在Laravel5封装包。

161.3k8[3 issues](https://github.com/gaoxuxu123/laravel-alipay/issues)PHP

Since Dec 7Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

\##安装

```
composer require laravel-alipay/alipay dev-master

或者在composer.json中加入

 "require": {

        "laravel-alipay/alipay": "dev-master"
}

```

更新依赖 `composer update`

\##使用说明

找到 `config/app.php` 文件

```
'providers' => [

   Lxu\Alipay\AlipayServiceProvider::class,
]

```

运行 `php artisan vendor:publish` 命令

配置文件 `config/lxu-alipay.php` 已经生成，按照要求配置即可

\##DEMO

\###PC网页支付

```
public function getPay(Request $request)
    {
        //唯一的订单号
        $out_trade_no       = '20160122';
        //订单名称
        $subject            = 'xxxxxxxxxxx';
        //付款金额
        $total_fee          = '0.01';
        //订单描述
        $body               = 'xxxxxxxxxxx';
        $show_url           = '';
        $anti_phishing_key  = '';
        $exter_invoke_ip    = $request->getClientIp();
        $parameter = [
                        "service"           => config('lxu-alipay.pcconfig.service'),
                        "partner"           => trim(config('lxu-alipay.pcconfig.partner')),
                        "seller_id"         => trim(config('lxu-alipay.pcconfig.seller_id')),
                        "payment_type"      => config('lxu-alipay.pcconfig.payment_type'),
                        "notify_url"        => config('lxu-alipay.pcconfig.notify_url'),
                        "return_url"        => config('lxu-alipay.pcconfig.return_url'),
                        "seller_email"      => config('lxu-alipay.pcconfig.seller_email'),
                        "out_trade_no"      => $out_trade_no,
                        "subject"           => $subject,
                        "total_fee"         => $total_fee,
                        "body"              => $body,
                        "show_url"          => $show_url,
                        "anti_phishing_key" => $anti_phishing_key,
                        "exter_invoke_ip"   => $exter_invoke_ip,
                        "_input_charset"    => trim(strtolower(config('lxu-alipay.pcconfig.input_charset')))
                    ];
        $pc =  app('PcAlipay');
        $html_text = $pc->buildRequestForm($parameter,"post", "确认");
        echo $html_text;

        }
     /**
         * 支付宝服务器异步通知
         * @param $request
         * @return mixed
         */
        public function getNotifyurl(Request $request)
        {
            $alipayNotify  = app('PcAlipay');
            $verify_result = $alipayNotify->verifyNotify();
            if($verify_result){
                //验证成功
                //获取支付宝的通知返回参数
            $parameter = [
                        "out_trade_no"      => $request->out_trade_no, //商户订单编号；
                        "trade_no"          => $request->trade_no,     //支付宝交易号；
                        "total_fee"         => $request->total_fee,    //交易金额；
                        "trade_status"      => $request->trade_status, //交易状态
                        "notify_id"         => $request->notify_id,    //通知校验ID。
                        "notify_time"       => $request->notify_time,  //通知的发送时间。格式为yyyy-MM-dd HH:mm:ss。
                        "buyer_email"       => $request->buyer_email,  //买家支付宝帐号；
                         ];
                if($request->trade_status == 'TRADE_FINISHED') {
                        //

                }else if ($request->trade_status == 'TRADE_SUCCESS') {

                        //进行订单处理，并传送从支付宝返回的参数；
                        //检查是否已经支付
                        //checkorderstatus($request->out_trade_no);
                        //修改支付状态
                        //orderHandle($parameter);
                }
                //请不要修改或删除
                echo "success";
            }else {
                //验证失败
                echo "fail";
            }
        }
        /**
         * 支付宝页面跳转同步通知
         * @param $request
         * @return mixed
         */
        public function getReturnurl(Request $request)
        {
            $alipayNotify   = app('PcAlipay');
            $verify_result  = $alipayNotify->verifyReturn();
            if($verify_result){

            $parameter = [
                        "out_trade_no"      => $request->out_trade_no, //商户订单编号；
                        "trade_no"          => $request->trade_no,     //支付宝交易号；
                        "total_fee"         => $request->total_fee,    //交易金额；
                        "trade_status"      => $request->trade_status, //交易状态
                        "notify_id"         => $request->notify_id,    //通知校验ID。
                        "notify_time"       => $request->notify_time,  //通知的发送时间。格式为yyyy-MM-dd HH:mm:ss。
                        "buyer_email"       => $request->buyer_email,  //买家支付宝帐号；
                        ];
                if($request->trade_status == 'TRADE_FINISHED' || $request->trade_status == 'TRADE_SUCCESS') {
                    //支付成功
                    //处理订单状态，记录支付记录
                    //检查是否已经支付
                    //checkorderstatus($request->out_trade_no);
                    //修改支付状态
                    //orderHandle($parameter);
                    //跳转支付成功界面
                    return view('');
                }else{

                    //跳转支付失败界面
                    return view('');
                }
            }else{
                 //echo '支付失败!';
                return view('');
            }
        }

```

\###手机网页支付

```
首先下载 Openssl工具，windows开发者下载链接: http://download.csdn.net/detail/gaoxuaiguoyi/9443275

Linux开发者直接去官网下载openssl.org

解压之后按照:

https://doc.open.alipay.com/doc2/detail.htm?spm=0.0.0.0.y0P2mJ&treeId=58&articleId=103242&docType=1

教程即可生成 rsa_private_key.pem和rsa_public_key.pem  2个文件覆盖项目中的key文件夹下载文件即可。

```

\##待续

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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/ef06e0da5ae8f04f8144998e334b559ee75452dd82adc41f0ec7aec32bee3ab3?d=identicon)[gaoxuxu123](/maintainers/gaoxuxu123)

---

Top Contributors

[![gaoxuxu123](https://avatars.githubusercontent.com/u/11934791?v=4)](https://github.com/gaoxuxu123 "gaoxuxu123 (29 commits)")

### Embed Badge

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

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

PHPackages © 2026

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