Mage_Payone - Version 3.1.3

Version Notes

Mage_Payone-3.1.3

Download this release

Release Info

Developer Magento Core Team
Extension Mage_Payone
Version 3.1.3
Comparing to
See all releases


Code changes from version 3.1.2 to 3.1.3

Files changed (46) hide show
  1. app/code/community/Payone/Core/Block/Adminhtml/System/Config/Form/Field/Abstract.php +42 -15
  2. app/code/community/Payone/Core/Block/Adminhtml/System/Config/Form/Field/StatusMapping.php +12 -12
  3. app/code/community/Payone/Core/Block/Adminhtml/System/Config/Payment.php +1 -0
  4. app/code/community/Payone/Core/Block/Payment/Method/Form/Abstract.php +1 -1
  5. app/code/community/Payone/Core/Block/Payment/Method/Form/OnlineBankTransfer.php +24 -0
  6. app/code/community/Payone/Core/Block/Payment/Method/Form/SafeInvoice.php +23 -0
  7. app/code/community/Payone/Core/Block/Payment/Method/Form/Wallet.php +23 -0
  8. app/code/community/Payone/Core/Block/Payment/Method/Info/SafeInvoice.php +1 -1
  9. app/code/community/Payone/Core/Model/Config/General/Global.php +40 -0
  10. app/code/community/Payone/Core/Model/Config/General/StatusMapping.php +24 -4
  11. app/code/community/Payone/Core/Model/Domain/Transaction.php +1 -1
  12. app/code/community/Payone/Core/Model/Factory.php +24 -0
  13. app/code/community/Payone/Core/Model/Handler/Verification/AddressCheck.php +9 -3
  14. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Abstract.php +42 -32
  15. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php +26 -12
  16. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Capture.php +12 -6
  17. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Debit.php +6 -0
  18. app/code/community/Payone/Core/Model/Observer/{TransactionStatus/StoreClearingParameters.php → Config/Protect.php} +12 -17
  19. app/code/community/Payone/Core/Model/Observer/Sales/Order.php +1 -6
  20. app/code/community/Payone/Core/Model/Payment/Method/Abstract.php +72 -5
  21. app/code/community/Payone/Core/Model/Payment/Method/SafeInvoice.php +9 -29
  22. app/code/community/Payone/Core/Model/Service/Config/ProtectCheck.php +143 -0
  23. app/code/community/Payone/Core/Model/Service/Config/XmlGenerate.php +12 -5
  24. app/code/community/Payone/Core/Model/Service/Sales/OrderStatus.php +20 -6
  25. app/code/community/Payone/Core/Model/Service/TransactionStatus/Process.php +26 -0
  26. app/code/community/Payone/Core/Model/Service/TransactionStatus/StoreClearingParameters.php +14 -5
  27. app/code/community/Payone/Core/Model/System/Config/Backend/Protect.php +16 -50
  28. app/code/community/Payone/Core/Model/System/Config/OrderStatus.php +137 -0
  29. app/code/community/Payone/Core/controllers/Adminhtml/Configuration/Wizard/PageController.php +8 -0
  30. app/code/community/Payone/Core/etc/config.xml +23 -15
  31. app/code/community/Payone/Core/etc/system.xml +23 -0
  32. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.0.3-3.0.4.php +1 -1
  33. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.0.8-3.0.9.php +1 -1
  34. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.1.2-3.1.3.php +69 -0
  35. app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.1.2-3.1.3.sql +14 -0
  36. app/design/adminhtml/default/default/template/payone/core/system/config/form/field/array.phtml +2 -0
  37. app/design/adminhtml/default/default/template/payone/core/system/config/payment/grid/container.phtml +0 -1
  38. app/design/frontend/base/default/template/payone/core/payment/method/form/onlinebanktransfer.phtml +1 -1
  39. app/design/frontend/base/default/template/payone/core/payment/method/form/safe_invoice.phtml +1 -1
  40. app/design/frontend/base/default/template/payone/core/payment/method/form/wallet.phtml +1 -1
  41. app/design/frontend/base/default/template/payone/core/payment/method/info/safe_invoice.phtml +14 -2
  42. app/locale/de_DE/Payone_Core.csv +3 -0
  43. js/payone/core/addresscheck.js +8 -6
  44. js/payone/core/creditcard.js +2 -2
  45. lib/Payone/Autoload.php +10 -3
  46. package.xml +5 -5
app/code/community/Payone/Core/Block/Adminhtml/System/Config/Form/Field/Abstract.php CHANGED
@@ -55,7 +55,7 @@ class Payone_Core_Block_Adminhtml_System_Config_Form_Field_Abstract
55
  */
56
  public function render(Varien_Data_Form_Element_Abstract $element)
57
  {
58
- $hint = (array) $element->getFieldConfig()->hint;
59
  if (!count($hint)) {
60
  return parent::render($element);
61
  }
@@ -79,11 +79,11 @@ class Payone_Core_Block_Adminhtml_System_Config_Form_Field_Abstract
79
  /**
80
  * @param $columnName string
81
  * @param $selectType string
82
- * @param $options array
83
  * @return string
84
  * @throws Exception
85
  */
86
- public function prepareCellTemplate($columnName, $selectType, $options)
87
  {
88
  if (empty($this->_columns[$columnName])) {
89
  throw new Exception('Wrong column name specified.');
@@ -98,24 +98,51 @@ class Payone_Core_Block_Adminhtml_System_Config_Form_Field_Abstract
98
  elseif ($selectType === self::PAYONE_CORE_FIELD_SELECT) {
99
  $definition = '" class="select"';
100
  }
101
- else
102
  throw new Exception('Unknown Type for Select');
 
103
 
104
- $rendered = '<select name="' . $inputName . $definition . (isset($column['style']) ? ' style="' . $column['style'] . '"' : '').' >';
105
-
106
- foreach ($options as $item) {
107
- $value = $item['value'];
108
- if(is_array($value))
109
- {
110
- $value = array_pop($value);
111
- $value = $value['value'];
 
 
 
 
 
 
 
 
 
112
  }
113
- $rendered .= '<option value="' . $value . '">' . $item['label'] . '</option>';
114
  }
115
 
116
- $rendered .= '</select>';
 
 
 
117
 
118
- return $rendered;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
 
121
  /**
55
  */
56
  public function render(Varien_Data_Form_Element_Abstract $element)
57
  {
58
+ $hint = (array)$element->getFieldConfig()->hint;
59
  if (!count($hint)) {
60
  return parent::render($element);
61
  }
79
  /**
80
  * @param $columnName string
81
  * @param $selectType string
82
+ * @param $values array
83
  * @return string
84
  * @throws Exception
85
  */
86
+ public function prepareCellTemplate($columnName, $selectType, $values)
87
  {
88
  if (empty($this->_columns[$columnName])) {
89
  throw new Exception('Wrong column name specified.');
98
  elseif ($selectType === self::PAYONE_CORE_FIELD_SELECT) {
99
  $definition = '" class="select"';
100
  }
101
+ else {
102
  throw new Exception('Unknown Type for Select');
103
+ }
104
 
105
+ $html = '<select name="' . $inputName . $definition . (isset($column['style']) ? ' style="' . $column['style'] . '"' : '') . ' >';
106
+ foreach ($values as $key => $option) {
107
+ if (!is_array($option)) {
108
+ $html .= $this->_optionToHtml(array(
109
+ 'value' => $key,
110
+ 'label' => $option)
111
+ );
112
+ }
113
+ elseif (is_array($option['value'])) {
114
+ $html .= '<optgroup label="' . $option['label'] . '">';
115
+ foreach ($option['value'] as $groupItem) {
116
+ $html .= $this->_optionToHtml($groupItem);
117
+ }
118
+ $html .= '</optgroup>';
119
+ }
120
+ else {
121
+ $html .= $this->_optionToHtml($option);
122
  }
 
123
  }
124
 
125
+ $html .= '</select>';
126
+
127
+ return $html;
128
+ }
129
 
130
+ protected function _optionToHtml($option)
131
+ {
132
+ if (is_array($option['value'])) {
133
+ $html = '<optgroup label="' . $option['label'] . '">';
134
+ foreach ($option['value'] as $groupItem) {
135
+ $html .= $this->_optionToHtml($groupItem);
136
+ }
137
+ $html .= '</optgroup>';
138
+ }
139
+ else {
140
+ $html = '<option value="' .($option['value']) . '"';
141
+ // $html .= isset($option['title']) ? 'title="' . ($option['title']) . '"' : '';
142
+ // $html .= isset($option['style']) ? 'style="' . $option['style'] . '"' : '';
143
+ $html .= '>' . ($option['label']) . '</option>';
144
+ }
145
+ return $html;
146
  }
147
 
148
  /**
app/code/community/Payone/Core/Block/Adminhtml/System/Config/Form/Field/StatusMapping.php CHANGED
@@ -43,7 +43,7 @@ class Payone_Core_Block_Adminhtml_System_Config_Form_Field_StatusMapping
43
  'style' => 'width:150px',
44
  ));
45
 
46
- $this->addColumn('status', array(
47
  'label' => Mage::helper('payone_core')->__('Magento-Status'),
48
  'style' => 'width:120px;',
49
  ));
@@ -59,22 +59,22 @@ class Payone_Core_Block_Adminhtml_System_Config_Form_Field_StatusMapping
59
  */
60
  protected function _renderCellTemplate($columnName)
61
  {
62
- $selectType = Payone_Core_Block_Adminhtml_System_Config_Form_Field_Abstract::PAYONE_CORE_FIELD_SELECT;
63
-
64
- if ($columnName == 'txaction')
65
- {
66
  $modelConfigCode = $this->getFactory()->getModelSystemConfigTransactionStatus();
 
67
  }
68
- elseif ($columnName == 'status')
69
- {
70
- $modelConfigCode = $this->getFactory()->getModelSystemConfigOrderStatus();
 
71
  }
72
 
73
- $options = $modelConfigCode->toOptionArray();
74
-
75
- $rendered = $this->prepareCellTemplate($columnName, $selectType, $options);
76
 
77
- return $rendered;
78
  }
79
 
80
  }
43
  'style' => 'width:150px',
44
  ));
45
 
46
+ $this->addColumn('state_status', array(
47
  'label' => Mage::helper('payone_core')->__('Magento-Status'),
48
  'style' => 'width:120px;',
49
  ));
59
  */
60
  protected function _renderCellTemplate($columnName)
61
  {
62
+ $selectType = '';
63
+ $options = array();
64
+ if ($columnName == 'txaction') {
65
+ $selectType = Payone_Core_Block_Adminhtml_System_Config_Form_Field_Abstract::PAYONE_CORE_FIELD_SELECT;
66
  $modelConfigCode = $this->getFactory()->getModelSystemConfigTransactionStatus();
67
+ $options = $modelConfigCode->toOptionArray();
68
  }
69
+ elseif ($columnName == 'state_status') {
70
+ $selectType = Payone_Core_Block_Adminhtml_System_Config_Form_Field_Abstract::PAYONE_CORE_FIELD_SELECT;
71
+ $statuses = new Payone_Core_Model_System_Config_OrderStatus();
72
+ $options = $statuses->toOptionGroupArray();
73
  }
74
 
75
+ $html = $this->prepareCellTemplate($columnName, $selectType, $options);
 
 
76
 
77
+ return $html;
78
  }
79
 
80
  }
app/code/community/Payone/Core/Block/Adminhtml/System/Config/Payment.php CHANGED
@@ -51,6 +51,7 @@ class Payone_Core_Block_Adminhtml_System_Config_Payment extends Mage_Adminhtml_B
51
  $this->_addNewMethodButton($key, $name);
52
  }
