# MOTO payments

MOTO (Mail Order / Telephone Order) is a way to take a card payment when the cardholder is not present - for example, an order placed over the phone or by mail. The operator keys the card details (number, expiry, and security code) into the terminal instead of the customer tapping or inserting a card.

## How it works

There is no separate MOTO call and no MOTO flag to pass to the SDK. A MOTO payment is created with the same `makePayment` call as any card payment.

The flow:

1. Your app calls `makePayment` exactly as it would for any card payment.
2. The operator selects MOTO / manual entry on the terminal and enters the card details.
3. While the form is open, the payment reports the in-progress state `MotoFormShown`.
4. The payment completes on the standard lifecycle, with MOTO markers in the completion metadata (`entryMode: Keyed`).

## Create the payment

Create the payment with the standard [makePayment](./make-payment.md) call — there is nothing MOTO-specific to pass. The operator chooses to key the card details on the terminal.

## Follow the payment and detect MOTO

Subscribe to the payment state the same way as any payment (see [Make Payment](./make-payment.md)). While the payment is in progress, an `inProgressState` of `MotoFormShown` means the operator is keying in the card details:

```tabs
    tab:
      title: Kotlin (callbacks)
      content:
        ```kotlin
        val listener = object : PaymentStateSubscription.PaymentStateChangeListener {
            override fun onPaymentStateChanged(state: PaymentStateSubscription.PaymentStateDetails) {
                when (state.inProgressState) {
                    PaymentStateSubscription.InProgressState.MotoFormShown -> {
                        // The operator is entering the card details by hand for a MOTO payment.
                    }
                    // ... other in-progress states
                    else -> { /* ... */ }
                }
            }
        }
        paymentSubscription.subscribe(listener)
        ```
    tab:
      title: Kotlin (coroutines)
      content:
        ```kotlin
        paymentHandle.stateUntilCompletion().collect { state ->
            when (state.inProgressState) {
                InProgressState.MotoFormShown -> {
                    // The operator is entering the card details by hand for a MOTO payment.
                }
                // ... other in-progress states
                else -> { /* ... */ }
            }
        }
        ```
    tab:
      title: Java
      content:
        ```java
        PaymentStateSubscription.PaymentStateChangeListener listener = state -> {
            if (state.getInProgressState() == InProgressState.MotoFormShown) {
                // The operator is entering the card details by hand for a MOTO payment.
            }
            // ... handle other in-progress states, keeping a fallback branch
        };
        paymentSubscription.subscribe(listener);
        ```
```

```admonition
icon: fas fa-circle-info
content: On older SDK or payment-app versions, `MotoFormShown` surfaces as `WaitingForCardEntry` instead.
```

## Confirm MOTO on completion

When the payment completes successfully, its `metadata` shows that the card details were keyed in manually. An `entryMode` of `Keyed` is the definitive marker that a completed payment was taken as MOTO / manual entry:

```tabs
    tab:
      title: Kotlin (callbacks)
      content:
        ```kotlin
        val metadata = state.metadata
        val wasMoto = metadata?.entryMode == PaymentStateSubscription.Metadata.EntryMode.Keyed

        if (state.state == PaymentStateSubscription.PaymentState.Successful && wasMoto) {
            val card = metadata?.card // last4, brand, type ...
            // This payment was taken as MOTO / manual entry.
        }
        ```
    tab:
      title: Kotlin (coroutines)
      content:
        ```kotlin
        val metadata = state.metadata
        val wasMoto = metadata?.entryMode == PaymentStateDetails.Metadata.EntryMode.Keyed

        if (state.state == PaymentState.Successful && wasMoto) {
            val card = metadata?.card // last4, brand, type ...
            // This payment was taken as MOTO / manual entry.
        }
        ```
    tab:
      title: Java
      content:
        ```java
        PaymentStateDetails.Metadata metadata = state.getMetadata();
        boolean wasMoto = metadata != null
                && metadata.getEntryMode() == PaymentStateDetails.Metadata.EntryMode.Keyed;

        if (state.getState() == PaymentState.Successful && wasMoto) {
            PaymentStateDetails.Metadata.Card card = metadata.getCard(); // last4, brand, type ...
            // This payment was taken as MOTO / manual entry.
        }
        ```
```

## Availability

MOTO support is delivered by the terminal. Until a terminal supports it, the `MotoFormShown` in-progress state stays dormant. Confirm the minimum terminal app version with Teya before going live.

As with all payment states, your `inProgressState` and `PaymentStateReason` handling should tolerate new or unrecognised values (fall back to your `else` branch), so the integration keeps working as new states are introduced.