Novalnet - Version 11.0.0

Version Notes

- Auto configuration of vendor credentials.

- One click shopping for Direct Debit SEPA.

- Iframe and hosted page implementation for Credit Card.

- Implemented Direct Debit SEPA with payment guarantee and Invoice
with payment guarantee.

- Edit option in Direct Debit SEPA for registered customers.

- Notify URL configuration in shop backend.

- Logo control has been implemented in global configuration.

- Responsive templates has been implemented.

- Novalnet payment module has been optimized as per new testcase.

Download this release

Release Info

Developer Gabriel Dixon
Extension Novalnet
Version 11.0.0
Comparing to
See all releases


Code changes from version 10.2.1 to 11.0.0

Files changed (164) hide show
  1. app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Config/Form.php +0 -123
  2. app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Config/Payment/Form.php +0 -132
  3. app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Page/Edit.php +0 -102
  4. app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Page/Save.php +0 -103
  5. app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Page/View.php +0 -116
  6. app/code/community/Novalnet/Payment/Block/Adminhtml/Information/{Novalnetmerchantadmin.php → Merchantadmin.php} +50 -50
  7. app/code/community/Novalnet/Payment/Block/Adminhtml/Information/Module.php +49 -50
  8. app/code/community/Novalnet/Payment/Block/Adminhtml/Notifications.php +116 -0
  9. app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile.php +5 -5
  10. app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile/Grid.php +54 -34
  11. app/code/community/Novalnet/Payment/Block/{Sales/Adminhtml → Adminhtml}/Recurring/Profile/View.php +72 -31
  12. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order.php +40 -38
  13. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Creditmemo/Totals.php +0 -63
  14. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Grid.php +145 -54
  15. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Invoice/Totals.php +0 -64
  16. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Invoice/View.php +0 -100
  17. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Render/Delete.php +50 -0
  18. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Totals.php +0 -62
  19. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View.php +0 -83
  20. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/Invoices.php +0 -197
  21. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/Renderer/Invoices.php +0 -45
  22. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/TransactionOverview.php +153 -31
  23. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/TransactionStatus.php +0 -247
  24. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/TransactionTraces.php +133 -0
  25. app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Sales.php +0 -53
  26. app/code/community/Novalnet/Payment/Block/Adminhtml/Transaction/Grid.php +0 -117
  27. app/code/community/Novalnet/Payment/Block/Adminhtml/Transaction/View.php +0 -104
  28. app/code/community/Novalnet/Payment/Block/Adminhtml/Transactionoverview.php +41 -40
  29. app/code/community/Novalnet/Payment/Block/Adminhtml/Transactionoverview/Grid.php +55 -37
  30. app/code/community/Novalnet/Payment/Block/Adminhtml/Transactionoverview/View.php +47 -27
  31. app/code/community/Novalnet/Payment/Block/Adminhtml/Transactionoverview/View/Form.php +10 -6
  32. app/code/community/Novalnet/Payment/Block/Adminhtml/{Transaction.php → Transactiontraces.php} +42 -40
  33. app/code/community/Novalnet/Payment/Block/Adminhtml/Transactiontraces/Grid.php +126 -0
  34. app/code/community/Novalnet/Payment/Block/Adminhtml/Transactiontraces/View.php +94 -0
  35. app/code/community/Novalnet/Payment/Block/Adminhtml/{Transaction → Transactiontraces}/View/Form.php +9 -9
  36. app/code/community/Novalnet/Payment/Block/Adminhtml/Widget.php +0 -49
  37. app/code/community/Novalnet/Payment/Block/{Payment/Method/Form/Sepa.php → Method/Form/Banktransfer.php} +72 -67
  38. app/code/community/Novalnet/Payment/Block/{Payment/Method → Method}/Form/Cc.php +102 -90
  39. app/code/community/Novalnet/Payment/Block/{Payment/Method/Form/Invoice.php → Method/Form/Eps.php} +23 -20
  40. app/code/community/Novalnet/Payment/Block/Method/Form/Giropay.php +72 -0
  41. app/code/community/Novalnet/Payment/Block/Method/Form/Ideal.php +72 -0
  42. app/code/community/Novalnet/Payment/Block/Method/Form/Invoice.php +72 -0
  43. app/code/community/Novalnet/Payment/Block/Method/Form/Paypal.php +72 -0
  44. app/code/community/Novalnet/Payment/Block/Method/Form/Prepayment.php +72 -0
  45. app/code/community/Novalnet/Payment/Block/Method/Form/Sepa.php +117 -0
  46. app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Sepa.php → Method/Info/Banktransfer.php} +72 -70
  47. app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Giropay.php → Method/Info/Cc.php} +20 -18
  48. app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Invoice.php → Method/Info/Eps.php} +18 -16
  49. app/code/community/Novalnet/Payment/Block/Method/Info/Giropay.php +72 -0
  50. app/code/community/Novalnet/Payment/Block/Method/Info/Ideal.php +72 -0
  51. app/code/community/Novalnet/Payment/Block/Method/Info/Invoice.php +72 -0
  52. app/code/community/Novalnet/Payment/Block/Method/Info/Paypal.php +72 -0
  53. app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Cc.php → Method/Info/Prepayment.php} +72 -70
  54. app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Prepayment.php → Method/Info/Sepa.php} +20 -17
  55. app/code/community/Novalnet/Payment/Block/Method/Redirect.php +71 -0
  56. app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Banktransfer.php +0 -49
  57. app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Eps.php +0 -49
  58. app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Giropay.php +0 -49
  59. app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Ideal.php +0 -49
  60. app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Paypal.php +0 -49
  61. app/code/community/Novalnet/Payment/Block/Payment/Method/Info/Banktransfer.php +0 -70
  62. app/code/community/Novalnet/Payment/Block/Payment/Method/Info/Eps.php +0 -70
  63. app/code/community/Novalnet/Payment/Block/Payment/Method/Info/Ideal.php +0 -69
  64. app/code/community/Novalnet/Payment/Block/Payment/Method/Info/Paypal.php +0 -70
  65. app/code/community/Novalnet/Payment/Block/Payment/Method/NovalnetRedirect.php +0 -93
  66. app/code/community/Novalnet/Payment/Block/{Sales/Recurring → Recurring}/Profile/View.php +64 -36
  67. app/code/community/Novalnet/Payment/Block/Sales/Order/Creditmemo/Totals.php +0 -63
  68. app/code/community/Novalnet/Payment/Block/Sales/Order/Invoice/Totals.php +0 -65
  69. app/code/community/Novalnet/Payment/Block/Sales/Order/Totals.php +0 -64
  70. app/code/community/Novalnet/Payment/Helper/AssignData.php +0 -432
  71. app/code/community/Novalnet/Payment/Helper/Data.php +212 -748
  72. app/code/community/Novalnet/Payment/Model/Adminhtml/Sales/Order/Create.php +28 -22
  73. app/code/community/Novalnet/Payment/Model/Callbackscript.php +0 -1624
  74. app/code/community/Novalnet/Payment/Model/Config.php +119 -119
  75. app/code/community/Novalnet/Payment/Model/Factory.php +0 -382
  76. app/code/community/Novalnet/Payment/Model/Ipn.php +0 -410
  77. app/code/community/Novalnet/Payment/Model/Method/Abstract.php +312 -0
  78. app/code/community/Novalnet/Payment/Model/Method/NovalnetBanktransfer.php +61 -0
  79. app/code/community/Novalnet/Payment/Model/Method/NovalnetCc.php +139 -0
  80. app/code/community/Novalnet/Payment/Model/{Payment/Method → Method}/NovalnetEps.php +33 -6
  81. app/code/community/Novalnet/Payment/Model/{Payment/Method → Method}/NovalnetGiropay.php +33 -6
  82. app/code/community/Novalnet/Payment/Model/{Payment/Method → Method}/NovalnetIdeal.php +33 -6
  83. app/code/community/Novalnet/Payment/Model/Method/NovalnetInvoice.php +124 -0
  84. app/code/community/Novalnet/Payment/Model/{Payment/Method → Method}/NovalnetPaypal.php +18 -6
  85. app/code/community/Novalnet/Payment/Model/Method/NovalnetPrepayment.php +77 -0
  86. app/code/community/Novalnet/Payment/Model/Method/NovalnetSepa.php +179 -0
  87. app/code/community/Novalnet/Payment/Model/{Affiliate.php → Mysql4/AffiliateInfo.php} +51 -53
  88. app/code/community/Novalnet/Payment/Model/{Affiliateuser.php → Mysql4/AffiliateUser.php} +51 -53
  89. app/code/community/Novalnet/Payment/Model/{Callback.php → Mysql4/Callback.php} +63 -64
  90. app/code/community/Novalnet/Payment/Model/Mysql4/Recurring.php +67 -0
  91. app/code/community/Novalnet/Payment/Model/{Resource/Recurring/Collection.php → Mysql4/Resource/AffiliateInfo.php} +37 -33
  92. app/code/community/Novalnet/Payment/Model/Mysql4/Resource/AffiliateInfo/Collection.php +36 -0
  93. app/code/community/Novalnet/Payment/Model/{Resource/Affiliate/Collection.php → Mysql4/Resource/AffiliateUser.php} +38 -34
  94. app/code/community/Novalnet/Payment/Model/Mysql4/Resource/AffiliateUser/Collection.php +36 -0
  95. app/code/community/Novalnet/Payment/Model/{Resource/Callback/Collection.php → Mysql4/Resource/Callback.php} +37 -33
  96. app/code/community/Novalnet/Payment/Model/{Resource/Affiliateuser → Mysql4/Resource/Callback}/Collection.php +37 -34
  97. app/code/community/Novalnet/Payment/Model/{Resource/Separefill/Collection.php → Mysql4/Resource/Recurring.php} +37 -33
  98. app/code/community/Novalnet/Payment/Model/{Resource/Amountchanged → Mysql4/Resource/Recurring}/Collection.php +36 -33
  99. app/code/community/Novalnet/Payment/Model/Mysql4/Resource/TransactionStatus.php +37 -0
  100. app/code/community/Novalnet/Payment/Model/{Resource/Transactionoverview → Mysql4/Resource/TransactionStatus}/Collection.php +48 -44
  101. app/code/community/Novalnet/Payment/Model/Mysql4/Resource/TransactionTraces.php +37 -0
  102. app/code/community/Novalnet/Payment/Model/{Resource/Transactionstatus → Mysql4/Resource/TransactionTraces}/Collection.php +48 -44
  103. app/code/community/Novalnet/Payment/Model/{Transactionstatus.php → Mysql4/TransactionStatus.php} +66 -65
  104. app/code/community/Novalnet/Payment/Model/{Transactionoverview.php → Mysql4/TransactionTraces.php} +63 -64
  105. app/code/community/Novalnet/Payment/Model/Novalnet/Request.php +0 -36
  106. app/code/community/Novalnet/Payment/Model/Observer.php +0 -175
  107. app/code/community/Novalnet/Payment/Model/Observer/InvoiceView.php +100 -0
  108. app/code/community/Novalnet/Payment/Model/Observer/LoadScripts.php +97 -0
  109. app/code/community/Novalnet/Payment/Model/Observer/OrderView.php +115 -0
  110. app/code/community/Novalnet/Payment/Model/Observer/Recurring.php +85 -0
  111. app/code/community/Novalnet/Payment/Model/Observer/SalesEmails.php +160 -0
  112. app/code/community/Novalnet/Payment/Model/Payment/Method/Abstract.php +0 -1910
  113. app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetBanktransfer.php +0 -34
  114. app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetCc.php +0 -34
  115. app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetInvoice.php +0 -33
  116. app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetPrepayment.php +0 -33
  117. app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetSepa.php +0 -34
  118. app/code/community/Novalnet/Payment/Model/Quote/Address/Total/Nominal.php +30 -18
  119. app/code/community/Novalnet/Payment/Model/Recurring.php +0 -285
  120. app/code/community/Novalnet/Payment/Model/Recurring/Payment.php +266 -0
  121. app/code/community/Novalnet/Payment/Model/Recurring/Profile.php +31 -30
  122. app/code/community/Novalnet/Payment/Model/Resource/Affiliate.php +0 -39
  123. app/code/community/Novalnet/Payment/Model/Resource/Affiliateuser.php +0 -39
  124. app/code/community/Novalnet/Payment/Model/Resource/Amountchanged.php +0 -38
  125. app/code/community/Novalnet/Payment/Model/Resource/Callback.php +0 -38
  126. app/code/community/Novalnet/Payment/Model/Resource/Recurring.php +0 -38
  127. app/code/community/Novalnet/Payment/Model/Resource/Separefill.php +0 -38
  128. app/code/community/Novalnet/Payment/Model/Resource/Transactionoverview.php +0 -38
  129. app/code/community/Novalnet/Payment/Model/Resource/Transactionstatus.php +0 -38
  130. app/code/community/Novalnet/Payment/Model/Sales/Order/Creditmemo/Total/Grand.php +0 -68
  131. app/code/community/Novalnet/Payment/Model/Sales/Order/Invoice.php +0 -98
  132. app/code/community/Novalnet/Payment/Model/Sales/Order/Payment.php +0 -161
  133. app/code/community/Novalnet/Payment/Model/Sales/Order/Pdf/Creditmemo.php +0 -142
  134. app/code/community/Novalnet/Payment/Model/Sales/Order/Pdf/Invoice.php +0 -143
  135. app/code/community/Novalnet/Payment/Model/Separefill.php +0 -67
  136. app/code/community/Novalnet/Payment/Model/Service/Abstract.php +401 -0
  137. app/code/community/Novalnet/Payment/Model/Service/Api/FraudPrevention.php +298 -0
  138. app/code/community/Novalnet/Payment/Model/Service/Api/Gateway.php +90 -0
  139. app/code/community/Novalnet/Payment/Model/Service/Api/Request.php +572 -0
  140. app/code/community/Novalnet/Payment/Model/Service/Api/Response.php +847 -0
  141. app/code/community/Novalnet/Payment/Model/Service/Validate/PaymentCheck.php +384 -0
  142. app/code/community/Novalnet/Payment/Model/{System/Config/Activemethods.php → Source/ActiveMethods.php} +20 -22
  143. app/code/community/Novalnet/Payment/Model/{Amountchanged.php → Source/CallbackEmail.php} +41 -39
  144. app/code/community/Novalnet/Payment/Model/{Novalnet/Source/Cctype.php → Source/CcCardTypes.php} +21 -12
  145. app/code/community/Novalnet/Payment/{Block/Adminhtml/Widget/Grid/Container.php → Model/Source/CcFormTypes.php} +41 -38
  146. app/code/community/Novalnet/Payment/Model/Source/CustomerGroups.php +58 -0
  147. app/code/community/Novalnet/Payment/Model/{Novalnet/Source/Callbacktypes.php → Source/PreventionTypes.php} +42 -35
  148. app/code/community/Novalnet/Payment/Model/Source/VendorAutoConfig.php +39 -0
  149. app/code/community/Novalnet/Payment/Model/System/Config/Backend/Notifyurl.php +0 -45
  150. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Configuration/Wizard/PageController.php +0 -190
  151. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Information/{NovalnetmerchantadminController.php → MerchantadminController.php} +53 -41
  152. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Information/ModuleController.php +55 -41
  153. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Sales/DeleteorderController.php +186 -0
  154. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Sales/OrderController.php +107 -263
  155. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Sales/Recurring/ProfileController.php +13 -156
  156. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/TransactionController.php +0 -89
  157. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/TransactionoverviewController.php +102 -88
  158. app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/TransactiontracesController.php +104 -0
  159. app/code/community/Novalnet/Payment/controllers/CallbackController.php +1497 -0
  160. app/code/community/Novalnet/Payment/controllers/CcController.php +86 -103
  161. app/code/community/Novalnet/Payment/controllers/Checkout/OnepageController.php +20 -12
  162. app/code/community/Novalnet/Payment/controllers/GatewayController.php +105 -384
  163. app/code/community/Novalnet/Payment/etc/adminhtml.xml +53 -43
  164. app/code/community/Novalnet/Payment/etc/config.xml +180 -192
app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Config/Form.php DELETED
@@ -1,123 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Configuration_Wizard_Config_Form extends Mage_Adminhtml_Block_System_Config_Form
27
- {
28
- /**
29
- * Prepare configuration wizard form layout
30
- *
31
- */
32
- protected function _prepareLayout()
33
- {
34
- $return = parent::_prepareLayout();
35
- $this->initForm();
36
- return $return;
37
- }
38
-
39
- /**
40
- * Initialize configuration wizard form
41
- *
42
- * @return Mage_Adminhtml_Block_System_Config_Form
43
- */
44
- public function initForm()
45
- {
46
- $this->_initObjects();
47
- $form = $this->_initForm();
48
- $getWebsiteCode = $this->getConfigPage('codes/website');
49
- $getStoreCode = $this->getConfigPage('codes/store');
50
- $sections = $this->_configFields->getSection(
51
- $this->getConfigPage('codes/section'), $getWebsiteCode, $getStoreCode
52
- );
53
-
54
- $session = Mage::getSingleton('admin/session');
55
-
56
- if (!$getWebsiteCode && !$getStoreCode) {
57
- $session->setNnStoreConfig('Standard');
58
- } elseif ($getWebsiteCode && !$getStoreCode) {
59
- $storeConfig = Mage::getModel('core/website')->load($getWebsiteCode)->getName();
60
- Mage::register('webConfig', Mage::getModel('core/website')->load($getWebsiteCode)->getId());
61
- $session->setNnStoreConfig($storeConfig);
62
- } else {
63
- $storeConfig = Mage::getModel('core/store')->load($getStoreCode)->getName();
64
- Mage::register('storeConfig', Mage::getModel('core/store')->load($getStoreCode)->getId());
65
- $session->setNnStoreConfig($storeConfig);
66
- }
67
-
68
- $groups = $sections->groups;
69
- $gropupArray = $this->getConfigPage('group_name');
70
- foreach ($gropupArray as $gropupArrayvalue) {
71
- $group = $groups->$gropupArrayvalue;
72
-
73
- $fieldsetRenderer = Mage::getBlockSingleton('Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset');
74
- $fieldsetConfig = array(
75
- 'legend' => Mage::helper('novalnet_payment')->__((string) $group->label),
76
- );
77
- $fieldset = $form->addFieldset($sections->getName() . '_' . $group->getName(), $fieldsetConfig);
78
- $fieldsetRenderer->setForm($this);
79
-
80
- $this->initFields($fieldset, $group, $sections);
81
- }
82
- $fieldset->addField(
83
- 'page_code', 'hidden', array(
84
- 'name' => 'page_code',
85
- 'value' => $this->getConfigPage('codes/page')
86
- )
87
- );
88
- $form->setUseContainer(true);
89
- $this->setForm($form);
90
- return $this;
91
- }
92
-
93
- /**
94
- * Initialize configuration wizard form
95
- *
96
- * @return Varien_Data_Form
97
- */
98
- protected function _initForm()
99
- {
100
- $form = new Varien_Data_Form(
101
- array(
102
- 'id' => 'edit_form',
103
- 'action' => $this->getUrl('*/*/save', array('_current' => true)),
104
- 'method' => 'post',
105
- 'enctype' => 'multipart/form-data'
106
- )
107
- );
108
- return $form;
109
- }
110
-
111
- /**
112
- * Get configuration page path
113
- *
114
- * @param string $path
115
- * @return mixed
116
- */
117
- public function getConfigPage($path)
118
- {
119
- $config = Mage::helper('novalnet_payment')->getConfigPage();
120
- return $config->getData($path);
121
- }
122
-
123
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Config/Payment/Form.php DELETED
@@ -1,132 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Configuration_Wizard_Config_Payment_Form extends Mage_Adminhtml_Block_System_Config_Form
27
- {
28
- /**
29
- * prepare configuration wizard layout
30
- *
31
- */
32
- protected function _prepareLayout()
33
- {
34
- $return = parent::_prepareLayout();
35
- $this->initForm();
36
- return $return;
37
- }
38
-
39
- /**
40
- * Initialize configuration wizard form
41
- *
42
- * @return Mage_Adminhtml_Block_System_Config_Form
43
- */
44
- public function initForm()
45
- {
46
- $this->_initObjects();
47
- $form = $this->_initForm();
48
- $getWebsiteCode = $this->getConfigPage('codes/website');
49
- $getStoreCode = $this->getConfigPage('codes/store');
50
- $sections = $this->_configFields->getSection(
51
- $this->getConfigPage('codes/section'), $getWebsiteCode, $getStoreCode
52
- );
53
-
54
- $session = Mage::getSingleton('admin/session');
55
-
56
- if (!$getWebsiteCode && !$getStoreCode) {
57
- $session->setNnStoreConfig('Standard');
58
- } else if ($getWebsiteCode && !$getStoreCode) {
59
- $storeConfig = Mage::getModel('core/website')->load($getWebsiteCode)->getName();
60
- Mage::register('webConfig', Mage::getModel('core/website')->load($getWebsiteCode)->getId());
61
- $session->setNnStoreConfig($storeConfig);
62
- } else {
63
- $storeConfig = Mage::getModel('core/store')->load($getStoreCode)->getName();
64
- Mage::register('storeConfig', Mage::getModel('core/store')->load($getStoreCode)->getId());
65
- $session->setNnStoreConfig($storeConfig);
66
- }
67
-
68
- $groups = $sections->groups;
69
- $gropupArray = $this->getConfigPage('group_name');
70
- foreach ($gropupArray as $gropupArrayvalue) {
71
- $group = $groups->$gropupArrayvalue;
72
-
73
- $fieldsetConfig = array(
74
- 'legend' => Mage::helper('novalnet_payment')->__((string) $group->label),
75
- );
76
-
77
- $fieldsetRenderer = $group->frontend_model
78
- ? Mage::getBlockSingleton((string) $group->frontend_model) : $this->_defaultFieldsetRenderer;
79
-
80
- $fieldsetRenderer->setForm($this)
81
- ->setConfigData($this->_configData);
82
- $fieldset = new Varien_Data_Form_Element_Fieldset($fieldsetConfig);
83
- $fieldset->setId($sections->getName() . '_' . $group->getName())
84
- ->setRenderer($fieldsetRenderer)
85
- ->setGroup($group);
86
- $form->addElement($fieldset);
87
-
88
- $this->initFields($fieldset, $group, $sections);
89
- }
90
-
91
- $fieldset->addField(
92
- 'page_code', 'hidden', array(
93
- 'name' => 'page_code',
94
- 'value' => $this->getConfigPage('codes/page')
95
- )
96
- );
97
- $form->setUseContainer(true);
98
- $this->setForm($form);
99
- return $this;
100
- }
101
-
102
- /**
103
- * Initialize configuration wizard form
104
- *
105
- * @return Varien_Data_Form
106
- */
107
- protected function _initForm()
108
- {
109
- $form = new Varien_Data_Form(
110
- array(
111
- 'id' => 'save_form',
112
- 'action' => $this->getUrl('*/*/paymentsave', array('_current' => true)),
113
- 'method' => 'post',
114
- 'enctype' => 'multipart/form-data'
115
- )
116
- );
117
- return $form;
118
- }
119
-
120
- /**
121
- * Get configuration page path
122
- *
123
- * @param string $path
124
- * @return mixed
125
- */
126
- public function getConfigPage($path)
127
- {
128
- $config = Mage::helper('novalnet_payment')->getConfigPage();
129
- return $config->getData($path);
130
- }
131
-
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Page/Edit.php DELETED
@@ -1,102 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Configuration_Wizard_Page_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
27
- {
28
-
29
- public function __construct()
30
- {
31
- $this->_mode = '';
32
- $this->_blockGroup = 'novalnet_payment';
33
- $this->_controller = 'adminhtml_configuration_wizard_page_edit';
34
-
35
- $this->_removeButton('delete')
36
- ->_removeButton('reset')
37
- ->_removeButton('back')
38
- ->_removeButton('save');
39
-
40
- $this->_addButton('back', array(
41
- 'label' => $this->helperWizard()->__('Back'),
42
- 'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
43
- 'class' => 'default',
44
- ));
45
-
46
- $this->_addButton('save', array(
47
- 'label' => $this->helperWizard()->__('Save'),
48
- 'onclick' => 'editForm.submit();',
49
- 'class' => 'default',
50
- ));
51
- }
52
-
53
- /**
54
- * Get header text of configuration wizard page
55
- *
56
- * @return string
57
- */
58
- public function getHeaderText()
59
- {
60
- $session = Mage::getSingleton('admin/session');
61
- $storeConfig = $session->getNnStoreConfig();
62
-
63
- $headerText = $this->helperWizard()->__($this->getConfigPage('header_text'));
64
- $text = $this->helperWizard()->__('%s for %s', $headerText, $storeConfig);
65
- $session->unsNnStoreConfig();
66
- return $text;
67
- }
68
-
69
- /**
70
- * Get configuration wizard page back url
71
- *
72
- * @return string
73
- */
74
- public function getBackUrl()
75
- {
76
- $url = $this->helperWizard()->getPreviousPageUrlAsString();
77
- return $this->getUrl($url, array('_current' => true));
78
- }
79
-
80
- /**
81
- * Get configuration page path
82
- *
83
- * @param string $path
84
- * @return mixed
85
- */
86
- public function getConfigPage($path)
87
- {
88
- $config = $this->helperWizard()->getConfigPage();
89
- return $config->getData($path);
90
- }
91
-
92
- /**
93
- * Get Novalnet payment helper
94
- *
95
- * @return Novalnet_Payment_Helper_Data
96
- */
97
- public function helperWizard()
98
- {
99
- return Mage::helper('novalnet_payment');
100
- }
101
-
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Page/Save.php DELETED
@@ -1,103 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Configuration_Wizard_Page_Save extends Mage_Adminhtml_Block_Widget_Form_Container
27
- {
28
-
29
- public function __construct()
30
- {
31
- $this->_mode = '';
32
- $this->_blockGroup = 'novalnet_payment';
33
- $this->_controller = 'adminhtml_configuration_wizard_page_save';
34
-
35
- $this->_removeButton('delete')
36
- ->_removeButton('reset')
37
- ->_removeButton('back')
38
- ->_removeButton('save');
39
-
40
- $this->_addButton('back', array(
41
- 'label' => $this->helperWizard()->__('Back'),
42
- 'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
43
- 'class' => 'default',
44
- 'style' => 'margin-top: 10px;',
45
- ));
46
-
47
- $this->_addButton('save', array(
48
- 'label' => $this->helperWizard()->__('Save'),
49
- 'onclick' => 'saveForm.submit();',
50
- 'class' => 'default',
51
- ));
52
- }
53
-
54
- /**
55
- * Get header text of configuration wizard page
56
- *
57
- * @return string
58
- */
59
- public function getHeaderText()
60
- {
61
- $session = Mage::getSingleton('admin/session');
62
- $storeConfig = $session->getNnStoreConfig();
63
-
64
- $headerText = $this->helperWizard()->__($this->getConfigPage('header_text'));
65
- $text = $this->helperWizard()->__('%s for %s', $headerText, $storeConfig);
66
- $session->unsNnStoreConfig();
67
- return $text;
68
- }
69
-
70
- /**
71
- * Get configuration wizard page back url
72
- *
73
- * @return string
74
- */
75
- public function getBackUrl()
76
- {
77
- $url = $this->helperWizard()->getPreviousPageUrlAsString();
78
- return $this->getUrl($url, array('_current' => true));
79
- }
80
-
81
- /**
82
- * Get configuration page path
83
- *
84
- * @param string $path
85
- * @return mixed
86
- */
87
- public function getConfigPage($path)
88
- {
89
- $config = $this->helperWizard()->getConfigPage();
90
- return $config->getData($path);
91
- }
92
-
93
- /**
94
- * Get Novalnet payment helper
95
- *
96
- * @return Novalnet_Payment_Helper_Data
97
- */
98
- public function helperWizard()
99
- {
100
- return Mage::helper('novalnet_payment');
101
- }
102
-
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Configuration/Wizard/Page/View.php DELETED
@@ -1,116 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Configuration_Wizard_Page_View extends Mage_Adminhtml_Block_Widget_View_Container
27
- {
28
-
29
- public function __construct()
30
- {
31
- $this->_blockGroup = 'novalnet_payment';
32
- $this->_controller = 'adminhtml_configuration_wizard_page';
33
- $this->_headerText = $this->helperWizard()->__('Novalnet Payment Configuration');
34
-
35
- $this->_removeButton('edit')
36
- ->_removeButton('back');
37
-
38
- $this->_addButton('save', array(
39
- 'label' => Mage::helper('adminhtml')->__('Continue'),
40
- 'class' => 'default',
41
- 'onclick' => 'window.location.href=\'' . $this->getNextUrl() . '\'',
42
- ));
43
- }
44
-
45
- /**
46
- * Get configuration wizard page view
47
- *
48
- * @return mixed
49
- */
50
- public function getViewHtml()
51
- {
52
- $html = '';
53
- foreach ($this->getSortedChildren() as $childName) {
54
-
55
- $child = $this->getChild($childName);
56
-
57
- $html .= $child->toHtml();
58
- }
59
- return $html;
60
- }
61
-
62
- /**
63
- * Get configuration wizard next page url
64
- *
65
- * @return string
66
- */
67
- protected function getNextUrl()
68
- {
69
- $url = $this->helperWizard()->getNextPageUrlAsString();
70
- return $this->getUrl($url, array('_current' => true));
71
- }
72
-
73
- /**
74
- * Get header text of configuration wizard page
75
- *
76
- * @return string
77
- */
78
- public function getHeaderText()
79
- {
80
- $headerText = $this->helperWizard()->__($this->getConfigPage('header_text'));
81
- return $headerText;
82
- }
83
-
84
- /**
85
- * Get configuration page path
86
- *
87
- * @param string $path
88
- * @return mixed
89
- */
90
- public function getConfigPage($path)
91
- {
92
- $config = $this->helperWizard()->getConfigPage();
93
- return $config->getData($path);
94
- }
95
-
96
- /**
97
- * Get Novalnet payment helper
98
- *
99
- * @return Novalnet_Payment_Helper_Data
100
- */
101
- public function helperWizard()
102
- {
103
- return Mage::helper('novalnet_payment');
104
- }
105
-
106
- /**
107
- * Prepare layout
108
- *
109
- * @return null
110
- */
111
- protected function _prepareLayout()
112
- {
113
- $this->unsetChild('', '');
114
- }
115
-
116
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Information/{Novalnetmerchantadmin.php → Merchantadmin.php} RENAMED
@@ -1,50 +1,50 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Information_Novalnetmerchantadmin extends Mage_Adminhtml_Block_Template
27
- {
28
-
29
- /**
30
- * Assign the template to load the novalnet magento module updates
31
- *
32
- */
33
- public function _construct()
34
- {
35
- $this->setTemplate("novalnet/information/novalnetmerchantadmin.phtml");
36
- }
37
-
38
- /**
39
- * Return Novalnet merchant admin link
40
- *
41
- * @return string
42
- */
43
- public function getNovalnetAdminUrl()
44
- {
45
- $protocol = Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http';
46
- $url = $this->escapeUrl($protocol . '://admin.novalnet.de');
47
- return $url;
48
- }
49
-
50
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Information_Merchantadmin extends Mage_Adminhtml_Block_Template
27
+ {
28
+
29
+ /**
30
+ * Assign the template to load the novalnet magento module updates
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->setTemplate("novalnet/information/merchantadmin.phtml");
35
+ }
36
+
37
+ /**
38
+ * Return Novalnet merchant admin portal link
39
+ *
40
+ * @param none
41
+ * @return string
42
+ */
43
+ public function getNovalnetAdminUrl()
44
+ {
45
+ $protocol = Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http';
46
+ $url = $this->escapeUrl($protocol . '://admin.novalnet.de');
47
+ return $url;
48
+ }
49
+
50
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/Information/Module.php CHANGED
@@ -1,50 +1,49 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Information_Module extends Mage_Adminhtml_Block_Template
27
- {
28
-
29
- /**
30
- * Assign the template to load the novalnet magento module updates
31
- *
32
- */
33
- public function _construct()
34
- {
35
- $this->setTemplate("novalnet/information/module.phtml");
36
- }
37
-
38
- /**
39
- * Return Magento module information link
40
- *
41
- * @return string
42
- */
43
- public function getNovalnetUrl()
44
- {
45
- $protocol = Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http';
46
- $url = $this->escapeUrl($protocol . '://www.novalnet.de/modul/magento-payment-module');
47
- return $url;
48
- }
49
-
50
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Information_Module extends Mage_Adminhtml_Block_Template
27
+ {
28
+
29
+ /**
30
+ * Assign the template to load the novalnet magento module updates
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->setTemplate("novalnet/information/module.phtml");
35
+ }
36
+
37
+ /**
38
+ * Return Magento module information link
39
+ *
40
+ * @return string
41
+ */
42
+ public function getNovalnetUrl()
43
+ {
44
+ $protocol = Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http';
45
+ $url = $this->escapeUrl($protocol . '://www.novalnet.de/modul/magento-payment-module');
46
+ return $url;
47
+ }
48
+
49
+ }
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Notifications.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the Paymentmodule of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script usefull a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Novalnet AG
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Novalnet_Payment_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Notification_Window
28
+ {
29
+ /**
30
+ * Get header text
31
+ *
32
+ * @param none
33
+ * @return string
34
+ */
35
+ public function getHeaderText()
36
+ {
37
+ return 'NOVALNET';
38
+ }
39
+
40
+ /**
41
+ * Show notifications
42
+ *
43
+ * @param none
44
+ * @return string
45
+ */
46
+ public function canShow()
47
+ {
48
+ $message = $this->getNoticeMessageText();
49
+ $session = Mage::getSingleton('core/session');
50
+ $result = (!$session->getNnVersionNotice() && !empty($message)) ? $message: '';
51
+ $session->setNnVersionNotice(true);
52
+ return $result;
53
+ }
54
+
55
+ /**
56
+ * Get latest Novalnet version infomation
57
+ *
58
+ * @param none
59
+ * @return string
60
+ */
61
+ public function getNoticeMessageText()
62
+ {
63
+ $message = '';
64
+ if (Mage::getStoreConfig('novalnet_global/novalnet/latest_updates_notify')) {
65
+ // Get Novalnet version information from magento connect
66
+ $package = 'Novalnet';
67
+ $channelUri = 'connect20.magentocommerce.com/community';
68
+ $protocol = $this->getProtocol();
69
+
70
+ // Rest API
71
+ $rest = new Mage_Connect_Rest();
72
+ $rest->setChannel($channelUri);
73
+ $rest->__construct($protocol);
74
+ $releases = $rest->getReleases($package);
75
+
76
+ // Get latest Novalnet version (Magento Connect)
77
+ $novalnetVersion = $releases[0]['v'];
78
+ $stability = $releases[0]['s'];
79
+
80
+ // Get installed Novalnet version information
81
+ $installedVersion = (string) Mage::getConfig()->getNode('modules/Novalnet_Payment/version');
82
+
83
+ // Notification message
84
+ if (version_compare($installedVersion, $novalnetVersion, '<')) {
85
+ $message = $this->__(
86
+ 'Novalnet version %s (%s) is now available for download and upgrade.', $novalnetVersion, $stability
87
+ );
88
+ }
89
+ }
90
+ return $message;
91
+ }
92
+
93
+ /**
94
+ * Get notice message redirect url
95
+ *
96
+ * @param none
97
+ * @return string
98
+ */
99
+ public function getNoticeMessageUrl()
100
+ {
101
+ $protocol = $this->getProtocol();
102
+ return $this->escapeUrl($protocol.'://www.magentocommerce.com/magento-connect/novalnet-payment-extension.html');
103
+ }
104
+
105
+ /**
106
+ * Get protocol
107
+ *
108
+ * @param none
109
+ * @return string
110
+ */
111
+ public function getProtocol()
112
+ {
113
+ return Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http';
114
+ }
115
+
116
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile.php CHANGED
@@ -18,10 +18,10 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Recurring_Profile extends Mage_Adminhtml_Block_Widget_Grid_Container
27
  {
@@ -31,7 +31,6 @@ class Novalnet_Payment_Block_Adminhtml_Recurring_Profile extends Mage_Adminhtml_
31
 
32
  /**
33
  * Set header text and remove "addnew" button
34
- *
35
  */
36
  public function __construct()
37
  {
@@ -39,4 +38,5 @@ class Novalnet_Payment_Block_Adminhtml_Recurring_Profile extends Mage_Adminhtml_
39
  parent::__construct();
40
  $this->_removeButton('add');
41
  }
 
42
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Recurring_Profile extends Mage_Adminhtml_Block_Widget_Grid_Container
27
  {
31
 
32
  /**
33
  * Set header text and remove "addnew" button
 
34
  */
35
  public function __construct()
36
  {
38
  parent::__construct();
39
  $this->_removeButton('add');
40
  }
41
+
42
  }
app/code/community/Novalnet/Payment/Block/Adminhtml/Recurring/Profile/Grid.php CHANGED
@@ -18,16 +18,16 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Recurring_Profile_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
  {
 
28
  /**
29
  * Set ajax/session parameters
30
- *
31
  */
32
  public function __construct()
33
  {
@@ -40,15 +40,18 @@ class Novalnet_Payment_Block_Adminhtml_Recurring_Profile_Grid extends Mage_Admin
40
  /**
41
  * Prepare grid collection object
42
  *
 
43
  * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_Grid
44
  */
45
  protected function _prepareCollection()
46
  {
47
  $collection = Mage::getResourceModel('sales/recurring_profile_collection')
48
- ->addFieldToFilter('method_code', array(
49
- 'like' => '%novalnet%',
50
- ));
51
- $collection->setOrder('profile_id', 'desc');
 
 
52
  $this->setCollection($collection);
53
 
54
  if (!$this->getParam($this->getVarNameSort())) {
@@ -60,71 +63,86 @@ class Novalnet_Payment_Block_Adminhtml_Recurring_Profile_Grid extends Mage_Admin
60
  /**
61
  * Prepare grid columns
62
  *
 
63
  * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_Grid
64
  */
65
  protected function _prepareColumns()
66
  {
67
  $profile = Mage::getModel('sales/recurring_profile');
68
 
69
- $this->addColumn('reference_id', array(
 
70
  'header' => $profile->getFieldLabel('reference_id'),
71
  'index' => 'reference_id',
72
  'html_decorators' => array('nobr'),
73
  'width' => 1,
74
- ));
 
75
 
76
  if (!Mage::app()->isSingleStoreMode()) {
77
- $this->addColumn('store_id', array(
78
- 'header' => Mage::helper('adminhtml')->__('Store'),
79
- 'index' => 'store_id',
80
- 'type' => 'store',
 
81
  'store_view' => true,
82
  'display_deleted' => true,
83
- ));
 
84
  }
85
 
86
- $this->addColumn('state', array(
 
87
  'header' => $profile->getFieldLabel('state'),
88
  'index' => 'state',
89
- 'type' => 'options',
90
  'options' => $profile->getAllStates(),
91
  'html_decorators' => array('nobr'),
92
  'width' => 1,
93
- ));
 
94
 
95
- $this->addColumn('created_at', array(
 
96
  'header' => $profile->getFieldLabel('created_at'),
97
  'index' => 'created_at',
98
  'type' => 'datetime',
99
  'html_decorators' => array('nobr'),
100
  'width' => 1,
101
- ));
 
102
 
103
- $this->addColumn('updated_at', array(
 
104
  'header' => $profile->getFieldLabel('updated_at'),
105
  'index' => 'updated_at',
106
  'type' => 'datetime',
107
  'html_decorators' => array('nobr'),
108
  'width' => 1,
109
- ));
 
110
 
111
  $methods = array();
112
  foreach (Mage::helper('payment')->getRecurringProfileMethods() as $method) {
113
- if(preg_match("/novalnet/i",$method->getCode())){
114
- $methods[$method->getCode()] = $method->getTitle();
115
  }
116
  }
117
- $this->addColumn('method_code', array(
118
- 'header' => $profile->getFieldLabel('method_code'),
119
- 'index' => 'method_code',
120
- 'type' => 'options',
 
121
  'options' => $methods,
122
- ));
 
123
 
124
- $this->addColumn('schedule_description', array(
 
125
  'header' => $profile->getFieldLabel('schedule_description'),
126
  'index' => 'schedule_description',
127
- ));
 
128
 
129
  return parent::_prepareColumns();
130
  }
@@ -132,7 +150,7 @@ class Novalnet_Payment_Block_Adminhtml_Recurring_Profile_Grid extends Mage_Admin
132
  /**
133
  * Get row url for js event handlers
134
  *
135
- * @param Varien_Object
136
  * @return string
137
  */
138
  public function getRowUrl($row)
@@ -143,10 +161,12 @@ class Novalnet_Payment_Block_Adminhtml_Recurring_Profile_Grid extends Mage_Admin
143
  /**
144
  * Get grid url
145
  *
 
146
  * @return string
147
  */
148
  public function getGridUrl()
149
  {
150
- return $this->getUrl('*/*/grid', array('_current'=>true));
151
  }
 
152
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Recurring_Profile_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
  {
28
+
29
  /**
30
  * Set ajax/session parameters
 
31
  */
32
  public function __construct()
33
  {
40
  /**
41
  * Prepare grid collection object
42
  *
43
+ * @param none
44
  * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_Grid
45
  */
46
  protected function _prepareCollection()
47
  {
48
  $collection = Mage::getResourceModel('sales/recurring_profile_collection')
49
+ ->addFieldToFilter(
50
+ 'method_code', array(
51
+ 'like' => '%novalnet%',
52
+ )
53
+ );
54
+ $collection->setOrder('profile_id', 'desc');
55
  $this->setCollection($collection);
56
 
57
  if (!$this->getParam($this->getVarNameSort())) {
63
  /**
64
  * Prepare grid columns
65
  *
66
+ * @param none
67
  * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_Grid
68
  */
69
  protected function _prepareColumns()
70
  {
71
  $profile = Mage::getModel('sales/recurring_profile');
72
 
73
+ $this->addColumn(
74
+ 'reference_id', array(
75
  'header' => $profile->getFieldLabel('reference_id'),
76
  'index' => 'reference_id',
77
  'html_decorators' => array('nobr'),
78
  'width' => 1,
79
+ )
80
+ );
81
 
82
  if (!Mage::app()->isSingleStoreMode()) {
83
+ $this->addColumn(
84
+ 'store_id', array(
85
+ 'header' => Mage::helper('adminhtml')->__('Store'),
86
+ 'index' => 'store_id',
87
+ 'type' => 'store',
88
  'store_view' => true,
89
  'display_deleted' => true,
90
+ )
91
+ );
92
  }
93
 
94
+ $this->addColumn(
95
+ 'state', array(
96
  'header' => $profile->getFieldLabel('state'),
97
  'index' => 'state',
98
+ 'type' => 'options',
99
  'options' => $profile->getAllStates(),
100
  'html_decorators' => array('nobr'),
101
  'width' => 1,
102
+ )
103
+ );
104
 
105
+ $this->addColumn(
106
+ 'created_at', array(
107
  'header' => $profile->getFieldLabel('created_at'),
108
  'index' => 'created_at',
109
  'type' => 'datetime',
110
  'html_decorators' => array('nobr'),
111
  'width' => 1,
112
+ )
113
+ );
114
 
115
+ $this->addColumn(
116
+ 'updated_at', array(
117
  'header' => $profile->getFieldLabel('updated_at'),
118
  'index' => 'updated_at',
119
  'type' => 'datetime',
120
  'html_decorators' => array('nobr'),
121
  'width' => 1,
122
+ )
123
+ );
124
 
125
  $methods = array();
126
  foreach (Mage::helper('payment')->getRecurringProfileMethods() as $method) {
127
+ if (preg_match("/novalnet/i", $method->getCode())) {
128
+ $methods[$method->getCode()] = $method->getTitle();
129
  }
130
  }
131
+ $this->addColumn(
132
+ 'method_code', array(
133
+ 'header' => $profile->getFieldLabel('method_code'),
134
+ 'index' => 'method_code',
135
+ 'type' => 'options',
136
  'options' => $methods,
137
+ )
138
+ );
139
 
140
+ $this->addColumn(
141
+ 'schedule_description', array(
142
  'header' => $profile->getFieldLabel('schedule_description'),
143
  'index' => 'schedule_description',
144
+ )
145
+ );
146
 
147
  return parent::_prepareColumns();
148
  }
150
  /**
151
  * Get row url for js event handlers
152
  *
153
+ * @param mixed $row
154
  * @return string
155
  */
156
  public function getRowUrl($row)
161
  /**
162
  * Get grid url
163
  *
164
+ * @param none
165
  * @return string
166
  */
167
  public function getGridUrl()
168
  {
169
+ return $this->getUrl('*/*/grid', array('_current' => true));
170
  }
171
+
172
  }
app/code/community/Novalnet/Payment/Block/{Sales/Adminhtml → Adminhtml}/Recurring/Profile/View.php RENAMED
@@ -18,71 +18,90 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Block_Sales_Adminhtml_Recurring_Profile_View extends Mage_Sales_Block_Adminhtml_Recurring_Profile_View
27
  {
28
 
29
  /**
30
  * Prepare layout for recurring profile
31
  *
 
32
  * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_View
33
  */
34
  protected function _prepareLayout()
35
  {
36
  $profile = Mage::registry('current_recurring_profile');
37
 
38
- if (!preg_match("/novalnet/i", $profile->getMethodCode()))
39
- return parent::_prepareLayout();
 
40
 
41
- $this->_addButton('back', array(
 
42
  'label' => Mage::helper('adminhtml')->__('Back'),
43
  'onclick' => "setLocation('{$this->getUrl('*/*/')}')",
44
  'class' => 'back'
45
- ));
 
 
 
46
 
47
  $comfirmationMessage = Mage::helper('sales')->__('Are you sure you want to do this?');
48
 
49
  // cancel
50
- if ($profile->canCancel()) {
51
- $url = $this->getUrl('*/*/updateState', array('profile' => $profile->getId(),
52
- 'action' => 'cancel'));
53
- $this->_addButton('cancel', array(
 
 
 
54
  'label' => Mage::helper('sales')->__('Cancel'),
55
- 'onclick' => "cancelviewstatus('recurring_buttons_view','recurring_cancel_button_view')",
56
  'class' => 'delete',
57
- ));
 
58
  }
59
  // suspend
60
  $state = $profile->getState();
61
- if ($profile->canSuspend() && $state != 'pending') {
62
- $url = $this->getUrl('*/*/updateState', array('profile' => $profile->getId(),
63
- 'action' => 'suspend'));
64
- $this->_addButton('suspend', array(
 
 
 
65
  'label' => Mage::helper('sales')->__('Suspend'),
66
  'onclick' => "confirmSetLocation('{$comfirmationMessage}', '{$url}')",
67
  'class' => 'delete',
68
- ));
 
69
  }
70
 
71
  // activate
72
  if ($profile->canActivate() && $state != 'pending') {
73
- $url = $this->getUrl('*/*/updateState', array('profile' => $profile->getId(),
74
- 'action' => 'activate'));
75
- $this->_addButton('activate', array(
 
 
 
76
  'label' => Mage::helper('sales')->__('Activate'),
77
  'onclick' => "confirmSetLocation('{$comfirmationMessage}', '{$url}')",
78
  'class' => 'add',
79
- ));
 
80
  }
81
  }
82
 
83
  /**
84
  * Set title and a hack for tabs container
85
  *
 
86
  * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_View
87
  */
88
  protected function _beforeToHtml()
@@ -96,6 +115,7 @@ class Novalnet_Payment_Block_Sales_Adminhtml_Recurring_Profile_View extends Mage
96
  /**
97
  * Get cancel reasons for recurring cancel
98
  *
 
99
  * @return mixed
100
  */
101
  protected function _getCancelButtonWithReasons()
@@ -117,25 +137,46 @@ class Novalnet_Payment_Block_Sales_Adminhtml_Recurring_Profile_View extends Mage
117
  $lang .= $helper->__("Other reasons");
118
  $cancelview = "";
119
  if ($profile->canCancel()) {
120
- $cancelReason = $helper->__("Please select the reason of subscription cancellation");
121
  $select = Mage::app()->getLayout()->createBlock('core/html_select')
122
  ->setName("cancel_reason")
123
- ->setId("reason-subscribe")
124
  ->setOptions(explode(",", $lang));
125
 
126
  $cancelview .= $select->getHtml();
127
 
128
- $url = $this->getUrl('*/*/updateState', array('profile' => $profile->getId(),
129
- 'action' => 'cancel'));
130
- $this->setChild('cancel', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
 
 
 
 
131
  'label' => Mage::helper('sales')->__('Cancel'),
132
- 'onclick' => "cancel_action('{$comfirmationMessage}', '{$url}', '{$cancelReason}')",
133
  'class' => 'delete',
134
- ))
 
135
  );
136
  $cancelview .= $this->getChildHtml('cancel');
137
  }
138
  return $cancelview;
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Block_Adminhtml_Recurring_Profile_View extends Mage_Sales_Block_Adminhtml_Recurring_Profile_View
27
  {
28
 
29
  /**
30
  * Prepare layout for recurring profile
31
  *
32
+ * @param none
33
  * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_View
34
  */
35
  protected function _prepareLayout()
36
  {
37
  $profile = Mage::registry('current_recurring_profile');
38
 
39
+ if (!preg_match("/novalnet/i", $profile->getMethodCode())) {
40
+ return parent::_prepareLayout();
41
+ }
42
 
43
+ $this->_addButton(
44
+ 'back', array(
45
  'label' => Mage::helper('adminhtml')->__('Back'),
46
  'onclick' => "setLocation('{$this->getUrl('*/*/')}')",
47
  'class' => 'back'
48
+ )
49
+ );
50
+ // Get transaction information
51
+ $transactionStatus = $this->getTransactionStatus($profile);
52
 
53
  $comfirmationMessage = Mage::helper('sales')->__('Are you sure you want to do this?');
54
 
55
  // cancel
56
+ if ($profile->canCancel() && $transactionStatus->getAmount()) {
57
+ $url = $this->getUrl(
58
+ '*/*/updateState', array('profile' => $profile->getId(),
59
+ 'action' => 'cancel')
60
+ );
61
+ $this->_addButton(
62
+ 'cancel', array(
63
  'label' => Mage::helper('sales')->__('Cancel'),
64
+ 'onclick' => "cancelButtonViewStatus('recurring_buttons_view','recurring_cancel_button_view')",
65
  'class' => 'delete',
66
+ )
67
+ );
68
  }
69
  // suspend
70
  $state = $profile->getState();
71
+ if ($profile->canSuspend() && $state != 'pending' && $transactionStatus->getAmount()) {
72
+ $url = $this->getUrl(
73
+ '*/*/updateState', array('profile' => $profile->getId(),
74
+ 'action' => 'suspend')
75
+ );
76
+ $this->_addButton(
77
+ 'suspend', array(
78
  'label' => Mage::helper('sales')->__('Suspend'),
79
  'onclick' => "confirmSetLocation('{$comfirmationMessage}', '{$url}')",
80
  'class' => 'delete',
81
+ )
82
+ );
83
  }
84
 
85
  // activate
86
  if ($profile->canActivate() && $state != 'pending') {
87
+ $url = $this->getUrl(
88
+ '*/*/updateState', array('profile' => $profile->getId(),
89
+ 'action' => 'activate')
90
+ );
91
+ $this->_addButton(
92
+ 'activate', array(
93
  'label' => Mage::helper('sales')->__('Activate'),
94
  'onclick' => "confirmSetLocation('{$comfirmationMessage}', '{$url}')",
95
  'class' => 'add',
96
+ )
97
+ );
98
  }
99
  }
100
 
101
  /**
102
  * Set title and a hack for tabs container
103
  *
104
+ * @param none
105
  * @return Mage_Sales_Block_Adminhtml_Recurring_Profile_View
106
  */
107
  protected function _beforeToHtml()
115
  /**
116
  * Get cancel reasons for recurring cancel
117
  *
118
+ * @param none
119
  * @return mixed
120
  */
121
  protected function _getCancelButtonWithReasons()
137
  $lang .= $helper->__("Other reasons");
138
  $cancelview = "";
139
  if ($profile->canCancel()) {
140
+ $cancelReason = $helper->__("Please select the reason of subscription cancellation");
141
  $select = Mage::app()->getLayout()->createBlock('core/html_select')
142
  ->setName("cancel_reason")
143
+ ->setId("reason-unsubscribe")
144
  ->setOptions(explode(",", $lang));
145
 
146
  $cancelview .= $select->getHtml();
147
 
148
+ $url = $this->getUrl(
149
+ '*/*/updateState', array('profile' => $profile->getId(),
150
+ 'action' => 'cancel')
151
+ );
152
+ $this->setChild(
153
+ 'cancel', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(
154
+ array(
155
  'label' => Mage::helper('sales')->__('Cancel'),
156
+ 'onclick' => "subscriptionCancel('{$comfirmationMessage}', '{$url}', '{$cancelReason}')",
157
  'class' => 'delete',
158
+ )
159
+ )
160
  );
161
  $cancelview .= $this->getChildHtml('cancel');
162
  }
163
  return $cancelview;
164
  }
165
 
166
+ /**
167
+ * Get transaction information
168
+ *
169
+ * @param Varien_Object $profile
170
+ * @return Varien_Object
171
+ */
172
+ public function getTransactionStatus($profile)
173
+ {
174
+ $transactionId = $profile->getReferenceId();
175
+ // load transaction status information
176
+ $helper = Mage::helper('novalnet_payment'); // Novalnet payment helper
177
+ $transactionStatus = $helper->getModel('Mysql4_TransactionStatus')
178
+ ->loadByAttribute('transaction_no', $transactionId);
179
+ return $transactionStatus;
180
+ }
181
+
182
  }
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order.php CHANGED
@@ -1,38 +1,40 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order extends Novalnet_Payment_Block_Adminhtml_Widget_Grid_Container
27
- {
28
-
29
- public function __construct()
30
- {
31
- parent::__construct();
32
- $this->_blockGroup = 'novalnet_payment';
33
- $this->_controller = 'adminhtml_sales_order';
34
- $this->_headerText = Mage::helper('novalnet_payment')->__('Orders');
35
- $this->removeButton('add');
36
- }
37
-
38
- }
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Sales_Order extends Mage_Adminhtml_Block_Sales_Order
27
+ {
28
+ /**
29
+ * Novalnet sales orders
30
+ */
31
+ public function __construct()
32
+ {
33
+ parent::__construct();
34
+ $this->_blockGroup = 'novalnet_payment';
35
+ $this->_controller = 'adminhtml_sales_order';
36
+ $this->_headerText = Mage::helper('novalnet_payment')->__('Orders');
37
+ $this->removeButton('add');
38
+ }
39
+
40
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Creditmemo/Totals.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_Creditmemo_Totals extends Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
27
- {
28
-
29
- /**
30
- * Initialize creditmemo totals array
31
- *
32
- * @return Mage_Sales_Block_Order_Totals
33
- */
34
- protected function _initTotals()
35
- {
36
- parent::_initTotals();
37
- $helper = Mage::helper('novalnet_payment');
38
- $amountchangedvalue = $helper->getAmountCollection($this->getOrder()->getId(), 1, NULL);
39
- if ($amountchangedvalue) {
40
- if (preg_match("/\bview\b/i", Mage::helper('core/url')->getCurrentUrl())) {
41
- $this->_totals['refund_amount_changed'] = new Varien_Object(array(
42
- 'code' => 'refund_amount_changed',
43
- 'strong' => true,
44
- 'value' => $this->getSource()->getGrandTotal(),
45
- 'base_value' => $this->getSource()->getBaseGrandTotal(),
46
- 'label' => Mage::helper('sales')->__('Novalnet refunded Amount'),
47
- 'area' => 'footer'
48
- ));
49
- }
50
-
51
- $this->_totals['amount_changed'] = new Varien_Object(array(
52
- 'code' => 'amount_changed',
53
- 'strong' => true,
54
- 'value' => $amountchangedvalue,
55
- 'base_value' => $amountchangedvalue,
56
- 'label' => Mage::helper('sales')->__('Novalnet Transaction Amount'),
57
- 'area' => 'footer'
58
- ));
59
- }
60
- return $this;
61
- }
62
-
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Grid.php CHANGED
@@ -18,16 +18,21 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
  {
28
 
29
- var $novalnetPayments = array();
30
 
 
 
 
 
 
31
  public function __construct()
32
  {
33
  parent::__construct();
@@ -38,18 +43,27 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
38
  $this->setSaveParametersInSession(true);
39
 
40
  /* Novalnet */
41
- $novalPaymentMethods = array_keys(Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('novalnetPaymentKey'));
 
42
 
43
- foreach($novalPaymentMethods as $paymentCode) {
44
  $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title');
45
  $this->novalnetPayments[$paymentCode] = $paymentTitle;
46
  }
47
  /* Novalnet */
 
 
 
 
 
 
 
48
  }
49
 
50
  /**
51
  * Retrieve collection class
52
  *
 
53
  * @return string
54
  */
55
  protected function _getCollectionClass()
@@ -60,17 +74,29 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
60
  /**
61
  * Prepare order Collection for novalnet payments
62
  *
 
63
  * @return Mage_Adminhtml_Block_Widget_Grid
64
  */
65
  protected function _prepareCollection()
66
  {
67
  $collection = Mage::getResourceModel($this->_getCollectionClass());
 
 
 
 
 
 
 
 
 
68
  if (version_compare(Mage::helper('novalnet_payment')->getMagentoVersion(), '1.6.0.0', '>')) {
69
  $collection->join(array('payment' => 'sales/order_payment'), 'main_table.entity_id = parent_id', 'method')
70
- ->getSelect()->where("`payment`.`method` like '%novalnet%'");
71
  } else {
72
  $flatOrderPayment = $collection->getTable('sales/order_payment');
73
- $collection->getSelect()->join(array('payment' => $flatOrderPayment), 'main_table.entity_id = payment.parent_id', 'method')->where("`payment`.`method` like '%novalnet%'");
 
 
74
  }
75
 
76
  $this->setCollection($collection);
@@ -80,92 +106,130 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
80
  /**
81
  * prepare column for order grid
82
  *
 
83
  * @return Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid
84
  */
85
  protected function _prepareColumns()
86
  {
87
- $this->addColumn('real_order_id', array(
 
88
  'header' => Mage::helper('sales')->__('Order #'),
89
  'width' => '80px',
90
  'type' => 'text',
91
  'index' => 'increment_id',
92
- ));
 
 
93
 
94
  if (!Mage::app()->isSingleStoreMode()) {
95
- $this->addColumn('store_id', array(
 
96
  'header' => Mage::helper('sales')->__('Purchased From (Store)'),
97
  'index' => 'store_id',
98
  'type' => 'store',
99
  'store_view' => true,
100
  'display_deleted' => true,
101
- ));
 
102
  }
103
 
104
- $this->addColumn('created_at', array(
 
105
  'header' => Mage::helper('sales')->__('Purchased On'),
106
  'index' => 'created_at',
107
  'type' => 'datetime',
108
  'width' => '100px',
109
- ));
 
 
110
 
111
- $this->addColumn('billing_name', array(
 
112
  'header' => Mage::helper('sales')->__('Bill to Name'),
113
  'index' => 'billing_name',
114
- ));
 
115
 
116
- $this->addColumn('shipping_name', array(
 
117
  'header' => Mage::helper('sales')->__('Ship to Name'),
118
  'index' => 'shipping_name',
119
- ));
120
-
121
- $this->addColumn('base_grand_total', array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  'header' => Mage::helper('sales')->__('G.T. (Base)'),
123
  'index' => 'base_grand_total',
124
  'type' => 'currency',
125
  'currency' => 'base_currency_code',
126
- ));
 
 
127
 
128
- $this->addColumn('grand_total', array(
 
129
  'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
130
  'index' => 'grand_total',
131
  'type' => 'currency',
132
  'currency' => 'order_currency_code',
133
- ));
 
 
134
 
135
- $this->addColumn('status', array(
 
136
  'header' => Mage::helper('sales')->__('Status'),
137
  'index' => 'status',
138
  'type' => 'options',
139
  'width' => '70px',
140
  'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
141
- ));
 
 
142
 
143
- $this->addColumn('novalnet_method', array(
 
144
  'header' => Mage::helper('sales')->__('Novalnet Method'),
145
  'index' => 'method',
146
  'type' => 'options',
147
  'width' => '70px',
148
  'options' => $this->novalnetPayments,
149
- ), 'method');
 
150
 
151
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
152
- $this->addColumn('action', array(
 
153
  'header' => Mage::helper('sales')->__('Action'),
154
- 'width' => '50px',
155
  'type' => 'action',
156
  'getter' => 'getId',
157
- 'actions' => array(
158
- array(
159
- 'caption' => Mage::helper('sales')->__('View'),
160
- 'url' => array('base' => 'adminhtml/sales_order/view'),
161
- 'field' => 'order_id'
162
- )
163
- ),
164
  'filter' => false,
165
  'sortable' => false,
166
  'index' => 'stores',
167
  'is_system' => true,
168
- ));
 
169
  }
170
 
171
  $this->setDefaultSort('created_at');
@@ -180,6 +244,7 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
180
  /**
181
  * prepare column for massaction order grid
182
  *
 
183
  * @return Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid
184
  */
185
  protected function _prepareMassaction()
@@ -189,50 +254,74 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
189
  $this->getMassactionBlock()->setUseSelectAll(false);
190
 
191
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
192
- $this->getMassactionBlock()->addItem('cancel_order', array(
 
193
  'label' => Mage::helper('sales')->__('Cancel'),
194
  'url' => $this->getUrl('*/*/massCancel'),
195
- ));
 
196
  }
197
 
198
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
199
- $this->getMassactionBlock()->addItem('hold_order', array(
 
200
  'label' => Mage::helper('sales')->__('Hold'),
201
  'url' => $this->getUrl('*/*/massHold'),
202
- ));
 
203
  }
204
 
205
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
206
- $this->getMassactionBlock()->addItem('unhold_order', array(
 
207
  'label' => Mage::helper('sales')->__('Unhold'),
208
  'url' => $this->getUrl('*/*/massUnhold'),
209
- ));
 
210
  }
211
 
212
- $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
 
213
  'label' => Mage::helper('sales')->__('Print Invoices'),
214
  'url' => $this->getUrl('*/*/pdfinvoices'),
215
- ));
 
216
 
217
- $this->getMassactionBlock()->addItem('pdfshipments_order', array(
 
218
  'label' => Mage::helper('sales')->__('Print Packingslips'),
219
  'url' => $this->getUrl('*/*/pdfshipments'),
220
- ));
 
221
 
222
- $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
 
223
  'label' => Mage::helper('sales')->__('Print Credit Memos'),
224
  'url' => $this->getUrl('*/*/pdfcreditmemos'),
225
- ));
 
226
 
227
- $this->getMassactionBlock()->addItem('pdfdocs_order', array(
 
228
  'label' => Mage::helper('sales')->__('Print All'),
229
  'url' => $this->getUrl('*/*/pdfdocs'),
230
- ));
 
231
 
232
- $this->getMassactionBlock()->addItem('print_shipping_label', array(
 
233
  'label' => Mage::helper('sales')->__('Print Shipping Labels'),
234
  'url' => $this->getUrl('adminhtml/sales_order_shipment/massPrintShippingLabel'),
235
- ));
 
 
 
 
 
 
 
 
 
236
 
237
  return $this;
238
  }
@@ -240,6 +329,7 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
240
  /**
241
  * Return row url
242
  *
 
243
  * @return string
244
  */
245
  public function getRowUrl($row)
@@ -250,6 +340,7 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
250
  /**
251
  * Return grid url
252
  *
 
253
  * @return string
254
  */
255
  public function getGridUrl()
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
  {
28
 
29
+ public $novalnetPayments = array();
30
 
31
+ public $groups = array();
32
+
33
+ /**
34
+ * Novalnet sales order grid
35
+ */
36
  public function __construct()
37
  {
38
  parent::__construct();
43
  $this->setSaveParametersInSession(true);
44
 
45
  /* Novalnet */
46
+ $novalnetPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('paymentMethods');
47
+ $novalPaymentMethods = array_keys($novalnetPayment);
48
 
49
+ foreach ($novalPaymentMethods as $paymentCode) {
50
  $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title');
51
  $this->novalnetPayments[$paymentCode] = $paymentTitle;
52
  }
53
  /* Novalnet */
54
+
55
+ /* Customer groups */
56
+ $this->groups = Mage::getResourceModel('customer/group_collection')
57
+ ->addFieldToFilter('customer_group_id', array('gt'=> 0))
58
+ ->load()
59
+ ->toOptionHash();
60
+ /* Customer groups */
61
  }
62
 
63
  /**
64
  * Retrieve collection class
65
  *
66
+ * @param none
67
  * @return string
68
  */
69
  protected function _getCollectionClass()
74
  /**
75
  * Prepare order Collection for novalnet payments
76
  *
77
+ * @param none
78
  * @return Mage_Adminhtml_Block_Widget_Grid
79
  */
80
  protected function _prepareCollection()
81
  {
82
  $collection = Mage::getResourceModel($this->_getCollectionClass());
83
+ // For customer email filter
84
+ $collection->getSelect()->joinLeft(
85
+ array('email'=>'sales_flat_order'), 'email.entity_id=main_table.entity_id', array('email.customer_email')
86
+ );
87
+ $collection->getSelect()->joinLeft(
88
+ array('cgroup'=>'sales_flat_order'), 'cgroup.entity_id=main_table.entity_id',
89
+ array('cgroup.customer_group_id')
90
+ );
91
+
92
  if (version_compare(Mage::helper('novalnet_payment')->getMagentoVersion(), '1.6.0.0', '>')) {
93
  $collection->join(array('payment' => 'sales/order_payment'), 'main_table.entity_id = parent_id', 'method')
94
+ ->getSelect()->where("`payment`.`method` like '%novalnet%'");
95
  } else {
96
  $flatOrderPayment = $collection->getTable('sales/order_payment');
97
+ $collection->getSelect()->join(
98
+ array('payment' => $flatOrderPayment), 'main_table.entity_id = payment.parent_id', 'method'
99
+ )->where("`payment`.`method` like '%novalnet%'");
100
  }
101
 
102
  $this->setCollection($collection);
106
  /**
107
  * prepare column for order grid
108
  *
109
+ * @param none
110
  * @return Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid
111
  */
112
  protected function _prepareColumns()
113
  {
114
+ $this->addColumn(
115
+ 'real_order_id', array(
116
  'header' => Mage::helper('sales')->__('Order #'),
117
  'width' => '80px',
118
  'type' => 'text',
119
  'index' => 'increment_id',
120
+ 'filter_index' => 'main_table.increment_id'
121
+ )
122
+ );
123
 
124
  if (!Mage::app()->isSingleStoreMode()) {
125
+ $this->addColumn(
126
+ 'store_id', array(
127
  'header' => Mage::helper('sales')->__('Purchased From (Store)'),
128
  'index' => 'store_id',
129
  'type' => 'store',
130
  'store_view' => true,
131
  'display_deleted' => true,
132
+ )
133
+ );
134
  }
135
 
136
+ $this->addColumn(
137
+ 'created_at', array(
138
  'header' => Mage::helper('sales')->__('Purchased On'),
139
  'index' => 'created_at',
140
  'type' => 'datetime',
141
  'width' => '100px',
142
+ 'filter_index' => 'main_table.created_at'
143
+ )
144
+ );
145
 
146
+ $this->addColumn(
147
+ 'billing_name', array(
148
  'header' => Mage::helper('sales')->__('Bill to Name'),
149
  'index' => 'billing_name',
150
+ )
151
+ );
152
 
153
+ $this->addColumn(
154
+ 'shipping_name', array(
155
  'header' => Mage::helper('sales')->__('Ship to Name'),
156
  'index' => 'shipping_name',
157
+ )
158
+ );
159
+
160
+ $this->addColumn(
161
+ 'customer_email', array(
162
+ 'header' => Mage::helper('sales')->__('Email'),
163
+ 'index' => 'customer_email',
164
+ 'filter_index' => 'email.customer_email'
165
+ )
166
+ );
167
+
168
+ $this->addColumn(
169
+ 'customer_group_id', array(
170
+ 'header' => Mage::helper('sales')->__('Group'),
171
+ 'index' => 'customer_group_id',
172
+ 'filter_index' => 'cgroup.customer_group_id',
173
+ 'type' => 'options',
174
+ 'options' => $this->groups,
175
+ )
176
+ );
177
+
178
+ $this->addColumn(
179
+ 'base_grand_total', array(
180
  'header' => Mage::helper('sales')->__('G.T. (Base)'),
181
  'index' => 'base_grand_total',
182
  'type' => 'currency',
183
  'currency' => 'base_currency_code',
184
+ 'filter_index' => 'main_table.base_grand_total'
185
+ )
186
+ );
187
 
188
+ $this->addColumn(
189
+ 'grand_total', array(
190
  'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
191
  'index' => 'grand_total',
192
  'type' => 'currency',
193
  'currency' => 'order_currency_code',
194
+ 'filter_index' => 'main_table.grand_total'
195
+ )
196
+ );
197
 
198
+ $this->addColumn(
199
+ 'status', array(
200
  'header' => Mage::helper('sales')->__('Status'),
201
  'index' => 'status',
202
  'type' => 'options',
203
  'width' => '70px',
204
  'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
205
+ 'filter_index' => 'main_table.status'
206
+ )
207
+ );
208
 
209
+ $this->addColumn(
210
+ 'novalnet_method', array(
211
  'header' => Mage::helper('sales')->__('Novalnet Method'),
212
  'index' => 'method',
213
  'type' => 'options',
214
  'width' => '70px',
215
  'options' => $this->novalnetPayments,
216
+ ), 'method'
217
+ );
218
 
219
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
220
+ $this->addColumn(
221
+ 'action', array(
222
  'header' => Mage::helper('sales')->__('Action'),
223
+ 'width' => '80px',
224
  'type' => 'action',
225
  'getter' => 'getId',
226
+ 'renderer' => 'novalnet_payment/adminhtml_sales_order_render_delete',
 
 
 
 
 
 
227
  'filter' => false,
228
  'sortable' => false,
229
  'index' => 'stores',
230
  'is_system' => true,
231
+ )
232
+ );
233
  }
234
 
235
  $this->setDefaultSort('created_at');
244
  /**
245
  * prepare column for massaction order grid
246
  *
247
+ * @param none
248
  * @return Novalnet_Payment_Block_Adminhtml_Sales_Order_Grid
249
  */
250
  protected function _prepareMassaction()
254
  $this->getMassactionBlock()->setUseSelectAll(false);
255
 
256
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
257
+ $this->getMassactionBlock()->addItem(
258
+ 'cancel_order', array(
259
  'label' => Mage::helper('sales')->__('Cancel'),
260
  'url' => $this->getUrl('*/*/massCancel'),
261
+ )
262
+ );
263
  }
264
 
265
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
266
+ $this->getMassactionBlock()->addItem(
267
+ 'hold_order', array(
268
  'label' => Mage::helper('sales')->__('Hold'),
269
  'url' => $this->getUrl('*/*/massHold'),
270
+ )
271
+ );
272
  }
273
 
274
  if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
275
+ $this->getMassactionBlock()->addItem(
276
+ 'unhold_order', array(
277
  'label' => Mage::helper('sales')->__('Unhold'),
278
  'url' => $this->getUrl('*/*/massUnhold'),
279
+ )
280
+ );
281
  }
282
 
283
+ $this->getMassactionBlock()->addItem(
284
+ 'pdfinvoices_order', array(
285
  'label' => Mage::helper('sales')->__('Print Invoices'),
286
  'url' => $this->getUrl('*/*/pdfinvoices'),
287
+ )
288
+ );
289
 
290
+ $this->getMassactionBlock()->addItem(
291
+ 'pdfshipments_order', array(
292
  'label' => Mage::helper('sales')->__('Print Packingslips'),
293
  'url' => $this->getUrl('*/*/pdfshipments'),
294
+ )
295
+ );
296
 
297
+ $this->getMassactionBlock()->addItem(
298
+ 'pdfcreditmemos_order', array(
299
  'label' => Mage::helper('sales')->__('Print Credit Memos'),
300
  'url' => $this->getUrl('*/*/pdfcreditmemos'),
301
+ )
302
+ );
303
 
304
+ $this->getMassactionBlock()->addItem(
305
+ 'pdfdocs_order', array(
306
  'label' => Mage::helper('sales')->__('Print All'),
307
  'url' => $this->getUrl('*/*/pdfdocs'),
308
+ )
309
+ );
310
 
311
+ $this->getMassactionBlock()->addItem(
312
+ 'print_shipping_label', array(
313
  'label' => Mage::helper('sales')->__('Print Shipping Labels'),
314
  'url' => $this->getUrl('adminhtml/sales_order_shipment/massPrintShippingLabel'),
315
+ )
316
+ );
317
+
318
+ $this->getMassactionBlock()->addItem(
319
+ 'delete_order', array(
320
+ 'label'=> Mage::helper('sales')->__('Delete Order'),
321
+ 'url' => $this->getUrl('adminhtml/novalnetpayment_sales_deleteorder/massDelete'),
322
+ 'confirm' => Mage::helper('sales')->__('Are you sure you want to delete order?')
323
+ )
324
+ );
325
 
326
  return $this;
327
  }
329
  /**
330
  * Return row url
331
  *
332
+ * @param none
333
  * @return string
334
  */
335
  public function getRowUrl($row)
340
  /**
341
  * Return grid url
342
  *
343
+ * @param none
344
  * @return string
345
  */
346
  public function getGridUrl()
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Invoice/Totals.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_Invoice_Totals extends Mage_Adminhtml_Block_Sales_Order_Invoice_Totals
27
- {
28
-
29
- /**
30
- * Initialize order totals array
31
- *
32
- * @return Mage_Sales_Block_Order_Totals
33
- */
34
- protected function _initTotals()
35
- {
36
- parent::_initTotals();
37
- $helper = Mage::helper('novalnet_payment');
38
- $amountchangedvalue = $helper->getAmountCollection($this->getOrder()->getId(), 1, NULL);
39
- if ($amountchangedvalue) {
40
- $adjustmentamount = -($this->getOrder()->getGrandTotal() - $amountchangedvalue);
41
-
42
- $this->_totals['adjust_amount_changed'] = new Varien_Object(array(
43
- 'code' => 'adjust_amount_changed',
44
- 'strong' => true,
45
- 'value' => $adjustmentamount,
46
- 'base_value' => $adjustmentamount,
47
- 'label' => Mage::helper('sales')->__('Novalnet Adjusted Amount'),
48
- 'area' => 'footer'
49
- ));
50
-
51
- $this->_totals['amount_changed'] = new Varien_Object(array(
52
- 'code' => 'amount_changed',
53
- 'strong' => true,
54
- 'value' => $amountchangedvalue,
55
- 'base_value' => $amountchangedvalue,
56
- 'label' => Mage::helper('sales')->__('Novalnet Transaction Amount'),
57
- 'area' => 'footer'
58
- ));
59
- }
60
-
61
- return $this;
62
- }
63
-
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Invoice/View.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_Invoice_View extends Mage_Adminhtml_Block_Sales_Order_Invoice_View
27
- {
28
-
29
- public function __construct()
30
- {
31
- parent::__construct();
32
- $helper = Mage::helper('novalnet_payment');
33
- $order = $this->getInvoice()->getOrder();
34
- $payment = $order->getPayment();
35
- $paymentMethod = $payment->getMethodInstance()->getCode();
36
- $sorderId = $order->getId();
37
- $amount = $helper->getAmountCollection($sorderId, 1, NULL);
38
- $nominalItem = $helper->checkNominalItem($order->getAllItems());
39
- $totalPaid = $order->getTotalPaid();
40
- $getTid = $helper->makeValidNumber($payment->getLastTransId());
41
- $getTransactionStatus = $helper->loadTransactionStatus($getTid);
42
-
43
- // Allow only for Novalnet payment methods
44
- if (preg_match("/novalnet/i", $paymentMethod)
45
- && $paymentMethod == Novalnet_Payment_Model_Config::NN_INVOICE) {
46
- $this->_removeButton('print');
47
- $this->_removeButton('capture');
48
-
49
- if ($this->getInvoice()->getOrder()->canCreditmemo()) {
50
- if (($payment->canRefundPartialPerInvoice()
51
- && $this->getInvoice()->canRefund()
52
- && $payment->getAmountPaid() > $payment->getAmountRefunded())
53
- || ($payment->canRefund() && !$this->getInvoice()->getIsUsedForRefund())) {
54
- $this->getCreditMemoButton();
55
- }
56
- }
57
- if ($this->getInvoice()->getId()) {
58
- $this->getPrintButton();
59
- }
60
- }
61
-
62
- if (($payment->getAmountRefunded() < $amount) || ($nominalItem && $payment->getAmountRefunded() < $totalPaid)) {
63
- $this->_removeButton('print');
64
- $this->_removeButton('capture');
65
- $this->getCreditMemoButton();
66
- if ($this->getInvoice()->getId()) {
67
- $this->getPrintButton();
68
- }
69
- }
70
- }
71
-
72
- /**
73
- * Add creditmemo button
74
- *
75
- */
76
- private function getCreditMemoButton()
77
- {
78
- $this->_addButton('capture', array(// capture?
79
- 'label' => Mage::helper('sales')->__('Credit Memo'),
80
- 'class' => 'go',
81
- 'onclick' => 'setLocation(\'' . $this->getCreditMemoUrl() . '\')'
82
- )
83
- );
84
- }
85
-
86
- /**
87
- * Add print button
88
- *
89
- */
90
- private function getPrintButton()
91
- {
92
- $this->_addButton('print', array(
93
- 'label' => Mage::helper('sales')->__('Print'),
94
- 'class' => 'save',
95
- 'onclick' => 'setLocation(\'' . $this->getPrintUrl() . '\')'
96
- )
97
- );
98
- }
99
-
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Render/Delete.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Sales_Order_Render_Delete
27
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
28
+ {
29
+ /**
30
+ * Render the delete button
31
+ *
32
+ * @param Varien_Object $row
33
+ * @return mixed $result
34
+ */
35
+ public function render(Varien_Object $row)
36
+ {
37
+ $info = $row->getData();
38
+ $orderId = $info['entity_id'];
39
+ $message = Mage::helper('sales')->__('Are you sure you want to delete this order?');
40
+ $viewLink = $this->getUrl('adminhtml/sales_order/view', array('order_id'=> $orderId));
41
+ $deleteLink = $this->getUrl(
42
+ 'adminhtml/novalnetpayment_sales_deleteorder/delete', array('order_id' => $orderId)
43
+ );
44
+ $result = '<a href="'.$viewLink.'">View</a>';
45
+ $result .= '&nbsp;&nbsp;&nbsp;&nbsp;';
46
+ $result .= '<a href="#" onclick="deleteConfirm(\''.$message.'\', \'' . $deleteLink . '\')">Delete</a>';
47
+ return $result;
48
+ }
49
+
50
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/Totals.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
27
- {
28
-
29
- /**
30
- * Initialize order totals array
31
- *
32
- * @return Mage_Sales_Block_Order_Totals
33
- */
34
- protected function _initTotals()
35
- {
36
- parent::_initTotals();
37
- $helper = Mage::helper('novalnet_payment');
38
- $amountchangedvalue = $helper->getAmountCollection($this->getOrder()->getId(), 1, NULL);
39
- if ($amountchangedvalue) {
40
- $adjustmentamount = -($this->getOrder()->getGrandTotal() - $amountchangedvalue);
41
- $this->_totals['adjust_amount_changed'] = new Varien_Object(array(
42
- 'code' => 'adjust_amount_changed',
43
- 'strong' => true,
44
- 'value' => $adjustmentamount,
45
- 'base_value' => $adjustmentamount,
46
- 'label' => Mage::helper('sales')->__('Novalnet Adjusted Amount'),
47
- 'area' => 'footer'
48
- ));
49
-
50
- $this->_totals['amount_changed'] = new Varien_Object(array(
51
- 'code' => 'amount_changed',
52
- 'strong' => true,
53
- 'value' => $amountchangedvalue,
54
- 'base_value' => $amountchangedvalue,
55
- 'label' => Mage::helper('sales')->__('Novalnet Transaction Amount'),
56
- 'area' => 'footer'
57
- ));
58
- }
59
- return $this;
60
- }
61
-
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View.php DELETED
@@ -1,83 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
27
- {
28
-
29
- public function __construct()
30
- {
31
- parent::__construct();
32
- $order = $this->getOrder();
33
- $payment = $order->getPayment();
34
- $paymentMethod = $payment->getMethodInstance()->getCode();
35
-
36
- if (preg_match("/novalnet/i", $paymentMethod)) {
37
- $helper = Mage::helper('novalnet_payment');
38
- $getTid = $helper->makeValidNumber($payment->getLastTransId());
39
- $this->_removeButton('order_creditmemo');
40
- $getTransactionStatus = $helper->loadTransactionStatus($getTid);
41
- $this->_updateButton('order_invoice', 'label', Mage::helper('novalnet_payment')->__('Capture'));
42
-
43
- if ($paymentMethod == Novalnet_Payment_Model_Config::NN_PAYPAL ||
44
- $getTransactionStatus->getTransactionStatus() == Novalnet_Payment_Model_Config::PAYMENT_VOID_STATUS) {
45
- $this->_removeButton('order_invoice');
46
- }
47
- if ($getTransactionStatus->getTransactionStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED ) {
48
- $this->_removeButton('void_payment');
49
- }
50
-
51
- if (in_array($paymentMethod, array(Novalnet_Payment_Model_Config::NN_INVOICE,
52
- Novalnet_Payment_Model_Config::NN_PREPAYMENT))) {
53
- $this->_removeButton('order_invoice');
54
- if ($getTransactionStatus->getTransactionStatus() == 91) {
55
- $this->_removeButton('order_invoice');
56
- $this->_addButton('novalnet_confirm', array(
57
- 'label' => Mage::helper('novalnet_payment')->__('Novalnet Capture'),
58
- 'onclick' => 'setLocation(\'' . $this->getUrl('*/novalnetpayment_sales_order/novalnetconfirm') . '\')',
59
- ), 0);
60
- }
61
- }
62
-
63
- if ($order->canCancel() && $getTransactionStatus->getTransactionStatus()
64
- < Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
65
- $this->_removeButton('void_payment');
66
- $message = Mage::helper('sales')->__('Are you sure you want to void the payment?');
67
- $this->addButton('void_payment', array(
68
- 'label' => Mage::helper('sales')->__('Void'),
69
- 'onclick' => "confirmSetLocation('{$message}', '{$this->getVoidPaymentUrl()}')",
70
- ));
71
- }
72
-
73
- if ($this->_isAllowedAction('ship') && $order->canShip()
74
- && !$order->getForcedDoShipmentWithInvoice()) {
75
- $this->_addButton('order_ship', array(
76
- 'label' => Mage::helper('sales')->__('Ship'),
77
- 'onclick' => 'setLocation(\'' . $this->getShipUrl() . '\')',
78
- 'class' => 'go'
79
- ));
80
- }
81
- }
82
- }
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/Invoices.php DELETED
@@ -1,197 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_Invoices extends Mage_Adminhtml_Block_Widget_Grid
27
- implements Mage_Adminhtml_Block_Widget_Tab_Interface
28
- {
29
-
30
- public function __construct()
31
- {
32
- parent::__construct();
33
- $this->setId('order_invoices');
34
- $this->setUseAjax(true);
35
- }
36
-
37
- /**
38
- * Retrieve collection class
39
- *
40
- * @return string
41
- */
42
- protected function _getCollectionClass()
43
- {
44
- return 'sales/order_invoice_grid_collection';
45
- }
46
-
47
- /**
48
- * Prepare order Collection for invoice
49
- *
50
- * @return Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_Invoices
51
- */
52
- protected function _prepareCollection()
53
- {
54
- $collection = Mage::getResourceModel($this->_getCollectionClass())
55
- ->addFieldToSelect('entity_id')
56
- ->addFieldToSelect('created_at')
57
- ->addFieldToSelect('order_id')
58
- ->addFieldToSelect('increment_id')
59
- ->addFieldToSelect('state')
60
- ->addFieldToSelect('grand_total')
61
- ->addFieldToSelect('base_grand_total')
62
- ->addFieldToSelect('store_currency_code')
63
- ->addFieldToSelect('base_currency_code')
64
- ->addFieldToSelect('order_currency_code')
65
- ->addFieldToSelect('billing_name')
66
- ->setOrderFilter($this->getOrder())
67
- ;
68
- $this->setCollection($collection);
69
- return parent::_prepareCollection();
70
- }
71
-
72
- /**
73
- * Define order invoice tab grid
74
- *
75
- * @return Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_Invoices
76
- */
77
- protected function _prepareColumns()
78
- {
79
- $this->addColumn('increment_id', array(
80
- 'header' => Mage::helper('sales')->__('Invoice #'),
81
- 'index' => 'increment_id',
82
- 'width' => '120px',
83
- ));
84
-
85
- $this->addColumn('billing_name', array(
86
- 'header' => Mage::helper('sales')->__('Bill to Name'),
87
- 'index' => 'billing_name',
88
- ));
89
-
90
- $this->addColumn('created_at', array(
91
- 'header' => Mage::helper('sales')->__('Invoice Date'),
92
- 'index' => 'created_at',
93
- 'type' => 'datetime',
94
- ));
95
-
96
- $this->addColumn('state', array(
97
- 'header' => Mage::helper('sales')->__('Status'),
98
- 'index' => 'state',
99
- 'type' => 'options',
100
- 'options' => Mage::getModel('sales/order_invoice')->getStates(),
101
- ));
102
-
103
- $this->addColumn('base_grand_total', array(
104
- 'header' => Mage::helper('customer')->__('Amount'),
105
- 'index' => 'base_grand_total',
106
- 'type' => 'currency',
107
- 'currency' => 'base_currency_code',
108
- ));
109
- $helper = Mage::helper('novalnet_payment');
110
- $countofvalues = $helper->getAmountCollection($this->getOrder()->getId(), NULL, NULL);
111
- if ($countofvalues > 0) {
112
- $this->addColumn('novalnet_amount', array(
113
- 'header' => Mage::helper('sales')->__('Novalnet Transaction Amount'),
114
- 'width' => '2px',
115
- 'sortable' => false,
116
- 'filter' => false,
117
- 'renderer' => 'novalnet_payment/adminhtml_sales_order_view_tab_renderer_invoices',
118
- ));
119
- }
120
- return parent::_prepareColumns();
121
- }
122
-
123
- /**
124
- * Retrieve order model instance
125
- *
126
- * @return Mage_Sales_Model_Order
127
- */
128
- public function getOrder()
129
- {
130
- return Mage::registry('current_order');
131
- }
132
-
133
- /**
134
- * Return row url
135
- *
136
- * @return string
137
- */
138
- public function getRowUrl($row)
139
- {
140
- return $this->getUrl('*/sales_order_invoice/view', array(
141
- 'invoice_id' => $row->getId(),
142
- 'order_id' => $row->getOrderId()
143
- )
144
- );
145
- }
146
-
147
- /**
148
- * Return grid url
149
- *
150
- * @return string
151
- */
152
- public function getGridUrl()
153
- {
154
- return $this->getUrl('*/*/invoices', array('_current' => true));
155
- }
156
-
157
- /**
158
- * Return tab label
159
- *
160
- * @return string
161
- */
162
- public function getTabLabel()
163
- {
164
- return Mage::helper('sales')->__('Invoices');
165
- }
166
-
167
- /**
168
- * Return tab title
169
- *
170
- * @return string
171
- */
172
- public function getTabTitle()
173
- {
174
- return Mage::helper('sales')->__('Order Invoices');
175
- }
176
-
177
- /**
178
- * Can show tab
179
- *
180
- * @return boolean
181
- */
182
- public function canShowTab()
183
- {
184
- return true;
185
- }
186
-
187
- /**
188
- * Tab is hidden
189
- *
190
- * @return boolean
191
- */
192
- public function isHidden()
193
- {
194
- return false;
195
- }
196
-
197
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/Renderer/Invoices.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_Renderer_Invoices extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
27
- {
28
-
29
- /**
30
- * Renders grid column
31
- *
32
- * @param Varien_Object $row
33
- * @return string
34
- */
35
- public function render(Varien_Object $row)
36
- {
37
- $amount = '';
38
- $orderId = $row->getOrderId();
39
- $symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
40
- $amount .= $symbol;
41
- $amount .= Mage::helper('novalnet_payment')->getAmountCollection($orderId, 1, NULL);
42
- return $amount;
43
- }
44
-
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/TransactionOverview.php CHANGED
@@ -18,59 +18,67 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_TransactionOverview extends Mage_Adminhtml_Block_Widget
27
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
28
  {
29
-
 
 
30
  public function __construct()
31
  {
32
- $this->setTemplate('novalnet/sales/order/view/tab/transactionoverview.phtml');
 
 
 
 
 
 
33
  }
34
 
35
  /**
36
- * Return tab label
37
  *
 
38
  * @return string
39
  */
40
  public function getTabLabel()
41
  {
42
- return Mage::helper('novalnet_payment')->__('Novalnet - Transaction Log');
43
  }
44
 
45
  /**
46
- * Return tab title
47
  *
 
48
  * @return string
49
  */
50
  public function getTabTitle()
51
  {
52
- return Mage::helper('novalnet_payment')->__('Novalnet - Transaction Log');
53
  }
54
 
55
  /**
56
- * Can show tab
57
  *
 
58
  * @return boolean
59
  */
60
  public function canShowTab()
61
  {
62
  $order = $this->getOrder();
63
  $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
64
- if (preg_match("/novalnet/i", $paymentCode)) {
65
- return true;
66
- } else {
67
- return false;
68
- }
69
  }
70
 
71
  /**
72
  * Tab is hidden
73
  *
 
74
  * @return boolean
75
  */
76
  public function isHidden()
@@ -79,8 +87,9 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_TransactionOverview
79
  }
80
 
81
  /**
82
- * Return tab class
83
  *
 
84
  * @return string
85
  */
86
  public function getTabClass()
@@ -91,6 +100,7 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_TransactionOverview
91
  /**
92
  * Get current order
93
  *
 
94
  * @return Mage_Sales_Model_Order
95
  */
96
  public function getOrder()
@@ -99,29 +109,141 @@ class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_TransactionOverview
99
  }
100
 
101
  /**
102
- * Get transaction overview
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  *
104
- * @return Novalnet_Payment_Model_TransactionOverview
 
105
  */
106
- public function getTransactionOverview()
107
  {
108
- if (!Mage::registry('novalnet_payment_transactionoverview_collection')) {
109
- $order = $this->getOrder();
110
-
111
- // @var $transactionOverview Novalnet_Payment_Model_TransactionOverview
112
- $transactionOverview = $this->helperNovalnetPayment()->getModelTransactionOverview()->getCollection();
113
- $transactionOverview->getByOrder($order);
114
- Mage::register('novalnet_payment_transactionoverview_collection', $transactionOverview);
115
- }
116
- return Mage::registry('novalnet_payment_transactionoverview_collection');
117
  }
118
 
119
  /**
120
  * Get Novalnet payment helper
121
  *
 
122
  * @return Novalnet_Payment_Helper_Data
123
  */
124
- protected function helperNovalnetPayment()
125
  {
126
  return Mage::helper('novalnet_payment');
127
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_TransactionOverview extends Mage_Adminhtml_Block_Widget_Grid
27
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
28
  {
29
+ /**
30
+ * Transaction status view tab
31
+ */
32
  public function __construct()
33
  {
34
+ parent::__construct();
35
+ $this->setId('novalnet_payment_block_adminhtml_sales_order_view_tab_transactionoverview');
36
+ $this->setDefaultSort('created_at');
37
+ $this->setDefaultDir('DESC');
38
+ $this->setSaveParametersInSession(true);
39
+ $this->setUseAjax(true);
40
+ $this->setSkipGenerateContent(true);
41
  }
42
 
43
  /**
44
+ * Return Tab label
45
  *
46
+ * @param none
47
  * @return string
48
  */
49
  public function getTabLabel()
50
  {
51
+ return $this->novalnetHelper()->__('Novalnet - Transaction Overview');
52
  }
53
 
54
  /**
55
+ * Return Tab title
56
  *
57
+ * @param none
58
  * @return string
59
  */
60
  public function getTabTitle()
61
  {
62
+ return $this->novalnetHelper()->__('Novalnet - Transaction Overview');
63
  }
64
 
65
  /**
66
+ * Can show tab in tabs
67
  *
68
+ * @param none
69
  * @return boolean
70
  */
71
  public function canShowTab()
72
  {
73
  $order = $this->getOrder();
74
  $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
75
+ return (preg_match("/novalnet/i", $paymentCode)) ? true : false;
 
 
 
 
76
  }
77
 
78
  /**
79
  * Tab is hidden
80
  *
81
+ * @param none
82
  * @return boolean
83
  */
84
  public function isHidden()
87
  }
88
 
89
  /**
90
+ * Return Tab class
91
  *
92
+ * @param none
93
  * @return string
94
  */
95
  public function getTabClass()
100
  /**
101
  * Get current order
102
  *
103
+ * @param none
104
  * @return Mage_Sales_Model_Order
105
  */
106
  public function getOrder()
109
  }
110
 
111
  /**
112
+ * Return tab url
113
+ *
114
+ * @param none
115
+ * @return string
116
+ */
117
+ public function getTabUrl()
118
+ {
119
+ return $this->getUrl(
120
+ 'adminhtml/novalnetpayment_sales_order/transactionOverviewGrid', array(
121
+ '_current' => true
122
+ )
123
+ );
124
+ }
125
+
126
+ /**
127
+ * Return grid url
128
+ *
129
+ * @param none
130
+ * @return string
131
+ */
132
+ public function getGridUrl()
133
+ {
134
+ return $this->getUrl(
135
+ 'adminhtml/novalnetpayment_sales_order/transactionOverviewGrid', array('_current' => true)
136
+ );
137
+ }
138
+
139
+ /**
140
+ * Return row url
141
+ *
142
+ * @param mixed $row
143
+ * @return string
144
+ */
145
+ public function getRowUrl($row)
146
+ {
147
+ return $this->getUrl('adminhtml/novalnetpayment_transactionoverview/view', array('nntxn_id' => $row->getId()));
148
+ }
149
+
150
+ /**
151
+ * Prepare order Collection for transaction status
152
+ *
153
+ * @param none
154
+ * @return Novalnet_Payment_Model_TransactionStatus
155
+ */
156
+ protected function _prepareCollection()
157
+ {
158
+ $collection = $this->getTransactionStatusCollection();
159
+ $this->setCollection($collection);
160
+ return parent::_prepareCollection();
161
+ }
162
+
163
+ /**
164
+ * Prepare order Collection for transaction status
165
+ *
166
+ * @param none
167
+ * @return mixed $collection
168
+ */
169
+ public function getTransactionStatusCollection()
170
+ {
171
+ $collection = Mage::getModel('novalnet_payment/Mysql4_TransactionStatus')->getCollection();
172
+ $collection->getByOrder($this->getOrder());
173
+ return $collection;
174
+ }
175
+
176
+ /**
177
+ * Define transaction status grid
178
+ *
179
+ * @param none
180
+ * @return mixed
181
+ */
182
+ protected function _prepareColumns()
183
+ {
184
+ $helper = $this->novalnetHelper();
185
+ $this->setColumn(
186
+ 'order_id', array(
187
+ 'header' => $helper->__('Order No'),
188
+ 'width' => '200px',
189
+ 'type' => 'text',
190
+ 'index' => 'order_id',
191
+ )
192
+ );
193
+ $this->setColumn(
194
+ 'txid', array(
195
+ 'header' => $helper->__('Transaction Id'),
196
+ 'width' => '200px',
197
+ 'type' => 'text',
198
+ 'index' => 'transaction_no',
199
+ )
200
+ );
201
+ $this->setColumn(
202
+ 'transaction_status', array(
203
+ 'header' => $helper->__('Transaction Status'),
204
+ 'width' => '200px',
205
+ 'type' => 'text',
206
+ 'index' => 'transaction_status',
207
+ )
208
+ );
209
+ $this->setColumn(
210
+ 'customer_id', array(
211
+ 'header' => $helper->__('Customer Id'),
212
+ 'width' => '200px',
213
+ 'type' => 'text',
214
+ 'index' => 'customer_id',
215
+ )
216
+ );
217
+ $this->setColumn(
218
+ 'store_id', array(
219
+ 'header' => $helper->__('Store Id'),
220
+ 'width' => '200px',
221
+ 'type' => 'text',
222
+ 'index' => 'store_id',
223
+ )
224
+ );
225
+
226
+ return parent::_prepareColumns();
227
+ }
228
+
229
+ /**
230
+ * Add coumn
231
  *
232
+ * @param none
233
+ * @return null
234
  */
235
+ protected function setColumn($field, $fieldColumnMap)
236
  {
237
+ $this->addColumn($field, $fieldColumnMap);
 
 
 
 
 
 
 
 
238
  }
239
 
240
  /**
241
  * Get Novalnet payment helper
242
  *
243
+ * @param none
244
  * @return Novalnet_Payment_Helper_Data
245
  */
246
+ protected function novalnetHelper()
247
  {
248
  return Mage::helper('novalnet_payment');
249
  }
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/TransactionStatus.php DELETED
@@ -1,247 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_TransactionStatus extends Mage_Adminhtml_Block_Widget_Grid
27
- implements Mage_Adminhtml_Block_Widget_Tab_Interface
28
- {
29
-
30
- public function __construct()
31
- {
32
- parent::__construct();
33
- $this->setId('novalnet_payment_block_adminhtml_sales_order_view_tab_transactionstatus');
34
- $this->setDefaultSort('created_at');
35
- $this->setDefaultDir('DESC');
36
- $this->setSaveParametersInSession(true);
37
- $this->setUseAjax(true);
38
- $this->setSkipGenerateContent(true);
39
- }
40
-
41
- /**
42
- * Return Tab label
43
- *
44
- * @return string
45
- */
46
- public function getTabLabel()
47
- {
48
- return Mage::helper('novalnet_payment')->__('Novalnet - Transaction Overview');
49
- }
50
-
51
- /**
52
- * Return Tab title
53
- *
54
- * @return string
55
- */
56
- public function getTabTitle()
57
- {
58
- return Mage::helper('novalnet_payment')->__('Novalnet - Transaction Overview');
59
- }
60
-
61
- /**
62
- * Can show tab in tabs
63
- *
64
- * @return boolean
65
- */
66
- public function canShowTab()
67
- {
68
- $order = $this->getOrder();
69
- $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
70
- if (preg_match("/novalnet/i", $paymentCode)) {
71
- return true;
72
- } else {
73
- return false;
74
- }
75
- }
76
-
77
- /**
78
- * Tab is hidden
79
- *
80
- * @return boolean
81
- */
82
- public function isHidden()
83
- {
84
- return false;
85
- }
86
-
87
- /**
88
- * Return Tab class
89
- *
90
- * @return string
91
- */
92
- public function getTabClass()
93
- {
94
- return 'ajax novalnet-widget-tab';
95
- }
96
-
97
- /**
98
- * Get current order
99
- *
100
- * @return Mage_Sales_Model_Order
101
- */
102
- public function getOrder()
103
- {
104
- return Mage::registry('current_order');
105
- }
106
-
107
- /**
108
- * Return tab url
109
- *
110
- * @return string
111
- */
112
- public function getTabUrl()
113
- {
114
- return $this->getUrl('adminhtml/novalnetpayment_sales_order/transactionStatusGrid', array(
115
- '_current' => true
116
- )
117
- );
118
- }
119
-
120
- /**
121
- * Return grid url
122
- *
123
- * @return string
124
- */
125
- public function getGridUrl()
126
- {
127
- return $this->getUrl('adminhtml/novalnetpayment_sales_order/transactionStatusGrid', array(
128
- '_current' => true
129
- )
130
- );
131
- }
132
-
133
- /**
134
- * Return row url
135
- *
136
- * @return string
137
- */
138
- public function getRowUrl($row)
139
- {
140
- return $this->getUrl('adminhtml/novalnetpayment_transaction/view', array(
141
- 'nntxn_id' => $row->getId()
142
- )
143
- );
144
- }
145
-
146
- /**
147
- * Prepare order Collection for transaction status
148
- *
149
- * @return Novalnet_Payment_Model_TransactionStatus
150
- */
151
- protected function _prepareCollection()
152
- {
153
- $collection = $this->getTransactionStatusCollection();
154
- $this->setCollection($collection);
155
- return parent::_prepareCollection();
156
- }
157
-
158
- /**
159
- * Prepare order Collection for transaction status
160
- *
161
- * @return mixed
162
- */
163
- public function getTransactionStatusCollection()
164
- {
165
- $order = $this->getOrder();
166
-
167
- // @var $StatusCollection Novalnet_Payment_Model_TransactionStatus_Collection
168
- $statusCollection = $this->helperNovalnetPayment()->getModelTransactionStatus()->getCollection();
169
- $statusCollection->getByOrder($order);
170
- return $statusCollection;
171
- }
172
-
173
- /**
174
- * Define transaction status grid
175
- *
176
- * @return Novalnet_Payment_Model_TransactionStatus
177
- */
178
- protected function _prepareColumns()
179
- {
180
- $helper = $this->helperNovalnetPayment();
181
- $this->setColumn('txid', array(
182
- 'header' => $helper->__('Transaction ID'),
183
- 'width' => '200px',
184
- 'type' => 'text',
185
- 'index' => 'transaction_no',
186
- )
187
- );
188
- $this->setColumn('order_id', array(
189
- 'header' => $helper->__('Order number'),
190
- 'width' => '200px',
191
- 'type' => 'text',
192
- 'index' => 'order_id',
193
- )
194
- );
195
- $this->setColumn('transaction_status', array(
196
- 'header' => $helper->__('Transaction Status'),
197
- 'width' => '200px',
198
- 'type' => 'text',
199
- 'index' => 'transaction_status',
200
- )
201
- );
202
- $this->setColumn('ncno', array(
203
- 'header' => $helper->__('NC No'),
204
- 'width' => '200px',
205
- 'type' => 'text',
206
- 'index' => 'nc_no',
207
- )
208
- );
209
- $this->setColumn('customer_id', array(
210
- 'header' => $helper->__('Customer ID'),
211
- 'width' => '200px',
212
- 'type' => 'text',
213
- 'index' => 'customer_id',
214
- )
215
- );
216
- $this->setColumn('store_id', array(
217
- 'header' => $helper->__('Store ID'),
218
- 'width' => '200px',
219
- 'type' => 'text',
220
- 'index' => 'store_id',
221
- )
222
- );
223
-
224
- return parent::_prepareColumns();
225
- }
226
-
227
- /**
228
- * Add coumn
229
- *
230
- * @return null
231
- */
232
- private function setColumn($field, $fieldColumnMap)
233
- {
234
- $this->addColumn($field, $fieldColumnMap);
235
- }
236
-
237
- /**
238
- * Get Novalnet payment helper
239
- *
240
- * @return Novalnet_Payment_Helper_Data
241
- */
242
- protected function helperNovalnetPayment()
243
- {
244
- return Mage::helper('novalnet_payment');
245
- }
246
-
247
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Order/View/Tab/TransactionTraces.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_TransactionTraces extends Mage_Adminhtml_Block_Widget
27
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
28
+ {
29
+ /**
30
+ * Transaction traces view tab
31
+ */
32
+ public function __construct()
33
+ {
34
+ $this->setTemplate('novalnet/sales/order/view/tab/transactiontraces.phtml');
35
+ }
36
+
37
+ /**
38
+ * Return tab label
39
+ *
40
+ * @param none
41
+ * @return string
42
+ */
43
+ public function getTabLabel()
44
+ {
45
+ return $this->novalnetHelper()->__('Novalnet - Transaction Log');
46
+ }
47
+
48
+ /**
49
+ * Return tab title
50
+ *
51
+ * @param none
52
+ * @return string
53
+ */
54
+ public function getTabTitle()
55
+ {
56
+ return $this->novalnetHelper()->__('Novalnet - Transaction Log');
57
+ }
58
+
59
+ /**
60
+ * Can show tab
61
+ *
62
+ * @param none
63
+ * @return boolean
64
+ */
65
+ public function canShowTab()
66
+ {
67
+ $order = $this->getOrder();
68
+ $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
69
+ return (preg_match("/novalnet/i", $paymentCode)) ? true : false;
70
+ }
71
+
72
+ /**
73
+ * Tab is hidden
74
+ *
75
+ * @param none
76
+ * @return boolean
77
+ */
78
+ public function isHidden()
79
+ {
80
+ return false;
81
+ }
82
+
83
+ /**
84
+ * Return tab class
85
+ *
86
+ * @param none
87
+ * @return string
88
+ */
89
+ public function getTabClass()
90
+ {
91
+ return 'ajax novalnet-widget-tab';
92
+ }
93
+
94
+ /**
95
+ * Get current order
96
+ *
97
+ * @param none
98
+ * @return Mage_Sales_Model_Order
99
+ */
100
+ public function getOrder()
101
+ {
102
+ return Mage::registry('current_order');
103
+ }
104
+
105
+ /**
106
+ * Get transaction overview
107
+ *
108
+ * @param none
109
+ * @return mixed
110
+ */
111
+ public function getTransactionTraces()
112
+ {
113
+ if (!Mage::registry('novalnet_payment_transactiontraces_collection')) {
114
+ $order = $this->getOrder();
115
+ $collection = Mage::getModel('novalnet_payment/Mysql4_TransactionTraces')->getCollection();
116
+ $collection->getByOrder($order);
117
+ Mage::register('novalnet_payment_transactiontraces_collection', $collection);
118
+ }
119
+ return Mage::registry('novalnet_payment_transactiontraces_collection');
120
+ }
121
+
122
+ /**
123
+ * Get Novalnet payment helper
124
+ *
125
+ * @param none
126
+ * @return Novalnet_Payment_Helper_Data
127
+ */
128
+ protected function novalnetHelper()
129
+ {
130
+ return Mage::helper('novalnet_payment');
131
+ }
132
+
133
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/Sales/Sales.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Sales_Sales extends Mage_Adminhtml_Block_Widget_Grid_Container
27
- {
28
-
29
- public function __construct()
30
- {
31
- $this->_controller = 'report_sales_sales';
32
- $this->_headerText = Mage::helper('reports')->__('Total Ordered Report');
33
- parent::__construct();
34
- $this->setTemplate('novalnet_payment/container.phtml');
35
- $this->_removeButton('add');
36
- $this->addButton('filter_form_submit', array(
37
- 'label' => Mage::helper('reports')->__('Show Report'),
38
- 'onclick' => 'filterFormSubmit()'
39
- ));
40
- }
41
-
42
- /**
43
- * Get filter url
44
- *
45
- * @return string
46
- */
47
- public function getFilterUrl()
48
- {
49
- $this->getRequest()->setParam('filter', null);
50
- return $this->getUrl('*/*/sales', array('_current' => true));
51
- }
52
-
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Transaction/Grid.php DELETED
@@ -1,117 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Transaction_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
- {
28
-
29
- var $novalnetPayments = array();
30
-
31
- public function __construct()
32
- {
33
- parent::__construct();
34
-
35
- $this->setId('novalnet_transaction_grid');
36
- $this->setUseAjax(true);
37
- $this->setDefaultSort('order_id');
38
- $this->setDefaultDir('desc');
39
- }
40
-
41
- /**
42
- * Prepare order Collection for Novalnet transaction status
43
- *
44
- * @return Novalnet_Payment_Block_Adminhtml_Transaction_Grid
45
- */
46
- protected function _prepareCollection()
47
- {
48
- $collection = Mage::getModel('novalnet_payment/transactionstatus')->getCollection();
49
- $this->setCollection($collection);
50
- return parent::_prepareCollection();
51
- }
52
-
53
- /**
54
- * prepare column for massaction order grid
55
- *
56
- * @return Novalnet_Payment_Block_Adminhtml_Transaction_Grid
57
- */
58
- protected function _prepareColumns()
59
- {
60
- $this->addColumn('order_id', array(
61
- 'header' => Mage::helper('sales')->__('Order no #'),
62
- 'width' => '80px',
63
- 'type' => 'text',
64
- 'index' => 'order_id',
65
- ));
66
- $this->addColumn('transaction_no', array(
67
- 'header' => Mage::helper('sales')->__('Transaction #'),
68
- 'width' => '80px',
69
- 'type' => 'text',
70
- 'index' => 'transaction_no',
71
- ));
72
- $this->addColumn('store_id', array(
73
- 'header' => Mage::helper('sales')->__('Store ID #'),
74
- 'width' => '80px',
75
- 'type' => 'text',
76
- 'index' => 'store_id',
77
- ));
78
- $this->addColumn('nc_no', array(
79
- 'header' => Mage::helper('sales')->__('NC No #'),
80
- 'width' => '80px',
81
- 'type' => 'text',
82
- 'index' => 'nc_no',
83
- ));
84
- $this->addColumn('transaction_status', array(
85
- 'header' => Mage::helper('sales')->__('Status #'),
86
- 'width' => '80px',
87
- 'type' => 'text',
88
- 'index' => 'transaction_status',
89
- ));
90
- parent::_prepareColumns();
91
- return $this;
92
- }
93
-
94
- /**
95
- * Return row url
96
- *
97
- * @return string
98
- */
99
- public function getRowUrl($row)
100
- {
101
- return $this->getUrl('adminhtml/novalnetpayment_transaction/view', array(
102
- 'nntxn_id' => $row->getId()
103
- )
104
- );
105
- }
106
-
107
- /**
108
- * Return grid url
109
- *
110
- * @return string
111
- */
112
- public function getGridUrl()
113
- {
114
- return $this->getUrl('*/*/grid', array('_current' => true));
115
- }
116
-
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Transaction/View.php DELETED
@@ -1,104 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Transaction_View extends Mage_Adminhtml_Block_Widget_Form_Container
27
- {
28
-
29
- public function __construct()
30
- {
31
- $this->_objectId = 'nntxn_id';
32
- $this->_mode = 'view';
33
- $this->_blockGroup = 'novalnet_payment';
34
- $this->_controller = 'adminhtml_transaction';
35
-
36
- parent::__construct();
37
-
38
- $this->setId('transaction_view');
39
-
40
- $this->_removeButton('reset');
41
- $this->_removeButton('delete');
42
- $this->_removeButton('save');
43
- }
44
-
45
- /**
46
- * Retrieve invoice model instance
47
- *
48
- * @return Mage_Sales_Model_Order_Invoice
49
- */
50
- public function getOrder()
51
- {
52
- return Mage::registry('current_order');
53
- }
54
-
55
- /**
56
- * Get Novalnet transaction status
57
- *
58
- * @return string
59
- */
60
- public function getNovalnetTransactionStatus()
61
- {
62
- return Mage::registry('novalnet_payment_transactionstatus');
63
- }
64
-
65
- /**
66
- * Get order currency code
67
- *
68
- * @return string
69
- */
70
- public function getCurrencyCode()
71
- {
72
- $order = Mage::getModel("sales/order")->loadByIncrementId(
73
- trim($this->getNovalnetTransactionStatus()->getOrderId()));
74
- return $order->getOrderCurrencyCode();
75
- }
76
-
77
- /**
78
- * Get payment method title
79
- *
80
- * @return string
81
- */
82
- public function getPaymentTitle()
83
- {
84
- $transactionStatus = $this->getNovalnetTransactionStatus();
85
- $title = Mage::helper("novalnet_payment")->getModel(
86
- $transactionStatus->getPaymentName())->getNovalnetConfig('title');
87
- return $title;
88
- }
89
-
90
- /**
91
- * Get header text of transaction status
92
- *
93
- * @return string
94
- */
95
- public function getHeaderText()
96
- {
97
- $transStatus = $this->getNovalnetTransactionStatus();
98
- $text = Mage::helper('novalnet_payment')->__(
99
- 'Order #%s | TID : %s ', $transStatus->getOrderId(), $transStatus->getTransactionNo()
100
- );
101
- return $text;
102
- }
103
-
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Transactionoverview.php CHANGED
@@ -1,40 +1,41 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Transactionoverview extends Mage_Adminhtml_Block_Widget_Grid_Container
27
- {
28
-
29
- public function __construct()
30
- {
31
- $this->_blockGroup = 'novalnet_payment';
32
- $this->_controller = 'adminhtml_transactionoverview';
33
- $this->_headerText = Mage::helper('novalnet_payment')->__('Novalnet Transactions Log');
34
- $this->setSaveParametersInSession(true);
35
-
36
- parent::__construct();
37
- $this->removeButton('add');
38
- }
39
-
40
- }
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Transactionoverview extends Mage_Adminhtml_Block_Widget_Grid_Container
27
+ {
28
+ /**
29
+ * Transaction status
30
+ */
31
+ public function __construct()
32
+ {
33
+ $this->_blockGroup = 'novalnet_payment';
34
+ $this->_controller = 'adminhtml_transactionoverview';
35
+ $this->_headerText = Mage::helper('novalnet_payment')->__('Novalnet Transactions Overview');
36
+ $this->setSaveParametersInSession(true);
37
+ parent::__construct();
38
+ $this->removeButton('add');
39
+ }
40
+
41
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/Transactionoverview/Grid.php CHANGED
@@ -18,85 +18,102 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Transactionoverview_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
  {
28
 
 
 
 
29
  public function __construct()
30
  {
31
  parent::__construct();
32
- $this->setId('novalnet_transactionoverview_grid');
33
  $this->setUseAjax(true);
34
  $this->setDefaultSort('order_id');
35
- $this->setDefaultDir('DESC');
36
  }
37
 
38
  /**
39
- * Prepare order Collection for novalnet transaction overview
40
  *
41
- * @return Novalnet_Payment_Block_Adminhtml_Transactionoverview_Grid
 
42
  */
43
  protected function _prepareCollection()
44
  {
45
- $collection = Mage::getModel('novalnet_payment/transactionoverview')->getCollection();
46
  $this->setCollection($collection);
47
  return parent::_prepareCollection();
48
  }
49
 
50
  /**
51
- * prepare column for transaction overview grid
52
  *
53
- * @return Novalnet_Payment_Block_Adminhtml_Transactionoverview_Grid
 
54
  */
55
  protected function _prepareColumns()
56
  {
57
- $helper = $this->helperNovalnetPayment();
58
-
59
- $this->addColumn('order_id', array(
60
- 'header' => $helper->__('Order no #'),
61
  'width' => '80px',
62
  'type' => 'text',
63
  'index' => 'order_id',
64
- ));
65
- $this->addColumn('transaction_no', array(
66
- 'header' => $helper->__('Transaction #'),
 
 
 
 
 
 
 
 
 
 
67
  'width' => '80px',
68
  'type' => 'text',
69
- 'index' => 'transaction_id',
70
- ));
71
- $this->addColumn('id', array(
72
- 'header' => $helper->__('Store id #'),
 
 
 
 
 
 
 
 
 
 
73
  'width' => '80px',
74
  'type' => 'text',
75
  'index' => 'store_id',
76
- ));
77
-
78
- return parent::_prepareColumns();
79
- }
80
-
81
- /**
82
- * Get Novalnet payment helper
83
- *
84
- * @return Novalnet_Payment_Helper_Data
85
- */
86
- protected function helperNovalnetPayment()
87
- {
88
- return Mage::helper('novalnet_payment');
89
  }
90
 
91
  /**
92
  * Return row url
93
  *
 
94
  * @return string
95
  */
96
  public function getRowUrl($row)
97
  {
98
- return $this->getUrl('adminhtml/novalnetpayment_transactionoverview/view', array(
99
- 'nnlog_id' => $row->getId()
 
100
  )
101
  );
102
  }
@@ -104,6 +121,7 @@ class Novalnet_Payment_Block_Adminhtml_Transactionoverview_Grid extends Mage_Adm
104
  /**
105
  * Return grid url
106
  *
 
107
  * @return string
108
  */
109
  public function getGridUrl()
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Transactionoverview_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
  {
28
 
29
+ /**
30
+ * Transaction status grid
31
+ */
32
  public function __construct()
33
  {
34
  parent::__construct();
35
+ $this->setId('novalnet_transaction_grid');
36
  $this->setUseAjax(true);
37
  $this->setDefaultSort('order_id');
38
+ $this->setDefaultDir('desc');
39
  }
40
 
41
  /**
42
+ * Prepare order Collection for Novalnet transaction status
43
  *
44
+ * @param none
45
+ * @return Novalnet_Payment_Block_Adminhtml_Transaction_Grid
46
  */
47
  protected function _prepareCollection()
48
  {
49
+ $collection = Mage::getModel('novalnet_payment/Mysql4_TransactionStatus')->getCollection();
50
  $this->setCollection($collection);
51
  return parent::_prepareCollection();
52
  }
53
 
54
  /**
55
+ * prepare column for massaction order grid
56
  *
57
+ * @param none
58
+ * @return Novalnet_Payment_Block_Adminhtml_Transaction_Grid
59
  */
60
  protected function _prepareColumns()
61
  {
62
+ $this->addColumn(
63
+ 'order_id', array(
64
+ 'header' => Mage::helper('sales')->__('Order No #'),
 
65
  'width' => '80px',
66
  'type' => 'text',
67
  'index' => 'order_id',
68
+ )
69
+ );
70
+ $this->addColumn(
71
+ 'transaction_no', array(
72
+ 'header' => Mage::helper('sales')->__('Transaction Id #'),
73
+ 'width' => '80px',
74
+ 'type' => 'text',
75
+ 'index' => 'transaction_no',
76
+ )
77
+ );
78
+ $this->addColumn(
79
+ 'transaction_status', array(
80
+ 'header' => Mage::helper('sales')->__('Transaction Status #'),
81
  'width' => '80px',
82
  'type' => 'text',
83
+ 'index' => 'transaction_status',
84
+ )
85
+ );
86
+ $this->addColumn(
87
+ 'customer_id', array(
88
+ 'header' => Mage::helper('sales')->__('Customer Id #'),
89
+ 'width' => '80px',
90
+ 'type' => 'text',
91
+ 'index' => 'customer_id',
92
+ )
93
+ );
94
+ $this->addColumn(
95
+ 'store_id', array(
96
+ 'header' => Mage::helper('sales')->__('Store Id #'),
97
  'width' => '80px',
98
  'type' => 'text',
99
  'index' => 'store_id',
100
+ )
101
+ );
102
+ parent::_prepareColumns();
103
+ return $this;
 
 
 
 
 
 
 
 
 
104
  }
105
 
106
  /**
107
  * Return row url
108
  *
109
+ * @param mixed $row
110
  * @return string
111
  */
112
  public function getRowUrl($row)
113
  {
114
+ return $this->getUrl(
115
+ 'adminhtml/novalnetpayment_transactionoverview/view', array(
116
+ 'nntxn_id' => $row->getId()
117
  )
118
  );
119
  }
121
  /**
122
  * Return grid url
123
  *
124
+ * @param none
125
  * @return string
126
  */
127
  public function getGridUrl()
app/code/community/Novalnet/Payment/Block/Adminhtml/Transactionoverview/View.php CHANGED
@@ -18,73 +18,93 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Transactionoverview_View extends Mage_Adminhtml_Block_Widget_Form_Container
27
  {
28
-
29
- var $novalnetPayments = array();
30
-
31
  public function __construct()
32
  {
33
- $this->_objectId = 'nnlog_id';
34
  $this->_mode = 'view';
35
  $this->_blockGroup = 'novalnet_payment';
36
- $this->_controller = 'adminhtml_transaction';
37
 
38
  parent::__construct();
39
 
40
- $this->setId('transactionoverview_view');
41
- $this->setUseAjax(true);
42
- $this->setDefaultSort('created_date');
43
- $this->setDefaultDir('DESC');
44
-
45
  $this->_removeButton('reset');
46
  $this->_removeButton('delete');
47
  $this->_removeButton('save');
48
  }
49
 
50
  /**
51
- * Get Novalnet transaction overview
 
 
 
 
 
 
 
 
 
 
 
52
  *
 
53
  * @return string
54
  */
55
- public function getNovalnetTransactionOverview()
56
  {
57
  return Mage::registry('novalnet_payment_transactionoverview');
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  /**
61
  * Get payment method title
62
  *
 
63
  * @return string
64
  */
65
  public function getPaymentTitle()
66
  {
67
- $order = Mage::getModel("sales/order")->loadByIncrementId(
68
- trim($this->getNovalnetTransactionOverview()->getOrderId()));
69
- if ($order->getPayment()) {
70
- $paymentMethod = $order->getPayment()->getMethod();
71
- $title = Mage::helper("novalnet_payment")->getModel($paymentMethod)->getNovalnetConfig('title');
72
- } else {
73
- $title = '';
74
- }
75
  return $title;
76
  }
77
 
78
  /**
79
- * Get header text of transaction overview
80
  *
 
81
  * @return string
82
  */
83
  public function getHeaderText()
84
  {
85
- $transStatus = $this->getNovalnetTransactionOverview();
86
  $text = Mage::helper('novalnet_payment')->__(
87
- 'Order #%s | TID : %s ', $transStatus->getOrderId(), $transStatus->getTransactionId()
88
  );
89
  return $text;
90
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Transactionoverview_View extends Mage_Adminhtml_Block_Widget_Form_Container
27
  {
28
+ /**
29
+ * Transaction status view
30
+ */
31
  public function __construct()
32
  {
33
+ $this->_objectId = 'nntxn_id';
34
  $this->_mode = 'view';
35
  $this->_blockGroup = 'novalnet_payment';
36
+ $this->_controller = 'adminhtml_transactionoverview';
37
 
38
  parent::__construct();
39
 
40
+ $this->setId('transaction_view');
 
 
 
 
41
  $this->_removeButton('reset');
42
  $this->_removeButton('delete');
43
  $this->_removeButton('save');
44
  }
45
 
46
  /**
47
+ * Retrieve invoice model instance
48
+ *
49
+ * @param none
50
+ * @return Mage_Sales_Model_Order_Invoice
51
+ */
52
+ public function getOrder()
53
+ {
54
+ return Mage::registry('current_order');
55
+ }
56
+
57
+ /**
58
+ * Get Novalnet transaction status
59
  *
60
+ * @param none
61
  * @return string
62
  */
63
+ public function getTransactionStatus()
64
  {
65
  return Mage::registry('novalnet_payment_transactionoverview');
66
  }
67
 
68
+ /**
69
+ * Get order currency code
70
+ *
71
+ * @param none
72
+ * @return string
73
+ */
74
+ public function getCurrencyCode()
75
+ {
76
+ $order = Mage::getModel("sales/order")->loadByIncrementId(
77
+ trim($this->getTransactionStatus()->getOrderId())
78
+ );
79
+ return $order->getOrderCurrencyCode();
80
+ }
81
+
82
  /**
83
  * Get payment method title
84
  *
85
+ * @param none
86
  * @return string
87
  */
88
  public function getPaymentTitle()
89
  {
90
+ $transactionStatus = $this->getTransactionStatus();
91
+ $title = Mage::helper("novalnet_payment")
92
+ ->getPaymentModel($transactionStatus->getPaymentName())
93
+ ->getConfigData('title');
 
 
 
 
94
  return $title;
95
  }
96
 
97
  /**
98
+ * Get header text of transaction status
99
  *
100
+ * @param none
101
  * @return string
102
  */
103
  public function getHeaderText()
104
  {
105
+ $transStatus = $this->getTransactionStatus();
106
  $text = Mage::helper('novalnet_payment')->__(
107
+ 'Order #%s | TID : %s ', $transStatus->getOrderId(), $transStatus->getTransactionNo()
108
  );
109
  return $text;
110
  }
app/code/community/Novalnet/Payment/Block/Adminhtml/Transactionoverview/View/Form.php CHANGED
@@ -18,17 +18,21 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Transactionoverview_View_Form extends Mage_Adminhtml_Block_Widget
27
  {
28
-
 
 
29
  public function __construct()
30
  {
31
- $this->_headerText = Mage::helper('novalnet_payment')->__('Transaction Overview');
 
 
32
  parent::__construct();
33
  }
34
 
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Block_Adminhtml_Transactionoverview_View_Form extends Mage_Adminhtml_Block_Widget
27
  {
28
+ /**
29
+ * Transaction status view
30
+ */
31
  public function __construct()
32
  {
33
+ $this->_blockGroup = 'novalnet_payment';
34
+ $this->_controller = 'adminhtml_transactionoverview';
35
+ $this->_headerText = Mage::helper('novalnet_payment')->__('Transactions');
36
  parent::__construct();
37
  }
38
 
app/code/community/Novalnet/Payment/Block/Adminhtml/{Transaction.php → Transactiontraces.php} RENAMED
@@ -1,40 +1,42 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Transaction extends Mage_Adminhtml_Block_Widget_Grid_Container
27
- {
28
-
29
- public function __construct()
30
- {
31
- $this->_blockGroup = 'novalnet_payment';
32
- $this->_controller = 'adminhtml_transaction';
33
- $this->_headerText = Mage::helper('novalnet_payment')->__('Novalnet Transactions Overview');
34
- $this->setSaveParametersInSession(true);
35
-
36
- parent::__construct();
37
- $this->removeButton('add');
38
- }
39
-
40
- }
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Transactiontraces extends Mage_Adminhtml_Block_Widget_Grid_Container
27
+ {
28
+ /**
29
+ * Transaction traces
30
+ */
31
+ public function __construct()
32
+ {
33
+ $this->_blockGroup = 'novalnet_payment';
34
+ $this->_controller = 'adminhtml_transactiontraces';
35
+ $this->_headerText = Mage::helper('novalnet_payment')->__('Novalnet Transactions Traces');
36
+ $this->setSaveParametersInSession(true);
37
+
38
+ parent::__construct();
39
+ $this->removeButton('add');
40
+ }
41
+
42
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/Transactiontraces/Grid.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Transactiontraces_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
+ {
28
+
29
+ /**
30
+ * Transaction traces grid
31
+ */
32
+ public function __construct()
33
+ {
34
+ parent::__construct();
35
+ $this->setId('novalnet_transactiontraces_grid');
36
+ $this->setUseAjax(true);
37
+ $this->setDefaultSort('order_id');
38
+ $this->setDefaultDir('DESC');
39
+ }
40
+
41
+ /**
42
+ * Prepare order Collection for novalnet transaction overview
43
+ *
44
+ * @param none
45
+ * @return Novalnet_Payment_Block_Adminhtml_Transactiontraces_Grid
46
+ */
47
+ protected function _prepareCollection()
48
+ {
49
+ $collection = Mage::getModel('novalnet_payment/Mysql4_TransactionTraces')->getCollection();
50
+ $this->setCollection($collection);
51
+ return parent::_prepareCollection();
52
+ }
53
+
54
+ /**
55
+ * prepare column for transaction overview grid
56
+ *
57
+ * @param none
58
+ * @return Novalnet_Payment_Block_Adminhtml_Transactionoverview_Grid
59
+ */
60
+ protected function _prepareColumns()
61
+ {
62
+ $helper = Mage::helper('novalnet_payment');
63
+
64
+ $this->addColumn(
65
+ 'order_id', array(
66
+ 'header' => $helper->__('Order No #'),
67
+ 'width' => '80px',
68
+ 'type' => 'text',
69
+ 'index' => 'order_id',
70
+ )
71
+ );
72
+ $this->addColumn(
73
+ 'transaction_no', array(
74
+ 'header' => $helper->__('Transaction Id #'),
75
+ 'width' => '80px',
76
+ 'type' => 'text',
77
+ 'index' => 'transaction_id',
78
+ )
79
+ );
80
+ $this->addColumn(
81
+ 'customer_id', array(
82
+ 'header' => Mage::helper('sales')->__('Customer Id #'),
83
+ 'width' => '80px',
84
+ 'type' => 'text',
85
+ 'index' => 'customer_id',
86
+ )
87
+ );
88
+ $this->addColumn(
89
+ 'id', array(
90
+ 'header' => $helper->__('Store Id #'),
91
+ 'width' => '80px',
92
+ 'type' => 'text',
93
+ 'index' => 'store_id',
94
+ )
95
+ );
96
+
97
+ return parent::_prepareColumns();
98
+ }
99
+
100
+ /**
101
+ * Return row url
102
+ *
103
+ * @param mixed $row
104
+ * @return string
105
+ */
106
+ public function getRowUrl($row)
107
+ {
108
+ return $this->getUrl(
109
+ 'adminhtml/novalnetpayment_transactiontraces/view', array(
110
+ 'nnlog_id' => $row->getId()
111
+ )
112
+ );
113
+ }
114
+
115
+ /**
116
+ * Return grid url
117
+ *
118
+ * @param none
119
+ * @return string
120
+ */
121
+ public function getGridUrl()
122
+ {
123
+ return $this->getUrl('*/*/grid', array('_current' => true));
124
+ }
125
+
126
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/Transactiontraces/View.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Adminhtml_Transactiontraces_View extends Mage_Adminhtml_Block_Widget_Form_Container
27
+ {
28
+
29
+ /**
30
+ * Transaction traces view
31
+ */
32
+ public function __construct()
33
+ {
34
+ $this->_objectId = 'nnlog_id';
35
+ $this->_mode = 'view';
36
+ $this->_blockGroup = 'novalnet_payment';
37
+ $this->_controller = 'adminhtml_transactiontraces';
38
+
39
+ parent::__construct();
40
+
41
+ $this->setId('transactiontraces_view');
42
+ $this->setUseAjax(true);
43
+ $this->setDefaultSort('created_date');
44
+ $this->setDefaultDir('DESC');
45
+
46
+ $this->_removeButton('reset');
47
+ $this->_removeButton('delete');
48
+ $this->_removeButton('save');
49
+ }
50
+
51
+ /**
52
+ * Get Novalnet transaction traces
53
+ *
54
+ * @param none
55
+ * @return string
56
+ */
57
+ public function getTransactionTraces()
58
+ {
59
+ return Mage::registry('novalnet_payment_transactiontraces');
60
+ }
61
+
62
+ /**
63
+ * Get payment method title
64
+ *
65
+ * @param none
66
+ * @return string
67
+ */
68
+ public function getPaymentTitle()
69
+ {
70
+ $title = '';
71
+ $order = Mage::getModel("sales/order")->loadByIncrementId(trim($this->getTransactionTraces()->getOrderId()));
72
+ if ($order->getPayment()) {
73
+ $paymentMethod = $order->getPayment()->getMethod();
74
+ $title = Mage::helper("novalnet_payment")->getPaymentModel($paymentMethod)->getConfigData('title');
75
+ }
76
+ return $title;
77
+ }
78
+
79
+ /**
80
+ * Get header text of transaction traces
81
+ *
82
+ * @param none
83
+ * @return string
84
+ */
85
+ public function getHeaderText()
86
+ {
87
+ $transStatus = $this->getTransactionTraces();
88
+ $text = Mage::helper('novalnet_payment')->__(
89
+ 'Order #%s | TID : %s ', $transStatus->getOrderId(), $transStatus->getTransactionId()
90
+ );
91
+ return $text;
92
+ }
93
+
94
+ }
app/code/community/Novalnet/Payment/Block/Adminhtml/{Transaction → Transactiontraces}/View/Form.php RENAMED
@@ -18,20 +18,20 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Block_Adminhtml_Transaction_View_Form extends Mage_Adminhtml_Block_Widget
27
  {
28
 
 
 
 
29
  public function __construct()
30
  {
31
- $this->_blockGroup = 'novalnet_payment';
32
- $this->_controller = 'adminhtml_transaction';
33
- $this->_headerText = Mage::helper('novalnet_payment')->__('Transactions');
34
-
35
  parent::__construct();
36
  }
37
 
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Block_Adminhtml_Transactiontraces_View_Form extends Mage_Adminhtml_Block_Widget
27
  {
28
 
29
+ /**
30
+ * Transaction traces view
31
+ */
32
  public function __construct()
33
  {
34
+ $this->_headerText = Mage::helper('novalnet_payment')->__('Transaction Traces');
 
 
 
35
  parent::__construct();
36
  }
37
 
app/code/community/Novalnet/Payment/Block/Adminhtml/Widget.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Widget extends Mage_Adminhtml_Block_Widget_Form_Container
27
- {
28
- /**
29
- * Set the configuration wizard template
30
- *
31
- */
32
- public function __construct()
33
- {
34
- parent::__construct();
35
- $this->setTemplate('configuration/wizard/index.phtml');
36
- }
37
-
38
- /**
39
- * Get child form html
40
- *
41
- * @return string
42
- */
43
- public function getFormHtml()
44
- {
45
- $this->getChild('form')->setData('action1', $this->getSaveUrl());
46
- return $this->getChildHtml('form');
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/{Payment/Method/Form/Sepa.php → Method/Form/Banktransfer.php} RENAMED
@@ -1,67 +1,72 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Form_Sepa extends Mage_Payment_Block_Form
27
- {
28
- /**
29
- * Init default template for block
30
- *
31
- */
32
- protected function _construct()
33
- {
34
- parent::_construct();
35
- $this->setTemplate('novalnet/payment/method/form/Sepa.phtml');
36
- }
37
-
38
- /**
39
- * Check whether Callback type allowed
40
- *
41
- * @return bool
42
- */
43
- public function isCallbackTypeCall()
44
- {
45
- return $this->getMethod()->isCallbackTypeCall();
46
- }
47
-
48
- /**
49
- * Novalnet Callback data getter
50
- *
51
- * @return string
52
- */
53
- public function getCallbackConfigData()
54
- {
55
- return $this->getMethod()->getNovalnetConfig('callback');
56
- }
57
-
58
- /**
59
- * Get information to end user from config
60
- *
61
- * @return string
62
- */
63
- public function getUserInfo()
64
- {
65
- return trim(strip_tags(trim($this->getMethod()->getConfigData('booking_reference'))));
66
- }
67
- }
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Form_Banktransfer extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Banktransfer.phtml');
36
+ }
37
+
38
+ /**
39
+ * Get information to end user from config
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function getUserInfo()
45
+ {
46
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
47
+ }
48
+
49
+ /**
50
+ * Get payment logo available status
51
+ *
52
+ * @param none
53
+ * @return boolean
54
+ */
55
+ public function logoAvailableStatus()
56
+ {
57
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
58
+ }
59
+
60
+ /**
61
+ * Get payment mode (test/live)
62
+ *
63
+ * @param none
64
+ * @return boolean
65
+ */
66
+ public function getPaymentMode()
67
+ {
68
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
69
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/{Payment/Method → Method}/Form/Cc.php RENAMED
@@ -1,90 +1,102 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Form_Cc extends Mage_Payment_Block_Form
27
- {
28
- /**
29
- * Init default template for block
30
- *
31
- */
32
- protected function _construct()
33
- {
34
- parent::_construct();
35
- $this->setTemplate('novalnet/payment/method/form/Cc.phtml');
36
- }
37
-
38
- /**
39
- * Retrieve availables Credit Card types
40
- *
41
- * @return array
42
- */
43
- public function getCcAvailableTypes()
44
- {
45
- $types = array(
46
- 'visacard' => 'Visa',
47
- 'mastercard' => 'MasterCard',
48
- 'amex' => 'American Express',
49
- 'maestro' => 'Maestro',
50
- 'cartasi' => 'CarteSi',
51
- );
52
- $method = $this->getMethod();
53
- if ($method) {
54
- $availableTypes = $method->getConfigData('cctypes');
55
- if ($availableTypes) {
56
- $availableTypes = explode(',', $availableTypes);
57
- foreach ($types as $code => $name) {
58
- if (!in_array($code, $availableTypes)) {
59
- unset($types[$code]);
60
- }
61
- }
62
- }
63
- }
64
- return $types;
65
- }
66
-
67
- /**
68
- * Retrieve payment configuration object
69
- *
70
- * @return Mage_Payment_Model_Config
71
- */
72
- protected function _getConfig()
73
- {
74
- if (!$this->_localConfig) {
75
- $this->_localConfig = Mage::getModel('payment/config');
76
- }
77
- return $this->_localConfig;
78
- }
79
-
80
- /**
81
- * Get information to end user from config
82
- *
83
- * @return string
84
- */
85
- public function getUserInfo()
86
- {
87
- return trim(strip_tags(trim($this->getMethod()->getConfigData('booking_reference'))));
88
- }
89
-
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Form_Cc extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Cc.phtml');
36
+ }
37
+
38
+ /**
39
+ * Retrieve availables Credit Card types
40
+ *
41
+ * @param none
42
+ * @return array
43
+ */
44
+ public function getCcAvailableTypes()
45
+ {
46
+ $types = array(
47
+ 'VI' => 'Visa',
48
+ 'MC' => 'MasterCard',
49
+ 'AE' => 'American Express',
50
+ 'TO' => 'Maestro',
51
+ 'T' => 'CarteSi',
52
+ );
53
+ $method = $this->getMethod();
54
+ if ($method) {
55
+ $availableTypes = $method->getConfigData('cc_types');
56
+ if ($availableTypes) {
57
+ $availableTypes = explode(',', $availableTypes);
58
+ foreach ($types as $code => $name) {
59
+ if (!in_array($code, $availableTypes)) {
60
+ unset($types[$code]);
61
+ }
62
+ }
63
+ }
64
+ }
65
+ return $types;
66
+ }
67
+
68
+ /**
69
+ * Get information to end user from config
70
+ *
71
+ * @param none
72
+ * @return string
73
+ */
74
+ public function getUserInfo()
75
+ {
76
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
77
+ }
78
+
79
+ /**
80
+ * Get payment logo available status
81
+ *
82
+ * @param none
83
+ * @return boolean
84
+ */
85
+ public function logoAvailableStatus()
86
+ {
87
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
88
+ }
89
+
90
+ /**
91
+ * Get payment mode (test/live)
92
+ *
93
+ * @param none
94
+ * @return boolean
95
+ */
96
+ public function getPaymentMode()
97
+ {
98
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
99
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
100
+ }
101
+
102
+ }
app/code/community/Novalnet/Payment/Block/{Payment/Method/Form/Invoice.php → Method/Form/Eps.php} RENAMED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Magento
5
  *
@@ -19,51 +18,55 @@
19
  * recommendation as well as a comment on merchant form
20
  * would be greatly appreciated.
21
  *
22
- * @category Novalnet
23
- * @package Novalnet_Payment
24
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
25
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
  */
27
- class Novalnet_Payment_Block_Payment_Method_Form_Invoice extends Mage_Payment_Block_Form
28
  {
 
29
  /**
30
  * Init default template for block
31
- *
32
  */
33
  protected function _construct()
34
  {
35
  parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/form/Invoice.phtml');
37
  }
38
 
39
  /**
40
- * Check whether Callback type allowed
41
  *
42
- * @return bool
 
43
  */
44
- public function isCallbackTypeCall()
45
  {
46
- return $this->getMethod()->isCallbackTypeCall();
47
  }
48
 
49
  /**
50
- * Novalnet Callback data getter
51
  *
52
- * @return string
 
53
  */
54
- public function getCallbackConfigData()
55
  {
56
- return $this->getMethod()->getNovalnetConfig('callback');
57
  }
58
 
59
  /**
60
- * Get information to end user from config
61
  *
62
- * @return string
 
63
  */
64
- public function getUserInfo()
65
  {
66
- return trim(strip_tags(trim($this->getMethod()->getConfigData('booking_reference'))));
 
67
  }
68
 
69
  }
1
  <?php
 
2
  /**
3
  * Magento
4
  *
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Block_Method_Form_Eps extends Mage_Payment_Block_Form
27
  {
28
+
29
  /**
30
  * Init default template for block
 
31
  */
32
  protected function _construct()
33
  {
34
  parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Eps.phtml');
36
  }
37
 
38
  /**
39
+ * Get information to end user from config
40
  *
41
+ * @param none
42
+ * @return string
43
  */
44
+ public function getUserInfo()
45
  {
46
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
47
  }
48
 
49
  /**
50
+ * Get payment logo available status
51
  *
52
+ * @param none
53
+ * @return boolean
54
  */
55
+ public function logoAvailableStatus()
56
  {
57
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
58
  }
59
 
60
  /**
61
+ * Get payment mode (test/live)
62
  *
63
+ * @param none
64
+ * @return boolean
65
  */
66
+ public function getPaymentMode()
67
  {
68
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
69
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
70
  }
71
 
72
  }
app/code/community/Novalnet/Payment/Block/Method/Form/Giropay.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Form_Giropay extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Giropay.phtml');
36
+ }
37
+
38
+ /**
39
+ * Get information to end user from config
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function getUserInfo()
45
+ {
46
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
47
+ }
48
+
49
+ /**
50
+ * Get payment logo available status
51
+ *
52
+ * @param none
53
+ * @return boolean
54
+ */
55
+ public function logoAvailableStatus()
56
+ {
57
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
58
+ }
59
+
60
+ /**
61
+ * Get payment mode (test/live)
62
+ *
63
+ * @param none
64
+ * @return boolean
65
+ */
66
+ public function getPaymentMode()
67
+ {
68
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
69
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/Method/Form/Ideal.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Form_Ideal extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Ideal.phtml');
36
+ }
37
+
38
+ /**
39
+ * Get information to end user from config
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function getUserInfo()
45
+ {
46
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
47
+ }
48
+
49
+ /**
50
+ * Get payment logo available status
51
+ *
52
+ * @param none
53
+ * @return boolean
54
+ */
55
+ public function logoAvailableStatus()
56
+ {
57
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
58
+ }
59
+
60
+ /**
61
+ * Get payment mode (test/live)
62
+ *
63
+ * @param none
64
+ * @return boolean
65
+ */
66
+ public function getPaymentMode()
67
+ {
68
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
69
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/Method/Form/Invoice.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Form_Invoice extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Invoice.phtml');
36
+ }
37
+
38
+ /**
39
+ * Get information to end user from config
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function getUserInfo()
45
+ {
46
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
47
+ }
48
+
49
+ /**
50
+ * Get payment logo available status
51
+ *
52
+ * @param none
53
+ * @return boolean
54
+ */
55
+ public function logoAvailableStatus()
56
+ {
57
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
58
+ }
59
+
60
+ /**
61
+ * Get payment mode (test/live)
62
+ *
63
+ * @param none
64
+ * @return boolean
65
+ */
66
+ public function getPaymentMode()
67
+ {
68
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
69
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/Method/Form/Paypal.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Form_Paypal extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Paypal.phtml');
36
+ }
37
+
38
+ /**
39
+ * Get information to end user from config
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function getUserInfo()
45
+ {
46
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
47
+ }
48
+
49
+ /**
50
+ * Get payment logo available status
51
+ *
52
+ * @param none
53
+ * @return boolean
54
+ */
55
+ public function logoAvailableStatus()
56
+ {
57
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
58
+ }
59
+
60
+ /**
61
+ * Get payment mode (test/live)
62
+ *
63
+ * @param none
64
+ * @return boolean
65
+ */
66
+ public function getPaymentMode()
67
+ {
68
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
69
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/Method/Form/Prepayment.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Form_Prepayment extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Prepayment.phtml');
36
+ }
37
+
38
+ /**
39
+ * Get information to end user from config
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function getUserInfo()
45
+ {
46
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
47
+ }
48
+
49
+ /**
50
+ * Get payment logo available status
51
+ *
52
+ * @param none
53
+ * @return boolean
54
+ */
55
+ public function logoAvailableStatus()
56
+ {
57
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
58
+ }
59
+
60
+ /**
61
+ * Get payment mode (test/live)
62
+ *
63
+ * @param none
64
+ * @return boolean
65
+ */
66
+ public function getPaymentMode()
67
+ {
68
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
69
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/Method/Form/Sepa.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Form_Sepa extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/form/Sepa.phtml');
36
+ }
37
+
38
+ /**
39
+ * Get information to end user from config
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function getUserInfo()
45
+ {
46
+ return trim(strip_tags($this->getMethod()->getConfigData('booking_reference')));
47
+ }
48
+
49
+ /**
50
+ * Get billing address information
51
+ *
52
+ * @param none
53
+ * @return array
54
+ */
55
+ public function getBillingInfo()
56
+ {
57
+ $checkoutSession = Mage::helper('novalnet_payment')->getCheckout();
58
+ return $checkoutSession->getQuote()->getBillingAddress();
59
+ }
60
+
61
+ /**
62
+ * Get form refill values
63
+ *
64
+ * @param none
65
+ * @return mixed
66
+ */
67
+ public function getRefillParams()
68
+ {
69
+ $refill = $this->getMethod()->getConfigData('sepa_audo_refill');
70
+ $paymentRefill = $this->getMethod()->getConfigData('sepa_payment_refill');
71
+
72
+ $panHash = '';
73
+ $methodSession = Mage::helper('novalnet_payment')->getMethodSession($this->getMethodCode());
74
+ $newForm = $methodSession ? $methodSession->getSepaNewForm() : '';
75
+
76
+ if ($paymentRefill && Mage::getSingleton('customer/session')->isLoggedIn()) {
77
+ // Order collection
78
+ $customerId = Mage::helper('novalnet_payment')->getCustomerId(); // Get customer id
79
+ $orderCollection = Mage::getResourceModel('sales/order_collection')
80
+ ->addAttributeToSelect('*')
81
+ ->addFieldToFilter('customer_id', $customerId);
82
+ $order = $orderCollection->getLastItem();
83
+ $paymentMethod = $order->getPayment() ? $order->getPayment()->getMethod() : '';
84
+ $maskedAccountInfo = $this->getMethod()->getMaskedAccountInfo();
85
+ $panHash = ($paymentMethod == Novalnet_Payment_Model_Config::NN_SEPA && $maskedAccountInfo)
86
+ ? $maskedAccountInfo['pan_hash'] : '';
87
+ } elseif ($refill) {
88
+ $panHash = $methodSession ? $methodSession->getSepaHash() : '';
89
+ }
90
+
91
+ return array('sepaHash' => $panHash, 'sepaNewForm' => $newForm);
92
+ }
93
+
94
+ /**
95
+ * Get payment logo available status
96
+ *
97
+ * @param none
98
+ * @return boolean
99
+ */
100
+ public function logoAvailableStatus()
101
+ {
102
+ return Mage::getStoreConfig('novalnet_global/novalnet/enable_payment_logo');
103
+ }
104
+
105
+ /**
106
+ * Get payment mode (test/live)
107
+ *
108
+ * @param none
109
+ * @return boolean
110
+ */
111
+ public function getPaymentMode()
112
+ {
113
+ $paymentMethod = Mage::getStoreConfig('novalnet_global/novalnet/live_mode');
114
+ return (!preg_match('/' . $this->getMethodCode() . '/i', $paymentMethod)) ? false : true;
115
+ }
116
+
117
+ }
app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Sepa.php → Method/Info/Banktransfer.php} RENAMED
@@ -1,70 +1,72 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Sepa extends Mage_Payment_Block_Info
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/info/Sepa.phtml');
37
- }
38
-
39
- /**
40
- * Render as PDF
41
- *
42
- * @return string
43
- */
44
- public function toPdf()
45
- {
46
- $this->setTemplate('novalnet/payment/method/pdf/Sepa.phtml');
47
- return $this->toHtml();
48
- }
49
-
50
- /**
51
- * Get some specific information
52
- *
53
- * @return array
54
- */
55
- public function getAdditionalData($key)
56
- {
57
- return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
58
- }
59
-
60
- /**
61
- * Retrieve payment method model
62
- *
63
- * @return Mage_Payment_Model_Method_Abstract
64
- */
65
- public function getMethod()
66
- {
67
- return $this->getInfo()->getMethodInstance();
68
- }
69
-
70
- }
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Info_Banktransfer extends Mage_Payment_Block_Info
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Banktransfer.phtml');
36
+ }
37
+
38
+ /**
39
+ * Render as PDF
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function toPdf()
45
+ {
46
+ $this->setTemplate('novalnet/method/pdf/Banktransfer.phtml');
47
+ return $this->toHtml();
48
+ }
49
+
50
+ /**
51
+ * Get some specific information
52
+ *
53
+ * @param string $key
54
+ * @return array
55
+ */
56
+ public function getAdditionalData($key)
57
+ {
58
+ return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
+ }
60
+
61
+ /**
62
+ * Retrieve payment method model
63
+ *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
+ */
67
+ public function getMethod()
68
+ {
69
+ return $this->getInfo()->getMethodInstance();
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Giropay.php → Method/Info/Cc.php} RENAMED
@@ -18,48 +18,39 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Giropay extends Mage_Payment_Block_Info
27
  {
28
 
29
  /**
30
  * Init default template for block
31
- *
32
  */
33
  protected function _construct()
34
  {
35
  parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/info/Giropay.phtml');
37
- }
38
-
39
- /**
40
- * Retrieve payment method model
41
- *
42
- * @return Mage_Payment_Model_Method_Abstract
43
- */
44
- public function getMethod()
45
- {
46
- return $this->getInfo()->getMethodInstance();
47
  }
48
 
49
  /**
50
  * Render as PDF
51
  *
 
52
  * @return string
53
  */
54
  public function toPdf()
55
  {
56
- $this->setTemplate('novalnet/payment/method/pdf/Giropay.phtml');
57
  return $this->toHtml();
58
  }
59
 
60
  /**
61
  * Get some specific information
62
  *
 
63
  * @return array
64
  */
65
  public function getAdditionalData($key)
@@ -67,4 +58,15 @@ class Novalnet_Payment_Block_Payment_Method_Info_Giropay extends Mage_Payment_Bl
67
  return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
68
  }
69
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Block_Method_Info_Cc extends Mage_Payment_Block_Info
27
  {
28
 
29
  /**
30
  * Init default template for block
 
31
  */
32
  protected function _construct()
33
  {
34
  parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Cc.phtml');
 
 
 
 
 
 
 
 
 
 
36
  }
37
 
38
  /**
39
  * Render as PDF
40
  *
41
+ * @param none
42
  * @return string
43
  */
44
  public function toPdf()
45
  {
46
+ $this->setTemplate('novalnet/method/pdf/Cc.phtml');
47
  return $this->toHtml();
48
  }
49
 
50
  /**
51
  * Get some specific information
52
  *
53
+ * @param string $key
54
  * @return array
55
  */
56
  public function getAdditionalData($key)
58
  return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
  }
60
 
61
+ /**
62
+ * Retrieve payment method model
63
+ *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
+ */
67
+ public function getMethod()
68
+ {
69
+ return $this->getInfo()->getMethodInstance();
70
+ }
71
+
72
  }
app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Invoice.php → Method/Info/Eps.php} RENAMED
@@ -18,53 +18,55 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Invoice extends Mage_Payment_Block_Info
27
  {
28
 
29
  /**
30
  * Init default template for block
31
- *
32
  */
33
  protected function _construct()
34
  {
35
  parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/info/Invoice.phtml');
37
  }
38
 
39
  /**
40
  * Render as PDF
41
  *
 
42
  * @return string
43
  */
44
  public function toPdf()
45
  {
46
- $this->setTemplate('novalnet/payment/method/pdf/Invoice.phtml');
47
  return $this->toHtml();
48
  }
49
 
50
  /**
51
- * Retrieve payment method model
52
  *
53
- * @return Mage_Payment_Model_Method_Abstract
 
54
  */
55
- public function getMethod()
56
  {
57
- return $this->getInfo()->getMethodInstance();
58
  }
59
 
60
  /**
61
- * Get some specific information
62
  *
63
- * @return array
 
64
  */
65
- public function getAdditionalData($key)
66
  {
67
- return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
68
  }
69
 
70
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Block_Method_Info_Eps extends Mage_Payment_Block_Info
27
  {
28
 
29
  /**
30
  * Init default template for block
 
31
  */
32
  protected function _construct()
33
  {
34
  parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Eps.phtml');
36
  }
37
 
38
  /**
39
  * Render as PDF
40
  *
41
+ * @param none
42
  * @return string
43
  */
44
  public function toPdf()
45
  {
46
+ $this->setTemplate('novalnet/method/pdf/Eps.phtml');
47
  return $this->toHtml();
48
  }
49
 
50
  /**
51
+ * Get some specific information
52
  *
53
+ * @param string $key
54
+ * @return array
55
  */
56
+ public function getAdditionalData($key)
57
  {
58
+ return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
  }
60
 
61
  /**
62
+ * Retrieve payment method model
63
  *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
  */
67
+ public function getMethod()
68
  {
69
+ return $this->getInfo()->getMethodInstance();
70
  }
71
 
72
  }
app/code/community/Novalnet/Payment/Block/Method/Info/Giropay.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Info_Giropay extends Mage_Payment_Block_Info
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Giropay.phtml');
36
+ }
37
+
38
+ /**
39
+ * Render as PDF
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function toPdf()
45
+ {
46
+ $this->setTemplate('novalnet/method/pdf/Giropay.phtml');
47
+ return $this->toHtml();
48
+ }
49
+
50
+ /**
51
+ * Get some specific information
52
+ *
53
+ * @param string $key
54
+ * @return array
55
+ */
56
+ public function getAdditionalData($key)
57
+ {
58
+ return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
+ }
60
+
61
+ /**
62
+ * Retrieve payment method model
63
+ *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
+ */
67
+ public function getMethod()
68
+ {
69
+ return $this->getInfo()->getMethodInstance();
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/Method/Info/Ideal.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Info_Ideal extends Mage_Payment_Block_Info
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Ideal.phtml');
36
+ }
37
+
38
+ /**
39
+ * Render as PDF
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function toPdf()
45
+ {
46
+ $this->setTemplate('novalnet/method/pdf/Ideal.phtml');
47
+ return $this->toHtml();
48
+ }
49
+
50
+ /**
51
+ * Get some specific information
52
+ *
53
+ * @param string $key
54
+ * @return array
55
+ */
56
+ public function getAdditionalData($key)
57
+ {
58
+ return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
+ }
60
+
61
+ /**
62
+ * Retrieve payment method model
63
+ *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
+ */
67
+ public function getMethod()
68
+ {
69
+ return $this->getInfo()->getMethodInstance();
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/Method/Info/Invoice.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Info_Invoice extends Mage_Payment_Block_Info
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Invoice.phtml');
36
+ }
37
+
38
+ /**
39
+ * Render as PDF
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function toPdf()
45
+ {
46
+ $this->setTemplate('novalnet/method/pdf/Invoice.phtml');
47
+ return $this->toHtml();
48
+ }
49
+
50
+ /**
51
+ * Get some specific information
52
+ *
53
+ * @param string $key
54
+ * @return array
55
+ */
56
+ public function getAdditionalData($key)
57
+ {
58
+ return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
+ }
60
+
61
+ /**
62
+ * Retrieve payment method model
63
+ *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
+ */
67
+ public function getMethod()
68
+ {
69
+ return $this->getInfo()->getMethodInstance();
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/Method/Info/Paypal.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Info_Paypal extends Mage_Payment_Block_Info
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Paypal.phtml');
36
+ }
37
+
38
+ /**
39
+ * Render as PDF
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function toPdf()
45
+ {
46
+ $this->setTemplate('novalnet/method/pdf/Paypal.phtml');
47
+ return $this->toHtml();
48
+ }
49
+
50
+ /**
51
+ * Get some specific information
52
+ *
53
+ * @param string $key
54
+ * @return array
55
+ */
56
+ public function getAdditionalData($key)
57
+ {
58
+ return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
+ }
60
+
61
+ /**
62
+ * Retrieve payment method model
63
+ *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
+ */
67
+ public function getMethod()
68
+ {
69
+ return $this->getInfo()->getMethodInstance();
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Cc.php → Method/Info/Prepayment.php} RENAMED
@@ -1,70 +1,72 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Cc extends Mage_Payment_Block_Info
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/info/Cc.phtml');
37
- }
38
-
39
- /**
40
- * Render as PDF
41
- *
42
- * @return string
43
- */
44
- public function toPdf()
45
- {
46
- $this->setTemplate('novalnet/payment/method/pdf/Cc.phtml');
47
- return $this->toHtml();
48
- }
49
-
50
- /**
51
- * Get some specific information
52
- *
53
- * @return array
54
- */
55
- public function getAdditionalData($key)
56
- {
57
- return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
58
- }
59
-
60
- /**
61
- * Retrieve payment method model
62
- *
63
- * @return Mage_Payment_Model_Method_Abstract
64
- */
65
- public function getMethod()
66
- {
67
- return $this->getInfo()->getMethodInstance();
68
- }
69
-
70
- }
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Info_Prepayment extends Mage_Payment_Block_Info
27
+ {
28
+
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Prepayment.phtml');
36
+ }
37
+
38
+ /**
39
+ * Render as PDF
40
+ *
41
+ * @param none
42
+ * @return string
43
+ */
44
+ public function toPdf()
45
+ {
46
+ $this->setTemplate('novalnet/method/pdf/Prepayment.phtml');
47
+ return $this->toHtml();
48
+ }
49
+
50
+ /**
51
+ * Get some specific information
52
+ *
53
+ * @param string $key
54
+ * @return array
55
+ */
56
+ public function getAdditionalData($key)
57
+ {
58
+ return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
+ }
60
+
61
+ /**
62
+ * Retrieve payment method model
63
+ *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
+ */
67
+ public function getMethod()
68
+ {
69
+ return $this->getInfo()->getMethodInstance();
70
+ }
71
+
72
+ }
app/code/community/Novalnet/Payment/Block/{Payment/Method/Info/Prepayment.php → Method/Info/Sepa.php} RENAMED
@@ -18,52 +18,55 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Prepayment extends Mage_Payment_Block_Info
27
  {
 
28
  /**
29
  * Init default template for block
30
- *
31
  */
32
  protected function _construct()
33
  {
34
  parent::_construct();
35
- $this->setTemplate('novalnet/payment/method/info/Prepayment.phtml');
36
  }
37
 
38
  /**
39
  * Render as PDF
40
- *
 
41
  * @return string
42
  */
43
  public function toPdf()
44
  {
45
- $this->setTemplate('novalnet/payment/method/pdf/Prepayment.phtml');
46
  return $this->toHtml();
47
  }
48
 
49
  /**
50
- * Retrieve payment method model
51
  *
52
- * @return Mage_Payment_Model_Method_Abstract
 
53
  */
54
- public function getMethod()
55
  {
56
- return $this->getInfo()->getMethodInstance();
57
  }
58
 
59
  /**
60
- * Get some specific information
61
  *
62
- * @return array
 
63
  */
64
- public function getAdditionalData($key)
65
  {
66
- return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
67
  }
68
 
69
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Block_Method_Info_Sepa extends Mage_Payment_Block_Info
27
  {
28
+
29
  /**
30
  * Init default template for block
 
31
  */
32
  protected function _construct()
33
  {
34
  parent::_construct();
35
+ $this->setTemplate('novalnet/method/info/Sepa.phtml');
36
  }
37
 
38
  /**
39
  * Render as PDF
40
+ *
41
+ * @param none
42
  * @return string
43
  */
44
  public function toPdf()
45
  {
46
+ $this->setTemplate('novalnet/method/pdf/Sepa.phtml');
47
  return $this->toHtml();
48
  }
49
 
50
  /**
51
+ * Get some specific information
52
  *
53
+ * @param string $key
54
+ * @return array
55
  */
56
+ public function getAdditionalData($key)
57
  {
58
+ return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
59
  }
60
 
61
  /**
62
+ * Retrieve payment method model
63
  *
64
+ * @param none
65
+ * @return Mage_Payment_Model_Method_Abstract
66
  */
67
+ public function getMethod()
68
  {
69
+ return $this->getInfo()->getMethodInstance();
70
  }
71
 
72
  }
app/code/community/Novalnet/Payment/Block/Method/Redirect.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * http://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Block_Method_Redirect extends Mage_Core_Block_Abstract
27
+ {
28
+
29
+ protected function _toHtml()
30
+ {
31
+ $helper = Mage::helper('novalnet_payment'); // Get Novalnet payment helper
32
+ $paymentCode = $this->getOrder()->getPayment()->getMethodInstance()->getCode(); // Get payment method code
33
+ $actionUrl = $helper->getPayportUrl('redirect', $paymentCode); // Get Novalnet payport URL
34
+ $params = $helper->getMethodSession($paymentCode)->getPaymentReqData(); // Get payment method session
35
+
36
+ // Create form
37
+ $form = new Varien_Data_Form();
38
+ $form->setAction($actionUrl)
39
+ ->setId($paymentCode)
40
+ ->setName($paymentCode)
41
+ ->setMethod(Novalnet_Payment_Model_Config::NOVALNET_RETURN_METHOD)
42
+ ->setUseContainer(true);
43
+ foreach ($params->getData() as $field => $value) {
44
+ $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
45
+ }
46
+
47
+ // Save payment transaction request data
48
+ $request = $helper->getModel('Service_Api_Response')->removeSensitiveData($params, $paymentCode);
49
+ $transactionTraces = $helper->getModel('Mysql4_TransactionTraces');
50
+ $transactionTraces->setOrderId($request->getOrderNo())
51
+ ->setRequestData(serialize($request->getData()))
52
+ ->setCreatedDate($helper->getCurrentDateTime())
53
+ ->save();
54
+
55
+ $submitButton = new Varien_Data_Form_Element_Submit(
56
+ array(
57
+ 'value' => $this->__('Click here if you are not redirected within 10 seconds...'),
58
+ )
59
+ );
60
+ $submitButton->setId("submit_to_{$paymentCode}_button");
61
+ $form->addElement($submitButton);
62
+
63
+ $html = '<html><body>';
64
+ $html.= $this->__('You will be redirected to Novalnet AG in a few seconds.');
65
+ $html.= $form->toHtml();
66
+ $html.= '<script type="text/javascript">document.getElementById("' . $paymentCode . '").submit();</script>';
67
+ $html.= '</body></html>';
68
+ return $html;
69
+ }
70
+
71
+ }
app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Banktransfer.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Form_Banktransfer extends Mage_Payment_Block_Form
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/form/Banktransfer.phtml');
37
- }
38
-
39
- /**
40
- * Get information to end user from config
41
- *
42
- * @return string
43
- */
44
- public function getUserInfo()
45
- {
46
- return trim(strip_tags(trim($this->getMethod()->getConfigData('booking_reference'))));
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Eps.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Form_Eps extends Mage_Payment_Block_Form
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/form/Eps.phtml');
37
- }
38
-
39
- /**
40
- * Get information to end user from config
41
- *
42
- * @return string
43
- */
44
- public function getUserInfo()
45
- {
46
- return trim(strip_tags(trim($this->getMethod()->getConfigData('booking_reference'))));
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Giropay.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Form_Giropay extends Mage_Payment_Block_Form
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/form/Giropay.phtml');
37
- }
38
-
39
- /**
40
- * Get information to end user from config
41
- *
42
- * @return string
43
- */
44
- public function getUserInfo()
45
- {
46
- return trim(strip_tags(trim($this->getMethod()->getConfigData('booking_reference'))));
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Ideal.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Form_Ideal extends Mage_Payment_Block_Form
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/form/Ideal.phtml');
37
- }
38
-
39
- /**
40
- * Get information to end user from config
41
- *
42
- * @return string
43
- */
44
- public function getUserInfo()
45
- {
46
- return trim(strip_tags(trim($this->getMethod()->getConfigData('booking_reference'))));
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/Form/Paypal.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Form_Paypal extends Mage_Payment_Block_Form
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/form/Paypal.phtml');
37
- }
38
-
39
- /**
40
- * Get information to end user from config
41
- *
42
- * @return string
43
- */
44
- public function getUserInfo()
45
- {
46
- return trim(strip_tags(trim($this->getMethod()->getConfigData('booking_reference'))));
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/Info/Banktransfer.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Banktransfer extends Mage_Payment_Block_Info
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/info/Banktransfer.phtml');
37
- }
38
-
39
- /**
40
- * Retrieve payment method model
41
- *
42
- * @return Mage_Payment_Model_Method_Abstract
43
- */
44
- public function getMethod()
45
- {
46
- return $this->getInfo()->getMethodInstance();
47
- }
48
-
49
- /**
50
- * Render as PDF
51
- *
52
- * @return string
53
- */
54
- public function toPdf()
55
- {
56
- $this->setTemplate('novalnet/payment/method/pdf/Banktransfer.phtml');
57
- return $this->toHtml();
58
- }
59
-
60
- /**
61
- * Get some specific information
62
- *
63
- * @return array
64
- */
65
- public function getAdditionalData($key)
66
- {
67
- return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
68
- }
69
-
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/Info/Eps.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Eps extends Mage_Payment_Block_Info
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/info/Eps.phtml');
37
- }
38
-
39
- /**
40
- * Retrieve payment method model
41
- *
42
- * @return Mage_Payment_Model_Method_Abstract
43
- */
44
- public function getMethod()
45
- {
46
- return $this->getInfo()->getMethodInstance();
47
- }
48
-
49
- /**
50
- * Render as PDF
51
- *
52
- * @return string
53
- */
54
- public function toPdf()
55
- {
56
- $this->setTemplate('novalnet/payment/method/pdf/Eps.phtml');
57
- return $this->toHtml();
58
- }
59
-
60
- /**
61
- * Get some specific information
62
- *
63
- * @return array
64
- */
65
- public function getAdditionalData($key)
66
- {
67
- return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
68
- }
69
-
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/Info/Ideal.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Ideal extends Mage_Payment_Block_Info
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- */
32
- protected function _construct()
33
- {
34
- parent::_construct();
35
- $this->setTemplate('novalnet/payment/method/info/Ideal.phtml');
36
- }
37
-
38
- /**
39
- * Retrieve payment method model
40
- *
41
- * @return Mage_Payment_Model_Method_Abstract
42
- */
43
- public function getMethod()
44
- {
45
- return $this->getInfo()->getMethodInstance();
46
- }
47
-
48
- /**
49
- * Render as PDF
50
- *
51
- * @return string
52
- */
53
- public function toPdf()
54
- {
55
- $this->setTemplate('novalnet/payment/method/pdf/Ideal.phtml');
56
- return $this->toHtml();
57
- }
58
-
59
- /**
60
- * Get some specific information
61
- *
62
- * @return array
63
- */
64
- public function getAdditionalData($key)
65
- {
66
- return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
67
- }
68
-
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/Info/Paypal.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_Info_Paypal extends Mage_Payment_Block_Info
27
- {
28
-
29
- /**
30
- * Init default template for block
31
- *
32
- */
33
- protected function _construct()
34
- {
35
- parent::_construct();
36
- $this->setTemplate('novalnet/payment/method/info/Paypal.phtml');
37
- }
38
-
39
- /**
40
- * Retrieve payment method model
41
- *
42
- * @return Mage_Payment_Model_Method_Abstract
43
- */
44
- public function getMethod()
45
- {
46
- return $this->getInfo()->getMethodInstance();
47
- }
48
-
49
- /**
50
- * Render as PDF
51
- *
52
- * @return string
53
- */
54
- public function toPdf()
55
- {
56
- $this->setTemplate('novalnet/payment/method/pdf/Paypal.phtml');
57
- return $this->toHtml();
58
- }
59
-
60
- /**
61
- * Get some specific information
62
- *
63
- * @return array
64
- */
65
- public function getAdditionalData($key)
66
- {
67
- return Mage::helper('novalnet_payment')->getAdditionalData($this->getInfo(), $key);
68
- }
69
-
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Payment/Method/NovalnetRedirect.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * http://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Payment_Method_NovalnetRedirect extends Mage_Core_Block_Abstract
27
- {
28
-
29
- protected function _toHtml()
30
- {
31
- $payment = $this->getOrder()->getPayment();
32
- $paymentObj = $payment->getMethodInstance();
33
- $helper = Mage::helper('novalnet_payment');
34
- $paymentCode = $payment->getMethodInstance()->getCode();
35
- $actionUrl = $helper->getPayportUrl('redirect', $paymentCode);
36
- $authorizeKey = $paymentObj->loadAffAccDetail();
37
-
38
- if ($authorizeKey) {
39
- $form = new Varien_Data_Form();
40
- $form->setAction($actionUrl)
41
- ->setId($paymentCode)
42
- ->setName($paymentCode)
43
- ->setMethod(Novalnet_Payment_Model_Config::NOVALNET_RETURN_METHOD)
44
- ->setUseContainer(true);
45
-
46
- $checkoutSession = $helper->getCheckoutSession();
47
- $profileId = $checkoutSession->getRecurringProfileNumber();
48
- $getFormData = (!empty($profileId)
49
- ? $checkoutSession->getPaymentReqData()->getData() : $paymentObj->buildRequest()->getData());
50
- foreach ($getFormData as $field => $value) {
51
- $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
52
- }
53
- $authCode = $paymentCode == Novalnet_Payment_Model_Config::NN_CC ? $getFormData['auth_code']
54
- : $helper->getDecodedParam($getFormData['auth_code'], $authorizeKey);
55
- $productId = $paymentCode == Novalnet_Payment_Model_Config::NN_CC ? $getFormData['product']
56
- : $helper->getDecodedParam($getFormData['product'], $authorizeKey);
57
- $tariffId = $paymentCode == Novalnet_Payment_Model_Config::NN_CC ? $getFormData['tariff']
58
- : $helper->getDecodedParam($getFormData['tariff'], $authorizeKey);
59
- $data = array('vendor' => $getFormData['vendor'],
60
- 'auth_code' => $authCode,
61
- 'product' => $productId,
62
- 'tariff' => $tariffId,
63
- 'key' => $getFormData['key'],
64
- 'authorize_key' => $authorizeKey
65
- );
66
-
67
- $payment->setAdditionalData(serialize($data))
68
- ->save();
69
-
70
- //Save Transaction request data
71
- $modNnTransOverview = $helper->getModelTransactionOverview();
72
- $modNnTransOverview->setOrderId($getFormData['order_no'])
73
- ->setRequestData(serialize($getFormData))
74
- ->setCreatedDate($helper->getCurrentDateTime())
75
- ->save();
76
-
77
- $checkoutSession->unsRecurringProfileNumber(); //unset recurring profile data
78
-
79
- // IE & Firefox will not submit form if the form is full of hidden fileds.
80
- $form->addField('continue', 'submit', array('name' => 'Continue', 'value' => $this->__('Continue')));
81
-
82
- $html = '<html><body>';
83
- $html.= $this->__('You will be redirected to Novalnet AG in a few seconds.');
84
- $html.= $form->toHtml();
85
- $html.= '<script type="text/javascript">document.getElementById("' . $paymentCode . '").submit();</script>';
86
- $html.= '</body></html>';
87
- return $html;
88
- } else {
89
- $html = $this->__('Theres no password defined');
90
- return $html;
91
- }
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/{Sales/Recurring → Recurring}/Profile/View.php RENAMED
@@ -18,26 +18,25 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
- /**
28
- * Recurring profile view
29
- */
30
- class Novalnet_Payment_Block_Sales_Recurring_Profile_View extends Mage_Sales_Block_Recurring_Profile_View
31
  {
32
 
33
  /**
34
  * Prepare recurring profile view
35
  *
 
 
36
  */
37
  public function prepareViewData()
38
  {
39
  if (preg_match("/novalnet/i", $this->_profile->getMethodCode())) {
40
- $this->setTemplate('novalnet/sales/recurring/profile/view.phtml');
41
  }
42
 
43
  $helper = Mage::helper('novalnet_payment');
@@ -56,65 +55,94 @@ class Novalnet_Payment_Block_Sales_Recurring_Profile_View extends Mage_Sales_Blo
56
 
57
  $select = Mage::app()->getLayout()->createBlock('core/html_select')
58
  ->setName("cancel_reason")
59
- ->setId("reason-subscribe")
60
  ->setOptions(explode(",", $lang));
61
 
62
- $this->addData(array(
 
63
  'reference_id' => $this->_profile->getReferenceId(),
64
  'can_cancel' => $this->_profile->canCancel(),
65
- 'cancel_url' => $this->getUrl('*/*/updateState', array('profile' => $this->_profile->getId(),
66
- 'action' => 'cancel')),
 
 
67
  'can_suspend' => $this->_profile->canSuspend(),
68
- 'suspend_url' => $this->getUrl('*/*/updateState', array('profile' => $this->_profile->getId(),
69
- 'action' => 'suspend')),
 
 
70
  'can_activate' => $this->_profile->canActivate(),
71
- 'activate_url' => $this->getUrl('*/*/updateState', array('profile' => $this->_profile->getId(),
72
- 'action' => 'activate')),
 
 
73
  'can_update' => $this->_profile->canFetchUpdate(),
74
  'update_url' => $this->getUrl('*/*/updateProfile', array('profile' => $this->_profile->getId())),
75
  'back_url' => $this->getUrl('*/*/'),
76
  'confirmation_message' => Mage::helper('sales')->__('Are you sure you want to do this?'),
77
  'cancel_reason' => $select->getHtml(),
78
- ));
 
79
  }
80
 
81
  /**
82
  * Prepare profile schedule info
83
  *
 
 
84
  */
85
  public function prepareScheduleInfo()
86
  {
87
  $this->_shouldRenderInfo = true;
88
- $getPaymentname = $this->_profile->getMethodCode();
89
- $paymentName = array(
90
- Novalnet_Payment_Model_Config::NN_PREPAYMENT,
91
- Novalnet_Payment_Model_Config::NN_INVOICE,
92
- Novalnet_Payment_Model_Config::NN_CC,
93
- Novalnet_Payment_Model_Config::NN_SEPA
94
- );
95
- $m = 0;
96
- if (!in_array($getPaymentname, $paymentName)) {
97
- $m = 1;
98
  foreach (array('start_datetime', 'suspension_threshold') as $key) {
99
- $this->_addInfo(array(
 
100
  'label' => $this->_profile->getFieldLabel($key),
101
  'value' => $this->_profile->renderData($key),
102
- ));
 
103
  }
104
  }
 
105
  foreach ($this->_profile->exportScheduleInfo() as $i) {
106
- if (!$m && $i->getTitle() != 'Trial Period') {
107
- $this->_addInfo(array(
 
108
  'label' => $i->getTitle(),
109
  'value' => $i->getSchedule(),
110
- ));
111
- } else if ($m == 1) {
112
- $this->_addInfo(array(
 
 
113
  'label' => $i->getTitle(),
114
  'value' => $i->getSchedule(),
115
- ));
 
116
  }
117
  }
118
  }
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
+ class Novalnet_Payment_Block_Recurring_Profile_View extends Mage_Sales_Block_Recurring_Profile_View
 
 
 
28
  {
29
 
30
  /**
31
  * Prepare recurring profile view
32
  *
33
+ * @param none
34
+ * @return none
35
  */
36
  public function prepareViewData()
37
  {
38
  if (preg_match("/novalnet/i", $this->_profile->getMethodCode())) {
39
+ $this->setTemplate('novalnet/recurring/profile/view.phtml');
40
  }
41
 
42
  $helper = Mage::helper('novalnet_payment');
55
 
56
  $select = Mage::app()->getLayout()->createBlock('core/html_select')
57
  ->setName("cancel_reason")
58
+ ->setId("reason-unsubscribe")
59
  ->setOptions(explode(",", $lang));
60
 
61
+ $this->addData(
62
+ array(
63
  'reference_id' => $this->_profile->getReferenceId(),
64
  'can_cancel' => $this->_profile->canCancel(),
65
+ 'cancel_url' => $this->getUrl(
66
+ '*/*/updateState', array('profile' => $this->_profile->getId(),
67
+ 'action' => 'cancel')
68
+ ),
69
  'can_suspend' => $this->_profile->canSuspend(),
70
+ 'suspend_url' => $this->getUrl(
71
+ '*/*/updateState', array('profile' => $this->_profile->getId(),
72
+ 'action' => 'suspend')
73
+ ),
74
  'can_activate' => $this->_profile->canActivate(),
75
+ 'activate_url' => $this->getUrl(
76
+ '*/*/updateState', array('profile' => $this->_profile->getId(),
77
+ 'action' => 'activate')
78
+ ),
79
  'can_update' => $this->_profile->canFetchUpdate(),
80
  'update_url' => $this->getUrl('*/*/updateProfile', array('profile' => $this->_profile->getId())),
81
  'back_url' => $this->getUrl('*/*/'),
82
  'confirmation_message' => Mage::helper('sales')->__('Are you sure you want to do this?'),
83
  'cancel_reason' => $select->getHtml(),
84
+ )
85
+ );
86
  }
87
 
88
  /**
89
  * Prepare profile schedule info
90
  *
91
+ * @param none
92
+ * @return none
93
  */
94
  public function prepareScheduleInfo()
95
  {
96
  $this->_shouldRenderInfo = true;
97
+ $paymentCode = $this->_profile->getMethodCode();
98
+ $recurringPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('recurringPayments');
99
+
100
+ $subscriptionFlag = 0;
101
+ if (!in_array($paymentCode, $recurringPayments)) {
102
+ $subscriptionFlag = 1;
 
 
 
 
103
  foreach (array('start_datetime', 'suspension_threshold') as $key) {
104
+ $this->_addInfo(
105
+ array(
106
  'label' => $this->_profile->getFieldLabel($key),
107
  'value' => $this->_profile->renderData($key),
108
+ )
109
+ );
110
  }
111
  }
112
+
113
  foreach ($this->_profile->exportScheduleInfo() as $i) {
114
+ if (!$subscriptionFlag && $i->getTitle() != 'Trial Period') {
115
+ $this->_addInfo(
116
+ array(
117
  'label' => $i->getTitle(),
118
  'value' => $i->getSchedule(),
119
+ )
120
+ );
121
+ } else if ($subscriptionFlag == 1) {
122
+ $this->_addInfo(
123
+ array(
124
  'label' => $i->getTitle(),
125
  'value' => $i->getSchedule(),
126
+ )
127
+ );
128
  }
129
  }
130
  }
131
 
132
+ /**
133
+ * Get transaction information
134
+ *
135
+ * @param none
136
+ * @return Varien_Object
137
+ */
138
+ public function getTransactionStatus()
139
+ {
140
+ $transactionId = $this->getReferenceId();
141
+ // load transaction status information
142
+ $helper = Mage::helper('novalnet_payment'); // Novalnet payment helper
143
+ $transactionStatus = $helper->getModel('Mysql4_TransactionStatus')
144
+ ->loadByAttribute('transaction_no', $transactionId);
145
+ return $transactionStatus;
146
+ }
147
+
148
  }
app/code/community/Novalnet/Payment/Block/Sales/Order/Creditmemo/Totals.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * Part of the payment module of Novalnet AG
17
- * https://www.novalnet.de
18
- * If you have found this script useful a small
19
- * recommendation as well as a comment on merchant form
20
- * would be greatly appreciated.
21
- *
22
- * @category Novalnet
23
- * @package Novalnet_Payment
24
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
25
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
- */
27
- class Novalnet_Payment_Block_Sales_Order_Creditmemo_Totals extends Mage_Sales_Block_Order_Creditmemo_Totals
28
- {
29
- /**
30
- * Initialize creditmemo totals array
31
- *
32
- * @return Mage_Sales_Block_Order_Totals
33
- */
34
- protected function _initTotals()
35
- {
36
- parent::_initTotals();
37
-
38
- $helper = Mage::helper('novalnet_payment');
39
- $amountchangedvalue = $helper->getAmountCollection($this->getOrder()->getId(), 1, NULL);
40
- if ($amountchangedvalue) {
41
- $this->_totals['refund_amount_changed'] = new Varien_Object(array(
42
- 'code' => 'refund_amount_changed',
43
- 'strong' => true,
44
- 'value' => $this->getSource()->getGrandTotal(),
45
- 'base_value' => $this->getSource()->getBaseGrandTotal(),
46
- 'label' => Mage::helper('sales')->__('Novalnet refunded Amount'),
47
- 'area' => 'footer'
48
- ));
49
-
50
- $this->_totals['amount_changed'] = new Varien_Object(array(
51
- 'code' => 'amount_changed',
52
- 'strong' => true,
53
- 'value' => $amountchangedvalue,
54
- 'base_value' => $amountchangedvalue,
55
- 'label' => Mage::helper('sales')->__('Novalnet Transaction Amount'),
56
- 'area' => 'footer'
57
- ));
58
- }
59
-
60
- return $this;
61
- }
62
-
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Sales/Order/Invoice/Totals.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * Part of the payment module of Novalnet AG
17
- * https://www.novalnet.de
18
- * If you have found this script useful a small
19
- * recommendation as well as a comment on merchant form
20
- * would be greatly appreciated.
21
- *
22
- * @category Novalnet
23
- * @package Novalnet_Payment
24
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
25
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
- */
27
- class Novalnet_Payment_Block_Sales_Order_Invoice_Totals extends Mage_Sales_Block_Order_Invoice_Totals
28
- {
29
-
30
- /**
31
- * Initialize order totals array
32
- *
33
- * @return Mage_Sales_Block_Order_Totals
34
- */
35
- protected function _initTotals()
36
- {
37
- parent::_initTotals();
38
-
39
- $helper = Mage::helper('novalnet_payment');
40
- $amountchangedvalue = $helper->getAmountCollection($this->getOrder()->getId(), 1, NULL);
41
- $grandtotal = $this->getOrder()->getGrandTotal();
42
- $adjustmentamount = -($this->getOrder()->getGrandTotal() - $amountchangedvalue);
43
- if ($amountchangedvalue) {
44
- $this->_totals['adjust_amount_changed'] = new Varien_Object(array(
45
- 'code' => 'adjust_amount_changed',
46
- 'strong' => true,
47
- 'value' => $adjustmentamount,
48
- 'base_value' => $adjustmentamount,
49
- 'label' => Mage::helper('sales')->__('Novalnet Adjusted Amount'),
50
- 'area' => 'footer'
51
- ));
52
- $this->_totals['amount_changed'] = new Varien_Object(array(
53
- 'code' => 'amount_changed',
54
- 'strong' => true,
55
- 'value' => $amountchangedvalue,
56
- 'base_value' => $amountchangedvalue,
57
- 'label' => Mage::helper('sales')->__('Novalnet Transaction Amount'),
58
- 'area' => 'footer'
59
- ));
60
- }
61
-
62
- return $this;
63
- }
64
-
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Block/Sales/Order/Totals.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * Part of the payment module of Novalnet AG
17
- * https://www.novalnet.de
18
- * If you have found this script useful a small
19
- * recommendation as well as a comment on merchant form
20
- * would be greatly appreciated.
21
- *
22
- * @category Novalnet
23
- * @package Novalnet_Payment
24
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
25
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
- */
27
- class Novalnet_Payment_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals
28
- {
29
- /**
30
- * Initialize order totals array
31
- *
32
- * @return Mage_Sales_Block_Order_Totals
33
- */
34
- protected function _initTotals()
35
- {
36
- parent::_initTotals();
37
-
38
- $helper = Mage::helper('novalnet_payment');
39
- $amountchangedvalue = $helper->getAmountCollection($this->getOrder()->getId(), 1, NULL);
40
- if ($amountchangedvalue) {
41
- $adjustmentamount = -($this->getOrder()->getGrandTotal() - $amountchangedvalue);
42
- $this->_totals['adjust_amount_changed'] = new Varien_Object(array(
43
- 'code' => 'adjust_amount_changed',
44
- 'strong' => true,
45
- 'value' => $adjustmentamount,
46
- 'base_value' => $adjustmentamount,
47
- 'label' => Mage::helper('sales')->__('Novalnet Adjusted Amount'),
48
- 'area' => 'footer'
49
- ));
50
-
51
- $this->_totals['amount_changed'] = new Varien_Object(array(
52
- 'code' => 'amount_changed',
53
- 'strong' => true,
54
- 'value' => $amountchangedvalue,
55
- 'base_value' => $amountchangedvalue,
56
- 'label' => Mage::helper('sales')->__('Novalnet Transaction Amount'),
57
- 'area' => 'footer'
58
- ));
59
- }
60
-
61
- return $this;
62
- }
63
-
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Helper/AssignData.php DELETED
@@ -1,432 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Helper_AssignData extends Novalnet_Payment_Helper_Data
27
- {
28
- /**
29
- * Name library directory.
30
- */
31
- const NAME_DIR_JS = 'novalnet/';
32
-
33
- /**
34
- * Novalnet script files
35
- *
36
- * @return array
37
- */
38
- protected $_files = array(
39
- 'novalnetJquery.js',
40
- 'novalnetsepa.js'
41
- );
42
-
43
- /**
44
- * Return path file.
45
- *
46
- * @param $file
47
- * @return string
48
- */
49
- public function getJQueryPath($file)
50
- {
51
- return self::NAME_DIR_JS . $file;
52
- }
53
-
54
- /**
55
- * Return list files.
56
- *
57
- * @return array
58
- */
59
- public function getFiles()
60
- {
61
- return $this->_files;
62
- }
63
-
64
- /**
65
- * Assign Form Data in quote instance based on payment method
66
- *
67
- * $param string $paymentCode
68
- * $param varien_object $data
69
- * $param instance $infoInstance
70
- * @return Mage_Payment_Model_Abstract Object
71
- */
72
- public function assignNovalnetData($paymentCode, $data, $infoInstance)
73
- {
74
- if ($paymentCode) {
75
- if (!($data instanceof Varien_Object)) {
76
- $data = new Varien_Object($data);
77
- }
78
- $this->getCheckout()->setRefilldatavalues($data);
79
- switch ($paymentCode) {
80
- case Novalnet_Payment_Model_Config::NN_SEPA:
81
- $infoInstance->setNnCallbackTelNovalnetSepa($data->getCallbackTel())
82
- ->setNnCallbackPinNovalnetSepa(trim($data->getCallbackPin()))
83
- ->setNnNewCallbackPinNovalnetSepa($data->getNewCallbackPin())
84
- ->setSepaDuedate($this->getModel($paymentCode)->getNovalnetConfig('sepa_due_date'))
85
- ->setCallbackPinValidationFlag(true);
86
- $this->getCheckout()->setSepaHash($this->novalnetCardDetails('result_sepa_hash'))
87
- ->setSepaUniqueId($this->novalnetCardDetails('result_mandate_unique'))
88
- ->setNnPaymentCode($paymentCode);
89
- break;
90
- case Novalnet_Payment_Model_Config::NN_INVOICE:
91
- $infoInstance->setNnCallbackTelNovalnetInvoice($data->getCallbackTel())
92
- ->setNnCallbackPinNovalnetInvoice(trim($data->getCallbackPin()))
93
- ->setNnNewCallbackPinNovalnetInvoice($data->getNewCallbackPin())
94
- ->setCallbackPinValidationFlag(true);
95
- $this->getCheckout()->setNnPaymentCode($paymentCode);
96
- break;
97
- }
98
- }
99
- }
100
-
101
- /**
102
- * validate Novalnet form data
103
- *
104
- * $param string $paymentCode
105
- * $param instance $infoInstance
106
- * throw Mage Exception
107
- */
108
- public function validateNovalnetData($paymentCode, $infoInstance)
109
- {
110
- switch ($paymentCode) {
111
- case Novalnet_Payment_Model_Config::NN_SEPA:
112
- $paymentInfo = $this->novalnetCardDetails('payment');
113
- $sepaHolder = $paymentInfo['account_holder'];
114
- $sepaDueDate = $infoInstance->getSepaDuedate();
115
- $callbackVal = $this->getModel($paymentCode)->getNovalnetConfig('callback');
116
- $infoObject = ($infoInstance->getOrder()) ? $infoInstance->getOrder() : $infoInstance->getQuote();
117
- $countryCode = strtoupper($infoObject->getBillingAddress()->getCountryId());
118
-
119
- if (strlen($sepaDueDate) > 0 && ($sepaDueDate < 7 || !$this->checkIsNumeric($sepaDueDate))) {
120
- Mage::throwException($this->__('SEPA Due date is not valid') . '!');
121
- } elseif (!$this->novalnetCardDetails('nnsepa_iban_confirmed')) {
122
- Mage::throwException($this->__('Please accept the SEPA direct debit mandate'));
123
- } elseif (!$this->getCheckout()->getSepaHash() || !$this->getCheckout()->getSepaUniqueId()) {
124
- Mage::throwException($this->__('Your account details are invalid'));
125
- } elseif (!$sepaHolder || preg_match('/[#%\^<>@$=*!]/', $sepaHolder)) {
126
- Mage::throwException($this->__('Your account details are invalid') . '!');
127
- } elseif ($this->checkCallbackAmount($paymentCode)
128
- && $callbackVal == '1' && !$infoInstance->getNnCallbackTelNovalnetSepa()
129
- && $this->isCallbackTypeAllowed($countryCode)) {
130
- Mage::throwException($this->__('Please enter your telephone number') . '!');
131
- } elseif ($this->checkCallbackAmount($paymentCode)
132
- && $callbackVal == '2' && !$infoInstance->getNnCallbackTelNovalnetSepa()
133
- && $this->isCallbackTypeAllowed($countryCode)) {
134
- Mage::throwException($this->__('Please enter your mobile number') . '!');
135
- }
136
- break;
137
- case Novalnet_Payment_Model_Config::NN_INVOICE:
138
- case Novalnet_Payment_Model_Config::NN_PREPAYMENT:
139
- $paymentRefOne = $this->getModel($paymentCode)->getNovalnetConfig('payment_ref_one');
140
- $paymentRefTwo = $this->getModel($paymentCode)->getNovalnetConfig('payment_ref_two');
141
- $paymentRefThree = $this->getModel($paymentCode)->getNovalnetConfig('payment_ref_three');
142
-
143
- if (!$paymentRefOne && !$paymentRefTwo && !$paymentRefThree) {
144
- Mage::throwException($this->__('Payment reference is missing or invalid') . '!');
145
- }
146
- break;
147
- case Novalnet_Payment_Model_Config::NN_CC:
148
- case Novalnet_Payment_Model_Config::NN_IDEAL:
149
- case Novalnet_Payment_Model_Config::NN_PAYPAL:
150
- case Novalnet_Payment_Model_Config::NN_SOFORT:
151
- case Novalnet_Payment_Model_Config::NN_EPS:
152
- case Novalnet_Payment_Model_Config::NN_GIROPAY:
153
- $accessKey = $this->getModel($paymentCode)->loadAffAccDetail();
154
-
155
- if (!$accessKey) {
156
- Mage::throwException($this->__('Basic parameter not valid') . '!');
157
- }
158
- break;
159
- }
160
- }
161
-
162
- /**
163
- * Assign Novalnet return params for redirect payments
164
- *
165
- * $param varien_object $request
166
- * $param string $paymentCode
167
- * @return Mage_Payment_Model_Abstract Object
168
- */
169
- public function assignNovalnetReturnData(Varien_Object $request, $paymentCode)
170
- {
171
- $redirectPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
172
- array_push($redirectPayment, Novalnet_Payment_Model_Config::NN_CC);
173
- $request->setUserVariable_0(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB))
174
- ->setReturnMethod(Novalnet_Payment_Model_Config::NOVALNET_RETURN_METHOD)
175
- ->setErrorReturnMethod(Novalnet_Payment_Model_Config::NOVALNET_RETURN_METHOD);
176
- if (in_array($paymentCode, $redirectPayment)) {
177
- $request->setReturnUrl($this->getUrl(Novalnet_Payment_Model_Config::GATEWAY_RETURN_URL))
178
- ->setErrorReturnUrl($this->getUrl(Novalnet_Payment_Model_Config::GATEWAY_ERROR_RETURN_URL));
179
- }
180
- }
181
-
182
- /**
183
- * To get encode data
184
- *
185
- * @param varien_object $dataObj
186
- * @param string $key
187
- * @param string $type
188
- * @return mixed
189
- */
190
- public function importNovalnetEncodeData(Varien_Object $dataObj, $key, $type = 'PHP')
191
- {
192
- $encoding = $this->getPciEncodedParam($dataObj, $key, $type);
193
- if ($encoding != true) {
194
- $this->getCoresession()->addError(
195
- $this->__('The methods for the handling of character sets are not available!'));
196
- $url = Mage::getModel('core/url')->getUrl("checkout/onepage/failure");
197
- Mage::app()->getResponse()->setRedirect($url);
198
- Mage::app()->getResponse()->sendResponse();
199
- exit;
200
- }
201
- $this->importNovalnetHashData($dataObj, $key, $type);
202
- return $dataObj;
203
- }
204
-
205
- /**
206
- * To get Hash data
207
- *
208
- * @param varien_object $dataObj
209
- * @param string $key
210
- * @param string $type
211
- * @return mixed
212
- */
213
- public function importNovalnetHashData(Varien_Object $dataObj, $key, $type = 'PHP')
214
- {
215
- $hash = $this->generateHash($dataObj, $key, $type);
216
- if ($hash == false) {
217
- $this->getCoresession()->addError($this->__('The hash functions are not available!'));
218
- $url = Mage::getModel('core/url')->getUrl("checkout/onepage/failure");
219
- Mage::app()->getResponse()->setRedirect($url);
220
- Mage::app()->getResponse()->sendResponse();
221
- exit;
222
- }
223
- $dataObj->setHash($hash);
224
- return $dataObj;
225
- }
226
-
227
- /**
228
- * Do XML call request to server
229
- *
230
- * @param varien_object $requestData
231
- * @param string $requestUrl
232
- * @param varien_object $paymentObj
233
- * @return Mage_Payment_Model_Abstract Object
234
- */
235
- public function setRawCallRequest($requestData, $requestUrl, $paymentObj)
236
- {
237
- $httpClientConfig = array('maxredirects' => 0);
238
-
239
- if ($paymentObj->getNovalnetConfig('use_proxy',true)) {
240
- $proxyHost = $paymentObj->getNovalnetConfig('proxy_host',true);
241
- $proxyPort = $paymentObj->getNovalnetConfig('proxy_port',true);
242
- if ($proxyHost && $proxyPort) {
243
- $httpClientConfig['proxy'] = $proxyHost. ':' . $proxyPort;
244
- $httpClientConfig['httpproxytunnel'] = true;
245
- $httpClientConfig['proxytype'] = CURLPROXY_HTTP;
246
- $httpClientConfig['SSL_VERIFYHOST'] = false;
247
- $httpClientConfig['SSL_VERIFYPEER'] = false;
248
- }
249
- }
250
-
251
- $gatewayTimeout = (int) $paymentObj->getNovalnetConfig('gateway_timeout',true);
252
- if ($gatewayTimeout > 0) {
253
- $httpClientConfig['timeout'] = $gatewayTimeout;
254
- }
255
-
256
- $client = new Varien_Http_Client($requestUrl, $httpClientConfig);
257
- $client->setRawData($requestData)->setMethod(Varien_Http_Client::POST);
258
- $response = $client->request();
259
- if (!$response->isSuccessful()) {
260
- Mage::throwException($this->__('Gateway request error: %s', $response->getMessage()));
261
- }
262
- $result = new Varien_Object();
263
- parse_str($response->getBody(), $data);
264
- $result->addData($data);
265
- return $result;
266
- }
267
-
268
- /**
269
- * Retrieve Credit Card Details
270
- *
271
- * @param string $param
272
- * @return string
273
- */
274
- public function novalnetCardDetails($param)
275
- {
276
- return Mage::app()->getRequest()->getPost($param);
277
- }
278
-
279
- /**
280
- * Remove sensitive data form Novalnet log
281
- *
282
- * @param varien_object $request
283
- * @param string $paymentCode
284
- * @return mixed
285
- */
286
- public function doRemoveSensitiveData($request = NULL, $paymentCode)
287
- {
288
- if ($paymentCode == Novalnet_Payment_Model_Config::NN_SEPA && $request) {
289
- $request->unsBankAccountHolder()
290
- ->unsSepaHash()
291
- ->unsSepaUniqueId();
292
- }
293
- return $request;
294
- }
295
-
296
- /**
297
- * Set Novalnet payment note for Invoice & Prepayment
298
- *
299
- * @return string
300
- */
301
- public function getNoteDescription()
302
- {
303
- return "<br /><b>" . $this->__(
304
- 'Please transfer the invoice amount with the following information to our payment provider Novalnet AG') . "</b><br />";
305
- }
306
-
307
- /**
308
- * Set Novalnet Due Date
309
- *
310
- * @param array $result
311
- * @param int $invoiceDuedate
312
- * @return mixed
313
- */
314
- public function getDueDate($result = NULL, $invoiceDuedate = NULL)
315
- {
316
- if ($result) {
317
- $dueDate = $result->getDueDate();
318
- } else if($invoiceDuedate) {
319
- $dueDate = $invoiceDuedate;
320
- }
321
-
322
- return ($dueDate) ? ($this->__('Due Date') . ' : <b><span id="due_date">' . Mage::helper('core')->formatDate($dueDate) . "</span></b><br />")
323
- : NULL;
324
- }
325
-
326
- /**
327
- * Get Novalnet Bank Account Details
328
- *
329
- * @param array $result
330
- * @return mixed
331
- */
332
- public function getNote($result)
333
- {
334
- $dueDate = $result->getDueDate();
335
- $note = NULL;
336
- $note .= $dueDate
337
- ? 'Due Date: ' . Mage::helper('core')->formatDate($dueDate) . '|NN Account Holder: NOVALNET AG'
338
- : 'NN Account Holder: NOVALNET AG';
339
- $note .= '|IBAN: ' . $result->getInvoiceIban();
340
- $note .= '|BIC: ' . $result->getInvoiceBic();
341
- $note .= '|NN_Bank: ' . $result->getInvoiceBankname() . ' ' . trim($result->getInvoiceBankplace());
342
- return $note;
343
- }
344
-
345
- /**
346
- * Return bank details amount
347
- *
348
- * @param float $amount
349
- * @return string
350
- */
351
- public function getBankDetailsAmount($amount)
352
- {
353
- return 'NN_Amount: ' . Mage::helper('core')->currency($amount, true, false);
354
- }
355
-
356
-
357
- /**
358
- * Return bank details transaction id
359
- *
360
- * @param int $tid
361
- * @param array $data
362
- * @param string $paymentCode
363
- * @return string
364
- */
365
- public function getReferenceDetails($tid, $data, $paymentCode)
366
- {
367
- $paymentReference = array();
368
- $note = NULL;
369
- $productId = $data['product'] ? $data['product'] : '';
370
- $orderNo = $data['orderNo'] ? $data['orderNo'] : '';
371
- $paymentRefOne = $this->getModel($paymentCode)->getNovalnetConfig('payment_ref_one');
372
- $paymentRefTwo = $this->getModel($paymentCode)->getNovalnetConfig('payment_ref_two');
373
- $paymentRefThree = $this->getModel($paymentCode)->getNovalnetConfig('payment_ref_three');
374
- $paymentRefConfig = array($paymentRefOne, $paymentRefTwo, $paymentRefThree);
375
-
376
- foreach ($paymentRefConfig as $key => $value) {
377
- if ($value == 1) {
378
- $paymentReference[] .= $value;
379
- }
380
- }
381
-
382
- $refCount = count($paymentReference);
383
- $note .= ($refCount > 1) ? "NN_Reference_desc1:" : "NN_Reference_desc2:";
384
-
385
- $i = 0;
386
- if (!empty($paymentRefOne)) {
387
- $i = ($refCount == 1) ? '' : $i + 1;
388
- $note .= "|NN_Reference$i:BNR-$productId-$orderNo";
389
- }
390
-
391
- if (!empty($paymentRefTwo)) {
392
- $i = ($refCount == 1) ? '' : $i + 1;
393
- $note .= "|NN_Reference$i:TID $tid";
394
- }
395
-
396
- if (!empty($paymentRefThree)) {
397
- $i = ($refCount == 1) ? '' : $i + 1;
398
- $note .= "|NN_Reference$i:NN Order No&$orderNo";
399
- }
400
- return $note;
401
- }
402
-
403
-
404
- /**
405
- * Check whether callback option is enabled
406
- *
407
- * @param string $paymentCode
408
- * @return boolean
409
- */
410
- public function checkCallbackAmount($paymentCode)
411
- {
412
- $grandTotal = $this->getCheckoutSession()->getQuote()->getBaseGrandTotal();
413
- $grandTotal = $this->getFormatedAmount($grandTotal);
414
- $callBackMinimum = (int) $this->getModel($paymentCode)->getNovalnetConfig('callback_minimum_amount');
415
-
416
- return ($callBackMinimum ? $grandTotal >= $callBackMinimum : true);
417
- }
418
-
419
- /**
420
- * Get checkout session
421
- *
422
- * @return Mage_Sales_Model_Order
423
- */
424
- public function getCheckout()
425
- {
426
- if ($this->checkIsAdmin()) {
427
- return $this->getAdminCheckoutSession();
428
- } else {
429
- return $this->getCheckoutSession();
430
- }
431
- }
432
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Helper/Data.php CHANGED
@@ -18,190 +18,17 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
27
  {
28
- /**
29
- * Array values to configure global configuration
30
- */
31
- protected $_config = array(
32
- 'index' => array(
33
- 'header_text' => 'Novalnet Global Configuration',
34
- 'previous_page' => '',
35
- 'next_page' => 'generalGlobal',
36
- ),
37
- 'generalGlobal' => array(
38
- 'group_name' => array('novalnet', 'novalnetsetting'),
39
- 'header_text' => 'Novalnet Global Configuration',
40
- 'codes' => array(
41
- 'page' => 'generalGlobal',
42
- 'section' => 'novalnet_global',
43
- ),
44
- 'previous_page' => 'index',
45
- 'next_page' => 'save',
46
- ),
47
- 'paymentSave' => array(
48
- 'group_name' => array('novalnetCc', 'novalnetSepa', 'novalnetInvoice',
49
- 'novalnetPrepayment',
50
- 'novalnetBanktransfer', 'novalnetPaypal', 'novalnetEps', 'novalnetIdeal', 'novalnetGiropay'),
51
- 'header_text' => 'Novalnet Global Configuration',
52
- 'codes' => array(
53
- 'page' => 'paymentSave',
54
- 'section' => 'novalnet_paymethods',
55
- ),
56
- 'previous_page' => 'generalGlobal',
57
- 'next_page' => '',
58
- )
59
- );
60
-
61
- /**
62
- * Initiate configuration
63
- *
64
- * @param $actionName
65
- * @param $request
66
- * @return varien_object
67
- */
68
- public function initConfig($actionName, $request)
69
- {
70
- $config = new Varien_Object($this->_config);
71
- $this->registerConfig($config);
72
-
73
- $configPages = $this->initConfigPage($actionName);
74
- $configPages = new Varien_Object($configPages);
75
-
76
- $codes = $configPages->getData('codes');
77
-
78
- $codes['website'] = $request->getParam('website');
79
- $codes['store'] = $request->getParam('store');
80
-
81
- $configPages->setData('codes', $codes);
82
-
83
- $this->registerConfigPage($configPages);
84
- return $configPages;
85
- }
86
-
87
- /**
88
- * Get Novalnet configure wizard details
89
- *
90
- * @return varien_object
91
- */
92
- public function getConfig()
93
- {
94
- return Mage::registry('novalnet_wizard_config');
95
- }
96
-
97
- /**
98
- * Register Novalnet configurtion wizard details
99
- *
100
- * @param Varien_Object $config
101
- */
102
- public function registerConfig(Varien_Object $config)
103
- {
104
- Mage::register('novalnet_wizard_config', $config);
105
- }
106
-
107
- /**
108
- * Get configuration page
109
- *
110
- * @return varien_object
111
- */
112
- public function getConfigPage()
113
- {
114
- return Mage::registry('novalnet_wizard_config_page');
115
- }
116
-
117
- /**
118
- * Register configuration page
119
- *
120
- * @param Varien_Object $config
121
- */
122
- public function registerConfigPage(Varien_Object $config)
123
- {
124
- Mage::register('novalnet_wizard_config_page', $config);
125
- }
126
-
127
- /**
128
- * Initiate configuration page process
129
- *
130
- * @param string $page
131
- * @return array|null
132
- */
133
- public function initConfigPage($page)
134
- {
135
- if (!array_key_exists($page, $this->_config)) {
136
- return null;
137
- }
138
- return $this->_config[$page];
139
- }
140
-
141
- /**
142
- * Get configuration wizard next page
143
- *
144
- * @return string
145
- */
146
- public function getNextPageUrlAsString()
147
- {
148
- $pageName = $this->getConfigPage()->getData('next_page');
149
- $url = $this->getPageUrlAsString($pageName);
150
- return $url;
151
- }
152
-
153
- /**
154
- * Get configuration wizard previous page
155
- *
156
- * @return string
157
- */
158
- public function getPreviousPageUrlAsString()
159
- {
160
- $pageName = $this->getConfigPage()->getData('previous_page');
161
- $url = $this->getPageUrlAsString($pageName);
162
- return $url;
163
- }
164
-
165
- /**
166
- * Get current page url
167
- *
168
- * @return string
169
- */
170
- public function getPageUrlAsString($nextPageName)
171
- {
172
- $config = $this->getConfig();
173
- $nextPage = $config->getData($nextPageName);
174
- if ($nextPage && array_key_exists('url', $nextPage)) {
175
- $url = $nextPage['url'];
176
- } else {
177
- $url = '*/novalnetpayment_configuration_wizard_page/' . $nextPageName;
178
- }
179
- return $url;
180
- }
181
-
182
- /**
183
- * Check whether logged in as admin
184
- *
185
- * @return boolean
186
- */
187
- public function checkIsAdmin()
188
- {
189
- return (Mage::app()->getStore()->isAdmin()) ? true : false;
190
- }
191
-
192
- /**
193
- * Retrieve Magento version
194
- *
195
- * @return int
196
- */
197
- public function getMagentoVersion()
198
- {
199
- return Mage::getVersion();
200
- }
201
-
202
  /**
203
  * Get current store id
204
  *
 
205
  * @return int
206
  */
207
  public function getMagentoStoreId()
@@ -214,84 +41,87 @@ class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
214
  }
215
 
216
  /**
217
- * Get current store details
218
  *
219
- * @return Mage_Core_Model_Store
220
- */
221
- public function getMagentoStore()
222
- {
223
- return Mage::app()->getStore();
224
- }
225
-
226
- /**
227
- * Get current Novalnet version
228
- *
229
- * @return string
230
  */
231
- public function getNovalnetVersion()
232
  {
233
- $versionInfo = (string) Mage::getConfig()->getNode('modules/Novalnet_Payment/version');
234
- return "NN({$versionInfo})";
 
 
 
 
 
 
 
235
  }
236
 
237
  /**
238
- * Get customer Ip address
239
  *
240
- * @return int
 
241
  */
242
- public function getRealIpAddr()
243
  {
244
- $ipAddr = Mage::helper('core/http')->getRemoteAddr();
245
- if ($ipAddr == '::1') {//IPv6 Issue
246
- return '127.0.0.1';
 
 
 
 
 
 
 
 
247
  }
248
- return $ipAddr;
249
  }
250
 
251
  /**
252
- * Get Server Ip address
253
  *
254
- * @return int
 
255
  */
256
- public function getServerAddr()
257
  {
258
- $serverAddr = Mage::helper('core/http')->getServerAddr();
259
- if ($serverAddr == '::1') {//IPv6 Issue
260
- return '127.0.0.1';
261
- }
262
- return $serverAddr;
263
  }
264
 
265
  /**
266
- * Novalnet web URL generic getter
267
  *
268
- * @return string
 
269
  */
270
- public function getNovalnetUrl()
271
  {
272
- if (strtoupper($this->getDefaultLanguage()) == 'DE') {
273
- $siteUrl = 'https://www.novalnet.de';
274
  } else {
275
- $siteUrl = 'http://www.novalnet.com';
276
  }
277
- return $siteUrl;
278
  }
279
 
280
  /**
281
- * Getter for Payment form logo images
282
  *
283
- * @return string
 
284
  */
285
- public function getNovalnetPaymentFormLogoUrl()
286
  {
287
- $baseUrl = Mage::getBaseUrl('skin');
288
- $imageUrl = $baseUrl . "frontend/base/default/images/novalnet/";
289
- return $imageUrl;
290
  }
291
 
292
  /**
293
- * Get singleton of Checkout Session Model
294
  *
 
295
  * @return Mage_Checkout_Model_Session
296
  */
297
  public function getCheckoutSession()
@@ -300,8 +130,9 @@ class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
300
  }
301
 
302
  /**
303
- * Get singleton of admin Checkout Session
304
  *
 
305
  * @return Mage_adminhtml_Model_Session_quote
306
  */
307
  public function getAdminCheckoutSession()
@@ -310,18 +141,9 @@ class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
310
  }
311
 
312
  /**
313
- * Get shop's date and time
314
- *
315
- * @return mixed
316
- */
317
- public function getCurrentDateTime()
318
- {
319
- return Mage::getModel('core/date')->date('Y-m-d H:i:s');
320
- }
321
-
322
- /**
323
- * Get singleton of customer Session
324
  *
 
325
  * @return Mage_customer_Model_Session
326
  */
327
  public function getCustomerSession()
@@ -330,79 +152,20 @@ class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
330
  }
331
 
332
  /**
333
- * Get the core session
334
- *
335
- * @return Mage_Core_Model_Session
336
- */
337
- public function getCoresession()
338
- {
339
- return Mage::getSingleton('core/session');
340
- }
341
-
342
- /**
343
- * Check customerNo for Logged in user
344
- *
345
- */
346
- public function customerNumberValidation()
347
- {
348
- $getCoreData = $this->getCurrentDateTime();
349
- try {
350
- $getCustomerSession = $this->getCustomerSession();
351
- $orderDetails = Mage::getModel('checkout/cart')->getQuote()->getData();
352
- //Checking customer login status
353
- $loginCheck = $getCustomerSession->isLoggedIn();
354
- if ($loginCheck) {
355
- $customerNo = $getCustomerSession->getCustomer()->getId();
356
- if (empty($customerNo)) {
357
- $visitorData = $this->getCoresession()->getVisitorData();
358
- $customerNo = $visitorData['customer_id']; // Used Only customer id is not assigned in mage session
359
- }
360
- //Log customer Order details
361
- if (!$customerNo) {
362
- Mage::log($getCustomerSession->getCustomer(), NULL, "Customerid_Missing_" . $getCoreData . ".log");
363
- Mage::log("Below are Order Details : ", NULL, "Customerid_Missing_" . $getCoreData . ".log");
364
- Mage::log($orderDetails, NULL, "Customerid_Missing_" . $getCoreData . ".log");
365
- Mage::throwException($this->__('Basic Parameter Missing. Please contact Shop Admin') . '!');
366
- }
367
- }
368
- } catch (Exception $e) {
369
- Mage::log($e->getMessage(), NULL, "Customerid_Missing_" . $getCoreData . ".log");
370
- }
371
- }
372
-
373
- /**
374
- * Check whether payment method can be used
375
- * for Zero subtotal Checkout
376
- *
377
- * $param int $grandTotal
378
- * @return boolean
379
- */
380
- public function isModuleActive($grandTotal = NULL)
381
- {
382
- if (!$grandTotal || $grandTotal == 0) {
383
- return false;
384
- }
385
- return true;
386
- }
387
-
388
- /**
389
- * Check whether the CallbackTypeCall can be used
390
  *
391
- * $param string $countryCode
392
  * @return boolean
393
  */
394
- public function isCallbackTypeAllowed($countryCode)
395
  {
396
- $allowedCountryCode = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('callbackAllowedCountry');
397
- if (in_array($countryCode, $allowedCountryCode) && !($this->checkIsAdmin())) {
398
- return true;
399
- }
400
- return false;
401
  }
402
 
403
  /**
404
  * Get shop default language
405
  *
 
406
  * @return string
407
  */
408
  public function getDefaultLanguage()
@@ -417,456 +180,239 @@ class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
417
  }
418
 
419
  /**
420
- * Retrieve customer id from current session
421
- *
422
- * @return int|null
423
- */
424
- public function getCustomerId()
425
- {
426
- $customerNo = '';
427
- if ($this->checkIsAdmin()) {
428
- $quoteCustomerNo = $this->getAdminCheckoutSession()->getQuote()->getCustomerId();
429
- $customerNo = $quoteCustomerNo ? $quoteCustomerNo : 'guest';
430
- } else {
431
- $loginCheck = $this->getCustomerSession()->isLoggedIn();
432
- if ($loginCheck) {
433
- $customerNo = $this->getCustomerSession()->getCustomerId();
434
- } else {
435
- $customerNo = 'guest';
436
- }
437
- }
438
- return $customerNo;
439
- }
440
-
441
- /**
442
- * Set secure url checkout is secure for current store.
443
  *
444
- * @param string $route
445
- * @param array $params
446
  * @return string
447
  */
448
- public function getUrl($route, $params = array())
449
  {
450
- $params['_type'] = Mage_Core_Model_Store::URL_TYPE_LINK;
451
- if (isset($params['is_secure'])) {
452
- $params['_secure'] = (bool) $params['is_secure'];
453
- } elseif ($this->getMagentoStore()->isCurrentlySecure()) {
454
- $params['_secure'] = true;
455
- }
456
- return parent::_getUrl($route, $params);
457
  }
458
 
459
  /**
460
- * Extract data from additional data array
461
  *
462
- * @param string $info
463
- * @param string $key
464
- * @return mixed
465
- */
466
- public function getAdditionalData($info, $key = null)
467
- {
468
- $data = array();
469
- if ($info->getAdditionalData()) {
470
- $data = unserialize($info->getAdditionalData());
471
- }
472
- if (!empty($key) && isset($data[$key])) {
473
- return $data[$key];
474
- } else {
475
- return '';
476
- }
477
- }
478
-
479
- /**
480
- * Check whether current user have access to the payment method
481
- *
482
- * @param int $userGroupId
483
- * @return boolean
484
- */
485
- public function checkCustomerAccess($userGroupId = NULL)
486
- {
487
- $exludedGroupes = trim($userGroupId);
488
- if (strlen($exludedGroupes)) {
489
- $exludedGroupes = explode(',', $exludedGroupes);
490
- $custGrpId = $this->getCustomerSession()->getCustomerGroupId();
491
- if ($this->checkIsAdmin()) {
492
- $custGrpId = $this->getAdminCheckoutSession()->getQuote()->getCustomerId();
493
- }
494
- return !in_array($custGrpId, $exludedGroupes);
495
- }
496
- return true;
497
- }
498
-
499
- /**
500
- * Function to Encode Novalnet PCI data
501
- *
502
- * @param string $data
503
- * @param string $key
504
- * @param string $type
505
- * @return boolean
506
  */
507
- public function getPciEncodedParam(&$fields, $key, $type = 'PHP')
508
  {
509
- if (!function_exists('base64_encode') || !function_exists('pack') || !function_exists('crc32')) {
510
- return false;
511
- }
512
- $toBeEncoded = ($type == 'PHP_PCI')
513
- ? Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('pciHashParams')
514
- : Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('novalnetHashParams');
515
- foreach ($toBeEncoded as $_value) {
516
- $data = $fields->$_value;
517
- if ($this->isEmptyString($data)) {
518
- return false;
519
- }
520
- try {
521
- $crc = sprintf('%u', crc32($data)); //%u is must
522
- $data = $crc . "|" . $data;
523
- $data = bin2hex($data . $key);
524
- $data = strrev(base64_encode($data));
525
- $fields->$_value = $data;
526
- } catch (Exception $e) {
527
- return false;
528
- }
529
  }
530
- return true;
531
  }
532
 
533
  /**
534
- * Function to Decode Novalnet data
535
  *
536
- * @param string $data
537
- * @param string $key
538
- * @return string
539
  */
540
- public function getDecodedParam($data, $key)
541
  {
542
- $data = trim($data);
543
- if (!$data) {
544
- return'Error: no data';
545
- }
546
- if (!function_exists('base64_decode') || !function_exists('pack') || !function_exists('crc32')) {
547
- return'Error: func n/a';
548
- }
549
- try {
550
- $data = base64_decode(strrev($data));
551
- $data = pack("H" . strlen($data), $data);
552
- $data = substr($data, 0, stripos($data, $key));
553
- $pos = strpos($data, "|");
554
- if ($pos === false) {
555
- return("Error: CKSum not found!");
556
- }
557
- $crc = substr($data, 0, $pos);
558
- $value = trim(substr($data, $pos + 1));
559
- if ($crc != sprintf('%u', crc32($value))) {
560
- return("Error; CKSum invalid!");
561
- }
562
- return $value;
563
- } catch (Exception $e) {
564
- Mage::logException('Error: ' . $e);
565
  }
 
566
  }
567
 
568
  /**
569
- * Check whether there is an Empty string
570
  *
571
- * @param string $str
572
- * @return boolean
573
  */
574
- public function isEmptyString($str)
575
  {
576
- $str = trim($str);
577
- return !isset($str[0]);
578
  }
579
 
580
  /**
581
- * Generate Hash value for PCI
582
  *
583
- * @param array $data
584
- * @param string $key
585
- * @param string $type
586
- * @return string
587
  */
588
- public function generateHash($data, $key, $type = 'PHP')
589
  {
590
- if (!function_exists('md5') || $this->isEmptyString($key)) {
591
- return false;
592
- }
593
- $hashFields = ($type == 'PHP_PCI')
594
- ? Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('pciHashParams')
595
- : Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('novalnetHashParams');
596
- $str = NULL;
597
- foreach ($hashFields as $_value) {
598
- if ($this->isEmptyString($data->$_value)) {
599
- return false;
600
- }
601
- $str .= $data->$_value;
602
- }
603
- return md5($str . strrev($key));
604
  }
605
 
606
  /**
607
- * Hash value getter
608
  *
609
- * @param array $request
610
- * @param string $key
611
- * @param string $type
612
  * @return string
613
  */
614
- public function getHash($request, $key, $type)
615
  {
616
- if (empty($request)) {
617
- return'Error: no data';
618
- }
619
- if (!function_exists('md5')) {
620
- return'Error: func n/a';
621
- }
622
-
623
- if ($type == 'PHP_PCI') {
624
- $hash = md5($request['vendor_authcode'] . $request['product_id'] . $request['tariff_id'] . $request['amount'] . $request['test_mode'] . $request['uniqid'] . strrev($key));
625
  } else {
626
- $hash = md5($request['auth_code'] . $request['product'] . $request['tariff'] . $request['amount'] . $request['test_mode'] . $request['uniqid'] . strrev($key));
627
- }
628
- return $hash;
629
- }
630
-
631
- /**
632
- * Check Hash value
633
- *
634
- * @param array $request
635
- * @param string $key
636
- * @param string $type
637
- * @return boolean
638
- */
639
- public function checkHash($request, $key, $type)
640
- {
641
- if (!$request) return false;
642
- if ($request['hash2'] != $this->getHash($request, $key, $type)) {
643
- return false;
644
  }
645
- return true;
646
  }
647
 
648
  /**
649
- * Check Novalnet response params
650
  *
651
- * @param array $response
652
- * @param string $password
653
- * @param string $type
654
- * @return int
655
  */
656
- public function checkParams($response, $password, $type)
657
  {
658
- $status = $response['status'];
659
- if (!$response['hash2']) {
660
- $status = '94';
661
- }if (!$this->checkHash($response, $password, $type)) {
662
- $status = '91';
663
- }
664
- $response['amount'] = $this->getDecodedParam($response['amount'], $password);
665
- if (!$this->checkIsNumeric($response['amount'])) {
666
- $status = '92';
667
- }
668
- $this->_status = $status;
669
- return $status;
670
  }
671
 
672
  /**
673
- * Retrieve Novalnet payment key
674
  *
675
- * @param string $code
676
  * @return int
677
  */
678
- public function getPaymentId($code)
679
  {
680
- $arrPaymentId = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('novalnetPaymentKey');
681
- return $arrPaymentId[$code];
682
  }
683
 
684
  /**
685
- * Retrieve Novalnet Payment Type
686
  *
687
- * @param string $code
688
  * @return string
689
  */
690
- public function getPaymentType($code)
691
  {
692
- $arrPaymentType = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('novalnetPaymentTypes');
693
- return $arrPaymentType[$code];
694
  }
695
 
696
  /**
697
- * Check orders count by customer id
698
  *
699
- * @param int $minOrderCount
700
- * @return boolean
 
701
  */
702
- public function checkOrdersCount($minOrderCount)
703
  {
704
- $customerId = $this->getCustomerId();
705
- // Load orders and check
706
- $orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $customerId);
707
- $ordersCount = $orders->count();
708
- if (trim($ordersCount) < $minOrderCount) {
709
- return true;
710
  }
711
- return false;
 
 
 
712
  }
713
 
714
  /**
715
- * set due date for invoice payment
716
  *
717
- * @param int $paymentDuration
718
  * @return int
719
  */
720
- public function setDueDate($paymentDuration)
721
- {
722
- $dueDate = '';
723
- if ($paymentDuration && $this->checkIsNumeric($paymentDuration)) {
724
- $dueDate = date('Y-m-d', strtotime('+' . (int) $paymentDuration . ' days'));
725
- } elseif ($paymentDuration == "0") {
726
- $dueDate = date('Y-m-d');
727
- }
728
- return $dueDate;
729
- }
730
-
731
- /**
732
- * Get Novalnet model class
733
- *
734
- * @param string $modelclass
735
- * @return Novalnet_Payment_Model_Payment_Method_Abstract
736
- */
737
- public function getModel($modelclass)
738
- {
739
- return Mage::getModel('novalnet_payment/payment_method_' . $modelclass);
740
- }
741
-
742
- /**
743
- * Get Novalnet transaction status model
744
- *
745
- * @return Novalnet_Payment_Model_Transactionstatus_Collection
746
- */
747
- public function getModelTransactionStatus()
748
- {
749
- return Mage::getModel('novalnet_payment/transactionstatus');
750
- }
751
-
752
- /**
753
- * Get Novalnet callback model
754
- *
755
- * @return Novalnet_Payment_Model_Callback_Collection
756
- */
757
- public function getModelCallback()
758
- {
759
- return Mage::getModel('novalnet_payment/callback');
760
- }
761
-
762
- /**
763
- * Get Novalnet Affiliate model
764
- *
765
- * @return Novalnet_Payment_Model_Affiliate_Collection
766
- */
767
- public function getModelAffiliate()
768
- {
769
- return Mage::getModel('novalnet_payment/affiliate');
770
- }
771
-
772
- /**
773
- * Get Novalnet Affiliate User model
774
- *
775
- * @return Novalnet_Payment_Model_Affiliateuser_Collection
776
- */
777
- public function getModelAffiliateuser()
778
- {
779
- return Mage::getModel('novalnet_payment/affiliateuser');
780
- }
781
-
782
- /**
783
- * Get Novalnet transaction overview model
784
- *
785
- * @return Novalnet_Payment_Model_Transactionoverview_Collection
786
- */
787
- public function getModelTransactionOverview()
788
- {
789
- return Mage::getModel('novalnet_payment/transactionoverview');
790
- }
791
-
792
- /**
793
- * Get Novalnet Separefill model
794
- *
795
- * @return Novalnet_Payment_Model_Separefill_Collection
796
- */
797
- public function getModelSepaRefill()
798
  {
799
- return Mage::getModel('novalnet_payment/separefill');
 
800
  }
801
 
802
  /**
803
- * Get Novalnet Amountchanged model
804
  *
805
- * @return Novalnet_Payment_Model_Amountchanged_Collection
 
 
806
  */
807
- public function getModelAmountchanged()
808
  {
809
- return Mage::getModel('novalnet_payment/amountchanged');
810
  }
811
 
812
  /**
813
- * Get Novalnet Recurring model
814
  *
815
- * @return Novalnet_Payment_Model_Recurring_Collection
 
 
816
  */
817
- public function getModelRecurring()
818
  {
819
- return Mage::getModel('novalnet_payment/recurring');
820
- }
 
 
 
 
 
 
 
 
821
 
822
- /**
823
- * Get Novalnet Factory model
824
- *
825
- * @return Novalnet_Payment_Model_Factory
826
- */
827
- public function getModelFactory()
828
- {
829
- return Mage::getModel('novalnet_payment/factory');
830
  }
831
 
832
  /**
833
- * Check the value is numeric
834
  *
835
- * @param mixed $value
836
- * @return boolean
837
  */
838
- public function checkIsNumeric($value)
839
  {
840
- return preg_match('/^\d+$/', $value) ? true : false;
 
 
 
 
841
  }
842
 
843
  /**
844
- * Check the value contains special characters
845
  *
846
- * @param mixed $value
847
- * @return boolean
848
  */
849
- public function checkIsValid($value)
850
  {
851
- return (!$value || preg_match('/[#%\^<>@$=*!]/', $value)) ? false : true;
 
852
  }
853
 
854
  /**
855
- * Check the email id is valid
856
  *
857
- * @param mixed $emailId
858
- * @return boolean
 
859
  */
860
- public function validateEmail($emailId)
861
  {
862
- $validatorEmail = new Zend_Validate_EmailAddress();
863
- return $validatorEmail->isValid($emailId) ? true : false;
 
 
 
864
  }
865
 
866
  /**
867
  * Replace strings from the value passed
868
  *
869
- * @param mixed $value
870
  * @return integer
871
  */
872
  public function makeValidNumber($value)
@@ -875,99 +421,55 @@ class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
875
  }
876
 
877
  /**
878
- * Get the formated amount in cents/euro
879
- *
880
- * @param float $amount
881
- * @param string $type
882
- * @return int
883
- */
884
- public function getFormatedAmount($amount, $type = 'CENT')
885
- {
886
- return ($type == 'RAW') ? $amount / 100 : round($amount, 2) * 100;
887
- }
888
-
889
- /**
890
- * Load Novalnet transaction status based on tid
891
  *
892
- * @param integer $txnId
893
- * @return object Novalnet_Payment_Model_Transactionstatus
 
894
  */
895
- public function loadTransactionStatus($txnId)
896
  {
897
- return $this->getModelTransactionStatus()->loadByAttribute('transaction_no', $txnId);
 
 
 
 
 
 
898
  }
899
 
900
  /**
901
- * Load Novalnet callback value based on order-id
902
  *
903
- * @param integer $orderId
904
- * @return object Novalnet_Payment_Model_Callback
905
  */
906
- public function loadCallbackValue($orderId)
907
  {
908
- return $this->getModelCallback()->loadByAttribute('order_id', $orderId);
909
  }
910
 
911
  /**
912
- * Get Novalnet payment configuration global path
913
  *
914
- * @return string
 
915
  */
916
- public function getNovalnetGlobalPath()
917
  {
918
- return 'novalnet_global/novalnet/';
919
  }
920
 
921
  /**
922
- * Get current site url
923
  *
924
- * @return string
 
925
  */
926
- public function getCurrentSiteUrl()
927
  {
928
- return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
929
- }
930
 
931
- /**
932
- * Get Amount collection
933
- *
934
- * $param int $orderId
935
- * $param int $confirm
936
- * $param int $param
937
- * @return int
938
- */
939
- public function getAmountCollection($orderId, $confirm, $param)
940
- {
941
- $countofCollection = '';
942
- $modNovalAmountcollection = $this->getModelAmountchanged()->getCollection();
943
- $modNovalAmountcollection->addFieldToFilter('order_id', $orderId);
944
- $modNovalAmountcollection->addFieldToSelect('amount_changed');
945
- $modNovalAmountcollection->addFieldToSelect('amount_datetime');
946
- $countofCollectionvalue = count($modNovalAmountcollection);
947
- if ($confirm != 1 && $param != 1) {
948
- $countofCollection = count($modNovalAmountcollection);
949
- } else if ($confirm == 1 && $param == 1 && $countofCollectionvalue != 0) {
950
- foreach ($modNovalAmountcollection as $modNovalAmountcollectionValue) {
951
- $countofCollection .= $modNovalAmountcollectionValue->getAmountChanged();
952
- $countofCollection .= '<br>';
953
- $countofCollection .= $modNovalAmountcollectionValue->getAmountDatetime();
954
- }
955
- } else if ($confirm == 1 && $countofCollectionvalue != 0) {
956
- foreach ($modNovalAmountcollection as $modNovalAmountcollectionValue) {
957
- $countofCollection .= $modNovalAmountcollectionValue->getAmountChanged();
958
- }
959
- }
960
- return $countofCollection;
961
- }
962
-
963
- /**
964
- * Check Nominal item or not
965
- *
966
- * $param varien_object $orderItems
967
- * @return mixed
968
- */
969
- public function checkNominalItem($orderItems)
970
- {
971
  foreach ($orderItems as $orderItemsValue) {
972
  if ($orderItemsValue) {
973
  $nominalItem = $orderItemsValue->getIsNominal();
@@ -977,42 +479,4 @@ class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
977
  return $nominalItem;
978
  }
979
 
980
- /**
981
- * Get the respective payport url
982
- *
983
- * @param string $reqType
984
- * @param string $paymentCode
985
- * @return string
986
- */
987
- public function getPayportUrl($reqType, $paymentCode = NULL)
988
- {
989
- if ($paymentCode && $reqType == 'redirect') {
990
- $redirectUrl = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayportUrl');
991
- $payportUrl = $redirectUrl[$paymentCode];
992
- } else {
993
- $urlType = array(
994
- 'paygate' => Novalnet_Payment_Model_Config::PAYPORT_URL,
995
- 'infoport' => Novalnet_Payment_Model_Config::INFO_REQUEST_URL
996
- );
997
- $payportUrl = $urlType[$reqType];
998
- }
999
- return $payportUrl;
1000
- }
1001
-
1002
- /**
1003
- * Get checkout session
1004
- *
1005
- * @return string
1006
- */
1007
- public function getCurrency()
1008
- {
1009
- $_order = new Mage_Sales_Model_Order();
1010
- $orderId = Mage::app()->getRequest()->getParam('order_id');
1011
- if (isset($orderId) && $orderId) {
1012
- $order = $_order->load($orderId);
1013
- $currency = $order->getOrderCurrency();
1014
- $currencyCode = $currency->getCurrencyCode();
1015
- return $currencyCode;
1016
- }
1017
- }
1018
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Helper_Data extends Mage_Core_Helper_Abstract
27
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Get current store id
30
  *
31
+ * @param none
32
  * @return int
33
  */
34
  public function getMagentoStoreId()
41
  }
42
 
43
  /**
44
+ * Get current admin scope id
45
  *
46
+ * @return int
 
 
 
 
 
 
 
 
 
 
47
  */
48
+ public function getScopeId()
49
  {
50
+ if (strlen($code = Mage::getSingleton('adminhtml/config_data')->getStore())) {
51
+ $scopeId = Mage::getModel('core/store')->load($code)->getId();
52
+ } elseif (strlen($code = Mage::getSingleton('adminhtml/config_data')->getWebsite())) {
53
+ $websiteId = Mage::getModel('core/website')->load($code)->getId();
54
+ $scopeId = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId();
55
+ } else {
56
+ $scopeId = 0;
57
+ }
58
+ return $scopeId;
59
  }
60
 
61
  /**
62
+ * Get customer id from current session
63
  *
64
+ * @param none
65
+ * @return int|string
66
  */
67
+ public function getCustomerId()
68
  {
69
+ $customerNo = '';
70
+ if ($this->checkIsAdmin()) {
71
+ $quoteCustomerNo = $this->getAdminCheckoutSession()->getQuote()->getCustomerId();
72
+ $customerNo = $quoteCustomerNo ? $quoteCustomerNo : 'guest';
73
+ } else {
74
+ $loginCheck = $this->getCustomerSession()->isLoggedIn();
75
+ if ($loginCheck) {
76
+ $customerNo = $this->getCustomerSession()->getCustomerId();
77
+ } else {
78
+ $customerNo = 'guest';
79
+ }
80
  }
81
+ return $customerNo;
82
  }
83
 
84
  /**
85
+ * Check the value is numeric
86
  *
87
+ * @param mixed $value
88
+ * @return boolean
89
  */
90
+ public function checkIsNumeric($value)
91
  {
92
+ return preg_match('/^\d+$/', $value) ? true : false;
 
 
 
 
93
  }
94
 
95
  /**
96
+ * Get checkout session
97
  *
98
+ * @param none
99
+ * @return Mage_Sales_Model_Order
100
  */
101
+ public function getCheckout()
102
  {
103
+ if ($this->checkIsAdmin()) {
104
+ return $this->getAdminCheckoutSession(); // Get admin checkout session
105
  } else {
106
+ return $this->getCheckoutSession(); // Get frontend checkout session
107
  }
 
108
  }
109
 
110
  /**
111
+ * Get Magento core session
112
  *
113
+ * @param none
114
+ * @return Mage_Core_Model_Session
115
  */
116
+ public function getCoreSession()
117
  {
118
+ return Mage::getSingleton('core/session');
 
 
119
  }
120
 
121
  /**
122
+ * Get frontend checkout session
123
  *
124
+ * @param none
125
  * @return Mage_Checkout_Model_Session
126
  */
127
  public function getCheckoutSession()
130
  }
131
 
132
  /**
133
+ * Get admin checkout session
134
  *
135
+ * @param none
136
  * @return Mage_adminhtml_Model_Session_quote
137
  */
138
  public function getAdminCheckoutSession()
141
  }
142
 
143
  /**
144
+ * Get customer session
 
 
 
 
 
 
 
 
 
 
145
  *
146
+ * @param none
147
  * @return Mage_customer_Model_Session
148
  */
149
  public function getCustomerSession()
152
  }
153
 
154
  /**
155
+ * Check whether logged in as admin
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  *
157
+ * @param none
158
  * @return boolean
159
  */
160
+ public function checkIsAdmin()
161
  {
162
+ return (Mage::app()->getStore()->isAdmin()) ? true : false;
 
 
 
 
163
  }
164
 
165
  /**
166
  * Get shop default language
167
  *
168
+ * @param none
169
  * @return string
170
  */
171
  public function getDefaultLanguage()
180
  }
181
 
182
  /**
183
+ * Get shop base url
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  *
185
+ * @param none
 
186
  * @return string
187
  */
188
+ public function getBaseUrl()
189
  {
190
+ $protocol = Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http'; // Get protocol
191
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); // Get base URL
192
+ $secureBaseUrl = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL);
193
+ return ($protocol == 'https' && $secureBaseUrl)
194
+ ? str_replace('index.php/', '', $secureBaseUrl)
195
+ : str_replace('index.php/', '', $baseUrl);
 
196
  }
197
 
198
  /**
199
+ * Get Remote IP address
200
  *
201
+ * @param none
202
+ * @return int
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  */
204
+ public function getRealIpAddr()
205
  {
206
+ $ipAddr = Mage::helper('core/http')->getRemoteAddr();
207
+ if (filter_var($ipAddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)
208
+ || $ipAddr == '::1') {//IPv6 Issue
209
+ return '127.0.0.1';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  }
211
+ return $ipAddr;
212
  }
213
 
214
  /**
215
+ * Get Server IP address
216
  *
217
+ * @param none
218
+ * @return int
 
219
  */
220
+ public function getServerAddr()
221
  {
222
+ $serverAddress = Mage::helper('core/http')->getServerAddr();
223
+ if (filter_var($serverAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)
224
+ || $serverAddress == '::1') {//IPv6 Issue
225
+ return '127.0.0.1';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  }
227
+ return $serverAddress;
228
  }
229
 
230
  /**
231
+ * Get Novalnet payment model
232
  *
233
+ * @param string $modelclass
234
+ * @return Varien_Object
235
  */
236
+ public function getPaymentModel($modelclass)
237
  {
238
+ return Mage::getModel('novalnet_payment/method_' . $modelclass);
 
239
  }
240
 
241
  /**
242
+ * Get Novalnet model
243
  *
244
+ * @param string $model
245
+ * @return Varien_Object
 
 
246
  */
247
+ public function getModel($model)
248
  {
249
+ return Mage::getModel('novalnet_payment/' . $model);
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  }
251
 
252
  /**
253
+ * Get Novalnet URL based on language
254
  *
255
+ * @param none
 
 
256
  * @return string
257
  */
258
+ public function getNovalnetUrl()
259
  {
260
+ if (strtoupper($this->getDefaultLanguage()) == 'DE') {
261
+ $siteUrl = 'https://www.novalnet.de';
 
 
 
 
 
 
 
262
  } else {
263
+ $siteUrl = 'http://www.novalnet.com';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  }
265
+ return $siteUrl;
266
  }
267
 
268
  /**
269
+ * Get payment logo URL
270
  *
271
+ * @param none
272
+ * @return string $imageUrl
 
 
273
  */
274
+ public function getPaymentLogoUrl()
275
  {
276
+ $baseUrl = Mage::getBaseUrl('skin');
277
+ $imageUrl = $baseUrl . "frontend/base/default/images/novalnet/";
278
+ return $imageUrl;
 
 
 
 
 
 
 
 
 
279
  }
280
 
281
  /**
282
+ * Get current Magento version
283
  *
284
+ * @param none
285
  * @return int
286
  */
287
+ public function getMagentoVersion()
288
  {
289
+ return Mage::getVersion();
 
290
  }
291
 
292
  /**
293
+ * Get current Novalnet version
294
  *
295
+ * @param none
296
  * @return string
297
  */
298
+ public function getNovalnetVersion()
299
  {
300
+ $versionInfo = (string) Mage::getConfig()->getNode('modules/Novalnet_Payment/version');
301
+ return "NN({$versionInfo})";
302
  }
303
 
304
  /**
305
+ * Show expection
306
  *
307
+ * @param string $text
308
+ * @param boolean $lang
309
+ * @return Mage_Payment_Model_Info_Exception
310
  */
311
+ public function showException($text, $lang = true)
312
  {
313
+ if ($lang) {
314
+ $text = $this->__($text);
 
 
 
 
315
  }
316
+ // Exception log for reference
317
+ Mage::log($text, null, 'nn_exception.log', true);
318
+ // Show payment exception
319
+ return Mage::throwException($text);
320
  }
321
 
322
  /**
323
+ * Get Novalnet payment key
324
  *
325
+ * @param string $code
326
  * @return int
327
  */
328
+ public function getPaymentId($code)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  {
330
+ $getPaymentId = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('paymentKey');
331
+ return $getPaymentId[$code];
332
  }
333
 
334
  /**
335
+ * Get the formated amount in Cents/Euro
336
  *
337
+ * @param float $amount
338
+ * @param string $type
339
+ * @return int
340
  */
341
+ public function getFormatedAmount($amount, $type = 'CENT')
342
  {
343
+ return ($type == 'RAW') ? $amount / 100 : round($amount, 2) * 100;
344
  }
345
 
346
  /**
347
+ * Get the respective payport url
348
  *
349
+ * @param string $reqType
350
+ * @param string $paymentCode
351
+ * @return string
352
  */
353
+ public function getPayportUrl($reqType, $paymentCode = null)
354
  {
355
+ if ($paymentCode && $reqType == 'redirect') { // For redirect payment methods
356
+ $redirectUrl = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayportUrl');
357
+ $payportUrl = $redirectUrl[$paymentCode];
358
+ } else { // For direct payment methods
359
+ $urlType = array(
360
+ 'paygate' => Novalnet_Payment_Model_Config::PAYPORT_URL,
361
+ 'infoport' => Novalnet_Payment_Model_Config::INFO_REQUEST_URL
362
+ );
363
+ $payportUrl = $urlType[$reqType];
364
+ }
365
 
366
+ return 'https://payport.novalnet.de/' . $payportUrl;
 
 
 
 
 
 
 
367
  }
368
 
369
  /**
370
+ * Get payment method session
371
  *
372
+ * @param string $paymentCode
373
+ * @return mixed
374
  */
375
+ public function getMethodSession($paymentCode = null)
376
  {
377
+ $checkoutSession = $this->getCheckout();
378
+ if ($paymentCode != null && !$checkoutSession->hasData($paymentCode)) {
379
+ $checkoutSession->setData($paymentCode, new Varien_Object());
380
+ }
381
+ return $checkoutSession->getData($paymentCode);
382
  }
383
 
384
  /**
385
+ * Unset payment method session
386
  *
387
+ * @param string $paymentCode
388
+ * @return none
389
  */
390
+ public function unsetMethodSession($paymentCode)
391
  {
392
+ $checkoutSession = $this->getCheckout();
393
+ $checkoutSession->unsetData($paymentCode);
394
  }
395
 
396
  /**
397
+ * Extract data from additional data array
398
  *
399
+ * @param string $info
400
+ * @param string $key
401
+ * @return mixed
402
  */
403
+ public function getAdditionalData($info, $key = null)
404
  {
405
+ $data = array();
406
+ if ($info->getAdditionalData()) {
407
+ $data = unserialize($info->getAdditionalData());
408
+ }
409
+ return (!empty($key) && isset($data[$key])) ? $data[$key] : '';
410
  }
411
 
412
  /**
413
  * Replace strings from the value passed
414
  *
415
+ * @param mixed $value
416
  * @return integer
417
  */
418
  public function makeValidNumber($value)
421
  }
422
 
423
  /**
424
+ * Set secure url checkout is secure for current store.
 
 
 
 
 
 
 
 
 
 
 
 
425
  *
426
+ * @param string $route
427
+ * @param array $params
428
+ * @return string
429
  */
430
+ public function getUrl($route, $params = array())
431
  {
432
+ $params['_type'] = Mage_Core_Model_Store::URL_TYPE_LINK;
433
+ if (isset($params['is_secure'])) {
434
+ $params['_secure'] = (bool) $params['is_secure'];
435
+ } elseif ($this->getMagentoStore()->isCurrentlySecure()) {
436
+ $params['_secure'] = true;
437
+ }
438
+ return parent::_getUrl($route, $params);
439
  }
440
 
441
  /**
442
+ * Get current store details
443
  *
444
+ * @param none
445
+ * @return Mage_Core_Model_Store
446
  */
447
+ public function getMagentoStore()
448
  {
449
+ return Mage::app()->getStore();
450
  }
451
 
452
  /**
453
+ * Get shop's date and time
454
  *
455
+ * @param none
456
+ * @return mixed
457
  */
458
+ public function getCurrentDateTime()
459
  {
460
+ return Mage::getModel('core/date')->date('Y-m-d H:i:s');
461
  }
462
 
463
  /**
464
+ * Check the order item is nominal or not
465
  *
466
+ * @param Varien_Object $order
467
+ * @return boolean $nominalItem
468
  */
469
+ public function checkNominalItem($order)
470
  {
471
+ $orderItems = $order->getAllItems();
 
472
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  foreach ($orderItems as $orderItemsValue) {
474
  if ($orderItemsValue) {
475
  $nominalItem = $orderItemsValue->getIsNominal();
479
  return $nominalItem;
480
  }
481
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
482
  }
app/code/community/Novalnet/Payment/Model/Adminhtml/Sales/Order/Create.php CHANGED
@@ -18,13 +18,14 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Model_Adminhtml_Sales_Order_Create extends Mage_Adminhtml_Model_Sales_Order_Create
27
  {
 
28
  /**
29
  * Create new order
30
  *
@@ -50,33 +51,35 @@ class Novalnet_Payment_Model_Adminhtml_Sales_Order_Create extends Mage_Adminhtml
50
  'relation_parent_id' => $oldOrder->getId(),
51
  'relation_parent_real_id' => $oldOrder->getIncrementId(),
52
  'edit_increment' => $oldOrder->getEditIncrement() + 1,
53
- 'increment_id' => $originalId . '-' . ($oldOrder->getEditIncrement()
54
- + 1)
55
  );
56
  $quote->setReservedOrderId($orderData['increment_id']);
57
  $service->setOrderData($orderData);
58
  }
59
 
60
  $order = $service->submit();
61
- $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
 
 
 
 
 
 
 
62
 
63
- if (preg_match("/novalnet/i", $paymentMethod)) {
64
- $payment = $order->getPayment();
65
- $paymentObj = $payment->getMethodInstance();
66
- $request = $this->getSession()->getPaymentReqData();
67
- $response = $paymentObj->postRequest($request);
68
- $paymentObj->validateNovalnetResponse($payment, $response);
69
- $this->getSession()->unsPaymentReqData()
70
- ->unsPaymentResData();
71
  }
72
 
73
- if ((!$quote->getCustomer()->getId() || !$quote->getCustomer()->isInStore($this->getSession()->getStore()))
74
- && !$quote->getCustomerIsGuest()
 
75
  ) {
76
  $quote->getCustomer()->setCreatedAt($order->getCreatedAt());
77
  $quote->getCustomer()
78
- ->save()
79
- ->sendNewAccountEmail('registered', '', $quote->getStoreId());
80
  }
81
  if ($this->getSession()->getOrder()->getId()) {
82
  $oldOrder = $this->getSession()->getOrder();
@@ -84,16 +87,19 @@ class Novalnet_Payment_Model_Adminhtml_Sales_Order_Create extends Mage_Adminhtml
84
  $this->getSession()->getOrder()->setRelationChildId($order->getId());
85
  $this->getSession()->getOrder()->setRelationChildRealId($order->getIncrementId());
86
  $this->getSession()->getOrder()->cancel()
87
- ->save();
88
  $order->save();
89
  }
90
  if ($this->getSendConfirmation()) {
91
  $order->sendNewOrderEmail();
92
  }
93
 
94
- Mage::dispatchEvent('checkout_submit_all_after', array('order' => $order,
95
- 'quote' => $quote));
 
 
96
 
97
  return $order;
98
  }
 
99
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Model_Adminhtml_Sales_Order_Create extends Mage_Adminhtml_Model_Sales_Order_Create
27
  {
28
+
29
  /**
30
  * Create new order
31
  *
51
  'relation_parent_id' => $oldOrder->getId(),
52
  'relation_parent_real_id' => $oldOrder->getIncrementId(),
53
  'edit_increment' => $oldOrder->getEditIncrement() + 1,
54
+ 'increment_id' => $originalId . '-' . ($oldOrder->getEditIncrement() + 1)
 
55
  );
56
  $quote->setReservedOrderId($orderData['increment_id']);
57
  $service->setOrderData($orderData);
58
  }
59
 
60
  $order = $service->submit();
61
+ $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
62
+
63
+ if (preg_match("/novalnet/i", $paymentCode)) {
64
+ $helper = Mage::helper('novalnet_payment'); // Novalnet payment helper
65
+ $methodSession = $helper->getMethodSession($paymentCode); // Get payment method session
66
+ $request = $methodSession->getPaymentReqData(); // Get payment request
67
+ $paymentObj = $order->getPayment()->getMethodInstance(); // Get payment method instance
68
+ $response = $paymentObj->postRequest($request); // Send payment request to Novalnet Gateway
69
 
70
+ $responseModel = $helper->getModel('Service_Api_Response'); // Get Novalnet Api response model
71
+ $responseModel->validateResponse($order, $request, $response); // Validate Novalnet payment response
72
+ $helper->unsetMethodSession($paymentCode); // Unset payment method session
 
 
 
 
 
73
  }
74
 
75
+ if ((!$quote->getCustomer()->getId()
76
+ || !$quote->getCustomer()->isInStore($this->getSession()->getStore()))
77
+ && !$quote->getCustomerIsGuest()
78
  ) {
79
  $quote->getCustomer()->setCreatedAt($order->getCreatedAt());
80
  $quote->getCustomer()
81
+ ->save()
82
+ ->sendNewAccountEmail('registered', '', $quote->getStoreId());
83
  }
84
  if ($this->getSession()->getOrder()->getId()) {
85
  $oldOrder = $this->getSession()->getOrder();
87
  $this->getSession()->getOrder()->setRelationChildId($order->getId());
88
  $this->getSession()->getOrder()->setRelationChildRealId($order->getIncrementId());
89
  $this->getSession()->getOrder()->cancel()
90
+ ->save();
91
  $order->save();
92
  }
93
  if ($this->getSendConfirmation()) {
94
  $order->sendNewOrderEmail();
95
  }
96
 
97
+ Mage::dispatchEvent(
98
+ 'checkout_submit_all_after', array('order' => $order,
99
+ 'quote' => $quote)
100
+ );
101
 
102
  return $order;
103
  }
104
+
105
  }
app/code/community/Novalnet/Payment/Model/Callbackscript.php DELETED
@@ -1,1624 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Callbackscript
27
- {
28
-
29
- var $useZendEmail = true; //false|true; adapt for your need
30
-
31
- public function Callback()
32
- {
33
- //Security Setting; only this IP is allowed for call back script
34
- $this->ipAllowed = array('195.143.189.210', '195.143.189.214'); //Novalnet IP, is a fixed value, DO NOT CHANGE!!!!!
35
- $this->debug = Mage::getStoreConfig('novalnet_global/novalnetsetting/enabledebugmode');
36
- $this->test = Mage::getStoreConfig('novalnet_global/novalnetsetting/enabletestmode');
37
-
38
- $this->callback = false;
39
- $this->recurring = false;
40
- $this->request = $this->getParam();
41
- $this->currentTime = Mage::getModel('core/date')->date('Y-m-d H:i:s');
42
- $this->emailSendOption = Mage::getStoreConfig('novalnet_global/novalnetsetting/emailsendoption');
43
-
44
- $this->allowedPayment = array(
45
- 'novalnetcc' => array('CREDITCARD', 'CREDITCARD_BOOKBACK', 'CREDITCARD_CHARGEBACK',
46
- 'CREDIT_ENTRY_CREDITCARD', 'SUBSCRIPTION_STOP', 'DEBT_COLLECTION_CREDITCARD'),
47
- 'novalnetinvoice' => array('INVOICE_START', 'INVOICE_CREDIT', 'SUBSCRIPTION_STOP'),
48
- 'novalnetprepayment' => array('INVOICE_START', 'INVOICE_CREDIT', 'SUBSCRIPTION_STOP'),
49
- 'novalnetideal' => array('IDEAL'),
50
- 'novalnetpaypal' => array('PAYPAL', 'PAYPAL_BOOKBACK', 'SUBSCRIPTION_STOP'),
51
- 'novalneteps' => array('EPS'),
52
- 'novalnetgiropay' => array('GIROPAY'),
53
- 'novalnetbanktransfer' => array('ONLINE_TRANSFER', 'REFUND_BY_BANK_TRANSFER_EU'),
54
- 'novalnetsepa' => array('DIRECT_DEBIT_SEPA', 'RETURN_DEBIT_SEPA', 'SUBSCRIPTION_STOP',
55
- 'DEBT_COLLECTION_SEPA', 'CREDIT_ENTRY_SEPA'));
56
- $this->invoiceAllowed = array('INVOICE_CREDIT', 'INVOICE_START');
57
- $this->recurringAllowed = array('INVOICE_CREDIT', 'INVOICE_START', 'CREDITCARD',
58
- 'DIRECT_DEBIT_SEPA', 'SUBSCRIPTION_STOP', 'PAYPAL');
59
-
60
- /** @Array Type of payment available - Level : 0 */
61
- $this->paymentTypes = array('INVOICE_START', 'PAYPAL', 'ONLINE_TRANSFER',
62
- 'CREDITCARD', 'IDEAL', 'DIRECT_DEBIT_SEPA', 'PAYSAFECARD', 'EPS', 'GUARANTEED_INVOICE_START', 'GIROPAY');
63
- /** @Array Type of Chargebacks available - Level : 1 */
64
- $this->chargebacks = array('CREDITCARD_CHARGEBACK', 'RETURN_DEBIT_SEPA',
65
- 'CREDITCARD_BOOKBACK', 'REFUND_BY_BANK_TRANSFER_EU', 'PAYPAL_BOOKBACK');
66
- /** @Array Type of CreditEntry payment and Collections available - Level : 2 */
67
- $this->aryCollection = array('INVOICE_CREDIT', 'GUARANTEED_INVOICE_CREDIT',
68
- 'CREDIT_ENTRY_CREDITCARD', 'CREDIT_ENTRY_SEPA', 'DEBT_COLLECTION_SEPA',
69
- 'DEBT_COLLECTION_CREDITCARD');
70
- $this->arySubscription = array('SUBSCRIPTION_STOP');
71
-
72
- $httpHost = Mage::helper('core/http')->getHttpHost();
73
- $this->lineBreak = empty($httpHost) ? PHP_EOL : '<br />';
74
-
75
- //Reporting Email Addresses Settings
76
- $this->shopInfo = 'Magento ' . $this->lineBreak; //mandatory;adapt for your need
77
- $this->mailHost = Mage::getStoreConfig('system/smtp/host'); //adapt or Mage::getStoreConfig('system/smtp/host')
78
- $this->mailPort = Mage::getStoreConfig('system/smtp/port'); //adapt or Mage::getStoreConfig('system/smtp/port')
79
-
80
- if (isset($this->request['vendor_activation']) && $this->request['vendor_activation'] == 1) {
81
- $this->doNovalnetAffAccInfoLog();
82
- return false;
83
- }
84
-
85
- $this->level = $this->getPaymentTypeLevel();
86
-
87
- if (in_array($this->request['payment_type'], $this->recurringAllowed)
88
- && (!empty($this->request['signup_tid']) || !empty($this->request['subs_billing']))) {
89
- $this->recurring = true;
90
- } else {
91
- $this->callback = true;
92
- }
93
-
94
- //Parameter Settings
95
- $this->paramsRequired = array(
96
- 'vendor_id' => '',
97
- 'tid' => '',
98
- 'payment_type' => '',
99
- 'status' => '',
100
- 'amount' => '',
101
- 'tid_payment' => '',
102
- 'signup_tid' => ''
103
- );
104
-
105
- if ($this->callback) {
106
- unset($this->paramsRequired['signup_tid']);
107
- $invoiceChargeback = array_merge($this->invoiceAllowed, $this->chargebacks);
108
- if ((!in_array($this->request['payment_type'], $invoiceChargeback))) {
109
- unset($this->paramsRequired['tid_payment']);
110
- }
111
- } else {
112
- unset($this->paramsRequired['tid_payment']);
113
- unset($this->paramsRequired['order_no']);
114
- }
115
-
116
- ksort($this->paramsRequired);
117
-
118
- // ################### Main Prog. ##########################
119
- try {
120
- //Check Params
121
- if ($this->checkIP()) {
122
-
123
- $response = $this->request;
124
- $helper = $this->_getNovalnetHelper();
125
- if ($this->recurring) {
126
- $recurringProfileId = $this->getProfileInformation($this->request);
127
- $orderNo = $this->getRecurringOrderNo($recurringProfileId);
128
- $this->orderNo = $orderNo;
129
- } else {
130
- $this->orderNo = isset($response['order_no']) && $response['order_no'] ? $response['order_no'] : '';
131
- if (!$this->orderNo) {
132
- $this->orderNo = $this->getOrderIdByTransId();
133
- }
134
- }
135
- $this->order = Mage::getModel('sales/order')->loadByIncrementId($this->orderNo); // Get order object
136
- $this->currency = $this->order->getOrderCurrencyCode(); // Get order currency
137
-
138
- if (empty($response['payment_type'])) {
139
- $this->showDebug("Required param (payment_type) missing!");
140
- } elseif (empty($this->orderNo)) {
141
- $this->showDebug("Required (Transaction ID) not Found!");
142
- } elseif (!empty($response['payment_type'])
143
- && in_array(strtoupper($response['payment_type']), array_merge($this->paymentTypes, $this->chargebacks, $this->aryCollection, $this->arySubscription))) {
144
- //Complete the order incase response failure from novalnet server
145
- $order = $this->getOrderByIncrementId($this->orderNo);
146
- $storeId = $order->getStoreId();
147
- $this->getEmailConfig($storeId);
148
- if ($order->getIncrementId()) {
149
- $payment = $order->getPayment();
150
- $paymentObj = $payment->getMethodInstance();
151
- $this->paymentCode = $paymentObj->getCode();
152
- $additionalData = $getResponseData = unserialize($payment->getAdditionalData());
153
- $paymentObj->_vendorId = ($getResponseData['vendor']) ? $getResponseData['vendor'] : $paymentObj->getNovalnetConfig('merchant_id', true, $storeId);
154
- $paymentObj->_authCode = ($getResponseData['auth_code']) ? $getResponseData['auth_code'] : $paymentObj->getNovalnetConfig('auth_code', true, $storeId);
155
- $paymentObj->_productId = ($getResponseData['product']) ? $getResponseData['product'] : $paymentObj->getNovalnetConfig('product_id', true, $storeId);
156
- $checkTidExist = $payment->getLastTransId();
157
- $this->paymentTypeValidation($order);
158
- if (!empty($this->orderNo) && $order->getIncrementId() == $this->orderNo && empty($checkTidExist)) {
159
-
160
- //Unhold an order:-
161
- if ($order->canUnhold()) {
162
- $order->unhold()->save();
163
- }
164
-
165
- $serverResponseMode = $response['test_mode'];
166
- $shopMode = $paymentObj->getNovalnetConfig('live_mode', '', $storeId);
167
- $testMode = ((isset($serverResponseMode) && $serverResponseMode == 1) || (isset($shopMode) && $shopMode == 0)) ? 1 : 0;
168
- $data = array('NnTestOrder' => $testMode);
169
- $data = $additionalData ? array_merge($additionalData, $data) : $data;
170
- $txnId = $response['tid'];
171
- $payment->setStatus(Novalnet_Payment_Model_Payment_Method_Abstract::STATUS_SUCCESS)
172
- ->setStatusDescription($helper->__('Payment was successful.'))
173
- ->setAdditionalData(serialize($data))
174
- ->setIsTransactionClosed(true)
175
- ->save();
176
- $dataObj = new Varien_Object($response);
177
- $this->doTransactionStatusSave($dataObj); // Save the Transaction status
178
- // Payment process based on response status
179
- if ($payment->getAdditionalInformation($paymentObj->getCode() . '_successAction') != 1) {
180
- $payment->setAdditionalInformation($paymentObj->getCode() . '_successAction', 1);
181
- $payment->setTransactionId($txnId)
182
- ->setLastTransId($txnId)
183
- ->setParentTransactionId(null);
184
- if ($order->canInvoice()
185
- && $this->request['status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
186
- && $this->request['tid_status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED ) {
187
- $payment->setIsTransactionClosed(true)
188
- ->capture(null);
189
- }
190
- $payment->save();
191
- $onHoldStatus = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('paymentOnholdStaus');
192
- array_push($onHoldStatus, '100', '90');
193
- if (in_array($this->request['status'], $onHoldStatus) && in_array($this->request['tid_status'], array(100,99,98,91,90)) ) {
194
- $this->callbackRegisterRecurring($payment, 'Success');
195
- $orderStatus = $this->getOrderStatus($order);
196
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $orderStatus, $helper->__('Customer successfully returned from Novalnet'), true
197
- )->save();
198
- $this->showDebug("Novalnet callback received. Order details are updated");
199
- } else {
200
- $payment->setStatus(Mage_Sales_Model_Order::STATE_CANCELED)
201
- ->setIsTransactionClosed(true)
202
- ->save();
203
- $this->callbackRegisterRecurring($payment);
204
- $paymentObj->saveCancelledOrder($dataObj, $payment);
205
- $this->showDebug("Novalnet callback received. Transaction status not valid");
206
- }
207
- }
208
-
209
- $this->callBackExecuted = true;
210
- $this->doTransactionOrderLog($response);
211
- //sendNewOrderEmail
212
- if (!$order->getEmailSent() && $order->getId()
213
- && in_array($this->request['status'], $onHoldStatus)) {
214
- try {
215
- $order->sendNewOrderEmail()
216
- ->setEmailSent(true)
217
- ->save();
218
- } catch (Exception $e) {
219
- $helper->showException('Cannot send new order email.');
220
- }
221
- }
222
- $order->save();
223
- $this->emailBody = "Novalnet Callback received for the TID: " . $txnId . ".";
224
- }
225
-
226
- //Get Order ID and Set New Order Status
227
- if ($this->checkParams($response)) {
228
- $orderCheckStatus = $this->BasicValidation();
229
- if ($orderCheckStatus) {
230
- $this->setOrderStatus();
231
- }
232
- }
233
- } else {
234
- $this->showDebug("Order no [" . $this->orderNo . "] is not valid!");
235
- }
236
- } else {
237
- $this->showDebug("Payment type [" . $response['payment_type'] . "] is mismatched!");
238
- }
239
- }
240
-
241
- } catch (Exception $e) {
242
- $this->emailBody .= "Exception catched: $this->lineBreak\$e:" . $e->getMessage() . $this->lineBreak;
243
- }
244
-
245
- $this->sendCallbackMail();
246
- }
247
-
248
- /**
249
- * Send callback notification E-mail
250
- *
251
- * @return boolean
252
- */
253
- private function sendCallbackMail()
254
- {
255
- if (isset($this->emailBody) && $this->emailBody && $this->emailFromAddr && $this->emailToAddr) {
256
- if (!$this->sendMail($this->emailBody)) {
257
- $this->showDebug("Mailing failed!".$this->lineBreak, false);
258
- $this->showDebug("This mail text should be sent: ", false);
259
- }
260
- }
261
-
262
- if (isset($this->emailBody)) {
263
- $this->showDebug($this->emailBody);
264
- }
265
- }
266
-
267
- /**
268
- * Send callback notification E-mail
269
- *
270
- * @param string $emailBody
271
- * @return boolean
272
- */
273
- public function sendMail($emailBody)
274
- {
275
- //Send Email
276
- if ($this->mailHost && $this->mailPort) {
277
- ini_set('SMTP', $this->mailHost);
278
- ini_set('smtp_port', $this->mailPort);
279
- }
280
-
281
- if ($this->useZendEmail) {
282
- if ($this->emailSendOption && !$this->sendEmailZend($emailBody)) {
283
- return false;
284
- }
285
- } else {
286
- if ($this->emailSendOption && !$this->sendEmailMagento($emailBody)) {
287
- return false;
288
- }
289
- }
290
-
291
- return true;
292
- }
293
-
294
- /**
295
- * Send callback notification E-mail via Magento
296
- *
297
- * @param string $emailBody
298
- * @return boolean
299
- */
300
- public function sendEmailMagento($emailBody)
301
- {
302
- /*
303
- * Loads the html file named 'novalnet_callback_email.html' from
304
- * E.G: app/locale/en_US/template/email/novalnet/novalnet_callback_email.html
305
- * OR: app/locale/YourLanguage/template/email/novalnet/novalnet_callback_email.html
306
- * Adapt the corresponding template if necessary
307
- */
308
- $emailTemplate = Mage::getModel('core/email_template')
309
- ->loadDefault('novalnet_callback_email_template');
310
-
311
- //Define some variables to assign to template
312
- $emailTemplateVariables = array();
313
- $emailTemplateVariables['fromName'] = $this->emailFromName;
314
- $emailTemplateVariables['fromEmail'] = $this->emailFromAddr;
315
- $emailTemplateVariables['toName'] = $this->emailToName;
316
- $emailTemplateVariables['toEmail'] = $this->emailToAddr;
317
- $emailTemplateVariables['subject'] = $this->emailSubject;
318
- $emailTemplateVariables['body'] = $emailBody;
319
- $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
320
-
321
- $mail = new Zend_Mail();
322
- $mail->setBodyHtml($processedTemplate);
323
- $mail->setFrom($this->emailFromAddr, $this->emailFromName);
324
- $mail->addTo($this->emailToAddr, $this->emailToName);
325
- $mail->setSubject($this->emailSubject);
326
-
327
- try {
328
- $this->showDebug(__FUNCTION__ . ': Sending Email succeeded!'.$this->lineBreak, false);
329
- $emailTemplate->send($this->emailToAddr, $this->emailToName, $emailTemplateVariables);
330
- } catch (Exception $e) {
331
- Mage::getSingleton('core/session')->addError($this->_getNovalnetHelper()->__('Unable to send email'));
332
- $this->showDebug('Email sending failed: ', false);
333
- return false;
334
- }
335
- return true;
336
- }
337
-
338
- /**
339
- * Send callback notification E-mail via zend
340
- *
341
- * @param string $emailBody
342
- * @return boolean
343
- */
344
- public function sendEmailZend($emailBody)
345
- {
346
- $this->validatorEmail = new Zend_Validate_EmailAddress();
347
-
348
- $mail = new Zend_Mail();
349
- $mail->setBodyHtml($emailBody);
350
- $mail->setFrom($this->emailFromAddr, $this->emailFromName);
351
- $this->emailSeparate($this->emailToAddr, $mail, 'To');
352
- $this->emailSeparate($this->emailBCcAddr, $mail, 'Bcc');
353
- $mail->setSubject($this->emailSubject);
354
-
355
- try {
356
- $mail->send();
357
- $this->showDebug(__FUNCTION__ . ': Sending Email succeeded!'.$this->lineBreak, false);
358
- } catch (Exception $e) {
359
- $this->showDebug('Email sending failed: ', false);
360
- return false;
361
- }
362
- return true;
363
- }
364
-
365
- /**
366
- * E-mail TO and Bcc address comma separate
367
- *
368
- * @param string $emailaddr
369
- * @param string $mail
370
- * @param string $addr
371
- * @return string
372
- */
373
- public function emailSeparate($emailaddr, $mail, $addr)
374
- {
375
- $email = explode(',', $emailaddr);
376
- $validatorEmail = $this->validatorEmail;
377
-
378
- foreach ($email as $emailAddrVal) {
379
- if ($validatorEmail->isValid(trim($emailAddrVal))) {
380
- ($addr == 'To') ? $mail->addTo($emailAddrVal) : $mail->addBcc($emailAddrVal);
381
- }
382
- }
383
- return $mail;
384
- }
385
-
386
- /**
387
- * Check the callback mandatory parameters.
388
- *
389
- * @param array $request
390
- * @return boolean
391
- */
392
- public function checkParams($request)
393
- {
394
- if (!$request) {
395
- $this->showDebug('Novalnet callback received. No params passed over!');
396
- }
397
-
398
- if (in_array($request['payment_type'], $this->arySubscription)) {
399
- unset($this->paramsRequired['amount']);
400
- }
401
-
402
- foreach ($this->paramsRequired as $k => $v) {
403
- if (isset($k) && $k == 'amount'
404
- && (!is_numeric($request[$k]) || $request[$k] < 0)) {
405
- $this->showDebug('Required param (' . $k . ') missing!');
406
- } elseif (isset($k) && !in_array($k, array('amount', 'status'))
407
- && (!isset($request[$k]) || empty($request[$k]))) {
408
- $this->showDebug('Required param (' . $k . ') missing!');
409
- }
410
- }
411
-
412
- if ($this->recurring && !preg_match('/^\d{17}$/', $request['signup_tid'])) {
413
- $this->showDebug('Novalnet callback received. Invalid TID [' . $request['signup_tid'] . '] for Order.');
414
- } else if ((in_array($request['payment_type'], $this->invoiceAllowed)) || (in_array($request['payment_type'], $this->chargebacks))) {
415
- if (!$this->recurring && !preg_match('/^\d{17}$/', $request['tid_payment'])) {
416
- $this->showDebug('Novalnet callback received. Invalid TID [' . $request['tid_payment'] . '] for Order:' . $this->orderNo);
417
- }
418
- }
419
-
420
- if (!preg_match('/^\d{17}$/', $request['tid'])) {
421
- if ((in_array($request['payment_type'], $this->invoiceAllowed)) || (in_array($request['payment_type'], $this->chargebacks))) {
422
- $this->showDebug('Novalnet callback received. New TID is not valid.');
423
- } else {
424
- $this->showDebug('Novalnet callback received. Invalid TID [' . $request['tid'] . '] for Order:' . $this->orderNo);
425
- }
426
- }
427
-
428
- if ($request['payment_type'] == 'INVOICE_CREDIT' && !empty($request['status']) && Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED != $request['status']) {
429
- $this->showDebug('Novalnet callback received. Callback Script executed already. Refer Order :' . $this->orderNo);
430
- }
431
-
432
- return true;
433
- }
434
-
435
- /**
436
- * validate the callback parameters.
437
- *
438
- * @return boolean
439
- */
440
- public function BasicValidation()
441
- {
442
- $request = $this->request;
443
- $orderNo = $this->orderNo;
444
- $order = $this->getOrderByIncrementId($orderNo);
445
-
446
- if ($this->recurring && $request['subs_billing'] && $request['signup_tid']) {
447
- $recurringProfileId = $this->getProfileInformation($request);
448
- $activeState = $recurringProfileId->getState();
449
- $orderNo = $this->getRecurringOrderNo($recurringProfileId);
450
- }
451
-
452
- if ($order->getIncrementId() == $orderNo && !empty($orderNo)) {
453
- $orderPaymentName = strtolower($this->paymentCode);
454
-
455
- if ($request['subs_billing'] == 1) {
456
- $orgTid = $request['signup_tid'];
457
- } else if ((in_array($request['payment_type'], $this->chargebacks)) || $request['payment_type'] == 'INVOICE_CREDIT') {
458
- $orgTid = $request['tid_payment'];
459
- } else {
460
- $orgTid = $request['tid'];
461
- }
462
-
463
- $paymentType = $this->allowedPayment[$orderPaymentName];
464
- if (!in_array($request['payment_type'], $paymentType)) {
465
- $this->showDebug("Novalnet callback received. Payment type (" . $request['payment_type'] . ") is not matched with $orderPaymentName!");
466
- }
467
-
468
- $payment = $order->getPayment();
469
- $additionalData = unserialize($payment->getAdditionalData());
470
- $orderTid = ((in_array($request['payment_type'], $this->chargebacks)) && $additionalData['NnTid']) ? $additionalData['NnTid'] : $order->getPayment()->getLastTransId();
471
-
472
- if (!preg_match('/^' . $orgTid . '/i', $orderTid) && !$this->recurring) {
473
- $this->showDebug('Novalnet callback received. Order no is not valid');
474
- }
475
-
476
- if ($this->recurring && $request['subs_billing'] && $activeState == 'canceled') {
477
- $this->showDebug('Subscription already Cancelled. Refer Order : ' . $orderNo);
478
- }
479
-
480
- return true;
481
- } else {
482
- $this->showDebug('Novalnet callback received. Order no is not valid');
483
- }
484
- }
485
-
486
- /**
487
- * Set the staus and state to an order payment
488
- *
489
- * @return boolean
490
- */
491
- public function setOrderStatus()
492
- {
493
- $order = $this->getOrderByIncrementId($this->orderNo);
494
- $orderItems = $order->getAllItems();
495
- $helper = $this->_getNovalnetHelper();
496
- $nominalItem = $helper->checkNominalItem($orderItems);
497
-
498
- if ($order) {
499
- $status = $this->getOrderStatus($order);
500
- $state = Mage_Sales_Model_Order::STATE_PROCESSING;
501
- $request = $this->request;
502
- $order->getPayment()->getMethodInstance()->setCanCapture(true);
503
- $payment = $order->getPayment();
504
- $data = unserialize($payment->getAdditionalData());
505
- $currency = $this->currency;
506
- if ($this->level == 1) { //level 1 payments - Type of Chargebacks
507
- if ($request['status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED && $request['tid_status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
508
- // Update callback comments for Chargebacks
509
- if (in_array($this->request['payment_type'], $this->chargebacks)) {
510
- $bookBack = array('CREDITCARD_BOOKBACK', 'REFUND_BY_BANK_TRANSFER_EU', 'PAYPAL_BOOKBACK');
511
- $tId = !$this->recurring ? $request['tid_payment'] : $request['signup_tid'];
512
- if (in_array($request['payment_type'], $bookBack)) {
513
- $script = 'Novalnet callback received. Refund/Bookback executed successfully for the TID: ' . $tId . ' amount: ' . ($request['amount'])
514
- / 100 . ' ' . $currency . " on " . date('Y-m-d H:i:s') . '. The subsequent TID: ' . $request['tid'];
515
- } else {
516
- $script = 'Novalnet callback received. Chargeback executed successfully for the TID ' . $tId . ' amount ' . ($request['amount']) / 100 . ' ' . $currency . " on " . $this->currentTime . '. The subsequent TID: ' . $request['tid'];
517
- }
518
- $this->emailBody = $script;
519
- $this->saveAdditionalInfo($payment, $data, $script, $order);
520
- return true;
521
- }
522
- } else {
523
- $this->showDebug("Novalnet callback received. Status is not valid.");
524
- }
525
- }
526
- if ($request['payment_type'] == 'SUBSCRIPTION_STOP') { ### Cancellation of a Subscription
527
- ### UPDATE THE STATUS OF THE USER SUBSCRIPTION ###
528
- $this->subscriptionCancel($request);
529
- return true;
530
- }
531
-
532
- $invoice = $order->getInvoiceCollection()->getFirstItem();
533
- $paid = $invoice->getState();
534
- $subsPaymentType = array('DIRECT_DEBIT_SEPA', 'INVOICE_START', 'CREDITCARD', 'PAYPAL');
535
- if ($this->level == 0 || $this->level == 2) {
536
- if($this->recurring && in_array($this->request['payment_type'], $subsPaymentType)) {
537
- if(!empty($request['tid_status']) && !empty($request['status']) && in_array($request['tid_status'], array(90, 91, 98, 99, 100) )) {
538
- if (!empty($this->request['signup_tid']) && $request['status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED ) {
539
- $recurringProfileId = $this->getProfileInformation($request);
540
- $periodMaxCycles = $recurringProfileId->getPeriodMaxCycles();
541
- $profileId = $recurringProfileId->getId();
542
- $helper = $this->_getNovalnetHelper();
543
- $next_charging_date = isset($this->request['next_subs_cycle']) ? $this->request['next_subs_cycle'] : $this->request['paid_until'] ;
544
- if (!$next_charging_date) {
545
- $this->showDebug("Novalnet callback received. Subscription Suspended. Refer Order :" . $this->orderNo);
546
- }
547
-
548
- $script = 'Novalnet Callback Script executed successfully for the subscription TID: ' . $request['signup_tid'] . ' with amount ' . ($request['amount']) / 100 . ' ' . $currency . ' ' . ' on ' . $this->currentTime . '. Please refer PAID transaction in our Novalnet Merchant Administration with the TID: '. $request['tid'];
549
-
550
- $callbackCycle = $this->getRecurringCallbackSave($request, $periodMaxCycles, $helper, $profileId);
551
- $this->getEndTime($request, $recurringProfileId, $callbackCycle);
552
- $paidAmount = ($request['amount'] / 100);
553
-
554
- $helper->loadTransactionStatus($request['tid'])
555
- ->setAmount($paidAmount)
556
- ->save();
557
- $this->createOrder($order, $script, $data, $payment, $profileId);
558
- return true;
559
- } else {
560
- $request['termination_reason'] = (!empty($request['status_text']) ? $request['status_text'] : (!empty($request['status_message']) ? $request['status_message'] : $request['status_desc']));
561
- $this->subscriptionCancel($request);
562
- return true;
563
- }
564
- } else {
565
- $this->showDebug("Novalnet callback received. Status is not valid.");
566
- }
567
- }
568
- if((isset($request['status']) && $request['status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) && (isset($request['tid_status']) && $request['tid_status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) ) {
569
- $saveInvoice = '';
570
- $saveInvoice = $this->saveInvoice($order, $nominalItem, $paid);
571
- if ($invoice) {
572
- if ($saveInvoice && in_array($request['payment_type'], array('INVOICE_CREDIT', 'PAYPAL'))) {
573
- $order->setState($state, true, 'Novalnet callback set state ' . $state . ' for Order-ID = ' . $this->orderNo);
574
- $order->addStatusToHistory($status, 'Novalnet callback added order status ' . $status);
575
- $this->emailBody .= 'Novalnet callback set state to ' . $state . $this->lineBreak;
576
- $this->emailBody .= 'Novalnet callback set status to ' . $status . ' ... ' . $this->lineBreak;
577
- $order->save();
578
-
579
- if (in_array($request['payment_type'], $this->invoiceAllowed)) {
580
- if ($nominalItem) {
581
- $tidPayment = isset($request['signup_tid']) && $request['signup_tid'] && $request['subs_billing'] ? trim($request['signup_tid']) : trim($request['tid_payment']);
582
- } else {
583
- $tidPayment = trim($request['tid']);
584
- }
585
- $amount = $this->_getNovalnetHelper()->getFormatedAmount($request['amount'], 'RAW');
586
- $currency = $this->currency;
587
- $script = 'Novalnet Callback Script executed successfully for the TID: ' . $request['tid_payment'] . ' with amount ' . $amount . ' ' . $currency . ' on ' . $this->currentTime . '. Please refer PAID transaction in our Novalnet Merchant Administration with the TID: ' . $request['tid'];
588
- } else {
589
- $tidPayment = trim($request['tid']);
590
- $script = 'Novalnet Callback Script executed successfully on ' . $this->currentTime;
591
- }
592
- $transMode = (version_compare($helper->getMagentoVersion(), '1.6', '<')) ? false : true;
593
- $payment->setTransactionId($tidPayment)
594
- ->setIsTransactionClosed($transMode);
595
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false);
596
- $transaction->setParentTxnId(null)
597
- ->save();
598
- $this->saveAdditionalInfo($payment, $data, $script, $order);
599
- $changeAmount = $helper->getAmountCollection($order->getId(), 1, NULL);
600
- if ($changeAmount) {
601
- $loadTransStatus = $helper->loadTransactionStatus($request['tid_payment']);
602
- $loadTransStatus->setAmount($changeAmount)
603
- ->save();
604
- }
605
- }
606
- } else {
607
- $this->showDebug("Novalnet Callback: No invoice for order (" . $order->getId() . ") found");
608
- }
609
- } else {
610
- $this->showDebug("Novalnet callback received. Status is not valid.");
611
- }
612
- }
613
- } else {
614
- $this->showDebug("Novalnet Callback: No order for Increment-ID $this->orderNo found.");
615
- }
616
- return true;
617
- }
618
-
619
- /**
620
- * Create invoice to order payment
621
- *
622
- * @param varien_object $order
623
- * @param varien_object $nominalItem
624
- * @param int $paid
625
- * @return boolean
626
- */
627
- public function saveInvoice(Mage_Sales_Model_Order $order, $nominalItem, $paid)
628
- {
629
- if (!$this->callBackExecuted) {
630
- $request = $this->request;
631
- $orderNo = $this->orderNo;
632
- $helper = $this->_getNovalnetHelper();
633
- $payment = $order->getPayment();
634
- $paymentObj = $payment->getMethodInstance();
635
- $data = unserialize($payment->getAdditionalData());
636
-
637
- $novalnetCallbackModel = Mage::getModel('novalnet_payment/callback')->loadLogByOrderId($orderNo);
638
- $sum = sprintf(($request['amount'] + $novalnetCallbackModel->getCallbackAmount()), 0.2);
639
- $amountvalue = $this->getRecurringTotal($request, $order, $nominalItem);
640
- $grandTotal = sprintf(($amountvalue * 100), 0.2);
641
- if (!$this->recurring) {
642
- $tidPayment = $request['tid_payment'];
643
- } else {
644
- $tidPayment = $request['signup_tid'];
645
- }
646
- if (in_array($request['payment_type'], $this->invoiceAllowed) && $sum < $grandTotal) {
647
-
648
- $this->doNovalnetCallbackLog($novalnetCallbackModel, $request, $sum);
649
- $amount = $helper->getFormatedAmount($request['amount'], 'RAW');
650
- $this->emailBody = "Novalnet Callback Script executed successfully for the TID: " . $tidPayment . " with amount " . $amount . " " . $this->currency . " on " . $this->currentTime . ". Please refer PAID transaction in our Novalnet Merchant Administration with the TID: " . $request['tid'] . "$this->lineBreak$this->lineBreak";
651
- $script = "Novalnet Callback Script executed successfully for the TID: " . $tidPayment . " with amount " . $amount . " " . $this->currency . " on " . $this->currentTime . ". Please refer PAID transaction in our Novalnet Merchant Administration with the TID: " . $request['tid'] . $this->lineBreak;
652
- $this->saveAdditionalInfo($payment, $data, $script, $order);
653
- return false;
654
- } else {
655
- $this->doNovalnetCallbackLog($novalnetCallbackModel, $request, $sum);
656
- $amount = $helper->getFormatedAmount($request['amount'], 'RAW');
657
- if ($order->canInvoice()) {
658
- $tid = $this->requestTid($request);
659
- $invoice = $order->prepareInvoice();
660
- $invoice->setTransactionId($tid);
661
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE)
662
- ->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID)
663
- ->register();
664
- Mage::getModel('core/resource_transaction')
665
- ->addObject($invoice)
666
- ->addObject($invoice->getOrder())
667
- ->save();
668
-
669
- $amount = $helper->getFormatedAmount($request['amount'], 'RAW');
670
- if (in_array($request['payment_type'], $this->invoiceAllowed)) {
671
- $emailText = "Novalnet Callback Script executed successfully for the TID: " . $tidPayment . " with amount " . $amount . " ". $this->currency . " on " . $this->currentTime . ". Please refer PAID transaction in our Novalnet Merchant Administration with the TID: " . $request['tid'] . "$this->lineBreak$this->lineBreak";
672
-
673
- $this->emailBody = ($sum > $grandTotal) ? $emailText . "Your paid amount is greater than the order total amount. $this->lineBreak" : $emailText;
674
- } else {
675
- $this->emailBody = "Novalnet Callback Script executed successfully for the TID: " . $request['tid'] . " with amount " . $amount . " ". $this->currency . " on " . $this->currentTime . ". $this->lineBreak$this->lineBreak";
676
- }
677
- $this->saveAdditionalInfo($payment, $data, $this->emailBody, $order);
678
- } else {
679
- if ($paymentObj->getCode() == Novalnet_Payment_Model_Config::NN_INVOICE && $paid == 1) {
680
- $currency = $this->currency;
681
- $scriptText = 'Novalnet Callback Script executed successfully for the TID: ' . $request['tid_payment'] . ' with amount ' . $amount . ' ' . $currency . ' on ' . $this->currentTime . '. Please refer PAID transaction in our Novalnet Merchant Administration with the TID: ' . $request['tid'];
682
- $script = ($sum > $grandTotal) ? $scriptText . '.Your paid amount is greater than the order total amount.' : $scriptText;
683
- $this->emailBody = $script;
684
- $this->saveAdditionalInfo($payment, $data, $scriptText, $order);
685
- $this->saveOrderStatus($order, $nominalItem);
686
- $this->sendCallbackMail();
687
- die;
688
- }
689
-
690
- $invoicePayments = array(Novalnet_Payment_Model_Config::NN_PREPAYMENT, Novalnet_Payment_Model_Config::NN_INVOICE);
691
- if (in_array($paymentObj->getCode(), $invoicePayments)) {
692
- $this->showDebug("Novalnet callback received. Callback Script executed already. Refer Order :" . $this->orderNo);
693
- } elseif ($paymentObj->getCode() == Novalnet_Payment_Model_Config::NN_PAYPAL) {
694
- $this->showDebug("Novalnet callback received. Order already paid.");
695
- } else {
696
- $this->showDebug("Novalnet Callbackscript received. Payment type ( " . $request['payment_type'] . " ) is not applicable for this process!");
697
- }
698
- }
699
- }
700
- }
701
- return true;
702
- }
703
-
704
- /**
705
- * Save order status invoice payment
706
- *
707
- * @param varien_object $order
708
- * @param varien_object $nominalItem
709
- */
710
- private function saveOrderStatus($order, $nominalItem)
711
- {
712
- $payment = $order->getPayment();
713
- $originalTid = trim($payment->getLastTransId());
714
- if (!$this->recurring && !$nominalItem) {
715
- $transaction = Mage::getModel('sales/order_payment')->getCollection()
716
- ->addFieldToFilter('last_trans_id', $originalTid)
717
- ->addFieldToSelect('entity_id');
718
- foreach ($transaction as $transactionId) {
719
- $entitiyId = $transactionId->getEntityId();
720
- }
721
- Mage::getModel('sales/order_payment')->load($entitiyId)
722
- ->setLastTransId(trim($this->request['tid']))
723
- ->save();
724
- }
725
-
726
- $orderStatus = $this->getOrderStatus($order);
727
- $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
728
- $order->setState($orderState, true, 'Novalnet callback set state ' . $orderState . ' for Order-ID = ' . $this->orderNo);
729
- $order->addStatusToHistory($orderStatus, 'Novalnet callback added order status ' . $orderStatus);
730
- $order->save();
731
-
732
- $invoice = $order->getInvoiceCollection()->getFirstItem();
733
- $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
734
- $invoice->save();
735
-
736
- if ($this->recurring || $nominalItem) {
737
- $profileInfo = $this->getProfileInformation($this->request);
738
- if ($profileInfo->getState() != 'canceled') {
739
- $profileInfo->setState('active');
740
- $profileInfo->save();
741
- }
742
- }
743
- }
744
-
745
- /**
746
- * Save order status invoice payment
747
- *
748
- * @param none
749
- * @return none
750
- */
751
- private function _updateOrderStatus($order)
752
- {
753
- $orderStatus = $this->getOrderStatus($order); // Get order status
754
- $state = Mage_Sales_Model_Order::STATE_PROCESSING;
755
- $order->setState($state, true, 'Novalnet callback set state ' . $state . ' for Order-ID = ' . $this->orderNo);
756
- $order->addStatusToHistory($orderStatus, 'Novalnet callback added order status ' . $orderStatus);
757
- $this->emailBody .= 'Novalnet callback set state to ' . $state . $this->lineBreak;
758
- $this->emailBody .= 'Novalnet callback set status to ' . $orderStatus . ' ... ' . $this->lineBreak;
759
- $order->save();
760
- }
761
-
762
- /**
763
- * Get the payment method code from order
764
- *
765
- * @param varien_object $order
766
- * @return string
767
- */
768
- private function getPaymentMethod($order)
769
- {
770
- return $order->getPayment()->getData('method');
771
- }
772
-
773
- /**
774
- * Check whether the ip address is authorised
775
- *
776
- * @return boolean
777
- */
778
- public function checkIP()
779
- {
780
- $callerIp = $this->_getNovalnetHelper()->getRealIpAddr();
781
-
782
- if (!in_array($callerIp, $this->ipAllowed) && !$this->test) {
783
- $this->debug = true;
784
- $this->showDebug('Novalnet callback received. Unauthorised access from the IP [' . $callerIp . ']');
785
- }
786
-
787
- return true;
788
- }
789
-
790
- /**
791
- * Log Novalnet transaction status data
792
- *
793
- * @param array $response
794
- */
795
- public function doTransactionStatusSave($response)
796
- {
797
- $order = $this->getOrderByIncrementId($this->orderNo);
798
- $amount = $response['amount'];
799
- $status = trim($this->request['status']);
800
- $ncNo = (isset($response['nc_no'])) ? $response['nc_no'] : NULL;
801
- $helper = $this->_getNovalnetHelper();
802
- $payment = $order->getPayment();
803
- $paymentObj = $payment->getMethodInstance();
804
- $storeId = $order->getStoreId();
805
- $transactionStatus = Mage::getModel('novalnet_payment/transactionstatus');
806
- $transactionStatus->setTransactionNo($response['tid'])
807
- ->setOrderId($this->orderNo)
808
- ->setTransactionStatus($status)
809
- ->setNcNo($ncNo)
810
- ->setCustomerId($response['customer_no'])
811
- ->setPaymentName($this->paymentCode)
812
- ->setAmount($helper->getFormatedAmount($amount, 'RAW'))
813
- ->setRemoteIp($helper->getRealIpAddr())
814
- ->setStoreId($storeId)
815
- ->setShopUrl($helper->getCurrentSiteUrl())
816
- ->setCreatedDate($helper->getCurrentDateTime())
817
- ->save();
818
- }
819
-
820
- /**
821
- * Log Novalnet transaction data
822
- *
823
- * @param array $response
824
- */
825
- public function doTransactionOrderLog($response)
826
- {
827
- $order = $this->getOrderByIncrementId($this->orderNo);
828
- $helper = $this->_getNovalnetHelper();
829
- $storeId = $order->getStoreId();
830
- $transactionOverview = $helper->getModelTransactionOverview()->loadByAttribute('order_id', $this->orderNo);
831
- $transactionOverview->setTransactionId($response['tid'])
832
- ->setResponseData(base64_encode(serialize($response)))
833
- ->setCustomerId($response['customer_no'])
834
- ->setStatus($response['status'])
835
- ->setStoreId($storeId)
836
- ->setShopUrl($helper->getCurrentSiteUrl())
837
- ->save();
838
- }
839
-
840
- /**
841
- * Log partial callback data
842
- *
843
- * @param Novalnet_Payment_Model_Callback $novalnetCallbackModel
844
- * @param array $response
845
- * @param int $sum
846
- */
847
- public function doNovalnetCallbackLog($novalnetCallbackModel, $response, $sum)
848
- {
849
- $orgTid = $this->requestTid($response);
850
- $orderNo = $this->orderNo;
851
- $reqUrl = Mage::helper('core/http')->getRequestUri();
852
- $novalnetCallbackModel->setOrderId($orderNo)
853
- ->setCallbackAmount($sum)
854
- ->setReferenceTid($orgTid)
855
- ->setCallbackDatetime($this->currentTime)
856
- ->setCallbackLog($reqUrl)
857
- ->save();
858
- }
859
-
860
- /**
861
- * Subscription cancellation
862
- *
863
- * @param $subscriptionParams
864
- */
865
- public function subscriptionCancel($request)
866
- {
867
- $helper = $this->_getNovalnetHelper();
868
- $script = 'Novalnet Callback script received. Subscription has been stopped for the TID:' . $request['signup_tid'] . " on " . $this->currentTime;
869
- $script .= '<br>Subscription has been canceled due to: ' . $request['termination_reason'];
870
- $this->emailBody = $script;
871
- $recurringProfileId = $this->getProfileInformation($request);
872
- $orderNumber = $helper->getModelRecurring()->getRecurringOrderNo($recurringProfileId);
873
- $parentOrder = $this->getOrderByIncrementId($orderNumber[0]);
874
- $parentPayment = $parentOrder->getPayment();
875
-
876
- $parentData = unserialize($parentPayment->getAdditionalData());
877
- $this->saveAdditionalInfo($parentPayment, $parentData, $script, $parentOrder);
878
- $recurringProfileId->setState('canceled');
879
- $recurringProfileId->save();
880
- }
881
-
882
- /**
883
- * Log Affiliate account details
884
- *
885
- */
886
- private function doNovalnetAffAccInfoLog()
887
- {
888
- $request = $this->request;
889
- $helper = $this->_getNovalnetHelper();
890
- $affiliateAccInfo = $helper->getModelAffiliate();
891
- $affiliateAccInfo->setVendorId($request['vendor_id'])
892
- ->setVendorAuthcode($request['vendor_authcode'])
893
- ->setProductId($request['product_id'])
894
- ->setProductUrl($request['product_url'])
895
- ->setActivationDate($request['activation_date'])
896
- ->setAffId($request['aff_id'])
897
- ->setAffAuthcode($request['aff_authcode'])
898
- ->setAffAccesskey($request['aff_accesskey'])
899
- ->save();
900
- //Send notification mail to Merchant
901
- $this->getEmailConfig();
902
- $this->emailBody = 'Novalnet callback script executed successfully with Novalnet account activation information.';
903
- $this->sendCallbackMail();
904
- }
905
-
906
- /**
907
- * Get Novalnet Helper
908
- *
909
- * @return Novalnet_Payment_Helper_Data
910
- */
911
- private function _getNovalnetHelper()
912
- {
913
- return Mage::helper('novalnet_payment');
914
- }
915
-
916
- /**
917
- * Get order object for specific order id
918
- *
919
- * @param int $incrementId
920
- * @return varien_object
921
- */
922
- public function getOrderByIncrementId($incrementId)
923
- {
924
- $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
925
- return $order;
926
- }
927
-
928
- /**
929
- * Get Request param
930
- *
931
- * @return array
932
- */
933
- public function getParam()
934
- {
935
- return Mage::app()->getRequest()->getPost() ? Mage::app()->getRequest()->getPost() : Mage::app()->getRequest()->getQuery();
936
- }
937
-
938
- /**
939
- * Get the order payment status
940
- *
941
- * @param varien_object $order
942
- * @return string
943
- */
944
- private function getOrderStatus($order)
945
- {
946
- $payment = $order->getPayment();
947
- $paymentObj = $payment->getMethodInstance();
948
- $storeId = $order->getStoreId();
949
- $getResponseData = unserialize($payment->getAdditionalData());
950
- $redirectPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
951
- array_push($redirectPayment, Novalnet_Payment_Model_Config::NN_PREPAYMENT, Novalnet_Payment_Model_Config::NN_INVOICE, Novalnet_Payment_Model_Config::NN_CC);
952
-
953
- $status = $paymentObj->getConfigData('order_status', '', $storeId);
954
- if ($paymentObj->getCode() && in_array($paymentObj->getCode(), $redirectPayment)) {
955
- $status = $paymentObj->getConfigData('order_status_after_payment', '', $storeId);
956
- }
957
-
958
- if ($paymentObj->getCode() && $paymentObj->getCode() == Novalnet_Payment_Model_Config::NN_PAYPAL && ($this->request['tid_status'] == Novalnet_Payment_Model_Config::PAYPAL_PENDING_CODE)) {
959
- $status = $paymentObj->getConfigData('order_status', '', $storeId) ? $paymentObj->getConfigData('order_status', '', $storeId) : Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
960
- }
961
-
962
- if (!$status) {
963
- $status = Mage_Sales_Model_Order::STATE_PROCESSING;
964
- }
965
- return $status;
966
- }
967
-
968
- /**
969
- * Get the Recurring Profile Order No
970
- *
971
- * @param int $recurringProfileId
972
- * @return int
973
- */
974
- private function getRecurringOrderNo($recurringProfileId)
975
- {
976
- $orderNo = '';
977
- $recurringProfileCollection = Mage::getResourceModel('sales/order_grid_collection')
978
- ->addRecurringProfilesFilter($recurringProfileId->getId());
979
- foreach ($recurringProfileCollection as $recurringProfileCollectionValue) {
980
- $orderNo = $recurringProfileCollectionValue->getIncrementId();
981
- }
982
- return $orderNo;
983
- }
984
-
985
- /**
986
- * Get the Recurring Profile Information
987
- *
988
- * @param varien_object $request
989
- * @return int
990
- */
991
- private function getProfileInformation($request)
992
- {
993
- $tid = (isset($request['signup_tid']) && $request['signup_tid']) ? $request['signup_tid'] : $request['tid_payment'];
994
-
995
- $recurringProfileId = Mage::getModel('sales/recurring_profile')->load($tid, 'reference_id');
996
- return $recurringProfileId;
997
- }
998
-
999
- /**
1000
- * Get the Recurring Callback save
1001
- *
1002
- * @param varien_object $request
1003
- * @param int $periodMaxCycles
1004
- * @param Novalnet_Payment_Helper_Data $helper
1005
- * @param int $profileId
1006
- * @return int
1007
- */
1008
- private function getRecurringCallbackSave($request, $periodMaxCycles, $helper, $profileId)
1009
- {
1010
- $recurringCollection = $helper->getModelRecurring()->getCollection();
1011
- $recurringCollection->addFieldToFilter('profile_id', $profileId);
1012
- $recurringCollection->addFieldToSelect('callbackcycle');
1013
- $countRecurring = count($recurringCollection);
1014
- if ($countRecurring == 0) {
1015
- $callbackCycle = 1;
1016
- $recurringSave = $helper->getModelRecurring();
1017
- $recurringSave->setProfileId($profileId);
1018
- $recurringSave->setSignupTid($request['signup_tid']);
1019
- $recurringSave->setBillingcycle($periodMaxCycles);
1020
- $recurringSave->setCallbackcycle($callbackCycle);
1021
- $recurringSave->setCycleDatetime($this->currentTime);
1022
- $recurringSave->save();
1023
- } else {
1024
- foreach ($recurringCollection as $recurringValue) {
1025
- $callbackCycle = $recurringValue->getCallbackcycle();
1026
- }
1027
- $callbackCycle = $callbackCycle + 1;
1028
- $recurringSave = $helper->getModelRecurring()->load($profileId, 'profile_id');
1029
- $recurringSave->setCallbackcycle($callbackCycle);
1030
- $recurringSave->setCycleDatetime($this->currentTime);
1031
- $recurringSave->save();
1032
- }
1033
- return $callbackCycle;
1034
- }
1035
-
1036
- /**
1037
- * Get the Recurring End Time
1038
- *
1039
- * @param varien_object $request
1040
- * @param int $recurringProfileId
1041
- * @param int $callbackCycle
1042
- */
1043
- private function getEndTime($request, $recurringProfileId, $callbackCycle)
1044
- {
1045
- $periodMaxCycles = $recurringProfileId->getPeriodMaxCycles();
1046
- $this->endTime = 0;
1047
-
1048
- if ($callbackCycle == $periodMaxCycles) {
1049
- $requestdata = new Varien_Object();
1050
- $order = $this->getOrderByIncrementId($this->orderNo);
1051
- $payment = $order->getPayment();
1052
- $paymentObj = $payment->getMethodInstance();
1053
- $helper = $this->_getNovalnetHelper();
1054
- $orderItems = $order->getAllItems();
1055
- $nominalItem = $helper->checkNominalItem($orderItems);
1056
- $storeId = $helper->getMagentoStoreId();
1057
- $paymentObj->assignOrderBasicParams($requestdata, $payment, $storeId, $nominalItem);
1058
- $requestdata->setNnLang(strtoupper($helper->getDefaultLanguage()))
1059
- ->setCancelSub(1)
1060
- ->setCancelReason('other')
1061
- ->setTid($request['signup_tid']);
1062
- $buildNovalnetParam = http_build_query($requestdata->getData());
1063
- $recurringCancelUrl = $helper->getPayportUrl('paygate');
1064
- $dataHelper = Mage::helper('novalnet_payment/AssignData');
1065
- $response = $dataHelper->setRawCallRequest($buildNovalnetParam, $recurringCancelUrl, $payment);
1066
- $orderNo = $this->getOrderIdByTransId();
1067
- // load parent order
1068
- $parentOrder = $this->getOrderByIncrementId($orderNo);
1069
- $parentPayment = $parentOrder->getPayment();
1070
- $data = unserialize($parentPayment->getAdditionalData());
1071
- $data['subsCancelReason'] = 'other';
1072
- $parentPayment->setAdditionalData(serialize($data))->save();
1073
- $paymentObj->logNovalnetTransactionData($requestdata, $response, $request['signup_tid'], NULL, $storeId, $orderNo);
1074
- if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
1075
- $recurringProfileId->setState('canceled');
1076
- $recurringProfileId->save();
1077
- $this->endTime = 1;
1078
- } else {
1079
- $this->endTime = 0;
1080
- }
1081
- }
1082
- }
1083
-
1084
- /**
1085
- * validate the payment type.
1086
- *
1087
- * @param varien_object $order
1088
- * @return boolean
1089
- */
1090
- private function paymentTypeValidation($order)
1091
- {
1092
- $orderPaymentName = strtolower($this->getPaymentMethod($order));
1093
- $paymentType = $this->allowedPayment[$orderPaymentName];
1094
- if (!in_array($this->request['payment_type'], $paymentType)) {
1095
- $this->showDebug("Novalnet callback received. Payment type (" . $this->request['payment_type'] . ") is not matched with $orderPaymentName!");
1096
- }
1097
-
1098
- return true;
1099
- }
1100
-
1101
- /**
1102
- * Get Recurring total.
1103
- *
1104
- * @param varien_object $request
1105
- * @param varien_object $order
1106
- * @param mixed $nominalItem
1107
- * @return float
1108
- */
1109
- private function getRecurringTotal($request, $order, $nominalItem)
1110
- {
1111
- if ($this->recurring || $nominalItem) {
1112
- $profileInfo = $this->getProfileInformation($request);
1113
- $billingAmount = $profileInfo->getBillingAmount();
1114
- }
1115
-
1116
- $changeAmount = $this->_getNovalnetHelper()->getAmountCollection($order->getId(), 1, NULL);
1117
- if ($changeAmount) {
1118
- $amountvalue = $changeAmount;
1119
- } elseif (($this->recurring || $nominalItem) && ($billingAmount)) {
1120
- $amountvalue = round(($billingAmount + $profileInfo->getShippingAmount()
1121
- + $profileInfo->getTaxAmount()), 2);
1122
- } else {
1123
- $amountvalue = $order->getGrandTotal();
1124
- }
1125
-
1126
- return $amountvalue;
1127
- }
1128
-
1129
- /**
1130
- * Save the additional data.
1131
- *
1132
- * @param varien_object $payment
1133
- * @param array $data
1134
- * @param string $script
1135
- * @param varien_object $order
1136
- */
1137
- private function saveAdditionalInfo($payment, $data, $script, $order)
1138
- {
1139
- $data['NnComments'] = empty($data['NnComments']) ? '<br>' . $script : $data['NnComments'] . '<br>' . $script;
1140
- if ($payment && $data) {
1141
- $payment->setAdditionalData(serialize($data));
1142
- $order->setPayment($payment)
1143
- ->save();
1144
- }
1145
- }
1146
-
1147
- /**
1148
- * Get email config
1149
- *
1150
- * @param int $storeId
1151
- */
1152
- private function getEmailConfig($storeId = NULL)
1153
- {
1154
- $this->emailFromAddr = Mage::getStoreConfig('trans_email/ident_general/email', $storeId);
1155
- $this->emailToAddr = Mage::getStoreConfig('novalnet_global/novalnetsetting/emailtoaddr', $storeId);
1156
- $this->emailBCcAddr = Mage::getStoreConfig('novalnet_global/novalnetsetting/emailBcc', $storeId);
1157
- $this->emailSubject = 'Novalnet Callback Script Access Report';
1158
- $this->emailBody = "";
1159
- $this->emailFromName = Mage::getStoreConfig('trans_email/ident_general/name', $storeId);
1160
- $this->emailToName = "";
1161
- $this->callBackExecuted = false;
1162
- }
1163
-
1164
- /*
1165
- * Get given payment_type level for process
1166
- *
1167
- * @return Integer | boolean
1168
- */
1169
-
1170
- private function getPaymentTypeLevel()
1171
- {
1172
- if (!empty($this->request)) {
1173
- if (in_array($this->request['payment_type'], $this->paymentTypes)) {
1174
- return 0;
1175
- } else if (in_array($this->request['payment_type'], $this->chargebacks)) {
1176
- return 1;
1177
- } else if (in_array($this->request['payment_type'], $this->aryCollection)) {
1178
- return 2;
1179
- }
1180
- }
1181
- return false;
1182
- }
1183
-
1184
- /**
1185
- * get order id based on last transaction id.
1186
- *
1187
- * @return int
1188
- */
1189
- private function getOrderIdByTransId()
1190
- {
1191
- $request = $this->request;
1192
- $orgTid = $this->requestTid($request);
1193
-
1194
- if(empty($orgTid)) { // Check whether the original/parent transaction id exists
1195
- return false;
1196
- }
1197
-
1198
- $tablePrefix = Mage::getConfig()->getTablePrefix();
1199
- if (in_array($request['payment_type'], $this->chargebacks)) {
1200
- $orderPayment = $tablePrefix . 'sales_payment_transaction';
1201
- $onCondition = "main_table.entity_id = $orderPayment.order_id";
1202
- $orderCollection = Mage::getModel('sales/order')->getCollection()
1203
- ->addFieldToFilter('txn_id', array('like' => "%$orgTid%"))
1204
- ->addFieldToSelect('increment_id');
1205
- } else {
1206
- $orderPayment = $tablePrefix . 'sales_flat_order_payment';
1207
- $onCondition = "main_table.entity_id = $orderPayment.parent_id";
1208
- $orderCollection = Mage::getModel('sales/order')->getCollection()
1209
- ->addFieldToFilter('last_trans_id', array('like' => "%$orgTid%"))
1210
- ->addFieldToSelect('increment_id');
1211
- }
1212
-
1213
- $orderCollection->getSelect()->join($orderPayment, $onCondition);
1214
- $count = $orderCollection->count();
1215
- if ($count > 0) {
1216
- foreach ($orderCollection as $order) {
1217
- $orderid = $order->getIncrementId();
1218
- }
1219
- }
1220
-
1221
- $orderId = !empty($orderid) ? $orderid : '';
1222
- return $orderId;
1223
- }
1224
-
1225
- /**
1226
- * Get transaction id based on payment type
1227
- *
1228
- * @param array $request
1229
- * @return int $tidPayment
1230
- */
1231
- private function requestTid($request)
1232
- {
1233
- if (isset($request['signup_tid']) && $request['signup_tid']) {
1234
- $tidPayment = trim($request['signup_tid']);
1235
- } elseif ((in_array($this->request['payment_type'], $this->chargebacks)) || ($this->request['payment_type'] == 'INVOICE_CREDIT')) {
1236
- $tidPayment = trim($request['tid_payment']);
1237
- } else {
1238
- $tidPayment = trim($request['tid']);
1239
- }
1240
-
1241
- return $tidPayment;
1242
- }
1243
-
1244
- /**
1245
- * New order create process
1246
- *
1247
- * @param varien_object $order
1248
- * @param string $script
1249
- * @param array $data
1250
- * @param varien_object $paymentold
1251
- * @param int $profileId
1252
- */
1253
- private function createOrder($order, $script, $data, $paymentold, $profileId)
1254
- {
1255
- $helper = $this->_getNovalnetHelper();
1256
- $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
1257
- $additionalInfo = $order->getPayment()->getAdditionalInformation();
1258
- $storeId = $order->getStoreId();
1259
- $this->setLanguageStore($storeId);
1260
- $orderNew = Mage::getModel('sales/order')
1261
- ->setState('new');
1262
-
1263
- $orderPayment = Mage::getModel('sales/order_payment')
1264
- ->setStoreId($storeId)
1265
- ->setMethod($paymentCode)
1266
- ->setPo_number('-');
1267
- $orderNew->setPayment($orderPayment);
1268
- $orderNew = $this->setOrderDetails($order, $orderNew);
1269
- $billingAddress = Mage::getModel('sales/order_address');
1270
- $getBillingAddress = Mage::getModel('sales/order_address')->load($order->getBillingAddress()->getId());
1271
- $orderNew = $this->setBillingShippingAddress($getBillingAddress, $billingAddress, $orderNew, $order);
1272
- $isVirtual = $order->getIsVirtual();
1273
-
1274
- if ($isVirtual == 0) {
1275
- $shippingAddress = Mage::getModel('sales/order_address');
1276
- $getShippingAddress = Mage::getModel('sales/order_address')->load($order->getShippingAddress()->getId());
1277
- $orderNew = $this->setBillingShippingAddress($getShippingAddress, $shippingAddress, $orderNew, $order);
1278
- }
1279
-
1280
- $orderNew = $this->setOrderItemsDetails($order, $orderNew);
1281
- $payment = $orderNew->getPayment();
1282
- $paymentObj = $payment->getMethodInstance();
1283
- $setOrderAfterStatus = ($this->request['tid_status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
1284
- && !in_array($this->request['payment_type'], $this->invoiceAllowed))
1285
- ? $paymentObj->getConfigData('order_status_after_payment', $storeId)
1286
- : $paymentObj->getConfigData('order_status', $storeId);
1287
- $setOrderAfterStatus = $setOrderAfterStatus ? $setOrderAfterStatus : Mage_Sales_Model_Order::STATE_PROCESSING;
1288
- $orderNew->addStatusToHistory($setOrderAfterStatus, $helper->__('Novalnet Recurring Callback script Executed Successfully'), false);
1289
- $tid = trim($this->request['tid']);
1290
- $orderNew->save();
1291
- $newOrderId = $orderNew->getId();
1292
- $parentOrderNo = $this->getOrderIdByTransId() ? $this->getOrderIdByTransId() : $orderNew->getIncrementId();
1293
- $script .= $comments = ' Reference Order No : ' . $parentOrderNo . '<br>';
1294
- $next_charging_date = isset($this->request['next_subs_cycle']) ? $this->request['next_subs_cycle'] : $this->request['paid_until'] ;
1295
- $script .= $nextDate = !$this->endTime ? '<br>Next charging date is: ' . $next_charging_date . '<br>' : '';
1296
- $this->emailBody = $script;
1297
-
1298
- $newData = array('NnTestOrder' => $this->request['test_mode'],
1299
- 'NnTid' => $tid,
1300
- 'orderNo' => $orderNew->getIncrementId(),
1301
- 'vendor' => $data['vendor'],
1302
- 'auth_code' => $data['auth_code'],
1303
- 'product' => $data['product'],
1304
- 'tariff' => $data['tariff'],
1305
- 'key' => $data['key'],
1306
- 'NnComments' => ($comments . $nextDate)
1307
- );
1308
-
1309
- if ($paymentCode == 'novalnetPrepayment' || $paymentCode == 'novalnetInvoice') {
1310
- $dataObj = new Varien_Object($this->request);
1311
- $dataHelper = Mage::helper('novalnet_payment/AssignData');
1312
- $newData['NnNoteDesc'] = $dataHelper->getNoteDescription();
1313
- $newData['NnRecurringOrder'] = 1;
1314
- $newData['NnDueDate'] = isset($this->request['due_date']) ? ($helper->__('Due Date') . ' : <b><span id="due_date">' . Mage::helper('core')->formatDate($this->request['due_date']) . "</span></b><br />") : '';
1315
- $newData['NnNote'] = $dataHelper->getNote($dataObj);
1316
- $newData['NnNoteAmount'] = $dataHelper->getBankDetailsAmount(($this->request['amount'] / 100));
1317
- }
1318
-
1319
- $payment->setTransactionId($tid)
1320
- ->setAdditionalData(serialize($newData))
1321
- ->setAdditionalInformation($additionalInfo)
1322
- ->setLastTransId($tid)
1323
- ->setParentTransactionId(null)
1324
- ->save();
1325
- $orderNew->sendNewOrderEmail()
1326
- ->setEmailSent(true)
1327
- ->setPayment($payment)
1328
- ->save();
1329
- $this->insertOrderId($newOrderId, $profileId);
1330
- $this->_logStatusData($tid, $orderNew, $paymentCode);
1331
- if ($orderNew->canInvoice() && $this->request['status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED && $paymentCode != Novalnet_Payment_Model_Config::NN_PREPAYMENT && $this->request['tid_status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
1332
- $invoice = $orderNew->prepareInvoice();
1333
- $invoice->setTransactionId($tid);
1334
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE)
1335
- ->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID)
1336
- ->register();
1337
-
1338
- Mage::getModel('core/resource_transaction')
1339
- ->addObject($invoice)
1340
- ->addObject($invoice->getOrder())
1341
- ->save();
1342
-
1343
- $magentoVersion = $this->_getNovalnetHelper()->getMagentoVersion();
1344
- $transMode = (version_compare($magentoVersion, '1.6', '<')) ? false : true;
1345
-
1346
- $payment->setTransactionId($tid)
1347
- ->setIsTransactionClosed($transMode);
1348
- }
1349
-
1350
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false);
1351
- $transaction->setParentTxnId(null)
1352
- ->save();
1353
- $this->updateInventory($order);
1354
- }
1355
-
1356
- /**
1357
- * Log Novalnet transaction status data
1358
- *
1359
- * @param varien_object $response
1360
- * @param int $txnId
1361
- * @param varien_object $order
1362
- * @param string $paymentCode
1363
- * @return null
1364
- */
1365
- private function _logStatusData($txnId, $order, $paymentCode)
1366
- {
1367
- $helper = $this->_getNovalnetHelper();
1368
- $customerId = $order->getCustomerId() ? $order->getCustomerId() : '';
1369
- $storeId = $order->getStoreId() ? $order->getStoreId() : '';
1370
- $amount = $this->request['amount'] ? ($this->request['amount'] / 100) : '';
1371
- $modNovalTransactionStatus = $helper->getModelTransactionStatus();
1372
- $modNovalTransactionStatus->setTransactionNo($txnId)
1373
- ->setOrderId($order->getIncrementId()) // Order number
1374
- ->setTransactionStatus($this->request['tid_status']) // Transaction status code
1375
- ->setCustomerId($customerId) // Customer number
1376
- ->setPaymentName($paymentCode) // Payment name
1377
- ->setAmount($amount) // Amount
1378
- ->setRemoteIp($helper->getRealIpAddr()) // Remote ip
1379
- ->setStoreId($storeId) // Store id
1380
- ->setShopUrl($helper->getCurrentSiteUrl())
1381
- ->setCreatedDate($helper->getCurrentDateTime()) // Created date
1382
- ->save();
1383
- }
1384
-
1385
- /**
1386
- * Set billing and sipping address informations
1387
- *
1388
- * @param varien_object $getBillingAddress
1389
- * @param varien_object $billingAddress
1390
- * @param varien_object $orderNew
1391
- * @param varien_object $order
1392
- * @return mixed
1393
- */
1394
- private function setBillingShippingAddress($getBillingAddress, $billingAddress, $orderNew, $order)
1395
- {
1396
- $addressType = $getBillingAddress->getAddressType();
1397
- $billingStreet = $getBillingAddress->getStreet();
1398
- $street = !empty($billingStreet[1]) ? array($billingStreet[0], $billingStreet[1]) : array($billingStreet[0]);
1399
- $billingAddress->setStoreId($order->getStoreId())
1400
- ->setAddressType($addressType)
1401
- ->setPrefix($getBillingAddress->getPrefix())
1402
- ->setFirstname($getBillingAddress->getFirstname())
1403
- ->setLastname($getBillingAddress->getLastname())
1404
- ->setMiddlename($getBillingAddress->getMiddlename())
1405
- ->setSuffix($getBillingAddress->getSuffix())
1406
- ->setCompany($getBillingAddress->getCompany())
1407
- ->setStreet($street)
1408
- ->setCity($getBillingAddress->getCity())
1409
- ->setCountryId($getBillingAddress->getCountryId())
1410
- ->setRegionId($getBillingAddress->getRegionId())
1411
- ->setTelephone($getBillingAddress->getTelephone())
1412
- ->setFax($getBillingAddress->getFax())
1413
- ->setVatId($getBillingAddress->getVatId())
1414
- ->setPostcode($getBillingAddress->getPostcode());
1415
-
1416
- if ($addressType == Mage_Sales_Model_Quote_Address::TYPE_BILLING) {
1417
- $orderNew->setBillingAddress($billingAddress);
1418
- } else {
1419
- $shippingMethod = $order->getShippingMethod();
1420
- $shippingDescription = $order->getShippingDescription();
1421
- $orderNew->setShippingAddress($billingAddress)
1422
- ->setShippingMethod($shippingMethod)
1423
- ->setShippingDescription($shippingDescription);
1424
- }
1425
-
1426
- return $orderNew;
1427
- }
1428
-
1429
- /**
1430
- * Set order amount and customer informations
1431
- *
1432
- * @param varien_object $order
1433
- * @param varien_object $orderNew
1434
- * @return mixed
1435
- */
1436
- private function setOrderDetails($order, $orderNew)
1437
- {
1438
- $orderNew->setStoreId($order->getStoreId())
1439
- ->setCustomerGroupId($order->getCustomerGroupId())
1440
- ->setQuoteId(0)
1441
- ->setIsVirtual($order->getIsVirtual())
1442
- ->setGlobalCurrencyCode($order->getGlobalCurrencyCode())
1443
- ->setBaseCurrencyCode($order->getBaseCurrencyCode())
1444
- ->setStoreCurrencyCode($order->getStoreCurrencyCode())
1445
- ->setOrderCurrencyCode($order->getOrderCurrencyCode())
1446
- ->setStoreName($order->getStoreName())
1447
- ->setCustomerEmail($order->getCustomerEmail())
1448
- ->setCustomerFirstname($order->getCustomerFirstname())
1449
- ->setCustomerLastname($order->getCustomerLastname())
1450
- ->setCustomerId($order->getCustomerId())
1451
- ->setCustomerIsGuest($order->getCustomerIsGuest())
1452
- ->setState('processing')
1453
- ->setStatus($order->getStatus())
1454
- ->setSubtotal($order->getSubtotal())
1455
- ->setBaseSubtotal($order->getBaseSubtotal())
1456
- ->setSubtotalInclTax($order->getSubtotalInclTax())
1457
- ->setBaseSubtotalInclTax($order->getBaseSubtotalInclTax())
1458
- ->setShippingAmount($order->getShippingAmount())
1459
- ->setBaseShippingAmount($order->getBaseShippingAmount())
1460
- ->setGrandTotal($order->getGrandTotal())
1461
- ->setBaseGrandTotal($order->getBaseGrandTotal())
1462
- ->setTaxAmount($order->getTaxAmount())
1463
- ->setTotalQtyOrdered($order->getTotalQtyOrdered())
1464
- ->setBaseTaxAmount($order->getBaseTaxAmount())
1465
- ->setBaseToGlobalRate($order->getBaseToGlobalRate())
1466
- ->setBaseToOrderRate($order->getBaseToOrderRate())
1467
- ->setStoreToBaseRate($order->getStoreToBaseRate())
1468
- ->setStoreToOrderRate($order->getStoreToOrderRate())
1469
- ->setWeight($order->getWeight())
1470
- ->setCustomerNoteNotify($order->getCustomerNoteNotify());
1471
- return $orderNew;
1472
- }
1473
-
1474
- /**
1475
- * Set product informations (product, discount, tax, etc.,)
1476
- *
1477
- * @param varien_object $order
1478
- * @param varien_object $orderNew
1479
- * @return mixed
1480
- */
1481
- private function setOrderItemsDetails($order, $orderNew)
1482
- {
1483
- foreach ($order->getAllItems() as $orderValue) {
1484
- $orderItem = Mage::getModel('sales/order_item')
1485
- ->setStoreId($orderValue->getStoreId())
1486
- ->setQuoteItemId(0)
1487
- ->setQuoteParentItemId(NULL)
1488
- ->setQtyBackordered(NULL)
1489
- ->setQtyOrdered($orderValue->getQtyOrdered())
1490
- ->setName($orderValue->getName())
1491
- ->setIsVirtual($orderValue->getIsVirtual())
1492
- ->setProductId($orderValue->getProductId())
1493
- ->setProductType($orderValue->getProductType())
1494
- ->setSku($orderValue->getSku())
1495
- ->setWeight($orderValue->getWeight())
1496
- ->setPrice($orderValue->getPrice())
1497
- ->setBasePrice($orderValue->getBasePrice())
1498
- ->setOriginalPrice($orderValue->getOriginalPrice())
1499
- ->setTaxAmount($orderValue->getTaxAmount())
1500
- ->setTaxPercent($orderValue->getTaxPercent())
1501
- ->setIsNominal($orderValue->getIsNominal())
1502
- ->setRowTotal($orderValue->getRowTotal())
1503
- ->setBaseRowTotal($orderValue->getBaseRowTotal())
1504
- ->setBaseWeeeTaxAppliedAmount($orderValue->getBaseWeeeTaxAppliedAmount())
1505
- ->setWeeeTaxAppliedAmount($orderValue->getWeeeTaxAppliedAmount())
1506
- ->setWeeeTaxAppliedRowAmount($orderValue->getWeeeTaxAppliedRowAmount())
1507
- ->setWeeeTaxApplied($orderValue->getWeeeTaxApplied())
1508
- ->setWeeeTaxDisposition($orderValue->getWeeeTaxDisposition())
1509
- ->setWeeeTaxRowDisposition($orderValue->getWeeeTaxRowDisposition())
1510
- ->setBaseWeeeTaxDisposition($orderValue->getBaseWeeeTaxDisposition())
1511
- ->setBaseWeeeTaxRowDisposition($orderValue->getBaseWeeeTaxRowDisposition());
1512
- $orderNew->addItem($orderItem);
1513
- }
1514
-
1515
- return $orderNew;
1516
- }
1517
-
1518
- /**
1519
- * Set the language by storeid
1520
- *
1521
- * @param int $storeId
1522
- */
1523
- private function setLanguageStore($storeId)
1524
- {
1525
- $app = Mage::app();
1526
- $app->setCurrentStore($storeId);
1527
- $locale = Mage::getStoreConfig('general/locale/code', $storeId);
1528
- $app->getLocale()->setLocaleCode($locale);
1529
- Mage::getSingleton('core/translate')->setLocale($locale)->init('frontend', true);
1530
- }
1531
-
1532
- /**
1533
- * Insert the order id in recurring order table
1534
- *
1535
- * @param int $newOrderId
1536
- * @param int $profileId
1537
- */
1538
- private function insertOrderId($newOrderId, $profileId)
1539
- {
1540
- if ($newOrderId && $profileId) {
1541
- $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
1542
- $connection->beginTransaction();
1543
- $tablePrefix = Mage::getConfig()->getTablePrefix();
1544
- $orderTable = $tablePrefix . 'sales_recurring_profile_order';
1545
- $fields = array();
1546
- $fields['profile_id'] = $profileId;
1547
- $fields['order_id'] = $newOrderId;
1548
- $connection->insert($orderTable, $fields);
1549
- $connection->commit();
1550
- }
1551
- }
1552
-
1553
- /**
1554
- * update the product inventory (stock)
1555
- *
1556
- * @param varien_object $order
1557
- */
1558
- private function updateInventory($order)
1559
- {
1560
- foreach ($order->getAllItems() as $orderValue) {
1561
- $itemsQtyOrdered = floor($orderValue->getQtyOrdered());
1562
- $productId = $orderValue->getProductId();
1563
- break;
1564
- }
1565
-
1566
- if ($productId) {
1567
- $stockObj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
1568
- $productQtyBefore = (int) $stockObj->getQty();
1569
- }
1570
-
1571
- if (isset($productQtyBefore) && $productQtyBefore > 0) {
1572
- $productQtyAfter = (int) ($productQtyBefore - $itemsQtyOrdered);
1573
- $stockObj->setQty($productQtyAfter);
1574
- $stockObj->save();
1575
- }
1576
- }
1577
-
1578
- /**
1579
- * Show debug message
1580
- *
1581
- * @param string $text
1582
- * @param bool $die
1583
- */
1584
- public function showDebug($text, $die = true) {
1585
- if ($this->debug == true && !empty($text)) {
1586
- echo $text;
1587
- }
1588
- if ($die) {
1589
- die;
1590
- }
1591
- }
1592
-
1593
- /**
1594
- * Register recurring profile data
1595
- *
1596
- * @param varien_object $payment
1597
- * @param string $status
1598
- */
1599
- public function callbackRegisterRecurring($payment, $status = NULL)
1600
- {
1601
- $response = $this->request;
1602
- $additionalData = unserialize($payment->getAdditionalData());
1603
- $profileId = (!empty($response['profile_id']) ? $response['profile_id']
1604
- : ((!empty($response['input5']) && $response['input5'] == 'profile_id') ? $response['inputval5'] : ''));
1605
- if($profileId) {
1606
- $profile = Mage::getModel('sales/recurring_profile')
1607
- ->load($profileId, 'profile_id');
1608
- if ($status == 'Success') {
1609
- $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
1610
- $data['paidUntil'] = !empty($response['next_subs_cycle']) ? $response['next_subs_cycle'] : $response['paid_until'];
1611
- $data = $additionalData ? array_merge($additionalData, $data) : $data;
1612
- $payment->setPreparedMessage($response['status'])
1613
- ->setAdditionalInformation('subs_id', $response['subs_id'])
1614
- ->setAdditionalData(serialize($data))
1615
- ->save();
1616
- } else {
1617
- $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
1618
- }
1619
- $profile->setReferenceId($response['tid'])
1620
- ->save();
1621
- }
1622
- }
1623
-
1624
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Config.php CHANGED
@@ -18,162 +18,161 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Model_Config
27
  {
28
- /* ******************************************** */
29
- /* NOVALNET GLOBAL PARAMS STARTS */
30
- /* ******************************************* */
31
- const RESPONSE_CODE_APPROVED = 100; //On Payment Success
32
- const PAYMENT_VOID_STATUS = 103; //On Payment void
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  const NOVALNET_RETURN_METHOD = 'POST';
34
- const NOVALNET_REDIRECT_BLOCK = 'novalnet_payment/payment_method_novalnetRedirect';
35
  const GATEWAY_REDIRECT_URL = 'novalnet_payment/gateway/redirect';
36
  const GATEWAY_DIRECT_URL = 'novalnet_payment/gateway/payment';
37
  const GATEWAY_RETURN_URL = 'novalnet_payment/gateway/return';
38
  const GATEWAY_ERROR_RETURN_URL = 'novalnet_payment/gateway/error';
39
  const CC_IFRAME_URL = 'novalnet_payment/cc/index';
 
40
  const CC_PCI_PAYPORT_URL = 'https://payport.novalnet.de/pci_payport';
41
- const PAYPORT_URL = 'https://payport.novalnet.de/paygate.jsp';
42
- const INFO_REQUEST_URL = 'https://payport.novalnet.de/nn_infoport.xml';
43
- const INVOICE_PAYMENT_METHOD = 'Invoice';
44
- const PREPAYMENT_PAYMENT_METHOD = 'Prepayment';
45
- const TRANS_STATUS = 'TRANSACTION_STATUS';
46
  const SUBS_PAUSE = 'SUBSCRIPTION_PAUSE';
47
- const TRANSMIT_PIN_AGAIN = 'TRANSMIT_PIN_AGAIN';
48
- const PIN_STATUS = 'PIN_STATUS';
49
- const METHOD_DISABLE_CODE = '0529006';
50
- const PAYPAL_PENDING_CODE = 90;
51
- const POST_NORMAL = 'normal';
52
- const POST_CALLBACK = 'callback';
53
-
54
- static protected $_instance;
55
- protected $_novalnetPaymentKey = array('novalnetCc' => 6, 'novalnetInvoice' => 27,
56
- 'novalnetPrepayment' => 27, 'novalnetPaypal' => 34, 'novalnetBanktransfer' => 33,
57
- 'novalnetIdeal' => 49, 'novalnetEps' => 50, 'novalnetSepa' => 37, 'novalnetGiropay' => 69);
58
- protected $_novalnetPaymentMethods = array('novalnetCc' => 'Novalnet Credit Card', 'novalnetInvoice' => 'Novalnet Invoice',
59
- 'novalnetPrepayment' => 'Novalnet Prepayment',
60
- 'novalnetPaypal' => 'Novalnet PayPal', 'novalnetBanktransfer' => 'Novalnet Instant Bank Transfer',
61
- 'novalnetIdeal' => 'Novalnet iDEAL', 'novalnetEps' => 'Novalnet Eps', 'novalnetSepa' => 'Novalnet Direct Debit SEPA',
62
- 'novalnetGiropay' => 'Novalnet Giropay');
63
- protected $_novalnetPaymentTypes = array('novalnetCc' => 'CREDITCARD', 'novalnetInvoice' => 'INVOICE',
64
- 'novalnetPrepayment' => 'PREPAYMENT', 'novalnetPaypal' => 'PAYPAL', 'novalnetBanktransfer' => 'ONLINE_TRANSFER',
65
- 'novalnetIdeal' => 'IDEAL', 'novalnetEps' => 'EPS', 'novalnetSepa' => 'DIRECT_DEBIT_SEPA', 'novalnetGiropay' => 'GIROPAY');
66
- protected $_redirectPayportUrl = array('novalnetPaypal' => 'https://payport.novalnet.de/paypal_payport',
67
- 'novalnetBanktransfer' => 'https://payport.novalnet.de/online_transfer_payport',
68
- 'novalnetIdeal' => 'https://payport.novalnet.de/online_transfer_payport',
69
- 'novalnetEps' => 'https://payport.novalnet.de/giropay',
70
- 'novalnetGiropay' => 'https://payport.novalnet.de/giropay');
71
- protected $_redirectPayments = array('novalnetPaypal', 'novalnetBanktransfer',
72
- 'novalnetIdeal', 'novalnetEps', 'novalnetGiropay');
73
- protected $_subscriptionPayments = array('novalnetSepa',
74
- 'novalnetPrepayment', 'novalnetInvoice');
75
- protected $_setonholdPayments = array('novalnetCc', 'novalnetSepa', 'novalnetInvoice');
76
- protected $_callbackAllowedCountry = array('AT', 'DE', 'CH');
77
- protected $_paymentOnholdStaus = array('91', '98', '99');
78
- protected $_pciHashParams = array('vendor_authcode', 'product_id', 'tariff_id', 'amount',
79
- 'test_mode', 'uniqid');
80
- protected $_novalnetHashParams = array('auth_code', 'product', 'tariff', 'amount',
81
- 'test_mode', 'uniqid');
82
- protected $_fraudCheckPayment = array('novalnetInvoice', 'novalnetSepa');
83
- protected $_subscriptionRedirectPayments = array('novalnetCc', 'novalnetPaypal');
84
 
85
- /* ******************************************** */
86
- /* NOVALNET CC PARAMS */
87
- /* ******************************************* */
88
 
89
  const NN_CC = 'novalnetCc';
90
- const NN_CC_CAN_CAPTURE = true;
91
- const NN_CC_CAN_USE_MULTISHIPPING = false;
92
  const NN_CC_CAN_USE_INTERNAL = false;
93
- const NN_CC_FORM_BLOCK = 'novalnet_payment/payment_method_form_Cc';
94
- const NN_CC_INFO_BLOCK = 'novalnet_payment/payment_method_info_Cc';
 
 
 
 
 
95
 
96
- /* ******************************************** */
97
- /* NOVALNET SEPA PARAMS */
98
- /* ******************************************* */
99
  const NN_SEPA = 'novalnetSepa';
100
- const NN_SEPA_CAN_CAPTURE = true;
101
- const NN_SEPA_CAN_USE_INTERNAL = true;
102
  const NN_SEPA_CAN_USE_MULTISHIPPING = false;
103
- const NN_SEPA_FORM_BLOCK = 'novalnet_payment/payment_method_form_Sepa';
104
- const NN_SEPA_INFO_BLOCK = 'novalnet_payment/payment_method_info_Sepa';
105
 
 
 
 
106
 
107
- /* ******************************************** */
108
- /* NOVALNET INVOICE PARAMS */
109
- /* ******************************************* */
110
  const NN_INVOICE = 'novalnetInvoice';
111
- const NN_INVOICE_CAN_CAPTURE = true;
112
  const NN_INVOICE_CAN_USE_MULTISHIPPING = false;
113
- const NN_INVOICE_FORM_BLOCK = 'novalnet_payment/payment_method_form_Invoice';
114
- const NN_INVOICE_INFO_BLOCK = 'novalnet_payment/payment_method_info_Invoice';
 
 
 
 
115
 
116
- /* ******************************************** */
117
- /* NOVALNET PREPAYMENT PARAMS */
118
- /* ******************************************* */
119
  const NN_PREPAYMENT = 'novalnetPrepayment';
120
- const NN_PREPAYMENT_CAN_CAPTURE = true;
121
  const NN_PREPAYMENT_CAN_USE_MULTISHIPPING = false;
122
- const NN_PREPAYMENT_FORM_BLOCK = 'novalnet_payment/payment_method_form_Prepayment';
123
- const NN_PREPAYMENT_INFO_BLOCK = 'novalnet_payment/payment_method_info_Prepayment';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
- /* ******************************************** */
126
- /* NOVALNET IDEAL PARAMS */
127
- /* ******************************************* */
128
  const NN_IDEAL = 'novalnetIdeal';
129
- const NN_IDEAL_CAN_CAPTURE = true;
130
  const NN_IDEAL_CAN_USE_INTERNAL = false;
131
  const NN_IDEAL_CAN_USE_MULTISHIPPING = false;
132
- const NN_IDEAL_FORM_BLOCK = 'novalnet_payment/payment_method_form_Ideal';
133
- const NN_IDEAL_INFO_BLOCK = 'novalnet_payment/payment_method_info_Ideal';
134
- /* ******************************************** */
135
- /* NOVALNET EPS PARAMS */
136
- /* ******************************************* */
 
 
137
  const NN_EPS = 'novalnetEps';
138
- const NN_EPS_CAN_CAPTURE = true;
139
  const NN_EPS_CAN_USE_INTERNAL = false;
140
  const NN_EPS_CAN_USE_MULTISHIPPING = false;
141
- const NN_EPS_FORM_BLOCK = 'novalnet_payment/payment_method_form_Eps';
142
- const NN_EPS_INFO_BLOCK = 'novalnet_payment/payment_method_info_Eps';
 
 
 
 
143
 
144
- /* ******************************************** */
145
- /* NOVALNET GIROPAY PARAMS */
146
- /* ******************************************* */
147
  const NN_GIROPAY = 'novalnetGiropay';
148
- const NN_GIROPAY_CAN_CAPTURE = true;
149
  const NN_GIROPAY_CAN_USE_INTERNAL = false;
150
  const NN_GIROPAY_CAN_USE_MULTISHIPPING = false;
151
- const NN_GIROPAY_FORM_BLOCK = 'novalnet_payment/payment_method_form_Giropay';
152
- const NN_GIROPAY_INFO_BLOCK = 'novalnet_payment/payment_method_info_Giropay';
153
 
154
- /* ******************************************** */
155
- /* NOVALNET PAYPAL PARAMS */
156
- /* ******************************************* */
157
- const NN_PAYPAL = 'novalnetPaypal';
158
- const NN_PAYPAL_CAN_CAPTURE = true;
159
- const NN_PAYPAL_CAN_USE_INTERNAL = false;
160
- const NN_PAYPAL_CAN_USE_MULTISHIPPING = false;
161
- const NN_PAYPAL_FORM_BLOCK = 'novalnet_payment/payment_method_form_Paypal';
162
- const NN_PAYPAL_INFO_BLOCK = 'novalnet_payment/payment_method_info_Paypal';
163
-
164
- /* ******************************************** */
165
- /* NOVALNET SOFORT PARAMS */
166
- /* ******************************************* */
167
- const NN_SOFORT = 'novalnetBanktransfer';
168
- const NN_SOFORT_CAN_CAPTURE = true;
169
- const NN_SOFORT_CAN_USE_INTERNAL = false;
170
- const NN_SOFORT_CAN_USE_MULTISHIPPING = false;
171
- const NN_SOFORT_FORM_BLOCK = 'novalnet_payment/payment_method_form_Banktransfer';
172
- const NN_SOFORT_INFO_BLOCK = 'novalnet_payment/payment_method_info_Banktransfer';
173
-
174
- /* ******************************************** */
175
- /* NOVALNET ABSTRACT FUNCTIONS */
176
- /* ******************************************* */
177
 
178
  static public function getInstance()
179
  {
@@ -187,4 +186,5 @@ class Novalnet_Payment_Model_Config
187
  {
188
  return $this->{'_' . $key};
189
  }
 
190
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Model_Config
27
  {
28
+
29
+ /**********************************************/
30
+ /* NOVALNET GLOBAL PARAMS */
31
+ /*********************************************/
32
+
33
+ static protected $_instance;
34
+ protected $_paymentKey = array('novalnetCc' => 6, 'novalnetSepa' => 37, 'novalnetInvoice' => 27,
35
+ 'novalnetPrepayment' => 27, 'novalnetPaypal' => 34, 'novalnetBanktransfer' => 33,
36
+ 'novalnetIdeal' => 49, 'novalnetEps' => 50, 'novalnetGiropay' => 69);
37
+ protected $_paymentMethods = array('novalnetCc' => 'Novalnet Credit Card',
38
+ 'novalnetSepa' => 'Novalnet Direct Debit SEPA', 'novalnetInvoice' => 'Novalnet Invoice',
39
+ 'novalnetPrepayment' => 'Novalnet Prepayment', 'novalnetPaypal' => 'Novalnet PayPal',
40
+ 'novalnetBanktransfer' => 'Novalnet Instant Bank Transfer', 'novalnetIdeal' => 'Novalnet iDEAL',
41
+ 'novalnetEps' => 'Novalnet eps', 'novalnetGiropay' => 'Novalnet giropay');
42
+ protected $_paymentTypes = array('novalnetCc' => 'CREDITCARD', 'novalnetSepa' => 'DIRECT_DEBIT_SEPA',
43
+ 'novalnetInvoice' => 'INVOICE', 'novalnetPrepayment' => 'PREPAYMENT',
44
+ 'novalnetPaypal' => 'PAYPAL', 'novalnetBanktransfer' => 'ONLINE_TRANSFER',
45
+ 'novalnetIdeal' => 'IDEAL', 'novalnetEps' => 'EPS', 'novalnetGiropay' => 'GIROPAY');
46
+ protected $_redirectPayportUrl = array('novalnetPaypal' => 'paypal_payport',
47
+ 'novalnetBanktransfer' => 'online_transfer_payport', 'novalnetIdeal' => 'online_transfer_payport',
48
+ 'novalnetEps' => 'giropay', 'novalnetGiropay' => 'giropay',
49
+ 'novalnetCc' => 'pci_payport');
50
+ protected $_redirectPayments = array('novalnetPaypal', 'novalnetBanktransfer',
51
+ 'novalnetIdeal', 'novalnetEps', 'novalnetGiropay');
52
+ protected $_recurringPayments = array('novalnetCc', 'novalnetSepa',
53
+ 'novalnetInvoice', 'novalnetPrepayment', 'novalnetPaypal');
54
+ protected $_pciHashParams = array('vendor_authcode', 'product_id', 'tariff_id', 'amount', 'test_mode', 'uniqid');
55
+ protected $_hashParams = array('auth_code', 'product', 'tariff', 'amount', 'test_mode', 'uniqid');
56
+ protected $_fraudCheckPayment = array('novalnetInvoice', 'novalnetSepa');
57
+ protected $_onHoldPayments = array('novalnetCc', 'novalnetSepa', 'novalnetInvoice');
58
+ protected $_allowedCountry = array('AT', 'DE', 'CH');
59
+ protected $_onHoldStaus = array('91', '98', '99');
60
+
61
+ const RESPONSE_CODE_APPROVED = '100';
62
+ const PAYPAL_PENDING_CODE = '90';
63
+ const PAYMENT_VOID_STATUS = '103';
64
+ const METHOD_DISABLE_CODE = '0529006';
65
+ const MAXPIN_DISABLE_CODE = '0529008';
66
+ const PIN_STATUS = 'PIN_STATUS';
67
+ const TRANSMIT_PIN_AGAIN = 'TRANSMIT_PIN_AGAIN';
68
  const NOVALNET_RETURN_METHOD = 'POST';
69
+ const NOVALNET_REDIRECT_BLOCK = 'novalnet_payment/method_redirect';
70
  const GATEWAY_REDIRECT_URL = 'novalnet_payment/gateway/redirect';
71
  const GATEWAY_DIRECT_URL = 'novalnet_payment/gateway/payment';
72
  const GATEWAY_RETURN_URL = 'novalnet_payment/gateway/return';
73
  const GATEWAY_ERROR_RETURN_URL = 'novalnet_payment/gateway/error';
74
  const CC_IFRAME_URL = 'novalnet_payment/cc/index';
75
+ const PAYPORT_URL = 'paygate.jsp';
76
  const CC_PCI_PAYPORT_URL = 'https://payport.novalnet.de/pci_payport';
77
+ const INFO_REQUEST_URL = 'nn_infoport.xml';
 
 
 
 
78
  const SUBS_PAUSE = 'SUBSCRIPTION_PAUSE';
79
+ const PREPAYMENT_PAYMENT_TYPE = 'Prepayment';
80
+ const INVOICE_PAYMENT_TYPE = 'Invoice';
81
+ const INVOICE_PAYMENT_GUARANTEE_TYPE = 'GUARANTEED_INVOICE_START';
82
+ const INVOICE_PAYMENT_GUARANTEE_KEY = '41';
83
+ const SEPA_PAYMENT_GUARANTEE_TYPE = 'GUARANTEED_DIRECT_DEBIT_SEPA';
84
+ const SEPA_PAYMENT_GUARANTEE_KEY = '40';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
+ /**********************************************/
87
+ /* NOVALNET CREDIT CARD PARAMS */
88
+ /*********************************************/
89
 
90
  const NN_CC = 'novalnetCc';
 
 
91
  const NN_CC_CAN_USE_INTERNAL = false;
92
+ const NN_CC_CAN_USE_MULTISHIPPING = false;
93
+ const NN_CC_FORM_BLOCK = 'novalnet_payment/method_form_Cc';
94
+ const NN_CC_INFO_BLOCK = 'novalnet_payment/method_info_Cc';
95
+
96
+ /**********************************************/
97
+ /* NOVALNET DIRECT DEBIT SEPA PARAMS */
98
+ /*********************************************/
99
 
 
 
 
100
  const NN_SEPA = 'novalnetSepa';
 
 
101
  const NN_SEPA_CAN_USE_MULTISHIPPING = false;
102
+ const NN_SEPA_FORM_BLOCK = 'novalnet_payment/method_form_Sepa';
103
+ const NN_SEPA_INFO_BLOCK = 'novalnet_payment/method_info_Sepa';
104
 
105
+ /**********************************************/
106
+ /* NOVALNET INVOICE PARAMS */
107
+ /*********************************************/
108
 
 
 
 
109
  const NN_INVOICE = 'novalnetInvoice';
 
110
  const NN_INVOICE_CAN_USE_MULTISHIPPING = false;
111
+ const NN_INVOICE_FORM_BLOCK = 'novalnet_payment/method_form_Invoice';
112
+ const NN_INVOICE_INFO_BLOCK = 'novalnet_payment/method_info_Invoice';
113
+
114
+ /**********************************************/
115
+ /* NOVALNET PREPAYMENT PARAMS */
116
+ /*********************************************/
117
 
 
 
 
118
  const NN_PREPAYMENT = 'novalnetPrepayment';
 
119
  const NN_PREPAYMENT_CAN_USE_MULTISHIPPING = false;
120
+ const NN_PREPAYMENT_FORM_BLOCK = 'novalnet_payment/method_form_Prepayment';
121
+ const NN_PREPAYMENT_INFO_BLOCK = 'novalnet_payment/method_info_Prepayment';
122
+
123
+ /**********************************************/
124
+ /* NOVALNET PAYPAL PARAMS */
125
+ /*********************************************/
126
+
127
+ const NN_PAYPAL = 'novalnetPaypal';
128
+ const NN_PAYPAL_CAN_USE_INTERNAL = false;
129
+ const NN_PAYPAL_CAN_USE_MULTISHIPPING = false;
130
+ const NN_PAYPAL_FORM_BLOCK = 'novalnet_payment/method_form_Paypal';
131
+ const NN_PAYPAL_INFO_BLOCK = 'novalnet_payment/method_info_Paypal';
132
+
133
+ /**********************************************/
134
+ /* NOVALNET ONLINE BANK TRANSFER PARAMS */
135
+ /*********************************************/
136
+
137
+ const NN_BANKTRANSFER = 'novalnetBanktransfer';
138
+ const NN_BANKTRANSFER_CAN_USE_INTERNAL = false;
139
+ const NN_BANKTRANSFER_CAN_USE_MULTISHIPPING = false;
140
+ const NN_BANKTRANSFER_FORM_BLOCK = 'novalnet_payment/method_form_Banktransfer';
141
+ const NN_BANKTRANSFER_INFO_BLOCK = 'novalnet_payment/method_info_Banktransfer';
142
+
143
+ /**********************************************/
144
+ /* NOVALNET IDEAL PARAMS */
145
+ /*********************************************/
146
 
 
 
 
147
  const NN_IDEAL = 'novalnetIdeal';
 
148
  const NN_IDEAL_CAN_USE_INTERNAL = false;
149
  const NN_IDEAL_CAN_USE_MULTISHIPPING = false;
150
+ const NN_IDEAL_FORM_BLOCK = 'novalnet_payment/method_form_Ideal';
151
+ const NN_IDEAL_INFO_BLOCK = 'novalnet_payment/method_info_Ideal';
152
+
153
+ /**********************************************/
154
+ /* NOVALNET EPS PARAMS */
155
+ /*********************************************/
156
+
157
  const NN_EPS = 'novalnetEps';
 
158
  const NN_EPS_CAN_USE_INTERNAL = false;
159
  const NN_EPS_CAN_USE_MULTISHIPPING = false;
160
+ const NN_EPS_FORM_BLOCK = 'novalnet_payment/method_form_Eps';
161
+ const NN_EPS_INFO_BLOCK = 'novalnet_payment/method_info_Eps';
162
+
163
+ /**********************************************/
164
+ /* NOVALNET GIROPAY PARAMS */
165
+ /*********************************************/
166
 
 
 
 
167
  const NN_GIROPAY = 'novalnetGiropay';
 
168
  const NN_GIROPAY_CAN_USE_INTERNAL = false;
169
  const NN_GIROPAY_CAN_USE_MULTISHIPPING = false;
170
+ const NN_GIROPAY_FORM_BLOCK = 'novalnet_payment/method_form_Giropay';
171
+ const NN_GIROPAY_INFO_BLOCK = 'novalnet_payment/method_info_Giropay';
172
 
173
+ /**********************************************/
174
+ /* NOVALNET ABSTRACT FUNCTIONS */
175
+ /*********************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
 
177
  static public function getInstance()
178
  {
186
  {
187
  return $this->{'_' . $key};
188
  }
189
+
190
  }
app/code/community/Novalnet/Payment/Model/Factory.php DELETED
@@ -1,382 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Factory
27
- {
28
- /**
29
- * Save capture response
30
- *
31
- * @param float $amount
32
- * @param varien_object $loadTransStatus
33
- * @param int $transStatus
34
- * @param varien_object $payment
35
- * @param int $lastTranId
36
- */
37
- public function captureResponseSave($amount, $loadTransStatus, $transStatus, $payment, $lastTranId)
38
- {
39
- if ($amount) {
40
- $loadTransStatus->setTransactionStatus(Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED)
41
- ->setAmount($amount)
42
- ->save();
43
- } else {
44
- $loadTransStatus->setTransactionStatus(Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED)
45
- ->save();
46
- }
47
-
48
- $magentoVersion = Mage::helper('novalnet_payment')->getMagentoVersion();
49
- // make capture transaction open for lower versions to make refund
50
- if (version_compare($magentoVersion, '1.6', '<')) {
51
- $payment->setIsTransactionClosed(false)
52
- ->save();
53
- }
54
-
55
- if ($transStatus != Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
56
- $transMode = (version_compare($magentoVersion, '1.6', '<')) ? false : true;
57
- $payment->setTransactionId($lastTranId)
58
- ->setIsTransactionClosed($transMode);
59
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false);
60
- $transaction->setParentTxnId(null)
61
- ->save();
62
- }
63
- }
64
-
65
- /**
66
- * Call Transation status refund and void
67
- *
68
- * @param int $getTid
69
- * @param varien_object $payment
70
- * @param int $amountAfterRefund
71
- * @param string $call
72
- * @param int $refundTid
73
- * @param int $customerId
74
- * @param array $response
75
- * @return mixed
76
- */
77
- public function getTransactionData($getTid, $payment, $amountAfterRefund, $call, $refundTid
78
- = NULL, $customerId = NULL, $response = NULL)
79
- {
80
- $helper = Mage::helper('novalnet_payment');
81
- $paymentObj = $payment->getMethodInstance();
82
- $amount = $helper->getFormatedAmount($response->getAmount(), 'RAW');
83
- if ($call == 1) {
84
- $loadTransaction = $helper->loadTransactionStatus($getTid);
85
- $loadTransaction->setTransactionStatus($response->getTidStatus())
86
- ->setAmount($amount)
87
- ->save();
88
- if (in_array($paymentObj->getCode(), array(Novalnet_Payment_Model_Config::NN_INVOICE,
89
- Novalnet_Payment_Model_Config::NN_PREPAYMENT))) {
90
- $loadTransaction->setAmount($amountAfterRefund)
91
- ->save();
92
- }
93
- } else {
94
- if ($refundTid) { // Only log the novalnet transaction which contains TID
95
- $response->setStatus($response->getTidStatus());
96
- $paymentObj->logNovalnetStatusData($response, $refundTid, $customerId, NULL, $response->getAmount());
97
- }
98
- }
99
- return $response;
100
-
101
- }
102
-
103
- /**
104
- * Check Magento version refund progress save
105
- *
106
- * @param Mage_Checkout_Model_Session $helper
107
- * @param varien_object $payment
108
- * @param int $refundTid
109
- * @param array $data
110
- */
111
- public function refundValidateProcess($helper, $payment, $refundTid,$data)
112
- {
113
- // make capture transaction open for lower versions to make refund
114
- if (version_compare($helper->getMagentoVersion(), '1.6', '<')) {
115
- $order = $payment->getOrder();
116
- $canRefundMore = $order->canCreditmemo();
117
-
118
- $payment->setTransactionId($refundTid)
119
- ->setLastTransId($refundTid)
120
- ->setAdditionalData(serialize($data))
121
- ->setIsTransactionClosed(1) // refund initiated by merchant
122
- ->setShouldCloseParentTransaction(!$canRefundMore)
123
- ->save();
124
- } else {
125
- $payment->setTransactionId($refundTid)
126
- ->setLastTransId($refundTid)
127
- ->setAdditionalData(serialize($data))
128
- ->save();
129
- }
130
- }
131
-
132
- /**
133
- * Set RequestParams Form
134
- *
135
- * @param varien_object $request
136
- * @param varien_object $infoObject
137
- * @param int $orderId
138
- * @param int $amount
139
- * @param int $livemode
140
- */
141
- public function requestParams($request, $infoObject, $orderId, $amount, $livemode)
142
- {
143
- $helper = Mage::helper('novalnet_payment');
144
- $billing = $infoObject->getBillingAddress();
145
- $shipping = $infoObject->getShippingAddress();
146
- if (!$infoObject->getIsVirtual()) {
147
- $company = $billing->getCompany() ? $billing->getCompany() : ($shipping->getCompany() ? $shipping->getCompany() : '');
148
- }
149
- $email = $billing->getEmail() ? $billing->getEmail() : $infoObject->getCustomerEmail();
150
- $request = $company ? $request->setCompany($company) : $request;
151
- $vendorScriptUrlConfig = Mage::getStoreConfig('novalnet_global/novalnetsetting/vendor_script_url');
152
- $vendorScriptUrl = $vendorScriptUrlConfig ? $vendorScriptUrlConfig :
153
- Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'callback_novalnet2magento.php';
154
- $request->setTestMode($livemode)
155
- ->setAmount($amount)
156
- ->setCurrency($infoObject->getBaseCurrencyCode())
157
- ->setCustomerNo($helper->getCustomerId())
158
- ->setFirstName($billing->getFirstname())
159
- ->setLastName($billing->getLastname())
160
- ->setSearchInStreet(1)
161
- ->setStreet(implode(',', $billing->getStreet()))
162
- ->setCity($billing->getCity())
163
- ->setZip($billing->getPostcode())
164
- ->setCountry($billing->getCountry())
165
- ->setCountryCode($billing->getCountry())
166
- ->setLanguage(strtoupper($helper->getDefaultLanguage()))
167
- ->setLang(strtoupper($helper->getDefaultLanguage()))
168
- ->setTel($billing->getTelephone())
169
- ->setFax($billing->getFax())
170
- ->setRemoteIp($helper->getRealIpAddr())
171
- ->setGender('u')
172
- ->setEmail($email)
173
- ->setOrderNo($orderId)
174
- ->setSystemUrl(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB))
175
- ->setSystemIp($helper->getServerAddr())
176
- ->setSystemName('Magento')
177
- ->setSystemVersion($helper->getMagentoVersion() . '-' . $helper->getNovalnetVersion())
178
- ->setNotifyUrl($vendorScriptUrl)
179
- ->setInput1('order_id')
180
- ->setInputval1($orderId);
181
- }
182
-
183
- /**
184
- * Set Request profile params
185
- *
186
- * @param varien_object $request
187
- * @param mixed $subsequentPeriod
188
- * @return null
189
- */
190
- public function requestProfileParams($request, $subsequentPeriod)
191
- {
192
- $helper = Mage::helper('novalnet_payment');
193
- $checkoutSession = $helper->getCheckoutSession();
194
- $periodUnit = $checkoutSession->getNnPeriodUnit();
195
- $periodFrequency = $checkoutSession->getNnPeriodFrequency();
196
- $periodUnitFormat = array("day" => "d", "month" => "m", "year" => "y");
197
-
198
- if ($periodUnit == "semi_month") {
199
- $tariffPeriod = "14d";
200
- } elseif ($periodUnit == "week") {
201
- $tariffPeriod = ($periodFrequency * 7) . "d";
202
- } else {
203
- $tariffPeriod = $periodFrequency . $periodUnitFormat[$periodUnit];
204
- }
205
-
206
- $subsequentPeriod = $subsequentPeriod ? $subsequentPeriod : $tariffPeriod;
207
- $regularAmount = $helper->getFormatedAmount($helper->getCheckoutSession()->getNnRegularAmount());
208
- $request->setTariffPeriod($tariffPeriod)
209
- ->setTariffPeriod2($subsequentPeriod)
210
- ->setTariffPeriod2Amount($regularAmount);
211
- }
212
-
213
- /**
214
- * Save Profile Active State
215
- *
216
- * @param int $lastTransId
217
- */
218
- public function saveProfileState($lastTransId)
219
- {
220
- $recurringProfileId = Mage::getModel('sales/recurring_profile')->load($lastTransId, 'reference_id');
221
- if ($recurringProfileId->getState() != 'canceled') {
222
- $recurringProfileId->setState('active');
223
- $recurringProfileId->save();
224
- }
225
- }
226
-
227
- /**
228
- * Set recurring profile state as canceled
229
- *
230
- * @param int $lastTransId
231
- */
232
- public function saveProfileCancelState($lastTransId)
233
- {
234
- $count = $this->recurringCollection($lastTransId);
235
- if ($count) {
236
- $recurringProfileId = Mage::getModel('sales/recurring_profile')->load($lastTransId, 'reference_id');
237
- $recurringProfileId->setState('canceled');
238
- $recurringProfileId->save();
239
- }
240
- }
241
-
242
- /**
243
- * Set reference id for recurring profile
244
- *
245
- * @param int $lastTransId
246
- * @param int $tid
247
- */
248
- public function saveProfileTID($lastTransId,$tid)
249
- {
250
- $count = $this->recurringCollection($lastTransId);
251
- if ($count) {
252
- $recurringProfileId = Mage::getModel('sales/recurring_profile')->load($lastTransId, 'reference_id');
253
- $recurringProfileId->setReferenceId($tid);
254
- $recurringProfileId->save();
255
- }
256
- }
257
-
258
- /**
259
- * Save Profile Cancel State
260
- *
261
- * @param int $lastTransId
262
- * @return int
263
- */
264
- private function recurringCollection($lastTransId)
265
- {
266
- $recurringCollection = Mage::getModel('sales/recurring_profile')->getCollection()
267
- ->addFieldToFilter('reference_id', $lastTransId)
268
- ->addFieldToSelect('reference_id');
269
- $countRecurring = count($recurringCollection);
270
- return $countRecurring;
271
- }
272
-
273
-
274
-
275
- /**
276
- * Request Types Capture,Refund and void
277
- *
278
- * @param varien_object $request
279
- * @param string $requestType
280
- * @param Novalnet_Payment_Helper_Data $helper
281
- * @param int $getTid
282
- * @param int $refundAmount
283
- */
284
- public function requestTypes($request, $requestType, $helper, $getTid, $refundAmount
285
- = NULL)
286
- {
287
- $setStatus = ($requestType == 'capture') ? Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
288
- : Novalnet_Payment_Model_Config::PAYMENT_VOID_STATUS;
289
-
290
- if ($requestType == 'void' || $requestType == 'capture') {
291
- $request->setTid($helper->makeValidNumber($getTid))
292
- ->setStatus($setStatus)
293
- ->setEditStatus(true);
294
- } else {
295
- $request->setTid($helper->makeValidNumber($getTid))
296
- ->setRefundRequest(true)
297
- ->setRefundParam($refundAmount);
298
- $this->refundAdditionalParam($request);
299
- }
300
- }
301
-
302
- /**
303
- * Add additonal params for refund process
304
- *
305
- * @param varien_object $request
306
- */
307
- private function refundAdditionalParam($request)
308
- {
309
- $getParamRequest = Mage::app()->getRequest();
310
- $helper = Mage::helper('novalnet_payment');
311
- $refundAccountholder = $getParamRequest->getParam('refund_payment_type_accountholder');
312
- $refundIban = $getParamRequest->getParam('refund_payment_type_iban');
313
- $refundBic = $getParamRequest->getParam('refund_payment_type_bic');
314
- $refundRef = $getParamRequest->getParam('nn_refund_ref');
315
- $refundType = $getParamRequest->getParam('refund_payment_type');
316
-
317
- if ($refundType == 'SEPA' && (!$refundIban || !$refundBic)) {
318
- Mage::throwException($helper->__('Please enter valid account details'));
319
- } elseif ($refundRef && !$helper->checkIsValid($refundRef)) {
320
- Mage::throwException($helper->__('Please enter valid account details'));
321
- }
322
-
323
- if ($refundRef) {
324
- $request->setRefundRef($refundRef);
325
- }
326
-
327
- if ($refundIban && $refundBic) {
328
- $request->setAccountHolder($refundAccountholder)
329
- ->setIban($refundIban)
330
- ->setBic($refundBic);
331
- }
332
- }
333
-
334
- /**
335
- * get last successful payment method
336
- *
337
- * @param int $customerId
338
- * @param Mage_Checkout_Model_Session $checkoutSession
339
- */
340
- public function getlastSuccesOrderMethod($customerId,$checkoutSession)
341
- {
342
- $table_prefix = Mage::getConfig()->getTablePrefix();
343
- $order_table = $table_prefix.'sales_flat_order';
344
- $on_condition = "main_table.parent_id = $order_table.entity_id";
345
- $orderCollection = Mage::getModel('sales/order_payment')->getCollection()
346
- ->addAttributeToSort('created_at', 'DESC')
347
- ->addFieldToFilter('customer_id', $customerId)
348
- ->addFieldToFilter('method',array('like' => '%novalnet%'))
349
- ->addFieldToSelect('method')
350
- ->setPageSize(1);
351
- $orderCollection->getSelect()->join($order_table,$on_condition);
352
- $count = $orderCollection->count();
353
- if ($count > 0) {
354
- foreach($orderCollection as $order):
355
- $paymentMethod = $order->getMethod();
356
- endforeach;
357
- $checkoutSession->getQuote()->getPayment()->setMethod($paymentMethod);
358
- }
359
- }
360
-
361
- /**
362
- * Build the refund details for reference
363
- *
364
- * @param int $refAmount
365
- * @param array $data
366
- * @param int $refundTid
367
- * @param int $getTid
368
- * @return array
369
- */
370
- public function refundTidData($refAmount,$data,$refundTid,$getTid)
371
- {
372
- if (!isset($data['refunded_tid'])) {
373
- $refundedTid = array('refunded_tid'=> array($refundTid => array('reftid' => $refundTid , 'refamount' => $refAmount , 'reqtid' => $getTid)));
374
- $data = array_merge($data, $refundedTid);
375
- } else {
376
- $data['refunded_tid'][$refundTid]['reftid'] = $refundTid;
377
- $data['refunded_tid'][$refundTid]['refamount'] = $refAmount;
378
- $data['refunded_tid'][$refundTid]['reqtid'] = $getTid;
379
- }
380
- return $data;
381
- }
382
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Ipn.php DELETED
@@ -1,410 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Ipn
27
- {
28
- /**
29
- * Default log filename
30
- *
31
- * @var string
32
- */
33
- const DEFAULT_LOG_FILE = 'novalnet_recurring_unknown_ipn.log';
34
-
35
- /**
36
- * Store order instance
37
- *
38
- * @var Mage_Sales_Model_Order
39
- */
40
- protected $_order = null;
41
-
42
- /*
43
- * Recurring profile instance
44
- *
45
- * @var Mage_Sales_Model_Recurring_Profile
46
- */
47
- protected $_recurringProfile = null;
48
-
49
- /**
50
- * IPN request data
51
- *
52
- * @var array
53
- */
54
- protected $_request = array();
55
-
56
- /**
57
- * Check the debug is enable
58
- *
59
- * @var array
60
- */
61
- protected $_debug = false;
62
-
63
- /**
64
- * Show the debug
65
- *
66
- * @var array
67
- */
68
- protected $_showdebug = false;
69
-
70
- /**
71
- * Collected debug information
72
- *
73
- * @var array
74
- */
75
- protected $_debugData = array();
76
-
77
- /**
78
- * IPN request data getter
79
- *
80
- * @param string $key
81
- * @return array|string
82
- */
83
- public function getRequestData($key = null)
84
- {
85
- if (null === $key) {
86
- return $this->_request;
87
- }
88
- return isset($this->_request[$key]) ? $this->_request[$key] : null;
89
- }
90
-
91
- /**
92
- * Process recurring profile request
93
- *
94
- * @param array $request
95
- * @param Zend_Http_Client_Adapter_Interface $httpAdapter
96
- * @param array $requestdata
97
- * @param array $resultdata
98
- * @throws Exception
99
- */
100
- public function processIpnRequest($request, Zend_Http_Client_Adapter_Interface $httpAdapter
101
- = null, $requestdata, $resultdata)
102
- {
103
- $this->_helper = Mage::helper('novalnet_payment');
104
- $this->_request = $request;
105
-
106
- try {
107
- $this->_getRecurringProfile();
108
- $statuscode = $this->_processRecurringProfile($httpAdapter, $requestdata, $resultdata);
109
- } catch (Exception $e) {
110
- $this->_debugData['exception'] = $e->getMessage();
111
- $this->_debug();
112
- throw $e;
113
- }
114
- $this->_debug();
115
- return $statuscode;
116
- }
117
-
118
- /**
119
- * Post back to Novalnet, check whether this request is a valid one
120
- *
121
- * @param Zend_Http_Client_Adapter_Interface $httpAdapter
122
- * @param array $postbackRequest
123
- */
124
- protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter, $postbackRequest)
125
- {
126
- $sReq = '';
127
- foreach ($postbackRequest->getData() as $k => $v) {
128
- $sReq .= '&' . $k . '=' . urlencode($v);
129
- }
130
- $sReq = substr($sReq, 1);
131
- $payportUrl = $this->_helper->getPayportUrl('paygate');
132
- $this->_debugData['postback'] = $sReq;
133
- $this->_debugData['postback_to'] = $payportUrl;
134
- $httpAdapter->write(Zend_Http_Client::POST, $payportUrl, '1.1', array(), $sReq);
135
- try {
136
- $response = $httpAdapter->read();
137
- } catch (Exception $e) {
138
- $this->_debugData['http_error'] = array('error' => $e->getMessage(),
139
- 'code' => $e->getCode());
140
- throw $e;
141
- }
142
- $this->_debugData['postback_result'] = $response;
143
- unset($this->_debugData['postback'], $this->_debugData['postback_result']);
144
- }
145
-
146
- /**
147
- * Load recurring profile
148
- *
149
- * @return Mage_Sales_Model_Recurring_Profile
150
- * @throws Exception
151
- */
152
- protected function _getRecurringProfile()
153
- {
154
- if (empty($this->_recurringProfile)) {
155
- $recurringProfileId = "";
156
- if (isset($this->_request['profile_id'])) {
157
- $recurringProfileId = $this->_request['profile_id'];
158
- }
159
-
160
- $referenceId = $this->_request['signup_tid'];
161
- if ($recurringProfileId) {
162
- $this->_recurringProfile = Mage::getModel('sales/recurring_profile')
163
- ->load($recurringProfileId, 'profile_id');
164
- } else {
165
- $this->_recurringProfile = Mage::getModel('sales/recurring_profile')
166
- ->load($referenceId, 'reference_id');
167
- }
168
-
169
- if (!$this->_recurringProfile->getId()) {
170
- $debugMsg = sprintf('Wrong recurring profile REFERENCE_ID: "%s".', $referenceId);
171
- if ($this->_showdebug) {
172
- echo $debugMsg;
173
- exit;
174
- }
175
- throw new Exception($debugMsg);
176
- }
177
-
178
- $methodCode = $this->_recurringProfile->getMethodCode();
179
- if (!$this->isMethodActive($methodCode, $this->_recurringProfile->getStoreId())) {
180
- $debugMsg = sprintf('Method "%s" is not available.', $methodCode);
181
- if ($this->_showdebug) {
182
- echo $debugMsg;
183
- exit;
184
- }
185
- throw new Exception($debugMsg);
186
- }
187
- if (!$recurringProfileId) {
188
- $this->_recurringProfileOrderTid = null;
189
- $this->_getRecurringProfileOrdersTid();
190
- }
191
- }
192
- return $this->_recurringProfile;
193
- }
194
-
195
- /**
196
- * Load recurring profile
197
- *
198
- * @return Mage_Sales_Model_Recurring_Profile
199
- * @throws Exception
200
- */
201
- protected function _getRecurringProfileOrdersTid()
202
- {
203
- if (empty($this->_recurringProfileOrderTid)) {
204
- $recurringProfileOrderTid = $this->_request['tid'];
205
- $checkNovalnetTids = Mage::getModel("sales/order_payment")->getCollection()
206
- ->addAttributeToSelect('last_trans_id')
207
- ->addFieldToFilter('last_trans_id', array('like' => "%" . $recurringProfileOrderTid . "%"))
208
- ->getData();
209
- if (!empty($checkNovalnetTids)) {
210
- $debugMsg = sprintf('Wrong recurring profile order TID: "%s".', $recurringProfileOrderTid);
211
- if ($this->_showdebug) {
212
- echo $debugMsg;
213
- exit;
214
- }
215
- throw new Exception($debugMsg);
216
- }
217
- }
218
-
219
- return $this->_recurringProfileOrderTid;
220
- }
221
-
222
- /**
223
- * Check whether method active in configuration and supported for merchant country or not
224
- *
225
- * @param string $method
226
- * @param int $storeId
227
- * @return boolean
228
- */
229
- public function isMethodActive($method, $storeId)
230
- {
231
- if (Mage::getStoreConfigFlag("payment/{$method}/active", $storeId)) {
232
- return true;
233
- }
234
- return false;
235
- }
236
-
237
- /**
238
- * Process notification from recurring profile payments
239
- *
240
- * @param Zend_Http_Client_Adapter_Interface $httpAdapter
241
- * @param array $requestdata
242
- * @param array $resultdata
243
- * @return int
244
- */
245
- protected function _processRecurringProfile(Zend_Http_Client_Adapter_Interface $httpAdapter, $requestdata, $resultdata)
246
- {
247
- $this->_recurringProfile = null;
248
- $this->_getRecurringProfile();
249
- try {
250
- // handle payment_status
251
- $paymentStatus = $this->_request['status'];
252
- switch ($paymentStatus) {
253
- // paid
254
- case Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED:
255
- $statuscode = $this->_registerRecurringProfilePaymentCapture($httpAdapter, $requestdata, $resultdata);
256
- break;
257
-
258
- default:
259
- $debugMsg = sprintf("Novalnet callback received. Status $paymentStatus is not valid: Only 100 is allowed.");
260
- if ($this->_showdebug) {
261
- echo $debugMsg;
262
- exit;
263
- }
264
- throw new Exception($debugMsg);
265
- }
266
- } catch (Mage_Core_Exception $e) {
267
- //TODO: add to payment profile comments
268
- $comment = $this->_createIpnComment($this->_helper->__('Note: %s', $e->getMessage()), true);
269
- $comment->save();
270
- throw $e;
271
- }
272
- return $statuscode;
273
- }
274
-
275
- /**
276
- * Register recurring payment notification, create and process order
277
- *
278
- * @param Zend_Http_Client_Adapter_Interface $httpAdapter
279
- * @param array $requestdata
280
- * @param array $resultdata
281
- * @return int
282
- */
283
- protected function _registerRecurringProfilePaymentCapture(Zend_Http_Client_Adapter_Interface $httpAdapter, $requestdata, $resultdata)
284
- {
285
- $tid = $this->getRequestData('tid');
286
- $product = $this->getRequestData('product');
287
- $recurringProfile = $this->_recurringProfile;
288
-
289
- $billlingAmount = $recurringProfile->getBillingAmount();
290
- $taxAmount = $recurringProfile->getTaxAmount();
291
- $shipAmount = $recurringProfile->getShippingAmount();
292
- $referenceId = $recurringProfile->getReferenceId();
293
- $amount = round(($billlingAmount + $shipAmount + $taxAmount), 2);
294
- $price = $billlingAmount;
295
- $originalPrice = $amount;
296
- $productItemInfo = new Varien_Object;
297
-
298
- $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
299
- $productItemInfo->setTaxAmount($taxAmount);
300
- $productItemInfo->setShippingAmount($shipAmount);
301
- $productItemInfo->setPrice($price);
302
-
303
- $order = $recurringProfile->createOrder($productItemInfo);
304
- $this->_order = $order;
305
- $payment = $order->getPayment();
306
- $order->save();
307
- $payment->setAdditionalData($this->getRequestData('additional_data'))
308
- ->save();
309
- $paymentObj = $payment->getMethodInstance();
310
-
311
- $paymentMethod = $paymentObj->getCode();
312
- $getStatus = $resultdata->getTidStatus();
313
- $subsId = $resultdata->getSubsId();
314
- $resultdata->setStatus($getStatus);
315
- if (!$referenceId
316
- && (in_array($paymentMethod, array(Novalnet_Payment_Model_Config::NN_PREPAYMENT, Novalnet_Payment_Model_Config::NN_INVOICE)) && $getStatus != 100)) {
317
- $payment->setIsTransactionPending(true);
318
- }
319
-
320
- $resultStatus = $resultdata->getStatus();
321
- $recurringProfile->addOrderRelation($order->getId());
322
- $this->_helper->getCoresession()->setStatusCode($resultStatus);
323
- $closed = $resultStatus == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
324
- ? 1 : 0;
325
- $payment->setTransactionId($tid)
326
- ->setPreparedMessage($this->_createIpnComment(''))
327
- ->setAdditionalInformation('subs_id', $subsId)
328
- ->setIsTransactionClosed($closed);
329
- $resultdata->setAmount($order->getGrandTotal());
330
- $paymentObj->logNovalnetStatusData($resultdata, trim($tid));
331
- $paymentObj->logNovalnetTransactionData($requestdata, $resultdata, trim($tid), $this->_helper->getCustomerId(), $this->_helper->getMagentoStoreId());
332
- $payment->registerCaptureNotification($originalPrice, 0);
333
-
334
- $order->save();
335
-
336
- if (!$referenceId && $httpAdapter) {
337
- $request = Mage::getModel('novalnet_payment/novalnet_request');
338
- $request->setTid($tid)
339
- ->setVendor($this->getRequestData('vendor'))
340
- ->setAuthCode($this->getRequestData('auth_code'))
341
- ->setTestMode($this->getRequestData('test_mode'))
342
- ->setProduct($product)
343
- ->setTariff($this->getRequestData('tariff'))
344
- ->setKey($this->getRequestData('key'))
345
- ->setOrderNo($order->getIncrementId())
346
- ->setStatus(100);
347
- if (in_array($paymentMethod, array(Novalnet_Payment_Model_Config::NN_PREPAYMENT, Novalnet_Payment_Model_Config::NN_INVOICE))) {
348
- $request->setInvoiceRef("BNR-" . $product . "-" . $order->getIncrementId());
349
- }
350
-
351
- $this->_postBack($httpAdapter, $request); // second call
352
- // Log Affiliate user details
353
- $nnAffId = $this->_helper->getCoresession()->getNnAffId();
354
- if ($nnAffId) {
355
- $paymentObj->doNovalnetAffUserInfoLog($nnAffId);
356
- }
357
- }
358
- // notify customer
359
- $subscriptionPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('subscriptionPayments');
360
-
361
- if (($resultStatus != 100 && in_array($paymentMethod, $subscriptionPayments))
362
- || ($resultStatus == 100 && $paymentMethod == Novalnet_Payment_Model_Config::NN_PREPAYMENT)) {
363
- if (!$order->getEmailSent() && $order->getId()) {
364
- $order->sendNewOrderEmail()
365
- ->setEmailSent(true)
366
- ->save();
367
- }
368
- } else if ($invoice = $payment->getCreatedInvoice()) {
369
- $message = $this->_helper->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
370
- $order->sendNewOrderEmail()->addStatusHistoryComment($message)
371
- ->setIsCustomerNotified(true)
372
- ->save();
373
- }
374
- return $getStatus;
375
- }
376
-
377
- /**
378
- * Generate an "IPN" comment with additional explanation.
379
- * Returns the generated comment or order status history object
380
- *
381
- * @param string $comment
382
- * @param bool $addToHistory
383
- * @return string|Mage_Sales_Model_Order_Status_History
384
- */
385
- protected function _createIpnComment($comment = '', $addToHistory = false)
386
- {
387
- $paymentStatus = $this->getRequestData('status');
388
- $message = $this->_helper->__('IPN "%s".', $paymentStatus);
389
- if ($comment) {
390
- $message .= ' ' . $comment;
391
- }
392
- if ($addToHistory) {
393
- $message = $this->_order->addStatusHistoryComment($message);
394
- $message->setIsCustomerNotified(null);
395
- }
396
- return $message;
397
- }
398
-
399
- /**
400
- * Log debug data to file
401
- *
402
- */
403
- protected function _debug()
404
- {
405
- if ($this->_debug) {
406
- $file = self::DEFAULT_LOG_FILE;
407
- Mage::getModel('core/log_adapter', $file)->log($this->_debugData);
408
- }
409
- }
410
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Method/Abstract.php ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Method_Abstract extends Mage_Payment_Model_Method_Abstract
27
+ implements Mage_Payment_Model_Recurring_Profile_MethodInterface
28
+ {
29
+ /**
30
+ * Payment Method features
31
+ * @var boolean
32
+ */
33
+ protected $_isGateway = false;
34
+ protected $_canOrder = false;
35
+ protected $_canCapture = true;
36
+ protected $_canCapturePartial = false;
37
+ protected $_canRefund = true;
38
+ protected $_canRefundInvoicePartial = true;
39
+ protected $_canVoid = true;
40
+ protected $_canUseCheckout = true;
41
+ protected $_canSaveCc = false;
42
+ protected $_isInitializeNeeded = false;
43
+ protected $_canManageRecurringProfiles = true;
44
+
45
+ /**
46
+ * Whether a captured transaction may be voided by this gateway
47
+ * This may happen when amount is captured, but not settled
48
+ * @var boolean
49
+ */
50
+ protected $_canCancelInvoice = false;
51
+
52
+ /**
53
+ * Constructor
54
+ */
55
+ public function __construct()
56
+ {
57
+ if (!$this->helper) {
58
+ $this->helper = Mage::helper('novalnet_payment');
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Check whether payment method can be used
64
+ *
65
+ * @param Mage_Sales_Model_Quote|null $quote
66
+ * @return boolean
67
+ */
68
+ public function isAvailable($quote = null)
69
+ {
70
+ if (Mage::registry('payment_code')) {
71
+ Mage::unregister('payment_code'); // Unregister existing payment method code
72
+ }
73
+ Mage::register('payment_code', $this->_code); // Register payment method code for payment process
74
+
75
+ // Get Novalnet payment validation model
76
+ $this->validateModel = $this->helper->getModel('Service_Validate_PaymentCheck');
77
+ // Check whether payment method can be used
78
+ if (!$this->validateModel->checkVisiblity($quote, $this->_code)) {
79
+ return false;
80
+ }
81
+ // verify Novalnet payment method session values
82
+ $this->validateModel->checkMethodSession();
83
+ return parent::isAvailable($quote);
84
+ }
85
+
86
+ /**
87
+ * Validate payment method information object
88
+ *
89
+ * @param none
90
+ * @return Mage_Payment_Model_Abstract
91
+ */
92
+ public function validate()
93
+ {
94
+ parent::validate();
95
+ $info = $this->getInfoInstance(); // Payment method instance
96
+ // Get Novalnet fraud prevention model
97
+ $this->preventionModel = $this->helper->getModel('Service_Api_FraudPrevention');
98
+
99
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) { // Sales quote payment instance
100
+ // Validate the Novalnet basic params and billing informations
101
+ $this->validateModel->validateNovalnetParams($info);
102
+ $this->validateModel->checkMethodSession(); // verify Novalnet payment method session values
103
+ } elseif ($info instanceof Mage_Sales_Model_Order_Payment
104
+ && !$this->preventionModel->getFraudPreventionStatus($info, $this->_code)
105
+ ) { // Sales order payment instance
106
+ $this->buildRequest($info); // Build Novalnet payport request params
107
+ }
108
+
109
+ return $this;
110
+ }
111
+
112
+ /**
113
+ * Prepare request to gateway
114
+ *
115
+ * @param Varien_Object $info
116
+ * @return none
117
+ */
118
+ public function buildRequest($info)
119
+ {
120
+ $requestModel = $this->helper->getModel('Service_Api_Request'); // Get Novalnet Api request model
121
+ $request = $requestModel->getPayportParams($info); // Get Novalnet payport request params
122
+ $methodSession = $this->helper->getMethodSession($this->_code); // Get current payment method session
123
+ $methodSession->setPaymentReqData($request); // Assign Novalnet payport request params to method session
124
+ }
125
+
126
+ /**
127
+ * Send payment request to Novalnet gateway
128
+ *
129
+ * @param Varien_Object $request
130
+ * @return Varien_Object $result
131
+ */
132
+ public function postRequest(Varien_Object $request)
133
+ {
134
+ $result = new Varien_Object();
135
+ // Get Novalnet payment validation model
136
+ $validateModel = $this->helper->getModel('Service_Validate_PaymentCheck');
137
+
138
+ // Validate request basic params and send to payport
139
+ if ($validateModel->validateMandateParams($request)) {
140
+ $payportUrl = $this->helper->getPayportUrl('paygate'); // Get payport url
141
+ $gatewayModel = $this->helper->getModel('Service_Api_Gateway'); // Get Novalnet gateway model
142
+ $response = $gatewayModel->payportRequestCall($request->getData(), $payportUrl);
143
+ parse_str($response->getBody(), $data);
144
+ $result->addData($data);
145
+ } else {
146
+ $this->helper->showException($this->helper->__('Required parameter not valid') . '!', false);
147
+ }
148
+
149
+ return $result;
150
+ }
151
+
152
+ /**
153
+ * Capture the payment transaction
154
+ *
155
+ * @param Varien_Object $payment
156
+ * @return Mage_Payment_Model_Abstract
157
+ */
158
+ public function capture(Varien_Object $payment)
159
+ {
160
+ $paymentStatus = $this->getPaymentStatus($payment); // Get current payment transaction status
161
+ $redirectPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
162
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl();
163
+
164
+ if ($this->canCapture() && !preg_match("/callback/i", $currentUrl)
165
+ && !in_array($this->_code, $redirectPayments)
166
+ && $paymentStatus->getTransactionStatus() != Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
167
+ ) {
168
+ $requestModel = $this->helper->getModel('Service_Api_Request'); // Get Novalnet Api request model
169
+ $request = $requestModel->buildProcessRequest($payment, 'capture'); // Build capture process request
170
+
171
+ $responseModel = $this->helper->getModel('Service_Api_Response'); // Get Novalnet Api response model
172
+ $responseModel->postProcessRequest($request, $payment, 'capture'); // Send capture process request
173
+ }
174
+ return $this;
175
+ }
176
+
177
+ /**
178
+ * Void the payment transaction
179
+ *
180
+ * @param Varien_Object $payment
181
+ * @return Mage_Payment_Model_Abstract
182
+ */
183
+ public function void(Varien_Object $payment)
184
+ {
185
+ if ($this->canVoid($payment)) {
186
+ $requestModel = $this->helper->getModel('Service_Api_Request'); // Get Novalnet Api request model
187
+ $request = $requestModel->buildProcessRequest($payment, 'void'); // Build void process request
188
+
189
+ $responseModel = $this->helper->getModel('Service_Api_Response'); // Get Novalnet Api response model
190
+ $responseModel->postProcessRequest($request, $payment, 'void'); // Send void process request
191
+ }
192
+ return $this;
193
+ }
194
+
195
+ /**
196
+ * Refund the transaction amount
197
+ *
198
+ * @param Varien_Object $payment
199
+ * @param float $amount
200
+ * @return Mage_Payment_Model_Abstract
201
+ */
202
+ public function refund(Varien_Object $payment, $amount)
203
+ {
204
+ if ($this->canRefund()) {
205
+ $requestModel = $this->helper->getModel('Service_Api_Request'); // Get Novalnet Api request model
206
+ $request = $requestModel->buildProcessRequest($payment, 'refund', $amount); // Build refund process request
207
+
208
+ $responseModel = $this->helper->getModel('Service_Api_Response'); // Get Novalnet Api response model
209
+ $responseModel->postProcessRequest($request, $payment, 'refund', $amount); // Send refund process request
210
+ }
211
+ return $this;
212
+ }
213
+
214
+ /**
215
+ * Get original payment transaction status
216
+ *
217
+ * @param Varien_Object $payment
218
+ * @return Varien_Object $paymentStatus
219
+ */
220
+ public function getPaymentStatus(Varien_Object $payment)
221
+ {
222
+ // Get payment Novalnet transaction id
223
+ $transactionId = $this->helper->makeValidNumber($payment->getLastTransId());
224
+ $paymentStatus = $this->helper->getModel('Mysql4_TransactionStatus')
225
+ ->loadByAttribute('transaction_no', $transactionId); // Get given payment transaction status
226
+ return $paymentStatus;
227
+ }
228
+
229
+ /**
230
+ * Validate recurring profile data
231
+ *
232
+ * @param Mage_Payment_Model_Recurring_Profile $profile
233
+ * @return boolean
234
+ */
235
+ public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
236
+ {
237
+ return true;
238
+ }
239
+
240
+ /**
241
+ * Fetch recurring profile details
242
+ *
243
+ * @param string $referenceId
244
+ * @param Varien_Object $result
245
+ * @return boolean
246
+ */
247
+ public function getRecurringProfileDetails($referenceId, Varien_Object $result)
248
+ {
249
+ return true;
250
+ }
251
+
252
+ /**
253
+ * Whether can get recurring profile details
254
+ *
255
+ * @param none
256
+ * @return boolean
257
+ */
258
+ public function canGetRecurringProfileDetails()
259
+ {
260
+ return true;
261
+ }
262
+
263
+ /**
264
+ * Update recurring profile data
265
+ *
266
+ * @param Mage_Payment_Model_Recurring_Profile $profile
267
+ * @return boolean
268
+ */
269
+ public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
270
+ {
271
+ return true;
272
+ }
273
+
274
+ /**
275
+ * Submit recurring profile
276
+ *
277
+ * @param Mage_Payment_Model_Recurring_Profile $profile
278
+ * @param Mage_Payment_Model_Info $paymentInfo
279
+ * @return none
280
+ */
281
+ public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
282
+ Mage_Payment_Model_Info $paymentInfo)
283
+ {
284
+ if ($profile->getTrialPeriodUnit() && $profile->getTrialPeriodFrequency()) {
285
+ $this->helper->showException('Trial Billing Cycles are not support Novalnet payment');
286
+ }
287
+ // Submit recurring profile request to Novalnet gateway
288
+ $this->helper->getModel('Recurring_Payment')->submitRecurringProfile($profile, $paymentInfo);
289
+ }
290
+
291
+ /**
292
+ * Manage recurring profile status
293
+ *
294
+ * @param Mage_Payment_Model_Recurring_Profile $profile
295
+ * @return none
296
+ */
297
+ public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
298
+ {
299
+ $recurringModel = $this->helper->getModel('Mysql4_Recurring'); // Get Novalnet recurring model
300
+ // Get recurring profile order number (related orders)
301
+ $orderNo = $recurringModel->getRecurringOrderNo($profile);
302
+ $order = $recurringModel->getOrderByIncrementId($orderNo[0]); // Get order object
303
+
304
+ $requestModel = $this->helper->getModel('Service_Api_Request'); // Get Novalnet Api request model
305
+ $request = $requestModel->buildRecurringApiRequest($order, $profile); // Get Novalnet recurring process request
306
+
307
+ $responseModel = $this->helper->getModel('Service_Api_Response'); // Get Novalnet Api response model
308
+ // Send Novalnet recurring process request
309
+ $responseModel->postRecurringApiRequest($order, $profile->getNewState(), $request);
310
+ }
311
+
312
+ }
app/code/community/Novalnet/Payment/Model/Method/NovalnetBanktransfer.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Method_NovalnetBanktransfer extends Novalnet_Payment_Model_Method_Abstract
27
+ {
28
+
29
+ protected $_code = Novalnet_Payment_Model_Config::NN_BANKTRANSFER;
30
+ protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_BANKTRANSFER_CAN_USE_INTERNAL;
31
+ protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_BANKTRANSFER_CAN_USE_MULTISHIPPING;
32
+ protected $_formBlockType = Novalnet_Payment_Model_Config::NN_BANKTRANSFER_FORM_BLOCK;
33
+ protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_BANKTRANSFER_INFO_BLOCK;
34
+
35
+ /**
36
+ * Check whether payment method can be used
37
+ *
38
+ * @param Mage_Sales_Model_Quote|null $quote
39
+ * @return boolean
40
+ */
41
+ public function isAvailable($quote = null)
42
+ {
43
+ if (!empty($quote) && $quote->hasNominalItems()) {
44
+ return false;
45
+ }
46
+
47
+ return parent::isAvailable($quote);
48
+ }
49
+
50
+ /**
51
+ * Get Novalnet payment redirect URL
52
+ *
53
+ * @param none
54
+ * @return string
55
+ */
56
+ public function getOrderPlaceRedirectUrl()
57
+ {
58
+ return $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
59
+ }
60
+
61
+ }
app/code/community/Novalnet/Payment/Model/Method/NovalnetCc.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Method_NovalnetCc extends Novalnet_Payment_Model_Method_Abstract
27
+ {
28
+ protected $_code = Novalnet_Payment_Model_Config::NN_CC;
29
+ protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_CC_CAN_USE_INTERNAL;
30
+ protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_CC_CAN_USE_MULTISHIPPING;
31
+ protected $_formBlockType = Novalnet_Payment_Model_Config::NN_CC_FORM_BLOCK;
32
+ protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_CC_INFO_BLOCK;
33
+
34
+ /**
35
+ * Validate payment method information object
36
+ *
37
+ * @param none
38
+ * @return Mage_Payment_Model_Abstract
39
+ */
40
+ public function validate()
41
+ {
42
+ parent::validate();
43
+ $info = $this->getInfoInstance(); // Current payment instance
44
+
45
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
46
+ $this->validateModel->validateFormInfo(); // Validate the form values
47
+ }
48
+
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * Assign data to info model instance
54
+ *
55
+ * @param mixed $data
56
+ * @return Mage_Payment_Model_Info
57
+ */
58
+ public function assignData($data)
59
+ {
60
+ if ($data) {
61
+ if (!($data instanceof Varien_Object)) {
62
+ $data = new Varien_Object($data);
63
+ }
64
+
65
+ $methodSession = $this->helper->getMethodSession($this->_code); // Get payment method session
66
+
67
+ if ($this->getFormValues('cc_oneclick_shopping')
68
+ && $this->getFormValues('cc_enter_data') && $data->getCcCid()
69
+ ) {
70
+ $maskedCardInfo = $this->getMaskedCardInfo();
71
+ $methodSession->setNnCcTid($maskedCardInfo['nn_tid'])
72
+ ->setNnCcCvc($data->getCcCid());
73
+ } elseif ($methodSession->hasNnCcTid()) {
74
+ $methodSession->unsNnCcTid();
75
+ }
76
+ }
77
+
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Get Novalnet payment redirect URL
83
+ *
84
+ * @param none
85
+ * @return string $actionUrl
86
+ */
87
+ public function getOrderPlaceRedirectUrl()
88
+ {
89
+ $methodSession = $this->helper->getMethodSession($this->_code); // Get payment method session
90
+
91
+ if ($methodSession->getNnCcTid()) {
92
+ // Credit Card payment redirect url
93
+ $actionUrl = $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_DIRECT_URL);
94
+ } elseif ($this->getConfigData('cc_form_type') == 1) {
95
+ // Credit Card hosted iframe payment redirect url
96
+ $actionUrl = $this->helper->getUrl(Novalnet_Payment_Model_Config::CC_IFRAME_URL);
97
+ } else {
98
+ // Credit Card 3D Secure payment redirect url
99
+ $actionUrl = $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
100
+ }
101
+
102
+ return $actionUrl;
103
+ }
104
+
105
+ /**
106
+ * Get the credit card informations
107
+ *
108
+ * @param string $param
109
+ * @return string
110
+ */
111
+ public function getFormValues($param)
112
+ {
113
+ return Mage::app()->getRequest()->getPost($param);
114
+ }
115
+
116
+ /**
117
+ * Get existing card details
118
+ *
119
+ * @param none
120
+ * @return Varien_Object $paymentValues
121
+ */
122
+ public function getMaskedCardInfo()
123
+ {
124
+ $paymentValues = '';
125
+ $customerId = $this->helper->getCustomerId(); // Get customer id
126
+
127
+ if ($customerId) {
128
+ // Get Masked Credit Card informations if available for the customer
129
+ $collection = $this->helper->getModel('Mysql4_TransactionStatus')->getCollection()
130
+ ->addFieldToFilter('customer_id', $customerId)
131
+ ->addFieldToFilter('payment_name', $this->_code)
132
+ ->addFieldToFilter('reference_transaction', 0)
133
+ ->addFieldToSelect('novalnet_acc_details');
134
+ $paymentValues = $collection->getLastItem()->hasNovalnetAccDetails()
135
+ ? unserialize(base64_decode($collection->getLastItem()->getNovalnetAccDetails())) : '';
136
+ }
137
+ return $paymentValues;
138
+ }
139
+ }
app/code/community/Novalnet/Payment/Model/{Payment/Method → Method}/NovalnetEps.php RENAMED
@@ -18,17 +18,44 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetEps extends Novalnet_Payment_Model_Payment_Method_Abstract
27
  {
 
28
  protected $_code = Novalnet_Payment_Model_Config::NN_EPS;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_EPS_CAN_CAPTURE;
30
  protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_EPS_CAN_USE_INTERNAL;
31
  protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_EPS_CAN_USE_MULTISHIPPING;
32
  protected $_formBlockType = Novalnet_Payment_Model_Config::NN_EPS_FORM_BLOCK;
33
  protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_EPS_INFO_BLOCK;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Model_Method_NovalnetEps extends Novalnet_Payment_Model_Method_Abstract
27
  {
28
+
29
  protected $_code = Novalnet_Payment_Model_Config::NN_EPS;
 
30
  protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_EPS_CAN_USE_INTERNAL;
31
  protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_EPS_CAN_USE_MULTISHIPPING;
32
  protected $_formBlockType = Novalnet_Payment_Model_Config::NN_EPS_FORM_BLOCK;
33
  protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_EPS_INFO_BLOCK;
34
+
35
+ /**
36
+ * Check whether payment method can be used
37
+ *
38
+ * @param Mage_Sales_Model_Quote|null $quote
39
+ * @return boolean
40
+ */
41
+ public function isAvailable($quote = null)
42
+ {
43
+ if (!empty($quote) && $quote->hasNominalItems()) {
44
+ return false;
45
+ }
46
+
47
+ return parent::isAvailable($quote);
48
+ }
49
+
50
+ /**
51
+ * Get Novalnet payment redirect URL
52
+ *
53
+ * @param none
54
+ * @return string
55
+ */
56
+ public function getOrderPlaceRedirectUrl()
57
+ {
58
+ return $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
59
+ }
60
+
61
  }
app/code/community/Novalnet/Payment/Model/{Payment/Method → Method}/NovalnetGiropay.php RENAMED
@@ -18,17 +18,44 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetGiropay extends Novalnet_Payment_Model_Payment_Method_Abstract
27
  {
 
28
  protected $_code = Novalnet_Payment_Model_Config::NN_GIROPAY;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_GIROPAY_CAN_CAPTURE;
30
  protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_GIROPAY_CAN_USE_INTERNAL;
31
  protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_GIROPAY_CAN_USE_MULTISHIPPING;
32
  protected $_formBlockType = Novalnet_Payment_Model_Config::NN_GIROPAY_FORM_BLOCK;
33
  protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_GIROPAY_INFO_BLOCK;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Model_Method_NovalnetGiropay extends Novalnet_Payment_Model_Method_Abstract
27
  {
28
+
29
  protected $_code = Novalnet_Payment_Model_Config::NN_GIROPAY;
 
30
  protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_GIROPAY_CAN_USE_INTERNAL;
31
  protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_GIROPAY_CAN_USE_MULTISHIPPING;
32
  protected $_formBlockType = Novalnet_Payment_Model_Config::NN_GIROPAY_FORM_BLOCK;
33
  protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_GIROPAY_INFO_BLOCK;
34
+
35
+ /**
36
+ * Check whether payment method can be used
37
+ *
38
+ * @param Mage_Sales_Model_Quote|null $quote
39
+ * @return boolean
40
+ */
41
+ public function isAvailable($quote = null)
42
+ {
43
+ if (!empty($quote) && $quote->hasNominalItems()) {
44
+ return false;
45
+ }
46
+
47
+ return parent::isAvailable($quote);
48
+ }
49
+
50
+ /**
51
+ * Get Novalnet payment redirect URL
52
+ *
53
+ * @param none
54
+ * @return string
55
+ */
56
+ public function getOrderPlaceRedirectUrl()
57
+ {
58
+ return $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
59
+ }
60
+
61
  }
app/code/community/Novalnet/Payment/Model/{Payment/Method → Method}/NovalnetIdeal.php RENAMED
@@ -18,17 +18,44 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetIdeal extends Novalnet_Payment_Model_Payment_Method_Abstract
27
  {
 
28
  protected $_code = Novalnet_Payment_Model_Config::NN_IDEAL;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_IDEAL_CAN_CAPTURE;
30
  protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_IDEAL_CAN_USE_INTERNAL;
31
  protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_IDEAL_CAN_USE_MULTISHIPPING;
32
  protected $_formBlockType = Novalnet_Payment_Model_Config::NN_IDEAL_FORM_BLOCK;
33
  protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_IDEAL_INFO_BLOCK;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Model_Method_NovalnetIdeal extends Novalnet_Payment_Model_Method_Abstract
27
  {
28
+
29
  protected $_code = Novalnet_Payment_Model_Config::NN_IDEAL;
 
30
  protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_IDEAL_CAN_USE_INTERNAL;
31
  protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_IDEAL_CAN_USE_MULTISHIPPING;
32
  protected $_formBlockType = Novalnet_Payment_Model_Config::NN_IDEAL_FORM_BLOCK;
33
  protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_IDEAL_INFO_BLOCK;
34
+
35
+ /**
36
+ * Check whether payment method can be used
37
+ *
38
+ * @param Mage_Sales_Model_Quote|null $quote
39
+ * @return boolean
40
+ */
41
+ public function isAvailable($quote = null)
42
+ {
43
+ if (!empty($quote) && $quote->hasNominalItems()) {
44
+ return false;
45
+ }
46
+
47
+ return parent::isAvailable($quote);
48
+ }
49
+
50
+ /**
51
+ * Get Novalnet payment redirect URL
52
+ *
53
+ * @param none
54
+ * @return string
55
+ */
56
+ public function getOrderPlaceRedirectUrl()
57
+ {
58
+ return $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
59
+ }
60
+
61
  }
app/code/community/Novalnet/Payment/Model/Method/NovalnetInvoice.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Method_NovalnetInvoice extends Novalnet_Payment_Model_Method_Abstract
27
+ {
28
+ protected $_code = Novalnet_Payment_Model_Config::NN_INVOICE;
29
+ protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_INVOICE_CAN_USE_MULTISHIPPING;
30
+ protected $_formBlockType = Novalnet_Payment_Model_Config::NN_INVOICE_FORM_BLOCK;
31
+ protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_INVOICE_INFO_BLOCK;
32
+
33
+ /**
34
+ * Check whether payment method can be used
35
+ *
36
+ * @param Mage_Sales_Model_Quote|null $quote
37
+ * @return boolean
38
+ */
39
+ public function isAvailable($quote = null)
40
+ {
41
+ // Get Novalnet payment validation model
42
+ $validateModel = $this->helper->getModel('Service_Validate_PaymentCheck');
43
+ // Get Payment disable time (fraud prevention process)
44
+ $paymentDisableTime = "getPaymentDisableTime" . ucfirst($this->_code);
45
+
46
+ if (time() < $this->helper->getCheckoutSession()->$paymentDisableTime()) {
47
+ return false;
48
+ } elseif (!$validateModel->getPaymentGuaranteeStatus($quote, $this->_code)) {
49
+ return false;
50
+ } elseif (!empty($quote) && $quote->hasNominalItems() && $this->helper->checkIsAdmin()) {
51
+ return false;
52
+ }
53
+
54
+ return parent::isAvailable($quote);
55
+ }
56
+
57
+ /**
58
+ * Assign data to info model instance
59
+ *
60
+ * @param mixed $data
61
+ * @return Mage_Payment_Model_Info
62
+ */
63
+ public function assignData($data)
64
+ {
65
+ if ($data) {
66
+ $methodSession = $this->helper->getMethodSession($this->_code); // Get payment method session
67
+ $fraudPreventType = $this->getConfigData('callback'); // Get fraud prevention type
68
+
69
+ if (!($data instanceof Varien_Object)) {
70
+ $data = new Varien_Object($data);
71
+ }
72
+ // Assign customer DOB
73
+ if ($methodSession->getPaymentGuaranteeFlag()) {
74
+ $methodSession->setCustomerDob($data->getDob());
75
+ }
76
+ // Assign fraud prevention form values
77
+ if ($fraudPreventType && $fraudPreventType != 3) {
78
+ $methodSession->setCallbackTelNovalnetInvoice($data->getCallbackTel())
79
+ ->setCallbackPinNovalnetInvoice(trim($data->getCallbackPin()))
80
+ ->setCallbackNewPinNovalnetInvoice($data->getCallbackNewPin())
81
+ ->setCallbackPinFlag(true);
82
+ } elseif ($fraudPreventType && $fraudPreventType == 3) {
83
+ $methodSession->setCallbackEmailNovalnetInvoice($data->getCallbackEmail());
84
+ }
85
+
86
+ $this->helper->getCheckoutSession()->setNnPaymentCode($this->_code);
87
+ }
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Validate payment method information object
93
+ *
94
+ * @param none
95
+ * @return Mage_Payment_Model_Abstract
96
+ */
97
+ public function validate()
98
+ {
99
+ parent::validate();
100
+ $info = $this->getInfoInstance(); // Current payment instance
101
+
102
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
103
+ $this->validateModel->validateFormInfo(); // Validate the form values
104
+ }
105
+
106
+ if ($this->preventionModel->getFraudPreventionStatus($info, $this->_code)) {
107
+ $this->preventionModel->fraudPreventionProcess($info); // Fraud prevention process handling
108
+ }
109
+
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * Get Novalnet payment redirect URL
115
+ *
116
+ * @param none
117
+ * @return string $actionUrl
118
+ */
119
+ public function getOrderPlaceRedirectUrl()
120
+ {
121
+ return $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_DIRECT_URL);
122
+ }
123
+
124
+ }
app/code/community/Novalnet/Payment/Model/{Payment/Method → Method}/NovalnetPaypal.php RENAMED
@@ -18,17 +18,29 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetPaypal extends Novalnet_Payment_Model_Payment_Method_Abstract
27
  {
 
28
  protected $_code = Novalnet_Payment_Model_Config::NN_PAYPAL;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_PAYPAL_CAN_CAPTURE;
30
  protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_PAYPAL_CAN_USE_INTERNAL;
31
  protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_PAYPAL_CAN_USE_MULTISHIPPING;
32
  protected $_formBlockType = Novalnet_Payment_Model_Config::NN_PAYPAL_FORM_BLOCK;
33
  protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_PAYPAL_INFO_BLOCK;
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Model_Method_NovalnetPaypal extends Novalnet_Payment_Model_Method_Abstract
27
  {
28
+
29
  protected $_code = Novalnet_Payment_Model_Config::NN_PAYPAL;
 
30
  protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_PAYPAL_CAN_USE_INTERNAL;
31
  protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_PAYPAL_CAN_USE_MULTISHIPPING;
32
  protected $_formBlockType = Novalnet_Payment_Model_Config::NN_PAYPAL_FORM_BLOCK;
33
  protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_PAYPAL_INFO_BLOCK;
34
+
35
+ /**
36
+ * Get Novalnet payment redirect URL
37
+ *
38
+ * @param none
39
+ * @return string
40
+ */
41
+ public function getOrderPlaceRedirectUrl()
42
+ {
43
+ return $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
44
+ }
45
+
46
  }
app/code/community/Novalnet/Payment/Model/Method/NovalnetPrepayment.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Method_NovalnetPrepayment extends Novalnet_Payment_Model_Method_Abstract
27
+ {
28
+ protected $_code = Novalnet_Payment_Model_Config::NN_PREPAYMENT;
29
+ protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_PREPAYMENT_CAN_USE_MULTISHIPPING;
30
+ protected $_formBlockType = Novalnet_Payment_Model_Config::NN_PREPAYMENT_FORM_BLOCK;
31
+ protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_PREPAYMENT_INFO_BLOCK;
32
+
33
+ /**
34
+ * Check whether payment method can be used
35
+ *
36
+ * @param Mage_Sales_Model_Quote|null $quote
37
+ * @return boolean
38
+ */
39
+ public function isAvailable($quote = null)
40
+ {
41
+ if (!empty($quote) && $quote->hasNominalItems() && $this->helper->checkIsAdmin()) {
42
+ return false;
43
+ }
44
+
45
+ return parent::isAvailable($quote);
46
+ }
47
+
48
+ /**
49
+ * Validate payment method information object
50
+ *
51
+ * @param none
52
+ * @return Mage_Payment_Model_Abstract
53
+ */
54
+ public function validate()
55
+ {
56
+ parent::validate();
57
+ $info = $this->getInfoInstance(); // Current payment instance
58
+
59
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
60
+ $this->validateModel->validateFormInfo(); // Validate the form values
61
+ }
62
+
63
+ return $this;
64
+ }
65
+
66
+ /**
67
+ * Get Novalnet payment redirect URL
68
+ *
69
+ * @param none
70
+ * @return string $actionUrl
71
+ */
72
+ public function getOrderPlaceRedirectUrl()
73
+ {
74
+ return $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_DIRECT_URL);
75
+ }
76
+
77
+ }
app/code/community/Novalnet/Payment/Model/Method/NovalnetSepa.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Method_NovalnetSepa extends Novalnet_Payment_Model_Method_Abstract
27
+ {
28
+ protected $_code = Novalnet_Payment_Model_Config::NN_SEPA;
29
+ protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_SEPA_CAN_USE_MULTISHIPPING;
30
+ protected $_formBlockType = Novalnet_Payment_Model_Config::NN_SEPA_FORM_BLOCK;
31
+ protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_SEPA_INFO_BLOCK;
32
+
33
+ /**
34
+ * Check whether payment method can be used
35
+ *
36
+ * @param Mage_Sales_Model_Quote|null $quote
37
+ * @return boolean
38
+ */
39
+ public function isAvailable($quote = null)
40
+ {
41
+ // Get Novalnet payment validation model
42
+ $validateModel = $this->helper->getModel('Service_Validate_PaymentCheck');
43
+ // Get Payment disable time (fraud prevention process)
44
+ $paymentDisableTime = "getPaymentDisableTime" . ucfirst($this->_code);
45
+
46
+ if (time() < $this->helper->getCheckoutSession()->$paymentDisableTime()) {
47
+ return false;
48
+ } elseif (!$validateModel->getPaymentGuaranteeStatus($quote, $this->_code)) {
49
+ return false;
50
+ } elseif (!empty($quote) && $quote->hasNominalItems() && $this->helper->checkIsAdmin()) {
51
+ return false;
52
+ }
53
+
54
+ return parent::isAvailable($quote);
55
+ }
56
+
57
+ /**
58
+ * Validate payment method information object
59
+ *
60
+ * @param none
61
+ * @return Mage_Payment_Model_Abstract
62
+ */
63
+ public function validate()
64
+ {
65
+ parent::validate();
66
+ $info = $this->getInfoInstance(); // Current payment instance
67
+
68
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
69
+ $this->validateModel->validateFormInfo(); // Validate the form values
70
+ }
71
+
72
+ $methodSession = $this->helper->getMethodSession($this->_code);
73
+ if ($methodSession->getSepaNewForm()
74
+ && $this->preventionModel->getFraudPreventionStatus($info, $this->_code)
75
+ ) {
76
+ $this->preventionModel->fraudPreventionProcess($info); // Fraud prevention process handling
77
+ }
78
+
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Assign data to info model instance
84
+ *
85
+ * @param mixed $data
86
+ * @return Mage_Payment_Model_Info
87
+ */
88
+ public function assignData($data)
89
+ {
90
+ if ($data) {
91
+ $methodSession = $this->helper->getMethodSession($this->_code); // Get payment method session
92
+ $fraudPreventType = $this->getConfigData('callback'); // Get fraud prevention type
93
+
94
+ if (!($data instanceof Varien_Object)) {
95
+ $data = new Varien_Object($data);
96
+ }
97
+
98
+ // Assign customer DOB
99
+ if ($methodSession->getPaymentGuaranteeFlag()) {
100
+ $methodSession->setCustomerDob($data->getDob());
101
+ }
102
+
103
+ $methodSession->setSepaHolder($this->getFormValues('novalnetSepa_account_holder'))
104
+ ->setSepaHash($this->getFormValues('result_sepa_hash'))
105
+ ->setSepaUniqueId($this->getFormValues('result_mandate_unique'))
106
+ ->setSepaMandateConfirm($this->getFormValues('nnsepa_iban_confirmed'))
107
+ ->setSepaDuedate($this->getConfigData('sepa_due_date'))
108
+ ->setSepaNewForm(1);
109
+
110
+ if ($fraudPreventType && $fraudPreventType != 3) {
111
+ $methodSession->setCallbackTelNovalnetSepa($data->getCallbackTel())
112
+ ->setCallbackPinNovalnetSepa(trim($data->getCallbackPin()))
113
+ ->setCallbackNewPinNovalnetSepa($data->getCallbackNewPin())
114
+ ->setCallbackPinFlag(true);
115
+ } elseif ($fraudPreventType && $fraudPreventType == 3) {
116
+ $methodSession->setCallbackEmailNovalnetSepa($data->getCallbackEmail());
117
+ }
118
+
119
+ if ($this->getFormValues('nnSepa_oneclick_shopping')
120
+ && !$this->getFormValues('nnSepa_new_form')
121
+ ) {
122
+ $maskedAccountInfo = $this->getMaskedAccountInfo();
123
+ $methodSession->setSepaNewForm(0)
124
+ ->setSepaHash($maskedAccountInfo['pan_hash'])
125
+ ->setSepaUniqueId($this->getUniqueId())
126
+ ->setNnSepaTid($maskedAccountInfo['nn_tid']);
127
+ }
128
+
129
+ $this->helper->getCheckoutSession()->setNnPaymentCode($this->_code);
130
+ }
131
+ return $this;
132
+ }
133
+
134
+ /**
135
+ * Get Novalnet payment redirect URL
136
+ *
137
+ * @param none
138
+ * @return string $actionUrl
139
+ */
140
+ public function getOrderPlaceRedirectUrl()
141
+ {
142
+ return $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_DIRECT_URL); // SEPA payment redirect url
143
+ }
144
+
145
+ /**
146
+ * Get the bank account informations
147
+ *
148
+ * @param string $param
149
+ * @return string
150
+ */
151
+ public function getFormValues($param)
152
+ {
153
+ return Mage::app()->getRequest()->getPost($param);
154
+ }
155
+
156
+ /**
157
+ * Get existing account details
158
+ *
159
+ * @param none
160
+ * @return Varien_Object $paymentValues
161
+ */
162
+ public function getMaskedAccountInfo()
163
+ {
164
+ $paymentValues = '';
165
+ $customerId = $this->helper->getCustomerId(); // Get customer id
166
+
167
+ if ($customerId) {
168
+ // Get Masked Credit Card informations if available for the customer
169
+ $collection = $this->helper->getModel('Mysql4_TransactionStatus')->getCollection()
170
+ ->addFieldToFilter('customer_id', $customerId)
171
+ ->addFieldToFilter('payment_name', $this->_code)
172
+ ->addFieldToFilter('reference_transaction', 0)
173
+ ->addFieldToSelect('novalnet_acc_details');
174
+ $paymentValues = $collection->getLastItem()->hasNovalnetAccDetails()
175
+ ? unserialize(base64_decode($collection->getLastItem()->getNovalnetAccDetails())) : '';
176
+ }
177
+ return $paymentValues;
178
+ }
179
+ }
app/code/community/Novalnet/Payment/Model/{Affiliate.php → Mysql4/AffiliateInfo.php} RENAMED
@@ -1,53 +1,51 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Affiliate extends Mage_Core_Model_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Affiliate
33
- */
34
- public function _construct()
35
- {
36
- parent::_construct();
37
- $this->_init('novalnet_payment/affiliate');
38
- }
39
-
40
- /**
41
- * Load affiliate by custom attribute value. Attribute value should be unique
42
- *
43
- * @param string $attribute
44
- * @param string $value
45
- * @return Novalnet_Payment_Model_Source_Affiliate
46
- */
47
- public function loadByAttribute($attribute, $value)
48
- {
49
- $this->load($value, $attribute);
50
- return $this;
51
- }
52
-
53
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_AffiliateInfo extends Mage_Core_Model_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->_init('novalnet_payment/affiliateInfo');
36
+ }
37
+
38
+ /**
39
+ * Load affiliate by custom attribute value. Attribute value should be unique
40
+ *
41
+ * @param string $attribute
42
+ * @param string $value
43
+ * @return Novalnet_Payment_Model_Mysql4_AffiliateInfo
44
+ */
45
+ public function loadByAttribute($attribute, $value)
46
+ {
47
+ $this->load($value, $attribute);
48
+ return $this;
49
+ }
50
+
51
+ }
 
 
app/code/community/Novalnet/Payment/Model/{Affiliateuser.php → Mysql4/AffiliateUser.php} RENAMED
@@ -1,53 +1,51 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Affiliateuser extends Mage_Core_Model_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Affiliateuser
33
- */
34
- public function _construct()
35
- {
36
- parent::_construct();
37
- $this->_init('novalnet_payment/affiliateuser');
38
- }
39
-
40
- /**
41
- * Load affiliate user information by custom attribute value. Attribute value should be unique
42
- *
43
- * @param string $attribute
44
- * @param string $value
45
- * @return Novalnet_Payment_Model_Source_Affiliateuser
46
- */
47
- public function loadByAttribute($attribute, $value)
48
- {
49
- $this->load($value, $attribute);
50
- return $this;
51
- }
52
-
53
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_AffiliateUser extends Mage_Core_Model_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->_init('novalnet_payment/affiliateUser');
36
+ }
37
+
38
+ /**
39
+ * Load affiliate user information by custom attribute value. Attribute value should be unique
40
+ *
41
+ * @param string $attribute
42
+ * @param string $value
43
+ * @return Novalnet_Payment_Model_Mysql4_AffiliateUser
44
+ */
45
+ public function loadByAttribute($attribute, $value)
46
+ {
47
+ $this->load($value, $attribute);
48
+ return $this;
49
+ }
50
+
51
+ }
 
 
app/code/community/Novalnet/Payment/Model/{Callback.php → Mysql4/Callback.php} RENAMED
@@ -1,64 +1,63 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Callback extends Mage_Core_Model_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Callback
33
- */
34
- public function _construct()
35
- {
36
- parent::_construct();
37
- $this->_init('novalnet_payment/callback');
38
- }
39
-
40
- /**
41
- * Load callback details by custom attribute value. Attribute value should be unique
42
- *
43
- * @param string $attribute
44
- * @param string $value
45
- * @return Novalnet_Payment_Model_Callback
46
- */
47
- public function loadByAttribute($attribute, $value)
48
- {
49
- $this->load($value, $attribute);
50
- return $this;
51
- }
52
-
53
- /**
54
- * Load order callback status by order id
55
- *
56
- * @param $orderId
57
- * @return Novalnet_Payment_Model_Callback
58
- */
59
- public function loadLogByOrderId($orderId)
60
- {
61
- $this->load($orderId, 'order_id');
62
- return $this;
63
- }
64
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Callback extends Mage_Core_Model_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->_init('novalnet_payment/callback');
36
+ }
37
+
38
+ /**
39
+ * Load callback details by custom attribute value. Attribute value should be unique
40
+ *
41
+ * @param string $attribute
42
+ * @param string $value
43
+ * @return Novalnet_Payment_Model_Mysql4_Callback
44
+ */
45
+ public function loadByAttribute($attribute, $value)
46
+ {
47
+ $this->load($value, $attribute);
48
+ return $this;
49
+ }
50
+
51
+ /**
52
+ * Load order callback status by order id
53
+ *
54
+ * @param $orderId
55
+ * @return Novalnet_Payment_Model_Mysql4_Callback
56
+ */
57
+ public function loadLogByOrderId($orderId)
58
+ {
59
+ $this->load($orderId, 'order_id');
60
+ return $this;
61
+ }
62
+
63
+ }
 
app/code/community/Novalnet/Payment/Model/Mysql4/Recurring.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Recurring extends Mage_Core_Model_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->_init('novalnet_payment/recurring');
36
+ }
37
+
38
+ /**
39
+ * Get recurring profile increment id
40
+ *
41
+ * @param Varien_Object $profile
42
+ * @return int $incrementId
43
+ */
44
+ public function getRecurringOrderNo($profile)
45
+ {
46
+ $incrementId = array();
47
+ $recurringCollection = Mage::getResourceModel('sales/order_grid_collection')
48
+ ->addRecurringProfilesFilter($profile->getId());
49
+ foreach ($recurringCollection as $profileValue) {
50
+ $incrementId[] = $profileValue->getIncrementId();
51
+ }
52
+ return $incrementId;
53
+ }
54
+
55
+ /**
56
+ * Get sales order
57
+ *
58
+ * @param int $incrementId
59
+ * @return Varien_Object $order
60
+ */
61
+ public function getOrderByIncrementId($incrementId)
62
+ {
63
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
64
+ return $order;
65
+ }
66
+
67
+ }
app/code/community/Novalnet/Payment/Model/{Resource/Recurring/Collection.php → Mysql4/Resource/AffiliateInfo.php} RENAMED
@@ -1,33 +1,37 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Recurring_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
- {
28
-
29
- public function _construct()
30
- {
31
- $this->_init('novalnet_payment/recurring');
32
- }
33
- }
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_AffiliateInfo extends Mage_Core_Model_Mysql4_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->_init('novalnet_payment/affiliate_info', 'id');
35
+ }
36
+
37
+ }
app/code/community/Novalnet/Payment/Model/Mysql4/Resource/AffiliateInfo/Collection.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_AffiliateInfo_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
+ {
28
+ /**
29
+ * Constructor
30
+ */
31
+ public function _construct()
32
+ {
33
+ $this->_init('novalnet_payment/mysql4_affiliateInfo');
34
+ }
35
+
36
+ }
app/code/community/Novalnet/Payment/Model/{Resource/Affiliate/Collection.php → Mysql4/Resource/AffiliateUser.php} RENAMED
@@ -1,34 +1,38 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Affiliate_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
- {
28
-
29
- public function _construct()
30
- {
31
- $this->_init('novalnet_payment/affiliate');
32
- }
33
-
34
- }
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * Part of the payment module of Novalnet AG
17
+ * https://www.novalnet.de
18
+ * If you have found this script useful a small
19
+ * recommendation as well as a comment on merchant form
20
+ * would be greatly appreciated.
21
+ *
22
+ * @category Novalnet
23
+ * @package Novalnet_Payment
24
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+ class Novalnet_Payment_Model_Mysql4_Resource_AffiliateUser extends Mage_Core_Model_Mysql4_Abstract
28
+ {
29
+
30
+ /**
31
+ * Constructor
32
+ */
33
+ public function _construct()
34
+ {
35
+ $this->_init('novalnet_payment/affiliate_user', 'id');
36
+ }
37
+
38
+ }
app/code/community/Novalnet/Payment/Model/Mysql4/Resource/AffiliateUser/Collection.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_AffiliateUser_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
+ {
28
+ /**
29
+ * Constructor
30
+ */
31
+ public function _construct()
32
+ {
33
+ $this->_init('novalnet_payment/mysql4_affiliateUser');
34
+ }
35
+
36
+ }
app/code/community/Novalnet/Payment/Model/{Resource/Callback/Collection.php → Mysql4/Resource/Callback.php} RENAMED
@@ -1,33 +1,37 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Callback_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
- {
28
-
29
- public function _construct()
30
- {
31
- $this->_init('novalnet_payment/callback');
32
- }
33
- }
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_Callback extends Mage_Core_Model_Mysql4_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->_init('novalnet_payment/callback', 'id');
35
+ }
36
+
37
+ }
app/code/community/Novalnet/Payment/Model/{Resource/Affiliateuser → Mysql4/Resource/Callback}/Collection.php RENAMED
@@ -1,34 +1,37 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Affiliateuser_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
- {
28
-
29
- public function _construct()
30
- {
31
- $this->_init('novalnet_payment/affiliateuser');
32
- }
33
-
34
- }
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * Part of the payment module of Novalnet AG
17
+ * https://www.novalnet.de
18
+ * If you have found this script useful a small
19
+ * recommendation as well as a comment on merchant form
20
+ * would be greatly appreciated.
21
+ *
22
+ * @category Novalnet
23
+ * @package Novalnet_Payment
24
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+ class Novalnet_Payment_Model_Mysql4_Resource_Callback_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
28
+ {
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->_init('novalnet_payment/mysql4_callback');
35
+ }
36
+
37
+ }
app/code/community/Novalnet/Payment/Model/{Resource/Separefill/Collection.php → Mysql4/Resource/Recurring.php} RENAMED
@@ -1,33 +1,37 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Separefill_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
- {
28
-
29
- public function _construct()
30
- {
31
- $this->_init('novalnet_payment/separefill');
32
- }
33
- }
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_Recurring extends Mage_Core_Model_Mysql4_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->_init('novalnet_payment/recurring', 'id');
35
+ }
36
+
37
+ }
app/code/community/Novalnet/Payment/Model/{Resource/Amountchanged → Mysql4/Resource/Recurring}/Collection.php RENAMED
@@ -1,33 +1,36 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Amountchanged_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
- {
28
-
29
- public function _construct()
30
- {
31
- $this->_init('novalnet_payment/amountchanged');
32
- }
33
- }
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_Recurring_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
+ {
28
+ /**
29
+ * Constructor
30
+ */
31
+ public function _construct()
32
+ {
33
+ $this->_init('novalnet_payment/mysql4_recurring');
34
+ }
35
+
36
+ }
app/code/community/Novalnet/Payment/Model/Mysql4/Resource/TransactionStatus.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_TransactionStatus extends Mage_Core_Model_Mysql4_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->_init('novalnet_payment/transaction_status', 'nn_txn_id');
35
+ }
36
+
37
+ }
app/code/community/Novalnet/Payment/Model/{Resource/Transactionoverview → Mysql4/Resource/TransactionStatus}/Collection.php RENAMED
@@ -1,44 +1,48 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Transactionoverview_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
- {
28
-
29
- public function _construct()
30
- {
31
- $this->_init('novalnet_payment/transactionoverview');
32
- }
33
-
34
- /**
35
- * Get order by using increment id
36
- *
37
- * @param Mage_Sales_Model_Order $order
38
- * @return void
39
- */
40
- public function getByOrder(Mage_Sales_Model_Order $order)
41
- {
42
- $this->addFieldToFilter('order_id', $order->getIncrementId());
43
- }
44
- }
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_TransactionStatus_Collection
27
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
28
+ {
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->_init('novalnet_payment/mysql4_transactionStatus');
35
+ }
36
+
37
+ /**
38
+ * Get order by using increment id
39
+ *
40
+ * @param Mage_Sales_Model_Order $order
41
+ * @return none
42
+ */
43
+ public function getByOrder(Mage_Sales_Model_Order $order)
44
+ {
45
+ $this->addFieldToFilter('order_id', $order->getIncrementId());
46
+ }
47
+
48
+ }
app/code/community/Novalnet/Payment/Model/Mysql4/Resource/TransactionTraces.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_TransactionTraces extends Mage_Core_Model_Mysql4_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->_init('novalnet_payment/transaction_traces', 'nn_log_id');
35
+ }
36
+
37
+ }
app/code/community/Novalnet/Payment/Model/{Resource/Transactionstatus → Mysql4/Resource/TransactionTraces}/Collection.php RENAMED
@@ -1,44 +1,48 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Transactionstatus_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
27
- {
28
-
29
- public function _construct()
30
- {
31
- $this->_init('novalnet_payment/transactionstatus');
32
- }
33
-
34
- /**
35
- * Get order by using increment id
36
- *
37
- * @param Mage_Sales_Model_Order $order
38
- * @return void
39
- */
40
- public function getByOrder(Mage_Sales_Model_Order $order)
41
- {
42
- $this->addFieldToFilter('order_id', $order->getIncrementId());
43
- }
44
- }
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_Resource_TransactionTraces_Collection
27
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
28
+ {
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ $this->_init('novalnet_payment/mysql4_transactionTraces');
35
+ }
36
+
37
+ /**
38
+ * Get order by using increment id
39
+ *
40
+ * @param Mage_Sales_Model_Order $order
41
+ * @return none
42
+ */
43
+ public function getByOrder(Mage_Sales_Model_Order $order)
44
+ {
45
+ $this->addFieldToFilter('order_id', $order->getIncrementId());
46
+ }
47
+
48
+ }
app/code/community/Novalnet/Payment/Model/{Transactionstatus.php → Mysql4/TransactionStatus.php} RENAMED
@@ -1,65 +1,66 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Transactionstatus extends Mage_Core_Model_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Transactionstatus
33
- */
34
- public function _construct()
35
- {
36
- parent::_construct();
37
- $this->_init('novalnet_payment/transactionstatus');
38
- }
39
-
40
- /**
41
- * Load order transaction status by custom attribute value. Attribute value should be unique
42
- *
43
- * @param string $attribute
44
- * @param string $value
45
- * @return Novalnet_Payment_Model_Source_Transactionstatus
46
- */
47
- public function loadByAttribute($attribute, $value)
48
- {
49
- $this->load($value, $attribute);
50
- return $this;
51
- }
52
-
53
- /**
54
- * Load order transaction status by transaction id
55
- *
56
- * @param mixed $transactionStatus
57
- * @return Novalnet_Payment_Model_Transactionstatus
58
- */
59
- public function loadByTransactionStatusId(Novalnet_Payment_Model_Transactionstatus $transactionStatus)
60
- {
61
- $this->load($transactionStatus->getNnTxnId(), 'nn_txn_id');
62
- return $this;
63
- }
64
-
65
- }
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_TransactionStatus extends Mage_Core_Model_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ *
32
+ * @see lib/Varien/Varien_Object#_construct()
33
+ * @return Novalnet_Payment_Model_Mysql4_TransactionStatus
34
+ */
35
+ public function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_init('novalnet_payment/transactionStatus');
39
+ }
40
+
41
+ /**
42
+ * Load order transaction status by custom attribute value. Attribute value should be unique
43
+ *
44
+ * @param string $attribute
45
+ * @param string $value
46
+ * @return Novalnet_Payment_Model_Mysql4_TransactionStatus
47
+ */
48
+ public function loadByAttribute($attribute, $value)
49
+ {
50
+ $this->load($value, $attribute);
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * Load order transaction status by transaction id
56
+ *
57
+ * @param mixed $transactionStatus
58
+ * @return Novalnet_Payment_Model_Mysql4_TransactionStatus
59
+ */
60
+ public function loadByTransactionStatusId(Novalnet_Payment_Model_Mysql4_TransactionStatus $transactionStatus)
61
+ {
62
+ $this->load($transactionStatus->getNnTxnId(), 'nn_txn_id');
63
+ return $this;
64
+ }
65
+
66
+ }
app/code/community/Novalnet/Payment/Model/{Transactionoverview.php → Mysql4/TransactionTraces.php} RENAMED
@@ -1,64 +1,63 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Transactionoverview extends Mage_Core_Model_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Transactionoverview
33
- */
34
- public function _construct()
35
- {
36
- parent::_construct();
37
- $this->_init('novalnet_payment/transactionoverview');
38
- }
39
-
40
- /**
41
- * Load order transaction log by custom attribute value. Attribute value should be unique
42
- *
43
- * @param string $attribute
44
- * @param string $value
45
- * @return Novalnet_Payment_Model_Source_Transactionoverview
46
- */
47
- public function loadByAttribute($attribute, $value)
48
- {
49
- $this->load($value, $attribute);
50
- return $this;
51
- }
52
-
53
- /**
54
- * Load order transaction status by log id
55
- *
56
- * @param mixed $orderLog
57
- * @return Novalnet_Payment_Model_Transactionoverview
58
- */
59
- public function loadByOrderLogId(Novalnet_Payment_Model_Transactionoverview $orderLog)
60
- {
61
- $this->load($orderLog->getNnLogId(), 'nn_log_id');
62
- return $this;
63
- }
64
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Mysql4_TransactionTraces extends Mage_Core_Model_Abstract
27
+ {
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->_init('novalnet_payment/transactionTraces');
36
+ }
37
+
38
+ /**
39
+ * Load order transaction traces by custom attribute value. Attribute value should be unique
40
+ *
41
+ * @param string $attribute
42
+ * @param string $value
43
+ * @return Novalnet_Payment_Model_Mysql4_TransactionTraces
44
+ */
45
+ public function loadByAttribute($attribute, $value)
46
+ {
47
+ $this->load($value, $attribute);
48
+ return $this;
49
+ }
50
+
51
+ /**
52
+ * Load order transaction traces by log id
53
+ *
54
+ * @param mixed $orderLog
55
+ * @return Novalnet_Payment_Model_Mysql4_TransactionTraces
56
+ */
57
+ public function loadByOrderLogId(Novalnet_Payment_Model_Mysql4_TransactionTraces $orderLog)
58
+ {
59
+ $this->load($orderLog->getNnLogId(), 'nn_log_id');
60
+ return $this;
61
+ }
62
+
63
+ }
 
app/code/community/Novalnet/Payment/Model/Novalnet/Request.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Novalnet_Request extends Varien_Object
27
- {
28
- public function toLatin1()
29
- {
30
- $data = $this->toArray();
31
- foreach ($data as $key => $val) {
32
- $setKey = "set" . ucfirst($key);
33
- $this->$setKey(utf8_decode($val));
34
- }
35
- }
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Observer.php DELETED
@@ -1,175 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Observer
27
- {
28
- /**
29
- * Send order invoice mail
30
- *
31
- * @param varien_object $observer
32
- * @return Novalnet_Payment_Model_Observer
33
- */
34
- public function sendInvoiceEmail($observer)
35
- {
36
- try {
37
- /* @var $order Magento_Sales_Model_Order_Invoice */
38
- $invoice = $observer->getEvent()->getInvoice();
39
- if(Mage::app()->getStore()->isAdmin()){
40
- $this->onHoldOrderStatus($invoice);
41
- }
42
- $invoice->save();
43
- $invoice->sendEmail($invoice);
44
- } catch (Mage_Core_Exception $e) {
45
- Mage::log($e->getMessage());
46
- }
47
-
48
- return $this;
49
- }
50
-
51
- /**
52
- * Send order creditmemo mail
53
- *
54
- * @param varien_object $observer
55
- * @return Novalnet_Payment_Model_Observer
56
- */
57
- public function sendCreditmemoEmail($observer)
58
- {
59
- try {
60
- /* @var $order Magento_Sales_Model_Order_Creditmemo */
61
- $refund = $observer->getEvent()->getCreditmemo();
62
- $refund->save();
63
- $refund->sendEmail($refund);
64
- } catch (Mage_Core_Exception $e) {
65
- Mage::logException($e->getMessage());
66
- }
67
-
68
- return $this;
69
- }
70
-
71
- /**
72
- * Load novalnet script files while prpareing layout
73
- *
74
- * @param varien_object $observer
75
- * @return Novalnet_Payment_Model_Observer
76
- */
77
- public function prepareLayoutBefore(Varien_Event_Observer $observer)
78
- {
79
- $nnAffId = Mage::app()->getRequest()->getParam('nn_aff_id');
80
- if ($nnAffId) {
81
- Mage::getSingleton('core/session')->setNnAffId(trim($nnAffId));
82
- }
83
- /* @var $block Mage_Page_Block_Html_Head */
84
- if (!Mage::app()->getStore()->isCurrentlySecure()) {
85
- $baseurl = Mage::getBaseUrl();
86
- } else {
87
- $baseurl = Mage::getUrl('', array('_secure' => true));
88
- }
89
- $currentUrl = Mage::helper('core/url')->getCurrentUrl();
90
- $block = $observer->getEvent()->getBlock();
91
- if ("head" == $block->getNameInLayout() && $currentUrl != $baseurl) {
92
- foreach (Mage::helper('novalnet_payment/AssignData')->getFiles() as $file) {
93
- $block->addJs(Mage::helper('novalnet_payment/AssignData')->getJQueryPath($file));
94
- }
95
- }
96
-
97
- return $this;
98
- }
99
-
100
- /**
101
- * Set customer login session
102
- *
103
- * @param varien_object $observer
104
- * @return Novalnet_Payment_Model_Observer
105
- */
106
- public function customerLogin($observer)
107
- {
108
- $customer = $observer->getCustomer();
109
- Mage::getSingleton('core/session')->setGuestloginvalue('');
110
- return;
111
- }
112
-
113
- /**
114
- * Set onhold status for Novalnet payments
115
- *
116
- * @param varien_object $invoice
117
- */
118
- private function onHoldOrderStatus($invoice)
119
- {
120
- $order = $invoice->getOrder();
121
- $storeId = $order->getStoreId();
122
- $payment = $order->getPayment();
123
- $paymentObj = $payment->getMethodInstance();
124
- $paymentCode = $paymentObj->getCode();
125
- if (preg_match("/novalnet/i", $paymentCode)) {
126
- $setOrderAfterStatus = $paymentObj->getNovalnetConfig('order_status',true,$storeId);
127
- $setOrderAfterStatus = $setOrderAfterStatus ? $setOrderAfterStatus : Mage_Sales_Model_Order::STATE_PROCESSING;
128
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $setOrderAfterStatus, Mage::helper('novalnet_payment')->__('Invoice Created Successfully'), true)->save();
129
- }
130
- }
131
-
132
- /**
133
- * Get recurring product custom option values
134
- *
135
- * @param null
136
- * @return null
137
- */
138
- public function getProfilePeriodValues(Varien_Event_Observer $observer) {
139
- $quote = $observer->getEvent()->getCart()->getQuote();
140
-
141
- foreach($quote->getAllItems() as $items) {
142
- if($items->getProduct()->isRecurring()) {
143
- $recurringProfile = $items->getProduct()->getRecurringProfile();
144
- $profileInfo = array('period_unit' => $recurringProfile['period_unit'],
145
- 'period_frequency' => $recurringProfile['period_frequency']);
146
- Mage::getSingleton('checkout/session')->setNnPeriodUnit($recurringProfile['period_unit'])
147
- ->setNnPeriodFrequency($recurringProfile['period_frequency']);
148
- }
149
- }
150
- }
151
-
152
- /**
153
- * Update redirect url for paypal recurring product
154
- *
155
- * @param null
156
- * @return null
157
- */
158
- public function updateRecurringUrl(Varien_Event_Observer $observer)
159
- {
160
- $quote = $observer->getEvent()->getQuote();
161
- $paymentCode = $quote->getPayment()->getMethodInstance()->getCode();
162
- $helper = Mage::helper('novalnet_payment');
163
- $profile = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
164
- $recurringProfile = (!empty($profile)) ? array_filter($profile) : '';
165
- $subRedirectPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('subscriptionRedirectPayments');
166
- if(!empty($recurringProfile) && in_array($paymentCode, $subRedirectPayments)) {
167
- $orderId = $helper->getCheckoutSession()->getRecurringOrderId();
168
- $actionUrl = ($paymentCode == Novalnet_Payment_Model_Config::NN_CC)
169
- ? $helper->getUrl(Novalnet_Payment_Model_Config::CC_IFRAME_URL)
170
- : $helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
171
- $helper->getCheckoutSession()->setLastRealOrderId($orderId)
172
- ->setRedirectUrl($actionUrl);
173
- }
174
- }
175
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Observer/InvoiceView.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Observer_InvoiceView
27
+ {
28
+
29
+ /**
30
+ * Add buttons to sales order invoice view (single order)
31
+ *
32
+ * @param Varien_Object $observer
33
+ * @return Novalnet_Payment_Model_Observer_OrderView
34
+ */
35
+ public function addButton($observer)
36
+ {
37
+ $block = $observer->getEvent()->getBlock();
38
+
39
+ // Add buttons to sales order view (single order)
40
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Invoice_View) {
41
+ $order = $block->getInvoice()->getOrder(); // Get current order
42
+ $orderPayment = $order->getPayment(); // Get order payment
43
+ $paymentCode = $order->getPayment()->getMethodInstance()->getCode(); // Get payment method code
44
+
45
+ // Allow only for Novalnet payment methods
46
+ if (preg_match("/novalnet/i", $paymentCode)) {
47
+ $block->removeButton('print');
48
+ $block->removeButton('capture');
49
+
50
+ if ($block->getInvoice()->getOrder()->canCreditmemo()) {
51
+ if (($orderPayment->canRefundPartialPerInvoice()
52
+ && $orderPayment->getAmountPaid() > $orderPayment->getAmountRefunded())
53
+ || ($orderPayment->canRefund() && !$block->getInvoice()->getIsUsedForRefund())
54
+ ) {
55
+ $this->getCreditMemoButton($block);
56
+ }
57
+ }
58
+
59
+ if ($block->getInvoice()->getId()) {
60
+ $this->getPrintButton($block);
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Add creditmemo button
68
+ *
69
+ * @param Mage_Adminhtml_Block_Sales_Order_Invoice_View $block
70
+ * @return none
71
+ */
72
+ public function getCreditMemoButton($block)
73
+ {
74
+ $block->addButton(
75
+ 'capture', array(// capture?
76
+ 'label' => Mage::helper('sales')->__('Credit Memo'),
77
+ 'class' => 'go',
78
+ 'onclick' => 'setLocation(\'' . $block->getCreditMemoUrl() . '\')'
79
+ )
80
+ );
81
+ }
82
+
83
+ /**
84
+ * Add print button
85
+ *
86
+ * @param Mage_Adminhtml_Block_Sales_Order_Invoice_View $block
87
+ * @return none
88
+ */
89
+ public function getPrintButton($block)
90
+ {
91
+ $block->addButton(
92
+ 'print', array(
93
+ 'label' => Mage::helper('sales')->__('Print'),
94
+ 'class' => 'save',
95
+ 'onclick' => 'setLocation(\'' . $block->getPrintUrl() . '\')'
96
+ )
97
+ );
98
+ }
99
+
100
+ }
app/code/community/Novalnet/Payment/Model/Observer/LoadScripts.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Observer_LoadScripts
27
+ {
28
+ /**
29
+ * Name library directory.
30
+ */
31
+ const NAME_DIR_JS = 'novalnet/';
32
+
33
+ /**
34
+ * Name library directory.
35
+ */
36
+ const NAME_DIR_CSS = 'css/novalnet/';
37
+
38
+ /**
39
+ * Novalnet script files
40
+ *
41
+ * @return array
42
+ */
43
+ protected $_files = array(
44
+ 'jquery-1.11.3.min.js',
45
+ 'cc.js',
46
+ 'sepa.js'
47
+ );
48
+
49
+ /**
50
+ * Get script file path
51
+ *
52
+ * @param string $file
53
+ * @param string $type
54
+ * @return string
55
+ */
56
+ public function getScriptPath($file, $type = 'Js')
57
+ {
58
+ return $type == 'Js' ? self::NAME_DIR_JS . $file : self::NAME_DIR_CSS . $file;
59
+ }
60
+
61
+ /**
62
+ * Load novalnet script files while preparing layout
63
+ *
64
+ * @param varien_object $observer
65
+ * @return Novalnet_Payment_Model_Observer
66
+ */
67
+ public function loadScriptFiles(Varien_Event_Observer $observer)
68
+ {
69
+ if (!Mage::app()->getStore()->isAdmin()) {
70
+ // Novalnet payment helper
71
+ $helper = Mage::helper('novalnet_payment');
72
+
73
+ // Set affiliate id if exist
74
+ $affiliateId = Mage::app()->getRequest()->getParam('nn_aff_id');
75
+ if ($affiliateId) {
76
+ $helper->getCoreSession()->setAffiliateId(trim($affiliateId));
77
+ }
78
+
79
+ /* $block Mage_Page_Block_Html_Head */
80
+ $baseUrl = $helper->getBaseUrl(); // Get shop base url
81
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl(); // Get shop current url
82
+ $block = $observer->getEvent()->getBlock(); // Get block
83
+
84
+ // Includes necessary Novalnet script files
85
+ if ("head" == $block->getNameInLayout() && $currentUrl != $baseUrl) {
86
+ $block->addCss($this->getScriptPath('novalnet.css', 'Css'));
87
+
88
+ foreach ($this->_files as $file) {
89
+ $block->addJs($this->getScriptPath($file));
90
+ }
91
+ }
92
+ }
93
+
94
+ return $this;
95
+ }
96
+
97
+ }
app/code/community/Novalnet/Payment/Model/Observer/OrderView.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Observer_OrderView
27
+ {
28
+
29
+ /**
30
+ * Add buttons to sales order view (single order)
31
+ *
32
+ * @param Varien_Object $observer
33
+ * @return Novalnet_Payment_Model_Observer_OrderView
34
+ */
35
+ public function addButton($observer)
36
+ {
37
+ $block = $observer->getEvent()->getBlock();
38
+
39
+ // Add buttons to sales order view (single order)
40
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
41
+ $order = $block->getOrder(); // Get current order
42
+ $paymentCode = $order->getPayment()->getMethodInstance()->getCode(); // Get payment method code
43
+
44
+ // allow only for Novalnet payment methods
45
+ if (preg_match("/novalnet/i", $paymentCode)) {
46
+
47
+ $helper = Mage::helper('novalnet_payment'); // Novalnet payment helper
48
+ $additionalData = unserialize($order->getPayment()->getAdditionalData());
49
+ // Get payment Novalnet transaction id
50
+ $transactionId = $helper->makeValidNumber($additionalData['NnTid']);
51
+
52
+ // Get current transaction status information
53
+ $transactionStatus = $helper->getModel('Mysql4_TransactionStatus')
54
+ ->loadByAttribute('transaction_no', $transactionId);
55
+ $paymentStatus = $transactionStatus->getTransactionStatus(); // Get payment original transaction status
56
+ // Get payment transaction amount
57
+ $transactionAmount = (int) str_replace(array('.', ','), '', $transactionStatus->getAmount());
58
+
59
+ if ($paymentStatus) {
60
+ // Rename invoice button for Novalnet payment orders
61
+ $block->updateButton('order_invoice', 'label', $helper->__('Capture'));
62
+ // Removes offline credit memo button in order history
63
+ $block->removeButton('order_creditmemo');
64
+ }
65
+
66
+ // Removes void button for success payment status
67
+ if ($paymentStatus && (!$transactionAmount
68
+ || $paymentStatus == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
69
+ || $paymentStatus == Novalnet_Payment_Model_Config::PAYMENT_VOID_STATUS)
70
+ ) {
71
+ $block->removeButton('void_payment');
72
+ }
73
+
74
+ // Removes order invoice button
75
+ if ($paymentStatus && ($paymentCode == Novalnet_Payment_Model_Config::NN_PAYPAL
76
+ || $paymentStatus == Novalnet_Payment_Model_Config::PAYMENT_VOID_STATUS
77
+ || in_array(
78
+ $paymentCode, array(Novalnet_Payment_Model_Config::NN_INVOICE,
79
+ Novalnet_Payment_Model_Config::NN_PREPAYMENT)
80
+ ) || !$transactionAmount)) {
81
+ $block->removeButton('order_invoice');
82
+ }
83
+
84
+ // Add confirm button for Novalnet invoice payments (Invoice/Prepayment)
85
+ if ($paymentStatus && $paymentStatus == 91) {
86
+ $confirmUrl = $block->getUrl(
87
+ 'adminhtml/novalnetpayment_sales_order/confirm', array('_current'=>true)
88
+ );
89
+ $message = Mage::helper('sales')->__('Are you sure you want to capture the payment?');
90
+ $block->addButton(
91
+ 'novalnet_confirm', array(
92
+ 'label' => Mage::helper('novalnet_payment')->__('Novalnet Capture'),
93
+ 'onclick' => "confirmSetLocation('{$message}', '{$confirmUrl}')",
94
+ )
95
+ );
96
+ }
97
+
98
+ // Add void button
99
+ if ($order->canCancel() && $transactionAmount
100
+ && $paymentStatus < Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
101
+ ) {
102
+ $block->removeButton('void_payment');
103
+ $message = Mage::helper('sales')->__('Are you sure you want to void the payment?');
104
+ $block->addButton(
105
+ 'void_payment', array(
106
+ 'label' => Mage::helper('sales')->__('Void'),
107
+ 'onclick' => "confirmSetLocation('{$message}', '{$block->getVoidPaymentUrl()}')",
108
+ )
109
+ );
110
+ }
111
+ }
112
+ }
113
+ }
114
+
115
+ }
app/code/community/Novalnet/Payment/Model/Observer/Recurring.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Observer_Recurring
27
+ {
28
+
29
+ /**
30
+ * Get recurring product custom option values
31
+ *
32
+ * @param varien_object $observer
33
+ * @return Novalnet_Payment_Model_Observer_Recurring
34
+ */
35
+ public function getProfilePeriodValues(Varien_Event_Observer $observer)
36
+ {
37
+ $quote = $observer->getEvent()->getCart()->getQuote(); // Get quote object
38
+
39
+ foreach ($quote->getAllItems() as $items) {
40
+ if ($items->getProduct()->isRecurring()) {
41
+ $recurringProfile = $items->getProduct()->getRecurringProfile(); // Get profile object
42
+ // Get recurring profile period values
43
+ Mage::getSingleton('checkout/session')->setNnPeriodUnit($recurringProfile['period_unit'])
44
+ ->setNnPeriodFrequency($recurringProfile['period_frequency']);
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Set redirect url for recurring payment (Credit Card PCI)
51
+ *
52
+ * @param varien_object $observer
53
+ * @return Novalnet_Payment_Model_Observer_Recurring
54
+ */
55
+ public function setPaymentRedirectUrl(Varien_Event_Observer $observer)
56
+ {
57
+ $quote = $observer->getEvent()->getQuote(); // Get quote object
58
+ $paymentCode = $quote->getPayment()->getMethodInstance()->getCode(); // Get payment method code
59
+ $helper = Mage::helper('novalnet_payment'); // Novalnet payment helper
60
+ $checkoutSession = $helper->getCheckoutSession(); // Get checkout session
61
+
62
+ // Get recurring profile id
63
+ $profileIds = $checkoutSession->getLastRecurringProfileIds();
64
+ $recurringProfileIds = !empty($profileIds) ? array_filter($profileIds) : '';
65
+ $redirectPayments = array(Novalnet_Payment_Model_Config::NN_CC, Novalnet_Payment_Model_Config::NN_PAYPAL);
66
+
67
+ if (!empty($recurringProfileIds) && in_array($paymentCode, $redirectPayments)) {
68
+ $methodSession = $helper->getMethodSession($paymentCode); // Payment method session
69
+ if ($paymentCode == Novalnet_Payment_Model_Config::NN_CC) {
70
+ $redirectUrl = $methodSession->getNnCcTid()
71
+ ? $helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_DIRECT_URL)
72
+ : ($methodSession->getCcFormType() == 1
73
+ ? $helper->getUrl(Novalnet_Payment_Model_Config::CC_IFRAME_URL)
74
+ : $helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL));
75
+ } elseif ($paymentCode == Novalnet_Payment_Model_Config::NN_PAYPAL) {
76
+ $redirectUrl = $helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
77
+ }
78
+
79
+ $checkoutSession->setLastOrderId($methodSession->getOrderId())
80
+ ->setLastRealOrderId($methodSession->getIncrementId())
81
+ ->setRedirectUrl($redirectUrl);
82
+ }
83
+ }
84
+
85
+ }
app/code/community/Novalnet/Payment/Model/Observer/SalesEmails.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Observer_SalesEmails
27
+ {
28
+ /**
29
+ * Send order mail
30
+ *
31
+ * @param Varien_Object $observer
32
+ * @return Novalnet_Payment_Model_Observer_SalesEmails
33
+ */
34
+ public function sendOrderEmail($observer)
35
+ {
36
+ /* $order Magento_Sales_Model_Order */
37
+ $order = $observer->getEvent()->getOrder();
38
+ if (!$order->getEmailSent() && $order->getId()) {
39
+ try {
40
+ $order->sendNewOrderEmail()
41
+ ->setEmailSent(true)
42
+ ->save();
43
+ } catch (Mage_Core_Exception $e) {
44
+ Mage::log($e->getMessage());
45
+ }
46
+ }
47
+
48
+ return $this;
49
+ }
50
+
51
+ /**
52
+ * Send order invoice mail
53
+ *
54
+ * @param Varien_Object $observer
55
+ * @return Novalnet_Payment_Model_Observer_SalesEmails
56
+ */
57
+ public function sendInvoiceEmail($observer)
58
+ {
59
+ try {
60
+ /* $order Magento_Sales_Model_Order_Invoice */
61
+ $invoice = $observer->getEvent()->getInvoice();
62
+ // Get payment method code
63
+ $paymentCode = $invoice->getOrder()->getPayment()->getMethodInstance()->getCode();
64
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl();
65
+ // Set capture status for Novalnet payments
66
+ if (Mage::app()->getStore()->isAdmin()
67
+ && !preg_match("/sales_order_create/i", $currentUrl)
68
+ ) {
69
+ $this->setCaptureOrderStatus($invoice->getOrder(), $paymentCode);
70
+ }
71
+ // Set order invoice status as pending for Novalnet invoice payment
72
+ if ($paymentCode == Novalnet_Payment_Model_Config::NN_INVOICE
73
+ && !Mage::app()->getRequest()->getParam('tid_payment')
74
+ ) {
75
+ $invoice->setState(1);
76
+ }
77
+ $invoice->save();
78
+ $invoice->sendEmail($invoice);
79
+ } catch (Mage_Core_Exception $e) {
80
+ Mage::log($e->getMessage());
81
+ }
82
+
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Send order creditmemo mail
88
+ *
89
+ * @param Varien_Object $observer
90
+ * @return Novalnet_Payment_Model_Observer_SalesEmails
91
+ */
92
+ public function sendCreditmemoEmail($observer)
93
+ {
94
+ try {
95
+ /* $order Magento_Sales_Model_Order_Creditmemo */
96
+ $refund = $observer->getEvent()->getCreditmemo();
97
+ $refund->save();
98
+ $refund->sendEmail($refund);
99
+ } catch (Mage_Core_Exception $e) {
100
+ Mage::logException($e->getMessage());
101
+ }
102
+
103
+ return $this;
104
+ }
105
+
106
+ /**
107
+ * Set canceled/VOID status for Novalnet payments
108
+ *
109
+ * @param Varien_Object $observer
110
+ * @param none
111
+ */
112
+ public function setVoidOrderStatus($observer)
113
+ {
114
+ /* $order Magento_Sales_Model_Order */
115
+ $payment = $observer->getEvent()->getPayment();
116
+ $order = $payment->getOrder(); // Get order object
117
+
118
+ if (preg_match("/novalnet/i", $payment->getMethodInstance()->getCode())) {
119
+ $voidOrderStatus = Mage::getStoreConfig(
120
+ 'novalnet_global/order_status_mapping/void_status', $order->getStoreId()
121
+ )
122
+ ? Mage::getStoreConfig(
123
+ 'novalnet_global/order_status_mapping/void_status', $order->getStoreId()
124
+ )
125
+ : Mage_Sales_Model_Order::STATE_CANCELED;
126
+ $order->setState(
127
+ Mage_Sales_Model_Order::STATE_PROCESSING,
128
+ $voidOrderStatus,
129
+ Mage::helper('novalnet_payment')->__('Order was canceled'),
130
+ true
131
+ )->save();
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Set capture status for Novalnet payments
137
+ *
138
+ * @param Varien_Object $order
139
+ * @param none
140
+ */
141
+ protected function setCaptureOrderStatus($order, $paymentCode)
142
+ {
143
+ if (preg_match("/novalnet/i", $paymentCode)) {
144
+ $captureOrderStatus = Mage::getStoreConfig(
145
+ 'novalnet_global/order_status_mapping/order_status', $order->getStoreId()
146
+ )
147
+ ? Mage::getStoreConfig(
148
+ 'novalnet_global/order_status_mapping/order_status', $order->getStoreId()
149
+ )
150
+ : Mage_Sales_Model_Order::STATE_PROCESSING;
151
+ $order->setState(
152
+ Mage_Sales_Model_Order::STATE_PROCESSING,
153
+ $captureOrderStatus,
154
+ Mage::helper('novalnet_payment')->__('The transaction has been confirmed'),
155
+ true
156
+ )->save();
157
+ }
158
+ }
159
+
160
+ }
app/code/community/Novalnet/Payment/Model/Payment/Method/Abstract.php DELETED
@@ -1,1910 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Payment_Method_Abstract extends Mage_Payment_Model_Method_Abstract
27
- implements Mage_Payment_Model_Recurring_Profile_MethodInterface
28
- {
29
- /**
30
- * Payment Method features
31
- * @var bool
32
- */
33
- protected $_isGateway = false;
34
- protected $_canOrder = false;
35
- protected $_canCapturePartial = false;
36
- protected $_canRefund = true;
37
- protected $_canRefundInvoicePartial = true;
38
- protected $_canVoid = true;
39
- protected $_canUseCheckout = true;
40
- protected $_canSaveCc = false;
41
- protected $_isInitializeNeeded = false;
42
- protected $_canManageRecurringProfiles = true;
43
-
44
- /**
45
- * TODO: whether a captured transaction may be voided by this gateway
46
- * This may happen when amount is captured, but not settled
47
- * @var bool
48
- */
49
- protected $_canCancelInvoice = false;
50
-
51
- var $infoInstance;
52
- var $helper;
53
- var $dataHelper;
54
-
55
- /**
56
- * Load Basic Params in constructor
57
- *
58
- * @return
59
- */
60
- public function __construct()
61
- {
62
- //Novalnet Basic parameters
63
- $this->assignUtilities();
64
- $this->_vendorId = $this->getNovalnetConfig('merchant_id', true);
65
- $this->_authcode = $this->getNovalnetConfig('auth_code', true);
66
- $this->_productId = $this->getNovalnetConfig('product_id', true);
67
- $this->_tariffId = $this->getNovalnetConfig('tariff_id', true);
68
- $this->_subscribTariffId = $this->getNovalnetConfig('subscrib_tariff_id', true);
69
- $this->_referrerId = trim($this->getNovalnetConfig('referrer_id', true));
70
- //Manual Check Limits
71
- $this->_manualCheckLimit = (int) $this->getNovalnetConfig('manual_checking_amount',true);
72
- }
73
-
74
- /**
75
- * Hide the payment method in checkout (without recurring products)
76
- *
77
- * @return boolean
78
- */
79
- public function canUseCheckout() {
80
- $quote = Mage::getModel('checkout/cart')->getQuote();
81
- $redirectPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
82
- unset($redirectPayment[0]);
83
- if (!empty($quote) && $quote->hasNominalItems()
84
- && (in_array($this->_code, $redirectPayment)
85
- || $this->helper->checkIsAdmin())) {
86
- return false;
87
- }
88
- return true;
89
- }
90
-
91
- /**
92
- * Validate recurring profile data
93
- *
94
- * @param Mage_Payment_Model_Recurring_Profile $profile
95
- * @return boolean
96
- */
97
- public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
98
- {
99
- return true;
100
- }
101
-
102
- /**
103
- * Submit recurring profile to the gateway
104
- *
105
- * @param Mage_Payment_Model_Recurring_Profile $profile
106
- * @param Mage_Payment_Model_Info $paymentInfo
107
- */
108
- public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo)
109
- {
110
- if ($profile->getTrialPeriodUnit() && $profile->getTrialPeriodFrequency()) {
111
- $this->showException($this->helper->__('Trial Billing Cycles are not support novalnet payment'), false);
112
- }
113
- $this->helper->getModelRecurring()->getProfileProgress($profile);
114
- }
115
-
116
- /**
117
- * Fetch recurring profile details
118
- *
119
- * @param string $referenceId
120
- * @param Varien_Object $result
121
- * @return boolean
122
- */
123
- public function getRecurringProfileDetails($referenceId, Varien_Object $result)
124
- {
125
- return true;
126
- }
127
-
128
- /**
129
- * Whether can get recurring profile details
130
- *
131
- * @return boolean
132
- */
133
- public function canGetRecurringProfileDetails()
134
- {
135
- return true;
136
- }
137
-
138
- /**
139
- * Update recurring profile data
140
- *
141
- * @param Mage_Payment_Model_Recurring_Profile $profile
142
- * @return boolean
143
- */
144
- public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
145
- {
146
- return true;
147
- }
148
-
149
- /**
150
- * Manage status
151
- *
152
- * @param Mage_Payment_Model_Recurring_Profile $profile
153
- */
154
- public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
155
- {
156
- $helper = $this->helper;
157
- $recuring = $helper->getModelRecurring();
158
- $orderNo = $recuring->getRecurringOrderNo($profile);
159
- $order = $recuring->getOrderByIncrementId($orderNo[0]);
160
- $payment = $order->getPayment();
161
- $paymentObj = $payment->getMethodInstance();
162
- $subsId = $payment->getAdditionalInformation('subs_id');
163
- $customerId = $order->getCustomerId();
164
- $orderItems = $order->getAllItems();
165
- $nominalItem = $helper->checkNominalItem($orderItems);
166
- $getRequest = Mage::app()->getRequest()->getQuery();
167
- $storeId = $helper->getMagentoStoreId();
168
-
169
- if ($profile->getNewState() == 'canceled') {
170
- $request = new Varien_Object();
171
- $paymentObj->assignOrderBasicParams($request, $payment, $storeId, $nominalItem);
172
- $request->setNnLang(strtoupper($helper->getDefaultLanguage()))
173
- ->setCancelSub(1)
174
- ->setCancelReason($getRequest['reason'])
175
- ->setTid($profile->getReferenceId());
176
- $buildNovalnetParam = http_build_query($request->getData());
177
- $recurringCancelUrl = $helper->getPayportUrl('paygate');
178
- $response = $this->dataHelper->setRawCallRequest($buildNovalnetParam, $recurringCancelUrl, $paymentObj);
179
- $data = unserialize($payment->getAdditionalData());
180
- $data['subsCancelReason'] = $getRequest['reason'];
181
- $payment->setAdditionalData(serialize($data))->save();
182
- $this->logNovalnetTransactionData($request, $response, $profile->getReferenceId(), $customerId, $storeId, $orderNo[0]);
183
- if ($response->getStatus() != Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
184
- $this->showException($response->getStatusDesc(), false);
185
- }
186
- } elseif ($profile->getNewState() == 'suspended' || $profile->getNewState() == 'active') {
187
- $this->infoRequestxml($profile->getNewState(), $profile, $subsId, $storeId, $customerId, $orderNo[0], $payment);
188
- }
189
- }
190
-
191
- /**
192
- * Recurring profile Suspend or Activate
193
- *
194
- * @param string $action
195
- * @param Mage_Payment_Model_Recurring_Profile $profile
196
- * @param int $subsId
197
- * @param int $storeId
198
- * @param int $customerId
199
- * @param int $orderNo
200
- * @param varien_object $payment
201
- * @return null
202
- */
203
- private function infoRequestxml($action, $profile, $subsId, $storeId, $customerId, $orderNo, $payment)
204
- {
205
- if ($action == 'suspended') {
206
- $pausePeriod = 1;
207
- $pausePeriodUnit = 'd';
208
- $suspend = 1;
209
- $subsIdRequest = $subsId;
210
- } else {
211
- $periodInfo = $this->getPeriodValues($profile);
212
- $pausePeriod = $periodInfo['periodFrequency'];
213
- $pausePeriodUnit = $periodInfo['periodUnit'];
214
- $suspend = 0;
215
- $subsIdRequest = $subsId;
216
- $subsId = NULL;
217
- }
218
-
219
- if ($payment) {
220
- $this->assignVendorConfig($payment);
221
- }
222
-
223
- $request = '<?xml version="1.0" encoding="UTF-8"?>';
224
- $request .= '<nnxml><info_request>';
225
- $request .= '<vendor_id>' . $this->_vendorId . '</vendor_id>';
226
- $request .= '<vendor_authcode>' . $this->_authcode . '</vendor_authcode>';
227
- $request .= '<request_type>' . Novalnet_Payment_Model_Config::SUBS_PAUSE . '</request_type>';
228
- $request .= '<product_id>' . $this->_productId . '</product_id>';
229
- $request .= '<tid>' . $profile->getReferenceId() . '</tid>';
230
- $request .= '<subs_id>' . $subsIdRequest . '</subs_id>';
231
- $request .= '<pause_period>' . $pausePeriod . '</pause_period>';
232
- $request .= '<pause_time_unit>' . $pausePeriodUnit . '</pause_time_unit>';
233
- $request .= '<suspend>' . $suspend . '</suspend>';
234
- $request .= '</info_request></nnxml>';
235
-
236
- $infoRequestUrl = $this->helper->getPayportUrl('infoport');
237
- $result = $this->setNovalnetRequestCall($request, $infoRequestUrl, 'XML');
238
- $xml = simplexml_load_string($request);
239
- $json = json_encode($xml);
240
- $array = json_decode($json, TRUE);
241
- $request = new Varien_Object($array['info_request']);
242
- $this->logNovalnetTransactionData($request, $result, $profile->getReferenceId(), $customerId, $storeId, $orderNo, $subsId);
243
- if ($result->getStatus() != Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
244
- $statusDesc = $result->getStatusDesc();
245
- if ($action == 'suspended') {
246
- $statusDesc = $result->getSubscriptionPause();
247
- $statusDesc = $statusDesc['status_message'];
248
- }
249
- $this->showException($statusDesc, false);
250
- }
251
- }
252
-
253
- /**
254
- * Get subscription period frequency and unit
255
- *
256
- * @param Mage_Payment_Model_Recurring_Profile $profile
257
- * @return array
258
- */
259
- public function getPeriodValues($profile) {
260
- $periodFrequency = $profile->getperiodFrequency();
261
- $periodUnit = $this->helper->__(ucfirst($profile->getperiodUnit()));
262
- $day = $this->helper->__('Day');
263
- $month = $this->helper->__('Month');
264
- $year = $this->helper->__('Year');
265
- $periodUnitFormat = array($day => "d", $month => "m", $year => "y");
266
-
267
- if ($periodUnit == 'Semi_month') {
268
- $tariffPeriod = array('periodFrequency' => '14', 'periodUnit' => 'd');
269
- } elseif ($periodUnit == 'Week') {
270
- $tariffPeriod = array('periodFrequency' => ($periodFrequency * 7), 'periodUnit' => 'd');
271
- } else {
272
- $tariffPeriod = array('periodFrequency' => $periodFrequency, 'periodUnit' => $periodUnitFormat[$periodUnit]);
273
- }
274
-
275
- return $tariffPeriod;
276
- }
277
-
278
- /**
279
- * Check whether payment method can be used
280
- *
281
- * @param Mage_Sales_Model_Quote
282
- * @return boolean
283
- */
284
- public function isAvailable($quote = null)
285
- {
286
- $getNnDisableTime = "getNnDisableTime" . ucfirst($this->_code); //Dynamic Getter based on payment methods
287
- $helper = $this->helper;
288
-
289
- if ($helper->checkOrdersCount($this->getNovalnetConfig('orderscount'))) {
290
- return false;
291
- } elseif (!$helper->checkCustomerAccess($this->getNovalnetConfig('user_group_excluded'))) {
292
- return false;
293
- } elseif (!empty($quote) && !$quote->hasNominalItems()
294
- && !$helper->isModuleActive($quote->getGrandTotal())) {
295
- return false;
296
- } elseif (!empty($quote) && $quote->hasNominalItems()
297
- && $this->helper->checkIsAdmin()) {
298
- return false;
299
- } elseif (time() < $this->_getCheckout()->$getNnDisableTime()) {
300
- return false;
301
- }
302
-
303
- $this->paymentRefillValidate();
304
- // Assign affiliate account information if available.
305
- $this->loadAffAccDetail();
306
- return parent::isAvailable($quote);
307
- }
308
-
309
- /**
310
- * Assign form data in quote instance
311
- *
312
- * @param array $data
313
- * @return Mage_Payment_Model_Abstract Object
314
- */
315
- public function assignData($data)
316
- {
317
- $infoInstance = $this->_getInfoInstance();
318
- // unset form method session
319
- $prevPaymentCode = $this->_getCheckout()->getNnPaymentCode();
320
- if ($prevPaymentCode && $this->_code != $prevPaymentCode) {
321
- $this->unsetFormMethodSession();
322
- $this->unsetMethodSession($prevPaymentCode);
323
- }
324
-
325
- $this->dataHelper->assignNovalnetData($this->_code, $data, $infoInstance);
326
- return $this;
327
- }
328
-
329
- /**
330
- * Validate payment method information object
331
- *
332
- * @param null
333
- * @return Mage_Payment_Model_Abstract
334
- */
335
- public function validate()
336
- {
337
- parent::validate();
338
-
339
- $infoInstance = $this->_getInfoInstance();
340
-
341
- if (!$this->_isPlaceOrder()) {
342
- // validate the Novalnet basic params and billing informations
343
- $this->validateNovalnetParams();
344
- //customer_no verification
345
- $this->helper->customerNumberValidation();
346
- // validate the form payment method values
347
- $this->dataHelper->validateNovalnetData($this->_code, $infoInstance);
348
- }
349
-
350
- $callbackPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('fraudCheckPayment');
351
- if (in_array($this->_code, $callbackPayment)) {
352
- $this->_initiateCallbackProcess($this->_code, $infoInstance);
353
- }
354
-
355
- if (!$this->isCallbackTypeCall() && $this->_isPlaceOrder()) {
356
- $this->_sendRequestToNovalnet();
357
- }
358
- return $this;
359
- }
360
-
361
- /**
362
- * Payment form refill validation
363
- *
364
- * @param null
365
- * @return null
366
- */
367
- public function paymentRefillValidate()
368
- {
369
- $helper = $this->helper;
370
- $checkoutSession = $this->_getCheckout();
371
- $prevPaymentCode = $checkoutSession->getNnPaymentCode();
372
- // Check the users (guest or login)
373
- $customerSession = $helper->getCustomerSession();
374
- $coreSession = $helper->getCoresession();
375
- if (!$customerSession->isLoggedIn() && !$coreSession->getGuestloginvalue()) {
376
- $coreSession->setGuestloginvalue('1');
377
- } elseif ($coreSession->getGuestloginvalue() && $customerSession->isLoggedIn()) {
378
- $coreSession->setGuestloginvalue('0');
379
- $this->unsetFormMethodSession();
380
- $this->unsetMethodSession($prevPaymentCode);
381
- }
382
- // unset form previous payment method session
383
- $paymentCode = $checkoutSession->getQuote()->getPayment()->getMethod();
384
- if ($paymentCode && !preg_match("/novalnet/i", $paymentCode) && $prevPaymentCode && $paymentCode != $prevPaymentCode) {
385
- $this->unsetFormMethodSession();
386
- $this->unsetMethodSession($prevPaymentCode);
387
- }
388
-
389
- $paymentSucess = $this->getNovalnetConfig('payment_last_success', true);
390
- if (!$helper->checkIsAdmin() && $customerSession->isLoggedIn() && empty($paymentCode) && $paymentSucess) {
391
- $helper->getModelFactory()->getlastSuccesOrderMethod($customerSession->getId(),$checkoutSession);
392
- }
393
- }
394
-
395
- /**
396
- * Assign the Novalnet direct payment methods request
397
- *
398
- * @param null
399
- * @return null
400
- */
401
- private function _sendRequestToNovalnet()
402
- {
403
- $redirectPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
404
-
405
- if ($this->_code && !in_array($this->_code, $redirectPayment)) {
406
- $storeId = $this->helper->getMagentoStoreId();
407
- $request = $this->buildRequest(Novalnet_Payment_Model_Config::POST_NORMAL, $storeId);
408
- $this->_getCheckout()->setPaymentReqData($request);
409
- }
410
- }
411
-
412
- /**
413
- * Payment capture process
414
- *
415
- * @param varien_object $payment
416
- * @param float $amount
417
- * @return Mage_Payment_Model_Abstract
418
- */
419
- public function capture(Varien_Object $payment, $amount)
420
- {
421
- $redirectPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
422
- $responseCodeApproved = Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED;
423
-
424
- if ($this->canCapture() && !in_array($this->_code, $redirectPayment)) {
425
- $helper = $this->helper;
426
- $orderId = $payment->getOrder()->getId();
427
- $amount = $helper->getAmountCollection($orderId, 1, NULL);
428
- $lastTranId = $helper->makeValidNumber($payment->getLastTransId());
429
- $loadTransStatus = $helper->loadTransactionStatus($lastTranId);
430
- $transStatus = $loadTransStatus->getTransactionStatus();
431
- if (!empty($transStatus) && $transStatus != $responseCodeApproved) {
432
- $response = $this->payportRequest($payment, 'capture');
433
- if ($response->getStatus() == $responseCodeApproved) {
434
- $data = unserialize($payment->getAdditionalData());
435
- $data['captureTid'] = $payment->getLastTransId();
436
- $data['CaptureCreateAt'] = $helper->getCurrentDateTime();
437
- $payment->setAdditionalData(serialize($data))->save();
438
- $helper->getModelFactory()->captureResponseSave($amount, $loadTransStatus, $transStatus, $payment, $lastTranId);
439
- } else {
440
- $this->showException('Error in you capture request');
441
- }
442
- }
443
- }
444
- return $this;
445
- }
446
-
447
- /**
448
- * Prepare request to gateway
449
- *
450
- * @param string $type
451
- * @param int $storeId
452
- * @param float $amountValue
453
- * @param varien_object $nominalItem
454
- * @return mixed
455
- */
456
- public function buildRequest($type = Novalnet_Payment_Model_Config::POST_NORMAL,
457
- $storeId = NULL, $amountValue = NULL, $nominalItem = NULL
458
- ) {
459
- if ($type == Novalnet_Payment_Model_Config::POST_NORMAL || $type == Novalnet_Payment_Model_Config::POST_CALLBACK) {
460
- $request = new Varien_Object();
461
- // set vendor params
462
- $this->assignNnAuthData($request, $storeId);
463
- $infoObject = $this->_getInfoObject();
464
- $orderId = $this->_getOrderId();
465
- $livemode = (!$this->getNovalnetConfig('live_mode')) ? 1 : 0;
466
- $helper = $this->helper;
467
- $modelFactory = $helper->getModelFactory();
468
- $amount = $nominalItem ? $helper->getFormatedAmount($this->_getCheckout()->getNnRowAmount())
469
- : ($amountValue ? $amountValue : $helper->getFormatedAmount($this->_getAmount()));
470
- $modelFactory->requestParams($request, $infoObject, $orderId, $amount, $livemode);
471
-
472
- if ($this->_manualCheckLimit) {
473
- $this->_manualCheckValidate($request);
474
- }
475
- // set reference params
476
- $this->setReferenceParams($request);
477
- // set payment type
478
- $request->setPaymentType($helper->getPaymentType($this->_code));
479
- // set Novalnet params
480
- $this->_setNovalnetParam($request, $this->_code);
481
- }
482
-
483
- // set nominal period params
484
- if ($nominalItem) {
485
- $subsequentPeriod = $this->getNovalnetConfig('subsequent_period', true);
486
- $modelFactory->requestProfileParams($request, $subsequentPeriod);
487
- }
488
-
489
- // Callback Method
490
- if ($type == Novalnet_Payment_Model_Config::POST_CALLBACK) {
491
- $paymentCode = ucfirst($this->_code);
492
- $callbackTelNo = "getNnCallbackTel" . $paymentCode;
493
-
494
- if ($this->getConfigData('callback') == 1) { //PIN By Callback
495
- $request->setTel($this->getInfoInstance()->$callbackTelNo());
496
- $request->setPinByCallback(true);
497
- } else if ($this->getConfigData('callback') == 2) { //PIN By SMS
498
- $request->setMobile($this->getInfoInstance()->$callbackTelNo());
499
- $request->setPinBySms(true);
500
- }
501
- }
502
-
503
- return $request;
504
- }
505
-
506
- /**
507
- * Set additional reference params
508
- *
509
- * @param varien_object $request
510
- * @return null
511
- */
512
- public function setReferenceParams($request) {
513
- $referenceOne = trim(strip_tags(trim($this->getNovalnetConfig('reference_one'))));
514
- $referenceTwo = trim(strip_tags(trim($this->getNovalnetConfig('reference_two'))));
515
-
516
- if ($this->_referrerId) {
517
- $request->setReferrerId($this->_referrerId);
518
- }
519
-
520
- if ($this->helper->checkIsAdmin()) {
521
- $adminUserId = Mage::getSingleton('admin/session')->getUser()->getUserId();
522
- $request->setInput2('admin_user')
523
- ->setInputval2($adminUserId);
524
- }
525
-
526
- if ($referenceOne) {
527
- $request->setInput3('reference1')
528
- ->setInputval3($referenceOne);
529
- }
530
-
531
- if ($referenceTwo) {
532
- $request->setInput4('reference2')
533
- ->setInputval4($referenceTwo);
534
- }
535
- }
536
-
537
- /**
538
- * Post request to gateway and return response
539
- *
540
- * @param varien_object $request
541
- * @return mixed
542
- */
543
- public function postRequest($request)
544
- {
545
- $result = new Varien_Object();
546
- $helper = $this->helper;
547
- $payportUrl = $helper->getPayportUrl('paygate');
548
-
549
- if ($this->_validateBasicParams()) {
550
- $response = $this->setNovalnetRequestCall($request->getData(), $payportUrl);
551
- parse_str($response->getBody(), $data);
552
- $result->addData($data);
553
- } else {
554
- $this->showException($helper->__('Required parameter not valid') . '!', false);
555
- }
556
- return $result;
557
- }
558
-
559
- /**
560
- * load order transaction details
561
- *
562
- * @param tid
563
- * @return integer
564
- */
565
- public function updatedAmount($tid)
566
- {
567
- $updated_amount = $this->helper->loadTransactionStatus($tid);
568
- return $updated_amount;
569
- }
570
-
571
- /**
572
- * Assign Novalnet authentication Data
573
- *
574
- * @param varien_object $request
575
- * @param int $storeId
576
- * @return null
577
- */
578
- public function assignNnAuthData(Varien_Object $request, $storeId = NULL)
579
- {
580
- //Reassign the Basic Params Based on store
581
- $this->_vendorId = $this->getNovalnetConfig('merchant_id', true, $storeId);
582
- $this->_authcode = $this->getNovalnetConfig('auth_code', true, $storeId);
583
- if ($this->_getCheckout()->getQuote()->hasNominalItems()) {
584
- $this->_tariffId = $this->_subscribTariffId;
585
- }
586
-
587
- // Assign affiliate account information if available.
588
- $this->loadAffAccDetail();
589
- $request->setVendor($this->_vendorId)
590
- ->setAuthCode($this->_authcode)
591
- ->setProduct($this->_productId)
592
- ->setTariff($this->_tariffId)
593
- ->setKey($this->helper->getPaymentId($this->_code));
594
- }
595
-
596
- /**
597
- * Get the Order basic configuration for refund, void, and capture
598
- *
599
- * @param varien_object $request
600
- * @param varien_object $payment
601
- * @param int $storeId
602
- * @param varien_object $nominalItem
603
- * @return null
604
- */
605
- public function assignOrderBasicParams(Varien_Object $request, $payment,
606
- $storeId = NULL, $nominalItem = NULL
607
- ) {
608
- $this->assignVendorConfig($payment);
609
- $getresponseData = unserialize($payment->getAdditionalData());
610
- // subscription tariff
611
- if ($nominalItem) {
612
- $this->_tariffId = $this->_subscribTariffId;
613
- }
614
- $this->_vendorId = ($getresponseData['vendor']) ? $getresponseData['vendor']
615
- : $this->_vendorId;
616
- $this->_authcode = ($getresponseData['auth_code']) ? $getresponseData['auth_code']
617
- : $this->_authcode;
618
- $this->_productId = ($getresponseData['product']) ? $getresponseData['product']
619
- : $this->_productId;
620
- $this->_tariffId = ($getresponseData['tariff']) ? $getresponseData['tariff']
621
- : $this->_tariffId;
622
- $key = ($getresponseData['key']) ? $getresponseData['key'] : $this->helper->getPaymentId($this->_code);
623
- // build basic merchant information
624
- $request->setVendor($this->_vendorId)
625
- ->setAuthCode($this->_authcode)
626
- ->setProduct($this->_productId)
627
- ->setTariff($this->_tariffId)
628
- ->setKey($key);
629
- }
630
-
631
- /**
632
- * Refund amount
633
- *
634
- * @param Varien_Object $payment
635
- * @param float $amount
636
- * @return Mage_Payment_Model_Abstract
637
- */
638
- public function refund(Varien_Object $payment, $amount)
639
- {
640
- if (!$this->canRefund()) {
641
- $this->showException('Refund action is not available.');
642
- }
643
-
644
- if ($payment->getRefundTransactionId() && $amount > 0) {
645
- $helper = $this->helper;
646
- $order = $payment->getOrder();
647
- $refundAmount = $helper->getFormatedAmount($amount);
648
- $orderItems = $this->getPaymentAllItems($order);
649
- $nominalItem = $helper->checkNominalItem($orderItems);
650
- $data = unserialize($payment->getAdditionalData());
651
- $getTid = $helper->makeValidNumber($payment->getRefundTransactionId());
652
- $invoicePayment = array(Novalnet_Payment_Model_Config::NN_PREPAYMENT, Novalnet_Payment_Model_Config::NN_INVOICE);
653
-
654
- if (($this->_code == Novalnet_Payment_Model_Config::NN_SEPA)
655
- || ($nominalItem && (in_array($this->_code, $invoicePayment)))) {
656
- // get payment last transaction id
657
- $getTid = $helper->makeValidNumber($payment->getLastTransId());
658
- if (!empty($data['NnSepaParentTid'])) {
659
- $getTid = $data['NnSepaParentTid'];
660
- }
661
- }
662
-
663
- $orderAmount = NULL;
664
- $modelFactory = $helper->getModelFactory();
665
- if ($nominalItem) {
666
- $orderAmount = $helper->getFormatedAmount($this->_getAmount());
667
- }
668
- $response = $this->payportRequest($payment, 'refund', $refundAmount, $getTid, $orderAmount);
669
-
670
- if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
671
- $amountAfterRefund = ($order->getTotalPaid() - $order->getBaseTotalRefunded());
672
- $response->setAmount($helper->getFormatedAmount($this->_getAmount()));
673
- $statusCode = $modelFactory->getTransactionData($getTid, $payment, $amountAfterRefund, 1, NULL, NULL, $response);
674
- $txnId = $response->getTid();
675
- $refundTid = !empty($txnId) ? $txnId : $payment->getLastTransId() . '-refund';
676
- $data['fullRefund'] = ((string)$this->_getAmount() == (string)$amount) ? true : false;
677
-
678
- if (in_array($this->_code, $invoicePayment)) {
679
- $data['NnTid'] = $data['NnTid'] . '-refund';
680
- $refundTid = $data['NnTid'];
681
- }
682
-
683
- if ($refundTid) {
684
- $refAmount = Mage::helper('core')->currency($amount, true, false);
685
- $data = $modelFactory->refundTidData($refAmount, $data, $refundTid, $getTid);
686
- }
687
- // For SEPA payment after submitting to bank
688
- if ($statusCode->getStatus() && $this->_code == Novalnet_Payment_Model_Config::NN_SEPA) {
689
- $data['NnSepaParentTid'] = $getTid;
690
- if ($statusCode->getStatus() == Novalnet_Payment_Model_Config::PAYMENT_VOID_STATUS
691
- && $statusCode->getChildTidInfo()) {
692
- parse_str($statusCode->getChildTidInfo(), $resInfo);
693
- $data['NnSepaParentTid'] = $resInfo['tid1'];
694
- }
695
- }
696
-
697
- $modelFactory->refundValidateProcess($helper, $payment, $refundTid,$data);
698
- if ($txnId) {
699
- $response->setAmount($amount);
700
- $modelFactory->getTransactionData($refundTid, $payment, $amountAfterRefund, 2, $refundTid, $order->getCustomerId(), $response);
701
- }
702
- } else {
703
- $this->showException($response->getStatusDesc(), false);
704
- }
705
- } else {
706
- $this->showException('Error in your refund request');
707
- }
708
- return $this;
709
- }
710
-
711
- /**
712
- * Void payment
713
- *
714
- * @param varien_object $payment
715
- * @return Mage_Payment_Model_Abstract
716
- */
717
- public function void(Varien_Object $payment)
718
- {
719
- if (!$this->canVoid($payment)) {
720
- $this->showException('Void action is not available.');
721
- }
722
-
723
- $helper = $this->helper;
724
- $getTid = $helper->makeValidNumber($payment->getLastTransId());
725
- $response = $this->payportRequest($payment, 'void');
726
-
727
- if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
728
- $txnId = trim($response->getTid());
729
- $voidTid = !empty($txnId) ? $txnId : $payment->getLastTransId() . '-void';
730
- $data = unserialize($payment->getAdditionalData());
731
- $data['voidTid'] = $voidTid;
732
- $data['voidCreateAt'] = $helper->getCurrentDateTime();
733
-
734
- if (in_array($this->_code, array(Novalnet_Payment_Model_Config::NN_INVOICE,
735
- Novalnet_Payment_Model_Config::NN_PREPAYMENT))) {
736
- $bankVoidTid = !empty($txnId) ? $txnId : $payment->getLastTransId();
737
- $data['NnNoteTID'] = $this->dataHelper->getReferenceDetails($bankVoidTid, $data, $this->_code);
738
- $payment->setAdditionalData(serialize($data));
739
- }
740
- $payment->setTransactionId($voidTid)
741
- ->setLastTransId($voidTid)
742
- ->setAdditionalData(serialize($data))
743
- ->save();
744
- $helper->getModelFactory()->getTransactionData($getTid, $payment, NULL, 1, NULL, NULL, $response);
745
- } else {
746
- $this->showException('Error in you void request');
747
- }
748
- return $this;
749
- }
750
-
751
- /**
752
- * Perform Novalnet request for Void, Capture, Refund
753
- *
754
- * @param varien_object $payment
755
- * @param string $requestType
756
- * @param float $refundAmount
757
- * @param int $refundTid
758
- * @param float $cardAmount
759
- * @return mixed
760
- */
761
- private function payportRequest($payment, $requestType, $refundAmount = NULL,
762
- $refundTid = NULL, $cardAmount = NULL
763
- ) {
764
- $request = new Varien_Object();
765
- $order = $payment->getOrder();
766
- $storeId = $order->getStoreId();
767
- $customerId = $order->getCustomerId();
768
- $orderItems = $this->getPaymentAllItems($order);
769
- $getTid = ($requestType == 'refund') ? $refundTid : $payment->getLastTransId();
770
- $helper = $this->helper;
771
- $nominalItem = $helper->checkNominalItem($orderItems);
772
- $responseCodeApproved = Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED;
773
- $this->assignOrderBasicParams($request, $payment, $storeId, $nominalItem);
774
- $modelFactory = $helper->getModelFactory();
775
- $totalRefunded = $order->getTotalRefunded();
776
- $lastTransId = $payment->getLastTransId();
777
-
778
- $modelFactory->requestTypes($request, $requestType, $helper, $getTid, $refundAmount);
779
-
780
- if (!in_array(NULL, $request->toArray())) {
781
- $buildNovalnetParam = http_build_query($request->getData());
782
- $payportUrl = $helper->getPayportUrl('paygate');
783
- $response = $this->dataHelper->setRawCallRequest($buildNovalnetParam, $payportUrl, $payment->getMethodInstance());
784
- $this->logNovalnetTransactionData($request, $response, $payment->getLastTransId(), $customerId, $storeId);
785
- } else {
786
- $this->showException('Error in processing the transactions request');
787
- }
788
-
789
- if ($response->getStatus() == $responseCodeApproved && $nominalItem) {
790
- // response transaction id
791
- $responseTid = $response->getTid();
792
- if ($requestType == 'void') {
793
- $modelFactory->saveProfileCancelState($lastTransId);
794
- } elseif ($requestType == 'refund' && $this->_code == Novalnet_Payment_Model_Config::NN_CC
795
- && $totalRefunded == $order->getTotalPaid()){
796
- $modelFactory->saveProfileCancelState($getTid);
797
- } elseif ($requestType == 'refund' && $this->_code != Novalnet_Payment_Model_Config::NN_CC
798
- && ($order->getGrandTotal() == $totalRefunded || $refundAmount == $cardAmount)) {
799
- $lastTransId = preg_match("/refund/i", $lastTransId) ? str_replace("-refund",'',$lastTransId) : $lastTransId;
800
- $modelFactory->saveProfileCancelState($lastTransId);
801
- $responseTid ? $modelFactory->saveProfileTID($lastTransId,$responseTid) : '';
802
- } elseif ($requestType == 'refund' && !empty($responseTid)
803
- && $this->_code != Novalnet_Payment_Model_Config::NN_CC) {
804
- $lastTransId = preg_match("/refund/i", $lastTransId) ? str_replace("-refund",'',$lastTransId) : $lastTransId;
805
- $modelFactory->saveProfileTID($lastTransId,$responseTid);
806
- }
807
- }
808
- return $response;
809
- }
810
-
811
- /**
812
- *
813
- * Get affiliate account/user detail
814
- *
815
- * @param null
816
- * @return mixed
817
- */
818
- public function loadAffAccDetail()
819
- {
820
- $helper = $this->helper;
821
- $nnAffId = $helper->getCoresession()->getNnAffId();
822
-
823
- if (empty($nnAffId)) {
824
- $customerId = $helper->getCustomerId();
825
- $orderCollection = Mage::getModel('novalnet_payment/affiliateuser')->getCollection()
826
- ->addFieldToFilter('customer_no', $customerId)
827
- ->addFieldToSelect('aff_id');
828
- $nnAffId = $orderCollection->getLastItem()->getAffId()
829
- ? $orderCollection->getLastItem()->getAffId() : NULL;
830
- $helper->getCoresession()->setNnAffId($nnAffId);
831
- }
832
-
833
- if ($nnAffId) {
834
- $orderCollection = Mage::getModel('novalnet_payment/affiliate')->getCollection()
835
- ->addFieldToFilter('aff_id', $nnAffId)
836
- ->addFieldToSelect('aff_id')
837
- ->addFieldToSelect('aff_authcode')
838
- ->addFieldToSelect('aff_accesskey');
839
- $vendorId = $orderCollection->getLastItem()->getAffId();
840
- $vendorAuthcode = $orderCollection->getLastItem()->getAffAuthcode();
841
- $affAccesskey = $orderCollection->getLastItem()->getAffAccesskey();
842
-
843
- // reassign vendor & authcode
844
- if ($vendorId && $vendorAuthcode) {
845
- $this->_vendorId = $vendorId;
846
- $this->_authcode = $vendorAuthcode;
847
- $this->_getCheckout()->setNnVendor($this->_vendorId)
848
- ->setNnAuthcode($this->_authcode);
849
- }
850
- }
851
-
852
- $accessKey = !empty($affAccesskey) ? $affAccesskey : $this->getNovalnetConfig('password', true);
853
- return $accessKey;
854
- }
855
-
856
- /**
857
- * Get Method Session
858
- *
859
- * @param string $paymentCode
860
- * @return mixed
861
- */
862
- private function _getMethodSession($paymentCode = NULL)
863
- {
864
- $paymentCode = (!empty($paymentCode)) ? $paymentCode : $this->getCode();
865
- $checkoutSession = $this->helper->getCheckoutSession();
866
- if (!$checkoutSession->hasData($paymentCode)) {
867
- $checkoutSession->setData($paymentCode, new Varien_Object());
868
- }
869
- return $checkoutSession->getData($paymentCode);
870
- }
871
-
872
- /**
873
- * Unset method session
874
- *
875
- * @param string $paymentCode
876
- * @return mixed
877
- */
878
- public function unsetMethodSession($paymentCode = NULL)
879
- {
880
- $paymentCode = (!empty($paymentCode)) ? $paymentCode : $this->getCode();
881
- $this->helper->getCheckoutSession()->unsetData($paymentCode);
882
- return $this;
883
- }
884
-
885
- /**
886
- * Get the Novalnet configuration data
887
- *
888
- * @param string $field
889
- * @param boolean $globalMode
890
- * @param int $storeId
891
- * @return boolean | null
892
- */
893
- public function getNovalnetConfig($field, $globalMode = false, $storeId = NULL)
894
- {
895
- $helper = $this->helper;
896
- $storeId = is_null($storeId) ? $helper->getMagentoStoreId() : $storeId;
897
- $path = $helper->getNovalnetGlobalPath() . $field;
898
- if ($field == 'live_mode') {
899
- $getTestModePaymentMethod = Mage::getStoreConfig($path, $storeId);
900
- if (!preg_match('/' . $this->_code . '/i', $getTestModePaymentMethod)) {
901
- return false;
902
- }
903
- return true;
904
- } elseif (!is_null($field)) {
905
- return ($globalMode == false) ? trim($this->getConfigData($field, $storeId))
906
- : trim(Mage::getStoreConfig($path, $storeId));
907
- }
908
- return null;
909
- }
910
-
911
- /**
912
- * Save canceled payment method
913
- *
914
- * @param varien_object $result
915
- * @param varien_object $payment
916
- * @return null
917
- */
918
- public function saveCancelledOrder($result, $payment)
919
- {
920
- $order = $payment->getOrder();
921
- $statusMessage = $result->getStatusMessage() ? $result->getStatusMessage() : ($result->getStatusDesc() ? $result->getStatusDesc()
922
- : ($result->getStatusText() ? $result->getStatusText() : $this->helper->__('Payment was not successfull')));
923
- $paystatus = "<b><font color='red'>" . $this->helper->__('Payment Failed') . "</font> - " . $statusMessage . "</b>";
924
- $data = unserialize($payment->getAdditionalData());
925
- // Set Novalnet Mode
926
- $authorizeKey = $data['authorize_key'];
927
- $serverResponse = ($result->getTestMode() && is_numeric($result->getTestMode()))
928
- ? $result->getTestMode()
929
- : $this->helper->getDecodedParam($result->getTestMode(), $authorizeKey);
930
- $shopMode = $this->getNovalnetConfig('live_mode', true);
931
- $testMode = (((isset($serverResponse) && $serverResponse == 1) || (isset($shopMode)
932
- && $shopMode == 0)) ? 1 : 0 );
933
- $data['NnTestOrder'] = $testMode;
934
- $data['NnComments'] = $paystatus;
935
- $payment->setLastTransId($result->getTid())
936
- ->setAdditionalData(serialize($data))
937
- ->save();
938
- $order->registerCancellation($statusMessage)
939
- ->save();
940
- }
941
-
942
- /**
943
- * Log Affiliate user details
944
- *
945
- * @param int $affId
946
- * @return null
947
- */
948
- public function doNovalnetAffUserInfoLog($affId)
949
- {
950
- $affiliateUserInfo = $this->helper->getModelAffiliateuser();
951
- $affiliateUserInfo->setAffId($affId)
952
- ->setCustomerNo($this->helper->getCustomerId())
953
- ->setAffOrderNo($this->_getOrderId())
954
- ->save();
955
- $this->helper->getCoresession()->unsNnAffId();
956
- }
957
-
958
- /**
959
- * Check the transaction status using API
960
- *
961
- * @param array $requestData
962
- * @param string $requestUrl
963
- * @param string $type
964
- * @return mixed
965
- */
966
- public function setNovalnetRequestCall($requestData, $requestUrl, $type = "")
967
- {
968
- if (!$requestUrl) {
969
- $this->showException('Server Request URL is Empty');
970
- return;
971
- }
972
- $httpClientConfig = array('maxredirects' => 0);
973
-
974
- if ($this->getNovalnetConfig('use_proxy',true)) {
975
- $proxyHost = $this->getNovalnetConfig('proxy_host',true);
976
- $proxyPort = $this->getNovalnetConfig('proxy_port',true);
977
- if ($proxyHost && $proxyPort) {
978
- $httpClientConfig['proxy'] = $proxyHost. ':' . $proxyPort;
979
- $httpClientConfig['httpproxytunnel'] = true;
980
- $httpClientConfig['proxytype'] = CURLPROXY_HTTP;
981
- $httpClientConfig['SSL_VERIFYHOST'] = false;
982
- $httpClientConfig['SSL_VERIFYPEER'] = false;
983
- }
984
- }
985
-
986
- $gatewayTimeout = (int) $this->getNovalnetConfig('gateway_timeout',true);
987
- if ($gatewayTimeout > 0) {
988
- $httpClientConfig['timeout'] = $gatewayTimeout;
989
- }
990
-
991
- $client = new Varien_Http_Client($requestUrl, $httpClientConfig);
992
-
993
- if ($type == 'XML') {
994
- $client->setUri($requestUrl);
995
- $client->setRawData($requestData)->setMethod(Varien_Http_Client::POST);
996
- } else {
997
- $client->setParameterPost($requestData)->setMethod(Varien_Http_Client::POST);
998
- }
999
- $response = $client->request();
1000
-
1001
- if (!$response->isSuccessful()) {
1002
- $this->showException($this->helper->__('Gateway request error: %s', $response->getMessage()), false);
1003
- }
1004
- if ($type == 'XML') {
1005
- $result = new Varien_Simplexml_Element($response->getRawBody());
1006
- $response = new Varien_Object($result->asArray());
1007
- }
1008
- return $response;
1009
- }
1010
-
1011
- /**
1012
- * Set the Novalnet parameter based on payment code
1013
- *
1014
- * @param Varien object $request
1015
- * @param string $paymentCode
1016
- * @return mixed
1017
- */
1018
- private function _setNovalnetParam(Varien_Object $request, $paymentCode)
1019
- {
1020
- $helper = $this->helper;
1021
- $dataHelper = $this->dataHelper;
1022
- if ($paymentCode) {
1023
- switch ($paymentCode) {
1024
- case Novalnet_Payment_Model_Config::NN_INVOICE:
1025
- $paymentDuration = trim($this->getNovalnetConfig('payment_duration'));
1026
- $dueDate = $helper->setDueDate($paymentDuration);
1027
- if ($dueDate) {
1028
- $request->setDueDate($dueDate);
1029
- }
1030
- $request->setInvoiceType(Novalnet_Payment_Model_Config::INVOICE_PAYMENT_METHOD)
1031
- ->setInvoiceRef('BNR-' . $request->getProduct() . '-' . $this->_getOrderId());
1032
- break;
1033
- case Novalnet_Payment_Model_Config::NN_PREPAYMENT:
1034
- $request->setInvoiceType(Novalnet_Payment_Model_Config::PREPAYMENT_PAYMENT_METHOD)
1035
- ->setInvoiceRef('BNR-' . $request->getProduct() . '-' . $this->_getOrderId());
1036
- break;
1037
- case Novalnet_Payment_Model_Config::NN_SOFORT:
1038
- case Novalnet_Payment_Model_Config::NN_PAYPAL:
1039
- case Novalnet_Payment_Model_Config::NN_IDEAL:
1040
- case Novalnet_Payment_Model_Config::NN_EPS:
1041
- case Novalnet_Payment_Model_Config::NN_GIROPAY:
1042
- $authorizeKey = $this->loadAffAccDetail();
1043
- $request->setUniqid(uniqid())
1044
- ->setSession(session_id())
1045
- ->setImplementation('PHP');
1046
- $this->dataHelper->assignNovalnetReturnData($request, $this->_code);
1047
- $this->dataHelper->importNovalnetEncodeData($request, $authorizeKey);
1048
- break;
1049
- case Novalnet_Payment_Model_Config::NN_CC:
1050
- $authorizeKey = $this->loadAffAccDetail();
1051
- $request->setUniqid(uniqid())
1052
- ->setSession(session_id())
1053
- ->setImplementation('PHP_PCI')
1054
- ->setVendorId($request->getVendor())
1055
- ->setVendorAuthcode($request->getAuthCode())
1056
- ->setTariffId($request->getTariff())
1057
- ->setProductId($request->getProduct());
1058
- $request->unsVendor()
1059
- ->unsAuthCode()
1060
- ->unsProduct()
1061
- ->unsTariff();
1062
- // Add Credit Card 3D Secure payment process params
1063
- if ($this->getNovalnetConfig('active_cc3d')) {
1064
- $request->setCc_3d(1);
1065
- }
1066
- $dataHelper->assignNovalnetReturnData($request, $this->_code);
1067
- $this->dataHelper->importNovalnetEncodeData($request, $authorizeKey, 'PHP_PCI');
1068
- break;
1069
- case Novalnet_Payment_Model_Config::NN_SEPA:
1070
- $paymentInfo = $dataHelper->novalnetCardDetails('payment');
1071
- $request->setBankAccountHolder($paymentInfo['account_holder'])
1072
- ->setSepaHash($dataHelper->novalnetCardDetails('result_sepa_hash'))
1073
- ->setSepaUniqueId($dataHelper->novalnetCardDetails('result_mandate_unique'))
1074
- ->setIbanBicConfirmed($dataHelper->novalnetCardDetails('nnsepa_iban_confirmed'));
1075
-
1076
- $paymentDuration = trim($this->getNovalnetConfig('sepa_due_date'));
1077
- $dueDate = (!$paymentDuration) ? date('Y-m-d', strtotime('+7 days'))
1078
- : date('Y-m-d', strtotime('+' . $paymentDuration . ' days'));
1079
- $request->setSepaDueDate($dueDate);
1080
- break;
1081
- }
1082
- }
1083
- return $request;
1084
- }
1085
-
1086
- /**
1087
- * Validate the Novalnet response
1088
- *
1089
- * @param varien_object $payment
1090
- * @param varien_object $result
1091
- * @return boolean
1092
- */
1093
- public function validateNovalnetResponse($payment, $result = NULL)
1094
- {
1095
- $order = $payment->getOrder();
1096
- $request = $this->_getCheckout()->getPaymentReqData();
1097
-
1098
- switch ($result->getStatus()) {
1099
- case Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED:
1100
- // Set Novalnet Mode
1101
- $txnId = trim($result->getTid());
1102
- $data = $this->setPaymentAddtionaldata($result, $request);
1103
- if ($this->_code == Novalnet_Payment_Model_Config::NN_SEPA) {
1104
- // Log sepa refill information for login users
1105
- $this->sepaPaymentRefill();
1106
- }
1107
- $payment->setStatus(self::STATUS_APPROVED)
1108
- ->setIsTransactionClosed(false)
1109
- ->setAdditionalData(serialize($data))
1110
- ->save();
1111
- $order->setPayment($payment);
1112
- $order->save();
1113
- /* Update the transaction status and transaction overview */
1114
- $result->setStatus($result->getTidStatus());
1115
- $this->logNovalnetStatusData($result, $txnId);
1116
-
1117
- $helper = $this->helper;
1118
- $captureMode = (version_compare($helper->getMagentoVersion(), '1.6', '<'))
1119
- ? false : true;
1120
-
1121
- // Capture the payment only if status is 100
1122
- if ($order->canInvoice() && $result->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
1123
- && $this->_code != Novalnet_Payment_Model_Config::NN_PREPAYMENT) {
1124
- $payment->setTransactionId($txnId) // Add capture text to make the new transaction
1125
- ->setIsTransactionClosed($captureMode) // Close the transaction
1126
- ->capture(null)
1127
- ->save();
1128
- $setOrderStatus = $this->getNovalnetConfig('order_status') ? $this->getNovalnetConfig('order_status')
1129
- : Mage_Sales_Model_Order::STATE_PROCESSING; // If after status is empty set default status
1130
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $setOrderStatus, $this->helper->__('Payment was successful.'), true);
1131
- }
1132
-
1133
- $payment->setTransactionId($txnId)
1134
- ->setLastTransId($txnId)
1135
- ->setParentTransactionId(null)
1136
- ->save();
1137
- $order->setPayment($payment);
1138
- $order->save();
1139
- $nnAffId = $helper->getCoresession()->getNnAffId();
1140
- if ($nnAffId) {
1141
- $this->doNovalnetAffUserInfoLog($nnAffId);
1142
- }
1143
- if (!$this->isCallbackTypeCall()) {
1144
- $this->logNovalnetTransactionData($request, $result, $txnId, $this->helper->getCustomerId(), $this->helper->getMagentoStoreId());
1145
- }
1146
- $statusText = $result->getStatusMessage() ? $result->getStatusMessage()
1147
- : ($result->getStatusDesc() ? $result->getStatusDesc() : ($result->getStatusText()
1148
- ? $result->getStatusText() : $helper->__('successful')));
1149
- $helper->getCoresession()->addSuccess($statusText);
1150
- $error = false;
1151
- break;
1152
- default:
1153
- $error = ($result->getStatusDesc()) ? $this->helper->htmlEscape($result->getStatusDesc())
1154
- : $this->helper->__('Error in capturing the payment');
1155
- if (!$this->isCallbackTypeCall()) {
1156
- $this->logNovalnetTransactionData($request, $result, $result->getTid(), $this->helper->getCustomerId(), $this->helper->getMagentoStoreId());
1157
- }
1158
- if ($error !== false) {
1159
- $this->saveCancelledOrder($result, $payment);
1160
- $this->helper->getCoresession()->addError($error);
1161
- }
1162
- break;
1163
- }
1164
- return $error;
1165
- }
1166
-
1167
- /**
1168
- * Set Payment method additional informations
1169
- *
1170
- * @param varien_object $result
1171
- * @param varien_object $request
1172
- * @param array
1173
- */
1174
- public function setPaymentAddtionaldata($result, $request = NULL)
1175
- {
1176
- $txnId = trim($result->getTid());
1177
- // set Novalnet Mode
1178
- $responseTestMode = $result->getTestMode();
1179
- $shopMode = $this->getNovalnetConfig('live_mode');
1180
- $testMode = (((isset($responseTestMode) && $responseTestMode == 1) || (isset($shopMode)
1181
- && $shopMode == 0)) ? 1 : 0 );
1182
- if ($this->_getCheckout()->getQuote()->hasNominalItems()) {
1183
- $this->_tariffId = $this->_subscribTariffId;
1184
- }
1185
-
1186
- $data = array('NnTestOrder' => $testMode,
1187
- 'NnTid' => $txnId,
1188
- 'orderNo' => trim($result->getOrderNo()),
1189
- 'vendor' => ($request->getVendor()) ? $request->getVendor() : $this->_vendorId,
1190
- 'auth_code' => ($request->getAuthCode()) ? $request->getAuthCode() : $this->_authcode,
1191
- 'product' => ($request->getProduct()) ? $request->getProduct() : $this->_productId,
1192
- 'tariff' => ($request->getTariff()) ? $request->getTariff() : $this->_tariffId,
1193
- 'key' => ($request->getKey()) ? $request->getKey() : $this->helper->getPaymentId($this->_code),
1194
- );
1195
-
1196
- if (in_array($this->_code, array(Novalnet_Payment_Model_Config::NN_INVOICE,
1197
- Novalnet_Payment_Model_Config::NN_PREPAYMENT))) {
1198
- $dataHelper = $this->dataHelper;
1199
- $data['NnNoteDesc'] = $dataHelper->getNoteDescription();
1200
- $data['NnDueDate'] = $dataHelper->getDueDate($result);
1201
- $data['NnNote'] = $dataHelper->getNote($result);
1202
- $data['NnNoteAmount'] = $dataHelper->getBankDetailsAmount($result->getAmount());
1203
- $data['NnNoteTID'] = $dataHelper->getReferenceDetails($txnId,$data, $this->_code);
1204
- }
1205
- return $data;
1206
- }
1207
-
1208
- /**
1209
- * Log sepa payment refill information
1210
- *
1211
- * @param null
1212
- * @return null
1213
- */
1214
- public function sepaPaymentRefill()
1215
- {
1216
- $helper = $this->helper;
1217
- $customerId = $helper->getCustomerId();
1218
-
1219
- if ($customerId != 'guest') {
1220
- $modNovalSepaReFillCollection = $helper->getModelSepaRefill()->getCollection();
1221
- $modNovalSepaReFillCollection->addFieldToFilter('customer_id', $customerId);
1222
- $modNovalSepaRefill = count($modNovalSepaReFillCollection)
1223
- ? $helper->getModelSepaRefill()->load($customerId, 'customer_id')
1224
- : $helper->getModelSepaRefill();
1225
- $modNovalSepaRefill->setCustomerId($customerId)
1226
- ->setPanHash($this->_getCheckout()->getSepaHash())
1227
- ->setSepaDatetime($helper->getCurrentDateTime())
1228
- ->save();
1229
- }
1230
- }
1231
-
1232
- /**
1233
- * Unset Form method session
1234
- *
1235
- * @param null
1236
- * @return null
1237
- */
1238
- public function unsetFormMethodSession()
1239
- {
1240
- $this->_getCheckout()->unsSepaHash()
1241
- ->unsSepaUniqueId()
1242
- ->unsRefilldatavalues()
1243
- ->unsNnPaymentCode()
1244
- ->unsNnVendor()
1245
- ->unsNnAuthcode();
1246
- }
1247
-
1248
- /**
1249
- * Unset payment method session
1250
- *
1251
- * @param null
1252
- * @return null
1253
- */
1254
- public function unsetPaymentReqResData()
1255
- {
1256
- $this->_getCheckout()->unsNominalRequest()
1257
- ->unsNominalResponse()
1258
- ->unsPaymentReqData()
1259
- ->unsPaymentResData()
1260
- ->unsNnCallbackReqData();
1261
- }
1262
-
1263
- /**
1264
- * Validate the transaction status
1265
- *
1266
- * @param integer $tid
1267
- * @param varien_object $payment
1268
- * @param string $reqType
1269
- * @param varien_object $extraOption
1270
- * @return mixed
1271
- */
1272
- public function doNovalnetStatusCall($tid, $payment = NULL, $reqType = Novalnet_Payment_Model_Config::TRANS_STATUS, $extraOption = NULL)
1273
- {
1274
- $requestType = ($reqType == Novalnet_Payment_Model_Config::TRANS_STATUS)
1275
- ? Novalnet_Payment_Model_Config::TRANS_STATUS : $reqType;
1276
-
1277
- if ($payment) {
1278
- $this->assignVendorConfig($payment);
1279
- }
1280
- // Callback request data re-assign
1281
- $callbackReqData = $this->_getCheckout()->getNnCallbackReqData();
1282
- if ($callbackReqData) {
1283
- $this->_vendorId = $callbackReqData->getVendor();
1284
- $this->_authcode = $callbackReqData->getAuthCode();
1285
- $this->_productId = $callbackReqData->getProduct();
1286
- }
1287
- $request = '<?xml version="1.0" encoding="UTF-8"?>';
1288
- $request .= '<nnxml><info_request>';
1289
- $request .= '<vendor_id>' . $this->_vendorId . '</vendor_id>';
1290
- $request .= '<vendor_authcode>' . $this->_authcode . '</vendor_authcode>';
1291
- $request .= '<request_type>' . $requestType . '</request_type>';
1292
- $request .= '<product_id>' . $this->_productId . '</product_id>';
1293
- $request .= '<tid>' . $tid . '</tid>' . $extraOption;
1294
- $request .= '</info_request></nnxml>';
1295
-
1296
- if ($this->_vendorId && $this->_authcode && $this->_productId) {
1297
- $infoRequestUrl = $this->helper->getPayportUrl('infoport');
1298
- $result = $this->setNovalnetRequestCall($request, $infoRequestUrl, 'XML');
1299
- return $result;
1300
- }
1301
- }
1302
-
1303
- /**
1304
- * Set the Order basic configuration
1305
- *
1306
- * @param string $payment
1307
- * @return null
1308
- */
1309
- public function assignVendorConfig($payment = NULL)
1310
- {
1311
- // Reassign the Basic Params Based on store
1312
- $getresponseData = $payment ? unserialize($payment->getAdditionalData()) : NULL;
1313
- $this->_vendorId = ($getresponseData['vendor']) ? $getresponseData['vendor']
1314
- : $this->_vendorId;
1315
- $this->_authcode = ($getresponseData['auth_code']) ? $getresponseData['auth_code']
1316
- : $this->_authcode;
1317
- $this->_productId = ($getresponseData['product']) ? $getresponseData['product']
1318
- : $this->_productId;
1319
- $this->_tariffId = ($getresponseData['tariff']) ? $getresponseData['tariff']
1320
- : $this->_tariffId;
1321
- }
1322
-
1323
- /**
1324
- * Get checkout session
1325
- *
1326
- * @param null
1327
- * @return Mage_Sales_Model_Order
1328
- */
1329
- protected function _getCheckout()
1330
- {
1331
- if ($this->helper->checkIsAdmin()) {
1332
- return $this->helper->getAdminCheckoutSession();
1333
- } else {
1334
- return $this->helper->getCheckoutSession();
1335
- }
1336
- }
1337
-
1338
- /**
1339
- * validate Novalnet params to proceed checkout
1340
- *
1341
- * @param null
1342
- * @return boolean
1343
- */
1344
- public function validateNovalnetParams()
1345
- {
1346
- $infoObject = $this->_getInfoObject();
1347
- $infoObjBilling = $infoObject->getBillingAddress();
1348
- $quoteBilling = $this->_getCheckout()->getQuote()->getBillingAddress();
1349
- $cusEmail = ($quoteBilling->getEmail()) ? $quoteBilling->getEmail() : $infoObject->getCustomerEmail();
1350
- $cusFirstname = ($quoteBilling->getFirstname()) ? $quoteBilling->getFirstname()
1351
- : $infoObjBilling->getFirstname();
1352
- $cusLastname = ($quoteBilling->getLastname()) ? $quoteBilling->getLastname()
1353
- : $infoObjBilling->getLastname();
1354
- $helper = $this->helper;
1355
- if (!$this->_validateBasicParams()) {
1356
- $this->showException($helper->__('Please fill in all the mandatory fields') . '!', false);
1357
- return false;
1358
- } elseif (!$helper->validateEmail($cusEmail) || !$cusFirstname || !$cusLastname) {
1359
- $this->showException($helper->__('Customer name/email fields are not valid') . '!', false);
1360
- return false;
1361
- }
1362
- return true;
1363
- }
1364
-
1365
- /**
1366
- * Validate manual checklimit and reassign product id and tariff id
1367
- *
1368
- * @param varien_object $request
1369
- * @return mixed
1370
- */
1371
- private function _manualCheckValidate($request)
1372
- {
1373
- $checkoutSession = $this->_getCheckout();
1374
- $setOnholdPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('setonholdPayments');
1375
- $amount = $checkoutSession->getQuote()->hasNominalItems()
1376
- ? $this->helper->getFormatedAmount($checkoutSession->getNnRowAmount())
1377
- : $this->helper->getFormatedAmount($this->_getAmount());
1378
- if (in_array($this->_code,$setOnholdPayments) && $this->_manualCheckLimit <= $amount) {
1379
- $request->setOnHold(1);
1380
- }
1381
-
1382
- return $request;
1383
- }
1384
-
1385
- /**
1386
- * Validate Novalnet basic params
1387
- *
1388
- * @param null
1389
- * @return boolean
1390
- */
1391
- private function _validateBasicParams()
1392
- {
1393
- $helper = $this->helper;
1394
-
1395
- if ($helper->checkIsNumeric($this->_vendorId) && $this->_authcode && $helper->checkIsNumeric($this->_productId)
1396
- && $helper->checkIsNumeric($this->_tariffId)) {
1397
- if ($this->_getCheckout()->getQuote()->hasNominalItems() && !$helper->checkIsNumeric($this->_subscribTariffId)) {
1398
- return false;
1399
- }
1400
- return true;
1401
- }
1402
-
1403
- return false;
1404
- }
1405
-
1406
- /**
1407
- * Check whether callback option is enabled
1408
- *
1409
- * @param null
1410
- * @return boolean
1411
- */
1412
- public function isCallbackTypeCall()
1413
- {
1414
- $callbackTid = "hasNnCallbackTid" . ucfirst($this->_code);
1415
- $total = $this->helper->getFormatedAmount($this->_getAmount());
1416
- $callBackMinimum = (int) $this->getNovalnetConfig('callback_minimum_amount');
1417
- $countryCode = strtoupper($this->_getInfoObject()->getBillingAddress()->getCountryId());
1418
- $checkoutSession = $this->_getCheckout();
1419
- $helper = $this->helper;
1420
- if ($checkoutSession->getQuote()->hasNominalItems()) {
1421
- $total = $helper->getFormatedAmount($checkoutSession->getNnRowAmount());
1422
- }
1423
-
1424
- return ($helper->getCheckoutSession()->$callbackTid() || ($this->getNovalnetConfig('callback')
1425
- && ($callBackMinimum ? $total >= $callBackMinimum : true) && ($helper->isCallbackTypeAllowed($countryCode))));
1426
- }
1427
-
1428
- /**
1429
- * Initiate callback process after selecting payment method
1430
- *
1431
- * @param string $code
1432
- * @param mixed $infoInstance
1433
- * @return null
1434
- */
1435
- private function _initiateCallbackProcess($code, $infoInstance)
1436
- {
1437
- $isCallbackTypeCall = $this->isCallbackTypeCall();
1438
- $methodSession = $this->_getMethodSession();
1439
- $isPlaceOrder = $this->_isPlaceOrder();
1440
-
1441
- $paymentCode = ucfirst($code);
1442
- $callbackTid = "getNnCallbackTid" . $paymentCode;
1443
- $callbackOrderNo = "getNnCallbackOrderNo" . $paymentCode;
1444
- $callbackPin = "getNnCallbackPin" . $paymentCode;
1445
- $callbackNewPin = "getNnNewCallbackPin" . $paymentCode;
1446
- $setcallbackPin = "setNnCallbackPin" . $paymentCode;
1447
-
1448
- if (!$isPlaceOrder && $isCallbackTypeCall && $this->_getIncrementId() != $methodSession->$callbackOrderNo()) {
1449
- $this->unsetMethodSession();
1450
- }
1451
-
1452
- // Validate callback session
1453
- $this->_validateCallbackSession($paymentCode);
1454
-
1455
- if ($isCallbackTypeCall && $infoInstance->getCallbackPinValidationFlag()
1456
- && $methodSession->$callbackTid()) {
1457
- $nnCallbackPin = $infoInstance->$callbackPin();
1458
- if (!$infoInstance->$callbackNewPin() && empty($nnCallbackPin)) {
1459
- $this->showException('Enter your PIN');
1460
- } elseif (!$infoInstance->$callbackNewPin() && !$this->helper->checkIsValid($nnCallbackPin)) {
1461
- $this->showException('The PIN you entered is incorrect');
1462
- }
1463
- }
1464
-
1465
- if ($isCallbackTypeCall && !$isPlaceOrder) {
1466
- if ($methodSession->$callbackTid()) {
1467
- $infoInstance->$callbackNewPin() ? $this->_regenerateCallbackPin($methodSession)
1468
- : $methodSession->$setcallbackPin($infoInstance->$callbackPin());
1469
- } elseif (!$methodSession->$callbackTid()) {
1470
- $this->_generateCallback($paymentCode);
1471
- }
1472
- }
1473
-
1474
- if ($isPlaceOrder) {
1475
- $this->validateCallbackProcess($paymentCode);
1476
- }
1477
- }
1478
-
1479
- /**
1480
- * Validate order amount is getting changed after callback initiation
1481
- *
1482
- * @param string $paymentCode
1483
- * @return throw Mage Exception
1484
- */
1485
- private function _validateCallbackSession($paymentCode)
1486
- {
1487
- $callbackTid = "hasNnCallbackTid" . $paymentCode;
1488
- $getNnDisableTime = "getNnDisableTime" . $paymentCode;
1489
- $checkoutSession = $this->_getCheckout();
1490
- $methodSession = $this->_getMethodSession();
1491
- $helper = $this->helper;
1492
- $amount = $this->_getCheckout()->getQuote()->hasNominalItems()
1493
- ? $helper->getFormatedAmount($checkoutSession->getNnRowAmount())
1494
- : $helper->getFormatedAmount($this->_getAmount());
1495
-
1496
- if ($methodSession->$callbackTid()) {
1497
- if ($checkoutSession->$getNnDisableTime() && time() > $checkoutSession->$getNnDisableTime()) {
1498
- $this->unsetMethodSession();
1499
- } elseif ($methodSession->getOrderAmount() != $amount) {
1500
- $this->unsetMethodSession();
1501
- if (!$this->_isPlaceOrder()) {
1502
- $this->showException('The order amount has been changed, please proceed with the new order');
1503
- }
1504
- }
1505
- }
1506
- }
1507
-
1508
- /**
1509
- * Get increment id for callback process
1510
- *
1511
- * @param null
1512
- * @return int
1513
- */
1514
- private function _getIncrementId()
1515
- {
1516
- $storeId = $this->helper->getMagentoStoreId();
1517
- $orders = Mage::getModel('sales/order')->getCollection()
1518
- ->addAttributeToFilter('store_id', $storeId)
1519
- ->setOrder('entity_id', 'DESC');
1520
- $lastIncrementId = $orders->getFirstItem()->getIncrementId();
1521
- if ($lastIncrementId) {
1522
- $incrementId = ++$lastIncrementId;
1523
- } else {
1524
- $incrementId = $storeId . Mage::getModel('eav/entity_increment_numeric')->getNextId();
1525
- }
1526
- return $incrementId;
1527
- }
1528
-
1529
- /**
1530
- * Make callback request and validate response
1531
- *
1532
- * @param string $paymentCode
1533
- * @return throw Mage Exception
1534
- */
1535
- private function _generateCallback($paymentCode)
1536
- {
1537
- $callbackTid = "setNnCallbackTid" . $paymentCode;
1538
- $callbackOrderNo = "setNnCallbackOrderNo" . $paymentCode;
1539
- $checkoutSession = $this->_getCheckout();
1540
- $nominalItem = $checkoutSession->getQuote()->hasNominalItems();
1541
-
1542
- if ($nominalItem) {
1543
- $request = $this->buildRequest(Novalnet_Payment_Model_Config::POST_CALLBACK, NULL, NULL, $nominalItem);
1544
- $response = $this->postRequest($request);
1545
- $checkoutSession->setNominalRequest($request)
1546
- ->setNominalResponse($response);
1547
- } else {
1548
- $request = $this->buildRequest(Novalnet_Payment_Model_Config::POST_CALLBACK);
1549
- $response = $this->postRequest($request);
1550
- $checkoutSession->setPaymentReqData($request)
1551
- ->setPaymentResData($response);
1552
- $this->logNovalnetTransactionData($request, $response, $response->getTid());
1553
- }
1554
-
1555
- $checkoutSession->setNnCallbackReqData($request);
1556
- if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
1557
- $this->_getMethodSession()
1558
- ->$callbackTid(trim($response->getTid()))
1559
- ->setNnTestMode(trim($response->getTestMode()))
1560
- ->setNnCallbackTidTimeStamp(time())
1561
- ->setOrderAmount($request->getAmount())
1562
- ->setNnCallbackSuccessState(true)
1563
- ->$callbackOrderNo(trim($response->getOrderNo()));
1564
- if($this->getNovalnetConfig('callback') == 2) {
1565
- $text = $this->helper->__('You will shortly receive an SMS containing your transaction PIN to complete the payment');
1566
- } else {
1567
- $text = $this->helper->__('You will shortly receive a transaction PIN through phone call to complete the payment');
1568
- }
1569
- } else {
1570
- $text = $this->helper->htmlEscape($response->getStatusDesc());
1571
- }
1572
- $this->showException($text, false);
1573
- }
1574
-
1575
- /**
1576
- * Regenerate new pin for callback process
1577
- *
1578
- * @param mixed $methodSession
1579
- * @return throw Mage Exception
1580
- */
1581
- private function _regenerateCallbackPin($methodSession)
1582
- {
1583
- $callbackTid = "getNnCallbackTid" . ucfirst($this->_code);
1584
- $response = $this->doNovalnetStatusCall($methodSession->$callbackTid(), NULL, Novalnet_Payment_Model_Config::TRANSMIT_PIN_AGAIN);
1585
-
1586
- if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
1587
- $text = $this->helper->__('You will shortly receive an SMS containing your transaction PIN to complete the payment');
1588
- } else {
1589
- $text = $this->helper->htmlEscape($response->getStatusMessage()); // Status_message
1590
- }
1591
-
1592
- $this->showException($text, false);
1593
- }
1594
-
1595
- /**
1596
- * Validate callback response
1597
- *
1598
- * @param string $paymentCode
1599
- * @param mixed $methodSession
1600
- * @return null
1601
- */
1602
- public function validateCallbackProcess($paymentCode)
1603
- {
1604
- $callbackTid = "getNnCallbackTid" . $paymentCode;
1605
- $callbackPin = "getNnCallbackPin" . $paymentCode;
1606
- $setNnDisableTime = "setNnDisableTime" . $paymentCode;
1607
- $methodSession = $this->_getMethodSession();
1608
- $checkoutSession = $this->_getCheckout();
1609
- $nominalItem = $checkoutSession->getQuote()->hasNominalItems();
1610
-
1611
- if ($methodSession->getNnCallbackSuccessState()) {
1612
- $type = Novalnet_Payment_Model_Config::PIN_STATUS;
1613
- $extraOption = '<pin>' . $methodSession->$callbackPin() . '</pin>';
1614
- $result = $this->doNovalnetStatusCall($methodSession->$callbackTid(), NULL, $type, $extraOption);
1615
- $result->setTid($methodSession->$callbackTid());
1616
- $result->setTestMode($methodSession->getNnTestMode());
1617
-
1618
- // Analyze the response from Novalnet
1619
- if ($result->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
1620
- $methodSession->setNnCallbackSuccessState(false);
1621
- ($nominalItem) ? $checkoutSession->getNominalResponse()->setTidStatus($result->getTidStatus())
1622
- : $checkoutSession->getPaymentResData()->setTidStatus($result->getTidStatus());
1623
- } else {
1624
- if ($result->getStatus() == Novalnet_Payment_Model_Config::METHOD_DISABLE_CODE) {
1625
- $this->_getCheckout()->$setNnDisableTime(time() + (30 * 60));
1626
- }
1627
- $error = ($result->getStatusDesc() || $result->getStatusMessage())
1628
- ? $this->helper->htmlEscape($result->getStatusMessage() . $result->getStatusDesc())
1629
- : $this->helper->htmlEscape($result->pinStatus['status_message']);
1630
- $this->showException($error, false);
1631
- }
1632
- }
1633
- }
1634
-
1635
- /**
1636
- * Log Novalnet transaction data
1637
- *
1638
- * @param varien_object $request
1639
- * @param varien_object $response
1640
- * @param int $txnId
1641
- * @param int $customerId
1642
- * @param int $storeId
1643
- * @param int $orderNo
1644
- * @param int $subsId
1645
- * @return null
1646
- */
1647
- public function logNovalnetTransactionData($request = NULL, $response = NULL, $txnId,
1648
- $customerId = NULL, $storeId = NULL, $orderNo = NULL, $subsId = NULL
1649
- ) {
1650
- $this->dataHelper->doRemoveSensitiveData($request, $this->_code);
1651
- $helper = $this->helper;
1652
- $shopUrl = ($response->getMemburl()) ? $response->getMemburl() : $helper->getCurrentSiteUrl();
1653
- if ($orderNo == NULL) {
1654
- $orderNo = $this->_getOrderId();
1655
- }
1656
-
1657
- $customerId = ($customerId) ? $customerId : $helper->getCustomerId();
1658
- $storeId = ($storeId) ? $storeId : $helper->getMagentoStoreId();
1659
- $modNovalTransactionOverview = $helper->getModelTransactionOverview();
1660
- $modNovalTransactionOverview->setTransactionId($txnId)
1661
- ->setOrderId($orderNo)
1662
- ->setRequestData(serialize($request->getData()))
1663
- ->setResponseData(base64_encode(serialize($response->getData())))
1664
- ->setCustomerId($customerId)
1665
- ->setStatus($response->getStatus())
1666
- ->setStoreId($storeId)
1667
- ->setShopUrl($shopUrl);
1668
- if ($subsId) {
1669
- $modNovalTransactionOverview->setAdditionalData($helper->getCurrentDateTime());
1670
- }
1671
- $modNovalTransactionOverview->setCreatedDate($helper->getCurrentDateTime())
1672
- ->save();
1673
- }
1674
-
1675
- /**
1676
- * Log Novalnet transaction status data
1677
- *
1678
- * @param varien_object $response
1679
- * @param int $txnId
1680
- * @param int $customerId
1681
- * @param int $storeId
1682
- * @param float $amount
1683
- * @return null
1684
- */
1685
- public function logNovalnetStatusData($response, $txnId, $customerId = NULL,
1686
- $storeId = NULL, $amount = NULL
1687
- ) {
1688
- $helper = $this->helper;
1689
- $shopUrl = ($response->getMemburl()) ? $response->getMemburl() : $helper->getCurrentSiteUrl();
1690
- $customerId = ($customerId) ? $customerId : $helper->getCustomerId();
1691
- $storeId = ($storeId) ? $storeId : $helper->getMagentoStoreId();
1692
- $amount = ($amount) ? $amount : $response->getAmount();
1693
- $modNovalTransactionStatus = $helper->getModelTransactionStatus();
1694
- $modNovalTransactionStatus->setTransactionNo($txnId)
1695
- ->setOrderId($this->_getOrderId()) // Order number
1696
- ->setTransactionStatus($response->getStatus()) // Transaction status code
1697
- ->setNcNo($response->getNcNo())
1698
- ->setCustomerId($customerId) // Customer number
1699
- ->setPaymentName($this->_code) // Payment name
1700
- ->setAmount($amount) // Amount
1701
- ->setRemoteIp($helper->getRealIpAddr()) // Remote ip
1702
- ->setStoreId($storeId) // Store id
1703
- ->setShopUrl($shopUrl)
1704
- ->setCreatedDate($helper->getCurrentDateTime()) // Created date
1705
- ->save();
1706
- }
1707
-
1708
- /**
1709
- * Log Novalnet payment response data
1710
- *
1711
- * @param varien_object $response
1712
- * @param int $orderId
1713
- * @return null
1714
- */
1715
- public function doTransactionOrderLog($response, $orderId)
1716
- {
1717
- $helper = $this->helper;
1718
- $modNovalTransactionOverview = $helper->getModelTransactionOverview()->loadByAttribute('order_id', $orderId);
1719
- $modNovalTransactionOverview->setTransactionId($response->gettid())
1720
- ->setResponseData(base64_encode(serialize($response->getData())))
1721
- ->setCustomerId($helper->getCustomerId())
1722
- ->setStatus($response->getstatus()) // Transaction status code
1723
- ->setStoreId($helper->getMagentoStoreId())
1724
- ->setShopUrl($helper->getCurrentSiteUrl())
1725
- ->save();
1726
- }
1727
-
1728
- /**
1729
- * Get current infoinstance
1730
- *
1731
- * @param null
1732
- * @return Mage_Payment_Model_Method_Abstract
1733
- */
1734
- private function _getInfoInstance()
1735
- {
1736
- if (!isset($this->infoInstance)) {
1737
- $this->infoInstance = $this->getInfoInstance();
1738
- }
1739
- return $this->infoInstance;
1740
- }
1741
-
1742
- /**
1743
- * Get current order/quote object
1744
- *
1745
- * @param null
1746
- * @return Mage_Payment_Model_Method_Abstract
1747
- */
1748
- private function _getInfoObject()
1749
- {
1750
- $info = $this->_getInfoInstance();
1751
- return ($this->_isPlaceOrder()) ? $info->getOrder() : $info->getQuote();
1752
- }
1753
-
1754
- /**
1755
- * Whether current operation is order placement
1756
- *
1757
- * @param null
1758
- * @return boolean
1759
- */
1760
- private function _isPlaceOrder()
1761
- {
1762
- $info = $this->_getInfoInstance();
1763
- if ($info instanceof Mage_Sales_Model_Quote_Payment) {
1764
- return false;
1765
- } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
1766
- return true;
1767
- }
1768
- }
1769
-
1770
- /**
1771
- * Get grand total amount
1772
- *
1773
- * @param null
1774
- * @return double
1775
- */
1776
- private function _getAmount()
1777
- {
1778
- $info = $this->_getInfoInstance();
1779
- return ($this->_isPlaceOrder())
1780
- ? (double) $info->getOrder()->getBaseGrandTotal()
1781
- : (double) $info->getQuote()->getBaseGrandTotal();
1782
- }
1783
-
1784
- /**
1785
- * Order increment ID getter (either real from order or a reserved from quote)
1786
- *
1787
- * @param null
1788
- * @return int
1789
- */
1790
- private function _getOrderId()
1791
- {
1792
- $info = $this->_getInfoInstance();
1793
- return ($this->_isPlaceOrder()) ? $info->getOrder()->getIncrementId()
1794
- : $this->_getIncrementId();
1795
- }
1796
-
1797
- /**
1798
- * Get payment data for current order
1799
- *
1800
- * @param null
1801
- * @return mixed
1802
- */
1803
- private function _getNnPaymentData()
1804
- {
1805
- $info = $this->_getInfoInstance();
1806
- return ($this->_isPlaceOrder()) ? $info->getOrder()->getPayment() : $info;
1807
- }
1808
-
1809
- /**
1810
- * Retrieve model helper
1811
- *
1812
- * @param null
1813
- * @return Novalnet_Payment_Helper_Data
1814
- */
1815
- protected function _getHelper()
1816
- {
1817
- return Mage::helper('novalnet_payment');
1818
- }
1819
-
1820
- /**
1821
- * Retrieve Assign data helper
1822
- *
1823
- * @param null
1824
- * @return Novalnet_Payment_Helper_AssignData
1825
- */
1826
- protected function _getDataHelper()
1827
- {
1828
- return Mage::helper('novalnet_payment/AssignData');
1829
- }
1830
-
1831
- /**
1832
- * Show expection
1833
- *
1834
- * @param string $text
1835
- * @param boolean $lang
1836
- * @return Mage::throwException
1837
- */
1838
- public function showException($text, $lang = true)
1839
- {
1840
- if ($lang) {
1841
- $text = $this->helper->__($text);
1842
- }
1843
- return Mage::throwException($text);
1844
- }
1845
-
1846
- /**
1847
- * Assign helper utilities needed for the payment process
1848
- *
1849
- * @param null
1850
- * @return Novalnet helper
1851
- */
1852
- public function assignUtilities()
1853
- {
1854
- if (!$this->helper) {
1855
- $this->helper = $this->_getHelper();
1856
- }
1857
- if (!$this->dataHelper) {
1858
- $this->dataHelper = $this->_getDataHelper();
1859
- }
1860
- }
1861
-
1862
- /**
1863
- * Get Billing Address
1864
- *
1865
- * @param null
1866
- * @return string
1867
- */
1868
- private function _getBillingAddress()
1869
- {
1870
- $info = $this->getInfoInstance();
1871
- if ($this->_isPlaceOrder()) {
1872
- return $info->getOrder()->getBillingAddress();
1873
- } else {
1874
- return $info->getQuote()->getBillingAddress();
1875
- }
1876
- }
1877
-
1878
- /**
1879
- * Get all order items
1880
- *
1881
- * @param varien_object $order
1882
- * @return mixed
1883
- */
1884
- private function getPaymentAllItems($order)
1885
- {
1886
- $orderItems = $order->getAllItems();
1887
- return $orderItems;
1888
- }
1889
-
1890
- /**
1891
- * Get redirect URL
1892
- *
1893
- * @param none
1894
- * @return string
1895
- */
1896
- public function getOrderPlaceRedirectUrl()
1897
- {
1898
- $redirectPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
1899
-
1900
- if ($this->_code == Novalnet_Payment_Model_Config::NN_CC) {
1901
- $actionUrl = $this->helper->getUrl(Novalnet_Payment_Model_Config::CC_IFRAME_URL);
1902
- } elseif(in_array($this->_code, $redirectPayment)) {
1903
- $actionUrl = $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_REDIRECT_URL);
1904
- } else {
1905
- $actionUrl = $this->helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_DIRECT_URL);
1906
- }
1907
- return $actionUrl;
1908
- }
1909
-
1910
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetBanktransfer.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetBanktransfer extends Novalnet_Payment_Model_Payment_Method_Abstract
27
- {
28
- protected $_code = Novalnet_Payment_Model_Config::NN_SOFORT;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_SOFORT_CAN_CAPTURE;
30
- protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_SOFORT_CAN_USE_INTERNAL;
31
- protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_SOFORT_CAN_USE_MULTISHIPPING;
32
- protected $_formBlockType = Novalnet_Payment_Model_Config::NN_SOFORT_FORM_BLOCK;
33
- protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_SOFORT_INFO_BLOCK;
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetCc.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetCc extends Novalnet_Payment_Model_Payment_Method_Abstract
27
- {
28
- protected $_code = Novalnet_Payment_Model_Config::NN_CC;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_CC_CAN_CAPTURE;
30
- protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_CC_CAN_USE_INTERNAL;
31
- protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_CC_CAN_USE_MULTISHIPPING;
32
- protected $_formBlockType = Novalnet_Payment_Model_Config::NN_CC_FORM_BLOCK;
33
- protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_CC_INFO_BLOCK;
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetInvoice.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetInvoice extends Novalnet_Payment_Model_Payment_Method_Abstract
27
- {
28
- protected $_code = Novalnet_Payment_Model_Config::NN_INVOICE;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_INVOICE_CAN_CAPTURE;
30
- protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_INVOICE_CAN_USE_MULTISHIPPING;
31
- protected $_formBlockType = Novalnet_Payment_Model_Config::NN_INVOICE_FORM_BLOCK;
32
- protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_INVOICE_INFO_BLOCK;
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetPrepayment.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetPrepayment extends Novalnet_Payment_Model_Payment_Method_Abstract
27
- {
28
- protected $_code = Novalnet_Payment_Model_Config::NN_PREPAYMENT;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_PREPAYMENT_CAN_CAPTURE;
30
- protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_PREPAYMENT_CAN_USE_MULTISHIPPING;
31
- protected $_formBlockType = Novalnet_Payment_Model_Config::NN_PREPAYMENT_FORM_BLOCK;
32
- protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_PREPAYMENT_INFO_BLOCK;
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Payment/Method/NovalnetSepa.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Payment_Method_NovalnetSepa extends Novalnet_Payment_Model_Payment_Method_Abstract
27
- {
28
- protected $_code = Novalnet_Payment_Model_Config::NN_SEPA;
29
- protected $_canCapture = Novalnet_Payment_Model_Config::NN_SEPA_CAN_CAPTURE;
30
- protected $_canUseInternal = Novalnet_Payment_Model_Config::NN_SEPA_CAN_USE_INTERNAL;
31
- protected $_canUseForMultishipping = Novalnet_Payment_Model_Config::NN_SEPA_CAN_USE_MULTISHIPPING;
32
- protected $_formBlockType = Novalnet_Payment_Model_Config::NN_SEPA_FORM_BLOCK;
33
- protected $_infoBlockType = Novalnet_Payment_Model_Config::NN_SEPA_INFO_BLOCK;
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Quote/Address/Total/Nominal.php CHANGED
@@ -18,22 +18,30 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 
 
 
 
 
 
25
  */
26
  class Novalnet_Payment_Model_Quote_Address_Total_Nominal extends Mage_Sales_Model_Quote_Address_Total_Nominal
27
  {
 
28
  /**
29
  * Invoke collector for nominal items
30
  *
31
- * @param Mage_Sales_Model_Quote_Address $address
32
  * @param Mage_Sales_Model_Quote_Address_Total_Nominal
33
  */
34
  public function collect(Mage_Sales_Model_Quote_Address $address)
35
  {
36
- $collector = Mage::getSingleton('sales/quote_address_total_nominal_collector', array(
 
37
  'store' => $address->getQuote()->getStore())
38
  );
39
 
@@ -57,31 +65,32 @@ class Novalnet_Payment_Model_Quote_Address_Total_Nominal extends Mage_Sales_Mode
57
  } else {
58
  $isCompounded = false;
59
  }
60
-
61
  if ((float) $itemRowTotal > 0) {
62
- $label = $model->getLabel();
63
  $helper = Mage::helper('novalnet_payment');
64
  $regularPayment = $helper->__('Regular Payment');
65
  $shipping = $helper->__('Shipping');
66
  $tax = $helper->__('Tax');
67
- if ($label == $regularPayment || $label == $shipping || $label
68
- == $tax) {
69
  $total = $total + $itemRowTotal;
70
  }
71
- $totalDetails[] = new Varien_Object(array(
 
72
  'label' => $label,
73
  'amount' => $itemRowTotal,
74
  'is_compounded' => $isCompounded,
75
- ));
 
76
  }
77
  }
78
- $session = Mage::getSingleton('checkout/session');
79
- $session->setNnRegularAmount($total);
80
- $session->setNnRowAmount($rowTotal);
81
 
82
  $item->setNominalRowTotal($rowTotal);
83
  $item->setBaseNominalRowTotal($baseRowTotal);
84
  $item->setNominalTotalDetails($totalDetails);
 
 
 
85
  }
86
 
87
  return $this;
@@ -90,20 +99,23 @@ class Novalnet_Payment_Model_Quote_Address_Total_Nominal extends Mage_Sales_Mode
90
  /**
91
  * Fetch collected nominal items
92
  *
93
- * @param Mage_Sales_Model_Quote_Address $address
94
  * @return Mage_Sales_Model_Quote_Address_Total_Nominal
95
  */
96
  public function fetch(Mage_Sales_Model_Quote_Address $address)
97
  {
98
  $items = $address->getAllNominalItems();
99
  if ($items) {
100
- $address->addTotal(array(
 
101
  'code' => $this->getCode(),
102
  'title' => Mage::helper('sales')->__('Nominal Items'),
103
  'items' => $items,
104
  'area' => 'footer',
105
- ));
 
106
  }
107
  return $this;
108
  }
 
109
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Nominal items total
29
+ * Collects only items segregated by isNominal property
30
+ * Aggregates row totals per item
31
  */
32
  class Novalnet_Payment_Model_Quote_Address_Total_Nominal extends Mage_Sales_Model_Quote_Address_Total_Nominal
33
  {
34
+
35
  /**
36
  * Invoke collector for nominal items
37
  *
38
+ * @param Mage_Sales_Model_Quote_Address $address
39
  * @param Mage_Sales_Model_Quote_Address_Total_Nominal
40
  */
41
  public function collect(Mage_Sales_Model_Quote_Address $address)
42
  {
43
+ $collector = Mage::getSingleton(
44
+ 'sales/quote_address_total_nominal_collector', array(
45
  'store' => $address->getQuote()->getStore())
46
  );
47
 
65
  } else {
66
  $isCompounded = false;
67
  }
68
+
69
  if ((float) $itemRowTotal > 0) {
70
+ $label = $model->getLabel();
71
  $helper = Mage::helper('novalnet_payment');
72
  $regularPayment = $helper->__('Regular Payment');
73
  $shipping = $helper->__('Shipping');
74
  $tax = $helper->__('Tax');
75
+ if ($label == $regularPayment || $label == $shipping || $label == $tax) {
 
76
  $total = $total + $itemRowTotal;
77
  }
78
+ $totalDetails[] = new Varien_Object(
79
+ array(
80
  'label' => $label,
81
  'amount' => $itemRowTotal,
82
  'is_compounded' => $isCompounded,
83
+ )
84
+ );
85
  }
86
  }
 
 
 
87
 
88
  $item->setNominalRowTotal($rowTotal);
89
  $item->setBaseNominalRowTotal($baseRowTotal);
90
  $item->setNominalTotalDetails($totalDetails);
91
+ // Assign recurring payment amount for Novalnet subscription process (fraud prevention)
92
+ Mage::getSingleton('checkout/session')->setNnRegularAmount($total)
93
+ ->setNnRowAmount($rowTotal);
94
  }
95
 
96
  return $this;
99
  /**
100
  * Fetch collected nominal items
101
  *
102
+ * @param Mage_Sales_Model_Quote_Address $address
103
  * @return Mage_Sales_Model_Quote_Address_Total_Nominal
104
  */
105
  public function fetch(Mage_Sales_Model_Quote_Address $address)
106
  {
107
  $items = $address->getAllNominalItems();
108
  if ($items) {
109
+ $address->addTotal(
110
+ array(
111
  'code' => $this->getCode(),
112
  'title' => Mage::helper('sales')->__('Nominal Items'),
113
  'items' => $items,
114
  'area' => 'footer',
115
+ )
116
+ );
117
  }
118
  return $this;
119
  }
120
+
121
  }
app/code/community/Novalnet/Payment/Model/Recurring.php DELETED
@@ -1,285 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Recurring extends Mage_Core_Model_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Recurring
33
- */
34
- public function _construct()
35
- {
36
- parent::_construct();
37
- $this->_init('novalnet_payment/recurring');
38
- }
39
-
40
- /**
41
- * Perform profile process
42
- *
43
- * @param Mage_Payment_Model_Recurring_Profile $profile
44
- */
45
- public function getProfileProgress($profile)
46
- {
47
- $helper = Mage::helper('novalnet_payment');
48
- $checkoutSession = $helper->getCheckoutSession();
49
- $quote = $checkoutSession->getQuote();
50
- $paymentObj = $quote->getPayment()->getMethodInstance();
51
- $paymentCode = $quote->getPayment()->getMethod();
52
- $subRedirectPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('subscriptionRedirectPayments');
53
-
54
- if ($checkoutSession->getNominalRequest() && $checkoutSession->getNominalResponse()) {
55
- $paymentObj->validateCallbackProcess(ucfirst($paymentCode));
56
- $request = $checkoutSession->getNominalRequest();
57
- $result = $checkoutSession->getNominalResponse();
58
- } else {
59
- $request = $this->_buildRecurringRequest($profile, $paymentObj);
60
- if (in_array($paymentCode, $subRedirectPayments)) {
61
- $checkoutSession->setPaymentReqData($request);
62
- $this->_registerRecurringProfile($profile);
63
- return true;
64
- }
65
- $result = $paymentObj->postRequest($request);
66
- }
67
-
68
- $txnId = trim($result->getTid());
69
- //set profile reference id
70
- $profile->setReferenceId($txnId);
71
- if ($result->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
72
- $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
73
- $statusText = ($result->getStatusText()) ? $result->getStatusText() : $helper->__('successful');
74
- $helper->getCoresession()->addSuccess($statusText);
75
- if ($paymentCode == Novalnet_Payment_Model_Config::NN_SEPA) {
76
- // log sepa refill information for login users
77
- $paymentObj->sepaPaymentRefill();
78
- }
79
-
80
- Mage::getModel('novalnet_payment/ipn')->processIpnRequest($this->_buildPostBackRequestForRecurring($request,$profile, $result, $paymentObj), new Varien_Http_Adapter_Curl(), $request, $result);
81
- // unset form payment method session
82
- $paymentObj->unsetFormMethodSession();
83
- // unset payment request and response values
84
- $paymentObj->unsetPaymentReqResData();
85
- // unset current payment method session
86
- $paymentObj->unsetMethodSession();
87
- // update the inventory
88
- $this->updateInventory($quote);
89
- } else {
90
- $error = $result->getStatusMessage() ? $result->getStatusMessage() : ($result->getStatusDesc() ? $result->getStatusDesc()
91
- : ($result->getStatusText() ? $result->getStatusText() : $this->helper->__('Error in capturing the payment')));
92
- if ($error !== false) {
93
- Mage::throwException($error);
94
- }
95
- }
96
- }
97
-
98
- /**
99
- * To build recurring post back request
100
- *
101
- * @param varien_object $config
102
- * @param Mage_Payment_Model_Recurring_Profile $profile
103
- * @param varien_object $result
104
- * @param varien_object $paymentObj
105
- * @result varien_object
106
- */
107
- protected function _buildPostBackRequestForRecurring($config, $profile, $result, $paymentObj)
108
- {
109
- $request = Mage::getModel('novalnet_payment/novalnet_request');
110
- $shopMode = (!$paymentObj->getNovalnetConfig('live_mode')) ? 1 : 0;
111
- $serverResponse = $result->getTestMode();
112
- $testMode = (((isset($serverResponse) && $serverResponse == 1) || (isset($shopMode)
113
- && $shopMode == 0)) ? 1 : 0 );
114
- $data = $paymentObj->setPaymentAddtionaldata($result, $config);
115
- $data['paidUntil'] = $result->getPaidUntil();
116
- $request->setVendor($config->getVendor())
117
- ->setAuthCode($config->getAuthCode())
118
- ->setProduct($config->getProduct())
119
- ->setTariff($config->getTariff())
120
- ->setKey($config->getKey())
121
- ->setProfileId($profile->getId())
122
- ->setSignupTid($result->getTid())
123
- ->setTid($result->getTid())
124
- ->setStatus($result->getStatus())
125
- ->setAmount($result->getAmount())
126
- ->setTestMode($testMode)
127
- ->setAdditionalData(serialize($data));
128
- return $request;
129
- }
130
-
131
- /**
132
- * Prepare request to gateway
133
- *
134
- * @param Mage_Payment_Model_Recurring_Profile $profile
135
- * @param varien_object $paymentObj
136
- * @return mixed
137
- */
138
- protected function _buildRecurringRequest(Mage_Payment_Model_Recurring_Profile $profile, $paymentObj)
139
- {
140
- $request = Mage::getModel('novalnet_payment/novalnet_request');
141
- $peroidUnit = $profile->getPeriodUnit();
142
- $periodUnitFormat = array("day" => "d", "month" => "m", "year" => "y");
143
-
144
- if ($peroidUnit == "semi_month") {
145
- $tariffPeriod = "14d";
146
- } elseif ($peroidUnit == "week") {
147
- $tariffPeriod = ($profile->getPeriodFrequency() * 7) . "d";
148
- } else {
149
- $tariffPeriod = $profile->getPeriodFrequency() . $periodUnitFormat[$peroidUnit];
150
- }
151
-
152
- $storeId = $paymentObj->helper->getMagentoStoreId();
153
- $originalAmount = round(($profile->getBillingAmount() + $profile->getShippingAmount()
154
- + $profile->getTaxAmount()), 2) * 100;
155
- $initAmount = $profile->getInitAmount();
156
- $amount = !empty($initAmount) ? $this->recurringAmount($profile) : $originalAmount;
157
- $request = $paymentObj->buildRequest(Novalnet_Payment_Model_Config::POST_NORMAL, $storeId, $amount);
158
- $period = $paymentObj->getNovalnetConfig('subsequent_period', true, $storeId);
159
- $subsequentPeriod = !empty($period) ? $period : $tariffPeriod;
160
- $request->setTariffPeriod($tariffPeriod)
161
- ->setTariffPeriod2($subsequentPeriod)
162
- ->setTariffPeriod2Amount($originalAmount)
163
- ->setInput5('profile_id')
164
- ->setInputval5($profile->getId());
165
-
166
- return $request;
167
- }
168
-
169
- /**
170
- * Get Recurring amount
171
- *
172
- * @param int @profile
173
- * @return int
174
- */
175
- public function recurringAmount($profile)
176
- {
177
- return round(($profile->getInitAmount() + $profile->getBillingAmount()
178
- + $profile->getShippingAmount() + $profile->getTaxAmount()), 2) * 100;
179
- }
180
-
181
- /**
182
- * Get Recurring Increment Id
183
- *
184
- * @param int @profile
185
- * @return int
186
- */
187
- public function getRecurringOrderNo($profile)
188
- {
189
- $incrementId = array();
190
- $recurringProfileCollection = Mage::getResourceModel('sales/order_grid_collection')
191
- ->addRecurringProfilesFilter($profile->getId());
192
- foreach ($recurringProfileCollection as $recurringProfileCollectionValue) {
193
- $incrementId[] = $recurringProfileCollectionValue->getIncrementId();
194
- }
195
- return $incrementId;
196
- }
197
-
198
- /**
199
- * Get Sales Order
200
- *
201
- * @param int @incrementId
202
- * @return varien_object
203
- */
204
- public function getOrderByIncrementId($incrementId)
205
- {
206
- $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
207
- return $order;
208
- }
209
-
210
- /**
211
- * Get recurring capture total amount
212
- *
213
- * @param int $lastTransId
214
- * @param varien_object $order
215
- * @return int
216
- */
217
- public function getRecurringCaptureTotal($lastTransId, $order)
218
- {
219
- $profileInfo = Mage::getModel('sales/recurring_profile')->load($lastTransId, 'reference_id');
220
- $billingAmount = $profileInfo->getBillingAmount();
221
-
222
- if (!empty($billingAmount)) {
223
- $amount = round(($billingAmount
224
- + $profileInfo->getShippingAmount() + $profileInfo->getTaxAmount()), 2);
225
- } else {
226
- $amount = $order->getGrandTotal();
227
- }
228
-
229
- Mage::helper('novalnet_payment')->loadTransactionStatus($lastTransId)
230
- ->setAmount($amount)
231
- ->save();
232
- return $amount;
233
- }
234
-
235
- /**
236
- * update the product inventory (stock)
237
- *
238
- * @param varien_object $quote
239
- */
240
- private function updateInventory($quote)
241
- {
242
- foreach ($quote->getAllVisibleItems() as $quoteItem) {
243
- $itemsQtyOrdered = $quoteItem->getQty();
244
- $productId = $quoteItem->getProductId();
245
- break;
246
- }
247
-
248
- if ($productId) {
249
- $stockObj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
250
- $productQtyBefore = (int)$stockObj->getQty();
251
- }
252
-
253
- if (isset($productQtyBefore) && $productQtyBefore > 0) {
254
- $productQtyAfter = (int)($productQtyBefore - $itemsQtyOrdered);
255
- $stockData['qty'] = $productQtyAfter;
256
- $stockObj->setQty($productQtyAfter);
257
- $stockObj->save();
258
- }
259
-
260
- Mage::getSingleton('checkout/session')->unsNnRegularAmount()
261
- ->unsNnRowAmount();
262
- }
263
-
264
- /**
265
- * Register recurring profile and create order
266
- *
267
- * @param Mage_Payment_Model_Recurring_Profile $profile
268
- */
269
- protected function _registerRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
270
- {
271
- $productItemInfo = new Varien_Object;
272
- $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
273
- $productItemInfo->setTaxAmount($profile->getTaxAmount());
274
- $productItemInfo->setShippingAmount($profile->getShippingAmount());
275
- $productItemInfo->setPrice($profile->getBillingAmount());
276
- $order = $profile->createOrder($productItemInfo);
277
- $order->save();
278
-
279
- $profile->addOrderRelation($order->getId());
280
- $checkoutSession = Mage::helper('novalnet_payment')->getCheckoutSession();
281
- $checkoutSession->setRecurringOrderId($order->getIncrementId())
282
- ->setRecurringProfileNumber($profile->getId());
283
- return true;
284
- }
285
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Recurring/Payment.php ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Recurring_Payment
27
+ {
28
+
29
+ /**
30
+ * Submit RP (recurring profile) to the gateway
31
+ *
32
+ * @param Mage_Payment_Model_Recurring_Profile $profile
33
+ * @param Mage_Payment_Model_Info $paymentInfo
34
+ * @return mixed
35
+ */
36
+ public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
37
+ Mage_Payment_Model_Info $paymentInfo)
38
+ {
39
+ $this->helper = Mage::helper('novalnet_payment'); // Novalnet payment helper
40
+ $this->paymentInfo = $paymentInfo; // Get current payment instance
41
+ $this->requestModel = $this->helper->getModel('Service_Api_Request'); // Get Novalnet Api request model
42
+ $this->responseModel = $this->helper->getModel('Service_Api_Response'); // Get Novalnet Api request model
43
+
44
+ $this->payment = $paymentInfo->getQuote()->getPayment(); // Get payment object
45
+ $this->code = $this->payment->getMethodInstance()->getCode(); // Payment method code
46
+ $methodSession = $this->helper->getMethodSession($this->code); // Payment method session
47
+
48
+ if ($methodSession->hasOrderAmount() && $methodSession->getOrderAmount()) {
49
+ // Get Novalnet Api request model
50
+ $fraudPreventionModel = $this->helper->getModel('Service_Api_FraudPrevention');
51
+ // Validate fraud prevention response process
52
+ $fraudPreventionModel->validateCallbackProcess($methodSession);
53
+ $request = $methodSession->getPaymentReqData(); // Recurring profile payment request
54
+ $response = $methodSession->getPaymentResData(); // Recurring profile payment response
55
+ } else {
56
+ $request = $this->buildRecurringRequest($profile); // Get RP payment request
57
+ $redirectPayments = array(Novalnet_Payment_Model_Config::NN_CC, Novalnet_Payment_Model_Config::NN_PAYPAL);
58
+
59
+ if (in_array($this->code, $redirectPayments)) {
60
+ $order = $this->setOriginalPrice($profile); // Get order with original product price values
61
+ $methodSession->setOrderId($order->getId())
62
+ ->setPaymentReqData($request)
63
+ ->setIncrementId($order->getIncrementId());
64
+ return true;
65
+ } else {
66
+ // Send RP payment request to Novalnet gateway
67
+ $response = $this->payment->getMethodInstance()->postRequest($request);
68
+ }
69
+ }
70
+ $this->validateRecurringResponse($profile, $request, $response); // Validate the RP response
71
+ }
72
+
73
+ /**
74
+ * Prepare RP payment request
75
+ *
76
+ * @param Mage_Payment_Model_Recurring_Profile $profile
77
+ * @return Varien_Object $request
78
+ */
79
+ protected function buildRecurringRequest($profile)
80
+ {
81
+ $subsequentPeriod = $this->requestModel->getNovalnetConfig('subsequent_period', true);
82
+ $tariffPeriod = $this->getRecurringPeriod($profile); // Get subscription payment periods
83
+ // Get RP order amount
84
+ $subsequentAmount = $amount = round(
85
+ ($profile->getBillingAmount() + $profile->getShippingAmount() + $profile->getTaxAmount()), 2
86
+ ) * 100;
87
+ if ($profile->getInitAmount()) { // Add initial fees if exist
88
+ $amount = round(
89
+ ($profile->getInitAmount() + $profile->getBillingAmount()
90
+ + $profile->getShippingAmount() + $profile->getTaxAmount()), 2
91
+ ) * 100;
92
+ }
93
+ // Build RP payment request
94
+ $request = $this->requestModel->getPayportParams($this->paymentInfo, $this->code, $amount);
95
+ $request->setTariffPeriod($tariffPeriod)
96
+ ->setTariffPeriod2($subsequentPeriod ? $subsequentPeriod : $tariffPeriod)
97
+ ->setTariffPeriod2Amount($subsequentAmount)
98
+ ->setInput4('profile_id')
99
+ ->setInputval4($profile->getId());
100
+
101
+ return $request;
102
+ }
103
+
104
+ /**
105
+ * Get subscription payment periods
106
+ *
107
+ * @param Mage_Payment_Model_Recurring_Profile $profile
108
+ * @param Varien_Object $paymentObj
109
+ * @return string $tariffPeriod
110
+ */
111
+ protected function getRecurringPeriod($profile)
112
+ {
113
+ // Get recurring profile period informations
114
+ $periodUnitFormat = array("day" => "d", "month" => "m", "year" => "y");
115
+
116
+ if ($profile->getPeriodUnit() == "semi_month") {
117
+ $tariffPeriod = "14d";
118
+ } elseif ($profile->getPeriodUnit() == "week") {
119
+ $tariffPeriod = ($profile->getPeriodFrequency() * 7) . "d";
120
+ } else {
121
+ $tariffPeriod = $profile->getPeriodFrequency() . $periodUnitFormat[$profile->getPeriodUnit()];
122
+ }
123
+
124
+ return $tariffPeriod;
125
+ }
126
+
127
+ /**
128
+ * Verify the RP payment process
129
+ *
130
+ * @param Mage_Payment_Model_Recurring_Profile $profile
131
+ * @param Varien_Object $request
132
+ * @param Varien_Object $response
133
+ * @return none
134
+ */
135
+ protected function validateRecurringResponse($profile, $request, $response)
136
+ {
137
+ $profile->setReferenceId(trim($response->getTid())); // Set profile reference id
138
+
139
+ // Novalnet successful transaction
140
+ if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
141
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
142
+ $this->recurringPaymentCapture($profile, $request, $response); // Capture RP payment
143
+ $this->helper->unsetMethodSession($this->code); // Unset current payment method session
144
+ $this->updateInventory($this->paymentInfo->getQuote()); // Update the product inventory
145
+ $statusText = $this->responseModel->getStatusText($response); // Get payment transaction status message
146
+ $this->helper->getCoreSession()->addSuccess($statusText);
147
+ } else { // Novalnet unsuccessful transaction
148
+ // Get payment transaction status message
149
+ $statusText = $this->responseModel->getUnSuccessPaymentText($response);
150
+ $this->helper->showException($statusText);
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Capture the RP payment
156
+ *
157
+ * @param Mage_Payment_Model_Recurring_Profile $profile
158
+ * @param Varien_Object $request
159
+ * @param Varien_Object $response
160
+ * @return none
161
+ */
162
+ protected function recurringPaymentCapture($profile, $request, $response)
163
+ {
164
+ $order = $this->setOriginalPrice($profile); // Get order with original product price values
165
+ $status = $this->requestModel->getNovalnetConfig('order_status'); // Set order status
166
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $status, 'Payment was successful')->save();
167
+ $payment = $order->getPayment(); // Get payment object
168
+
169
+ $this->responseModel->logTransactionStatus($response, $order); // Log Novalnet payment transaction informations
170
+ // Log Novalnet payment transaction traces informations
171
+ $this->responseModel->logTransactionTraces($request, $response, $order);
172
+
173
+ // Novalnet payment transaction mode in Novalnet global configuration
174
+ $shopMode = $this->requestModel->getNovalnetConfig('live_mode', true);
175
+ $testMode = ($response->getTestMode() == 1 || $shopMode == 0) ? 1 : 0; // Get Novalnet payment transaction mode
176
+ // Get Novalnet payment additional informations
177
+ $data = $this->responseModel->getPaymentAddtionaldata($response, $request, $testMode);
178
+ $data['paidUntil'] = $response->getNextSubsCycle() ? $response->getNextSubsCycle() : $response->getPaidUntil();
179
+
180
+ // Save the additional transaction informations for reference
181
+ $payment->setPreparedMessage($this->createIpnComment($response->getTidStatus(), $order))
182
+ ->setAdditionalData(serialize($data))
183
+ ->setAdditionalInformation('subs_id', $response->getSubsId())
184
+ ->save();
185
+
186
+ // Save the transaction informations
187
+ $this->responseModel->capturePayment($order, $response);
188
+ // Log affiliate user informations
189
+ $this->responseModel->logAffiliateUserInfo($request);
190
+
191
+ // Send order email for successful Novalnet transaction
192
+ Mage::dispatchEvent('novalnet_sales_order_email', array('order' => $order));
193
+ }
194
+
195
+ /**
196
+ * Generate an "IPN" comment with additional explanation.
197
+ * Returns the generated comment or order status history object
198
+ *
199
+ * @param string $paymentStatus
200
+ * @param Varien_Object $order
201
+ * @param string $paymentStatus
202
+ * @param boolean $addToHistory
203
+ * @return string
204
+ */
205
+ public function createIpnComment($paymentStatus, $order, $comment = '', $addToHistory = false)
206
+ {
207
+ $message = Mage::helper('novalnet_payment')->__('IPN "%s".', $paymentStatus);
208
+ if ($comment) {
209
+ $message .= ' ' . $comment;
210
+ }
211
+ if ($addToHistory) {
212
+ $message = $order->addStatusHistoryComment($message);
213
+ $message->setIsCustomerNotified(null);
214
+ }
215
+ return $message;
216
+ }
217
+
218
+ /**
219
+ * Create order with original product price values
220
+ *
221
+ * @param Mage_Payment_Model_Recurring_Profile $profile
222
+ * @return Varien_Object $order
223
+ */
224
+ protected function setOriginalPrice($profile)
225
+ {
226
+ $productItemInfo = new Varien_Object;
227
+ $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
228
+ $productItemInfo->setTaxAmount($profile->getTaxAmount());
229
+ $productItemInfo->setShippingAmount($profile->getShippingAmount());
230
+ $productItemInfo->setPrice($profile->getBillingAmount());
231
+ // Create an order with respected price values
232
+ $order = $profile->createOrder($productItemInfo);
233
+ $order->save();
234
+ // Add related orders to profile
235
+ $profile->addOrderRelation($order->getId());
236
+
237
+ return $order;
238
+ }
239
+
240
+ /**
241
+ * Update the product inventory (stock)
242
+ *
243
+ * @param Varien_Object $quote
244
+ * @return none
245
+ */
246
+ protected function updateInventory($quote)
247
+ {
248
+ foreach ($quote->getAllVisibleItems() as $quoteItem) {
249
+ $itemsQtyOrdered = $quoteItem->getQty();
250
+ $productId = $quoteItem->getProductId();
251
+ break;
252
+ }
253
+
254
+ if ($productId) {
255
+ $stockObj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
256
+ $productQtyBefore = (int) $stockObj->getQty();
257
+ }
258
+
259
+ if (isset($productQtyBefore) && $productQtyBefore > 0) {
260
+ $productQtyAfter = (int) ($productQtyBefore - $itemsQtyOrdered);
261
+ $stockObj->setQty($productQtyAfter);
262
+ $stockObj->save();
263
+ }
264
+ }
265
+
266
+ }
app/code/community/Novalnet/Payment/Model/Recurring/Profile.php CHANGED
@@ -18,13 +18,14 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Model_Recurring_Profile extends Mage_Sales_Model_Recurring_Profile
27
  {
 
28
  /**
29
  * Initialize new order based on profile data
30
  *
@@ -73,7 +74,7 @@ class Novalnet_Payment_Model_Recurring_Profile extends Mage_Sales_Model_Recurrin
73
  $payment = Mage::getModel('sales/order_payment')
74
  ->setMethod($this->getMethodCode());
75
 
76
- $transferDataKays = array(
77
  'store_id', 'store_name', 'customer_id', 'customer_email',
78
  'customer_firstname', 'customer_lastname', 'customer_middlename', 'customer_prefix',
79
  'customer_suffix', 'customer_taxvat', 'customer_gender', 'customer_is_guest',
@@ -85,7 +86,7 @@ class Novalnet_Payment_Model_Recurring_Profile extends Mage_Sales_Model_Recurrin
85
  );
86
 
87
  $orderInfo = $this->getOrderInfo();
88
- foreach ($transferDataKays as $key) {
89
  if (isset($orderInfo[$key])) {
90
  $order->setData($key, $orderInfo[$key]);
91
  } elseif (isset($shippingInfo[$key])) {
@@ -94,24 +95,24 @@ class Novalnet_Payment_Model_Recurring_Profile extends Mage_Sales_Model_Recurrin
94
  }
95
 
96
  $order->setStoreId($this->getStoreId())
97
- ->setState(Mage_Sales_Model_Order::STATE_NEW)
98
- ->setBaseToOrderRate($this->getInfoValue('order_info', 'base_to_quote_rate'))
99
- ->setStoreToOrderRate($this->getInfoValue('order_info', 'store_to_quote_rate'))
100
- ->setOrderCurrencyCode($this->getInfoValue('order_info', 'quote_currency_code'))
101
- ->setBaseSubtotal($billingAmount)
102
- ->setSubtotal($billingAmount)
103
- ->setBaseShippingAmount($shippingAmount)
104
- ->setShippingAmount($shippingAmount)
105
- ->setBaseTaxAmount($taxAmount)
106
- ->setTaxAmount($taxAmount)
107
- ->setBaseGrandTotal($grandTotal)
108
- ->setGrandTotal($grandTotal)
109
- ->setIsVirtual($isVirtual)
110
- ->setWeight($weight)
111
- ->setTotalQtyOrdered($this->getInfoValue('order_info', 'items_qty'))
112
- ->setBillingAddress($billingAddress)
113
- ->setShippingAddress($shippingAddress)
114
- ->setPayment($payment);
115
 
116
  foreach ($items as $item) {
117
  $order->addItem($item);
@@ -123,25 +124,24 @@ class Novalnet_Payment_Model_Recurring_Profile extends Mage_Sales_Model_Recurrin
123
  /**
124
  * Get the reqular order items
125
  *
126
- * @param varien_object $itemInfo
127
  * @return mixed
128
  */
129
  protected function _getRegularItem($itemInfo)
130
  {
131
  $price = $itemInfo->getPrice() ? $itemInfo->getPrice() : $this->getBillingAmount();
132
- $shippingAmount = $itemInfo->getShippingAmount() ? $itemInfo->getShippingAmount()
133
- : $this->getShippingAmount();
134
  $taxAmount = $itemInfo->getTaxAmount() ? $itemInfo->getTaxAmount() : $this->getTaxAmount();
135
 
136
  $qtyOrdered = $this->getInfoValue('order_info', 'items_qty');
137
- $pricevalue = ($price / $qtyOrdered);
138
 
139
  $item = Mage::getModel('sales/order_item')
140
  ->setData($this->getOrderItemInfo())
141
  ->setQtyOrdered($this->getInfoValue('order_item_info', 'qty'))
142
  ->setBaseOriginalPrice($this->getInfoValue('order_item_info', 'price'))
143
- ->setPrice($pricevalue)
144
- ->setBasePrice($pricevalue)
145
  ->setRowTotal($price)
146
  ->setBaseRowTotal($price)
147
  ->setTaxAmount($taxAmount)
@@ -149,4 +149,5 @@ class Novalnet_Payment_Model_Recurring_Profile extends Mage_Sales_Model_Recurrin
149
  ->setId(null);
150
  return $item;
151
  }
 
152
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_Model_Recurring_Profile extends Mage_Sales_Model_Recurring_Profile
27
  {
28
+
29
  /**
30
  * Initialize new order based on profile data
31
  *
74
  $payment = Mage::getModel('sales/order_payment')
75
  ->setMethod($this->getMethodCode());
76
 
77
+ $transferDataKeys = array(
78
  'store_id', 'store_name', 'customer_id', 'customer_email',
79
  'customer_firstname', 'customer_lastname', 'customer_middlename', 'customer_prefix',
80
  'customer_suffix', 'customer_taxvat', 'customer_gender', 'customer_is_guest',
86
  );
87
 
88
  $orderInfo = $this->getOrderInfo();
89
+ foreach ($transferDataKeys as $key) {
90
  if (isset($orderInfo[$key])) {
91
  $order->setData($key, $orderInfo[$key]);
92
  } elseif (isset($shippingInfo[$key])) {
95
  }
96
 
97
  $order->setStoreId($this->getStoreId())
98
+ ->setState(Mage_Sales_Model_Order::STATE_NEW)
99
+ ->setBaseToOrderRate($this->getInfoValue('order_info', 'base_to_quote_rate'))
100
+ ->setStoreToOrderRate($this->getInfoValue('order_info', 'store_to_quote_rate'))
101
+ ->setOrderCurrencyCode($this->getInfoValue('order_info', 'quote_currency_code'))
102
+ ->setBaseSubtotal($billingAmount)
103
+ ->setSubtotal($billingAmount)
104
+ ->setBaseShippingAmount($shippingAmount)
105
+ ->setShippingAmount($shippingAmount)
106
+ ->setBaseTaxAmount($taxAmount)
107
+ ->setTaxAmount($taxAmount)
108
+ ->setBaseGrandTotal($grandTotal)
109
+ ->setGrandTotal($grandTotal)
110
+ ->setIsVirtual($isVirtual)
111
+ ->setWeight($weight)
112
+ ->setTotalQtyOrdered($this->getInfoValue('order_info', 'items_qty'))
113
+ ->setBillingAddress($billingAddress)
114
+ ->setShippingAddress($shippingAddress)
115
+ ->setPayment($payment);
116
 
117
  foreach ($items as $item) {
118
  $order->addItem($item);
124
  /**
125
  * Get the reqular order items
126
  *
127
+ * @param varien_object $itemInfo
128
  * @return mixed
129
  */
130
  protected function _getRegularItem($itemInfo)
131
  {
132
  $price = $itemInfo->getPrice() ? $itemInfo->getPrice() : $this->getBillingAmount();
133
+ $shippingAmount = $itemInfo->getShippingAmount() ? $itemInfo->getShippingAmount() : $this->getShippingAmount();
 
134
  $taxAmount = $itemInfo->getTaxAmount() ? $itemInfo->getTaxAmount() : $this->getTaxAmount();
135
 
136
  $qtyOrdered = $this->getInfoValue('order_info', 'items_qty');
137
+ $priceValue = ($price / $qtyOrdered);
138
 
139
  $item = Mage::getModel('sales/order_item')
140
  ->setData($this->getOrderItemInfo())
141
  ->setQtyOrdered($this->getInfoValue('order_item_info', 'qty'))
142
  ->setBaseOriginalPrice($this->getInfoValue('order_item_info', 'price'))
143
+ ->setPrice($priceValue)
144
+ ->setBasePrice($priceValue)
145
  ->setRowTotal($price)
146
  ->setBaseRowTotal($price)
147
  ->setTaxAmount($taxAmount)
149
  ->setId(null);
150
  return $item;
151
  }
152
+
153
  }
app/code/community/Novalnet/Payment/Model/Resource/Affiliate.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Affiliate extends Mage_Core_Model_Mysql4_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Resource_Affiliate
33
- */
34
- public function _construct()
35
- {
36
- $this->_init('novalnet_payment/aff_account_detail', 'id');
37
- }
38
-
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Resource/Affiliateuser.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Affiliateuser extends Mage_Core_Model_Mysql4_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Resource_Affiliateuser
33
- */
34
- public function _construct()
35
- {
36
- $this->_init('novalnet_payment/aff_user_detail', 'id');
37
- }
38
-
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Resource/Amountchanged.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Amountchanged extends Mage_Core_Model_Mysql4_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Resource_Amountchanged
33
- */
34
- public function _construct()
35
- {
36
- $this->_init('novalnet_payment/amountchanged', 'id');
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Resource/Callback.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Callback extends Mage_Core_Model_Mysql4_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Resource_Callback
33
- */
34
- public function _construct()
35
- {
36
- $this->_init('novalnet_payment/callback', 'id');
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Resource/Recurring.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Recurring extends Mage_Core_Model_Mysql4_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Resource_Recurring
33
- */
34
- public function _construct()
35
- {
36
- $this->_init('novalnet_payment/recurring', 'id');
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Resource/Separefill.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Separefill extends Mage_Core_Model_Mysql4_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Resource_Separefill
33
- */
34
- public function _construct()
35
- {
36
- $this->_init('novalnet_payment/separefill', 'id');
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Resource/Transactionoverview.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Transactionoverview extends Mage_Core_Model_Mysql4_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Resource_Transactionoverview
33
- */
34
- public function _construct()
35
- {
36
- $this->_init('novalnet_payment/order_log', 'nn_log_id');
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Resource/Transactionstatus.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Resource_Transactionstatus extends Mage_Core_Model_Mysql4_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Resource_Transactionstatus
33
- */
34
- public function _construct()
35
- {
36
- $this->_init('novalnet_payment/transaction_status', 'nn_txn_id');
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Sales/Order/Creditmemo/Total/Grand.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Sales
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Sales_Order_Creditmemo_Total_Grand extends Mage_Sales_Model_Order_Creditmemo_Total_Grand
27
- {
28
- public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
29
- {
30
- $order = $creditmemo->getOrder();
31
- $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
32
-
33
- if (preg_match("/novalnet/i", $paymentMethod)) {
34
- $helper = Mage::helper('novalnet_payment');
35
- $orderItems = $order->getAllItems();
36
- $nominalItem = $helper->checkNominalItem($orderItems);
37
- $redirectPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
38
- !$nominalItem ? array_push($redirectPayments, Novalnet_Payment_Model_Config::NN_CC) : $redirectPayments;
39
-
40
- if (in_array($paymentMethod, $redirectPayments)) {
41
- return parent::collect($creditmemo);
42
- }
43
-
44
- if ($nominalItem) {
45
- $order->setTotalInvoiced($order->getTotalPaid());
46
- }
47
-
48
- $amountvalue = $helper->getAmountCollection($order->getId(), 1, NULL);
49
-
50
- if (!empty($amountvalue)) {
51
- $order->setTotalInvoiced($amountvalue);
52
- $totalRefunded = (int)$order->getTotalRefunded();
53
- $captureAmount = empty($totalRefunded) ? $amountvalue : 0;
54
-
55
- $creditmemo->setSubtotal($captureAmount)
56
- ->setShippingAmount(0)
57
- ->setBaseShippingAmount(0)
58
- ->setTaxAmount(0)
59
- ->setBaseTaxAmount(0)
60
- ->setBaseSubtotal($captureAmount)
61
- ->setBaseGrandTotal($captureAmount)
62
- ->setGrandTotal($captureAmount);
63
- }
64
- }
65
-
66
- return parent::collect($creditmemo);
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Sales/Order/Invoice.php DELETED
@@ -1,98 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Sales_Order_Invoice extends Mage_Sales_Model_Order_Invoice
27
- {
28
- /**
29
- * Pay invoice
30
- *
31
- * @return Mage_Sales_Model_Order_Invoice
32
- */
33
- public function pay()
34
- {
35
- if ($this->_wasPayCalled) {
36
- return $this;
37
- }
38
- $this->_wasPayCalled = true;
39
-
40
- $invoiceState = self::STATE_PAID;
41
- if ($this->getOrder()->getPayment()->hasForcedState()) {
42
- $invoiceState = $this->getOrder()->getPayment()->getForcedState();
43
- }
44
-
45
- $paymentCode = $this->getOrder()->getPayment()->getMethodInstance()->getCode();
46
- $helper = Mage::helper('novalnet_payment');
47
- $countofvalue = $helper->getAmountCollection($this->getOrder()->getId(), NULL, NULL);
48
- $tidPayment = Mage::app()->getRequest()->getParam('tid_payment');
49
- if ($paymentCode == Novalnet_Payment_Model_Config::NN_INVOICE && $countofvalue
50
- == 0 && !$tidPayment) {
51
- $this->setState(1);
52
- } else {
53
- $this->setState($invoiceState);
54
- }
55
-
56
- $captrueAmount = Mage::app()->getRequest()->getParam('amount');
57
- $subsBilling = Mage::app()->getRequest()->getParam('subs_billing');
58
- $paymentType = Mage::app()->getRequest()->getParam('payment_type');
59
-
60
- $invoicePayments = array(
61
- Novalnet_Payment_Model_Config::NN_PREPAYMENT,
62
- Novalnet_Payment_Model_Config::NN_INVOICE
63
- );
64
- $directPayment = array(
65
- Novalnet_Payment_Model_Config::NN_SEPA,
66
- );
67
- $subproduct = 0;
68
- if ($helper->checkIsAdmin()) {
69
- $orderItems = $this->getOrder()->getAllItems();
70
- $nominalItem = $helper->checkNominalItem($orderItems);
71
- $subproduct = $nominalItem ? 1 : 0;
72
- }
73
-
74
- $this->getOrder()->getPayment()->pay($this);
75
- if ($captrueAmount && in_array($paymentCode, $invoicePayments) && $countofvalue
76
- != 0) {
77
- $amount = $helper->getAmountCollection($this->getOrder()->getId(), 1, NULL);
78
- $this->getOrder()->setTotalPaid($amount);
79
- $this->getOrder()->setBaseTotalPaid($amount);
80
- } else if ($countofvalue == 1 && in_array($paymentCode, $directPayment)) {
81
- $amount = $helper->getAmountCollection($this->getOrder()->getId(), 1, NULL);
82
- $this->getOrder()->setTotalPaid($amount);
83
- $this->getOrder()->setBaseTotalPaid($amount);
84
- } else if ($subproduct || $subsBilling || $paymentType == "INVOICE_CREDIT") {
85
- $lastTranId = $this->getOrder()->getPayment()->getLastTransId();
86
- $amount = $helper->getModelRecurring()->getRecurringCaptureTotal($lastTranId,$this->getOrder());
87
- $this->getOrder()->setTotalPaid($amount);
88
- $this->getOrder()->setBaseTotalPaid($amount);
89
- } else {
90
- $this->getOrder()->setTotalPaid($this->getOrder()->getTotalPaid() + $this->getGrandTotal());
91
- $this->getOrder()->setBaseTotalPaid(
92
- $this->getOrder()->getBaseTotalPaid() + $this->getBaseGrandTotal()
93
- );
94
- }
95
- Mage::dispatchEvent('sales_order_invoice_pay', array($this->_eventObject => $this));
96
- return $this;
97
- }
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Sales/Order/Payment.php DELETED
@@ -1,161 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Sales_Order_Payment extends Mage_Sales_Model_Order_Payment
27
- {
28
- /**
29
- * Register capture notification
30
- *
31
- * @param float $amount
32
- * @param mixed $skipFraudDetection
33
- * @return Mage_Sales_Model_Order_Payment
34
- */
35
- public function registerCaptureNotification($amount, $skipFraudDetection = false)
36
- {
37
- $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $this->getAuthorizationTransaction()
38
- );
39
-
40
- $order = $this->getOrder();
41
- $payment = $order->getPayment();
42
- $paymentObj = $payment->getMethodInstance();
43
- $magentoVersion = Mage::helper('novalnet_payment')->getMagentoVersion();
44
- $captureMode = (version_compare($magentoVersion, '1.6', '<')) ? false : true;
45
-
46
- $txnId = $this->getTransactionId();
47
- $amount = (float) $amount;
48
- $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
49
- if (!preg_match("/novalnet/i", $paymentMethod)) {
50
- return parent::registerCaptureNotification($amount);
51
- }
52
- $statuscode = Mage::getSingleton('core/session')->getStatusCode();
53
- $invoice = false;
54
- if (!$this->getIsTransactionPending()) {
55
- $invoice = $this->_getInvoiceForTransactionId($this->getTransactionId());
56
- // register new capture
57
- if (!$invoice && $statuscode == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
58
- && $paymentMethod != Novalnet_Payment_Model_Config::NN_PREPAYMENT) {
59
- if ($this->_isCaptureFinal($amount)) {
60
- $payment->setTransactionId($txnId) // Add capture text to make the new transaction
61
- ->setIsTransactionClosed($captureMode) // Close the transaction
62
- ->capture(null)
63
- ->save();
64
- } else {
65
- $this->setIsFraudDetected(true);
66
- $this->_updateTotals(array('base_amount_paid_online' => $amount));
67
- }
68
- }
69
- }
70
- $status = true;
71
- $setOrderAfterStatus = $paymentObj->getNovalnetConfig('order_status') ? $paymentObj->getNovalnetConfig('order_status')
72
- : Mage_Sales_Model_Order::STATE_PROCESSING; // If after status is empty set default status
73
- $state = Mage_Sales_Model_Order::STATE_PROCESSING;
74
- $payment->setTransactionId($txnId)
75
- ->setLastTransId($txnId)
76
- ->setParentTransactionId(null)
77
- ->save();
78
- $message = '';
79
- if ($this->getIsTransactionPending()) {
80
- $message = Mage::helper('sales')->__('Capturing amount of %s is pending approval on gateway.', $this->_formatPrice($amount));
81
- $state = Mage_Sales_Model_Order::STATE_NEW;
82
- if ($this->getIsFraudDetected()) {
83
- $message = Mage::helper('sales')->__('Order is suspended as its capture amount %s is suspected to be fraudulent.', $this->_formatPrice($amount));
84
- $status = Mage_Sales_Model_Order::STATUS_FRAUD;
85
- }
86
- } else if ($statuscode == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
87
- $message = Mage::helper('sales')->__('Registered notification about captured amount of %s.', $this->_formatPrice($amount));
88
- $state = Mage_Sales_Model_Order::STATE_PROCESSING;
89
- if ($this->getIsFraudDetected()) {
90
- $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
91
- $message = Mage::helper('sales')->__('Order is suspended as its capture amount %s is suspected to be fraudulent.', $this->_formatPrice($amount));
92
- $status = Mage_Sales_Model_Order::STATUS_FRAUD;
93
- }
94
- // register capture for an existing invoice
95
- if ($invoice && Mage_Sales_Model_Order_Invoice::STATE_OPEN == $invoice->getState()) {
96
- $invoice->pay();
97
- $this->_updateTotals(array('base_amount_paid_online' => $amount));
98
- $order->addRelatedObject($invoice);
99
- }
100
- }
101
- $order->setState($state, $setOrderAfterStatus, $message);
102
- Mage::getSingleton('core/session')->setStatusCode('');
103
- return $this;
104
- }
105
-
106
- /**
107
- * Void payment either online or offline (process void notification)
108
- * NOTE: that in some cases authorization can be voided after a capture. In such case it makes sense to use
109
- * the amount void amount, for informational purposes.
110
- * Updates payment totals, updates order status and adds proper comments
111
- *
112
- * @param bool $isOnline
113
- * @param float $amount
114
- * @param string $gatewayCallback
115
- * @return Mage_Sales_Model_Order_Payment
116
- */
117
- protected function _void($isOnline, $amount = null, $gatewayCallback = 'void')
118
- {
119
- $order = $this->getOrder();
120
- $storeId = $order->getStoreId();
121
- $payment = $order->getPayment();
122
- $paymentObj = $payment->getMethodInstance();
123
- $setOrderAfterStatus = $paymentObj->getNovalnetConfig('void_status',true,$storeId);
124
- $authTransaction = $this->getAuthorizationTransaction();
125
- $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID, $authTransaction);
126
- $this->setShouldCloseParentTransaction(true);
127
-
128
- // attempt to void
129
- if ($isOnline) {
130
- $this->getMethodInstance()->setStore($order->getStoreId())->$gatewayCallback($this);
131
- }
132
- if ($this->_isTransactionExists()) {
133
- return $this;
134
- }
135
-
136
- // if the authorization was untouched, we may assume voided amount = order grand total
137
- // but only if the payment auth amount equals to order grand total
138
- if ($authTransaction && ($order->getBaseGrandTotal() == $this->getBaseAmountAuthorized())
139
- && (0 == $this->getBaseAmountCanceled())) {
140
- if ($authTransaction->canVoidAuthorizationCompletely()) {
141
- $amount = (float)$order->getBaseGrandTotal();
142
- }
143
- }
144
-
145
- if ($amount) {
146
- $amount = $this->_formatAmount($amount);
147
- }
148
-
149
- // update transactions, order state and add comments
150
- $transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID, null, true);
151
- $message = $this->hasMessage() ? $this->getMessage() : Mage::helper('sales')->__('Voided authorization.');
152
- $message = $this->_prependMessage($message);
153
- if ($amount) {
154
- $message .= ' ' . Mage::helper('sales')->__('Amount: %s.', $this->_formatPrice($amount));
155
- }
156
- $setOrderAfterStatus = $setOrderAfterStatus ? $setOrderAfterStatus : true;
157
- $message = $this->_appendTransactionToMessage($transaction, $message);
158
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $setOrderAfterStatus, $message);
159
- return $this;
160
- }
161
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Sales/Order/Pdf/Creditmemo.php DELETED
@@ -1,142 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Sales_Order_Pdf_Creditmemo extends Mage_Sales_Model_Order_Pdf_Creditmemo
27
- {
28
- /**
29
- * Return PDF document
30
- *
31
- * @param array $creditmemos
32
- * @return Zend_Pdf
33
- */
34
- public function getPdf($creditmemos = array())
35
- {
36
- $this->_beforeGetPdf();
37
- $this->_initRenderer('creditmemo');
38
-
39
- $pdf = new Zend_Pdf();
40
- $this->_setPdf($pdf);
41
- $style = new Zend_Pdf_Style();
42
- $this->_setFontBold($style, 10);
43
-
44
- foreach ($creditmemos as $creditmemo) {
45
- if ($creditmemo->getStoreId()) {
46
- Mage::app()->getLocale()->emulate($creditmemo->getStoreId());
47
- Mage::app()->setCurrentStore($creditmemo->getStoreId());
48
- }
49
- $page = $this->newPage();
50
- $order = $creditmemo->getOrder();
51
- /* Add image */
52
- $this->insertLogo($page, $creditmemo->getStore());
53
- /* Add address */
54
- $this->insertAddress($page, $creditmemo->getStore());
55
- /* Add head */
56
- $this->insertOrder(
57
- $page,
58
- $order,
59
- Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_CREDITMEMO_PUT_ORDER_ID, $order->getStoreId())
60
- );
61
- /* Add document text and number */
62
- $this->insertDocumentNumber(
63
- $page,
64
- Mage::helper('sales')->__('Credit Memo # ') . $creditmemo->getIncrementId()
65
- );
66
- /* Add table head */
67
- $this->_drawHeader($page);
68
- /* Add body */
69
- foreach ($creditmemo->getAllItems() as $item){
70
- if ($item->getOrderItem()->getParentItem()) {
71
- continue;
72
- }
73
- /* Draw item */
74
- $this->_drawItem($item, $page, $order);
75
- $page = end($pdf->pages);
76
- }
77
- /* Add totals */
78
- $this->insertTotals($page, $creditmemo);
79
- $helper = Mage::helper('novalnet_payment');
80
- $amountchangedvalue = $helper->getAmountCollection($order->getId(), 1, NULL);
81
- if ($amountchangedvalue) {
82
- $lineBlock = $this->amountRefundUpdateDetails($order,$amountchangedvalue,$creditmemo);
83
- $this->y -= 1;
84
- $page = $this->drawLineBlocks($page, array($lineBlock));
85
- }
86
- }
87
- $this->_afterGetPdf();
88
- if ($creditmemo->getStoreId()) {
89
- Mage::app()->getLocale()->revert();
90
- }
91
- return $pdf;
92
- }
93
-
94
- /**
95
- * amount refund details append in pdf
96
- *
97
- * @param varien_object $order
98
- * @param int $amountchangedvalue
99
- * @param varien_object $creditmemo
100
- * @return Zend_Pdf
101
- */
102
- private function amountRefundUpdateDetails($order,$amountchangedvalue,$creditmemo)
103
- {
104
- $currency = $order->getOrderCurrency();
105
- $currencyCode = $currency->getCurrencyCode();
106
- $currencySymbol = Mage::app()->getLocale()->currency($currencyCode)->getSymbol();
107
- $lineBlock['lines'][] = array(
108
- array(
109
- 'text' => Mage::helper('sales')->__('Novalnet refunded Amount').':',
110
- 'feed' => 475,
111
- 'align' => 'right',
112
- 'font_size' => 10,
113
- 'font' => 'bold'
114
- ),
115
- array(
116
- 'text' => $currencySymbol.number_format($creditmemo->getGrandTotal(),2),
117
- 'feed' => 565,
118
- 'align' => 'right',
119
- 'font_size' => 10,
120
- 'font' => 'bold'
121
- ),
122
- );
123
- $lineBlock['lines'][] = array(
124
- array(
125
- 'text' => Mage::helper('sales')->__('Novalnet Transaction Amount').':',
126
- 'feed' => 475,
127
- 'align' => 'right',
128
- 'font_size' => 10,
129
- 'font' => 'bold'
130
- ),
131
- array(
132
- 'text' => $currencySymbol.number_format($amountchangedvalue,2),
133
- 'feed' => 565,
134
- 'align' => 'right',
135
- 'font_size' => 10,
136
- 'font' => 'bold'
137
- ),
138
- );
139
- return $lineBlock;
140
- }
141
-
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Sales/Order/Pdf/Invoice.php DELETED
@@ -1,143 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Sales_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice
27
- {
28
- /**
29
- * Return PDF document
30
- *
31
- * @param array $invoices
32
- * @return Zend_Pdf
33
- */
34
- public function getPdf($invoices = array())
35
- {
36
- $this->_beforeGetPdf();
37
- $this->_initRenderer('invoice');
38
-
39
- $pdf = new Zend_Pdf();
40
- $this->_setPdf($pdf);
41
- $style = new Zend_Pdf_Style();
42
- $this->_setFontBold($style, 10);
43
-
44
- foreach ($invoices as $invoice) {
45
- if ($invoice->getStoreId()) {
46
- Mage::app()->getLocale()->emulate($invoice->getStoreId());
47
- Mage::app()->setCurrentStore($invoice->getStoreId());
48
- }
49
- $page = $this->newPage();
50
- $order = $invoice->getOrder();
51
- /* Add image */
52
- $this->insertLogo($page, $invoice->getStore());
53
- /* Add address */
54
- $this->insertAddress($page, $invoice->getStore());
55
- /* Add head */
56
- $this->insertOrder(
57
- $page,
58
- $order,
59
- Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId())
60
- );
61
- /* Add document text and number */
62
- $this->insertDocumentNumber(
63
- $page,
64
- Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId()
65
- );
66
- /* Add table */
67
- $this->_drawHeader($page);
68
- /* Add body */
69
- foreach ($invoice->getAllItems() as $item){
70
- if ($item->getOrderItem()->getParentItem()) {
71
- continue;
72
- }
73
- /* Draw item */
74
- $this->_drawItem($item, $page, $order);
75
- $page = end($pdf->pages);
76
- }
77
- /* Add totals */
78
- $this->insertTotals($page, $invoice);
79
- $helper = Mage::helper('novalnet_payment');
80
- $amountchangedvalue = $helper->getAmountCollection($order->getId(), 1, NULL);
81
- if($amountchangedvalue){
82
- $lineBlock = $this->amountUpdateDetails($order,$amountchangedvalue);
83
- $this->y -= 1;
84
- $page = $this->drawLineBlocks($page, array($lineBlock));
85
- }
86
-
87
-
88
- if ($invoice->getStoreId()) {
89
- Mage::app()->getLocale()->revert();
90
- }
91
- }
92
- $this->_afterGetPdf();
93
- return $pdf;
94
- }
95
-
96
- /**
97
- * amount update details append in pdf
98
- *
99
- * @param varien_object $order
100
- * @param int $amountchangedvalue
101
- * @return Zend_Pdf
102
- */
103
- private function amountUpdateDetails($order,$amountchangedvalue)
104
- {
105
- $adjustmentamount = -($order->getGrandTotal() - $amountchangedvalue);
106
- $currency = $order->getOrderCurrency();
107
- $currencyCode = $currency->getCurrencyCode();
108
- $currencySymbol = Mage::app()->getLocale()->currency($currencyCode)->getSymbol();
109
- $lineBlock['lines'][] = array(
110
- array(
111
- 'text' => Mage::helper('sales')->__('Novalnet Adjusted Amount').':',
112
- 'feed' => 475,
113
- 'align' => 'right',
114
- 'font_size' => 10,
115
- 'font' => 'bold'
116
- ),
117
- array(
118
- 'text' => $currencySymbol.number_format($adjustmentamount,2),
119
- 'feed' => 565,
120
- 'align' => 'right',
121
- 'font_size' => 10,
122
- 'font' => 'bold'
123
- ),
124
- );
125
- $lineBlock['lines'][] = array(
126
- array(
127
- 'text' => Mage::helper('sales')->__('Novalnet Transaction Amount').':',
128
- 'feed' => 475,
129
- 'align' => 'right',
130
- 'font_size' => 10,
131
- 'font' => 'bold'
132
- ),
133
- array(
134
- 'text' => $currencySymbol.number_format($amountchangedvalue,2),
135
- 'feed' => 565,
136
- 'align' => 'right',
137
- 'font_size' => 10,
138
- 'font' => 'bold'
139
- ),
140
- );
141
- return $lineBlock;
142
- }
143
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Separefill.php DELETED
@@ -1,67 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Separefill extends Mage_Core_Model_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Separefill
33
- */
34
- public function _construct()
35
- {
36
- parent::_construct();
37
- $this->_init('novalnet_payment/separefill');
38
- }
39
-
40
- /**
41
- * Get PanHash
42
- *
43
- * @param Novalnet_Payment_Helper_Data $helper
44
- * @return mixed
45
- */
46
- public function getSepaPanHash($helper)
47
- {
48
- $customerId = Mage::getSingleton('customer/session')->getCustomerId();
49
- $modNovalSeparefill = $helper->getModelSepaRefill()->getCollection();
50
- $modNovalSeparefill->addFieldToFilter('customer_id', $customerId);
51
- $modNovalSeparefill->addFieldToSelect('pan_hash');
52
- $modNovalSeparefillcount = count($modNovalSeparefill);
53
- $orderCollection = Mage::getResourceModel('sales/order_collection')
54
- ->addAttributeToSelect('*')
55
- ->addFieldToFilter('customer_id', $customerId);
56
- $order = $orderCollection->getLastItem();
57
- $paymentMethod = $order->getPayment()->getMethod();
58
- if ($modNovalSeparefillcount > 0 && $paymentMethod == Novalnet_Payment_Model_Config::NN_SEPA) {
59
- foreach ($modNovalSeparefill as $modNovalSeparefillvalue) {
60
- $panhash = $modNovalSeparefillvalue->getPanHash();
61
- }
62
- } else {
63
- $panhash = '';
64
- }
65
- return $panhash;
66
- }
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/Model/Service/Abstract.php ADDED
@@ -0,0 +1,401 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Service_Abstract
27
+ {
28
+ /**
29
+ * Helper
30
+ */
31
+ protected $_helper;
32
+
33
+ /**
34
+ * Storeid
35
+ */
36
+ protected $_storeId;
37
+
38
+ /**
39
+ * Constructor
40
+ */
41
+ public function __construct()
42
+ {
43
+ // Payment method code
44
+ $this->code = Mage::registry('payment_code');
45
+ // Assign Novalnet helper
46
+ $this->assignUtilities();
47
+ // Assign basic vendor informations
48
+ $this->setVendorInfo();
49
+ }
50
+
51
+ /**
52
+ * Assign utilities (Novalnet payment helper)
53
+ *
54
+ * @param none
55
+ * @return Novalnet helper
56
+ */
57
+ public function assignUtilities()
58
+ {
59
+ // Assign helper
60
+ if (!$this->_helper) {
61
+ $this->_helper = Mage::helper('novalnet_payment');
62
+ }
63
+ // Assign store id
64
+ if (!$this->_storeId) {
65
+ $this->_storeId = $this->_helper->getMagentoStoreId();
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Set merchant configuration details
71
+ *
72
+ * @param none
73
+ * @return none
74
+ */
75
+ protected function setVendorInfo()
76
+ {
77
+ $this->vendorId = $this->getNovalnetConfig('merchant_id', true);
78
+ $this->authcode = $this->getNovalnetConfig('auth_code', true);
79
+ $this->productId = $this->getNovalnetConfig('product_id', true);
80
+ $this->tariffId = $this->getNovalnetConfig('tariff_id', true);
81
+ $this->recurringTariffId = $this->getNovalnetConfig('subscrib_tariff_id', true);
82
+ $this->accessKey = $this->getNovalnetConfig('password', true);
83
+ $this->manualCheckLimit = (int) $this->getNovalnetConfig('manual_checking_amount', true);
84
+ $this->loadAffiliateInfo(); // Re-assign merchant params based on affiliate
85
+ }
86
+
87
+ /**
88
+ * Get affiliate account/user detail
89
+ *
90
+ * @param null
91
+ * @return mixed
92
+ */
93
+ public function loadAffiliateInfo()
94
+ {
95
+ $affiliateId = $this->_helper->getCoreSession()->getAffiliateId(); // Get affiliate user id if exist
96
+ $customerId = $this->_helper->getCustomerId(); // Get current customer id
97
+
98
+ if (!$affiliateId && $customerId != 'guest') { // Get affiliate id for existing customer (if available)
99
+ $collection = $this->_helper->getModel('Mysql4_AffiliateUser')->getCollection()
100
+ ->addFieldToFilter('customer_no', $customerId)
101
+ ->addFieldToSelect('aff_id');
102
+ $affiliateId = $collection->getLastItem()->getAffId() ? $collection->getLastItem()->getAffId() : null;
103
+ $this->_helper->getCoreSession()->setAffiliateId($affiliateId);
104
+ }
105
+
106
+ if ($affiliateId) { // Get affiliate configuration values (if affiliate user id exist)
107
+ $orderCollection = $this->_helper->getModel('Mysql4_AffiliateInfo')->getCollection()
108
+ ->addFieldToFilter('aff_id', $affiliateId)
109
+ ->addFieldToSelect('aff_id')
110
+ ->addFieldToSelect('aff_authcode')
111
+ ->addFieldToSelect('aff_accesskey');
112
+ $this->vendorId = $orderCollection->getLastItem()->getAffId()
113
+ ? $orderCollection->getLastItem()->getAffId() : $this->vendorId;
114
+ $this->authcode = $orderCollection->getLastItem()->getAffAuthcode()
115
+ ? $orderCollection->getLastItem()->getAffAuthcode() : $this->authcode;
116
+ $this->accessKey = $orderCollection->getLastItem()->getAffAccesskey()
117
+ ? $orderCollection->getLastItem()->getAffAccesskey() : $this->accessKey;
118
+ }
119
+
120
+ }
121
+
122
+ /**
123
+ * Get the Novalnet configuration (global/payment)
124
+ *
125
+ * @param string $field
126
+ * @param boolean $global
127
+ * @return mixed|null
128
+ */
129
+ public function getNovalnetConfig($field, $global = false)
130
+ {
131
+ $path = 'novalnet_global/novalnet/' . $field; // Global config value path
132
+
133
+ if ($field == 'live_mode') { // Novalnet payment mode
134
+ $paymentMethod = Mage::getStoreConfig($path, $this->_storeId);
135
+ return (!preg_match('/' . $this->code . '/i', $paymentMethod)) ? false : true;
136
+ } elseif ($field !== null) { // Get Novalnet payment/global configuration
137
+ return ($global != false) ? trim(Mage::getStoreConfig($path, $this->_storeId))
138
+ : trim(Mage::getStoreConfig('payment/'. $this->code . '/' . $field, $this->_storeId));
139
+ }
140
+ return null;
141
+ }
142
+
143
+ /**
144
+ * Whether current operation is order placement
145
+ *
146
+ * @param Varien_Object $info
147
+ * @return boolean
148
+ */
149
+ protected function _isPlaceOrder($info)
150
+ {
151
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
152
+ return false;
153
+ } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
154
+ return true;
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Get current order/quote object
160
+ *
161
+ * @param Varien_Object $info
162
+ * @return Mage_Payment_Model_Method_Abstract
163
+ */
164
+ protected function _getInfoObject($info)
165
+ {
166
+ return ($this->_isPlaceOrder($info)) ? $info->getOrder() : $info->getQuote();
167
+ }
168
+
169
+ /**
170
+ * Check the value is numeric
171
+ *
172
+ * @param mixed $value
173
+ * @return boolean
174
+ */
175
+ public function checkIsNumeric($value)
176
+ {
177
+ return preg_match('/^\d+$/', $value) ? true : false;
178
+ }
179
+
180
+ /**
181
+ * Check the email id is valid
182
+ *
183
+ * @param mixed $emailId
184
+ * @return boolean
185
+ */
186
+ public function validateEmail($emailId)
187
+ {
188
+ $validatorEmail = new Zend_Validate_EmailAddress();
189
+ return $validatorEmail->isValid($emailId) ? true : false;
190
+ }
191
+
192
+ /**
193
+ * Check the value contains special characters
194
+ *
195
+ * @param mixed $value
196
+ * @return boolean
197
+ */
198
+ public function checkIsValid($value)
199
+ {
200
+ return (!$value || preg_match('/[#%\^<>@$=*!]/', $value)) ? false : true;
201
+ }
202
+
203
+ /**
204
+ * Get grand total amount
205
+ *
206
+ * @param Varien_Object $info
207
+ * @return double
208
+ */
209
+ protected function _getAmount($info)
210
+ {
211
+ return ($this->_isPlaceOrder($info))
212
+ ? (double) $info->getOrder()->getBaseGrandTotal()
213
+ : (double) $info->getQuote()->getBaseGrandTotal();
214
+ }
215
+
216
+ /**
217
+ * Check whether the fraud prevention available
218
+ *
219
+ * @param string $countryCode
220
+ * @return boolean
221
+ */
222
+ public function isCallbackTypeAllowed($countryCode)
223
+ {
224
+ $allowedCountryCode = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('allowedCountry');
225
+ if (in_array($countryCode, $allowedCountryCode) && !$this->_helper->checkIsAdmin()) {
226
+ return true;
227
+ }
228
+ return false;
229
+ }
230
+
231
+ /**
232
+ * Get order increment id
233
+ *
234
+ * @param none
235
+ * @return int
236
+ */
237
+ protected function _getIncrementId()
238
+ {
239
+ $storeId = $this->_helper->getMagentoStoreId(); // Get store id
240
+ $orders = Mage::getModel('sales/order')->getCollection()
241
+ ->addAttributeToFilter('store_id', $storeId)
242
+ ->setOrder('entity_id', 'DESC')
243
+ ->setPageSize(1); // Get order collection
244
+ $lastIncrementId = $orders->getFirstItem()->getIncrementId();
245
+ return !empty($lastIncrementId) ? ++$lastIncrementId
246
+ : $storeId . Mage::getModel('eav/entity_increment_numeric')->getNextId();
247
+ }
248
+
249
+ /**
250
+ * Encoded the requested data
251
+ *
252
+ * @param string $data
253
+ * @return string
254
+ */
255
+ public function encode($data)
256
+ {
257
+ $data = trim($data);
258
+ if ($data == null) {
259
+ return'Error: no data';
260
+ }
261
+ if (!function_exists('base64_decode') or ! function_exists('pack') or ! function_exists('crc32')) {
262
+ return'Error: func n/a';
263
+ }
264
+ try {
265
+ $crc = sprintf('%u', crc32($data));
266
+ $data = $crc . "|" . $data;
267
+ $data = bin2hex($data . $this->accessKey);
268
+ $data = strrev(base64_encode($data));
269
+ } catch (Exception $e) {
270
+ Mage::logException('Error: ' . $e);
271
+ }
272
+ return $data;
273
+ }
274
+
275
+ /**
276
+ * Decoded the requested data
277
+ *
278
+ * @param string $data
279
+ * @return string
280
+ */
281
+ public function decode($data)
282
+ {
283
+ $data = trim($data);
284
+ if ($data == null) {
285
+ return'Error: no data';
286
+ }
287
+ if (!function_exists('base64_decode') || !function_exists('pack') || !function_exists('crc32')) {
288
+ return'Error: func n/a';
289
+ }
290
+
291
+ try {
292
+ $data = base64_decode(strrev($data));
293
+ $data = pack("H" . strlen($data), $data);
294
+ $data = substr($data, 0, stripos($data, $this->accessKey));
295
+ $pos = strpos($data, "|");
296
+ if ($pos === false) {
297
+ return("Error: CKSum not found!");
298
+ }
299
+ $crc = substr($data, 0, $pos);
300
+ $value = trim(substr($data, $pos + 1));
301
+ if ($crc != sprintf('%u', crc32($value))) {
302
+ return("Error; CKSum invalid!");
303
+ }
304
+ return $value;
305
+ } catch (Exception $e) {
306
+ Mage::logException('Error: ' . $e);
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Hash value getter
312
+ *
313
+ * @param array $request
314
+ * @return string
315
+ */
316
+ public function getHash($request)
317
+ {
318
+ if (empty($request)) {
319
+ return'Error: no data';
320
+ }
321
+
322
+ if (!function_exists('md5')) {
323
+ return'Error: func n/a';
324
+ }
325
+
326
+ if ($request->getImplementation() == 'PHP_PCI') {
327
+ $hash = md5(
328
+ $request->getVendorAuthcode() . $request->getProductId() . $request->getTariffId() .
329
+ $request->getAmount() . $request->getTestMode() . $request->getUniqid() . strrev($this->accessKey)
330
+ );
331
+ } else {
332
+ $hash = md5(
333
+ $request->getAuthCode() . $request->getProduct() . $request->getTariff() .
334
+ $request->getAmount() . $request->getTestMode() . $request->getUniqid() . strrev($this->accessKey)
335
+ );
336
+ }
337
+
338
+ return $hash;
339
+ }
340
+
341
+ /**
342
+ * Check Hash value
343
+ *
344
+ * @param array $request
345
+ * @return boolean
346
+ */
347
+ public function checkHash($response)
348
+ {
349
+ if (!$response) {
350
+ return false;
351
+ }
352
+
353
+ if ($response->hasHash2()
354
+ && $response->getHash2() != $this->getHash($response)
355
+ ) {
356
+ return false;
357
+ }
358
+
359
+ return true;
360
+ }
361
+
362
+ /**
363
+ * Get encoded payment data
364
+ *
365
+ * @param Varien_Object $request
366
+ * @return none
367
+ */
368
+ public function getEncodedParams($request)
369
+ {
370
+ $params = ($request->getImplementation() == 'PHP_PCI')
371
+ ? Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('pciHashParams')
372
+ : Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('hashParams');
373
+ foreach ($params as $value) {
374
+ $data = $request->$value;
375
+ $data = $this->encode($data);
376
+ $request->$value = $data;
377
+ }
378
+ $request->setHash($this->getHash($request));
379
+ }
380
+
381
+ /**
382
+ * Get decoded payment data
383
+ *
384
+ * @param Varien_Object $response
385
+ * @param int|null $storeId
386
+ * @return none
387
+ */
388
+ public function getDecodedParams($response, $storeId = null)
389
+ {
390
+ $this->_storeId = ($storeId !== null) ? $storeId : $this->_storeId;
391
+ $params = ($response->getImplementation() == 'PHP_PCI')
392
+ ? Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('pciHashParams')
393
+ : Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('hashParams');
394
+ foreach ($params as $value) {
395
+ $data = $response->$value;
396
+ $data = $this->decode($data);
397
+ $response->$value = $data;
398
+ }
399
+ }
400
+
401
+ }
app/code/community/Novalnet/Payment/Model/Service/Api/FraudPrevention.php ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Service_Api_FraudPrevention extends Novalnet_Payment_Model_Service_Abstract
27
+ {
28
+
29
+ /**
30
+ * Initiate fraud prevention process
31
+ *
32
+ * @param Varien_Object $info
33
+ * @return none
34
+ */
35
+ public function fraudPreventionProcess($info)
36
+ {
37
+ $methodSession = $this->_helper->getMethodSession($this->code); // Get current payment method session
38
+ $callbackStatus = $this->getFraudPreventionStatus($info); // Check fraud prevention availability
39
+ $this->_verifyCallbackOrderNo($info, $methodSession, $callbackStatus); // Check whether increment id is valid
40
+ $this->_verifyCallbackInfo($info, $methodSession); // Validate fraud prevention informations
41
+ $this->_verifyCallbackPinInfo($methodSession, $callbackStatus); // Validate the fraud prevention data
42
+ // Send fraud prevention PIN (New/Forget) request
43
+ $this->_performCallbackProcess($info, $methodSession, $callbackStatus);
44
+ if ($this->_isPlaceOrder($info)) {
45
+ $this->validateCallbackProcess($methodSession); // Validate fraud prevention response process
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Check fraud prevention availability
51
+ *
52
+ * @param Varien_Object $info
53
+ * @param string|null $code
54
+ * @return boolean
55
+ */
56
+ public function getFraudPreventionStatus($info, $code = null)
57
+ {
58
+ $this->code = ($code !== null) ? $code : $this->code; // Payment method code
59
+ $orderAmount = (string) $this->_helper->getFormatedAmount($this->_getAmount($info)); // Get order amount
60
+ $callBackMinimum = (string) $this->getNovalnetConfig('callback_minimum_amount');
61
+ $countryCode = strtoupper($this->_getInfoObject($info)->getBillingAddress()->getCountryId());
62
+ $callbackPayment = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('fraudCheckPayment');
63
+ $methodSession = $this->_helper->getMethodSession($this->code);
64
+
65
+ if ((!$this->getNovalnetConfig('callback') || !$this->isCallbackTypeAllowed($countryCode))
66
+ || ($callBackMinimum && $orderAmount < $callBackMinimum)
67
+ || (!in_array($this->code, $callbackPayment))
68
+ ) {
69
+ return false;
70
+ } elseif ($this->code == Novalnet_Payment_Model_Config::NN_SEPA
71
+ && $methodSession->hasSepaNewForm() && !$methodSession->getSepaNewForm()
72
+ ) {
73
+ return false;
74
+ }
75
+
76
+ return true;
77
+ }
78
+
79
+ /**
80
+ * Check whether increment id is valid
81
+ *
82
+ * @param Varien_Object $info
83
+ * @param Varien_Object $methodSession
84
+ * @param boolean $callbackStatus
85
+ * @return none
86
+ */
87
+ protected function _verifyCallbackOrderNo($info, $methodSession, $callbackStatus)
88
+ {
89
+ $callbackOrderNo = "getCallbackOrderNo" . ucfirst($this->code);
90
+ $callbackIncrementId = $methodSession->$callbackOrderNo();
91
+ $incrementId = $this->_getIncrementId(); // Get order increment id
92
+
93
+ // Check whether increment id is valid
94
+ if (!$this->_isPlaceOrder($info) && $callbackStatus && $incrementId
95
+ && $callbackIncrementId && ($incrementId != $callbackIncrementId)
96
+ ) {
97
+ $this->_helper->unsetMethodSession($this->code); // Unset the payment method session
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Validate order amount is getting changed after callback initiation
103
+ *
104
+ * @param Varien_Object $info
105
+ * @param Varien_Object $methodSession
106
+ * @return throw Mage Exception|none
107
+ */
108
+ protected function _verifyCallbackInfo($info, $methodSession)
109
+ {
110
+ // Callback initiated transaction id
111
+ $callbackTid = "hasCallbackTid" . ucfirst($this->code);
112
+
113
+ if ($methodSession->$callbackTid()) {
114
+ // Get order total amount
115
+ $checkoutSession = $this->_helper->getCheckoutSession();
116
+ $amount = $checkoutSession->getQuote()->hasNominalItems()
117
+ ? $this->_helper->getFormatedAmount($checkoutSession->getNnRowAmount())
118
+ : $this->_helper->getFormatedAmount($this->_getAmount($info));
119
+ // Get payment method order amount if available
120
+ $orderAmount = $methodSession->getOrderAmount();
121
+ // Get payment method disable time if available
122
+ $paymentDisableTime = "getPaymentDisableTime" . ucfirst($this->code);
123
+
124
+ if ($checkoutSession->$paymentDisableTime()
125
+ && (time() > $checkoutSession->$paymentDisableTime())
126
+ ) {
127
+ $this->_helper->unsetMethodSession($this->code); // Unset the payment method session
128
+ } elseif ($orderAmount && $orderAmount != $amount) {
129
+ $this->_helper->unsetMethodSession($this->code); // Unset the payment method session
130
+ if (!$this->_isPlaceOrder($info)) {
131
+ $this->_helper->showException('The order amount has been changed');
132
+ }
133
+ }
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Validate the fraud prevention data
139
+ *
140
+ * @param Varien_Object $methodSession
141
+ * @param boolean $callbackStatus
142
+ * @return throw Mage Exception|none
143
+ */
144
+ protected function _verifyCallbackPinInfo($methodSession, $callbackStatus)
145
+ {
146
+ $paymentCode = ucfirst($this->code);
147
+ $callbackTid = "getCallbackTid" . $paymentCode;
148
+ $callbackPin = "getCallbackPin" . $paymentCode;
149
+
150
+ if ($callbackStatus && $methodSession->getCallbackPinFlag()
151
+ && $methodSession->$callbackTid()
152
+ ) {
153
+ $callbackPin = $methodSession->$callbackPin();
154
+ $callbackNewPin = "getCallbackNewPin" . $paymentCode;
155
+
156
+ if (!$methodSession->$callbackNewPin() && empty($callbackPin)) {
157
+ $this->_helper->showException('Enter your PIN');
158
+ } elseif (!$methodSession->$callbackNewPin() && !$this->checkIsValid($callbackPin)) {
159
+ $this->_helper->showException('The PIN you entered is incorrect');
160
+ }
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Send fraud prevention PIN (New/Forget) request
166
+ *
167
+ * @param Varien_Object $info
168
+ * @param Varien_Object $methodSession
169
+ * @param boolean $callbackStatus
170
+ * @return none
171
+ */
172
+ protected function _performCallbackProcess($info, $methodSession, $callbackStatus)
173
+ {
174
+ if ($callbackStatus && !$this->_isPlaceOrder($info)) {
175
+ $paymentCode = ucfirst($this->code);
176
+ $callbackTid = "getCallbackTid" . $paymentCode;
177
+
178
+ if ($methodSession->$callbackTid() && $this->getNovalnetConfig('callback') != 3) {
179
+ $callbackPin = "getCallbackPin" . $paymentCode;
180
+ $callbackNewPin = "getCallbackNewPin" . $paymentCode;
181
+ $setcallbackPin = "setCallbackPin" . $paymentCode;
182
+ $methodSession->$callbackNewPin() ? $this->_regenerateCallbackPin($methodSession)
183
+ : $methodSession->$setcallbackPin($methodSession->$callbackPin());
184
+ } elseif (!$methodSession->$callbackTid()) {
185
+ $this->_generateCallbackPin($info, $paymentCode, $methodSession);
186
+ }
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Make callback request and validate response
192
+ *
193
+ * @param Varien_Object $info
194
+ * @param string $paymentCode
195
+ * @param Varien_Object $methodSession
196
+ * @return throw Mage Exception|none
197
+ */
198
+ protected function _generateCallbackPin($info, $paymentCode, $methodSession)
199
+ {
200
+ $callbackTid = "setCallbackTid" . $paymentCode;
201
+ $callbackOrderNo = "setCallbackOrderNo" . $paymentCode;
202
+ $nominalItem = $this->_helper->getCheckoutSession()->getQuote()->hasNominalItems();
203
+
204
+ // Prepare payport request params
205
+ $requestModel = $this->_helper->getModel('Service_Api_Request');
206
+ $request = $requestModel->getPayportParams($info);
207
+ $requestModel->setFraudModuleParams($request, $methodSession);
208
+ if ($nominalItem) {
209
+ $requestModel->getCallbackProfileParams($request);
210
+ }
211
+ $methodSession->setPaymentReqData($request);
212
+ // Receive payport response params
213
+ $paymentModel = $this->_helper->getPaymentModel($this->code);
214
+ $response = $paymentModel->postRequest($request);
215
+ $methodSession->setPaymentResData($response);
216
+ // Novalnet successful transaction status
217
+ if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
218
+ $methodSession->$callbackTid(trim($response->getTid()))
219
+ ->$callbackOrderNo(trim($response->getOrderNo()))
220
+ ->setNnTestMode(trim($response->getTestMode()))
221
+ ->setOrderAmount($request->getAmount())
222
+ ->setCallbackSuccessState(true);
223
+ if ($this->getNovalnetConfig('callback') == 1) {
224
+ $text = $this->_helper->showException('You will shortly receive a transaction PIN');
225
+ } elseif ($this->getNovalnetConfig('callback') == 2) {
226
+ $text = $this->_helper->showException('You will shortly receive an SMS');
227
+ }
228
+ } else { // Novalnet unsuccessful transaction status
229
+ $text = $this->_helper->htmlEscape($response->getStatusDesc());
230
+ }
231
+ $this->_helper->showException($text, false);
232
+ }
233
+
234
+ /**
235
+ * Regenerate new PIN for fraud prevention process
236
+ *
237
+ * @param Varien_Object $methodSession
238
+ * @return throw Mage Exception
239
+ */
240
+ protected function _regenerateCallbackPin($methodSession)
241
+ {
242
+ // Callback request data re-assign
243
+ $request = $methodSession->getPaymentReqData();
244
+ $response = $methodSession->getPaymentResData();
245
+
246
+ $responseModel = $this->_helper->getModel('Service_Api_Response'); // Get Novalnet api response model
247
+ $response = $responseModel->pinStatusCall($request, $response->getTid(), Novalnet_Payment_Model_Config::TRANSMIT_PIN_AGAIN);
248
+ // Novalnet successful transaction status
249
+ if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
250
+ $text = $this->_helper->showException('You will shortly receive an SMS');
251
+ } else { // Novalnet unsuccessful transaction status
252
+ $text = $this->_helper->htmlEscape($response->getStatusMessage()); // Status_message
253
+ if ($response->getStatus() == Novalnet_Payment_Model_Config::MAXPIN_DISABLE_CODE) {
254
+ $this->_helper->unsetMethodSession($this->code);
255
+ }
256
+ }
257
+
258
+ $this->_helper->showException($text, false);
259
+ }
260
+
261
+ /**
262
+ * Validate fraud prevention response process
263
+ *
264
+ * @param Varien_Object $methodSession
265
+ * @return none
266
+ */
267
+ public function validateCallbackProcess($methodSession)
268
+ {
269
+ if ($methodSession->getCallbackSuccessState()) { // Fraud prevention process success state
270
+ $paymentCode = ucfirst($this->code);
271
+ $callbackPin = "getCallbackPin" . $paymentCode;
272
+ $type = Novalnet_Payment_Model_Config::PIN_STATUS;
273
+ $extraOption = '<pin>' . $methodSession->$callbackPin() . '</pin>';
274
+
275
+ // Verify entered PIN via API request
276
+ $responseModel = $this->_helper->getModel('Service_Api_Response');
277
+ $tid = $methodSession->getPaymentResData()->getTid();
278
+ $result = $responseModel->pinStatusCall($methodSession->getPaymentReqData(), $tid, $type, $extraOption);
279
+ $callbackTid = "getCallbackTid" . $paymentCode;
280
+ $result->setTid($methodSession->$callbackTid());
281
+ $result->setTestMode($methodSession->getNnTestMode());
282
+ $methodSession->getPaymentResData()->setTidStatus($result->getTidStatus());
283
+
284
+ // Verify the response from Novalnet
285
+ if ($result->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
286
+ $methodSession->setCallbackSuccessState(false);
287
+ } else { // Novalnet unsuccessful transaction status
288
+ if ($result->getStatus() == Novalnet_Payment_Model_Config::METHOD_DISABLE_CODE) {
289
+ $paymentDisableTime = "setPaymentDisableTime" . $paymentCode;
290
+ $this->_helper->getCheckoutSession()->$paymentDisableTime(time() + (30 * 60));
291
+ }
292
+ $statusMessage = $this->_helper->htmlEscape($result->getStatusMessage());
293
+ $this->_helper->showException($statusMessage, false);
294
+ }
295
+ }
296
+ }
297
+
298
+ }
app/code/community/Novalnet/Payment/Model/Service/Api/Gateway.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Service_Api_Gateway extends Novalnet_Payment_Model_Service_Abstract
27
+ {
28
+ /**
29
+ * Send API request to Novalnet gateway
30
+ *
31
+ * @param array $requestData
32
+ * @param string $requestUrl
33
+ * @param string $type
34
+ * @return mixed
35
+ */
36
+ public function payportRequestCall($requestData, $requestUrl, $type = "")
37
+ {
38
+ if (!$requestUrl) {
39
+ $this->_helper->showException('Server Request URL is Empty');
40
+ return;
41
+ }
42
+
43
+ $httpClientConfig = array('maxredirects' => 0);
44
+ // Assign proxy whether if configured
45
+ if ($this->getNovalnetConfig('use_proxy', true)) {
46
+ $proxyHost = $this->getNovalnetConfig('proxy_host', true);
47
+ $proxyPort = $this->getNovalnetConfig('proxy_port', true);
48
+ if ($proxyHost && $proxyPort) {
49
+ $httpClientConfig['proxy'] = $proxyHost . ':' . $proxyPort;
50
+ $httpClientConfig['httpproxytunnel'] = true;
51
+ $httpClientConfig['proxytype'] = CURLPROXY_HTTP;
52
+ $httpClientConfig['SSL_VERIFYHOST'] = false;
53
+ $httpClientConfig['SSL_VERIFYPEER'] = false;
54
+ }
55
+ }
56
+ // Assign gateway timeout whether if configured
57
+ $gatewayTimeout = $this->getNovalnetConfig('gateway_timeout', true);
58
+ if ($gatewayTimeout > 0) {
59
+ $httpClientConfig['timeout'] = $gatewayTimeout;
60
+ }
61
+
62
+ $client = new Varien_Http_Client($requestUrl, $httpClientConfig);
63
+ // Assign post payport params
64
+ if ($type == 'XML') {
65
+ $client->setUri($requestUrl);
66
+ $client->setRawData($requestData)->setMethod(Varien_Http_Client::POST);
67
+ } else {
68
+ $client->setParameterPost($requestData)->setMethod(Varien_Http_Client::POST);
69
+ }
70
+ // Get response from payment gatway
71
+ try {
72
+ $response = $client->request();
73
+ } catch (Exception $e) {
74
+ Mage::log($e->getMessage(), null, 'nn_exception.log', true);
75
+ }
76
+ // Show exception if payment unsuccessful
77
+ if (!$response->isSuccessful()) {
78
+ $helper = Mage::helper('novalnet_payment');
79
+ $helper->showException($helper->__('Gateway request error: %s', $response->getMessage()), false);
80
+ }
81
+ // Convert xml response to array
82
+ if ($type == 'XML') {
83
+ $result = new Varien_Simplexml_Element($response->getRawBody());
84
+ $response = new Varien_Object($result->asArray());
85
+ }
86
+
87
+ return $response;
88
+ }
89
+
90
+ }
app/code/community/Novalnet/Payment/Model/Service/Api/Request.php ADDED
@@ -0,0 +1,572 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Service_Api_Request extends Novalnet_Payment_Model_Service_Abstract
27
+ {
28
+
29
+ /**
30
+ * Prepare payment request params
31
+ *
32
+ * @param Varien_Object $infoObject
33
+ * @param string|null $code
34
+ * @param int|null $amount
35
+ * @return Varien_Object $request
36
+ */
37
+ public function getPayportParams($infoObject, $code = null, $amount = null)
38
+ {
39
+ $this->code = ($code !== null) ? $code : $this->code;
40
+ $request = new Varien_Object();
41
+ $this->getVendorInfo($request); // Get Novalnet merchant authentication informations
42
+ $this->getBillingInfo($request, $infoObject); // Get customer billing infromations
43
+ $this->getCommonInfo($request, $infoObject, $amount); // Get common params for Novalnet payment api request
44
+ $this->getPaymentInfo($request); // Get needed Novalnet payment params
45
+ return $request;
46
+ }
47
+
48
+ /**
49
+ * Assign Novalnet authentication Data
50
+ *
51
+ * @param Varien_Object $request
52
+ * @return Varien_Object $request
53
+ */
54
+ public function getVendorInfo(Varien_Object $request)
55
+ {
56
+ $testMode = $this->getNovalnetConfig('live_mode', true); // Novalnet payment mode configuration
57
+ $request->setVendor($this->vendorId)
58
+ ->setAuthCode($this->authcode)
59
+ ->setProduct($this->productId)
60
+ ->setTariff($this->tariffId)
61
+ ->setKey($this->_helper->getPaymentId($this->code))
62
+ ->setTestMode(!$testMode ? 1 : 0);
63
+
64
+ $checkoutSession = $this->_helper->getCheckoutSession(); // Get checkout session
65
+ if ($checkoutSession->getQuote()->hasNominalItems()) {
66
+ $request->setTariff($this->recurringTariffId);
67
+ }
68
+
69
+ return $request;
70
+ }
71
+
72
+ /**
73
+ * Get end-customer billing informations
74
+ *
75
+ * @param Varien_Object $request
76
+ * @param Varien_Object $info
77
+ * @return mixed
78
+ */
79
+ public function getBillingInfo(Varien_Object $request, $info)
80
+ {
81
+ $infoObject = $this->_getInfoObject($info); // Get current payment object informations
82
+ $billing = $infoObject->getBillingAddress(); // Get end-customer billing address
83
+ $shipping = !$infoObject->getIsVirtual() ? $infoObject->getShippingAddress() : '';
84
+ // Get company param if exist either billing/shipping address
85
+ $company = $billing->getCompany() ? $billing->getCompany()
86
+ : ($shipping && $shipping->getCompany() ? $shipping->getCompany() : '');
87
+ $request->setFirstName($billing->getFirstname())
88
+ ->setLastName($billing->getLastname())
89
+ ->setEmail($billing->getEmail() ? $billing->getEmail() : $infoObject->getCustomerEmail())
90
+ ->setCity($billing->getCity())
91
+ ->setZip($billing->getPostcode())
92
+ ->setTel($billing->getTelephone())
93
+ ->setFax($billing->getFax())
94
+ ->setSearchInStreet(1)
95
+ ->setStreet(implode(',', $billing->getStreet()))
96
+ ->setCountry($billing->getCountry())
97
+ ->setCountryCode($billing->getCountry());
98
+ $request = $company ? $request->setCompany($company) : $request; // Set company param if exist
99
+ }
100
+
101
+ /**
102
+ * Get common params for Novalnet payment API request
103
+ *
104
+ * @param Varien_Object $request
105
+ * @param Varien_Object $info
106
+ * @param int|null $amount
107
+ * @return mixed
108
+ */
109
+ public function getCommonInfo(Varien_Object $request, $info, $amount = null)
110
+ {
111
+ $this->getReferenceParams($request); // Get payment reference params like referer id/reference value
112
+ $infoObject = $this->_getInfoObject($info); // Get current payment object informations
113
+ $amount = $amount ? $amount : $this->_helper->getFormatedAmount($this->_getAmount($info));
114
+ $vendorScriptUrl = Mage::getStoreConfig('novalnet_global/merchant_script/vendor_script_url');
115
+ $request->setAmount($amount)
116
+ ->setCurrency($infoObject->getBaseCurrencyCode())
117
+ ->setCustomerNo($this->_helper->getCustomerId())
118
+ ->setLang(strtoupper($this->_helper->getDefaultLanguage()))
119
+ ->setRemoteIp($this->_helper->getRealIpAddr())
120
+ ->setSystemIp($this->_helper->getServerAddr())
121
+ ->setSystemUrl($this->_helper->getBaseUrl())
122
+ ->setSystemName('Magento')
123
+ ->setSystemVersion($this->_helper->getMagentoVersion() . '-' . $this->_helper->getNovalnetVersion())
124
+ ->setOrderNo($this->getOrderId($info));
125
+
126
+ if ($vendorScriptUrl) {
127
+ $request->setNotifyUrl($vendorScriptUrl); // Get vendor script url
128
+ }
129
+
130
+ if ($this->manualCheckLimit) { // Manual checking limit for payment onHold process
131
+ $this->manualCheckValidate($request); // Check whether payment using onHold or not
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Set additional payment reference params
137
+ *
138
+ * @param Varien_Object $request
139
+ * @return mixed
140
+ */
141
+ public function getReferenceParams(Varien_Object $request)
142
+ {
143
+ $referenceOne = trim(strip_tags($this->getNovalnetConfig('reference_one')));
144
+ // Assign reference value if exist
145
+ !empty($referenceOne) ? $request->setInput1('reference1')->setInputval1($referenceOne) : '';
146
+ $referenceTwo = trim(strip_tags($this->getNovalnetConfig('reference_two')));
147
+ // Assign reference value if exist
148
+ !empty($referenceTwo) ? $request->setInput2('reference2')->setInputval2($referenceTwo) : '';
149
+ $referrerId = trim($this->getNovalnetConfig('referrer_id', true)); // Novalnet merchant reference id
150
+ !empty($referrerId) ? $request->setReferrerId($referrerId) : ''; // Assign referer id if exist
151
+ $adminUserId = ($this->_helper->checkIsAdmin())
152
+ ? Mage::getSingleton('admin/session')->getUser()->getUserId() : '';
153
+ // Assign admin order reference value if exist
154
+ !empty($adminUserId) ? $request->setInput3('admin_user')->setInputval3($adminUserId) : '';
155
+ }
156
+
157
+ /**
158
+ * Validate manual checklimit and assign onHold payment status
159
+ *
160
+ * @param Varien_Object $request
161
+ * @return mixed
162
+ */
163
+ public function manualCheckValidate(Varien_Object $request)
164
+ {
165
+ // Get onHold available payments
166
+ $setOnholdPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('onHoldPayments');
167
+ if (in_array($this->code, $setOnholdPayments)
168
+ && (string) $this->manualCheckLimit <= (string) $request->getAmount()
169
+ ) {
170
+ $request->setOnHold(1); // Set payment status as onHold
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Get order increment id
176
+ *
177
+ * @param Varien_Object $info
178
+ * @return int
179
+ */
180
+ public function getOrderId($info)
181
+ {
182
+ return ($this->_isPlaceOrder($info))
183
+ ? $info->getOrder()->getIncrementId() : $this->_getIncrementId();
184
+ }
185
+
186
+ /**
187
+ * Assign Novalnet payment data
188
+ *
189
+ * @param Varien_Object $request
190
+ * @return none
191
+ */
192
+ public function getPaymentInfo(Varien_Object $request)
193
+ {
194
+ $methodSession = $this->_helper->getMethodSession($this->code); // Get current payment method session
195
+ $request->setPaymentType($this->getPaymentType($this->code)); // Set payment type param in payment request
196
+
197
+ switch ($this->code) {
198
+ case Novalnet_Payment_Model_Config::NN_CC:
199
+ $methodSession->setCcFormType($this->getNovalnetConfig('cc_form_type'));
200
+ if ($methodSession->getNnCcTid()) {
201
+ // Add Credit Card payment process required params
202
+ $request->setCcCvc2($methodSession->getNnCcCvc());
203
+ $request->setPaymentRef($methodSession->getNnCcTid());
204
+ } else {
205
+ // Add Credit Card PCI (Iframe) payment process params
206
+ $this->getCcIframeParams($request);
207
+ }
208
+
209
+ // Add Credit Card 3D Secure payment process params
210
+ if ($this->getNovalnetConfig('enable_cc3d')) {
211
+ $request->setCc_3d(1);
212
+ }
213
+
214
+ break;
215
+ case Novalnet_Payment_Model_Config::NN_SEPA:
216
+ if ($methodSession->getNnSepaTid()) {
217
+ $request->setPaymentRef($methodSession->getNnSepaTid());
218
+ } else {
219
+ $request->setBankAccountHolder($methodSession->getSepaHolder())
220
+ ->setSepaHash($methodSession->getSepaHash())
221
+ ->setSepaUniqueId($methodSession->getSepaUniqueId())
222
+ ->setIbanBicConfirmed($methodSession->getSepaMandateConfirm());
223
+ }
224
+ // Assign params for SEPA payment guarantee
225
+ if ($methodSession->getPaymentGuaranteeFlag()) {
226
+ $request->setBirthDate($methodSession->getCustomerDob())
227
+ ->setPaymentType(Novalnet_Payment_Model_Config::SEPA_PAYMENT_GUARANTEE_TYPE)
228
+ ->setKey(Novalnet_Payment_Model_Config::SEPA_PAYMENT_GUARANTEE_KEY);
229
+ }
230
+ $paymentDuration = trim($this->getNovalnetConfig('sepa_due_date'));
231
+ $dueDate = (!$paymentDuration) ? date('Y-m-d', strtotime('+7 days'))
232
+ : date('Y-m-d', strtotime('+' . $paymentDuration . ' days'));
233
+ $request->setSepaDueDate($dueDate);
234
+ break;
235
+ case Novalnet_Payment_Model_Config::NN_INVOICE:
236
+ $request->setInvoiceType(Novalnet_Payment_Model_Config::INVOICE_PAYMENT_TYPE)
237
+ ->setInvoiceRef('BNR-' . $request->getProduct() . '-' . $request->getOrderNo());
238
+ // Assign invoice payment due date
239
+ if ($dueDate = $this->getPaymentDueDate()) {
240
+ $request->setDueDate($dueDate);
241
+ }
242
+ // Assign params for invoice payment guarantee
243
+ if ($methodSession->getPaymentGuaranteeFlag()) {
244
+ $request->setBirthDate($methodSession->getCustomerDob())
245
+ ->setPaymentType(Novalnet_Payment_Model_Config::INVOICE_PAYMENT_GUARANTEE_TYPE)
246
+ ->setKey(Novalnet_Payment_Model_Config::INVOICE_PAYMENT_GUARANTEE_KEY);
247
+ }
248
+ break;
249
+ case Novalnet_Payment_Model_Config::NN_PREPAYMENT:
250
+ $request->setInvoiceType(Novalnet_Payment_Model_Config::PREPAYMENT_PAYMENT_TYPE)
251
+ ->setInvoiceRef('BNR-' . $request->getProduct() . '-' . $request->getOrderNo());
252
+ break;
253
+ case Novalnet_Payment_Model_Config::NN_PAYPAL:
254
+ case Novalnet_Payment_Model_Config::NN_BANKTRANSFER:
255
+ case Novalnet_Payment_Model_Config::NN_IDEAL:
256
+ case Novalnet_Payment_Model_Config::NN_EPS:
257
+ case Novalnet_Payment_Model_Config::NN_GIROPAY:
258
+ $request->setUniqid(uniqid())
259
+ ->setSession(session_id())
260
+ ->setImplementation('PHP');
261
+ $this->getMethodAndUrlInfo($request);
262
+ $this->getEncodedParams($request);
263
+ break;
264
+
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Get due date for invoice payment
270
+ *
271
+ * @param none
272
+ * @return int
273
+ */
274
+ public function getPaymentDueDate()
275
+ {
276
+ $dueDate = '';
277
+ $paymentDuration = trim($this->getNovalnetConfig('payment_duration'));
278
+ if ($paymentDuration && $this->_helper->checkIsNumeric($paymentDuration)) {
279
+ $dueDate = date('Y-m-d', strtotime('+' . (int) $paymentDuration . ' days'));
280
+ } elseif ($paymentDuration == "0") {
281
+ $dueDate = date('Y-m-d');
282
+ }
283
+ return $dueDate;
284
+ }
285
+
286
+ /**
287
+ * Get Credit Card iframe payment params
288
+ *
289
+ * @param Varien_Object $request
290
+ * @return none
291
+ */
292
+ public function getCcIframeParams($request)
293
+ {
294
+ $request->setUniqid(uniqid())
295
+ ->setSession(session_id())
296
+ ->setImplementation('PHP_PCI')
297
+ ->setVendorId($request->getVendor())
298
+ ->setVendorAuthcode($request->getAuthCode())
299
+ ->setTariffId($request->getTariff())
300
+ ->setProductId($request->getProduct());
301
+ $this->getMethodAndUrlInfo($request);
302
+ $this->getEncodedParams($request);
303
+ $request->unsVendor()
304
+ ->unsAuthCode()
305
+ ->unsProduct()
306
+ ->unsTariff();
307
+ }
308
+
309
+ /**
310
+ * Retrieve Novalnet payment type
311
+ *
312
+ * @param string $code
313
+ * @return string
314
+ */
315
+ public function getPaymentType($code)
316
+ {
317
+ $arrPaymentType = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('paymentTypes');
318
+ return $arrPaymentType[$code];
319
+ }
320
+
321
+ /**
322
+ * Get method and url infromations for redirect payments
323
+ *
324
+ * @param Varien_Object $request
325
+ * @return mixed
326
+ */
327
+ public function getMethodAndUrlInfo($request)
328
+ {
329
+ $request->setUserVariable_0(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB))
330
+ ->setReturnMethod(Novalnet_Payment_Model_Config::NOVALNET_RETURN_METHOD)
331
+ ->setErrorReturnMethod(Novalnet_Payment_Model_Config::NOVALNET_RETURN_METHOD)
332
+ ->setReturnUrl($this->_helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_RETURN_URL))
333
+ ->setErrorReturnUrl($this->_helper->getUrl(Novalnet_Payment_Model_Config::GATEWAY_ERROR_RETURN_URL));
334
+ }
335
+
336
+ /**
337
+ * Assign fraud module params
338
+ *
339
+ * @param Varien_Object $request
340
+ * @param Varien_Object $methodSession
341
+ * @return none
342
+ */
343
+ public function setFraudModuleParams($request, $methodSession)
344
+ {
345
+ $paymentCode = ucfirst($this->code); // Payment method code
346
+ $callbackTelNo = "getCallbackTel" . $paymentCode; // End-customer telephone/mobile number
347
+ $callbackEmail = "getCallbackEmail" . $paymentCode; // End-customer email address
348
+
349
+ if ($this->getNovalnetConfig('callback') == 1) { //PIN By Callback
350
+ $request->setTel($methodSession->$callbackTelNo())
351
+ ->setPinByCallback(true);
352
+ } elseif ($this->getNovalnetConfig('callback') == 2) { //PIN By SMS
353
+ $request->setTel($methodSession->$callbackTelNo())
354
+ ->setPinBySms(true);
355
+ }
356
+ }
357
+
358
+ /**
359
+ * build process (capture/void/refund) request
360
+ *
361
+ * @param Varien_Object $payment
362
+ * @param string $type
363
+ * @param float|NULL $amount
364
+ * @return Varien_Object $request
365
+ */
366
+ public function buildProcessRequest(Varien_Object $payment, $type, $amount = null)
367
+ {
368
+ $request = $this->getprocessVendorInfo($payment); // Get Novalnet merchant authentication informations
369
+
370
+ if ($type == 'void' || $type == 'capture') { // Assign needed capture/void process request params
371
+ $getTid = $this->_helper->makeValidNumber($payment->getLastTransId());
372
+ $status = ($type == 'capture')
373
+ ? Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
374
+ : Novalnet_Payment_Model_Config::PAYMENT_VOID_STATUS;
375
+ $request->setTid($getTid)
376
+ ->setStatus($status)
377
+ ->setEditStatus(true);
378
+ } else { // Assign needed refund process request params
379
+ // Refund validation for Invoice payment method
380
+ $refundTid = $this->_helper->makeValidNumber($payment->getRefundTransactionId());
381
+ $paymentCode = $payment->getMethodInstance()->getCode(); // Get payment method code
382
+
383
+ if ($paymentCode == Novalnet_Payment_Model_Config::NN_SEPA) {
384
+ // Get payment last transaction id
385
+ $refundTid = $this->_helper->makeValidNumber($payment->getLastTransId());
386
+ }
387
+
388
+ $refundAmount = $this->_helper->getFormatedAmount($amount); // Refund amount in cents
389
+ $request->setTid($refundTid)
390
+ ->setRefundRequest(true)
391
+ ->setRefundParam($refundAmount);
392
+ $this->refundAdditionalParam($request); // Add additonal params for refund process
393
+ }
394
+
395
+ return $request;
396
+ }
397
+
398
+ /**
399
+ * Assign Novalnet authentication Data
400
+ *
401
+ * @param Varien_Object $payment
402
+ * @return Varien_Object $request
403
+ */
404
+ public function getprocessVendorInfo($payment)
405
+ {
406
+ $data = unserialize($payment->getAdditionalData()); // Get payment additional data
407
+ $paymentCode = $payment->getMethodInstance()->getCode(); // Get payment method code
408
+ $paymentId = $this->_helper->getPaymentId($paymentCode);
409
+
410
+ $request = new Varien_Object();
411
+ $request->setVendor(!empty($data['vendor']) ? trim($data['vendor']) : $this->vendorId)
412
+ ->setAuthCode(!empty($data['auth_code']) ? trim($data['auth_code']) : $this->authcode)
413
+ ->setProduct(!empty($data['product']) ? trim($data['product']) : $this->productId)
414
+ ->setTariff(!empty($data['tariff']) ? trim($data['tariff']) : $this->tariffId)
415
+ ->setKey(!empty($data['payment_id']) ? trim($data['payment_id']) : $paymentId);
416
+ return $request;
417
+ }
418
+
419
+ /**
420
+ * Add additonal params for refund process
421
+ *
422
+ * @param Varien_Object $request
423
+ * @return none
424
+ */
425
+ public function refundAdditionalParam($request)
426
+ {
427
+ $getParam = Mage::app()->getRequest();
428
+ // Get bank account information for refund process
429
+ $refundType = $getParam->getParam('refund_payment_type');
430
+ $accountHolder = $getParam->getParam('nn_sepa_holder');
431
+ $iban = $getParam->getParam('nn_sepa_iban');
432
+ $bic = $getParam->getParam('nn_sepa_bic');
433
+ // Get reference value for refund process
434
+ $refundRef = $getParam->getParam('nn_refund_ref');
435
+
436
+ if ($refundType == 'SEPA' && (!$iban || !$bic || !$accountHolder)) {
437
+ $this->_helper->showException('Your account details are invalid');
438
+ } elseif ($refundRef && preg_match('/[#%\^<>@$=*!]/', $refundRef)) {
439
+ $this->_helper->showException('Your account details are invalid');
440
+ }
441
+
442
+ if ($refundRef) {
443
+ $request->setRefundRef($refundRef); // Add reference param
444
+ }
445
+
446
+ if ($iban && $bic) { // Add bank account params
447
+ $request->setAccountHolder($accountHolder)
448
+ ->setIban($iban)
449
+ ->setBic($bic);
450
+ }
451
+ }
452
+
453
+ /**
454
+ * build recurring API process (cancel/suspend/active) request
455
+ *
456
+ * @param Varien_Object $order
457
+ * @param Mage_Payment_Model_Recurring_Profile $profile
458
+ * @return Varien_Object $request
459
+ */
460
+ public function buildRecurringApiRequest(Varien_Object $order, $profile)
461
+ {
462
+ $request = new Varien_Object();
463
+ // Get Novalnet merchant authentication informations
464
+ $request = $this->getprocessVendorInfo($order->getPayment());
465
+
466
+ if ($profile->getNewState() == 'canceled') {
467
+ $getRequest = Mage::app()->getRequest()->getQuery();
468
+ $request->setNnLang(strtoupper($this->_helper->getDefaultLanguage()))
469
+ ->setCancelSub(1)
470
+ ->setCancelReason($getRequest['reason'])
471
+ ->setTid($profile->getReferenceId());
472
+ } elseif ($profile->getNewState() == 'suspended' || $profile->getNewState() == 'active') {
473
+ $request = $this->recurringActiveSuspendRequest($order->getPayment(), $profile, $request);
474
+ }
475
+
476
+ return $request;
477
+ }
478
+
479
+ /**
480
+ * build recurring API process (cancel/suspend/active) request
481
+ *
482
+ * @param Varien_Object $payment
483
+ * @param Mage_Payment_Model_Recurring_Profile $profile
484
+ * @return Varien_Object $request
485
+ */
486
+ public function recurringActiveSuspendRequest(Varien_Object $payment, $profile, $request)
487
+ {
488
+ $type = $profile->getNewState(); // Get recurring profile state
489
+ $periodInfo = $this->getPeriodValues($profile);// Get subscription period frequency and unit
490
+ $subsIdRequest = $payment->getAdditionalInformation('subs_id'); // Get subsId
491
+ $suspend = ($type == 'suspended') ? 1 : 0;
492
+ $pausePeriod = ($type == 'suspended') ? 1 : $periodInfo['periodFrequency'];
493
+ $pausePeriodUnit = ($type == 'suspended') ? 'd' : $periodInfo['periodUnit'];
494
+
495
+ $params = '<?xml version="1.0" encoding="UTF-8"?>';
496
+ $params .= '<nnxml><info_request>';
497
+ $params .= '<vendor_id>' . $request->getVendor() . '</vendor_id>';
498
+ $params .= '<vendor_authcode>' . $request->getAuthCode() . '</vendor_authcode>';
499
+ $params .= '<request_type>' . Novalnet_Payment_Model_Config::SUBS_PAUSE . '</request_type>';
500
+ $params .= '<product_id>' . $request->getProduct() . '</product_id>';
501
+ $params .= '<tid>' . $profile->getReferenceId() . '</tid>';
502
+ $params .= '<subs_id>' . $subsIdRequest . '</subs_id>';
503
+ $params .= '<pause_period>' . $pausePeriod . '</pause_period>';
504
+ $params .= '<pause_time_unit>' . $pausePeriodUnit . '</pause_time_unit>';
505
+ $params .= '<suspend>' . $suspend . '</suspend>';
506
+ $params .= '</info_request></nnxml>';
507
+
508
+ return $params;
509
+ }
510
+
511
+ /**
512
+ * Get subscription period frequency and unit
513
+ *
514
+ * @param Mage_Payment_Model_Recurring_Profile $profile
515
+ * @return string
516
+ */
517
+ public function getPeriodValues($profile)
518
+ {
519
+ $periodFrequency = $profile->getperiodFrequency();
520
+ $periodUnit = $this->_helper->__(ucfirst($profile->getperiodUnit()));
521
+ $periodUnitFormat = array(
522
+ $this->_helper->__('Day') => "d",
523
+ $this->_helper->__('Month') => "m",
524
+ $this->_helper->__('Year') => "y"
525
+ );
526
+
527
+ if ($periodUnit == 'Semi_month') {
528
+ $tariffPeriod = array('periodFrequency' => '14', 'periodUnit' => 'd');
529
+ } elseif ($periodUnit == 'Week') {
530
+ $tariffPeriod = array('periodFrequency' => ($periodFrequency * 7), 'periodUnit' => 'd');
531
+ } else {
532
+ $tariffPeriod = array('periodFrequency' => $periodFrequency, 'periodUnit' => $periodUnitFormat[$periodUnit]);
533
+ }
534
+
535
+ return $tariffPeriod;
536
+ }
537
+
538
+ /**
539
+ * Set recurring profile params for fraud prevention process
540
+ *
541
+ * @param varien_object $request
542
+ * @return none
543
+ */
544
+ public function getCallbackProfileParams($request)
545
+ {
546
+ $checkoutSession = $this->_helper->getCheckoutSession(); // Get checkout session
547
+ $subsequentPeriod = $this->getNovalnetConfig('subsequent_period', true);
548
+ $recurringTariffId = $this->getNovalnetConfig('subscrib_tariff_id', true);
549
+ // Get order amount (Add initial fees if exist)
550
+ $amount = $this->_helper->getFormatedAmount($checkoutSession->getNnRowAmount());
551
+ // Get order amount
552
+ $subsequentAmount = $this->_helper->getFormatedAmount($checkoutSession->getNnRegularAmount());
553
+ $periodUnit = $checkoutSession->getNnPeriodUnit(); // Get recurring profile period unit
554
+ $periodFrequency = $checkoutSession->getNnPeriodFrequency(); // Get recurring profile period frequency
555
+ $periodUnitFormat = array("day" => "d", "month" => "m", "year" => "y");
556
+
557
+ if ($periodUnit == "semi_month") {
558
+ $tariffPeriod = "14d";
559
+ } elseif ($periodUnit == "week") {
560
+ $tariffPeriod = ($periodFrequency * 7) . "d";
561
+ } else {
562
+ $tariffPeriod = $periodFrequency . $periodUnitFormat[$periodUnit];
563
+ }
564
+ // Add recurring payment params
565
+ $request->setTariff($recurringTariffId)
566
+ ->setTariffPeriod($tariffPeriod)
567
+ ->setTariffPeriod2($subsequentPeriod ? $subsequentPeriod : $tariffPeriod)
568
+ ->setAmount($amount)
569
+ ->setTariffPeriod2Amount($subsequentAmount);
570
+ }
571
+
572
+ }
app/code/community/Novalnet/Payment/Model/Service/Api/Response.php ADDED
@@ -0,0 +1,847 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Service_Api_Response extends Novalnet_Payment_Model_Service_Abstract
27
+ {
28
+ /**
29
+ * Validate the Novalnet payment response
30
+ *
31
+ * @param Varien_Object $order
32
+ * @param Varien_Object $request
33
+ * @param Varien_Object $response
34
+ * @return boolean
35
+ */
36
+ public function validateResponse($order, $request, $response)
37
+ {
38
+ $status = false;
39
+ $payment = $order->getPayment(); // Get payment object
40
+ $this->code = $payment->getMethodInstance()->getCode(); // Get payment method code
41
+
42
+ $shopMode = $this->getNovalnetConfig('live_mode', true); // Novalnet payment mode from global configuration
43
+ $testMode = ($response->getTestMode() == 1 || $shopMode == 0) ? 1 : 0; // Get Novalnet payment transaction mode
44
+
45
+ // Log Novalnet payment transaction informations
46
+ $this->logTransactionStatus($response, $order);
47
+ // Log Novalnet payment transaction traces informations
48
+ $this->logTransactionTraces($request, $response, $order);
49
+
50
+ switch ($response->getStatus()) {
51
+ case Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED: // Novalnet successful transaction status
52
+ $data = $this->getPaymentAddtionaldata($response, $request, $testMode); // Get Novalnet transaction details
53
+ $this->saveAdditionalData($order, $data); // Save Novalnet payment additional informations
54
+ $this->setRecurringState($response, $order); // Assign recurring profile state if profile exist
55
+ $this->capturePayment($order, $response); // Capture the payment based on real transaction status
56
+ $this->logAffiliateUserInfo($request); // Log affiliate user information
57
+ $statusText = $this->getStatusText($response); // Get payment transaction status message
58
+ $this->_helper->getCoreSession()->addSuccess($statusText);
59
+ $status = true;
60
+ break;
61
+ default: // Novalnet unsuccessful transaction status
62
+ $this->setRecurringState($response, '', 'canceled'); // Assign recurring profile state if profile exist
63
+ $this->saveCanceledOrder($response, $order, $testMode); // Cancel the order for failure transaction
64
+ $statusMessage = $this->getUnSuccessPaymentText($response); // Get payment transaction status message
65
+ $this->_helper->getCoreSession()->addError($statusMessage);
66
+ $status = false;
67
+ break;
68
+ }
69
+ return $status;
70
+ }
71
+
72
+ /**
73
+ * Log affiliate user details
74
+ *
75
+ * @param Varien_Object $request
76
+ * @return none
77
+ */
78
+ public function logAffiliateUserInfo($request)
79
+ {
80
+ $affiliateId = $this->_helper->getCoreSession()->getAffiliateId(); // Get affiliate user id if exist
81
+
82
+ if ($affiliateId) {
83
+ $affiliateUserInfo = $this->_helper->getModel('Mysql4_AffiliateUser');
84
+ $affiliateUserInfo->setAffId($affiliateId)
85
+ ->setCustomerNo($request->getCustomerNo())
86
+ ->setAffOrderNo($request->getOrderNo())
87
+ ->save();
88
+ $this->_helper->getCoresession()->unsAffiliateId();
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Get Payment method additional informations
94
+ *
95
+ * @param Varien_Object $response
96
+ * @param int $testMode
97
+ * @param array
98
+ */
99
+ public function getPaymentAddtionaldata($response, $request, $testMode)
100
+ {
101
+ $data = array('NnTestOrder' => $testMode, 'NnTid' => trim($response->getTid()),
102
+ 'vendor' => $request->getVendor(), 'auth_code' => $request->getAuthCode(),
103
+ 'product' => $request->getProduct(), 'tariff' => $request->getTariff(),
104
+ 'payment_id'=> $request->getKey(), 'accessKey' => $this->accessKey
105
+ );
106
+ if (in_array($this->code, array('novalnetInvoice', 'novalnetPrepayment'))) {
107
+ $amount = Mage::helper('core')->currency($response->getAmount(), true, false);
108
+ $data['NnNote'] = $this->getInvoicePaymentNote($response);
109
+ $data['NnDueDate'] = $response->getDueDate();
110
+ $data['NnNoteAmount'] = 'NN_Amount: ' . $amount;
111
+ $data['NnNoteTID'] = $this->getReferenceDetails($response, $request);
112
+ }
113
+ $data['paidUntil'] = $response->getNextSubsCycle() ? $response->getNextSubsCycle()
114
+ : ($response->getPaidUntil() ? $response->getPaidUntil() : '');
115
+ return $data;
116
+ }
117
+
118
+ /**
119
+ * Get Novalnet invoice payments bank account details
120
+ *
121
+ * @param array $response
122
+ * @return mixed
123
+ */
124
+ public function getInvoicePaymentNote($response)
125
+ {
126
+ $dueDate = Mage::helper('core')->formatDate($response->getDueDate());
127
+ $note = null;
128
+ $note .= 'Due Date: ' . $dueDate . '|NN Account Holder: NOVALNET AG';
129
+ $note .= '|IBAN: ' . $response->getInvoiceIban();
130
+ $note .= '|BIC: ' . $response->getInvoiceBic();
131
+ $note .= '|NN_Bank: ' . $response->getInvoiceBankname() . ' ' . $response->getInvoiceBankplace();
132
+ return $note;
133
+ }
134
+
135
+ /**
136
+ * Get Novalnet invoice payment reference details
137
+ *
138
+ * @param Varien_Object $response
139
+ * @param Varien_Object $request
140
+ * @return string
141
+ */
142
+ public function getReferenceDetails($response, $request)
143
+ {
144
+ $paymentReference = array();
145
+ $note = null;
146
+ $transactionId = trim($response->getTid());
147
+ $productId = $request->getProduct() ? $request->getProduct() : '';
148
+ $orderNo = $request->getOrderNo() ? $request->getOrderNo() : '';
149
+ $paymentRefOne = $this->getNovalnetConfig('payment_ref_one');
150
+ $paymentRefTwo = $this->getNovalnetConfig('payment_ref_two');
151
+ $paymentRefThree = $this->getNovalnetConfig('payment_ref_three');
152
+ $paymentRefConfig = array($paymentRefOne, $paymentRefTwo, $paymentRefThree);
153
+
154
+ foreach ($paymentRefConfig as $value) {
155
+ if ($value == 1) {
156
+ $paymentReference[] .= $value;
157
+ }
158
+ }
159
+
160
+ $refCount = count($paymentReference);
161
+ $note .= ($refCount > 1) ? "NN_Reference_desc1:" : "NN_Reference_desc2:";
162
+
163
+ $flag = 0;
164
+ if (!empty($paymentRefOne)) {
165
+ $flag = ($refCount == 1) ? '' : $flag + 1;
166
+ $note .= "|NN_Reference$flag:BNR-$productId-$orderNo";
167
+ }
168
+
169
+ if (!empty($paymentRefTwo)) {
170
+ $flag = ($refCount == 1) ? '' : $flag + 1;
171
+ $note .= "|NN_Reference$flag:TID $transactionId";
172
+ }
173
+
174
+ if (!empty($paymentRefThree)) {
175
+ $flag = ($refCount == 1) ? '' : $flag + 1;
176
+ $note .= "|NN_Reference$flag:Order No&$orderNo";
177
+ }
178
+
179
+ return $note;
180
+ }
181
+
182
+ /**
183
+ * Remove sensitive data form Novalnet request
184
+ *
185
+ * @param Varien_Object $request
186
+ * @param string $paymentCode
187
+ * @return Varien_Object $request
188
+ */
189
+ public function removeSensitiveData($request, $paymentCode)
190
+ {
191
+ if ($paymentCode) {
192
+ switch ($paymentCode) {
193
+ case Novalnet_Payment_Model_Config::NN_CC:
194
+ $request->unsCcCvc2();
195
+ break;
196
+ case Novalnet_Payment_Model_Config::NN_SEPA:
197
+ $request->unsBankAccountHolder()
198
+ ->unsSepaHash()
199
+ ->unsIbanBicConfirmed()
200
+ ->unsSepaUniqueId();
201
+ break;
202
+ }
203
+ }
204
+ return $request;
205
+ }
206
+
207
+ /**
208
+ * Fraud prevention API request process
209
+ *
210
+ * @param Varien_Object $request
211
+ * @param int $transactionId
212
+ * @param string $requestType
213
+ * @param mixed $extraOption
214
+ * @return Varien_Object $result
215
+ */
216
+ public function pinStatusCall($request, $transactionId, $requestType, $extraOption = null)
217
+ {
218
+ $params = '<?xml version="1.0" encoding="UTF-8"?>';
219
+ $params .= '<nnxml><info_request>';
220
+ $params .= '<vendor_id>' . $request->getVendor() . '</vendor_id>';
221
+ $params .= '<vendor_authcode>' . $request->getAuthCode() . '</vendor_authcode>';
222
+ $params .= '<request_type>' . $requestType . '</request_type>';
223
+ $params .= '<product_id>' . $request->getProduct() . '</product_id>';
224
+ $params .= '<tid>' . $transactionId . '</tid>' . $extraOption;
225
+ $params .= '</info_request></nnxml>';
226
+
227
+ $infoRequestUrl = $this->_helper->getPayportUrl('infoport'); // Get Novalnet payport URL
228
+ $gatewayModel = $this->_helper->getModel('Service_Api_Gateway'); // Get Novalnet gateway model
229
+ $result = $gatewayModel->payportRequestCall($params, $infoRequestUrl, 'XML'); // Send API request
230
+
231
+ return $result;
232
+ }
233
+
234
+ /**
235
+ * Save payment additional informations
236
+ *
237
+ * @param Varien_Object $order
238
+ * @param array $data
239
+ * @return none
240
+ */
241
+ public function saveAdditionalData($order, $data)
242
+ {
243
+ $payment = $order->getPayment(); // Get payment object
244
+ // Save additional transaction informations
245
+ $payment->setIsTransactionClosed(false)
246
+ ->setAdditionalData(serialize($data))
247
+ ->save();
248
+ $order->setPayment($payment);
249
+ $order->save();
250
+ }
251
+
252
+ /**
253
+ * Save payment informations
254
+ *
255
+ * @param Varien_Object $order
256
+ * @param Varien_Object $response
257
+ * @return none
258
+ */
259
+ public function capturePayment($order, $response)
260
+ {
261
+ $payment = $order->getPayment(); // Get payment object
262
+ $paymentCode = $payment->getMethodInstance()->getCode(); // Payment method code
263
+ $transactionId = $response->getTid(); // Get Novalnet transaction id
264
+
265
+ // Save TID details
266
+ $payment->setTransactionId($transactionId)
267
+ ->setLastTransId($transactionId)
268
+ ->setParentTransactionId(null);
269
+ // Capture the payment only if status (original status - tid_status) is 100
270
+ if ($order->canInvoice() && ($paymentCode != Novalnet_Payment_Model_Config::NN_PREPAYMENT)
271
+ && $response->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
272
+ ) {
273
+ $captureMode = (version_compare($this->_helper->getMagentoVersion(), '1.6', '<')) ? false : true;
274
+ $payment->setTransactionId($transactionId) // Add capture text to make the new transaction
275
+ ->setIsTransactionClosed($captureMode) // Close the transaction
276
+ ->capture(null);
277
+ }
278
+
279
+ $payment->save();
280
+ $order->setPayment($payment);
281
+
282
+ $orderStatus = ($paymentCode == Novalnet_Payment_Model_Config::NN_CC)
283
+ ? $this->getNovalnetConfig('order_status_after_payment') : $this->getNovalnetConfig('order_status');
284
+ // If after status is empty set default status
285
+ $status = Mage_Sales_Model_Order::STATE_PROCESSING;
286
+ $setOrderStatus = $orderStatus ? $orderStatus : $status;
287
+ $order->setState($status, $setOrderStatus, $this->_helper->__('Payment was successful'), true);
288
+ $order->save();
289
+ }
290
+
291
+ /**
292
+ * Get response status message
293
+ *
294
+ * @param Varien_Object $result
295
+ * @return string
296
+ */
297
+ public function getStatusText(Varien_Object $result)
298
+ {
299
+ return $result->getStatusMessage() ? $result->getStatusMessage()
300
+ : ($result->getStatusDesc() ? $result->getStatusDesc() : ($result->getStatusText()
301
+ ? $result->getStatusText() : $this->_helper->__('successful')));
302
+ }
303
+
304
+ /**
305
+ * Get response status message for failure payments
306
+ *
307
+ * @param Varien_Object $result
308
+ * @return string
309
+ */
310
+ public function getUnSuccessPaymentText(Varien_Object $result)
311
+ {
312
+ return $result->getStatusMessage() ? $result->getStatusMessage()
313
+ : ($result->getStatusDesc() ? $result->getStatusDesc() : ($result->getStatusText()
314
+ ? $result->getStatusText() : $this->_helper->__('Payment was not successfull')));
315
+ }
316
+
317
+ /**
318
+ * Save canceled payment transaction
319
+ *
320
+ * @param Varien_Object $response
321
+ * @param Varien_Object $order
322
+ * @param int $testMode
323
+ * @return none
324
+ */
325
+ public function saveCanceledOrder($response, $order, $testMode)
326
+ {
327
+ $payment = $order->getPayment();
328
+ $statusMessage = $this->getUnSuccessPaymentText($response); // Get payment transaction status message
329
+ $payStatus = "<b><font color='red'>" . $this->_helper->__('Payment Failed') . "</font> - " . $statusMessage . "</b>";
330
+ $data = unserialize($payment->getAdditionalData());
331
+ $data['NnTid'] = $response->getTid();
332
+ $data['NnTestOrder'] = $testMode;
333
+ $data['NnComments'] = empty($data['NnComments']) ? $payStatus : $data['NnComments'] . '<br />' . $payStatus;
334
+ $payment->setLastTransId($response->getTid())
335
+ ->setAdditionalData(serialize($data))
336
+ ->save();
337
+ $order->registerCancellation($statusMessage)
338
+ ->save();
339
+ Mage::dispatchEvent('sales_order_payment_void', array('payment' => $payment));
340
+ }
341
+
342
+ /**
343
+ * Checking Novalnet response data for redirect payments
344
+ *
345
+ * @param Varien_Object $response
346
+ * @param Varien_Object $order
347
+ * @return boolean
348
+ */
349
+ public function checkReturnedData($response, $order)
350
+ {
351
+ $status = false;
352
+ $payment = $order->getPayment(); // Get payment object
353
+ $paymentObj = $payment->getMethodInstance(); // Get payment method instance
354
+ $this->code = $paymentObj->getCode(); // Get payment method code
355
+ $this->_helper->getCheckout()->getQuote()->setIsActive(true)->save();
356
+
357
+ // Unhold an order
358
+ if ($order->canUnhold()) {
359
+ $order->unhold()->save();
360
+ }
361
+
362
+ $checkHash = $this->checkHash($response); // Validate hash value if exist
363
+ $this->getDecodedParams($response); // Get decoded payment params if exist
364
+ $shopMode = $this->getNovalnetConfig('live_mode', true); // Novalnet payment mode from global configuration
365
+ $testMode = ($response->getTestMode() == 1 || $shopMode == 0) ? 1 : 0; // Get Novalnet payment mode
366
+
367
+ if (!$checkHash) { // Cancel the order when hash value mismatched
368
+ $response->setStatusMessage($this->_helper->__('checkHash failed'));
369
+ $this->saveCanceledOrder($response, $order, $testMode); // Cancel the order for failure transaction
370
+ $this->_helper->getCoreSession()->addError($response->getStatusMessage());
371
+ return false;
372
+ }
373
+
374
+ $request = $this->_helper->getMethodSession($this->code)->getPaymentReqData(); // Get payment request params
375
+ $this->logTransactionStatus($response, $order); // Log Novalnet payment transaction informations
376
+
377
+ if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
378
+ || $response->getTidStatus() == Novalnet_Payment_Model_Config::PAYPAL_PENDING_CODE
379
+ ) { // Novalnet successful transaction status
380
+ $successActionFlag = $this->code . '_successAction';
381
+ if ($payment->getAdditionalInformation($successActionFlag) != 1) {
382
+ $payment->setAdditionalInformation($successActionFlag, 1)->save();
383
+ // Assign recurring profile state if profile exist
384
+ $this->setRecurringState($response, $order);
385
+ // save payment additional informations
386
+ $data = array('NnTestOrder' => $testMode, 'NnTid' => trim($response->getTid()),
387
+ 'vendor' => ($request->hasVendorId() ? $response->getVendorId() : $response->getVendor()),
388
+ 'auth_code' => ($request->hasVendorAuthcode() ? $response->getVendorAuthcode() : $response->getAuthCode()),
389
+ 'product' => ($request->hasProductId() ? $response->getProductId() : $response->getProduct()),
390
+ 'tariff' => ($request->hasTariffId() ? $response->getTariffId() : $response->getTariff()),
391
+ 'payment_id'=> $request->getKey(), 'accessKey' => $this->accessKey
392
+ );
393
+ $data['paidUntil'] = $response->getNextSubsCycle() ? $response->getNextSubsCycle()
394
+ : ($response->getPaidUntil() ? $response->getPaidUntil() : '');
395
+ $this->saveAdditionalData($order, $data);
396
+ // save transaction informations to order
397
+ $this->saveSuccessOrder($order, $request, $response);
398
+ }
399
+ $status = true;
400
+ } else { // Novalnet unsuccessful transaction status
401
+ $this->setRecurringState($response, '', 'canceled'); // Assign recurring profile state if profile exist
402
+ $this->saveCanceledOrder($response, $order, $testMode); // Cancel the order for failure transaction
403
+ $statusMessage = $this->getUnSuccessPaymentText($response); // Get payment transaction status message
404
+ $this->_helper->getCoreSession()->addError($statusMessage);
405
+ $status = false;
406
+ }
407
+
408
+ $this->_helper->unsetMethodSession($this->code); // Unset payment method session
409
+ Mage::unregister('payment_code'); // Unregister the payment code
410
+ $order->save();
411
+ return $status;
412
+ }
413
+
414
+ /**
415
+ * validate the Novalnet response and save the order
416
+ *
417
+ * @param Varien_Object $order
418
+ * @param Varien_Object $request
419
+ * @param Varien_Object $response
420
+ * @return none
421
+ */
422
+ public function saveSuccessOrder($order, $request, $response)
423
+ {
424
+ $this->capturePayment($order, $response); // Capture the transaction
425
+ $this->logAffiliateUserInfo($request); // Log affiliate user information
426
+ $orderStatus = $this->getNovalnetConfig('order_status_after_payment')
427
+ ? $this->getNovalnetConfig('order_status_after_payment') : Mage_Sales_Model_Order::STATE_PROCESSING;
428
+ if ($response->getTidStatus() == Novalnet_Payment_Model_Config::PAYPAL_PENDING_CODE) {
429
+ $orderStatus = $this->getNovalnetConfig('order_status')
430
+ ? $this->getNovalnetConfig('order_status') : Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
431
+ }
432
+
433
+ $message = $this->_helper->__('Customer successfully returned from Novalnet');
434
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $orderStatus, $message, true)->save();
435
+ $statusText = $this->getStatusText($response); // Get payment response status text
436
+ $this->_helper->getCoreSession()->addSuccess($statusText);
437
+ }
438
+
439
+ /**
440
+ * Save the failure transaction
441
+ *
442
+ * @param Varien_Object $response
443
+ * @param Varien_Object $order
444
+ * @return none
445
+ */
446
+ public function checkErrorReturnedData($response, $order)
447
+ {
448
+ $payment = $order->getPayment(); // Get payment object
449
+ $this->code = $payment->getMethodInstance()->getCode(); // Get payment method code
450
+ $this->_helper->getCheckout()->getQuote()->setIsActive(false)->save();
451
+ $this->getDecodedParams($response); // Get decoded payment data
452
+ $shopMode = $this->getNovalnetConfig('live_mode', true); // Novalnet payment mode from global configuration
453
+ $testMode = ($response->getTestMode() == 1 || $shopMode == 0) ? 1 : 0; // Get Novalnet payment mode
454
+
455
+ //Unhold an order
456
+ if ($order->canUnhold()) {
457
+ $order->unhold()->save();
458
+ }
459
+
460
+ // Assign recurring profile state if profile exist
461
+ $this->setRecurringState($response, '', 'canceled');
462
+
463
+ // Cancel the order
464
+ $errorActionFlag = $this->code . '_errorAction';
465
+ if ($payment->getAdditionalInformation($errorActionFlag) != 1) {
466
+ $this->logTransactionStatus($response, $order); // Log Novalnet payment transaction informations
467
+ $payment->setAdditionalInformation($errorActionFlag, 1); // Get payment request params
468
+ $this->saveCanceledOrder($response, $order, $testMode); // Cancel the order for failure transaction
469
+ $statusMessage = $this->getUnSuccessPaymentText($response); // Get payment transaction status message
470
+ $this->_helper->getCoreSession()->addError($statusMessage);
471
+ $this->_helper->unsetMethodSession($this->code); // Unset payment method session
472
+ Mage::unregister('payment_code'); // Unregister the payment code
473
+ }
474
+ }
475
+
476
+ /**
477
+ * Set recurring profile state
478
+ *
479
+ * @param Varien_Object $response
480
+ * @param Varien_Object|null $order
481
+ * @param string|null $state
482
+ * @return none
483
+ */
484
+ public function setRecurringState($response, $order, $state = 'Active')
485
+ {
486
+ $profileId = $response->hasProfileId() ? $response->getProfileId()
487
+ : ($response->hasInput4() && $response->getInput4() == 'profile_id'
488
+ ? $response->getInputval4() : '');
489
+
490
+ if ($profileId) {
491
+ $profile = Mage::getModel('sales/recurring_profile')->load($profileId, 'profile_id');
492
+
493
+ if ($state == 'Active') {
494
+ $payment = $order->getPayment();
495
+ $recurringModel = $this->_helper->getModel('Recurring_Payment');
496
+ $message = $recurringModel->createIpnComment($response->getTidStatus(), $order);
497
+ $payment->setPreparedMessage($message)
498
+ ->setAdditionalInformation('subs_id', $response->getSubsId())->save();
499
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
500
+ } else {
501
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
502
+ }
503
+
504
+ $profile->setReferenceId($response->getTid())->save();
505
+ }
506
+ }
507
+
508
+ /**
509
+ * Log Novalnet transaction status data
510
+ *
511
+ * @param Varien_Object $response
512
+ * @param Varien_Object $order
513
+ * @return none
514
+ */
515
+ public function logTransactionStatus($response, $order)
516
+ {
517
+ $amount = str_replace(array('.', ','), '', $response->getAmount()); // Get amount
518
+ $maskedAccountInfo = $this->saveMaskedAccountInfo($response); // Get masked card/account data
519
+ $transactionStatus = $this->_helper->getModel('Mysql4_TransactionStatus'); // Get transaction status model
520
+ $paymentCode = $order->getPayment()->getMethodInstance()->getCode(); // Get payment method code
521
+ $transactionStatus->setTransactionNo(trim($response->getTid()))
522
+ ->setOrderId($order->getIncrementId())
523
+ ->setTransactionStatus($response->getTidStatus())
524
+ ->setNcNo($response->getNcNo())
525
+ ->setCustomerId($order->getCustomerId())
526
+ ->setPaymentName($paymentCode)
527
+ ->setAmount($amount)
528
+ ->setRemoteIp($this->_helper->getRealIpAddr())
529
+ ->setStoreId($order->getStoreId())
530
+ ->setShopUrl($this->_helper->getBaseUrl())
531
+ ->setCreatedDate($this->_helper->getCurrentDateTime())
532
+ ->setNovalnetAccDetails($maskedAccountInfo)
533
+ ->setReferenceTransaction($this->refTransaction)
534
+ ->save();
535
+ }
536
+
537
+ /**
538
+ * Get masked card/account data
539
+ *
540
+ * @param Varien_Object $response
541
+ * @return array $maskedInfo
542
+ */
543
+ public function saveMaskedAccountInfo($response)
544
+ {
545
+ $maskedInfo = '';
546
+ $methodSession = $this->_helper->getMethodSession($this->code);
547
+ $this->refTransaction = 1;
548
+
549
+ if ($this->code == Novalnet_Payment_Model_Config::NN_CC
550
+ && in_array($response->getTidStatus(), array(100, 98))
551
+ ) {
552
+ $this->refTransaction = ($methodSession->getNnCcTid()) ? 1 : 0;
553
+ $maskedInfo = $this->getMaskedCardInfo($response); // Get masked card data
554
+ } elseif ($this->code == Novalnet_Payment_Model_Config::NN_SEPA
555
+ && in_array($response->getTidStatus(), array(100, 99))
556
+ ) {
557
+ $this->refTransaction = ($methodSession->getNnSepaTid()) ? 1 : 0;
558
+ $maskedInfo = $this->getMaskedAccountInfo($response, $methodSession); // Get masked account data
559
+ }
560
+ return $maskedInfo;
561
+ }
562
+
563
+ /**
564
+ * Get masked card data
565
+ *
566
+ * @param Varien_Object $response
567
+ * @return array $maskedCardInfo
568
+ */
569
+ public function getMaskedCardInfo($response)
570
+ {
571
+ $maskedCardInfo = array(
572
+ 'card_type' => $response->getCcCardType(),
573
+ 'card_holder' => $response->getCcHolder(),
574
+ 'cc_no' => $response->getCcNo(),
575
+ 'exp_month' => $response->getCcExpMonth(),
576
+ 'exp_year' => $response->getCcExpYear(),
577
+ 'nn_tid' => $response->getTid(),
578
+ 'nn_amount' => $response->getAmount(),
579
+ );
580
+ return base64_encode(serialize($maskedCardInfo));
581
+ }
582
+
583
+ /**
584
+ * Get masked account data
585
+ *
586
+ * @param Varien_Object $response
587
+ * @param Varien_Object $methodSession
588
+ * @return array $maskedAccountInfo
589
+ */
590
+ public function getMaskedAccountInfo($response, $methodSession)
591
+ {
592
+ $maskedAccountInfo = array(
593
+ 'account_holder' => $response->getBankaccountHolder(),
594
+ 'iban' => $response->getIban(),
595
+ 'bic' => $response->getBic(),
596
+ 'pan_hash' => $methodSession->getSepaHash(),
597
+ 'nn_tid' => $response->getTid(),
598
+ 'nn_amount' => $response->getAmount(),
599
+ );
600
+ return base64_encode(serialize($maskedAccountInfo));
601
+ }
602
+
603
+ /**
604
+ * Log Novalnet payment response data
605
+ *
606
+ * @param Varien_Object $request
607
+ * @param Varien_Object $response
608
+ * @param Varien_Object $order
609
+ * @param string $transactionId
610
+ * @return none
611
+ */
612
+ public function logTransactionTraces($request, $response, $order, $transactionId = null)
613
+ {
614
+ $transactionId = ($transactionId != null) ? $transactionId : $response->getTid(); // Novalnet transaction id
615
+ // Remove the sensitive data from payment request
616
+ $request = $this->removeSensitiveData($request, $order->getPayment()->getMethodInstance()->getCode());
617
+ $transactionTraces = $this->_helper->getModel('Mysql4_TransactionTraces'); // Get transaction traces model
618
+ $transactionTraces->setTransactionId(trim($transactionId))
619
+ ->setOrderId($order->getIncrementId())
620
+ ->setRequestData(serialize($request->getData()))
621
+ ->setResponseData(base64_encode(serialize($response->getData())))
622
+ ->setCustomerId($order->getCustomerId())
623
+ ->setStatus($response->getStatus())
624
+ ->setStoreId($order->getStoreId())
625
+ ->setShopUrl($request->getSystemUrl())
626
+ ->setCreatedDate($this->_helper->getCurrentDateTime())
627
+ ->save();
628
+ }
629
+
630
+ /**
631
+ * Send process (capture/void/refund) request
632
+ *
633
+ * @param Varien_Object $request
634
+ * @param Varien_Object $payment
635
+ * @param string $type
636
+ * @param float|NULL $amount
637
+ * @return none
638
+ */
639
+ public function postProcessRequest($request, $payment, $type, $amount = null)
640
+ {
641
+ $paymentObj = $payment->getMethodInstance(); // Get payment method instance
642
+ $this->code = $paymentObj->getCode(); // Get payment method code
643
+ $response = $paymentObj->postRequest($request); // send process request to Novalnet gateway
644
+ // log payment capture traces
645
+ $this->logTransactionTraces($request, $response, $payment->getOrder(), $request->getTid());
646
+ // set profile state
647
+ $nominalItem = $this->_helper->checkNominalItem($payment->getOrder());
648
+ if ($nominalItem
649
+ && $response->getTidStatus() == Novalnet_Payment_Model_Config::PAYMENT_VOID_STATUS
650
+ ) {
651
+ $profile = Mage::getModel('sales/recurring_profile')->load($request->getTid(), 'reference_id');
652
+ $profile->setState('canceled')->save(); // Set profile status as canceled
653
+ }
654
+ // Novalnet successful transaction status
655
+ if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
656
+ if ($type == 'capture' || $type == 'void') {
657
+ // get current payment status
658
+ $transactionId = $this->_helper->makeValidNumber($payment->getLastTransId()); // payment transaction id
659
+ $transactionStatusModel = $this->_helper->getModel('Mysql4_TransactionStatus');
660
+ $transactionStatus = $transactionStatusModel->loadByAttribute('transaction_no', $transactionId);
661
+ $paymentStatus = $transactionStatus->getTransactionStatus();
662
+ // set payment transaction informations
663
+ $this->saveProcessTransInfo($payment, $paymentStatus, $request, $type);
664
+ // reset payment transaction status
665
+ $transactionStatus->setTransactionStatus($response->getTidStatus())->save();
666
+ } else {
667
+ // set payment refund transaction informations
668
+ $this->saveRefundTransInfo($payment, $amount, $request, $response);
669
+ }
670
+ } else { // Novalnet unsuccessful transaction status
671
+ $statusMessage = $this->getUnSuccessPaymentText($response); // Get payment transaction status message
672
+ $this->_helper->showException($statusMessage);
673
+ }
674
+ }
675
+
676
+ /**
677
+ * Verify the process (capture/void) response
678
+ *
679
+ * @param Varien_Object $payment
680
+ * @param int $paymentStatus
681
+ * @param Varien_Object $request
682
+ * @param string $type
683
+ * @return none
684
+ */
685
+ public function saveProcessTransInfo($payment, $paymentStatus, $request, $type)
686
+ {
687
+ $transactionId = $this->_helper->makeValidNumber($payment->getLastTransId()); // Novalnet transaction id
688
+ $magentoVersion = $this->_helper->getMagentoVersion(); // Get installed Magento shop system version
689
+ // Save additional informations
690
+ $data = unserialize($payment->getAdditionalData());
691
+ $data[$type.'Tid'] = $request->getTid();
692
+ $data[$type.'CreateAt'] = $this->_helper->getCurrentDateTime();
693
+ $payment->setAdditionalData(serialize($data))->save();
694
+
695
+ if ($type == 'capture'
696
+ && $paymentStatus != Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
697
+ ) { // Novalnet successful transaction status
698
+ // Make capture transaction open for lower versions to make refund
699
+ if (version_compare($magentoVersion, '1.6', '<')) {
700
+ $payment->setIsTransactionClosed(false)->save();
701
+ }
702
+ // Add capture transaction
703
+ $payment->setTransactionId($transactionId)
704
+ ->setIsTransactionClosed((version_compare($magentoVersion, '1.6', '<')) ? false : true);
705
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false);
706
+ $transaction->setParentTxnId(null)->save();
707
+ } elseif ($type == 'void') {
708
+ // Save void transaction information
709
+ $payment->setTransactionId($transactionId)
710
+ ->setLastTransId($transactionId)
711
+ ->save();
712
+ }
713
+ }
714
+
715
+ /**
716
+ * Save refund additional transaction information
717
+ *
718
+ * @param Varien_Object $payment
719
+ * @param float $amount
720
+ * @param Varien_Object $request
721
+ * @param Varien_Object $response
722
+ * @return none
723
+ */
724
+ public function saveRefundTransInfo($payment, $amount, $request, $response)
725
+ {
726
+ $order = $payment->getOrder(); // Get order object
727
+ $parentTxnId = $this->_helper->makeValidNumber($payment->getRefundTransactionId()); // Get refund transaction id
728
+ $childTid = $response->hasTid() ? trim($response->getTid()) : ''; // Get child tid if exist
729
+ if (!$childTid) { // Save transaction information for full refund
730
+ $transactionStatusModel = $this->_helper->getModel('Mysql4_TransactionStatus');
731
+ $transactionStatus = $transactionStatusModel->loadByAttribute('transaction_no', $parentTxnId);
732
+ $transactionStatus->setTransactionStatus($response->getTidStatus())->save();
733
+ }
734
+
735
+ // Save payment refund transaction additional information
736
+ $refundTid = !empty($childTid) ? $childTid : $payment->getLastTransId() . '-refund';
737
+ $data = unserialize($payment->getAdditionalData());
738
+ $data['fullRefund'] = ((string) $order->getBaseGrandTotal() == (string) $amount) ? true : false;
739
+ $data = $this->getRefundTidInfo($amount, $data, $refundTid, $parentTxnId);
740
+ $payment->setTransactionId($refundTid)
741
+ ->setLastTransId($refundTid)
742
+ ->setAdditionalData(serialize($data));
743
+
744
+ // Make capture transaction open for lower versions to make refund
745
+ if (version_compare($this->_helper->getMagentoVersion(), '1.6', '<')) {
746
+ $payment->setIsTransactionClosed(true) // refund initiated by merchant
747
+ ->setShouldCloseParentTransaction(!$order->canCreditmemo());
748
+ }
749
+ $payment->save();
750
+
751
+ // Save refund child transaction informations
752
+ if ($childTid) {
753
+ $this->saveChildRefundTransInfo($order, $request, $response);
754
+ }
755
+ }
756
+
757
+ /**
758
+ * Get refund transaction information
759
+ *
760
+ * @param float $amount
761
+ * @param array $data
762
+ * @param int $refundTid
763
+ * @param int $parentTxnId
764
+ * @return array
765
+ */
766
+ public function getRefundTidInfo($amount, $data, $refundTid, $parentTxnId)
767
+ {
768
+ $refundAmount = Mage::helper('core')->currency($amount, true, false);
769
+ if (!isset($data['refunded_tid'])) {
770
+ $refundedTid = array('refunded_tid' => array($refundTid => array(
771
+ 'reftid' => $refundTid,
772
+ 'refamount' => $refundAmount,
773
+ 'reqtid' => $parentTxnId
774
+ )));
775
+ $data = array_merge($data, $refundedTid);
776
+ } else {
777
+ $data['refunded_tid'][$refundTid]['reftid'] = $refundTid;
778
+ $data['refunded_tid'][$refundTid]['refamount'] = $refundAmount;
779
+ $data['refunded_tid'][$refundTid]['reqtid'] = $parentTxnId;
780
+ }
781
+ return $data;
782
+ }
783
+
784
+ /**
785
+ * Save refund child transaction information
786
+ *
787
+ * @param Varien_Object $order
788
+ * @param Varien_Object $request
789
+ * @param Varien_Object $response
790
+ * @return none
791
+ */
792
+ public function saveChildRefundTransInfo($order, $request, $response)
793
+ {
794
+ // Refund child transaction information log
795
+ $transactionStatus = $this->_helper->getModel('Mysql4_TransactionStatus');
796
+ $transactionStatus->setTransactionNo(trim($response->getTid()))
797
+ ->setOrderId($order->getIncrementId())
798
+ ->setTransactionStatus($response->getTidStatus())
799
+ ->setCustomerId($order->getCustomerId())
800
+ ->setRemoteIp($this->_helper->getRealIpAddr())
801
+ ->setShopUrl($this->_helper->getBaseUrl())
802
+ ->setPaymentName($order->getPayment()->getMethodInstance()->getCode())
803
+ ->setAmount($request->getRefundParam())
804
+ ->setStoreId($order->getStoreId())
805
+ ->setReferenceTransaction(1)
806
+ ->setCreatedDate($this->_helper->getCurrentDateTime())
807
+ ->save();
808
+ }
809
+
810
+ /**
811
+ * Send recurring process (cancel/re-active/suspend) request
812
+ *
813
+ * @param Varien_Object $order
814
+ * @param string $type
815
+ * @param Varien_Object $request
816
+ * @return none
817
+ */
818
+ public function postRecurringApiRequest($order, $type, $request)
819
+ {
820
+ $payment = $order->getPayment(); // Get payment object
821
+ $paymentObj = $payment->getMethodInstance(); // Get payment method instance
822
+
823
+ if ($type == 'canceled') { // For subscription cancel process
824
+ $response = $paymentObj->postRequest($request);
825
+ $data = unserialize($payment->getAdditionalData());
826
+ $data['subsCancelReason'] = $request->getCancelReason();
827
+ $payment->setAdditionalData(serialize($data))->save();
828
+ } elseif ($type == 'suspended' || $type == 'active') { // For subscription suspend/re-active process
829
+ $gatewayModel = $this->_helper->getModel('Service_Api_Gateway'); // Get Novalnet gateway model
830
+ $payportUrl = $this->_helper->getPayportUrl('infoport'); // Get Novalnet payport url
831
+ $response = $gatewayModel->payportRequestCall($request, $payportUrl, 'XML');
832
+ // Convert xml request to array for transaction traces log
833
+ $xmlRequest = simplexml_load_string($request);
834
+ $decodedRequest = json_decode(json_encode($xmlRequest), true);
835
+ $request = new Varien_Object($decodedRequest['info_request']);
836
+ }
837
+
838
+ // Log Novalnet payment transaction traces informations
839
+ $this->logTransactionTraces($request, $response, $order, $request->getTid());
840
+
841
+ if ($response->getStatus() != Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
842
+ $statusText = $this->getUnSuccessPaymentText($response); // Get payment transaction status message
843
+ $this->_helper->showException($statusText, false);
844
+ }
845
+ }
846
+
847
+ }
app/code/community/Novalnet/Payment/Model/Service/Validate/PaymentCheck.php ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Service_Validate_PaymentCheck extends Novalnet_Payment_Model_Service_Abstract
27
+ {
28
+ /**
29
+ * Check payment visiblity based on payment configuration
30
+ *
31
+ * @param Mage_Sales_Model_Quote|null $quote
32
+ * @return boolean
33
+ */
34
+ public function checkVisiblity($quote = null)
35
+ {
36
+ if (!$this->validateBasicParams()) {
37
+ return false;
38
+ } elseif (!$this->checkOrdersCount()) {
39
+ return false;
40
+ } elseif (!$this->checkCustomerAccess()) {
41
+ return false;
42
+ } elseif (!empty($quote) && !$quote->hasNominalItems()
43
+ && !$quote->getGrandTotal()
44
+ ) {
45
+ return false;
46
+ }
47
+
48
+ return true;
49
+ }
50
+
51
+ /**
52
+ * Validate Novalnet basic params
53
+ *
54
+ * @param none
55
+ * @return boolean
56
+ */
57
+ public function validateBasicParams()
58
+ {
59
+ if ($this->vendorId && $this->authcode
60
+ && $this->productId && $this->tariffId && $this->accessKey
61
+ ) {
62
+ return true;
63
+ }
64
+
65
+ return false;
66
+ }
67
+
68
+ /**
69
+ * Check orders count by customer id
70
+ *
71
+ * @param none
72
+ * @return boolean
73
+ */
74
+ public function checkOrdersCount()
75
+ {
76
+ // Load orders by customer id
77
+ $customerId = $this->_helper->getCustomerId();
78
+ $orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $customerId);
79
+ $ordersCount = $orders->count();
80
+ // Get orders count from payment configuration
81
+ $minOrderCount = $this->getNovalnetConfig('orders_count');
82
+ return ($ordersCount >= trim($minOrderCount)) ? true : false;
83
+ }
84
+
85
+ /**
86
+ * Check whether current user have access to process the payment
87
+ *
88
+ * @param none
89
+ * @return boolean
90
+ */
91
+ public function checkCustomerAccess()
92
+ {
93
+ // Excluded customer groups from payment configuration
94
+ $excludedGroupes = $this->getNovalnetConfig('user_group_excluded');
95
+
96
+ if (!$this->_helper->checkIsAdmin() && strlen($excludedGroupes)) {
97
+ $excludedGroupes = explode(',', $excludedGroupes);
98
+ $customerGroupId = $this->_helper->getCustomerSession()->getCustomerGroupId();
99
+ return !in_array($customerGroupId, $excludedGroupes);
100
+ }
101
+ return true;
102
+ }
103
+
104
+ /**
105
+ * validate Novalnet params to proceed checkout
106
+ *
107
+ * @param Varien_Object $info
108
+ * @return boolean
109
+ */
110
+ public function validateNovalnetParams($info)
111
+ {
112
+ if (!$this->validateBasicParams()) {
113
+ $this->_helper->showException('Basic parameter not valid.');
114
+ return false;
115
+ } elseif (!$this->validateBillingInfo($info)) {
116
+ $this->_helper->showException('Customer name/email fields are not valid');
117
+ return false;
118
+ }
119
+ return true;
120
+ }
121
+
122
+ /**
123
+ * Validate billing information
124
+ *
125
+ * @param Varien_Object $info
126
+ * @return boolean
127
+ */
128
+ public function validateBillingInfo($info)
129
+ {
130
+ $request = new Varien_Object();
131
+ $requestModel = $this->_helper->getModel('Service_Api_Request');
132
+ $requestModel->getBillingInfo($request, $info);
133
+
134
+ if (!$this->validateEmail($request->getEmail())
135
+ || !$request->getFirstName() || !$request->getLastName()
136
+ ) {
137
+ return false;
138
+ }
139
+ return true;
140
+ }
141
+
142
+ /**
143
+ * validate Novalnet form data
144
+ *
145
+ * @param none
146
+ * @return throw Mage Exception|none
147
+ */
148
+ public function validateFormInfo()
149
+ {
150
+ $methodSession = $this->_helper->getMethodSession($this->code);
151
+
152
+ switch ($this->code) {
153
+ case Novalnet_Payment_Model_Config::NN_SEPA:
154
+ $sepaDueDate = $methodSession->getSepaDuedate();
155
+
156
+ // Validate the Direct Debit SEPA form data
157
+ if (!$methodSession->getSepaMandateConfirm()) {
158
+ $this->_helper->showException('Please accept the SEPA direct debit mandate');
159
+ } elseif (strlen($sepaDueDate) > 0 && ($sepaDueDate < 7
160
+ || !$this->_helper->checkIsNumeric($sepaDueDate))
161
+ ) {
162
+ $this->_helper->showException('SEPA Due date is not valid');
163
+ } elseif ($methodSession->getSepaNewForm()
164
+ && (!$methodSession->getSepaHash() || !$methodSession->getSepaUniqueId())
165
+ ) {
166
+ $this->_helper->showException('Your account details are invalid');
167
+ }
168
+
169
+ // Validate DOB
170
+ if ($methodSession->getPaymentGuaranteeFlag()) {
171
+ $customerDob = (string) $methodSession->getCustomerDob();
172
+ if ($customerDob && !$this->validateBirthDate($customerDob)) {
173
+ $methodSession->unsPaymentGuaranteeFlag();
174
+ if (!$this->getNovalnetConfig('payment_guarantee_force')) {
175
+ $this->_helper->showException('You need to be at least 18 years old');
176
+ }
177
+ }
178
+ }
179
+
180
+ // Validate fraud prevention form values
181
+ if ($methodSession->getSepaNewForm()) {
182
+ $this->fraudModuleValidation($methodSession);
183
+ }
184
+ break;
185
+ case Novalnet_Payment_Model_Config::NN_INVOICE:
186
+ // Validate the payment reference values
187
+ $referenceOne = $this->getNovalnetConfig('payment_ref_one');
188
+ $referenceTwo = $this->getNovalnetConfig('payment_ref_two');
189
+ $referenceThree = $this->getNovalnetConfig('payment_ref_three');
190
+
191
+ if (!$referenceOne && !$referenceTwo && !$referenceThree) {
192
+ $this->_helper->showException('Please select atleast one payment reference.');
193
+ }
194
+ // Validate DOB
195
+ if ($methodSession->getPaymentGuaranteeFlag()) {
196
+ $customerDob = (string) $methodSession->getCustomerDob();
197
+ if ($customerDob && !$this->validateBirthDate($customerDob)) {
198
+ $methodSession->unsPaymentGuaranteeFlag();
199
+ if (!$this->getNovalnetConfig('payment_guarantee_force')) {
200
+ $this->_helper->showException('You need to be at least 18 years old');
201
+ }
202
+ }
203
+ }
204
+ // Validate fraud prevention form values
205
+ $this->fraudModuleValidation($methodSession);
206
+ break;
207
+ case Novalnet_Payment_Model_Config::NN_PREPAYMENT:
208
+ // Validate the payment reference values
209
+ $referenceOne = $this->getNovalnetConfig('payment_ref_one');
210
+ $referenceTwo = $this->getNovalnetConfig('payment_ref_two');
211
+ $referenceThree = $this->getNovalnetConfig('payment_ref_three');
212
+
213
+ if (!$referenceOne && !$referenceTwo && !$referenceThree) {
214
+ $this->_helper->showException('Please select atleast one payment reference.');
215
+ }
216
+ break;
217
+ }
218
+ }
219
+
220
+ /**
221
+ * fraud modules validation
222
+ *
223
+ * @param Varien_Object $methodSession
224
+ * @return throw Mage Exception|none
225
+ */
226
+ public function fraudModuleValidation($methodSession)
227
+ {
228
+ $callbackType = $this->getNovalnetConfig('callback');
229
+
230
+ if ($callbackType && !$this->_helper->checkIsAdmin() && $this->checkCallbackAmount()) {
231
+ $callbackTelNo = "getCallbackTel" . ucfirst($this->code);
232
+ $callbackEmail = "getCallbackEmail" . ucfirst($this->code);
233
+
234
+ if ($callbackType == '1' && !$methodSession->$callbackTelNo()) {
235
+ $this->_helper->showException('Please enter your telephone number');
236
+ } elseif ($callbackType == '2' && !$methodSession->$callbackTelNo()) {
237
+ $this->_helper->showException('Please enter your mobile number');
238
+ } elseif ($callbackType == '3' && !$this->validateEmail($methodSession->$callbackEmail())) {
239
+ $this->_helper->showException('Your E-mail address is invalid');
240
+ }
241
+ }
242
+ }
243
+
244
+ /**
245
+ * Verify the payment method values
246
+ *
247
+ * @param null
248
+ * @return null
249
+ */
250
+ public function checkMethodSession()
251
+ {
252
+ if (!$this->_helper->checkIsAdmin()) {
253
+ $checkoutSession = $this->_helper->getCheckoutSession();
254
+ $customerSession = $this->_helper->getCustomerSession();
255
+ $previousPaymentCode = $checkoutSession->getNnPaymentCode();
256
+
257
+ // Unset payment method session (for pre-select Novalnet payment)
258
+ $paymentCode = $checkoutSession->getQuote()->getPayment()->getMethod();
259
+ if ($paymentCode && $previousPaymentCode
260
+ && $paymentCode != $previousPaymentCode
261
+ ) {
262
+ $this->_helper->unsetMethodSession($previousPaymentCode);
263
+ }
264
+
265
+ $paymentSucess = $this->getNovalnetConfig('payment_last_success', true);
266
+ if ($customerSession->isLoggedIn()
267
+ && empty($paymentCode) && $paymentSucess
268
+ ) {
269
+ $this->getLastSuccessOrderMethod($customerSession->getId(), $checkoutSession);
270
+ }
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Get last successful payment method
276
+ *
277
+ * @param int $customerId
278
+ * @param Mage_Checkout_Model_Session $checkoutSession
279
+ */
280
+ public function getLastSuccessOrderMethod($customerId, $checkoutSession)
281
+ {
282
+ $tablePrefix = Mage::getConfig()->getTablePrefix();
283
+ $orderTable = $tablePrefix.'sales_flat_order';
284
+ $onCondition = "main_table.parent_id = $orderTable.entity_id";
285
+ $orderCollection = Mage::getModel('sales/order_payment')->getCollection()
286
+ ->addAttributeToSort('created_at', 'DESC')
287
+ ->addFieldToFilter('customer_id', $customerId)
288
+ ->addFieldToFilter('method', array('like' => '%novalnet%'))
289
+ ->addFieldToSelect('method')
290
+ ->setPageSize(1);
291
+ $orderCollection->getSelect()->join($orderTable, $onCondition);
292
+ $count = $orderCollection->count();
293
+ if ($count > 0) {
294
+ foreach($orderCollection as $order):
295
+ $paymentMethod = $order->getMethod();
296
+ endforeach;
297
+ $checkoutSession->getQuote()->getPayment()->setMethod($paymentMethod);
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Check customer DOB is valid
303
+ *
304
+ * @param string $birthDate
305
+ * @return boolean
306
+ */
307
+ public function validateBirthDate($birthDate)
308
+ {
309
+ $birthDate = strtotime($birthDate);
310
+ $age = strtotime('+18 years', $birthDate);
311
+ return (time() < $age) ? false : true;
312
+ }
313
+
314
+ /**
315
+ * Check fraud prevention availability
316
+ *
317
+ * @param none
318
+ * @return boolean
319
+ */
320
+ public function checkCallbackAmount()
321
+ {
322
+ $grandTotal = $this->_helper->getCheckoutSession()->getQuote()->getBaseGrandTotal();
323
+ $amount = $this->_helper->getFormatedAmount($grandTotal);
324
+ $minimumAmount = (int) $this->getNovalnetConfig('callback_minimum_amount');
325
+ return ($minimumAmount ? $amount >= $minimumAmount : true);
326
+ }
327
+
328
+ /**
329
+ * Validate payment request params
330
+ *
331
+ * @param Varien_Object $request
332
+ * @return boolean
333
+ */
334
+ public function validateMandateParams($request)
335
+ {
336
+ if ($this->checkIsNumeric($request->getVendor()) && $request->getAuthCode()
337
+ && $this->checkIsNumeric($request->getProduct())
338
+ && $this->checkIsNumeric($request->getTariff())
339
+ ) {
340
+ return true;
341
+ }
342
+ // error request log - reference
343
+ Mage::log($request->getData(), null, 'nn_error_req.log', true);
344
+ return false;
345
+ }
346
+
347
+ /**
348
+ * Check Novalnet invoice payment guarantee availability
349
+ *
350
+ * @param Mage_Sales_Model_Quote|null $quote
351
+ * @param string $code
352
+ * @return boolean
353
+ */
354
+ public function getPaymentGuaranteeStatus($quote, $code)
355
+ {
356
+ $this->code = $code; // Payment method code
357
+ $methodSession = $this->_helper->getMethodSession($code); // Get payment method session
358
+ $methodSession->setPaymentGuaranteeFlag(0);
359
+
360
+ if ($this->getNovalnetConfig('payment_guarantee')) {
361
+ $allowedCountryCode = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('allowedCountry');
362
+ $countryCode = strtoupper($quote->getBillingAddress()->getCountryId()); // Get country code
363
+ $orderAmount = $this->_helper->getFormatedAmount($quote->getBaseGrandTotal()); // Get order amount
364
+ if ($quote->hasNominalItems()) {
365
+ $checkoutSession = $this->_helper->getCheckoutSession(); // Get checkout session
366
+ // Get order amount (Add initial fees if exist)
367
+ $orderAmount = $this->_helper->getFormatedAmount($checkoutSession->getNnRowAmount());
368
+ }
369
+
370
+ if (in_array($countryCode, $allowedCountryCode)
371
+ && ($orderAmount >= 2000 && $orderAmount <= 500000)
372
+ && ($quote->getBaseCurrencyCode() == 'EUR')
373
+ ) {
374
+ $methodSession->setPaymentGuaranteeFlag(1);
375
+ return true;
376
+ } elseif ($this->getNovalnetConfig('payment_guarantee_force')) {
377
+ return true;
378
+ }
379
+ return false;
380
+ }
381
+ return true;
382
+ }
383
+
384
+ }
app/code/community/Novalnet/Payment/Model/{System/Config/Activemethods.php → Source/ActiveMethods.php} RENAMED
@@ -18,36 +18,31 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class Novalnet_Payment_Model_System_Config_Activemethods
27
  {
28
  /**
29
- * Options getter
30
  *
31
- * @return array
 
32
  */
33
  public function toOptionArray()
34
  {
35
  $methods = array();
36
  $activePayment = false;
 
 
 
 
 
 
37
 
38
- if (strlen($code = Mage::app()->getRequest()->getParam('store'))) { // store level
39
- $scopeId = Mage::getModel('core/store')->load($code)->getId();
40
- } elseif (strlen($code = Mage::app()->getRequest()->getParam('website'))) { // website level
41
- $websiteId = Mage::getModel('core/website')->load($code)->getId();
42
- $scopeId = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId();
43
- } else { // default level
44
- $scopeId = 0;
45
- }
46
-
47
- $novalPaymentMethods = array_keys(Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('novalnetPaymentKey'));
48
-
49
- foreach($novalPaymentMethods as $paymentCode) {
50
-
51
  $paymentActive = Mage::getStoreConfig('payment/' . $paymentCode . '/active', $scopeId);
52
  if ($paymentActive == true) {
53
  $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title', $scopeId);
@@ -56,10 +51,12 @@ class Novalnet_Payment_Model_System_Config_Activemethods
56
  'value' => $paymentCode,
57
  );
58
  $activePayment = true;
59
- }
 
 
60
  }
61
 
62
- if (!$activePayment) {
63
  $methods[$paymentCode] = array(
64
  'label' => Mage::helper('novalnet_payment')->__('No active payment method for this store'),
65
  'value' => false,
@@ -67,4 +64,5 @@ class Novalnet_Payment_Model_System_Config_Activemethods
67
  }
68
  return $methods;
69
  }
 
70
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Model_Source_ActiveMethods
27
  {
28
  /**
29
+ * Options getter (Active Novalnet payment methods)
30
  *
31
+ * @param none
32
+ * @return array $methods
33
  */
34
  public function toOptionArray()
35
  {
36
  $methods = array();
37
  $activePayment = false;
38
+ $inactivePayment = false;
39
+ $scopeId = Mage::helper('novalnet_payment')->getScopeId(); // Get store id
40
+ // Novalnet payment methods
41
+ $novalnetPayments = array_keys(
42
+ Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('paymentMethods')
43
+ );
44
 
45
+ foreach ($novalnetPayments as $paymentCode) {
 
 
 
 
 
 
 
 
 
 
 
 
46
  $paymentActive = Mage::getStoreConfig('payment/' . $paymentCode . '/active', $scopeId);
47
  if ($paymentActive == true) {
48
  $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title', $scopeId);
51
  'value' => $paymentCode,
52
  );
53
  $activePayment = true;
54
+ } else {
55
+ $inactivePayment = true;
56
+ }
57
  }
58
 
59
+ if (!$activePayment && $inactivePayment) {
60
  $methods[$paymentCode] = array(
61
  'label' => Mage::helper('novalnet_payment')->__('No active payment method for this store'),
62
  'value' => false,
64
  }
65
  return $methods;
66
  }
67
+
68
  }
app/code/community/Novalnet/Payment/Model/{Amountchanged.php → Source/CallbackEmail.php} RENAMED
@@ -1,39 +1,41 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Amountchanged extends Mage_Core_Model_Abstract
27
- {
28
- /**
29
- * Constructor
30
- *
31
- * @see lib/Varien/Varien_Object#_construct()
32
- * @return Novalnet_Payment_Model_Amountchanged
33
- */
34
- public function _construct()
35
- {
36
- parent::_construct();
37
- $this->_init('novalnet_payment/amountchanged');
38
- }
39
- }
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Source_CallbackEmail
27
+ {
28
+ /**
29
+ * Options getter (Callback email functions)
30
+ *
31
+ * @param none
32
+ * @return array
33
+ */
34
+ public function toOptionArray()
35
+ {
36
+ return array(1 => Mage::helper('novalnet_payment')->__('Zend E-mail'),
37
+ 2 => Mage::helper('novalnet_payment')->__('Magento E-mail')
38
+ );
39
+ }
40
+
41
+ }
app/code/community/Novalnet/Payment/Model/{Novalnet/Source/Cctype.php → Source/CcCardTypes.php} RENAMED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Magento
5
  *
@@ -19,30 +18,40 @@
19
  * recommendation as well as a comment on merchant form
20
  * would be greatly appreciated.
21
  *
22
- * @category Novalnet
23
- * @package Novalnet_Payment
24
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
25
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
  */
27
- class Novalnet_Payment_Model_Novalnet_Source_Cctype
28
  {
29
-
 
 
 
 
 
30
  public function toOptionArray()
31
  {
32
  $cardTypes = array(
33
- 'visacard' => 'Visa',
34
- 'mastercard' => 'MasterCard',
35
- 'amex' => 'American Express',
36
- 'maestro' => 'Maestro',
37
- 'cartasi' => 'CartaSi',
38
  );
 
 
39
  $options = array();
40
  foreach ($cardTypes as $code => $name) {
 
41
  $options[] = array(
42
  'value' => $code,
43
  'label' => $name
44
  );
 
45
  }
 
46
  return $options;
47
  }
48
 
1
  <?php
 
2
  /**
3
  * Magento
4
  *
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ class Novalnet_Payment_Model_Source_CcCardTypes
27
  {
28
+ /**
29
+ * Options getter (Credit Card types)
30
+ *
31
+ * @param none
32
+ * @return array $options
33
+ */
34
  public function toOptionArray()
35
  {
36
  $cardTypes = array(
37
+ 'VI' => 'Visa',
38
+ 'MC' => 'MasterCard',
39
+ 'AE' => 'American Express',
40
+ 'TO' => 'Maestro',
41
+ 'T' => 'CartaSi',
42
  );
43
+
44
+ $allowed = array('AE', 'VI', 'MC', 'TO', 'T');
45
  $options = array();
46
  foreach ($cardTypes as $code => $name) {
47
+ if (in_array($code, $allowed)) {
48
  $options[] = array(
49
  'value' => $code,
50
  'label' => $name
51
  );
52
+ }
53
  }
54
+
55
  return $options;
56
  }
57
 
app/code/community/Novalnet/Payment/{Block/Adminhtml/Widget/Grid/Container.php → Model/Source/CcFormTypes.php} RENAMED
@@ -1,38 +1,41 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Block_Adminhtml_Widget_Grid_Container extends Mage_Adminhtml_Block_Widget_Grid_Container
27
- {
28
- /**
29
- * Return grid header css class
30
- *
31
- * @return mixed
32
- */
33
- public function getHeaderCssClass()
34
- {
35
- return 'novalnet-adminhtml-head ' . parent::getHeaderCssClass();
36
- }
37
-
38
- }
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Source_CcFormtypes
27
+ {
28
+ /**
29
+ * Options getter (Credit Card form types)
30
+ *
31
+ * @param none
32
+ * @return array
33
+ */
34
+ public function toOptionArray()
35
+ {
36
+ return array(1 => Mage::helper('novalnet_payment')->__('Iframe form'),
37
+ 2 => Mage::helper('novalnet_payment')->__('Redirection')
38
+ );
39
+ }
40
+
41
+ }
app/code/community/Novalnet/Payment/Model/Source/CustomerGroups.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Source_CustomerGroups
27
+ {
28
+ /**
29
+ * Options getter (customer groups)
30
+ *
31
+ * @param none
32
+ * @return array $options
33
+ */
34
+ public function toOptionArray()
35
+ {
36
+ $collection = Mage::getModel('customer/group')->getCollection();
37
+ $groups = array();
38
+ foreach ($collection as $group) {
39
+ $groupInfo = array(
40
+ 'customer_group_id' => $group->getCustomerGroupId(),
41
+ 'customer_group_code' => $group->getCustomerGroupCode(),
42
+ );
43
+
44
+ if (!empty($groupInfo)) {
45
+ array_push($groups, $groupInfo);
46
+ }
47
+ }
48
+
49
+ foreach ($groups as $name) {
50
+ $options[] = array(
51
+ 'value' => $name['customer_group_id'],
52
+ 'label' => $name['customer_group_code']
53
+ );
54
+ }
55
+
56
+ return $options;
57
+ }
58
+ }
app/code/community/Novalnet/Payment/Model/{Novalnet/Source/Callbacktypes.php → Source/PreventionTypes.php} RENAMED
@@ -1,35 +1,42 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Model_Novalnet_Source_Callbacktypes
27
- {
28
- public function toOptionArray()
29
- {
30
- return array(0 => Mage::helper('novalnet_payment')->__('None'),
31
- 1 => Mage::helper('novalnet_payment')->__('PIN by callback'),
32
- 2 => Mage::helper('novalnet_payment')->__('PIN by SMS'),
33
- );
34
- }
35
- }
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Source_PreventionTypes
27
+ {
28
+ /**
29
+ * Options getter (fraud prevention types)
30
+ *
31
+ * @param none
32
+ * @return array
33
+ */
34
+ public function toOptionArray()
35
+ {
36
+ return array(0 => Mage::helper('novalnet_payment')->__('NN None'),
37
+ 1 => Mage::helper('novalnet_payment')->__('PIN by callback'),
38
+ 2 => Mage::helper('novalnet_payment')->__('PIN by SMS')
39
+ );
40
+ }
41
+
42
+ }
app/code/community/Novalnet/Payment/Model/Source/VendorAutoConfig.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Model_Source_VendorAutoConfig
27
+ {
28
+ /**
29
+ * Options getter
30
+ *
31
+ * @param none
32
+ * @return array
33
+ */
34
+ public function toOptionArray()
35
+ {
36
+ return array(0 => Mage::helper('novalnet_payment')->__('NN None'));
37
+ }
38
+
39
+ }
app/code/community/Novalnet/Payment/Model/System/Config/Backend/Notifyurl.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magento.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magento.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Adminhtml
23
- * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
-
28
- class Novalnet_Payment_Model_System_Config_Backend_Notifyurl extends Mage_Core_Model_Config_Data
29
- {
30
-
31
- /**
32
- * Processing object after load data
33
- *
34
- * @return Mage_Core_Model_Abstract
35
- */
36
- protected function _afterLoad()
37
- {
38
- $value = $this->getValue();
39
- $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
40
- $notifyurl = $baseUrl.'callback_novalnet2magento.php';
41
- $value = !empty($value) ? $value : $notifyurl;
42
- $this->setValue($value);
43
- return parent::_afterLoad();
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Configuration/Wizard/PageController.php DELETED
@@ -1,190 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Adminhtml_Novalnetpayment_Configuration_Wizard_PageController extends Mage_Adminhtml_Controller_Action
27
- {
28
- /**
29
- * Init layout, menu and breadcrumb
30
- *
31
- * @return Mage_Adminhtml_Controller_Action
32
- */
33
- protected function _initAction()
34
- {
35
- $this->loadLayout()
36
- ->setUsedModuleName('novalnet_payment')
37
- ->_setActiveMenu('novalnet/configuration')
38
- ->_addBreadcrumb($this->__('Novalnet'), $this->__('Configuration'));
39
-
40
- return $this;
41
- }
42
-
43
- /**
44
- * Configuration wizard
45
- *
46
- */
47
- public function indexAction()
48
- {
49
- $this->initConfig('index');
50
-
51
- $this->_initAction();
52
- $this->renderLayout();
53
- }
54
-
55
- /**
56
- * Get config action
57
- *
58
- * @param string $actionName
59
- * @return string
60
- */
61
- protected function initConfig($actionName)
62
- {
63
- return $this->helperWizard()->initConfig($actionName, $this->getRequest());
64
- }
65
-
66
- /**
67
- * Get Novalnet Helper
68
- *
69
- * @return Novalnet_Payment_Helper_Data
70
- */
71
- public function helperWizard()
72
- {
73
- return Mage::helper('novalnet_payment');
74
- }
75
-
76
- /**
77
- * Configuration global action
78
- *
79
- */
80
- public function generalGlobalAction()
81
- {
82
- $this->_editAction('generalGlobal');
83
- }
84
-
85
- /**
86
- * Configuration wizard edit action
87
- *
88
- */
89
- protected function _editAction($actionName)
90
- {
91
- $this->initConfig($actionName);
92
-
93
- $configPage = Mage::registry('novalnet_wizard_config_page');
94
-
95
- Mage::getSingleton('adminhtml/config_data')
96
- ->setSection($configPage->getData('codes/section'))
97
- ->setWebsite($configPage->getData('codes/website'))
98
- ->setStore($configPage->getData('codes/store'));
99
-
100
- $this->_initAction();
101
- $this->renderLayout();
102
- }
103
-
104
- /**
105
- * Page redirect
106
- *
107
- */
108
- private function _redirectByPageConfig()
109
- {
110
- $url = $this->helperWizard()->getNextPageUrlAsString();
111
- $this->_redirect($url, array('_current' => true));
112
- }
113
-
114
- /**
115
- * Amount update process
116
- *
117
- */
118
- public function saveAction()
119
- {
120
- $config = $this->initConfig('paymentSave');
121
- $configPage = Mage::registry('novalnet_wizard_config_page');
122
- Mage::getSingleton('adminhtml/config_data')
123
- ->setSection($configPage->getData('codes/section'))
124
- ->setWebsite($configPage->getData('codes/website'))
125
- ->setStore($configPage->getData('codes/store'));
126
-
127
- $session = Mage::getSingleton('adminhtml/session');
128
-
129
- try {
130
-
131
- $website = $this->getRequest()->getParam('website');
132
- $store = $this->getRequest()->getParam('store');
133
- $groups = $this->getRequest()->getPost('groups');
134
- $configData = Mage::getModel('adminhtml/config_data');
135
- $configData->setSection('novalnet_global')
136
- ->setWebsite($website)
137
- ->setStore($store)
138
- ->setGroups($groups)
139
- ->save();
140
-
141
- $session->addSuccess(Mage::helper('novalnet_payment')->__('The configuration has been saved.'));
142
- } catch (Mage_Core_Exception $e) {
143
- foreach (explode("\n", $e->getMessage()) as $message) {
144
- $session->addError($message);
145
- }
146
- } catch (Exception $e) {
147
- $msg = Mage::helper('novalnet_payment')->__('An error occurred while saving:') . ' ' . $e->getMessage();
148
- $session->addException($e, $msg);
149
- }
150
-
151
- $this->_initAction();
152
- $this->renderLayout();
153
- }
154
-
155
- /**
156
- * Save payment configuration
157
- *
158
- */
159
- public function paymentSaveAction()
160
- {
161
- $pageCode = $this->getRequest()->getParam('page_code');
162
-
163
- $config = $this->initConfig($pageCode);
164
- $session = Mage::getSingleton('adminhtml/session');
165
-
166
- try {
167
-
168
- $section = $config->getData('codes/section');
169
- $website = $this->getRequest()->getParam('website');
170
- $store = $this->getRequest()->getParam('store');
171
- $groups = $this->getRequest()->getPost('groups');
172
- $configData = Mage::getModel('adminhtml/config_data');
173
- $configData->setSection($section)
174
- ->setWebsite($website)
175
- ->setStore($store)
176
- ->setGroups($groups)
177
- ->save();
178
-
179
- $session->addSuccess(Mage::helper('novalnet_payment')->__('The configuration has been saved.'));
180
- } catch (Mage_Core_Exception $e) {
181
- foreach (explode("\n", $e->getMessage()) as $message) {
182
- $session->addError($message);
183
- }
184
- } catch (Exception $e) {
185
- $msg = Mage::helper('novalnet_payment')->__('An error occurred while saving:') . ' ' . $e->getMessage();
186
- $session->addException($e, $msg);
187
- }
188
- $this->_redirectByPageConfig();
189
- }
190
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Information/{NovalnetmerchantadminController.php → MerchantadminController.php} RENAMED
@@ -1,41 +1,53 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Adminhtml_Novalnetpayment_Information_NovalnetmerchantadminController extends Mage_Adminhtml_Controller_Action
27
- {
28
- /**
29
- * Render layout
30
- *
31
- */
32
- public function indexAction()
33
- {
34
- $this->loadLayout()
35
- ->setUsedModuleName('novalnet_payment')
36
- ->_setActiveMenu('novalnet/information')
37
- ->_addBreadcrumb($this->__('Novalnet'), $this->__('Novalnet Merchant Admin'));
38
-
39
- $this->renderLayout();
40
- }
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Adminhtml_Novalnetpayment_Information_MerchantadminController
27
+ extends Mage_Adminhtml_Controller_Action
28
+ {
29
+
30
+ /**
31
+ * Render layout
32
+ */
33
+ public function indexAction()
34
+ {
35
+ $this->loadLayout()
36
+ ->setUsedModuleName('novalnet_payment')
37
+ ->_setActiveMenu('novalnet/information')
38
+ ->_addBreadcrumb($this->__('Novalnet'), $this->__('Novalnet Merchant Admin'));
39
+
40
+ $this->renderLayout();
41
+ }
42
+
43
+ /**
44
+ * Check admin permissions for this controller
45
+ *
46
+ * @return bool
47
+ */
48
+ protected function _isAllowed()
49
+ {
50
+ return Mage::getSingleton('admin/session')->isAllowed('novalnetpayment_information_merchantadmin');
51
+ }
52
+
53
+ }
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Information/ModuleController.php CHANGED
@@ -1,41 +1,55 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Adminhtml_Novalnetpayment_Information_ModuleController extends Mage_Adminhtml_Controller_Action
27
- {
28
- /**
29
- * Render layout
30
- *
31
- */
32
- public function indexAction()
33
- {
34
- $this->loadLayout()
35
- ->setUsedModuleName('novalnet_payment')
36
- ->_setActiveMenu('novalnet/information')
37
- ->_addBreadcrumb($this->__('Novalnet'), $this->__('Novalnet Magento Module'));
38
-
39
- $this->renderLayout();
40
- }
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Adminhtml_Novalnetpayment_Information_ModuleController extends Mage_Adminhtml_Controller_Action
27
+ {
28
+
29
+ /**
30
+ * Render layout
31
+ *
32
+ * @param none
33
+ * @return none
34
+ */
35
+ public function indexAction()
36
+ {
37
+ $this->loadLayout()
38
+ ->setUsedModuleName('novalnet_payment')
39
+ ->_setActiveMenu('novalnet/information')
40
+ ->_addBreadcrumb($this->__('Novalnet'), $this->__('Novalnet Magento Module'));
41
+
42
+ $this->renderLayout();
43
+ }
44
+
45
+ /**
46
+ * Check admin permissions for this controller
47
+ *
48
+ * @return bool
49
+ */
50
+ protected function _isAllowed()
51
+ {
52
+ return Mage::getSingleton('admin/session')->isAllowed('novalnetpayment_information_module');
53
+ }
54
+
55
+ }
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Sales/DeleteorderController.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Novalnet_Payment_Adminhtml_Novalnetpayment_Sales_DeleteorderController extends Mage_Adminhtml_Controller_Action
28
+ {
29
+
30
+ /**
31
+ * Initialize order model instance
32
+ *
33
+ * @param none
34
+ * @return Mage_Sales_Model_Order
35
+ */
36
+ protected function _initOrder()
37
+ {
38
+ $orderId = $this->getRequest()->getParam('order_id');
39
+ $order = Mage::getModel('sales/order')->load($orderId);
40
+
41
+ if (!$order->getId()) {
42
+ $this->_getSession()->addError($this->__('This order no longer exists.'));
43
+ $this->_redirect('*/*/');
44
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
45
+ return false;
46
+ }
47
+ Mage::register('sales_order', $order);
48
+ Mage::register('current_order', $order);
49
+ return $order;
50
+ }
51
+
52
+ /**
53
+ * Delete single order
54
+ *
55
+ * @param none
56
+ * @return none
57
+ */
58
+ public function deleteAction()
59
+ {
60
+ if ($order = $this->_initOrder()) {
61
+ try {
62
+ if ($this->removeOrderRelatedItems($order)) {
63
+ $message = Mage::helper('novalnet_payment')->__('Order was successfully deleted');
64
+ $url = Mage::helper('adminhtml')->getUrl('adminhtml/novalnetpayment_sales_order/index');
65
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
66
+ $this->_redirectUrl($url);
67
+ }
68
+ } catch (Exception $e) {
69
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
70
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('order_ids')));
71
+ }
72
+ }
73
+ $this->_redirectUrl(Mage::helper('adminhtml')->getUrl('adminhtml/novalnetpayment_sales_order/index'));
74
+ }
75
+
76
+ /**
77
+ * Delete multiple orders
78
+ *
79
+ * @param none
80
+ * @return none
81
+ */
82
+ public function massDeleteAction()
83
+ {
84
+ $orderIds = $this->getRequest()->getParam('order_ids');
85
+ $adminSession = Mage::getSingleton('adminhtml/session');
86
+
87
+ if (!is_array($orderIds)) {
88
+ $adminSession->addError(Mage::helper('novalnet_payment')->__('Please select the orders'));
89
+ } else {
90
+ try {
91
+ foreach ($orderIds as $orderId) {
92
+ $order = Mage::getModel('sales/order')->load($orderId);
93
+ $this->removeOrderRelatedItems($order);
94
+ }
95
+ $message = Mage::helper('novalnet_payment')->__('Total of %d order(s) were successfully deleted', count($orderIds));
96
+ $adminSession->addSuccess($message);
97
+ } catch (Exception $e) {
98
+ $adminSession->addError($e->getMessage());
99
+ }
100
+ }
101
+ $this->_redirectUrl(Mage::helper('adminhtml')->getUrl('adminhtml/novalnetpayment_sales_order/index'));
102
+ }
103
+
104
+ /**
105
+ * Delete the order related informations (invoice, creditmemo, shipment)
106
+ *
107
+ * @param Varien_Object $order
108
+ * @return boolean
109
+ */
110
+ public function removeOrderRelatedItems($order)
111
+ {
112
+ // delete order invoice
113
+ $this->removeInvoice($order);
114
+ // delete order creditmemo
115
+ $this->removeCreditmemo($order);
116
+ // delete order shipment
117
+ $this->removeShipment($order);
118
+ //delete order
119
+ $order->delete();
120
+ return true;
121
+ }
122
+
123
+ /**
124
+ * delete the order invoice
125
+ *
126
+ * @param Varien_Object $order
127
+ * @return none
128
+ */
129
+ public function removeInvoice($order)
130
+ {
131
+ $collection = $order->getInvoiceCollection();
132
+ foreach ($collection as $invoice) {
133
+ $items = $invoice->getAllItems();
134
+ foreach ($items as $item) {
135
+ $item->delete();
136
+ }
137
+ $invoice->delete();
138
+ }
139
+ }
140
+
141
+ /**
142
+ * delete the order creditmemo
143
+ *
144
+ * @param Varien_Object $order
145
+ * @return none
146
+ */
147
+ public function removeCreditmemo($order)
148
+ {
149
+ $collection = $order->getCreditmemosCollection();
150
+ foreach ($collection as $creditmemo) {
151
+ $items = $creditmemo->getAllItems();
152
+ foreach ($items as $item) {
153
+ $item->delete();
154
+ }
155
+ $creditmemo->delete();
156
+ }
157
+ }
158
+
159
+ /**
160
+ * delete the order shipment
161
+ *
162
+ * @param Varien_Object $order
163
+ * @return none
164
+ */
165
+ public function removeShipment($order)
166
+ {
167
+ $collection = $order->getShipmentsCollection();
168
+ foreach ($collection as $shipment) {
169
+ $items = $shipment->getAllItems();
170
+ foreach ($items as $item) {
171
+ $item->delete();
172
+ }
173
+ $shipment->delete();
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Check admin permissions for this controller
179
+ *
180
+ * @return bool
181
+ */
182
+ protected function _isAllowed()
183
+ {
184
+ return Mage::getSingleton('admin/session')->isAllowed('novalnetpayment_sales_deleteorder');
185
+ }
186
+ }
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Sales/OrderController.php CHANGED
@@ -18,342 +18,186 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  require_once 'Mage' . DS . 'Adminhtml' . DS . 'controllers' . DS . 'Sales' . DS . 'OrderController.php';
27
 
28
  class Novalnet_Payment_Adminhtml_Novalnetpayment_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
29
  {
30
- var $moduleName = 'novalnet_payment';
31
-
32
  /**
33
  * Init layout, menu and breadcrumb
34
  *
 
35
  * @return Mage_Adminhtml_Sales_OrderController
36
  */
37
  protected function _initAction()
38
  {
39
  $this->loadLayout()
40
- ->setUsedModuleName($this->moduleName)
41
- ->_setActiveMenu('novalnet')
42
- ->_addBreadcrumb($this->__('Novalnet'), $this->__('Orders'));
43
 
44
  return $this;
45
  }
46
 
47
  /**
48
- * Orders grid
49
  *
 
 
50
  */
51
  public function indexAction()
52
  {
53
  $this->_title($this->__('Novalnet'))->_title($this->__('Orders'));
54
 
55
  $this->_initAction()
56
- ->renderLayout();
57
  }
58
 
59
  /**
60
- * Set transactionstatus grid in sales order
61
  *
 
 
62
  */
63
- public function transactionStatusGridAction()
64
  {
65
- $this->_initOrder();
66
  $this->getResponse()->setBody(
67
- Mage::getBlockSingleton('novalnet_payment/adminhtml_sales_order_view_tab_transactionStatus')->toHtml()
68
  );
69
  }
70
 
71
  /**
72
- * Set transactionoverview grid in sales order
73
  *
 
 
74
  */
75
  public function transactionOverviewGridAction()
76
  {
77
  $this->_initOrder();
78
  $this->getResponse()->setBody(
79
- Mage::getBlockSingleton('novalnet_payment/adminhtml_sales_order_view_tab_transactionOverview')->toHtml()
80
  );
81
  }
82
 
83
  /**
84
- * Create sales order block for Novalnet payments
85
  *
 
 
86
  */
87
- public function gridAction()
88
  {
 
89
  $this->getResponse()->setBody(
90
- $this->getLayout()->createBlock('novalnet_payment/adminhtml_sales_order_grid')->toHtml()
91
  );
92
  }
93
 
94
  /**
95
- * Order confirmation process for Novalnet payments (Prepayment & Invoice)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  *
 
 
 
 
97
  */
98
- public function novalnetconfirmAction()
99
  {
100
- $order = $this->_initOrder();
101
- $orderItems = $order->getAllItems();
102
- $helper = Mage::helper('novalnet_payment');
103
- $nominalItem = $helper->checkNominalItem($orderItems);
104
- if ($order) {
105
- try {
106
- $payment = $order->getPayment();
107
- $paymentObj = $payment->getMethodInstance();
108
- $paymentCode = $paymentObj->getCode();
109
- $responseCodeApproved = Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED;
110
- $request = new Varien_Object();
111
- $storeId = $payment->getOrder()->getStoreId();
112
- $lastTranId = $helper->makeValidNumber($payment->getLastTransId());
113
- $paymentObj->assignOrderBasicParams($request, $payment, $storeId, $nominalItem);
114
- $request->setTid($lastTranId)
115
- ->setStatus($responseCodeApproved)
116
- ->setEditStatus(true);
117
- $loadTransStatus = Mage::helper('novalnet_payment')->loadTransactionStatus($lastTranId);
118
- $transStatus = $loadTransStatus->getTransactionStatus();
119
- if (!in_array(NULL, $request->toArray()) && !empty($transStatus)
120
- && $transStatus != $responseCodeApproved) {
121
- $buildNovalnetParam = http_build_query($request->getData());
122
- $payportUrl = $helper->getPayportUrl('paygate');
123
- $response = Mage::helper('novalnet_payment/AssignData')->setRawCallRequest($buildNovalnetParam, $payportUrl, $paymentObj);
124
- $responseStatus = $response->getStatus();
125
- if ($responseStatus == $responseCodeApproved) {
126
- $captureMode = (version_compare($helper->getMagentoVersion(), '1.6', '<'))
127
- ? false : true;
128
- $loadTransStatus->setTransactionStatus($responseCodeApproved)
129
- ->save();
130
- $data = unserialize($payment->getAdditionalData());
131
- $data['captureTid'] = $lastTranId;
132
- $data['CaptureCreateAt'] = Mage::getModel('core/date')->date('Y-m-d H:i:s');
133
- $payment->setAdditionalData(serialize($data))
134
- ->save();
135
- if ($paymentCode == Novalnet_Payment_Model_Config::NN_INVOICE) {
136
- $order = $payment->getOrder();
137
- if ($order->canInvoice()) {
138
- $this->saveInvoice($order, $lastTranId);
139
- }
140
- $payment->setTransactionId($lastTranId)
141
- ->setIsTransactionClosed($captureMode);
142
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false);
143
- $transaction->setParentTxnId(null)
144
- ->save();
145
- }
146
- }
147
- $this->setOrderStatus($order, 'confirmStatus');
148
- $customerId = $payment->getOrder()->getCustomerId();
149
- $paymentObj->logNovalnetTransactionData($request, $response, $payment->getLastTransId(), $customerId, $storeId);
150
- if ($responseStatus != $responseCodeApproved) {
151
- $this->_getSession()->addSuccess(
152
- $this->__('There was an error in refund request. Status Code : ' . $responseStatus)
153
- );
154
- } else {
155
- $this->_getSession()->addSuccess(
156
- $this->__('The order has been updated.')
157
- );
158
- }
159
- }
160
- } catch (Mage_Core_Exception $e) {
161
- $this->_getSession()->addError($e->getMessage());
162
- } catch (Exception $e) {
163
- $this->_getSession()->addError($e->getMessage());
164
  }
165
- $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
166
  }
167
  }
168
 
169
  /**
170
  * Save order invoice
171
  *
172
- * @param varien_object $order
173
- * @param int $txnId
174
- * @param string $paymentCode
175
  */
176
- protected function saveInvoice($order, $txnId,$paymentCode = NULL)
177
  {
178
- $paid = $paymentCode ? Mage_Sales_Model_Order_Invoice::STATE_PAID : Mage_Sales_Model_Order_Invoice::STATE_OPEN;
179
  $invoice = $order->prepareInvoice();
180
- $invoice->setTransactionId($txnId);
181
  $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE)
182
- ->register();
183
- $invoice->setState($paid)
184
- ->save();
185
  Mage::getModel('core/resource_transaction')
186
  ->addObject($invoice)
187
  ->addObject($invoice->getOrder())
188
  ->save();
189
- if ($paymentCode) {
190
- $magentoVersion = Mage::helper('novalnet_payment')->getMagentoVersion();
191
- $transMode = (version_compare($magentoVersion, '1.6', '<'))
192
- ? false : true;
193
- $payment = $order->getPayment();
194
- $payment->setTransactionId($txnId)
195
- ->setIsTransactionClosed($transMode);
196
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false);
197
- $transaction->setParentTxnId(null)
198
- ->save();
199
- }
200
- }
201
-
202
- /**
203
- * Amount update process
204
- *
205
- */
206
- public function amountupdateAction()
207
- {
208
- $amountChanged = $this->getRequest()->getParam('amount_change');
209
- $invoiceDuedate = $this->getRequest()->getParam('invoice_duedate');
210
- $finalAmount = str_replace(array('.', ','), "", $amountChanged);
211
- $rawAmount = ($finalAmount / 100);
212
-
213
- $order = $this->_initOrder();
214
- $helper = Mage::helper('novalnet_payment');
215
- $incrementId = $order->getIncrementId();
216
- $callbackTrans = $helper->loadCallbackValue($incrementId);
217
- $callbackValue = $callbackTrans && $callbackTrans->getCallbackAmount() ? ($callbackTrans->getCallbackAmount() / 100) : '';
218
-
219
- try {
220
- if (empty($rawAmount) || !is_numeric($rawAmount)) {
221
- Mage::throwException($helper->__('Enter the valid amount'));
222
- } elseif ($invoiceDuedate && (strtotime($invoiceDuedate) < strtotime(date('Y-m-d')))) {
223
- Mage::throwException($helper->__('The date should be in future'));
224
- }
225
-
226
- if ($order) {
227
- try {
228
- $orderId = $order->getId();
229
- $payment = $order->getPayment();
230
- $paymentObj = $payment->getMethodInstance();
231
- $paymentCode = $paymentObj->getCode();
232
- $lastTranId = $helper->makeValidNumber($payment->getLastTransId());
233
- $responseCodeApproved = Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED;
234
- $storeId = $order->getStoreId();
235
- $request = new Varien_Object();
236
- $paymentObj->assignOrderBasicParams($request, $payment, $storeId);
237
- $request->setTid($lastTranId)
238
- ->setStatus($responseCodeApproved)
239
- ->setEditStatus(true)
240
- ->setUpdateInvAmount(1)
241
- ->setAmount($amountChanged);
242
- if ($invoiceDuedate) {
243
- $request->setDueDate($invoiceDuedate);
244
- }
245
-
246
- $amountChanged = $rawAmount;
247
- $loadTransStatus = $helper->loadTransactionStatus($lastTranId);
248
- $transStatus = $loadTransStatus->getTransactionStatus();
249
- if (!in_array(NULL, $request->toArray()) && !empty($transStatus)) {
250
- $buildNovalnetParam = http_build_query($request->getData());
251
- $payportUrl = $helper->getPayportUrl('paygate');
252
- $dataHelper = Mage::helper('novalnet_payment/AssignData');
253
- $response = $dataHelper->setRawCallRequest($buildNovalnetParam, $payportUrl, $paymentObj);
254
- if ($response->getStatus() == $responseCodeApproved) {
255
- // set transaction amount
256
- $loadTransStatus->setAmount($amountChanged)
257
- ->save();
258
- // make capture transaction open for lower versions to make refund
259
- if (version_compare($helper->getMagentoVersion(), '1.6', '<')) {
260
- $payment->setIsTransactionClosed(false)
261
- ->save();
262
- }
263
- $countAmount = $helper->getAmountCollection($orderId, NULL, NULL);
264
- $modNovalamountchanged = $helper->getModelAmountchanged();
265
- if ($paymentCode == Novalnet_Payment_Model_Config::NN_INVOICE || $paymentCode == Novalnet_Payment_Model_Config::NN_PREPAYMENT) {
266
- $data = unserialize($payment->getAdditionalData());
267
- if ($invoiceDuedate) {
268
- $note = explode('|',$data['NnNote']);
269
- $formatDate = Mage::helper('core')->formatDate($invoiceDuedate);
270
- $note[0] = 'Due Date: ' . $formatDate;
271
- $data['NnNote'] = implode('|',$note);
272
- $data['NnDueDate'] = 'Due Date: <span id="due_date">' . $formatDate . '</span>';
273
- }
274
- $data['NnNoteAmount'] = $dataHelper->getBankDetailsAmount($amountChanged);
275
- $payment->setAdditionalData(serialize($data))
276
- ->save();
277
- $modNovalamountchanged->setInvoiceDuedate($invoiceDuedate);
278
- }
279
- $countAmount = $helper->getAmountCollection($orderId, NULL, NULL);
280
- $modNovalamountchanged = $countAmount ? $helper->getModelAmountchanged()->load($orderId, 'order_id')
281
- : $helper->getModelAmountchanged();
282
- $modNovalamountchanged->setOrderId($orderId)
283
- ->setAmountChanged($amountChanged)
284
- ->setAmountDatetime($helper->getCurrentDateTime())
285
- ->save();
286
- if ($amountChanged == $callbackValue && $paymentCode == Novalnet_Payment_Model_Config::NN_PREPAYMENT) {
287
- $this->setOrderStatus($order);
288
- $this->saveInvoice($order,$lastTranId,$paymentCode);
289
- $this->setNNTotalPaid($order,$amountChanged);
290
- }
291
-
292
- if ($paymentCode == Novalnet_Payment_Model_Config::NN_INVOICE) {
293
- $payment->setAmountRefunded(0)
294
- ->setBaseAmountRefunded(0)
295
- ->save();
296
- $order->setTotalRefunded(0);
297
- $order->setBaseTotalRefunded(0);
298
- $order->save();
299
- $this->setNNTotalPaid($order,$amountChanged);
300
-
301
- if ($amountChanged == $callbackValue) {
302
- $this->setOrderStatus($order);
303
- $invoice = $order->getInvoiceCollection()->getFirstItem();
304
- $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
305
- $invoice->save();
306
- }
307
- }
308
- } else {
309
- Mage::throwException($response->getStatusDesc());
310
- }
311
- $customerId = $order->getCustomerId();
312
- $paymentObj->logNovalnetTransactionData($request, $response, $lastTranId, $customerId, $storeId);
313
- $this->_getSession()->addSuccess(
314
- $this->__('Transaction amount updated successfully.')
315
- );
316
- }
317
- } catch (Mage_Core_Exception $e) {
318
- $this->_getSession()->addError($e->getMessage());
319
- } catch (Exception $e) {
320
- $this->_getSession()->addError($e->getMessage());
321
- }
322
- $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
323
- }
324
- } catch (Mage_Core_Exception $e) {
325
- $this->_getSession()->addError($e->getMessage());
326
- $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
327
- }
328
- }
329
 
330
- /**
331
- * Set the total paid amount after amount update
332
- *
333
- * @param varien_object $order
334
- * @param int $amountChanged
335
- */
336
- private function setNNTotalPaid($order,$amountChanged)
337
- {
338
- $order->setTotalPaid($amountChanged)
339
- ->setBaseTotalPaid($amountChanged)
340
- ->save();
341
  }
342
 
343
- /**
344
- * Set callback status
345
- *
346
- * @param varien_object $order
347
- * @return null
348
- */
349
- private function setOrderStatus($order, $confirmStatus = NULL)
350
- {
351
- $payment = $order->getPayment();
352
- $storeId = $payment->getOrder()->getStoreId();
353
- $paymentObj = $payment->getMethodInstance();
354
- $orderStatus = $confirmStatus
355
- ? $paymentObj->getNovalnetConfig('order_status', true)
356
- : $paymentObj->getNovalnetConfig('order_status_after_payment', '', $storeId);
357
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $orderStatus, '', true)->save();
358
- }
359
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  require_once 'Mage' . DS . 'Adminhtml' . DS . 'controllers' . DS . 'Sales' . DS . 'OrderController.php';
27
 
28
  class Novalnet_Payment_Adminhtml_Novalnetpayment_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
29
  {
 
 
30
  /**
31
  * Init layout, menu and breadcrumb
32
  *
33
+ * @param none
34
  * @return Mage_Adminhtml_Sales_OrderController
35
  */
36
  protected function _initAction()
37
  {
38
  $this->loadLayout()
39
+ ->setUsedModuleName('novalnet_payment')
40
+ ->_setActiveMenu('novalnet')
41
+ ->_addBreadcrumb($this->__('Novalnet'), $this->__('Orders'));
42
 
43
  return $this;
44
  }
45
 
46
  /**
47
+ * Novalnet payments order grid
48
  *
49
+ * @param none
50
+ * @return none
51
  */
52
  public function indexAction()
53
  {
54
  $this->_title($this->__('Novalnet'))->_title($this->__('Orders'));
55
 
56
  $this->_initAction()
57
+ ->renderLayout();
58
  }
59
 
60
  /**
61
+ * Create sales order block for Novalnet payments
62
  *
63
+ * @param none
64
+ * @return none
65
  */
66
+ public function gridAction()
67
  {
 
68
  $this->getResponse()->setBody(
69
+ $this->getLayout()->createBlock('novalnet_payment/adminhtml_sales_order_grid')->toHtml()
70
  );
71
  }
72
 
73
  /**
74
+ * Set transactionoverview grid in sales order view page
75
  *
76
+ * @param none
77
+ * @return none
78
  */
79
  public function transactionOverviewGridAction()
80
  {
81
  $this->_initOrder();
82
  $this->getResponse()->setBody(
83
+ Mage::getBlockSingleton('novalnet_payment/adminhtml_sales_order_view_tab_transactionOverview')->toHtml()
84
  );
85
  }
86
 
87
  /**
88
+ * Set transactionoverview grid in sales order view page
89
  *
90
+ * @param none
91
+ * @return none
92
  */
93
+ public function transactionTracesGridAction()
94
  {
95
+ $this->_initOrder();
96
  $this->getResponse()->setBody(
97
+ Mage::getBlockSingleton('novalnet_payment/adminhtml_sales_order_view_tab_transactionTraces')->toHtml()
98
  );
99
  }
100
 
101
  /**
102
+ * Order confirm process for Novalnet invoice payments (Invoice/Prepayment)
103
+ *
104
+ * @param none
105
+ * @return none
106
+ */
107
+ public function confirmAction()
108
+ {
109
+ $order = $this->_initOrder(); // Get order object
110
+ $paymentObj = $order->getPayment()->getMethodInstance(); // Get payment method instance
111
+ $this->code = $paymentObj->getCode(); // Get payment method code
112
+ $this->helper = Mage::helper('novalnet_payment'); // Novalnet payment helper
113
+ // Get payment last transaction id
114
+ $transactionId = $this->helper->makeValidNumber($order->getPayment()->getLastTransId());
115
+ // Build confirm payment request
116
+ $request = $this->helper->getModel('Service_Api_Request')
117
+ ->getprocessVendorInfo($order->getPayment()); // Get Novalnet authentication Data
118
+ $request->setTid($transactionId)
119
+ ->setStatus(100)
120
+ ->setEditStatus(true);
121
+ $response = $paymentObj->postRequest($request); // Send confirm payment request
122
+ $this->validateConfirmResponse($response, $order, $transactionId); // Validate the payport response
123
+ // Save the transaction traces
124
+ $responseModel = $this->helper->getModel('Service_Api_Response');
125
+ $responseModel->logTransactionTraces($request, $response, $order, $transactionId);
126
+ if ($response->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
127
+ $this->_getSession()->addSuccess($this->__('The order has been updated.'));
128
+ } else {
129
+ $message = $this->__('Error in your process request. Status Code : ' . $response->getStatus());
130
+ $this->_getSession()->addError($message);
131
+ }
132
+ $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
133
+ }
134
+
135
+ /**
136
+ * Validate the confirm payment response data
137
  *
138
+ * @param Varien_Object $request
139
+ * @param Varien_Object $order
140
+ * @param string $transactionId
141
+ * @return none
142
  */
143
+ public function validateConfirmResponse($response, $order, $transactionId)
144
  {
145
+ if ($response->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
146
+ $payment = $order->getPayment(); // Get payment object
147
+
148
+ // Save payment additional transaction details
149
+ $data = unserialize($payment->getAdditionalData());
150
+ $data['captureTid'] = $transactionId;
151
+ $data['CaptureCreateAt'] = Mage::getModel('core/date')->date('Y-m-d H:i:s');
152
+ $payment->setAdditionalData(serialize($data))->save();
153
+
154
+ // Add transaction status information
155
+ $transactionStatus = $this->helper->getModel('Mysql4_TransactionStatus')
156
+ ->loadByAttribute('transaction_no', $transactionId);
157
+ $transactionStatus->setTransactionStatus($response->getTidStatus())->save();
158
+
159
+ // Create order invoice
160
+ if ($this->code == Novalnet_Payment_Model_Config::NN_INVOICE && $order->canInvoice()) {
161
+ $this->saveOrderInvoice($order, $transactionId);
162
+ } elseif ($this->code == Novalnet_Payment_Model_Config::NN_PREPAYMENT) {
163
+ $captureOrderStatus = Mage::getStoreConfig('novalnet_global/order_status_mapping/order_status', $order->getStoreId())
164
+ ? Mage::getStoreConfig('novalnet_global/order_status_mapping/order_status', $order->getStoreId())
165
+ : Mage_Sales_Model_Order::STATE_PROCESSING;
166
+ $message = Mage::helper('novalnet_payment')->__('The transaction has been confirmed');
167
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $captureOrderStatus, $message, true)->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  }
 
169
  }
170
  }
171
 
172
  /**
173
  * Save order invoice
174
  *
175
+ * @param varien_object $order
176
+ * @param int $transactionId
177
+ * @return none
178
  */
179
+ protected function saveOrderInvoice($order, $transactionId)
180
  {
181
+ // Create order invoice
182
  $invoice = $order->prepareInvoice();
183
+ $invoice->setTransactionId($transactionId);
184
  $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE)
185
+ ->register();
186
+ $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_OPEN)
187
+ ->save();
188
  Mage::getModel('core/resource_transaction')
189
  ->addObject($invoice)
190
  ->addObject($invoice->getOrder())
191
  ->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
+ $captureMode = (version_compare($this->helper->getMagentoVersion(), '1.6', '<')) ? false : true;
194
+ $payment = $order->getPayment(); // Get payment object
195
+ // Add capture transaction
196
+ $payment->setTransactionId($transactionId)
197
+ ->setIsTransactionClosed($captureMode);
198
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false);
199
+ $transaction->setParentTxnId(null)
200
+ ->save();
 
 
 
201
  }
202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/Sales/Recurring/ProfileController.php CHANGED
@@ -18,184 +18,41 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
 
26
 
27
- require_once 'Mage' . DS . 'Adminhtml'. DS . 'controllers' . DS . 'Sales' . DS . 'Recurring' . DS . 'ProfileController.php';
28
-
29
- class Novalnet_Payment_Adminhtml_Novalnetpayment_Sales_Recurring_ProfileController extends Mage_Adminhtml_Sales_Recurring_ProfileController
30
  {
31
- /**
 
32
  * Recurring profiles list
33
  *
 
34
  * @return Mage_Adminhtml_Sales_Recurring_ProfileController
35
  */
36
  public function indexAction()
37
  {
38
- $this->_title(Mage::helper('novalnet_payment')->__('Sales'))->_title(Mage::helper('novalnet_payment')->__('Novalnet Recurring Profiles'))
 
39
  ->loadLayout()
40
  ->_setActiveMenu('novalnet')
41
  ->renderLayout();
42
  return $this;
43
  }
44
 
45
- /**
46
- * View recurring profile information's
47
- *
48
- */
49
- public function viewAction()
50
- {
51
- try {
52
- $this->_title(Mage::helper('sales')->__('Sales'))->_title(Mage::helper('sales')->__('Recurring Profiles'));
53
- $profile = $this->_initProfile();
54
- $this->loadLayout()
55
- ->_setActiveMenu('sales/recurring_profile')
56
- ->_title(Mage::helper('sales')->__('Profile #%s', $profile->getReferenceId()))
57
- ->renderLayout()
58
- ;
59
- return;
60
- } catch (Mage_Core_Exception $e) {
61
- $this->_getSession()->addError($e->getMessage());
62
- } catch (Exception $e) {
63
- Mage::logException($e);
64
- }
65
- $this->_redirect('*/*/');
66
- }
67
-
68
  /**
69
  * Profiles ajax grid
70
- *
71
  */
72
  public function gridAction()
73
  {
74
  $this->getResponse()->setBody(
75
- $this->getLayout()->createBlock('novalnet_payment/adminhtml_recurring_profile_grid')->toHtml()
76
  );
77
  }
78
 
79
- /**
80
- * Profile orders ajax grid
81
- *
82
- */
83
- public function ordersAction()
84
- {
85
- try {
86
- $this->_initProfile();
87
- $this->loadLayout()->renderLayout();
88
- } catch (Exception $e) {
89
- Mage::logException($e);
90
- $this->norouteAction();
91
- }
92
- }
93
-
94
- /**
95
- * Profile state updater action
96
- *
97
- */
98
- public function updateStateAction()
99
- {
100
- $profile = null;
101
- try {
102
- $profile = $this->_initProfile();
103
-
104
- switch ($this->getRequest()->getParam('action')) {
105
- case 'cancel':
106
- $profile->cancel();
107
- break;
108
- case 'suspend':
109
- $profile->suspend();
110
- break;
111
- case 'activate':
112
- $profile->activate();
113
- break;
114
- }
115
- $this->_getSession()->addSuccess(Mage::helper('sales')->__('The profile state has been updated.'));
116
- } catch (Mage_Core_Exception $e) {
117
- $this->_getSession()->addError($e->getMessage());
118
- } catch (Exception $e) {
119
- $this->_getSession()->addError(Mage::helper('sales')->__('Failed to update the profile.'));
120
- Mage::logException($e);
121
- }
122
- if ($profile) {
123
- $this->_redirect('*/*/view', array('profile' => $profile->getId()));
124
- } else {
125
- $this->_redirect('*/*/');
126
- }
127
- }
128
-
129
- /**
130
- * Profile information updater action
131
- *
132
- */
133
- public function updateProfileAction()
134
- {
135
- $profile = null;
136
- try {
137
- $profile = $this->_initProfile();
138
- $profile->fetchUpdate();
139
- if ($profile->hasDataChanges()) {
140
- $profile->save();
141
- $this->_getSession()->addSuccess($this->__('The profile has been updated.'));
142
- } else {
143
- $this->_getSession()->addNotice($this->__('The profile has no changes.'));
144
- }
145
- } catch (Mage_Core_Exception $e) {
146
- $this->_getSession()->addError($e->getMessage());
147
- } catch (Exception $e) {
148
- $this->_getSession()->addError($this->__('Failed to update the profile.'));
149
- Mage::logException($e);
150
- }
151
- if ($profile) {
152
- $this->_redirect('*/*/view', array('profile' => $profile->getId()));
153
- } else {
154
- $this->_redirect('*/*/');
155
- }
156
- }
157
-
158
- /**
159
- * Cutomer billing agreements ajax action
160
- *
161
- */
162
- public function customerGridAction()
163
- {
164
- $this->_initCustomer();
165
- $this->loadLayout(false)
166
- ->renderLayout();
167
- }
168
-
169
- /**
170
- * Initialize customer by ID specified in request
171
- *
172
- * @return Mage_Adminhtml_Sales_Billing_AgreementController
173
- */
174
- protected function _initCustomer()
175
- {
176
- $customerId = (int) $this->getRequest()->getParam('id');
177
- $customer = Mage::getModel('customer/customer');
178
-
179
- if ($customerId) {
180
- $customer->load($customerId);
181
- }
182
-
183
- Mage::register('current_customer', $customer);
184
- return $this;
185
- }
186
-
187
- /**
188
- * Load/set profile
189
- *
190
- * @return Mage_Sales_Model_Recurring_Profile
191
- */
192
- protected function _initProfile()
193
- {
194
- $profile = Mage::getModel('sales/recurring_profile')->load($this->getRequest()->getParam('profile'));
195
- if (!$profile->getId()) {
196
- Mage::throwException($this->__('Specified profile does not exist.'));
197
- }
198
- Mage::register('current_recurring_profile', $profile);
199
- return $profile;
200
- }
201
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
+ require_once 'Mage' . DS . 'Adminhtml' . DS . 'controllers' . DS . 'Sales' . DS . 'Recurring' . DS . 'ProfileController.php';
27
 
28
+ class Novalnet_Payment_Adminhtml_Novalnetpayment_Sales_Recurring_ProfileController
29
+ extends Mage_Adminhtml_Sales_Recurring_ProfileController
 
30
  {
31
+
32
+ /**
33
  * Recurring profiles list
34
  *
35
+ * @param none
36
  * @return Mage_Adminhtml_Sales_Recurring_ProfileController
37
  */
38
  public function indexAction()
39
  {
40
+ $helper = Mage::helper('novalnet_payment');
41
+ $this->_title($helper->__('Sales'))->_title($helper->__('Novalnet Recurring Profiles'))
42
  ->loadLayout()
43
  ->_setActiveMenu('novalnet')
44
  ->renderLayout();
45
  return $this;
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  /**
49
  * Profiles ajax grid
 
50
  */
51
  public function gridAction()
52
  {
53
  $this->getResponse()->setBody(
54
+ $this->getLayout()->createBlock('novalnet_payment/adminhtml_recurring_profile_grid')->toHtml()
55
  );
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/TransactionController.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Adminhtml_Novalnetpayment_TransactionController extends Mage_Adminhtml_Controller_Action
27
- {
28
- /**
29
- * Init layout, menu and breadcrumb
30
- *
31
- * @return Novalnet_Payment_Adminhtml_TransactionController
32
- *
33
- */
34
- protected function _initAction()
35
- {
36
- $this->loadLayout()
37
- ->setUsedModuleName('novalnet_payment')
38
- ->_setActiveMenu('novalnet/transactionstatus')
39
- ->_addBreadcrumb($this->__('Novalnet'), $this->__('Transaction'));
40
-
41
- return $this;
42
- }
43
-
44
- /**
45
- * Render layout
46
- *
47
- */
48
- public function indexAction()
49
- {
50
- $this->_initAction();
51
- $this->renderLayout();
52
- }
53
-
54
- /**
55
- * Create transaction status block
56
- *
57
- */
58
- public function gridAction()
59
- {
60
- $this->getResponse()->setBody(
61
- $this->getLayout()->createBlock('novalnet_payment/adminhtml_transaction_grid')->toHtml()
62
- );
63
- }
64
-
65
- /**
66
- * View the transaction status information
67
- *
68
- */
69
- public function viewAction()
70
- {
71
- $nnTxnId = $this->getRequest()->getParam('nntxn_id');
72
- $transactionStatus = Mage::helper('novalnet_payment')->getModelTransactionStatus()->load($nnTxnId);
73
-
74
- if (empty($nnTxnId) || !$transactionStatus->getNnTxnId()) {
75
- $this->_forward('noRoute');
76
- }
77
-
78
- $this->_title(sprintf("#%s", $transactionStatus->getTransactionNo()));
79
-
80
- // @var $transactionStatus Novalnet_Payment_Model_Transactionstatus
81
- $modelTransaction = Mage::helper('novalnet_payment')->getModelTransactionStatus();
82
- $modelTransaction->loadByTransactionStatusId($transactionStatus);
83
-
84
- Mage::register('novalnet_payment_transactionstatus', $modelTransaction);
85
-
86
- $this->_initAction();
87
- $this->renderLayout();
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/TransactionoverviewController.php CHANGED
@@ -1,88 +1,102 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the payment module of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script useful a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_Adminhtml_Novalnetpayment_TransactionoverviewController extends Mage_Adminhtml_Controller_Action
27
- {
28
- /**
29
- * Init layout, menu and breadcrumb
30
- *
31
- * @return Novalnet_NovalnetIdeal_Adminhtml_TransactionController
32
- *
33
- */
34
- protected function _initAction()
35
- {
36
- $this->loadLayout()
37
- ->setUsedModuleName('novalnet_payment')
38
- ->_setActiveMenu('novalnet/transactionoverview')
39
- ->_addBreadcrumb($this->__('Novalnet'), $this->__('Transaction Overview'));
40
-
41
- return $this;
42
- }
43
-
44
- /**
45
- * Render layout
46
- *
47
- */
48
- public function indexAction()
49
- {
50
- $this->_initAction();
51
- $this->renderLayout();
52
- }
53
-
54
- /**
55
- * Create transaction overview block
56
- *
57
- */
58
- public function gridAction()
59
- {
60
- $this->getResponse()->setBody(
61
- $this->getLayout()->createBlock('novalnet_payment/adminhtml_transactionoverview_grid')->toHtml()
62
- );
63
- }
64
-
65
- /**
66
- * View the transaction overview information
67
- *
68
- */
69
- public function viewAction()
70
- {
71
- $nnTxnId = $this->getRequest()->getParam('nnlog_id');
72
- $modelTransaction = Mage::helper('novalnet_payment')->getModelTransactionOverview();
73
- $transOverview = $modelTransaction->load($nnTxnId);
74
-
75
- if (empty($nnTxnId) || !$transOverview->getNnLogId()) {
76
- $this->_forward('noRoute');
77
- }
78
-
79
- $this->_title(sprintf("#%s", $transOverview->getTransactionId()));
80
-
81
- $modelTransaction->loadByOrderLogId($transOverview);
82
-
83
- Mage::register('novalnet_payment_transactionoverview', $transOverview);
84
-
85
- $this->_initAction();
86
- $this->renderLayout();
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Adminhtml_Novalnetpayment_TransactionoverviewController extends Mage_Adminhtml_Controller_Action
27
+ {
28
+
29
+ /**
30
+ * Init layout, menu and breadcrumb
31
+ *
32
+ * @param none
33
+ * @return Novalnet_Payment_Adminhtml_Novalnetpayment_TransactionoverviewController
34
+ */
35
+ protected function _initAction()
36
+ {
37
+ $this->loadLayout()
38
+ ->setUsedModuleName('novalnet_payment')
39
+ ->_setActiveMenu('novalnet/transactionstatus')
40
+ ->_addBreadcrumb($this->__('Novalnet'), $this->__('Transaction'));
41
+
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * Transaction status overview
47
+ *
48
+ * @param none
49
+ * @return none
50
+ */
51
+ public function indexAction()
52
+ {
53
+ $this->_initAction();
54
+ $this->renderLayout();
55
+ }
56
+
57
+ /**
58
+ * Create transaction status block
59
+ *
60
+ * @param none
61
+ * @return none
62
+ */
63
+ public function gridAction()
64
+ {
65
+ $this->getResponse()->setBody(
66
+ $this->getLayout()->createBlock('novalnet_payment/adminhtml_transactionoverview_grid')->toHtml()
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Get the transaction status information
72
+ *
73
+ * @param none
74
+ * @return none
75
+ */
76
+ public function viewAction()
77
+ {
78
+ $nnTxnId = $this->getRequest()->getParam('nntxn_id');
79
+ $transactionStatus = Mage::getModel('novalnet_payment/Mysql4_TransactionStatus');
80
+ $statusCollection = $transactionStatus->load($nnTxnId);
81
+
82
+ if (empty($nnTxnId) || !$statusCollection->getNnTxnId()) {
83
+ $this->_forward('noRoute');
84
+ }
85
+
86
+ $this->_title(sprintf("#%s", $statusCollection->getTransactionNo()));
87
+ $transactionStatus->loadByTransactionStatusId($statusCollection);
88
+ Mage::register('novalnet_payment_transactionoverview', $transactionStatus);
89
+ $this->_initAction();
90
+ $this->renderLayout();
91
+ }
92
+
93
+ /**
94
+ * Check admin permissions for this controller
95
+ *
96
+ * @return bool
97
+ */
98
+ protected function _isAllowed()
99
+ {
100
+ return Mage::getSingleton('admin/session')->isAllowed('novalnetpayment_transactionoverview');
101
+ }
102
+ }
app/code/community/Novalnet/Payment/controllers/Adminhtml/Novalnetpayment/TransactiontracesController.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the payment module of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script useful a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_Adminhtml_Novalnetpayment_TransactiontracesController extends Mage_Adminhtml_Controller_Action
27
+ {
28
+ /**
29
+ * Init layout, menu and breadcrumb
30
+ *
31
+ * @param none
32
+ * @return Novalnet_Payment_Adminhtml_Novalnetpayment_TransactiontracesController
33
+ */
34
+ protected function _initAction()
35
+ {
36
+ $this->loadLayout()
37
+ ->setUsedModuleName('novalnet_payment')
38
+ ->_setActiveMenu('novalnet/transactiontraces')
39
+ ->_addBreadcrumb($this->__('Novalnet'), $this->__('Transaction Traces'));
40
+
41
+ return $this;
42
+ }
43
+
44
+ /**
45
+ * Transaction traces overview
46
+ *
47
+ * @param none
48
+ * @return none
49
+ */
50
+ public function indexAction()
51
+ {
52
+ $this->_initAction();
53
+ $this->renderLayout();
54
+ }
55
+
56
+ /**
57
+ * Create transaction traces block
58
+ *
59
+ * @param none
60
+ * @return none
61
+ */
62
+ public function gridAction()
63
+ {
64
+ $this->getResponse()->setBody(
65
+ $this->getLayout()->createBlock('novalnet_payment/adminhtml_transactiontraces_grid')->toHtml()
66
+ );
67
+ }
68
+
69
+ /**
70
+ * Get the transaction traces information
71
+ *
72
+ * @param none
73
+ * @return none
74
+ */
75
+ public function viewAction()
76
+ {
77
+ $nnLogId = $this->getRequest()->getParam('nnlog_id');
78
+ $transactionTraces = Mage::getModel('novalnet_payment/Mysql4_TransactionTraces');
79
+ $tracesCollection = $transactionTraces->load($nnLogId);
80
+
81
+ if (empty($nnLogId) || !$tracesCollection->getNnLogId()) {
82
+ $this->_forward('noRoute');
83
+ }
84
+
85
+ $this->_title(sprintf("#%s", $tracesCollection->getTransactionId()));
86
+
87
+ $transactionTraces->loadByOrderLogId($tracesCollection);
88
+
89
+ Mage::register('novalnet_payment_transactiontraces', $tracesCollection);
90
+
91
+ $this->_initAction();
92
+ $this->renderLayout();
93
+ }
94
+
95
+ /**
96
+ * Check admin permissions for this controller
97
+ *
98
+ * @return bool
99
+ */
100
+ protected function _isAllowed()
101
+ {
102
+ return Mage::getSingleton('admin/session')->isAllowed('novalnetpayment_transactiontraces');
103
+ }
104
+ }
app/code/community/Novalnet/Payment/controllers/CallbackController.php ADDED
@@ -0,0 +1,1497 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the Paymentmodule of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script usefull a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Novalnet AG
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_CallbackController extends Mage_Core_Controller_Front_Action
27
+ {
28
+
29
+ /**
30
+ * Get Novalnet vendor script response
31
+ *
32
+ * @param none
33
+ * @return none
34
+ */
35
+ public function indexAction()
36
+ {
37
+ $this->_assignGlobalParams(); // Assign Global params for callback process
38
+
39
+ if ($this->checkIP()) { // Check whether the IP address is authorized
40
+ // Make reference log (Novalnet callback response) based on configuration settings
41
+ if ($this->logTraces) {
42
+ $fileName = 'novalnet_callback_script_' . $this->currentTime . '.log';
43
+ Mage::log($this->response->getData(), null, $fileName, true);
44
+ }
45
+
46
+ // Make affiliate process
47
+ if ($this->response->getVendorActivation()) {
48
+ $this->affiliateProcess();
49
+ return false;
50
+ }
51
+
52
+ $this->level = $this->getCallbackProcessLevel(); // Assign callback process level
53
+ $this->orderNo = $this->getOrderIncrementId(); // Assign order number
54
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($this->orderNo); // Get order object
55
+ $this->storeId = $this->order->getStoreId(); // Get order store id
56
+ $this->payment = $this->order->getPayment(); // Get payment object
57
+ $this->code = $this->payment->getMethodInstance()->getCode(); // Get payment method code
58
+ $this->paymentTxnId = $this->payment->getLastTransId(); // Get payment last transaction id
59
+ $this->currency = $this->order->getOrderCurrencyCode(); // Get order currency
60
+ $this->responseModel = $this->helper->getModel('Service_Api_Response');
61
+
62
+ // Complete the order in-case response failure from Novalnet server
63
+ $this->_handleCommunicationFailure();
64
+
65
+ // Perform callback process for recurring and payment credit related process
66
+ if ($this->_checkParams()) {
67
+ $this->_callbackProcess();
68
+ $this->sendCallbackMail(); // Send callback notification E-mail
69
+ } else {
70
+ $this->showDebug($this->responseModel->getStatusText($this->response));
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Assign Global params for callback process
77
+ *
78
+ * @param none
79
+ * @return none
80
+ */
81
+ protected function _assignGlobalParams()
82
+ {
83
+ // Get callback setting params (from shop admin)
84
+ $this->debug = Mage::getStoreConfig('novalnet_global/merchant_script/debug_mode');
85
+ $this->test = Mage::getStoreConfig('novalnet_global/merchant_script/test_mode');
86
+ $this->logTraces = Mage::getStoreConfig('novalnet_global/merchant_script/vendor_script_log');
87
+ // Get Novalnet callback response values
88
+ $params = Mage::app()->getRequest()->getPost()
89
+ ? Mage::app()->getRequest()->getPost()
90
+ : Mage::app()->getRequest()->getQuery();
91
+ $params = array_filter($params);
92
+ if (empty($params)) {
93
+ $this->showDebug('Novalnet callback received. No params passed over!');
94
+ }
95
+
96
+ $this->response = new Varien_Object();
97
+ $this->response->setData($params); // Assign response params to object data
98
+ // Novalnet IP, is a fixed value, DO NOT CHANGE !!!!!
99
+ $this->ipAllowed = array('195.143.189.210', '195.143.189.214');
100
+ $this->currentTime = Mage::getModel('core/date')->date('Y-m-d H:i:s'); // Get current time for callback process
101
+ $httpHost = Mage::helper('core/http')->getHttpHost();
102
+ $this->lineBreak = empty($httpHost) ? PHP_EOL : '<br />';
103
+ $this->helper = Mage::helper('novalnet_payment'); // Novalnet payment helper
104
+ $this->callback = $this->recurring = false;
105
+
106
+ // Assign callback process payment types
107
+ $this->callbackPaymentTypes();
108
+ }
109
+
110
+ /**
111
+ * Assign callback process payment types
112
+ *
113
+ * @param none
114
+ * @return none
115
+ */
116
+ public function callbackPaymentTypes()
117
+ {
118
+ $this->allowedPayment = array(
119
+ 'novalnetcc' => array('CREDITCARD', 'CREDITCARD_BOOKBACK', 'CREDITCARD_CHARGEBACK',
120
+ 'CREDIT_ENTRY_CREDITCARD', 'SUBSCRIPTION_STOP', 'DEBT_COLLECTION_CREDITCARD'),
121
+ 'novalnetinvoice' => array('INVOICE_START', 'INVOICE_CREDIT', 'SUBSCRIPTION_STOP',
122
+ 'GUARANTEED_INVOICE_START', 'GUARANTEED_INVOICE_CREDIT'),
123
+ 'novalnetprepayment' => array('INVOICE_START', 'INVOICE_CREDIT', 'SUBSCRIPTION_STOP',
124
+ 'GUARANTEED_INVOICE_START', 'GUARANTEED_INVOICE_CREDIT'),
125
+ 'novalnetideal' => array('IDEAL'),
126
+ 'novalnetpaypal' => array('PAYPAL', 'PAYPAL_BOOKBACK', 'SUBSCRIPTION_STOP'),
127
+ 'novalneteps' => array('EPS'),
128
+ 'novalnetbanktransfer' => array('ONLINE_TRANSFER', 'REFUND_BY_BANK_TRANSFER_EU'),
129
+ 'novalnetsepa' => array('DIRECT_DEBIT_SEPA', 'RETURN_DEBIT_SEPA', 'SUBSCRIPTION_STOP',
130
+ 'DEBT_COLLECTION_SEPA', 'CREDIT_ENTRY_SEPA', 'GUARANTEED_DIRECT_DEBIT_SEPA'));
131
+ $this->invoiceAllowed = array('INVOICE_CREDIT', 'INVOICE_START');
132
+ $this->recurringAllowed = array('INVOICE_CREDIT', 'INVOICE_START', 'CREDITCARD',
133
+ 'DIRECT_DEBIT_SEPA', 'SUBSCRIPTION_STOP', 'GUARANTEED_DIRECT_DEBIT_SEPA',
134
+ 'GUARANTEED_INVOICE_START', 'GUARANTEED_INVOICE_CREDIT', 'PAYPAL');
135
+ // Array Type of payment available - Level : 0
136
+ $this->paymentTypes = array('CREDITCARD', 'INVOICE_START', 'DIRECT_DEBIT_SEPA',
137
+ 'GUARANTEED_INVOICE_START', 'PAYPAL', 'ONLINE_TRANSFER', 'IDEAL',
138
+ 'EPS', 'PAYSAFECARD', 'GIROPAY', 'GUARANTEED_DIRECT_DEBIT_SEPA');
139
+ // Array Type of Chargebacks available - Level : 1
140
+ $this->chargebacks = array('CREDITCARD_CHARGEBACK', 'RETURN_DEBIT_SEPA',
141
+ 'CREDITCARD_BOOKBACK', 'REFUND_BY_BANK_TRANSFER_EU', 'PAYPAL_BOOKBACK');
142
+ // Array Type of CreditEntry payment and Collections available - Level : 2
143
+ $this->aryCollection = array('INVOICE_CREDIT', 'GUARANTEED_INVOICE_CREDIT',
144
+ 'CREDIT_ENTRY_CREDITCARD', 'CREDIT_ENTRY_SEPA', 'DEBT_COLLECTION_SEPA',
145
+ 'DEBT_COLLECTION_CREDITCARD');
146
+ $this->arySubscription = array('SUBSCRIPTION_STOP');
147
+ }
148
+
149
+ /**
150
+ * Get email config
151
+ *
152
+ * @param none
153
+ * @return none
154
+ */
155
+ public function getEmailConfig()
156
+ {
157
+ $this->emailSendOption = Mage::getStoreConfig('novalnet_global/merchant_script/mail_send_option');
158
+ $this->useEmailOption = Mage::getStoreConfig('novalnet_global/merchant_script/use_mail_option');
159
+ $this->emailFromAddr = Mage::getStoreConfig('trans_email/ident_general/email');
160
+ $this->emailFromName = Mage::getStoreConfig('trans_email/ident_general/name');
161
+ $this->emailToAddr = Mage::getStoreConfig('novalnet_global/merchant_script/mail_to_addr');
162
+ $this->emailToName = 'store admin'; // Adapt for your need
163
+ $this->emailBCcAddr = Mage::getStoreConfig('novalnet_global/merchant_script/mail_bcc_addr');
164
+ $this->emailSubject = 'Novalnet Callback Script Access Report';
165
+ //Reporting Email Addresses Settings
166
+ $this->shopInfo = 'Magento ' . $this->lineBreak; //mandatory;adapt for your need
167
+ $this->mailHost = Mage::getStoreConfig('system/smtp/host');
168
+ $this->mailPort = Mage::getStoreConfig('system/smtp/port');
169
+ }
170
+
171
+ /**
172
+ * Log Affiliate account details
173
+ *
174
+ * @param none
175
+ * @return none
176
+ */
177
+ public function affiliateProcess()
178
+ {
179
+ $paramsRequired = $this->getRequiredParams(); // Get required params for callback process
180
+ // Check the necessary params for callback script process
181
+ foreach ($paramsRequired as $param) {
182
+ if (!$this->response->getData($param)) {
183
+ $this->showDebug('Required param (' . $param . ') missing!');
184
+ }
185
+ }
186
+
187
+ $affiliateModel = $this->helper->getModel('Mysql4_AffiliateInfo');
188
+ $affiliateModel->setVendorId($this->response->getVendorId())
189
+ ->setVendorAuthcode($this->response->getVendorAuthcode())
190
+ ->setProductId($this->response->getProductId())
191
+ ->setProductUrl($this->response->getProductUrl())
192
+ ->setActivationDate($this->response->getActivationDate())
193
+ ->setAffId($this->response->getAffId())
194
+ ->setAffAuthcode($this->response->getAffAuthcode())
195
+ ->setAffAccesskey($this->response->getAffAccesskey())
196
+ ->save();
197
+ // Send notification mail to Merchant
198
+ $message = 'Novalnet callback script executed successfully with Novalnet account activation information.';
199
+ $this->emailBody = $message;
200
+ $this->sendCallbackMail(); // Send callback notification E-mail
201
+ }
202
+
203
+ /**
204
+ * Complete the order in-case response failure from Novalnet server
205
+ *
206
+ * @param none
207
+ * @return none
208
+ */
209
+ protected function _handleCommunicationFailure()
210
+ {
211
+ $successActionFlag = $this->code . '_successAction';
212
+
213
+ if (empty($this->paymentTxnId)
214
+ && $this->payment->getAdditionalInformation($successActionFlag) != 1
215
+ ) {
216
+ $this->payment->setAdditionalInformation($successActionFlag, 1)->save();
217
+ // Unhold an order
218
+ if ($this->order->canUnhold()) {
219
+ $this->order->unhold()->save();
220
+ }
221
+
222
+ // Save transaction additional information
223
+ $transactionId = $this->response->getTid();
224
+ // Get payment mode from Novalnet global configuration
225
+ $responsePaymentMode = $this->response->getTestMode();
226
+ $shopMode = $this->_getConfig('live_mode'); // Get payment mode from callback response
227
+ $testMode = ($responsePaymentMode == 1 || $shopMode == 0) ? 1 : 0; // Get payment process mode
228
+ $paymentId = $this->helper->getPaymentId($this->code); // Get payment key
229
+ $confirmText = 'Novalnet Callback Script executed successfully on ' . $this->currentTime;
230
+ $data = array('NnTestOrder' => $testMode, 'NnTid' => $transactionId,
231
+ 'vendor' => $this->_getConfig('merchant_id'),
232
+ 'auth_code' => $this->_getConfig('auth_code'),
233
+ 'product' => $this->_getConfig('product_id'),
234
+ 'tariff' => $this->_getConfig('tariff_id'),
235
+ 'payment_id'=> $paymentId,
236
+ 'NnComments' => $confirmText
237
+ );
238
+ $data['paidUntil'] = $this->response->hasNextSubsCycle() ? $this->response->getNextSubsCycle()
239
+ : ($this->response->hasPaidUntil() ? $this->response->getPaidUntil() : '');
240
+ // Get payment additional information
241
+ $additionalData = unserialize($this->payment->getAdditionalData());
242
+ // Merge payment additional information if exist
243
+ $data = $additionalData ? array_merge($additionalData, $data) : $data;
244
+
245
+ // Save the payment transaction information
246
+ $this->payment->setTransactionId($transactionId)
247
+ ->setLastTransId($transactionId)
248
+ ->setParentTransactionId(null)
249
+ ->setAdditionalData(serialize($data));
250
+
251
+ // Capture the payment
252
+ if ($this->order->canInvoice()
253
+ && $this->response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
254
+ && $this->response->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
255
+ ) {
256
+ // Save payment information with invoice for Novalnet successful transaction
257
+ $this->payment->setIsTransactionClosed(true)
258
+ ->capture(null);
259
+ }
260
+ $this->payment->save();
261
+
262
+ // Get payment request params
263
+ $request = new Varien_Object();
264
+ $traces = $this->helper->getModel('Mysql4_TransactionTraces')
265
+ ->loadByAttribute('order_id', $this->orderNo);
266
+ $request->setData(unserialize($traces->getRequestData()));
267
+ $this->responseModel->logTransactionStatus($this->response, $this->order); // Log Novalnet payment transaction informations
268
+ $this->savePayportResponse(); // Log Novalnet payment transaction traces informations
269
+
270
+ // Set order status based on Novalnet transaction status
271
+ if ($this->response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
272
+ && in_array($this->response->getTidStatus(), array(100, 90, 91, 98, 99))
273
+ ) {
274
+ $this->setRecurringProfileState(); // Assign recurring profile state if profile exist
275
+ $orderStatus = $this->getOrderStatus(); // Get order status
276
+ $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $orderStatus, $this->helper->__('Customer successfully returned from Novalnet'), true)->save();
277
+ $this->paymentTxnId = $transactionId; // Get payment last transaction id
278
+ // Send order email for successful Novalnet transaction
279
+ Mage::dispatchEvent('novalnet_sales_order_email', array('order' => $this->order));
280
+ } else {
281
+ $this->setRecurringProfileState('canceled'); // Assign recurring profile state if profile exist
282
+ $this->responseModel->saveCanceledOrder($this->response, $this->order, $testMode); // Cancel the order based on Novalnet transaction status
283
+ }
284
+
285
+ $this->order->save(); // Save the current order
286
+ $this->showDebug($confirmText);
287
+ }
288
+ }
289
+
290
+ /**
291
+ * Check the callback mandatory parameters.
292
+ *
293
+ * @param none
294
+ * @return boolean
295
+ */
296
+ protected function _checkParams()
297
+ {
298
+ $paramsRequired = $this->getRequiredParams(); // Get required params for callback process
299
+ $amount = $this->response->getAmount() ? (int) $this->response->getAmount() : '';
300
+
301
+ // Check the necessary params for callback script process
302
+ foreach ($paramsRequired as $param) {
303
+ if ($param == 'amount' && (!$amount)) {
304
+ $this->showDebug('Required param (amount) missing!');
305
+ } elseif ($param != 'amount' && !$this->response->getData($param)) {
306
+ $this->showDebug('Required param (' . $param . ') missing!');
307
+ }
308
+ }
309
+
310
+ // Check whether Novalnet Tid is valid
311
+ $transactionId = $this->getParentTid(); // Get the original/parent transaction id
312
+
313
+ if (!preg_match('/^\d{17}$/', $transactionId)) {
314
+ $this->showDebug('Novalnet callback received. Invalid TID [' . $transactionId . '] for Order :' . $this->orderNo);
315
+ }
316
+
317
+ $referenceTid = ($transactionId != $this->response->getTid()) ? $this->response->getTid() : '';
318
+
319
+ if ($referenceTid && !preg_match('/^\d{17}$/', $referenceTid)) {
320
+ $this->showDebug('Novalnet callback received. Invalid TID [' . $referenceTid . '] for Order :' . $this->orderNo);
321
+ }
322
+
323
+ // Check whether payment type is valid
324
+ $paymentType = $this->allowedPayment[strtolower($this->code)];
325
+ if (!in_array($this->response->getPaymentType(), $paymentType)) {
326
+ $this->showDebug("Novalnet callback received. Payment type (" . $this->response->getPaymentType() . ") is not matched with $this->code!");
327
+ }
328
+
329
+ if ($this->recurring && $this->response->getSubsBilling() && $this->response->getSignupTid()) {
330
+ $profile = $this->getProfileInformation(); // Get the Recurring Profile Information
331
+ if ($profile->getState() == 'canceled') {
332
+ // Get parent order object for given recurring profile
333
+ $profileOrders = $this->helper->getModel('Mysql4_Recurring')->getRecurringOrderNo($profile);
334
+ $parentOrder = Mage::getModel('sales/order')->loadByIncrementId($profileOrders[0]);
335
+ $this->showDebug('Subscription already Cancelled. Refer Order : ' . $parentOrder->getIncrementId());
336
+ }
337
+ } else {
338
+ $additionalData = unserialize($this->payment->getAdditionalData());
339
+ $orderTid = (in_array($this->response->getPaymentType(), $this->chargebacks)
340
+ && $additionalData['NnTid']) ? $additionalData['NnTid'] : $this->paymentTxnId;
341
+ if (!preg_match('/^' . $transactionId . '/i', $orderTid)) {
342
+ $this->showDebug('Novalnet callback received. Order no is not valid');
343
+ }
344
+ }
345
+
346
+ if (($this->response->getPaymentType() == 'INVOICE_CREDIT'
347
+ || in_array($this->response->getPaymentType(), $this->chargebacks))
348
+ && ($this->response->getStatus() != Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
349
+ || $this->response->getTidStatus() != Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED)
350
+ ) {
351
+ $this->showDebug('Novalnet callback received. Status is not valid. Refer Order :' . $this->orderNo);
352
+ }
353
+
354
+ return true;
355
+ }
356
+
357
+ /**
358
+ * Get required params for callback process
359
+ *
360
+ * @param none
361
+ * @return array $paramsRequired
362
+ */
363
+ public function getRequiredParams()
364
+ {
365
+ $paramsRequired = array('amount', 'payment_type', 'status', 'tid_status', 'tid', 'vendor_id');
366
+
367
+ if ($this->response->getVendorActivation()) {
368
+ $paramsRequired = array('vendor_id', 'vendor_authcode', 'product_id',
369
+ 'product_url', 'activation_date', 'aff_id', 'aff_authcode', 'aff_accesskey'
370
+ );
371
+ } elseif ($this->callback) {
372
+ $invoicePayments = array_merge($this->invoiceAllowed, $this->chargebacks);
373
+ if ((in_array($this->response->getPaymentType(), $invoicePayments))) {
374
+ array_push($paramsRequired, 'tid_payment');
375
+ }
376
+ } elseif ($this->recurring) {
377
+ array_push($paramsRequired, 'signup_tid');
378
+ if ($this->response->getPaymentType() == 'SUBSCRIPTION_STOP') {
379
+ unset($paramsRequired[0]);
380
+ }
381
+ }
382
+
383
+ return $paramsRequired;
384
+ }
385
+
386
+ /**
387
+ * Perform callback process
388
+ *
389
+ * @param none
390
+ * @return boolean
391
+ */
392
+ protected function _callbackProcess()
393
+ {
394
+ if ($this->order) {
395
+ if ($this->level == 1
396
+ && $this->response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
397
+ && $this->response->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
398
+ ) { // Level 1 payments - Type of Chargebacks
399
+ $this->_refundProcess();
400
+ return true;
401
+ }
402
+
403
+ if ($this->response->getPaymentType() == 'SUBSCRIPTION_STOP') { // Cancellation of a subscription
404
+ $this->_subscriptionCancel();
405
+ return true;
406
+ }
407
+
408
+ if ($this->level == 0 || $this->level == 2) {
409
+ if ($this->recurring) { // Handle subscription process
410
+ $this->_recurringProcess();
411
+ return true;
412
+ }
413
+
414
+ $saveInvoice = '';
415
+ if ($this->response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
416
+ && $this->response->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
417
+ ) {
418
+ $saveInvoice = $this->_saveInvoice(); // Handle payment credit process
419
+ }
420
+
421
+ $invoice = $this->order->getInvoiceCollection()->getFirstItem(); // Get order invoice items
422
+ if ($invoice && $saveInvoice) { // Handle payment credit process
423
+ $this->_updateOrderStatus(); // Update order status for payment credit process
424
+ }
425
+ }
426
+ } else {
427
+ $this->showDebug("Novalnet Callback: No order for Increment-ID $this->orderNo found.");
428
+ }
429
+ }
430
+
431
+ /**
432
+ * Handle payment chargeback and bookback process
433
+ *
434
+ * @param none
435
+ * @return none
436
+ */
437
+ protected function _refundProcess()
438
+ {
439
+ // Update callback comments for Chargebacks
440
+ if (in_array($this->response->getPaymentType(), $this->chargebacks)) {
441
+ $bookBack = array('CREDITCARD_BOOKBACK', 'PAYPAL_BOOKBACK', 'REFUND_BY_BANK_TRANSFER_EU');
442
+ $transactionId = !$this->recurring ? $this->response->getTidPayment() : $this->response->getSignupTid();
443
+ $message = (in_array($this->response->getPaymentType(), $bookBack)) ? 'Refund/Bookback' : 'Chargeback';
444
+ $this->emailBody = $script = 'Novalnet callback received. ' . $message . ' executed successfully for the TID: ' . $transactionId . ' amount: ' . ($this->response->getAmount())/ 100 . ' ' . $this->currency . " on " . $this->currentTime . '. The subsequent TID: ' . $this->response->getTid();
445
+ $data = unserialize($this->payment->getAdditionalData());
446
+ $data['NnComments'] = empty($data['NnComments'])
447
+ ? '<br>' . $script : $data['NnComments'] . '<br>' . $script;
448
+ $this->payment->setAdditionalData(serialize($data))->save();
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Handle subscription cancel process
454
+ *
455
+ * @param none
456
+ * @return none
457
+ */
458
+ protected function _subscriptionCancel()
459
+ {
460
+ // Update the status of the user subscription
461
+ $statusText = $this->response->getTerminationReason()
462
+ ? $this->response->getTerminationReason() : $this->responseModel->getStatusText($this->response);
463
+ $script = 'Novalnet Callback script received. Subscription has been stopped for the TID:' . $this->response->getSignupTid() . " on " . $this->currentTime;
464
+ $script .= '<br>Subscription has been canceled due to : ' . $statusText;
465
+ $this->emailBody = $script;
466
+ $profile = $this->getProfileInformation(); // Get the Recurring Profile Information
467
+ $profile->setState('canceled')->save(); // Set profile status as canceled
468
+
469
+ // Get parent order object for given recurring profile
470
+ $profileOrders = $this->helper->getModel('Mysql4_Recurring')->getRecurringOrderNo($profile);
471
+ $parentOrder = Mage::getModel('sales/order')->loadByIncrementId($profileOrders[0]);
472
+ $parentPayment = $parentOrder->getPayment();
473
+
474
+ // Save additional transaction information
475
+ $data = unserialize($parentPayment->getAdditionalData());
476
+ $data['NnComments'] = empty($data['NnComments']) ? '<br>' . $script : $data['NnComments'] . '<br>' . $script;
477
+ $parentPayment->setAdditionalData(serialize($data))->save();
478
+ }
479
+
480
+ /**
481
+ * Handle recurring payment process
482
+ *
483
+ * @param none
484
+ * @return boolean
485
+ */
486
+ protected function _recurringProcess()
487
+ {
488
+ $recurringTypes = array('CREDITCARD', 'DIRECT_DEBIT_SEPA', 'GUARANTEED_DIRECT_DEBIT_SEPA', 'INVOICE_START',
489
+ 'GUARANTEED_INVOICE_START', 'PAYPAL');
490
+ $profile = $this->getProfileInformation(); // Get the Recurring Profile Information
491
+
492
+ if ($this->response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
493
+ && in_array($this->response->getPaymentType(), $recurringTypes)
494
+ ) {
495
+ $script = 'Novalnet Callback Script executed successfully for the subscription TID ' . $this->response->getSignupTid() . ' with amount ' . ($this->response->getAmount()) / 100 . ' ' . $this->currency . ' ' . " on " . $this->currentTime . '.';
496
+ // Save subscription callback values
497
+ $callbackCycle = $this->saveRecurringProcess($profile->getPeriodMaxCycles(), $profile->getId());
498
+ // Verify subscription period (cycles)
499
+ $this->verifyRecurringCycle($profile, $callbackCycle);
500
+ // Create recurring payment order
501
+ $this->_createOrder($script, $profile->getId());
502
+ } else {
503
+ if ($profile->getState() != 'canceled') { // Cancellation of a subscription
504
+ $this->_subscriptionCancel();
505
+ }
506
+ }
507
+ return true;
508
+ }
509
+
510
+ /**
511
+ * Save subscription callback informations
512
+ *
513
+ * @param int $periodMaxCycles
514
+ * @param int $profileId
515
+ * @return int $callbackCycle
516
+ */
517
+ public function saveRecurringProcess($periodMaxCycles, $profileId)
518
+ {
519
+ $recurringModel = $this->helper->getModel('Mysql4_Recurring');
520
+ $recurringCollection = $recurringModel->getCollection();
521
+ $recurringCollection->addFieldToFilter('profile_id', $profileId);
522
+ $recurringCollection->addFieldToSelect('callbackcycle');
523
+ $countRecurring = count($recurringCollection);
524
+ if ($countRecurring == 0) {
525
+ $callbackCycle = 1;
526
+ $recurringModel->setProfileId($profileId)
527
+ ->setSignupTid($this->response->getSignupTid())
528
+ ->setBillingcycle($periodMaxCycles)
529
+ ->setCallbackcycle($callbackCycle)
530
+ ->setCycleDatetime($this->currentTime)
531
+ ->save();
532
+ } else {
533
+ foreach ($recurringCollection as $profile) {
534
+ $callbackCycle = $profile->getCallbackcycle();
535
+ }
536
+ $callbackCycle = ++$callbackCycle;
537
+ $recurring = $recurringModel->load($profileId, 'profile_id');
538
+ $recurring->setCallbackcycle($callbackCycle)
539
+ ->setCycleDatetime($this->currentTime)
540
+ ->save();
541
+ }
542
+ return $callbackCycle;
543
+ }
544
+
545
+ /**
546
+ * Verify subscription period (cycles)
547
+ *
548
+ * @param int $profile
549
+ * @param int $callbackCycle
550
+ * @return none
551
+ */
552
+ public function verifyRecurringCycle($profile, $callbackCycle)
553
+ {
554
+ $periodMaxCycles = $profile->getPeriodMaxCycles();
555
+ $this->endTime = 0;
556
+
557
+ if ($callbackCycle == $periodMaxCycles) {
558
+ // Get parent order object for given recurring profile
559
+ $profileOrders = $this->helper->getModel('Mysql4_Recurring')->getRecurringOrderNo($profile);
560
+ $this->parentOrder = Mage::getModel('sales/order')->loadByIncrementId($profileOrders[0]);
561
+ $this->parentPayment = $this->parentOrder->getPayment();
562
+ $this->parentPaymentObj = $this->parentPayment->getMethodInstance();
563
+
564
+ // Send subscription cancel request to Novalnet
565
+ $response = $this->initiateSubscriptionCancel();
566
+
567
+ // Save additional transaction information
568
+ $data = unserialize($this->parentPayment->getAdditionalData());
569
+ $data['subsCancelReason'] = 'other';
570
+ $this->parentPayment->setAdditionalData(serialize($data))->save();
571
+
572
+ if ($response->getStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
573
+ $profile->setState('canceled')->save();
574
+ $this->endTime = 1;
575
+ } else {
576
+ $this->endTime = 0;
577
+ }
578
+ }
579
+ }
580
+
581
+ /**
582
+ * Send subscription cancel request to Novalnet
583
+ *
584
+ * @param none
585
+ * @return Varien_Object $response
586
+ */
587
+ public function initiateSubscriptionCancel()
588
+ {
589
+ $traces = $this->helper->getModel('Mysql4_TransactionTraces')
590
+ ->loadByAttribute('order_id', $this->parentOrder->getIncrementId());
591
+ $paymentRequest = unserialize($traces->getRequestData());
592
+ $additionalData = unserialize($this->parentPayment->getAdditionalData());
593
+ // Build subscription cancel request
594
+ $request = new Varien_Object();
595
+ $request->setVendor($additionalData['vendor'])
596
+ ->setAuthCode($additionalData['auth_code'])
597
+ ->setProduct($additionalData['product'])
598
+ ->setTariff($additionalData['tariff'])
599
+ ->setKey($paymentRequest['key'])
600
+ ->setNnLang($paymentRequest['lang'])
601
+ ->setCancelSub(1)
602
+ ->setCancelReason('other')
603
+ ->setTid($this->response->getSignupTid());
604
+ // Send recurring cancel request to Novalnet gateway
605
+ $response = $this->parentPaymentObj->postRequest($request);
606
+ // Log Novalnet payment transaction informations
607
+ $this->responseModel->logTransactionTraces($request, $response, $this->parentOrder, $request->getTid());
608
+ return $response;
609
+ }
610
+
611
+ /**
612
+ * New order create process
613
+ *
614
+ * @param string $script
615
+ * @param int $profileId
616
+ * @return none
617
+ */
618
+ protected function _createOrder($script, $profileId)
619
+ {
620
+ $this->setLanguageStore(); // Set the language by store id
621
+ $orderNew = Mage::getModel('sales/order')
622
+ ->setState('new');
623
+
624
+ $orderPayment = Mage::getModel('sales/order_payment')
625
+ ->setStoreId($this->storeId)
626
+ ->setMethod($this->code)
627
+ ->setPo_number('-');
628
+ $orderNew->setPayment($orderPayment);
629
+ $orderNew = $this->setOrderDetails($this->order, $orderNew);
630
+ $billingAddress = Mage::getModel('sales/order_address');
631
+ $getBillingAddress = Mage::getModel('sales/order_address')->load($this->order->getBillingAddress()->getId());
632
+ $orderNew = $this->setBillingShippingAddress($getBillingAddress, $billingAddress, $orderNew, $this->order);
633
+
634
+ if ($this->order->getIsVirtual() == 0) {
635
+ $shippingAddress = Mage::getModel('sales/order_address');
636
+ $getShipping = Mage::getModel('sales/order_address')->load($this->order->getShippingAddress()->getId());
637
+ $orderNew = $this->setBillingShippingAddress($getShipping, $shippingAddress, $orderNew, $this->order);
638
+ }
639
+
640
+ $orderNew = $this->setOrderItemsDetails($this->order, $orderNew);
641
+ $paymentNew = $orderNew->getPayment();
642
+ $orderStatus = $this->getOrderStatus(); // Get order status
643
+ $message = $this->helper->__('Novalnet Recurring Callback script Executed Successfully');
644
+ $orderNew->addStatusToHistory($orderStatus, $message, false)->save();
645
+
646
+ $transactionId = trim($this->response->getTid());
647
+ $data = $this->getPaymentAddtionaldata($orderNew, $script);
648
+ $additionalInfo = $this->payment->getAdditionalInformation();
649
+ // Save payment transaction informations
650
+ $paymentNew->setTransactionId($transactionId)
651
+ ->setAdditionalData(serialize($data))
652
+ ->setAdditionalInformation($additionalInfo)
653
+ ->setLastTransId($transactionId)
654
+ ->setParentTransactionId(null)
655
+ ->save();
656
+ // Send new order email
657
+ $orderNew->sendNewOrderEmail()
658
+ ->setEmailSent(true)
659
+ ->setPayment($paymentNew)
660
+ ->save();
661
+
662
+ $this->insertOrderId($orderNew->getId(), $profileId); // Insert the order id in recurring order table
663
+ $this->updateInventory($this->order); // Update the product inventory (stock)
664
+ // Log Novalnet payment transaction informations
665
+ $this->responseModel->logTransactionStatus($this->response, $orderNew);
666
+
667
+ if ($orderNew->canInvoice() && $this->code != Novalnet_Payment_Model_Config::NN_PREPAYMENT
668
+ && $this->response->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
669
+ ) {
670
+ $this->createInvoice($orderNew, $transactionId);
671
+ }
672
+ }
673
+
674
+ /**
675
+ * Get payment method additional informations
676
+ *
677
+ * @param Varien_Object $orderNew
678
+ * @param mixed $script
679
+ * @param array $data
680
+ */
681
+ public function getPaymentAddtionaldata($orderNew, $script)
682
+ {
683
+ $parentOrderNo = $this->getOrderIdByTransId() ? $this->getOrderIdByTransId() : $orderNew->getIncrementId();
684
+ $subsCycleDate = $this->response->getNextSubsCycle()
685
+ ? $this->response->getNextSubsCycle() : $this->response->getPaidUntil();
686
+ $script .= $comments = ' Reference order id : ' . $parentOrderNo . '<br>';
687
+ $script .= $nextDate = !$this->endTime ? '<br>Next charging date : ' . $subsCycleDate . '<br>' : '';
688
+ $this->emailBody = $script;
689
+
690
+ $parentAdditionalData = unserialize($this->payment->getAdditionalData());
691
+ $data = array('NnTestOrder' => $this->response->getTestMode(),
692
+ 'NnTid' => trim($this->response->getTid()),
693
+ 'NnComments' => ($comments . $nextDate),
694
+ 'vendor' => $parentAdditionalData['vendor'],
695
+ 'auth_code' => $parentAdditionalData['auth_code'],
696
+ 'product' => $parentAdditionalData['product'],
697
+ 'tariff' => $parentAdditionalData['tariff'],
698
+ 'payment_id' => $parentAdditionalData['payment_id'],
699
+ );
700
+
701
+ if (in_array($this->code, array('novalnetInvoice', 'novalnetPrepayment'))) {
702
+ $amount = Mage::helper('core')->currency($this->response->getAmount()/100, true, false);
703
+ $data['NnNote'] = $this->responseModel->getInvoicePaymentNote($this->response);
704
+ $data['NnDueDate'] = $this->response->getDueDate();
705
+ $data['NnNoteAmount'] = 'NN_Amount: ' . $amount;
706
+ }
707
+
708
+ return $data;
709
+ }
710
+
711
+ /**
712
+ * Create order invoice
713
+ *
714
+ * @param Varien_Object $orderNew
715
+ * @param int $transactionId
716
+ * @param none
717
+ */
718
+ public function createInvoice($order, $transactionId)
719
+ {
720
+ $invoice = $order->prepareInvoice();
721
+ $invoice->setTransactionId($transactionId);
722
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE)
723
+ ->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID)
724
+ ->register();
725
+
726
+ Mage::getModel('core/resource_transaction')
727
+ ->addObject($invoice)
728
+ ->addObject($invoice->getOrder())
729
+ ->save();
730
+
731
+ $transMode = (version_compare($this->helper->getMagentoVersion(), '1.6', '<')) ? false : true;
732
+ $payment = $order->getPayment();
733
+ $payment->setTransactionId($transactionId)
734
+ ->setIsTransactionClosed($transMode);
735
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, false);
736
+ $transaction->setParentTxnId(null)
737
+ ->save();
738
+ }
739
+
740
+ /**
741
+ * Set the language based on store id
742
+ *
743
+ * @param int $storeId
744
+ * @return none
745
+ */
746
+ public function setLanguageStore()
747
+ {
748
+ $app = Mage::app();
749
+ $app->setCurrentStore($this->storeId);
750
+ $locale = Mage::getStoreConfig('general/locale/code', $this->storeId);
751
+ $app->getLocale()->setLocaleCode($locale);
752
+ Mage::getSingleton('core/translate')->setLocale($locale)->init('frontend', true);
753
+ }
754
+
755
+ /**
756
+ * Set order item and customer informations
757
+ *
758
+ * @param Varien_Object $order
759
+ * @param Varien_Object $orderNew
760
+ * @return Varien_Object $orderNew
761
+ */
762
+ public function setOrderDetails($order, $orderNew)
763
+ {
764
+ $orderNew->setStoreId($order->getStoreId())
765
+ ->setCustomerGroupId($order->getCustomerGroupId())
766
+ ->setQuoteId(0)
767
+ ->setIsVirtual($order->getIsVirtual())
768
+ ->setGlobalCurrencyCode($order->getGlobalCurrencyCode())
769
+ ->setBaseCurrencyCode($order->getBaseCurrencyCode())
770
+ ->setStoreCurrencyCode($order->getStoreCurrencyCode())
771
+ ->setOrderCurrencyCode($order->getOrderCurrencyCode())
772
+ ->setStoreName($order->getStoreName())
773
+ ->setCustomerEmail($order->getCustomerEmail())
774
+ ->setCustomerFirstname($order->getCustomerFirstname())
775
+ ->setCustomerLastname($order->getCustomerLastname())
776
+ ->setCustomerId($order->getCustomerId())
777
+ ->setCustomerIsGuest($order->getCustomerIsGuest())
778
+ ->setState('processing')
779
+ ->setStatus($order->getStatus())
780
+ ->setSubtotal($order->getSubtotal())
781
+ ->setBaseSubtotal($order->getBaseSubtotal())
782
+ ->setSubtotalInclTax($order->getSubtotalInclTax())
783
+ ->setBaseSubtotalInclTax($order->getBaseSubtotalInclTax())
784
+ ->setShippingAmount($order->getShippingAmount())
785
+ ->setBaseShippingAmount($order->getBaseShippingAmount())
786
+ ->setGrandTotal($order->getGrandTotal())
787
+ ->setBaseGrandTotal($order->getBaseGrandTotal())
788
+ ->setTaxAmount($order->getTaxAmount())
789
+ ->setTotalQtyOrdered($order->getTotalQtyOrdered())
790
+ ->setBaseTaxAmount($order->getBaseTaxAmount())
791
+ ->setBaseToGlobalRate($order->getBaseToGlobalRate())
792
+ ->setBaseToOrderRate($order->getBaseToOrderRate())
793
+ ->setStoreToBaseRate($order->getStoreToBaseRate())
794
+ ->setStoreToOrderRate($order->getStoreToOrderRate())
795
+ ->setWeight($order->getWeight())
796
+ ->setCustomerNoteNotify($order->getCustomerNoteNotify());
797
+ return $orderNew;
798
+ }
799
+
800
+ /**
801
+ * Set billing and shipping address informations
802
+ *
803
+ * @param Varien_Object $getBillingAddress
804
+ * @param Varien_Object $billingAddress
805
+ * @param Varien_Object $orderNew
806
+ * @param Varien_Object $order
807
+ * @return mixed
808
+ */
809
+ public function setBillingShippingAddress($getBillingAddress, $billingAddress, $orderNew, $order)
810
+ {
811
+ $addressType = $getBillingAddress->getAddressType();
812
+ $billingStreet = $getBillingAddress->getStreet();
813
+ $street = !empty($billingStreet[1])
814
+ ? array($billingStreet[0], $billingStreet[1]) : array($billingStreet[0]);
815
+ $billingAddress->setStoreId($order->getStoreId())
816
+ ->setAddressType($addressType)
817
+ ->setPrefix($getBillingAddress->getPrefix())
818
+ ->setFirstname($getBillingAddress->getFirstname())
819
+ ->setLastname($getBillingAddress->getLastname())
820
+ ->setMiddlename($getBillingAddress->getMiddlename())
821
+ ->setSuffix($getBillingAddress->getSuffix())
822
+ ->setCompany($getBillingAddress->getCompany())
823
+ ->setStreet($street)
824
+ ->setCity($getBillingAddress->getCity())
825
+ ->setCountryId($getBillingAddress->getCountryId())
826
+ ->setRegionId($getBillingAddress->getRegionId())
827
+ ->setTelephone($getBillingAddress->getTelephone())
828
+ ->setFax($getBillingAddress->getFax())
829
+ ->setVatId($getBillingAddress->getVatId())
830
+ ->setPostcode($getBillingAddress->getPostcode());
831
+
832
+ if ($addressType == Mage_Sales_Model_Quote_Address::TYPE_BILLING) {
833
+ $orderNew->setBillingAddress($billingAddress);
834
+ } else {
835
+ $shippingMethod = $order->getShippingMethod();
836
+ $shippingDescription = $order->getShippingDescription();
837
+ $orderNew->setShippingAddress($billingAddress)
838
+ ->setShippingMethod($shippingMethod)
839
+ ->setShippingDescription($shippingDescription);
840
+ }
841
+
842
+ return $orderNew;
843
+ }
844
+
845
+ /**
846
+ * Set product informations (product, discount, tax, etc.,)
847
+ *
848
+ * @param Varien_Object $order
849
+ * @param Varien_Object $orderNew
850
+ * @return mixed
851
+ */
852
+ public function setOrderItemsDetails($order, $orderNew)
853
+ {
854
+ foreach ($order->getAllItems() as $orderValue) {
855
+ $orderItem = Mage::getModel('sales/order_item')
856
+ ->setStoreId($orderValue->getStoreId())
857
+ ->setQuoteItemId(0)
858
+ ->setQuoteParentItemId(null)
859
+ ->setQtyBackordered(null)
860
+ ->setQtyOrdered($orderValue->getQtyOrdered())
861
+ ->setName($orderValue->getName())
862
+ ->setIsVirtual($orderValue->getIsVirtual())
863
+ ->setProductId($orderValue->getProductId())
864
+ ->setProductType($orderValue->getProductType())
865
+ ->setSku($orderValue->getSku())
866
+ ->setWeight($orderValue->getWeight())
867
+ ->setPrice($orderValue->getPrice())
868
+ ->setBasePrice($orderValue->getBasePrice())
869
+ ->setOriginalPrice($orderValue->getOriginalPrice())
870
+ ->setTaxAmount($orderValue->getTaxAmount())
871
+ ->setTaxPercent($orderValue->getTaxPercent())
872
+ ->setIsNominal($orderValue->getIsNominal())
873
+ ->setRowTotal($orderValue->getRowTotal())
874
+ ->setBaseRowTotal($orderValue->getBaseRowTotal())
875
+ ->setBaseWeeeTaxAppliedAmount($orderValue->getBaseWeeeTaxAppliedAmount())
876
+ ->setWeeeTaxAppliedAmount($orderValue->getWeeeTaxAppliedAmount())
877
+ ->setWeeeTaxAppliedRowAmount($orderValue->getWeeeTaxAppliedRowAmount())
878
+ ->setWeeeTaxApplied($orderValue->getWeeeTaxApplied())
879
+ ->setWeeeTaxDisposition($orderValue->getWeeeTaxDisposition())
880
+ ->setWeeeTaxRowDisposition($orderValue->getWeeeTaxRowDisposition())
881
+ ->setBaseWeeeTaxDisposition($orderValue->getBaseWeeeTaxDisposition())
882
+ ->setBaseWeeeTaxRowDisposition($orderValue->getBaseWeeeTaxRowDisposition());
883
+ $orderNew->addItem($orderItem);
884
+ }
885
+
886
+ return $orderNew;
887
+ }
888
+
889
+ /**
890
+ * Insert the order id in recurring order table
891
+ *
892
+ * @param int $newOrderId
893
+ * @param int $profileId
894
+ * @return none
895
+ */
896
+ public function insertOrderId($newOrderId, $profileId)
897
+ {
898
+ if ($newOrderId && $profileId) {
899
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
900
+ $connection->beginTransaction();
901
+ $tablePrefix = Mage::getConfig()->getTablePrefix();
902
+ $orderTable = $tablePrefix . 'sales_recurring_profile_order';
903
+ $fields = array();
904
+ $fields['profile_id'] = $profileId;
905
+ $fields['order_id'] = $newOrderId;
906
+ $connection->insert($orderTable, $fields);
907
+ $connection->commit();
908
+ }
909
+ }
910
+
911
+ /**
912
+ * Update the product inventory (stock)
913
+ *
914
+ * @param Varien_Object $order
915
+ * @return none
916
+ */
917
+ public function updateInventory($order)
918
+ {
919
+ foreach ($order->getAllItems() as $orderValue) {
920
+ $itemsQtyOrdered = floor($orderValue->getQtyOrdered());
921
+ $productId = $orderValue->getProductId();
922
+ break;
923
+ }
924
+
925
+ if ($productId) {
926
+ $stockObj = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
927
+ $productQtyBefore = (int) $stockObj->getQty();
928
+ }
929
+
930
+ if (isset($productQtyBefore) && $productQtyBefore > 0) {
931
+ $productQtyAfter = (int) ($productQtyBefore - $itemsQtyOrdered);
932
+ $stockObj->setQty($productQtyAfter);
933
+ $stockObj->save();
934
+ }
935
+ }
936
+
937
+ /**
938
+ * Create invoice to order payment
939
+ *
940
+ * @param none
941
+ * @return boolean
942
+ */
943
+ protected function _saveInvoice()
944
+ {
945
+ $data = unserialize($this->payment->getAdditionalData());
946
+ $callbackModel = $this->helper->getModel('Mysql4_Callback')->loadLogByOrderId($this->orderNo);
947
+ $tidPayment = (!$this->recurring) ? $this->response->getTidPayment() : $this->response->getSignupTid();
948
+ $totalAmount = sprintf(($this->response->getAmount() + $callbackModel->getCallbackAmount()), 0.2);
949
+ $grandTotal = sprintf(($this->order->getGrandTotal() * 100), 0.2);
950
+ $amount = $this->helper->getFormatedAmount($this->response->getAmount(), 'RAW');
951
+
952
+ if (in_array($this->response->getPaymentType(), $this->invoiceAllowed) && $totalAmount < $grandTotal) {
953
+ $this->logCallbackInfo($callbackModel, $totalAmount, $this->orderNo); // Log callback data
954
+ $this->emailBody = "Novalnet Callback Script executed successfully for the TID: " . $tidPayment . " with amount " . $amount . " " . $this->currency . " on " . $this->currentTime . ". Please refer PAID transaction in our Novalnet Merchant Administration with the TID: " . $this->response->getTid() . "$this->lineBreak$this->lineBreak";
955
+ $script = "Novalnet Callback Script executed successfully for the TID: " . $tidPayment . " with amount " . $amount . " " . $this->currency . " on " . $this->currentTime . ". Please refer PAID transaction in our Novalnet Merchant Administration with the TID: " . $this->response->getTid() . $this->lineBreak;
956
+ $data['NnComments'] = empty($data['NnComments'])
957
+ ? '<br>' . $script
958
+ : $data['NnComments'] . '<br>' . $script;
959
+ $this->payment->setAdditionalData(serialize($data))->save();
960
+ return false;
961
+ } else {
962
+ $this->logCallbackInfo($callbackModel, $totalAmount, $this->orderNo); // Log callback data
963
+ if ($this->order->canInvoice()) {
964
+ $transactionId = $this->getParentTid(); // Get the original/parent transaction id
965
+ // Create order invoice
966
+ $this->createInvoice($this->order, $transactionId);
967
+
968
+ if (in_array($this->response->getPaymentType(), $this->invoiceAllowed)) {
969
+ $emailText = "Novalnet Callback Script executed successfully for the TID: " . $tidPayment . " with amount " . $amount . " ". $this->currency . " on " . $this->currentTime . ". Please refer PAID transaction in our Novalnet Merchant Administration with the TID: " . $this->response->getTid() . "$this->lineBreak$this->lineBreak";
970
+ $this->emailBody = ($totalAmount > $grandTotal)
971
+ ? $emailText . "Your paid amount is greater than the order total amount. $this->lineBreak"
972
+ : $emailText;
973
+ } else {
974
+ $this->emailBody = "Novalnet Callback Script executed successfully for the TID: " . $this->response->getTid() . " with amount " . $amount . " ". $this->currency . " on " . $this->currentTime . ". $this->lineBreak$this->lineBreak";
975
+ }
976
+ } else {
977
+ // Get order invoice collection
978
+ $invoice = $this->order->getInvoiceCollection()->getFirstItem();
979
+
980
+ if ($this->code == Novalnet_Payment_Model_Config::NN_INVOICE && $invoice->getState() == 1) {
981
+ $scriptText = 'Novalnet Callback Script executed successfully for the TID: ' . $tidPayment . ' with amount ' . $amount . ' ' . $this->currency . ' on ' . $this->currentTime . '. Please refer PAID transaction in our Novalnet Merchant Administration with the TID: ' . $this->response->getTid();
982
+ $this->emailBody = $script = ($totalAmount > $grandTotal)
983
+ ? $scriptText . '.Your paid amount is greater than the order total amount.' : $scriptText;
984
+ $data['NnComments'] = empty($data['NnComments']) ? '<br>' . $script : $data['NnComments'] . '<br>' . $script;
985
+ $this->payment->setAdditionalData(serialize($data))->save();
986
+ $this->saveOrderStatus();
987
+ $this->sendCallbackMail(); // Send callback notification E-mail
988
+ $this->showDebug($script);
989
+ }
990
+
991
+ $invoicePayments = array(Novalnet_Payment_Model_Config::NN_PREPAYMENT, Novalnet_Payment_Model_Config::NN_INVOICE);
992
+ if (in_array($this->code, $invoicePayments)) {
993
+ $this->showDebug("Novalnet callback received. Callback Script executed already. Refer Order :" . $this->orderNo);
994
+ } elseif ($this->code == Novalnet_Payment_Model_Config::NN_PAYPAL) {
995
+ $this->showDebug("Novalnet callback received. Order already paid.");
996
+ } else {
997
+ $this->showDebug("Novalnet Callbackscript received. Payment type ( " . $this->response->getPaymentType() . " ) is not applicable for this process!");
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ return true;
1003
+ }
1004
+
1005
+ /**
1006
+ * Save order status for invoice payment
1007
+ *
1008
+ * @param none
1009
+ * @return none
1010
+ */
1011
+ public function saveOrderStatus()
1012
+ {
1013
+ $orderStatus = $this->getOrderStatus(); // Get order status
1014
+ $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
1015
+ $message = 'Novalnet callback set state ' . $orderState . ' for Order-ID = ' . $this->orderNo;
1016
+ $this->order->setState($orderState, true, $message);
1017
+ $this->order->addStatusToHistory($orderStatus, 'Novalnet callback added order status ' . $orderStatus);
1018
+ $this->order->save();
1019
+
1020
+ $invoice = $this->order->getInvoiceCollection()->getFirstItem();
1021
+ $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
1022
+ $invoice->save();
1023
+ }
1024
+
1025
+ /**
1026
+ * Save order status invoice payment
1027
+ *
1028
+ * @param none
1029
+ * @return none
1030
+ */
1031
+ protected function _updateOrderStatus()
1032
+ {
1033
+ $orderStatus = $this->getOrderStatus(); // Get order status
1034
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
1035
+ $message = 'Novalnet callback set state ' . $state . ' for Order-ID = ' . $this->orderNo;
1036
+ $this->order->setState($state, true, $message);
1037
+ $this->order->addStatusToHistory($orderStatus, 'Novalnet callback added order status ' . $orderStatus);
1038
+ $this->emailBody .= 'Novalnet callback set state to ' . $state . $this->lineBreak;
1039
+ $this->emailBody .= 'Novalnet callback set status to ' . $orderStatus . ' ... ' . $this->lineBreak;
1040
+ $this->order->save();
1041
+
1042
+ if (in_array($this->response->getPaymentType(), $this->invoiceAllowed)) {
1043
+ $amount = $this->helper->getFormatedAmount($this->response->getAmount(), 'RAW');
1044
+ $script = 'Novalnet Callback Script executed successfully for the TID: ' . $this->response->getTidPayment() . ' with amount ' . $amount . ' ' . $this->currency . ' on ' . $this->currentTime . '. Please refer PAID transaction in our Novalnet Merchant Administration with the TID: ' . $this->response->getTid();
1045
+ } else {
1046
+ $script = 'Novalnet Callback Script executed successfully on ' . $this->currentTime;
1047
+ }
1048
+
1049
+ $data = unserialize($this->payment->getAdditionalData()); // Get payment additional information
1050
+ $data['NnComments'] = empty($data['NnComments']) ? '<br>' . $script : $data['NnComments'] . '<br>' . $script;
1051
+ $this->payment->setAdditionalData(serialize($data));
1052
+ $this->order->setPayment($this->payment)->save();
1053
+ }
1054
+
1055
+ /**
1056
+ * Log callback transaction information
1057
+ *
1058
+ * @param Novalnet_Payment_Model_Mysql4_Callback $callbackModel
1059
+ * @param float $amount
1060
+ * @param int $orderNo
1061
+ * @return none
1062
+ */
1063
+ public function logCallbackInfo($callbackModel, $amount, $orderNo)
1064
+ {
1065
+ $transactionId = $this->getParentTid(); // Get the original/parent transaction id
1066
+ $reqUrl = Mage::helper('core/http')->getRequestUri();
1067
+ $callbackModel->setOrderId($orderNo)
1068
+ ->setCallbackAmount($amount)
1069
+ ->setReferenceTid($this->response->getTid())
1070
+ ->setCallbackTid($transactionId)
1071
+ ->setCallbackDatetime($this->currentTime)
1072
+ ->setCallbackLog($reqUrl)
1073
+ ->save();
1074
+ }
1075
+
1076
+ /**
1077
+ * Get payment order status
1078
+ *
1079
+ * @param none
1080
+ * @return string
1081
+ */
1082
+ public function getOrderStatus()
1083
+ {
1084
+ $paymentObj = $this->payment->getMethodInstance(); // Payment method instance
1085
+ $status = $paymentObj->getConfigData('order_status', $this->storeId);
1086
+ $redirectPayments = Novalnet_Payment_Model_Config::getInstance()->getNovalnetVariable('redirectPayments');
1087
+ array_push($redirectPayments, Novalnet_Payment_Model_Config::NN_PREPAYMENT, Novalnet_Payment_Model_Config::NN_INVOICE);
1088
+
1089
+ // Redirect payment method order status
1090
+ if (($this->response->getTidStatus() == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED
1091
+ && $this->response->getPaymentType() != 'INVOICE_START'
1092
+ && in_array($this->code, $redirectPayments))
1093
+ || $this->code == Novalnet_Payment_Model_Config::NN_CC
1094
+ ) {
1095
+ $status = $paymentObj->getConfigData('order_status_after_payment', $this->storeId);
1096
+ }
1097
+
1098
+ // PayPal payment pending order status
1099
+ if ($this->code == Novalnet_Payment_Model_Config::NN_PAYPAL
1100
+ && ($this->response->getTidStatus() == Novalnet_Payment_Model_Config::PAYPAL_PENDING_CODE)
1101
+ ) {
1102
+ $status = $paymentObj->getConfigData('order_status', $this->storeId)
1103
+ ? $paymentObj->getConfigData('order_status', $this->storeId)
1104
+ : Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
1105
+ }
1106
+
1107
+ return !empty($status) ? $status : Mage_Sales_Model_Order::STATE_PROCESSING;;
1108
+ }
1109
+
1110
+ /**
1111
+ * Log Novalnet callback response data
1112
+ *
1113
+ * @param none
1114
+ * @return none
1115
+ */
1116
+ public function savePayportResponse()
1117
+ {
1118
+ $transactionTraces = $this->helper->getModel('Mysql4_TransactionTraces')
1119
+ ->loadByAttribute('order_id', $this->orderNo); // Get Novalnet transaction traces model
1120
+ $transactionTraces->setTransactionId($this->response->getTid())
1121
+ ->setResponseData(base64_encode(serialize($this->response->getData())))
1122
+ ->setCustomerId($this->order->getCustomerId())
1123
+ ->setStatus($this->response->getTidStatus())
1124
+ ->setStoreId($this->storeId)
1125
+ ->setShopUrl($this->response->getSystemUrl() ? $this->response->getSystemUrl() : '')
1126
+ ->save();
1127
+ }
1128
+
1129
+ /**
1130
+ * Get Novalnet global configuration values
1131
+ *
1132
+ * @param string $field
1133
+ * @return mixed
1134
+ */
1135
+ protected function _getConfig($field)
1136
+ {
1137
+ $path = 'novalnet_global/novalnet/' . $field; // Global config value path
1138
+
1139
+ if ($field == 'live_mode') { // Novalnet payment mode
1140
+ $paymentMethod = Mage::getStoreConfig($path, $this->storeId);
1141
+ return preg_match('/' . $this->code . '/i', $paymentMethod) ? true : false;
1142
+ } elseif ($field !== null) { // Get Novalnet payment/global configuration
1143
+ return Mage::getStoreConfig($path, $this->storeId);
1144
+ }
1145
+
1146
+ return null;
1147
+ }
1148
+
1149
+ /*
1150
+ * Assign callback process level
1151
+ *
1152
+ * @param none
1153
+ * @return int
1154
+ */
1155
+ public function getCallbackProcessLevel()
1156
+ {
1157
+ if ($this->response->getPaymentType()) {
1158
+ // Assign callback process flag
1159
+ if (in_array($this->response->getPaymentType(), $this->recurringAllowed)
1160
+ && ($this->response->getSignupTid() || $this->response->getSubsBilling())
1161
+ ) {
1162
+ $this->recurring = true;
1163
+ } else {
1164
+ $this->callback = true;
1165
+ }
1166
+ // Assign callback process level
1167
+ if (in_array($this->response->getPaymentType(), $this->paymentTypes)) {
1168
+ return 0;
1169
+ } else if (in_array($this->response->getPaymentType(), $this->chargebacks)) {
1170
+ return 1;
1171
+ } else if (in_array($this->response->getPaymentType(), $this->aryCollection)) {
1172
+ return 2;
1173
+ }
1174
+ } else {
1175
+ $this->showDebug("Required param (payment_type) missing!");
1176
+ }
1177
+ }
1178
+
1179
+ /**
1180
+ * Get order increment id
1181
+ *
1182
+ * @param none
1183
+ * @return int $orderNo
1184
+ */
1185
+ public function getOrderIncrementId()
1186
+ {
1187
+ if ($this->recurring) { // Get recurring profile increment id
1188
+ $orderNo = $this->getRecurringOrderId();
1189
+ } else { // Get order increment id
1190
+ $orderNo = $this->response->getOrderNo() ? $this->response->getOrderNo()
1191
+ : ($this->response->getOrderId() ? $this->response->getOrderId() : '');
1192
+ $orderNo = $orderNo ? $orderNo : $this->getOrderIdByTransId();
1193
+ }
1194
+
1195
+ return !empty($orderNo) ? $orderNo : $this->showDebug("Required (Transaction ID) not Found!");
1196
+ }
1197
+
1198
+ /**
1199
+ * Get increment id based on payment last transaction id
1200
+ *
1201
+ * @param none
1202
+ * @return int
1203
+ */
1204
+ public function getOrderIdByTransId()
1205
+ {
1206
+ $parentTid = $this->getParentTid(); // Get the original/parent transaction id
1207
+
1208
+ if (empty($parentTid)) { // Check whether the original/parent transaction id exists
1209
+ return false;
1210
+ }
1211
+
1212
+ $tablePrefix = Mage::getConfig()->getTablePrefix();
1213
+ if (in_array($this->response->getPaymentType(), $this->chargebacks)) {
1214
+ $orderPayment = $tablePrefix . 'sales_payment_transaction';
1215
+ $onCondition = "main_table.entity_id = $orderPayment.order_id";
1216
+ $orderCollection = Mage::getModel('sales/order')->getCollection()
1217
+ ->addFieldToFilter('txn_id', array('like' => "%$parentTid%"))
1218
+ ->addFieldToSelect('increment_id');
1219
+ } else {
1220
+ $orderPayment = $tablePrefix . 'sales_flat_order_payment';
1221
+ $onCondition = "main_table.entity_id = $orderPayment.parent_id";
1222
+ $orderCollection = Mage::getModel('sales/order')->getCollection()
1223
+ ->addFieldToFilter('last_trans_id', array('like' => "%$parentTid%"))
1224
+ ->addFieldToSelect('increment_id');
1225
+ }
1226
+ // Get order collection
1227
+ $orderCollection->getSelect()->join($orderPayment, $onCondition);
1228
+ $count = $orderCollection->count();
1229
+ $orderId = '';
1230
+
1231
+ if ($count > 0) {
1232
+ foreach ($orderCollection as $order) {
1233
+ $orderId = $order->getIncrementId();
1234
+ }
1235
+ }
1236
+
1237
+ return $orderId;
1238
+ }
1239
+
1240
+ /**
1241
+ * Get subscription payment increment id
1242
+ *
1243
+ * @param none
1244
+ * @return int $orderNo
1245
+ */
1246
+ public function getRecurringOrderId()
1247
+ {
1248
+ $orderNo = '';
1249
+ $profile = $this->getProfileInformation(); // Get the Recurring Profile Information
1250
+ $profileCollection = Mage::getResourceModel('sales/order_grid_collection')
1251
+ ->addRecurringProfilesFilter($profile->getId());
1252
+ foreach ($profileCollection as $profileValue) {
1253
+ $orderNo = $profileValue->getIncrementId();
1254
+ }
1255
+ return $orderNo;
1256
+ }
1257
+
1258
+ /**
1259
+ * Get the Recurring Profile Information
1260
+ *
1261
+ * @param none
1262
+ * @return Varien_Object $profile
1263
+ */
1264
+ public function getProfileInformation()
1265
+ {
1266
+ // Get the original/parent transaction id
1267
+ $tid = ($this->response->getSignupTid()) ? $this->response->getSignupTid() : $this->response->getTidPayment();
1268
+ $profile = Mage::getModel('sales/recurring_profile')->load($tid, 'reference_id');
1269
+ return $profile;
1270
+ }
1271
+
1272
+ /**
1273
+ * Get transaction id based on payment type
1274
+ *
1275
+ * @param none
1276
+ * @return int $tid
1277
+ */
1278
+ public function getParentTid()
1279
+ {
1280
+ // Get the original/parent transaction id
1281
+ if ($this->response->getSignupTid()) {
1282
+ $tid = trim($this->response->getSignupTid());
1283
+ } elseif (($this->response->getPaymentType() == 'INVOICE_CREDIT')
1284
+ || (in_array($this->response->getPaymentType(), $this->chargebacks))
1285
+ ) {
1286
+ $tid = $this->response->getTidPayment();
1287
+ } else {
1288
+ $tid = $this->response->getTid();
1289
+ }
1290
+
1291
+ return $tid;
1292
+ }
1293
+
1294
+ /**
1295
+ * Check whether the ip address is authorised
1296
+ *
1297
+ * @param none
1298
+ * @return boolean
1299
+ */
1300
+ public function checkIP()
1301
+ {
1302
+ $callerIp = $this->helper->getRealIpAddr();
1303
+
1304
+ if (!in_array($callerIp, $this->ipAllowed) && !$this->test) {
1305
+ $message = 'Novalnet callback received. Unauthorised access from the IP [' . $callerIp . ']';
1306
+ $this->showDebug($message, true, true);
1307
+ }
1308
+
1309
+ return true;
1310
+ }
1311
+
1312
+ /**
1313
+ * Show callback process transaction comments
1314
+ *
1315
+ * @param string $text
1316
+ * @param boolean $die
1317
+ * @param boolean $forceDisplay
1318
+ * @return none
1319
+ */
1320
+ public function showDebug($text, $die = true, $forceDisplay = false)
1321
+ {
1322
+ if (!empty($text) && ($forceDisplay || $this->debug == true)) {
1323
+ echo $text;
1324
+ }
1325
+ if ($die) {
1326
+ die;
1327
+ }
1328
+ }
1329
+
1330
+ /**
1331
+ * Send callback notification E-mail
1332
+ *
1333
+ * @param none
1334
+ * @return boolean
1335
+ */
1336
+ public function sendCallbackMail()
1337
+ {
1338
+ $this->getEmailConfig(); // Get email configuration settings
1339
+
1340
+ if ($this->emailBody && $this->emailFromAddr && $this->emailToAddr) {
1341
+ if (!$this->sendMail()) {
1342
+ $this->showDebug("Mailing failed!".$this->lineBreak, false);
1343
+ $this->showDebug("This mail text should be sent: ", false);
1344
+ }
1345
+ }
1346
+
1347
+ if ($this->emailBody) {
1348
+ $this->showDebug($this->emailBody);
1349
+ }
1350
+ }
1351
+
1352
+ /**
1353
+ * Send callback notification E-mail
1354
+ *
1355
+ * @param none
1356
+ * @return boolean
1357
+ */
1358
+ public function sendMail()
1359
+ {
1360
+ if ($this->mailHost && $this->mailPort) {
1361
+ ini_set('SMTP', $this->mailHost);
1362
+ ini_set('smtp_port', $this->mailPort);
1363
+ }
1364
+
1365
+ if ($this->emailSendOption && $this->useEmailOption == 1) {
1366
+ if (!$this->sendEmailZend()) {
1367
+ return false;
1368
+ }
1369
+ } elseif ($this->emailSendOption && $this->useEmailOption == 2) {
1370
+ if (!$this->sendEmailMagento()) {
1371
+ return false;
1372
+ }
1373
+ }
1374
+
1375
+ return true;
1376
+ }
1377
+
1378
+ /**
1379
+ * Send callback notification E-mail (with callback template)
1380
+ *
1381
+ * @param none
1382
+ * @return boolean
1383
+ */
1384
+ public function sendEmailMagento()
1385
+ {
1386
+ /*
1387
+ * Loads the html file named 'novalnet_callback_email.html' from
1388
+ * E.G: app/locale/en_US/template/email/novalnet/novalnet_callback_email.html
1389
+ * OR: app/locale/YourLanguage/template/email/novalnet/novalnet_callback_email.html
1390
+ * Adapt the corresponding template if necessary
1391
+ */
1392
+ $emailTemplate = Mage::getModel('core/email_template')
1393
+ ->loadDefault('novalnet_callback_email_template');
1394
+
1395
+ // Define some variables to assign to template
1396
+ $templateParams = array();
1397
+ $templateParams['fromName'] = $this->emailFromName;
1398
+ $templateParams['fromEmail'] = $this->emailFromAddr;
1399
+ $templateParams['toName'] = $this->emailToName;
1400
+ $templateParams['toEmail'] = $this->emailToAddr;
1401
+ $templateParams['subject'] = $this->emailSubject;
1402
+ $templateParams['body'] = $this->emailBody;
1403
+ $template = $emailTemplate->getProcessedTemplate($templateParams);
1404
+
1405
+ $mail = new Zend_Mail();
1406
+ $mail->setBodyHtml($template);
1407
+ $mail->setFrom($this->emailFromAddr, $this->emailFromName);
1408
+ $this->assignEmailAddress($this->emailToAddr, $mail, 'To');
1409
+ $this->assignEmailAddress($this->emailBCcAddr, $mail, 'Bcc');
1410
+ $mail->setSubject($this->emailSubject);
1411
+
1412
+ try {
1413
+ $mail->send();
1414
+ $this->showDebug(__FUNCTION__ . ': Sending Email succeeded!'.$this->lineBreak, false);
1415
+ } catch (Exception $e) {
1416
+ Mage::getSingleton('core/session')->addError($this->helper()->__('Unable to send email'));
1417
+ $this->showDebug('Email sending failed: ', false);
1418
+ return false;
1419
+ }
1420
+ return true;
1421
+ }
1422
+
1423
+ /**
1424
+ * Send callback notification E-mail via zend
1425
+ *
1426
+ * @param none
1427
+ * @return boolean
1428
+ */
1429
+ public function sendEmailZend()
1430
+ {
1431
+ $mail = new Zend_Mail();
1432
+ $mail->setBodyHtml($this->emailBody);
1433
+ $mail->setFrom($this->emailFromAddr, $this->emailFromName);
1434
+ $this->assignEmailAddress($this->emailToAddr, $mail, 'To');
1435
+ $this->assignEmailAddress($this->emailBCcAddr, $mail, 'Bcc');
1436
+ $mail->setSubject($this->emailSubject);
1437
+
1438
+ try {
1439
+ $mail->send();
1440
+ $this->showDebug(__FUNCTION__ . ': Sending Email succeeded!'.$this->lineBreak, false);
1441
+ } catch (Exception $e) {
1442
+ $this->showDebug('Email sending failed: ', false);
1443
+ return false;
1444
+ }
1445
+ return true;
1446
+ }
1447
+
1448
+ /**
1449
+ * Assign E-mail (TO and Bcc) address
1450
+ *
1451
+ * @param string $emailaddr
1452
+ * @param mixed $mail
1453
+ * @param string $addr
1454
+ * @return string
1455
+ */
1456
+ public function assignEmailAddress($emailaddr, $mail, $addr)
1457
+ {
1458
+ $email = explode(',', $emailaddr);
1459
+ $emailValidator = new Zend_Validate_EmailAddress();
1460
+
1461
+ foreach ($email as $emailAddrVal) {
1462
+ if ($emailValidator->isValid(trim($emailAddrVal))) {
1463
+ ($addr == 'To') ? $mail->addTo($emailAddrVal) : $mail->addBcc($emailAddrVal);
1464
+ }
1465
+ }
1466
+ return $mail;
1467
+ }
1468
+
1469
+ /**
1470
+ * Set recurring profile state
1471
+ *
1472
+ * @param string|null $state
1473
+ * @return none
1474
+ */
1475
+ public function setRecurringProfileState($state = 'Active')
1476
+ {
1477
+ $profileId = $this->response->hasProfileId() ? $this->response->getProfileId()
1478
+ : ($this->response->hasInput4() && $this->response->getInput4() == 'profile_id'
1479
+ ? $this->response->getInputval4() : '');
1480
+ if ($profileId) {
1481
+ $profile = Mage::getModel('sales/recurring_profile')->load($profileId, 'profile_id');
1482
+
1483
+ if ($state == 'Active') {
1484
+ $status = $this->response->getTidStatus();
1485
+ $message = $this->helper->getModel('Recurring_Payment')->createIpnComment($status, $this->order);
1486
+ $this->payment->setPreparedMessage($message)
1487
+ ->setAdditionalInformation('subs_id', $this->response->getSubsId())->save();
1488
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE); //Set profile status as active
1489
+ } else {
1490
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED); //Set profile status as canceled
1491
+ }
1492
+
1493
+ $profile->setReferenceId($this->response->getTid())->save();
1494
+ }
1495
+ }
1496
+
1497
+ }
app/code/community/Novalnet/Payment/controllers/CcController.php CHANGED
@@ -1,103 +1,86 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * Part of the Paymentmodule of Novalnet AG
16
- * https://www.novalnet.de
17
- * If you have found this script usefull a small
18
- * recommendation as well as a comment on merchant form
19
- * would be greatly appreciated.
20
- *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Novalnet AG
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- class Novalnet_Payment_CcController extends Mage_Core_Controller_Front_Action
27
- {
28
-
29
- /**
30
- * Get Credit Card iframe
31
- *
32
- * @param none
33
- * @return none
34
- */
35
- public function indexAction()
36
- {
37
- // Loading current layout
38
- $this->loadLayout();
39
-
40
- // Creating a new block
41
- $block = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'CcForm', array(
42
- 'template' => 'novalnet/payment/method/form/Cciframe.phtml'));
43
- $this->getLayout()->getBlock('content')->append($block);
44
-
45
- // Set on-hold status
46
- $helper = $this->_getHelper();
47
- $order = $this->_getOrder();
48
- $payment = $order->getPayment();
49
- $paymentObj = $payment->getMethodInstance();
50
- $authorizeKey = $paymentObj->loadAffAccDetail();
51
- $paymentRequest = $helper->getCheckoutSession()->getPaymentReqData();
52
-
53
- if(!$payment->getLastTransId()) {
54
- // Get Vendor configuration values from payport request
55
- $authCode = $helper->getDecodedParam($paymentRequest->getVendorAuthcode(), $authorizeKey);
56
- $productId = $helper->getDecodedParam($paymentRequest->getProductId(), $authorizeKey);
57
- $tariffId = $helper->getDecodedParam($paymentRequest->getTariffId(), $authorizeKey);
58
-
59
- // Payment additional data
60
- $data = array('vendor' => $paymentRequest->getVendorId(),
61
- 'auth_code' => $authCode,
62
- 'product' => $productId,
63
- 'tariff' => $tariffId,
64
- 'key' => $paymentRequest->getKey(),
65
- 'authorize_key' => $authorizeKey
66
- );
67
-
68
- $payment->setAdditionalData(serialize($data))->save();
69
- $status = $state = Mage_Sales_Model_Order::STATE_HOLDED; //set State,Status to HOLD
70
- $order->setState($state, $status, $helper->__('Customer was redirected to Novalnet'), false)->save();
71
- $helper->getCheckoutSession()->unsRecurringProfileNumber(); //unset recurring profile data
72
-
73
- //Now showing it with rendering of layout
74
- $this->renderLayout();
75
- } else {
76
- $this->_redirect('checkout/cart');
77
- }
78
- }
79
-
80
- /**
81
- * Get Last placed order object
82
- *
83
- * @param none
84
- * @return Varien_Object
85
- */
86
- private function _getOrder()
87
- {
88
- $incrementId = $this->_getHelper()->getCheckoutSession()->getLastRealOrderId();
89
- return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
90
- }
91
-
92
- /**
93
- * Get Novalnet payment helper
94
- *
95
- * @param none
96
- * @return Novalnet_Payment_Helper_Data
97
- */
98
- private function _getHelper()
99
- {
100
- return Mage::helper('novalnet_payment');
101
- }
102
-
103
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * Part of the Paymentmodule of Novalnet AG
16
+ * https://www.novalnet.de
17
+ * If you have found this script usefull a small
18
+ * recommendation as well as a comment on merchant form
19
+ * would be greatly appreciated.
20
+ *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Novalnet AG
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Novalnet_Payment_CcController extends Mage_Core_Controller_Front_Action
27
+ {
28
+
29
+ /**
30
+ * Get Credit Card iframe
31
+ *
32
+ * @param none
33
+ * @return none
34
+ */
35
+ public function indexAction()
36
+ {
37
+ // Loading current layout
38
+ $this->loadLayout();
39
+
40
+ $order = $this->_getOrder();
41
+ $payment = $order->getPayment(); // Get payment object
42
+
43
+ if (!$payment->getLastTransId()) {
44
+ // Creating a new block
45
+ $block = $this->getLayout()->createBlock(
46
+ 'Mage_Core_Block_Template', 'CcForm', array(
47
+ 'template' => 'novalnet/method/form/Cciframe.phtml')
48
+ );
49
+ $this->getLayout()->getBlock('content')->append($block);
50
+
51
+ // Set on-hold status
52
+ $status = $state = Mage_Sales_Model_Order::STATE_HOLDED; //set State,Status to HOLD
53
+ $message = $this->_getHelper()->__('Customer was redirected to Novalnet');
54
+ $order->setState($state, $status, $message, false)->save();
55
+
56
+ //Now showing it with rendering of layout
57
+ $this->renderLayout();
58
+ } else {
59
+ $this->_redirect('checkout/cart');
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Get Last placed order object
65
+ *
66
+ * @param none
67
+ * @return Varien_Object
68
+ */
69
+ protected function _getOrder()
70
+ {
71
+ $incrementId = $this->_getHelper()->getCheckoutSession()->getLastRealOrderId();
72
+ return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
73
+ }
74
+
75
+ /**
76
+ * Get Novalnet payment helper
77
+ *
78
+ * @param none
79
+ * @return Novalnet_Payment_Helper_Data
80
+ */
81
+ protected function _getHelper()
82
+ {
83
+ return Mage::helper('novalnet_payment');
84
+ }
85
+
86
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Novalnet/Payment/controllers/Checkout/OnepageController.php CHANGED
@@ -18,12 +18,13 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  require_once 'Mage/Checkout/controllers/OnepageController.php';
 
27
  class Novalnet_Payment_Checkout_OnepageController extends Mage_Checkout_OnepageController
28
  {
29
 
@@ -34,9 +35,11 @@ class Novalnet_Payment_Checkout_OnepageController extends Mage_Checkout_OnepageC
34
  {
35
  $magentoVersion = Mage::helper("novalnet_payment")->getMagentoVersion();
36
  $quote = Mage::getModel('checkout/cart')->getQuote();
 
37
 
38
- if (!$quote->hasNominalItems() || version_compare($magentoVersion, '1.7', '>=')
39
- || version_compare($magentoVersion, '1.5', '<')) {
 
40
  return parent::saveOrderAction();
41
  }
42
 
@@ -46,9 +49,11 @@ class Novalnet_Payment_Checkout_OnepageController extends Mage_Checkout_OnepageC
46
 
47
  $result = array();
48
  try {
49
- if ($requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds()) {
 
50
  $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
51
- if ($diff = array_diff($requiredAgreements, $postedAgreements)) {
 
52
  $result['success'] = false;
53
  $result['error'] = true;
54
  $result['error_messages'] = $this->__('Please agree to all the terms and conditions before placing the order.');
@@ -56,9 +61,11 @@ class Novalnet_Payment_Checkout_OnepageController extends Mage_Checkout_OnepageC
56
  return;
57
  }
58
  }
 
59
  if ($data = $this->getRequest()->getPost('payment', false)) {
60
  $this->getOnepage()->getQuote()->getPayment()->importData($data);
61
  }
 
62
  $this->getOnepage()->saveOrder();
63
 
64
  $redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
@@ -66,7 +73,7 @@ class Novalnet_Payment_Checkout_OnepageController extends Mage_Checkout_OnepageC
66
  $result['error'] = false;
67
  } catch (Mage_Payment_Model_Info_Exception $e) {
68
  $message = $e->getMessage();
69
- if( !empty($message) ) {
70
  $result['error_messages'] = $message;
71
  }
72
  $result['goto_section'] = 'payment';
@@ -81,12 +88,13 @@ class Novalnet_Payment_Checkout_OnepageController extends Mage_Checkout_OnepageC
81
  $result['error'] = true;
82
  $result['error_messages'] = $e->getMessage();
83
 
84
- if ($gotoSection = $this->getOnepage()->getCheckout()->getGotoSection()) {
 
85
  $result['goto_section'] = $gotoSection;
86
  $this->getOnepage()->getCheckout()->setGotoSection(null);
87
  }
88
-
89
- if ($updateSection = $this->getOnepage()->getCheckout()->getUpdateSection()) {
90
  if (isset($this->_sectionUpdateFunctions[$updateSection])) {
91
  $updateSectionFunction = $this->_sectionUpdateFunctions[$updateSection];
92
  $result['update_section'] = array(
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  require_once 'Mage/Checkout/controllers/OnepageController.php';
27
+
28
  class Novalnet_Payment_Checkout_OnepageController extends Mage_Checkout_OnepageController
29
  {
30
 
35
  {
36
  $magentoVersion = Mage::helper("novalnet_payment")->getMagentoVersion();
37
  $quote = Mage::getModel('checkout/cart')->getQuote();
38
+ $paymentCode = $quote->getPayment()->getMethodInstance()->getCode();
39
 
40
+ if (!preg_match("/novalnet/i", $paymentCode) || !$quote->hasNominalItems()
41
+ || version_compare($magentoVersion, '1.7', '>=') || version_compare($magentoVersion, '1.5', '<')
42
+ ) {
43
  return parent::saveOrderAction();
44
  }
45
 
49
 
50
  $result = array();
51
  try {
52
+ $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
53
+ if ($requiredAgreements) {
54
  $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
55
+ $diff = array_diff($requiredAgreements, $postedAgreements);
56
+ if ($diff) {
57
  $result['success'] = false;
58
  $result['error'] = true;
59
  $result['error_messages'] = $this->__('Please agree to all the terms and conditions before placing the order.');
61
  return;
62
  }
63
  }
64
+
65
  if ($data = $this->getRequest()->getPost('payment', false)) {
66
  $this->getOnepage()->getQuote()->getPayment()->importData($data);
67
  }
68
+
69
  $this->getOnepage()->saveOrder();
70
 
71
  $redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
73
  $result['error'] = false;
74
  } catch (Mage_Payment_Model_Info_Exception $e) {
75
  $message = $e->getMessage();
76
+ if (!empty($message)) {
77
  $result['error_messages'] = $message;
78
  }
79
  $result['goto_section'] = 'payment';
88
  $result['error'] = true;
89
  $result['error_messages'] = $e->getMessage();
90
 
91
+ $gotoSection = $this->getOnepage()->getCheckout()->getGotoSection();
92
+ if ($gotoSection) {
93
  $result['goto_section'] = $gotoSection;
94
  $this->getOnepage()->getCheckout()->setGotoSection(null);
95
  }
96
+ $updateSection = $this->getOnepage()->getCheckout()->getUpdateSection();
97
+ if ($updateSection) {
98
  if (isset($this->_sectionUpdateFunctions[$updateSection])) {
99
  $updateSectionFunction = $this->_sectionUpdateFunctions[$updateSection];
100
  $result['update_section'] = array(
app/code/community/Novalnet/Payment/controllers/GatewayController.php CHANGED
@@ -18,464 +18,185 @@
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
- * @category Novalnet
22
- * @package Novalnet_Payment
23
- * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_GatewayController extends Mage_Core_Controller_Front_Action
27
  {
28
  /**
29
- * Redirection process
30
  *
 
 
31
  */
32
  public function redirectAction()
33
  {
 
 
 
34
  try {
35
- $session = $this->_getCheckout();
36
- $order = $this->_getOrder();
37
- $payment = $order->getPayment();
38
- $paymentObj = $payment->getMethodInstance();
39
  $quoteId = $session->getQuoteId() ? $session->getQuoteId() : $session->getLastQuoteId();
40
  $items = Mage::getModel('sales/quote')->load($quoteId)->getItemsQty();
41
  $session->getQuote()->setIsActive(true)->save();
42
  $redirectActionFlag = $paymentObj->getCode() . '_redirectAction';
43
 
44
  if ($payment->getAdditionalInformation($redirectActionFlag) != 1
45
- && $session->getLastRealOrderId() && $items) {
 
46
  $payment->setAdditionalInformation($redirectActionFlag, 1);
47
- $status = $state = Mage_Sales_Model_Order::STATE_HOLDED; //set State,Status to HOLD
48
- $order->setState($state, $status, $this->_getNovalnetHelper()->__('Customer was redirected to Novalnet'), false)->save();
 
49
  $this->getResponse()->setBody(
50
- $this->getLayout()
51
- ->createBlock(Novalnet_Payment_Model_Config::NOVALNET_REDIRECT_BLOCK)
52
- ->setOrder($order)
53
- ->toHtml()
54
  );
55
  } else {
56
  $this->_redirect('checkout/cart');
57
  }
58
  } catch (Mage_Core_Exception $e) {
59
- $this->_getCheckout()->addError($e->getMessage());
60
  } catch (Exception $e) {
61
  Mage::logException($e);
62
  }
63
  }
64
 
65
  /**
66
- * When Novalnet returns after successful payment
67
  *
68
- * The order information at this point is in POST
 
69
  */
70
  public function returnAction()
71
  {
72
- $session = $this->_getCheckout();
73
- $response = $this->getRequest()->getParams();
74
- $this->doTransactionOrderLog($response);
75
- $status = $this->_checkReturnedData();
76
- $session->getQuote()->setIsActive(false)->save();
77
- $this->_redirect((!$response['order_no'] || !$status) ? 'checkout/onepage/failure' : 'checkout/onepage/success' );
 
 
 
 
 
 
 
78
  }
79
 
80
  /**
81
- * When Customer cancelled/error in the payment
82
  *
83
- * Redirects to failure page.
 
84
  */
85
  public function errorAction()
86
  {
87
- $order = $this->_getOrder();
88
- $session = $this->_getCheckout();
89
- $payment = $order->getPayment();
90
- $helper = $this->_getNovalnetHelper();
91
- $paymentObj = $payment->getMethodInstance();
92
-
93
- $paymentObj->unsetFormMethodSession();
94
- $session->getQuote()->setIsActive(false)->save();
95
- $response = $this->getRequest()->getParams();
96
- $this->doTransactionOrderLog($response); // Save return error response
97
- //Unhold an order:-
98
- if ($order->canUnhold()) {
99
- $order->unhold()->save();
100
- }
101
-
102
- //Cancel the order:-
103
- $errorActionFlag = $paymentObj->getCode() . '_errorAction';
104
- if ($payment->getAdditionalInformation($errorActionFlag)
105
- != 1) {
106
- $payment->setAdditionalInformation($errorActionFlag, 1);
107
- $dataObj = new Varien_Object($response);
108
- $paymentObj->saveCancelledOrder($dataObj, $payment);
109
- $profileId = (!empty($response['profile_id'])
110
- ? $response['profile_id']
111
- : ((!empty($response['input5']) && $response['input5'] == 'profile_id') ? $response['inputval5'] : ''));
112
- if ($profileId) {
113
- $recurringProfile = $this->loadRecurringProfile($profileId);
114
- $recurringProfile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED)
115
- ->setReferenceId($dataObj->getTid())
116
- ->save();
117
- $this->unsetRecurringData(); //unset recurring order id and profile id
118
- $this->_getCheckout()->setLastOrderId($order->getId());
119
- }
120
- $statusMessage = $dataObj->getStatusMessage() ? $dataObj->getStatusMessage()
121
- : ($dataObj->getStatusDesc() ? $dataObj->getStatusDesc() : ($dataObj->getStatusText()
122
- ? $dataObj->getStatusText() : $helper->__('Payment was not successfull')));
123
- $helper->getCoresession()->addError($statusMessage);
124
- }
125
-
126
- $this->_redirect('checkout/onepage/failure', array('_secure' => true));
127
  }
128
 
129
  /**
130
- * Receive server response for Novalnet direct payment methods.
131
  *
132
- * Redirects to success or failure page.
 
133
  */
134
  public function paymentAction()
135
  {
136
- $order = $this->_getOrder();
137
- $payment = $order->getPayment();
138
- $paymentObj = $payment->getMethodInstance();
139
- $paymentActionFlag = $paymentObj->getCode() . '_paymentAction';
140
-
141
- if ($payment->getAdditionalInformation($paymentActionFlag)
142
- != 1) {
143
- $payment->setAdditionalInformation($paymentActionFlag, 1);
144
- $session = $this->_getCheckout();
145
-
146
- if (!$paymentObj->isCallbackTypeCall()) {
147
- $request = $session->getPaymentReqData();
148
- $response = $paymentObj->postRequest($request);
149
- $error = $paymentObj->validateNovalnetResponse($payment, $response);
 
150
  } else {
151
- $error = $paymentObj->validateNovalnetResponse($payment, $session->getPaymentResData());
152
  }
153
 
154
- //sendNewOrderEmail
155
- if (!$order->getEmailSent() && $order->getId() && $error == false) {
156
- try {
157
- $order->sendNewOrderEmail()
158
- ->setEmailSent(true)
159
- ->save();
160
- } catch (Exception $e) {
161
- Mage::throwException($this->_getNovalnetHelper()->__('Cannot send new order email.'));
162
- }
163
  }
164
- // unset form payment method session
165
- $paymentObj->unsetFormMethodSession();
166
- // unset payment request and response values
167
- $paymentObj->unsetPaymentReqResData();
168
- $actionUrl = $error !== false ? 'checkout/onepage/failure' : 'checkout/onepage/success';
169
  } else {
170
  $actionUrl = 'checkout/cart';
171
  }
172
 
173
- $this->_redirect($actionUrl);
174
  }
175
 
176
  /**
177
- * Checking Post variables.
178
- *
179
- * @return boolean
180
- */
181
- protected function _checkReturnedData()
182
- {
183
- try {
184
- $status = false;
185
- if (!$this->getRequest()->isPost()) {
186
- $this->norouteAction();
187
- return false;
188
- }
189
-
190
- $order = $this->_getOrder();
191
- $payment = $order->getPayment();
192
- $paymentObj = $payment->getMethodInstance();
193
- $this->_getCheckout()->getQuote()->setIsActive(true)->save();
194
- //Get response
195
- $response = $this->getRequest()->getParams();
196
- $dataObj = new Varien_Object($response);
197
- $helper = $this->_getNovalnetHelper();
198
-
199
- //Unhold an order:-
200
- if ($order->canUnhold()) {
201
- $order->unhold()->save();
202
- }
203
-
204
- $data = unserialize($payment->getAdditionalData());
205
- $authorizeKey = $data['authorize_key'];
206
- // unset payment method session
207
- $paymentObj->unsetFormMethodSession();
208
-
209
- // check response status
210
- $response = $this->responseStatus($authorizeKey,$response,$paymentObj);
211
- $checkHash = $helper->checkHash($response, $authorizeKey, $response['implementation']);
212
- if (!$checkHash) {
213
- $response['status_text'] = $helper->__('checkHash failed');
214
- $dataObj = new Varien_Object($response);
215
- $paymentObj->saveCancelledOrder($dataObj, $payment);
216
- $helper->getCoresession()->addError($helper->__('checkHash failed'));
217
- return false;
218
- }
219
-
220
- $profileId = (!empty($response['profile_id'])
221
- ? $response['profile_id']
222
- : ((!empty($response['input5']) && $response['input5'] == 'profile_id') ? $response['inputval5'] : ''));
223
- if ($profileId) {
224
- $recurringProfile = $this->loadRecurringProfile($profileId);
225
- }
226
-
227
- //success
228
- if (($paymentObj->getCode() == Novalnet_Payment_Model_Config::NN_PAYPAL
229
- && $response['status'] == Novalnet_Payment_Model_Config::PAYPAL_PENDING_CODE)
230
- || $response['status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
231
- //set Novalnet Mode
232
- $testMode = $this->setNovalnetMode($paymentObj,$response,$authorizeKey);
233
- $data['NnTestOrder'] = $testMode;
234
- $data['NnTid'] = $response['tid'];
235
- if (!empty($profileId)) {
236
- $recurringProfile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE)
237
- ->setReferenceId($response['tid'])
238
- ->save();
239
-
240
- $recurringAmount = round(($recurringProfile->getBillingAmount() + $recurringProfile->getShippingAmount() + $recurringProfile->getTaxAmount()), 2);
241
- $payment->registerCaptureNotification($recurringAmount, 0);
242
- $IpnComment = $helper->__('IPN "%s".', $response['status']);
243
- $payment->setPreparedMessage($IpnComment)
244
- ->setAdditionalInformation('subs_id', $response['subs_id']);
245
- $data['paidUntil'] = !empty($response['next_subs_cycle']) ? $response['next_subs_cycle'] : $response['paid_until'];
246
- $this->unsetRecurringData(); //unset recurring order id and profile id
247
- }
248
-
249
- $payment->setStatus(Novalnet_Payment_Model_Payment_Method_Abstract::STATUS_SUCCESS)
250
- ->setStatusDescription($helper->__('Payment was successful.'))
251
- ->setAdditionalData(serialize($data))
252
- ->setIsTransactionClosed(true)
253
- ->save();
254
- $order->setPayment($payment);
255
- $order->save(); //Save details in order
256
- $successActionFlag = $paymentObj->getCode() . '_successAction';
257
-
258
- if ($payment->getAdditionalInformation($successActionFlag)
259
- != 1) {
260
- $payment->setAdditionalInformation($successActionFlag, 1);
261
- $this->_saveSuccessOrder($order, $response, $authorizeKey);
262
- }
263
- $status = true;
264
- } else {
265
- $paymentObj->saveCancelledOrder($dataObj, $payment);
266
- if (!empty($profileId)) {
267
- $recurringProfile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED)
268
- ->setReferenceId($response['tid'])
269
- ->save();
270
- $this->unsetRecurringData(); //unset recurring order id and profile id
271
- }
272
- $statusMessage = $dataObj->getStatusMessage() ? $dataObj->getStatusMessage()
273
- : ($dataObj->getStatusDesc() ? $dataObj->getStatusDesc() : ($dataObj->getStatusText()
274
- ? $dataObj->getStatusText() : $helper->__('Payment was not successfull')));
275
- $helper->getCoresession()->addError($statusMessage);
276
- $status = false;
277
- }
278
- $order->save();
279
- return $status;
280
- } catch (Mage_Core_Exception $e) {
281
- $this->_getCheckout()->addError($e->getMessage());
282
- return false;
283
- } catch (Exception $e) {
284
- Mage::logException($e);
285
- }
286
- }
287
-
288
- /**
289
- * validate the response and save the order
290
  *
291
- * @param varien_object $order
292
- * @param array $response
293
- * @param mixed $authorizeKey
294
  */
295
- private function _saveSuccessOrder($order, $response, $authorizeKey)
296
  {
297
- $payment = $order->getPayment();
298
- $payment->setStatus($response['tid_status']);
299
- $paymentObj = $payment->getMethodInstance();
300
- $txnId = $response['tid'];
301
- $helper = $this->_getNovalnetHelper();
302
- // save transaction id
303
- $payment->setTransactionId($txnId)
304
- ->setLastTransId($txnId)
305
- ->setParentTransactionId(null);
306
- // capture process
307
- if ($order->canInvoice() && $response['tid_status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
308
- $captureMode = (version_compare($helper->getMagentoVersion(), '1.6', '<')) ? false : true;
309
- $payment->setIsTransactionClosed($captureMode)
310
- ->capture(null);
311
- }
312
- $payment->save();
313
-
314
- $setOrderAfterStatus = $paymentObj->getNovalnetConfig('order_status_after_payment')
315
- ? $paymentObj->getNovalnetConfig('order_status_after_payment')
316
- : Mage_Sales_Model_Order::STATE_PROCESSING; // If after status is empty set default status
317
- if ($paymentObj->getCode() == Novalnet_Payment_Model_Config::NN_PAYPAL && $response['status']
318
- == Novalnet_Payment_Model_Config::PAYPAL_PENDING_CODE) {
319
- $setOrderAfterStatus = $paymentObj->getNovalnetConfig('order_status')
320
- ? $paymentObj->getNovalnetConfig('order_status') : Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
321
- }
322
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $setOrderAfterStatus, $helper->__('Customer successfully returned from Novalnet'), true
323
- )->save();
324
-
325
- //sendNewOrderEmail
326
- if (!$order->getEmailSent() && $order->getId()) {
327
- try {
328
- $order->sendNewOrderEmail()
329
- ->setEmailSent(true)
330
- ->save();
331
- } catch (Exception $e) {
332
- Mage::throwException($helper->__('Cannot send new order email.'));
333
- }
334
- }
335
-
336
- $nnAffId = $helper->getCoresession()->getNnAffId();
337
- if ($nnAffId) {
338
- $paymentObj->doNovalnetAffUserInfoLog($nnAffId);
339
- }
340
- $statusText = !empty($response['status_message']) ? $response['status_message']
341
- : (!empty($response['status_desc']) ? $response['status_desc'] : (!empty($response['status_text'])
342
- ? $response['status_text'] : $helper->__('successful')));
343
- $helper->getCoresession()->addSuccess($statusText);
344
- $order->save();
345
- $amount = is_numeric($response['amount']) ? $response['amount'] : $helper->getDecodedParam($response['amount'], $authorizeKey);
346
- // Save the Transaction status
347
- $this->doTransactionStatusSave($response, $payment, $amount, $paymentObj->getCode());
348
  }
349
 
350
  /**
351
- * Get singleton of Checkout Session Model
352
  *
353
- * @return Mage_Checkout_Model_Session
 
354
  */
355
- private function _getCheckout()
356
  {
357
- return Mage::getSingleton('checkout/session');
 
358
  }
359
 
360
  /**
361
- * Get Novalnet Helper
362
  *
 
363
  * @return Novalnet_Payment_Helper_Data
364
  */
365
- private function _getNovalnetHelper()
366
  {
367
  return Mage::helper('novalnet_payment');
368
  }
369
 
370
- /**
371
- * Get Last placed order object
372
- *
373
- * @return payment object
374
- */
375
- private function _getOrder()
376
- {
377
- return Mage::getModel('sales/order')->loadByIncrementId($this->_getCheckout()->getLastRealOrderId());
378
- }
379
-
380
- /**
381
- * Log Novalnet transaction status data
382
- *
383
- * @param array $response
384
- * @param varien_object $transactionStatus
385
- * @param int $amount
386
- * @param string $paymentCode
387
- */
388
- public function doTransactionStatusSave($response, $transactionStatus,$amount, $paymentCode)
389
- {
390
- $helper = $this->_getNovalnetHelper();
391
- $ncNo = (isset($response['nc_no'])) ? $response['nc_no'] : NULL;
392
- Mage::getModel('novalnet_payment/transactionstatus')->setTransactionNo($response['tid'])
393
- ->setOrderId($response['order_no'])
394
- ->setTransactionStatus(trim($transactionStatus->getStatus())) //Novalnet Admin transaction status
395
- ->setNcNo($ncNo) //nc number
396
- ->setCustomerId($helper->getCustomerId())
397
- ->setPaymentName($paymentCode)
398
- ->setAmount($helper->getFormatedAmount($amount, 'RAW'))
399
- ->setRemoteIp($helper->getRealIpAddr())
400
- ->setStoreId($helper->getMagentoStoreId())
401
- ->setShopUrl($helper->getCurrentSiteUrl())
402
- ->setCreatedDate($helper->getCurrentDateTime())
403
- ->save();
404
- }
405
-
406
- /**
407
- * Log Novalnet payment response data
408
- *
409
- * @param array $response
410
- */
411
- public function doTransactionOrderLog($response)
412
- {
413
-
414
- $modNovalTransactionOverview = $this->_getNovalnetHelper()->getModelTransactionOverview()->loadByAttribute('order_id', $response['order_no']);
415
- $helper = $this->_getNovalnetHelper();
416
-
417
- $modNovalTransactionOverview->setTransactionId($response['tid'])
418
- ->setResponseData(base64_encode(serialize($response)))
419
- ->setCustomerId($helper->getCustomerId())
420
- ->setStatus($response['status']) //transaction status code
421
- ->setStoreId($helper->getMagentoStoreId())
422
- ->setShopUrl($helper->getCurrentSiteUrl())
423
- ->save();
424
- }
425
-
426
- /**
427
- * Set payment status for Novalnet redirect payment methods
428
- *
429
- * @param mixed $authorizeKey
430
- * @param array $response
431
- * @param varien_object $paymentObj
432
- * @return array
433
- */
434
- private function responseStatus($authorizeKey,$response,$paymentObj)
435
- {
436
- if ($response['status'] == Novalnet_Payment_Model_Config::RESPONSE_CODE_APPROVED) {
437
- $response['status'] = $this->_getNovalnetHelper()->checkParams($response, $authorizeKey, $response['implementation']);
438
- }
439
- return $response;
440
- }
441
-
442
- /**
443
- * Set Novalnet payment mode (test/live)
444
- *
445
- * @param varien_object $paymentObj
446
- * @param array $response
447
- * @param mixed $authorizeKey
448
- * @return int
449
- */
450
- private function setNovalnetMode($paymentObj,$response,$authorizeKey)
451
- {
452
- $serverResponse = $this->_getNovalnetHelper()->getDecodedParam($response['test_mode'], $authorizeKey);
453
- $shopMode = $paymentObj->getNovalnetConfig('live_mode');
454
- $testMode = (((isset($serverResponse) && $serverResponse == 1) || (isset($shopMode)
455
- && $shopMode == 0)) ? 1 : 0 );
456
- return $testMode;
457
- }
458
-
459
- /**
460
- * Unset recurring payment data
461
- *
462
- * @param null
463
- * @return null
464
- */
465
- private function unsetRecurringData()
466
- {
467
- $this->_getCheckout()->unsRecurringOrderId();
468
- }
469
-
470
- /**
471
- * load recurring payment profile
472
- *
473
- * @param int $profileId
474
- * @return varien_object
475
- */
476
- private function loadRecurringProfile($profileId)
477
- {
478
- return Mage::getModel('sales/recurring_profile')
479
- ->load($profileId, 'profile_id');
480
- }
481
  }
18
  * recommendation as well as a comment on merchant form
19
  * would be greatly appreciated.
20
  *
21
+ * @category Novalnet
22
+ * @package Novalnet_Payment
23
+ * @copyright Copyright (c) Novalnet AG. (https://www.novalnet.de)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
  class Novalnet_Payment_GatewayController extends Mage_Core_Controller_Front_Action
27
  {
28
  /**
29
+ * Initiate redirect payment process
30
  *
31
+ * @param none
32
+ * @return none
33
  */
34
  public function redirectAction()
35
  {
36
+ $helper = $this->_getHelper(); // Get Novalnet payment helper
37
+ $session = $helper->getCheckoutSession(); // Get checkout session
38
+
39
  try {
40
+ $order = $this->_getOrder(); // Get order object
41
+ $payment = $order->getPayment(); // Get payment object
42
+ $paymentObj = $payment->getMethodInstance(); // Get payment method instance
 
43
  $quoteId = $session->getQuoteId() ? $session->getQuoteId() : $session->getLastQuoteId();
44
  $items = Mage::getModel('sales/quote')->load($quoteId)->getItemsQty();
45
  $session->getQuote()->setIsActive(true)->save();
46
  $redirectActionFlag = $paymentObj->getCode() . '_redirectAction';
47
 
48
  if ($payment->getAdditionalInformation($redirectActionFlag) != 1
49
+ && $session->getLastRealOrderId() && $items
50
+ ) {
51
  $payment->setAdditionalInformation($redirectActionFlag, 1);
52
+ // Set order status as on-hold
53
+ $status = $state = Mage_Sales_Model_Order::STATE_HOLDED;
54
+ $order->setState($state, $status, $helper->__('Customer was redirected to Novalnet'), false)->save();
55
  $this->getResponse()->setBody(
56
+ $this->getLayout()
57
+ ->createBlock(Novalnet_Payment_Model_Config::NOVALNET_REDIRECT_BLOCK)
58
+ ->setOrder($order)
59
+ ->toHtml()
60
  );
61
  } else {
62
  $this->_redirect('checkout/cart');
63
  }
64
  } catch (Mage_Core_Exception $e) {
65
+ $session->addError($e->getMessage());
66
  } catch (Exception $e) {
67
  Mage::logException($e);
68
  }
69
  }
70
 
71
  /**
72
+ * Get Novalnet payment transaction response
73
  *
74
+ * @param none
75
+ * @return none
76
  */
77
  public function returnAction()
78
  {
79
+ $helper = $this->_getHelper(); // Get Novalnet payment helper
80
+ $order = $this->_getOrder(); // Get order object
81
+ $response = new Varien_Object();
82
+ $response->setData($this->getRequest()->getParams()); // Get payment response data
83
+ $this->_savePayportResponse($response, $order); // Save payment response traces
84
+ $responseModel = $helper->getModel('Service_Api_Response'); // Get Novalnet Api response model
85
+ $status = $responseModel->checkReturnedData($response, $order);
86
+ if ($status) {
87
+ // Send order email for successful Novalnet transaction
88
+ Mage::dispatchEvent('novalnet_sales_order_email', array('order' => $order));
89
+ }
90
+ $helper->getCheckoutSession()->getQuote()->setIsActive(false)->save();
91
+ $this->_redirect(!$status ? 'checkout/onepage/failure' : 'checkout/onepage/success');
92
  }
93
 
94
  /**
95
+ * Failure payment transaction
96
  *
97
+ * @param none
98
+ * @return none
99
  */
100
  public function errorAction()
101
  {
102
+ $helper = $this->_getHelper(); // Get Novalnet payment helper
103
+ $order = $this->_getOrder(); // Get order object
104
+ $response = new Varien_Object();
105
+ $response->setData($this->getRequest()->getParams()); // Get payment response data
106
+ $this->_savePayportResponse($response, $order); // Save payment response traces
107
+ $responseModel = $helper->getModel('Service_Api_Response'); // Get Novalnet Api response model
108
+ $responseModel->checkErrorReturnedData($response, $order); // Verify the payment response data
109
+ $helper->getCheckoutSession()->getQuote()->setIsActive(false)->save();
110
+ $this->_redirect('checkout/onepage/failure', array('_secure' => true)); // Redirects to failure page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  }
112
 
113
  /**
114
+ * Send payment request to Novalnet gateway
115
  *
116
+ * @param none
117
+ * @return none
118
  */
119
  public function paymentAction()
120
  {
121
+ $helper = $this->_getHelper(); // Get Novalnet payment helper
122
+ $order = $this->_getOrder(); // Get order object
123
+ $paymentObj = $order->getPayment()->getMethodInstance(); // Get payment method instance
124
+ $paymentCode = $paymentObj->getCode(); // Get payment method code
125
+ $paymentActionFlag = $paymentCode . '_paymentAction';
126
+
127
+ if ($order->getPayment()->getAdditionalInformation($paymentActionFlag) != 1) {
128
+ $order->getPayment()->setAdditionalInformation($paymentActionFlag, 1);
129
+ $methodSession = $helper->getMethodSession($paymentCode); // Get payment method session
130
+ $responseModel = $helper->getModel('Service_Api_Response');// Get Novalnet Api response model
131
+ $request = $methodSession->getPaymentReqData(); // Get Novalnet payment request data
132
+
133
+ if ($methodSession->getPaymentResData()) { // For fraud prevention process
134
+ $request = $methodSession->getPaymentReqData(); // Novalnet payment request data
135
+ $response = $methodSession->getPaymentResData(); // Novalnet payment response data
136
  } else {
137
+ $response = $paymentObj->postRequest($request); // Send payment request to Novalnet gatway
138
  }
139
 
140
+ // Validate Novalnet payment response
141
+ $status = $responseModel->validateResponse($order, $request, $response);
142
+
143
+ if ($status) {
144
+ // Send order email for successful Novalnet transaction
145
+ Mage::dispatchEvent('novalnet_sales_order_email', array('order' => $order));
 
 
 
146
  }
147
+
148
+ $helper->unsetMethodSession($paymentCode); // Unset payment method session
149
+ Mage::unregister('payment_code'); // Unregister the payment code
150
+ $actionUrl = $status !== true ? 'checkout/onepage/failure' : 'checkout/onepage/success';
 
151
  } else {
152
  $actionUrl = 'checkout/cart';
153
  }
154
 
155
+ $this->_redirect($actionUrl); // Either redirects to success/failure page
156
  }
157
 
158
  /**
159
+ * Log Novalnet payment response data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  *
161
+ * @param Varien_Object $response
162
+ * @param Varien_Object $order
163
+ * @return none
164
  */
165
+ protected function _savePayportResponse($response, $order)
166
  {
167
+ // Get Novalnet transaction traces model
168
+ $transactionTraces = Mage::getModel('novalnet_payment/Mysql4_TransactionTraces')
169
+ ->loadByAttribute('order_id', $response->getOrderNo());
170
+ $transactionTraces->setTransactionId($response->getTid())
171
+ ->setResponseData(base64_encode(serialize($response->getData())))
172
+ ->setCustomerId($order->getCustomerId())
173
+ ->setStatus($response->getStatus()) //transaction status code
174
+ ->setStoreId($order->getStoreId())
175
+ ->setShopUrl($response->getSystemUrl())
176
+ ->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
 
179
  /**
180
+ * Get Last placed order object
181
  *
182
+ * @param none
183
+ * @return Varien_Object
184
  */
185
+ protected function _getOrder()
186
  {
187
+ $incrementId = $this->_getHelper()->getCheckoutSession()->getLastRealOrderId();
188
+ return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
189
  }
190
 
191
  /**
192
+ * Get Novalnet payment helper
193
  *
194
+ * @param none
195
  * @return Novalnet_Payment_Helper_Data
196
  */
197
+ protected function _getHelper()
198
  {
199
  return Mage::helper('novalnet_payment');
200
  }
201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  }
app/code/community/Novalnet/Payment/etc/adminhtml.xml CHANGED
@@ -26,83 +26,91 @@
26
  */
27
  -->
28
  <config>
 
29
  <menu>
30
  <novalnet translate="title" module="novalnet_payment">
31
  <title>Novalnet</title>
32
  <sort_order>100</sort_order>
33
  <children>
 
34
  <sales_order module="novalnet_payment">
35
  <title>Orders</title>
36
  <sort_order>1</sort_order>
37
  <action>adminhtml/novalnetpayment_sales_order</action>
38
  </sales_order>
 
39
  <sales_recurring module="novalnet_payment">
40
  <title>Recurring Profiles</title>
41
  <sort_order>2</sort_order>
42
  <action>adminhtml/novalnetpayment_sales_recurring_profile</action>
43
  </sales_recurring>
 
44
  <transaction module="novalnet_payment">
45
- <title>Novalnet Transactions</title>
46
  <sort_order>3</sort_order>
47
  <children>
48
- <transactionStatus module="novalnet_payment">
49
- <title>Novalnet Transactions Overview</title>
 
50
  <sort_order>1</sort_order>
51
- <action>adminhtml/novalnetpayment_transaction</action>
52
- </transactionStatus>
53
- <transactionOverivew module="novalnet_payment">
54
- <title>Novalnet Transactions Log</title>
55
- <sort_order>2</sort_order>
56
  <action>adminhtml/novalnetpayment_transactionoverview</action>
57
- </transactionOverivew>
 
 
 
 
 
 
58
  </children>
59
  </transaction>
 
60
  <fraud_prevention module="novalnet_payment">
61
  <title>Risk and Control</title>
62
  <sort_order>4</sort_order>
63
  <action>adminhtml/system_config/edit/section/fraud_prevent/</action>
64
  </fraud_prevention>
65
- <configuration_wizard module="novalnet_payment">
66
- <title>Configuration-wizard</title>
67
- <sort_order>5</sort_order>
68
- <action>adminhtml/novalnetpayment_configuration_wizard_page</action>
69
- </configuration_wizard>
70
  <configuration module="novalnet_payment">
71
  <title>Configuration</title>
72
- <sort_order>6</sort_order>
73
  <children>
 
74
  <general module="novalnet_payment">
75
  <title>General</title>
76
  <sort_order>1</sort_order>
77
  <action>adminhtml/system_config/edit/section/novalnet_global/</action>
78
  </general>
 
79
  <payment module="novalnet_payment">
80
  <title>Payment Methods</title>
81
  <sort_order>2</sort_order>
82
- <action>adminhtml/system_config/edit/section/novalnet_paymethods/</action>
83
  </payment>
84
  </children>
85
  </configuration>
 
86
  <information module="novalnet_payment">
87
  <title>Information</title>
88
- <sort_order>7</sort_order>
89
  <children>
90
- <novalnetmerchantadmin module="novalnet_payment">
 
91
  <title>Novalnet Merchant Admin</title>
92
  <sort_order>1</sort_order>
93
- <action>adminhtml/novalnetpayment_information_novalnetmerchantadmin/</action>
94
- </novalnetmerchantadmin>
95
- <information module="novalnet_payment">
 
96
  <title>Novalnet Magento Module</title>
97
  <sort_order>2</sort_order>
98
  <action>adminhtml/novalnetpayment_information_module/</action>
99
- </information>
100
  </children>
101
  </information>
102
  </children>
103
  </novalnet>
104
  </menu>
105
- <!-- Access control list-->
106
  <acl>
107
  <resources>
108
  <admin>
@@ -115,18 +123,14 @@
115
  <title>General</title>
116
  <sort_order>1</sort_order>
117
  </novalnet_global>
118
- <novalnet_paymethods>
119
  <title>Payment</title>
120
  <sort_order>2</sort_order>
121
- </novalnet_paymethods>
122
  <fraud_prevent>
123
- <title>Payment</title>
124
  <sort_order>3</sort_order>
125
  </fraud_prevent>
126
- <callback_script>
127
- <title>Payment</title>
128
- <sort_order>4</sort_order>
129
- </callback_script>
130
  </children>
131
  </config>
132
  </children>
@@ -147,27 +151,23 @@
147
  <title>Novalnet Transactions</title>
148
  <sort_order>3</sort_order>
149
  <children>
150
- <transactionStatus module="novalnet_payment">
151
  <title>Novalnet Transactions Overview</title>
152
  <sort_order>1</sort_order>
153
- </transactionStatus>
154
- <transactionOverivew module="novalnet_payment">
155
- <title>Novalnet Transactions Log</title>
156
  <sort_order>2</sort_order>
157
- </transactionOverivew>
158
  </children>
159
  </transaction>
160
- <fraud_prevention module="novalnet_payment">
161
  <title>Risk and Control</title>
162
  <sort_order>4</sort_order>
163
- </fraud_prevention>
164
- <configuration_wizard module="novalnet_payment">
165
- <title>Configuration-wizard</title>
166
- <sort_order>5</sort_order>
167
- </configuration_wizard>
168
  <configuration module="novalnet_payment">
169
  <title>Configuration</title>
170
- <sort_order>6</sort_order>
171
  <children>
172
  <general module="novalnet_payment">
173
  <title>General</title>
@@ -181,7 +181,17 @@
181
  </configuration>
182
  <information module="novalnet_payment">
183
  <title>Information</title>
184
- <sort_order>7</sort_order>
 
 
 
 
 
 
 
 
 
 
185
  </information>
186
  </children>
187
  </novalnet>
26
  */
27
  -->
28
  <config>
29
+ <!-- Defines Novalnet tab/menu in admin -->
30
  <menu>
31
  <novalnet translate="title" module="novalnet_payment">
32
  <title>Novalnet</title>
33
  <sort_order>100</sort_order>
34
  <children>
35
+ <!-- Sales orders for Novalnet payments -->
36
  <sales_order module="novalnet_payment">
37
  <title>Orders</title>
38
  <sort_order>1</sort_order>
39
  <action>adminhtml/novalnetpayment_sales_order</action>
40
  </sales_order>
41
+ <!-- Sales recurring profiles for Novalnet payments -->
42
  <sales_recurring module="novalnet_payment">
43
  <title>Recurring Profiles</title>
44
  <sort_order>2</sort_order>
45
  <action>adminhtml/novalnetpayment_sales_recurring_profile</action>
46
  </sales_recurring>
47
+ <!-- Sales transaction for Novalnet payments -->
48
  <transaction module="novalnet_payment">
49
+ <title>Transactions</title>
50
  <sort_order>3</sort_order>
51
  <children>
52
+ <!-- Sales transaction status overview for Novalnet payments -->
53
+ <transactionOverview module="novalnet_payment">
54
+ <title>Transactions Overview</title>
55
  <sort_order>1</sort_order>
 
 
 
 
 
56
  <action>adminhtml/novalnetpayment_transactionoverview</action>
57
+ </transactionOverview>
58
+ <!-- Sales transaction traces for Novalnet payments -->
59
+ <transactionTraces module="novalnet_payment">
60
+ <title>Transactions Log</title>
61
+ <sort_order>2</sort_order>
62
+ <action>adminhtml/novalnetpayment_transactiontraces</action>
63
+ </transactionTraces>
64
  </children>
65
  </transaction>
66
+ <!-- Fraud prevention configuration settings for Novalnet payments -->
67
  <fraud_prevention module="novalnet_payment">
68
  <title>Risk and Control</title>
69
  <sort_order>4</sort_order>
70
  <action>adminhtml/system_config/edit/section/fraud_prevent/</action>
71
  </fraud_prevention>
72
+ <!-- Configuration settings for Novalnet payments -->
 
 
 
 
73
  <configuration module="novalnet_payment">
74
  <title>Configuration</title>
75
+ <sort_order>5</sort_order>
76
  <children>
77
+ <!-- Global configuration settings for Novalnet payments -->
78
  <general module="novalnet_payment">
79
  <title>General</title>
80
  <sort_order>1</sort_order>
81
  <action>adminhtml/system_config/edit/section/novalnet_global/</action>
82
  </general>
83
+ <!-- Payment configuration settings for Novalnet payments -->
84
  <payment module="novalnet_payment">
85
  <title>Payment Methods</title>
86
  <sort_order>2</sort_order>
87
+ <action>adminhtml/system_config/edit/section/novalnet_payments/</action>
88
  </payment>
89
  </children>
90
  </configuration>
91
+ <!-- Informations about Novalnet -->
92
  <information module="novalnet_payment">
93
  <title>Information</title>
94
+ <sort_order>6</sort_order>
95
  <children>
96
+ <!-- Novalnet merchant admin portal -->
97
+ <merchantadmin module="novalnet_payment">
98
  <title>Novalnet Merchant Admin</title>
99
  <sort_order>1</sort_order>
100
+ <action>adminhtml/novalnetpayment_information_merchantadmin</action>
101
+ </merchantadmin>
102
+ <!-- Novalnet payment module information -->
103
+ <moduleinfo module="novalnet_payment">
104
  <title>Novalnet Magento Module</title>
105
  <sort_order>2</sort_order>
106
  <action>adminhtml/novalnetpayment_information_module/</action>
107
+ </moduleinfo>
108
  </children>
109
  </information>
110
  </children>
111
  </novalnet>
112
  </menu>
113
+ <!-- Defines access control list-->
114
  <acl>
115
  <resources>
116
  <admin>
123
  <title>General</title>
124
  <sort_order>1</sort_order>
125
  </novalnet_global>
126
+ <novalnet_payments>
127
  <title>Payment</title>
128
  <sort_order>2</sort_order>
129
+ </novalnet_payments>
130
  <fraud_prevent>
131
+ <title>Risk and Control</title>
132
  <sort_order>3</sort_order>
133
  </fraud_prevent>
 
 
 
 
134
  </children>
135
  </config>
136
  </children>
151
  <title>Novalnet Transactions</title>
152
  <sort_order>3</sort_order>
153
  <children>
154
+ <transactionOverview module="novalnet_payment">
155
  <title>Novalnet Transactions Overview</title>
156
  <sort_order>1</sort_order>
157
+ </transactionOverview>
158
+ <transactionTraces module="novalnet_payment">
159
+ <title>Novalnet Transactions Traces</title>
160
  <sort_order>2</sort_order>
161
+ </transactionTraces>
162
  </children>
163
  </transaction>
164
+ <fraud_prevent module="novalnet_payment">
165
  <title>Risk and Control</title>
166
  <sort_order>4</sort_order>
167
+ </fraud_prevent>
 
 
 
 
168
  <configuration module="novalnet_payment">
169
  <title>Configuration</title>
170
+ <sort_order>5</sort_order>
171
  <children>
172
  <general module="novalnet_payment">
173
  <title>General</title>
181
  </configuration>
182
  <information module="novalnet_payment">
183
  <title>Information</title>
184
+ <sort_order>6</sort_order>
185
+ <children>
186
+ <merchantadmin module="novalnet_payment">
187
+ <title>Novalnet Merchant Admin</title>
188
+ <sort_order>1</sort_order>
189
+ </merchantadmin>
190
+ <moduleinfo module="novalnet_payment">
191
+ <title>Novalnet Magento Module</title>
192
+ <sort_order>2</sort_order>
193
+ </moduleinfo>
194
+ </children>
195
  </information>
196
  </children>
197
  </novalnet>
app/code/community/Novalnet/Payment/etc/config.xml CHANGED
@@ -26,49 +26,33 @@
26
  */
27
  -->
28
  <config>
 
29
  <modules>
30
  <Novalnet_Payment>
31
- <!-- declare module's version information for database updates -->
32
- <version>10.2.1</version>
33
  </Novalnet_Payment>
34
  </modules>
35
 
36
  <global>
37
- <template>
38
- <email>
39
- <novalnet_callback_email_template module="novalnet_payment">
40
- <label>Novalnet Callback Email</label>
41
- <file>novalnet/novalnet_callback_email.html</file>
42
- <type>html</type>
43
- </novalnet_callback_email_template>
44
- </email>
45
- </template>
46
  <blocks>
47
  <novalnet_payment>
 
48
  <class>Novalnet_Payment_Block</class>
49
  </novalnet_payment>
50
- <adminhtml>
51
- <rewrite>
52
- <sales_order_view>Novalnet_Payment_Block_Adminhtml_Sales_Order_View</sales_order_view>
53
- <sales_order_invoice_view>Novalnet_Payment_Block_Adminhtml_Sales_Order_Invoice_View</sales_order_invoice_view>
54
- <sales_order_totals>Novalnet_Payment_Block_Adminhtml_Sales_Order_Totals</sales_order_totals>
55
- <sales_order_invoice_totals>Novalnet_Payment_Block_Adminhtml_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
56
- <sales_order_view_tab_invoices>Novalnet_Payment_Block_Adminhtml_Sales_Order_View_Tab_Invoices</sales_order_view_tab_invoices>
57
- <sales_order_creditmemo_totals>Novalnet_Payment_Block_Adminhtml_Sales_Order_Creditmemo_Totals</sales_order_creditmemo_totals>
58
- </rewrite>
59
- </adminhtml>
60
  <sales>
61
  <rewrite>
62
- <order_totals>Novalnet_Payment_Block_Sales_Order_Totals</order_totals>
63
- <order_invoice_totals>Novalnet_Payment_Block_Sales_Order_Invoice_Totals</order_invoice_totals>
64
- <order_creditmemo_totals>Novalnet_Payment_Block_Sales_Order_Creditmemo_Totals</order_creditmemo_totals>
65
- <recurring_profile_view>Novalnet_Payment_Block_Sales_Recurring_Profile_View</recurring_profile_view>
66
- <adminhtml_recurring_profile_view>Novalnet_Payment_Block_Sales_Adminhtml_Recurring_Profile_View</adminhtml_recurring_profile_view>
67
  </rewrite>
68
  </sales>
69
  </blocks>
70
-
71
- <!-- declare model group for new module -->
 
 
 
 
 
72
  <models>
73
  <adminhtml>
74
  <rewrite>
@@ -77,92 +61,57 @@
77
  </adminhtml>
78
  <sales>
79
  <rewrite>
80
- <order_invoice>Novalnet_Payment_Model_Sales_Order_Invoice</order_invoice>
81
- <order_payment>Novalnet_Payment_Model_Sales_Order_Payment</order_payment>
82
- <order_pdf_invoice>Novalnet_Payment_Model_Sales_Order_Pdf_Invoice</order_pdf_invoice>
83
- <order_pdf_creditmemo>Novalnet_Payment_Model_Sales_Order_Pdf_Creditmemo</order_pdf_creditmemo>
84
  <recurring_profile>Novalnet_Payment_Model_Recurring_Profile</recurring_profile>
85
- <order_creditmemo_total_grand>Novalnet_Payment_Model_Sales_Order_Creditmemo_Total_Grand</order_creditmemo_total_grand>
86
  <quote_address_total_nominal>Novalnet_Payment_Model_Quote_Address_Total_Nominal</quote_address_total_nominal>
87
  </rewrite>
88
  </sales>
89
-
90
  <novalnet_payment>
91
- <!-- base class name for the model group -->
92
  <class>Novalnet_Payment_Model</class>
93
- <resourceModel>novalnet_resource</resourceModel>
94
  </novalnet_payment>
95
- <novalnet_payment_abstract>
96
- <class>Novalnet_Payment_Model</class>
97
- </novalnet_payment_abstract>
98
- <novalnet_resource>
99
- <class>Novalnet_Payment_Model_Resource</class>
100
  <entities>
101
  <transaction_status>
 
102
  <table>novalnet_payment_transaction_status</table>
103
  </transaction_status>
104
- <order_log>
 
105
  <table>novalnet_payment_order_log</table>
106
- </order_log>
 
 
 
 
 
 
 
 
107
  <callback>
 
108
  <table>novalnet_payment_callback</table>
109
  </callback>
110
- <separefill>
111
- <table>novalnet_payment_separefill</table>
112
- </separefill>
113
- <amountchanged>
114
- <table>novalnet_payment_amountchanged</table>
115
- </amountchanged>
116
  <recurring>
 
117
  <table>novalnet_payment_recurring</table>
118
  </recurring>
119
- <aff_account_detail>
120
- <table>novalnet_payment_aff_account_detail</table>
121
- </aff_account_detail>
122
- <aff_user_detail>
123
- <table>novalnet_payment_aff_user_detail</table>
124
- </aff_user_detail>
125
  </entities>
126
- </novalnet_resource>
127
  </models>
128
 
129
- <!-- convert Novalnet field values from quote to order, make it available in orderobject -->
130
- <fieldsets>
131
- <sales_convert_quote_payment>
132
- <nn_testorder>
133
- <to_order_payment>*</to_order_payment>
134
- </nn_testorder>
135
- <nn_comments>
136
- <to_order_payment>*</to_order_payment>
137
- </nn_comments>
138
- <id>
139
- <to_order_payment>nn_id</to_order_payment>
140
- </id>
141
- </sales_convert_quote_payment>
142
- <sales_convert_order_payment>
143
- <nn_testorder>
144
- <to_quote_payment>*</to_quote_payment>
145
- </nn_testorder>
146
- <nn_comments>
147
- <to_quote_payment>*</to_quote_payment>
148
- </nn_comments>
149
- <id>
150
- <to_quote_payment>nn_id</to_quote_payment>
151
- </id>
152
- </sales_convert_order_payment>
153
- </fieldsets>
154
-
155
  <resources>
156
- <!-- resource identifier -->
157
  <novalnet_setup>
158
- <!-- this resource is a setup resource and used for upgrades -->
159
  <setup>
160
- <!-- which module to look for install/upgrade files in -->
161
  <module>Novalnet_Payment</module>
162
  </setup>
163
- <!-- specify database connection for this resource -->
164
  <connection>
165
- <!-- do not create new connection, use predefined core setup connection -->
166
  <use>core_setup</use>
167
  </connection>
168
  <novalnet_payment_write>
@@ -177,94 +126,111 @@
177
  </novalnet_payment_read>
178
  </novalnet_setup>
179
  </resources>
180
-
181
- <helpers>
182
- <novalnet_payment>
183
- <class>Novalnet_Payment_Helper</class>
184
- </novalnet_payment>
185
- </helpers>
186
- <payment>
187
- <groups>
188
- <novalnet>Novalnet</novalnet>
189
- </groups>
190
- </payment>
191
  <events>
192
- <core_block_abstract_prepare_layout_before>
193
- <observers>
194
- <novalnet_payment_prepare_layout_before>
195
- <class>Novalnet_Payment_Model_Observer</class>
196
- <method>prepareLayoutBefore</method>
197
- </novalnet_payment_prepare_layout_before>
198
- </observers>
199
- </core_block_abstract_prepare_layout_before>
200
- <customer_logout>
201
  <observers>
202
- <novalnet>
203
  <type>singleton</type>
204
- <class>Novalnet_Payment_Model_Observer</class>
205
- <method>customerLogin</method>
206
- </novalnet>
207
  </observers>
208
- </customer_logout>
 
209
  <sales_order_invoice_pay>
210
  <observers>
211
- <novalnet_payment_order_observer_invoice_send_email>
212
  <type>singleton</type>
213
- <class>Novalnet_Payment_Model_Observer</class>
214
  <method>sendInvoiceEmail</method>
215
- </novalnet_payment_order_observer_invoice_send_email>
216
  </observers>
217
  </sales_order_invoice_pay>
 
218
  <sales_order_creditmemo_refund>
219
  <observers>
220
- <novalnet_payment_order_observer_creditmemo_send_email>
221
  <type>singleton</type>
222
- <class>Novalnet_Payment_Model_Observer</class>
223
  <method>sendCreditmemoEmail</method>
224
- </novalnet_payment_order_observer_creditmemo_send_email>
225
  </observers>
226
  </sales_order_creditmemo_refund>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  <checkout_cart_save_after>
228
  <observers>
229
- <novalnet_payment_cart_save_after>
230
  <type>singleton</type>
231
- <class>Novalnet_Payment_Model_Observer</class>
232
  <method>getProfilePeriodValues</method>
233
- </novalnet_payment_cart_save_after>
234
  </observers>
235
  </checkout_cart_save_after>
 
236
  <checkout_submit_all_after>
237
  <observers>
238
- <novalnet_payment_recurring_redirect_url>
239
  <type>singleton</type>
240
- <class>Novalnet_Payment_Model_Observer</class>
241
- <method>updateRecurringUrl</method>
242
- </novalnet_payment_recurring_redirect_url>
243
  </observers>
244
  </checkout_submit_all_after>
245
  </events>
 
 
 
 
 
 
 
 
 
 
246
  </global>
247
 
248
- <adminhtml>
249
- <layout>
250
- <updates>
251
- <novalnet_payment>
252
- <file>novalnet/configuration.xml</file>
253
- </novalnet_payment>
254
- </updates>
255
- </layout>
256
- <translate>
257
- <modules>
258
- <novalnet_Payment>
259
- <files>
260
- <default>Novalnet_Payment.csv</default>
261
- </files>
262
- </novalnet_Payment>
263
- </modules>
264
- </translate>
265
- </adminhtml>
266
-
267
  <frontend>
 
268
  <routers>
269
  <novalnet_payment>
270
  <use>standard</use>
@@ -281,6 +247,15 @@
281
  </args>
282
  </checkout>
283
  </routers>
 
 
 
 
 
 
 
 
 
284
  <translate>
285
  <modules>
286
  <novalnet_Payment>
@@ -290,16 +265,10 @@
290
  </novalnet_Payment>
291
  </modules>
292
  </translate>
293
- <layout>
294
- <updates>
295
- <novalnet>
296
- <file>novalnet.xml</file>
297
- </novalnet>
298
- </updates>
299
- </layout>
300
  </frontend>
301
 
302
  <admin>
 
303
  <routers>
304
  <adminhtml>
305
  <args>
@@ -311,103 +280,121 @@
311
  </routers>
312
  </admin>
313
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  <default>
 
315
  <novalnet_global>
316
  <novalnet>
317
  <gateway_timeout>240</gateway_timeout>
 
 
 
 
 
318
  <order_status>processing</order_status>
319
  <void_status>canceled</void_status>
320
- </novalnet>
321
  </novalnet_global>
322
- <!-- 'payment' configuration section (tab) -->
323
  <payment>
324
- <novalnetInvoice translate="title" module="novalnet_payment">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  <active>0</active>
326
- <model>novalnet_payment/payment_method_novalnetInvoice</model>
327
  <title>Kauf auf Rechnung</title>
328
  <order_status>pending</order_status>
329
  <order_status_after_payment>processing</order_status_after_payment>
330
  <allowspecific>0</allowspecific>
331
- <group>novalnet</group>
 
332
  <payment_ref_one>1</payment_ref_one>
333
  <payment_ref_two>1</payment_ref_two>
334
  <payment_ref_three>1</payment_ref_three>
 
335
  </novalnetInvoice>
336
- <novalnetPrepayment translate="title" module="novalnet_payment">
337
  <active>0</active>
338
- <model>novalnet_payment/payment_method_novalnetPrepayment</model>
339
  <title>Vorauskasse</title>
340
  <order_status>pending</order_status>
341
  <order_status_after_payment>processing</order_status_after_payment>
342
  <allowspecific>0</allowspecific>
343
- <group>novalnet</group>
344
  <payment_ref_one>1</payment_ref_one>
345
  <payment_ref_two>1</payment_ref_two>
346
  <payment_ref_three>1</payment_ref_three>
 
347
  </novalnetPrepayment>
348
- <novalnetCc translate="title" module="novalnet_payment">
349
- <cctypes>visacard,mastercard</cctypes>
350
  <active>0</active>
351
- <model>novalnet_payment/payment_method_novalnetCc</model>
352
- <title>Kreditkarte</title>
353
  <order_status>pending</order_status>
354
  <order_status_after_payment>processing</order_status_after_payment>
355
  <allowspecific>0</allowspecific>
356
- <group>novalnet</group>
357
- </novalnetCc>
358
- <novalnetSepa translate="title" module="novalnet_payment">
359
- <active>0</active>
360
- <sepa_refill>0</sepa_refill>
361
- <model>novalnet_payment/payment_method_novalnetSepa</model>
362
- <allowspecific>0</allowspecific>
363
- <title>Lastschrift SEPA</title>
364
- <order_status>processing</order_status>
365
- <group>novalnet</group>
366
- </novalnetSepa>
367
- <novalnetBanktransfer translate="title" module="novalnet_payment">
368
  <active>0</active>
369
- <model>novalnet_payment/payment_method_novalnetBanktransfer</model>
370
  <title>Sofortüberweisung</title>
371
  <order_status>pending</order_status>
372
  <order_status_after_payment>processing</order_status_after_payment>
373
  <allowspecific>0</allowspecific>
374
- <group>novalnet</group>
375
  </novalnetBanktransfer>
376
- <novalnetPaypal translate="title" module="novalnet_payment">
377
- <active>0</active>
378
- <model>novalnet_payment/payment_method_novalnetPaypal</model>
379
- <title>PayPal</title>
380
- <order_status>pending</order_status>
381
- <order_status_after_payment>processing</order_status_after_payment>
382
- <allowspecific>0</allowspecific>
383
- <group>novalnet</group>
384
- </novalnetPaypal>
385
- <novalnetIdeal translate="title" module="novalnet_payment">
386
  <active>0</active>
387
- <model>novalnet_payment/payment_method_novalnetIdeal</model>
388
  <title>iDEAL</title>
389
  <order_status>pending</order_status>
390
  <order_status_after_payment>processing</order_status_after_payment>
391
  <allowspecific>0</allowspecific>
392
- <group>novalnet</group>
393
  </novalnetIdeal>
394
- <novalnetEps translate="title" module="novalnet_payment">
395
  <active>0</active>
396
- <model>novalnet_payment/payment_method_novalnetEps</model>
397
- <title>Eps</title>
398
  <order_status>pending</order_status>
399
  <order_status_after_payment>processing</order
26
  */
27
  -->
28
  <config>
29
+ <!-- Defines module with version for database updates -->
30
  <modules>
31
  <Novalnet_Payment>
32
+ <version>11.0.0</version>
 
33
  </Novalnet_Payment>
34
  </modules>
35
 
36
  <global>
37
+ <!-- Defines block for Novalnet payment module -->
 
 
 
 
 
 
 
 
38
  <blocks>
39
  <novalnet_payment>
40
+ <!-- Base class name for block -->
41
  <class>Novalnet_Payment_Block</class>
42
  </novalnet_payment>
 
 
 
 
 
 
 
 
 
 
43
  <sales>
44
  <rewrite>
45
+ <recurring_profile_view>Novalnet_Payment_Block_Recurring_Profile_View</recurring_profile_view>
 
 
 
 
46
  </rewrite>
47
  </sales>
48
  </blocks>
49
+ <!-- Defines helper for Novalnet payment module -->
50
+ <helpers>
51
+ <novalnet_payment>
52
+ <class>Novalnet_Payment_Helper</class>
53
+ </novalnet_payment>
54
+ </helpers>
55
+ <!-- Defines model (logic) for Novalnet payment module -->
56
  <models>
57
  <adminhtml>
58
  <rewrite>
61
  </adminhtml>
62
  <sales>
63
  <rewrite>
 
 
 
 
64
  <recurring_profile>Novalnet_Payment_Model_Recurring_Profile</recurring_profile>
 
65
  <quote_address_total_nominal>Novalnet_Payment_Model_Quote_Address_Total_Nominal</quote_address_total_nominal>
66
  </rewrite>
67
  </sales>
 
68
  <novalnet_payment>
69
+ <!-- Base class name for model -->
70
  <class>Novalnet_Payment_Model</class>
71
+ <resourceModel>novalnet_payment_mysql4</resourceModel>
72
  </novalnet_payment>
73
+ <!-- Novalnet payment module custom tables -->
74
+ <novalnet_payment_mysql4>
75
+ <class>Novalnet_Payment_Model_Mysql4_Resource</class>
 
 
76
  <entities>
77
  <transaction_status>
78
+ <!-- Logs Novalnet transaction details -->
79
  <table>novalnet_payment_transaction_status</table>
80
  </transaction_status>
81
+ <transaction_traces>
82
+ <!-- Logs Novalnet transaction traces details -->
83
  <table>novalnet_payment_order_log</table>
84
+ </transaction_traces>
85
+ <affiliate_info>
86
+ <!-- Logs Novalnet affiliate account details -->
87
+ <table>novalnet_payment_aff_account_detail</table>
88
+ </affiliate_info>
89
+ <affiliate_user>
90
+ <!-- Logs Novalnet affiliate user details -->
91
+ <table>novalnet_payment_aff_user_detail</table>
92
+ </affiliate_user>
93
  <callback>
94
+ <!-- Logs Novalnet callback transaction details -->
95
  <table>novalnet_payment_callback</table>
96
  </callback>
 
 
 
 
 
 
97
  <recurring>
98
+ <!-- Logs Novalnet subscription transaction details -->
99
  <table>novalnet_payment_recurring</table>
100
  </recurring>
 
 
 
 
 
 
101
  </entities>
102
+ </novalnet_payment_mysql4>
103
  </models>
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  <resources>
106
+ <!-- Resource identifier -->
107
  <novalnet_setup>
108
+ <!-- This resource is a setup resource and used for upgrades -->
109
  <setup>
 
110
  <module>Novalnet_Payment</module>
111
  </setup>
112
+ <!-- Specify database connection for this resource -->
113
  <connection>
114
+ <!-- Do not create new connection, use predefined core setup connection -->
115
  <use>core_setup</use>
116
  </connection>
117
  <novalnet_payment_write>
126
  </novalnet_payment_read>
127
  </novalnet_setup>
128
  </resources>
 
 
 
 
 
 
 
 
 
 
 
129
  <events>
130
+ <!-- Send order order email -->
131
+ <novalnet_sales_order_email>
 
 
 
 
 
 
 
132
  <observers>
133
+ <novalnet_payment_sales_order_email>
134
  <type>singleton</type>
135
+ <class>Novalnet_Payment_Model_Observer_SalesEmails</class>
136
+ <method>sendOrderEmail</method>
137
+ </novalnet_payment_sales_order_email>
138
  </observers>
139
+ </novalnet_sales_order_email>
140
+ <!-- Send order invoice email -->
141
  <sales_order_invoice_pay>
142
  <observers>
143
+ <novalnet_payment_sales_order_invoice_email>
144
  <type>singleton</type>
145
+ <class>Novalnet_Payment_Model_Observer_SalesEmails</class>
146
  <method>sendInvoiceEmail</method>
147
+ </novalnet_payment_sales_order_invoice_email>
148
  </observers>
149
  </sales_order_invoice_pay>
150
+ <!-- Send order creditmemo/refund email -->
151
  <sales_order_creditmemo_refund>
152
  <observers>
153
+ <novalnet_payment_sales_order_creditmemo_email>
154
  <type>singleton</type>
155
+ <class>Novalnet_Payment_Model_Observer_SalesEmails</class>
156
  <method>sendCreditmemoEmail</method>
157
+ </novalnet_payment_sales_order_creditmemo_email>
158
  </observers>
159
  </sales_order_creditmemo_refund>
160
+ <!-- Set void/canceled status for Novalnet payments -->
161
+ <sales_order_payment_void>
162
+ <observers>
163
+ <novalnet_payment_sales_order_canceled_status>
164
+ <type>singleton</type>
165
+ <class>Novalnet_Payment_Model_Observer_SalesEmails</class>
166
+ <method>setVoidOrderStatus</method>
167
+ </novalnet_payment_sales_order_canceled_status>
168
+ </observers>
169
+ </sales_order_payment_void>
170
+ <!-- Load Novalnet script files (css/js) -->
171
+ <core_block_abstract_prepare_layout_before>
172
+ <observers>
173
+ <novalnet_payment_prepare_layout_before>
174
+ <class>Novalnet_Payment_Model_Observer_LoadScripts</class>
175
+ <method>loadScriptFiles</method>
176
+ </novalnet_payment_prepare_layout_before>
177
+ </observers>
178
+ </core_block_abstract_prepare_layout_before>
179
+ <!-- Add buttons to sales order view page -->
180
+ <core_block_abstract_prepare_layout_after>
181
+ <observers>
182
+ <novalnet_payment_sales_order_view_addbutton>
183
+ <type>singleton</type>
184
+ <class>Novalnet_Payment_Model_Observer_OrderView</class>
185
+ <method>addButton</method>
186
+ </novalnet_payment_sales_order_view_addbutton>
187
+ </observers>
188
+ </core_block_abstract_prepare_layout_after>
189
+ <!-- Add buttons to sales order invoice view page -->
190
+ <core_block_abstract_prepare_layout_after>
191
+ <observers>
192
+ <novalnet_payment_order_invoice_view_addbutton>
193
+ <type>singleton</type>
194
+ <class>Novalnet_Payment_Model_Observer_InvoiceView</class>
195
+ <method>addButton</method>
196
+ </novalnet_payment_order_invoice_view_addbutton>
197
+ </observers>
198
+ </core_block_abstract_prepare_layout_after>
199
+ <!-- Get recurring product custom option/period values -->
200
  <checkout_cart_save_after>
201
  <observers>
202
+ <novalnet_payment_checkout_cart_save_after>
203
  <type>singleton</type>
204
+ <class>Novalnet_Payment_Model_Observer_Recurring</class>
205
  <method>getProfilePeriodValues</method>
206
+ </novalnet_payment_checkout_cart_save_after>
207
  </observers>
208
  </checkout_cart_save_after>
209
+ <!-- Set redirect url for recurring payment (Credit Card PCI & PayPal) -->
210
  <checkout_submit_all_after>
211
  <observers>
212
+ <novalnet_payment_checkout_submit_all_after>
213
  <type>singleton</type>
214
+ <class>Novalnet_Payment_Model_Observer_Recurring</class>
215
+ <method>setPaymentRedirectUrl</method>
216
+ </novalnet_payment_checkout_submit_all_after>
217
  </observers>
218
  </checkout_submit_all_after>
219
  </events>
220
+ <!-- Defines callback email template for Novalnet payment module -->
221
+ <template>
222
+ <email>
223
+ <novalnet_callback_email_template module="novalnet_payment">
224
+ <label>Novalnet Callback Email</label>
225
+ <file>novalnet/novalnet_callback_email.html</file>
226
+ <type>html</type>
227
+ </novalnet_callback_email_template>
228
+ </email>
229
+ </template>
230
  </global>
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  <frontend>
233
+ <!-- Defines frontend controller -->
234
  <routers>
235
  <novalnet_payment>
236
  <use>standard</use>
247
  </args>
248
  </checkout>
249
  </routers>
250
+ <!-- Defines frontend layout for updates -->
251
+ <layout>
252
+ <updates>
253
+ <novalnet>
254
+ <file>novalnet.xml</file>
255
+ </novalnet>
256
+ </updates>
257
+ </layout>
258
+ <!-- Defines frontend language translate file -->
259
  <translate>
260
  <modules>
261
  <novalnet_Payment>
265
  </novalnet_Payment>
266
  </modules>
267
  </translate>
 
 
 
 
 
 
 
268
  </frontend>
269
 
270
  <admin>
271
+ <!-- Defines adminhtml controller -->
272
  <routers>
273
  <adminhtml>
274
  <args>
280
  </routers>
281
  </admin>
282
 
283
+ <adminhtml>
284
+ <!-- Defines adminhtml layout for updates -->
285
+ <layout>
286
+ <updates>
287
+ <novalnet_payment>
288
+ <file>novalnet.xml</file>
289
+ </novalnet_payment>
290
+ </updates>
291
+ </layout>
292
+ <!-- Defines adminhtml language translate file -->
293
+ <translate>
294
+ <modules>
295
+ <novalnet_Payment>
296
+ <files>
297
+ <default>Novalnet_Payment.csv</default>
298
+ </files>
299
+ </novalnet_Payment>
300
+ </modules>
301
+ </translate>
302
+ </adminhtml>
303
+
304
  <default>
305
+ <!-- Defines default global/payment configuration values -->
306
  <novalnet_global>
307
  <novalnet>
308
  <gateway_timeout>240</gateway_timeout>
309
+ <enable_payment_logo>1</enable_payment_logo>
310
+ <canceled_order_email>0</canceled_order_email>
311
+ <latest_updates_notify>1</latest_updates_notify>
312
+ </novalnet>
313
+ <order_status_mapping>
314
  <order_status>processing</order_status>
315
  <void_status>canceled</void_status>
316
+ </order_status_mapping>
317
  </novalnet_global>
 
318
  <payment>
319
+ <novalnetCc>
320
+ <active>0</active>
321
+ <title>Kreditkarte</title>
322
+ <order_status>pending</order_status>
323
+ <order_status_after_payment>processing</order_status_after_payment>
324
+ <cc_types>VI,MC</cc_types>
325
+ <allowspecific>0</allowspecific>
326
+ <model>novalnet_payment/method_novalnetCc</model>
327
+ </novalnetCc>
328
+ <novalnetSepa>
329
+ <active>0</active>
330
+ <title>Lastschrift SEPA</title>
331
+ <order_status>processing</order_status>
332
+ <allowspecific>0</allowspecific>
333
+ <model>novalnet_payment/method_novalnetSepa</model>
334
+ </novalnetSepa>
335
+ <novalnetInvoice>
336
  <active>0</active>
 
337
  <title>Kauf auf Rechnung</title>
338
  <order_status>pending</order_status>
339
  <order_status_after_payment>processing</order_status_after_payment>
340
  <allowspecific>0</allowspecific>
341
+ <payment_guarantee>0</payment_guarantee>
342
+ <payment_guarantee_force>0</payment_guarantee_force>
343
  <payment_ref_one>1</payment_ref_one>
344
  <payment_ref_two>1</payment_ref_two>
345
  <payment_ref_three>1</payment_ref_three>
346
+ <model>novalnet_payment/method_novalnetInvoice</model>
347
  </novalnetInvoice>
348
+ <novalnetPrepayment>
349
  <active>0</active>
 
350
  <title>Vorauskasse</title>
351
  <order_status>pending</order_status>
352
  <order_status_after_payment>processing</order_status_after_payment>
353
  <allowspecific>0</allowspecific>
 
354
  <payment_ref_one>1</payment_ref_one>
355
  <payment_ref_two>1</payment_ref_two>
356
  <payment_ref_three>1</payment_ref_three>
357
+ <model>novalnet_payment/method_novalnetPrepayment</model>
358
  </novalnetPrepayment>
359
+ <novalnetPaypal>
 
360
  <active>0</active>
361
+ <title>PayPal</title>
 
362
  <order_status>pending</order_status>
363
  <order_status_after_payment>processing</order_status_after_payment>
364
  <allowspecific>0</allowspecific>
365
+ <model>novalnet_payment/method_novalnetPaypal</model>
366
+ </novalnetPaypal>
367
+ <novalnetBanktransfer>
 
 
 
 
 
 
 
 
 
368
  <active>0</active>
 
369
  <title>Sofortüberweisung</title>
370
  <order_status>pending</order_status>
371
  <order_status_after_payment>processing</order_status_after_payment>
372
  <allowspecific>0</allowspecific>
373
+ <model>novalnet_payment/method_novalnetBanktransfer</model>
374
  </novalnetBanktransfer>
375
+ <novalnetIdeal>
 
 
 
 
 
 
 
 
 
376
  <active>0</active>
 
377
  <title>iDEAL</title>
378
  <order_status>pending</order_status>
379
  <order_status_after_payment>processing</order_status_after_payment>
380
  <allowspecific>0</allowspecific>
381
+ <model>novalnet_payment/method_novalnetIdeal</model>
382
  </novalnetIdeal>
383
+ <novalnetEps>
384
  <active>0</active>
385
+ <title>eps</title>
 
386
  <order_status>pending</order_status>
387
  <order_status_after_payment>processing</order