53
  }
 
54
  }
55
 
56
  /**
51
  $this->_addNewMethodButton($key, $name);
52
  }
53
  }
54
+ $this->setTemplate('payone/core/system/config/payment/grid/container.phtml');
55
  }
56
 
57
  /**
app/code/community/Payone/Core/Block/Payment/Method/Form/Abstract.php CHANGED
@@ -155,6 +155,7 @@ class Payone_Core_Block_Payment_Method_Form_Abstract
155
 
156
  $systemTypes = $this->getSystemConfigMethodTypes();
157
 
 
158
  foreach ($this->getPaymentConfigs() as $key => $config) {
159
  $feeConfig = $config->getFeeConfigForQuote($quote);
160
 
@@ -173,7 +174,6 @@ class Payone_Core_Block_Payment_Method_Form_Abstract
173
  continue;
174
  }
175
 
176
- /** @var $config Payone_Core_Model_Config_Payment_Method */
177
  foreach ($configTypes as $keyType => $typeCode) {
178
  $configTypeKey = $configId . '_' . $typeCode; // key to correctly identify this config and type
179
  $return[$configTypeKey]['code'] = $typeCode;
155
 
156
  $systemTypes = $this->getSystemConfigMethodTypes();
157
 
158
+ /** @var $config Payone_Core_Model_Config_Payment_Method */
159
  foreach ($this->getPaymentConfigs() as $key => $config) {
160
  $feeConfig = $config->getFeeConfigForQuote($quote);
161
 
174
  continue;
175
  }
176
 
 
177
  foreach ($configTypes as $keyType => $typeCode) {
178
  $configTypeKey = $configId . '_' . $typeCode; // key to correctly identify this config and type
179
  $return[$configTypeKey]['code'] = $typeCode;
app/code/community/Payone/Core/Block/Payment/Method/Form/OnlineBankTransfer.php CHANGED
@@ -96,4 +96,28 @@ class Payone_Core_Block_Payment_Method_Form_OnlineBankTransfer
96
  $html = $block->toHtml();
97
  return $html;
98
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
96
  $html = $block->toHtml();
97
  return $html;
98
  }
99
+
100
+
101
+ /**
102
+ * Retrieve the payment config method id from Quote.
103
+ * If it matches payment method, return it, otherwise 0
104
+ * @return int|mixed
105
+ */
106
+ public function getPaymentMethodConfigId()
107
+ {
108
+ $preselectedConfigId = $this->getInfoData('payone_config_payment_method_id');
109
+
110
+ $preselectPossible = false;
111
+ foreach ($this->getTypes() as $type) {
112
+ if ($type['config_id'] == $preselectedConfigId) {
113
+ $preselectPossible = true;
114
+ }
115
+ }
116
+ if ($preselectPossible) {
117
+ return $preselectedConfigId;
118
+ }
119
+ else {
120
+ return 0;
121
+ }
122
+ }
123
  }
app/code/community/Payone/Core/Block/Payment/Method/Form/SafeInvoice.php CHANGED
@@ -58,4 +58,27 @@ class Payone_Core_Block_Payment_Method_Form_SafeInvoice
58
  {
59
  return $this->getFactory()->getModelSystemConfigSafeInvoiceType()->toSelectArray();
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
58
  {
59
  return $this->getFactory()->getModelSystemConfigSafeInvoiceType()->toSelectArray();
60
  }
61
+
62
+ /**
63
+ * Retrieve the payment config method id from Quote.
64
+ * If it matches payment method, return it, otherwise 0
65
+ * @return int|mixed
66
+ */
67
+ public function getPaymentMethodConfigId()
68
+ {
69
+ $preselectedConfigId = $this->getInfoData('payone_config_payment_method_id');
70
+
71
+ $preselectPossible = false;
72
+ foreach ($this->getTypes() as $type) {
73
+ if ($type['config_id'] == $preselectedConfigId) {
74
+ $preselectPossible = true;
75
+ }
76
+ }
77
+ if ($preselectPossible) {
78
+ return $preselectedConfigId;
79
+ }
80
+ else {
81
+ return 0;
82
+ }
83
+ }
84
  }
app/code/community/Payone/Core/Block/Payment/Method/Form/Wallet.php CHANGED
@@ -58,4 +58,27 @@ class Payone_Core_Block_Payment_Method_Form_Wallet
58
  {
59
  return $this->getFactory()->getModelSystemConfigWalletType()->toSelectArray();
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
58
  {
59
  return $this->getFactory()->getModelSystemConfigWalletType()->toSelectArray();
60
  }
61
+
62
+ /**
63
+ * Retrieve the payment config method id from Quote.
64
+ * If it matches payment method, return it, otherwise 0
65
+ * @return int|mixed
66
+ */
67
+ public function getPaymentMethodConfigId()
68
+ {
69
+ $preselectedConfigId = $this->getInfoData('payone_config_payment_method_id');
70
+
71
+ $preselectPossible = false;
72
+ foreach ($this->getTypes() as $type) {
73
+ if ($type['config_id'] == $preselectedConfigId) {
74
+ $preselectPossible = true;
75
+ }
76
+ }
77
+ if ($preselectPossible) {
78
+ return $preselectedConfigId;
79
+ }
80
+ else {
81
+ return 0;
82
+ }
83
+ }
84
  }
app/code/community/Payone/Core/Block/Payment/Method/Info/SafeInvoice.php CHANGED
@@ -150,7 +150,7 @@ class Payone_Core_Block_Payment_Method_Info_SafeInvoice
150
  */
151
  public function getPayoneClearingLegalnote()
152
  {
153
- return $this->getInfo()->getPayoneClearingBankName();
154
  }
155
 
156
 
150
  */
151
  public function getPayoneClearingLegalnote()
152
  {
153
+ return $this->getInfo()->getPayoneClearingLegalnote();
154
  }
155
 
156
 
app/code/community/Payone/Core/Model/Config/General/Global.php CHANGED
@@ -60,6 +60,14 @@ class Payone_Core_Model_Config_General_Global extends Payone_Core_Model_Config_A
60
  * @var string
61
  */
62
  protected $request_type = '';
 
 
 
 
 
 
 
 
63
 
64
  /**
65
  * initialize config with specificcounty as array
@@ -203,4 +211,36 @@ class Payone_Core_Model_Config_General_Global extends Payone_Core_Model_Config_A
203
  {
204
  return implode(',', $this->specificcountry);
205
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  }
60
  * @var string
61
  */
62
  protected $request_type = '';
63
+ /**
64
+ * @var int
65
+ */
66
+ protected $transmit_ip = 1;
67
+ /**
68
+ * @var int
69
+ */
70
+ protected $proxy_mode = 0;
71
 
72
  /**
73
  * initialize config with specificcounty as array
211
  {
212
  return implode(',', $this->specificcountry);
213
  }
214
+
215
+ /**
216
+ * @param int $transmit_ip
217
+ */
218
+ public function setTransmitIp($transmit_ip)
219
+ {
220
+ $this->transmit_ip = $transmit_ip;
221
+ }
222
+
223
+ /**
224
+ * @return int
225
+ */
226
+ public function getTransmitIp()
227
+ {
228
+ return $this->transmit_ip;
229
+ }
230
+
231
+ /**
232
+ * @param int $proxy_mode
233
+ */
234
+ public function setProxyMode($proxy_mode)
235
+ {
236
+ $this->proxy_mode = $proxy_mode;
237
+ }
238
+
239
+ /**
240
+ * @return int
241
+ */
242
+ public function getProxyMode()
243
+ {
244
+ return $this->proxy_mode;
245
+ }
246
  }
