The SecucardConnect class

Smart object

From the SecucardConnect object, you have direct access to the Smart object, which contains implementations for all Smart products (Idents, Checkins, Transactions). Since these implementations all inherit from ProductService, CRUD (Create, Read, Update, Delete) functionality is supported for all products. Refer to Query Parameters for information on retrieval of data. Some usage examples include:

// Get avaliable Idents
var idents = Client.Smart.Idents.GetList(null);
// Create new transaction
var newTransaction = new Transaction
{
    BasketInfo = new BasketInfo {Sum = 1, Currency = "EUR"},
    MerchantRef = "John Doe",
    TransactionRef = "Transaction #1234"
};

var transaction = Client.Smart.Idents.Transactions.Create(newTransaction);

For products where events are meaningful, you can also register for these events:

// Register checkin events
Client.Smart.Checkins.CheckinEvent += OnCheckinEvent;

...

private void OnCheckinEvent(object sender, CheckinEventArgs args)
{
    var checkedinCustomer = args.Customer;
}

You will see that there are a lot of similarities between all smart services, and that knowing how to use one service means that you can use them all.

Checkins

The Checkin data type signifies a checked-in user and is, simplified, defined as follows:

Checkin class diagram

The checkin service can be queried for a list of checkins, by means of the method GetList. Optional query parameters for pagination, sorting, etc. can be specified; refer to Query Parameters for more information. A typical use case for the checkin service is the retrieval of all checkins on (re)start of the application, and registration for checkin events in order to keep the checkins list up to date, as is depicted in the following sequence diagram.

Checkin service

As you can see, all you need is an instantiated Client object, which you have authenticated. We explained how to obtain this object state in the previous chapter. As soon as you have this object, a minimal implementation of the above diagram is as simple as:

foreach (var checkin in Client.Smart.Checkins.GetList(null).List)
{
    // Add checkin to local cache
}

Client.Smart.Checkins.CheckinEvent += CheckinEvent;

...

private void CheckinEvent(object sender, CheckinEventEventArgs args)
{
    // add args.SecucardEvent.Data to local cache
}

Idents

The Ident data type signifies any ident (customer card, discount option, ..) and is, simplified, defined as follows:

Ident class diagram

The ident service can be queried for a list of idents, by means of the method GetList. Optional query parameters for pagination, sorting, etc. can be specified; refer to Query Parameters for more information. A typical use case for the ident service is the retrieval of all idents on (re)start of the application, as is depicted in the following sequence diagram.

Ident service

As is the case with all other services, you need an instantiated and authenticated Client object. A minimal implementation of the above diagram could be:

foreach (var ident in Client.Smart.Idents.GetList(null).List)
{
    // Add ident to cache
}

Transactions

The Transaction data type signifies a transaction and is, simplified, defined as follows:

Ident class diagram

A transaction first needs to be created using the transaction service. The transaction object receives an identifier, which is used for future reference to this transaction. The basket and other sales information can be set, and when the transaction is ready to be updated, the transaction service starts the transaction. It is only necessary to process a transaction when an ident (like a customer card) is added or removed from the list of products in the basket. More information on transaction handling will be added at a later point in time.

When a transaction has successfully been processed, the transaction status is set to OK and includes the receipt information. When a failure arises, or the transaction is canceled, the transaction is provided with a detailed error description. The receipt consists of a list of text lines, where each line has its own decoration hints. Depending on the capabilities of your device, you can translate these hints to receipt markup. Hints include font weight and text alignment and will be described better at a later point in time.

A typical use of the transaction service is the end of a shopping sequence, after payment by the customer. Payment has been verified (either by the cashier in person, or by using our payment services), and the customer is awaiting the receipt. The receipt is then created and processed immediately. Another use case is where the receipt is created as soon as the customer is being served, the transaction is continuously validated throughout processing the basket, after which the transaction can be processed and the receipt generated.

As explained before, it is sufficient to update or process a receipt only when an ident is added or removed from the basket. This is where the ident cache comes in handy, for which an example was given in the previous section. As soon as a product is added or removed, which matches one of the idents in your cache, you know it is time to update your transaction. The use case including continuous updating of the transaction using an ident cache is depicted below:

Transaction service