Add Razorpay QR list endpoint
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:
@@ -4,6 +4,7 @@ import com.android.trisolarisserver.component.PropertyAccess
|
||||
import com.android.trisolarisserver.controller.dto.RazorpayQrGenerateRequest
|
||||
import com.android.trisolarisserver.controller.dto.RazorpayQrEventResponse
|
||||
import com.android.trisolarisserver.controller.dto.RazorpayQrGenerateResponse
|
||||
import com.android.trisolarisserver.controller.dto.RazorpayQrRecordResponse
|
||||
import com.android.trisolarisserver.models.booking.BookingStatus
|
||||
import com.android.trisolarisserver.models.payment.RazorpayQrRequest
|
||||
import com.android.trisolarisserver.models.property.Role
|
||||
@@ -225,6 +226,33 @@ class RazorpayQrPayments(
|
||||
return out
|
||||
}
|
||||
|
||||
@GetMapping("/qr")
|
||||
fun listQr(
|
||||
@PathVariable propertyId: UUID,
|
||||
@PathVariable bookingId: UUID,
|
||||
@AuthenticationPrincipal principal: MyPrincipal?
|
||||
): List<RazorpayQrRecordResponse> {
|
||||
requireRole(propertyAccess, propertyId, principal, Role.ADMIN, Role.MANAGER, Role.STAFF)
|
||||
val booking = bookingRepo.findById(bookingId).orElseThrow {
|
||||
ResponseStatusException(HttpStatus.NOT_FOUND, "Booking not found")
|
||||
}
|
||||
if (booking.property.id != propertyId) {
|
||||
throw ResponseStatusException(HttpStatus.NOT_FOUND, "Booking not found for property")
|
||||
}
|
||||
return qrRequestRepo.findByBookingIdOrderByCreatedAtDesc(bookingId).map { qr ->
|
||||
RazorpayQrRecordResponse(
|
||||
qrId = qr.qrId,
|
||||
amount = qr.amount,
|
||||
currency = qr.currency,
|
||||
status = qr.status,
|
||||
imageUrl = qr.imageUrl,
|
||||
expiryAt = qr.expiryAt?.toString(),
|
||||
createdAt = qr.createdAt.toString(),
|
||||
responsePayload = qr.responsePayload
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun postJson(url: String, settings: com.android.trisolarisserver.models.payment.RazorpaySettings, json: String): ResponseEntity<String> {
|
||||
val headers = HttpHeaders()
|
||||
headers.contentType = MediaType.APPLICATION_JSON
|
||||
|
||||
@@ -63,3 +63,14 @@ data class RazorpayQrEventResponse(
|
||||
val status: String?,
|
||||
val receivedAt: String
|
||||
)
|
||||
|
||||
data class RazorpayQrRecordResponse(
|
||||
val qrId: String?,
|
||||
val amount: Long,
|
||||
val currency: String,
|
||||
val status: String,
|
||||
val imageUrl: String?,
|
||||
val expiryAt: String?,
|
||||
val createdAt: String,
|
||||
val responsePayload: String?
|
||||
)
|
||||
|
||||
@@ -18,4 +18,6 @@ interface RazorpayQrRequestRepo : JpaRepository<RazorpayQrRequest, UUID> {
|
||||
): RazorpayQrRequest?
|
||||
|
||||
fun findTopByQrIdOrderByCreatedAtDesc(qrId: String): RazorpayQrRequest?
|
||||
|
||||
fun findByBookingIdOrderByCreatedAtDesc(bookingId: UUID): List<RazorpayQrRequest>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user