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 Pandamp_Modules_Payment_Order_Model_Order(); $items = $tblOrder->getOrderDetail($orderId); $tmpMethod = $this->_request->getParam('method'); if (!empty($tmpMethod)) { $items[0]['paymentMethod'] = $tmpMethod; } 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"); 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", ROOT_URL); $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); $ivnum = $this->updateInvoiceMethod($orderId, 'nsiapay', 1, 0, 'paid with nsiapay method'); $data['orderId'] = $orderId; $data['starttime'] = date('YmdHis'); $data['amount'] = $subTotal; $data['transidmerchant'] = $items[0]['invoiceNumber']; $tblNsiapay = new Pandamp_Modules_Payment_Nsiapay_Model_Nsiapay(); $tblNsiapay->insert($data); $nhis['orderId'] = $items[0]['invoiceNumber']; $nhis['paymentStatus'] = 'requested'; $nhis['dateAdded'] = date('YmdHis'); $tblNhis = new Pandamp_Modules_Payment_NsiapayHistory_Model_NsiapayHistory(); $tblNhis->insert($nhis); // $paymentObject->dumpFields(); $this->_helper->layout->disableLayout(); $paymentObject->submitPayment(); break; 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, $items[$iCart]['price']); //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(); $this->_helper->layout->disableLayout(); $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'); // 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 Pandamp_Modules_Payment_Order_Model_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 { $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; } break; } }
public function viewinvoiceAction() { $orderId = $this->_request->getParam('orderId'); $tblOrder = new Pandamp_Modules_Payment_Order_Model_Order(); $items = $tblOrder->getOrderDetail($orderId); $this->view->orderId = $orderId; $this->view->invoiceNumber = $items[0]['invoiceNumber']; $tblPaymentSetting = new Pandamp_Modules_Payment_Setting_Model_PaymentSetting(); $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'"); if ($this->_userId != $items[0]['userId']) { $this->_redirect(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; }
function processAction() { $formater = new Pandamp_Core_Hol_User(); $orderId = $this->_request->getParam('orderId'); $this->_orderIdNumber = $orderId; if (empty($orderId)) { echo "kosong"; die; } $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 Pandamp_Modules_Payment_Order_Model_Order(); $items = $tblOrder->getOrderDetail($orderId); $tmpMethod = $this->_request->getParam('method'); if (!empty($tmpMethod)) { $items[0]['paymentMethod'] = $tmpMethod; } $tblUser = new Pandamp_Modules_Identity_User_Model_User(); $rowUser = $tblUser->find($items[0]['userId'])->current(); $total = $formater->checkPromoValidation('Total', $rowUser->packageId, $rowUser->promotionId, $rowUser->paymentId); 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"); for ($iCart = 0; $iCart < count($items); $iCart++) { $i = $iCart + 1; $basket[] = $items[$iCart]['documentName'] . " " . $rowUser->paymentId . " Months," . $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', 'store_payment', 'hol-site', array('orderId' => $orderId)); break; } }