Integration: Xero Accounting
Ali Ryder
I would love to see native integration with accounting platforms. I use Xero. Here's what that would look like for me, ideally:
- Add a new Payment Processor called Xero
- When a new paid purchase is made in Simplero, create a contact in Xero if it doesn't already exist
- When a Simplero purchase is made and the Xero payment method is selected, create an invoice in Xero and send it to the customer
- b) When that invoice in Xero is paid, mark the purchase in Simplero as paid and activate the purchase
- When a Simplero purchase is made and Simplero handles the payment processing, create an invoice in Xero and mark it as paid
- When a Simplero purchase is refunded, likewise update the books in Xero
Now I actually already have much of this set up by posting to webhooks, and I can share with you much of the necessary code. But there's some parts that are missing. For example, using the Simplero API, you can't activate a pending purchase, so that has to be done manually. And you need to set up the triggers for each and every product, of which I have hundreds, so that's a pain in the butt.
This general approach could easily be replicated for most other accounting softwares that have an API, including Quickbooks, Freshbooks, Sage, etc.
Log In
Ali Ryder
Here's some code for creating an invoice:
POST https://api.xero.com/api.xro/2.0/Invoices
[
{
"Url": "https://{{mysite}}.simplero.com/admin/purchases/{{purchase_id}}",
"Date": "{{created_at}}",
"Type": "ACCREC",
"Status": "DRAFT", -- or "AUTHORISED" for paid
"Contact": "{{get from customer in Xero}}",
"tenantId": "{{get from Xero account}}",
"LineItems": [
{
"TaxType": "{{get from customer in Xero}}",
"ItemCode": "{{product_id}}",
"Quantity": {{quantity}},
"TaxAmount": {{sales_tax}},
"LineAmount": {{sales_price}},
"UnitAmount": {{sales_price}},
"AccountCode": "200", -- or probably an integration setting; what account do you want these to go into
"Description": "Online purchase by {{name}} on {{created_at}} for {{product_name}}"
}
],
"Reference": "{{purchase_id}}",
"CurrencyCode": "{{currency_code}}",
"LineAmountTypes": "Exclusive" -- this depends on product tax setting, "list price with tax" or not, or no tax. Could be "Inclusive" or "NoTax"
}
]