Mage_Payone - Version 3.5.5

Version Notes

Mage_Payone-3.5.5

Download this release

Release Info

Developer PAYONE
Extension Mage_Payone
Version 3.5.5
Comparing to
See all releases


Code changes from version 3.4.15 to 3.5.5

Files changed (72) hide show
  1. app/code/community/Payone/Core/Block/Adminhtml/System/Config/Form/Field/RatePayStoreIds.php +84 -0
  2. app/code/community/Payone/Core/Block/Payment/Method/Form/Payolution.php +185 -0
  3. app/code/community/Payone/Core/Block/Payment/Method/Form/Ratepay.php +90 -0
  4. app/code/community/Payone/Core/Block/Payment/Method/Info/Payolution.php +39 -0
  5. app/code/community/Payone/Core/Block/Payment/Method/Info/Ratepay.php +39 -0
  6. app/code/community/Payone/Core/Model/Config/General/ParameterNarrativeText.php +21 -0
  7. app/code/community/Payone/Core/Model/Config/Payment/Method.php +85 -0
  8. app/code/community/Payone/Core/Model/Config/Payment/Method/Interface.php +40 -0
  9. app/code/community/Payone/Core/Model/Domain/Config/PaymentMethod.php +15 -0
  10. app/code/community/Payone/Core/Model/Factory.php +9 -1
  11. app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php +15 -0
  12. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php +79 -1
  13. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Capture.php +16 -8
  14. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Debit.php +10 -0
  15. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php +79 -0
  16. app/code/community/Payone/Core/Model/Observer/Checkout/Onepage/DebitPayment.php +32 -1
  17. app/code/community/Payone/Core/Model/Payment/Method/Abstract.php +15 -1
  18. app/code/community/Payone/Core/Model/Payment/Method/Payolution.php +37 -0
  19. app/code/community/Payone/Core/Model/Payment/Method/Ratepay.php +256 -0
  20. app/code/community/Payone/Core/Model/Service/Payment/Abstract.php +4 -2
  21. app/code/community/Payone/Core/Model/Service/Paypal/Express/Checkout.php +1 -1
  22. app/code/community/Payone/Core/Model/System/Config/PaymentMethodCode.php +5 -1
  23. app/code/community/Payone/Core/Model/System/Config/PaymentMethodType.php +5 -1
  24. app/code/community/Payone/Core/Model/System/Config/PayolutionType.php +40 -0
  25. app/code/community/Payone/Core/Model/System/Config/RatepayType.php +40 -0
  26. app/code/community/Payone/Core/controllers/Adminhtml/Payonecore/System/Config/PaymentController.php +6 -0
  27. app/code/community/Payone/Core/etc/config.xml +36 -1
  28. app/code/community/Payone/Core/etc/system.xml +85 -0
  29. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.4.16-3.5.0.php +259 -0
  30. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.5.0-3.5.1.php +49 -0
  31. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.5.2-3.5.3.php +58 -0
  32. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.5.3-3.5.4.php +140 -0
  33. app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.4.16-3.5.0.sql +85 -0
  34. app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.5.0-3.5.1.sql +29 -0
  35. app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.5.2-3.5.3.sql +6 -0
  36. app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.5.3-3.5.4.sql +29 -0
  37. app/design/adminhtml/default/default/layout/payone/core.xml +2 -0
  38. app/design/adminhtml/default/default/template/payone/core/payment/method/form/debitpayment.phtml +84 -86
  39. app/design/adminhtml/default/default/template/payone/core/payment/method/form/payolution.phtml +159 -0
  40. app/design/adminhtml/default/default/template/payone/core/payment/method/form/ratepay.phtml +109 -0
  41. app/design/adminhtml/default/default/template/payone/core/system/config/form/field/creditcard_template.phtml +5 -5
  42. app/design/adminhtml/default/default/template/payone/core/system/config/form/field/ratepay_shopids.phtml +175 -0
  43. app/design/frontend/base/default/layout/payone/core.xml +3 -0
  44. app/design/frontend/base/default/template/payone/core/payment/method/form/onlinebanktransfer/bankgroup.phtml +6 -5
  45. app/design/frontend/base/default/template/payone/core/payment/method/form/payolution.phtml +188 -0
  46. app/design/frontend/base/default/template/payone/core/payment/method/form/ratepay.phtml +111 -0
  47. app/design/frontend/base/default/template/payone/core/payment/method/info/creditcard.phtml +3 -1
  48. app/design/frontend/base/default/template/payone/core/payment/method/info/payolution.phtml +45 -0
  49. app/design/frontend/base/default/template/payone/core/payment/method/info/ratepay.phtml +44 -0
  50. app/locale/de_DE/Payone_Core.csv +37 -1
  51. app/locale/en_US/Payone_Core.csv +17 -1
  52. js/payone/core/payolution.js +39 -0
  53. js/payone/core/ratepay.js +48 -0
  54. lib/Payone/Api/Adapter/Http/Curl.php +1 -1
  55. lib/Payone/Api/Enum/GenericpaymentAction.php +4 -0
  56. lib/Payone/Api/Enum/PayolutionType.php +57 -0
  57. lib/Payone/Api/Enum/RatepayType.php +30 -0
  58. lib/Payone/Api/Mapper/Request/Payment/Genericpayment.php +3 -1
  59. lib/Payone/Api/Request/Capture.php +40 -1
  60. lib/Payone/Api/Request/Debit.php +39 -0
  61. lib/Payone/Api/Request/Genericpayment.php +138 -0
  62. lib/Payone/Api/Request/Parameter/Authorization/PaymentMethod/Payolution.php +157 -0
  63. lib/Payone/Api/Request/Parameter/Authorization/PaymentMethod/RatePay.php +123 -0
  64. lib/Payone/Api/Request/Parameter/Paydata/DataItem.php +1 -1
  65. lib/Payone/Api/Request/Parameter/Paydata/Paydata.php +0 -2
  66. lib/Payone/Api/Response/Authorization/Abstract.php +93 -0
  67. lib/Payone/Api/Response/Capture/Approved.php +11 -0
  68. lib/Payone/Api/Response/Genericpayment/Approved.php +16 -0
  69. lib/Payone/Enum/ClearingType.php +2 -0
  70. lib/Payone/Settings/Data/ConfigFile/PaymentMethod/RatePay.php +63 -0
  71. package.xml +5 -5
  72. skin/frontend/base/default/payone/core/payolution.css +41 -0
