Code Duplication    Length = 21-21 lines in 2 locations

Controller/PaymentController.php 2 locations

@@ 202-222 (lines=21) @@
199
     *
200
     * @return RedirectResponse
201
     */
202
    public function captureAction(int $paymentId, Request $request)
203
    {
204
        $payment = $this->getPaymentFromId($paymentId);
205
206
        if ($payment) {
207
            $altapayClient = $this->get('loevgaard_dandomain_altapay.altapay_client');
208
209
            $payload = new CaptureReservationPayload($payment->getAltapayId());
210
            $res = $altapayClient->captureReservation($payload);
211
212
            if ($res->isSuccessful()) {
213
                $this->addFlash('success', 'The payment for order '.$payment->getOrderId().' was captured.'); // @todo fix translation
214
            } else {
215
                $this->addFlash('danger', 'An error occurred during capture of the payment: '.$res->getErrorMessage()); // @todo fix translation
216
            }
217
        }
218
219
        $redirect = $request->headers->get('referer') ? $request->headers->get('referer') : $this->generateUrl('loevgaard_dandomain_altapay_payment_index');
220
221
        return $this->redirect($redirect);
222
    }
223
224
    /**
225
     * @Method({"POST", "GET"})
@@ 233-253 (lines=21) @@
230
     *
231
     * @return RedirectResponse
232
     */
233
    public function refundAction(int $paymentId, Request $request)
234
    {
235
        $payment = $this->getPaymentFromId($paymentId);
236
237
        if ($payment) {
238
            $altapayClient = $this->get('loevgaard_dandomain_altapay.altapay_client');
239
240
            $payload = new RefundCapturedReservationPayload($payment->getAltapayId());
241
            $res = $altapayClient->refundCapturedReservation($payload);
242
243
            if ($res->isSuccessful()) {
244
                $this->addFlash('success', 'The payment for order '.$payment->getOrderId().' was refunded.'); // @todo fix translation
245
            } else {
246
                $this->addFlash('danger', 'An error occurred during refund of the payment: '.$res->getErrorMessage()); // @todo fix translation
247
            }
248
        }
249
250
        $redirect = $request->headers->get('referer') ? : $this->generateUrl('loevgaard_dandomain_altapay_payment_index');
251
252
        return $this->redirect($redirect);
253
    }
254
255
    /**
256
     * @Method("GET")