app/code/community/Payone/Core/Model/Config/General/StatusMapping.php CHANGED
@@ -92,16 +92,36 @@ class Payone_Core_Model_Config_General_StatusMapping extends Payone_Core_Model_C
92
  }
93
 
94
  foreach ($raw as $key => $data) {
95
- $txaction = $orderStatus = '';
96
  if (array_key_exists('txaction', $data)) {
97
  $txaction = array_shift($data['txaction']);
98
  }
99
- if (array_key_exists('status', $data)) {
100
- $orderStatus = array_shift($data['status']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
- if ($txaction == '' and $orderStatus == '') {
 
103
  continue;
104
  }
 
105
  $return[$txaction] = $orderStatus;
106
  }
107
  return $return;
92
  }
93
 
94
  foreach ($raw as $key => $data) {
95
+ $txaction = $orderStatus = null;
96
  if (array_key_exists('txaction', $data)) {
97
  $txaction = array_shift($data['txaction']);
98
  }
99
+
100
+ // State_Status Mapping @since 3.1.0
101
+ if (array_key_exists('state_status', $data)) {
102
+ $orderStateStatus = array_shift($data['state_status']);
103
+ $orderStateStatusArray = explode('|', $orderStateStatus);
104
+ if (count($orderStateStatusArray) !== 2) {
105
+ continue;
106
+ }
107
+ $orderStatus = array(
108
+ 'state' => $orderStateStatusArray[0],
109
+ 'status' => $orderStateStatusArray[1]
110
+ );
111
+ }
112
+ // Fallback to old Configs < 3.1.0
113
+ elseif (array_key_exists('status', $data)) {
114
+ $orderStatusCode = array_shift($data['status']);
115
+ $orderStatus = array(
116
+ 'state' => '',
117
+ 'status' => $orderStatusCode
118
+ );
119
  }
120
+
121
+ if ($txaction === null and $orderStatus === null) {
122
  continue;
123
  }
124
+
125
  $return[$txaction] = $orderStatus;
126
  }
127
  return $return;
app/code/community/Payone/Core/Model/Domain/Transaction.php CHANGED
@@ -63,7 +63,7 @@
63
  * @method setBalance($balance)
64
  * @method float getBalance()
65
  * @method setCustomerid($customerid)
66
- * @method int getCustomerid()
67
  * @method setUserid($userid)
68
  * @method int getUserid()
69
  * @method setReminderlevel($level)
63
  * @method setBalance($balance)
64
  * @method float getBalance()
65
  * @method setCustomerid($customerid)
66
+ * @method string getCustomerid()
67
  * @method setUserid($userid)
68
  * @method int getUserid()
69
  * @method setReminderlevel($level)
app/code/community/Payone/Core/Model/Factory.php CHANGED
@@ -784,6 +784,8 @@ class Payone_Core_Model_Factory
784
  $service->setServiceTransaction($this->getServiceTransactionUpdate());
785
  $service->setServiceOrderStatus($this->getServiceSalesOrderStatus());
786
  $service->setServiceOrderComment($this->getServiceSalesOrderComment());
 
 
787
 
788
  return $service;
789
  }
@@ -926,6 +928,18 @@ class Payone_Core_Model_Factory
926
  return $service;
927
  }
928
 
 
 
 
 
 
 
 
 
 
 
 
 
929
  /**
930
  * @return Payone_Core_Model_Service_Protocol_Api_Export
931
  */
@@ -1445,4 +1459,14 @@ class Payone_Core_Model_Factory
1445
  {
1446
  return new Varien_Http_Client();
1447
  }
 
 
 
 
 
 
 
 
 
 
1448
  }
784
  $service->setServiceTransaction($this->getServiceTransactionUpdate());
785
  $service->setServiceOrderStatus($this->getServiceSalesOrderStatus());
786
  $service->setServiceOrderComment($this->getServiceSalesOrderComment());
787
+ $service->setServiceStoreClearingParams($this->getServiceTransactionStatusStoreClearingParameters());
788
+
789
 
790
  return $service;
791
  }
928
  return $service;
929
  }
930
 
931
+ /**
932
+ * @return Payone_Core_Model_Service_Config_ProtectCheck
933
+ */
934
+ public function getServiceConfigProtectCheck()
935
+ {
936
+ /** @var $service Payone_Core_Model_Service_Config_ProtectCheck */
937
+ $service = Mage::getModel('payone_core/service_config_protectCheck');
938
+ $service->setFactory($this);
939
+
940
+ return $service;
941
+ }
942
+
943
  /**
944
  * @return Payone_Core_Model_Service_Protocol_Api_Export
945
  */
1459
  {
1460
  return new Varien_Http_Client();
1461
  }
1462
+
1463
+ /**
1464
+ * @return Mage_Core_Model_Config_Data
1465
+ */
1466
+ public function getModelCoreConfigData()
1467
+ {
1468
+ /** @var $configData Mage_Core_Model_Config_Data */
1469
+ $configData = Mage::getModel('core/config_data');
1470
+ return $configData;
1471
+ }
1472
  }
app/code/community/Payone/Core/Model/Handler/Verification/AddressCheck.php CHANGED
@@ -57,10 +57,16 @@ class Payone_Core_Model_Handler_Verification_AddressCheck
57
  // Do nothing, best case, resume with personStatus mapping.
58
  }
59
  elseif ($response->isCorrectable()) {
60
-
61
- if ($this->getConfig()->getConfirmAddressCorrection()) {
 
 
 
 
 
 
 
62
  // Address correction must be confirmed by customer, hand it up to controller/frontend
63
- $correctedAddress = $this->prepareAddressCorrectionDataForCustomer($response);
64
  $errors->setData('payone_address_corrected', $correctedAddress);
65
  }
66
  else {
57
  // Do nothing, best case, resume with personStatus mapping.
58
  }
59
  elseif ($response->isCorrectable()) {
60
+ $correctedAddress = $this->prepareAddressCorrectionDataForCustomer($response);
61
+ if($correctedAddress['city'] == $address->getCity()
62
+ && $correctedAddress['postcode'] == $address->getPostcode()
63
+ && $correctedAddress['street'] == $address->getStreetFull())
64
+ {
65
+ // PAYONE Api supports name correction, but it is not desired here, handle as a correct address.
66
+ $this->handleCorrectAddress();
67
+ }
68
+ elseif ($this->getConfig()->getConfirmAddressCorrection()) {
69
  // Address correction must be confirmed by customer, hand it up to controller/frontend
 
70
  $errors->setData('payone_address_corrected', $correctedAddress);
71
  }
72
  else {
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Abstract.php CHANGED
@@ -106,7 +106,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
106
  $params['pr'] = $order->getShippingInclTax();
107
  $params['va'] = $this->getShippingTaxRate();
108
 
109
- if($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
110
  $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
111
  }
112
 
@@ -120,32 +120,32 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
120
  * @param float $discountAmount
121
  * @return Payone_Api_Request_Parameter_Invoicing_Item
122
  */
123
- protected function mapDiscountAsItem($discountAmount)
124
- {
125
- $configMiscDiscount = $this->getConfigMisc()->getDiscount();
126
- $sku = $configMiscDiscount->getSku();
127
- $description = $configMiscDiscount->getDescription();
128
- if (empty($sku)) {
129
- $sku = $this->helper()->__(self::DEFAULT_DISCOUNT_SKU);
130
- }
131
- if (empty($description)) {
132
- $description = $this->helper()->__(self::DEFAULT_DISCOUNT_SKU);
133
- }
134
-
135
- $params['id'] = $sku;
136
- $params['de'] = $description;
137
- $params['no'] = 1;
138
- $params['pr'] = $discountAmount;
139
-
140
- if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
141
- $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER;
142
- }
143
- $item = new Payone_Api_Request_Parameter_Invoicing_Item();
144
- $item->init($params);
145
-
146
- return $item;
147
  }
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  /**
150
  * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
151
  * @return Payone_Api_Request_Parameter_Invoicing_Item
@@ -166,8 +166,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
166
  $params['de'] = $order->getShippingDescription();
167
  $params['no'] = 1;
168
  $params['pr'] = $creditmemo->getShippingInclTax();
169
- if($this->getPaymentMethod()->mustTransmitInvoicingItemTypes())
170
- {
171
  $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
172
  }
173
 
@@ -199,8 +198,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
199
  $params['de'] = $name;
200
  $params['no'] = 1;
201
  $params['pr'] = $creditmemo->getAdjustmentPositive();
202
- if($this->getPaymentMethod()->mustTransmitInvoicingItemTypes())
203
- {
204
  $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER;
205
  }
206
 
@@ -233,8 +231,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
233
  $params['de'] = $name;
234
  $params['no'] = 1;
235
  $params['pr'] = $creditmemo->getAdjustmentNegative() * (-1);
236
- if($this->getPaymentMethod()->mustTransmitInvoicingItemTypes())
237
- {
238
  $params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
239
  }
240
 
@@ -358,6 +355,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
358
 
359
  return false;
360
  }
 
361
  /**
362
  * @param Mage_Sales_Model_Abstract $object
363
  * @return string
@@ -433,6 +431,18 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
433
  return $this->getPaymentMethod()->getStore();
434
  }
435
 
 
 
 
 
 
 
 
 
 
 
 
 
436
  /**
437
  * @param Mage_Sales_Model_Order $order
438
  */
@@ -488,7 +498,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
488
  {
489
  return $this->getFactory()->helperConfig();
490
  }
491
-
492
  /**
493
  * @return Payone_Core_Helper_Registry
494
  */
106
  $params['pr'] = $order->getShippingInclTax();
107
  $params['va'] = $this->getShippingTaxRate();
108
 
109
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
110
  $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
111
  }
112
 
120
  * @param float $discountAmount
121
  * @return Payone_Api_Request_Parameter_Invoicing_Item
122
  */
123
+ protected function mapDiscountAsItem($discountAmount)
124
+ {
125
+ $configMiscDiscount = $this->getConfigMisc()->getDiscount();
126
+ $sku = $configMiscDiscount->getSku();
127
+ $description = $configMiscDiscount->getDescription();
128
+ if (empty($sku)) {
129
+ $sku = $this->helper()->__(self::DEFAULT_DISCOUNT_SKU);
130
+ }
131
+ if (empty($description)) {
132
+ $description = $this->helper()->__(self::DEFAULT_DISCOUNT_SKU);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
134
 
135
+ $params['id'] = $sku;
136
+ $params['de'] = $description;
137
+ $params['no'] = 1;
138
+ $params['pr'] = $discountAmount;
139
+
140
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
141
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER;
142
+ }
143
+ $item = new Payone_Api_Request_Parameter_Invoicing_Item();
144
+ $item->init($params);
145
+
146
+ return $item;
147
+ }
148
+
149
  /**
150
  * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
151
  * @return Payone_Api_Request_Parameter_Invoicing_Item
166
  $params['de'] = $order->getShippingDescription();
167
  $params['no'] = 1;
168
  $params['pr'] = $creditmemo->getShippingInclTax();
169
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
 
170
  $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
171
  }
172
 
198
  $params['de'] = $name;
199
  $params['no'] = 1;
200
  $params['pr'] = $creditmemo->getAdjustmentPositive();
201
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
 
202
  $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER;
203
  }
204
 
231
  $params['de'] = $name;
232
  $params['no'] = 1;
233
  $params['pr'] = $creditmemo->getAdjustmentNegative() * (-1);
234
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
 
235
  $params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
236
  }
237
 
355
 
356
  return false;
357
  }
358
+
359
  /**
360
  * @param Mage_Sales_Model_Abstract $object
361
  * @return string
431
  return $this->getPaymentMethod()->getStore();
432
  }
433
 
434
+ /**
435
+ * @param $storeId
436
+ * @return Payone_Core_Model_Config_General
437
+ */
438
+ protected function getConfigGeneral($storeId = null)
439
+ {
440
+ if (is_null($storeId)) {
441
+ $storeId = $this->getStoreId();
442
+ }
443
+ return $this->helperConfig()->getConfigGeneral($storeId);
444
+ }
445
+
446
  /**
447
  * @param Mage_Sales_Model_Order $order
448
  */
498
  {
499
  return $this->getFactory()->helperConfig();
500
  }
501
+
502
  /**
503
  * @return Payone_Core_Helper_Registry
504
  */
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php CHANGED
@@ -101,7 +101,6 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
101
  }