app/code/community/Payone/Core/Block/Adminhtml/System/Config/Form/Field/RatePayStoreIds.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Payment
18
+ * @copyright Copyright (c) 2016 <kontakt@fatchip.de> - www.fatchip.com
19
+ * @author Robert M�ller <robert.mueller@fatchip.de>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.fatchip.com
22
+ */
23
+
24
+
25
+ class Payone_Core_Block_Adminhtml_System_Config_Form_Field_RatePayStoreIds
26
+ extends Payone_Core_Block_Adminhtml_System_Config_Form_Field_Abstract
27
+ {
28
+
29
+ protected $_oRatePay = null;
30
+
31
+ public function __construct() {
32
+ parent::__construct();
33
+ $this->setTemplate('payone/core/system/config/form/field/ratepay_shopids.phtml');
34
+ }
35
+
36
+ protected function _prepareToRender()
37
+ {
38
+ $this->addColumn('ratepay_shopid', array(
39
+ 'label' => Mage::helper('payone_core')->__('Shop-ID'),
40
+ 'style' => 'min-width:120px;',
41
+ ));
42
+ $this->_addAfter = false;
43
+ $this->_addButtonLabel = Mage::helper('payone_core')->__('Add Shop-ID');
44
+ parent::_prepareToRender();
45
+ }
46
+
47
+ protected function _getRatePayObject() {
48
+ if($this->_oRatePay === null) {
49
+ $this->_oRatePay = Mage::getModel('payone_core/payment_method_ratepay');
50
+ }
51
+ return $this->_oRatePay;
52
+ }
53
+
54
+ protected function _requestRatePayConfigFromApi($sRatePayShopId) {
55
+ $sMethodId = $this->getRequest()->get('id');
56
+ $oConfigHelper = $this->getFactory()->helperConfig();
57
+ $oConfig = $oConfigHelper->getConfigPaymentMethodById($sMethodId);
58
+ $oService = $this->getFactory()->getServicePaymentGenericpayment($oConfig);
59
+ $oMapper = $oService->getMapper();
60
+ $oRequest = $oMapper->addRatePayParameters($sRatePayShopId);
61
+ $oResponse = $this->getFactory()->getServiceApiPaymentGenericpayment()->request($oRequest);
62
+
63
+ if($oResponse instanceof Payone_Api_Response_Genericpayment_Ok) {
64
+ $aPayData = $oResponse->getPaydataArray();
65
+ $aPayData['shop_id'] = $sRatePayShopId;
66
+
67
+ $oRatePay = $this->_getRatePayObject();
68
+ $oRatePay->addRatePayConfig($aPayData);
69
+ return $aPayData;
70
+ }
71
+ return false;
72
+ }
73
+
74
+ public function getRatePayShopConfig($sRatePayShopId) {
75
+ $sRatePayShopId = trim($sRatePayShopId);
76
+ $oRatePay = $this->_getRatePayObject();
77
+ $aRatePayConfig = $oRatePay->getRatePayConfigById($sRatePayShopId);
78
+ if(!$aRatePayConfig) {
79
+ $aRatePayConfig = $this->_requestRatePayConfigFromApi($sRatePayShopId);
80
+ }
81
+ return $aRatePayConfig;
82
+ }
83
+
84
+ }
app/code/community/Payone/Core/Block/Payment/Method/Form/Payolution.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2015 <kontakt@fatchip.de> - www.fatchip.com
19
+ * @author Robert M�ller <robert.mueller@fatchip.de>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.fatchip.com
22
+ */
23
+
24
+ class Payone_Core_Block_Payment_Method_Form_Payolution extends Payone_Core_Block_Payment_Method_Form_Abstract {
25
+
26
+ protected $_sAcceptanceBaseUrl = 'https://payment.payolution.com/payolution-payment/infoport/dataprivacydeclaration?mId=';
27
+
28
+ protected $hasTypes = true;
29
+
30
+ protected $_sFallback = "<header>
31
+ <strong>Zus�tzliche Hinweise f�r die Datenschutzerkl�rung f�r Kauf auf Rechnung, Ratenzahlung und Zahlung mittels SEPA-Basis-Lastschrift von **company** (im Folgenden: �wir�)</strong></br>
32
+ <span><i>(Stand: 17.03.2016)</i></span>
33
+ </header>
34
+ <ol>
35
+ <li><p>Bei Kauf auf Rechnung oder Ratenzahlung oder SEPA-Basis-Lastschrift wird von Ihnen w�hrend des Bestellprozesses eine datenschutzrechtliche Einwilligung eingeholt. Folgend finden Sie eine Wiederholung dieser Bestimmungen, die lediglich informativen Charakter haben.</p></li>
36
+ <li><p>Bei Auswahl von Kauf auf Rechnung oder Ratenzahlung oder Bezahlung mittels SEPA-Basis-Lastschrift werden f�r die Abwicklung dieser Zahlarten personenbezogene Daten (Vorname, Nachname, Adresse, Email, Telefonnummer, Geburtsdatum, IP-Adresse, Geschlecht) gemeinsam mit f�r die Transaktionsabwicklung erforderlichen Daten (Artikel, Rechnungsbetrag, Zinsen, Raten, F�lligkeiten, Gesamtbetrag, Rechnungsnummer, Steuern, W�hrung, Bestelldatum und Bestellzeitpunkt) an payolution �bermittelt werden. payolution hat ein berechtigtes Interesse an den Daten und ben�tigt bzw. verwendet diese um Risiko�berpr�fungen durchzuf�hren.</p></li>
37
+ <li>
38
+ <p>Zur �berpr�fung der Identit�t bzw. Bonit�t des Kunden werden Abfragen und Ausk�nfte bei �ffentlich zug�nglichen Datenbanken sowie Kreditauskunfteien durchgef�hrt. Bei nachstehenden Anbietern k�nnen Ausk�nfte und gegebenenfalls Bonit�tsinformationen auf Basis mathematisch-statistischer Verfahren eingeholt werden:</p>
39
+ <ul>
40
+ <li>CRIF GmbH, Diefenbachgasse 35, A-1150 Wien</li>
41
+ <li>CRIF AG, Hagenholzstrasse 81, CH-8050 Z�rich</li>
42
+ <li>Deltavista GmbH, Dessauerstra�e 9, D-80992 M�nchen</li>
43
+ <li>SCHUFA Holding AG, Kormoranweg 5, D-65201 Wiesbaden</li>
44
+ <li>KSV1870 Information GmbH, Wagenseilgasse 7, A-1120 Wien</li>
45
+ <li>B�rgel Wirtschaftsinformationen GmbH & Co. KG, Gasstra�e 18, D-22761 Hamburg</li>
46
+ <li>Creditreform Boniversum GmbH, Hellersbergstr. 11, D-41460 Neuss</li>
47
+ <li>infoscore Consumer Data GmbH, Rheinstra�e 99, D-76532 Baden-Baden</li>
48
+ <li>ProfileAddress Direktmarketing GmbH, Altmannsdorfer Strasse 311, A-1230 Wien</li>
49
+ <li>Deutsche Post Direkt GmbH, Junkersring 57, D-53844 Troisdorf</li>
50
+ <li>payolution GmbH, Am Euro Platz 2, A-1120 Wien</li>
51
+ </ul>
52
+ <p>payolution wird Ihre Angaben zur Bankverbindung (insbesondere Bankleitzahl und Kontonummer) zum Zwecke der Kontonummernpr�fung an die SCHUFA Holding AG �bermitteln. Die SCHUFA pr�ft anhand dieser Daten zun�chst, ob die von Ihnen gemachten Angaben zur Bankverbindung plausibel sind. Die SCHUFA �berpr�ft, ob die zur Pr�fung verwendeten Daten ggf. in Ihrem Datenbestand gespeichert sind und �bermittelt sodann das Ergebnis der �berpr�fung an payolution zur�ck. Ein weiterer Datenaustausch wie die Bekanntgabe von Bonit�tsinformationen oder eine �bermittlung abweichender Bankverbindungsdaten sowie Speicherung Ihrer Daten im SCHUFA-Datenbestand finden im Rahmen der Kontonummernpr�fung nicht statt. Es wird aus Nachweisgr�nden allein die Tatsache der �berpr�fung der Bankverbindungsdaten bei der SCHUFA gespeichert.</p>
53
+ <p>payolution ist berechtigt, auch Daten zu etwaigem nicht-vertragsgem��en Verhalten (z.B. unbestrittene offene Forderungen) zu speichern, zu verarbeiten, zu nutzen und an oben genannte Auskunfteien zu �bermitteln.</p>
54
+ </li>
55
+ <li><p>Wir sind bereits nach den Bestimmungen des B�rgerlichen Gesetzbuches �ber Finanzierungshilfen zwischen Unternehmern und Verbrauchern, zu einer Pr�fung Ihrer Kreditw�rdigkeit gesetzlich verpflichtet.</p></li>
56
+ <li><p>Im Fall eines Kaufs auf Rechnung oder Ratenkauf oder einer Bezahlung mittels SEPA-Basis-Lastschrift werden der payolution GmbH Daten �ber die Aufnahme (zu Ihrer Person, Kaufpreis, Laufzeit des Teilzahlungsgesch�fts, Ratenbeginn) und vereinbarungsgem��e Abwicklung (z.B. vorzeitige R�ckzahlung, Laufzeitverl�ngerung, erfolgte R�ckzahlungen) dieses Teilzahlungsgesch�fts �bermittelt. Nach Abtretung der Kaufpreisforderung wird die forderungs�bernehmende Bank die genannten Daten�bermittlungen vornehmen. Wir bzw. die Bank, der die Kaufpreisforderung abgetreten wird, werden payolution GmbH auch Daten aufgrund nichtvertragsgem��er Abwicklung (z.B. K�ndigung des Teilzahlungsgesch�fts, Zwangsvollstreckungs-ma�nahmen) melden. Diese Meldungen d�rfen nach den datenschutzrechtlichen Bestimmungen nur erfolgen, soweit dies zur Wahrung berechtigter Interessen von Vertragspartnern der payolution GmbH oder der Allgemeinheit erforderlich ist und dadurch Ihre schutzw�rdigen Belange nicht beeintr�chtigt werden. payolution GmbH speichert die Daten, um ihren Vertragspartnern, die gewerbsm��ig Teilzahlungs- und sonstige Kreditgesch�fte an Verbraucher geben, Informationen zur Beurteilung der Kreditw�rdigkeit von Kunden geben zu k�nnen. An Unternehmen, die gewerbsm��ig Forderungen einziehen und payolution GmbH vertraglich angeschlossen sind, k�nnen zum Zwecke der Schuldnerermittlung Adressdaten �bermittelt werden. payolution GmbH stellt die Daten ihren Vertragspartnern nur zur Verf�gung, wenn diese ein berechtigtes Interesse an der Daten�bermittlung glaubhaft darlegen. payolution GmbH �bermittelt nur objektive Daten ohne Angabe der Bank; subjektive Werturteile sowie pers�nliche Einkommens- und Verm�gensverh�ltnisse sind in Ausk�nften der payolution GmbH nicht enthalten.</p></li>
57
+ <li><p>Die im Bestellprozess durch Einwilligung erfolgte Zustimmung zur Datenweitergabe kann jederzeit, auch ohne Angabe von Gr�nden, uns gegen�ber widerrufen k�nnen. Die oben genannten gesetzlichen Verpflichtungen zur �berpr�fung Ihrer Kreditw�rdigkeit bleiben von einem allf�lligen Widerruf jedoch unber�hrt. Sie sind verpflichtet ausschlie�lich wahrheitsgetreue Angaben gegen�ber uns zu machen.</p></li>
58
+ <li><p>Sollten Sie Auskunft �ber die Erhebung, Nutzung, Verarbeitung oder �bermittlung von Sie betreffenden personenbezogenen Daten erhalten wollen oder Ausk�nfte, Berichtigungen, Sperrungen oder L�schung dieser Daten w�nschen, k�nnen Sie sich an den Sachbearbeiter f�r Datenschutz bei payolution wenden:</p></li>
59
+ </ol>
60
+
61
+ <footer>Sachbearbeiter f�r Datenschutz<br />
62
+ datenschutz@payolution.com<br />
63
+ payolution GmbH<br />
64
+ Am Euro Platz 2<br />
65
+ 1120 Wien<br />
66
+ DVR: 4008655
67
+ </footer>";
68
+
69
+ protected function _construct() {
70
+ parent::_construct();
71
+ $this->setTemplate('payone/core/payment/method/form/payolution.phtml');
72
+ }
73
+
74
+ public function getPayolutionType() {
75
+ if($this->_sType === null) {
76
+ $aTypes = $this->getMethod()->getConfig()->getTypes();
77
+ $this->_sType = array_shift($aTypes);
78
+ }
79
+ return $this->_sType;
80
+ }
81
+
82
+ public function getPayolutionTypes() {
83
+ return $this->getMethod()->getConfig()->getTypes();
84
+ }
85
+
86
+ /**
87
+ * @return bool
88
+ */
89
+ public function isDobRequired()
90
+ {
91
+ // required for all countries
92
+ // required only if customer didn't enter Dob in previous checkout step
93
+ $customerDob = $this->getQuote()->getCustomerDob();
94
+ if (empty($customerDob)) {
95
+ return true;
96
+ }
97
+ return false;
98
+ }
99
+
100
+ /**
101
+ * @return bool
102
+ */
103
+ public function isTelephoneRequired()
104
+ {
105
+ // telephone is mandatory for any country in case of Klarna
106
+ $telephone = $this->getQuote()->getBillingAddress()->getTelephone();
107
+ if (empty($telephone)) {
108
+ return true;
109
+ }
110
+
111
+ return false;
112
+ }
113
+
114
+ public function isB2BMode() {
115
+ if((bool)$this->getMethod()->getConfig()->getB2bMode() === true) {
116
+ $sCompany = $this->getQuote()->getBillingAddress()->getCompany();
117
+ if($sCompany) {
118
+ return true;
119
+ }
120
+ }
121
+ return false;
122
+ }
123
+
124
+ public function showBirthdayFields() {
125
+ if($this->isB2BMode() === false) {
126
+ return true;
127
+ }
128
+ return false;
129
+ }
130
+
131
+ public function showDebitFields() {
132
+ if ($this->getPayolutionType() == Payone_Api_Enum_PayolutionType::PYD) {
133
+ return true;
134
+ }
135
+ return false;
136
+ }
137
+
138
+ protected function _getFallbackText($sCompany) {
139
+ $sFallback = str_replace('**company**', $sCompany, $this->_sFallback);
140
+ return $sFallback;
141
+ }
142
+
143
+ protected function _isUtf8EncodingNeeded($sString) {
144
+ if (preg_match('!!u', $sString)) {
145
+ // this is utf-8
146
+ return false;
147
+ } else {
148
+ // definitely not utf-8
149
+ return true;
150
+ }
151
+ }
152
+
153
+ public function getPayolutionAcceptanceText() {
154
+ $sCompany = $this->getMethod()->getConfig()->getCompanyName();
155
+ $sUrl = $this->_sAcceptanceBaseUrl.base64_encode($sCompany);
156
+ $sContent = file_get_contents($sUrl);
157
+ $sPage = false;
158
+ if(!empty($sContent) && stripos($sContent, 'payolution') !== false && stripos($sContent, '<header>') !== false) {
159
+ //Parse content from HTML-body-tag from the given page
160
+ $sRegex = "#<\s*?body\b[^>]*>(.*?)</body\b[^>]*>#s";
161
+ preg_match($sRegex, $sContent, $aMatches);
162
+ if(is_array($aMatches) && count($aMatches) > 1) {
163
+ $sPage = $aMatches[1];
164
+ //remove everything bevore the <header> tag ( a window.close link which wouldn't work in the given context )
165
+ $sPage = substr($sPage, stripos($sPage, '<header>'));
166
+ }
167
+ }
168
+ if(!$sPage) {
169
+ $sPage = $this->_getFallbackText($sCompany);
170
+ }
171
+ if($this->_isUtf8EncodingNeeded($sPage)) {
172
+ $sPage = utf8_encode($sPage);
173
+ }
174
+ return $sPage;
175
+ }
176
+
177
+ /**
178
+ * @return array
179
+ */
180
+ protected function getSystemConfigMethodTypes()
181
+ {
182
+ return $this->getFactory()->getModelSystemConfigPayolutionType()->toSelectArray();
183
+ }
184
+
185
+ }
app/code/community/Payone/Core/Block/Payment/Method/Form/Ratepay.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2015 <kontakt@fatchip.de> - www.fatchip.com
19
+ * @author Robert M�ller <robert.mueller@fatchip.de>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.fatchip.com
22
+ */
23
+
24
+ class Payone_Core_Block_Payment_Method_Form_Ratepay extends Payone_Core_Block_Payment_Method_Form_Abstract {
25
+
26
+ protected function _construct() {
27
+ parent::_construct();
28
+ $this->setTemplate('payone/core/payment/method/form/ratepay.phtml');
29
+ }
30
+
31
+ /**
32
+ * @return bool
33
+ */
34
+ public function isDobRequired()
35
+ {
36
+ // required for all countries
37
+ // required only if customer didn't enter Dob in previous checkout step
38
+ $customerDob = $this->getQuote()->getCustomerDob();
39
+ if (empty($customerDob)) {
40
+ return true;
41
+ }
42
+ return false;
43
+ }
44
+
45
+ /**
46
+ * @return bool
47
+ */
48
+ public function isTelephoneRequired()
49
+ {
50
+ // telephone is mandatory for any country in case of Klarna
51
+ $telephone = $this->getQuote()->getBillingAddress()->getTelephone();
52
+ if (empty($telephone)) {
53
+ return true;
54
+ }
55
+
56
+ return false;
57
+ }
58
+
59
+ public function getMatchingRatePayShopId() {
60
+ $oMethod = $this->getMethod();
61
+ $aConfig = $oMethod->getMatchingRatePayConfig();
62
+ return $aConfig['shop_id'];
63
+ }
64
+
65
+ public function getRatePayDeviceFingerprintSnippetId() {
66
+ $oMethod = $this->getMethod();
67
+ $aConfig = $oMethod->getMatchingRatePayConfig();
68
+ return $aConfig['device_fingerprint_snippet_id'];
69
+ }
70
+
71
+ protected function _setSessionFingerprint($sFingerprint) {
72
+ $checkoutSession = $this->getFactory()->getSingletonCheckoutSession();
73
+ $checkoutSession->setRatePayFingerprint($sFingerprint);
74
+ }
75
+
76
+ public function getRatePayDeviceFingerprint() {
77
+ $checkoutSession = $this->getFactory()->getSingletonCheckoutSession();
78
+ if(!$checkoutSession->getRatePayFingerprint()) {
79
+ $sFingerprint = $this->getQuote()->getBillingAddress()->getFirstname();
80
+ $sFingerprint .= $this->getQuote()->getBillingAddress()->getLastname();
81
+ $sFingerprint .= microtime();
82
+ $sFingerprint = md5($sFingerprint);
83
+ $this->_setSessionFingerprint($sFingerprint);
84
+ } else {
85
+ $sFingerprint = $checkoutSession->getRatePayFingerprint();
86
+ }
87
+ return $sFingerprint;
88
+ }
89
+
90
+ }
app/code/community/Payone/Core/Block/Payment/Method/Info/Payolution.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2015 <kontakt@fatchip.de> - www.fatchip.com
19
+ * @author Robert M�ller <robert.mueller@fatchip.de>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.fatchip.com
22
+ */
23
+
24
+ class Payone_Core_Block_Payment_Method_Info_Payolution extends Payone_Core_Block_Payment_Method_Info_Abstract {
25
+
26
+ protected function _construct() {
27
+ parent::_construct();
28
+ $this->setTemplate('payone/core/payment/method/info/payolution.phtml');
29
+ }
30
+
31
+ /**
32
+ * @return string
33
+ */
34
+ public function getPayoneClearingReference()
35
+ {
36
+ return $this->getInfo()->getPayoneClearingReference();
37
+ }
38
+
39
+ }
app/code/community/Payone/Core/Block/Payment/Method/Info/Ratepay.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2015 <kontakt@fatchip.de> - www.fatchip.com
19
+ * @author Robert M�ller <robert.mueller@fatchip.de>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.fatchip.com
22
+ */
23
+
24
+ class Payone_Core_Block_Payment_Method_Info_Ratepay extends Payone_Core_Block_Payment_Method_Info_Abstract {
25
+
26
+ protected function _construct() {
27
+ parent::_construct();
28
+ $this->setTemplate('payone/core/payment/method/info/ratepay.phtml');
29
+ }
30
+
31
+ /**
32
+ * @return string
33
+ */
34
+ public function getPayoneClearingReference()
35
+ {
36
+ return $this->getInfo()->getPayoneClearingReference();
37
+ }
38
+
39
+ }
app/code/community/Payone/Core/Model/Config/General/ParameterNarrativeText.php CHANGED
@@ -45,6 +45,11 @@ class Payone_Core_Model_Config_General_ParameterNarrativeText
45
  * @var string
