Skip to content

API: Invoice CRUD Endpoints & PDF Generation #66

@0xdevcollins

Description

@0xdevcollins

Summary

Implement full Invoice CRUD API endpoints and server-side PDF generation using Puppeteer.

Requirements

  • POST /v1/invoices — Create invoice with line items, tax, discount, customer details
  • GET /v1/invoices — List merchant invoices (paginated, filterable by status)
  • GET /v1/invoices/:id — Get invoice detail
  • PATCH /v1/invoices/:id — Update draft invoice
  • DELETE /v1/invoices/:id — Cancel/delete draft invoice
  • GET /v1/invoices/:id/pdf — Generate and return PDF
  • PDF generation using Puppeteer rendering a React template
  • Store PDFs in Cloudflare R2, save URL to pdfUrl field
  • Multi-currency support (USD, EUR, NGN, etc.)
  • Partial payment tracking
  • Status lifecycle: DRAFT → SENT → VIEWED → PARTIALLY_PAID → PAID → OVERDUE → CANCELLED

Database

Invoice model already exists in Prisma schema. May need migration for additional fields.

Acceptance Criteria

  • All CRUD endpoints functional with proper validation (Zod)
  • PDF renders with merchant branding (logo, color)
  • PDF stored in R2 and accessible via signed URL
  • Partial payments update invoice status correctly
  • Proper error handling with descriptive messages

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions