Skip to content

Payment Reminder Escalation Flow #417

Description

@Kingsman-99

Description

Creators currently have no structured follow-up strategy for overdue invoices beyond manually resending the invoice link. This issue implements a configurable reminder escalation flow where creators define a sequence of reminder actions (email notification, activity feed alert, on-chain memo notification) at intervals after the due date, and the system automatically executes each step. The escalation state is visible on the invoice page and can be paused or cancelled by the creator.

Technical Context

Create components/invoice/EscalationFlowBuilder.tsx on the invoice detail page allowing creators to add escalation steps with { delayDays, channels: ('email'|'feed'|'memo')[], message }. Persist the escalation config in the invoice record via PATCH /api/invoices/[id]. Implement app/api/cron/escalation/route.ts as a Next.js Cron Route (or Vercel Cron) that runs daily, queries overdue invoices with active escalation flows, computes which steps are due, and dispatches them. Email dispatch uses nodemailer or Resend SDK. On-chain memo notifications use a zero-amount Stellar transaction with memo text to the payer's address. Track each dispatched step in an EscalationLog table. Surface escalation status on app/invoice/[id]/page.tsx as a timeline showing past and upcoming steps.

Acceptance Criteria

  • Adding an escalation flow with at least two steps and saving the invoice persists the escalation config in the database and displays the timeline on the invoice page
  • The cron route dispatches the correct escalation step on the correct day after the due date (verified via a mock date injection in tests)
  • Pausing escalation halts all future step dispatches; resuming re-calculates the next due step based on the current date
  • Email escalation steps send an email to the payer address (if on file) with the creator's custom message and a link to the public invoice page
  • Each dispatched escalation step is logged in EscalationLog with status (success/failure), channel, timestamp, and any error message
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions