示例#1
0
 function viewinvoiceAction()
 {
     $orderId = $this->_request->getParam('orderId');
     $tblOrder = new Kutu_Core_Orm_Table_Order();
     $items = $tblOrder->getOrderDetail($orderId);
     $this->view->orderId = $orderId;
     $this->view->invoiceNumber = $items[0]['invoiceNumber'];
     $this->view->datePurchased = Kutu_Lib_Formater::get_date($items[0]['datePurchased']);
     $tblPaymentSetting = new Kutu_Core_Orm_Table_PaymentSetting();
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     if ($this->_user->kopel != $items[0]['userId']) {
         $this->_redirect(KUTU_ROOT_URL . '/store/cartempty');
     }
     $result = array();
     $result['subTotal'] = 0;
     for ($iCart = 0; $iCart < count($items); $iCart++) {
         $itemId = $items[$iCart]['itemId'];
         $qty = 1;
         $itemPrice = $items[$iCart]['price'];
         $result['items'][$iCart]['itemId'] = $itemId;
         $result['items'][$iCart]['item_name'] = $items[$iCart]['documentName'];
         $result['items'][$iCart]['itemPrice'] = $itemPrice;
         $result['items'][$iCart]['qty'] = $qty;
         $result['subTotal'] += $itemPrice * $qty;
     }
     $result['taxAmount'] = $result['subTotal'] * $rowTaxRate->settingValue / 100;
     $result['grandTotal'] = $result['subTotal'] + $result['taxAmount'];
     $this->view->cart = $result;
     $data = array();
     $data['taxNumber'] = $items[0]['taxNumber'];
     $data['taxCompany'] = $items[0]['taxCompany'];
     $data['taxAddress'] = $items[0]['taxAddress'];
     $data['taxCity'] = $items[0]['taxCity'];
     $data['taxZip'] = $items[0]['taxZip'];
     $data['taxProvince'] = $items[0]['taxProvince'];
     $data['taxCountry'] = $items[0]['taxCountryId'];
     $data['paymentMethod'] = $items[0]['paymentMethod'];
     $data['currencyValue'] = $items[0]['currencyValue'];
     $this->view->data = $data;
 }
示例#2
0
 function processAction()
 {
     $formater = new Kutu_Core_Hol_User();
     $orderId = $this->_request->getParam('orderId');
     $packageId = $this->_request->getParam('packageId');
     $paymentSubscription = $this->_request->getParam('paymentSubscription');
     $this->_orderIdNumber = $orderId;
     if (empty($orderId)) {
         echo "kosong";
         die;
     }
     include_once KUTU_ROOT_DIR . '/application/models/Store.php';
     $modelAppStore = new App_Model_Store();
     if ($modelAppStore->isOrderPaid($orderId)) {
         //forward to error page
         $this->_helper->redirector->gotoSimple('error', 'store', 'hol-site', array('view' => 'orderalreadypaid'));
         die;
     }
     $tblOrder = new Kutu_Core_Orm_Table_Order();
     $items = $tblOrder->getOrderDetail($orderId);
     $tmpMethod = $this->_request->getParam('method');
     if (!empty($tmpMethod)) {
         $items[0]['paymentMethod'] = $tmpMethod;
     }
     $tblUser = new Kutu_Core_Orm_Table_User();
     $rowUser = $tblUser->find($items[0]['userId'])->current();
     $total = $formater->checkPromoValidation('Total', $packageId, $rowUser->promotionId, $paymentSubscription);
     switch ($items[0]['paymentMethod']) {
         case 'nsiapay':
             require_once 'PaymentGateway/Nsiapay.php';
             // include the class file
             $paymentObject = new Nsiapay();
             // initiate an instance of the class
             if ($this->_testMode) {
                 $paymentObject->enableTestMode();
             }
             $paymentObject->addField('TYPE', "IMMEDIATE");
             $subTotal = 0;
             for ($iCart = 0; $iCart < count($items); $iCart++) {
                 $i = $iCart + 1;
                 $basket[] = $items[$iCart]['documentName'] . "," . $items[$iCart]['price'] . ".00" . "," . $items[$iCart]['qty'] . "," . $items[$iCart]['finalPrice'] . ".00";
                 $subTotal += $items[$iCart]['price'] * $items[$iCart]['qty'];
             }
             $ca = implode(";", $basket);
             $merchantId = "000100090000028";
             $paymentObject->addField("BASKET", $ca);
             $paymentObject->addField("MERCHANTID", $merchantId);
             $paymentObject->addField("CHAINNUM", "NA");
             $paymentObject->addField("TRANSIDMERCHANT", $items[0]['invoiceNumber']);
             $paymentObject->addField("AMOUNT", $subTotal);
             $paymentObject->addField("CURRENCY", "360");
             $paymentObject->addField("PurchaseCurrency", "360");
             $paymentObject->addField("acquirerBIN", "360");
             $paymentObject->addField("password", "123456");
             $paymentObject->addField("URL", "http://hukumonline.pl");
             $paymentObject->addField("MALLID", "199");
             $paymentObject->addField("SESSIONID", Zend_Session::getId());
             $sha1 = sha1($subTotal . ".00" . $merchantId . "08iIWbWvO16w" . $items[0]['invoiceNumber']);
             //                echo $subTotal.".00".$merchantId."08iIWbWvO16w".$items[0]['invoiceNumber']."<br>";
             //                echo $sha1;die;
             $paymentObject->addField("WORDS", $sha1);
             //$paymentObject->dumpFields();
             $this->_helper->layout->disableLayout();
             $paymentObject->submitPayment();
             break;
         case 'manual':
         case 'bank':
             /*
              1. update order status
              2. redirect to instruction page 
             */
             //setting payment and status as pending (1), notify = 0, notes = 'paid with...'
             $this->updateInvoiceMethod($orderId, 'bank', 1, 0, 'paid with manual method');
             // HAP: i think we should send this notification when user were on page "Complete Order" and after confirmation made by user is approved;
             //$this->Mailer($orderId, 'admin-order', 'admin');
             //$this->Mailer($orderId, 'user-order', 'user');
             $this->_helper->redirector('instruction', 'payment', 'membership', array('orderId' => $orderId));
             break;
     }
 }
