Auto-fetch PayU payment link tokens
All checks were successful
build-and-deploy / build-deploy (push) Successful in 36s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 36s
This commit is contained in:
@@ -41,6 +41,8 @@ class PayuPaymentLinkSettingsController(
|
||||
configured = false,
|
||||
merchantId = null,
|
||||
isTest = false,
|
||||
hasClientId = false,
|
||||
hasClientSecret = false,
|
||||
hasAccessToken = false
|
||||
)
|
||||
}
|
||||
@@ -60,22 +62,23 @@ class PayuPaymentLinkSettingsController(
|
||||
val merchantId = request.merchantId.trim().ifBlank {
|
||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "merchantId required")
|
||||
}
|
||||
val accessToken = request.accessToken.trim().ifBlank {
|
||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "accessToken required")
|
||||
}
|
||||
val isTest = request.isTest ?: false
|
||||
val existing = settingsRepo.findByPropertyId(propertyId)
|
||||
val updated = if (existing == null) {
|
||||
PayuPaymentLinkSettings(
|
||||
property = property,
|
||||
merchantId = merchantId,
|
||||
accessToken = accessToken,
|
||||
clientId = request.clientId?.trim()?.ifBlank { null },
|
||||
clientSecret = request.clientSecret?.trim()?.ifBlank { null },
|
||||
accessToken = request.accessToken?.trim()?.ifBlank { null },
|
||||
isTest = isTest,
|
||||
updatedAt = OffsetDateTime.now()
|
||||
)
|
||||
} else {
|
||||
existing.merchantId = merchantId
|
||||
existing.accessToken = accessToken
|
||||
if (request.clientId != null) existing.clientId = request.clientId.trim().ifBlank { null }
|
||||
if (request.clientSecret != null) existing.clientSecret = request.clientSecret.trim().ifBlank { null }
|
||||
if (request.accessToken != null) existing.accessToken = request.accessToken.trim().ifBlank { null }
|
||||
existing.isTest = isTest
|
||||
existing.updatedAt = OffsetDateTime.now()
|
||||
existing
|
||||
@@ -91,6 +94,8 @@ private fun PayuPaymentLinkSettings.toResponse(): PayuPaymentLinkSettingsRespons
|
||||
configured = true,
|
||||
merchantId = merchantId,
|
||||
isTest = isTest,
|
||||
hasAccessToken = accessToken.isNotBlank()
|
||||
hasClientId = !clientId.isNullOrBlank(),
|
||||
hasClientSecret = !clientSecret.isNullOrBlank(),
|
||||
hasAccessToken = !accessToken.isNullOrBlank()
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user