Skip to main content

Transaction History

Introduction

The Transaction history service exposes operations for retrieving customer's transactions:

  • Get full customer transaction history
  • Get a single transaction by ID

Use the following code to obtain an instance of TransactionHistoryService:

val transactionHistory = Wallet.getInstance().getTransactionHistoryService()

Get Transaction History

Use getTransactionHistory method to retrieve a list of user transactions for an account or specific merchantRefNum ordered by creationTime descending. Configure the filtering and pagination by providing a TransactionHistoryParameters object. Either accountId or merchantRefNum must be provided. If both are missing a WalletException will be thrown.

The result is a TransactionList, containing a list of Transaction objects and a PagingResultMeta, used for pagination implementation.

val parameters = TransactionHistoryParameters(
accountId = "1234567890",
merchantRefNum = null,
slipId = null,
limit = null,
offset = null,
startDate = null,
endDate = null,
status = null,
type = null,
cardId = null
)

try {
val transactionList = transactionHistory.getTransactionHistory(parameters)
Log.d(TAG, transactionList.transactions.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

You can achieve pagination by combining the limit and offset filters. For instance, implementing pagination with a page size of 10 results per page would involve configuring:

  • Page 1: limit=10, offset=0
  • Page 2: limit=10, offset=10
  • Page 3: limit=10, offset=20
val parameters = TransactionHistoryParameters(
accountId = "1234567890",
merchantRefNum = null,
slipId = null,
limit = 10,
offset = 20, // change the offset for the corresponding page
startDate = null,
endDate = null,
status = null,
type = null,
cardId = null
)

Get Single Transaction

Use getTransaction method to retrieve a specific user transaction by ID. The result is a Transaction object, containing transaction amount, currency code, creation time, etc.

note

Transactions of type PREPAID_CARD_AUTHORIZATION`.prepaidCardAuthorization` should be retrieved from Authorization history service

try {
val transaction = transactionHistory.getTransaction("1234567890")
Log.d(TAG, transaction.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}