Package Setup
Firstly, it is necessary to install the Xero package into the client's org - contact the Seven20 Product team to obtain the link for the latest package version. Seven20's Xero package is dependent on the following core product packages:
- Seven20 - Utilities
- Seven20 - Core
- Seven20 - Billing
Connect a Xero developer app
Create the Xero app
-
Navigate to the Xero Developer site and sign in
-
Create a new App and complete the fields on the page
- For Integration type, select Web app
- For Redirect URL enter a placeholder value, this will be completed correctly in a later step
-
Enter the newly created app and navigate to Configuration
tipKeep the Xero Configuration tab open in your browser as you will need to refer back to it in future steps.
Set up the Auth. Provider in Salesforce
- In Salesforce setup navigate to Auth. Providers and create a new record with the values below:
| Auth. Provider Field | Value |
|---|---|
| Name | Xero |
| URL Suffix | Xero |
| Consumer Key | Return to the Xero configuration tab, copy the Client id and paste the value in this field |
| Consumer Secret | Return to the Xero configuration tab, click Generate a secret, copy the value and paste it in this field |
| Authorize Endpoint URL | https://login.xero.com/identity/connect/authorize |
| Token Endpoint URL | https://login.xero.com/identity/connect/token |
| Default Scopes | openid profile email offline_access accounting.transactions accounting.contacts |
| Send access token in header | Checked |
| Include Consumer Secret in SOAP API Responses | Checked |
Update the Redirect URIs in Xero
- Under Salesforce Configuration for the newly created record find and copy the Callback URL
- Return to the Xero configuration tab and overwrite the value in Redirect URIs
- Save the changes
Set up the credentials in Salesforce
- With the Auth. Provider created, an OAuth 2.0 external credential must now be created - follow the Salesforce guidance here using the configuration specified below:
| External Credential Field | Value |
|---|---|
| Label | Xero |
| Name | Xero |
| Authentication Protocol | OAuth2.0 |
| Authentication Flow Type | Browser Flow |
| Authentication Provider | Select the Auth. Provider created above, Xero |
- Configure and authenticate a Principle with the below configuration
| Principal Field | Value |
|---|---|
| Parameter Name | Xero |
| Sequence Number | 1 |
| Identity Type | Named Principle |
-
The authentication process will launch a browser flow where the User must sign into Xero and select the organisations the integration can access
infoIf there are multiple Xero Organisations the authentication will have to be repeated as only one Organisation can be authenticated at a time
infoEnsure the Principal has been authenticated following the steps in Salesforce documentation
-
Follow the Salesforce guidance to create a named credential with the below configuration:
| Principal Field | Value |
|---|---|
| Label | Xero |
| Name | Xero |
| URL | https://api.xero.com/ |
| Enabled for Callouts | Enabled |
| External Credential | Select the External Credential create above, Xero |
| Generate Authorization Header | Checked |
| Allowed Namespaces | seven20 |
Create a Permission Set for External Credentials
Create a new permission set called Xero_External_Credentials
- Enable access to the external credential principle
- On the permission set, select the settings for External Credential Principal Access
- Enable the Principals created above
- Assign Read permissions for the User External Credentials Object
- On the permission set, select the Object Settings
- Navigate to User External Credentials
- Enable Read permissions
- Assign this Permission Set to all users who will be using the integration
Set up the webhook
Create a site in Salesforce
- In Salesforce setup create a site and copy the created site's URL
- Assign the Xero External Credentials (Xero_External_Credentials) Permission Set to the guest site user
- Assign permissions to the Site as follows:
| Permission Type | Name | Value |
|---|---|---|
| Apex Class | seven20.XeroUpdateInvoiceWebhook | Enabled |
| Custom Metadata Types | seven20.Trigger Action | Enabled |
Configure and confirm the webhook in Xero
- Return to the Xero developer app and navigate to Webhooks
- In the Notify this app about changes to setting select Invoices
- In Delivery URL paste the Salesforce site's URL appended with /services/apexrest/seven20/updateInvoiceStatus
- Save the changes
- Copy the Webhooks Key
- In Salesforce setup navigate to Custom Metadata Types and select Xero Connection
- Navigate to the TenantId metadata record
- Paste the copied key into the Xero Webhook Key field and save the record
- Navigate back to the Xero Webhook configuration screen and press Send 'Intent to receive'
- After a few seconds, the status should appear as OK
Set up Xero Organisations
- As a Salesforce Admin assign yourself the Xero Admin permission set
- In the app explorer navigate to Get Organisations
- Click the Get Organisations button
- After a few seconds a table of authorised organisations will appear
- In the object manager for seven20__Billing__c update the seven20__Xero_Organisation__c picklist to match the values displayed in the Get Organisations screen
Setting up multiple currencies
If multiple currencies will be used when sending invoices, they must be enabled in Xero.
Sending a currency from Seven20 that has not been configured in Xero will cause a failure