46
  */
47
  protected $paydirekt = '';
 
 
 
 
 
48
 
49
  /**
50
  * @param string $creditcard
@@ -93,4 +98,20 @@ class Payone_Core_Model_Config_General_ParameterNarrativeText
93
  {
94
  return $this->paydirekt;
95
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
45
  * @var string
46
  */
47
  protected $paydirekt = '';
48
+
49
+ /**
50
+ * @var string
51
+ */
52
+ protected $paypal_express = '';
53
 
54
  /**
55
  * @param string $creditcard
98
  {
99
  return $this->paydirekt;
100
  }
101
+
102
+ /**
103
+ * @param string $paydirekt
104
+ */
105
+ public function setPaypalExpress($paypal_express)
106
+ {
107
+ $this->paypal_express = $paypal_express;
108
+ }
109
+
110
+ /**
111
+ * @return string
112
+ */
113
+ public function getPaypalExpress()
114
+ {
115
+ return $this->paypal_express;
116
+ }
117
  }
app/code/community/Payone/Core/Model/Config/Payment/Method.php CHANGED
@@ -201,6 +201,26 @@ class Payone_Core_Model_Config_Payment_Method
201
  * @var int
202
  */
203
  protected $currency_convert = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
  /**
206
  * Check if Method can be used in Country
@@ -988,4 +1008,69 @@ class Payone_Core_Model_Config_Payment_Method
988
  {
989
  return $this->currency_convert;
990
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
991
  }
201
  * @var int
202
  */
