PHPackages                             hejunjie/alipay-bill-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. hejunjie/alipay-bill-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

hejunjie/alipay-bill-parser
===========================

一个高性能、自动化的支付宝账单解析器，支持压缩包密码自动破解与账单数据智能提取，适用于账单分析、账单自动化入账、个人理财工具开发等场景 | A fast, automated Alipay bill parser that cracks compressed file passwords and extracts bill data. Perfect for bill analysis, automatic bookkeeping, and personal finance tools

v1.1.1(1mo ago)3301MITPHPPHP &gt;=8.1

Since May 26Pushed 1mo agoCompare

[ Source](https://github.com/zxc7563598/php-alipay-bill-parser)[ Packagist](https://packagist.org/packages/hejunjie/alipay-bill-parser)[ RSS](/packages/hejunjie-alipay-bill-parser/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

hejunjie/alipay-bill-parser
===========================

[](#hejunjiealipay-bill-parser)

English ｜ [简体中文](./README.zh-CN.md)

A PHP library that automatically cracks Alipay bill ZIP passwords and extracts transaction details. Combined with email monitoring scripts, it enables fully automated bill collection and parsing.

[![Packagist Version](https://camo.githubusercontent.com/513e40f1d77cdecb7436f5329ea91e7e01c6d141a9d1d6fd616ca59f4b7045fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68656a756e6a69652f616c697061792d62696c6c2d706172736572)](https://packagist.org/packages/hejunjie/alipay-bill-parser)[![PHP Version](https://camo.githubusercontent.com/634e62d5b9d31528ab9248f288e140e8b37a5738b2541ab4f52d682d0dccd5d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f68656a756e6a69652f616c697061792d62696c6c2d706172736572)](https://packagist.org/packages/hejunjie/alipay-bill-parser)[![License](https://camo.githubusercontent.com/46215e9505583b313a896c8864f804f280ade59ad8436ca18c8df4b9ad17dc9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f68656a756e6a69652f616c697061792d62696c6c2d706172736572)](LICENSE)

Warning

This project is for learning and communication purposes only. Commercial or illegal use is strictly prohibited.

**Want a quick overview?** The codebase has been parsed by [Zread](https://zread.ai/zxc7563598/php-alipay-bill-parser).

Features
--------

[](#features)

- 🔐 **Automatic password cracking**: Built-in C-based multithreaded brute-force tool for 6-digit numeric passwords, significantly faster than pure PHP implementations
- 📦 **No manual extraction**: Automatically detects encrypted ZIP files, extracts them, and reads the CSV bill file inside
- 📄 **Smart encoding detection**: Auto-detects UTF-8 / GBK / CP936 encodings to prevent garbled Chinese characters
- 🧩 **Callback-driven flow control**: Flexibly control the parsing process via callbacks — retrieve only the password, only the data, or abort at any stage
- 📬 **Automation-friendly**: Works with email monitoring scripts to achieve fully automated bill processing

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- PHP extensions: `ext-zip`, `ext-mbstring`
- [libzip](https://libzip.org/) development library (for compiling the C brute-force tool)
- GCC (usually pre-installed on macOS / Linux; Windows users need a pre-compiled `zip_bruteforce.exe`)

### Installing libzip

[](#installing-libzip)

```
# macOS
brew install libzip

# Ubuntu / Debian
sudo apt install libzip-dev
```

Windows users are recommended to use WSL, or use a pre-compiled `zip_bruteforce.exe`.

Installation
------------

[](#installation)

```
composer require hejunjie/alipay-bill-parser
```

On first use, the library automatically detects the libzip environment and compiles the C brute-force tool. If compilation fails, make sure libzip is properly installed.

Quick Start
-----------

[](#quick-start)

```
use Hejunjie\AlipayBillParser\AlipayBillParser;
use Hejunjie\AlipayBillParser\ParseOptions;

$zipFile = '/path/to/alipay-transactions(20240501-20250430).zip';

$options = new ParseOptions($zipFile);
$options->onPasswordFound = function ($password) {
    echo "Password: $password\n";
    return true; // Return false to abort subsequent parsing
};
$options->onDataParsed = function ($data) {
    echo "Name: " . $data['real_name'] . PHP_EOL;
    echo "Account: " . $data['account'] . PHP_EOL;
    echo "Total records: " . count($data['data']) . "\n";
    return true;
};

$parser = new AlipayBillParser();
$parser->parse($options);
```

Usage
-----

[](#usage)

### Get password only

[](#get-password-only)

```
$options = new ParseOptions('/path/to/bill.zip');
$options->onPasswordFound = function ($password) {
    echo "Password: $password\n";
    return false; // Return false to skip CSV parsing
};

(new AlipayBillParser())->parse($options);
```

### Get bill data only (when password is known)

[](#get-bill-data-only-when-password-is-known)

If you already know the ZIP password, you can ignore it in the `onPasswordFound` callback and let the flow proceed to data extraction. Alternatively, extend `ZipPasswordCracker` to skip the brute-force step entirely.

### Output data structure

[](#output-data-structure)

The `$data` array passed to the `onDataParsed` callback:

```
[
    'real_name' => '张三',           // Alipay real name
    'account'   => '18273727771',    // Registered account (phone number or email)
    'data'      => [
        // Each record contains 12 fields
        ['Transaction Time', 'Transaction Category', 'Counterparty', 'Counterparty Account', 'Product Description', 'Income/Expense', 'Amount', 'Payment Method', 'Transaction Status', 'Transaction Order No.', 'Merchant Order No.', 'Remarks'],
        // ...
    ],
]
```

Directory Structure
-------------------

[](#directory-structure)

```
├── bin/zip_bruteforce.c    # C source code for the brute-force tool
├── resources/               # Compiled binary (zip_bruteforce executable)
├── src/
│   ├── AlipayBillParser.php    # Entry point, orchestrates the parsing pipeline
│   ├── ParseOptions.php        # Options DTO (ZIP path + callbacks)
│   ├── ZipPasswordCracker.php  # Password cracker (invokes the C binary)
│   ├── CsvExtractor.php        # ZIP extraction and CSV parsing
│   └── Installer.php           # libzip environment detection and C compilation
├── composer.json
├── README.md
└── README.zh-CN.md

```

FAQ
---

[](#faq)

### "zip\_bruteforce executable not found and cannot be auto-compiled"

[](#zip_bruteforce-executable-not-found-and-cannot-be-auto-compiled)

Your system is likely missing the libzip development library or GCC. Install the required dependencies as described in the Requirements section and try again.

### Password cracking failed with a non-zero exit code

[](#password-cracking-failed-with-a-non-zero-exit-code)

Alipay bill ZIP passwords are typically 6-digit numbers. This tool brute-forces the range 000000–999999. If the password falls outside this range (e.g., alphanumeric), cracking will fail.

### Garbled Chinese characters in CSV output

[](#garbled-chinese-characters-in-csv-output)

The library includes automatic UTF-8 / GBK / CP936 detection and conversion, so garbled text should not occur under normal circumstances. If you encounter an unexpected encoding, please file an issue with a sanitized sample of the bill file.

### Which Alipay bill formats are supported?

[](#which-alipay-bill-formats-are-supported)

This tool is designed for the "Transaction Details" ZIP file exported from the Alipay web portal. Other bill export formats may not be compatible.

Motivation
----------

[](#motivation)

I maintain a personal finance tracker, but the bill formats exported by Alipay and WeChat are inconsistent and often arrive as encrypted ZIP files. Manually processing them every time was tedious. So I built this tool — paired with automatic email forwarding, it parses bill emails into structured data with a single step, eliminating download, extraction, and manual verification. Hopefully it helps others with the same need.

Contact
-------

[](#contact)

For questions or suggestions, feel free to [open an issue](https://github.com/zxc7563598/php-alipay-bill-parser/issues).

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance93

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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.

###  Release Activity

Cadence

Every ~137 days

Total

4

Last Release

34d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b65d4b40ae456172fb38f63f84bf737ac88031484b1f228b1cc8d71baa80adf?d=identicon)[苏青安](/maintainers/%E8%8B%8F%E9%9D%92%E5%AE%89)

---

Top Contributors

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

---

Tags

alipayautomationbill-parsercsv-parserfinancial-toolpassword-bruteforcepersonal-financephp-library

### Embed Badge

![Health badge](/badges/hejunjie-alipay-bill-parser/health.svg)

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

###  Alternatives

[mwgg/airports

A JSON collection of ~29k entries with basic information about nearly every airport and landing strip in the world

7683.4k](/packages/mwgg-airports)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9845.4k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46164.0k6](/packages/jstewmc-rtf)[glauberportella/cnab-layouts-parser

Parser de arquivos de configuração CNAB gerados no projeto https://github.com/glauberportella/cnab-layouts

2154.5k](/packages/glauberportella-cnab-layouts-parser)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.4k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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