ml-connector
Microsoft Dynamics 365 Business CentralSquare

Microsoft Dynamics 365 Business Central and Square integration

This connection links the Square commerce and payments platform with the Microsoft Dynamics 365 Business Central ERP so retail and online sales land in the books automatically. Square captures payments, orders, and customer activity at the point of sale; Business Central holds the accounting record, GL, and reporting. ml-connector reads completed Square transactions and posts them into Business Central as sales invoices and customer payment journal entries, then keeps catalog items and customer records aligned across both systems. Because Square has no chart of accounts, the connector maps Square locations and item categories to Business Central GL dimensions so revenue is recorded against the right accounts. The result is one ledger that reflects every Square sale without manual re-keying.

How Microsoft Dynamics 365 Business Central works

Microsoft Dynamics 365 Business Central exposes data through the Business Central API v2.0, a REST API built on OData v4 with JSON payloads. Authentication uses OAuth2 client credentials (service-to-service) against Microsoft Entra ID, with a tenant id, client id, client secret, and environment name. Key entities for this pair are customers, salesInvoices, customerPaymentJournals, items, and accounts (read-only chart of accounts), all scoped under a company id. Sales invoices are created as drafts and posted with the bound action Microsoft.NAV.post. Change subscriptions provide push webhooks, but they are signal-only and expire after three days, so the connector renews them and refetches the changed record. Incremental reads use the OData filter lastModifiedDateTime gt a timestamp.

How Square works

Square exposes data through the Square API, a REST API with JSON bodies, versioned by a date-based Square-Version header. Calls authenticate with a Bearer access token obtained through the OAuth2 authorization code flow, or a personal access token for a single account. Access tokens expire in 30 days and are renewed with a non-expiring refresh token, so the connector refreshes proactively rather than waiting for a 401. Relevant entities are payments, orders, invoices, customers, and catalog items, most scoped to a location id. Square sends HMAC-SHA256 signed webhooks for events such as payment.updated, order.updated, and customer.updated, and supports idempotency keys in the request body on create operations.

What moves between them

Sales activity moves from Square into Business Central. Completed Square payments and orders become posted sales invoices in Business Central, and the matching settlement becomes a customer payment journal line applied to that invoice. New or updated Square customers create or update Business Central customers. Reference data moves the other way: Business Central items and customers can be written to the Square catalog and customer list so the storefront and the ERP share the same products and buyers. Square sends payment, order, and customer webhooks in near real time; Business Central change subscriptions and a polling fallback on lastModifiedDateTime cover the reverse direction. Item and customer alignment runs on a schedule, typically every few minutes to hourly.

How ml-connector handles it

The connector holds two credential sets and bridges them per request: a Square Bearer token (refreshed before its 30-day expiry) and a Business Central OAuth2 client-credentials token scoped to https://api.businesscentral.dynamics.com/.default. Square webhooks are verified with HMAC-SHA256 over the signature key, notification URL, and raw body using a constant-time compare, returning 403 on failure; a bad signature is never accepted. Business Central change subscriptions are renewed before the three-day expiry by a cron job, and because those notifications carry no payload the connector refetches the named resource. A Square payment is matched to a Business Central customer by reference id or email, written as a draft sales invoice, then posted with Microsoft.NAV.post and settled through a customer payment journal line. Since Square has no chart of accounts, location id and item category map to Business Central GL dimensions so revenue posts to valid accounts. Writes are deduplicated with a Square idempotency_key on creates and a stable BullMQ jobId on the Business Central side; the Square invoice gotcha (an order must exist before an invoice) is respected when invoices are involved. On 429 from either side the connector backs off with jitter and retries.

A real-world example

A regional specialty coffee roaster with about 60 staff runs eight retail cafes and an online shop on Square while keeping its books in Microsoft Dynamics 365 Business Central. Every night a bookkeeper exports Square sales by location and re-keys totals into the ERP, which is slow and drifts out of balance when refunds land late. With the connector, each completed Square payment posts as a sales invoice and a settled payment journal line in Business Central, tagged to the cafe location as a GL dimension, so daily revenue by store is accurate without manual entry and refunds reconcile automatically.

What you can do

  • Post completed Square payments and orders into Microsoft Dynamics 365 Business Central as sales invoices with the bound post action.
  • Record Square settlements as customer payment journal lines applied to the matching Business Central invoice.
  • Map Square location ids and item categories to Business Central GL dimensions since Square has no chart of accounts.
  • Keep catalog items and customer profiles aligned in both directions between Square and Business Central.
  • Verify Square HMAC webhooks and renew Business Central change subscriptions so only changed records move.

Questions

How does the connector handle Square access tokens expiring every 30 days?
Square access tokens expire after 30 days, so the connector refreshes proactively using the non-expiring refresh token from the authorization code flow rather than waiting for a 401. The new token is stored encrypted and used as the Bearer credential on the next request. For a single Square account, a personal access token can be used instead of the OAuth flow.
Can Square map sales to the right GL accounts in Business Central?
Square is a commerce and payments platform and does not expose a chart of accounts or GL dimensions. The connector closes that gap by mapping Square location ids and item categories to Business Central GL dimensions, so each posted invoice lands on valid accounts. The Business Central accounts endpoint is read-only, so the mapping is configured in the connector, not written back to Square.
Why does the connector still poll Business Central if webhooks exist?
Business Central change subscriptions are push, but they carry no payload and expire after three days, so the connector renews them on a schedule and refetches each changed record. Some changes, such as edits by users who cannot run job queues, are not notified, so a polling fallback on the lastModifiedDateTime filter catches anything the subscription misses. Together they keep the two systems in step without missing updates.

Related integrations

Connect Microsoft Dynamics 365 Business Central and Square

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

Get started