Search Overlay

Transaction History

asdf

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()
import PaysafeWallet

let transactionHistory = Wallet.instance.transactionHistoryService

Get Transaction History

Use getTransactionHistory method to retrieve a list of user transactions by accountId or merchantRefNum. Configure the filtering and pagination by providing a TransactionHistoryParameters object. Either accountId or merchantRefNum must be provided. If both are missing a WalletException/WalletError will be thrown.

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

TransactionHistoryParameters

Parameter Data type Description Example
accountId String Required. Filter transactions by account ID "192837465"
merchantRefNum String Optional. Filter transactions by merchant reference number "546372819"
slipId String Optional. Filter transactions by slip ID "645924334"
limit Int Optional. Limit the number of results 20
offset Int Optional. Specify the starting point for fetching results, indicating the number of items to skip 0
startDate Calendar/Date Optional. Filter transactions created after the specified date and time Calendar.getInstance()/Date()
endDate Calendar/Date Optional. Filter transactions created before the specified date and time Calendar.getInstance()/Date()
val parameters = TransactionHistoryParameters(
    accountId = "1234567890",
    merchantRefNum = null,
    slipId = null,
    limit = null,
    offset = null,
    startDate = null,
    endDate = null
)

try {
    val transactionList = transactionHistory.getTransactionHistory(parameters)
    Log.d(TAG, transactionList.transactions.toString())
} catch (exception: Exception) {
    Log.d(TAG, exception.toString())
}
let parameters = Wallet.TransactionHistoryParameters(accountID: "1234567890",
                                                     merchantRefNum: nil,
                                                     slipId: nil,
                                                     limit: nil,
                                                     offset: nil,
                                                     startDate: nil,
                                                     endDate: nil)
transactionHistory.getTransactionHistory(parameters: parameters, completion: { result in
    switch result {
    case .success(let transactionList):
        // Display transactions in the list - transactionList.transactions
        // Handle pagination
    case .failure(let error):
        // Handle error
    }
})

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
)
let parameters = Wallet.TransactionHistoryParameters(accountID: "1234567890",
                                                     merchantRefNum: nil,
                                                     slipId: nil,
                                                     limit: 10,
                                                     offset: 20, // change the offset for the corresponding page
                                                     startDate: nil,
                                                     endDate: nil)

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.

try {
    val transaction = transactionHistory.getTransaction("1234567890")
    Log.d(TAG, transaction.toString())
} catch (exception: Exception) {
    Log.d(TAG, exception.toString())
}
transactionHistory.getTransaction(transactionID: "1234567890", completion: { result in
    switch result {
    case .success(let transaction):
        // Display transaction details
    case .failure(let error):
        // Handle error
    }
})
On this Page