示例#3
0
 public function indexAction()
 {
     //[TODO] must check if orderId has been paid before to avoid double charge, if somehow user can access directly to payment controller.
     $this->_checkAuth();
     $orderId = $this->_request->getParam('orderId');
     $this->_orderIdNumber = $orderId;
     if (empty($orderId)) {
         echo "kosong";
         die;
     }
     $modelAppStore = new App_Model_Store();
     if (!$modelAppStore->isUserOwnOrder($this->_userDetailInfo->guid, $orderId)) {
         //forward to error page
         $this->_helper->redirector->gotoSimple('error', 'store', 'site', array('view' => 'notowner'));
         die;
     }
     if ($modelAppStore->isOrderPaid($orderId)) {
         //forward to error page
         $this->_helper->redirector->gotoSimple('error', 'store', 'site', array('view' => 'orderalreadypaid'));
         die;
     }
     $tblOrder = new Kutu_Core_Orm_Table_Order();
     $items = $tblOrder->getOrderDetail($orderId);
     //var_dump($items); die();
     $tmpMethod = $this->_request->getParam('method');
     if (!empty($tmpMethod)) {
         $items[0]['paymentMethod'] = $tmpMethod;
     }
     switch ($items[0]['paymentMethod']) {
         case 'paypal':
             /*
              - Detect Multi Item and set accordingly
              - Logic for test mode 
             */
             require_once 'PaymentGateway/Paypal.php';
             // include the class file
             $paymentObject = new Paypal();
             // initiate an instance of the class
             if ($this->_testMode) {
                 $paymentObject->addField('business', $this->_paymentVars['paypalTestBusiness']);
                 $paymentObject->addField('return', $this->_paymentVars['paypalTestSuccessUrl']);
                 $paymentObject->addField('cancel_return', $this->_paymentVars['paypalTestCancelUrl']);
                 $paymentObject->addField('notify_url', $this->_paymentVars['paypalTestNotifyUrl']);
                 $paymentObject->enableTestMode();
             } else {
                 $paymentObject->addField('business', $this->_paymentVars['paypalBusiness']);
                 $paymentObject->addField('return', $this->_paymentVars['paypalSuccessUrl']);
                 $paymentObject->addField('cancel_return', $this->_paymentVars['paypalCancelUrl']);
                 $paymentObject->addField('notify_url', $this->_paymentVars['paypalNotifyUrl']);
             }
             for ($iCart = 0; $iCart < count($items); $iCart++) {
                 $i = $iCart + 1;
                 $paymentObject->addField("item_number_" . $i, $items[$iCart]['itemId']);
                 $paymentObject->addField("item_name_" . $i, $items[$iCart]['documentName']);
                 //nama barang [documentName]
                 $paymentObject->addField("amount_" . $i, number_format($items[$iCart]['price'], 2, '.', ''));
                 //harga satuan [price]
                 $paymentObject->addField("quantity_" . $i, $items[$iCart]['qty']);
                 //jumlah barang [qty]\
             }
             $paymentObject->addField('tax_cart', $items[0]['orderTax']);
             $paymentObject->addField('currency_code', $this->_defaultCurrency);
             //$paymentObject->addField('custom',$_SESSION['_orderIdNumber']);
             $paymentObject->addField('custom', $orderId);
             $ivnum = $this->updateInvoiceMethod($orderId, 'paypal', 1, 0, 'paid with paypal method');
             //$paymentObject->dumpFields();
             $mod = new App_Model_Store_Mailer();
             $mod->sendInvoiceToUser($orderId, 1);
             $paymentObject->submitPayment();
             //setting payment and status as pending (1), notify = 0, notes = 'paid with...'
             break;
         case 'manual':
         case 'bank':
             /*
              1. update order status
              2. redirect to instruction page 
             */
             //setting payment and status as pending (1), notify = 0, notes = 'paid with...'
             $this->updateInvoiceMethod($orderId, 'bank', 1, 0, 'paid with manual method');
             $mod = new App_Model_Store_Mailer();
             $mod->sendBankInvoiceToUser($orderId, 1);
             // HAP: i think we should send this notification when user were on page "Complete Order" and after confirmation made by user is approved;
             //$this->Mailer($orderId, 'admin-order', 'admin');
             //$this->Mailer($orderId, 'user-order', 'user');
             $this->_helper->redirector('instruction', 'store_payment', 'site', array('orderId' => $orderId));
             break;
         case 'postpaid':
             /*
              1. validate POSTPAID status of the client 
              2. validate CREDIT LIMIT (per user) with current Outstanding Bill + New Bill
              3. update order status
              4. redirect to success or failed 
             */
             /*
              * if userid isn't listed as postpaid user will be redirected
              */
             if (!$this->_userInfo->isPostPaid) {
                 echo 'Not Post Paid Customer';
                 //$paymentObject->submitPayment();
                 return $this->_helper->redirector('notpostpaid');
             }
             /*====================VALIDATE CREDIT LIMIT=====================*/
             /*
              * validate credit limit :
              * 1. count total transaction 
              * 2. counting total previous unpaid postpaid transaction
              * 3. validate
              */
             //$cart = $this->completeItem();
             /*-----count total amount of prevous unpaid transaction------*/
             $tblOrder = new Kutu_Core_Orm_Table_Order();
             //table kutuOrder
             //select previous transaction that are postpaid based on userid
             //echo ($tblOrder->outstandingUserAmout($this->_userInfo->userId));
             $outstandingAmount = $tblOrder->outstandingUserAmout($this->_userInfo->userId);
             /*count total amount of prevous unpaid transaction------*/
             if ($this->_userInfo->creditLimit == 0) {
                 $limit = 'Unlimited';
                 $netLimit = 'Unlimited';
             } else {
                 $limit = number_format($this->_userInfo->creditLimit, 2);
                 $netLimit = $limit - $outstandingAmount;
                 $netLimit = number_format($netLimit, 2);
             }
             //$superTotal = $cart['grandTotal']+$outstandingAmount;
             $superTotal = $items[0]['orderTotal'] + $outstandingAmount;
             if ($this->_userInfo->creditLimit != 0 and $this->_userInfo->creditLimit < $superTotal) {
                 echo $superTotal . $limit;
                 $this->_helper->redirector('postpaidlimit');
                 echo 'Credit Limit Reached, Please Contact Our Billing';
                 /*====================VALIDATE CREDIT LIMIT=====================*/
             } else {
                 /*view file =index.phtml*/
                 $this->view->type = "postpaid";
                 $this->view->limit = $limit;
                 $this->view->outstandingAmount = $outstandingAmount;
                 $this->view->grandTotal = $items[0]['orderTotal'];
                 $this->view->netLimit = $netLimit;
                 $this->view->taxInfo = $items[0];
                 $this->view->orderId = $orderId;
                 //var_dump($items[0]);die();
             }
             break;
     }
     //var_dump($items[0]);
     //die();
 }
