hejunjie/alipay-bill-parser
Composer 安装命令:
composer require 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
README 文档
README
English | 简体中文
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.
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.
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
- PHP >= 8.1
- PHP extensions:
ext-zip,ext-mbstring - libzip 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
# 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
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
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
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)
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
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
├── 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
"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
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
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?
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
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
For questions or suggestions, feel free to open an issue.
hejunjie/alipay-bill-parser 适用场景与选型建议
hejunjie/alipay-bill-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 05 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hejunjie/alipay-bill-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hejunjie/alipay-bill-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-27