TRIMS Connector - API

Created by Migration Bot, Modified on Mon, 7 Sep at 2:40 PM by Migration Bot

Originally written by Stuart Francis, last updated 16 March 2022, on the Swan Retail knowledge base (Trims Support › Connectors).


The following API reference guide is available to help integrate 3rd party systems with TRIMS. 

https://www.touchretail.co.uk/trims-api-reference.html

What is an API?

An API is a set of functions and procedures that allow other applications to access the features or data exposed through the hosts API. Using the TRIMS API, 3rd party systems can talk to TRIMS directly and make requests, such as for a list of new products, or products where the stock level has changed. The TRIMS API is primarily used by web developers for integrating TRIMS with their clients' websites, however, amongst the many other integration uses are Warehouse Management Systems (WMS), Analytic Dashboards and Accounting Software.


Best Practises For eCommerce Integration

1 – OLD METHOD

Product Updates

There are 3 ways to get product updates. Use a combination of the 3 to achieve the best results.

  • All products since the last query to the Touchretail API.
    Should be used periodically, say every 5 minutes to update changes to the product details
  • All products from a specified date.
    Should be used overnight, specifying a date of 1 or 2 days prior, to ensure no product updates have been missed (eg system failure or internet issues)
  • All products.
    Should be used for initial data load and in cases of long term system failures to ensure all products are in line. This process can take some time to return the data dependant on the size of the Customers data, so should only be used occasionally when required

Your Integration should take into account that Attributes can be added and edited by the customer and would appear as additional or changed Categories, Variants or Tags, dependent on how the TRIMS user has configured them. It may be that these new attributes will need to be mapped to new fields on the website, so a mapping table is always a preferred method of handling this. It is advised to use the 'code' JSON field reference when mapping these as the 'code' remains the same over the lifetime of the attribute, whereas the name may change.

Stock Updates

There are 3 ways to get Stock updates

  • All stock since the last query to the Touchretail API.
    Should be used periodically say every 30 seconds to ensure any sales on the epos system adjust the stock on the website
  • All stock from a specified date.
    Should be used overnight specifying a date of 1 or 2 days prior to ensure no stock updates have been missed
  • All stock.
    Should be used for the initial data load but can also be used every night if required (instead as the from date option). The process of returning all stock is fairly quick.

2 - NEW METHOD

The latest and preferred way to obtain product updates from TRIMS is to use the ‘Connector In Progress’ methods.

TRIMS supports multiple connectors, each having its own set of credentials and configuration. Once a ‘Connector’ is set up in TRIMS, method calls can be made to the connector to retrieve a list of products that need to be updated by the 3rd party. Each connector has a queue which keeps track of changes with the TRIMS system that meet the criteria set in the connector’s configuration. The queue returns results in batches, and once dealt with by the 3rd party, the 3rd party posts back to state which of the updates have been handled, which will then be removed from the connector queue. This form of communication minimises service activity, displays visibility of progress within TRIMS and provides a robust check-list integration to avoid gaps in data updates.

  • Get Products In Progress.
    The method returns the top x products from a queue containing products that have changed based on the criteria set on the connector being called.
  • Send Product In Progress Updates.
    The method is used to tell TRIMS which entries within the queue have been addressed. Once the connector has been notified, the items are removed from the queue.

3 – Sales

To ensure sales amend the stock as quickly as possible on the epos this method should be called every time a Sale is completed on the web site. The web developer can do it one of 2 ways:

  • Real-time (Recommended)
    Send all orders as soon as they are placed and if the order is subsequently cancelled send a return for that order or items on the order.The advantages of this are that the stock is deducted quickly from the inventory and therefore less likelihood of it being sold twice. The disadvantages are that if there are a lot of orders being placed which subsequently are cancelled, stock is being reserved and therefore not available for Sale.Often a side effect of fraudulent orders, it is advised that the web developer puts procedures in place to handle this aforementioned scenario. One way to achieve this is to cap the maximum basket quantity of any single item to a realistic value, this way a single fraudulent order couldn’t reserve all stock.
  • Intervention (Not recommended)
    Only send orders once they are verified and accepted as an order.The advantages of this method is that stock is not reserved for Fraudulent orders, the disadvantage is that if the process of confirming an order requires user intervention, the stock is available to sell until the order is confirmed which could be an issue if there is a delay in processing the orders.

