Magento 2 Xero Integration

Table of Contents

  1. 1. Extension Installation
  2. 2. Get Client ID & Secret from Xero
  3. 3. Configure Integration in Extension
    1. 3.1 Connect Magento 2 with Xero
    2. 3.2 Select Website to Sync
    3. 3.3 Map Accounts with Xero
    4. 3.4 Data Synchronization Settings
    5. 3.5 Generate Debug Log
  4. 4. Map Tax Codes & Payment Methods
  5. 5. Manage Sync Queue & Logs

1. Extension Installation

For Magento Marketplace Customers

Find the extension’s Composer name and version in its composer.json file.

  • Login to your SSH and run:

    • composer require meetanshi/magento-2-xero-integration

  • Enter your authentication keys. Your public key is your username; your private key is your password.

  • Wait for Composer to finish updating your project dependencies and make sure there aren’t any errors.

  • To verify that the extension is installed properly, run the command:

    • php bin/magento module:status Meetanshi_XeroIntegration

  • By default, the extension is probably disabled. Enable the extension and clear static view files:

    • php bin/magento module:enable Meetanshi_XeroIntegration  --clear-static-content

    • php bin/magento setup:upgrade

    • For Magento version 2.0.x to 2.1.x - php bin/magento setup:static-content:deploy

    • For Magento version 2.2.x & above - php bin/magento setup:static-content:deploy –f

    • php bin/magento cache:flush

For Meetanshi Customers

  • Download the extension zip file and extract it to your Magento’s root directory.

  • Login to your SSH and run the below commands step by step:

  • php bin/magento setup:upgrade

  • For Magento version 2.0.x to 2.1.x - php bin/magento setup:static-content:deploy

  • For Magento version 2.2.x & above - php bin/magento setup:static-content:deploy –f

  • php bin/magento cache:flush

2. Get Client ID & secret from Xero

First, you need to configure Xero for the API connection. You’ll need the following details from your Xero account:

  • Client ID

  • Client Secret

Go to Xero Developer Portal and log in using your account credentials. Next, click square on the upper right side beside your profile click the API Explorer > My Apps > OAuth2 Test > Configuration to generate and copy the client ID and client secret.

3. Configure Integration in Extension

Log into your Magento 2 admin panel and navigate to Xero Integration > Configuration to configure the extension.

3.1 Connect Magento 2 with Xero

  • Enable Xero Integration: Enable the button to integrate Magento 2 and Xero.

  • Connection Status: It displays the Magento-Xero connection status.

  • Connection Mode: You can choose from the following two modes:

    • Sandbox (for testing)

    • Production (for live)

  • Sandbox Client ID: Enter the Client ID you received from your Xero account (see previous section)

  • Sandbox Client Secret: Enter the Client Secret you received from your Xero account (see previous section)

Click Save to connect your Magento 2 store with Xero.

Now, click the Get Access Token button and you’ll be redirected to Xero for authentication.

Log into your Xero account and authorize the connection and you’ll be redirected back to your Magento 2 store with a success message.

The connection status in the extension configuration will change to Connected.

3.2 Select Website to Sync

Here, you can choose the website you want to sync with Xero.

3.3 Map Accounts with Xero

Once connected, you can get various accounts from your Xero integration for synchronization.

Click the Fetch Xero Accounts button to get the available accounts and select the following accounts:

  • Bank Account

  • Sales Account

  • Sales (Shipping) Account

  • Inventory Account

  • Cost of Goods Sold Account
     

All your Magento store data will be synced to these selected Xero accounts.

3.4 Data Synchronization Settings

You can sync accounts, products, and invoices with Xero. You can choose options for each of these data.

For each data sync, you can choose from the following sync mode:

  • Immediate: The data is synced immediately from Magento 2 to Xero.

  • Cron Job: The data is synced regularly at a specific interval. E.g., daily, weekly, or monthly

Accounts Sync:

Here’s what the synced accounts look like in Xero:

Products Sync:


 

Here’s what the synced products look like in Xero:

Invoices Sync:

For the invoices synchronization, you can also choose the following options:’

  • Sync to Xero Invoice: Choose whether to sync Magento orders as invoices or sync Magento invoices directly with Xero.

  • Sync Orders with Status: Select which order statuses in Magento should be synced with Xero.

  • Invoice Types on Xero: Define the type of invoices to sync:

    • ACCPAY: For bills or supplier invoices.

    • ACCREC: For sales or customer invoices.

  • Invoice Status on Xero: Set the status of synced invoices:

    • Draft

    • Submitted

    • Authorized

  • Sync Mode: Choose the sync mode for credit memo synchronization:

    • Immediate: Sync as soon as changes occur

    • Cron Job: Sync at scheduled intervals.

Here’s what the synced invoices look like in Xero:

Credit Memo Synchronization Settings

  • Credit Memo Synchronization: Enable or disable the synchronization of credit memos between Magento and Xero.

  • Sync Mode: Choose the sync mode for credit memo synchronization:

    • Immediate: Sync as soon as changes occur

    • Cron Job: Sync at scheduled intervals.

 

3.5 Generate Debug Log

Developer Options provides an option to enable logging errors to troubleshoot the integration in case of any issues.

  • Generate Debug Log: Enable the option to get detailed logs of the integration process of Magento 2 Xero Integration.

Once enabled, you can find the debug logs at /var/log/xerointegration.log 

4. Map Tax Codes & Payment Methods

Move to Xero Integration  > Tax Mapping to map Magento 2 tax classes with Xero. First of all, click the “Add All Tax Code” button to add all the Magento 2 tax codes to the list in the grid and then, click “Synchronize” to sync each tax code with Xero API.

 

Navigate to Xero Integration settings > Payment Mapping. Choose a payment method used in your Magento store (e.g., Credit Card, PayPal) by clicking “Add All Payments”. And select the corresponding Xero account where this payment should be recorded. Click “Save”.

5. Manage Sync Queue & Logs

If your store already has customers, products, orders, invoices and want all of them to sync with Xero, move to Xero Integration > Sync Queue.

Click Add Customers, Add Products, Add Invoices, and Add CreditMemos, one by one in the same order as mentioned to add all here in the sync queue.
 

 

Once synchronized, the status of each entity is shown with the details at Xero Integration > History Logs. If the data is synchronized correctly, the status will be successful, else if there's a problem during data sync, it will show error status.