fix(courier): parse XFX form-urlencoded track callbacks and raw ACK

Enable urlencoded body parser, return XFX {code,message} without API envelope, and harden callback payload parsing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-06 17:51:00 +08:00
parent 83b1b0e5f6
commit 571959900b
4 changed files with 31 additions and 9 deletions
@@ -138,7 +138,15 @@ export class XiaofeixiaProvider implements ICourierProvider {
parseTrackCallback(body: unknown): TrackCallbackPayload | null {
if (!body || typeof body !== 'object') return null;
const raw = body as Record<string, unknown>;
const root = body as Record<string, unknown>;
// 兼容顶层字段或 data/payload 包裹
const nested =
root.data && typeof root.data === 'object'
? (root.data as Record<string, unknown>)
: root.payload && typeof root.payload === 'object'
? (root.payload as Record<string, unknown>)
: null;
const raw = nested ? { ...nested, ...root } : root;
const outNumber = String(raw.outNumber ?? '').trim();
const trackingNumber = String(raw.number ?? raw.trackingNumber ?? '').trim();
const status = String(raw.status ?? '').trim();