203
  protected $currency_convert = 0;
204
+
205
+ /**
206
+ * @var array
207
+ */
208
+ protected $ratepay_config = array();
209
+
210
+ /**
211
+ * @var bool
212
+ */
213
+ protected $show_customermessage = false;
214
+
215
+ /**
216
+ * @var string
217
+ */
218
+ protected $company_name = '';
219
+
220
+ /**
221
+ * @var bool
222
+ */
223
+ protected $b2b_mode = false;
224
 
225
  /**
226
  * Check if Method can be used in Country
1008
  {
1009
  return $this->currency_convert;
1010
  }
1011
+
1012
+ /**
1013
+ * @param array $ratepay_config
1014
+ */
1015
+ public function setRatepayConfig($ratepay_config)
1016
+ {
1017
+ $this->ratepay_config = $ratepay_config;
1018
+ }
1019
+
1020
+ /**
1021
+ * @return array
1022
+ */
1023
+ public function getRatepayConfig()
1024
+ {
1025
+ return $this->ratepay_config;
1026
+ }
1027
+
1028
+ /**
1029
+ * @param bool $show_customermessage
1030
+ */
1031
+ public function setShowCustomermessage($show_customermessage)
1032
+ {
1033
+ $this->show_customermessage = (bool)$show_customermessage;
1034
+ }
1035
+
1036
+ /**
1037
+ * @return bool
1038
+ */
1039
+ public function getShowCustomermessage()
1040
+ {
1041
+ return $this->show_customermessage;
1042
+ }
1043
+
1044
+ /**
1045
+ * @param string $company_name
1046
+ */
1047
+ public function setCompanyName($company_name)
1048
+ {
1049
+ $this->company_name = $company_name;
1050
+ }
1051
+
1052
+ /**
1053
+ * @return string
1054
+ */
1055
+ public function getCompanyName()
1056
+ {
1057
+ return $this->company_name;
1058
+ }
1059
+
1060
+ /**
1061
+ * @param bool $b2b_mode
1062
+ */
1063
+ public function setB2bMode($b2b_mode)
1064
+ {
1065
+ $this->b2b_mode = $b2b_mode;
1066
+ }
1067
+
1068
+ /**
1069
+ * @return bool
1070
+ */
1071
+ public function getB2bMode()
1072
+ {
1073
+ return $this->b2b_mode;
1074
+ }
1075
+
1076
  }
app/code/community/Payone/Core/Model/Config/Payment/Method/Interface.php CHANGED
@@ -459,4 +459,44 @@ interface Payone_Core_Model_Config_Payment_Method_Interface
459
 
460
  public function hasParent();
461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
  }
459
 
460
  public function hasParent();
461
 
462
+ /**
463
+ * @param array $ratepay_config
464
+ */
465
+ public function setRatepayConfig($ratepay_config);
466
+
467
+ /**
468
+ * @return array
469
+ */
470
+ public function getRatepayConfig();
471
+
472
+ /**
473
+ * @param bool $show_customermessage
474
+ */
475
+ public function setShowCustomermessage($show_customermessage);
476
+
477
+ /**
478
+ * @return bool
479
+ */
480
+ public function getShowCustomermessage();
481
+
482
+ /**
483
+ * @param string $company_name
484
+ */
485
+ public function setCompanyName($company_name);
486
+
487
+ /**
488
+ * @return string
489
+ */
490
+ public function getCompanyName();
491
+
492
+ /**
493
+ * @param bool $b2b_mode
494
+ */
495
+ public function setB2bMode($b2b_mode);
496
+
497
+ /**
498
+ * @return bool
499
+ */
500
+ public function getB2bMode();
501
+
502
  }
app/code/community/Payone/Core/Model/Domain/Config/PaymentMethod.php CHANGED
@@ -455,6 +455,7 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
455
  switch ($fieldKey) {
456
  case 'klarna_config':
457
  case 'fee_config':
 
458
  unset($value['__empty']);
459
  $value = empty($value) ? null : $value;
460
  break;
@@ -584,6 +585,8 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
584
  $this->unserializeData('fee_config');
585
  // prepare klarna config
586
  $this->unserializeData('klarna_config');
 
 
587
  $this->explodeData('types');
588
  $this->explodeData('specificcountry');
589
  $this->explodeData('sepa_country');
@@ -617,6 +620,9 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
617
 
618
  // prepare klarna_config
619
  $this->serializeData('klarna_config');
 
 
 
620
  }
621
 
622
  /**
@@ -691,6 +697,15 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
691
  $this->unserializeData('klarna_config');
692
  return $this->getData('klarna_config');
693
  }
 
 
 
 
 
 
 
 
 
694
 
695
  /**
696
  * @return array
455
  switch ($fieldKey) {
456
  case 'klarna_config':
457
  case 'fee_config':
458
+ case 'ratepay_config':
459
  unset($value['__empty']);
460
  $value = empty($value) ? null : $value;
461
  break;
585
  $this->unserializeData('fee_config');
586
  // prepare klarna config
587
  $this->unserializeData('klarna_config');
588
+ // prepare ratepay config
589
+ $this->unserializeData('ratepay_config');
590
  $this->explodeData('types');
591
  $this->explodeData('specificcountry');
592
  $this->explodeData('sepa_country');
620
 
621
  // prepare klarna_config
622
  $this->serializeData('klarna_config');
623
+
624
+ // prepare ratepay_config
625
+ $this->serializeData('ratepay_config');
626
  }
627
 
628
  /**
697
  $this->unserializeData('klarna_config');
698
  return $this->getData('klarna_config');
699
  }
700
+
701
+ /**
702
+ * @return array
703
+ */
704
+ public function getRatepayConfig()
705
+ {
706
+ $this->unserializeData('ratepay_config');
707
+ return $this->getData('ratepay_config');
708
+ }
709
 
