fix(ancpi): add credit parsing debug logging
This commit is contained in:
@@ -272,7 +272,28 @@ export class EpayClient {
|
||||
const match2 = html.match(/(\d+)\s+puncte?\s+de\s+credit/i);
|
||||
if (match2) return parseInt(match2[1] ?? "0", 10);
|
||||
|
||||
console.warn("[epay] Could not parse credits from HTML");
|
||||
// Broader search: any number near "credit"
|
||||
const match3 = html.match(/credit[^<]{0,30}?(\d+)|(\d+)[^<]{0,30}?credit/i);
|
||||
if (match3) {
|
||||
const n = parseInt(match3[1] ?? match3[2] ?? "0", 10);
|
||||
if (n > 0) return n;
|
||||
}
|
||||
|
||||
// Log context around "credit" or "punct" for debugging
|
||||
const creditIdx = html.toLowerCase().indexOf("credit");
|
||||
if (creditIdx >= 0) {
|
||||
console.log(
|
||||
"[epay] Credit context:",
|
||||
html.slice(Math.max(0, creditIdx - 80), creditIdx + 80),
|
||||
);
|
||||
} else {
|
||||
// Maybe the page didn't load — check if we're on the login page
|
||||
const isLoginPage = html.includes("IDToken1");
|
||||
console.warn(
|
||||
`[epay] No 'credit' found in HTML (${html.length} chars, isLogin=${isLoginPage})`,
|
||||
);
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user