Exemplo n.º 1
0
$cardNumber = $_GET['CARDNUMBER'];
$bank = $_GET['BANK'];
$approvalCode = $_GET['APPROVALCODE'];
$result = strtoupper($_GET['RESULT']);
$tblOrder = new Pandamp_Modules_Payment_Order_Model_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 Pandamp_Modules_Payment_Nsiapay_Model_Nsiapay();
            $tblNsiapay->update($data, "transidmerchant='" . $transidmerchant . "'");
            $tblNhis = new Pandamp_Modules_Payment_NsiapayHistory_Model_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 {
    $rowOrder->orderStatus = 7;
    $rowOrder->datePurchased = $datenow;
Exemplo n.º 2
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->_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;
     }
 }