Mage_Payone - Version 3.1.1

Version Notes

Mage_Payone-3.1.1

Download this release

Release Info

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


Code changes from version 3.0.12 to 3.1.1

Files changed (84) hide show
  1. app/code/community/Payone/Core/Block/Payment/Method/Form/Abstract.php +3 -3
  2. app/code/community/Payone/Core/Block/Payment/Method/Form/Financing.php +61 -0
  3. app/code/community/Payone/Core/Block/Payment/Method/Form/SafeInvoice.php +61 -0
  4. app/code/community/Payone/Core/Block/Payment/Method/Info/Abstract.php +4 -2
  5. app/code/community/Payone/Core/Block/Payment/Method/Info/Financing.php +52 -0
  6. app/code/community/Payone/Core/Block/Payment/Method/Info/SafeInvoice.php +164 -0
  7. app/code/community/Payone/Core/Helper/Config.php +13 -2
  8. app/code/community/Payone/Core/Helper/Data.php +68 -0
  9. app/code/community/Payone/Core/Helper/Registry.php +96 -0
  10. app/code/community/Payone/Core/Model/Config/General/StatusMapping.php +40 -0
  11. app/code/community/Payone/Core/Model/Config/Payment.php +1 -1
  12. app/code/community/Payone/Core/Model/Domain/Config/PaymentMethod.php +136 -2
  13. app/code/community/Payone/Core/Model/Domain/Protocol/TransactionStatus.php +13 -1
  14. app/code/community/Payone/Core/Model/Domain/Resource/Config/PaymentMethod/Collection.php +4 -4
  15. app/code/community/Payone/Core/Model/Factory.php +67 -0
  16. app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php +17 -0
  17. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Abstract.php +45 -2
  18. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php +56 -15
  19. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Capture.php +50 -8
  20. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Debit.php +63 -80
  21. app/code/community/Payone/Core/Model/Observer/Sales/Order.php +19 -0
  22. app/code/community/Payone/Core/Model/Observer/Store/PaymentConfig.php +71 -0
  23. app/code/community/Payone/Core/Model/Observer/TransactionStatus/InvoiceCreate.php +8 -0
  24. app/code/community/Payone/Core/Model/Observer/TransactionStatus/OrderConfirmation.php +97 -0
  25. app/code/community/Payone/Core/Model/Observer/TransactionStatus/StoreClearingParameters.php +51 -0
  26. app/code/community/Payone/Core/Model/Payment/Method/Abstract.php +31 -0
  27. app/code/community/Payone/Core/Model/Payment/Method/Financing.php +87 -0
  28. app/code/community/Payone/Core/Model/Payment/Method/SafeInvoice.php +156 -0
  29. app/code/community/Payone/Core/Model/Repository/TransactionStatus.php +8 -0
  30. app/code/community/Payone/Core/Model/Sales/Quote/Address/Total/Fee.php +3 -0
  31. app/code/community/Payone/Core/Model/Service/Abstract.php +9 -0
  32. app/code/community/Payone/Core/Model/Service/Config/PaymentMethod/Create.php +102 -0
  33. app/code/community/Payone/Core/Model/Service/Config/XmlGenerate.php +12 -1
  34. app/code/community/Payone/Core/Model/Service/InitializeConfig.php +14 -48
  35. app/code/community/Payone/Core/Model/Service/InitializePayment.php +1 -0
  36. app/code/community/Payone/Core/Model/Service/Sales/InvoiceCreate.php +3 -0
  37. app/code/community/Payone/Core/Model/Service/Sales/OrderConfirmation.php +58 -0
  38. app/code/community/Payone/Core/Model/Service/Sales/OrderStatus.php +6 -0
  39. app/code/community/Payone/Core/Model/Service/TransactionStatus/StoreClearingParameters.php +75 -0
  40. app/code/community/Payone/Core/Model/System/Config/AuthorizeMethodFinancing.php +46 -0
  41. app/code/community/Payone/Core/Model/System/Config/FinancingType.php +47 -0
  42. app/code/community/Payone/Core/Model/System/Config/MethodType.php +12 -3
  43. app/code/community/Payone/Core/Model/System/Config/PaymentMethodCode.php +4 -0
  44. app/code/community/Payone/Core/Model/System/Config/PaymentMethodType.php +4 -0
  45. app/code/community/Payone/Core/Model/System/Config/SafeInvoiceType.php +44 -0
  46. app/code/community/Payone/Core/controllers/Adminhtml/System/ConfigurationController.php +4 -0
  47. app/code/community/Payone/Core/etc/config.xml +66 -1
  48. app/code/community/Payone/Core/etc/system.xml +84 -0
  49. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.0.12-3.1.0.php +239 -0
  50. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.1.0-3.1.1.php +134 -0
  51. app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.0.12-3.1.0.sql +40 -0
  52. app/code/community/Payone/Migrator/Model/Service/Configuration/PaymentMigrate.php +28 -30
  53. app/design/adminhtml/default/default/template/payone/core/payment/method/info/financing.phtml +35 -0
  54. app/design/adminhtml/default/default/template/payone/core/payment/method/info/safe_invoice.phtml +47 -0
  55. app/design/adminhtml/default/default/template/payone/core/payment/method/pdf/safe_invoice.phtml +66 -0
  56. app/design/adminhtml/default/default/template/payone/core/system/config/tooltip/payment/financing.phtml +32 -0
  57. app/design/adminhtml/default/default/template/payone/core/system/config/tooltip/payment/safe_invoice.phtml +32 -0
  58. app/design/frontend/base/default/layout/payone/core.xml +1 -0
  59. app/design/frontend/base/default/template/payone/core/payment/method/form/financing.phtml +73 -0
  60. app/design/frontend/base/default/template/payone/core/payment/method/form/invoice.phtml +1 -1
  61. app/design/frontend/base/default/template/payone/core/payment/method/form/safe_invoice.phtml +73 -0
  62. app/design/frontend/base/default/template/payone/core/payment/method/info/financing.phtml +36 -0
  63. app/design/frontend/base/default/template/payone/core/payment/method/info/safe_invoice.phtml +36 -0
  64. app/locale/de_DE/Payone_Core.csv +25 -0
  65. app/locale/en_US/Payone_Core.csv +4 -1
  66. js/payone/core/financing.js +34 -0
  67. js/payone/core/safe_invoice.js +34 -0
  68. lib/Payone/Api/Enum/CaptureMode.php +36 -0
  69. lib/Payone/Api/Enum/FinancingType.php +37 -0
  70. lib/Payone/Api/Enum/InvoicingItemType.php +38 -0
  71. lib/Payone/Api/Factory.php +1 -1
  72. lib/Payone/Api/Request/Parameter/Authorization/PaymentMethod/Financing.php +119 -0
  73. lib/Payone/Api/Request/Parameter/Capture/Invoicing/Transaction.php +47 -0
  74. lib/Payone/Api/Request/Parameter/Invoicing/Item.php +23 -0
  75. lib/Payone/Api/Request/Parameter/Invoicing/Transaction.php +6 -3
  76. lib/Payone/Api/Response/Authorization/Abstract.php +4 -1
  77. lib/Payone/Api/Response/Capture/Approved.php +78 -0
  78. lib/Payone/Enum/ClearingType.php +1 -0
  79. lib/Payone/Log4php/LoggerPatternConverterSuperglobal.php +3 -3
  80. lib/Payone/Settings/Configuration/PaymentMethod/Financing.php +48 -0
  81. lib/Payone/Settings/Data/ConfigFile/PaymentMethod/Financing.php +76 -0
  82. lib/Payone/Settings/Service/XmlGenerate.php +18 -14
  83. lib/Payone/TransactionStatus/Request.php +242 -0
  84. package.xml +5 -5
