ml-connector
FreshBooksShopify

FreshBooks and Shopify integration

Shopify powers your e-commerce storefront and generates orders, customers, and payments. FreshBooks tracks invoices, expenses, and revenue. Connecting them keeps your financial records aligned with your sales: every Shopify order becomes an invoice in FreshBooks, transaction data syncs as payments, and customer records stay in sync. ml-connector bridges the two systems and handles the OAuth flows so your accounting stays current without manual entry.

How FreshBooks works

FreshBooks is a cloud accounting platform exposing clients, invoices, bills, expenses, payments, chart of accounts, and journal entries through REST APIs at https://api.freshbooks.com. Authentication is OAuth 2.0 Authorization Code grant with user-delegated tokens (Client Credentials is not supported), requiring the user to authorize each customer account. FreshBooks delivers near-real-time event notifications via webhooks to a customer-supplied endpoint, with event types covering invoice, payment, bill, expense, and client lifecycle events. Webhook payloads are signed with HMAC-SHA256. Webhook delivery can range from seconds to minutes, and failures trigger retries until the callback is disabled by persistent timeout.

How Shopify works

Shopify is a cloud e-commerce platform exposing orders, customers, transactions, inventory, and draft orders through GraphQL and REST APIs at https://{shop}.myshopify.com/admin/api. Authentication is OAuth 2.0 with offline tokens (long-lived, do not expire, prefixed shpat_) and online tokens (expire with session, prefixed shpua_). Shopify delivers finance-relevant webhooks for orders/create, orders/updated, orders/paid, customers/create, customers/update, and transaction activity. Webhook deduplication is via X-Shopify-Webhook-Id header. Shopify has no native Purchase Order or Vendor entity and no general ledger; it is read-only for sales transactions.

What moves between them

Orders and transactions flow from Shopify into FreshBooks. Each Shopify order triggers creation of an invoice in FreshBooks, mapped to the matching customer account. Transaction data from Shopify orders syncs as payments in FreshBooks. Shopify customer records sync to FreshBooks clients so billing and shipping addresses are shared. Reference data like currency and tax rates are validated in both directions. The flow is unidirectional: FreshBooks does not write back to Shopify.

How ml-connector handles it

ml-connector stores both OAuth credential sets encrypted and handles the user-delegated OAuth flow for FreshBooks on behalf of each customer. Shopify offline tokens are cached and refreshed on expiry per customer shop. ml-connector subscribes to Shopify order and customer webhooks and validates signatures using Shopify's X-Shopify-Hmac-SHA256 header and FreshBooks' HMAC-SHA256 X-FreshBooks-Hmac-SHA256 header. When an order is created or updated in Shopify, ml-connector creates or updates the matching FreshBooks invoice and links it to the corresponding client. Transactions are mapped to FreshBooks payment records with the order ID for traceability. Because Shopify webhooks can range from seconds to minutes in delivery, ml-connector does not guarantee invoice-payment ordering and may need to look back and reconcile older orders. FreshBooks invoices and payment statuses are computed by the system, so ml-connector never writes to those fields. Every record is audited with the original Shopify order ID, timestamp, and field mapping.

A real-world example

A direct-to-consumer retailer runs Shopify for its storefront and FreshBooks for accounting and invoicing. Each day brings dozens of orders, refunds, and customer updates. Without the integration, the accountant exports Shopify orders weekly and manually enters them into FreshBooks as invoices, then matches Shopify payment confirmations to FreshBooks payments, a process that takes hours and invites errors. With Shopify and FreshBooks connected, each order becomes an invoice automatically, payments are recorded as they clear Shopify, and customers are kept in sync. Month-end close is faster because the invoice register is already current.

What you can do

  • Sync Shopify orders to FreshBooks as invoices, with order number and date preserved for traceability.
  • Map Shopify customers to FreshBooks clients and keep names and addresses synchronized.
  • Record Shopify transactions as FreshBooks payments, linked to the originating order.
  • Validate order and payment data in both directions and handle webhook signature verification for both platforms.
  • Maintain a complete audit trail of every synced record with timestamps and original Shopify order IDs for reconciliation.

Questions

What data flows between Shopify and FreshBooks?
Orders and transactions flow from Shopify into FreshBooks. Each Shopify order becomes a FreshBooks invoice with the customer linked to a FreshBooks client. Shopify payments and transactions sync as FreshBooks payment records. Customer records stay synchronized so billing addresses are shared. The flow is unidirectional: FreshBooks does not write back to Shopify because Shopify transaction data is read-only.
How does ml-connector handle the OAuth authentication for both platforms?
FreshBooks requires user-delegated OAuth 2.0 Authorization Code grant per customer account, so ml-connector securely stores the authorization code and token for each customer. Shopify uses offline tokens (long-lived, prefixed shpat_) that do not expire, simplifying storage and refresh. Both are encrypted at rest and presented on every API call. If either token expires or is revoked, ml-connector detects the 401 response and alerts the customer to re-authorize.
What happens if Shopify and FreshBooks webhooks arrive out of order or are delayed?
Shopify and FreshBooks webhooks can be delayed by seconds to minutes and may arrive out of order. ml-connector stores order and payment records with timestamps and order IDs so it can detect and log out-of-order events. If a payment arrives before its corresponding invoice, ml-connector queues it and links it after the invoice is created. Every record includes a full audit trail with the original Shopify order ID, so reconciliation is always traceable.

Related integrations

Connect FreshBooks and Shopify

Free to use. Add your credentials, ping your real systems, and see if we fit.

Get started