102
 
103
 
104
-
105
  /**
106
  * @param Payone_Api_Request_Authorization_Abstract $request
107
  */
@@ -165,10 +164,23 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
165
  $personalData->setLanguage($language);
166
  $personalData->setVatid($order->getCustomerTaxvat());
167
 
168
- // Multiple Ips can be included, we only send the last one.
169
- $remoteIps = explode(',', $order->getRemoteIp());
170
- $lastRemoteIp = array_pop($remoteIps);
171
- $personalData->setIp($lastRemoteIp);
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
  // US and CA always need state and shipping_state paramters
174
  if ($billingCountry == 'US' or $billingCountry == 'CA') {
@@ -186,11 +198,14 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
186
  $helper = $this->helper();
187
  $paymentMethod = $this->getPaymentMethod();
188
  $info = $paymentMethod->getInfoInstance();
189
- if($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice
190
- and $info->getPayoneSafeInvoiceType() === Payone_Api_Enum_FinancingType::BSV)
191
- $address = $this->getOrder()->getBillingAddress(); // Always use same address for BillSAFE
192
- else
 
 
193
  $address = $this->getOrder()->getShippingAddress();
 
194
 
195
  $deliveryData = new Payone_Api_Request_Parameter_Authorization_DeliveryData();
196
 
@@ -229,7 +244,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
229
  foreach ($order->getItemsCollection() as $key => $itemData) {
230
  /** @var $itemData Mage_Sales_Model_Order_Item */
231
  if ($itemData->isDummy()) {
232
- continue;// Do not map dummy items
233
  }
234
 
235
  $number = $itemData->getQtyToInvoice();
@@ -415,8 +430,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
415
  */
416
  protected function getNarrativeText($type)
417
  {
418
- $storeId = $this->getPaymentMethod()->getStore();
419
- $general = $this->helperConfig()->getConfigGeneral($storeId);
420
  $parameterNarrativeText = $general->getParameterNarrativeText();
421
 
422
  $narrativeText = '';
101
  }
102
 
103
 
 
104
  /**
105
  * @param Payone_Api_Request_Authorization_Abstract $request
106
  */
164
  $personalData->setLanguage($language);
165
  $personalData->setVatid($order->getCustomerTaxvat());
166
 
167
+ $global = $this->getConfigGeneral()->getGlobal();
168
+ // Send Ip when enabled
169
+ if ($global->getTransmitIp()) {
170
+ if ($global->getProxyMode()) {
171
+ // Use X-Forwarded-For when in Proxy-Mode
172
+ $remoteIp = $order->getXForwardedFor();
173
+ }
174
+ else {
175
+ $remoteIp = $order->getRemoteIp();
176
+ }
177
+
178
+ // Multiple Ips could be included, we only send the last one.
179
+ $remoteIps = explode(',', $remoteIp);
180
+ $ip = array_pop($remoteIps);
181
+
182
+ $personalData->setIp($ip);
183
+ }
184
 
185
  // US and CA always need state and shipping_state paramters
186
  if ($billingCountry == 'US' or $billingCountry == 'CA') {
198
  $helper = $this->helper();
199
  $paymentMethod = $this->getPaymentMethod();
200
  $info = $paymentMethod->getInfoInstance();
201
+ if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice
202
+ and $info->getPayoneSafeInvoiceType() === Payone_Api_Enum_FinancingType::BSV
203
+ ) {
204
+ $address = $this->getOrder()->getBillingAddress();
205
+ } // Always use same address for BillSAFE
206
+ else {
207
  $address = $this->getOrder()->getShippingAddress();
208
+ }
209
 
210
  $deliveryData = new Payone_Api_Request_Parameter_Authorization_DeliveryData();
211
 
244
  foreach ($order->getItemsCollection() as $key => $itemData) {
245
  /** @var $itemData Mage_Sales_Model_Order_Item */
246
  if ($itemData->isDummy()) {
247
+ continue; // Do not map dummy items
248
  }
249
 
250
  $number = $itemData->getQtyToInvoice();
430
  */
431
  protected function getNarrativeText($type)
432
  {
433
+ $general = $this->getConfigGeneral();
 
434
  $parameterNarrativeText = $general->getParameterNarrativeText();
435
 
436
  $narrativeText = '';
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Capture.php CHANGED
@@ -102,25 +102,29 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
102
 
103
  $paymentMethod = $this->getPaymentMethod();
104
 
105
- // Some payment methods can not use settleaccount auto:
106
  if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_AdvancePayment
107
- or $paymentMethod instanceof Payone_Core_Model_Payment_Method_Invoice)
108
  {
109
- // Check if the invoice completes the order
110
- if ($this->isInvoiceLast()) {
 
 
111
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
112
  }
113
  else {
 
114
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::NO);
115
  }
116
  }
117
- else if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice)
118
  {
119
  // BillSAFE always settles account:
120
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::YES);
121
  }
122
  else
123
  {
 
124
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
125
  }
126
  return $business;
@@ -192,7 +196,9 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
192
  }
193
 
194
  // Capture mode:
195
- if ($this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_SafeInvoice) {
 
 
196
  $invoicing->setCapturemode($this->mapCaptureMode());
197
  }
198
 
102
 
103
  $paymentMethod = $this->getPaymentMethod();
104
 
105
+ // settleaccount possibilities depend on payment method:
106
  if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_AdvancePayment
107
+ or $paymentMethod instanceof Payone_Core_Model_Payment_Method_OnlineBankTransfer)
108
  {
109
+ $payment = $paymentMethod->getInfoInstance();
110
+ // Advancepayment and OnlineBankTransfer use NO/AUTO
111
+ if ($this->isInvoiceLast() || $this->helperRegistry()->isPaymentCancelRegistered($payment)) {
112
+ // Invoice completes the order
113
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
114
  }
115
  else {
116
+ // partial payment
117
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::NO);
118
  }
119
  }
120
+ elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice)
121
  {
122
  // BillSAFE always settles account:
123
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::YES);
124
  }
125
  else
126
  {
127
+ // all other can always use AUTO, regardless of complete or partial capture
128
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
129
  }
130
  return $business;
196
  }
197
 
198
  // Capture mode:
199
+ $payment = $this->getPaymentMethod()->getInfoInstance();
200
+ if ($this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_SafeInvoice
201
+ or $this->helperRegistry()->isPaymentCancelRegistered($payment)) {
202
  $invoicing->setCapturemode($this->mapCaptureMode());
203
  }
204
 
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Debit.php CHANGED
@@ -179,6 +179,12 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
179
  if ($creditmemo->getAdjustmentNegative() > 0) {
180
  $invoicing->addItem($this->mapAdjustmentNegativeAsItemByCreditmemo($creditmemo));
181
  }
 
 
 
 
 
 
182
  }
183
  return $invoicing;
184
  }
179
  if ($creditmemo->getAdjustmentNegative() > 0) {
180
  $invoicing->addItem($this->mapAdjustmentNegativeAsItemByCreditmemo($creditmemo));
181
  }
