Xero is a popular accounting software with API endpoints available for developers. Here I will show you how to create invoices using Xero API.
Cons
Take a look at Xero Getting Started Guide where you can find useful information and a simple guide which allows you to go through an implementation process easily. We are going to use a Xero demo company example, because it is a free solution and it's possible to reset it. You can also use trial version of Xero.com. Here youhere: https://developer.xero.com/documentation/getting-started/development-accounts/ is a link which allows a developer to configure a Xero demo company app.
This blogpost might be useful for working with 2 and 3-legged OAuth: What is 2-legged OAuth
In this tutorial, we are going to use a private version of API. It requires generating certificates and is a little bit simpler than other kinds of an access to API.
Create a private application (guide)
Please see a section titled Using OpenSSL. Key generation requires only these steps in your console
openssl genrsa -out privatekey.pem 1024
openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 1825
openssl pkcs12 -export -out public_privatekey.pfx -inkey privatekey.pem -in publickey.cer
You will end up with three files:
Move them to app/certs in your application folder
Install gem you prefer (I will show you examples for both of them below)
gem 'xeroizer'
or
gem 'xero_gateway'
and run bundle install
Retrieve Xero API credentials (guide) and place them in your secrets.yml
development:
secret_key_base:
xero_consumer_key:
xero_consumer_secret:
cert_path: 'app/certs/privatekey.pem'
Here is a piece of code with allows a developer to connect with API and return all list with which is rendered inside a view
[code]
[code]
Here is a piece of code with allows a developer to connect with API and return all list with which is rendered inside a view
[code]
[code]
If you encounter any problems with API, you might be able to find an error at https://app.xero.com/Application/History where you can see latest queries to API.