If you are looking for Xero integration please read this article.
First, we have to create a Customer Account.
The following elements are required for creating accounts.
Account Code – Customer defined alphanumeric account code e.g 200 or SALES (max length = 10)
Account Name – Name of Account
Type – Bank, Current, Fixed, Sales, etc.
See many account types here
BankAccountNumber – For bank accounts only (Account Type BANK)
BankAccountType – Bank (Creating credit card or Paypal accounts is not currently supported).
The following elements are optional for creating accounts.
Status – Accounts with a status of ACTIVE can be updated to ARCHIVED.
Description – Description of the Account. Valid for all types of bank accounts.
C# Code Example
Create the Helpers folder and make a class file namely XeroApiHelper.cs and add the code in it.
using System; using Xero.Api.Core; using Xero.Api.Example.Applications.Partner; using Xero.Api.Example.Applications.Public; using Xero.Api.Infrastructure.Interfaces; using Xero.Api.Infrastructure.OAuth; using Xero.Api.Example.TokenStores; using Xero.Api.Serialization; using System.Configuration; namespace XeroApplication.Helpers { public class ApplicationSettings { public string BaseApiUrl { get; set; } public Consumer Consumer { get; set; } public object Authenticator { get; set; } } public static class XeroApiHelper { private static ApplicationSettings _applicationSettings; static XeroApiHelper() { var callbackUrl = ConfigurationManager.AppSettings["callbackUrl"]; var memoryStore = new MemoryTokenStore(); var requestTokenStore = new MemoryTokenStore(); var baseApiUrl = ConfigurationManager.AppSettings["baseApiUrl"]; // Consumer details for Application var consumerKey = ConfigurationManager.AppSettings["consumerKey"]; var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"]; // Public Application Settings var publicConsumer = new Consumer(consumerKey, consumerSecret); var publicAuthenticator = new PublicMvcAuthenticator(baseApiUrl, baseApiUrl, callbackUrl, memoryStore, publicConsumer, requestTokenStore); var publicApplicationSettings = new ApplicationSettings { BaseApiUrl = baseApiUrl, Consumer = publicConsumer, Authenticator = publicAuthenticator }; _applicationSettings = publicApplicationSettings; } public static ApiUser User() { return new ApiUser { Name = Environment.MachineName }; } public static IConsumer Consumer() { return _applicationSettings.Consumer; } public static IMvcAuthenticator MvcAuthenticator() { return (IMvcAuthenticator)_applicationSettings.Authenticator; } public static IXeroCoreApi CoreApi() { if (_applicationSettings.Authenticator is IAuthenticator) { return new XeroCoreApi(_applicationSettings.BaseApiUrl, _applicationSettings.Authenticator as IAuthenticator, _applicationSettings.Consumer, User(), new DefaultMapper(), new DefaultMapper()); } return null; } } }
Open the HomeController.cs file and create a new method and add the below code in it.
var api = XeroApiHelper.CoreApi(); Account CreateAccount = new Account { Code = "925",//uniq number Name = "TheCodeHubs",//uniq name for customer Type = Xero.Api.Core.Model.Types.AccountType.Current, BankAccountNumber = "456-121-1234567",//your bank account number BankAccountType = Xero.Api.Core.Model.Types.BankAccountType.Bank }; api.Accounts.Create(CreateAccount); status = "true";
You can explore API by the following URL