ml-connector
Sage 50Shopify

Sage 50 and Shopify integration

Shopify runs your online store and fulfills orders. Sage 50 runs your accounting. Connecting them keeps your revenue in sync without manual re-entry. New orders and customer records from Shopify flow into Sage 50 as sales invoices and customer accounts. ml-connector handles the architecture mismatch: Shopify is cloud-hosted with webhooks and OAuth, while Sage 50 is desktop-based and accessed through a local Windows SDK that requires an interactive session.

How Sage 50 works

Shopify exposes orders, customers, transactions, refunds, and fulfillments through GraphQL and REST APIs at https://{shop}.myshopify.com/admin/api. Authentication uses OAuth 2.0 with offline tokens that do not expire, issued with the shpat_ prefix. Shopify can push events to a registered webhook endpoint for orders/create, orders/updated, orders/paid, customers/create, customers/update, and related topics. Webhook deduplication uses X-Shopify-Webhook-Id and requires 401 return on bad signature. Shopify provides no native purchase order or vendor object, and has no general ledger.

How Shopify works

Sage 50 is a desktop accounting application installed on Windows, sold in US edition (formerly Peachtree Accounting) and UK edition (formerly Sage Line 50). It exposes customers, sales invoices, sales orders, general journal entries, employees, and inventory items through the Sage 50 .NET SDK (US edition) or Sage Data Objects COM/ActiveX DLLs (UK edition). Authentication is local Windows username and password paired with a company data folder path. Sage 50 has no REST API, no webhooks, no event stream, and no cloud integration surface. Integration requires a Windows process with direct file access to the Sage 50 company folder, typically on the same machine or LAN.

What moves between them

The flow is Shopify into Sage 50. When a Shopify order is placed, Shopify pushes an order webhook to ml-connector with order ID, customer, line items, total, and payment status. ml-connector translates the order into a Sage 50 sales invoice, creates or updates the Shopify customer as a Sage 50 customer record if it does not exist, and writes both through the Sage 50 SDK. Refunds are translated as credit memos. Customer profile updates from Shopify flow into matching Sage 50 customer records. The Sage 50 side is write-only; no data flows back to Shopify. The sync is event-driven: Shopify webhooks trigger writes immediately when they arrive.

How ml-connector handles it

ml-connector runs a Windows service or scheduled process that hosts the Sage 50 SDK session. When a Shopify webhook arrives, ml-connector validates the signature using the shared webhook secret and the X-Shopify-Webhook-Id header. It refreshes the OAuth token if needed (offline tokens do not expire, but the integration is prepared for token refresh). It translates Shopify order structure into the Sage 50 sales invoice structure: order number maps to invoice number, customer name maps to customer account, line items map to invoice detail lines, and order total maps to the invoice amount. Customer country and email are copied to the Sage 50 customer record. If a customer does not exist in Sage 50, it is created using the Shopify customer ID as a reference. If an invoice number already exists in Sage 50 (webhook replay), it is skipped. The integration tracks which Shopify orders have been written and which failed, with a full audit log. If a Sage 50 write fails (for example, due to an account validation error), the record is queued for replay when the error is resolved.

A real-world example

A small to mid-sized retailer runs Shopify for their online store and Sage 50 for accounting. Every order placed on Shopify must become a sales invoice in Sage 50 for month-end close. Before the integration, the accounting team exported orders from Shopify daily and re-entered them as sales invoices in Sage 50 by hand, a process that took 2-3 hours per day and introduced re-keying errors. With the integration in place, each Shopify order becomes a Sage 50 sales invoice automatically, the customer name and address are synced, and the accounting team has a complete, accurate sales journal ready for close without manual intervention.

What you can do

  • Translate Shopify orders into Sage 50 sales invoices with line-item detail, mapped to the correct sales accounts.
  • Create and update Shopify customers as Sage 50 customer records, populated with name, email, and address.
  • Handle Shopify refunds as Sage 50 credit memos against the original sales invoice.
  • Validate Shopify webhook signatures and authenticate with Sage 50 using the local Windows SDK and Windows credentials.
  • Queue failed records and replay them when the error is resolved, with a full audit trail of every order and write attempt.

Questions

How does ml-connector write to Sage 50 when it has no REST API?
ml-connector runs a Windows process that loads the Sage 50 SDK directly into memory. It uses the Sage 50 .NET SDK (US edition) or Sage Data Objects COM DLLs (UK edition) to open the company data folder, authenticate with a local Windows username and password, and write customer records and sales invoices directly. This requires the Windows machine where Sage 50 is installed to host the ml-connector process.
What happens if a Shopify webhook arrives twice with the same order?
ml-connector deduplicates using the Shopify webhook ID (X-Shopify-Webhook-Id header) and its own record of which order IDs have been written to Sage 50. If the same Shopify order ID arrives twice, the second webhook is skipped and logged as a duplicate. If a Sage 50 write fails and is replayed, ml-connector checks whether the invoice number already exists before writing again.
Does Sage 50 need to be running while ml-connector writes orders?
No. Sage 50 does not need to be running interactively. ml-connector opens the company data folder using the Sage 50 SDK and writes to it directly. However, a Sage 50 user must not be logged into that company at the same time ml-connector is writing, because Sage 50 locks the company folder during interactive use. A best practice is to run ml-connector on a dedicated Windows machine or virtual machine that hosts only the Sage 50 company data and the integration service.

Related integrations

Connect Sage 50 and Shopify

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

Get started