From 1d41f1f1564807b5d77af454b414ec88276e12da Mon Sep 17 00:00:00 2001 From: KjellBerlin Date: Fri, 30 Aug 2024 16:12:08 +0200 Subject: [PATCH] Response status for mollie webhook and finish slack message --- .../core/payment/MolliePaymentWebhookController.kt | 7 ++++--- .../com/carbonara/core/slack/SlackMessageService.kt | 8 -------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/carbonara/core/payment/MolliePaymentWebhookController.kt b/src/main/kotlin/com/carbonara/core/payment/MolliePaymentWebhookController.kt index d82de5b..e34ab1b 100644 --- a/src/main/kotlin/com/carbonara/core/payment/MolliePaymentWebhookController.kt +++ b/src/main/kotlin/com/carbonara/core/payment/MolliePaymentWebhookController.kt @@ -2,6 +2,7 @@ package com.carbonara.core.payment import com.carbonara.core.order.OrderService import mu.KotlinLogging +import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RestController @@ -11,12 +12,12 @@ class MolliePaymentWebhookController( ) { // Potential dos attack endpoint, introduce rate limiting - // TODO: Add response status - @PostMapping("/mollie-payment-status", "application/x-www-form-urlencoded") - suspend fun handleMollieWebhook(requestBody: MollieWebhookRequestBody) { + @PostMapping("/mollie-payment-status", consumes = ["application/x-www-form-urlencoded"]) + suspend fun handleMollieWebhook(requestBody: MollieWebhookRequestBody): ResponseEntity { log.info("Webhook received for paymentId: {}", requestBody.id) orderService.handleOrderPayment(requestBody.id) + return ResponseEntity.ok().build() } companion object { diff --git a/src/main/kotlin/com/carbonara/core/slack/SlackMessageService.kt b/src/main/kotlin/com/carbonara/core/slack/SlackMessageService.kt index 41114f3..f2db45f 100644 --- a/src/main/kotlin/com/carbonara/core/slack/SlackMessageService.kt +++ b/src/main/kotlin/com/carbonara/core/slack/SlackMessageService.kt @@ -26,14 +26,6 @@ class SlackMessageService { val response = slack.methods(slackToken).chatPostMessage { req -> req .channel(slackChannel) .blocks { - section { - markdownText("*New Order*") - } - /* - header { - plainText("New order") - } - */ section { fields { markdownText("*Customer Name:*\n$customerName")