Skip to content

refactor: extract _refund_payers helper to deduplicate refund logic - #131

Open
MarcusDavidG wants to merge 1 commit into
mainfrom
refactor/extract-refund-payers-helper
Open

refactor: extract _refund_payers helper to deduplicate refund logic#131
MarcusDavidG wants to merge 1 commit into
mainfrom
refactor/extract-refund-payers-helper

Conversation

@MarcusDavidG

Copy link
Copy Markdown
Contributor

Three functions (refund, cancel_invoice, resolve_dispute) each contained identical ~15 line blocks: iterate payments → aggregate by payer into a Map → transfer → emit pyr event.

Changes

  • New private _refund_payers(env, invoice_id, invoice) helper
  • refund(), cancel_invoice(), and resolve_dispute(release=false) all delegate to it
  • Zero behaviour change — all 92 existing tests still pass

Closes #122

refund(), cancel_invoice(), and resolve_dispute(release=false) all
iterated payments, aggregated by payer, and transferred. This
extracts that logic into a single private _refund_payers() helper.

- ~40 lines of duplicated code removed
- Behaviour is identical — Map aggregation + pyr event per payer
- resolve_dispute updated to use the helper

Closes #122
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.

refactor: extract _refund_payers helper to deduplicate refund logic in refund(), cancel_invoice(), and resolve_dispute()

1 participant