Catching errors while parsing credit card transactions
This commit is contained in:
parent
16ae00a81d
commit
26cc2088ad
|
@ -690,12 +690,13 @@ open class ResponseParser(
|
||||||
|
|
||||||
return ReceivedCreditCardTransactionsAndBalance(
|
return ReceivedCreditCardTransactionsAndBalance(
|
||||||
balance,
|
balance,
|
||||||
transactionsDataElementGroups.map { mapCreditCardTransaction(it) },
|
transactionsDataElementGroups.mapNotNull { mapCreditCardTransaction(it) },
|
||||||
segment
|
segment
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun mapCreditCardTransaction(transactionDataElementGroup: String): CreditCardTransaction {
|
protected open fun mapCreditCardTransaction(transactionDataElementGroup: String): CreditCardTransaction? {
|
||||||
|
try {
|
||||||
val dataElements = getDataElements(transactionDataElementGroup)
|
val dataElements = getDataElements(transactionDataElementGroup)
|
||||||
|
|
||||||
val bookingDate = parseDate(dataElements[1])
|
val bookingDate = parseDate(dataElements[1])
|
||||||
|
@ -705,6 +706,11 @@ open class ResponseParser(
|
||||||
val isCleared = parseBoolean(dataElements[20])
|
val isCleared = parseBoolean(dataElements[20])
|
||||||
|
|
||||||
return CreditCardTransaction(amount, otherPartyName, bookingDate, valueDate, isCleared)
|
return CreditCardTransaction(amount, otherPartyName, bookingDate, valueDate, isCleared)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
log.error("Could not parse Credit card transaction '$transactionDataElementGroup'", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseCreditCardAmount(amountDataElements: List<String>): Money {
|
private fun parseCreditCardAmount(amountDataElements: List<String>): Money {
|
||||||
|
|
Loading…
Reference in New Issue