Hide closed Razorpay requests from list
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s
This commit is contained in:
@@ -54,7 +54,9 @@ class RazorpayPaymentRequestsController(
|
||||
throw ResponseStatusException(HttpStatus.NOT_FOUND, "Booking not found for property")
|
||||
}
|
||||
|
||||
val qrItems = qrRequestRepo.findByBookingIdOrderByCreatedAtDesc(bookingId).map { qr ->
|
||||
val qrItems = qrRequestRepo.findByBookingIdOrderByCreatedAtDesc(bookingId)
|
||||
.filter { !isQrClosed(it.status) }
|
||||
.map { qr ->
|
||||
RazorpayPaymentRequestResponse(
|
||||
type = "QR",
|
||||
requestId = qr.id!!,
|
||||
@@ -68,7 +70,9 @@ class RazorpayPaymentRequestsController(
|
||||
)
|
||||
}
|
||||
|
||||
val linkItems = paymentLinkRequestRepo.findByBookingIdOrderByCreatedAtDesc(bookingId).map { link ->
|
||||
val linkItems = paymentLinkRequestRepo.findByBookingIdOrderByCreatedAtDesc(bookingId)
|
||||
.filter { !isLinkClosed(it.status) }
|
||||
.map { link ->
|
||||
RazorpayPaymentRequestResponse(
|
||||
type = "PAYMENT_LINK",
|
||||
requestId = link.id!!,
|
||||
@@ -173,4 +177,18 @@ class RazorpayPaymentRequestsController(
|
||||
val encoded = Base64.getEncoder().encodeToString(raw.toByteArray())
|
||||
return "Basic $encoded"
|
||||
}
|
||||
|
||||
private fun isQrClosed(status: String?): Boolean {
|
||||
return when (status?.lowercase()) {
|
||||
"closed", "expired", "credited" -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun isLinkClosed(status: String?): Boolean {
|
||||
return when (status?.lowercase()) {
|
||||
"cancelled", "canceled", "paid", "expired" -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user