Prompt file imported from nick-syspac/paidsoon (
.github/prompts/build-myob-integration.prompt.md). Copyright stays with the author.
Build MYOB Integration — PaidSoon
Role
You are a senior full-stack engineer implementing a MYOB invoice provider integration for PaidSoon.
Goal
Implement a MYOB provider that reads overdue invoices from MYOB AccountRight or MYOB Essentials and feeds them into PaidSoon's tracking flow.
Important: MYOB integration is not currently implemented in this repository. Only implement this if the user explicitly requests it. If MYOB API credentials and documentation are not provided, document what is needed instead of inventing an integration.
PaidSoon Context
PaidSoon uses a provider abstraction (lib/providers/types.ts) that allows plugging in different invoice sources. The only current provider is Stripe Connect (lib/providers/stripe.ts). MYOB would be a second provider.
Files to Inspect
lib/providers/types.ts—InvoiceProviderinterface (must be implemented)lib/providers/stripe.ts— reference implementationlib/providers/index.ts— provider registrylib/email/catchup.ts— how providers are called during catch-up scanprisma/schema.prisma—InvoiceConnectionmodel (stores provider credentials)app/api/stripe/connect/— OAuth connect flow (reference for MYOB OAuth)docs/runbooks/README.md— env var documentation pattern
What MYOB Requires (Document If Not Available)
- MYOB API OAuth 2.0 credentials (Client ID, Client Secret)
- MYOB API endpoint for reading invoices
- Webhook or polling approach for detecting newly overdue invoices
- A MYOB developer account and registered application
If these are not available, output a docs/runbooks/myob.md runbook describing what is needed.
Implementation Rules
Provider Implementation
Create lib/providers/myob.ts implementing InvoiceProvider:
getOverdueInvoices(credentials)— call MYOB API, filter overdue, map toNormalizedInvoicegetInvoiceDetails(credentials, externalId)— fetch single invoiceverifyWebhookSignature— implement if MYOB supports webhooksparseWebhookEvent— implement if MYOB supports webhooks
Normalisation
Map MYOB invoice fields to NormalizedInvoice:
externalId— MYOB invoice UIDprovider = "myob"amountDue— in cents (integer); convert from MYOB's decimal formatclientEmail,clientName,dueDate,currency,invoiceNumber
OAuth Connect Flow
Create /api/myob/connect/authorize, /api/myob/connect/callback, /api/myob/connect/disconnect routes following the Stripe Connect pattern.
Environment Variables
New vars to document in docs/runbooks/README.md:
MYOB_CLIENT_IDMYOB_CLIENT_SECRETMYOB_WEBHOOK_SECRET(if webhooks supported)
Tests
- Test provider normalisation with mock MYOB API responses
- Test idempotency: same invoice imported twice = one row
- Never call real MYOB API from tests
Expected Output
lib/providers/myob.tsimplementation- OAuth connect routes in
app/api/myob/connect/ - Provider registered in
lib/providers/index.ts docs/runbooks/myob.mdwith setup instructionsdocs/runbooks/README.mdupdated with new env vars- Tests in
tests/ docs/DDD.mdupdated
Acceptance Criteria
NormalizedInvoicefields all populated correctlyamountDueis always integer cents- Provider implements full
InvoiceProviderinterface - Tests pass
- No TypeScript errors