Authorization History
Introduction
The Authorization history service exposes operations for retrieving customer's prepaid card authorizations:
- Get full customer authorization history
- Get a single authorization by ID
Use the following code to obtain an instance of AuthorizationHistoryService
:
- Kotlin
- Swift
val authorizationHistory = Wallet.getInstance().getAuthorizationHistoryService()
import PaysafeWallet
let authorizationHistory = Wallet.instance.authorizationHistoryService
Get Authorization History
Use getAuthorizationHistory
method to retrieve a list of all user authorizations.
Configure the filtering and pagination by providing an AuthorizationHistoryParameters
object.
The result is an AuthorizationList
object containing a list of Authorization
objects and a PagingResultMeta
object,
used for pagination implementation.
AuthorizationHistoryParameters
Parameter | Data type | Description | Example |
---|---|---|---|
accountId | String | Optional. Filter authorizations by account ID. | "192837465" |
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 authorizations created after the specified date and time. | Calendar.getInstance()/Date() |
endDate | Calendar/Date | Optional. Filter authorizations created before the specified date and time. | Calendar.getInstance()/Date() |
status | AuthorizationStatus | Optional. Filter authorizations by status. | AuthorizationStatus.APPROVED/.approved |
cardId | String | Optional. Filter authorizations by card ID | f16ba382-eb42-481a-b08f-c57bdc9aae24 |
- Kotlin
- Swift
val parameters = AuthorizationHistoryParameters(
accountId = "1234567890",
limit = null,
offset = null, // adjust the offset to the desired starting position
startDate = null,
endDate = null,
status = null,
cardId = null
)
try {
val authorizationList = authorizationHistory.getAuthorizationHistory(parameters)
Log.d(TAG, authorizationList.authorizations.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
let parameters = Wallet.AuthorizationHistoryParameters(limit: nil,
offset: nil, // adjust the offset to the desired starting position
accountID: "1234567890",
cardID: nil,
startDate: nil,
endDate: nil,
status: nil)
authorizationHistory.getAuthorizationHistory(parameters: parameters, completion: { result in
switch result {
case .success(let authorizationList):
// Display authorizations in the list - authorizationList.authorizations
// 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 = AuthorizationHistoryParameters(
accountId = "1234567890",
limit = 10,
offset = 20,
startDate = null,
endDate = null,
status = null,
cardId = null
)
let parameters = Wallet.AuthorizationHistoryParameters(limit: 10,
offset: 20,
accountID: "1234567890",
cardID: nil,
startDate: nil,
endDate: nil,
status: nil)
Get Single Authorization
Use getAuthorization
method to retrieve a specific user authorization by ID. The result is an Authorization
object,
containing amounts,fees, creation time, challenge type and other various authorization details.
- Kotlin
- Swift
try {
val authorization = authorizationHistory.getAuthorization("1234567890")
Log.d(TAG, authorization.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
authorizationHistory.getAuthorization(id: "1234567890", completion: { result in
switch result {
case .success(let authorization):
// Display authorization details
case .failure(let error):
// Handle error
}
})