Xero Connection Configuration

Learn about how to connect Xero to Maica to enable the synchronisation.

When you first enter Client Management Settings, you will be prompted with the following error message, which states that there are no credentials named ‘Maica_Xero’

At the bottom of the page, you will see an ‘Edit’ button. Click on this, followed by ‘Add New Connection’, which is under the Active Connections subheading. After you press this button, you will be taken to the Named Credentials page.

Named Credentials

You must now create a credential.

FieldValue

Label

Maica Xero

Name

Maica_Xero

URL

Identity Type

Named Principal

Authentication Protocol

OAuth 2.0

Authentication Provider

Scope

offline_access openid profile email accounting.transactions accounting.contacts accounting.journals.read accounting.settings

You can untick the checkbox titled 'Start Authentication Flow on Save' and you can save, once all the fields above are completed. After you have saved, return to Client Management Settings. You should now see the following error message

Updating Client Management Settings

In Client Management Settings, click Edit and enable Xero Management in the top-right corner. Then, select the following options.

Note: You may need to activate Xero Invoice Sync Flow, and Webhooks will not be available unless you have already created and activated the site.

Salesforce Auth Provider

Next, we need to create the Authentication Provider. In the top left of the screen, you will see a Quick Find search option. Search ‘auth’ and select the Auth. Providers option. Make sure you right click and open link in new tab, so you do not lose your current page.

A Salesforce Auth Provider to set up the technical connection to the Xero financial system, as shown below:

The following values apply when configuring the Salesforce Auth Provider:

FieldValue

Auth Provider Id

Salesforce generated

Provider Type

Open ID Connect

Name

Xero

URL Suffix

Xero

Consumer Key

Consumer Secret

Authorize Endpoint URL

Token Endpoint URL

Use Proof Key for Code Exchange

Ticked

Default Scope

offline_access openid profile email accounting transactions accounting. contacts accountingjournals.read accounting.settings

Send Access Token in Header

Ticked

Include Consumer Secret in...

Ticked

Test-Only Initialization URL

OAuth-Only Initialization URL

Callback URL

Single Logon URL

Get Values from your Xero Instance

In order to complete Salesforce Auth Provider configuration, you need to log into your Xero instance to retrieve the values marked above. These can be found within the following sections:

Consumer Key and Consumer Secret

To access the consumer key and consumer secret, you will need to log into developer.xero.com using your credentials and follow the below steps:

Now, you can return to Named Credentials and select your newly created Authentication Provider.

Initialization URLs

Creating a Xero Web App

First, login to Xero using the link https://login.xero.com/. Next, you need to go to App Management in the developer website, which can be found using the link https://developer.xero.com/app/manage. The account should be the same one that you have used to login previously.

Create a new app, with Company URL https://api.xero.com/api.xro/2.0/. The redirect URL can be configured later, but for now use a dummy URL such as http://localhost:8000.

Now, you can go to Configuration and copy the Client ID and Client Secret, which are the Consumer Key and Consumer Secret respectively.

Creating a Site

Go to the Sites section in Setup. You can find this using the Quick Find in the top-left corner. Now, create a new site. Note: you may need to check the following box to accept the terms and conditions

The following values apply when configuring the site.

FieldValue

Site Label

Webhooks

Site Name

Webhooks

Site Contact

Generic

Default Record Owner

Generic

Active Site Home Page

ParticipantStatement

After saving, ensure that you activate the site. Now, return to Client Management Settings.

Configuring the Redirect URL

The Redirect URL is the Callback URL from the Auth. Provider, as shown below.

Enabling Authentication Flow

Return to your Named Credential and edit. Now, you can select the 'Start Authentication Flow on Save' box and click Save. You should be redirected to Xero, where you will be prompted with the following screen.

Allow access. You will be brought back to the Named Crediential and will notice that the Authentication Status is now Authenticated. Now, in Client Management Settings, we can setup Webhooks.

Configuring Webhooks

Your Client Management Settings page should look like this

Edit, and enable Xero Management. Select the Tenant 'Active' checkbox. Finally, make sure Webhooks is selected as Notifications Endpoint (Site) and Xero Invoice Sync Flow is selected for Syncronisation, as shown in the photo above.

Now, we need to populate the Webhooks Key and set up the URL. This is done from the Xero site.

Go to your App, then under Webhooks, complete the options as shown below. The URL comes from the URL under Webhooks in Client Management Settings, which is shown above.

When you save, you will be given a Webhooks key which can be copy and pasted into Client Management Settings. Now, you can save the settings and you should be prompted with the following message.

Site Settings

Now, double check the following settings in Salesforce. First, go to Sites and click on the Site Label Webhooks. This will take you to a page where you will see a button named Public Access Settings. Now, click on Apex Class Access, edit and ensure that maica.vertic_RestService is enabled. Then, search for REST in the Find Settings searchbar and select Apex Rest Services. Make sure that the checkbox Apex REST Services is enabled.

Back in Xero, click the following button after you have saved the settings in Salesforce.

Invoices

Go to https://go.xero.com, which will take you to a dashboard. Under Business - Invoices, you will see the invoices.

In the top right, you will see an option to Sync with Xero. Note: it may be in the drop down menu

Please click confirm to initiate the Sync

In case of any errors, refer to Xero Sync article within this knowledge base.

Last updated