Skip to content

Commit

Permalink
More webhook related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPowerGamerBR committed Apr 23, 2024
1 parent 77bf894 commit 50c763c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class PostMercadoPagoCallbackRoute(val m: PerfectPayments) : BaseRoute("/api/v1/
val xSignature = call.request.header("x-signature")
val xRequestId = call.request.header("x-request-id")

logger.info { "MercadoPago x-signature header: $xSignature" }
logger.info { "MercadoPago x-request-id header: $xRequestId" }

if (xSignature == null) {
logger.warn { "MercadoPago request is missing the x-signature header!" }
call.respondEmptyJson(HttpStatusCode.Forbidden)
Expand Down Expand Up @@ -124,7 +127,16 @@ class PostMercadoPagoCallbackRoute(val m: PerfectPayments) : BaseRoute("/api/v1/
}

// Generate the manifest string
val manifest = String.format("id:%s;request-id:%s;ts:%s;", dataID, xRequestId, ts)
val manifest = buildString {
// "Caso algum dos valores apresentados no template acima não esteja presente em sua notificação, você deverá removê-los do template."
// https://www.mercadopago.com.br/developers/pt/docs/your-integrations/notifications/webhooks
if (dataID != null) {
append("id:$dataID;")
}

append("request-id:$xRequestId;")
append("ts:$ts;")
}

logger.info { "MercadoPago request manifest: $manifest; TS: $ts; Hash: $hash" }
val mac = Mac.getInstance("HmacSHA256")
Expand Down

0 comments on commit 50c763c

Please sign in to comment.