# Working with payment terminals

Spense supports a range of payment terminals from different providers.

See the API Reference for payment methods in order to take use of including support for terminals in your integration!

There are different workflows for different cases, below are two flow charts for a couple of them.

## Trigger a terminal payment, for a existing payment there is already sent a payment link for


```mermaid
flowchart TD
    A[<strong>GET /payment-methods</strong>] --> B{Are there terminals listed and active?}
    B -- Yes --> C[List terminals to user]
    B -- No --> Z[Show error and stop]
    C --> D[User selects terminal]
    D --> E[<strong>PUT /payment-methods/<em>payflow_id</em></strong><br><br>Include ID of the selected terminal. This<br>will send payment data to the chosen terminal.]
    E --> F{Did user complete payment?}
    F -- Yes --> G[Payment update webhook]
    F -- No --> H[Terminal failure webhook]
    H --> C

    click A "/apis/partner/payment-methods/get_payment_methods" "Go to API docs"
    click E "/apis/partner/payment-methods/send_to_payment_method" "Go to API docs"

    classDef apiCall fill:#e0f7fa,stroke:#00796b,stroke-width:4px;
    class A apiCall
    class E apiCall
```

#### API Reference

GET /payment-methods
To get a list of available payment payments, which may include other methods than just terminals.

## Trigger a terminal payment during creation

This example is slightly different as we include an extra API call - the one that creates the payment, and at the
same time we send the selected payment method to the payment.


```mermaid
flowchart TD
    A[<strong>GET /payment-methods</strong>] --> B{Are there terminals listed and active?}
    B -- Yes --> C[List terminals to user]
    B -- No --> Z[Show error and stop]
    C --> D[User selects terminal]
    D --> E[<strong>POST /api/payments</strong><br><br>Include ID of the selected terminal in <em>paymentMethodId</em>. This<br>will send payment data to the chosen terminal.]
    E --> F{Did user complete payment?}
    F -- Yes --> G[Payment update webhook]
    F -- No --> H[Terminal failure webhook]
    H --> I[User selects terminal]
    I --> J[<strong>PUT /payment-methods/<em>payflow_id</em></strong><br><br>Include ID of the selected terminal. This<br>will send payment data to the chosen terminal.]
    J --> K{Did user complete payment?}
    K -- Yes --> G
    K -- No --> H

    click A "/apis/partner/payment-methods/get_payment_methods" "Go to API docs"
    click E "/apis/payment-management/other/create_payment" "Go to API docs"
    click J "/apis/partner/payment-methods/send_to_payment_method" "Go to API docs"

    classDef apiCall fill:#e0f7fa,stroke:#00796b,stroke-width:4px;
    class A apiCall
    class E apiCall
    class J apiCall
```

#### API Reference

GET /payment-methods
To get a list of available payment payments, which may include other methods than just terminals.

POST /api/payments
Create the payment, and pass on the selected `paymentMethodId` when doing it.