/** * Validates response from PaynetEasy server. * * Creates the order if the payment was successful * and redirect customer to result page with success message. * * If the payment is made with an error, * displays an error message. */ public function display() { $payment_aggregate = new PaymentAggregate($this->module); $prestashop_cart = new Cart(Tools::getValue('id_cart')); $paynet_response = new CallbackResponse($_REQUEST); try { $this->validatePaymentData($prestashop_cart, $paynet_response); if ($prestashop_cart->orderExists()) { $this->successRedirect(); } $paynet_response = $payment_aggregate->finishSale($prestashop_cart, $paynet_response); } catch (Exception $ex) { $this->logException($ex); $this->createOrderWithErrorPayment($prestashop_cart, $paynet_response, $ex->getMessage()); return $this->displayError('Invalid payment data received.'); } if (!$paynet_response->isApproved()) { $this->createOrderWithErrorPayment($prestashop_cart, $paynet_response); return $this->displayError('Payment not passed'); } $this->createOrderWithSuccessPayment($prestashop_cart, $paynet_response); $this->successRedirect(); }