QuickBooks Online Integration
CaseSolo's QuickBooks Online integration uses Intuit OAuth and the QuickBooks Online Accounting API directly. The launch path supports connection status, account mapping, invoice/payment/expense operations, CDC polling, reconciliation summaries, webhook activity capture, and replay for failed create operations.
Runtime Inputs
QUICKBOOKS_CLIENT_IDandQUICKBOOKS_CLIENT_SECRETare required for OAuth.QUICKBOOKS_WEBHOOK_VERIFIER_TOKENverifies Intuit webhook signatures when configured.- Firm OAuth state is stored in
firm.settings.quickbooksOAuth. - Local admin preview state is stored in
firm.settings.quickbooksand mirrored to OAuth config when a live connection exists.
Account Mapping
QBOConfig.accountMapping controls the QuickBooks IDs used by live payload builders:
serviceItemIdmaps invoice lines to a QuickBooks product/service item. Default is1, matching Intuit's common service-item example.bankAccountIdmaps expense purchases to an operating bank or credit-card account.expenseAccountIdmaps account-based expense lines.trustAccountIdmaps trust-account sync when enabled.paymentMethodIdmaps replayed/default payments to a tender type.
buildQBOAccountMappingReadiness() returns required and recommended mapping gaps. Expense sync requires both bankAccountId and expenseAccountId; trust-account sync requires trustAccountId.
Sync And Replay
fetchChanges()uses QBO CDC forInvoice,Payment, andPurchase.runSync()pulls changed QBO entities, logs sync activity, processes the replay queue, and updates sync status.processErrorQueue()maps CaseSoloexpenseerrors to QBO's/purchaseendpoint because Intuit represents expenses asPurchaseobjects.- Replay currently covers create-style payloads. Update/delete replay should stay gated until CaseSolo has SyncToken-aware mutation tracking.
Provider References
- Intuit CDC: https://developer.intuit.com/app/developer/qbo/docs/learn/explore-the-quickbooks-online-api/change-data-capture
- Intuit invoice workflow: https://developer.intuit.com/app/developer/qbo/docs/workflows/create-an-invoice
- Intuit Purchase API: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/Purchase
- Intuit webhooks: https://developer.intuit.com/app/developer/qbo/docs/develop/webhooks
Verification
Run focused checks before changing provider behavior:
npm run test:run -- quickbooks
npx eslint src/lib/integrations/quickbooks.ts src/app/api/integrations/quickbooks/route.ts src/__tests__/lib/quickbooks-live.test.ts src/__tests__/api/quickbooks-integration.test.ts
npm run typecheck