示例#4
0
 public function viewinvoiceAction()
 {
     $orderId = $this->_request->getParam('orderId');
     $tblOrder = new Kutu_Core_Orm_Table_Order();
     $items = $tblOrder->getOrderDetail($orderId);
     $this->view->orderId = $orderId;
     $this->view->invoiceNumber = $items[0]['invoiceNumber'];
     $tblPaymentSetting = new Kutu_Core_Orm_Table_PaymentSetting();
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     //var_dump($items);
     //die();
     if ($this->_userId != $items[0]['userId']) {
         //forward to somewhere
         //echo "SHOULD BE FORWARDED";
         $this->_helper->redirector('cartempty', 'store', 'site');
     }
     $result = array();
     $result['subTotal'] = 0;
     for ($iCart = 0; $iCart < count($items); $iCart++) {
         $itemId = $items[$iCart]['itemId'];
         $qty = 1;
         $itemPrice = $items[$iCart]['price'];
         $result['items'][$iCart]['itemId'] = $itemId;
         $result['items'][$iCart]['item_name'] = $items[$iCart]['documentName'];
         $result['items'][$iCart]['itemPrice'] = $itemPrice;
         $result['items'][$iCart]['qty'] = $qty;
         $result['subTotal'] += $itemPrice * $qty;
     }
     $result['taxAmount'] = $result['subTotal'] * $rowTaxRate->settingValue / 100;
     $result['grandTotal'] = $result['subTotal'] + $result['taxAmount'];
     $this->view->cart = $result;
     $data = array();
     $data['taxNumber'] = $items[0]['taxNumber'];
     $data['taxCompany'] = $items[0]['taxCompany'];
     $data['taxAddress'] = $items[0]['taxAddress'];
     $data['taxCity'] = $items[0]['taxCity'];
     $data['taxZip'] = $items[0]['taxZip'];
     $data['taxProvince'] = $items[0]['taxProvince'];
     $data['taxCountry'] = $items[0]['taxCountryId'];
     $data['paymentMethod'] = $items[0]['paymentMethod'];
     $data['currencyValue'] = $items[0]['currencyValue'];
     $this->view->data = $data;
 }