710
  /**
711
  * @return array
app/code/community/Payone/Core/Model/Factory.php CHANGED
@@ -307,7 +307,7 @@ class Payone_Core_Model_Factory
307
  /**
308
  * @return bool
309
  */
310
- protected function getIsAdmin()
311
  {
312
  return Mage::app()->getStore()->isAdmin();
313
  }
@@ -1552,6 +1552,14 @@ class Payone_Core_Model_Factory
1552
  {
1553
  return Mage::getSingleton('payone_core/system_config_onlinebanktransferType');
1554
  }
 
 
 
 
 
 
 
 
1555
 
1556
  /**
1557
  * @return Payone_Core_Model_System_Config_WalletType
307
  /**
308
  * @return bool
309
  */
310
+ public function getIsAdmin()
311
  {
312
  return Mage::app()->getStore()->isAdmin();
313
  }
1552
  {
1553
  return Mage::getSingleton('payone_core/system_config_onlinebanktransferType');
1554
  }
1555
+
1556
+ /**
1557
+ * @return Payone_Core_Model_System_Config_PayolutionType
1558
+ */
1559
+ public function getModelSystemConfigPayolutionType()
1560
+ {
1561
+ return Mage::getSingleton('payone_core/system_config_payolutionType');
1562
+ }
1563
 
