Xero Billing Setup Guide
This guide walks you through setting up Xero as the billing provider for your AMS installation. This is a one-time setup process that must be completed before deploying the AMS website.
Overview
AMS integrates with Xero to handle:
- Creating and managing customer contact records
- Generating invoices for memberships and services
- Sending invoice emails to customers
- Tracking invoice payment status automatically via webhooks
- Synchronizing invoice data between AMS and Xero
Prerequisites
Before you begin, ensure you have:
- Xero account with administrator access to your organization
- Xero Custom Connection subscription - See Xero's Custom Connection documentation for details
- Note: The Xero Demo Company can be used for free during testing and development
- Access to the Xero Developer Portal at https://developer.xero.com/
- The domain name where your AMS website will be hosted (for webhook configuration)
Step 1: Create a Custom Connection in Xero
- Navigate to Xero My Apps in the Xero Developer Portal
- Click "New App" button
- Fill in the application details:
- App name: Give it a descriptive name (e.g., "AMS Billing Integration" or "Association Management Billing")
- Integration type: Select "Custom connection"
- Company or application URL: This is not used as part of the integration, just a reference of the website. Enter your domain here.
- Click "Create app"
Step 2: Configure App Scopes
After creating the app, you'll need to select which permissions (scopes) the integration requires:
- In your app's configuration page, locate the "OAuth 2.0 Scopes" section
- Select the following scopes:
- ✅
accounting.contacts- Required for creating and managing customer contacts - ✅
accounting.transactions- Required for creating, retrieving, and managing invoices
- ✅
- Click "Save" to apply the scope changes
Step 3: Authorize the Connection
- In the "Select the authorizing user" section, choose the Xero user who will authorize the connection
- This user must have the appropriate permissions in your Xero organization
- The selected user will receive an email with an authorization link
- Have them:
- Click the link in the email
- Review and consent to the requested scopes
- Select the Xero organization to connect to AMS
- Complete the authorization
Custom Connection Subscription
Your organization must have an active Custom Connection subscription to use this integration in production. For testing and development, you can use the Xero Demo Company for free.
Step 4: Retrieve API Credentials
Once the connection is authorized, you need to collect several pieces of information to provide to your deployment team.
Client ID and Client Secret
- In the Xero Developer Portal, go to your app's configuration page
- Locate the "Client credentials" section
- Copy the Client ID - this is your
XERO_CLIENT_ID - Click "Generate a secret" if you haven't already
-
Copy the Client Secret immediately - this is your
XERO_CLIENT_SECRETImportant
The client secret is only shown once. Store it securely - you won't be able to see it again. If you lose it, you'll need to generate a new one.
Step 5: Configure Webhooks
Webhooks allow Xero to notify AMS when invoice status changes (e.g., when an invoice is paid).
Webhook URL Requirements
- Make sure your AMS deployment is accessible before configuring the webhook
- The webhook URL must be HTTPS (secure connection)
- Xero will send a test request to verify the endpoint during setup
- In the Xero Developer Portal, go to your app's configuration page
- Navigate to the "Webhooks" section.
- For the 'Notify this app about changes to' field, select 'Contacts' and 'Invoices'.
- Enter your webhook URL:
- Format:
https://YOUR_DOMAIN/billing/xero/webhooks/ - Example:
https://members.example.org/billing/xero/webhooks/
- Format:
- A Webhook Key will be automatically generated - this is your
XERO_WEBHOOK_KEY - Copy this webhook key and store it securely
- Click "Save"
Step 6: Collect Required Values
Tenant ID (Organization ID)
- Within your app on the Xero Developer Portal, select "Connection management"
- The Tenant ID will be listed here - this is your
XERO_TENANT_ID
Account Code
The Account Code determines which account in your Xero Chart of Accounts will be used for invoice line items.
- Log into your Xero organization
- Navigate to Accounting → Chart of Accounts
- Identify the account you want to use for membership fees and services
- Common choices include revenue accounts like "Sales" (often code
200) or "Membership Income"
- Common choices include revenue accounts like "Sales" (often code
- Note the Code column value for that account - this is your
XERO_ACCOUNT_CODE
Currency and Tax Settings
Based on your organization's location and Xero setup, determine:
- Currency Code: The 3-letter ISO currency code (e.g.,
NZD,AUD,USD,GBP,EUR)- This is your
XERO_CURRENCY_CODE
- This is your
- Amount Type: How tax is calculated on invoices:
INCLUSIVE- Line item amounts include taxEXCLUSIVE- Tax is added on top of line item amounts- This is your
XERO_AMOUNT_TYPE
Step 7: Prepare Credentials for Deployment
Once you've collected all the required information, you need to provide it to your deployment team or system administrator. Prepare a secure document containing:
Required Credentials
| Variable Name | Description | Your Value |
|---|---|---|
AMS_BILLING_SERVICE_CLASS |
Required to use Xero billing | ams.billing.providers.xero.XeroBillingService |
XERO_CLIENT_ID |
OAuth2 Client ID from Step 4 | |
XERO_CLIENT_SECRET |
OAuth2 Client Secret from Step 4 | |
XERO_TENANT_ID |
Organization/Tenant ID from Step 4 | |
XERO_WEBHOOK_KEY |
Webhook signing key from Step 5 | |
XERO_ACCOUNT_CODE |
Chart of Accounts code from Step 4 | |
XERO_AMOUNT_TYPE |
Either INCLUSIVE or EXCLUSIVE |
|
XERO_CURRENCY_CODE |
3-letter currency code (e.g., NZD) |
Optional Configuration
| Variable Name | Description | Recommended Value |
|---|---|---|
XERO_EMAIL_INVOICES |
Enable/disable invoice emails | True for production, False for Demo Company (unsupported by Xero) |
AMS_BILLING_EMAIL_WHITELIST_REGEX |
Filter invoice email recipients (for testing) | Leave empty for production |
Security Warning
These credentials provide access to your Xero organization's financial data. Handle them with extreme care:
- Use a secure method to transmit credentials (encrypted email, password manager, secure portal)
- Never commit credentials to version control
- Never share credentials in plain text chat or unencrypted email
- Restrict access to only those who need it
- Consider using a password manager or secrets management system
Testing with Xero Demo Company
For development and testing purposes, you can use the Xero Demo Company instead of a production organization:
- When authorizing the Custom Connection in Step 3, select the "Demo Company" instead of your production organization
- The Demo Company is free and comes with sample data
- Set
XERO_EMAIL_INVOICES=Falsein your environment variables when using the Demo Company to prevent sending test emails - You can create and manage test invoices without affecting real financial data
Demo Company Limitations
- Demo Company data may be reset periodically
- Some features may behave differently than in production organizations
- Always perform final testing in a production-like environment before going live
Verifying the Integration
After your deployment team has configured AMS with the credentials:
- Log into the AMS website as a user
- Try creating a membership
- Verify that:
- Contact is created in Xero
- Invoice appears in Xero with correct details
- Once paid in Xero, the membership is marked as paid within the AMS website
Troubleshooting
"Invalid credentials" or "Unauthorized" errors
- Double-check that
XERO_CLIENT_IDandXERO_CLIENT_SECRETare correct - Ensure the Custom Connection is still authorized
- Verify the user who authorized the connection still has appropriate permissions
Invoices not appearing in Xero
- Verify
XERO_TENANT_IDmatches your organization - Check that the scopes
accounting.contactsandaccounting.transactionsare enabled - Review application logs for API errors
Webhook not receiving updates
- Verify the webhook URL is correct and accessible via HTTPS
- Check that
XERO_WEBHOOK_KEYmatches the key in Xero Developer Portal - Test the webhook endpoint manually or check Xero's webhook delivery logs
Invoice emails not sending
- Verify
XERO_EMAIL_INVOICES=Truein your environment variables - Check that contact email addresses are valid in Xero
- If using Demo Company, email sending is disabled by default
Rate limiting errors
If you encounter rate limiting errors (too many API requests):
- Xero has API rate limits (60 requests per minute)
- The AMS system handles this automatically with exponential backoff
- If issues persist, contact your developer team to review API usage patterns
- Consider spreading bulk operations (like importing many members) over time
Next Steps
Once the Xero integration is configured and verified:
- Train your team on how to use the billing features in AMS
- Set up your membership plans and pricing
- Configure invoice templates in Xero (if desired)
- Establish billing workflows and processes
- Monitor the integration during the first billing cycle
For additional support, contact your AMS implementation team or refer to the developer documentation.