# Connect a card machine

Connecting and setting up the Teya card machine requires three steps.
1. Retrieve list of stores for the merchant
2. Retrieve list of card machines for the selected store
3. Configure Teya card machine

## Retrieve list of stores for the merchant

```admonition
icon: fas fa-exclamation-triangle
title: Keep your Teya ID credentials in mind
content: If you are a partner integrating who has already created an application, please use your Teya ID credentials to test the flows below.
```

The ePOS application needs to know which store the merchant is setting up. This requires the [Retrieve List of Stores](/apis/poslink/apis#get--poslink-v1-stores) API call which will list `store_id` for the given Teya account using the provided access token.<br>

A merchant may have multiple stores so the ePOS will need to provide an interface for the merchant to choose which store they are setting up. This way only card machines belonging to that store are listed.

```shell title="Example request"
curl --request GET \
  --url https://api.teya.com/poslink/v1/stores \
  --header 'Authorization: ' \
  --header 'Content-Type: application/json'
```

<br>

```json title="Example response"
{
  "stores": [
    {
      "id": "da728238-ee94-470a-a1ba-a03161fdf98c",
      "name": "Store - 2022-07-15T10:09:10",
      "address": {
        "city": "City",
        "country": "GB",
        "street_address_line_1": "Store address line one",
        "street_address_line_2": "Store address line two",
        "zipcode": "1111 11"
      }
    }
  ]
}
```

## Retrieve list of card machines for the selected store

The ePOS will now need to [Retrieve List of Card Machines](/apis/poslink/apis#get--poslink-v2-stores--store-id--terminals) which will return a list of `terminal_id`/`serial_number` for a given `store_id`. <br>

We suggest that you present the card machine serial numbers as the card machine identifier in the ePOS interface as this is printed on the card machine and can also be found in the card machine settings.

```shell title="Example request"
curl --request GET \
  --url https://api.teya.com/poslink/v2/stores/{store-id}/terminals \
  --header 'Authorization: ' \
  --header 'Content-Type: application/json'
```

<br>

```json title="Example response"
{
  "terminals": [
    {
      "terminal_id": "22164648",
      "terminal_name": "My Terminal 📠",
      "device_model": "PAX_A77",
      "serial_number": "202877303091039717483041"
    }
  ]
}
```

## Configure Teya card machine

The merchant also needs to enable pay at counter mode following these steps:

1. Go to Settings on Card Machine
2. Go to POS integrations
3. Go to External ePOS integrations
4. Enable Cloud communication

>Pay at counter mode limits the functionality of the card machine to only facilitate payments initiated by the ePOS. This also prompts the card machine to remain connected to Teya's web service meaning when a payment request is sent from the ePOS, the card machine automatically actions the request.


### Fallback options for merchant

```tabs
    tab:
      title: If the ePOS is unavailable
      content:
        If a merchant isn't able to send payment requests using their ePOS the merchant can disable **pay at counter mode**. This way the amount can be entered manually on the terminal in **standalone mode**.
        
        **Be Mindful.**
        
        When a payment request or refund is initiated via terminal, the ePOS will not know about these payments. This might lead to reporting inconsistencies.
    tab:
      title: If the terminal doesn't auto action payment request
      content:
        If a terminal does not automatically action a payment request sent by the ePOS, the merchant can disable **pay at counter mode** and manually retrieve the transaction request by using the button that should appear on the top right corner of the homescreen. Note: **ePOS cloud** needs to be enabled in the feature menu for the button to appear.
```
