API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Book a DIBS payment


I am building an eCommerce solution for one of your customers and I need some advice on how to integrate through the API. When the payment is processed I want to properly book it.

After checking the documentation, here is my assumption. In order to properly book the payment already made I simply create an invoice related to an existing debtor and create a cash book entry connecting that to the invoice like the sample below. Also if there is anything special I need to do when creating the invoice please let me know... Am I correct in this assumption?

        private void CreateCashBookEntry()
            EconomicSession session = new EconomicSession();

            //get the invoice from e-conomic
            IInvoice invoice = session.Invoice.FindByNumber(_invNo);
            //get cashbook and contraaccount from e-conomic
            ICashBook cashBook = session.CashBook.GetAll()[0];
            IAccount contraAccount = session.Account.FindByNumber(1012);

            //create a debtorpayment for the invoice
            ICashBookEntryData cashBookEntryData = session.CashBookEntryData.Create(CashBookEntryType.DebtorPayment, cashBook, invoice.Debtor, null, null, contraAccount);
            cashBookEntryData.Date = DateTime.Today;
            cashBookEntryData.VoucherNumber = (new Random().Next(1000000)) + 1;
            cashBookEntryData.Currency = session.Currency.FindByCode(SEK);
            cashBookEntryData.Amount = invoice.GrossAmount;
            cashBookEntryData.AmountDefaultCurrency = invoice.GrossAmount;
            cashBookEntryData.Text = Payment, Invoice:  + invoice.Number;
            ICashBookEntry entry = session.CashBookEntry.CreateFromData(cashBookEntryData);
            entry.DebtorInvoiceNumber = invoice.Number;                              
created Sep 20, 2012 by lajo_79
0% Accept Rate
Q 2 A 0 C 0

2 Answers

The creation and booking of payment is correct, but are you sure you retrieve the correct cashbook by just grabbing the first one?
answered Oct 9, 2012 by nkn
I was wondering if there is an automatic way of applying the information so that you can avoide the dynamic problem, when adding payment on an invoice from a customer.

The problem is that if you have to set accounts and everything else to do these sorts of transactions.
You would have to have a definition of your account settings in other systems that you want to connect to E-conomics, and you can not do it in a general settings because of the dynamic settings in E-conomics.


You have a POS system in a pizza place, or other type of store and the store owner is not an E-conomics shark (nor am i at this point)

Any way to simplify matters.  This customer that purchased the POS system now have 3 standard customers in E-conomics and they are as follows.:

1 Cash customer
1 Credit card customer
1 Gift certificate customer.

As the day rings to an end the POS user does a z-out on the cash register (POS) system and the system creates (x) no. of invoices in E-conomics - 1 per customer according to the payments on the cash register

Simplified example:

We have 1500 in cash payment and 200 on creditcard

So at the end of the day I add 2 invoices to E-conomics.
One for the cash payment and one for the credicard payment and then I would have to apply these invoices to the system so that it shows up in the right accounts and we do not have a problem with the accountant.

How ever you can do the DebitorPayment settings in the Cashbook controls of E-conomics and there every thing with the dynamic data works because you have predefined it in E-conomics and because you do it on the E-conomics site it works.
But will this also work when using the programming interface or ?

One senario in Sudo code could be

[code=php:2ftrb84g]Customer = Economics-getDebtorByName('Cash Customer');Service = Economics-getProductByName('Sold goods');Economics-AddInvoice(Customer,Service,Amount);Customer = Economics-getDebtorByName('Credit Customer');Service = Economics-getProductByName('Sold goods');Economics-AddInvoice(Customer,Service,Amount);$Customer = Economics-getDebtorByName('Gift certificate Customer');$Service = Economics-getProductByName('Sold goods');Economics-AddInvoice(Customer,Service,Amount);$AllInvoices = Economics-debtor-getAllOrdersByDebtor('Cash Customers');Ecomnomics-cashBookEntryData-Create(cashBookEntryTypedebtorPayment,cashBook,AllInvoicesdebtor);ETC
answered Dec 13, 2012 by HansenKent
Visma e-conomic A/S