Overview
This guide walks through the complete integration workflow between Flexprice and QuickBooks Online, from initial setup to invoice sync and payment reconciliation. Integration Type: One-way sync (Flexprice → QuickBooks) Key Capabilities:- ✅ Automatic invoice sync
- ✅ On-demand customer creation
- ✅ Automatic item (product/service) creation
- ✅ Inbound Payment sync
Step-by-Step Workflow
Phase 1: Initial Setup
Create QuickBooks App
- Go to Intuit Developer Portal
- Create new app for QuickBooks Online
- Configure OAuth 2.0 settings
- Copy Client ID and Client Secret
Configure Webhook
- In Intuit Developer Portal, go to Webhooks
- Add webhook endpoint:
https://api.cloud.flexprice.io/v1/webhooks/quickbooks/{tenant_id}/{environment_id} - Subscribe to Payment entity events
- Copy webhook verifier token
Create Connection in Flexprice
- Navigate to Integrations
- Go to QuickBooks and click “Add a connection”
- Enter credentials and configuration
- Complete OAuth authorization flow
- Verify connection is active
Phase 2: Plan and Price Setup
Create Plan in Flexprice
- Recurring charge: $99/month (Flat fee)
- Metered charge: $0.01 per API call (Usage-based)
QuickBooks Connection Active
- Status: Active
- Invoice sync: Enabled
- Income Account: Configured
Phase 3: Customer Subscription
Customer Subscribes
Subscription Period Runs
- Customer uses 4,500 API calls
- Usage is tracked via events
- Billing period ends on 2025-01-31
Phase 4: Invoice Generation
Invoice Auto-Generated
Sync Trigger Check
- ✅ QuickBooks connection exists
- ✅ Connection is active
- ✅ Invoice sync is enabled
- ✅ Customer has valid data
Phase 5: Customer Sync
Check Customer Mapping
Create Customer in QuickBooks
Store Customer Mapping
Phase 6: Item Creation
Process Line Item 1 (Recurring)
price_recurring_01 (Monthly Fee)- Check mapping → Not found
- Query QuickBooks for item → Not found
- Create service item:
- QB Response:
{"Id": "125"} - Store mapping:
price_recurring_01→125
Process Line Item 2 (Metered)
price_metered_02 (API Calls)- Check mapping → Not found
- Query QuickBooks for item → Not found
- Create service item:
- QB Response:
{"Id": "126"} - Store mapping:
price_metered_02→126
Phase 7: Invoice Sync
Create Invoice in QuickBooks
Store Invoice Mapping
Update Flexprice Invoice
Phase 8: Payment Recording (in QuickBooks)
Accountant Records Payment
- Open QuickBooks Desktop/Online
- Navigate to invoice #219
- Click “Receive Payment”
- Enter payment details:
- Amount: $144.00
- Date: 2025-02-05
- Method: Bank Transfer
- Mark invoice as paid
QuickBooks Creates Payment Entity
Phase 9: Webhook Notification
QuickBooks Sends Webhook
Flexprice Verifies Webhook
- Verify webhook signature (if verifier token configured)
- Check payment sync is enabled
- Extract payment ID: “222”
Phase 10: Payment Reconciliation
Fetch Payment Details
Find Flexprice Invoice
inv_xyz789Update Invoice Status
Reconciliation Complete
- ✅ Payment status: SUCCEEDED
- ✅ Amount paid: $144.00
- ✅ Linked to QuickBooks payment
- ✅ Audit trail maintained
Next Invoice (Same Customer)
When the next billing cycle arrives:Invoice Generated
Customer Check
Item Check
Invoice Created
Key Integration Points
1. Entity Integration Mapping
Purpose: Track relationships between Flexprice and QuickBooks entities Entities Tracked:- Customers:
cust_abc123↔ QB Customer67 - Prices/Items:
price_recurring_01↔ QB Item125 - Invoices:
inv_xyz789↔ QB Invoice219
- Prevents duplicate entity creation
- Enables bidirectional lookups
- Maintains data integrity
2. Sync Configuration
Invoice Sync:3. Webhook Processing
Flow:- QuickBooks sends webhook → Flexprice
- Verify signature (optional)
- Fetch full payment details
- Find linked invoice
- Update invoice status
- Return 200 OK immediately
- HMAC-SHA256 signature verification
- HTTPS only
- Idempotency handling
- Rate limiting
Error Handling
Common Scenarios
| Scenario | Handling | Result |
|---|---|---|
| Customer already exists | Use existing QB customer | No error |
| Item already exists | Use existing QB item | No error |
| Invoice already synced | Skip sync, return mapping | No error |
| Missing Income Account | Return error, block sync | User must configure |
| QB API rate limit | Retry with exponential backoff | Eventual success |
| OAuth token expired | Auto-refresh token, retry | Transparent to user |
| Webhook signature fail | Log warning, skip processing | Security measure |
Graceful Degradation
Philosophy: Integration failures should NOT break core Flexprice functionality Example:- Invoice creation in Flexprice: ✅ Success
- QB sync fails due to API error: ⚠️ Logged, not blocking
- Invoice is still accessible in Flexprice
- Manual retry available
Performance Considerations
First Invoice Sync
- Time: ~5-10 seconds
- Operations: Customer creation + 2 item creations + invoice creation
Subsequent Invoice Syncs
- Time: ~2-3 seconds
- Operations: Invoice creation only (reuses existing customer and items)
Optimization Strategies
- ✅ Entity mapping cache
- ✅ Parallel API calls where possible
- ✅ Connection pooling
- ✅ Automatic token refresh
Troubleshooting Guide
Invoice Not Syncing
Check Connection Status
Check Connection Status
- Verify QB connection is active
- Check OAuth token is valid
- Test API connectivity
Check Sync Configuration
Check Sync Configuration
- Verify invoice sync is enabled
- Check sync_config.invoice.outbound = true
- Ensure no sync filters blocking
Check Income Account
Check Income Account
- Verify Income Account ID is configured
- Ensure account exists in QB and is active
- Query QB to confirm account type
Payment Not Updating
Check Webhook Configuration
Check Webhook Configuration
- Verify webhook endpoint is correct
- Check webhook events are subscribed
- Review webhook delivery logs in Intuit portal
Check Payment Sync Setting
Check Payment Sync Setting
- Verify payment sync is enabled
- Check sync_config.payment.inbound = true
- Ensure webhook verifier token is configured (optional)
Check Invoice Mapping
Check Invoice Mapping
- Verify invoice was synced to QB
- Check entity_integration_mapping exists
- Confirm QB invoice ID matches
Related Documentation
- Connection Setup - Initial QuickBooks connection setup
- Item Sync - Detailed item creation and mapping

