> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/nfc-wallet-sdk-android/implement-nfc-wallet/make-payment/get-transaction-history.md).

# Get transaction history

## Overview

Transaction history lets your **digital wallet application** support:

* Transaction notifications
* Refreshing transaction history

{% hint style="warning" %}
During onboarding, confirm that transaction history is enabled in your program configuration.
{% endhint %}

## SDK integration

### Transaction notifications

To support transaction notifications, process **TNS notifications (transactions)** as described in [Handle push notifications](/nfc-wallet-sdk-android/get-started/configuration/5.-push-notifications/handle-push-notifications.md).

### Retrieve transaction history

`MGTransactionHistoryService.refreshHistory(...)` retrieves transaction records from the NFC Wallet backend.

If you support co-badged cards, use the overload that accepts `transactionRecordType` to retrieve primary or auxiliary records.

The transaction record contains the following information:

* Transaction ID
* Transaction date
* Transaction type
* Transaction status
* Currency code
* Amount and display amount
* Merchant name
* Merchant type
* Merchant postal code
* Terminal ID
* Merchant ID
* Primary or auxiliary card indicator (for co-badged cards)

Transaction history limits depend on the payment network:

* Time window (for example, transactions from the last 30 days).
* Maximum count (for example, the last 10 transactions).

#### Implementation

To retrieve transaction history for a digital card:

1. Get the corresponding **digital card ID**.

   See [Display digital cards](/nfc-wallet-sdk-android/implement-nfc-wallet/manage-digital-cards/display-digital-cards.md#tokenized-card-id-versus-digital-card-id).
2. Get an access token.

   See [Get an access token](/nfc-wallet-sdk-android/implement-nfc-wallet/manage-digital-cards/get-an-access-token.md).
3. (Optional) Provide the `transactionRecordType` :

   `PRIMARY` or `AUXILIARY` use in co-badged and provided on [Handle push notifications](/nfc-wallet-sdk-android/get-started/configuration/5.-push-notifications/handle-push-notifications.md).
4. Call `MGTransactionHistoryService.refreshHistory(...)` and implement `TransactionHistoryListener`:
   1. `onSuccess`

      Triggered when the SDK successfully retrieves transactions. The callback provides a `List<MGTransactionRecord>`.

      Each `MGTransactionRecord` represents a transaction record.
   2. `onError`

      Triggered when the SDK cannot retrieve transaction history. Use `MobileGatewayError` for error details.

The following code snippet demonstrates how to retrieve the transaction records:

{% code title="GetTransactionHistory.java" %}

```java
// Values previously initialized.
String digitalCardId = "...";
String accessToken = "...";

// Get the transaction history service.
MobileGatewayManager mgClient = MobileGatewayManager.INSTANCE;
MGTransactionHistoryService transactionHistoryService = mgClient.getTransactionHistoryService();

// Fetch the transaction history.
transactionHistoryService.refreshHistory(
        accessToken,
        digitalCardId,
        null,
        new TransactionHistoryListener() {

            @Override
            public void onSuccess(
                    List<MGTransactionRecord> records,
                    String digitalCardId,
                    String timeStamp) {
                // Success.
                // Each MGTransactionRecord holds details for one transaction.
                // See the API reference for field-level details.
            }

            @Override
            public void onError(String digitalCardId, MobileGatewayError error) {
                // Handle the error.
            }
        }
);
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-android/implement-nfc-wallet/make-payment/get-transaction-history.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