1564
  /**
1565
  * @return Payone_Core_Model_System_Config_WalletType
app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php CHANGED
@@ -188,6 +188,10 @@ abstract class Payone_Core_Model_Handler_Payment_Abstract
188
  $order->setData('payone_payment_method_type',
189
  $this->getPayment()->getData('payone_safe_invoice_type'));
190
  }
 
 
 
 
191
  }
192
 
193
  /**
@@ -222,6 +226,17 @@ abstract class Payone_Core_Model_Handler_Payment_Abstract
222
  $payment->setPayoneClearingLegalnote($response->getClearingLegalnote());
223
  $payment->setPayoneClearingDuedate($response->getClearingDuedate());
224
  }
 
 
 
 
 
 
 
 
 
 
 
225
  }
226
  }
227
 
188
  $order->setData('payone_payment_method_type',
189
  $this->getPayment()->getData('payone_safe_invoice_type'));
190
  }
191
+ elseif ($this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_Payolution) {
192
+ $order->setData('payone_payment_method_type',
193
+ $this->getPayment()->getData('payone_payolution_type'));
194
+ }
195
  }
196
 
197
  /**
226
  $payment->setPayoneClearingLegalnote($response->getClearingLegalnote());
227
  $payment->setPayoneClearingDuedate($response->getClearingDuedate());
228
  }
229
+ } elseif($paymentMethod instanceof Payone_Core_Model_Payment_Method_Ratepay) {
230
+ $oSession = Mage::getSingleton('checkout/session');
231
+ $oSession->unsRatePayFingerprint();
232
+ }
233
+
234
+ if($response instanceof Payone_Api_Response_Authorization_Abstract) {
235
+ if($response->getAddPaydataClearingReference()) {
236
+ $payment->setPayoneClearingReference($response->getAddPaydataClearingReference());
237
+ } elseif($response->getClearingReference()) {
238
+ $payment->setPayoneClearingReference($response->getClearingReference());
239
+ }
240
  }
241
  }
242
 
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php CHANGED
@@ -135,6 +135,11 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
135
  if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Barzahlen) {
136
  $requestType = Payone_Api_Enum_RequestType::PREAUTHORIZATION;
137
  }
 
 
 
 
 
138
 
139
  $request->setRequest($requestType);
140
  $request->setAid($this->configPayment->getAid());
@@ -151,6 +156,8 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
151
  $narrativeText = $this->getNarrativeText('debit_payment');
152
  } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Wallet && $this->_getWalletType() == Payone_Api_Enum_WalletType::PAYDIREKT) {
153
  $narrativeText = $order->getIncrementId();
 
 
154
  }
155
  $request->setNarrativeText($narrativeText);
156
 
@@ -203,7 +210,9 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
203
  // Send Ip when enabled
204
  if ($global->getTransmitIp()) {
205
  $ip = $this->getCustomerIp();
206
-
 
 
207
  $personalData->setIp($ip);
208
  }
209
 
@@ -565,6 +574,67 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
565
  $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Barzahlen();
566
  $payment->setApiVersion();
567
  $payment->setCashtype();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
  }
569
 
570
  if ($isRedirect === true) {
@@ -633,6 +703,12 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
633
  elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Barzahlen) {
634
  $clearingType = Payone_Enum_ClearingType::BARZAHLEN;
635
  }
 
 
 
 
 
 
636
 
637
  return $clearingType;
638
  }
@@ -666,6 +742,8 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
666
  $narrativeText = $parameterNarrativeText->getDebitPayment();
667
  } elseif ($type === 'paydirekt') {
668
  $narrativeText = $parameterNarrativeText->getPaydirekt();
 
 
669
  }
670
 
671
  $substitutionArray = array(
135
  if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Barzahlen) {
136
  $requestType = Payone_Api_Enum_RequestType::PREAUTHORIZATION;
137
  }
138
+
139
+ // Always use PREAUTHORIZATION for Payolution
140
+ if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Payolution) {
141
+ $requestType = Payone_Api_Enum_RequestType::PREAUTHORIZATION;
142
+ }
143
 
144
  $request->setRequest($requestType);
145
  $request->setAid($this->configPayment->getAid());
156
  $narrativeText = $this->getNarrativeText('debit_payment');
157
  } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Wallet && $this->_getWalletType() == Payone_Api_Enum_WalletType::PAYDIREKT) {
158
  $narrativeText = $order->getIncrementId();
159
+ } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Wallet && $this->_getWalletType() == Payone_Api_Enum_WalletType::PAYPAL_EXPRESS) {
160
+ $narrativeText = $this->getNarrativeText('paypal_express');
161
  }
162
  $request->setNarrativeText($narrativeText);
163
 
210
  // Send Ip when enabled
211
  if ($global->getTransmitIp()) {
212
  $ip = $this->getCustomerIp();
213
+ if(!$ip && $paymentMethod->getIsIpMandatory() === true) {
214
+ $ip = Mage::helper('core/http')->getRemoteAddr();
215
+ }
216
  $personalData->setIp($ip);
217
  }
218
 
574
  $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Barzahlen();
575
  $payment->setApiVersion();
576
  $payment->setCashtype();
577
+ } elseif($paymentMethod instanceof Payone_Core_Model_Payment_Method_Ratepay) {
578
+ $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_RatePay();
579
+ $payment->setFinancingtype();
580
+ $payment->setApiVersion();
581
+
582
+ $checkoutSession = $this->getFactory()->getSingletonCheckoutSession();
583
+ $mandateStatus = $checkoutSession->getRatePayFingerprint();
584
+
585
+ $payData = new Payone_Api_Request_Parameter_Paydata_Paydata();
586
+ $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
587
+ array('key' => 'customer_allow_credit_inquiry', 'data' => 'yes') // hardcoded by concept
588
+ ));
589
+ $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
590
+ array('key' => 'device_token', 'data' => $checkoutSession->getRatePayFingerprint())
591
+ ));
592
+ $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
593
+ array('key' => 'shop_id', 'data' => $info->getPayoneRatepayShopId())
594
+ ));
595
+ $payment->setPaydata($payData);
596
+
597
+ $birthdayDate = $info->getPayoneCustomerDob();
598
+ if (empty($birthdayDate)) {
599
+ $birthdayDate = $this->getOrder()->getCustomerDob();
600
+ }
601
+ $payment->setBirthday($this->formatBirthday($birthdayDate));
602
+
603
+ $telephone = $info->getPayoneCustomerTelephone();
604
+ if (empty($telephone)) {
605
+ $telephone = $this->getOrder()->getBillingAddress()->getTelephone();
606
+ }
607
+ $payment->setTelephonenumber($telephone);
608
+ } elseif($paymentMethod instanceof Payone_Core_Model_Payment_Method_Payolution) {
609
+ $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Payolution();
610
+ $payment->setApiVersion();
611
+ $payment->setFinancingtype($info->getPayonePayolutionType());
612
+ $payment->setWorkorderid($info->getPayoneWorkorderid());
613
+ $payment->setIban(strtoupper($info->getPayoneSepaIban()));
614
+ $payment->setBic(strtoupper($info->getPayoneSepaBic()));
615
+
616
+ $checkoutSession = $this->getFactory()->getSingletonCheckoutSession();
617
+ $payment->setWorkorderid($checkoutSession->getPayoneWorkorderId());
618
+ $info->setPayoneWorkorderId($checkoutSession->getPayoneWorkorderId());
619
+
620
+ if((bool)$info->getPayoneIsb2b() === true) {
621
+ $payData = new Payone_Api_Request_Parameter_Paydata_Paydata();
622
+ $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
623
+ array('key' => 'b2b', 'data' => 'yes')
624
+ ));
625
+ $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
626
+ array('key' => 'company_trade_registry_number', 'data' => $info->getPayoneTradeRegistryNumber())
627
+ ));
628
+ $payment->setPaydata($payData);
629
+ } else {
630
+ $birthdayDate = $info->getPayoneCustomerDob();
631
+ if (empty($birthdayDate)) {
632
+ $birthdayDate = $this->getOrder()->getCustomerDob();
633
+ }
634
+ if($birthdayDate) {
635
+ $payment->setBirthday($this->formatBirthday($birthdayDate));
636
+ }
637
+ }
638
  }
639
 
640
  if ($isRedirect === true) {
703
  elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Barzahlen) {
704
  $clearingType = Payone_Enum_ClearingType::BARZAHLEN;
705
  }
706
+ elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Ratepay) {
707
+ $clearingType = Payone_Enum_ClearingType::RATEPAY;
708
+ }
709
+ elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Payolution) {
710
+ $clearingType = Payone_Enum_ClearingType::PAYOLUTION;
711
+ }
712
 
713
  return $clearingType;
714
  }
742
  $narrativeText = $parameterNarrativeText->getDebitPayment();
743
  } elseif ($type === 'paydirekt') {
744
  $narrativeText = $parameterNarrativeText->getPaydirekt();
745
+ } elseif ($type === 'paypal_express') {
746
+ $narrativeText = $parameterNarrativeText->getPaypalExpress();
747
  }
748
 
749
  $substitutionArray = array(
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Capture.php CHANGED
@@ -72,6 +72,18 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
72
  }
73
  }
74
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  $this->dispatchEvent($this->getEventName(), array('request' => $request, 'invoice' => $this->getInvoice()));
76
  $this->dispatchEvent($this->getEventPrefix() . '_all', array('request' => $request));
77
 
@@ -121,19 +133,15 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
121
  if ($this->isInvoiceLast() || $this->helperRegistry()->isPaymentCancelRegistered($payment)) {
122
  // Invoice completes the order
123
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
124
- }
125
- else {
126
  // partial payment
127
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::NO);
128
  }
129
- }
130
- elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice
131
- and $paymentMethod->getInfoInstance()->getPayoneSafeInvoiceType() == Payone_Api_Enum_FinancingType::BSV
132
- ) {
133
  // BillSAFE always settles account:
134
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::YES);
135
- }
136
- else {
137
  // all other can always use AUTO, regardless of complete or partial capture
138
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
139
  }
72
  }
73
  }
74
 
75
+ $paymentMethod = $this->getPaymentMethod();
76
+ if($paymentMethod instanceof Payone_Core_Model_Payment_Method_Ratepay) {
77
+ $info = $paymentMethod->getInfoInstance();
78
+
79
+ $payData = new Payone_Api_Request_Parameter_Paydata_Paydata();
80
+ $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
81
+ array('key' => 'shop_id', 'data' => $info->getPayoneRatepayShopId())
82
+ ));
83
+ $request->setPaydata($payData);
84
+ $request->setApiVersion('3.10');
85
+ }
86
+
87
  $this->dispatchEvent($this->getEventName(), array('request' => $request, 'invoice' => $this->getInvoice()));
88
  $this->dispatchEvent($this->getEventPrefix() . '_all', array('request' => $request));
89
 
133
  if ($this->isInvoiceLast() || $this->helperRegistry()->isPaymentCancelRegistered($payment)) {
134
  // Invoice completes the order
135
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
136
+ } else {
 
137
  // partial payment
138
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::NO);
139
  }
140
+ } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice
141
+ && $paymentMethod->getInfoInstance()->getPayoneSafeInvoiceType() == Payone_Api_Enum_FinancingType::BSV) {
 
 
142
  // BillSAFE always settles account:
143
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::YES);
144
+ } else {
 
145
  // all other can always use AUTO, regardless of complete or partial capture
146
  $business->setSettleaccount(Payone_Api_Enum_Settleaccount::AUTO);
147
  }
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Debit.php CHANGED
@@ -69,6 +69,16 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
69
  $request->setInvoicing($invoicing);
70
  }
71
 
 
 
 
 
 
 
 
 
 
 
72
  $this->dispatchEvent($this->getEventName(), array('request' => $request, 'creditmemo' => $this->getCreditmemo()));
73
  $this->dispatchEvent($this->getEventPrefix() . '_all', array('request' => $request));
74
  return $request;
69
  $request->setInvoicing($invoicing);
70
  }
71
 
72
+ $paymentMethod = $this->getPaymentMethod();
73
+ if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Ratepay) {
74
+ $payData = new Payone_Api_Request_Parameter_Paydata_Paydata();
75
+ $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
76
+ array('key' => 'shop_id', 'data' => $paymentMethod->getInfoInstance()->getPayoneRatepayShopId())
77
+ ));
78
+ $request->setPaydata($payData);
79
+ $request->setApiVersion('3.10');
80
+ }
81
+
82
  $this->dispatchEvent($this->getEventName(), array('request' => $request, 'creditmemo' => $this->getCreditmemo()));
83
  $this->dispatchEvent($this->getEventPrefix() . '_all', array('request' => $request));
84
  return $request;
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php CHANGED
@@ -101,6 +101,85 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Genericpayment
101
  )));
102
  return $request;
103
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  /**
106
  * @return string
101
  )));
102
  return $request;
103
  }
104
+
105
+ public function addRatePayParameters($sRatePayShopId) {
106
+ $request = $this->getRequest();
107
+ $this->mapDefaultParameters($request);
108
+ $paydata = new Payone_Api_Request_Parameter_Paydata_Paydata();
109
+ $paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
110
+ array('key' => 'action', 'data' => Payone_Api_Enum_GenericpaymentAction::RATEPAY_PROFILE)
111
+ ));
112
+ $paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
113
+ array('key' => 'shop_id', 'data' => $sRatePayShopId)
114
+ ));
115
+ $request->setPaydata($paydata);
116
+ $request->setAid($this->getConfigPayment()->getAid());
117
+ $request->setClearingtype(Payone_Enum_ClearingType::FINANCING);
118
+ $request->setCurrency('EUR');
119
+ $request->setFinancingType(Payone_Api_Enum_RatepayType::RPV);
120
+ return $request;
121
+ }
122
+
123
+ /**
124
+ * @param $date
125
+ * @return string
126
+ */
127
+ public function formatBirthday($date)
128
+ {
129
+ if (strlen($date) > 0) {
130
+ $date = substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2);
131
+ }
132
+ return $date;
133
+ }
134
+
135
+ public function addPayolutionPreCheckParameters($oQuote, $aRequestParams) {
136
+ $request = $this->getRequest();
137
+ $this->mapDefaultParameters($request);
138
+
139
+ $oAddress = $oQuote->getBillingAddress();
140
+ if ($oAddress->getCompany()) {
141
+ $request->setCompany($oAddress->getCompany());
142
+ }
143
+ $request->setFirstname($oAddress->getFirstname());
144
+ $request->setLastname($oAddress->getLastname());
145
+ $request->setStreet($this->helper()->normalizeStreet($oAddress->getStreet()));
146
+ $request->setZip($oAddress->getPostcode());
147
+ $request->setCity($oAddress->getCity());
148
+ $request->setCountry($oAddress->getCountry());
149
+
150
+ $request->setAmount($oQuote->getGrandTotal());
151
+ $request->setApiVersion('3.10');
152
+ if(isset($aRequestParams['payone_customer_dob'])) {
153
+ $request->setBirthday($this->formatBirthday($aRequestParams['payone_customer_dob']));
154
+ } elseif($oQuote->getCustomerDob()) {
155
+ $request->setBirthday($this->formatBirthday($oQuote->getCustomerDob()));
156
+ }
157
+ $request->setEmail($oQuote->getCustomerEmail());
158
+ $request->setIp(Mage::helper('core/http')->getRemoteAddr());
159
+ $request->setLanguage($this->helper()->getDefaultLanguage());
160
+
161
+ $paydata = new Payone_Api_Request_Parameter_Paydata_Paydata();
162
+ $paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
163
+ array('key' => 'action', 'data' => Payone_Api_Enum_GenericpaymentAction::PAYOLUTION_PRE_CHECK)
164
+ ));
165
+ $paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
166
+ array('key' => 'payment_type', 'data' => Payone_Api_Enum_PayolutionType::getLongType($aRequestParams['payone_payolution_type']))
167
+ ));
168
+ if(isset($aRequestParams['payone_trade_registry_number'])) {
169
+ $paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
170
+ array('key' => 'b2b', 'data' => 'yes')
171
+ ));
172
+ $paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
173
+ array('key' => 'company_trade_registry_number', 'data' => $aRequestParams['payone_trade_registry_number'])
174
+ ));
175
+ }
176
+ $request->setPaydata($paydata);
177
+ $request->setAid($this->getConfigPayment()->getAid());
178
+ $request->setCurrency($oQuote->getQuoteCurrencyCode());
179
+ $request->setClearingtype(Payone_Enum_ClearingType::FINANCING);
180
+ $request->setFinancingType($aRequestParams['payone_payolution_type']);
181
+ return $request;
182
+ }
183
 