*Order numbers must be unique, duplicates will be ignored. If you are refunding an order you should generate a new unique order number.

4 – Sales processing by the Web developer on the WEB site

From experience of things which may go wrong, we strongly recommend that there is an Interim file on the web site which all orders get placed into and then a cron job which runs say every 30 seconds and sends all orders which have not be sent previously. The reason for doing this is 2 fold, the API responds with a success flag which, when set to false means the order has failed and therefore the cron job should re-send that order next time, it also returns a reason description which can be stored in the file and can be used for debug purposes if the order fails to complete after numerous retries.

The Touchretail API should be available 24/7 however in practice this cannot be relied on due to all sorts of circumstances, Internet failures, Touchretail Servers downtime for patching etc, so by adhering to the above processes the system should be resilient enough to cope with these outages.


CRM Integration

This section explains the processes required to integrate TRIMS CRM with your website. The following integration will link Web and Store Customers resulting in:

  • A central customer database within TRIMS recording purchases both online, and offline.
  • Ability to redeem accumulated loyalty points both online, and offline.
  • Ability to redeem Gift Cards both online, and offline.

All websales

When using the sendsales method to send sales to Touchretail, please now always populate the ‘externalaccount’ field.

Redeeming Gift Cards online

Use CRMGetGiftCardValues to query the Balance of the Gift Card.

On completion of a websale, when posting the transaction details using Sendsales, a tender entry must be populated stating a tendername, amount and Gift Card number.

Redeeming Loyalty Points online

Use CRMGetAccountValues to query the available Loyalty Points and parameters of the customer account.

Use CRMRedeemLoyalty to add or remove points.

Linking online/store customers

All websales (providing the ExternalAccount field is populated) will automatically be linked to a store account if one already exists.

In cases where the customer already has a store account and wants to link their website account they should be able to login to their website account and click a link to ‘link with store account’ this will use CRMRegisterAccount to link the account.

New customers created online should always use CRMRegisterAccount which will create/link the customer as soon as the online account is created.


Gift Card Integration

The following section is available to help assist with integration of the Touchretail Gift Card system.

For each gift card issued in store at a POS the customer has a card number and an online code.

Query a Gift Card

A service is available which you contact to check the available funds on the gift card. This also provides information of how the balance is made up and when elements of the balance expire.

For example you may query a card using the online code and the current balance is £25. This could be an original 50 gift card that the customer has spent 40 pound on and then added 15 to the card.

  • This will appear as balance £25.
  • Then three transaction details one for the original £50 of which £10 is remaining purchased on 11/05/2016 and expires on 11/05/2017
  • One for the £40 sale
  • One for the 15 top up which will say original £15 remaining £15 purchased on 01/08/2016 expires 01/08/2017.
  • This means today the balance is £25 on the 12/05 the balance will be £15 as the remaining £10 of the original top-up will have expired.

Redeeming a Gift Card

In terms of redeeming this value then it just gets returned as a tender with the externalaccount populated with the gift card/online code and value being redeemed.

Purchasing a Gift Card

If a customer wishes to purchase a gift card online, this will need to be sold as a product online. When the sale of the gift card is received the store will need to refund this product at the point of the sale and add a new GCAS Activation for the value. Once they tender on exchange, this will produce an online code, this alongside the physical card can be posted out to the customer.

Usage

For Gift cards there is one process CRMGetGiftCardValues which is called with the gift card number / online code, and some connector details (service, username and password) which are supplied from our side.

This process needs to be called when the customer wishes to pay using the gift card, this endpoint will return the balance and how this balance is made up.

As long as funds are available the customer should be allowed to spend all or a portion of the available funds.

The customer then completes the transaction if a value is left to pay and upon successful completion the sale is sent over to ourselves to remove the funds from the gift card.

This is achieved by including tender information within the Send Sales method and as one of the tenders including the external account as the gift card number and the value as the value being removed

Attachments (1)

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article