function isOrderPaid($orderId) { $tblOrder = new Pandamp_Modules_Payment_Order_Model_Order(); $rowOrder = $tblOrder->find($orderId)->current(); if (!empty($rowOrder)) { if ($rowOrder->orderStatus == 3) { return true; } else { return false; } } else { return false; } }
public function sendReceiptToUser($orderId, $paymentMethod = '', $statusText = '') { $config = new Zend_Config_Ini(ROOT_DIR . '/app/configs/mail.ini', 'general'); $siteOwner = "Hukumonline"; $siteName = $config->mail->sender->support->name; $contactEmail = $config->mail->sender->support->email; $tblOrder = new Pandamp_Modules_Payment_Order_Model_Order(); $rowOrder = $tblOrder->find($orderId)->current(); $userId = $rowOrder->userId; //first check if orderId status is PAID, then send the email. switch ($rowOrder->orderStatus) { case 1: die('ORDER STATUS IS NOT YET PAID. CAN NOT SEND RECEIPT!.'); break; case 3: $orderStatus = "PAID"; break; case 5: $orderStatus = "POSTPAID PENDING"; break; case 6: $orderStatus = "PAYMENT REJECTED"; break; case 7: $orderStatus = "PAYMENT ERROR"; break; default: $orderStatus = "PAYMENT ERROR"; break; } $tblUser = new Pandamp_Modules_Identity_User_Model_User(); $rowUser = $tblUser->find($userId)->current(); $userEmail = $rowUser->email; $userFullname = $rowUser->fullName; switch (strtolower($paymentMethod)) { case 'paypal': case 'manual': case 'bank': case 'postpaid': default: $message = "\t\t\t\t\t\r\nDear {$userFullname},\r\n\r\nThis is a payment receipt for Invoice # {$rowOrder->invoiceNumber}\r\n\r\nTotal Amount: USD {$rowOrder->orderTotal}\r\nTransaction #:\r\nTotal Paid: USD {$rowOrder->orderTotal}\r\nStatus: {$orderStatus}\r\nYour payment method is: {$paymentMethod}\r\n\r\nYou may review your invoice history at any time by logging in to your account " . ROOT_URL . "/store/payment/list\r\n\r\nNote: This email will serve as an official receipt for this payment.\r\n\r\nSalam,\r\n\r\nHukumonline\r\n\r\n=============================="; } $this->send($config->mail->sender->support->email, $config->mail->sender->support->name, $userEmail, '', "Hukumonline Receipt Invoice# " . $rowOrder->invoiceNumber, $message); }
private function saveOrder($cart, $method) { $defaultCurrency = 'Rp'; $tblPaymentSetting = new Pandamp_Modules_Payment_Setting_Model_PaymentSetting(); $usdIdrEx = $tblPaymentSetting->fetchRow(" settingKey= 'USDIDR'"); $currencyValue = $usdIdrEx->settingValue; $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'"); $taxRate = $rowTaxRate->settingValue; $auth = Zend_Auth::getInstance(); $userId = $auth->getIdentity()->guid; $tblOrder = new Pandamp_Modules_Payment_Order_Model_Order(); $row = $tblOrder->fetchNew(); $row->userId = $userId; //get value from post var (store/checkout.phtml) if ($this->getRequest()->getPost()) { $value = $this->getRequest()->getPost(); $row->taxNumber = $value['taxNumber']; $row->taxCompany = $value['taxCompany']; $row->taxAddress = $value['taxAddress']; $row->taxCity = $value['taxCity']; $row->taxZip = $value['taxZip']; $row->taxProvince = $value['taxProvince']; $row->taxCountryId = $value['taxCountry']; $row->paymentMethod = $method; } $row->datePurchased = date('YmdHis'); // if ($method == "nsiapay") { // $row->orderStatus=8; // } // else { // $row->orderStatus=1; //pending // } $row->orderStatus = 1; //pending $row->currency = $defaultCurrency; $row->currencyValue = $currencyValue; $row->orderTotal = $cart['grandTotal']; $row->orderTax = $cart['taxAmount']; $row->ipAddress = Pandamp_Lib_Formater::getRealIpAddr(); $orderId = $row->save(); $rowJustInserted = $tblOrder->find($orderId)->current(); // $rowJustInserted->invoiceNumber = date('Ymd') . '.' . $orderId; $tblNumber = new Pandamp_Modules_Misc_Number_Model_GenerateNumber(); $rowset = $tblNumber->fetchRow(); $num = $rowset->invoice; $totdigit = 5; $num = strval($num); $jumdigit = strlen($num); $noinvoice = str_repeat("0", $totdigit - $jumdigit) . $num; $rowset->invoice = $rowset->invoice += 1; $tblNumber->update(array('invoice' => $rowset->invoice)); $rowJustInserted->invoiceNumber = $noinvoice; $rowJustInserted->save(); $this->view->invoiceNumber = $rowJustInserted->invoiceNumber; $this->view->datePurchased = $rowJustInserted->datePurchased; $tblOrderDetail = new Pandamp_Modules_Payment_OrderDetail_Model_OrderDetail(); for ($iCart = 0; $iCart < count($cart['items']); $iCart++) { $rowDetail = $tblOrderDetail->fetchNew(); $itemId = $cart['items'][$iCart]['itemId']; $rowDetail->orderId = $orderId; $rowDetail->itemId = $itemId; $rowDetail->documentName = $cart['items'][$iCart]['item_name']; $rowDetail->price = $cart['items'][$iCart]['itemPrice']; $itemPrice = $rowDetail->price; @($rowDetail->tax = ($cart['grandTotal'] - $cart['subTotal']) / $cart['subTotal'] * 100); $rowDetail->qty = $cart['items'][$iCart]['qty']; $rowDetail->finalPrice = $cart['items'][$iCart]['itemTotal']; $rowDetail->save(); } //[TODO] MUST ALSO INSERT/UPDATE KutuUserFinance return $orderId; }
protected function updateInvoiceMethod($orderId, $payMethod, $status, $notify, $note) { $tblOrder = new Pandamp_Modules_Payment_Order_Model_Order(); $rows = $tblOrder->find($orderId)->current(); $row = array(); $ivnum = $rows->invoiceNumber; /*if(empty($ivnum)){ if($status==3 || $status==5 || (!empty($_SESSION['_method'])&&($_SESSION['_method'] =='paypal'))) $ivnum = $this->getInvoiceNumber(); //$row=array ('invoiceNumber' => $ivnum); }*/ //if( )$ivnum = $this->getInvoiceNumber(); $row = array('orderStatus' => $status, 'paymentMethod' => $payMethod); //$_SESSION['_method'] = ''; /*$this->_paymentMethod=$payMethod;//set payment method on table $row->paymentMethod=$this->_paymentMethod;*/ $tblOrder->update($row, 'orderId = ' . $orderId); $tblHistory = new Pandamp_Modules_Payment_OrderHistory_Model_OrderHistory(); $rowHistory = $tblHistory->fetchNew(); $rowHistory->orderId = $orderId; $rowHistory->orderStatusId = $status; $rowHistory->dateCreated = date('YmdHis'); $rowHistory->userNotified = $notify; $rowHistory->note = $note; $rowHistory->save(); return $ivnum; }