184
  /**
185
  * @return string
app/code/community/Payone/Core/Model/Observer/Checkout/Onepage/DebitPayment.php CHANGED
@@ -52,7 +52,9 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
52
  $paymentData = $controllerAction->getRequest()->getPost('payment', array());
53
  $selectedMethod = $paymentData['method'];
54
 
55
- if ($selectedMethod != Payone_Core_Model_System_Config_PaymentMethodCode::DEBITPAYMENT) {
 
 
56
  return; // only active for payone_debit_payment
57
  }
58
 
@@ -70,6 +72,16 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
70
 
71
  $this->init($observer);
72
 
 
 
 
 
 
 
 
 
 
 
73
  $paymentConfig = $this->getPaymentConfig();
74
  $sepaMandateEnabled = $paymentConfig->isSepaMandateEnabled();
75
  $checkBankaccountEnabled = $paymentConfig->isBankAccountCheckEnabled();
@@ -90,6 +102,25 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
90
  }
91
  }
92
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
  /**
95
  * @throws Payone_Core_Exception_PaymentMethodConfigNotFound|Mage_Core_Exception
52
  $paymentData = $controllerAction->getRequest()->getPost('payment', array());
53
  $selectedMethod = $paymentData['method'];
54
 
55
+ if ($selectedMethod != Payone_Core_Model_System_Config_PaymentMethodCode::DEBITPAYMENT &&
56
+ $selectedMethod != Payone_Core_Model_System_Config_PaymentMethodCode::PAYOLUTION
57
+ ) {
58
  return; // only active for payone_debit_payment
59
  }
60
 
72
 
73
  $this->init($observer);
74
 
75
+ if ($selectedMethod == Payone_Core_Model_System_Config_PaymentMethodCode::DEBITPAYMENT) {
76
+ $controllerAction = $this->_performDebitChecks($controllerAction);
77
+ } elseif($selectedMethod == Payone_Core_Model_System_Config_PaymentMethodCode::PAYOLUTION) {
78
+ $controllerAction = $this->_performPayolutionChecks($controllerAction);
79
+ }
80
+ return $controllerAction;
81
+ }
82
+
83
+ protected function _performDebitChecks($controllerAction)
84
+ {
85
  $paymentConfig = $this->getPaymentConfig();
86
  $sepaMandateEnabled = $paymentConfig->isSepaMandateEnabled();
87
  $checkBankaccountEnabled = $paymentConfig->isBankAccountCheckEnabled();
102
  }
103
  }
104
  }
105
+
106
+ protected function _performPayolutionChecks($controllerAction)
107
+ {
108
+ $oQuote = $this->getQuote();
109
+
110
+ $oService = $this->getFactory()->getServicePaymentGenericpayment($this->getPaymentConfig());
111
+ $oMapper = $oService->getMapper();
112
+ $oRequest = $oMapper->addPayolutionPreCheckParameters($oQuote, $this->getPaymentData());
113
+ $oResponse = $this->getFactory()->getServiceApiPaymentGenericpayment()->request($oRequest);
114
+
115
+ if($oResponse instanceof Payone_Api_Response_Error) {
116
+ $controllerAction->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
117
+ $jsonResponse = array('error' => Mage::helper('payone_core')->__($oResponse->getErrormessage()));
118
+ return $controllerAction->getResponse()->setBody(Mage::helper('core')->jsonEncode($jsonResponse));
119
+ } elseif($oResponse instanceof Payone_Api_Response_Genericpayment_Ok) {
120
+ $checkoutSession = $this->getFactory()->getSingletonCheckoutSession();
121
+ $checkoutSession->setPayoneWorkorderId($oResponse->getWorkorderId());
122
+ }
123
+ }
124
 
125
  /**
126
  * @throws Payone_Core_Exception_PaymentMethodConfigNotFound|Mage_Core_Exception
app/code/community/Payone/Core/Model/Payment/Method/Abstract.php CHANGED
@@ -55,6 +55,8 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
55
  protected $methodType = '';
56
  protected $redirectUrl = '';
57
 
 
 
58
  /**
59
  * @var Payone_Core_Model_Config_Interface
60
  */
@@ -64,6 +66,8 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
64
  */
65
  protected $config = null;
66
 
 
 
67
  /**
68
  * override parent method to get the user-configured title, not the one from config.xml
69
  *
@@ -90,7 +94,7 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
90
  return $this->getConfigForQuote($quote)->getName();
91
  }
92
  }
93
- catch (Payone_Core_Exception_PaymentMethodConfigNotFound $e) {
94
  return parent::getTitle(); // if for some reason config was not found, use parent method
95
  }
96
  // call parent method if no config available
@@ -536,5 +540,15 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
536
  {
537
  return $this->methodType;
538
  }
 
 
 
 
 
 
 
 
 
 
539
 
540
  }
55
  protected $methodType = '';
56
  protected $redirectUrl = '';
57
 
58
+ protected $_defaultApiResponseErrorMessage = 'There has been an error processing your payment';
59
+
60
  /**
61
  * @var Payone_Core_Model_Config_Interface
62
  */
66
  */
67
  protected $config = null;
68
 
