Add Razorpay QR close by id
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s
This commit is contained in:
@@ -197,6 +197,39 @@ class RazorpayQrPayments(
|
||||
)
|
||||
}
|
||||
|
||||
@PostMapping("/qr/{qrId}/close")
|
||||
@Transactional
|
||||
fun closeQrById(
|
||||
@PathVariable propertyId: UUID,
|
||||
@PathVariable bookingId: UUID,
|
||||
@PathVariable qrId: String,
|
||||
@AuthenticationPrincipal principal: MyPrincipal?
|
||||
): RazorpayQrGenerateResponse? {
|
||||
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")
|
||||
}
|
||||
val record = qrRequestRepo.findTopByQrIdOrderByCreatedAtDesc(qrId)
|
||||
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "QR not found")
|
||||
val settings = settingsRepo.findByPropertyId(propertyId)
|
||||
?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Razorpay settings not configured")
|
||||
val response = postJson(resolveBaseUrl(settings.isTest) + "/payments/qr_codes/$qrId/close", settings, "{}")
|
||||
if (!response.statusCode.is2xxSuccessful) {
|
||||
throw ResponseStatusException(HttpStatus.BAD_GATEWAY, "Razorpay close request failed")
|
||||
}
|
||||
record.status = "closed"
|
||||
qrRequestRepo.save(record)
|
||||
return RazorpayQrGenerateResponse(
|
||||
qrId = record.qrId,
|
||||
amount = record.amount,
|
||||
currency = record.currency,
|
||||
imageUrl = record.imageUrl
|
||||
)
|
||||
}
|
||||
|
||||
@GetMapping("/qr/{qrId}/events")
|
||||
fun qrEvents(
|
||||
@PathVariable propertyId: UUID,
|
||||
|
||||
Reference in New Issue
Block a user