Skip to content

[UX] Send payment link email to client on invoice creation #283

@davedumto

Description

@davedumto

Problem

When a freelancer creates an invoice via POST /api/invoices, the client receives no notification. The payment link exists in the database but the client has no way to know they have an invoice to pay unless the freelancer manually shares the link.

What needs to be built

After the invoice is successfully created in app/api/invoices/route.ts, send an email to clientEmail with the payment link.

Email content (minimum viable)

  • Subject: Invoice from {freelancerName} — {invoiceNumber}
  • Body:
    • Freelancer name + amount + currency
    • Due date (if set)
    • Prominent CTA button linking to invoice.paymentLink

Implementation

Use the existing lib/email.ts / Resend setup:

// lib/email.ts — add a new function
export async function sendInvoiceToClient(params: {
  clientEmail: string
  clientName: string | null
  freelancerName: string
  invoiceNumber: string
  amount: number
  currency: string
  dueDate: string | null
  paymentLink: string
})

Call it at the end of the POST /api/invoices handler (fire-and-forget — don't let email failure block the API response).

Acceptance criteria

  • Client receives an email with the payment link immediately after invoice creation
  • Email send failure does not cause the API to return an error (log and continue)
  • Email is not sent if clientEmail is invalid format (basic validation)
  • Unit test: assert sendInvoiceToClient is called with correct params on successful invoice creation

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions