Derive PayU return URLs from property
Some checks failed
build-and-deploy / build-deploy (push) Failing after 30s
Some checks failed
build-and-deploy / build-deploy (push) Failing after 30s
This commit is contained in:
@@ -117,8 +117,8 @@ class PayuQrPayments(
|
||||
add("firstname", firstname)
|
||||
add("email", email)
|
||||
add("phone", phone)
|
||||
add("surl", settings.successUrl)
|
||||
add("furl", settings.failureUrl)
|
||||
add("surl", buildReturnUrl(propertyId, true))
|
||||
add("furl", buildReturnUrl(propertyId, false))
|
||||
add("pg", "DBQR")
|
||||
add("bankcode", "UPIDBQR")
|
||||
add("hash", hash)
|
||||
@@ -191,6 +191,11 @@ class PayuQrPayments(
|
||||
?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "PayU salt missing")
|
||||
}
|
||||
|
||||
private fun buildReturnUrl(propertyId: UUID, success: Boolean): String {
|
||||
val path = if (success) "success" else "failure"
|
||||
return "https://api.hoteltrisolaris.in/properties/$propertyId/payu/return/$path"
|
||||
}
|
||||
|
||||
private fun sha512(input: String): String {
|
||||
val bytes = MessageDigest.getInstance("SHA-512").digest(input.toByteArray())
|
||||
return bytes.joinToString("") { "%02x".format(it) }
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.android.trisolarisserver.controller
|
||||
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.ResponseStatus
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import java.util.UUID
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/properties/{propertyId}/payu/return")
|
||||
class PayuReturnController {
|
||||
|
||||
@GetMapping("/success")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
fun success(@PathVariable propertyId: UUID) {
|
||||
// PayU redirect target; no-op.
|
||||
}
|
||||
|
||||
@GetMapping("/failure")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
fun failure(@PathVariable propertyId: UUID) {
|
||||
// PayU redirect target; no-op.
|
||||
}
|
||||
}
|
||||
@@ -53,10 +53,6 @@ class PayuSettingsController(
|
||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "merchantKey required")
|
||||
}
|
||||
val baseUrl = request.baseUrl?.trim()?.ifBlank { null } ?: "https://secure.payu.in/_payment"
|
||||
val successUrl = request.successUrl?.trim()?.ifBlank { null }
|
||||
?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "successUrl required")
|
||||
val failureUrl = request.failureUrl?.trim()?.ifBlank { null }
|
||||
?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "failureUrl required")
|
||||
val existing = payuSettingsRepo.findByPropertyId(propertyId)
|
||||
val updated = if (existing == null) {
|
||||
PayuSettings(
|
||||
@@ -65,8 +61,6 @@ class PayuSettingsController(
|
||||
salt32 = request.salt32?.trim()?.ifBlank { null },
|
||||
salt256 = request.salt256?.trim()?.ifBlank { null },
|
||||
baseUrl = baseUrl,
|
||||
successUrl = successUrl,
|
||||
failureUrl = failureUrl,
|
||||
useSalt256 = request.useSalt256 ?: true,
|
||||
updatedAt = OffsetDateTime.now()
|
||||
)
|
||||
@@ -75,8 +69,6 @@ class PayuSettingsController(
|
||||
if (request.salt32 != null) existing.salt32 = request.salt32.trim().ifBlank { null }
|
||||
if (request.salt256 != null) existing.salt256 = request.salt256.trim().ifBlank { null }
|
||||
existing.baseUrl = baseUrl
|
||||
existing.successUrl = successUrl
|
||||
existing.failureUrl = failureUrl
|
||||
if (request.useSalt256 != null) existing.useSalt256 = request.useSalt256
|
||||
existing.updatedAt = OffsetDateTime.now()
|
||||
existing
|
||||
@@ -91,8 +83,6 @@ private fun PayuSettings.toResponse(): PayuSettingsResponse {
|
||||
propertyId = propertyId,
|
||||
merchantKey = merchantKey,
|
||||
baseUrl = baseUrl,
|
||||
successUrl = successUrl,
|
||||
failureUrl = failureUrl,
|
||||
useSalt256 = useSalt256,
|
||||
hasSalt32 = !salt32.isNullOrBlank(),
|
||||
hasSalt256 = !salt256.isNullOrBlank()
|
||||
|
||||
@@ -7,8 +7,6 @@ data class PayuSettingsUpsertRequest(
|
||||
val salt32: String? = null,
|
||||
val salt256: String? = null,
|
||||
val baseUrl: String? = null,
|
||||
val successUrl: String? = null,
|
||||
val failureUrl: String? = null,
|
||||
val useSalt256: Boolean? = null
|
||||
)
|
||||
|
||||
@@ -16,8 +14,6 @@ data class PayuSettingsResponse(
|
||||
val propertyId: UUID,
|
||||
val merchantKey: String,
|
||||
val baseUrl: String,
|
||||
val successUrl: String,
|
||||
val failureUrl: String,
|
||||
val useSalt256: Boolean,
|
||||
val hasSalt32: Boolean,
|
||||
val hasSalt256: Boolean
|
||||
|
||||
Reference in New Issue
Block a user