@@ -101,44 +101,29 @@ to enable the actions in sf_event_mgt
101101
102102Please also refer to the :php: `PaymentController ` in sf_event_mgt to see all available PSR-14 Events.
103103
104- In this example I create the class :php: `DERHANSEN\S fEventMgtMypaymentmethod\P ayment\M ypaymentmethod ` and add
105- the following method.::
106-
107- /**
108- * Adds required HTML (for redirection) to the given values-array
109- *
110- * @param array $values
111- * @param bool $updateRegistration
112- * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration
113- * @param ActionController $pObj
114- * @return void
115- */
116- public function renderRedirectView(&$values, &$updateRegistration, $registration, $pObj)
104+ In this example I create the class :php: `DERHANSEN\S fEventMgtMypaymentmethod\E ventListener\M yPaymentRedirectResponse `
105+ and as following::
106+
107+ class MyPaymentRedirectResponse
117108 {
118- $pluginSettings = $this->getPluginSettings();
119-
120- $view = GeneralUtility::makeInstance(StandaloneView::class);
121- $view->setFormat('html');
122- $view->setLayoutRootPaths($pluginSettings['view']['layoutRootPaths']);
123- $view->setPartialRootPaths($pluginSettings['view']['partialRootPaths']);
124- $view->setTemplateRootPaths($pluginSettings['view']['templateRootPaths']);
125-
126- // @todo - e.g. call payment providers API to initialize payment
127- //
128- // Make sure to multiply the price with the given amount of depending registrations
129- //
130- // Depending on the payment provider you may receive a redirection URL or a token
131- // which can be passed to the standalone view.
132-
133- $view->assignMultiple([
134- 'settings' => $pluginSettings['settings'],
135- ]);
136- $values['html'] = $view->render();
109+ #[AsEventListener('sf-event-mgt-mypaymentmethod/payment-redirect-response')]
110+ public function __invoke(ModifyPaymentRedirectResponseEvent $processPaymentInitializeEvent): void
111+ {
112+ if ($processPaymentInitializeEvent->getRegistration()->getPaymentmethod() !== 'mypaymentmethod') {
113+ return;
114+ }
115+
116+ // @todo Initial payment provider and determine redirect URL
117+ $redirectUrl = 'https://paymentprovider.tld/foo/bar'
118+
119+ $redirectResponse = new RedirectResponse($redirectUrl, 303);
120+ $processPaymentInitializeEvent->setResponse($redirectResponse);
121+ }
137122 }
138123
139- Replace the @todo section with your own code. The returned view should include some text
140- and at least the link for the redirection. In order process automatic redirection, the
141- view could include a JavaScript redirect to the payment providers payment page .
124+ The event listener shows how to use the PSR-14 event :php: ` ModifyPaymentRedirectResponseEvent ` to
125+ set a redirect response, which is handled by the extensions internal redirect process and redirects
126+ the user to the given redirect URL .
142127
1431285. Implement methods
144129--------------------
@@ -165,10 +150,10 @@ using a HMAC, the cHash can manually be removed from generated URLs by implement
165150the :php: `ProcessPaymentInitializeEvent ` PSR-14 event.
166151
167152
168- 7. Security conciderations
153+ 7. Security considerations
169154--------------------------
170155
171- Make sure that your rendered Fluid standlone views do not contain sensitive data or possibilities
156+ Make sure that rendered Fluid views do not contain sensitive data or possibilities
172157for Cross Site Scripting (XSS) (:php: `values['html'] ` is rendered with :php: `f:format.raw `).
173158
174159
0 commit comments