69
+ protected $_blIpMandatory = false;
70
+
71
  /**
72
  * override parent method to get the user-configured title, not the one from config.xml
73
  *
94
  return $this->getConfigForQuote($quote)->getName();
95
  }
96
  }
97
+ catch (Exception $e) {
98
  return parent::getTitle(); // if for some reason config was not found, use parent method
99
  }
100
  // call parent method if no config available
540
  {
541
  return $this->methodType;
542
  }
543
+
544
+ public function getApiResponseErrorMessage($response)
545
+ {
546
+ return $this->_defaultApiResponseErrorMessage;
547
+ }
548
+
549
+ public function getIsIpMandatory()
550
+ {
551
+ return $this->_blIpMandatory;
552
+ }
553
 
554
  }
app/code/community/Payone/Core/Model/Payment/Method/Payolution.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Payment
18
+ * @copyright Copyright (c) 2015 <kontakt@fatchip.de> - www.fatchip.com
19
+ * @author Robert M�ller <robert.mueller@fatchip.de>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.fatchip.com
22
+ */
23
+
24
+ class Payone_Core_Model_Payment_Method_Payolution extends Payone_Core_Model_Payment_Method_Abstract
25
+ {
26
+ protected $_canUseForMultishipping = true;
27
+
28
+ protected $methodType = Payone_Core_Model_System_Config_PaymentMethodType::PAYOLUTION;
29
+
30
+ protected $_code = Payone_Core_Model_System_Config_PaymentMethodCode::PAYOLUTION;
31
+
32
+ protected $_formBlockType = 'payone_core/payment_method_form_payolution';
33
+ protected $_infoBlockType = 'payone_core/payment_method_info_payolution';
34
+
35
+ protected $_blIpMandatory = true;
36
+
37
+ }
app/code/community/Payone/Core/Model/Payment/Method/Ratepay.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Payment
18
+ * @copyright Copyright (c) 2016 <kontakt@fatchip.de> - www.fatchip.com
19
+ * @author Robert M�ller <robert.mueller@fatchip.de>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.fatchip.com
22
+ */
23
+
24
+ class Payone_Core_Model_Payment_Method_Ratepay extends Payone_Core_Model_Payment_Method_Abstract
25
+ {
26
+ protected $_canUseForMultishipping = true;
27
+
28
+ protected $methodType = Payone_Core_Model_System_Config_PaymentMethodType::RATEPAY;
29
+
30
+ protected $_code = Payone_Core_Model_System_Config_PaymentMethodCode::RATEPAY;
31
+
32
+ protected $_formBlockType = 'payone_core/payment_method_form_ratepay';
33
+ protected $_infoBlockType = 'payone_core/payment_method_info_ratepay';
34
+
35
+ protected $_sTableName = 'payone_ratepay_config';
36
+
37
+ protected $_mustTransimitInvoicingData = true;
38
+
39
+ protected $_aRatePayShopConfig = null;
40
+
41
+ protected $_aExistingColumns = array(
42
+ 'shop_id',
43
+ 'merchant_name',
44
+ 'merchant_status',
45
+ 'shop_name',
46
+ 'name',
47
+ 'currency',
48
+ 'type',
49
+ 'activation_status_elv',
50
+ 'activation_status_installment',
51
+ 'activation_status_invoice',
52
+ 'activation_status_prepayment',
53
+ 'amount_min_longrun',
54
+ 'b2b_pq_full',
55
+ 'b2b_pq_light',
56
+ 'b2b_elv',
57
+ 'b2b_installment',
58
+ 'b2b_invoice',
59
+ 'b2b_prepayment',
60
+ 'country_code_billing',
61
+ 'country_code_delivery',
62
+ 'delivery_address_pq_full',
63
+ 'delivery_address_pq_light',
64
+ 'delivery_address_elv',
65
+ 'delivery_address_installment',
66
+ 'delivery_address_invoice',
67
+ 'delivery_address_prepayment',
68
+ 'device_fingerprint_snippet_id',
69
+ 'eligibility_device_fingerprint',
70
+ 'eligibility_ratepay_elv',
71
+ 'eligibility_ratepay_installment',
72
+ 'eligibility_ratepay_invoice',
73
+ 'eligibility_ratepay_pq_full',
74
+ 'eligibility_ratepay_pq_light',
75
+ 'eligibility_ratepay_prepayment',
76
+ 'interest_rate_merchant_towards_bank',
77
+ 'interestrate_default',
78
+ 'interestrate_max',
79
+ 'interestrate_min',
80
+ 'min_difference_dueday',
81
+ 'month_allowed',
82
+ 'month_longrun',
83
+ 'month_number_max',
84
+ 'month_number_min',
85
+ 'payment_amount',
86
+ 'payment_firstday',
87
+ 'payment_lastrate',
88
+ 'rate_min_longrun',
89
+ 'rate_min_normal',
90
+ 'service_charge',
91
+ 'tx_limit_elv_max',
92
+ 'tx_limit_elv_min',
93
+ 'tx_limit_installment_max',
94
+ 'tx_limit_installment_min',
95
+ 'tx_limit_invoice_max',
96
+ 'tx_limit_invoice_min',
97
+ 'tx_limit_prepayment_max',
98
+ 'tx_limit_prepayment_min',
99
+ 'valid_payment_firstdays',
100
+ );
101
+
102
+ protected $_aBooleanConversionColumns = array(
103
+ 'b2b_pq_full',
104
+ 'b2b_pq_light',
105
+ 'b2b_elv',
106
+ 'b2b_installment',
107
+ 'b2b_invoice',
108
+ 'b2b_prepayment',
109
+ 'delivery_address_pq_full',
110
+ 'delivery_address_pq_light',
111
+ 'delivery_address_elv',
112
+ 'delivery_address_installment',
113
+ 'delivery_address_invoice',
114
+ 'delivery_address_prepayment',
115
+ 'eligibility_device_fingerprint',
116
+ 'eligibility_ratepay_elv',
117
+ 'eligibility_ratepay_installment',
118
+ 'eligibility_ratepay_invoice',
119
+ 'eligibility_ratepay_pq_full',
120
+ 'eligibility_ratepay_pq_light',
121
+ 'eligibility_ratepay_prepayment',
122
+ );
123
+
124
+ public function addRatePayConfig($aPayData) {
125
+ $oResource = Mage::getSingleton('core/resource');
126
+ $oWrite = $oResource->getConnection('core_write');
127
+ $sTable = $oResource->getTableName($this->_sTableName);
128
+
129
+ $sQuery = " INSERT INTO {$sTable} (";
130
+
131
+ $blFirst = true;
132
+ foreach ($aPayData as $sKey => $sValue) {
133
+ if(array_search($sKey, $this->_aExistingColumns) !== false) {
134
+ if(!$blFirst) $sQuery .= ',';
135
+ $sQuery .= $sKey;
136
+ $blFirst = false;
137
+ }
138
+ }
139
+ $sQuery .= ") VALUES (";
140
+
141
+ $blFirst = true;
142
+ foreach ($aPayData as $sKey => $sValue) {
143
+ if(array_search($sKey, $this->_aExistingColumns) !== false) {
144
+ if(!$blFirst) $sQuery .= ',';
145
+ $sValue = $this->_getCorrectedValue($sKey, $sValue);
146
+ $sQuery .= $oWrite->quote($sValue);
147
+ $blFirst = false;
148
+ }
149
+ }
150
+
151
+ $sQuery .= ")";
152
+
153
+ $oWrite->query($sQuery);
154
+ }
155
+
156
+ protected function _getCorrectedValue($sKey, $sValue) {
157
+ if(array_search($sKey, $this->_aBooleanConversionColumns) !== false) {
158
+ if(strtolower($sValue) == 'yes') {
159
+ $sValue = 1;
160
+ } elseif(strtolower($sValue) == 'no') {
161
+ $sValue = 0;
162
+ }
163
+ }
164
+ return $sValue;
165
+ }
166
+
167
+ public function getRatePayConfigById($sRatePayShopId) {
168
+ $oResource = Mage::getSingleton('core/resource');
169
+ $oRead = $oResource->getConnection('core_read');
170
+ $sTable = $oResource->getTableName($this->_sTableName);
171
+
172
+ $sQuery = "SELECT * FROM {$sTable} WHERE shop_id = {$oRead->quote($sRatePayShopId)} LIMIT 1";
173
+ $aResult = $oRead->fetchAll($sQuery);
174
+ if(is_array($aResult) && count($aResult) == 1) {
175
+ return array_shift($aResult);
176
+ }
177
+ return false;
178
+ }
179
+
180
+ protected function _getQuote() {
181
+ /** @var $session Mage_Checkout_Model_Session */
182
+ $oSession = Mage::getSingleton('checkout/session');
183
+ if($this->getFactory()->getIsAdmin() === true) {
184
+ $oSession = Mage::getSingleton('adminhtml/session_quote');
185
+ }
186
+ $oQuote = $oSession->getQuote();
187
+ try {
188
+ if (!$oQuote instanceof Mage_Sales_Model_Quote or !$oQuote->getId()) {
189
+ $oQuote = $this->getInfoInstance()->getQuote();
190
+ }
191
+ } catch (Exception $ex) {
192
+ $oQuote = false;
193
+ }
194
+ return $oQuote;
195
+ }
196
+
197
+ public function getMatchingRatePayConfig() {
198
+ if($this->_aRatePayShopConfig === null) {
199
+ $this->_aRatePayShopConfig = false;
200
+
201
+ $oQuote = $this->_getQuote();
202
+ if($oQuote) {
203
+ $oResource = Mage::getSingleton('core/resource');
204
+ $oRead = $oResource->getConnection('core_read');
205
+
206
+ $sTable = $oResource->getTableName($this->_sTableName);
207
+ $blAddressesAreEqual = $this->helper()->addressesAreEqual($oQuote->getBillingAddress(), $oQuote->getShippingAddress());
208
+
209
+ $sQuery = " SELECT
210
+ shop_id
211
+ FROM
212
+ {$sTable}
213
+ WHERE
214
+ {$oQuote->getGrandTotal()} BETWEEN tx_limit_invoice_min AND tx_limit_invoice_max AND
215
+ currency = {$oRead->quote($oQuote->getQuoteCurrencyCode())} AND
216
+ country_code_billing = {$oRead->quote($oQuote->getBillingAddress()->getCountryId())}";
217
+ if($blAddressesAreEqual === false) {
218
+ $sQuery .= " AND delivery_address_invoice = 1 ";
219
+ $sQuery .= " AND country_code_delivery = {$oRead->quote($oQuote->getShippingAddress()->getCountryId())} ";
220
+ }
221
+ $sQuery .= " LIMIT 1";
222
+ $sShopId = $oRead->fetchOne($sQuery);
223
+ if($sShopId) {
224
+ $this->_aRatePayShopConfig = $this->getRatePayConfigById($sShopId);
225
+ }
226
+ }
227
+ }
228
+ return $this->_aRatePayShopConfig;
229
+ }
230
+
231
+ protected function _hasMatchingRatePayConfig() {
232
+ $aRatePayConfig = $this->getMatchingRatePayConfig();
233
+ if($aRatePayConfig !== false) {
234
+ return true;
235
+ }
236
+ return false;
237
+ }
238
+
239
+ public function isAvailable($quote = null) {
240
+ $blParentReturn = parent::isAvailable($quote);
241
+ if($blParentReturn === true) {
242
+ $blHasMatchingRatePayConfig = $this->_hasMatchingRatePayConfig();
243
+ return $blHasMatchingRatePayConfig;
244
+ }
245
+ return $blParentReturn;
246
+ }
247
+
248
+ public function getApiResponseErrorMessage($response)
249
+ {
250
+ if((bool)$this->getConfig()->getShowCustomermessage() === true) {
251
+ return $response->getCustomermessage();
252
+ }
253
+ return parent::getApiResponseErrorMessage($response);
254
+ }
255
+
256
+ }