> 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/ja/implement-nfc-wallet/make-payment/get-transaction-history.md).

# 取引履歴を取得する

## 概要

取引履歴を利用すると、あなたの **デジタルウォレットアプリケーション** サポート:

* 取引通知
* 取引履歴の更新

{% hint style="warning" %}
オンボーディング中に、プログラム設定で取引履歴が有効になっていることを確認してください。
{% endhint %}

## SDK 連携

### 取引通知

取引通知をサポートするには、処理する **TNS通知（取引）** で説明されているとおり [プッシュ通知の処理](/nfc-wallet-sdk-android/ja/get-started/configuration/5.-push-notifications/handle-push-notifications.md).

### 取引履歴を取得する

`MGTransactionHistoryService.refreshHistory(...)` NFC Wallet バックエンドから取引記録を取得します。

コーブランデッドカードをサポートする場合は、受け取るオーバーロードを使用します `transactionRecordType` プライマリまたは補助の記録を取得するために。

取引記録には次の情報が含まれます：

* 取引ID
* 取引日
* 取引タイプ
* 取引ステータス
* 通貨コード
* 金額と表示金額
* 加盟店名
* 加盟店種別
* 加盟店郵便番号
* 端末ID
* 加盟店ID
* プライマリカードまたは補助カードの識別子（コーブランデッドカード用）

取引履歴の制限は決済ネットワークによって異なります：

* 時間枠（たとえば、過去30日間の取引）。
* 最大件数（たとえば、最新の10件の取引）。

#### 実装

デジタルカードの取引履歴を取得するには：

1. 対応するものを取得する **デジタルカード ID**.

   参照 [デジタルカードを表示する](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/manage-digital-cards/display-digital-cards.md#tokenized-card-id-versus-digital-card-id).
2. アクセストークンを取得します。

   参照 [アクセストークンを取得する](/nfc-wallet-sdk-android/ja/implement-nfc-wallet/manage-digital-cards/get-an-access-token.md).
3. （任意）次を指定します `transactionRecordType` :

   `プライマリ` または `補助` コーブランデッドで使用し、提供されます [プッシュ通知の処理](/nfc-wallet-sdk-android/ja/get-started/configuration/5.-push-notifications/handle-push-notifications.md).
4. 呼び出します `MGTransactionHistoryService.refreshHistory(...)` および実装します `TransactionHistoryListener`:
   1. `onSuccess`

      SDK が取引の取得に成功したときにトリガーされます。コールバックは次を提供します： `List<MGTransactionRecord>`.

      各 `MGTransactionRecord` 取引記録を表します。
   2. `onError`

      SDK が取引履歴を取得できないときにトリガーされます。次を使用します： `MobileGatewayError` エラーの詳細について。

次のコードスニペットは、取引記録を取得する方法を示しています：

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

```java
// 事前に初期化された値。
String digitalCardId = "...";
String accessToken = "...";

// 取引履歴サービスを取得します。
MobileGatewayManager mgClient = MobileGatewayManager.INSTANCE;
MGTransactionHistoryService transactionHistoryService = mgClient.getTransactionHistoryService();

// 取引履歴を取得します。
transactionHistoryService.refreshHistory(
        accessToken,
        digitalCardId,
        null,
        new TransactionHistoryListener() {

            @Override
            public void onSuccess(
                    List<MGTransactionRecord> records,
                    String digitalCardId,
                    String timeStamp) {
                // 成功。
                // 各 MGTransactionRecord には 1 件の取引の詳細が含まれます。
                // フィールドレベルの詳細については、API リファレンスを参照してください。
            }

            @Override
            public void onError(String digitalCardId, MobileGatewayError 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/ja/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.
