Created with Sketch.
Created with Sketch.

How to get started

On this page you will find information about how to Construct the authentication header and how to Initialize payment.

API Authentication

Merchants have to authenticate themselves using Basic HTTP Authentication to be able to use the API. Each HTTP request sent by a Merchant must contain an HTTP header with Site Code as a user name and Site Password as a password. 

Although it should not ever be necessary to construct the authentication header manually, it is easy to do so.

Constructing the Authentication Header

The Site Code and Site Password are concatenated into a single string delimited by a colon. E.g.: 

MyContosoSite1:P@ssw0rd

The concatenated string is encoded into a Base64 string (using ASCII encoding): 

TXlDb250b3NvU2l0ZTE6UEBzc3cwcmQ=

The encoded string is added to the HTTP request as an HTTP header like this: 

Authorization: Basic TXlDb250b3NvU2l0ZTE6UEBzc3cwcmQ=

Notes

There is no kind of access token that merchants would have to remember between consecutive calls. That way, Merchants also does not need to handle related issues such as access token expiration. The same authentication header can be used as long as the credentials are valid.
If the authentication fails (e.g. due to invalid credentials), the API methods returns HTTP status code 401 (Unauthorized).

BaseURL:s

Avarda base url:s for checkoutAPI:

Test environment: https://stage.avarda.org/checkout2

Production environment: https://online.avarda.org/checkout2

InitializePayment

Call InitializePayment to start the payment session.

POST /CheckOut2Api/InitializePayment

Passes information about an order from the partner site to the service and negotiates a new session.

In this method, the partner site has an option to provide various information about the customer that can be pre-filled into the checkout form once shown. Based on further business logic, the customer may or may not be allowed to change some of these values.

{   
    "Mail" : "Customers@mail.adddress"
    "Description" : "New standard purchase",
    "Price" : 100,
    "Items": [
    {
      "Amount": 90,
      "Description" : "quitar"
    },
    {
      "Amount": 10,
      "Description" : "piano"
    }
  ],

}

Return Value

The method returns a Purchase ID for the Negotiated session formated as a String. An eample:

"19ac0d1ee909c302d212b4324d9194b5"

Please note that although the return type is just a simple string, it is still formatted as JSON. Hence the quotes.