diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7b607ad
--- /dev/null
+++ b/README.md
@@ -0,0 +1,68 @@
+# MAGENTO PAYMENT INTEGRATION BY NOVALNET
+The Magento Payment Gateway by Novalnet enables secure integration of payments and payment services for all Magento shops. The full-service platform allow merchant to automate payment processing, enrich customer experiences and improve conversion rate through one interface and one contract partner.
+
+## Integration requirements
+Novalnet merchant account is required for processing all international and local payments through this Magento Payment Gateway. The module is available for the magento versions 1.4.2.x to 1.9.4.5 in the following languages: EN & DE
+
+## Key features
+- Easy configuration of all international & local payment methods
+- One PCI DSS certified payment platform for all payment services from checkout to collection
+- Complete automation of all payment processes
+- 60+ risk & payment fraud detection modules to prevent defaults in real time
+- Clear overview of payment status from checkout to receivables
+- Multilevel claims management with integrated handover to collection and various export functions for the accounting
+- Comprehensive fraud prevention solution with more than 60 modules (Machine learning)
+- Reporting & analytics dashboards with multiple export options
+- Automated e-mail notifications for staying up to date on the payment status
+- Automated bookkeeping report in XML, SOAP, CSV, MT940
+- Simple seamless integration of the payment module
+- Secure SSL-encoded gateways
+- Credit/Debit Card iframe integration
+- Custom CSS configuration for Credit/Debit Card iframe
+- One click shopping supported for Credit/Debit Cards, Direct Debit SEPA, Direct Debit SEPA with payment guarantee, Instalment by Direct Debit SEPA & PayPal
+- Easy way of confirmation and cancellation of on-hold transactions (Cancel & Confirm option) for Direct Debit SEPA, Direct Debit SEPA with payment guarantee, Instalment payment for Direct Debit SEPA, Credit/Debit Cards, Invoice, Invoice with payment guarantee, Instalment payment for Invoice, Prepayment & PayPal.
+- Refund option for Credit/Debit Cards, Direct Debit SEPA, Debit SEPA with payment guarantee, Instalment payment for Direct Debit SEPA, Invoice, Invoice with payment guarantee, Instalment payment for Invoice, Prepayment, Barzahlen/viacash, Sofort, iDEAL, eps, giropay, PayPal & Przelewy24.
+- Due date change option for Prepayment & Invoice payment.
+- Payment slip expiry date update option for Barzahlen/viacash payment.
+- Supports the multi-store features of Magento
+- Allowed countries customization
+- All SUPEE secure patches are supported
+- Automatic order creation on subscription renewal
+- Subscription management (suspend, reactivate, cancel) in both Magento store and Magento admin
+
+For detailed documentation and other technical inquiries, please send us an email at sales@novalnet.de
+
+## Integrated payment methods
+- Direct Debit SEPA
+- Credit/Debit Cards
+- Invoice
+- Prepayment
+- Invoice with payment guarantee
+- Direct Debit SEPA with payment guarantee
+- iDEAL
+- Sofort
+- giropay
+- Barzahlen/viacash
+- Przelewy24
+- eps
+- Instalment by Invoice
+- Instalment by Direct Debit SEPA
+- PayPal
+
+## License
+See our License Agreement at: https://www.novalnet.com/payment-plugins/free/license
+
+## Documentation & Support
+For more information about the Magento Payment Integration by Novalnet, please get in touch with us: sales@novalnet.de or +49 89 9230683-20
+
+Novalnet AG
+Zahlungsinstitut (ZAG)
+Feringastr. 4
+85774 Unterföhring
+Deutschland
+Website: www.novalnet.de
+
+## Who is Novalnet AG?
+
Novalnet AG is a leading financial service institution offering payment gateways for processing online payments. Operating in the market as a full payment service provider Novalnet AG provides online merchants user-friendly payment integration with all major shop systems and self-programmed sites.
+Accept, manage and monitor payments all on one platform with one single contract!
+Our SaaS engine is PCI DSS certified and designed to enable real-time risk management, secured payments via escrow accounts, efficient receivables management, dynamic member and subscription management, customized payment solutions for various business models (e.g. marketplaces, affiliate programs etc.) etc.
diff --git a/app/code/community/Novalnet/Payment/Block/Adminhtml/Novalnetutility.php b/app/code/community/Novalnet/Payment/Block/Adminhtml/Novalnetutility.php new file mode 100755 index 0000000..da31131 --- /dev/null +++ b/app/code/community/Novalnet/Payment/Block/Adminhtml/Novalnetutility.php @@ -0,0 +1,23 @@ +_headerText = Mage::helper('novalnet_payment')->__('Novalnet Recurring Profiles'); + parent::__construct(); + $this->_removeButton('add'); + } + +} diff --git a/app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile/Grid.php b/app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile/Grid.php new file mode 100755 index 0000000..f373759 --- /dev/null +++ b/app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile/Grid.php @@ -0,0 +1,171 @@ +setId('novalnet_recurring_profile_grid'); + $this->setUseAjax(true); + $this->setSaveParametersInSession(true); + } + + /** + * Prepare grid collection object + * + * @param none + * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_Grid + */ + protected function _prepareCollection() + { + $collection = Mage::getResourceModel('sales/recurring_profile_collection') + ->addFieldToFilter( + 'method_code', array( + 'like' => '%novalnet%', + ) + ); + $collection->setOrder('profile_id', 'desc'); + $this->setCollection($collection); + + if (!$this->getParam($this->getVarNameSort())) { + $collection->setOrder('profile_id', 'desc'); + } + + return parent::_prepareCollection(); + } + + /** + * Prepare grid columns + * + * @param none + * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_Grid + */ + protected function _prepareColumns() + { + $profile = Mage::getModel('sales/recurring_profile'); + + $this->addColumn( + 'reference_id', array( + 'header' => $profile->getFieldLabel('reference_id'), + 'index' => 'reference_id', + 'html_decorators' => array('nobr'), + 'width' => 1, + ) + ); + + if (!Mage::app()->isSingleStoreMode()) { + $this->addColumn( + 'store_id', array( + 'header' => Mage::helper('adminhtml')->__('Store'), + 'index' => 'store_id', + 'type' => 'store', + 'store_view' => true, + 'display_deleted' => true, + ) + ); + } + + $profileState = $profile->getAllStates(); + uasort($profileState, 'strcasecmp'); + $this->addColumn( + 'state', array( + 'header' => $profile->getFieldLabel('state'), + 'index' => 'state', + 'type' => 'options', + 'options' => $profileState, + 'html_decorators' => array('nobr'), + 'width' => 1, + ) + ); + + $this->addColumn( + 'created_at', array( + 'header' => Mage::helper('novalnet_payment')->__('Created on'), + 'index' => 'created_at', + 'type' => 'datetime', + 'html_decorators' => array('nobr'), + 'width' => 1, + ) + ); + + $this->addColumn( + 'updated_at', array( + 'header' => Mage::helper('novalnet_payment')->__('Updated on'), + 'index' => 'updated_at', + 'type' => 'datetime', + 'html_decorators' => array('nobr'), + 'width' => 1, + ) + ); + + $methods = array(); + foreach (Mage::helper('payment')->getRecurringProfileMethods() as $method) { + if (preg_match("/novalnet/i", $method->getCode())) { + $methods[$method->getCode()] = $method->getTitle(); + } + } + + $this->addColumn( + 'method_code', array( + 'header' => $profile->getFieldLabel('method_code'), + 'index' => 'method_code', + 'type' => 'options', + 'options' => $methods, + ) + ); + + $this->addColumn( + 'schedule_description', array( + 'header' => $profile->getFieldLabel('schedule_description'), + 'index' => 'schedule_description', + ) + ); + + return parent::_prepareColumns(); + } + + /** + * Get row url for js event handlers + * + * @param mixed $row + * @return string + */ + public function getRowUrl($row) + { + return $this->getUrl('adminhtml/sales_recurring_profile/view', array('profile' => $row->getId())); + } + + /** + * Get grid url + * + * @param none + * @return string + */ + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current' => true)); + } + +} diff --git a/app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile/View.php b/app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile/View.php new file mode 100755 index 0000000..189e57f --- /dev/null +++ b/app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile/View.php @@ -0,0 +1,172 @@ +getMethodCode())) { + return parent::_prepareLayout(); + } + + $this->_addButton( + 'back', array( + 'label' => Mage::helper('adminhtml')->__('Back'), + 'onclick' => "setLocation('{$this->getUrl('*/*/')}')", + 'class' => 'back' + ) + ); + // Get transaction information + $transactionStatus = $this->getTransactionStatus($profile); + + $comfirmationMessage = Mage::helper('sales')->__('Are you sure you want to do this?'); + + // cancel + if ($profile->canCancel() && $transactionStatus->getAmount()) { + $url = $this->getUrl( + '*/*/updateState', array('profile' => $profile->getId(), + 'action' => 'cancel') + ); + $this->_addButton( + 'cancel', array( + 'label' => Mage::helper('sales')->__('Cancel'), + 'onclick' => "cancelButtonViewStatus('recurring_buttons_view','recurring_cancel_button_view')", + 'class' => 'delete', + ) + ); + } + + // suspend + $state = $profile->getState(); + if ($profile->canSuspend() && $state != 'pending' && $transactionStatus->getAmount()) { + $url = $this->getUrl( + '*/*/updateState', array('profile' => $profile->getId(), + 'action' => 'suspend') + ); + $this->_addButton( + 'suspend', array( + 'label' => Mage::helper('sales')->__('Suspend'), + 'onclick' => "confirmSetLocation('{$comfirmationMessage}', '{$url}')", + 'class' => 'delete', + ) + ); + } + + // activate + if ($profile->canActivate() && $state != 'pending') { + $url = $this->getUrl( + '*/*/updateState', array('profile' => $profile->getId(), + 'action' => 'activate') + ); + $this->_addButton( + 'activate', array( + 'label' => Mage::helper('sales')->__('Activate'), + 'onclick' => "confirmSetLocation('{$comfirmationMessage}', '{$url}')", + 'class' => 'add', + ) + ); + } + } + + /** + * Set title and a hack for tabs container + * + * @param none + * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_View + */ + protected function _beforeToHtml() + { + $profile = Mage::registry('current_recurring_profile'); + $this->_headerText = Mage::helper('sales')->__('Recurring Profile # %s', $profile->getReferenceId()); + $this->setViewHtml(''); + return parent::_beforeToHtml(); + } + + /** + * Get cancel reasons for recurring cancel + * + * @param none + * @return mixed + */ + protected function _getCancelButtonWithReasons() + { + $profile = Mage::registry('current_recurring_profile'); + $comfirmationMessage = Mage::helper('sales')->__('Are you sure you want to do this?'); + $helper = Mage::helper('sales'); + $lang = array($helper->__("Please select reason"), $helper->__("Product is costly"), $helper->__("Cheating"), + $helper->__("Partner interfered"), $helper->__("Financial problem"), + $helper->__("Content does not match my likes"), $helper->__("Content is not enough"), + $helper->__("Interested only for a trial"), $helper->__("Page is very slow"), + $helper->__("Satisfied customer"), $helper->__("Logging in problems"), $helper->__("Other reasons")); + $cancelview = ""; + if ($profile->canCancel()) { + $cancelReason = $helper->__("Please select the reason of subscription cancellation"); + $select = Mage::app()->getLayout()->createBlock('core/html_select') + ->setName("cancel_reason") + ->setId("reason-unsubscribe") + ->setOptions($lang); + + $cancelview .= $select->getHtml(); + + $url = $this->getUrl( + '*/*/updateState', array('profile' => $profile->getId(), + 'action' => 'cancel') + ); + $this->setChild( + 'cancel', $this->getLayout()->createBlock('adminhtml/widget_button')->setData( + array( + 'label' => Mage::helper('sales')->__('Cancel'), + 'onclick' => "subscriptionCancel('{$comfirmationMessage}', '{$url}', '{$cancelReason}')", + 'class' => 'delete', + ) + ) + ); + $cancelview .= $this->getChildHtml('cancel'); + } + + return $cancelview; + } + + /** + * Get transaction information + * + * @param Varien_Object $profile + * @return Varien_Object + */ + public function getTransactionStatus($profile) + { + $transactionId = $profile->getReferenceId(); + // load transaction status information + $helper = Mage::helper('novalnet_payment'); // Novalnet payment helper + $transactionStatus = $helper->getModel('Mysql4_TransactionStatus') + ->loadByAttribute('transaction_no', $transactionId); + return $transactionStatus; + } + +} diff --git a/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order.php b/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order.php new file mode 100755 index 0000000..6cbe0af --- /dev/null +++ b/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order.php @@ -0,0 +1,36 @@ +_blockGroup = 'novalnet_payment'; + $this->_controller = 'adminhtml_sales_order'; + $this->_headerText = Mage::helper('novalnet_payment')->__('Orders'); + $this->removeButton('add'); + } + +} diff --git a/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Grid.php b/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Grid.php new file mode 100755 index 0000000..5f9a863 --- /dev/null +++ b/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Grid.php @@ -0,0 +1,353 @@ +setId('novalnet_sales_order_grid'); + $this->setUseAjax(true); + $this->setDefaultSort('created_at'); + $this->setDefaultDir('DESC'); + $this->setSaveParametersInSession(true); + + // Novalnet + $novalnetPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('paymentMethods'); + $novalPaymentMethods = array_keys($novalnetPayment); + + foreach ($novalPaymentMethods as $paymentCode) { + $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title'); + $this->novalnetPayments[$paymentCode] = $paymentTitle; + } + + // Novalnet + // Customer groups + $this->groups = Mage::getResourceModel('customer/group_collection') + ->addFieldToFilter('customer_group_id', array('gt' => 0)) + ->load() + ->toOptionHash(); + // Customer groups + } + + /** + * Retrieve collection class + * + * @param none + * @return string + */ + protected function _getCollectionClass() + { + return 'sales/order_grid_collection'; + } + + /** + * Prepare order Collection for novalnet payments + * + * @param none + * @return Mage_Adminhtml_Block_Widget_Grid + */ + protected function _prepareCollection() + { + $collection = Mage::getResourceModel($this->_getCollectionClass()); + $tablePrefix = Mage::getConfig()->getTablePrefix(); + // For customer email filter + $collection->getSelect()->joinLeft( + array('email' => $tablePrefix . 'sales_flat_order'), + 'email.entity_id=main_table.entity_id', + array('email.customer_email') + ); + $collection->getSelect()->joinLeft( + array('cgroup' => $tablePrefix . 'sales_flat_order'), + 'cgroup.entity_id=main_table.entity_id', + array('cgroup.customer_group_id') + ); + + if (version_compare(Mage::helper('novalnet_payment')->getMagentoVersion(), '1.6.0.0', '>')) { + $collection->join(array('payment' => 'sales/order_payment'), 'main_table.entity_id = parent_id', 'method') + ->getSelect()->where("`payment`.`method` like '%novalnet%'"); + } else { + $flatOrderPayment = $collection->getTable('sales/order_payment'); + $collection->getSelect()->join( + array('payment' => $flatOrderPayment), 'main_table.entity_id = payment.parent_id', 'method' + )->where("`payment`.`method` like '%novalnet%'"); + } + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * prepare column for order grid + * + * @param none + * @return Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid + */ + protected function _prepareColumns() + { + $this->addColumn( + 'real_order_id', array( + 'header' => Mage::helper('sales')->__('Order #'), + 'width' => '80px', + 'type' => 'text', + 'index' => 'increment_id', + 'filter_index' => 'main_table.increment_id' + ) + ); + + if (!Mage::app()->isSingleStoreMode()) { + $this->addColumn( + 'store_id', array( + 'header' => Mage::helper('sales')->__('Purchased From (Store)'), + 'index' => 'store_id', + 'type' => 'store', + 'store_view' => true, + 'display_deleted' => true, + 'filter_index' => 'main_table.store_id' + ) + ); + } + + $this->addColumn( + 'created_at', array( + 'header' => Mage::helper('sales')->__('Purchased On'), + 'index' => 'created_at', + 'type' => 'datetime', + 'width' => '100px', + 'filter_index' => 'main_table.created_at' + ) + ); + + $this->addColumn( + 'billing_name', array( + 'header' => Mage::helper('sales')->__('Bill to Name'), + 'index' => 'billing_name', + ) + ); + + $this->addColumn( + 'shipping_name', array( + 'header' => Mage::helper('sales')->__('Ship to Name'), + 'index' => 'shipping_name', + ) + ); + + $this->addColumn( + 'customer_email', array( + 'header' => Mage::helper('sales')->__('Email'), + 'index' => 'customer_email', + 'filter_index' => 'email.customer_email' + ) + ); + + $this->addColumn( + 'customer_group_id', array( + 'header' => Mage::helper('sales')->__('Group'), + 'index' => 'customer_group_id', + 'filter_index' => 'cgroup.customer_group_id', + 'type' => 'options', + 'options' => $this->groups, + ) + ); + + $this->addColumn( + 'base_grand_total', array( + 'header' => Mage::helper('sales')->__('G.T. (Base)'), + 'index' => 'base_grand_total', + 'type' => 'currency', + 'currency' => 'base_currency_code', + 'filter_index' => 'main_table.base_grand_total' + ) + ); + + $this->addColumn( + 'grand_total', array( + 'header' => Mage::helper('sales')->__('G.T. (Purchased)'), + 'index' => 'grand_total', + 'type' => 'currency', + 'currency' => 'order_currency_code', + 'filter_index' => 'main_table.grand_total' + ) + ); + + $orderStatus = Mage::getSingleton('sales/order_config')->getStatuses(); + uasort($orderStatus, 'strcasecmp'); + $this->addColumn( + 'status', array( + 'header' => Mage::helper('sales')->__('Status'), + 'index' => 'status', + 'type' => 'options', + 'width' => '70px', + 'options' => $orderStatus, + 'filter_index' => 'main_table.status' + ) + ); + + uasort($this->novalnetPayments, 'strcasecmp'); + $this->addColumn( + 'novalnet_method', array( + 'header' => Mage::helper('sales')->__('Payment Method'), + 'index' => 'method', + 'type' => 'options', + 'width' => '70px', + 'options' => $this->novalnetPayments, + ), 'method' + ); + + if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { + $this->addColumn( + 'action', array( + 'header' => Mage::helper('sales')->__('Action'), + 'width' => '80px', + 'type' => 'action', + 'getter' => 'getId', + 'renderer' => 'novalnet_payment/adminhtml_sales_order_render_delete', + 'filter' => false, + 'sortable' => false, + 'index' => 'stores', + 'is_system' => true, + ) + ); + } + + $this->setDefaultSort('created_at'); + $this->setDefaultDir('DESC'); + + $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS')); + + parent::_prepareColumns(); + return $this; + } + + /** + * prepare column for massaction order grid + * + * @param none + * @return Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid + */ + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setFormFieldName('order_ids'); + $this->getMassactionBlock()->setUseSelectAll(false); + + if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) { + $this->getMassactionBlock()->addItem( + 'cancel_order', array( + 'label' => Mage::helper('sales')->__('Cancel'), + 'url' => $this->getUrl('*/*/massCancel'), + ) + ); + } + + if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) { + $this->getMassactionBlock()->addItem( + 'hold_order', array( + 'label' => Mage::helper('sales')->__('Hold'), + 'url' => $this->getUrl('*/*/massHold'), + ) + ); + } + + if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) { + $this->getMassactionBlock()->addItem( + 'unhold_order', array( + 'label' => Mage::helper('sales')->__('Unhold'), + 'url' => $this->getUrl('*/*/massUnhold'), + ) + ); + } + + $this->getMassactionBlock()->addItem( + 'pdfinvoices_order', array( + 'label' => Mage::helper('sales')->__('Print Invoices'), + 'url' => $this->getUrl('*/*/pdfinvoices'), + ) + ); + + $this->getMassactionBlock()->addItem( + 'pdfshipments_order', array( + 'label' => Mage::helper('sales')->__('Print Packingslips'), + 'url' => $this->getUrl('*/*/pdfshipments'), + ) + ); + + $this->getMassactionBlock()->addItem( + 'pdfcreditmemos_order', array( + 'label' => Mage::helper('sales')->__('Print Credit Memos'), + 'url' => $this->getUrl('*/*/pdfcreditmemos'), + ) + ); + + $this->getMassactionBlock()->addItem( + 'pdfdocs_order', array( + 'label' => Mage::helper('sales')->__('Print All'), + 'url' => $this->getUrl('*/*/pdfdocs'), + ) + ); + + $this->getMassactionBlock()->addItem( + 'print_shipping_label', array( + 'label' => Mage::helper('sales')->__('Print Shipping Labels'), + 'url' => $this->getUrl('adminhtml/sales_order_shipment/massPrintShippingLabel'), + ) + ); + + $this->getMassactionBlock()->addItem( + 'delete_order', array( + 'label' => Mage::helper('sales')->__('Delete Order'), + 'url' => $this->getUrl('adminhtml/novalnetpayment_sales_deleteorder/massDelete'), + 'confirm' => Mage::helper('sales')->__('Are you sure you want to delete order?') + ) + ); + + return $this; + } + + /** + * Return row url + * + * @param none + * @return string + */ + public function getRowUrl($row) + { + return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId())); + } + + /** + * Return grid url + * + * @param none + * @return string + */ + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current' => true)); + } + +} diff --git a/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Render/Delete.php b/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Render/Delete.php new file mode 100755 index 0000000..c1a4561 --- /dev/null +++ b/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Render/Delete.php @@ -0,0 +1,45 @@ +getData(); + $orderId = $info['entity_id']; + $message = Mage::helper('sales')->__('Are you sure you want to delete this order?'); + $viewLink = $this->getUrl('adminhtml/sales_order/view', array('order_id' => $orderId)); + $deleteLink = $this->getUrl( + 'adminhtml/novalnetpayment_sales_deleteorder/delete', array('order_id' => $orderId) + ); + $result = 'View'; + $result .= ' '; + $result .= 'Delete'; + return $result; + } + +} diff --git a/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/Instalment.php b/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/Instalment.php new file mode 100755 index 0000000..032e24e --- /dev/null +++ b/app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/Instalment.php @@ -0,0 +1,174 @@ +setTemplate('novalnet/sales/order/view/tab/instalment.phtml'); + } + + /** + * Return tab label + * + * @param none + * @return string + */ + public function getTabLabel() + { + return $this->novalnetHelper()->__('Instalment'); + } + + /** + * Return tab title + * + * @param none + * @return string + */ + public function getTabTitle() + { + return $this->novalnetHelper()->__('Instalment'); + } + + /** + * Can show tab + * + * @param none + * @return boolean + */ + public function canShowTab() + { + $order = $this->getOrder(); + $payment = $order->getPayment(); + $paymentCode = $payment->getMethodInstance()->getCode(); + if (in_array($paymentCode, array(Novalnet_Payment_Model_Config::NN_INVOICE_INSTALMENT, Novalnet_Payment_Model_Config::NN_SEPA_INSTALMENT))) { + $helper = $this->novalnetHelper(); + $additionalData = unserialize($payment->getAdditionalData()); + $transactionId = !empty($payment->getLastTransId()) ? $payment->getLastTransId() : $additionalData['NnTid']; + + if (!empty($transactionId)) { + // Get current transaction status information + $transactionStatus = $helper->getModel('Mysql4_TransactionStatus') + ->loadByAttribute('transaction_no', $helper->makeValidNumber($transactionId)); // Get payment original transaction status + return ($transactionStatus->getTransactionStatus() == 100) ? true : false; + } + } + + return false; + } + + /** + * Tab is hidden + * + * @param none + * @return boolean + */ + public function isHidden() + { + return false; + } + + /** + * Return tab class + * + * @param none + * @return string + */ + public function getTabClass() + { + return 'ajax novalnet-widget-tab'; + } + + /** + * Get current order + * + * @param none + * @return Mage_Sales_Model_Order + */ + public function getOrder() + { + return Mage::registry('current_order'); + } + + /** + * Get URL to edit the customer. + * + * @return string + */ + public function getCustomerViewUrl() + { + if ($this->getOrder()->getCustomerIsGuest() || !$this->getOrder()->getCustomerId()) { + return ''; + } + + return Mage::helper('adminhtml')->getUrl('adminhtml/customer/edit', array('id' => $this->getOrder()->getCustomerId())); + } + + /** + * Get order store name + * + * @return null|string + */ + public function getOrderStoreName() + { + if ($this->getOrder()) { + $storeId = $this->getOrder()->getStoreId(); + if ($storeId === null) { + $deleted = __(' [deleted]'); + return nl2br($this->getOrder()->getStoreName()) . $deleted; + } + $store = Mage::app()->getStore($storeId); + $name = array($store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()); + return implode('