Beispiel #1
0
 protected function _postDelete()
 {
     $tblOrderDetail = new App_Model_Db_Table_OrderDetail();
     $tblOrderDetail->delete("orderId=" . $this->orderId);
     $tblOrderHistory = new App_Model_Db_Table_OrderHistory();
     $tblOrderHistory->delete("orderId=" . $this->orderId);
     $tblPaymentHistory = new App_Model_Db_Table_PaymentConfirmation();
     $tblPaymentHistory->delete("orderId=" . $this->orderId);
     $tblNsiapay = new App_Model_Db_Table_Nsiapay();
     $tblNsiapay->delete("orderId=" . $this->orderId);
     $tblNsiapayHistory = new App_Model_Db_Table_NsiapayHistory();
     $tblNsiapayHistory->delete("orderId='{$this->invoiceNumber}'");
 }
Beispiel #2
0
$cardNumber = $_GET['CARDNUMBER'];
$bank = $_GET['BANK'];
$approvalCode = $_GET['APPROVALCODE'];
$result = strtoupper($_GET['RESULT']);
require_once ROOT_DIR . '/app/models/Db/Table/Order.php';
require_once ROOT_DIR . '/app/models/Db/Table/Row/Order.php';
$tblOrder = new App_Model_Db_Table_Order();
$rowOrder = $tblOrder->fetchRow("invoiceNumber='" . $transidmerchant . "' AND orderStatus=1");
$datenow = date('YmdHis');
if ($_SERVER['REMOTE_ADDR'] == "203.190.41.220") {
    if ($rowOrder > 0) {
        if ($result == "SUCCESS") {
            //$rowOrder->orderStatus = 14;
            $rowOrder->paymentDate = $datenow;
            $data = array('status' => 'notify', 'responseCode' => $responseCode, 'creditcard' => $cardNumber, 'bank' => $bank, 'approvalCode' => $approvalCode);
            $tblNsiapay = new App_Model_Db_Table_Nsiapay();
            $tblNsiapay->update($data, "transidmerchant='" . $transidmerchant . "'");
            $tblNhis = new App_Model_Db_Table_NsiapayHistory();
            $tblNhis->insert(array('orderId' => $rowOrder->orderId, 'paymentStatus' => 'notify', 'dateAdded' => date('YmdHis')));
            $response = "Continue";
        } else {
            //$rowOrder->orderStatus = 15;
            $rowOrder->paymentDate = $datenow;
            $response = "Stop";
        }
        $rowOrder->save();
    } else {
        $response = "Stop";
    }
    echo $response;
} else {
Beispiel #3
0
 public function trdetailAction()
 {
     $orderId = $this->_request->getParam('orderId');
     $tblOrder = new App_Model_Db_Table_Order();
     $tblOrderDetail = new App_Model_Db_Table_OrderDetail();
     $tblOrderHistory = new App_Model_Db_Table_OrderHistory();
     //$tblOrderPaypalHistory = new Kutu_Core_Orm_Table_PaypalPaymentHistory();
     $tblOrderNsiapay = new App_Model_Db_Table_Nsiapay();
     $rowset = $tblOrder->fetchAll("orderID ='" . $orderId . "'");
     $rowsetDetail = $tblOrderDetail->fetchAll("orderId='" . $orderId . "'");
     $rowsetHistory = App_Model_Show_OrderHistory::show()->getHistory($orderId);
     //$rowsetPaypalHistory = $tblOrderPaypalHistory->fetchAll($tblOrderPaypalHistory->select()->where("orderId='".$orderId."'"));
     $rowsetNsiapay = $tblOrderNsiapay->fetchAll("orderID ='" . $orderId . "'");
     $this->view->listOrder = $rowset;
     $this->view->listOrderDetail = $rowsetDetail;
     $this->view->rowsetHistory = $rowsetHistory;
     //$this->view->rowsetPaypalHistory = $rowsetPaypalHistory;
     $this->view->rowsetNsiapay = $rowsetNsiapay;
 }
Beispiel #4
0
 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->_helper->viewRenderer->setNoRender(TRUE);
     $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->_user->kopel, $orderId)) {
         //forward to error page
         $this->_helper->redirector->gotoSimple('error', 'store', 'hol-site', array('view' => 'notowner'));
         die;
     }
     if ($modelAppStore->isOrderPaid($orderId)) {
         //forward to error page
         $this->_helper->redirector->gotoSimple('error', 'store', 'hol-site', array('view' => 'orderalreadypaid'));
         die;
     }
     $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';
             // 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", 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 App_Model_Db_Table_Nsiapay();
             $tblNsiapay->insert($data);
             $nhis['orderId'] = $items[0]['invoiceNumber'];
             $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 '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->_userFinanceInfo->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 = App_Model_Show_Order::show()->outstandingUserAmout($this->_userFinanceInfo->userId);
             /*count total amount of prevous unpaid transaction------*/
             if ($this->_userFinanceInfo->creditLimit == 0) {
                 $limit = 'Unlimited';
                 $netLimit = 'Unlimited';
             } else {
                 $limit = number_format($this->_userFinanceInfo->creditLimit, 2);
                 $netLimit = $limit - $outstandingAmount;
                 $netLimit = number_format($netLimit, 2);
             }
             //$superTotal = $cart['grandTotal']+$outstandingAmount;
             $superTotal = $items[0]['orderTotal'] + $outstandingAmount;
             if ($this->_userFinanceInfo->creditLimit != 0 and $this->_userFinanceInfo->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;
     }
 }
