Skip to content

feat: seller invoice actions - cancel, resend link, and detail management (#288) - #360

Draft
s6pa1rta3n-lab wants to merge 1 commit into
Quittance-Labs:mainfrom
s6pa1rta3n-lab:fix-issue-288
Draft

feat: seller invoice actions - cancel, resend link, and detail management (#288)#360
s6pa1rta3n-lab wants to merge 1 commit into
Quittance-Labs:mainfrom
s6pa1rta3n-lab:fix-issue-288

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Resolves #288. Implements end-to-end seller invoice management actions:

  • Invoice Cancellation: Sellers can cancel pending invoices directly from the invoice detail page and dashboard cards with a confirmation prompt and optimistic UI updates.
  • Backend Authorization: Gated cancellation on POST /api/invoices/:id/cancel requiring the requesting wallet to match sellerPublicKey (returning 403 Forbidden on mismatch, 400 Bad Request if already paid/expired).
  • Copy Actions: Direct Copy Pay Link and Copy Invoice ID buttons with toast feedback.
  • Payment Proof Navigation: Jump to payment proof / view proof on paid invoices.
  • Public Pay Page Handling: Dedicated CANCELLED status view on /pay/[id] preventing payment attempts.

Changes & Touch List (32 files changed, >= 25 from touch list)

Backend

  • backend/src/routes/invoice.handlers.ts: Handled sellerPublicKey parameter in cancelInvoice with 403 on authorization failure and validation.
  • backend/src/routes/invoice.routes.ts: Documented cancel endpoint seller authorization.
  • backend/src/types/api.ts & backend/src/utils/validation.ts: Exported CancelInvoiceInput and cancelInvoiceSchema.
  • backend/src/storage/invoice-storage.ts, backend/src/storage/memory-storage.ts, backend/src/storage/memory-invoice-storage.ts, backend/src/storage/postgres-invoice-storage.ts: Forwarded and enforced sellerPublicKey check and expiry check in storage layers.
  • backend/src/services/invoice-memory.service.ts & backend/src/services/invoice.service.ts: Enforced seller wallet authorization in both memory and Postgres services.
  • backend/tests/invoice-handlers.test.ts, backend/tests/invoice-service.test.ts, backend/tests/memory-storage.test.ts: Added unit tests covering cancellation authorization, 403 mismatch rejection, and status transitions.

Frontend

  • frontend/app/invoice/[id]/page.tsx: Integrated connected wallet check, confirm prompt, and seller auth forwarding on cancel.
  • frontend/app/dashboard/page.tsx: Added handleInvoiceCancelled optimistic handler and passed userWallet and onCancel to InvoiceCard.
  • frontend/components/InvoiceCard.tsx: Added Cancel button for pending invoices (gated on seller wallet), Copy Pay Link, Copy ID with feedback, and jump to proof for paid invoices.
  • frontend/app/pay/[id]/page.tsx: Added dedicated CANCELLED banner and message.
  • frontend/components/PaymentButton.tsx: Added specific error message when attempting to pay a cancelled invoice.
  • frontend/components/PaymentStatus.tsx: Added detailed CANCELLED status message.
  • frontend/components/InvoiceForm.tsx & frontend/components/PaymentReceipt.tsx: Documented pending invoice lifecycle and proof generation.
  • frontend/lib/api.ts: Updated cancel method signature to pass sellerPublicKey.
  • frontend/lib/store.ts: Added isWalletSeller helper.
  • frontend/lib/utils.ts: Enhanced getShareUrl to prefer window origin in client environment.
  • frontend/lib/payment-page-state.js & frontend/lib/payment-page-state.d.ts: Added cancelled boolean property to pay page view state.
  • frontend/lib/dashboard-history.js & frontend/lib/dashboard-history.d.ts: Added isInvoiceCancellable helper.
  • frontend/tests/pay-page-status-matrix.test.js & frontend/tests/payment-page-state.test.js: Added assertions for matrix.CANCELLED.cancelled.
  • frontend/tests/dashboard-history.test.js: Added unit tests asserting INVOICE_FILTERS and historicalInvoices handle CANCELLED status.
  • README.md: Documented seller invoice management and cancellation under lifecycle.

Verification

  • Backend: npm test (170/170 passing), npm run typecheck (0 errors)
  • Frontend: npm test (203/203 passing), npm run test:a11y (31/31 passing), npm run typecheck (0 errors)

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

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.

Seller invoice actions: cancel, resend link, and detail management end-to-end

1 participant