Reset link token on credential changes
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:
@@ -76,10 +76,20 @@ class PayuPaymentLinkSettingsController(
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
existing.merchantId = merchantId
|
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.clientId != null) existing.clientId = request.clientId.trim().ifBlank { null }
|
||||||
if (request.clientSecret != null) existing.clientSecret = request.clientSecret.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 }
|
if (request.accessToken != null) existing.accessToken = request.accessToken.trim().ifBlank { null }
|
||||||
existing.isTest = isTest
|
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.updatedAt = OffsetDateTime.now()
|
||||||
existing
|
existing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class PayuPaymentLinksController(
|
|||||||
contentType = MediaType.APPLICATION_JSON
|
contentType = MediaType.APPLICATION_JSON
|
||||||
set("Authorization", "Bearer $accessToken")
|
set("Authorization", "Bearer $accessToken")
|
||||||
set("merchantId", settings.merchantId)
|
set("merchantId", settings.merchantId)
|
||||||
|
set("mid", settings.merchantId)
|
||||||
}
|
}
|
||||||
val entity = HttpEntity(body, headers)
|
val entity = HttpEntity(body, headers)
|
||||||
val response = restTemplate.postForEntity(resolveBaseUrl(settings.isTest), entity, String::class.java)
|
val response = restTemplate.postForEntity(resolveBaseUrl(settings.isTest), entity, String::class.java)
|
||||||
|
|||||||
Reference in New Issue
Block a user