182
+
183
+ // Add Discount as a position
184
+ $discountAmount = $creditmemo->getDiscountAmount();
185
+ if ($discountAmount > 0) {
186
+ $invoicing->addItem($this->mapDiscountAsItem(-1 * $discountAmount));
187
+ }
188
  }
189
  return $invoicing;
190
  }
app/code/community/Payone/Core/Model/Observer/{TransactionStatus/StoreClearingParameters.php → Config/Protect.php} RENAMED
@@ -13,9 +13,10 @@
13
  * needs please refer to http://www.payone.de for more information.
14
  *
15
  * @category Payone
16
- * @package Payone_Core_Model_Service_Abstract
17
- * @subpackage Response
18
- * @copyright Copyright (c) 2012 <info@payone.de> - www.noovias.com
 
19
  * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
20
  * @link http://www.noovias.com
21
  */
@@ -23,29 +24,23 @@
23
  /**
24
  *
25
  * @category Payone
26
- * @package Payone_Core_Model_Service_Abstract
27
- * @subpackage Response
28
  * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
29
  * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
30
  * @link http://www.noovias.com
31
- *
32
  */
33
- class Payone_Core_Model_Observer_TransactionStatus_StoreClearingParameters
34
  extends Payone_Core_Model_Observer_Abstract
35
  {
 
36
  /**
37
  * @param Varien_Event_Observer $observer
38
  */
39
- public function onAppointed(Varien_Event_Observer $observer)
40
- {
41
-
42
- $event = $observer->getEvent();
43
-
44
- /** @var $transactionStatus Payone_Core_Model_Domain_Protocol_TransactionStatus */
45
- $transactionStatus = $event->getTransactionStatus();
46
-
47
- $service = $this->getFactory()->getServiceTransactionStatusStoreClearingParameters();
48
 
49
- $service->execute($transactionStatus);
 
 
50
  }
51
  }
13
  * needs please refer to http://www.payone.de for more information.
14
  *
15
  * @category Payone
16
+ * @package Payone_Core_Model
17
+ * @subpackage Observer
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
  * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
  * @link http://www.noovias.com
22
  */
24
  /**
25
  *
26
  * @category Payone
27
+ * @package Payone_Core_Model
28
+ * @subpackage Observer
29
  * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
  * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
  * @link http://www.noovias.com
 
32
  */
33
+ class Payone_Core_Model_Observer_Config_Protect
34
  extends Payone_Core_Model_Observer_Abstract
35
  {
36
+
37
  /**
38
  * @param Varien_Event_Observer $observer
39
  */
40
+ public function checkAllStatuses(Varien_Event_Observer $observer){
 
 
 
 
 
 
 
 
41
 
42
+ $serviceProtectCheck = $this->getFactory()->getServiceConfigProtectCheck();
43
+ $serviceProtectCheck->setScopeId(0);
44
+ $serviceProtectCheck->execute();
45
  }
46
  }
app/code/community/Payone/Core/Model/Observer/Sales/Order.php CHANGED
@@ -74,11 +74,6 @@ class Payone_Core_Model_Observer_Sales_Order
74
 
75
  $methodInstance = $payment->getMethodInstance();
76
 
77
- if($methodInstance instanceof Payone_Core_Model_Payment_Method_Financing
78
- || $methodInstance instanceof Payone_Core_Model_Payment_Method_SafeInvoice)
79
- {
80
-
81
- $methodInstance->cancel($payment);
82
- }
83
  }
84
  }
74
 
75
  $methodInstance = $payment->getMethodInstance();
76
 
77
+ $methodInstance->cancel($payment);
 
 
 
 
 
78
  }
79
  }
app/code/community/Payone/Core/Model/Payment/Method/Abstract.php CHANGED
@@ -70,13 +70,19 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
70
  */
71
  public function isAvailable($quote = null)
72
  {
73
- if ($quote === null) {
74
- $configPayment = $this->getConfigPayment(null);
75
- return $configPayment->isAvailable($this->getMethodType());
76
  }
 
 
 
 
 
 
 
 
77
 
78
- $configPayment = $this->helperConfig()->getConfigPaymentByQuote($quote);
79
- return $configPayment->isAvailable($this->getMethodType(), $quote);
80
  }
81
 
82
  /**
@@ -116,6 +122,25 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
116
  return $canUse;
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  /**
120
  * Called before initalize to determine action needed
121
  *
@@ -330,6 +355,40 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
330
  return $data;
331
  }
332
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  /**
334
  * Some Payment methods require transmitting of invoicing data, regardless of configuration.
335
  *
@@ -385,6 +444,14 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
385
  return $this->getFactory()->helper();
386
  }
387
 
 
 
 
 
 
 
 
 
388
  /**
389
  * @return Payone_Core_Helper_Config
390
  */
70
  */
71
  public function isAvailable($quote = null)
72
  {
73
+ if (is_null($quote)) {
74
+ // No quote given, availability check is basic (e.g. method is enabled, not marked as deleted)
75
+ $configPayment = $this->getConfigPayment();
76
  }
77
+ else {
78
+ // Quote is given, availability check is detailed (includes store, country settings, min/max quote totals, etc.)
79
+ $configPayment = $this->helperConfig()->getConfigPaymentByQuote($quote);
80
+ }
81
+ $isAvailable = $configPayment->isAvailable($this->getMethodType(), $quote);
82
+
83
+ return $this->dispatchPaymentMethodIsActive($isAvailable, $quote);
84
+
85
 
 
 
86
  }
87
 
88
  /**
122
  return $canUse;
123
  }
124
 
125
+ /**
126
+ * @param Varien_Object $payment
127
+ * @return Mage_Payment_Model_Method_Abstract
128
+ */
129
+ public function cancel(Varien_Object $payment)
130
+ {
131
+ $status = $payment->getOrder()->getPayoneTransactionStatus();
132
+
133
+ if (empty($status) or $status == 'REDIRECT') {
134
+ return $this; // Don´t send cancel to PAYONE on orders without TxStatus
135
+ }
136
+
137
+ // Capture0, to notify PAYONE that the order is complete (invoiced/cancelled all items)
138
+ $this->helperRegistry()->registerPaymentCancel($this->getInfoInstance());
139
+ $this->capture($payment, 0.0000);
140
+
141
+ return $this;
142
+ }
143
+
144
  /**
145
  * Called before initalize to determine action needed
146
  *
355
  return $data;
356
  }
357
 
358
+ /**
359
+ * Trigger Magento Standard Event, to allow changing of isAvailable() result
360
+ *
361
+ * @param bool $isAvailable
362
+ * @param Mage_Sales_Model_Quote $quote
363
+ * @return bool
364
+ */
365
+ protected function dispatchPaymentMethodIsActive($isAvailable, $quote)
366
+ {
367
+ $checkResult = new StdClass;
368
+ $checkResult->isAvailable = $isAvailable;
369
+
370
+ $this->dispatchEvent('payment_method_is_active', array(
371
+ 'result' => $checkResult,
372
+ 'method_instance' => $this,
373
+ 'quote' => $quote,
374
+ ));
375
+
376
+ return $checkResult->isAvailable;
377
+ }
378
+
379
+ /**
380
+ * Wrapper for Mage::dispatchEvent()
381
+ *
382
+ * @param $name
383
+ * @param array $data
384
+ *
385
+ * @return Mage_Core_Model_App
386
+ */
387
+ protected function dispatchEvent($name, array $data = array())
388
+ {
389
+ return Mage::dispatchEvent($name, $data);
390
+ }
391
+
392
  /**
393
  * Some Payment methods require transmitting of invoicing data, regardless of configuration.
394
  *
444
  return $this->getFactory()->helper();
445
  }
446
 
447
+ /**
448
+ * @return Payone_Core_Helper_Registry
449
+ */
450
+ protected function helperRegistry()
451
+ {
452
+ return $this->getFactory()->helperRegistry();
453
+ }
454
+
455
  /**
456
  * @return Payone_Core_Helper_Config
457
  */
app/code/community/Payone/Core/Model/Payment/Method/SafeInvoice.php CHANGED
@@ -53,35 +53,23 @@ class Payone_Core_Model_Payment_Method_SafeInvoice
53
  /** @var Payone_Core_Model_Config_Payment_Method_Interface[] */
54
  protected $matchingConfigs = array();
55
 
 
 
 
 
 
 
56
  public function isAvailable($quote = null)
57
  {
58
  if (!empty($quote) &&
59
- count($this->getAllConfigsByQuote($quote)) < 1) {
60
- return false;
 
61
  }
62
 
63
  return parent::isAvailable($quote);
64
  }
65
 
66
-
67
- /**
68
- * @param Varien_Object $payment
69
- * @return Mage_Payment_Model_Method_Abstract
70
- */
71
- public function cancel(Varien_Object $payment)
72
- {
73
- $status = $payment->getOrder()->getPayoneTransactionStatus();
74
-
75
- if(empty($status) or $status == 'REDIRECT')
76
- return $this; // Don´t send cancel to PAYONE on orders without TxStatus
77
-
78
- // Capture0, to notify Magento that the order is complete (invoiced/cancelled all items)
79
- $this->helperRegistry()->registerPaymentCancel($this->getInfoInstance());
80
- $this->capture($payment, 0.0000);
81
-
82
- return $this;
83
- }
84
-
85
  /**
86
  * @api
87
  *
@@ -147,12 +135,4 @@ class Payone_Core_Model_Payment_Method_SafeInvoice
147
 
148
  return true;
149
  }
150
-
151
- /**
152
- * @return Payone_Core_Helper_Registry
153
- */
154
- protected function helperRegistry()
155
- {
156
- return $this->getFactory()->helperRegistry();
157
- }
158
  }
