# TransactionListener

Call the **TransactionListener** API to monitor transaction processes.

## Method Signature

```java
public interface TransactionListener {
    void onTransactionStart();

    void onTransactionComplete(@Nullable APTransactionContext transactionInfo);

    void onTransactionFailed(@NotNull String errorCode, @Nullable TransactionInfo transactionInfo);

    void onTransactionAuth();
}

// Register listener
ACTapManager.getInstance(context).setTransactionListener(new TransactionListener())
```

## Request parameters

| **Item** | **Type** | **Parameters** | **Description** |
| --- | --- | --- | --- |
| onTransactionStart() | Function | / | Called when a transaction starts or when the SDK receives the first APDU command. |
| onTransactionComplete(@Nullable APTransactionContext transactionInfo)) | Function | [APTransactionContext](#BGGAZ) transactionInfo | Called when a transaction completes or when the SDK receives the final command. |
| onTransactionFailed(@NotNull String errorCode, @Nullable TransactionInfo transactionInfo) | Function | String errorCode TransactionInfo transactionInfo | Called when a transaction fails. For more information, see [Result codes](result_codes). |
| onTransactionAuth() | Function | / | Called when a transaction requires authentication. When called, onTransactionFailed is also called with error code 10003. For more information, see [Result codes](result_codes). |

### APTransactionContext

| **Item**                | **Type**        | **Description**                                                                                                                                                                                                                                                                                                                                                                                              |
|-------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| mcc                     | String          | Merchant MCC                                                                                                                                                                                                                                                                                                                                                                                                 |
| currencyCode            | byte\[\]        | Currency                                                                                                                                                                                                                                                                                                                                                                                                     |
| amount                  | byte\[\]        | Transaction amount                                                                                                                                                                                                                                                                                                                                                                                           |
| transactionRange        | String          | The transaction risk level under EMV standards varies by country and region, with different amount thresholds. Valid values are: - LVT-Low Value - HVT-High Value                                                                                                                                                                                                                                            |
| richTransactionType     | String          | Type of transactions. Valid values are: - `PURCHASE`: ordinary transaction - `REFUND`: refund - `CASH`: cash withdrawal - `TRANSIT`: transit transaction - `PURCHASE_WITH_CASHBACK`: purchase with cashback                                                                                                                                                                                                  |
| TransactionInfo         | TransactionInfo | Compatible with older versions, This parameter can be ignored.                                                                                                                                                                                                                                                                                                                                               |
| purpose                 | String          | The purpose of the transaction. Valid values are: - `AUTHORIZE`: The purpose of this transaction is pre-authorization. - `AUTHENTICATE`: This transaction requires an authentication to process. - `UNKNOWN`: Unknown purpose.                                                                                                                                                                               |
| expectedUserActionOnPoi | String          | The expected user action to authorize this transaction at the point of interaction. - `NONE`: Use Dsrp or Qrc to authorize this transaction. - `ONLINE_PIN`: Use online pin to authorize this transaction. - `SIGNATURE`: Use signature to authorize this transaction. - `ONLINE_PIN_OR_SIGNATURE`: Use online pin or signature to authorize this transaction. - `UNKNOWN`: Unexpected results are returned. |
| conditionsOfUse         | String          | Whether this transaction is local or cross-border. Valid values are: - `DOMESTIC`: This transaction is a local transaction. - `INTERNATIONAL`: This transaction is a cross-border transaction. - `UNKNOWN`: The type of this transaction is unknown.                                                                                                                                                         |

## Response parameters

N/A

## Sample

```java
class Demo implements TransactionListener {
    @Override
    public void onTransactionStart() {
        log("received onTransactionStart");
    }

    @Override
    public void onTransactionComplete(@Nullable APTransactionContext transactionInfo) {
        log("received onTransactionComplete");
    }

    @Override
    public void onTransactionFailed(@NonNull String errorCode, @Nullable TransactionInfo transactionInfo) {
        log("received onTransactionFailed： " + errorCode);
    }

    @Override
    public void onTransactionAuth() {
        log("received onTransactionAuth");
        Intent intent = new Intent(this, AuthActivity.class);
        startActivity(intent);
    }
}

```