private function confirm($methodname)
 {
     $order = Khipu_KhMage_Helper_Api::getOrderFromNotification($methodname);
     if ($order != null) {
         if ($order->getId()) {
             if ($order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT && $order->getState() != Mage_Sales_Model_Order::STATE_NEW) {
                 $confirmAction = $this->__('confirmAction: Can not change status to order:');
                 // agregado 11-08-2013
                 Mage::log($confirmAction . $order->getId() . " status:" . $order->getState(), Zend_Log::WARN);
                 die;
             }
             $notificationIdentifier = Khipu_KhMage_Helper_Api::getNotificationIdentifier($methodname);
             $khipuhas = $this->__('khipu has confirmed the payment. Notification ID: ');
             // agregado 11-08-2013
             $order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true, $khipuhas . $notificationIdentifier)->save();
             $order->sendNewOrderEmail();
             $order->setEmailSent(true);
             $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
             $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
             $invoice->register();
             $transaction = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($order);
             $transaction->save();
             $invoice->setEmailSent(true);
             $invoice->save();
             $invoice->sendEmail();
             echo "OK";
             die;
         } else {
             $confirmActionlog = $this->__('confirmAction: Valid order not found: ');
             Mage::log($confirmActionlog . $this->getRequest()->getParam('transaction_id'), Zend_Log::WARN);
         }
     }
 }
Пример #2
0
 public static function getOrderFromNotification($methodname)
 {
     $post = array_map('stripslashes', $_POST);
     if ($post['api_version'] == '1.2') {
         return Khipu_KhMage_Helper_Api::getOrderFromNotification_1_2($methodname);
     }
     if ($post['api_version'] == '1.3') {
         return Khipu_KhMage_Helper_Api::getOrderFromNotification_1_3($methodname);
     }
     return null;
 }