/** * Create the payment module * @param $id */ public function getPaymentsForm($orderid = NULL) { $payments = array(); $banks = Banks::findAllActive("classname", true); $translator = Shineisp_Registry::get('Zend_Translate'); if (!empty($banks)) { foreach ($banks as $bank) { if (!empty($bank['classname']) && class_exists($bank['classname'])) { if (class_exists($bank['classname'])) { $class = $bank['classname']; $payment = new $class($orderid); $payments[] = $payment->setUrlOk($_SERVER['HTTP_HOST'] . "/orders/response/gateway/" . md5($bank['classname']))->setUrlKo($_SERVER['HTTP_HOST'] . "/orders/response/" . md5($bank['classname']))->setUrlCallback($_SERVER['HTTP_HOST'] . "/common/callback/gateway/" . md5($bank['classname']))->setRedirect(false)->setFormHidden(false)->CreateForm(); } } } } $this->view->payments = $payments; // Path of the template return $this->view->render('partials/payments.phtml'); }
/** * Payment gateway page */ public function paymentAction() { $session = new Zend_Session_Namespace('Default'); if (empty($session->cart) || $session->cart->isEmpty()) { $this->_helper->redirector('index', 'index', 'default', array('mex' => "Cart is empty")); } // get the bank payment gateway $gateways = Banks::findAllActive("name, description, classname", true); $form = new Default_Form_PaymentForm(array('action' => '/cart/redirect', 'method' => 'post')); $this->getHelper('layout')->setLayout('1column'); $this->view->gateways = $gateways; $this->view->form = $form; }
public function get($uuid, $order_uuid = null, $service_uuid = null) { $this->authenticate(); $customers = Customers::findWithUuid($uuid); if (empty($customers)) { throw new Shineisp_Api_Exceptions(400006, ":: 'uuid' not valid"); exit; } $id = $customers['customer_id']; if ($order_uuid == null && $service_uuid == null) { throw new Shineisp_Api_Exceptions(400006, ":: 'order_uuid' not valid and 'service_uuid' not valid"); } #TODO get order from $order_uuid if ($service_uuid != null) { $objService = OrdersItems::findByUUID($service_uuid); if ($objService == false) { return false; } $service = $objService->toArray(); $orderid = $service['order_id']; $fields = "o.order_id, \n \t\t o.order_number,\n DATE_FORMAT(o.order_date, '%d/%m/%Y') as Starting, \n DATE_FORMAT(o.expiring_date, '%d/%m/%Y') as Valid_Up, \n in.invoice_id as invoice_id, \n in.number as Invoice, \n CONCAT(d.domain, '.', w.tld) as Domain, \n c.company as company, \n o.status_id, \n s.status as Status, \n o.vat as VAT, \n o.total as Total, \n o.grandtotal as Grandtotal\n so.code as servStatus"; $rs = Orders::getAllInfo($orderid, "*", true, $id); if (empty($rs)) { throw new Shineisp_Api_Exceptions(404001, ":: Orders not found"); } return $rs; $currency = Shineisp_Registry::getInstance()->Zend_Currency; $result = array(); $order = array_shift($rs); // Check the status of the order. // If the order has to be paid we have update it to the last prices and taxes if ($order['status_id'] == Statuses::id('tobepaid', 'orders')) { // Update the total order Orders::updateTotalsOrder($orderid); // Reload the data $rs = Orders::getAllInfo($orderid, $fields, true, $id); $order = array_shift($rs); $order['Total'] = $currency->toCurrency($order['Total'], array('currency' => Settings::findbyParam('currency'))); $order['VAT'] = $currency->toCurrency($order['VAT'], array('currency' => Settings::findbyParam('currency'))); $order['Grandtotal'] = $currency->toCurrency($order['Grandtotal'], array('currency' => Settings::findbyParam('currency'))); $order['price'] = $order['Grandtotal']; $result['tobepaid'] = true; } $result['order'] = $order; $records = OrdersItems::getAllDetails($orderid, "oi.detail_id, oi.description as description, DATE_FORMAT(oi.date_end, '%d/%m/%Y') as expiration_date, oi.quantity as quantity, oi.price as price, bc.name as billingcycle, oi.setupfee as setupfee,p.autosetup as autosetup, s.code as statuscode", true); $allactive = false; for ($i = 0; $i < count($records); $i++) { $records[$i]['itemactiveonorder'] = false; if ($records[$i]['autosetup'] == 1) { $records[$i]['itemactiveonorder'] = true; $allactive = true; } else { $allactive = false; } $records[$i]['price'] = $currency->toCurrency($records[$i]['price'], array('currency' => Settings::findbyParam('currency'))); $records[$i]['setupfee'] = $currency->toCurrency($records[$i]['setupfee'], array('currency' => Settings::findbyParam('currency'))); } $result['activeonorder'] = $allactive; $result['orderitems'] = $records; $result['invoidid'] = $order['status_id'] == Statuses::id("complete", "orders") && $order['Invoice'] > 0 ? true : false; $result['invoidnumber'] = $order['Invoice']; $result['invoidid'] = $order['invoice_id']; $result['payments'] = ""; if ($result['tobepaid'] == true) { $result['payments'] = array(); $banks = Banks::findAllActive("classname", true); if (!empty($banks)) { foreach ($banks as $bank) { if (!empty($bank['classname']) && class_exists($bank['classname'])) { if (class_exists($bank['classname'])) { $class = $bank['classname']; $payment = new $class($id); $payment->setUrlOk($_SERVER['HTTP_HOST'] . "/orders/response/gateway/" . md5($bank['classname'])); $payment->setUrlKo($_SERVER['HTTP_HOST'] . "/orders/response/gateway/" . md5($bank['classname'])); $payment->setUrlCallback($_SERVER['HTTP_HOST'] . "/common/callback/gateway/" . md5($bank['classname'])); $result['payments'][] = $payment->CreateForm(); } } } } } return $result; } }