# Abort Transaction (/global/en/docs/Terminal/CodeDevelopment/Abort-Transaction)

## Abort transaction

### Transaction Flow

![](https://docs.newlandnpt.us/assets/_shared/249e8da78718/abort-process.svg)

### Transaction Abort Mechanism

**API reference**
[AbortParam Object](doc-id:0963eff1#abort-request)

**Applicable Scenarios**

The transaction abort mechanism allows the EPOS application to actively terminate an ongoing transaction in certain situations, such as:

- The customer does not complete the payment operation for an extended period.

- The EPOS application needs to cancel the current transaction.

- An abnormal condition is detected during the transaction process.

- A previous Display is still shown and the next operation presents its own terminal UI, such as a financial operation or NFC Tag (see [Device Display & Interaction](doc-id:afad6b34)).

In these cases, the EPOS can send an Abort request.

```java
AbortParam abortParam = AbortParam.newBuilder()
        .orgExchangeIdentification(lastExchangeId)
        .build();

// Send abort request to cancel the specified exchange
RetailerManager.provideSystemService()
        .newAbortExchange(abortParam)
        .startAsyncExchange(new Exchange.RetailerSDKCallback<AbortResult>() {

    @Override
    public void onError(int errCode, String errMsg) {
        // Called when the abort request fails
    }

    @Override
    public void onResult(AbortResult abortResult) {
        // Handle abort result.
    }
});                  
```

### Determining the Abort Result

**API reference**
[AbortResult Object](doc-id:0963eff1#abort-response)

After the abort request is sent, the terminal will return a response indicating whether the abort was successful.

**Successful Abort**

The terminal receives the abort instruction and successfully stops the current transaction process.
A clear abort success response is returned to the EPOS.

**Invalid Abort**

If the transaction has already entered a non-interruptible financial processing stage, the terminal may return an “Abort Invalid” error code.

### Common Scenarios Where Abort May Fail

Abort requests may fail in the following situations:

The transaction request has already been sent to the acquirer channel, and the acquiring application is waiting for the channel response.

The payment terminal is currently executing a critical transaction operation, and the transaction cannot be interrupted at that stage.