Notify a Slack channel via webhook 

Besides the emails, EXT:cart can notify other systems about orders, e.g. post a message to a Slack channel when an order is finished or paid. EXT:cart has no configuration for this; register your own event listeners for the events which also send the emails:

\Extcode\Cart\Event\Order\FinishEvent
Dispatched when an order is finished. With a payment provider which redirects to an external payment page, the payment provider extension dispatches it after a successful payment, see Events.
\Extcode\Cart\Event\Order\AfterStatusChangeEvent
Dispatched after the payment or the shipping status of an order was changed, e.g. in the backend module or by a payment provider, see Events.

The examples use a Slack incoming webhook. Other services (Microsoft Teams, Mattermost, Discord, n8n, Zapier, ...) expect a different body, only the payload of the request has to be changed.

Webhook URL 

Create an incoming webhook for your Slack channel, see Sending messages using incoming webhooks. Everyone who knows the URL can post to the channel, so keep it out of the repository, e.g. in an environment variable:

.env
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T000/B000/XXXX
Copied!

Sending the message 

A small service sends the message. It is used by both listeners.

EXT:my_extension/Classes/Notification/SlackNotifier.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Notification;

use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Http\RequestFactory;

final readonly class SlackNotifier
{
    public function __construct(
        private RequestFactory $requestFactory,
        private LoggerInterface $logger,
    ) {
    }

    public function send(string $text): bool
    {
        $webhookUrl = (string)getenv('SLACK_WEBHOOK_URL');
        if ($webhookUrl === '') {
            return false;
        }

        try {
            $this->requestFactory->request($webhookUrl, 'POST', [
                'json' => ['text' => $text],
                // The buyer waits for the response in the checkout.
                'timeout' => 3,
            ]);
        } catch (\Throwable $exception) {
            // A failed notification must never break the order.
            $this->logger->error('Slack notification failed', ['exception' => $exception]);

            return false;
        }

        return true;
    }
}
Copied!

The request is sent synchronously. Keep the timeout short and catch every exception: in the checkout the buyer waits for the response, and an exception would abort the remaining listeners, e.g. the emails.

New orders 

EXT:my_extension/Classes/EventListener/NotifySlackAboutNewOrder.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\EventListener;

use Extcode\Cart\Event\Order\FinishEvent;
use MyVendor\MyExtension\Notification\SlackNotifier;
use TYPO3\CMS\Core\Attribute\AsEventListener;

#[AsEventListener('my-extension--order--finish--notify-slack')]
final readonly class NotifySlackAboutNewOrder
{
    public function __construct(
        private SlackNotifier $slackNotifier,
    ) {
    }

    public function __invoke(FinishEvent $event): void
    {
        $orderItem = $event->getOrderItem();

        $this->slackNotifier->send(sprintf(
            'New order %s: %s %s',
            $orderItem->getOrderNumber(),
            number_format($orderItem->getTotalGross(), 2),
            $orderItem->getCurrencyCode()
        ));
    }
}
Copied!

Things to consider 

Personal data
The messages are stored by Slack. Send only what the channel needs, e.g. the order number, the total and the status, but not the name, the address or the email address of the buyer.
Sending only once
The AfterStatusChangeEvent is dispatched once per change. If you send the messages later or retry them, use the uid of the change ($event->getOrderChange()->uid) to send each message only once.
Asynchronous sending
To keep the checkout independent of the response time of the webhook, dispatch a message to the message bus of TYPO3 in the listener and send the request in its handler. With an asynchronous transport the request is sent by a worker, which can also retry failed requests.