.NET Core, Framework and third-party SDKs
The Billecta SDK offers models and stub methods for remote calls. We currrently offer official SDKs for and .NET Core (.NET 5 compatible).
The .NET SDKs are available through NuGet.
Each section in the API has its own Connector in the .NET SDK library. Initiating a connector is made through the following code.
var dc = new DebtorConnector("[SECURETOKEN]", true);
or
var dc = new DebtorConnector("[USERNAME]", "[PASSWORD]", true);
Both SecureToken sign in and username/password sign in is supported in the library. The third parameter (ReThrowErrors) defines if exceptions should be swallowed by the connector, and in case of an
exception instead return null, or rethrow exceptions from the api server to the calling application (your application).
If ReThrowErrors parameter is set to false then null or nothing (in void methods) is returned and any error is found in the dc.HasError
and dc.Error
properties. That means
that you in those cases must check dc.HasError if it is critical that no error has occurred before moving on.
The same SDK can be used for both test and production environments. Default configuration of the SDK is that i makes all calls to htts://api.billecta.com> and version 1 of the API. To change api server to test environment you need to make the following calls.
Billecta.Connector.Connector.BillectaApiServerUrl = "https://apitest.billecta.com";
Billecta.Connector.Connector.BillectaApiVersion = "v1"; // not required since there is currently only one version of the API
To quickly get started with the SDK we have created some code samples
The following sample show how to create a new Debtor
Billecta.Connector.DebtorConnector dc = new Billecta.Connector.DebtorConnector("", "", true); Guid creditorPublicId = /* Enter the owner creditor public id here */; DebtorView debtor = new DebtorView { CreditorPublicId = creditorPublicId, Name = "Acme AB", Address = "Address 1", ZipCode = "11173", City = "Stockholm", ContactEmail = "john.doe@acme.com", ContactName = "John Doe", CountryCode = "SE", Email = "invoice@acme.com", OrgNo = "556677-8899", VatNumber = "SE556677889901", }; var created = dc.CreateDebtor(debtor); Guid debtorPublicId = Guid.Parse(created.PublicId); // save debtorPublicId on you side
A common use of the API is to create an invoice
Billecta.Connector.InvoiceConnector ic = new Billecta.Connector.InvoiceConnector("", "", true); Guid creditorPublicId = /* Enter the owner creditor public id here */; Guid shoesProductPublicId = /* Retreive the shoes product public id here */; Guid socksProductPublicId = /* Retreive the socks product public id here */; InvoiceActionEntryView debtor = new InvoiceActionEntryView { CreditorPublicId = creditorPublicId, CommunicationLanguage = LanguageTypeView.SV, DebtorPublicId = debtorPublicId, DeliveryMethod = DeliveryMethodTypeView.Email, InvoiceDate = DateTime.Now, DueDate = DateTime.Now.AddDays(20), InvoiceNumber = null, // when set to null Billecta api will generate invoice number for you, InvoiceFee = new AmountView(2500, "SEK"), // 25 SEK invoice fee InvoicePDF = null, // when set to null Billecta wil generate the invoice pdf, as alternative that you generate it in your app OurReference = "John Doe", // you contact person YourReference = "Customer contact name", InterestPercentage = 8, InterestTermsInDays = 365, // interest ticks 8% every 360 days InterestType = InterestTypeView.AboveEffectiveReference, InterestStartInDaysAfterDueDate = 0, // start ticking invoice from first due date Records = new List// invoice with two sold products and one message line { new InvoiceActionRecordView { SequenceNo = 0, // sorting order of rows ArticleNumber = 1, ArticleDescription = "Socks", ProductPublicId = socksProductPublicId, Quantity = 10, Units = "pairs", RecordType = RecordTypeView.Standard, UnitPrice =new AmountView(10000, "SEK"), // costs 100 SEK each pair VAT = 25, }, new InvoiceActionRecordView { SequenceNo = 1, ArticleNumber = 4, ArticleDescription = "Shoes", ProductPublicId = shoesProductPublicId, Quantity = 2, Units = "pairs", RecordType = RecordTypeView.Standard, UnitPrice =new AmountView(50000, "SEK"), // costs 500 SEK each pair VAT = 25, }, new InvoiceActionRecordView { SequenceNo = 3, ArticleDescription = "Thank you for purchasing at Acme", RecordType = RecordTypeView.Message } } }; var created = ic.CreateInvoice(debtor); string actionPublicId = created.PublicId;
There is an open source PHP SDK initiated by Johan Eliasson (elitan). The SDK is not complete but a good start and may be contributed to. Please note that this is third-party maintained by the open source community.
The library can be found at https://github.com/elitan/billecta-api-php-client. Please note the license agreement found here before using the SDK.