53
  /** @var Payone_Core_Model_Config_Payment_Method_Interface[] */
54
  protected $matchingConfigs = array();
55
 
56
+ /**
57
+ * @override to further restrict availability of SafeInvoice by rules
58
+ *
59
+ * @param null|Mage_Sales_Model_Quote $quote
60
+ * @return bool
61
+ */
62
  public function isAvailable($quote = null)
63
  {
64
  if (!empty($quote) &&
65
+ count($this->getAllConfigsByQuote($quote)) < 1
66
+ ) {
67
+ return $this->dispatchPaymentMethodIsActive(false, $quote);
68
  }
69
 
70
  return parent::isAvailable($quote);
71
  }
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  /**
74
  * @api
75
  *
135
 
136
  return true;
137
  }
 
 
 
 
 
 
 
 
138
  }
app/code/community/Payone/Core/Model/Service/Config/ProtectCheck.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
+ * versions in the future. If you wish to customize Payone_Core for your
13
+ * needs please refer to http://www.payone.de for more information.
14
+ *
15
+ * @category Payone
16
+ * @package Payone_Core_Model
17
+ * @subpackage Service
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.noovias.com
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @category Payone
27
+ * @package Payone_Core_Model
28
+ * @subpackage Service
29
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
+ * @link http://www.noovias.com
32
+ */
33
+ class Payone_Core_Model_Service_Config_ProtectCheck
34
+ extends Payone_Core_Model_Service_Abstract
35
+ {
36
+
37
+ /**
38
+ * @var null
39
+ */
40
+ protected $scopeId = null;
41
+
42
+ /**
43
+ * @param $addressCheckEnabled
44
+ * @param $creditratingEnabled
45
+ */
46
+ public function execute($addressCheckEnabled = null, $creditratingEnabled = null)
47
+ {
48
+ $protectValue = 0;
49
+
50
+ if ($addressCheckEnabled == 1 || $creditratingEnabled == 1) {
51
+ $protectValue = 1;
52
+ }
53
+ else {
54
+ $configCollection = $this->getFilteredModelConfigCollection();
55
+
56
+ $configData = $configCollection->getFirstItem();
57
+ if ($configData->hasData()) {
58
+ $protectValue = 1;
59
+ }
60
+ }
61
+
62
+ $path = 'payone_protect/general/enabled';
63
+
64
+ /**
65
+ * @var $protect Mage_Core_Model_Config_Data
66
+ */
67
+ $protect = $this->getFactory()->getModelCoreConfigData();
68
+ $protect->setScope('default');
69
+ $protect->setScopeId(0);
70
+
71
+ $protect->setPath($path);
72
+
73
+ /** We must check wheter there is a DB entry for the unique constraint 'config_scope'
74
+ * in Magento versions < 1.6 (in newer versions this check is done by Magento)
75
+ *
76
+ * @see Mage_Core_Model_Resource_Config_Data::_checkUnique() since Magento 1.6.0.0
77
+ */
78
+ if (version_compare($this->helper()->getMagentoVersion(), '1.6', '<')) {
79
+ $protect = $this->checkConfigUnique($protect);
80
+ }
81
+
82
+ $protect->setValue($protectValue);
83
+
84
+ return $protect->save();
85
+ }
86
+
87
+ /**
88
+ * @param Mage_Core_Model_Config_Data $object
89
+ * @return Mage_Core_Model_Config_Data
90
+ */
91
+ protected function checkConfigUnique(Mage_Core_Model_Config_Data $object)
92
+ {
93
+ /** @var $collection Mage_Core_Model_Mysql4_Config_Data_Collection | Mage_Core_Model_Resource_Config_Data_Collection */
94
+ $collection = $this->getFactory()->getModelCoreConfigData()->getCollection();
95
+ $collection->addFieldToFilter('scope', $object->getScope());
96
+ $collection->addFieldToFilter('scope_id', $object->getScopeId());
97
+ $collection->addFieldToFilter('path', $object->getPath());
98
+ $collection->load();
99
+
100
+ if ($collection->count() > 0) {
101
+ /** @var $config Mage_Core_Model_Config_Data */
102
+ $config = $collection->getFirstItem();
103
+ $object->setId($config->getId());
104
+ }
105
+
106
+ return $object;
107
+ }
108
+
109
+ /**
110
+ * Add default filter to collection
111
+ *
112
+ * @return Mage_Core_Model_Mysql4_Config_Data_Collection
113
+ */
114
+ protected function getFilteredModelConfigCollection()
115
+ {
116
+ /** @var $configCollection Mage_Core_Model_Mysql4_Config_Data_Collection */
117
+ $configCollection = $this->getFactory()->getModelCoreConfigData()->getCollection();
118
+ $configCollection->addFieldToFilter('path',
119
+ array(
120
+ array('eq' => 'payone_protect/creditrating/enabled'),
121
+ array('eq' => 'payone_protect/address_check/enabled'))
122
+ );
123
+ $configCollection->addFieldToFilter('value', array('eq' => '1'));
124
+
125
+ return $configCollection;
126
+ }
127
+
128
+ /**
129
+ * @param $scopeId
130
+ */
131
+ public function setScopeId($scopeId)
132
+ {
133
+ $this->scopeId = $scopeId;
134
+ }
135
+
136
+ /**
137
+ * @return int|null
138
+ */
139
+ public function getScopeId()
140
+ {
141
+ return $this->scopeId;
142
+ }
143
+ }
app/code/community/Payone/Core/Model/Service/Config/XmlGenerate.php CHANGED
@@ -52,7 +52,7 @@ class Payone_Core_Model_Service_Config_XmlGenerate
52
 
53
  $stores = $this->getStores();
