/** * callbackAction * This method isn't called from the project * but it is called from a bank gateway service * in order to set as payed the order processed * * IMPORTANT: * This method was within the /default/orders controller and it has been moved here * because the access to the /default/orders is denied without an authentication process * /default/common controller is accessible without login process. */ public function callbackAction() { $request = $this->getRequest(); $response = $request->getParams(); if (!empty($response['custom']) && is_numeric(trim($response['custom']))) { // Getting the md5 value in order to match with the class name. $classrequest = $request->gateway; // Orderid back from the bank $order_id = trim($response['custom']); // Get the bank selected using the MD5 code $bank = Banks::findbyMD5($classrequest); if (!empty($bank[0]['classname'])) { if (!empty($bank[0]['classname']) && class_exists($bank[0]['classname'])) { $class = $bank[0]['classname']; $payment = new $class($response['custom']); // Check if the method "Response" exists in the Payment class and send all the bank information to the payment module if (method_exists($class, "Response")) { Shineisp_Commons_Utilities::logs("Callback called: {$class}\nParameters: " . json_encode($response), "payments.log"); $payment->Callback($response); } } } } die; }
/** * Process the response of the banks gateways * * @return void */ public function responseAction() { $request = $this->getRequest(); $response = $request->getParams(); if (!empty($response['custom']) && is_numeric(trim($response['custom']))) { $isp = Shineisp_Registry::get('ISP'); // Orderid back from the bank $order_id = trim($response['custom']); // Getting the md5 value in order to match with the class name. $classrequest = $request->gateway; // Get the bank selected using the MD5 code $bank = Banks::findbyMD5($classrequest); if (!empty($bank[0]['classname'])) { if (!empty($bank[0]['classname']) && class_exists($bank[0]['classname'])) { $class = $bank[0]['classname']; $payment = new $class($order_id); // Check if the method "Response" exists in the Payment class and send all the bank information to the payment module if (method_exists($class, "Response")) { $OrderID = $payment->Response($response); } else { $OrderID = false; } } } // Check if the OrderID is a number because it // means that the order has been executed correctly if (is_numeric($OrderID)) { // Sending an email to the customer and the administrator with the order details. $order = Orders::getAllInfo($OrderID, null, true); Shineisp_Commons_Utilities::sendEmailTemplate($order[0]['Customers']['email'], 'order_confirm', array('fullname' => $order[0]['Customers']['fullname'], 'orderid' => $OrderID, 'order' => $order), null, null, null, null, $order[0]['Customers']['language_id']); // Redirect the user in the The task requested has been executed successfully. page $this->_helper->redirector('list', 'orders', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } } $this->_helper->redirector('list', 'orders', 'default', array('mex' => 'There was a problem during the payment process.', 'status' => 'danger')); }