Skip to content

feat(cli): add partial payment support and preview to iln pay command…#307

Open
BernardOnuh wants to merge 1 commit into
Invoice-Liquidity-Network:mainfrom
BernardOnuh:feat/cli-pay-partial
Open

feat(cli): add partial payment support and preview to iln pay command…#307
BernardOnuh wants to merge 1 commit into
Invoice-Liquidity-Network:mainfrom
BernardOnuh:feat/cli-pay-partial

Conversation

@BernardOnuh

Copy link
Copy Markdown

What this PR does

Implements the iln pay command with partial payment mode and a payment preview before signing — resolving the two missing features called out in #232.


Usage

# Full payment (defaults to remaining balance)
iln pay --id INV-100

# Partial payment
iln pay --id INV-100 --amount 50

# Skip confirmation
iln pay --id INV-100 --amount 50 --yes

User-facing output

Preview (shown before signing):
Paying 50 USDC of 100 USDC remaining on Invoice #INV-100 (Payer earns LP: 0.25 USDC)

Partial progress:
Paid 50 USDC. 50 USDC remaining.

Settlement receipt (full payment):
── Settlement Receipt ──────────────────────────────

Invoice: INV-100

Paid: 100 USDC

Remaining: 0 USDC

LP earned: 0.5 USDC

Tx hash: TX_ABC123

Status: FULLY PAID ✓

────────────────────────────────────────────────────


Files changed

File What
cli/src/commands/pay-types.ts PayOptions, InvoicePayState, PayResult types
cli/src/commands/pay.ts Command factory + preview/receipt printers
cli/tests/e2e/pay.test.ts 14 tests across all flows
cli/src/index.ts Wired makePayCommand into the CLI

Test coverage

Scenario Covered
Full payment calls executor with remaining balance
Partial payment calls executor with --amount value
Amount exceeding remaining balance rejected with error
Preview printed before signing
LP earnings note shown / hidden based on invoice
Confirmation prompt shown without --yes
Prompt skipped with --yes
Payment cancelled on user decline
Settlement receipt on full payment
Partial progress line on partial payment

Closes #232

…Invoice-Liquidity-Network#232)

- Add cli/src/commands/pay-types.ts
  PayOptions, InvoicePayState, PayResult

- Add cli/src/commands/pay.ts
  - makePayCommand(prompter, fetcher, executor) — injected-deps pattern
  - Full payment: iln pay --id X (uses remaining amount)
  - Partial payment: iln pay --id X --amount 50
  - Payment preview before signing with LP earnings note
  - Confirmation prompt (skipped with --yes)
  - printSettlementReceipt: full breakdown with LP earnings and tx hash
  - printPartialProgress: 'Paid X USDC. Y USDC remaining.'
  - Amount validation: rejects amounts exceeding remaining balance

- Add cli/tests/e2e/pay.test.ts (14 tests)
  Full payment, partial payment, preview, confirmation, cancellation,
  receipt printers, amount validation

Closes Invoice-Liquidity-Network#232
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@BernardOnuh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Implement iln pay command for payers

1 participant