public function action_pay() { $this->auto_render = FALSE; $id_order = $this->request->param('id'); //retrieve info for the item in DB $order = new Model_Order(); $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find(); if ($order->loaded()) { // Security Checking : The results from Paysbuy should be completed and not corrupted. if (empty($_POST['result']) or empty($_POST['apCode']) or empty($_REQUEST['amt'])) { Alert::set(Alert::INFO, __('Please fill your card details.')); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } //its a fraud...lets let him know if ($order->is_fraud() === TRUE) { Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.')); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } // Value from untrusts identity which Act as Paysbuy Co. Ltd. $payment_status = substr($_POST["result"], 0, 2); $cartnumber = trim(substr($_POST["result"], 2)); $amount = $_POST['amt']; $psbRef = $_POST['apCode']; //correct payment? if ($payment_status == '00' and paysbuy::recheck($cartnumber, $psbRef, $amount)) { //mark as paid $order->confirm_payment('paysbuy', $psbRef); //redirect him to his ads Alert::set(Alert::SUCCESS, __('Thanks for your payment!')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))); } else { // The card has been declined Kohana::$log->add(Log::ERROR, 'Paysbuy The card has been declined'); Alert::set(Alert::ERROR, 'Paysbuy The card has been declined'); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } } else { Alert::set(Alert::INFO, __('Order could not be loaded')); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } }
</li> <?php } ?> <?php if (($two = twocheckout::form($order)) != '') { ?> <li class="text-right"><?php echo $two; ?> </li> <?php } ?> <?php if (($paysbuy = paysbuy::form($order)) != '') { ?> <li class="text-right"><?php echo $paysbuy; ?> </li> <?php } ?> <?php if (($securepay = securepay::button($order)) != '') { ?> <li class="text-right"><?php echo $securepay; ?> </li>