---
title: "Payment"
manual: "Event management and registration"
version: "main"
permalink: "https://docs.typo3.org/permalink/derhansen/sf_event_mgt:developer-payment@main"
source: "ForDevelopers/Payment/Index.rst"
rendered: "2026-09-26T09:24:29+00:00"
---

# Payment {#developer-payment}

The extension supports custom payment methods, which can be added by creating an own extension that adds a new
payment method and implement Event Listeners for the PSR-14 Events for the different payment actions. It is
required, that the payment is processed by an external payment provider (e.g. Paypal payment page).
Please refer to the General workflow image shown below.

It is also required, that each Event Listener uses a Fluid standalone view to render the output that will be
shown in the desired payment action in sf_event_mgt

> [!NOTE]
> Please note, that it is only possible to start the payment process **after** the registration has been
> confirmed by the user.

This section describes how to create your own payment solution for sf_event_mgt which makes use of the provided
payment actions.

I will assume, that the new payment method is called `mypaymentmethod` and the extension key for the new
payment method is `sf_event_mgt_mypaymentmethod`

## General workflow {#general-workflow}

![Payment workflow](../../Images/payment-workflow.png)

Depending on the selected payment method, the user is redirected to the payment providers payment page.

As a reference, please check this demo extension: [https://github.com/derhansen/sf_event_mgt_payment_demo](https://github.com/derhansen/sf_event_mgt_payment_demo)

## 1\. Blank extension {#1-blank-extension}

First of all you need a blank TYPO3 extension with at least an `ext_emconf.php` and an `ext_localconf.php` file.

## 2\. Registration of payment method {#2-registration-of-payment-method}

Add the following content to the file `ext_localconf.php`:

```
// Register payment provider
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sf_event_mgt']['paymentMethods']['mypaymentmethod'] = [
    'class' => 'DERHANSEN\\SfEventMgtMypaymentmethod\\Payment\\Mypaymentmethod',
    'extkey' => 'sf_event_mgt_mypaymentmethod'
];

```

## 3\. Implement Event Listeners {#3-implement-event-listeners}

Depending on the requirements of the payment method, you should implement an Event Listener for available PSR-14 Events.
You should at least implement handling of redirect, success, failure and cancel actions.

The code below shows how to implement your payment method to the redirectAction PSR-14 Event of sf_event_mgt:

```
// Configuration/Services.yaml
services:
  Vendor\Extension\EventListener\YourListener:
    tags:
      - name: event.listener
        identifier: 'yourListener'
        event: DERHANSEN\SfEventMgt\Event\ProcessPaymentInitializeEvent

```

After you registered your event listener, you can add code for your Event Listener to initialize the payment:

```
<?php
namespace Vendor\Extension\EventListener;

use DERHANSEN\SfEventMgt\Event\ModifyDetailViewVariablesEvent;

class YourListener
{
    public function __invoke(ModifyDetailViewVariablesEvent $modifyDetailViewVariablesEvent): void {
       // Implement your code (e.g. add variables)
       $variables = $modifyDetailViewVariablesEvent->getVariables();
       $variables['newVariable'] = 'Just testing';
       $modifyDetailViewVariablesEvent->setVariables($variables);
    }
}

```

The setters in all events allow you to control the behavior of the payment process in the main extension.

## 4\. Add payment class {#4-add-payment-class}

Please refer to the class `AbstractPayment` in sf_event_mgt for possible settings. You payment class
must extend `AbstractPayment` and you should override/set the local `$enable` properties in order
to enable the actions in sf_event_mgt

Please also refer to the `PaymentController` in sf_event_mgt to see all available PSR-14 Events.

In this example I create the class `\DERHANSEN\SfEventMgtMypaymentmethod\EventListener\MyPaymentRedirectResponse`
and as following:

```
class MyPaymentRedirectResponse
{
    #[AsEventListener('sf-event-mgt-mypaymentmethod/payment-redirect-response')]
    public function __invoke(ModifyPaymentRedirectResponseEvent $processPaymentInitializeEvent): void
    {
        if ($processPaymentInitializeEvent->getRegistration()->getPaymentmethod() !== 'mypaymentmethod') {
            return;
        }

        // @todo Initial payment provider and determine redirect URL
        $redirectUrl = 'https://paymentprovider.tld/foo/bar'

        $redirectResponse = new RedirectResponse($redirectUrl, 303);
        $processPaymentInitializeEvent->setResponse($redirectResponse);
    }
}

```

The event listener shows how to use the PSR-14 event `ModifyPaymentRedirectResponseEvent` to
set a redirect response, which is handled by the extensions internal redirect process and redirects
the user to the given redirect URL.

## 5\. Implement methods {#5-implement-methods}

Step 4 already showed how to implement one action. Feel free to implement other required
actions (at least `success`, `failure` and `cancel` to your need.

Each PSR-14 Event enables you to update the given registration. Just set the properties of the
`$registration` object and set `$updateRegistration` to `true`.

It is also possible to remove a registrations, if payment failed or was cancelled. Please
see the corresponding PSr-14 Events for possible options.

## 6\. cHash in generated links {#6-chash-in-generated-links}

All links created in `PaymentController` will automatically have a cHash added by TYPO3.
This should be ok for most scenarios, but sometimes the payment provider will append GET
parameters to links (e.g. successUrl or failureUrl), which then leads to the situation,
that the TYPO3 cHash check fails.

Since all Payment actions are uncached and the registration GET parameter is checked
using a HMAC, the cHash can manually be removed from generated URLs by implementing
the `ProcessPaymentInitializeEvent` PSR-14 event.

## 7\. Security considerations {#7-security-considerations}

Make sure that rendered Fluid views do not contain sensitive data or possibilities
for Cross Site Scripting (XSS) (`values['html']` is rendered with `f:format.raw`).

## Working with currencies {#working-with-currencies}

Since version 9.0 the extension allows to define the ISO 4217 currency code
for the event price. The ISO 4217 currency code is saved to the event record
and can be used when working with payment providers.

The extension provides the following helpers for currencies:

-   `\DERHANSEN\SfEventMgt\Utility\CurrencyUtility` class for currency data
-   `<f:format.currencySymbol>` ViewHelper to get the currency symbol for a currency
