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; } }
function processAction() { $formater = new Pandamp_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 ROOT_DIR . '/app/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 App_Model_Db_Table_Order(); $items = App_Model_Show_Order::show()->getOrderDetail($orderId); $tmpMethod = $this->_request->getParam('method'); if (!empty($tmpMethod)) { $items[0]['paymentMethod'] = $tmpMethod; } $tblUser = new App_Model_Db_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; } }
function processAction() { $this->_helper->viewRenderer->setNoRender(TRUE); $this->_checkAuth(); $orderId = $this->_request->getParam('orderId'); if (empty($orderId)) { $this->_redirect(ROOT_URL . '/shop/payment/cartempty'); } $modelAppStore = new App_Model_Store(); if (!$modelAppStore->isUserOwnOrder($this->_user->kopel, $orderId)) { $this->_helper->redirector->gotoSimple('error', 'manager', 'shop', array('view' => 'notowner')); die; } if ($modelAppStore->isOrderPaid($orderId)) { $this->_helper->redirector->gotoSimple('error', 'manager', 'shop', array('view' => 'orderalreadypaid')); die; } $this->view->identity = "Process-" . $orderId; $items = App_Model_Show_Order::show()->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'; $paymentObject = new Nsiapay(); 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"; development $merchantId = "000100013001060"; $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"); development $paymentObject->addField("MALLID", "332"); $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 App_Model_Db_Table_Nsiapay(); $rowNsia = $tblNsiapay->fetchRow("transidmerchant='" . $items[0]['invoiceNumber'] . "'"); if (!$rowNsia) { $id = $tblNsiapay->insert($data); $nhis['nsiaId'] = $id; $nhis['paymentStatus'] = 'requested'; $nhis['dateAdded'] = date('YmdHis'); $tblNhis = new App_Model_Db_Table_NsiapayHistory(); $tblNhis->insert($nhis); } else { $nhis['nsiaId'] = $rowNsia->nsiaId; $nhis['paymentStatus'] = 'requested'; $nhis['dateAdded'] = date('YmdHis'); $tblNhis = new App_Model_Db_Table_NsiapayHistory(); $tblNhis->insert($nhis); } //$paymentObject->dumpFields();die(); $this->_helper->layout->disableLayout(); $paymentObject->submitPayment(); break; case 'bank': $this->updateInvoiceMethod($orderId, 'bank', 1, 0, 'paid with manual method'); $this->_helper->redirector('instruction', 'payment', 'shop', array('orderId' => $orderId)); break; } }