Skip to content

fix: reject malformed invoice amounts before creating payments - #97

Merged
ralyodio merged 2 commits into
profullstack:masterfrom
zhangzhenggit:fix/validate-invoice-amount-format
Sep 12, 2026
Merged

fix: reject malformed invoice amounts before creating payments#97
ralyodio merged 2 commits into
profullstack:masterfrom
zhangzhenggit:fix/validate-invoice-amount-format

Conversation

@zhangzhenggit

Copy link
Copy Markdown
Contributor

parseAmount currently removes every $, comma and whitespace character before validating. This turns malformed input such as 1,2, 1$2 and 1 2 into a valid $12.00 invoice, which could charge a different amount from what the sender entered.

Validate the input first: allow a leading dollar sign, plain digits or properly grouped thousands, and up to two decimal places. Strip only the accepted formatting after validation. Add regression coverage for malformed separators, symbols and embedded spaces while preserving valid $1,200.50 and surrounding whitespace.

Validation: pnpm run build && node --test test/billing.test.ts (9 passing).

@ralyodio
ralyodio merged commit a39db4f into profullstack:master Sep 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants