How To's

Github testshop

The code for the externalshop can be found here https://github.com/webwinkelfacturen/externalshop.

Loom overview of the externalshop code: https://www.loom.com/share/d5a1e61934114f2ca562c8f92006d4e4?sharedAppSource=team_library

To connect to Wisteria OAuth is used. There is example code for this and it is explained here: https://www.loom.com/share/c41e270007c54ea9a67f99d79dd36220?sharedAppSource=team_library

The Wisteria tests: https://www.loom.com/share/d3bdd7e8852b4c20958c45d22832849c?sharedAppSource=team_library

To add a merchant to your partner dashboard: https://www.loom.com/share/1be01ed729984325b9aacba4bb7cbcfc

Signatures

What?
Signing requests

Why?
Done for security.

Example signing post
The input for the signing request is the data to be added, the currect date and the clientsecret. In PHP the calculation is done as, where the reset function returns the first item in the array:
md5( gmdate("Ydm").gmdate("dmY").$secret.(string)reset($array).gmdate("dmY") )

So for

- date = 2022-05-31
- $secret = DBsrN.lt6RZ6G4TJGtdGbDo.F and
- $array = ["order" => '{"orderid":100012510}']
- md5( 
      '20223105'.'31052022'.'DBsrN.lt6RZ6G4TJGtdGbDo.F'.'{"orderid":100012510}'.'31052022' 
     )
- the signature would be 97586f4d3ef50ea70622d4132955d430

Example signing read
md5( gmdate("Ydm").gmdate("dmY").$secret.gmdate("dmY") )

- date = 2022-05-31
- $secret = DBsrN.lt6RZ6G4TJGtdGbDo.F and
- the signature would be 123da89bf3fd9d2aebf74cf6017cc6e3


In the example code: externalshop/system/utils/constants.php

Categories

What?
Add categories from the shop to Wisteria.

Why?
Categories are used when pushing closures to Wisteria. In the closures both the turnover and the payments are pushed. There is a choice between pushing the turnover based on the taxes or on these categories.

Notice: The categories are NOT used for pushing individual sales.

Example post

Request

{"categories":"[{\"categoryid\":111,\"code\":\"CAT_001\",\"name\":\"Tea\"},{\"categoryid\":112,\"code\":\"CAT_002\",\"name\":\"Bread\"},{\"categoryid\":211,\"code\":\"CAT_003\",\"name\":\"Cookies\"},{\"categoryid\":212,\"code\":\"CAT_004\",\"name\":\"Vegetables\"}]","signature":"d7283f9128fe22ae8d2db1e887f9467d"}

Response

{"data":[{"categoryid":"111","code":"CAT_001","name":"Tea"},{"categoryid":"112","code":"CAT_002","name":"Bread"},{"categoryid":"211","code":"CAT_003","name":"Cookies"},{"categoryid":"212","code":"CAT_004","name":"Vegetables"}],"message":"Your data is inserted successfully"}


In the example code: externalshop/tests/categoryapi/addCategories.php

Closures

What?
Add dayclosures from the POS to Wisteria.

Why?
This option can be used if you want to add the dayclosure of a POS. You simple add all turnover per productgroup and payments per paymentmethod. You do not need to push the underlying receipts. Wisteria creates a daily booking based on the closure and will push this closure to the accounting system.

Wisteria checks if the categories and paymentmethods are already available. Matching is done on the groupid for categories and the methodid for the paymentmethods. If a category or paymentmethod is not available it is added automatically to Wisteria. This means that you will not need separate calls to add categories and paymentmethods.

If you pos works with closures this is an easy way to push the pos finances. It is also easy to verify the booking in the accounting system with the closure data. If you do not have closures in the pos you should not use this option. In that case it is better to push the receipts.

Example post

Request

{"closure":"{\"closureid\":111,\"closurenumber\":\"CLS_001\",\"closurename\":\"Dagafsluiting 2021-03-21\",\"closuredate\":\"2021-03-21\",\"registerid\":\"2\",\"registername\":\"Toonbank\",\"currency\":\"EUR\",\"productcategories\":[{\"groupid\":1,\"lineExcl\":50,\"taxValue\":4.5,\"taxRate\":9},{\"groupid\":2,\"lineExcl\":50,\"taxValue\":4.5,\"taxRate\":9},{\"groupid\":3,\"lineExcl\":100,\"taxValue\":4.5,\"taxRate\":21}],\"payments\":[{\"methodid\":1,\"total\":54.5},{\"methodid\":2,\"total\":121}]}","signature":"491fcaba18d1e1dafe8df20872fee0fc"}

