From 9b3c8bf2581ff29d047f988a111bef3a7f9dac3d Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Fri, 30 Jan 2026 08:37:57 +0530 Subject: [PATCH] Reset link token on credential changes --- .../controller/PayuPaymentLinkSettingsController.kt | 10 ++++++++++ .../controller/PayuPaymentLinksController.kt | 1 + 2 files changed, 11 insertions(+) diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/PayuPaymentLinkSettingsController.kt b/src/main/kotlin/com/android/trisolarisserver/controller/PayuPaymentLinkSettingsController.kt index 8e931bd..12ea025 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/PayuPaymentLinkSettingsController.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/PayuPaymentLinkSettingsController.kt @@ -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 } diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/PayuPaymentLinksController.kt b/src/main/kotlin/com/android/trisolarisserver/controller/PayuPaymentLinksController.kt index 143531b..4960fb4 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/PayuPaymentLinksController.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/PayuPaymentLinksController.kt @@ -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)