Code Duplication    Length = 19-19 lines in 2 locations

Controller/PaymentController.php 2 locations

@@ 137-155 (lines=19) @@
134
     *
135
     * @return RedirectResponse
136
     */
137
    public function captureAction(int $paymentId, Request $request)
138
    {
139
        $payment = $this->getPaymentFromId($paymentId);
140
141
        if ($payment) {
142
            $paymentHandler = $this->getPaymentHandler();
143
            $res = $paymentHandler->capture($payment, $request->query->get('amount'));
144
145
            if ($res->isSuccessful()) {
146
                $this->addFlash('success', 'The payment for order '.$payment->getOrderId().' was captured.'); // @todo fix translation
147
            } else {
148
                $this->addFlash('danger', 'An error occurred during capture of the payment: '.$res->getErrorMessage()); // @todo fix translation
149
            }
150
        }
151
152
        $redirect = $request->headers->get('referer') ? $request->headers->get('referer') : $this->generateUrl('loevgaard_dandomain_altapay_payment_index');
153
154
        return $this->redirect($redirect);
155
    }
156
157
    /**
158
     * @Method({"POST", "GET"})
@@ 166-184 (lines=19) @@
163
     *
164
     * @return RedirectResponse
165
     */
166
    public function refundAction(int $paymentId, Request $request)
167
    {
168
        $payment = $this->getPaymentFromId($paymentId);
169
170
        if ($payment) {
171
            $paymentHandler = $this->getPaymentHandler();
172
            $res = $paymentHandler->refund($payment, null, $request->query->get('amount'));
173
174
            if ($res->isSuccessful()) {
175
                $this->addFlash('success', 'The payment for order '.$payment->getOrderId().' was refunded.'); // @todo fix translation
176
            } else {
177
                $this->addFlash('danger', 'An error occurred during refund of the payment: '.$res->getErrorMessage()); // @todo fix translation
178
            }
179
        }
180
181
        $redirect = $request->headers->get('referer') ?: $this->generateUrl('loevgaard_dandomain_altapay_payment_index');
182
183
        return $this->redirect($redirect);
184
    }
185
186
    /**
187
     * @Method("GET")