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
:
- Kotlin
- Swift
val transactionHistory = Wallet.getInstance().getTransactionHistoryService()
import PaysafeWallet
let transactionHistory = Wallet.instance.transactionHistoryService
Get Transaction History
- Kotlin
- Swift
Use getTransactionHistory
method to retrieve a list of customer's 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())
}
Use getTransactionHistory
method to retrieve a list of customer's 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 WalletError
will be thrown.
The result is a TransactionList,
containing an array of Transaction objects and a PagingResultMeta
, used for pagination implementation.
let parameters = Wallet.TransactionHistoryParameters(accountID: "1234567890")
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
- Kotlin
- Swift
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
)
let parameters = Wallet.TransactionHistoryParameters(accountID: "1234567890",
limit: 10,
offset: 20, // change the offset for the corresponding page
)
Get Single Transaction
- Kotlin
- Swift
Use getTransaction
method to retrieve a specific customer transaction by ID. The result is a Transaction object,
containing transaction amount, currency code, creation time, etc.
Transactions of type PREPAID_CARD_AUTHORIZATION
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())
}
Use getTransaction
method to retrieve a specific customer transaction by ID. The result is a Transaction object,
containing transaction amount, currency code, creation time, etc.
Transactions of type .prepaidCardAuthorization
should be retrieved from Authorization history service
transactionHistory.getTransaction(transactionID: "1234567890", completion: { result in
switch result {
case .success(let transaction):
// Display transaction details
case .failure(let error):
// Handle error
}
})