app/code/community/Payone/Core/Block/Payment/Method/Form/Abstract.php CHANGED
@@ -135,10 +135,10 @@ class Payone_Core_Block_Payment_Method_Form_Abstract
135
* Provide an array of credit card types for the template
136
*
137
* Each value is an array, with the keys:
138
- * code - type code, e.g. 'V'
139
- * name - name for display, e.g. "Visa"
140
* fee - Formatted fee price for this type, empty if no price is configured.
141
- * check_cvc - 1 or 0, depends on the used configuration only set for Creditcard
142
* config_id - Id of the payment method configuration for this card type
143
*
144
* @api
135
* Provide an array of credit card types for the template
136
*
137
* Each value is an array, with the keys:
138
+ * code - type code, e.g. 'V', PNC', 'BSV'
139
+ * name - name for display, e.g. "Visa", "Sofortueberweisung" "BillSafe'
140
* fee - Formatted fee price for this type, empty if no price is configured.
141
+ * check_cvc - 1 or 0, depends on the used configuration. only set for Creditcard
142
* config_id - Id of the payment method configuration for this card type
143
*
144
* @api
app/code/community/Payone/Core/Block/Payment/Method/Form/Financing.php ADDED
@@ -0,0 +1,61 @@
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_Block
17
+ * @subpackage Payment
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_Block
28
+ * @subpackage Payment
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_Block_Payment_Method_Form_Financing
34
+ extends Payone_Core_Block_Payment_Method_Form_Abstract
35
+ {
36
+ protected $hasTypes = true;
37
+
38
+ protected function _construct()
39
+ {
40
+ parent::_construct();
41
+ $this->setTemplate('payone/core/payment/method/form/financing.phtml');
42
+ }
43
+
44
+ /**
45
+ * @override To prevent display of fee config on payment method, as there might be different fees for each financing type
46
+ *
47
+ * @return string
48
+ */
49
+ public function getMethodLabelAfterHtml()
50
+ {
51
+ return '';
52
+ }
53
+
54
+ /**
55
+ * @return array
56
+ */
57
+ protected function getSystemConfigMethodTypes()
58
+ {
59
+ return $this->getFactory()->getModelSystemConfigFinancingType()->toSelectArray();
60
+ }
61
+ }
app/code/community/Payone/Core/Block/Payment/Method/Form/SafeInvoice.php ADDED
@@ -0,0 +1,61 @@
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_Block
17
+ * @subpackage Payment
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_Block
28
+ * @subpackage Payment
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_Block_Payment_Method_Form_SafeInvoice
34
+ extends Payone_Core_Block_Payment_Method_Form_Abstract
35
+ {
36
+ protected $hasTypes = true;
37
+
38
+ protected function _construct()
39
+ {
40
+ parent::_construct();
41
+ $this->setTemplate('payone/core/payment/method/form/safe_invoice.phtml');
42
+ }
43
+
44
+ /**
45
+ * @override To prevent display of fee config on payment method, as there might be different fees for each safe_invoice type
46
+ *
47
+ * @return string
48
+ */
49
+ public function getMethodLabelAfterHtml()
50
+ {
51
+ return '';
52
+ }
53
+
54
+ /**
55
+ * @return array
56
+ */
57
+ protected function getSystemConfigMethodTypes()
58
+ {
59
+ return $this->getFactory()->getModelSystemConfigSafeInvoiceType()->toSelectArray();
60
+ }
61
+ }
app/code/community/Payone/Core/Block/Payment/Method/Info/Abstract.php CHANGED
@@ -60,7 +60,8 @@ class Payone_Core_Block_Payment_Method_Info_Abstract
60
}
61
if(empty($config))
62
{
63
- throw new Payone_Core_Exception_PaymentMethodConfigNotFound();
64
}
65
$this->paymentConfig = $config;
66
}
@@ -72,7 +73,8 @@ class Payone_Core_Block_Payment_Method_Info_Abstract
72
*/
73
public function getMethodTitle()
74
{
75
- return $this->getPaymentConfig()->getName();
76
}
77
78
/**
60
}
61
if(empty($config))
62
{
63
+ $message = 'Payment method configuration not found.';
64
+ throw new Payone_Core_Exception_PaymentMethodConfigNotFound($message);
65
}
66
$this->paymentConfig = $config;
67
}
73
*/
74
public function getMethodTitle()
75
{
76
+ $paymentconfig = $this->getPaymentConfig();
77
+ return $paymentconfig->getName();
78
}
79
80
/**
app/code/community/Payone/Core/Block/Payment/Method/Info/Financing.php ADDED
@@ -0,0 +1,52 @@
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_Block
17
+ * @subpackage Payment
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_Block
28
+ * @subpackage Payment
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_Block_Payment_Method_Info_Financing
34
+ extends Payone_Core_Block_Payment_Method_Info_Abstract
35
+ {
36
+ protected function _construct()
37
+ {
38
+ parent::_construct();
39
+ $this->setTemplate('payone/core/payment/method/info/financing.phtml');
40
+
41
+ }
42
+
43
+ /**
44
+ * @return string
45
+ */
46
+ public function getFinancingType()
47
+ {
48
+ $model = $this->getFactory()->getModelSystemConfigFinancingType();
49
+ $array = $model->toSelectArray();
50
+ return $array[$this->getInfo()->getPayoneFinancingType()];
51
+ }
52
+ }
app/code/community/Payone/Core/Block/Payment/Method/Info/SafeInvoice.php ADDED
@@ -0,0 +1,164 @@
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_Block
17
+ * @subpackage Payment
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_Block
28
+ * @subpackage Payment
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_Block_Payment_Method_Info_SafeInvoice
34
+ extends Payone_Core_Block_Payment_Method_Info_Abstract
35
+ {
36
+ protected function _construct()
37
+ {
38
+ parent::_construct();
39
+ $this->setTemplate('payone/core/payment/method/info/safe_invoice.phtml');
40
+
41
+ }
42
+
43
+ /**
44
+ * @return string
45
+ */
46
+ public function getSafeInvoiceType()
47
+ {
48
+ $model = $this->getFactory()->getModelSystemConfigSafeInvoiceType();
49
+ $array = $model->toSelectArray();
50
+
51
+ $safeInvoiceType = $this->getInfo()->getPayoneSafeInvoiceType();
52
+ if (array_key_exists($safeInvoiceType, $array)) {
53
+ return $array[$safeInvoiceType];
54
+ }
55
+ return '';
56
+ }
57
+
58
+ public function toPdf()
59
+ {
60
+ $this->setTemplate('payone/core/payment/method/pdf/safe_invoice.phtml');
61
+ return $this->toHtml();
62
+ }
63
+
64
+
65
+ /**
66
+ * @return string
67
+ */
68
+ public function getPayoneClearingBankAccountholder()
69
+ {
70
+ return $this->getInfo()->getPayoneClearingBankAccountholder();
71
+ }
72
+
73
+ /**
74
+ * @return string
75
+ */
76
+ public function getPayoneClearingBankCountry()
77
+ {
78
+ return $this->getInfo()->getPayoneClearingBankCountry();
79
+ }
80
+
81
+ /**
82
+ * @return string
83
+ */
84
+ public function getPayoneClearingBankAccount()
85
+ {
86
+ return $this->getInfo()->getPayoneClearingBankAccount();
87
+ }
88
+
89
+ /**
90
+ * @return string
91
+ */
92
+ public function getPayoneClearingBankCode()
93
+ {
94
+ return $this->getInfo()->getPayoneClearingBankCode();
95
+ }
96
+
97
+ /**
98
+ * @return string
99
+ */
100
+ public function getPayoneClearingBankIban()
101
+ {
102
+ return $this->getInfo()->getPayoneClearingBankIban();
103
+ }
104
+
105
+ /**
106
+ * @return string
107
+ */
108
+ public function getPayoneClearingBankBic()
109
+ {
110
+ return $this->getInfo()->getPayoneClearingBankBic();
111
+ }
112
+
113
+ /**
114
+ * @return string
115
+ */
116
+ public function getPayoneClearingBankCity()
117
+ {
118
+ return $this->getInfo()->getPayoneClearingBankCity();
119
+ }
120
+
121
+ /**
122
+ * @return string
123
+ */
124
+ public function getPayoneClearingBankName()
125
+ {
126
+ return $this->getInfo()->getPayoneClearingBankName();
127
+ }
128
+
129
+
130
+ /**
131
+ * @return string
132
+ */
133
+ public function getPayoneClearingReference()
134
+ {
135
+ return $this->getInfo()->getPayoneClearingReference();
136
+ }
137
+
138
+
139
+ /**
140
+ * @return string
141
+ */
142
+ public function getPayoneClearingInstructionnote()
143
+ {
144
+ return $this->getInfo()->getPayoneClearingInstructionnote();
145
+ }
146
+
147
+
148
+ /**
149
+ * @return string
150
+ */
151
+ public function getPayoneClearingLegalnote()
152
+ {
153
+ return $this->getInfo()->getPayoneClearingBankName();
154
+ }
155
+
156
+
157
+ /**
158
+ * @return string
159
+ */
160
+ public function getPayoneClearingDuedate()
161
+ {
162
+ return $this->getInfo()->getPayoneClearingDuedate();
163
+ }
164
+ }
app/code/community/Payone/Core/Helper/Config.php CHANGED
@@ -88,8 +88,19 @@ class Payone_Core_Helper_Config
88
*/
89
public function getConfigPaymentMethodById($id, $storeId = null)
90
{
91
- $configPayment = $this->getConfigPayment($storeId);
92
- $config = $configPayment->getMethodById($id);
93
return $config;
94
}
95
88
*/
89
public function getConfigPaymentMethodById($id, $storeId = null)
90
{
91
+ $general = $this->getConfigGeneral($storeId);
92
+ $defaultConfig = $general->getGlobal()->toArray();
93
+ $invoiceTransmit = $general->getParameterInvoice()->getTransmitEnabled();
94
+
95
+ // Add invoice_transmit to defaultConfig
96
+ $defaultConfig['invoice_transmit'] = $invoiceTransmit;
97
+
98
+
99
+ $config = $this->getFactory()->getModelDomainConfigPaymentMethod();
100
+ $config->load($id);
101
+ $config->loadMergedData();
102
+ $config = $config->toConfigPayment($storeId, $defaultConfig);
103
+
104
return $config;
105
}
106
app/code/community/Payone/Core/Helper/Data.php CHANGED
@@ -98,6 +98,59 @@ class Payone_Core_Helper_Data
98
return $edition;
99
}
100
101
/**
102
* @return int
103
*/
@@ -216,6 +269,21 @@ class Payone_Core_Helper_Data
216
return $hash;
217
}
218
219
/**
220
* Check if Mage-Compiler is enabled
221
* @return bool
98
return $edition;
99
}
100
101
+ /**
102
+ * Determine installer style to use, by Magento version/edition
103
+ * Pre-CE1.6 = use SQL script
104
+ *
105
+ * @return bool
106
+ */
107
+ public function mustUseSqlInstaller()
108
+ {
109
+ $magentoVersion = $this->getMagentoVersion();
110
+
111
+ switch ($this->getMagentoEdition()) {
112
+ case 'CE' :
113
+ if (version_compare($magentoVersion, '1.6', '<')) {
114
+ return true;
115
+ }
116
+ break;
117
+ case 'EE' : // Intentional fallthrough
118
+ case 'PE' :
119
+ if (version_compare($magentoVersion, '1.11', '<')) {
120
+ return true;
121
+ }
122
+ break;
123
+ }
124
+
125
+ return false;
126
+ }
127
+
128
+ /**
129
+ * Determine if Magento App Emulation is available
130
+ *
131
+ * @return bool
132
+ */
133
+ public function canUseAppEmulation()
134
+ {
135
+ $magentoVersion = $this->getMagentoVersion();
136
+
137
+ switch ($this->getMagentoEdition()) {
138
+ case 'CE' :
139
+ if (version_compare($magentoVersion, '1.5', '<')) {
140
+ return false;
141
+ }
142
+ break;
143
+ case 'EE' : // Intentional fallthrough
144
+ case 'PE' :
145
+ if (version_compare($magentoVersion, '1.10', '<')) {
146
+ return false;
147
+ }
148
+ break;
149
+ }
150
+
151
+ return true;
152
+ }
153
+
154
/**
155
* @return int
156
*/
269
return $hash;
270
}
271
272
+ /**
273
+ * @param Mage_Customer_Model_Address_Abstract $address1
274
+ * @param Mage_Customer_Model_Address_Abstract $address2
275
+ * @return bool
276
+ */
277
+ public function addressesAreEqual(Mage_Customer_Model_Address_Abstract $address1, Mage_Customer_Model_Address_Abstract $address2)
278
+ {
279
+ $hash1 = $this->createAddressHash($address1);
280
+ $hash2 = $this->createAddressHash($address2);
281
+
282
+ if($hash1 == $hash2)
283
+ return true;
284
+ return false;
285
+ }
286
+
287
/**
288
* Check if Mage-Compiler is enabled
289
* @return bool
app/code/community/Payone/Core/Helper/Registry.php ADDED
@@ -0,0 +1,96 @@
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_Helper
17
+ * @subpackage
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_Helper
28
+ * @subpackage
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_Helper_Registry
34
+ extends Payone_Core_Helper_Abstract
35
+ {
36
+ const KEY_PAYMENT_CANCEL = 'payone_payment_cancel_';
37
+
38
+ /**
39
+ * Wrapper for Mage::registry()
40
+ * @param string $key
41
+ *
42
+ * @return mixed
43
+ */
44
+ public function registry($key)
45
+ {
46
+ return Mage::registry($key);
47
+ }
48
+
49
+
50
+ /**
51
+ * Wrapper for Mage::register()
52
+ *
53
+ * @param string $key
54
+ * @param mixed $value
55
+ * @param bool $graceful
56
+ *
57
+ * @throws Mage_Core_Exception
58
+ */
59
+ public function register($key, $value, $graceful = false)
60
+ {
61
+ return Mage::register($key, $value, $graceful);
62
+ }
63
+
64
+ /**
65
+ * Wrapper for Mage::unregister()
66
+ *
67
+ * @param string $key
68
+ */
69
+ public function unregister($key)
70
+ {
71
+ Mage::unregister($key);
72
+ }
73
+
74
+ /**
75
+ * @param Mage_Payment_Model_Info $payment
76
+ */
77
+ public function registerPaymentCancel(Mage_Payment_Model_Info $payment)
78
+ {
79
+ $this->register(self::KEY_PAYMENT_CANCEL.$payment->getId(), true);
80
+ }
81
+
82
+ /**
83
+ *
84
+ * @param Mage_Payment_Model_Info $payment
85
+ * @return bool
86
+ */
87
+ public function isPaymentCancelRegistered(Mage_Payment_Model_Info $payment)
88
+ {
89
+ $value = $this->registry(self::KEY_PAYMENT_CANCEL.$payment->getId());
90
+
91
+ if(empty($value) or !($value))
92
+ return false;
93
+ else
94
+ return true;
95
+ }
96
+ }
app/code/community/Payone/Core/Model/Config/General/StatusMapping.php CHANGED
@@ -36,6 +36,14 @@ class Payone_Core_Model_Config_General_StatusMapping extends Payone_Core_Model_C
36
* @var null
37
*/
38
protected $creditcard = null;
39
/**
40
* @var null
41
*/
@@ -240,4 +248,36 @@ class Payone_Core_Model_Config_General_StatusMapping extends Payone_Core_Model_C
240
{
241
return $this->wallet;
242
}
243
}
36
* @var null
37
*/
38
protected $creditcard = null;
39
+ /**
40
+ * @var null
41
+ */
42
+ protected $safe_invoice = null;
43
+ /**
44
+ * @var null
45
+ */
46
+ protected $financing = null;
47
/**
48
* @var null
49
*/
248
{
249
return $this->wallet;
250
}
251
+
252
+ /**
253
+ * @param null $financing
254
+ */
255
+ public function setFinancing($financing)
256
+ {
257
+ $this->financing = $financing;
258
+ }
259
+
260
+ /**
261
+ * @return null
262
+ */
263
+ public function getFinancing()
264
+ {
265
+ return $this->financing;
266
+ }
267
+
268
+ /**
269
+ * @param null $safe_invoice
270
+ */
271
+ public function setSafeInvoice($safe_invoice)
272
+ {
273
+ $this->safe_invoice = $safe_invoice;
274
+ }
275
+
276
+ /**
277
+ * @return null
278
+ */
279
+ public function getSafeInvoice()
280
+ {
281
+ return $this->safe_invoice;
282
+ }
283
}
app/code/community/Payone/Core/Model/Config/Payment.php CHANGED
@@ -125,7 +125,7 @@ class Payone_Core_Model_Config_Payment extends Payone_Core_Model_Config_AreaAbst
125
public function getMethodsForQuote($type, Mage_Sales_Model_Quote $quote)
126
{
127
$country = $quote->getBillingAddress()->getCountry();
128
- $quoteTotal = $quote->getSubtotal();
129
130
$methodsForCountry = $this->getMethodsForCountry($type, $country);
131
125
public function getMethodsForQuote($type, Mage_Sales_Model_Quote $quote)
126
{
127
$country = $quote->getBillingAddress()->getCountry();
128
+ $quoteTotal = $quote->getGrandTotal();
129
130
$methodsForCountry = $this->getMethodsForCountry($type, $country);
131
app/code/community/Payone/Core/Model/Domain/Config/PaymentMethod.php CHANGED
@@ -97,6 +97,9 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
97
/** @var Payone_Core_Model_Factory */
98
protected $factory = null;
99
100
/**
101
*
102
*/
@@ -121,6 +124,7 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
121
}
122
123
$originModel = $this->loadOriginPaymentMethodConfig();
124
if ($originModel
125
&& ($this->getScope() != $originModel->getScope()
126
|| $this->getScopeId() != $originModel->getScopeId()
@@ -143,7 +147,7 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
143
$store = $this->getFactory()->getModelCoreStore()->load($this->getScopeId());
144
$websiteId = $store->getWebsiteId();
145
146
- $dummy = Mage::getModel('payone_core/domain_config_paymentMethod');
147
$dummy->setScope($parentScope);
148
$dummy->setScopeId($websiteId);
149
$dummy->setCode($originModel->getCode());
@@ -185,6 +189,7 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
185
$this->prepareData();
186
187
if ($this->isObjectNew()) {
188
$this->setCreatedAt(date('Y-m-d H:i:s'));
189
$this->setUpdatedAt(date('Y-m-d H:i:s'));
190
}
@@ -195,6 +200,126 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
195
return $this;
196
}
197
198
/**
199
* Load original PaymentMethod from Database
200
* @return Payone_Core_Model_Domain_Config_PaymentMethod
@@ -204,7 +329,7 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
204
if ($this->getId()) {
205
206
/** @var $originModel Payone_Core_Model_Domain_Config_PaymentMethod */
207
- $originModel = Mage::getModel('payone_core/domain_config_paymentMethod');
208
$originModel->load($this->getId());
209
$originModel->prepareData();
210
return $originModel;
@@ -450,6 +575,15 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
450
$this->explodeData('specificcountry');
451
}
452
453
/**
454
*
455
*/
97
/** @var Payone_Core_Model_Factory */
98
protected $factory = null;
99
100
+
101
+ protected $isNew = false;
102
+
103
/**
104
*
105
*/
124
}
125
126
$originModel = $this->loadOriginPaymentMethodConfig();
127
+
128
if ($originModel
129
&& ($this->getScope() != $originModel->getScope()
130
|| $this->getScopeId() != $originModel->getScopeId()
147
$store = $this->getFactory()->getModelCoreStore()->load($this->getScopeId());
148
$websiteId = $store->getWebsiteId();
149
150
+ $dummy = $this->getFactory()->getModelDomainConfigPaymentMethod();
151
$dummy->setScope($parentScope);
152
$dummy->setScopeId($websiteId);
153
$dummy->setCode($originModel->getCode());
189
$this->prepareData();
190
191
if ($this->isObjectNew()) {
192
+ $this->isNew = true; // to trigger actions in _afterSave()
193
$this->setCreatedAt(date('Y-m-d H:i:s'));
194
$this->setUpdatedAt(date('Y-m-d H:i:s'));
195
}
200
return $this;
201
}
202
203
+ /**
204
+ * On creation of a new configuration, propagate it to the deeper scopes, with all possible values inherited
205
+ * _afterSave is called on the new objects as well.
206
+ *
207
+ * @return Mage_Core_Model_Abstract
208
+ */
209
+ protected function _afterSave()
210
+ {
211
+ if ($this->isNew) {
212
+ // Check the next "deeper" scope, if no config exists, add inherited configs
213
+ $myScope = $this->getScope();
214
+ if ($myScope == 'default') {
215
+ $websites = $this->getFactory()->getModelCoreWebsite()->getCollection();
216
+
217
+ // 1 for each website
218
+ foreach ($websites as $website) {
219
+ /** @var $website Mage_Core_Model_Website */
220
+ $this->saveChildConfig($website->getId(), 'websites');
221
+
222
+ }
223
+ }
224
+ elseif ($myScope == 'websites') {
225
+ /** @var $stores Mage_Core_Model_Mysql4_Store_Collection */
226
+ $stores = $this->getFactory()->getModelCoreStore()->getCollection();
227
+ $stores->addFieldToFilter('website_id', $this->getScopeId());
228
+
229
+ // 1 for each storeView on the website
230
+ foreach ($stores as $store) {
231
+ /** @var $store Mage_Core_Model_Store */
232
+ $this->saveChildConfig($store->getId(), 'stores');
233
+
234
+ }
235
+ }
236
+ }
237
+ return parent::_afterSave();
238
+ }
239
+
240
+ /**
241
+ * Save a child config that inherits all data from current model
242
+ *
243
+ * @param $scopeId
244
+ * @param $childScope
245
+ *
246
+ * @return void
247
+ */
248
+ protected function saveChildConfig($scopeId, $childScope)
249
+ {
250
+
251
+ if ($childScope == 'websites') {
252
+ $parentField = 'parent_default_id';
253
+ }
254
+ elseif ($childScope == 'stores') {
255
+ $parentField = 'parent_websites_id';
256
+ }
257
+ else {
258
+ return;
259
+ }
260
+
261
+ $childConfig = $this->getFactory()->getModelDomainConfigPaymentMethod();
262
+ $childConfig->setScope($childScope);
263
+ $childConfig->setScopeId($scopeId);
264
+ $childConfig->setCode($this->getCode());
265
+ $childConfig->setData($parentField, $this->getId());
266
+
267
+ $childConfig->save();
268
+
269
+
270
+ }
271
+
272
+ /**
273
+ * @param int $storeId
274
+ * @param array $defaultConfig
275
+ * @return Payone_Core_Model_Config_Payment_Method_Interface
276
+ */
277
+ public function toConfigPayment($storeId, array $defaultConfig = array())
278
+ {
279
+ /**
280
+ * The object we want to return:
281
+ * @var $configMethod Payone_Core_Model_Config_Payment_Method */
282
+ $configMethod = $this->getFactory()->getModelConfigPaymentMethod();
283
+
284
+ $configMethod->init($this->_data);
285
+
286
+ // Use Global Config if use_global is set
287
+ if ($configMethod->getUseGlobal()) {
288
+ $configMethod->init($defaultConfig);
289
+ }
290
+ else {
291
+ // Check globals also if they are not to use
292
+ foreach ($defaultConfig as $key => $value) {
293
+ if (!array_key_exists($key, $this->_data) || $this->_data[$key] == '') {
294
+ $this->_data[$key] = $value;
295
+ }
296
+ }
297
+ $configMethod->init($this->_data);
298
+ }
299
+
300
+ // init Allowed Countries
301
+ if (array_key_exists('allowspecific', $this->_data) and $this->getAllowspecific()) {
302
+ $allowedCountries = $configMethod->getSpecificcountry();
303
+ }
304
+ else {
305
+ $generalAllowedCountries = $this->helperConfig()->getStoreConfig('general/country/allow', $storeId);
306
+ $allowedCountries = explode(',', $generalAllowedCountries);
307
+ }
308
+ $configMethod->setAllowedCountries($allowedCountries);
309
+
310
+ $parentDefaultId = $this->getParentDefaultId();
311
+ $parentWebsitesId = $this->getParentWebsitesId();
312
+ if (!empty($parentDefaultId) && empty($parentWebsitesId)) {
313
+ $configMethod->setParent($parentDefaultId);
314
+ return $configMethod;
315
+ }
316
+ elseif (!empty($parentWebsitesId)) {
317
+ $configMethod->setParent($parentWebsitesId);
318
+ return $configMethod;
319
+ }
320
+ return $configMethod;
321
+ }
322
+
323
/**
324
* Load original PaymentMethod from Database
325
* @return Payone_Core_Model_Domain_Config_PaymentMethod
329
if ($this->getId()) {
330
331
/** @var $originModel Payone_Core_Model_Domain_Config_PaymentMethod */
332
+ $originModel = $this->getFactory()->getModelDomainConfigPaymentMethod();
333
$originModel->load($this->getId());
334
$originModel->prepareData();
335
return $originModel;
575
$this->explodeData('specificcountry');
576
}
577
578
+
579
+ /**
580
+ * @return Payone_Core_Helper_Config
581
+ */
582
+ protected function helperConfig()
583
+ {
584
+ return $this->getFactory()->helperConfig();
585
+ }
586
+
587
/**
588
*
589
*/
app/code/community/Payone/Core/Model/Domain/Protocol/TransactionStatus.php CHANGED
@@ -162,7 +162,19 @@ class Payone_Core_Model_Domain_Protocol_TransactionStatus extends Mage_Core_Mode
162
'invoice_grossamount',
163
'invoice_date',
164
'invoice_deliverydate',
165
- 'invoice_deliveryenddate');
166
167
$rawData = $this->__toArray($allowedKeys);
168
ksort($rawData);
162
'invoice_grossamount',
163
'invoice_date',
164
'invoice_deliverydate',
165
+ 'invoice_deliveryenddate',
166
+ 'clearing_bankaccountholder',
167
+ 'clearing_bankcountry',
168
+ 'clearing_bankaccount',
169
+ 'clearing_bankcode',
170
+ 'clearing_bankiban',
171
+ 'clearing_bankbic',
172
+ 'clearing_bankcity',
173
+ 'clearing_bankname',
174
+ 'clearing_reference',
175
+ 'clearing_duedate',
176
+ 'clearing_legalnote',
177
+ 'clearing_instructionnote');
178
179
$rawData = $this->__toArray($allowedKeys);
180
ksort($rawData);
app/code/community/Payone/Core/Model/Domain/Resource/Config/PaymentMethod/Collection.php CHANGED
@@ -111,8 +111,8 @@ class Payone_Core_Model_Domain_Resource_Config_PaymentMethod_Collection
111
}
112
113
/**
114
- * @param $id
115
- *
116
* @return Payone_Core_Model_Domain_Resource_Config_PaymentMethod_Collection
117
*/
118
public function getCollectionByStoreId($id, $includeDeleted = false)
@@ -160,8 +160,8 @@ class Payone_Core_Model_Domain_Resource_Config_PaymentMethod_Collection
160
}
161
162
/**
163
- * @param $id
164
- *
165
* @return Payone_Core_Model_Domain_Resource_Config_PaymentMethod_Collection
166
*/
167
public function getCollectionByWebsiteId($id, $includeDeleted = false)
111
}
112
113
/**
114
+ * @param int $id
115
+ * @param bool $includeDeleted
116
* @return Payone_Core_Model_Domain_Resource_Config_PaymentMethod_Collection
117
*/
118
public function getCollectionByStoreId($id, $includeDeleted = false)
160
}
161
162
/**
163
+ * @param int $id
164
+ * @param bool $includeDeleted
165
* @return Payone_Core_Model_Domain_Resource_Config_PaymentMethod_Collection
166
*/
167
public function getCollectionByWebsiteId($id, $includeDeleted = false)
app/code/community/Payone/Core/Model/Factory.php CHANGED
@@ -72,6 +72,16 @@ class Payone_Core_Model_Factory
72
return Mage::helper('payone_core/config');
73
}
74
75
/**
76
* @return Payone_Core_Helper_Url
77
*/
@@ -790,6 +800,19 @@ class Payone_Core_Model_Factory
790
return $service;
791
}
792
793
/**
794
* @return Payone_Core_Model_Service_Transaction_Update
795
*/
@@ -854,6 +877,20 @@ class Payone_Core_Model_Factory
854
$service->setFactory($this);
855
return $service;
856
}
857
858
/**
859
* @return Payone_Settings_Service_XmlGenerate
@@ -864,6 +901,19 @@ class Payone_Core_Model_Factory
864
return $service;
865
}
866
867
/**
868
* @return Payone_Core_Model_Service_Config_XmlGenerate
869
*/
@@ -1299,6 +1349,23 @@ class Payone_Core_Model_Factory
1299
return Mage::getSingleton('payone_core/system_config_walletType');
1300
}
1301
1302
/**
1303
* @return Payone_Core_Model_System_Config_AddressCheckType
1304
*/
72
return Mage::helper('payone_core/config');
73
}
74
75
+
76
+ /**
77
+ *
78
+ * @return Payone_Core_Helper_Registry
79
+ */
80
+ public function helperRegistry()
81
+ {
82
+ return Mage::helper('payone_core/registry');
83
+ }
84
+
85
/**
86
* @return Payone_Core_Helper_Url
87
*/
800
return $service;
801
}
802
803
+
804
+ /**
805
+ * @return Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters
806
+ */
807
+ public function getServiceTransactionStatusStoreClearingParameters()
808
+ {
809
+ /** @var $service Payone_Core_Model_Service_TransactionStatus_StoreClearingParameters */
810
+ $service = Mage::getModel('payone_core/service_transactionStatus_storeClearingParameters');
811
+ $service->setFactory($this);
812
+
813
+ return $service;
814
+ }
815
+
816
/**
817
* @return Payone_Core_Model_Service_Transaction_Update
818
*/
877
$service->setFactory($this);
878
return $service;
879
}
880
+
881
+ /**
882
+ * @return Payone_Core_Model_Service_Sales_OrderConfirmation
883
+ */
884
+ public function getServiceSalesOrderConfirmation()
885
+ {
886
+ /**
887
+ * @var $service Payone_Core_Model_Service_Sales_OrderConfirmation
888
+ */
889
+ $service = Mage::getModel('payone_core/service_sales_orderConfirmation');
890
+ $service->setFactory($this);
891
+ return $service;
892
+ }
893
+
894
895
/**
896
* @return Payone_Settings_Service_XmlGenerate
901
return $service;
902
}
903
904
+
905
+ /**
906
+ * @return Payone_Core_Model_Service_Config_PaymentMethod_Create
907
+ */
908
+ public function getServiceConfigPaymentMethodCreate()
909
+ {
910
+ /** @var $service Payone_Core_Model_Service_Config_PaymentMethod_Create */
911
+ $service = Mage::getModel('payone_core/service_config_paymentMethod_create');
912
+ $service->setFactory($this);
913
+
914
+ return $service;
915
+ }
916
+
917
/**
918
* @return Payone_Core_Model_Service_Config_XmlGenerate
919
*/
1349
return Mage::getSingleton('payone_core/system_config_walletType');
1350
}
1351
1352
+ /**
1353
+ * @return Payone_Core_Model_System_Config_FinancingType
1354
+ */
1355
+ public function getModelSystemConfigFinancingType()
1356
+ {
1357
+ return Mage::getSingleton('payone_core/system_config_financingType');
1358
+ }
1359
+
1360
+
1361
+ /**
1362
+ * @return Payone_Core_Model_System_Config_SafeInvoiceType
1363
+ */
1364
+ public function getModelSystemConfigSafeInvoiceType()
1365
+ {
1366
+ return Mage::getSingleton('payone_core/system_config_safeInvoiceType');
1367
+ }
1368
+
1369
/**
1370
* @return Payone_Core_Model_System_Config_AddressCheckType
1371
*/
app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php CHANGED
@@ -140,6 +140,14 @@ abstract class Payone_Core_Model_Handler_Payment_Abstract
140
$order->setData('payone_payment_method_type',
141
$this->getPayment()->getData('payone_onlinebanktransfer_type'));
142
}
143
}
144
145
/**
@@ -155,6 +163,7 @@ abstract class Payone_Core_Model_Handler_Payment_Abstract
155
if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_AdvancePayment
156
or $paymentMethod instanceof Payone_Core_Model_Payment_Method_Invoice
157
or $paymentMethod instanceof Payone_Core_Model_Payment_Method_CashOnDelivery
158
) {
159
/** @var $response Payone_Api_Response_Authorization_Approved */
160
$payment->setPayoneClearingBankAccountholder($response->getClearingBankaccountholder());
@@ -165,6 +174,14 @@ abstract class Payone_Core_Model_Handler_Payment_Abstract
165
$payment->setPayoneClearingBankBic($response->getClearingBankbic());
166
$payment->setPayoneClearingBankCity($response->getClearingBankcity());
167
$payment->setPayoneClearingBankName($response->getClearingBankname());
168
}
169
}
170
140
$order->setData('payone_payment_method_type',
141
$this->getPayment()->getData('payone_onlinebanktransfer_type'));
142
}
143
+ elseif ($this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_Financing) {
144
+ $order->setData('payone_payment_method_type',
145
+ $this->getPayment()->getData('payone_financing_type'));
146
+ }
147
+ elseif ($this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_SafeInvoice) {
148
+ $order->setData('payone_payment_method_type',
149
+ $this->getPayment()->getData('payone_safe_invoice_type'));
150
+ }
151
}
152
153
/**
163
if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_AdvancePayment
164
or $paymentMethod instanceof Payone_Core_Model_Payment_Method_Invoice
165
or $paymentMethod instanceof Payone_Core_Model_Payment_Method_CashOnDelivery
166
+ or ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice and $response instanceof Payone_Api_Response_Capture_Approved)
167
) {
168
/** @var $response Payone_Api_Response_Authorization_Approved */
169
$payment->setPayoneClearingBankAccountholder($response->getClearingBankaccountholder());
174
$payment->setPayoneClearingBankBic($response->getClearingBankbic());
175
$payment->setPayoneClearingBankCity($response->getClearingBankcity());
176
$payment->setPayoneClearingBankName($response->getClearingBankname());
177
+
178
+ if($response instanceof Payone_Api_Response_Capture_Approved)
179
+ {
180
+ $payment->setPayoneClearingReference($response->getClearingReference());
181
+ $payment->setPayoneClearingInstructionnote($response->getClearingInstructionnote());
182
+ $payment->setPayoneClearingLegalnote($response->getClearingLegalnote());
183
+ $payment->setPayoneClearingDuedate($response->getClearingDuedate());
184
+ }
185
}
186
}
187
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Abstract.php CHANGED
@@ -106,6 +106,10 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
106
$params['pr'] = $order->getShippingInclTax();
107
$params['va'] = $this->getShippingTaxRate();
108
109
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
110
$item->init($params);
111
@@ -133,6 +137,9 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
133
$params['no'] = 1;
134
$params['pr'] = $discountAmount;
135
136
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
137
$item->init($params);
138
@@ -159,6 +166,10 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
159
$params['de'] = $order->getShippingDescription();
160
$params['no'] = 1;
161
$params['pr'] = $creditmemo->getShippingInclTax();
162
163
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
164
$item->init($params);
@@ -188,6 +199,10 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
188
$params['de'] = $name;
189
$params['no'] = 1;
190
$params['pr'] = $creditmemo->getAdjustmentPositive();
191
192
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
193
$item->init($params);
@@ -218,6 +233,10 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
218
$params['de'] = $name;
219
$params['no'] = 1;
220
$params['pr'] = $creditmemo->getAdjustmentNegative() * (-1);
221
222
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
223
$item->init($params);
@@ -322,6 +341,23 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
322
return $appendix;
323
}
324
325
/**
326
* @param Mage_Sales_Model_Abstract $object
327
* @return string
@@ -366,8 +402,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
366
*/
367
protected function getConfigMisc()
368
{
369
- if($this->configMisc === null)
370
- {
371
$this->configMisc = $this->helperConfig()->getConfigMisc($this->getStoreId());
372
}
373
return $this->configMisc;
@@ -453,4 +488,12 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
453
{
454
return $this->getFactory()->helperConfig();
455
}
456
}
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
+
113
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
114
$item->init($params);
115
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
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
174
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
175
$item->init($params);
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
207
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
208
$item->init($params);
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
241
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
242
$item->init($params);
341
return $appendix;
342
}
343
344
+
345
+ /**
346
+ * @return bool
347
+ */
348
+ protected function mustTransmitInvoiceData()
349
+ {
350
+ if ($this->getConfigPayment()->isInvoiceTransmitEnabled()) {
351
+ return true;
352
+ }
353
+
354
+ $paymentMethod = $this->getPaymentMethod();
355
+ if ($paymentMethod->mustTransmitInvoicingData()) { // Certain payment methods require invoicing data to be transmitted ALWAYS.
356
+ return true;
357
+ }
358
+
359
+ return false;
360
+ }
361
/**
362
* @param Mage_Sales_Model_Abstract $object
363
* @return string
402
*/
403
protected function getConfigMisc()
404
{
405
+ if ($this->configMisc === null) {
406
$this->configMisc = $this->helperConfig()->getConfigMisc($this->getStoreId());
407
}
408
return $this->configMisc;
488
{
489
return $this->getFactory()->helperConfig();
490
}
491
+
492
+ /**
493
+ * @return Payone_Core_Helper_Registry
494
+ */
495
+ protected function helperRegistry()
496
+ {
497
+ return $this->getFactory()->helperRegistry();
498
+ }
499
}
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php CHANGED
@@ -47,8 +47,6 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
47
{
48
$this->init($payment);
49
50
- $configPayment = $this->getConfigPayment();
51
-
52
$request = $this->getRequest();
53
54
$this->beforeMapFromPayment($request);
@@ -68,8 +66,8 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
68
$deliveryData = $this->mapDeliveryParameters();
69
$request->setDeliveryData($deliveryData);
70
}
71
- // Only add Invoiceing Parameters if enabled
72
- if ($configPayment->isInvoiceTransmitEnabled()) {
73
$invoicing = $this->mapInvoicingParameters();
74
$request->setInvoicing($invoicing);
75
}
@@ -102,6 +100,8 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
102
103
}
104
105
/**
106
* @param Payone_Api_Request_Authorization_Abstract $request
107
*/
@@ -164,7 +164,11 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
164
$language = $helper->getDefaultLanguage();
165
$personalData->setLanguage($language);
166
$personalData->setVatid($order->getCustomerTaxvat());
167
- $personalData->setIp($order->getRemoteIp());
168
169
// US and CA always need state and shipping_state paramters
170
if ($billingCountry == 'US' or $billingCountry == 'CA') {
@@ -180,24 +184,30 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
180
protected function mapDeliveryParameters()
181
{
182
$helper = $this->helper();
183
- $shippingAddress = $this->getOrder()->getShippingAddress();
184
185
$deliveryData = new Payone_Api_Request_Parameter_Authorization_DeliveryData();
186
187
- $shippingCountry = $shippingAddress->getCountry();
188
189
- $deliveryData->setShippingFirstname($shippingAddress->getFirstname());
190
- $deliveryData->setShippingLastname($shippingAddress->getLastname());
191
- $deliveryData->setShippingCompany($shippingAddress->getCompany());
192
- $street = $helper->normalizeStreet($shippingAddress->getStreet());
193
$deliveryData->setShippingStreet($street);
194
- $deliveryData->setShippingZip($shippingAddress->getPostcode());
195
- $deliveryData->setShippingCity($shippingAddress->getCity());
196
$deliveryData->setShippingCountry($shippingCountry);
197
198
// US and CA always need shipping_state paramters
199
if ($shippingCountry == 'US' or $shippingCountry == 'CA') {
200
- $deliveryData->setShippingState($shippingAddress->getRegionCode());
201
}
202
203
return $deliveryData;
@@ -222,12 +232,22 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
222
continue;// Do not map dummy items
223
}
224
225
$params['id'] = $itemData->getSku();
226
$params['pr'] = $itemData->getPriceInclTax();
227
- $params['no'] = $itemData->getQtyToInvoice();
228
$params['de'] = $itemData->getName();
229
$params['va'] = number_format($itemData->getTaxPercent(), 0, '.', '');
230
231
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
232
$item->init($params);
233
$invoicing->addItem($item);
@@ -292,6 +312,21 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
292
293
$isRedirect = true;
294
}
295
elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Wallet) {
296
$payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Wallet();
297
// @comment currently hardcoded because there is no other Type
@@ -351,6 +386,12 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
351
elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_DebitPayment) {
352
$clearingType = Payone_Enum_ClearingType::DEBITPAYMENT;
353
}
354
355
return $clearingType;
356
}
47
{
48
$this->init($payment);
49
50
$request = $this->getRequest();
51
52
$this->beforeMapFromPayment($request);
66
$deliveryData = $this->mapDeliveryParameters();
67
$request->setDeliveryData($deliveryData);
68
}
69
+ // Only add Invoiceing Parameters if enabled / required by payment method
70
+ if ($this->mustTransmitInvoiceData()) {
71
$invoicing = $this->mapInvoicingParameters();
72
$request->setInvoicing($invoicing);
73
}
100
101
}
102
103
+
104
+
105
/**
106
* @param Payone_Api_Request_Authorization_Abstract $request
107
*/
164
$language = $helper->getDefaultLanguage();
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') {
184
protected function mapDeliveryParameters()
185
{
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
197
+ $shippingCountry = $address->getCountry();
198
199
+ $deliveryData->setShippingFirstname($address->getFirstname());
200
+ $deliveryData->setShippingLastname($address->getLastname());
201
+ $deliveryData->setShippingCompany($address->getCompany());
202
+ $street = $helper->normalizeStreet($address->getStreet());
203
$deliveryData->setShippingStreet($street);
204
+ $deliveryData->setShippingZip($address->getPostcode());
205
+ $deliveryData->setShippingCity($address->getCity());
206
$deliveryData->setShippingCountry($shippingCountry);
207
208
// US and CA always need shipping_state paramters
209
if ($shippingCountry == 'US' or $shippingCountry == 'CA') {
210
+ $deliveryData->setShippingState($address->getRegionCode());
211
}
212
213
return $deliveryData;
232
continue;// Do not map dummy items
233
}
234
235
+ $number = $itemData->getQtyToInvoice();
236
+ if ($number <= 0) {
237
+ continue; // Do not map items with zero quanity
238
+ }
239
+
240
$params['id'] = $itemData->getSku();
241
$params['pr'] = $itemData->getPriceInclTax();
242
+ $params['no'] = $number;
243
$params['de'] = $itemData->getName();
244
$params['va'] = number_format($itemData->getTaxPercent(), 0, '.', '');
245
246
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
247
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
248
+ }
249
+
250
+
251
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
252
$item->init($params);
253
$invoicing->addItem($item);
312
313
$isRedirect = true;
314
}
315
+ elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Financing) {
316
+
317
+ $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Financing();
318
+ $payment->setFinancingtype($info->getPayoneFinancingType());
319
+
320
+ $isRedirect = true;
321
+ }
322
+
323
+ elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice) {
324
+
325
+ $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Financing();
326
+ $payment->setFinancingtype($info->getPayoneSafeInvoiceType());
327
+
328
+ $isRedirect = true;
329
+ }
330
elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Wallet) {
331
$payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Wallet();
332
// @comment currently hardcoded because there is no other Type
386
elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_DebitPayment) {
387
$clearingType = Payone_Enum_ClearingType::DEBITPAYMENT;
388
}
389
+ elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Financing) {
390
+ $clearingType = Payone_Enum_ClearingType::FINANCING;
391
+ }
392
+ elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice) {
393
+ $clearingType = Payone_Enum_ClearingType::FINANCING;
394
+ }
395
396
return $clearingType;
397
}
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Capture.php CHANGED
@@ -36,6 +36,7 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
36
/** @var Mage_Sales_Model_Order_Invoice */
37
protected $invoice = null;
38
39
/**
40
* @return Payone_Api_Request_Capture
41
*/
@@ -62,9 +63,11 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
62
$request->setBusiness($business);
63
64
/** Set Invoiceing-Parameter only if enabled in Config */
65
- if ($this->getConfigPayment()->isInvoiceTransmitEnabled()) {
66
$invoicing = $this->mapInvoicingParameters();
67
- $request->setInvoicing($invoicing);
68
}
69
70
return $request;
@@ -111,6 +114,11 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
111
$business->setSettleaccount(Payone_Api_Enum_Settleaccount::NO);
112
}
113
}
114
else
115
{
116
$business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
@@ -126,7 +134,7 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
126
$order = $this->getOrder();
127
$invoice = $this->getInvoice();
128
129
- $invoicing = new Payone_Api_Request_Parameter_Invoicing_Transaction();
130
if (!empty($invoice) && $invoice->hasData()) {
131
132
$invoiceIncrementId = $invoice->getIncrementId();
@@ -141,18 +149,28 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
141
142
// Regular order items:
143
foreach ($invoice->getItemsCollection() as $itemData) {
144
/** @var $orderItem Mage_Sales_Model_Order_Item */
145
$orderItem = $order->getItemById($itemData->getOrderItemId());
146
147
if ($orderItem->isDummy()) {
148
- continue;
149
- } // Do not map dummy items.
150
- /** @var $itemData Mage_Sales_Model_Order_Invoice_Item */
151
$params['id'] = $itemData->getSku();
152
$params['de'] = $itemData->getName();
153
- $params['no'] = number_format($itemData->getQty(), 0, '.', '');
154
$params['pr'] = $itemData->getPriceInclTax();
155
156
// We have to load the tax percentage from the order item
157
$params['va'] = number_format($orderItem->getTaxPercent(), 0, '.', '');
158
@@ -173,6 +191,13 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
173
}
174
}
175
176
return $invoicing;
177
}
178
@@ -198,6 +223,22 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
198
return true;
199
}
200
201
/**
202
* @return Mage_Sales_Model_Order_Invoice|null
203
*/
@@ -205,7 +246,7 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
205
{
206
if ($this->invoice === null) {
207
// we need to check registry because Magento won't give the invoice instance to PaymentMethodInstance
208
- $this->invoice = Mage::registry('current_invoice');
209
}
210
return $this->invoice;
211
}
@@ -218,4 +259,5 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
218
$this->invoice = $invoice;
219
}
220
221
}
36
/** @var Mage_Sales_Model_Order_Invoice */
37
protected $invoice = null;
38
39
+
40
/**
41
* @return Payone_Api_Request_Capture
42
*/
63
$request->setBusiness($business);
64
65
/** Set Invoiceing-Parameter only if enabled in Config */
66
+ if ($this->mustTransmitInvoiceData()) {
67
$invoicing = $this->mapInvoicingParameters();
68
+ if (!empty($invoicing)) {
69
+ $request->setInvoicing($invoicing);
70
+ }
71
}
72
73
return $request;
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);
134
$order = $this->getOrder();
135
$invoice = $this->getInvoice();
136
137
+ $invoicing = new Payone_Api_Request_Parameter_Capture_Invoicing_Transaction();
138
if (!empty($invoice) && $invoice->hasData()) {
139
140
$invoiceIncrementId = $invoice->getIncrementId();
149
150
// Regular order items:
151
foreach ($invoice->getItemsCollection() as $itemData) {
152
+ /** @var $itemData Mage_Sales_Model_Order_Invoice_Item */
153
/** @var $orderItem Mage_Sales_Model_Order_Item */
154
$orderItem = $order->getItemById($itemData->getOrderItemId());
155
156
if ($orderItem->isDummy()) {
157
+ continue; // Do not map dummy items.
158
+ }
159
+
160
+
161
+ $number = number_format($itemData->getQty(), 0, '.', '');
162
+ if ($number <= 0) {
163
+ continue; // Do not map items with zero quantity
164
+ }
165
$params['id'] = $itemData->getSku();
166
$params['de'] = $itemData->getName();
167
+ $params['no'] = $number;
168
$params['pr'] = $itemData->getPriceInclTax();
169
170
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
171
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
172
+ }
173
+
174
// We have to load the tax percentage from the order item
175
$params['va'] = number_format($orderItem->getTaxPercent(), 0, '.', '');
176
191
}
192
}
193
194
+ // Capture mode:
195
+ if ($this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_SafeInvoice) {
196
+ $invoicing->setCapturemode($this->mapCaptureMode());
197
+ }
198
+
199
+
200
+
201
return $invoicing;
202
}
203
223
return true;
224
}
225
226
+ /**
227
+ * @return string
228
+ */
229
+ protected function mapCaptureMode()
230
+ {
231
+ $payment = $this->getPaymentMethod()->getInfoInstance();
232
+ if ($this->isInvoiceLast() || $this->helperRegistry()->isPaymentCancelRegistered($payment)) {
233
+ $captureMode = Payone_Api_Enum_CaptureMode::COMPLETED;
234
+ }
235
+ else {
236
+ $captureMode = Payone_Api_Enum_CaptureMode::NOTCOMPLETED;
237
+ }
238
+
239
+ return $captureMode;
240
+ }
241
+
242
/**
243
* @return Mage_Sales_Model_Order_Invoice|null
244
*/
246
{
247
if ($this->invoice === null) {
248
// we need to check registry because Magento won't give the invoice instance to PaymentMethodInstance
249
+ $this->invoice = $this->helperRegistry()->registry('current_invoice');
250
}
251
return $this->invoice;
252
}
259
$this->invoice = $invoice;
260
}
261
262
+
263
}
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Debit.php CHANGED
@@ -62,7 +62,7 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
62
$request->setBusiness($business);
63
64
/** Set Invoiceing-Parameter only if enabled in Config */
65
- if ($this->getConfigPayment()->isInvoiceTransmitEnabled()) {
66
$invoicing = $this->mapInvoicingParameters();
67
$request->setInvoicing($invoicing);
68
}
@@ -94,11 +94,21 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
94
protected function mapBusinessParameters()
95
{
96
$business = new Payone_Api_Request_Parameter_Debit_Business();
97
- $business->setSettleaccount('auto');
98
$business->setTransactiontype('');
99
$business->setBookingDate('');
100
$business->setDocumentDate('');
101
102
return $business;
103
}
104
@@ -110,91 +120,67 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
110
$order = $this->getOrder();
111
$creditmemo = $this->getCreditmemo();
112
113
- $creditmemoIncrementId = $creditmemo->getIncrementId();
114
- if ($creditmemoIncrementId === null) {
115
- $creditmemoIncrementId = $this->fetchNewIncrementId($creditmemo);
116
- }
117
-
118
- $appendix = $this->getInvoiceAppendixRefund($creditmemo);
119
-
120
$invoicing = new Payone_Api_Request_Parameter_Invoicing_Transaction();
121
- $invoicing->setInvoiceid($creditmemoIncrementId);
122
- $invoicing->setInvoiceappendix($appendix);
123
-
124
- // Regular order items:
125
- foreach ($creditmemo->getItemsCollection() as $itemData) {
126
- /** @var $itemData Mage_Sales_Model_Order_Creditmemo_Item */
127
- /** @var $orderItem Mage_Sales_Model_Order_Item */
128
- $orderItem = $order->getItemById($itemData->getOrderItemId());
129
-
130
- if($orderItem->isDummy())
131
- {
132
- continue; // Do not map dummy items.
133
}
134
135
- $params['id'] = $itemData->getSku();
136
- $params['de'] = $itemData->getName();
137
- $params['no'] = number_format($itemData->getQty(), 0, '.', '');
138
- $params['pr'] = $itemData->getPriceInclTax();
139
140
141
- // We have to load the tax percentage from the order item
142
- $params['va'] = number_format($orderItem->getTaxPercent(), 0, '.', '');
143
144
- $item = new Payone_Api_Request_Parameter_Invoicing_Item();
145
- $item->init($params);
146
- $invoicing->addItem($item);
147
- }
148
149
- // Refund shipping
150
- if ($creditmemo->getShippingInclTax() > 0) {
151
- $invoicing->addItem($this->mapRefundShippingAsItemByCreditmemo($creditmemo));
152
- }
153
154
- // Adjustment Refund (positive adjustment)
155
- if($creditmemo->getAdjustmentPositive() > 0) {
156
- $invoicing->addItem($this->mapAdjustmentPositiveAsItemByCreditmemo($creditmemo));
157
- }
158
159
- // Adjustment Fee (negative adjustment)
160
- if($creditmemo->getAdjustmentNegative() > 0) {
161
- $invoicing->addItem($this->mapAdjustmentNegativeAsItemByCreditmemo($creditmemo));
162
- }
163
164
- return $invoicing;
165
- }
166
167
- /**
168
- * @param Payone_Core_Model_Payment_Method_Abstract $paymentMethod
169
- * @return string
170
- */
171
- protected function mapClearingType(Payone_Core_Model_Payment_Method_Abstract $paymentMethod)
172
- {
173
- $clearingType = '';
174
175
- if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_CashOnDelivery) {
176
- $clearingType = Payone_Enum_ClearingType::CASHONDELIVERY;
177
- }
178
- elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Creditcard) {
179
- $clearingType = Payone_Enum_ClearingType::CREDITCARD;
180
- }
181
- elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_OnlineBankTransfer) {
182
- $clearingType = Payone_Enum_ClearingType::ONLINEBANKTRANSFER;
183
- }
184
- elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Wallet) {
185
- $clearingType = Payone_Enum_ClearingType::WALLET;
186
- }
187
- elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Invoice) {
188
- $clearingType = Payone_Enum_ClearingType::INVOICE;
189
- }
190
- elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_AdvancePayment) {
191
- $clearingType = Payone_Enum_ClearingType::ADVANCEPAYMENT;
192
- }
193
- elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_DebitPayment) {
194
- $clearingType = Payone_Enum_ClearingType::DEBITPAYMENT;
195
- }
196
197
- return $clearingType;
198
}
199
200
/**
@@ -204,12 +190,9 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
204
{
205
if ($this->creditmemo === null) {
206
// we need to check registry because Magento won't give the creditmemo instance to PaymentMethodInstance
207
- $creditmemo = Mage::registry('current_creditmemo');
208
- if (is_null($creditmemo)) {
209
- // fallback to lastInvoice when invoice could not be fetched from Registry
210
- $order = $this->getOrder();
211
- $creditmemo = $order->getCreditmemosCollection()->getLastItem();
212
- }
213
$this->creditmemo = $creditmemo;
214
}
215
return $this->creditmemo;
62
$request->setBusiness($business);
63
64
/** Set Invoiceing-Parameter only if enabled in Config */
65
+ if ($this->mustTransmitInvoiceData()) {
66
$invoicing = $this->mapInvoicingParameters();
67
$request->setInvoicing($invoicing);
68
}
94
protected function mapBusinessParameters()
95
{
96
$business = new Payone_Api_Request_Parameter_Debit_Business();
97
$business->setTransactiontype('');
98
$business->setBookingDate('');
99
$business->setDocumentDate('');
100
101
+ $paymentMethod = $this->getPaymentMethod();
102
+
103
+ // Some payment methods can not use settleaccount auto:
104
+ if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice) {
105
+ // BillSAFE always settles account:
106
+ $business->setSettleaccount(Payone_Api_Enum_Settleaccount::YES);
107
+ }
108
+ else {
109
+ $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
110
+ }
111
+
112
return $business;
113
}
114
120
$order = $this->getOrder();
121
$creditmemo = $this->getCreditmemo();
122
123
$invoicing = new Payone_Api_Request_Parameter_Invoicing_Transaction();
124
+ if (!empty($creditmemo) && $creditmemo->hasData()) {
125
+ $creditmemoIncrementId = $creditmemo->getIncrementId();
126
+ if ($creditmemoIncrementId === null) {
127
+ $creditmemoIncrementId = $this->fetchNewIncrementId($creditmemo);
128
}
129
130
+ $appendix = $this->getInvoiceAppendixRefund($creditmemo);
131
132
+ $invoicing->setInvoiceid($creditmemoIncrementId);
133
+ $invoicing->setInvoiceappendix($appendix);
134
135
+ // Regular order items:
136
+ foreach ($creditmemo->getItemsCollection() as $itemData) {
137
+ /** @var $itemData Mage_Sales_Model_Order_Creditmemo_Item */
138
+ /** @var $orderItem Mage_Sales_Model_Order_Item */
139
+ $orderItem = $order->getItemById($itemData->getOrderItemId());
140
141
+ if ($orderItem->isDummy()) {
142
+ continue; // Do not map dummy items.
143
+ }
144
145
+ $number = number_format($itemData->getQty(), 0, '.', '');
146
+ if ($number <= 0) {
147
+ continue; // Do not map items with zero quantity
148
+ }
149
150
+ $params['id'] = $itemData->getSku();
151
+ $params['de'] = $itemData->getName();
152
+ $params['no'] = $number;
153
+ $params['pr'] = $itemData->getPriceInclTax();
154
155
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
156
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
157
+ }
158
159
160
+ // We have to load the tax percentage from the order item
161
+ $params['va'] = number_format($orderItem->getTaxPercent(), 0, '.', '');
162
163
+ $item = new Payone_Api_Request_Parameter_Invoicing_Item();
164
+ $item->init($params);
165
+ $invoicing->addItem($item);
166
+ }
167
+
168
+ // Refund shipping
169
+ if ($creditmemo->getShippingInclTax() > 0) {
170
+ $invoicing->addItem($this->mapRefundShippingAsItemByCreditmemo($creditmemo));
171
+ }
172
+
173
+ // Adjustment Refund (positive adjustment)
174
+ if ($creditmemo->getAdjustmentPositive() > 0) {
175
+ $invoicing->addItem($this->mapAdjustmentPositiveAsItemByCreditmemo($creditmemo));
176
+ }
177
178
+ // Adjustment Fee (negative adjustment)
179
+ if ($creditmemo->getAdjustmentNegative() > 0) {
180
+ $invoicing->addItem($this->mapAdjustmentNegativeAsItemByCreditmemo($creditmemo));
181
+ }
182
+ }
183
+ return $invoicing;
184
}
185
186
/**
190
{
191
if ($this->creditmemo === null) {
192
// we need to check registry because Magento won't give the creditmemo instance to PaymentMethodInstance
193
+ $creditmemo = $this->helperRegistry()
194
+ ->registry('current_creditmemo');
195
+
196
$this->creditmemo = $creditmemo;
197
}
198
return $this->creditmemo;
app/code/community/Payone/Core/Model/Observer/Sales/Order.php CHANGED
@@ -62,4 +62,23 @@ class Payone_Core_Model_Observer_Sales_Order
62
63
$this->helperConfig()->incrementCreditratingSampleCounter($storeId);
64
}
65
}
62
63
$this->helperConfig()->incrementCreditratingSampleCounter($storeId);
64
}
65
+
66
+ /**
67
+ *
68
+ * @param Varien_Event_Observer $observer (has data 'payment' with a payment info instance (Mage_Sales_Model_Order_Payment))
69
+ */
70
+ public function cancelPayment(Varien_Event_Observer $observer)
71
+ {
72
+ /** @var $payment Mage_Sales_Model_Order_Payment */
73
+ $payment = $observer->getPayment();
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
}
app/code/community/Payone/Core/Model/Observer/Store/PaymentConfig.php ADDED
@@ -0,0 +1,71 @@
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 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
+ */
23
+
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_Store_PaymentConfig
34
+ extends Payone_Core_Model_Observer_Abstract
35
+ {
36
+ /**
37
+ * @param Varien_Event_Observer $observer
38
+ */
39
+ public function createByWebsite(Varien_Event_Observer $observer)
40
+ {
41
+ /** @var $website Mage_Core_Model_Website */
42
+ $website = $observer->getWebsite();
43
+
44
+ if (!$website->isObjectNew()) {
45
+ return;
46
+ }
47
+
48
+ $service = $this->getFactory()->getServiceConfigPaymentMethodCreate();
49
+ $service->executeByWebsite($website);
50
+
51
+ }
52
+
53
+
54
+ /**
55
+ * @param Varien_Event_Observer $observer
56
+ */
57
+ public function createByStore(Varien_Event_Observer $observer)
58
+ {
59
+ /** @var $store Mage_Core_Model_Store */
60
+ $store = $observer->getStore();
61
+
62
+ if (!$store->isObjectNew()) {
63
+ return;
64
+ }
65
+
66
+ $service = $this->getFactory()->getServiceConfigPaymentMethodCreate();
67
+ $service->executeByStore($store);
68
+
69
+ }
70
+
71
+ }
app/code/community/Payone/Core/Model/Observer/TransactionStatus/InvoiceCreate.php CHANGED
@@ -173,11 +173,19 @@ class Payone_Core_Model_Observer_TransactionStatus_InvoiceCreate
173
174
/**
175
* @return bool|Payone_Core_Model_Config_Payment_Method_Interface
176
*/
177
protected function getConfigPaymentMethodById()
178
{
179
$id = $this->payment->getPayoneConfigPaymentMethodId();
180
$configPaymentMethod = $this->config->getPayment()->getMethodById($id);
181
return $configPaymentMethod;
182
}
183
173
174
/**
175
* @return bool|Payone_Core_Model_Config_Payment_Method_Interface
176
+ * @throws Payone_Core_Exception_PaymentMethodConfigNotFound
177
*/
178
protected function getConfigPaymentMethodById()
179
{
180
$id = $this->payment->getPayoneConfigPaymentMethodId();
181
$configPaymentMethod = $this->config->getPayment()->getMethodById($id);
182
+
183
+ if(empty($configPaymentMethod) )
184
+ {
185
+ $message = 'Payment method configuration with id "' . $id . '" not found.';
186
+ throw new Payone_Core_Exception_PaymentMethodConfigNotFound($message);
187
+ }
188
+
189
return $configPaymentMethod;
190
}
191
app/code/community/Payone/Core/Model/Observer/TransactionStatus/OrderConfirmation.php ADDED
@@ -0,0 +1,97 @@
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 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
+ */
23
+
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_TransactionStatus_OrderConfirmation
34
+ extends Payone_Core_Model_Observer_Abstract
35
+ {
36
+ /**
37
+ * @var Payone_Core_Model_Service_Sales_OrderConfirmation
38
+ */
39
+ protected $serviceOrderConfirmation = null;
40
+
41
+
42
+ /** @var $order Mage_Sales_Model_Order */
43
+ private $order = null;
44
+
45
+
46
+ /** @var $transactionStatus Payone_Core_Model_Domain_Protocol_TransactionStatus */
47
+ private $transactionStatus = null;
48
+
49
+ /**
50
+ * @param Varien_Event_Observer $observer
51
+ */
52
+ public function onAppointed(Varien_Event_Observer $observer)
53
+ {
54
+ $this->initData($observer);
55
+
56
+
57
+ $this->getServiceOrderConfirmation()->sendMail($this->order);
58
+ }
59
+
60
+ /**
61
+ * @param Varien_Event_Observer $observer
62
+ */
63
+ protected function initData(Varien_Event_Observer $observer)
64
+ {
65
+ $event = $observer->getEvent();
66
+
67
+ /** @var $transactionStatus Payone_Core_Model_Domain_Protocol_TransactionStatus */
68
+ $this->transactionStatus = $event->getTransactionStatus();
69
+
70
+ $order = $this->getOrderByTransactionStatus($this->transactionStatus);
71
+ $this->order = $order;
72
+ }
73
+
74
+ /**
75
+ * @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus
76
+ * @return Mage_Sales_Model_Order
77
+ */
78
+ protected function getOrderByTransactionStatus(Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus)
79
+ {
80
+ $order = $this->getFactory()->getModelSalesOrder();
81
+ $order->load($transactionStatus->getOrderId());
82
+ return $order;
83
+ }
84
+
85
+ /**
86
+ * @return Payone_Core_Model_Service_Sales_OrderConfirmation
87
+ */
88
+ public function getServiceOrderConfirmation()
89
+ {
90
+ if ($this->serviceOrderConfirmation === null) {
91
+ $this->serviceOrderConfirmation = $this->getFactory()->getServiceSalesOrderConfirmation();
92
+ }
93
+ return $this->serviceOrderConfirmation;
94
+ }
95
+
96
+
97
+ }
app/code/community/Payone/Core/Model/Observer/TransactionStatus/StoreClearingParameters.php ADDED
@@ -0,0 +1,51 @@
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_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
+ */
22
+
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_Tra