Skip to content

Xero integration

Synchronize Xero invoices and contacts with ERPNext / custom flows, and receive webhooks from Xero.

  • leekimerp/leekimerp/api/xero.py (primary)
  • Xero tenant and invoice mapping (see DocTypes under lee_kim_alliance_erp related to Xero — e.g. tenant tables, invoice linkage)
sequenceDiagram
participant Xero as Xero Cloud
participant WH as Webhook handler
participant API as xero.py handlers
participant ERP as ERPNext Sales Invoice / Custom
Xero->>WH: Invoice created/updated
WH->>API: Verify signature, parse payload
API->>ERP: Map line items, contacts
API->>ERP: create_lk_erp_invoice / update

Representative functions (internal + exposed): xero_webhook_connection, handle_xero_call, handle_created_invoice, handle_updated_invoice, create_lk_erp_invoice, update_lk_erp_invoice, create_erpnext_sales_flow, sync_xero_invoices, get_xero_invoices.

TypeFunctionNotes
API (GET)get_app_webhook_secretallow_guest=True — review exposure
API (POST)xero_webhook_connectionWebhook payload
APIsync_contact_with_tenant, create_contact, update_sync_statusContact sync
API (GET)get_xero_invoices, sync_xero_invoicesFetch/sync
APImake_new_item, get_total_amount_due_by_contact, get_officersBusiness helpers

Exact signatures and return shapes: read api/xero.py.

  • OAuth token storage (obtain_xero_oauth2_token, store_xero_oauth2_token)
  • ERPNext Sales Invoice, Customer, Item as applicable
  • Xero app credentials and tenant records in Frappe (DocTypes as defined in the project)
  • Webhook signature verification: xero_webhook_verification
  • Use test_mode flags where present (invoice_fetcher, get_xero_invoices) during UAT
  • Maintain parity with Xero API version changes; regression-test webhook and polling paths after upgrades.