Code Duplication    Length = 17-30 lines in 2 locations

app/Http/Controllers/CartController.php 1 location

@@ 108-137 (lines=30) @@
105
    /**
106
     * Done.
107
     */
108
    public function done(Request $request)
109
    {
110
111
        //je recupere les informations de retour de Paypal
112
        $id = $request->get('paymentId');
113
//        $token = $request->get('token');
114
        $payer_id = $request->get('PayerID');
115
        $payment = PayPal::getById($id, $this->_apiContext);
116
117
        $paymentExecution = PayPal::PaymentExecution();
118
        //execution du paiment a partir du Payer
119
        //Requete à Paypal: débit du montant de a transaction au Payer
120
        $paymentExecution->setPayerId($payer_id);
121
        $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
122
123
        // Clear the shopping cart,
124
        $request->session()->pull('likes', []);
125
126
        //write log
127
        Log::info('Un client vient de passer uen commande via Paypal'.$payer_id);
128
129
        // Write database
130
131
        // Thank the user for the purchase
132
        return view('Cart/success');
133
    }
134
135
    /**
136
     * Cancel.
137
     */
138
    public function cancel()
139
    {
140
    }

app/Http/Controllers/MainController.php 1 location

@@ 68-84 (lines=17) @@
65
     *
66
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
67
     */
68
    public function done(Request $request)
69
    {
70
        $id = $request->get('paymentId');
71
        $payer_id = $request->get('PayerID');
72
73
        $payment = PayPal::getById($id, $this->_apiContext);
74
75
        $paymentExecution = PayPal::PaymentExecution();
76
77
        $paymentExecution->setPayerId($payer_id);
78
        $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
79
80
        // Clear the shopping cart, write to database, send notifications, etc.
81
        $request->session()->pull('likes', []);
82
83
        return view('Main/index');
84
    }
85
86
    /**
87
     * Page Dashboard.