PHPackages                             lovecn/alipaybatchphp - 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. lovecn/alipaybatchphp

ActiveLibrary

lovecn/alipaybatchphp
=====================

支付宝转账api，php版。本package尽量保持官方sdk代码和使对autoload做处理。

1.0.1(10y ago)11371PHP

Since Jan 12Pushed 9y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

composer require lovecn/alipaybatchphp

[支付宝转账api](https://doc.open.alipay.com/doc2/detail?treeId=64&articleId=103569&docType=1)

以下代码采用laravel框架，如果原生php自行改动

\###同步请求

```
    /**
     * 支付宝转账
     * @param  string $batch_no    转账批次号
     * @param  string $batch_fee   付款总金额
     * @param  string $batch_num   付款总笔数
     * @param  string $detail_data 付款详细数据
     * @return string              跳转支付宝
     */
    public function alipay($batch_no, $batch_fee, $batch_num, $detail_data)
    {

        $notify_url = config('services.alipay.notify');;//异步回调地址
        $email = config('services.alipay.email');
        $account_name = config('services.alipay.account');
        $pay_date = date('Ymd');
        /**
        测试
        $batch_no = date('Ymd').rand(1000000,9999999999);
        $batch_fee = 0.02;
        $batch_num = 2;
        $fee = 0.01;
        $detail_data = date('Ymd').rand(1000000,9999999999).'^xxx@qq.com^小明^'.$fee.'^转账|'.date('Ymd').rand(1000000,9999999999).'^xxx@qq.com^小红^'.$fee.'^转账';
        */

        //合作身份者id，以2088开头的16位纯数字
        $alipay_config['partner']       = config('services.alipay.id');

        //安全检验码，以数字和字母组成的32位字符
        $alipay_config['key']           = config('services.alipay.key');

        //签名方式 不需修改
        $alipay_config['sign_type']    = strtoupper('MD5');

        //字符编码格式 目前支持 gbk 或 utf-8
        $alipay_config['input_charset']= strtolower('utf-8');

        //ca证书路径地址，用于curl中ssl校验
        //请保证cacert.pem文件在当前文件夹目录中
        $alipay_config['cacert']    = getcwd().'\\cacert.pem';

        //访问模式,根据自己的服务器是否支持ssl访问，若支持请选择https；若不支持请选择http
        $alipay_config['transport']    = 'http';

        //构造要请求的参数数组，无需改动
        $parameter = array(
            "service" => "batch_trans_notify",
            "partner" => trim($alipay_config['partner']),
            "notify_url"    => $notify_url,
            "email" => $email,
            "account_name"  => $account_name,
            "pay_date"  => $pay_date,
            "batch_no"  => $batch_no,
            "batch_fee" => $batch_fee,
            "batch_num" => $batch_num,
            "detail_data"   => $detail_data,
            "_input_charset"    => trim(strtolower($alipay_config['input_charset']))
        );
        //建立请求
        $alipaySubmit = new \AlipaySubmit($alipay_config);
        $html_text = $alipaySubmit->buildRequestForm($parameter,"get", "确认");

        return $html_text;
    }
```

\###异步回调

```
public function postAlipay()
    {
        $success = Input::get('success_details', '');
        $fail = Input::get('fail_details', '');
        $notifyId = Input::get('notify_id', '');
        $batchNo = Input::get('batch_no', '');
        $alipayConfig = [
            'partner' => config('services.alipay.id'),
            'key' => config('services.alipay.key'),
            'sign_type' => strtoupper('MD5'),
            'input_charset' => strtolower('utf-8'),
            'cacert' => getcwd() . '\\cacert.pem',
            'transport' => 'http',
        ];
        $alipayNotify = new \AlipayNotify($alipayConfig);
        $result = $alipayNotify->verifyNotify();
        if ($result) {
            //更新订单状态
            return 'success';
        }

        return 'fail';
    }
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

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

Total

2

Last Release

3775d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/lovecn-alipaybatchphp/health.svg)

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

PHPackages © 2026

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