Transaction History
Introduction
The Transaction History Service provides operations to retrieve customer’s past transactions. It supports flexible filtering, pagination, and reports generation.
Key Features
- Retrieve all transactions associated for a customer.
- Apply filters (date, status, type) and paginate results.
- Generate and download detailed transaction history reports.
Prerequisites
Before integrating the Transaction History Service, ensure you have:
- A valid Paysafe account with appropriate permissions.
- Set up instructions for Paysafe SDK Android or iOS.
To get started, initialize the TransactionHistoryService
instance in your app as shown below:
- Kotlin
- Swift
import com.paysafe.wallet.android.core.wallet.Wallet
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
}
})
Transaction History Report
The Transaction History Report feature allows you to generate and download detailed reports of customer transactions. It supports various formats and can be customized to include specific transaction type, making it easy to analyze and share transaction history.
Steps to generate a transaction history report:
- Request a Transaction History Report: Use the
requestTransactionHistoryReport
method to initiate the generation of a transaction report. - Get Transaction History Report Status: Use the
getTransactionHistoryReportStatus
method to check the status of the report generation. - Get Transaction History Report: Use the
getTransactionHistoryReport
method to download the report once it is ready.
Request Transaction History Report
Use the requestTransactionHistoryReport
method to request transaction report generation.
You can apply filters such as startDate
, endDate
, format
, and transactionType
to customize the report.
- Kotlin
- Swift
The result is a TransactionHistoryReportStatusResponse object, containing report identifier and status.
try {
var reportRequest = TransactionHistoryReportRequest(
format = TransactionHistoryReportFormat.PDF,
accountId = "4632535"
)
val reportStatus = transactionHistory.requestTransactionHistoryReport(reportRequest)
Log.d(TAG, reportStatus.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
The result is a TransactionHistoryReportStatusResponse object, containing report identifier and status.
let reportRequest = TransactionHistoryReportRequest(
format: .pdf,
accountID: "4632535"
)
transactionHistory.requestTransactionHistoryReport(request: reportRequest, completion: { result in
switch result {
case .success(let report):
// Use the reportID to track the report's status or download it
case .failure(let error):
// Handle error
}
})
Get Transaction History Report Status
Use the getTransactionHistoryReportStatus
method to check the status of a previously requested transaction report.
Poll this status periodically until it returns either COMPLETED
or FAILED
.
- Kotlin
- Swift
The result is a TransactionHistoryReportStatusResponse object, containing report identifier, status, format, etc.
try {
val reportId = reportStatus.reportId
val reportStatus = transactionHistory.getTransactionHistoryReportStatus(reportId)
Log.d(TAG, reportStatus.toString())
} catch (exception: Exception) {
Log.d(TAG, reportStatus.toString())
}
The result is a TransactionHistoryReportStatusResponse object, containing report identifier, status, format, etc.
transactionHistory.getTransactionHistoryReportStatus(reportID: reportID, completion: { result in
switch result {
case .success(let reportStatus):
// Handle the reportStatus
case .failure(let error):
// Handle error
}
})
Get Transaction History Report
Use getTransactionHistoryReport
method to download the transaction report once you receive a COMPLETED
status from the previous step.
- Kotlin
- Swift
The result is a TransactionHistoryReport object, containing report file path and type.
try {
val reportId = reportStatus.reportId
val report = transactionHistory.requestTransactionHistoryReport(reportId)
Log.d(TAG, report.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
The result is a TransactionHistoryReport object, containing report file path and type.
transactionHistory.getTransactionHistoryReport(reportID: reportID, completion: { result in
switch result {
case .success(let report):
// Handle the report
case .failure(let error):
// Handle error
}
})
The report is stored as temporary file and can be accessed using the path
property of the TransactionHistoryReport
object.