Skip to content

fix: prevent negative merchant amounts in fee split - #595

Open
Adecom16 wants to merge 1 commit into
Betta-Pay:mainfrom
Adecom16:fix/calculate-split-negative-amount
Open

fix: prevent negative merchant amounts in fee split#595
Adecom16 wants to merge 1 commit into
Betta-Pay:mainfrom
Adecom16:fix/calculate-split-negative-amount

Conversation

@Adecom16

Copy link
Copy Markdown

Fixes #355

Prevents calculate_split from producing a negative merchant_amount when independently rounded-up fees exceed the payment amount.

Changes

  • Added validation for invalid fee splits.
  • Prevented fee calculations from extracting more than the payment amount.
  • Added regression tests covering rounding and over-extraction cases.
  • Updated affected settlement/payment tests.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test

All relevant checks pass.

Impact

Valid fee calculations remain unchanged. Invalid fee configurations now fail safely instead of storing or processing a negative merchant payout.

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.

calculate_split ceiling division can extract >100% of payment value with zero downstream validation

1 participant