Beispiel #5
0
define("_MERCHANTWEB", ROOT_URL);
$transidmerchant = $_GET['TRANSIDMERCHANT'];
$totalamount = $_GET['AMOUNT'];
$status_code = $_GET['STATUSCODE'];
$tblOrder = new App_Model_Db_Table_Order();
$rowOrder = $tblOrder->fetchRow("invoiceNumber='" . $transidmerchant . "' AND orderStatus=1");
$datenow = date('YmdHis');
//if ($_SERVER['REMOTE_ADDR'] == "203.190.41.220") {
if ($rowOrder) {
    if ($status_code == 00) {
        $rowOrder->orderStatus = 3;
    } else {
        $rowOrder->orderStatus = 6;
    }
    $rowOrder->paymentDate = $datenow;
    $tblNsiapay = new App_Model_Db_Table_Nsiapay();
    $tblNsiapay->update(array('status' => 'paid', 'finishtime' => date('YmdHis')), "transidmerchant='" . $transidmerchant . "'");
    $tblNhis = new App_Model_Db_Table_NsiapayHistory();
    $tblNhis->insert(array('orderId' => $rowOrder->orderId, 'paymentStatus' => 'paid', 'dateAdded' => date('YmdHis')));
    $redirect_url = _MERCHANTWEB . "?status_code=" . $status_code . "&order_number=" . $transidmerchant;
    $rowOrder->save();
    $tblHistory = new App_Model_Db_Table_OrderHistory();
    $orderHistory = array('orderId' => $rowOrder->orderId, 'orderStatusId' => $rowOrder->orderStatus, 'dateCreated' => date('YmdHis'), 'userNotified' => 0, 'note' => 'paid with nsiapay method');
    $tblHistory->insert($orderHistory);
} else {
    $redirect_url = _MERCHANTWEB;
}
//}
//else
//{
//	$rowOrder->orderStatus = 7;
 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;
     }
 }
Beispiel #7
0
Pandamp_Application::getResource('session');
Pandamp_Application::getResource('multidb')->getDb('db1');
$transidmerchant = $_GET['TRANSIDMERCHANT'];
$currency = $_GET['CURRENCY'];
require_once ROOT_DIR . '/app/models/Db/Table/Order.php';
require_once ROOT_DIR . '/app/models/Db/Table/Nsiapay.php';
require_once ROOT_DIR . '/app/models/Db/Table/NsiapayHistory.php';
$tblOrder = new App_Model_Db_Table_Order();
$rowOrder = $tblOrder->fetchRow("invoiceNumber='" . $transidmerchant . "'");
$datenow = date('YmdHis');
//if ($_SERVER['REMOTE_ADDR'] == '202.182.62.118') {
if ($rowOrder) {
    //$rowOrder->orderStatus = 9;
    $rowOrder->datePurchased = $datenow;
    $rowOrder->save();
    $tblNsiapay = new App_Model_Db_Table_Nsiapay();
    $tblNsiapay->update(array('status' => 'verify', 'bin' => $currency), "transidmerchant='" . $transidmerchant . "'");
    $tblNhis = new App_Model_Db_Table_NsiapayHistory();
    $tblNhis->insert(array('nsiaId' => $rowOrder->orderId, 'paymentStatus' => 'verify', 'dateAdded' => date('YmdHis')));
    $response = "continue";
} else {
    $response = "stop";
}
echo $response;
//}
//else
//{
//	$rowOrder->orderStatus = 7;
//	$rowOrder->datePurchased = $datenow;
//
//	$rowOrder->save();