Reset link token on credential changes
All checks were successful
build-and-deploy / build-deploy (push) Successful in 36s

This commit is contained in:
androidlover5842
2026-01-30 08:37:57 +05:30
parent 0d831eaed7
commit 9b3c8bf258
2 changed files with 11 additions and 0 deletions

View File

@@ -76,10 +76,20 @@ class PayuPaymentLinkSettingsController(
)
} else {
existing.merchantId = merchantId
val oldClientId = existing.clientId
val oldClientSecret = existing.clientSecret
val oldIsTest = existing.isTest
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
val credsChanged = (request.clientId != null && existing.clientId != oldClientId) ||
(request.clientSecret != null && existing.clientSecret != oldClientSecret) ||
oldIsTest != isTest
if (credsChanged) {
existing.accessToken = null
existing.tokenExpiresAt = null
}
existing.updatedAt = OffsetDateTime.now()
existing
}

View File

@@ -125,6 +125,7 @@ class PayuPaymentLinksController(
contentType = MediaType.APPLICATION_JSON
set("Authorization", "Bearer $accessToken")
set("merchantId", settings.merchantId)
set("mid", settings.merchantId)
}
val entity = HttpEntity(body, headers)
val response = restTemplate.postForEntity(resolveBaseUrl(settings.isTest), entity, String::class.java)