#payment #pku #cli #campus-card

bin+lib pku-campuscard

北大校园卡 CLI 客户端

5 releases

0.1.4 Apr 29, 2026
0.1.3 Apr 28, 2026
0.1.2 Apr 15, 2026
0.1.1 Apr 10, 2026
0.1.0 Apr 9, 2026

#3 in #payment


MIT license

110KB
2.5K SLoC

pku-campuscard

A command-line client for PKU Campus Card (校园卡).

crates.io License

Check your campus card balance, show payment QR codes, view transaction history, and see monthly spending breakdowns -- all from the terminal.

Install

cargo install pku-campuscard

Or install the complete PKU toolkit:

cargo install pku-cli

Setup

Store your IAAA credentials once (encrypted in your OS keychain):

cargo install pku-auth
info-auth store

Then login:

campuscard login -p

Usage

Card Info & Payment

campuscard info                  # Card details & current balance
campuscard pay                   # Show payment QR code in terminal
campuscard pay -o qr.png         # Export payment QR to a PNG file

Recharge

campuscard recharge              # Interactive amount selection
campuscard recharge -a 100       # Top up 100 yuan

Transaction History

campuscard bills                 # Recent transactions
campuscard bills -p 2 -n 20      # Page 2, 20 per page
campuscard bills -m 2026-03      # March 2026 only
campuscard ls                    # Short alias for bills

Statistics

campuscard stats                 # Current month spending breakdown
campuscard stats -m 2026-03      # Specific month

TOTP (手机令牌)

campuscard otp bind              # Bind mobile token
campuscard otp show              # Display current OTP

How It Works

Campus card data comes from the Synjones platform at bdcard.pku.edu.cn. The auth chain is:

IAAA SSO → portal2017 → berserker-auth → Synjones JWT

The client uses a mobile User-Agent (PKUANDROID) and forces HTTP/1.1, as the server does not support HTTP/2.

Dependencies

~26–47MB
~679K SLoC