Code Duplication    Length = 27-27 lines in 2 locations

Controller/ApiController.php 2 locations

@@ 22-48 (lines=27) @@
19
     *
20
     * @return Response
21
     */
22
    public function paymentCaptureAction(Request $request, $id)
23
    {
24
        $data = [
25
            'error' => false,
26
            'captured_amount' => null,
27
            'refunded_amount' => null,
28
        ];
29
30
        $payment = $this->findPaymentByOrderIdOrAltapayId($id);
31
        $paymentHandler = $this->getPaymentHandler();
32
        $res = $paymentHandler->capture($payment, $request->query->get('amount'));
33
34
        if ($res->isSuccessful()) {
35
            $transactions = $res->getTransactions();
36
            if (count($transactions)) {
37
                $data['captured_amount'] = $transactions[0]->getCapturedAmount();
38
                $data['refunded_amount'] = $transactions[0]->getRefundedAmount();
39
            }
40
        } else {
41
            $data['error'] = true;
42
        }
43
44
        $view = $this->view($data);
45
        $view->setTemplate('@LoevgaardDandomainAltapay/api/payment_capture.html.twig');
46
47
        return $this->handleView($view);
48
    }
49
50
    /**
51
     * @Annotations\Post("/api/payment/{id}/refund")
@@ 58-84 (lines=27) @@
55
     *
56
     * @return Response
57
     */
58
    public function paymentRefundAction(Request $request, $id)
59
    {
60
        $data = [
61
            'error' => false,
62
            'captured_amount' => null,
63
            'refunded_amount' => null,
64
        ];
65
66
        $payment = $this->findPaymentByOrderIdOrAltapayId($id);
67
        $paymentHandler = $this->getPaymentHandler();
68
        $res = $paymentHandler->refund($payment);
69
70
        if ($res->isSuccessful()) {
71
            $transactions = $res->getTransactions();
72
            if (count($transactions)) {
73
                $data['captured_amount'] = $transactions[0]->getCapturedAmount();
74
                $data['refunded_amount'] = $transactions[0]->getRefundedAmount();
75
            }
76
        } else {
77
            $data['error'] = true;
78
        }
79
80
        $view = $this->view($data);
81
        $view->setTemplate('@LoevgaardDandomainAltapay/api/payment_capture.html.twig');
82
83
        return $this->handleView($view);
84
    }
85
86
    /**
87
     * @param string|int $id