Skip to content

Commit

Permalink
More logs
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPowerGamerBR committed Apr 23, 2024
1 parent 6d7b6ac commit 1b00e51
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class PostMercadoPagoCallbackRoute(val m: PerfectPayments) : BaseRoute("/api/v1/
call.respondEmptyJson()
}

fun validate(dataID: String?, xSignature: String, xRequestId: String): Boolean {
private fun validate(dataID: String?, xSignature: String, xRequestId: String): Boolean {
// Separating the x-signature into parts
val parts = xSignature.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()

Expand Down Expand Up @@ -131,8 +131,12 @@ class PostMercadoPagoCallbackRoute(val m: PerfectPayments) : BaseRoute("/api/v1/
val signingKey = SecretKeySpec(m.gateway.mercadoPago.webhookSecretSignature.toByteArray(Charsets.UTF_8), "HmacSHA256")
mac.init(signingKey)
val doneFinal = mac.doFinal(manifest.toByteArray(Charsets.UTF_8))
val doneFinalAsHex = doneFinal.bytesToHex()

return hash == doneFinal.bytesToHex()
logger.info { "MercadoPago's request signature hash: $hash" }
logger.info { "Our generated request signature hash: $doneFinalAsHex" }

return hash == doneFinalAsHex
}

/**
Expand Down

0 comments on commit 1b00e51

Please sign in to comment.