Response

{"data":{"closureid":"111","closurenumber":"CLS_001","closurename":"Dagafsluiting 2021-03-21","closuredate":"2021-03-21 00:00:00","currency":"EUR","registerid":"2","registername":"Toonbank","payments":[{"closureid":"111","methodid":"1","methodname":null,"total":"54.5"},{"closureid":"111","methodid":"2","methodname":null,"total":"121"}],"productcategories":[{"groupid":"1","currency":null,"lineExcl":"50.0000","taxValue":"4.5000","taxRate":"9.0000"},{"groupid":"2","currency":null,"lineExcl":"50.0000","taxValue":"4.5000","taxRate":"9.0000"},{"groupid":"3","currency":null,"lineExcl":"100.0000","taxValue":"4.5000","taxRate":"21.0000"}]}


In the example code: externalshop/tests/closureapi/addClosure.php

Customers

What?
Add customer-details from the shop to Wisteria.

Why?
For shop sales customer-details should also be added to the accounting system. The sales for this customer can then always be booked using this customer in the accounting system. Matching will be done on emailaddress.

There are two ways to add the customer. The customer can be added as part of the sales. Care must be taken that the customer is not already present. The check is done on customer id and emailaddress. It is also possible to add a customer separately to Wisteria. This option can be choosen if all sales must be booked on one default debtor.

Example post

Request

{"customer":"{\"customerid\":1,\"customernumber\":\"CUST001\",\"firstname\":\"Jean\",\"lastname\":\"Doe\",\"company\":\"Grocery online\",\"address1\":\"Stationstraat 12\",\"zipcode\":\"1000 AA\",\"city\":\"Amsterdam\",\"isocountry\":\"NL\",\"mobile\":\"0612345678\",\"email\":\"jean@mycompany.nl\"}","signature":"f4fd6431c2bfcef9d6288caa2aa24d9b"}

Response

{"data":{"customerid":"1","orderid":"","customernumber":"CUST001","firstname":"Jean","lastname":"Doe","company":"Grocery online","address1":"Stationstraat 12","address2":null,"housenr":null,"zipcode":"1000 AA","city":"Amsterdam","state":null,"country":null,"isocountry":"NL","kvk":null,"btwnr":null,"telnr":null,"mobile":"0612345678","email":"jean@mycompany.nl","iscompany":null,"isicp":null,"isinternational":null,"incltax":null},"message":"Your data is inserted successfully"}


In the example code: externalshop/tests/customerapi/addCustomer.php

Ledgercodes

What?
Add ledgercodes to Wisteria.

Why?
The ledgercodes are used in the configuration of the connector. There must be a way to match the ledgercodepercentages from the shop with the the ledgercodes in the accounting system. Since very often there must a booking in the accounting system per country we advise you add the ledgercodes per EU iso country code. It is also useful to add separate ledgercodes for the UK, Norway and Switzerland.

Add one ledgercode for ICP inside the EU and one ledgercode for sales outside the EU.

Example post
Request

{"ledgercodes":"[{\"ledgercodeid\":61,\"code\":"8000",\"name\":\"Omzet 21%\",\"description\":\"Verkopen Hoog NL\",\"taxpercentage\":\"21\",\"type\":\"turnover\",\"country\":\"NL\"},{\"ledgercodeid\":62,\"code\":\"8010\",\"name\":\"Omzet 9%\",\"description\":\"Verkopen Laag NL\",\"taxpercentage\":\"0.09\",\"type\":\"turnover\",\"country\":\"NL\"},{\"ledgercodeid\":63,\"code\":\"8110\",\"name\":\"Omzet 6% BE\",\"description\":\"Verkopen Laag BE\",\"percentage\":6,\"type\":\"turnover\",\"country\":\"BE\"},{\"ledgercodeid\":64,\"code\":\"8100\",\"name\":\"testledgercode\",\"description\":\"Verkopen Hoog BE\",\"percentage\":0.21,\"type\":\"turnover\",\"country\":\"BE\"}]","signature":"8ff6657af67372582b57d28b7451d33b"}
Response
{"data":[{"ledgercodeid":"61","code":"8000","percentage":"21","name":"Omzet 21%","description":"Verkopen Hoog NL","type":"turnover","country":"NL"},{"ledgercodeid":"62","code":"8010","percentage0":"21","name":"Omzet 9%","description":"Verkopen Laag NL","type":"turnover","country":"NL"},{"ledgercodeid":"63","code":"8110","percentage":"6","name":"Omzet 6% BE","description":"Verkopen Laag BE","type":"turnover","country":"BE"},{"ledgercodeid":"64","code":"8100","percentage":"21","name":"Omzet 21% BE","description":"Verkopen Hoog BE","type":"turnover","country":"BE"}],"message":"Your data is inserted successfully"}


In the example code: externalshop/tests/ledgercodeapi/addLedgercodes.php

Sales

What?
Add sales from the shop to Wisteria.

Why?
When adding the shop sales to Wisteria our connectors will pick them up and push them to the accounting system. A sale consists of sale-lines (required) and possibly shipping, paymentcosts and fees. Discounts can be given either as an overall amount or per saleline, not both.

When adding an sale to Wisteria many validity checks will be done. It will be checked whether the sale totals match the amounts on the lines. If both unitprices and lineprices are given in the sale-lines it is checked that these amounts are in sync. Wisteria will accept a delta of max 5 cents.

It is possible to add customer-data with the sale or to add a customerid. If a customerid is used, a customer with that customerid must be in Wisteria. If the customer-data is added it must be ensured that the customer is not yet in Wisteria. Matching is done on the emailaddress and the customerid given in the customerdata.

The checks are done to ensure that the data in Wisteria is correct data.

Example post

Request

{"sale":"{\"saleid\":112,\"salenumber\":\"ORD003\",\"affiliatenr\":\"testaff2\",\"paymentstatus\":\"paid\",\"salestatus\":\"completed\",\"saledate\":\"2021-03-21\",\"totalExclWithDiscount\":100,\"totalInclWithDiscount\":109,\"totalVatWithDiscount\":9,\"items\":[{\"referenceid\":112,\"lineid\":1,\"name\":\"Bag of Apples\",\"productcode\":\"SKU_BOA\",\"quantity\":1,\"lineInclWithDiscount\":54.5,\"lineExclWithDiscount\":50,\"lineVatWithDiscount\":4.5,\"taxpercentage\":9}],\"shipping\":[{\"referenceid\":112,\"shippingid\":1,\"name\":\"Verzendkosten\",\"quantity\":1,\"lineInclWithDiscount\":54.5,\"lineExclWithDiscount\":50,\"lineVatWithDiscount\":4.5,\"taxpercentage\":9}],\"customer\":{\"customerid\":1,\"customernumber\":\"CUST001\",\"firstname\":\"Jean\",\"lastname\":\"Doe\",\"company\":\"Grocery online\",\"address1\":\"Stationstraat 12\",\"zipcode\":\"1000 AA\",\"city\":\"Amsterdam\",\"isocountry\":\"NL\",\"mobile\":\"0612345678\",\"email\":\"jean@mycompany.nl\"}}","signature":"82dfaa9c9c6747c2d09cc21cedb52d73"}

Response

{"data":[{"saleid":"112","affiliatenr":"testaff2","cartnr":null,"currency":null,"customerid":"1","deliveryaddressid":null,"paymentstatus":"paid","salestatus":"completed","salenumber":"ORD003","saledate":"2021-03-21 00:00:00","deliverydate":null,"totalDiscountVat":null,"totalDiscountIncl":null,"totalDiscountExcl":null,"totalInclWithDiscount":"109.0000","totalExclWithDiscount":"100.0000","totalVatWithDiscount":"9.0000","items":[],"customer":{"customerid":"1","saleid":"112","customernumber":"CUST001","firstname":"Jean","lastname":"Doe","company":"Grocery online","address1":"Stationstraat 12","address2":null,"housenr":null,"zipcode":"1000 AA","city":"Amsterdam","state":null,"country":null,"isocountry":"NL","kvk":null,"btwnr":null,"telnr":null,"mobile":"0612345678","email":"jean@mycompany.nl","iscompany":null,"isicp":null,"isinternational":null,"incltax":null},"shipping":[{"name":"Verzendkosten","referenceid":"112","shippingid":"1","code":null,"taxpercentage":"9.0000","unitInclWithDiscount":null,"unitExclWithDiscount":null,"unitVatWithDiscount":null,"unitDiscountIncl":null,"unitDiscountExcl":null,"unitDiscountVat":null,"createddate":"2021-04-15 00:00:00"}],"payment":[],"fees":[]}],"message":"Your data is inserted successfully"}


In the example code: externalshop/tests/saleapi/addSale.php

Paymentmethods

What?
Add the shop paymentmethods to Wisteria.

Why?
The connector uses paymentmethods in two situations:

  1. Individual sales: Normally the customer-data is pushed to the accounting system. Sometimes this is not required because adding all these customers to the accounting system will result in too many customers in the accounting system. By assigning default debtors per paymentmethod the number of customers in the accounting system will be restricted. Using the fixed debtors may also make an easier matching possible between the payments and sales.
  2. Closures: For closures the payments are assigned to ledgercodes, depending on the paymentmethods.

Example post
Request

{"paymentmethods":"[{\"paymentmethodid\":112,\"name\":\"ideal\",\"type\":\"standard\"},{\"paymentmethodid\":113,\"name\":\"cash\",\"type\":\"standard\"}]","signature":"2035ddf2b385d8778cef2df9dc2b34b8"}
Response
{"data":[{"paymentmethodid":"112","name":"ideal","type":"standard"},{"paymentmethodid":"113","name":"cash","type":"standard"}],"message":"Your data is inserted successfully"}


In the example code: externalshop/tests/paymentmethodapi/addPaymentmethods.php

Taxes

What?
Add taxes to Wisteria.

Why?
The taxes are used in the configuration of the connector. There must be a way to match the taxpercentages from the shop with the taxes, and if applicable, the ledgercodes in the accounting system. Since very often there must a booking in the accounting system per country we advise you add the taxes per EU iso country code. It is also useful to add separate taxes for the UK, Norway and Switzerland.

The connector will itself add tax-codes for ICP and sales outside Europe. Taxes for countries outside the EU unequal to UK, Norway and Switzerland will not be processed by the connector. If you try to add them you will receive an error message.

Example post
Request

{"taxes":"[{\"taxid\":111,\"taxcode\":\"VL\",\"percentage\":9,\"title\":\"testtax\",\"country\":\"NL\"},{\"taxid\":112,\"taxcode\":\"VH\",\"percentage\":0.21,\"title\":\"testtax\",\"country\":\"NL\"},{\"taxid\":211,\"taxcode\":\"VLBE\",\"percentage\":6,\"title\":\"testtax\",\"country\":\"BE\"},{\"taxid\":212,\"taxcode\":\"VHBE\",\"percentage\":0.21,\"title\":\"testtax\",\"country\":\"BE\"}]","signature":"8ff6657af67372582b57d28b7451d33b"}
Response
{"data":[{"taxid":"111","taxcode":"VL","percentage_1":"0.0900","percentage_100":"9.0000","title":"testtax","description":null,"country":"NL"},{"taxid":"112","taxcode":"VH","percentage_1":"0.2100","percentage_100":"21.0000","title":"testtax","description":null,"country":"NL"},{"taxid":"211","taxcode":"VLBE","percentage_1":"0.0600","percentage_100":"6.0000","title":"testtax","description":null,"country":"BE"},{"taxid":"212","taxcode":"VHBE","percentage_1":"0.2100","percentage_100":"21.0000","title":"testtax","description":null,"country":"BE"}],"message":"Your data is inserted successfully"}


In the example code: externalshop/tests/taxapi/addTaxes.php

How to connect

Are you looking for instructions how to add, read and remove data to and from Wisteria? Here you can find How to's including code examples. Background Image

Which entities

You can choose which entities to use. You can add sales via the order, invoice, receipt, refund and closure endpoints. You can add additional information via the customer, taxes, payment-methods and category endpoints. You can collect the financial transaction for the accounting system. Background Image

Flow via Wisteria to Invoicesystem

Once your data is added to Wisteria the connection with the accounting/invoicesystem can be configured provided the merchant has subscribed to an accounting connection. The sale will automatically be pushed from Wisteria to the accountingsystem. More details how this can be done and some do's and don'ts…. Background Image