public function process() { $this->load->model('checkout/order'); include_once DIR_APPLICATION . '../system/library/Everypay.php'; $everyPay = new Everypay(); if ($this->config->get('everypay_mode') === 'live') { $everyPay->init($this->config->get('everypay_api_username'), $this->config->get('everypay_api_secret')); } else { $everyPay->init($this->config->get('everypay_test_api_username'), $this->config->get('everypay_test_api_secret')); } $response = $this->request->post; unset($response['utf8'], $response['_method'], $response['authenticity_token']); $status = ''; //if opencart has automatically escaped the json, unescape it for HMAC validation. if (isset($response['processing_warnings'])) { $response['processing_warnings'] = html_entity_decode($response['processing_warnings']); } if (isset($response['processing_errors'])) { $response['processing_errors'] = html_entity_decode($response['processing_errors']); } foreach ($response as $key => $value) { $status .= "\n{$key} => {$value}"; } $status = $everyPay->verify($response); switch ($status) { case 1: $this->model_checkout_order->addOrderHistory($this->request->post['order_reference'], $this->config->get('everypay_order_status_id'), '', true); $this->response->redirect($this->url->link('checkout/success')); break; case 2: $this->model_checkout_order->addOrderHistory($this->request->post['order_reference'], 7, '', true); $this->response->redirect($this->url->link('checkout/checkout')); break; case 3: $this->model_checkout_order->addOrderHistory($this->request->post['order_reference'], 10, '', true); $this->response->redirect($this->url->link('checkout/failure')); break; default: $this->response->redirect($this->url->link('checkout/checkout')); } }