54
  foreach ($stores as $store) {
55
- /** @var $store Mage_Core_Model_Store */
56
  /** @var $config Payone_Core_Model_Config */
57
  $this->store = $store;
58
  $config = $serviceConfig->execute($store->getStoreId());
@@ -160,7 +160,7 @@ class Payone_Core_Model_Service_Config_XmlGenerate
160
  $statusMapping = $general->getStatusMapping();
161
  $paymentCreditcard = $general->getPaymentCreditcard();
162
 
163
- /** @var $globalConfig Payone_Settings_Data_ConfigFile_Shop_Global */
164
  $globalConfig = $this->generateSettingsBySection('shop_global', $global);
165
  $statusMappingConfig = new Payone_Settings_Data_ConfigFile_Global_StatusMapping();
166
  foreach ($statusMapping->toArray() as $keyClearingType => $mapping) {
@@ -171,7 +171,13 @@ class Payone_Core_Model_Service_Config_XmlGenerate
171
  foreach ($mapping as $key => $value) {
172
  $singleMap = array();
173
  $singleMap['from'] = $key;
174
- $singleMap['to'] = $value;
 
 
 
 
 
 
175
  array_push($data, $singleMap);
176
  }
177
  $statusMappingConfig->addStatusMapping($keyClearingType, $data);
@@ -354,8 +360,9 @@ class Payone_Core_Model_Service_Config_XmlGenerate
354
  */
355
  protected function getPaymentMethodClass($key)
356
  {
357
- if($key === 'safe_invoice')
358
- $key = 'financing'; // safe_invoice is a sub-paymentmethod of financing in SDK.
 
359
  $key = uc_words($key, '');
360
  $classname = self::PAYMENT_METHOD_CLASS_PREFIX . $key;
361
  $classInstance = new $classname();
52
 
53
  $stores = $this->getStores();
54
  foreach ($stores as $store) {
55
+ /** @var $store Mage_Core_Model_Store */
56
  /** @var $config Payone_Core_Model_Config */
57
  $this->store = $store;
58
  $config = $serviceConfig->execute($store->getStoreId());
160
  $statusMapping = $general->getStatusMapping();
161
  $paymentCreditcard = $general->getPaymentCreditcard();
162
 
163
+ /** @var $globalConfig Payone_Settings_Data_ConfigFile_Shop_Global */
164
  $globalConfig = $this->generateSettingsBySection('shop_global', $global);
165
  $statusMappingConfig = new Payone_Settings_Data_ConfigFile_Global_StatusMapping();
166
  foreach ($statusMapping->toArray() as $keyClearingType => $mapping) {
171
  foreach ($mapping as $key => $value) {
172
  $singleMap = array();
173
  $singleMap['from'] = $key;
174
+
175
+ $mapTo = $value;
176
+ if (is_array($value)) {
177
+ $mapTo = implode('|', $value);
178
+ }
179
+ $singleMap['to'] = $mapTo;
180
+
181
  array_push($data, $singleMap);
182
  }
183
  $statusMappingConfig->addStatusMapping($keyClearingType, $data);
360
  */
361
  protected function getPaymentMethodClass($key)
362
  {
363
+ if ($key === 'safe_invoice') {
364
+ $key = 'financing';
365
+ } // safe_invoice is a sub-paymentmethod of financing in SDK.
366
  $key = uc_words($key, '');
367
  $classname = self::PAYMENT_METHOD_CLASS_PREFIX . $key;
368
  $classInstance = new $classname();
app/code/community/Payone/Core/Model/Service/Sales/OrderStatus.php CHANGED
@@ -45,7 +45,7 @@ class Payone_Core_Model_Service_Sales_OrderStatus extends Payone_Core_Model_Serv
45
  $order->setPayoneTransactionStatus($transactionStatus->getTxaction());
46
 
47
  // Update dunning status
48
- if($transactionStatus->getReminderlevel()){
49
  $order->setPayoneDunningStatus($transactionStatus->getReminderlevel());
50
  }
51
 
@@ -59,17 +59,31 @@ class Payone_Core_Model_Service_Sales_OrderStatus extends Payone_Core_Model_Serv
59
  $paymentMethod = $order->getPayment()->getMethodInstance();
60
  $type = $paymentMethod->getMethodType();
61
 
62
-
63
  $mapping = $statusMapping->getByType($type);
 
 
 
64
 
65
- if (!is_array($mapping)
66
- or !array_key_exists($txAction, $mapping)) {
 
 
 
 
67
  return;
68
  }
69
 
70
- $newOrderStatus = $mapping[$txAction];
 
 
71
 
72
- $order->setStatus($newOrderStatus);
 
 
 
 
 
73
  }
74
 
75
  /**
45
  $order->setPayoneTransactionStatus($transactionStatus->getTxaction());
46
 
47
  // Update dunning status
48
+ if ($transactionStatus->getReminderlevel()) {
49
  $order->setPayoneDunningStatus($transactionStatus->getReminderlevel());
50
  }
51
 
59
  $paymentMethod = $order->getPayment()->getMethodInstance();
60
  $type = $paymentMethod->getMethodType();
61
 
62
+ // Mapping
63
  $mapping = $statusMapping->getByType($type);
64
+ if (!is_array($mapping) or !array_key_exists($txAction, $mapping)) {
65
+ return;
66
+ }
67
 
68
+ // Check for valid Mapping
69
+ $mappingOrderState = $mapping[$txAction];
70
+ if (!is_array($mappingOrderState)
71
+ or !array_key_exists('status', $mappingOrderState)
72
+ or !array_key_exists('state', $mappingOrderState)
73
+ ) {
74
  return;
75
  }
76
 
77
+ // Get State / Status and set to Order
78
+ $newOrderState = $mappingOrderState['state'];
79
+ $newOrderStatus = $mappingOrderState['status'];
80
 
81
+ if($newOrderState != '') {
82
+ $order->setState($newOrderState, $newOrderStatus);
83
+ }
84
+ else {
85
+ $order->setStatus($newOrderStatus);
86
+ }
87
  }
88
 
89
  /**
app/code/community/Payone/Core/Model/Service/TransactionStatus/Process.php CHANGED
@@ -54,6 +54,11 @@ class Payone_Core_Model_Service_TransactionStatus_Process extends Payone_Core_Mo
54
  */
55
  protected $serviceOrderComment = null;
56
 
 
 
 
 
 
57
  /**
58
  * @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus
59
  * @throws Payone_Core_Exception_OrderNotFound
@@ -90,12 +95,16 @@ class Payone_Core_Model_Service_TransactionStatus_Process extends Payone_Core_Mo
90
  // Add Order Comment
91
  $this->getServiceOrderComment()->addByTransactionStatus($order, $transactionStatus);
92
 
 
 
 
93
  // Save before Event is triggerd
94
  $resouce = $this->getFactory()->getModelResourceTransaction();
95
  $resouce->addObject($order);
96
  $resouce->addObject($transactionStatus);
97
  $resouce->save();
98
 
 
99
  // Trigger Event
100
  $params = array(
101
  self::EVENT_PARAMETER_TRANSACTIONSTATUS => $transactionStatus,
@@ -165,4 +174,21 @@ class Payone_Core_Model_Service_TransactionStatus_Process extends Payone_Core_Mo
165
  return $this->serviceTransaction;
166
  }
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  }
54
  */
55
  protected $serviceOrderComment = null;
56
 
57
+ /**
58
+ * @var Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters
59
+ */
60
+ protected $serviceStoreClearingParams = null;
61
+
62
  /**
63
  * @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus
64
  * @throws Payone_Core_Exception_OrderNotFound
95
  // Add Order Comment
96
  $this->getServiceOrderComment()->addByTransactionStatus($order, $transactionStatus);
97
 
98
+ // Store Clearing Parameters (needs to be done before the events get triggered)
99
+ $this->getServiceStoreClearingParams()->execute($transactionStatus, $order);
100
+
101
  // Save before Event is triggerd
102
  $resouce = $this->getFactory()->getModelResourceTransaction();
103
  $resouce->addObject($order);
104
  $resouce->addObject($transactionStatus);
105
  $resouce->save();
106
 
107
+
108
  // Trigger Event
109
  $params = array(
110
  self::EVENT_PARAMETER_TRANSACTIONSTATUS => $transactionStatus,
174
  return $this->serviceTransaction;
175
  }
176
 
177
+ /**
178
+ * @param Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters $serviceStoreClearingParams
179
+ */
180
+ public function setServiceStoreClearingParams(Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters $serviceStoreClearingParams)
181
+ {
182
+ $this->serviceStoreClearingParams = $serviceStoreClearingParams;
183
+ }
184
+
185
+ /**
186
+ * @return Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters
187
+ */
188
+ public function getServiceStoreClearingParams()
189
+ {
190
+ return $this->serviceStoreClearingParams;
191
+ }
192
+
193
+
194
  }
app/code/community/Payone/Core/Model/Service/TransactionStatus/StoreClearingParameters.php CHANGED
@@ -32,15 +32,23 @@
32
  */
33
  class Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters
34
  extends Payone_Core_Model_Service_Abstract
35
- { /**
 
36
  * @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus
 
 
37
  */
38
- public function execute(Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus)
39
  {
40
- // Map clearing params:
41
- $order = $this->getFactory()->getModelSalesOrder();
42
- $order->load($transactionStatus->getOrderId());
43
 
 
 
 
 
 
 
 
 
44
  $payment = $order->getPayment();
45
  $methodInstance = $payment->getMethodInstance();
46
 
@@ -49,6 +57,7 @@ class Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters
49
  return;
50
  }
51
 
 
52
  $config = $this->helperConfig()->getConfigPaymentMethodByOrder($order);
53
 
54
 
32
  */
33
  class Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters
34
  extends Payone_Core_Model_Service_Abstract
35
+ {
36
+ /**
37
  * @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus
38
+ * @param Mage_Sales_Model_Order $order
39
+ * @return void
40
  */
41
+ public function execute(Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus, Mage_Sales_Model_Order $order = null)
42
  {
 
 
 
43
 
44
+ if(!$transactionStatus->isAppointed())
45
+ return;
46
+
47
+ if(is_null($order))
48
+ {
49
+ $order = $this->getFactory()->getModelSalesOrder();
50
+ $order->load($transactionStatus->getOrderId());
51
+ }
52
  $payment = $order->getPayment();
53
  $methodInstance = $payment->getMethodInstance();
54
 
57
  return;
58
  }
59
 
60
+
61
  $config = $this->helperConfig()->getConfigPaymentMethodByOrder($order);
62
 
63
 
app/code/community/Payone/Core/Model/System/Config/Backend/Protect.php CHANGED
@@ -32,73 +32,39 @@
32
  */
33
  class Payone_Core_Model_System_Config_Backend_Protect extends Mage_Core_Model_Config_Data
34
  {
 
 
 
35
  protected function _beforeSave()
36
  {
37
  $addressCheckEnabled = $this->getData('groups/address_check/fields/enabled/value');
38
  $creditratingEnabled = $this->getData('groups/creditrating/fields/enabled/value');
39
 
40
- if ($addressCheckEnabled == 1 or $creditratingEnabled == 1) {
41
- $protectValue = 1;
42
- }
43
- else {
44
- $protectValue = 0;
45
- }
46
-
47
- $path = 'payone_protect/general/enabled';
48
-
49
- /**
50
- * @var $protect Mage_Core_Model_Config_Data
51
- */
52
- $protect = Mage::getModel('core/config_data');
53
- $protect->setScope($this->getScope());
54
- $protect->setScopeId($this->getScopeId());
55
-
56
- $protect->setPath($path);
57
-
58
- /** We must check wheter there is a DB entry for the unique constraint 'config_scope'
59
- * in Magento versions < 1.6 (in newer versions this check is done by Magento)
60
- *
61
- * @see Mage_Core_Model_Resource_Config_Data::_checkUnique() since Magento 1.6.0.0
62
- */
63
- if(version_compare($this->helper()->getMagentoVersion(), '1.6','<')) {
64
- $protect = $this->checkConfigUnique($protect);
65
- }
66
-
67
- $protect->setValue($protectValue);
68
-
69
- $protect->save();
70
 
71
  parent::_beforeSave();
72
  }
73
 
74
-
75
  /**
76
- * @param Mage_Core_Model_Config_Data $object
77
- * @return Mage_Core_Model_Config_Data
78
  */
79
- protected function checkConfigUnique(Mage_Core_Model_Config_Data $object)
80
  {
81
- /** @var $collection Mage_Core_Model_Mysql4_Config_Data_Collection | Mage_Core_Model_Resource_Config_Data_Collection */
82
- $collection = Mage::getModel('core/config_data')->getCollection();
83
- $collection->addFieldToFilter('scope', $object->getScope());
84
- $collection->addFieldToFilter('scope_id', $object->getScopeId());
85
- $collection->addFieldToFilter('path', $object->getPath());
86
- $collection->load();
87
-
88
- if($collection->count() > 0) {
89
- /** @var $config Mage_Core_Model_Config_Data */
90
- $config = $collection->getFirstItem();
91
- $object->setId($config->getId());
92
  }
93
-
94
- return $object;
95
  }
96
 
97
  /**
98
- * @return Payone_Core_Helper_Data
 
99
  */
100
- protected function helper()
101
  {
102
- return Mage::helper('payone_core');
103
  }
104
  }
32
  */
33
  class Payone_Core_Model_System_Config_Backend_Protect extends Mage_Core_Model_Config_Data
34
  {
35
+ /** @var Payone_Core_Model_Factory */
36
+ protected $factory = null;
37
+
38
  protected function _beforeSave()
39
  {
40
  $addressCheckEnabled = $this->getData('groups/address_check/fields/enabled/value');
41
  $creditratingEnabled = $this->getData('groups/creditrating/fields/enabled/value');
42
 
43
+ $serviceProtectCheck = $this->getFactory()->getServiceConfigProtectCheck();
44
+ $serviceProtectCheck->setScopeId($this->getScopeId());
45
+ $serviceProtectCheck->execute($addressCheckEnabled, $creditratingEnabled);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  parent::_beforeSave();
48
  }
49
 
 
50
  /**
51
+ *
52
+ * @return Payone_Core_Model_Factory
53
  */
54
+ public function getFactory()
55
  {
56
+ if ($this->factory === null) {
57
+ $this->factory = new Payone_Core_Model_Factory();
 
 
 
 
 
 
 
 
 
58
  }
59
+ return $this->factory;
 
60
  }
61
 
62
  /**
63
+ *
64
+ * @param Payone_Core_Model_Factory $factory
65
  */
66
+ public function setFactory(Payone_Core_Model_Factory $factory)
67
  {
68
+ $this->factory = $factory;
69
  }
70
  }
app/code/community/Payone/Core/Model/System/Config/OrderStatus.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Order Statuses source model
29
+ */
30
+ class Payone_Core_Model_System_Config_OrderStatus extends Payone_Core_Model_System_Config_Abstract
31
+ {
32
+ // set null to enable all possible
33
+ protected $_states = array(
34
+ Mage_Sales_Model_Order::STATE_NEW,
35
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
36
+ Mage_Sales_Model_Order::STATE_PROCESSING,
37
+ Mage_Sales_Model_Order::STATE_HOLDED,
38
+ Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
39
+ );
40
+
41
+ /**
42
+ * @return array
43
+ */
44
+ public function toArray()
45
+ {
46
+ // TODO: Implement toArray() method.
47
+ }
48
+
49
+ public function toOptionArray()
50
+ {
51
+ if ($this->_states) {
52
+ $statuses = Mage::getSingleton('sales/order_config')->getStateStatuses($this->_states);
53
+ }
54
+ else {
55
+ $statuses = Mage::getSingleton('sales/order_config')->getStatuses();
56
+ }
57
+ $options = array();
58
+ $options[] = array(
59
+ 'value' => '',
60
+ 'label' => Mage::helper('adminhtml')->__('-- Please Select --')
61
+ );
62
+ foreach ($statuses as $code => $label) {
63
+ $options[] = array(
64
+ 'value' => $code,
65
+ 'label' => $label
66
+ );
67
+ }
68
+ return $options;
69
+ }
70
+
71
+ /**
72
+ * @return array
73
+ */
74
+ public function toGroupArray()
75
+ {
76
+ $states = Mage::getSingleton('sales/order_config')->getStates();
77
+
78
+ $stateStatusArray = array();
79
+ foreach ($this->_states as $state) {
80
+ $stateStatuses = Mage::getSingleton('sales/order_config')->getStateStatuses($state);
81
+
82
+ if (array_key_exists($state, $states)) {
83
+ $stateLabel = $states[$state];
84
+ }
85
+ else {
86
+ $stateLabel = $this->helper()->__($state);
87
+ }
88
+
89
+ $stateStatusArray[$state] = array(
90
+ 'label' => $stateLabel,
91
+ 'values' => $stateStatuses
92
+ );
93
+ }
94
+ return $stateStatusArray;
95
+ }
96
+
97
+ /**
98
+ * @return array
99
+ */
100
+ public function toOptionGroupArray()
101
+ {
102
+ $data = array();
103
+ $options = $this->toGroupArray();
104
+ foreach ($options as $stateCode => $stateConfig) {
105
+ if (!array_key_exists('values', $stateConfig)) {
106
+ continue;
107
+ }
108
+ $stateValues = $stateConfig['values'];
109
+
110
+ if (array_key_exists('label', $stateConfig)) {
111
+ $stateLabel = $stateConfig['label'];
112
+ }
113
+ else {
114
+ $stateLabel = $this->helper()->__($stateCode);
115
+ }
116
+
117
+ if (!array_key_exists($stateCode, $data)) {
118
+ $data[$stateCode] = array(
119
+ 'label' => $stateLabel,
120
+ 'value' => array(),
121
+ );
122
+ }
123
+
124
+ foreach ($stateValues as $key => $value) {
125
+ $keyValue = $stateCode . '|' . $key;
126
+ $data[$stateCode]['value'][$keyValue] = array(
127
+ 'value' => $keyValue,
128
+ 'label' => $this->helper()->__($value)
129
+ );
130
+ }
131
+ }
132
+
133
+ array_unshift($data, $this->helper()->__('-- Please Select --'));
134
+
135
+ return $data;
136
+ }
137
+ }
app/code/community/Payone/Core/controllers/Adminhtml/Configuration/Wizard/PageController.php CHANGED
@@ -72,6 +72,13 @@ class Payone_Core_Adminhtml_Configuration_Wizard_PageController
72
  // $actionName = $this->getRequest()->getActionName(); // @comment we could use ActionName from Request
73
  $this->initConfig($actionName);
74
 
 
 
 
 
 
 
 
75
  $this->loadLayout('payone_core_adminhtml_configuration_wizard_page_edit');
76
  $this->renderLayout();
77
  }
@@ -131,6 +138,7 @@ class Payone_Core_Adminhtml_Configuration_Wizard_PageController
131
  // website and store codes can be used in event implementation, so set them as well
132
  $params = array('website' => $website, 'store' => $store);
133
  Mage::dispatchEvent("admin_system_config_changed_section_{$section}", $params);
 
134
 
135
  $session->addSuccess(Mage::helper('payone_core')->__('The configuration has been saved.'));
136
  }
72
  // $actionName = $this->getRequest()->getActionName(); // @comment we could use ActionName from Request
73
  $this->initConfig($actionName);
74
 
75
+ $configPage = Mage::registry('payone_wizard_config_page');
76
+
77
+ Mage::getSingleton('adminhtml/config_data')
78
+ ->setSection($configPage->getData('codes/section'))
79
+ ->setWebsite($configPage->getData('codes/website'))
80
+ ->setStore($configPage->getData('codes/store'));
81
+
82
  $this->loadLayout('payone_core_adminhtml_configuration_wizard_page_edit');
83
  $this->renderLayout();
84
  }
138
  // website and store codes can be used in event implementation, so set them as well
139
  $params = array('website' => $website, 'store' => $store);
140
  Mage::dispatchEvent("admin_system_config_changed_section_{$section}", $params);
141
+ Mage::dispatchEvent("admin_system_config_changed_section_{$section}_{$pageCode}", $params);
142
 
143
  $session->addSuccess(Mage::helper('payone_core')->__('The configuration has been saved.'));
144
  }
app/code/community/Payone/Core/etc/config.xml CHANGED
@@ -24,7 +24,7 @@
24
  <config>
25
  <modules>
26
  <Payone_Core>
27
- <version>3.1.2</version>
28
  </Payone_Core>
29
  </modules>
30
 
@@ -315,11 +315,6 @@
315
  <class>payone_core/observer_transactionStatus_orderConfirmation</class>
316
  <method>onAppointed</method>
317
  </payone_core_observer_orderConfirmation>
318
- <payone_core_observer_transactionstatus_clearingparameters>
319
- <type>singleton</type>
320
- <class>payone_core/observer_transactionStatus_storeClearingParameters</class>
321
- <method>onAppointed</method>
322
- </payone_core_observer_transactionstatus_clearingparameters>
323
  </observers>
324
  </payone_core_transactionstatus_appointed>
325
  <payone_core_transactionstatus_paid>
@@ -376,6 +371,15 @@
376
  </payone_core_observer_protocol_api>
377
  </observers>
378
  </payone_core_service_payment>
 
 
 
 
 
 
 
 
 
379
  </events>
380
  </global>
381
 
@@ -529,6 +533,10 @@
529
  </template_cash_on_delivery>
530
  </payone_payment>
531
  <payone_general>
 
 
 
 
532
  <parameter_invoice>
533
  <pdf_download_enabled>0</pdf_download_enabled>
534
  </parameter_invoice>
@@ -536,15 +544,15 @@
536
  <max_execution_time>35</max_execution_time>
537
  </transactionstatus_execute>
538
  <status_mapping>
539
- <creditcard>a:1:{s:23:"_payone_status_mapping1";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</creditcard>
540
- <invoice>a:1:{s:23:"_payone_status_mapping2";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</invoice>
541
- <debit_payment>a:1:{s:23:"_payone_status_mapping3";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</debit_payment>
542
- <financing>a:1:{s:23:"_payone_status_mapping2";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</financing>
543
- <safe_invoice>a:1:{s:23:"_payone_status_mapping2";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</safe_invoice>
544
- <advance_payment>a:2:{s:23:"_payone_status_mapping4";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:7:"pending";}}s:23:"_payone_status_mapping5";a:2:{s:8:"txaction";a:1:{i:0;s:4:"paid";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</advance_payment>
545
- <online_bank_transfer>a:1:{s:23:"_payone_status_mapping6";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</online_bank_transfer>
546
- <cash_on_delivery>a:1:{s:23:"_payone_status_mapping7";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</cash_on_delivery>
547
- <wallet>a:1:{s:23:"_payone_status_mapping8";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:6:"status";a:1:{i:0;s:10:"processing";}}}</wallet>
548
  </status_mapping>
549
  </payone_general>
550
  <payone_protect>
24
  <config>
25
  <modules>
26
  <Payone_Core>
27
+ <version>3.1.3</version>
28
  </Payone_Core>
29
  </modules>
30
 
315
  <class>payone_core/observer_transactionStatus_orderConfirmation</class>
316