getActiveMethods(); $isPPEnabled = false; foreach ($payments as $paymentCode => $paymentModel) { $isPPEnabled = $paymentCode == "paypal_express" || $paymentCode == "paypal_standard" ? true : $isPPEnabled; if ($isPPEnabled) { break; } } if (Mage::getStoreConfig('custominvoice_section/main_group/module_enable') != '1' || $isPPEnabled != true) { return $this->_forward('noRoute'); } $alias = $this->getRequest()->getParam("key"); if (!$alias) { return $this->_forward('noRoute'); } $model = Mage::getModel('orange35_custominvoicesgenerator/order'); $model->load($alias, 'alias'); if (!$model->getId()) { return $this->_forward('noRoute'); } /*if invoice status RECEIVED- Received the return 404*/ if ($model->getPaymentStatus() == Orange35_CustomInvoicesGenerator_Model_Info::STATUS_RECEIVED) { return $this->_forward('noRoute'); } $this->loadLayout(); $this->getLayout()->getBlock('custom_invoice')->setOrder($model); $this->renderLayout(); return $this; } public function sentAction() { $alias = $_POST['key']; if (!$alias || !Mage::getModel('orange35_custominvoicesgenerator/order')->load($alias, 'alias')->getId()) { Mage::getSingleton('core/session')->addError('Order key not found in database!'); Mage::log('Order with key ' . $alias . ' found in database!', null, 'custom_invoices.log'); return $this->_forward('noRoute'); } if (isset($_POST['amount'])) { /** @var $invoiceHelper Orange35_CustomInvoicesGenerator_Helper_Data */ $invoiceHelper = Mage::helper('orange35_custominvoicesgenerator/data'); $invoiceInfo = array( 'invoice' => $invoiceHelper->createNewInvoice($alias), 'item_name' => $_POST['item_name'], 'amount' => $_POST['amount'], ); $PayPalForm = $invoiceHelper->getSubmitForm($invoiceInfo); $invoiceHelper->processPayment($PayPalForm); } return $this; } public function ipnAction() { if (strtolower($_POST['payment_status']) == Mage_Paypal_Model_Info::PAYMENTSTATUS_COMPLETED) { $data['paid'] = $_POST['mc_gross']; $data['country'] = $_POST['address_country']; $data['customer_email'] = $_POST['payer_email']; $data['customer_name'] = $_POST['first_name']; $data['customer_lastname'] = $_POST['last_name']; $data['payment_status'] = $_POST['payment_status']; /** @var $invoiceModel Orange35_CustomInvoicesGenerator_Model_Invoice */ $invoiceModel = Mage::getModel('orange35_custominvoicesgenerator/invoice')->load(date('Y-m-d H:i:s', $_POST['invoice']), 'date'); $invoiceModel->updateInvoice($data); } } }