Ogone_ePayments - Version 16.04.13

Version Notes

Download this release

Release Info

Developer Michael Lühr
Extension Ogone_ePayments
Version 16.04.13
Comparing to
See all releases


Code changes from version 15.11.09 to 16.04.13

Files changed (165) hide show
  1. app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Edit/Tab/Alias.php +2 -3
  2. app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Renderer/PaymentMethod.php +20 -0
  3. app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixocategory/CategoryTree.php +6 -12
  4. app/code/community/Netresearch/OPS/Block/Adminhtml/Sales/Order/Creditmemo/Warning/OpenInvoiceNl.php +0 -13
  5. app/code/community/Netresearch/OPS/Block/Adminhtml/Sales/Order/Invoice/Warning/OpenInvoice.php +0 -15
  6. app/code/community/Netresearch/OPS/Block/Checkout/SubscriptionNotice.php +193 -0
  7. app/code/community/Netresearch/OPS/Block/Form.php +34 -212
  8. app/code/community/Netresearch/OPS/Block/Form/Cc.php +241 -11
  9. app/code/community/Netresearch/OPS/Block/Form/DirectDebit.php +9 -7
  10. app/code/community/Netresearch/OPS/Block/Form/Flex.php +71 -0
  11. app/code/community/Netresearch/OPS/Block/Form/InterSolve.php +52 -0
  12. app/code/community/Netresearch/OPS/Block/Form/Other.php +0 -23
  13. app/code/community/Netresearch/OPS/Block/Form/RecurringCc.php +36 -0
  14. app/code/community/Netresearch/OPS/Block/Frauddetection.php +10 -8
  15. app/code/community/Netresearch/OPS/Block/Info/Flex.php +53 -0
  16. app/code/community/Netresearch/OPS/Block/Info/RecurringCc.php +32 -0
  17. app/code/community/Netresearch/OPS/Block/Placeform.php +19 -2
  18. app/code/community/Netresearch/OPS/Block/RetryPayment.php +3 -3
  19. app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/Method.php +53 -0
  20. app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/RecurringActive.php +55 -0
  21. app/code/community/Netresearch/OPS/Controller/Abstract.php +60 -15
  22. app/code/community/Netresearch/OPS/Helper/Alias.php +49 -76
  23. app/code/community/Netresearch/OPS/Helper/Creditcard.php +6 -3
  24. app/code/community/Netresearch/OPS/Helper/Data.php +1 -1
  25. app/code/community/Netresearch/OPS/Helper/Debitcard.php +21 -0
  26. app/code/community/Netresearch/OPS/Helper/Directlink.php +41 -219
  27. app/code/community/Netresearch/OPS/Helper/Order.php +27 -54
  28. app/code/community/Netresearch/OPS/Helper/Order/Capture.php +0 -105
  29. app/code/community/Netresearch/OPS/Helper/Order/Refund.php +13 -180
  30. app/code/community/Netresearch/OPS/Helper/Order/Void.php +0 -52
  31. app/code/community/Netresearch/OPS/Helper/Payment.php +177 -141
  32. app/code/community/Netresearch/OPS/Helper/Payment/DirectLink/Request.php +4 -3
  33. app/code/community/Netresearch/OPS/Helper/Payment/Request.php +65 -10
  34. app/code/community/Netresearch/OPS/Helper/Quote.php +1 -1
  35. app/code/community/Netresearch/OPS/Helper/Subscription.php +148 -0
  36. app/code/community/Netresearch/OPS/Model/Api/Directlink.php +7 -6
  37. app/code/community/Netresearch/OPS/Model/Backend/Operation/Capture/Parameter.php +13 -2
  38. app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter.php +2 -3
  39. app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Abstract.php +27 -21
  40. app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Interface.php +1 -2
  41. app/code/community/Netresearch/OPS/Model/Backend/Operation/Refund/Parameter.php +22 -7
  42. app/code/community/Netresearch/OPS/Model/Config.php +211 -62
  43. app/code/community/Netresearch/OPS/Model/Observer.php +235 -137
  44. app/code/community/Netresearch/OPS/Model/Payment/Abstract.php +378 -365
  45. app/code/community/Netresearch/OPS/Model/Payment/Bancontact.php +48 -0
  46. app/code/community/Netresearch/OPS/Model/Payment/Cc.php +43 -46
  47. app/code/community/Netresearch/OPS/Model/Payment/Cod.php +0 -25
  48. app/code/community/Netresearch/OPS/Model/Payment/Debitcard.php +51 -0
  49. app/code/community/Netresearch/OPS/Model/Payment/DirectLink.php +47 -65
  50. app/code/community/Netresearch/OPS/Model/Payment/Features/PaymentEmail.php +115 -19
  51. app/code/community/Netresearch/OPS/Model/Payment/Features/ZeroAmountAuth.php +1 -0
  52. app/code/community/Netresearch/OPS/Model/Payment/Flex.php +41 -0
  53. app/code/community/Netresearch/OPS/Model/Payment/InterSolve.php +1 -0
  54. app/code/community/Netresearch/OPS/Model/Payment/Kwixo/Abstract.php +2 -2
  55. app/code/community/Netresearch/OPS/Model/Payment/Masterpass.php +27 -0
  56. app/code/community/Netresearch/OPS/Model/Payment/MiniTix.php +0 -26
  57. app/code/community/Netresearch/OPS/Model/Payment/OpenInvoice/Abstract.php +10 -9
  58. app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceAt.php +98 -0
  59. app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceDe.php +2 -1
  60. app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceNl.php +7 -6
  61. app/code/community/Netresearch/OPS/Model/Payment/Other.php +0 -32
  62. app/code/community/Netresearch/OPS/Model/Payment/Recurring/Cc.php +382 -0
  63. app/code/community/Netresearch/OPS/Model/Payment/Recurring/Cc/ParameterBag.php +526 -0
  64. app/code/community/Netresearch/OPS/Model/Payment/Tunz.php +0 -26
  65. app/code/community/Netresearch/OPS/Model/Payment/Wallie.php +0 -26
  66. app/code/community/Netresearch/OPS/Model/Response/Handler.php +76 -0
  67. app/code/community/Netresearch/OPS/Model/Response/Type/Abstract.php +341 -0
  68. app/code/community/Netresearch/OPS/Model/Response/Type/Authorize.php +182 -0
  69. app/code/community/Netresearch/OPS/Model/Response/Type/Capture.php +108 -0
  70. app/code/community/Netresearch/OPS/Model/Response/Type/Refund.php +169 -0
  71. app/code/community/Netresearch/OPS/Model/Response/Type/Special.php +92 -0
  72. app/code/community/Netresearch/OPS/Model/Response/Type/Void.php +68 -0
  73. app/code/community/Netresearch/OPS/Model/Response/TypeInterface.php +51 -0
  74. app/code/community/Netresearch/OPS/Model/Source/Cc/RecurringTypes.php +50 -0
  75. app/code/community/Netresearch/OPS/Model/Source/DebitCard/AliasInterfaceEnabledTypes.php +61 -0
  76. app/code/community/Netresearch/OPS/Model/Source/DebitCard/Types.php +52 -0
  77. app/code/community/Netresearch/OPS/Model/Source/Template.php +4 -2
  78. app/code/community/Netresearch/OPS/Model/Source/TemplateType.php +21 -0
  79. app/code/community/Netresearch/OPS/Model/Status.php +299 -0
  80. app/code/community/Netresearch/OPS/Model/Status/Mapping.php +0 -171
  81. app/code/community/Netresearch/OPS/Model/Status/Transition.php +0 -567
  82. app/code/community/Netresearch/OPS/Model/Status/Update.php +25 -51
  83. app/code/community/Netresearch/OPS/Model/Subscription/Manager.php +304 -0
  84. app/code/community/Netresearch/OPS/Model/System/Config/Backend/Flex/Methods.php +67 -0
  85. app/code/community/Netresearch/OPS/Model/System/Config/Backend/HashMethods.php +48 -0
  86. app/code/community/Netresearch/OPS/Model/System/Config/Mode.php +39 -0
  87. app/code/community/Netresearch/OPS/Model/System/Config/Template.php +63 -0
  88. app/code/community/Netresearch/OPS/Test/Block/Adminhtml/Sales/Order/Invoice/Warning/OpenInvoiceTest.php +0 -19
  89. app/code/community/Netresearch/OPS/Test/Block/Form/CcTest.php +414 -3
  90. app/code/community/Netresearch/OPS/Test/Block/Form/CcTest/fixtures/aliases.yaml +92 -0
  91. app/code/community/Netresearch/OPS/Test/Block/Form/DirectDebitTest.php +3 -3
  92. app/code/community/Netresearch/OPS/Test/Block/Form/Field/MethodTest.php +42 -0
  93. app/code/community/Netresearch/OPS/Test/Block/Form/FlexTest.php +89 -0
  94. app/code/community/Netresearch/OPS/Test/Block/Form/InterSolveTest.php +52 -0
  95. app/code/community/Netresearch/OPS/Test/Block/FormTest.php +11 -382
  96. app/code/community/Netresearch/OPS/Test/Block/FrauddetectionTest.php +22 -10
  97. app/code/community/Netresearch/OPS/Test/Block/Info/FlexTest.php +50 -0
  98. app/code/community/Netresearch/OPS/Test/Controller/AliasControllerTest.php +106 -0
  99. app/code/community/Netresearch/OPS/Test/Controller/AliasControllerTest/fixtures/orders.yaml +595 -0
  100. app/code/community/Netresearch/OPS/Test/Controller/ApiControllerTest.php +1 -1
  101. app/code/community/Netresearch/OPS/Test/Controller/DeviceControllerTest.php +66 -0
  102. app/code/community/Netresearch/OPS/Test/Controller/PaymentControllerTest.php +9 -275
  103. app/code/community/Netresearch/OPS/Test/Helper/AliasTest.php +89 -56
  104. app/code/community/Netresearch/OPS/Test/Helper/DirectDebitTest.php +1 -1
  105. app/code/community/Netresearch/OPS/Test/Helper/DirectLinkTest.php +105 -106
  106. app/code/community/Netresearch/OPS/Test/Helper/Order/VoidTest.php +0 -24
  107. app/code/community/Netresearch/OPS/Test/Helper/Order/VoidTest/fixtures/.gitkeep +0 -0
  108. app/code/community/Netresearch/OPS/Test/Helper/OrderTest.php +0 -31
  109. app/code/community/Netresearch/OPS/Test/Helper/Payment/DirectLink/RequestTest.php +2 -1
  110. app/code/community/Netresearch/OPS/Test/Helper/Payment/RequestTest.php +66 -20
  111. app/code/community/Netresearch/OPS/Test/Helper/PaymentTest.php +80 -85
  112. app/code/community/Netresearch/OPS/Test/Helper/QuoteTest.php +2 -11
  113. app/code/community/Netresearch/OPS/Test/Helper/SubscriptionTest.php +115 -0
  114. app/code/community/Netresearch/OPS/Test/Helper/SubscriptionTest/fixtures/profile.yaml +11 -0
  115. app/code/community/Netresearch/OPS/Test/Model/Api/DirectLinkTest.php +2 -2
  116. app/code/community/Netresearch/OPS/Test/Model/Backend/Operation/Capture/ParameterTest.php +5 -5
  117. app/code/community/Netresearch/OPS/Test/Model/Backend/Operation/ParameterTest.php +13 -6
  118. app/code/community/Netresearch/OPS/Test/Model/Backend/Operation/Refund/ParameterTest.php +5 -4
  119. app/code/community/Netresearch/OPS/Test/Model/ConfigTest.php +84 -45
  120. app/code/community/Netresearch/OPS/Test/Model/ObserverTest.php +291 -326
  121. app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractCaptureTest.php +16 -14
  122. app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractRefundTest.php +11 -18
  123. app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractTest.php +95 -201
  124. app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractTest/expectations/paymentMethods.yaml +7 -1
  125. app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractTest/fixtures/.gitkeep +0 -0
  126. app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractTest/fixtures/orders.yaml +135 -0
  127. app/code/community/Netresearch/OPS/Test/Model/Payment/BancontactTest.php +31 -0
  128. app/code/community/Netresearch/OPS/Test/Model/Payment/CcTest.php +4 -21
  129. app/code/community/Netresearch/OPS/Test/Model/Payment/ChinaUnionPayTest.php +1 -1
  130. app/code/community/Netresearch/OPS/Test/Model/Payment/DebitcardTest.php +53 -0
  131. app/code/community/Netresearch/OPS/Test/Model/Payment/DirectLinkTest.php +16 -20
  132. app/code/community/Netresearch/OPS/Test/Model/Payment/Features/PaymentEmailTest.php +45 -18
  133. app/code/community/Netresearch/OPS/Test/Model/Payment/Features/ZeroAmountAuthTest.php +4 -1
  134. app/code/community/Netresearch/OPS/Test/Model/Payment/FlexTest.php +77 -0
  135. app/code/community/Netresearch/OPS/Test/Model/Payment/Kwixo/AbstractTest.php +3 -1
  136. app/code/community/Netresearch/OPS/Test/Model/Payment/Kwixo/AbstractTest/expectations/paymentMethods.yaml +7 -1
  137. app/code/community/Netresearch/OPS/Test/Model/Payment/Kwixo/AbstractTest/fixtures/orders.yaml +633 -0
  138. app/code/community/Netresearch/OPS/Test/Model/Payment/OpenInvoiceAtTest.php +60 -0
  139. app/code/community/Netresearch/OPS/Test/Model/Payment/Recurring/Cc/ParameterBagTest.php +395 -0
  140. app/code/community/Netresearch/OPS/Test/Model/Payment/Recurring/CcTest.php +579 -0
  141. app/code/community/Netresearch/OPS/Test/Model/Response/Type/AuthorizeTest.php +266 -0
  142. app/code/community/Netresearch/OPS/Test/Model/Response/Type/AuthorizeTest/fixtures/orders.yaml +239 -0
  143. app/code/community/Netresearch/OPS/Test/Model/Response/Type/CaptureTest.php +192 -0
  144. app/code/community/Netresearch/OPS/Test/Model/Response/Type/CaptureTest/fixtures/orders.yaml +135 -0
  145. app/code/community/Netresearch/OPS/Test/Model/Response/Type/RefundTest.php +284 -0
  146. app/code/community/Netresearch/OPS/Test/Model/Response/Type/RefundTest/fixtures/orders.yaml +157 -0
  147. app/code/community/Netresearch/OPS/Test/Model/Source/Cc/RecurringTypesTest.php +41 -0
  148. app/code/community/Netresearch/OPS/Test/Model/Status/MappingTest.php +0 -135
  149. app/code/community/Netresearch/OPS/Test/Model/Status/TransitionTest.php +0 -270
  150. app/code/community/Netresearch/OPS/Test/Model/Status/UpdateTest.php +12 -26
  151. app/code/community/Netresearch/OPS/Test/Model/Status/UpdateTest/fixtures/orders.yaml +135 -0
  152. app/code/community/Netresearch/OPS/Test/Model/StatusTest.php +122 -0
  153. app/code/community/Netresearch/OPS/Test/Model/Subscription/ManagerTest.php +175 -0
  154. app/code/community/Netresearch/OPS/Test/Model/System/Config/Backend/Flex/MethodsTest.php +106 -0
  155. app/code/community/Netresearch/OPS/Trait/AliasController.php +233 -0
  156. app/code/community/Netresearch/OPS/Trait/PaymentHelper.php +60 -0
  157. app/code/community/Netresearch/OPS/controllers/Adminhtml/AliasController.php +4 -0
  158. app/code/community/Netresearch/OPS/controllers/Adminhtml/OpsstatusController.php +1 -1
  159. app/code/community/Netresearch/OPS/controllers/AliasController.php +13 -0
  160. app/code/community/Netresearch/OPS/controllers/ApiController.php +30 -19
  161. app/code/community/Netresearch/OPS/controllers/DeviceController.php +82 -0
  162. app/code/community/Netresearch/OPS/controllers/PaymentController.php +68 -206
  163. app/code/community/Netresearch/OPS/data/ops_setup/data-upgrade-15.11.09-16.03.09.php +37 -0
  164. app/code/community/Netresearch/OPS/etc/config.xml +178 -144
  165. app/code/community/Netresearch/OPS/etc/system.xml +152 -131
app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Edit/Tab/Alias.php CHANGED
@@ -108,12 +108,11 @@ class Netresearch_OPS_Block_Adminhtml_Customer_Edit_Tab_Alias
108
  'index' => 'alias',
109
  ));
110
 
111
- /*
112
  $this->addColumn('payment_method', array(
113
- 'header' => Mage::helper('ops')->__('Brand'),
114
  'index' => 'payment_method',
 
115
  ));
116
- */
117
 
118
  $this->addColumn('brand', array(
119
  'header' => Mage::helper('ops')->__('Credit Card Type'),
108
  'index' => 'alias',
109
  ));
110
 
 
111
  $this->addColumn('payment_method', array(
112
+ 'header' => Mage::helper('ops')->__('Payment method'),
113
  'index' => 'payment_method',
114
+ 'renderer' => 'Netresearch_OPS_Block_Adminhtml_Customer_Renderer_PaymentMethod'
115
  ));
 
116
 
117
  $this->addColumn('brand', array(
118
  'header' => Mage::helper('ops')->__('Credit Card Type'),
app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Renderer/PaymentMethod.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PaymentMethod.php
5
+ *
6
+ * @author Paul Siedler <paul.siedler@netresearch.de>
7
+ */
8
+ class Netresearch_OPS_Block_Adminhtml_Customer_Renderer_PaymentMethod
9
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
10
+ {
11
+
12
+ public function render(Varien_Object $row)
13
+ {
14
+ $methodCode = $row->getData($this->getColumn()->getIndex());
15
+ $instance = Mage::helper('payment')->getMethodInstance($methodCode);
16
+ if ($instance) {
17
+ return $instance->getTitle();
18
+ }
19
+ }
20
+ }
app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixocategory/CategoryTree.php CHANGED
@@ -1,7 +1,6 @@
1
-
2
  <?php
3
  /**
4
- * Magento
5
  *
6
  * NOTICE OF LICENSE
7
  *
@@ -9,20 +8,15 @@
9
  * that is bundled with this package in the file LICENSE.txt.
10
  * It is also available through the world-wide-web at this URL:
11
  * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
  * DISCLAIMER
17
  *
18
- * Do not edit or add to this file if you wish to upgrade Magento to newer
19
- * versions in the future. If you wish to customize Magento for your
20
- * needs please refer to http://www.magentocommerce.com for more information.
21
  *
22
- * @category Mage
23
- * @package Netresearch_OPS
24
- * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
25
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
  */
27
 
28
  class Netresearch_OPS_Block_Adminhtml_Kwixocategory_CategoryTree
 
1
  <?php
2
  /**
3
+ * Netresearch OPS
4
  *
5
  * NOTICE OF LICENSE
6
  *
8
  * that is bundled with this package in the file LICENSE.txt.
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/osl-3.0.php
 
 
 
11
  *
12
  * DISCLAIMER
13
  *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
 
16
  *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
 
20
  */
21
 
22
  class Netresearch_OPS_Block_Adminhtml_Kwixocategory_CategoryTree
app/code/community/Netresearch/OPS/Block/Adminhtml/Sales/Order/Creditmemo/Warning/OpenInvoiceNl.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: paul.siedler
5
- * Date: 25.09.2014
6
- * Time: 10:13
7
- */
8
-
9
- class Netresearch_OPS_Block_Adminhtml_Sales_Order_Creditmemo_Warning_OpenInvoiceNl
10
- extends Mage_Core_Block_Template
11
- {
12
- protected $_template = 'ops/sales/order/creditmemo/warning/openinvoicenl.phtml';
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Block/Adminhtml/Sales/Order/Invoice/Warning/OpenInvoice.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @author Michael Lühr <michael.luehr@netresearch.de>
4
- * @category Netresearch
5
- * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
6
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
- */
8
-
9
-
10
- class Netresearch_OPS_Block_Adminhtml_Sales_Order_Invoice_Warning_OpenInvoice extends Mage_Core_Block_Template
11
- {
12
-
13
- protected $_template = 'ops/sales/order/invoice/warning/open-invoice.phtml';
14
-
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Block/Checkout/SubscriptionNotice.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * SubscriptionNotice.php
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ *
29
+ *
30
+ * @method Netresearch_OPS_Block_Checkout_SubscriptionNotice setProfile(Mage_Catalog_Model_Product $product)
31
+ *
32
+ */
33
+ class Netresearch_OPS_Block_Checkout_SubscriptionNotice extends Mage_Core_Block_Template
34
+ {
35
+
36
+ /**
37
+ * Returns the quotes nominal items product
38
+ *
39
+ * @return Mage_Sales_Model_Recurring_Profile
40
+ */
41
+ public function getProfile()
42
+ {
43
+ if (!$this->hasData('profile')) {
44
+ /** @var Mage_Sales_Model_Quote_Item $item */
45
+ foreach ($this->getQuote()->getAllItems() as $item) {
46
+ $product = $item->getProduct();
47
+ if (is_object($product) && $product->isRecurring()
48
+ && $profile = Mage::getModel('sales/recurring_profile')->importProduct($product)
49
+ ) {
50
+ $profile->importQuote($this->getQuote());
51
+ $profile->importQuoteItem($item);
52
+ $this->setProfile($profile);
53
+ break;
54
+ }
55
+ }
56
+ }
57
+
58
+ return $this->getData('profile');
59
+ }
60
+
61
+ /**
62
+ * Get checkout session quote
63
+ *
64
+ * @return Mage_Sales_Model_Quote
65
+ */
66
+ public function getQuote()
67
+ {
68
+ return Mage::getSingleton('checkout/session')->getQuote();
69
+ }
70
+
71
+ /**
72
+ * Checks wether the recurring profile has a trial period specified
73
+ *
74
+ * @return bool
75
+ */
76
+ public function hasTrial()
77
+ {
78
+ return (bool)$this->getProfile()->getTrialPeriodUnit();
79
+ }
80
+
81
+ /**
82
+ * Checks wether the recurring profile has an initial fee specified
83
+ *
84
+ * @return bool
85
+ */
86
+ public function hasInitialFee()
87
+ {
88
+ return $this->getProfile()->getInitAmount() > 0;
89
+ }
90
+
91
+ /**
92
+ * @return string
93
+ */
94
+ public function getInitialFeeText()
95
+ {
96
+ return $this->__('You will be charged an initial amount of %s.',
97
+ $this->helper('checkout')->formatPrice($this->getProfile()->getInitAmount())
98
+ );
99
+ }
100
+
101
+ /**
102
+ * @return string
103
+ */
104
+ public function getTrialSubscriptionText()
105
+ {
106
+ $profile = $this->getProfile();
107
+
108
+ return $this->__('A trial subscription will be created. This will charge you %s every %s %s until %s.',
109
+ $this->helper('checkout')->formatPrice(
110
+ $profile->getTrialBillingAmount() + $profile->getShippingAmount()
111
+ ),
112
+ $profile->getTrialPeriodFrequency(),
113
+ $profile->getPeriodUnitLabel($profile->getTrialPeriodUnit()),
114
+ $this->localizeDate($this->getTrialSubscriptionEndDate())
115
+ );
116
+ }
117
+
118
+ /**
119
+ * @return string
120
+ */
121
+ public function getRegularSubscriptionText()
122
+ {
123
+ $profile = $this->getProfile();
124
+
125
+ $message = $this->__('A subscription will be created. This will charge you %s every %s %s.',
126
+ $this->helper('checkout')->formatPrice(
127
+ $profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount()
128
+ ),
129
+ $profile->getPeriodFrequency(),
130
+ $profile->getPeriodUnitLabel($profile->getPeriodUnit())
131
+ );
132
+
133
+ if($this->getRegularSubscriptionEndDate()){
134
+ $message .= $this->__(' The subscription will end on %s.',
135
+ $this->localizeDate($this->getRegularSubscriptionEndDate()));
136
+ }
137
+ return $message;
138
+ }
139
+
140
+ public function getCancelInformationText()
141
+ {
142
+ return $this->__('To cancel the subscription, please send an email to the shop owner' .
143
+ ' or request this by clicking the suspend button on the subscriptions detail view in your customer account.'
144
+ . ' A link to that page will be displayed on the checkout success page.'
145
+ );
146
+ }
147
+
148
+ public function displayNotice()
149
+ {
150
+ $result = true;
151
+ if (!$this->getProfile()
152
+ || $this->getQuote()->getPayment()->getMethod() != Netresearch_OPS_Model_Payment_Recurring_Cc::CODE
153
+ ) {
154
+ $result = false;
155
+ }
156
+
157
+ return $result;
158
+ }
159
+
160
+ protected function getTrialSubscriptionEndDate()
161
+ {
162
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag $parameterModel */
163
+ $parameterModel = Mage::getModel('ops/payment_recurring_cc_parameterBag');
164
+ $enddate = null;
165
+ $startDate = new DateTime($this->getProfile()->getStartDatetime());
166
+ $enddate = $parameterModel->calculateEndDate($startDate, $this->getProfile()->getTrialPeriodUnit(),
167
+ $this->getProfile()->getTrialPeriodFrequency(), $this->getProfile()->getTrialPeriodMaxCycles()
168
+ );
169
+
170
+ return $enddate;
171
+ }
172
+
173
+ protected function getRegularSubscriptionEndDate()
174
+ {
175
+ $parameterModel = Mage::getModel('ops/payment_recurring_cc_parameterBag');
176
+ $enddate = null;
177
+ if ($this->hasTrial()) {
178
+ $startDate = $this->getTrialSubscriptionEndDate();
179
+ } else {
180
+ $startDate = new DateTime($this->getProfile()->getStartDatetime());
181
+ }
182
+ $enddate = $parameterModel->calculateEndDate($startDate, $this->getProfile()->getPeriodUnit(),
183
+ $this->getProfile()->getPeriodFrequency(), $this->getProfile()->getPeriodMaxCycles()
184
+ );
185
+
186
+ return $enddate;
187
+ }
188
+
189
+ protected function localizeDate(DateTime $date){
190
+ $date = new Zend_Date($date->getTimestamp());
191
+ return Mage::helper('core')->formatDate($date);
192
+ }
193
+ }
app/code/community/Netresearch/OPS/Block/Form.php CHANGED
@@ -27,8 +27,6 @@
27
  class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
28
  {
29
 
30
- private $aliasDataForCustomer = null;
31
-
32
  protected $pmLogo = null;
33
 
34
  protected $fieldMapping = array();
@@ -64,6 +62,10 @@ class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
64
  return $this->config;
65
  }
66
 
 
 
 
 
67
  public function setConfig(Netresearch_OPS_Model_Config $config)
68
  {
69
  $this->config = $config;
@@ -71,16 +73,17 @@ class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
71
  return $this;
72
  }
73
 
 
 
 
74
  public function getQuote()
75
  {
76
  return Mage::getSingleton('checkout/session')->getQuote();
77
  }
78
 
79
- public function getCcBrands()
80
- {
81
- return explode(',', $this->getConfig()->getAcceptedCcTypes());
82
- }
83
-
84
  public function getDirectDebitCountryIds()
85
  {
86
  return explode(',', $this->getConfig()->getDirectDebitCountryIds());
@@ -91,218 +94,41 @@ class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
91
  return explode(',', $this->getConfig()->getBankTransferCountryIds());
92
  }
93
 
94
- public function getPSPID($storeId = null)
95
- {
96
- return Mage::getModel('ops/config')->getPSPID($storeId);
97
- }
98
-
99
- public function getAliasAcceptUrl($storeId = null, $admin = false)
100
- {
101
- return Mage::getModel('ops/config')->getAliasAcceptUrl($storeId, $admin);
102
- }
103
-
104
- public function getAliasExceptionUrl($storeId = null, $admin = false)
105
- {
106
- return Mage::getModel('ops/config')->getAliasExceptionUrl($storeId, $admin);
107
- }
108
-
109
- public function getAliasGatewayUrl($storeId = null)
110
- {
111
- return Mage::getModel('ops/config')->getAliasGatewayUrl($storeId);
112
- }
113
-
114
- public function getSaveCcBrandUrl()
115
- {
116
- return Mage::getModel('ops/config')->getSaveCcBrandUrl();
117
- }
118
-
119
- public function getGenerateHashUrl($storeId = null, $admin = false)
120
- {
121
- return Mage::getModel('ops/config')->getGenerateHashUrl($storeId, $admin);
122
- }
123
-
124
- public function getCcSaveAliasUrl($storeId = null, $admin = false)
125
- {
126
- return Mage::getModel('ops/config')->getCcSaveAliasUrl($storeId, $admin);
127
- }
128
-
129
- public function getRegisterDirectDebitPaymentUrl()
130
- {
131
- return Mage::getModel('ops/config')->getRegisterDirectDebitPaymentUrl();
132
- }
133
-
134
- public function getValidationUrl()
135
- {
136
- return Mage::getModel('ops/config')->getValidationUrl();
137
- }
138
-
139
- public function getDirectEbankingBrands()
140
- {
141
-
142
- return explode(',', $this->getConfig()->getDirectEbankingBrands());
143
- }
144
-
145
  /**
146
- * checks if the 'alias' payment method (!) is available
147
- * no check for customer has aliases here
148
- * just a passthrough of the isAvailable of Netresearch_OPS_Model_Payment_Abstract::isAvailable
149
- *
150
- * @return boolean
151
- */
152
- public function isAliasPMEnabled()
153
- {
154
- return Mage::getModel('ops/config')->isAliasManagerEnabled();
155
- }
156
-
157
- /**
158
- *
159
- * @return array empty or intersolve Vouchers
160
- */
161
- public function getInterSolveBrands()
162
- {
163
- $brands = array();
164
- if ($this->getMethodCode() == 'ops_interSolve') {
165
- $brands = Mage::getModel('ops/config')->getIntersolveBrands();
166
- }
167
- return $brands;
168
- }
169
-
170
- /**
171
- * retrieves the alias data for the logged in customer
172
- *
173
- * @return array | null - array the alias data or null if the customer
174
- * is not logged in
175
- */
176
- protected function getStoredAliasForCustomer()
177
- {
178
- if (Mage::helper('customer/data')->isLoggedIn()
179
- && Mage::getModel('ops/config')->isAliasManagerEnabled()) {
180
- $quote = $this->getQuote();
181
- $alias = Mage::helper('ops/alias')->getAliasesForAddresses(
182
- $quote->getCustomer()->getId(), $quote->getBillingAddress(),
183
- $quote->getShippingAddress(), $quote->getStoreId()
184
- )
185
- ->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
186
- ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC)
187
- ->getFirstItem();
188
- $this->aliasDataForCustomer = $alias->getData();
189
- }
190
- return $this->aliasDataForCustomer;
191
- }
192
-
193
-
194
- /**
195
- * retrieves single values to given keys from the alias data
196
- *
197
- * @param $key - string the key for the alias data
198
- *
199
- * @return null | string - null if key is not set in the alias data, otherwise
200
- * the value for the given key from the alias data
201
- *
202
- */
203
- protected function getStoredAliasDataForCustomer($key)
204
- {
205
- $returnValue = null;
206
- $aliasData = null;
207
- if (is_null($this->aliasData)) {
208
- $aliasData = $this->getStoredAliasForCustomer();
209
- }
210
- if (is_array($aliasData) && array_key_exists($key, $aliasData)) {
211
- $returnValue = $aliasData[$key];
212
- }
213
- return $returnValue;
214
- }
215
-
216
- /**
217
- * retrieves the given path (month or year) from stored expiration date
218
- *
219
- * @param $key - the requested path
220
- *
221
- * @return null | string the extracted part of the date
222
  */
223
- public function getExpirationDatePart($key)
224
  {
225
- $returnValue = null;
226
- $expirationDate = $this->getStoredAliasDataForCustomer('expiration_date');
227
- // set expiration date to actual date if no stored Alias is used
228
- if ($expirationDate === null) {
229
- $expirationDate = date('my');
230
- }
231
-
232
- if (0 < strlen(trim($expirationDate))
233
- ) {
234
- $expirationDateValues = str_split($expirationDate, 2);
235
-
236
- if ($key == 'month') {
237
- $returnValue = $expirationDateValues[0];
238
- }
239
- if ($key == 'year') {
240
- $returnValue = $expirationDateValues[1];
241
- }
242
- }
243
- return $returnValue;
244
-
245
  }
246
 
247
  /**
248
- * retrieves the masked alias card number and formats it in a card specific format
249
- *
250
- * @return null|string - null if no alias data were found,
251
- * otherwise the formatted card number
252
  */
253
- public function getAliasCardNumber()
254
  {
255
- $aliasCardNumber = $this->getStoredAliasDataForCustomer('pseudo_account_or_cc_no');
256
- if (0 < strlen(trim($aliasCardNumber))) {
257
- $aliasCardNumber = Mage::helper('ops/alias')->formatAliasCardNo(
258
- $this->getStoredAliasDataForCustomer('brand'), $aliasCardNumber
259
- );
260
- }
261
- return $aliasCardNumber;
262
  }
263
 
264
  /**
265
- * @return null|string - the card holder either from alias data or
266
- * the name from the the user who is logged in, null otherwise
267
  */
268
- public function getCardHolderName()
269
  {
270
- $cardHolderName = $this->getStoredAliasDataForCustomer('card_holder');
271
- $customerHelper = Mage::helper('customer/data');
272
- if ((is_null($cardHolderName) || 0 === strlen(trim($cardHolderName)))
273
- && (!is_null($this->getStoredAlias('alias')))
274
- && $customerHelper->isLoggedIn()
275
- && Mage::getModel('ops/config')->isAliasManagerEnabled()
276
- ) {
277
- $cardHolderName = $customerHelper->getCustomerName();
278
- }
279
- return $cardHolderName;
280
  }
281
 
282
  /**
283
- * the brand of the stored card data
284
- *
285
- * @return null|string - string if stored card data were found, null otherwise
286
  */
287
- public function getStoredAliasBrand()
288
  {
289
- $storedBrand = $this->getStoredAliasDataForCustomer('brand');
290
- if (in_array($storedBrand, Mage::getModel('ops/config')->getInlinePaymentCcTypes())) {
291
- return $storedBrand;
292
- }
293
- return '';
294
  }
295
 
296
- /**
297
- * retrieves an old alias for re-usage or updating it
298
- *
299
- * @return null|string - string the stored alias for re-usage or
300
- * null if no alias data were stored
301
- */
302
- public function getStoredAlias()
303
- {
304
- return $this->getStoredAliasDataForCustomer('alias');
305
- }
306
 
307
  /**
308
  * wrapper for Netresearch_OPS_Helper_Data::checkIfUserRegistering
@@ -324,18 +150,6 @@ class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
324
  return Mage::Helper('ops/data')->checkIfUserIsNotRegistering();
325
  }
326
 
327
- /**
328
- * determines whether the hint is shown to guests or not
329
- *
330
- * @return bool true if alias feature is enabled and display the hint to
331
- * guests is enabled
332
- */
333
- public function isAliasInfoBlockEnabled()
334
- {
335
- return ($this->isAliasPMEnabled()
336
- && Mage::getModel('ops/config')->isAliasInfoBlockEnabled());
337
- }
338
-
339
  /**
340
  * @return string
341
  */
@@ -344,7 +158,9 @@ class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
344
  return $this->pmLogo;
345
  }
346
 
347
-
 
 
348
  protected function getFieldMapping()
349
  {
350
  return $this->getConfig()->getFrontendFieldMapping();
@@ -391,4 +207,10 @@ class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
391
 
392
  return $frontendFields;
393
  }
 
 
 
 
 
 
394
  }
27
  class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
28
  {
29
 
 
 
30
  protected $pmLogo = null;
31
 
32
  protected $fieldMapping = array();
62
  return $this->config;
63
  }
64
 
65
+ /**
66
+ * @param Netresearch_OPS_Model_Config $config
67
+ * @return $this
68
+ */
69
  public function setConfig(Netresearch_OPS_Model_Config $config)
70
  {
71
  $this->config = $config;
73
  return $this;
74
  }
75
 
76
+ /**
77
+ * @return Mage_Sales_Model_Quote
78
+ */
79
  public function getQuote()
80
  {
81
  return Mage::getSingleton('checkout/session')->getQuote();
82
  }
83
 
84
+ /**
85
+ * @return array
86
+ */
 
 
87
  public function getDirectDebitCountryIds()
88
  {
89
  return explode(',', $this->getConfig()->getDirectDebitCountryIds());
94
  return explode(',', $this->getConfig()->getBankTransferCountryIds());
95
  }
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  /**
98
+ * @param null $storeId
99
+ * @return string
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  */
101
+ public function getPSPID($storeId = null)
102
  {
103
+ return Mage::getModel('ops/config')->getPSPID($storeId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }
105
 
106
  /**
107
+ * @param null $storeId
108
+ * @param bool $admin
109
+ * @return string
 
110
  */
111
+ public function getGenerateHashUrl($storeId = null, $admin = false)
112
  {
113
+ return Mage::getModel('ops/config')->getGenerateHashUrl($storeId, $admin);
 
 
 
 
 
 
114
  }
115
 
116
  /**
117
+ * @return string
 
118
  */
119
+ public function getValidationUrl()
120
  {
121
+ return Mage::getModel('ops/config')->getValidationUrl();
 
 
 
 
 
 
 
 
 
122
  }
123
 
124
  /**
125
+ * @return array
 
 
126
  */
127
+ public function getDirectEbankingBrands()
128
  {
129
+ return explode(',', $this->getConfig()->getDirectEbankingBrands());
 
 
 
 
130
  }
131
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  /**
134
  * wrapper for Netresearch_OPS_Helper_Data::checkIfUserRegistering
150
  return Mage::Helper('ops/data')->checkIfUserIsNotRegistering();
151
  }
152
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  /**
154
  * @return string
155
  */
158
  return $this->pmLogo;
159
  }
160
 
161
+ /**
162
+ * @return Simple_Xml
163
+ */
164
  protected function getFieldMapping()
165
  {
166
  return $this->getConfig()->getFrontendFieldMapping();
207
 
208
  return $frontendFields;
209
  }
210
+
211
+ public function getImageForBrand($brand)
212
+ {
213
+ $brandName = str_replace(' ', '', $brand);
214
+ return $this->getSkinUrl('images/ops/alias/brands/'. $brandName .'.png');
215
+ }
216
  }
app/code/community/Netresearch/OPS/Block/Form/Cc.php CHANGED
@@ -2,37 +2,267 @@
2
 
3
  /**
4
  * Netresearch_OPS_Block_Form_OpsId
5
- *
6
  * @package OPS
7
  * @copyright 2012 Netresearch App Factory AG <http://www.netresearch.de>
8
- * @author Thomas Birke <thomas.birke@netresearch.de>
9
  * @license OSL 3.0
10
  */
11
  class Netresearch_OPS_Block_Form_Cc extends Netresearch_OPS_Block_Form
12
  {
 
 
 
13
  /**
14
- * Backend Payment Template
15
  */
16
- const BACKEND_TEMPLATE = 'ops/form/cc.phtml';
17
 
18
  protected function _construct()
19
  {
20
  parent::_construct();
21
-
22
- //Only in case that the form is loaded in the backend, use a special template
23
- if (false === Mage::getModel("ops/config")->isFrontendEnvironment()) {
24
- $this->setTemplate(self::BACKEND_TEMPLATE);
25
- }
26
  }
27
 
 
28
  /**
29
  * gets all Alias CC brands
30
- *
31
  * @return array
32
  */
33
  public function getAliasBrands()
34
  {
35
  return Mage::getModel('ops/source_cc_aliasInterfaceEnabledTypes')
36
- ->getAliasInterfaceCompatibleTypes();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
2
 
3
  /**
4
  * Netresearch_OPS_Block_Form_OpsId
5
+ *
6
  * @package OPS
7
  * @copyright 2012 Netresearch App Factory AG <http://www.netresearch.de>
8
+ * @author Thomas Birke <thomas.birke@netresearch.de>
9
  * @license OSL 3.0
10
  */
11
  class Netresearch_OPS_Block_Form_Cc extends Netresearch_OPS_Block_Form
12
  {
13
+
14
+ private $aliasDataForCustomer = array();
15
+
16
  /**
17
+ * CC Payment Template
18
  */
19
+ const FRONTEND_TEMPLATE = 'ops/form/cc.phtml';
20
 
21
  protected function _construct()
22
  {
23
  parent::_construct();
24
+ $this->setTemplate(self::FRONTEND_TEMPLATE);
 
 
 
 
25
  }
26
 
27
+
28
  /**
29
  * gets all Alias CC brands
30
+ *
31
  * @return array
32
  */
33
  public function getAliasBrands()
34
  {
35
  return Mage::getModel('ops/source_cc_aliasInterfaceEnabledTypes')
36
+ ->getAliasInterfaceCompatibleTypes();
37
+ }
38
+
39
+ /**
40
+ * @param null $storeId
41
+ * @param bool $admin
42
+ *
43
+ * @return string
44
+ */
45
+ public function getAliasAcceptUrl($storeId = null, $admin = false)
46
+ {
47
+ return Mage::getModel('ops/config')->getAliasAcceptUrl($storeId, $admin);
48
+ }
49
+
50
+ /**
51
+ * @param null $storeId
52
+ * @param bool $admin
53
+ *
54
+ * @return string
55
+ */
56
+ public function getAliasExceptionUrl($storeId = null, $admin = false)
57
+ {
58
+ return Mage::getModel('ops/config')->getAliasExceptionUrl($storeId, $admin);
59
+ }
60
+
61
+ /**
62
+ * @param null $storeId
63
+ *
64
+ * @return string
65
+ */
66
+ public function getAliasGatewayUrl($storeId = null)
67
+ {
68
+ return Mage::getModel('ops/config')->getAliasGatewayUrl($storeId);
69
+ }
70
+
71
+ /**
72
+ * @return string
73
+ */
74
+ public function getSaveCcBrandUrl()
75
+ {
76
+ return Mage::getModel('ops/config')->getSaveCcBrandUrl();
77
+ }
78
+
79
+ /**
80
+ * @param null $storeId
81
+ * @param bool $admin
82
+ *
83
+ * @return mixed
84
+ */
85
+ public function getCcSaveAliasUrl($storeId = null, $admin = false)
86
+ {
87
+ return Mage::getModel('ops/config')->getCcSaveAliasUrl($storeId, $admin);
88
  }
89
+
90
+ /**
91
+ * checks if the 'alias' payment method (!) is available
92
+ * no check for customer has aliases here
93
+ * just a passthrough of the isAvailable of Netresearch_OPS_Model_Payment_Abstract::isAvailable
94
+ *
95
+ * @return boolean
96
+ */
97
+ public function isAliasPMEnabled()
98
+ {
99
+ return Mage::getModel('ops/config')->isAliasManagerEnabled($this->getMethodCode());
100
+ }
101
+
102
+
103
+ /**
104
+ * retrieves the alias data for the logged in customer
105
+ *
106
+ * @return array | null - array the alias data or null if the customer
107
+ * is not logged in
108
+ */
109
+ protected function getStoredAliasForCustomer()
110
+ {
111
+ if (Mage::helper('customer/data')->isLoggedIn()
112
+ && Mage::getModel('ops/config')->isAliasManagerEnabled($this->getMethodCode())
113
+ ) {
114
+ $quote = $this->getQuote();
115
+ $aliases = Mage::helper('ops/alias')->getAliasesForAddresses(
116
+ $quote->getCustomer()->getId(), $quote->getBillingAddress(),
117
+ $quote->getShippingAddress(), $quote->getStoreId()
118
+ )
119
+ ->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
120
+ ->addFieldToFilter('payment_method', $this->getMethodCode())
121
+ ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
122
+
123
+
124
+ foreach ($aliases as $key => $alias) {
125
+ $this->aliasDataForCustomer[$key] = $alias;
126
+ }
127
+ }
128
+
129
+ return $this->aliasDataForCustomer;
130
+ }
131
+
132
+
133
+ /**
134
+ * retrieves single values to given keys from the alias data
135
+ *
136
+ * @param $aliasId
137
+ * @param $key - string the key for the alias data
138
+ *
139
+ * @return null|string - null if key is not set in the alias data, otherwise
140
+ * the value for the given key from the alias data
141
+ */
142
+ protected function getStoredAliasDataForCustomer($aliasId, $key)
143
+ {
144
+ $returnValue = null;
145
+ $aliasData = array();
146
+
147
+ if (empty($this->aliasDataForCustomer)) {
148
+ $aliasData = $this->getStoredAliasForCustomer();
149
+ } else {
150
+ $aliasData = $this->aliasDataForCustomer;
151
+ }
152
+
153
+ if (array_key_exists($aliasId, $aliasData) && $aliasData[$aliasId]->hasData($key)) {
154
+ $returnValue = $aliasData[$aliasId]->getData($key);
155
+ }
156
+
157
+ return $returnValue;
158
+ }
159
+
160
+ /**
161
+ * retrieves the given path (month or year) from stored expiration date
162
+ *
163
+ * @param $key - the requested path
164
+ *
165
+ * @return null | string the extracted part of the date
166
+ */
167
+ public function getExpirationDatePart($aliasId, $key)
168
+ {
169
+ $returnValue = null;
170
+ $expirationDate = $this->getStoredAliasDataForCustomer($aliasId, 'expiration_date');
171
+ // set expiration date to actual date if no stored Alias is used
172
+ if ($expirationDate === null) {
173
+ $expirationDate = date('my');
174
+ }
175
+
176
+ if (0 < strlen(trim($expirationDate))
177
+ ) {
178
+ $expirationDateValues = str_split($expirationDate, 2);
179
+
180
+ if ($key == 'month') {
181
+ $returnValue = $expirationDateValues[0];
182
+ }
183
+ if ($key == 'year') {
184
+ $returnValue = $expirationDateValues[1];
185
+ }
186
+
187
+ if ($key == 'complete') {
188
+ $returnValue = implode('/', $expirationDateValues);
189
+ }
190
+ }
191
+
192
+ return $returnValue;
193
+
194
+ }
195
+
196
+ /**
197
+ * retrieves the masked alias card number and formats it in a card specific format
198
+ *
199
+ * @return null|string - null if no alias data were found,
200
+ * otherwise the formatted card number
201
+ */
202
+ public function getAliasCardNumber($aliasId)
203
+ {
204
+ $aliasCardNumber = $this->getStoredAliasDataForCustomer($aliasId, 'pseudo_account_or_cc_no');
205
+ if (0 < strlen(trim($aliasCardNumber))) {
206
+ $aliasCardNumber = Mage::helper('ops/alias')->formatAliasCardNo(
207
+ $this->getStoredAliasDataForCustomer($aliasId, 'brand'), $aliasCardNumber
208
+ );
209
+ }
210
+
211
+ return $aliasCardNumber;
212
+ }
213
+
214
+ /**
215
+ * @return null|string - the card holder either from alias data or
216
+ * the name from the the user who is logged in, null otherwise
217
+ */
218
+ public function getCardHolderName($aliasId)
219
+ {
220
+ $cardHolderName = $this->getStoredAliasDataForCustomer($aliasId, 'card_holder');
221
+ $customerHelper = Mage::helper('customer/data');
222
+ if ((is_null($cardHolderName) || 0 === strlen(trim($cardHolderName)))
223
+ && $customerHelper->isLoggedIn()
224
+ && Mage::getModel('ops/config')->isAliasManagerEnabled($this->getMethodCode())
225
+ ) {
226
+ $cardHolderName = $customerHelper->getCustomerName();
227
+ }
228
+
229
+ return $cardHolderName;
230
+ }
231
+
232
+ /**
233
+ * the brand of the stored card data
234
+ *
235
+ * @return null|string - string if stored card data were found, null otherwise
236
+ */
237
+ public function getStoredAliasBrand($aliasId)
238
+ {
239
+ $storedBrand = $this->getStoredAliasDataForCustomer($aliasId, 'brand');
240
+ $methodCode = $this->getMethodCode();
241
+ if (in_array($storedBrand, Mage::getModel('ops/config')->getInlinePaymentCcTypes($methodCode))) {
242
+ return $storedBrand;
243
+ }
244
+
245
+ return '';
246
+ }
247
+
248
+ /**
249
+ * determines whether the alias hint is shown to guests or not
250
+ *
251
+ * @return bool true if alias feature is enabled and display the hint to
252
+ * guests is enabled
253
+ */
254
+ public function isAliasInfoBlockEnabled()
255
+ {
256
+ return ($this->isAliasPMEnabled()
257
+ && Mage::getModel('ops/config')->isAliasInfoBlockEnabled());
258
+ }
259
+
260
+ /**
261
+ * @return string[]
262
+ */
263
+ public function getCcBrands()
264
+ {
265
+ return explode(',', $this->getConfig()->getAcceptedCcTypes($this->getMethodCode()));
266
+ }
267
+
268
  }
app/code/community/Netresearch/OPS/Block/Form/DirectDebit.php CHANGED
@@ -15,16 +15,12 @@ class Netresearch_OPS_Block_Form_DirectDebit extends Netresearch_OPS_Block_Form
15
  /**
16
  * Backend Payment Template
17
  */
18
- const BACKEND_TEMPLATE = 'ops/form/directDebit.phtml';
19
 
20
  protected function _construct()
21
  {
22
  parent::_construct();
23
-
24
- //Only in case that the form is loaded in the backend, use a special template
25
- if (false === Mage::getModel("ops/config")->isFrontendEnvironment()) {
26
- $this->setTemplate(self::BACKEND_TEMPLATE);
27
- }
28
  }
29
 
30
  /**
@@ -216,10 +212,11 @@ class Netresearch_OPS_Block_Form_DirectDebit extends Netresearch_OPS_Block_Form
216
 
217
  /**
218
  * gets the previously entered card holder (if any)
 
219
  *
220
  * @return string - empty string if no card holder is given, otherwise the card holder
221
  */
222
- public function getCardholderName()
223
  {
224
  $cardholder = '';
225
  if (array_key_exists('CN', $this->previousParams)) {
@@ -228,4 +225,9 @@ class Netresearch_OPS_Block_Form_DirectDebit extends Netresearch_OPS_Block_Form
228
 
229
  return $cardholder;
230
  }
 
 
 
 
 
231
  }
15
  /**
16
  * Backend Payment Template
17
  */
18
+ const TEMPLATE = 'ops/form/directDebit.phtml';
19
 
20
  protected function _construct()
21
  {
22
  parent::_construct();
23
+ $this->setTemplate(self::TEMPLATE);
 
 
 
 
24
  }
25
 
26
  /**
212
 
213
  /**
214
  * gets the previously entered card holder (if any)
215
+ * @param $aliasId - not used, but required by parent methods
216
  *
217
  * @return string - empty string if no card holder is given, otherwise the card holder
218
  */
219
+ public function getCardholderName($aliasId = null)
220
  {
221
  $cardholder = '';
222
  if (array_key_exists('CN', $this->previousParams)) {
225
 
226
  return $cardholder;
227
  }
228
+
229
+ public function getRegisterDirectDebitPaymentUrl()
230
+ {
231
+ return Mage::getModel('ops/config')->getRegisterDirectDebitPaymentUrl();
232
+ }
233
  }
app/code/community/Netresearch/OPS/Block/Form/Flex.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Flex.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Block_Form_Flex extends Netresearch_OPS_Block_Form
33
+ {
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ protected function _construct()
38
+ {
39
+ parent::_construct();
40
+ $this->setTemplate('ops/form/flex.phtml');
41
+ }
42
+
43
+ /**
44
+ * get configurable payment methods
45
+ *
46
+ * @return string[][]
47
+ */
48
+ public function getFlexMethods()
49
+ {
50
+
51
+ $methods = $this->getMethod()->getConfigData('methods');
52
+ if(!is_array($methods)){
53
+ $methods = unserialize($methods);
54
+ }
55
+
56
+ return $methods;
57
+ }
58
+
59
+ /**
60
+ * @return boolean
61
+ */
62
+ public function isDefaultOptionActive()
63
+ {
64
+ return (bool) $this->getMethod()->getConfigData('default');
65
+ }
66
+
67
+ public function getDefaultOptionTitle()
68
+ {
69
+ return $this->getMethod()->getConfigData('default_title');
70
+ }
71
+ }
app/code/community/Netresearch/OPS/Block/Form/InterSolve.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * InterSolve.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Block_Form_InterSolve extends Netresearch_OPS_Block_Form
33
+ {
34
+
35
+ protected function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->setTemplate('ops/form/intersolve.phtml');
39
+ }
40
+
41
+ /**
42
+ *
43
+ * @return array empty or intersolve Vouchers
44
+ */
45
+ public function getInterSolveBrands()
46
+ {
47
+ $brands = Mage::getModel('ops/config')->getIntersolveBrands();
48
+
49
+ return $brands;
50
+ }
51
+
52
+ }
app/code/community/Netresearch/OPS/Block/Form/Other.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- /**
3
- * @author Michael Lühr <michael.luehr@netresearch.de>
4
- * @category Netresearch
5
- * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
6
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
- */
8
-
9
-
10
- class Netresearch_OPS_Block_Form_Other
11
- extends Mage_Payment_Block_Form
12
- {
13
-
14
- /**
15
- * Init OPS payment form
16
- *
17
- */
18
- protected function _construct()
19
- {
20
- parent::_construct();
21
- $this->setTemplate('ops/form/other.phtml');
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Block/Form/RecurringCc.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * RecurringCc.php
24
+ *
25
+ * @category payment form block
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+
30
+ class Netresearch_OPS_Block_Form_RecurringCc extends Netresearch_OPS_Block_Form_Cc {
31
+
32
+ public function getCcBrands()
33
+ {
34
+ return $this->getConfig()->getAcceptedRecurringCcTypes();
35
+ }
36
+ }
app/code/community/Netresearch/OPS/Block/Frauddetection.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -23,7 +24,6 @@
23
  * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
-
27
  class Netresearch_OPS_Block_Frauddetection
28
  extends Mage_Core_Block_Template
29
  {
@@ -33,24 +33,24 @@ class Netresearch_OPS_Block_Frauddetection
33
 
34
  /**
35
  * renders the additional fraud detection js
 
36
  * @return string
37
  */
38
  protected function _toHtml()
39
  {
40
  $html = null;
41
  $storeId = Mage::helper('core/data')->getStoreId();
42
- if (true === Mage::getModel('ops/config')->isTrackingCodeActivated(
43
- $storeId
44
- )
45
- ) {
46
  $html = parent::_toHtml();
47
  }
 
48
  return $html;
49
  }
50
 
51
  /**
52
  * get the tracking code application id from config
53
- *
54
  * @return string
55
  */
56
  public function getTrackingCodeAid()
@@ -61,12 +61,14 @@ class Netresearch_OPS_Block_Frauddetection
61
 
62
  /**
63
  * build md5 hash from customer session ID
64
- *
65
  * @return string
66
  */
67
  public function getTrackingSid()
68
  {
69
- return md5(Mage::getSingleton("customer/session")->getSessionId());
 
 
70
  }
71
 
72
  }
1
  <?php
2
+
3
  /**
4
  * Magento
5
  *
24
  * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
25
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
  */
 
27
  class Netresearch_OPS_Block_Frauddetection
28
  extends Mage_Core_Block_Template
29
  {
33
 
34
  /**
35
  * renders the additional fraud detection js
36
+ *
37
  * @return string
38
  */
39
  protected function _toHtml()
40
  {
41
  $html = null;
42
  $storeId = Mage::helper('core/data')->getStoreId();
43
+ if (true == Mage::getModel('ops/config')->getDeviceFingerPrinting($storeId)
44
+ && Mage::getSingleton('customer/session')->getData(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY)) {
 
 
45
  $html = parent::_toHtml();
46
  }
47
+
48
  return $html;
49
  }
50
 
51
  /**
52
  * get the tracking code application id from config
53
+ *
54
  * @return string
55
  */
56
  public function getTrackingCodeAid()
61
 
62
  /**
63
  * build md5 hash from customer session ID
64
+ *
65
  * @return string
66
  */
67
  public function getTrackingSid()
68
  {
69
+ $quote = Mage::getSingleton('checkout/type_onepage')->getQuote();
70
+
71
+ return md5(Mage::getModel('ops/config')->getPSPID($quote->getStoreId()) . Mage::helper('ops/order')->getOpsOrderId($quote));
72
  }
73
 
74
  }
app/code/community/Netresearch/OPS/Block/Info/Flex.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Flex.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Block_Info_Flex extends Mage_Payment_Block_Info
33
+ {
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ protected function _construct()
38
+ {
39
+ parent::_construct();
40
+ $this->setTemplate('ops/info/flex.phtml');
41
+ }
42
+
43
+
44
+ /**
45
+ * @return string
46
+ */
47
+ public function getFlexTitle()
48
+ {
49
+ return $this->getMethod()->getInfoInstance()->getAdditionalInformation(
50
+ Netresearch_OPS_Model_Payment_Flex::INFO_KEY_TITLE
51
+ );
52
+ }
53
+ }
app/code/community/Netresearch/OPS/Block/Info/RecurringCc.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * RecurringCc.php
24
+ *
25
+ * @category payment info block
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+
30
+ class Netresearch_OPS_Block_Info_RecurringCc extends Netresearch_OPS_Block_Info_Cc {
31
+
32
+ }
app/code/community/Netresearch/OPS/Block/Placeform.php CHANGED
@@ -115,8 +115,20 @@ class Netresearch_OPS_Block_Placeform extends Mage_Core_Block_Template
115
  */
116
  public function getFormAction()
117
  {
118
- return $this->getRequest()->isPost() || is_null($this->getQuestion()) ? $this->getConfig()->getFrontendGatewayPath() :
119
- Mage::getUrl('*/*/*', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
 
 
 
 
 
 
 
 
 
 
 
 
120
  }
121
 
122
  public function hasMissingParams()
@@ -145,6 +157,11 @@ class Netresearch_OPS_Block_Placeform extends Mage_Core_Block_Template
145
  }
146
  return $this->missingFormFields;
147
  }
 
 
 
 
 
148
 
149
 
150
  }
115
  */
116
  public function getFormAction()
117
  {
118
+ $formAction = '';
119
+
120
+ // extract variable to ensure php 5.4 compatibility
121
+ $question = $this->getQuestion();
122
+
123
+ if ($this->getRequest()->isPost() || empty($question)) {
124
+ $formAction = $this->getConfig()->getFrontendGatewayPath();
125
+ } else {
126
+ $formAction = Mage::getUrl(
127
+ '*/*/*', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())
128
+ );
129
+ }
130
+
131
+ return $formAction;
132
  }
133
 
134
  public function hasMissingParams()
157
  }
158
  return $this->missingFormFields;
159
  }
160
+
161
+ public function isIframeTarget()
162
+ {
163
+ return $this->getConfig()->getConfigData('template') === Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME;
164
+ }
165
 
166
 
167
  }
app/code/community/Netresearch/OPS/Block/RetryPayment.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * ${PACKAGE}
4
  *
5
  * NOTICE OF LICENSE
6
  *
@@ -22,8 +22,8 @@
22
  /**
23
  * RetryPayment.php
24
  *
25
- * @category ${CATEGORY}
26
- * @package ${PACKAGE}
27
  * @author Paul Siedler <paul.siedler@netresearch.de>
28
  */
29
 
1
  <?php
2
  /**
3
+ * Netresearch_OPS
4
  *
5
  * NOTICE OF LICENSE
6
  *
22
  /**
23
  * RetryPayment.php
24
  *
25
+ * @category payment
26
+ * @package Netresearch_OPS
27
  * @author Paul Siedler <paul.siedler@netresearch.de>
28
  */
29
 
app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/Method.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Method.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+
30
+ class Netresearch_OPS_Block_System_Config_Form_Field_Method extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
31
+ {
32
+ public function __construct()
33
+ {
34
+ $this->addColumn('title', array(
35
+ 'label' => Mage::helper('ops')->__('Title'),
36
+ 'style' => 'width:80px',
37
+ 'class' => 'required-entry'
38
+ ));
39
+ $this->addColumn('pm', array(
40
+ 'label' => 'PM',
41
+ 'style' => 'width:80px',
42
+ 'class' => 'required-entry'
43
+ ));
44
+ $this->addColumn('brand', array(
45
+ 'label' => 'BRAND',
46
+ 'style' => 'width:80px',
47
+ ));
48
+
49
+ $this->_addAfter = false;
50
+ $this->_addButtonLabel = Mage::helper('ops')->__('Add Method');
51
+ parent::__construct();
52
+ }
53
+ }
app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/RecurringActive.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * RecurringActive.php
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Block_System_Config_Form_Field_RecurringActive
33
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
34
+ {
35
+
36
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
37
+ {
38
+ $html = parent::_getElementHtml($element);
39
+
40
+ $javascript
41
+ = "
42
+ <script type=\"text/javascript\">
43
+ element = $('" . $element->getHtmlId() . "');
44
+ Event.observe(element, 'change', function(){
45
+ if(element.value == 1){
46
+ $('ops_recurring_cc_active_comment').style.display = 'block';
47
+ } else {
48
+ $('ops_recurring_cc_active_comment').style.display = 'none';
49
+ }
50
+ });
51
+ </script>";
52
+
53
+ return $html . $javascript;
54
+ }
55
+ }
app/code/community/Netresearch/OPS/Controller/Abstract.php CHANGED
@@ -42,9 +42,9 @@ class Netresearch_OPS_Controller_Abstract extends Mage_Core_Controller_Front_Act
42
  * @return Mage_Sales_Model_Order
43
  */
44
 
45
- protected function _getOrder($opsOrderId=null)
46
  {
47
- if (empty($this->_order)) {
48
  if (is_null($opsOrderId)) {
49
  $opsOrderId = $this->getRequest()->getParam('orderID');
50
  }
@@ -69,7 +69,7 @@ class Netresearch_OPS_Controller_Abstract extends Mage_Core_Controller_Front_Act
69
 
70
  /**
71
  * get payment helper
72
- *
73
  * @return Netresearch_OPS_Helper_Payment
74
  */
75
  protected function getPaymentHelper()
@@ -79,7 +79,7 @@ class Netresearch_OPS_Controller_Abstract extends Mage_Core_Controller_Front_Act
79
 
80
  /**
81
  * get direct link helper
82
- *
83
  * @return Netresearch_OPS_Helper_Directlink
84
  */
85
  protected function getDirectlinkHelper()
@@ -87,6 +87,11 @@ class Netresearch_OPS_Controller_Abstract extends Mage_Core_Controller_Front_Act
87
  return Mage::helper('ops/directlink');
88
  }
89
 
 
 
 
 
 
90
  /**
91
  * Validation of incoming OPS data
92
  *
@@ -94,20 +99,55 @@ class Netresearch_OPS_Controller_Abstract extends Mage_Core_Controller_Front_Act
94
  */
95
  protected function _validateOPSData()
96
  {
 
97
  $params = $this->getRequest()->getParams();
98
- $order = $this->_getOrder();
99
- if (!$order->getId()) {
100
- $this->_getCheckout()->addError($this->__('Order is not valid'));
101
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
103
- $secureKey = $this->_getApi()->getConfig()->getShaInCode($order->getStoreId());
 
104
  $secureSet = $this->getPaymentHelper()->getSHAInSet($params, $secureKey);
105
 
106
- $helper = Mage::helper('ops');
107
- $helper->log($helper->__("Incoming Ingenico Payment Services Feedback\n\nRequest Path: %s\nParams: %s\n",
108
- $this->getRequest()->getPathInfo(),
109
- serialize($this->getRequest()->getParams())
110
- ));
 
 
111
 
112
  if (Mage::helper('ops/payment')->shaCryptValidation($secureSet, $params['SHASIGN']) !== true) {
113
  $this->_getCheckout()->addError($this->__('Hash is not valid'));
@@ -120,8 +160,13 @@ class Netresearch_OPS_Controller_Abstract extends Mage_Core_Controller_Front_Act
120
  public function isJsonRequested($params)
121
  {
122
  if (array_key_exists('RESPONSEFORMAT', $params) && $params['RESPONSEFORMAT'] == 'JSON') {
123
- return true;
124
  }
125
  return false;
126
  }
 
 
 
 
 
127
  }
42
  * @return Mage_Sales_Model_Order
43
  */
44
 
45
+ protected function _getOrder($opsOrderId = null)
46
  {
47
+ if (empty($this->_order)) {
48
  if (is_null($opsOrderId)) {
49
  $opsOrderId = $this->getRequest()->getParam('orderID');
50
  }
69
 
70
  /**
71
  * get payment helper
72
+ *
73
  * @return Netresearch_OPS_Helper_Payment
74
  */
75
  protected function getPaymentHelper()
79
 
80
  /**
81
  * get direct link helper
82
+ *
83
  * @return Netresearch_OPS_Helper_Directlink
84
  */
85
  protected function getDirectlinkHelper()
87
  return Mage::helper('ops/directlink');
88
  }
89
 
90
+ protected function getSubscriptionHelper()
91
+ {
92
+ return Mage::helper('ops/subscription');
93
+ }
94
+
95
  /**
96
  * Validation of incoming OPS data
97
  *
99
  */
100
  protected function _validateOPSData()
101
  {
102
+ $helper = Mage::helper('ops');
103
  $params = $this->getRequest()->getParams();
104
+ if ($this->getSubscriptionHelper()->isSubscriptionFeedback($params)) {
105
+ $profile = $this->getSubscriptionHelper()->getProfileForSubscription($params['orderID']);
106
+ if (!$profile->getId()) {
107
+ $this->_getCheckout()->addError($this->__('Subscription is not valid'));
108
+ $helper->log(
109
+ $helper->__(
110
+ "Incoming Ingenico ePayments Feedback\n\nRequest Path: %s\nParams: %s\n\nSubscription not valid\n",
111
+ $this->getRequest()->getPathInfo(),
112
+ serialize($this->getRequest()->getParams())
113
+ )
114
+ );
115
+ return false;
116
+ }
117
+ $storeId = $profile->getStoreId();
118
+ } else {
119
+ $order = $this->_getOrder();
120
+ if (!$order->getId()) {
121
+ $helper->log(
122
+ $helper->__(
123
+ "Incoming Ingenico ePayments Feedback\n\nRequest Path: %s\nParams: %s\n\nOrder not valid\n",
124
+ $this->getRequest()->getPathInfo(),
125
+ serialize($this->getRequest()->getParams())
126
+ )
127
+ );
128
+ $this->_getCheckout()->addError($this->__('Order is not valid'));
129
+ return false;
130
+ }
131
+ $storeId = $order->getStoreId();
132
+ }
133
+
134
+ //remove custom responseparams, because they are not hashed by Ingenico ePayments
135
+ if ($this->getConfig()->getConfigData('template') == Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME
136
+ && array_key_exists('IFRAME', $params)
137
+ ) {
138
+ unset($params['IFRAME']);
139
  }
140
+
141
+ $secureKey = $this->getConfig()->getShaInCode($storeId);
142
  $secureSet = $this->getPaymentHelper()->getSHAInSet($params, $secureKey);
143
 
144
+ $helper->log(
145
+ $helper->__(
146
+ "Incoming Ingenico ePayments Feedback\n\nRequest Path: %s\nParams: %s\n",
147
+ $this->getRequest()->getPathInfo(),
148
+ serialize($this->getRequest()->getParams())
149
+ )
150
+ );
151
 
152
  if (Mage::helper('ops/payment')->shaCryptValidation($secureSet, $params['SHASIGN']) !== true) {
153
  $this->_getCheckout()->addError($this->__('Hash is not valid'));
160
  public function isJsonRequested($params)
161
  {
162
  if (array_key_exists('RESPONSEFORMAT', $params) && $params['RESPONSEFORMAT'] == 'JSON') {
163
+ return true;
164
  }
165
  return false;
166
  }
167
+
168
+ public function getSubscriptionManager()
169
+ {
170
+ return Mage::getModel('ops/subscription_manager');
171
+ }
172
  }
app/code/community/Netresearch/OPS/Helper/Alias.php CHANGED
@@ -75,17 +75,13 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
75
  *
76
  * @return string
77
  */
78
- public function getAlias($quote)
79
  {
80
 
81
  $alias = $quote->getPayment()->getAdditionalInformation('alias');
82
- if (0 == strlen($alias)) {
83
  /* turn createdAt into format MMDDHHii */
84
- $createdAt = substr(
85
- str_replace(array(':', '-', ' '), '', $quote->getCreatedAt()),
86
- 4,
87
- -2
88
- );
89
  $quoteId = $quote->getId();
90
  /* shorten createdAt, if we would exceed maximum length */
91
  $maxAliasLength = 16;
@@ -115,60 +111,28 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
115
  $quote = null;
116
  $aliasModel = null;
117
  Mage::helper('ops')->log('aliasData ' . Zend_Json::encode(Mage::helper('ops/data')->clearMsg($aliasData)));
118
- if (array_key_exists('OrderID', $aliasData) && is_numeric($aliasData['OrderID'])) {
119
- $quote = Mage::getModel('sales/quote')->load($aliasData['OrderID']);
120
  }
121
 
122
- $aliasModel = null;
123
  if ($quote instanceof Mage_Sales_Model_Quote
124
  && $quote->getPayment()
125
- && (1 == $quote->getPayment()->getAdditionalInformation('saveOpsAlias'))
 
 
126
  ) {
127
- $customerId = $quote->getCustomer()->getId();
128
- $billingAddressHash = $this->generateAddressHash(
129
- $quote->getBillingAddress()
130
- );
131
- $shippingAddressHash = $this->generateAddressHash(
132
- $quote->getShippingAddress()
133
- );
134
 
135
- // first: check if alias exists
136
- $oldAlias = Mage::getModel('ops/alias')->getCollection()
137
- ->addFieldToFilter('customer_id', $customerId)
138
- ->addFieldToFilter('billing_address_hash', $billingAddressHash)
139
- ->addFieldToFilter('shipping_address_hash', $shippingAddressHash)
140
- ->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
141
- ->addFieldToFilter('store_id', array(
142
- array('attribute' => 'store_id', 'eq' => $quote->getStoreId()),
143
- array('attribute' => 'store_id', 'null' => true)
144
- ))
145
- ->getFirstItem();
146
- // and if so update this alias with alias data from alias gateway
147
- if (is_numeric($oldAlias->getAlias())) {
148
- $oldAlias->setCardHolder($aliasData['CN']);
149
- $oldAlias->setBrand($aliasData['Brand']);
150
- $oldAlias->setExpirationDate($aliasData['ED']);
151
- $oldAlias->setPseudoAccountOrCCNo($aliasData['CardNo']);
152
- $oldAlias->setStoreId($quote->getStoreId());
153
- $oldAlias->save();
154
- $aliasModel = $oldAlias;
155
- } else {
156
- // alias does not exist -> create a new one if requested
157
- if (!is_null($quote) && $quote->getPayment()
158
- && $quote->getPayment()->getAdditionalInformation('saveOpsAlias')
159
- ) {
160
- if (!is_null($quote->getCustomer()->getId())) {
161
- $this->deleteAlias($quote, $aliasData);
162
- }
163
- // create new alias
164
- $aliasModel = $this->saveNewAlias($quote, $aliasData);
165
- $quote->getPayment()->setAdditionalInformation(
166
- 'opsAliasId', $aliasModel->getId()
167
- );
168
- $quote->getPayment()->save();
169
- }
170
  }
171
  }
 
172
  return $aliasModel;
173
  }
174
 
@@ -212,17 +176,17 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
212
 
213
  $aliasModel = Mage::getModel('ops/alias');
214
  $aliasModel->setCustomerId($customerId);
215
- $aliasModel->setAlias($aliasData['Alias']);
216
- $aliasModel->setExpirationDate($aliasData['ED']);
217
  $aliasModel->setBillingAddressHash($billingAddressHash);
218
  $aliasModel->setShippingAddressHash($shippingAddressHash);
219
- $aliasModel->setBrand($aliasData['Brand']);
220
  $aliasModel->setPaymentMethod($quote->getPayment()->getMethod());
221
- $aliasModel->setPseudoAccountOrCCNo($aliasData['CardNo']);
222
  $aliasModel->setState(Netresearch_OPS_Model_Alias_State::PENDING);
223
  $aliasModel->setStoreId($quote->getStoreId());
224
- if (array_key_exists('CN', $aliasData)) {
225
- $aliasModel->setCardHolder($aliasData['CN']);
226
  }
227
  Mage::helper('ops')->log(
228
  'saving alias' . Zend_Json::encode($aliasModel->getData())
@@ -237,12 +201,14 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
237
  *
238
  * @param Mage_Sales_Model_Quote_Address $address the address data to hash
239
  *
240
- * @returns sha1 hash of address
241
  */
242
  public function generateAddressHash(
243
  Mage_Customer_Model_Address_Abstract $address
244
  )
245
  {
 
 
246
  $addressString = $address->getFirstname();
247
  $addressString .= $address->getMiddlename();
248
  $addressString .= $address->getLastname();
@@ -256,7 +222,7 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
256
  $addressString .= $address->getCity();
257
  $addressString .= $address->getCountryId();
258
 
259
- return sha1($addressString);
260
  }
261
 
262
  /**
@@ -370,20 +336,27 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
370
  */
371
  public function setAliasToPayment(Mage_Payment_Model_Info $payment, array $aliasData, $userIsRegistering = false, $paymentSave = false)
372
  {
373
- if (array_key_exists('alias', $aliasData) && 0 < strlen(trim($aliasData['alias']))) {
374
- $payment->setAdditionalInformation('alias', trim($aliasData['alias']));
375
  $payment->setAdditionalInformation('userIsRegistering', $userIsRegistering);
376
- if (array_key_exists('CVC', $aliasData)) {
377
- $payment->setAdditionalInformation('cvc', $aliasData['CVC']);
378
  $this->setCardHolderToAlias($payment->getQuote(), $aliasData);
379
  }
 
 
 
 
 
 
 
380
  $payment->setDataChanges(true);
381
  if($paymentSave === true){
382
  $payment->save();
383
  }
384
  } else {
385
  Mage::helper('ops/data')->log('did not save alias due to empty alias');
386
- Mage::helper('ops/data')->log($aliasData);
387
  }
388
  }
389
 
@@ -400,9 +373,9 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
400
  ->addFieldToFilter('store_id', array(array('eq' => $quote->getStoreId()), array('null' => true)))
401
  ->getFirstItem();
402
  // and if so update this alias with alias data from alias gateway
403
- if (is_numeric($oldAlias->getId()) && is_null($oldAlias->getCardHolder()) && array_key_exists('CN', $aliasData)
404
  ) {
405
- $oldAlias->setCardHolder($aliasData['CN']);
406
  $oldAlias->save();
407
  }
408
  }
@@ -418,7 +391,7 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
418
  $saveSalesObjects = false
419
  ) {
420
  if (is_null($quote->getPayment()->getAdditionalInformation('userIsRegistering'))
421
- || false === $quote->getPayment()->getAdditionalInformation('userIsRegistering')
422
  ) {
423
  $aliasesToDelete = Mage::helper('ops/alias')->getAliasesForAddresses(
424
  $quote->getCustomer()->getId(), $quote->getBillingAddress(), $quote->getShippingAddress()
@@ -439,6 +412,7 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
439
  $alias->delete();
440
  }
441
  $lastPendingAlias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
 
442
  $lastPendingAlias->save();
443
  }
444
  } else {
@@ -452,7 +426,7 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
452
  Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote
453
  )
454
  {
455
- if (true === $quote->getPayment()->getAdditionalInformation('userIsRegistering')
456
  ) {
457
  $customerId = $order->getCustomerId();
458
  $billingAddressHash = $this->generateAddressHash(
@@ -477,12 +451,11 @@ class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
477
  )
478
  ->addFieldToFilter('store_id', array('eq' => $quote->getStoreId()))
479
  ->getFirstItem();
480
- if ($alias->getState() === Netresearch_OPS_Model_Alias_State::PENDING
481
- ) {
482
- $alias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
483
- $alias->setCustomerId($customerId);
484
- $alias->save();
485
- }
486
  }
487
  }
488
  }
75
  *
76
  * @return string
77
  */
78
+ public function getAlias($quote, $forceNew = false)
79
  {
80
 
81
  $alias = $quote->getPayment()->getAdditionalInformation('alias');
82
+ if (0 == strlen($alias) || $forceNew) {
83
  /* turn createdAt into format MMDDHHii */
84
+ $createdAt = time();
 
 
 
 
85
  $quoteId = $quote->getId();
86
  /* shorten createdAt, if we would exceed maximum length */
87
  $maxAliasLength = 16;
111
  $quote = null;
112
  $aliasModel = null;
113
  Mage::helper('ops')->log('aliasData ' . Zend_Json::encode(Mage::helper('ops/data')->clearMsg($aliasData)));
114
+ if (array_key_exists('Alias_OrderId', $aliasData) && is_numeric($aliasData['Alias_OrderId'])) {
115
+ $quote = Mage::getModel('sales/quote')->load($aliasData['Alias_OrderId']);
116
  }
117
 
 
118
  if ($quote instanceof Mage_Sales_Model_Quote
119
  && $quote->getPayment()
120
+ && Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod()
121
+ != Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
122
+ && (array_key_exists('Alias_StorePermanently',$aliasData) && 'Y' == $aliasData['Alias_StorePermanently'])
123
  ) {
 
 
 
 
 
 
 
124
 
125
+ // alias does not exist -> create a new one if requested
126
+ if (!is_null($quote) && $quote->getPayment()) {
127
+ // create new alias
128
+ $aliasModel = $this->saveNewAlias($quote, $aliasData);
129
+ $quote->getPayment()->setAdditionalInformation(
130
+ 'opsAliasId', $aliasModel->getId()
131
+ );
132
+ $quote->getPayment()->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
134
  }
135
+
136
  return $aliasModel;
137
  }
138
 
176
 
177
  $aliasModel = Mage::getModel('ops/alias');
178
  $aliasModel->setCustomerId($customerId);
179
+ $aliasModel->setAlias($aliasData['Alias_AliasId']);
180
+ $aliasModel->setExpirationDate($aliasData['Card_ExpiryDate']);
181
  $aliasModel->setBillingAddressHash($billingAddressHash);
182
  $aliasModel->setShippingAddressHash($shippingAddressHash);
183
+ $aliasModel->setBrand($aliasData['Card_Brand']);
184
  $aliasModel->setPaymentMethod($quote->getPayment()->getMethod());
185
+ $aliasModel->setPseudoAccountOrCCNo($aliasData['Card_CardNumber']);
186
  $aliasModel->setState(Netresearch_OPS_Model_Alias_State::PENDING);
187
  $aliasModel->setStoreId($quote->getStoreId());
188
+ if (array_key_exists('Card_CardHolderName', $aliasData)) {
189
+ $aliasModel->setCardHolder($aliasData['Card_CardHolderName']);
190
  }
191
  Mage::helper('ops')->log(
192
  'saving alias' . Zend_Json::encode($aliasModel->getData())
201
  *
202
  * @param Mage_Sales_Model_Quote_Address $address the address data to hash
203
  *
204
+ * @returns string hash of address
205
  */
206
  public function generateAddressHash(
207
  Mage_Customer_Model_Address_Abstract $address
208
  )
209
  {
210
+ /** @var Netresearch_OPS_Helper_Payment $opsHelper */
211
+ $opsHelper = Mage::helper('ops/payment');
212
  $addressString = $address->getFirstname();
213
  $addressString .= $address->getMiddlename();
214
  $addressString .= $address->getLastname();
222
  $addressString .= $address->getCity();
223
  $addressString .= $address->getCountryId();
224
 
225
+ return hash($opsHelper->getCryptMethod(), $addressString);
226
  }
227
 
228
  /**
336
  */
337
  public function setAliasToPayment(Mage_Payment_Model_Info $payment, array $aliasData, $userIsRegistering = false, $paymentSave = false)
338
  {
339
+ if (array_key_exists('alias_aliasid', $aliasData) && 0 < strlen(trim($aliasData['alias_aliasid']))) {
340
+ $payment->setAdditionalInformation('alias', trim($aliasData['alias_aliasid']));
341
  $payment->setAdditionalInformation('userIsRegistering', $userIsRegistering);
342
+ if (array_key_exists('card_cvc', $aliasData)) {
343
+ $payment->setAdditionalInformation('cvc', $aliasData['card_cvc']);
344
  $this->setCardHolderToAlias($payment->getQuote(), $aliasData);
345
  }
346
+
347
+ if ( array_key_exists('method', $aliasData)) {
348
+ $alias = Mage::getModel('ops/alias')->load($aliasData['alias_aliasid'], 'alias');
349
+ $alias->setPaymentMethod($aliasData['method']);
350
+ $alias->save();
351
+ }
352
+
353
  $payment->setDataChanges(true);
354
  if($paymentSave === true){
355
  $payment->save();
356
  }
357
  } else {
358
  Mage::helper('ops/data')->log('did not save alias due to empty alias');
359
+ Mage::helper('ops/data')->log(serialize($aliasData));
360
  }
361
  }
362
 
373
  ->addFieldToFilter('store_id', array(array('eq' => $quote->getStoreId()), array('null' => true)))
374
  ->getFirstItem();
375
  // and if so update this alias with alias data from alias gateway
376
+ if (is_numeric($oldAlias->getId()) && is_null($oldAlias->getCardHolder()) && array_key_exists('Card_CardHolderName', $aliasData)
377
  ) {
378
+ $oldAlias->setCardHolder($aliasData['Card_CardHolderName']);
379
  $oldAlias->save();
380
  }
381
  }
391
  $saveSalesObjects = false
392
  ) {
393
  if (is_null($quote->getPayment()->getAdditionalInformation('userIsRegistering'))
394
+ || false == $quote->getPayment()->getAdditionalInformation('userIsRegistering')
395
  ) {
396
  $aliasesToDelete = Mage::helper('ops/alias')->getAliasesForAddresses(
397
  $quote->getCustomer()->getId(), $quote->getBillingAddress(), $quote->getShippingAddress()
412
  $alias->delete();
413
  }
414
  $lastPendingAlias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
415
+ $lastPendingAlias->setPaymentMethod($order->getPayment()->getMethod());
416
  $lastPendingAlias->save();
417
  }
418
  } else {
426
  Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote
427
  )
428
  {
429
+ if (true == $quote->getPayment()->getAdditionalInformation('userIsRegistering')
430
  ) {
431
  $customerId = $order->getCustomerId();
432
  $billingAddressHash = $this->generateAddressHash(
451
  )
452
  ->addFieldToFilter('store_id', array('eq' => $quote->getStoreId()))
453
  ->getFirstItem();
454
+
455
+ $alias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
456
+ $alias->setPaymentMethod($order->getPayment()->getMethod());
457
+ $alias->setCustomerId($customerId);
458
+ $alias->save();
 
459
  }
460
  }
461
  }
app/code/community/Netresearch/OPS/Helper/Creditcard.php CHANGED
@@ -14,7 +14,7 @@ class Netresearch_OPS_Helper_Creditcard extends Netresearch_OPS_Helper_Payment_D
14
  protected $aliasHelper = null;
15
 
16
  /**
17
- * @param null $aliasHelper
18
  */
19
  public function setAliasHelper($aliasHelper)
20
  {
@@ -22,7 +22,7 @@ class Netresearch_OPS_Helper_Creditcard extends Netresearch_OPS_Helper_Payment_D
22
  }
23
 
24
  /**
25
- * @return null
26
  */
27
  public function getAliasHelper()
28
  {
@@ -50,8 +50,11 @@ class Netresearch_OPS_Helper_Creditcard extends Netresearch_OPS_Helper_Payment_D
50
  $alias = $this->getAliasHelper()->getAlias($quote);
51
  }
52
  $params = array (
53
- 'ALIAS' => $alias,
54
  );
 
 
 
55
  if (is_numeric($quote->getPayment()->getAdditionalInformation('cvc'))) {
56
  $params['CVC'] = $quote->getPayment()->getAdditionalInformation('cvc');
57
  }
14
  protected $aliasHelper = null;
15
 
16
  /**
17
+ * @param Netresearch_OPS_Helper_Alias $aliasHelper
18
  */
19
  public function setAliasHelper($aliasHelper)
20
  {
22
  }
23
 
24
  /**
25
+ * @return Netresearch_OPS_Helper_Alias
26
  */
27
  public function getAliasHelper()
28
  {
50
  $alias = $this->getAliasHelper()->getAlias($quote);
51
  }
52
  $params = array (
53
+ 'ALIAS' => $alias
54
  );
55
+ if($this->getConfig()->getCreditDebitSplit($quote->getStoreId())){
56
+ $params['CREDITDEBIT'] = 'C';
57
+ }
58
  if (is_numeric($quote->getPayment()->getAdditionalInformation('cvc'))) {
59
  $params['CVC'] = $quote->getPayment()->getAdditionalInformation('cvc');
60
  }
app/code/community/Netresearch/OPS/Helper/Data.php CHANGED
@@ -125,7 +125,7 @@ class Netresearch_OPS_Helper_Data extends Mage_Core_Helper_Abstract
125
  public function isAdminSession()
126
  {
127
  if ($this->getAdminSession()->getUser()) {
128
- return 0 < $this->getAdminSession()->getUser()->getUserId();
129
  }
130
  return false;
131
  }
125
  public function isAdminSession()
126
  {
127
  if ($this->getAdminSession()->getUser()) {
128
+ return 0 < $this->getAdminSession()->getUser()->getUserId() || $this->getAdminSession()->isLoggedIn();
129
  }
130
  return false;
131
  }
app/code/community/Netresearch/OPS/Helper/Debitcard.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Paul Siedler <paul.siedler@netresearch.de>
4
+ * @category Netresearch
5
+ * @package Netresearch_OPS
6
+ * @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+
11
+ class Netresearch_OPS_Helper_Debitcard extends Netresearch_OPS_Helper_Creditcard
12
+ {
13
+ protected function getPaymentSpecificParams(Mage_Sales_Model_Quote $quote)
14
+ {
15
+ $params = parent::getPaymentSpecificParams($quote);
16
+ if($this->getConfig()->getCreditDebitSplit($quote->getStoreId())){
17
+ $params['CREDITDEBIT'] = 'D';
18
+ }
19
+ return $params;
20
+ }
21
+ }
app/code/community/Netresearch/OPS/Helper/Directlink.php CHANGED
@@ -26,12 +26,10 @@ class Netresearch_OPS_Helper_Directlink extends Mage_Core_Helper_Abstract
26
  {
27
  $payment = $order->getPayment();
28
  $payment->setTransactionId($transactionID."/".$subPayID);
29
- $transaction = $payment->addTransaction($typename, null, false, $comment);
30
- $transaction->setParentTxnId($transactionID);
31
- $transaction->setIsClosed($closed);
32
- $transaction->setAdditionalInformation("arrInfo", serialize($arrInformation));
33
- $transaction->save();
34
- $order->save();
35
  return $this;
36
  }
37
 
@@ -65,32 +63,32 @@ class Netresearch_OPS_Helper_Directlink extends Mage_Core_Helper_Abstract
65
  public function getTypeForStatus($status)
66
  {
67
  switch ($status) {
68
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUNDED :
69
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING:
70
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_UNCERTAIN_STATUS :
71
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_REFUSED :
72
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_DECLINED_ACQUIRER :
73
  return Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE;
74
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED :
75
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSED_MERCHANT :
76
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING:
77
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN:
78
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_IN_PROGRESS:
79
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED:
80
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DECLINED_ACQUIRER:
81
  return Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE;
82
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED: //Void finished
83
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED_ACCEPTED:
84
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_WAITING:
85
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_UNCERTAIN:
86
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_REFUSED:
87
  return Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE;
88
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED:
89
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_WAITING:
90
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_UNCERTAIN:
91
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_REFUSED:
92
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_OK:
93
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_PROCESSED_MERCHANT:
94
  return Netresearch_OPS_Model_Payment_Abstract::OPS_DELETE_TRANSACTION_TYPE;
95
  }
96
  }
@@ -105,159 +103,24 @@ class Netresearch_OPS_Helper_Directlink extends Mage_Core_Helper_Abstract
105
  */
106
  public function processFeedback($order, $params)
107
  {
108
- $transaction = null;
109
- if ($params['STATUS'] < 50 || $params['STATUS'] >= 60) {
110
- try {
111
- $transaction = $this->getPaymentTransaction($order, null, $this->getTypeForStatus($params['STATUS']));
112
- } catch (Mage_Core_Exception $e) {
113
- $transaction = null;
114
- }
115
- }
116
- if (false == $this->isValidOpsRequest($transaction, $order, $params)) {
117
- $order->addStatusHistoryComment(
118
- Mage::helper('ops')->__(
119
- 'Could not perform actions for Ingenico Payment Services status: %s.',
120
- Mage::helper('ops')->getStatusText($params['STATUS'])
121
- )
122
- )->save();
123
- throw new Mage_Core_Exception('invalid Ingenico Payment Services request');
124
- }
125
-
126
- Mage::helper('ops/payment')->saveOpsStatusToPayment($order->getPayment(), $params);
127
- switch ($params['STATUS']) {
128
- case Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID :
129
- break;
130
 
131
- /*
132
- * Refund Actions
133
- */
134
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUNDED :
135
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PROCESSED_MERCHANT :
136
- Mage::helper('ops/order_refund')->createRefund($order, $params);
137
- break;
138
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING:
139
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_UNCERTAIN_STATUS :
140
- $order->addStatusHistoryComment(
141
- Mage::helper('ops')->__(
142
- 'Refund is waiting or uncertain. Ingenico Payment Services status: %s.',
143
- Mage::helper('ops')->getStatusText($params['STATUS'])
144
- )
145
- );
146
- $order->save();
147
- break;
148
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_REFUSED :
149
- case Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_DECLINED_ACQUIRER :
150
- $this->closePaymentTransaction(
151
- $order,
152
- $params,
153
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE,
154
- Mage::helper('ops')->__(
155
- 'Refund was refused. Automatic creation failed. Ingenico Payment Services status: %s.',
156
- Mage::helper('ops')->getStatusText($params['STATUS'])
157
- )
158
- );
159
- break;
160
-
161
- /*
162
- * Capture Actions
163
- */
164
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED :
165
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSED_MERCHANT :
166
- Mage::helper("ops/order_capture")->acceptCapture($order, $params);
167
- break;
168
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING:
169
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN:
170
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_IN_PROGRESS:
171
- $order->addStatusHistoryComment(
172
- Mage::helper('ops')->__(
173
- 'Capture is waiting or uncertain. Ingenico Payment Services status: %s.',
174
- Mage::helper('ops')->getStatusText($params['STATUS'])
175
- )
176
- );
177
- $order->save();
178
- break;
179
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED:
180
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DECLINED_ACQUIRER:
181
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTH_REFUSED :
182
- $this->closePaymentTransaction(
183
- $order,
184
- $params,
185
- Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE,
186
- Mage::helper('ops')->__(
187
- 'Capture was refused. Automatic creation failed. Ingenico Payment Services status: %s.',
188
- Mage::helper('ops')->getStatusText($params['STATUS'])
189
- )
190
- );
191
- break;
192
-
193
- /*
194
- * Void Actions
195
- */
196
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED: //Void finished
197
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED_ACCEPTED:
198
- Mage::helper("ops/order_void")->acceptVoid($order, $params);
199
- break;
200
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_WAITING:
201
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_UNCERTAIN:
202
- $order->addStatusHistoryComment(
203
- Mage::helper('ops')->__(
204
- 'Void is waiting or uncertain. Ingenico Payment Services status: %s.',
205
- Mage::helper('ops')->getStatusText($params['STATUS'])
206
- )
207
- );
208
- $order->save();
209
- break;
210
- case Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_REFUSED:
211
- $this->closePaymentTransaction(
212
- $order,
213
- $params,
214
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE,
215
- Mage::helper('ops')->__(
216
- 'Void was refused. Automatic creation failed. Ingenico Payment Services status: %s.',
217
- Mage::helper('ops')->getStatusText($params['STATUS'])
218
- )
219
- );
220
- break;
221
-
222
- /*
223
- * Authorize Actions
224
- */
225
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED:
226
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING:
227
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_UNKNOWN:
228
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_TO_GET_MANUALLY:
229
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_KWIXO:
230
- if ($params['STATUS'] == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED
231
- && $order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Kwixo_Abstract) {
232
- Mage::helper('ops/data')->log('acceptOrder in directLink helper');
233
- Mage::helper('ops/payment')->acceptOrder($order, $params);
234
- $comment = Mage::helper('ops')->__('Authorization status changed. Current Ingenico Payment Services status is: %s.', Mage::helper('ops')->getStatusText($params['STATUS']));
235
- // $this->closePaymentTransaction($order, null, 'authorization', "", false);
236
- } else {
237
- $order->addStatusHistoryComment(Mage::helper('ops')->__('Authorization status changed. Current Ingenico Payment Services status is: %s.', Mage::helper('ops')->getStatusText($params['STATUS'])));
238
- $order->save();
239
- }
240
- break;
241
- default:
242
- $order->addStatusHistoryComment(
243
- Mage::helper('ops')->__('Unknown Ingenico Payment Services status: %s.', Mage::helper('ops')->getStatusText($params['STATUS']))
244
- );
245
- $order->save();
246
- Mage::helper("ops")->log("Unknown status code:".$params['STATUS']);
247
- break;
248
- }
249
  }
250
 
251
  /**
252
  * Get the payment transaction by PAYID and Operation
253
  *
254
  * @param Mage_Sales_Model_Order $order
255
- * @param int $payid
256
- * @param string $authorization
257
  *
258
  * @return Mage_Sales_Model_Order_Payment_Transaction
 
 
259
  */
260
- public function getPaymentTransaction($order, $payid, $operation)
261
  {
262
  $helper = Mage::helper('ops');
263
  $transactionCollection = Mage::getModel('sales/order_payment_transaction')
@@ -265,15 +128,15 @@ class Netresearch_OPS_Helper_Directlink extends Mage_Core_Helper_Abstract
265
  ->addAttributeToFilter('txn_type', $operation)
266
  ->addAttributeToFilter('is_closed', 0)
267
  ->addAttributeToFilter('order_id', $order->getId());
268
- if ($payid != '') {
269
- $transactionCollection->addAttributeToFilter('parent_txn_id', $payid);
270
  }
271
 
272
  if ($transactionCollection->count()>1 || $transactionCollection->count() == 0) {
273
  $errorMsq = $helper->__(
274
- 'Warning, transaction count is %s instead of 1 for the Payid "%s", order "%s" and Operation "%s".',
275
  $transactionCollection->count(),
276
- $payid,
277
  $order->getId(),
278
  $operation
279
  );
@@ -372,7 +235,7 @@ class Netresearch_OPS_Helper_Directlink extends Mage_Core_Helper_Abstract
372
 
373
  if ($this->getTypeForStatus($opsRequestParams['STATUS']) == Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE) {
374
  if (is_null($requestedAmount)) {
375
- Mage::helper('ops')->log('Please configure Ingenico Payment Services to submit amount');
376
  return false;
377
  }
378
  $grandTotal = $this->formatAmount(Mage::helper('ops/payment')->getBaseGrandTotalFromSalesObject($order));
@@ -387,47 +250,6 @@ class Netresearch_OPS_Helper_Directlink extends Mage_Core_Helper_Abstract
387
  return true;
388
  }
389
 
390
- /**
391
- * Close a payment transaction
392
- *
393
- * @param Mage_Sales_Model_Order $order
394
- * @param array $params
395
- *
396
- * @return Mage_Sales_Model_Order_Payment_Transaction
397
- */
398
- public function closePaymentTransaction($order, $params, $type, $comment = "", $isCustomerNotified = false)
399
- {
400
- try {
401
- $transaction = Mage::helper('ops/directlink')->getPaymentTransaction(
402
- $order,
403
- $params['PAYID'],
404
- $type
405
- );
406
-
407
- if (1 !== $transaction->getIsClosed()) {
408
- $transaction->setIsClosed(1);
409
- $transaction->save();
410
- }
411
-
412
- $transactionId = $transaction->getTxnId();
413
- if ($comment) {
414
- $comment .= ' Transaction ID: '.'"'.$transactionId.'"';
415
- $order
416
- ->addStatusHistoryComment($comment)
417
- ->setIsCustomerNotified($isCustomerNotified);
418
- }
419
-
420
- } catch (Exception $e) {
421
- if (array_key_exists('STATUS', $params) && in_array($params['STATUS'], array(Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED,
422
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DECLINED_ACQUIRER))) {
423
- Mage::helper('ops/payment')->declineOrder($order, $params);
424
- }
425
-
426
- }
427
-
428
- $order->save();
429
- }
430
-
431
  public function performDirectLinkRequest($quote, $params, $storeId = null)
432
  {
433
  $url = Mage::getModel('ops/config')->getDirectLinkGatewayOrderPath($storeId);
@@ -439,7 +261,7 @@ class Netresearch_OPS_Helper_Directlink extends Mage_Core_Helper_Abstract
439
  && Mage::helper('ops/payment')->isPaymentFailed($response['STATUS'])
440
  ) {
441
  Mage::getSingleton('checkout/type_onepage')->getCheckout()->setGotoSection('payment');
442
- throw new Mage_Core_Exception(Mage::helper('ops/data')->__('Ingenico Payment Services Payment failed'));
443
  }
444
  return $response;
445
  }
26
  {
27
  $payment = $order->getPayment();
28
  $payment->setTransactionId($transactionID."/".$subPayID);
29
+ // $transaction = $payment->addTransaction($typename, null, false, $comment);
30
+ $payment->setParentTransactionId($transactionID);
31
+ $payment->setIsTransactionClosed($closed);
32
+ $payment->setTransactionAdditionalInfo($arrInformation, null);
 
 
33
  return $this;
34
  }
35
 
63
  public function getTypeForStatus($status)
64
  {
65
  switch ($status) {
66
+ case Netresearch_OPS_Model_Status::REFUNDED :
67
+ case Netresearch_OPS_Model_Status::REFUND_PENDING:
68
+ case Netresearch_OPS_Model_Status::REFUND_UNCERTAIN :
69
+ case Netresearch_OPS_Model_Status::REFUND_REFUSED :
70
+ case Netresearch_OPS_Model_Status::REFUNDED_OK :
71
  return Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE;
72
+ case Netresearch_OPS_Model_Status::PAYMENT_REQUESTED :
73
+ case Netresearch_OPS_Model_Status::PAYMENT_PROCESSED_BY_MERCHANT :
74
+ case Netresearch_OPS_Model_Status::PAYMENT_PROCESSING:
75
+ case Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN:
76
+ case Netresearch_OPS_Model_Status::PAYMENT_IN_PROGRESS:
77
+ case Netresearch_OPS_Model_Status::PAYMENT_REFUSED:
78
+ case Netresearch_OPS_Model_Status::PAYMENT_DECLINED_BY_ACQUIRER:
79
  return Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE;
80
+ case Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED: //Void finished
81
+ case Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED_OK:
82
+ case Netresearch_OPS_Model_Status::DELETION_WAITING:
83
+ case Netresearch_OPS_Model_Status::DELETION_UNCERTAIN:
84
+ case Netresearch_OPS_Model_Status::DELETION_REFUSED:
85
  return Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE;
86
+ case Netresearch_OPS_Model_Status::PAYMENT_DELETED:
87
+ case Netresearch_OPS_Model_Status::PAYMENT_DELETION_PENDING:
88
+ case Netresearch_OPS_Model_Status::PAYMENT_DELETION_UNCERTAIN:
89
+ case Netresearch_OPS_Model_Status::PAYMENT_DELETION_REFUSED:
90
+ case Netresearch_OPS_Model_Status::PAYMENT_DELETION_OK:
91
+ case Netresearch_OPS_Model_Status::DELETION_HANDLED_BY_MERCHANT:
92
  return Netresearch_OPS_Model_Payment_Abstract::OPS_DELETE_TRANSACTION_TYPE;
93
  }
94
  }
103
  */
104
  public function processFeedback($order, $params)
105
  {
106
+ Mage::getModel('ops/response_handler')->processResponse($params, $order->getPayment()->getMethodInstance());
107
+ $order->getPayment()->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }
111
 
112
  /**
113
  * Get the payment transaction by PAYID and Operation
114
  *
115
  * @param Mage_Sales_Model_Order $order
116
+ * @param int $payId
117
+ * @param string $operation
118
  *
119
  * @return Mage_Sales_Model_Order_Payment_Transaction
120
+ *
121
+ * @throws Mage_Core_Exception
122
  */
123
+ public function getPaymentTransaction($order, $payId, $operation)
124
  {
125
  $helper = Mage::helper('ops');
126
  $transactionCollection = Mage::getModel('sales/order_payment_transaction')
128
  ->addAttributeToFilter('txn_type', $operation)
129
  ->addAttributeToFilter('is_closed', 0)
130
  ->addAttributeToFilter('order_id', $order->getId());
131
+ if ($payId != '') {
132
+ $transactionCollection->addAttributeToFilter('parent_txn_id', $payId);
133
  }
134
 
135
  if ($transactionCollection->count()>1 || $transactionCollection->count() == 0) {
136
  $errorMsq = $helper->__(
137
+ "Warning, transaction count is %s instead of 1 for the Payid '%s', order '%s' and Operation '%s'.",
138
  $transactionCollection->count(),
139
+ $payId,
140
  $order->getId(),
141
  $operation
142
  );
235
 
236
  if ($this->getTypeForStatus($opsRequestParams['STATUS']) == Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE) {
237
  if (is_null($requestedAmount)) {
238
+ Mage::helper('ops')->log('Please configure Ingenico ePayments to submit amount');
239
  return false;
240
  }
241
  $grandTotal = $this->formatAmount(Mage::helper('ops/payment')->getBaseGrandTotalFromSalesObject($order));
250
  return true;
251
  }
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  public function performDirectLinkRequest($quote, $params, $storeId = null)
254
  {
255
  $url = Mage::getModel('ops/config')->getDirectLinkGatewayOrderPath($storeId);
261
  && Mage::helper('ops/payment')->isPaymentFailed($response['STATUS'])
262
  ) {
263
  Mage::getSingleton('checkout/type_onepage')->getCheckout()->setGotoSection('payment');
264
+ throw new Mage_Core_Exception(Mage::helper('ops/data')->__('Ingenico ePayments Payment failed'));
265
  }
266
  return $response;
267
  }
app/code/community/Netresearch/OPS/Helper/Order.php CHANGED
@@ -38,26 +38,6 @@ class Netresearch_OPS_Helper_Order extends Mage_Core_Helper_Abstract
38
  return $this->dataHelper;
39
  }
40
 
41
- /**
42
- * @param null $statusMappingModel
43
- */
44
- public function setStatusMappingModel(Netresearch_OPS_Model_Status_Mapping $statusMappingModel)
45
- {
46
- $this->statusMappingModel = $statusMappingModel;
47
- }
48
-
49
- /**
50
- * @return null
51
- */
52
- public function getStatusMappingModel()
53
- {
54
- if (null == $this->statusMappingModel) {
55
- $this->statusMappingModel = Mage::getModel('ops/status_mapping');
56
- }
57
-
58
- return $this->statusMappingModel;
59
- }
60
-
61
  protected $dataHelper = null;
62
 
63
 
@@ -78,21 +58,34 @@ class Netresearch_OPS_Helper_Order extends Mage_Core_Helper_Abstract
78
  /**
79
  * generates the OPS order id in dependency to the config
80
  *
81
- * @param Mage_Sales_Order $order
82
- * @param $useOrderIdIfPossible if false forces the usage of quoteid (for Kwixo pm etc.)
83
  *
84
  * @return string
85
  */
86
- public function getOpsOrderId($order, $useOrderIdIfPossible = true)
87
  {
88
- $config = $this->getConfig();
89
  $devPrefix = $config->getConfigData('devprefix');
90
- $orderRef = $order->getQuoteId();
91
- if ($config->getOrderReference($order->getStoreId())
 
 
 
 
 
 
 
92
  == Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID
93
  && $useOrderIdIfPossible === true
94
  ) {
95
- $orderRef = self::DELIMITER . $order->getIncrementId();
 
 
 
 
 
 
96
  }
97
 
98
  return $devPrefix . $orderRef;
@@ -108,17 +101,19 @@ class Netresearch_OPS_Helper_Order extends Mage_Core_Helper_Abstract
108
  */
109
  public function getOrder($opsOrderId)
110
  {
111
- $order = null;
112
  $fieldToFilter = 'quote_id';
113
- $devPrefix = $this->getConfig()->getConfigData('devprefix');
114
  if ($devPrefix == substr($opsOrderId, 0, strlen($devPrefix))) {
115
  $opsOrderId = substr($opsOrderId, strlen($devPrefix));
116
  }
117
  // opsOrderId was created from order increment id, use increment id for filtering
118
  if (0 === strpos($opsOrderId, self::DELIMITER)) {
119
- $opsOrderId = substr($opsOrderId, strlen(self::DELIMITER));
120
  $fieldToFilter = 'increment_id';
121
  }
 
 
122
  /* @var $order Mage_Sales_Model_Resource_Order_Collection */
123
  $order = Mage::getModel('sales/order')->getCollection()
124
  ->addFieldToFilter($fieldToFilter, $opsOrderId)
@@ -152,8 +147,8 @@ class Netresearch_OPS_Helper_Order extends Mage_Core_Helper_Abstract
152
  */
153
  public function checkIfAddressesAreSame(Mage_Sales_Model_Order $order)
154
  {
155
- $addMatch = 0;
156
- $billingAddressHash = null;
157
  $shippingAddressHash = null;
158
  if ($order->getBillingAddress() instanceof Mage_Customer_Model_Address_Abstract) {
159
  $billingAddressHash = Mage::helper('ops/alias')->generateAddressHash(
@@ -173,26 +168,4 @@ class Netresearch_OPS_Helper_Order extends Mage_Core_Helper_Abstract
173
  return $addMatch;
174
  }
175
 
176
- /**
177
- * checks if the order's state is valid for the according Ingenico Payment Services's status. If not the order's state is reset
178
- * to it's previous state
179
- *
180
- * @param Mage_Sales_Model_Order $order
181
- *
182
- * @return $this
183
- */
184
- public function checkForOpsStateOnStatusUpdate(Mage_Sales_Model_Order $order)
185
- {
186
- $opsStatus = $order->getPayment()->getAdditionalInformation('status');
187
- $opsOrderStates = $this->getStatusMappingModel()->getStatusForOpsStatus($opsStatus);
188
- $origData = $order->getOrigData();
189
- if (0 < count($opsOrderStates) && !in_array($order->getStatus(), $opsOrderStates)) {
190
- $comment = $this->getDataHelper()->__(
191
- 'revert state update to it\'s original one because of Ingenico Payment Services\'s state restriction'
192
- );
193
- $order->addStatusHistoryComment($comment, $origData['status']);
194
- }
195
-
196
- return $this;
197
- }
198
  }
38
  return $this->dataHelper;
39
  }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  protected $dataHelper = null;
42
 
43
 
58
  /**
59
  * generates the OPS order id in dependency to the config
60
  *
61
+ * @param mixed $salesObject
62
+ * @param bool $useOrderIdIfPossible if false forces the usage of quoteid (for Kwixo pm etc.)
63
  *
64
  * @return string
65
  */
66
+ public function getOpsOrderId($salesObject, $useOrderIdIfPossible = true)
67
  {
68
+ $config = $this->getConfig();
69
  $devPrefix = $config->getConfigData('devprefix');
70
+ if ($salesObject instanceof Mage_Sales_Model_Order) {
71
+ /** @var $salesObject Mage_Sales_Model_Order */
72
+ $orderRef = $salesObject->getQuoteId();
73
+ } elseif ($salesObject instanceof Mage_Sales_Model_Quote) {
74
+ /** @var $salesObject Mage_Sales_Model_Quote */
75
+ $orderRef = $salesObject->getId();
76
+ }
77
+
78
+ if ($config->getOrderReference($salesObject->getStoreId())
79
  == Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID
80
  && $useOrderIdIfPossible === true
81
  ) {
82
+ if ($salesObject instanceof Mage_Sales_Model_Quote) {
83
+ $salesObject->reserveOrderId();
84
+ $orderRef = self::DELIMITER . $salesObject->getReservedOrderId();
85
+ } elseif ($salesObject instanceof Mage_Sales_Model_Order) {
86
+ $orderRef = self::DELIMITER . $salesObject->getIncrementId();
87
+ }
88
+
89
  }
90
 
91
  return $devPrefix . $orderRef;
101
  */
102
  public function getOrder($opsOrderId)
103
  {
104
+ $order = null;
105
  $fieldToFilter = 'quote_id';
106
+ $devPrefix = $this->getConfig()->getConfigData('devprefix');
107
  if ($devPrefix == substr($opsOrderId, 0, strlen($devPrefix))) {
108
  $opsOrderId = substr($opsOrderId, strlen($devPrefix));
109
  }
110
  // opsOrderId was created from order increment id, use increment id for filtering
111
  if (0 === strpos($opsOrderId, self::DELIMITER)) {
112
+ $opsOrderId = substr($opsOrderId, strlen(self::DELIMITER));
113
  $fieldToFilter = 'increment_id';
114
  }
115
+
116
+
117
  /* @var $order Mage_Sales_Model_Resource_Order_Collection */
118
  $order = Mage::getModel('sales/order')->getCollection()
119
  ->addFieldToFilter($fieldToFilter, $opsOrderId)
147
  */
148
  public function checkIfAddressesAreSame(Mage_Sales_Model_Order $order)
149
  {
150
+ $addMatch = 0;
151
+ $billingAddressHash = null;
152
  $shippingAddressHash = null;
153
  if ($order->getBillingAddress() instanceof Mage_Customer_Model_Address_Abstract) {
154
  $billingAddressHash = Mage::helper('ops/alias')->generateAddressHash(
168
  return $addMatch;
169
  }
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
app/code/community/Netresearch/OPS/Helper/Order/Capture.php CHANGED
@@ -46,111 +46,6 @@ class Netresearch_OPS_Helper_Order_Capture extends Netresearch_OPS_Helper_Order_
46
  return $arrInfo;
47
  }
48
 
49
- /**
50
- * Creates the Invoice for the appropriate capture
51
- *
52
- *
53
- * @param array $params
54
- */
55
- public function acceptCapture($order, $params)
56
- {
57
- $arrInfo = array();
58
- Mage::register('ops_auto_capture', true);
59
- $forceFullInvoice = false;
60
- $payId = $params['PAYID'];
61
- try {
62
- if ($payId) {
63
- $transaction = Mage::helper("ops/directlink")->getPaymentTransaction(
64
- $order,
65
- $payId,
66
- Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE
67
- );
68
- if ($transaction) {
69
- $arrInfoSerialized = $transaction->getAdditionalInformation();
70
- $arrInfo = unserialize($arrInfoSerialized['arrInfo']);
71
- if (array_key_exists('type', $arrInfo) && $arrInfo['type'] == 'full') {
72
- $forceFullInvoice = true;
73
- }
74
- }
75
- }
76
- } catch (Mage_Core_Exception $e) {
77
- //If no transaction was found create a full invoice if possible
78
- $forceFullInvoice = true;
79
- $transaction = null;
80
- }
81
-
82
- if ($forceFullInvoice === true) {
83
- if (!$order->getInvoiceCollection()->getSize()) {
84
- $invoice = $order->prepareInvoice();
85
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
86
- $comment = Mage::helper("ops")->__("Capture process complete");
87
- } else {
88
- Mage::throwException(
89
- Mage::helper('ops')->__('The capture has already been invoiced.')
90
- );
91
- }
92
- } else {
93
- $invoice = Mage::getModel('sales/service_order', $order)
94
- ->prepareInvoice($arrInfo['items']);
95
- if (!$invoice->getTotalQty()) {
96
- Mage::throwException(
97
- Mage::helper('ops')->__('Cannot create an invoice without products.')
98
- );
99
- }
100
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
101
- $comment = Mage::helper("ops")->__("Capture process complete");
102
- }
103
-
104
- if (is_object($invoice)) {
105
- $invoice->register();
106
- $transactionSave = Mage::getModel('core/resource_transaction')
107
- ->addObject($invoice)
108
- ->addObject($invoice->getOrder());
109
- $shipment = false;
110
- if (isset($transaction)
111
- && array_key_exists('do_shipment', $arrInfo)
112
- && $arrInfo['do_shipment']
113
- ) {
114
- $shipment = $this->_prepareShipment($invoice, $arrInfo);
115
- if ($shipment) {
116
- $shipment->setEmailSent($invoice->getEmailSent());
117
- $transactionSave->addObject($shipment);
118
- }
119
- }
120
-
121
- $transactionSave->save();
122
-
123
- //Send E-Mail and Comment
124
- $sendEMail = false;
125
- $sendEMailWithComment = false;
126
- if (isset($arrInfo['send_email'])) $sendEMail = true;
127
- if (isset($arrInfo['comment_customer_notify'])) $sendEMailWithComment = true;
128
- $comment = array_key_exists('comment_text', $arrInfo) ? $arrInfo['comment_text'] : '';
129
-
130
- $invoice->addComment($comment, $sendEMailWithComment);
131
- if ($sendEMail) {
132
- $invoice->sendEmail(true, $comment);
133
- $invoice->setEmailSent(true);
134
- }
135
-
136
- Mage::helper("ops/directlink")->closePaymentTransaction(
137
- $order,
138
- $params,
139
- Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE,
140
- Mage::helper('ops')->__(
141
- 'Invoice "%s" was created automatically. Ingenico Payment Services Status: %s.',
142
- $invoice->getIncrementId(),
143
- Mage::helper('ops')->getStatusText($params['STATUS'])
144
- ),
145
- $sendEMail
146
- );
147
- Mage::helper('ops')->log(sprintf("Invoice created for order: %s", $order->getIncrementId()));
148
- }
149
- $order->save();
150
- $eventData = array('data_object' => $order, 'order' => $order);
151
- Mage::dispatchEvent('ops_sales_order_save_commit_after', $eventData);
152
- }
153
-
154
  /**
155
  * Prepare shipment
156
  *
46
  return $arrInfo;
47
  }
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  /**
50
  * Prepare shipment
51
  *
app/code/community/Netresearch/OPS/Helper/Order/Refund.php CHANGED
@@ -117,189 +117,22 @@ class Netresearch_OPS_Helper_Order_Refund extends Netresearch_OPS_Helper_Order_A
117
  return $arrInfo;
118
  }
119
 
120
-
121
- /**
122
- * Create a new payment transaction for the refund
123
- *
124
- * @param array $response
125
- * @param int $closed
126
- *
127
- * @return void
128
- */
129
- public function createRefundTransaction($response, $closed = 0)
130
- {
131
- $transactionParams = array(
132
- 'creditmemo_request' => $this->getCreditMemoRequestParams(),
133
- 'response' => $response,
134
- 'amount' => $this->amount
135
- );
136
-
137
- Mage::helper('ops/directlink')->directLinkTransact(
138
- Mage::getModel('sales/order')->load($this->payment->getOrder()->getId()),
139
- $response['PAYID'],
140
- $response['PAYIDSUB'],
141
- $transactionParams,
142
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE,
143
- Mage::helper('ops')->__('Start Ingenico Payment Services refund request'),
144
- $closed
145
- );
146
-
147
- $order = Mage::getModel('sales/order')->load($this->payment->getOrder()->getId());
148
- $order->addStatusHistoryComment(
149
- Mage::helper('ops')->__(
150
- 'Creditmemo will be created automatically as soon as Ingenico Payment Services sends an acknowledgement. Ingenico Payment Services Status: %s.',
151
- Mage::helper('ops')->getStatusText($response['STATUS'])
152
- )
153
- );
154
- $order->save();
155
- }
156
-
157
  /**
158
- * Create a new refund
159
  *
160
- * @param Mage_Sales_Model_Order $order
161
- * @param array $params
162
- * @param bool $setPaymentRefundDisallowed
163
  *
 
164
  */
165
- public function createRefund(Mage_Sales_Model_Order $order, $params, $setPaymentRefundDisallowed = true)
166
- {
167
- $transactionParams = array();
168
- try {
169
- $refundTransaction = Mage::helper('ops/directlink')->getPaymentTransaction(
170
- $order,
171
- $params['PAYID'],
172
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE
173
- );
174
- $transactionParams = $refundTransaction->getAdditionalInformation();
175
- } catch (Mage_Core_Exception $e) {
176
-
177
- }
178
- try {
179
-
180
- if (array_key_exists('arrInfo', $transactionParams)) {
181
- $transactionParams = unserialize($transactionParams['arrInfo']);
182
- $invoice = Mage::getModel('sales/order_invoice')
183
- ->load($transactionParams['creditmemo_request']['invoice_id'])
184
- ->setOrder($order);
185
- } elseif ($order->getInvoiceCollection()->count() === 1) {
186
- $invoice = $order->getInvoiceCollection()->getFirstItem();
187
- }
188
- //Start to create the creditmemo
189
- Mage::register('ops_auto_creditmemo', true);
190
- $service = Mage::getModel('sales/service_order', $order);
191
-
192
- $data = $this->prepareCreditMemoData($transactionParams);
193
- $creditmemo = $service->prepareInvoiceCreditmemo($invoice, $data);
194
-
195
- /**
196
- * Process back to stock flags
197
- */
198
- $backToStock = array();
199
- if (array_key_exists('backToStock', $data)) {
200
- $backToStock = $data['backToStock'];
201
- }
202
- foreach ($creditmemo->getAllItems() as $creditmemoItem) {
203
- $orderItem = $creditmemoItem->getOrderItem();
204
- $parentId = $orderItem->getParentItemId();
205
- if (isset($backToStock[$orderItem->getId()])) {
206
- $creditmemoItem->setBackToStock(true);
207
- } elseif ($orderItem->getParentItem() && isset($backToStock[$parentId]) && $backToStock[$parentId]) {
208
- $creditmemoItem->setBackToStock(true);
209
- } elseif (empty($savedData)) {
210
- $creditmemoItem->setBackToStock(Mage::helper('cataloginventory')->isAutoReturnEnabled());
211
- } else {
212
- $creditmemoItem->setBackToStock(false);
213
- }
214
- }
215
-
216
- //Send E-Mail and Comment
217
- $comment = '';
218
- $sendEmail = false;
219
- $sendEMailWithComment = false;
220
- if (isset($data['send_email']) && $data['send_email'] == 1) {
221
- $sendEmail = true;
222
- }
223
- if (isset($data['comment_customer_notify'])) {
224
- $sendEMailWithComment = true;
225
- }
226
-
227
- if (!empty($data['comment_text'])):
228
- $creditmemo->addComment($data['comment_text'], $sendEMailWithComment);
229
- if ($sendEMailWithComment):
230
- $comment = $data['comment_text'];
231
- endif;
232
- endif;
233
-
234
- $creditmemo->setPaymentRefundDisallowed($setPaymentRefundDisallowed);
235
- $creditmemo->setRefundRequested(true);
236
- $creditmemo->setOfflineRequested(false);
237
- $creditmemo->register();
238
- if ($sendEmail):
239
- $creditmemo->setEmailSent(true);
240
- endif;
241
- $creditmemo->getOrder()->setCustomerNoteNotify($sendEMailWithComment);
242
-
243
- $transactionSave = Mage::getModel('core/resource_transaction')
244
- ->addObject($creditmemo)
245
- ->addObject($creditmemo->getOrder());
246
- if ($creditmemo->getInvoice()):
247
- $transactionSave->addObject($creditmemo->getInvoice());
248
- endif;
249
- $transactionSave->save();
250
- $creditmemo->sendEmail($sendEmail, $comment);
251
-
252
-
253
- //End of create creditmemo
254
-
255
- //close refund payment transaction
256
- Mage::helper('ops/directlink')->closePaymentTransaction(
257
- $order,
258
- $params,
259
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE,
260
- Mage::helper('ops')->__(
261
- 'Creditmemo "%s" was created automatically. Ingenico Payment Services Status: %s.',
262
- $creditmemo->getIncrementId(),
263
- Mage::helper('ops')->getStatusText($params['STATUS'])
264
- ),
265
- $sendEmail
266
- );
267
- Mage::helper('ops/payment')->setCanRefundToPayment($order->getPayment());
268
- } catch (Exception $e) {
269
- Mage::logException($e);
270
- Mage::throwException('Error in Creditmemo creation process: ' . $e->getMessage());
271
- }
272
-
273
- }
274
-
275
- /**
276
- * Get requested items qtys
277
- */
278
- protected function prepareCreditMemoData($transactionParams)
279
- {
280
- if (!array_key_exists('creditmemo_request', $transactionParams)
281
- || !array_key_exists('creditmemo', $transactionParams['creditmemo_request'])
282
- ) {
283
- return array();
284
- }
285
- $data = $transactionParams['creditmemo_request']['creditmemo'];
286
- $qtys = array();
287
- $backToStock = array();
288
-
289
- if (array_key_exists('items', $data)) {
290
- foreach ($data['items'] as $orderItemId => $itemData):
291
- if (isset($itemData['qty'])):
292
- $qtys[$orderItemId] = $itemData['qty'];
293
- else:
294
- if (isset($itemData['back_to_stock'])):
295
- $backToStock[$orderItemId] = true;
296
- endif;
297
- endif;
298
- endforeach;
299
- }
300
- $data['qtys'] = $qtys;
301
- $data['backToStock'] = $backToStock;
302
-
303
- return $data;
304
  }
305
  }
117
  return $arrInfo;
118
  }
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  /**
121
+ * Checks for open refund transaction
122
  *
123
+ * @param Mage_Sales_Model_Order_Payment $payment
 
 
124
  *
125
+ * @return Mage_Sales_Model_Order_Payment_Transaction|null
126
  */
127
+ public function getOpenRefundTransaction($payment){
128
+ /** @var Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection $refundTransactions */
129
+ $refundTransactions = Mage::getModel('sales/order_payment_transaction')->getCollection();
130
+ $transaction = $refundTransactions->addPaymentIdFilter($payment->getId())
131
+ ->addTxnTypeFilter(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND)
132
+ ->setOrderFilter($payment->getOrder())
133
+ ->addFieldToFilter('is_closed', 0)
134
+ ->getFirstItem();
135
+
136
+ return $transaction;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
  }
app/code/community/Netresearch/OPS/Helper/Order/Void.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
- /**
3
- * Netresearch_OPS_Helper_Order_Void
4
- *
5
- * @package
6
- * @copyright 2011 Netresearch
7
- * @author André Herrn <andre.herrn@netresearch.de>
8
- * @license OSL 3.0
9
- */
10
- class Netresearch_OPS_Helper_Order_Void extends Mage_Core_Helper_Abstract
11
- {
12
- /**
13
- * Cancels the appropriate order and closes the transaction
14
- *
15
- * @param array $params
16
- */
17
- public function acceptVoid($order, $params)
18
- {
19
- Mage::register('ops_auto_void', true);
20
- $order->cancel();
21
- $order->save();
22
- Mage::helper("ops/directlink")->closePaymentTransaction(
23
- $order,
24
- $params,
25
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE
26
- );
27
- Mage::helper('ops')->log("order voided: ".$params['orderID']);
28
- }
29
-
30
- public function getCapturedAmount($order)
31
- {
32
- $sumAmount = 0;
33
- $transactionCollection = Mage::getModel('sales/order_payment_transaction')
34
- ->getCollection()
35
- ->addAttributeToFilter('txn_type', Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE)
36
- ->addAttributeToFilter('order_id', $order->getId())
37
- ->addAttributeToFilter('is_closed', 1);
38
-
39
- foreach ($transactionCollection as $transaction) {
40
- $arrInfo = null;
41
- $arrInfoRough = $transaction->getAdditionalInformation();
42
- if (isset($arrInfoRough['arrInfo'])) {
43
- $arrInfo = unserialize($arrInfoRough['arrInfo']);
44
- }
45
-
46
- if (isset($arrInfo['amount'])) {
47
- $sumAmount += $arrInfo['amount'];
48
- }
49
- }
50
- return $sumAmount;
51
- }
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Helper/Payment.php CHANGED
@@ -11,7 +11,7 @@
11
  */
12
  class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
13
  {
14
- const HASH_ALGO = 'sha1';
15
 
16
  /**
17
  * Get checkout session namespace
@@ -26,28 +26,42 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
26
  /**
27
  * Get checkout session namespace
28
  *
29
- * @return Mage_Checkout_Model_Session
30
  */
31
  protected function getConfig()
32
  {
33
  return Mage::getSingleton('ops/config');
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Crypt Data by SHA1 ctypting algorithm by secret key
38
  *
39
- * @param array $data
40
  * @param string $key
41
  *
42
- * @return hash
43
  */
44
  public function shaCrypt($data, $key = '')
45
  {
46
  if (is_array($data)) {
47
- return hash(self::HASH_ALGO, implode("", $data));
48
  }
49
  if (is_string($data)) {
50
- return hash(self::HASH_ALGO, $data);
51
  } else {
52
  return "";
53
  }
@@ -56,7 +70,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
56
  /**
57
  * Check hash crypted by SHA1 with existing data
58
  *
59
- * @param array $data
60
  * @param string $hash
61
  * @param string $key
62
  *
@@ -68,8 +82,8 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
68
  $data = implode("", $data);
69
  }
70
 
71
- $hashUtf8 = strtoupper(hash(self::HASH_ALGO, $data));
72
- $hashNonUtf8 = strtoupper(hash(self::HASH_ALGO, utf8_encode($data)));
73
 
74
  $helper = Mage::helper('ops');
75
  $helper->log($helper->__("Module Secureset: %s", $data));
@@ -88,7 +102,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
88
  $helper = Mage::helper('ops');
89
  $helper->log(
90
  $helper->__(
91
- "Checking hashes\nHashed String by Magento: %s\nHashed String by Ingenico Payment Services: %s",
92
  $actual,
93
  $hashFromOPS
94
  )
@@ -106,14 +120,14 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
106
  /**
107
  * Return set of data which is ready for SHA crypt
108
  *
109
- * @param array $data
110
  * @param string $key
111
  *
112
  * @return string
113
  */
114
  public function getSHAInSet($params, $SHAkey)
115
  {
116
- $params = $this->prepareParamsAndSort($params);
117
  $plainHashString = "";
118
  foreach ($params as $paramSet):
119
  if ($paramSet['value'] == '' || $paramSet['key'] == 'SHASIGN') {
@@ -183,7 +197,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
183
  * We get some CC info from ops, so we must save it
184
  *
185
  * @param Mage_Sales_Model_Order $order
186
- * @param array $ccInfo
187
  *
188
  * @return Netresearch_OPS_ApiController
189
  */
@@ -210,14 +224,14 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
210
  {
211
  return in_array(
212
  $status, array(
213
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED,
214
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING,
215
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_UNKNOWN,
216
- Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT,
217
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED,
218
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING,
219
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN,
220
- Netresearch_OPS_Model_Payment_Abstract::OPS_WAITING_FOR_IDENTIFICATION
221
  )
222
  );
223
  }
@@ -226,10 +240,10 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
226
  {
227
  return in_array(
228
  $status, array(
229
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED,
230
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING,
231
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_UNKNOWN,
232
- Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT
233
  )
234
  );
235
  }
@@ -238,9 +252,9 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
238
  {
239
  return in_array(
240
  $status, array(
241
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED,
242
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING,
243
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN
244
  )
245
  );
246
  }
@@ -253,61 +267,46 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
253
  /**
254
  * apply ops state for order
255
  *
256
- * @param Mage_Sales_Model_Order $order Order
257
- * @param array $params Request params
258
  *
259
  * @return void
260
  */
261
  public function applyStateForOrder($order, $params)
262
  {
263
- /**
264
- * OpenInvoiceDe should always have status code 41, which is a final state in this case
265
- */
266
- if ($order->getPayment()->getMethodInstance()->getCode() == 'ops_openInvoiceDe'
267
- && $params['STATUS'] == Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT
268
- ) {
269
- $params['STATUS'] = Netresearch_OPS_Model_Payment_Abstract::OPS_OPEN_INVOICE_DE_PROCESSED;
270
- }
271
 
272
  $feedbackStatus = '';
273
 
274
  switch ($params['STATUS']) {
275
- case Netresearch_OPS_Model_Payment_Abstract::OPS_WAITING_FOR_IDENTIFICATION : //3D-Secure
276
- $this->waitOrder($order, $params);
277
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
278
  break;
279
-
280
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED:
281
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_KWIXO:
282
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING:
283
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_UNKNOWN:
284
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT:
285
- $this->acceptOrder($order, $params);
286
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
287
  break;
288
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED:
289
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING:
290
- case Netresearch_OPS_Model_Payment_Abstract::OPS_OPEN_INVOICE_DE_PROCESSED:
291
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSED_MERCHANT:
292
- $this->acceptOrder($order, $params, 1);
293
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
294
  break;
295
- case Netresearch_OPS_Model_Payment_Abstract::OPS_AUTH_REFUSED:
296
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED:
297
- $this->declineOrder($order, $params);
298
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_DECLINE;
299
  break;
300
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_CANCELED_BY_CUSTOMER:
301
- $this->cancelOrder($order, $params, Mage_Sales_Model_Order::STATE_CANCELED,
302
- Mage::helper('ops')->__(
303
- 'Order canceled on Ingenico Payment Services side. Status: %s, Payment ID: %s.',
304
- Mage::helper('ops')->getStatusText($params['STATUS']),
305
- $params['PAYID']));
306
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_CANCEL;
307
  break;
308
  default:
309
  //all unknown transaction will accept as exceptional
310
- $this->handleException($order, $params);
311
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_EXCEPTION;
312
  }
313
 
@@ -317,8 +316,8 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
317
  /**
318
  * Process success action by accept url
319
  *
320
- * @param Mage_Sales_Model_Order $order Order
321
- * @param array $params Request params
322
  */
323
  public function acceptOrder($order, $params, $instantCapture = 0)
324
  {
@@ -332,11 +331,11 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
332
  }
333
 
334
  try {
335
- if (false === $this->forceAuthorize($order) &&
336
- ($this->getConfig()->getConfigData('payment_action')
337
  == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
338
  || $instantCapture)
339
- && $params['STATUS'] != Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT
340
  ) {
341
  $this->_processDirectSale($order, $params, $instantCapture);
342
  } else {
@@ -352,8 +351,8 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
352
  * Set Payment Transaction Information
353
  *
354
  * @param Mage_Sales_Model_Order_Payment $payment Sales Payment Model
355
- * @param array $params Request params
356
- * @param string $action Action (accept|cancel|decline|wait|exception)
357
  */
358
  protected function setPaymentTransactionInformation(Mage_Sales_Model_Order_Payment $payment, $params, $action)
359
  {
@@ -364,7 +363,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
364
 
365
  /* In authorize mode we still have no authorization transaction for CC and DirectDebit payments,
366
  * so capture or cancel won't work. So we need to create a new authorization transaction for them
367
- * when a payment was accepted by Ingenico Payment Services
368
  *
369
  * In exception-case we create the authorization-transaction too because some exception-cases can turn into accepted
370
  */
@@ -374,13 +373,18 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
374
  $payment->setIsTransactionClosed(false);
375
  $isInline = $this->isInlinePayment($payment);
376
  /* create authorization transaction for non-inline pms */
377
- if (false === $isInline || (array_key_exists('HTML_ANSWER', $params) || 0 < strlen($payment->getAdditionalInformation('HTML_ANSWER')))) {
 
 
 
 
 
378
  $payment->addTransaction("authorization", null, true, $this->__("Process outgoing transaction"));
379
  }
380
  $payment->setLastTransId($params['PAYID']);
381
  }
382
 
383
- /* Ingenico Payment Services sends parameter HTML_ANSWER to trigger 3D secure redirection */
384
  if (isset($params['HTML_ANSWER']) && ('ops_cc' == $code)) {
385
  $payment->setAdditionalInformation('HTML_ANSWER', $params['HTML_ANSWER']);
386
  $payment->setIsTransactionPending(true);
@@ -402,10 +406,10 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
402
  }
403
 
404
  /**
405
- * add fraud detection of Ingenico Payment Services to additional payment data
406
  *
407
  * @param Mage_Sales_Model_Order_Payment $payment
408
- * @param array $params
409
  */
410
  protected function setFraudDetectionParameters($payment, $params)
411
  {
@@ -433,12 +437,16 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
433
  * Process cancel action by cancel url
434
  *
435
  * @param Mage_Sales_Model_Order $order Order
436
- * @param array $params Request params
437
  * @param string $status Order status
438
  * @param string $comment Order comment
 
 
439
  */
440
  public function cancelOrder($order, $params, $status, $comment)
441
  {
 
 
442
  try {
443
  Mage::register('ops_auto_void', true); //Set this session value to true to allow cancel
444
  $this->cancelInvoices($order);
@@ -464,11 +472,13 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
464
  /**
465
  * Process decline action by ops decline url
466
  *
467
- * @param Mage_Sales_Model_Order $order Order
468
- * @param array $params Request params
469
  */
470
  public function declineOrder($order, $params)
471
  {
 
 
472
  try {
473
  Mage::register('ops_auto_void', true); //Set this session value to true to allow cancel
474
  $this->cancelInvoices($order);
@@ -477,7 +487,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
477
  Mage_Sales_Model_Order::STATE_CANCELED,
478
  Mage_Sales_Model_Order::STATE_CANCELED,
479
  Mage::helper('ops')->__(
480
- 'Order declined on ops side. Ingenico Payment Services status: %s, Payment ID: %s.',
481
  Mage::helper('ops')->getStatusText($params['STATUS']),
482
  $params['PAYID']
483
  )
@@ -494,17 +504,19 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
494
  /**
495
  * Wait for 3D secure confirmation
496
  *
497
- * @param Mage_Sales_Model_Order $order Order
498
- * @param array $params Request params
499
  */
500
  public function waitOrder($order, $params)
501
  {
 
 
502
  try {
503
  $order->setState(
504
  Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
505
  Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
506
  Mage::helper('ops')->__(
507
- 'Order is waiting for Ingenico Payment Services confirmation of 3D-Secure. Ingenico Payment Services status: %s, Payment ID: %s.',
508
  Mage::helper('ops')->getStatusText($params['STATUS']),
509
  $params['PAYID']
510
  )
@@ -513,7 +525,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
513
  $this->setPaymentTransactionInformation($order->getPayment(), $params, 'wait');
514
  } catch (Exception $e) {
515
  $this->_getCheckout()->addError(
516
- Mage::helper('ops')->__('Error during 3D-Secure processing of Ingenico Payment Services. Error: %s', $e->getMessage())
517
  );
518
  throw $e;
519
  }
@@ -522,11 +534,12 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
522
  /**
523
  * Process exception action by ops exception url
524
  *
525
- * @param Mage_Sales_Model_Order $order Order
526
- * @param array $params Request params
527
  */
528
  public function handleException($order, $params)
529
  {
 
530
  $exceptionMessage = $this->getPaymentExceptionMessage($params['STATUS']);
531
 
532
  if (!empty($exceptionMessage)) {
@@ -561,15 +574,15 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
561
  {
562
  $exceptionMessage = '';
563
  switch ($ops_status) {
564
- case Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN :
565
  $exceptionMessage = Mage::helper('ops')->__(
566
- 'A technical problem arose during payment process, giving unpredictable result. Ingenico Payment Services status: %s.',
567
  Mage::helper('ops')->getStatusText($ops_status)
568
  );
569
  break;
570
  default:
571
  $exceptionMessage = Mage::helper('ops')->__(
572
- 'An unknown exception was thrown in the payment process. Ingenico Payment Services status: %s.',
573
  Mage::helper('ops')->getStatusText($ops_status)
574
  );
575
  }
@@ -580,14 +593,16 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
580
  /**
581
  * Process Configured Payment Action: Direct Sale, create invoice if state is Pending
582
  *
583
- * @param Mage_Sales_Model_Order $order Order
584
- * @param array $params Request params
585
  */
586
  protected function _processDirectSale($order, $params, $instantCapture = 0)
587
  {
 
 
588
  Mage::register('ops_auto_capture', true);
589
  $status = $params['STATUS'];
590
- if ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT) {
591
  $order->setState(
592
  Mage_Sales_Model_Order::STATE_PROCESSING,
593
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
@@ -602,23 +617,23 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
602
  }
603
 
604
  $order->save();
605
- } elseif ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING) {
606
  $order->setState(
607
  Mage_Sales_Model_Order::STATE_PROCESSING,
608
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
609
- Mage::helper('ops')->__('Authorization waiting from Ingenico Payment Services')
610
  );
611
  $order->save();
612
  } elseif (($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
613
- || $instantCapture)
614
  && !$this->isPaypalSpecialStatus($order->getPayment()->getMethodInstance(), $status)
615
  ) {
616
- if ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED) {
617
  if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
618
  $order->setState(
619
  Mage_Sales_Model_Order::STATE_PROCESSING,
620
  Mage_Sales_Model_Order::STATE_PROCESSING,
621
- Mage::helper('ops')->__('Processed by Ingenico Payment Services')
622
  );
623
 
624
  }
@@ -626,7 +641,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
626
  $order->setState(
627
  Mage_Sales_Model_Order::STATE_PROCESSING,
628
  true,
629
- Mage::helper('ops')->__('Processed by Ingenico Payment Services')
630
  );
631
  $order->save();
632
  }
@@ -643,9 +658,9 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
643
  $this->sendInvoiceToCustomer($invoice);
644
 
645
  $transactionSave = Mage::getModel('core/resource_transaction')
646
- ->addObject($invoice)
647
- ->addObject($invoice->getOrder())
648
- ->save();
649
 
650
  /*
651
  * If the payment method is a redirect-payment-method send the email
@@ -662,20 +677,27 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
662
 
663
  if ($this->isInlinePayment($order->getPayment())
664
  && 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER')))
665
- && $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED
666
  ) {
667
- $order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true)->save();
 
 
668
  $this->setInvoicesToPaid($order);
669
  $order->getPayment()->getAuthorizationTransaction()->setIsClosed(true)->save();
670
- $order->getPayment()->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $order->getPayment())->setIsClosed(true)->save();
 
 
671
 
672
- if($order->getEmailSent() != 1) {
673
  $order->sendNewOrderEmail();
674
  }
675
 
676
  $order->save();
677
  }
678
- if ($this->isInlinePayment($order->getPayment()) && Mage::getModel('ops/config')->getSendInvoice() && Mage::getModel('ops/config')->getPaymentAction($order->getStoreId()) === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
 
 
 
679
  foreach ($order->getInvoiceCollection() as $invoice) {
680
  $this->sendInvoiceToCustomer($invoice);
681
  }
@@ -705,18 +727,18 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
705
  * Process Configured Payment Actions: Authorized, Default operation
706
  * just place order
707
  *
708
- * @param Mage_Sales_Model_Order $order Order
709
- * @param array $params Request params
710
  */
711
  protected function _processAuthorize($order, $params)
712
  {
713
  $status = $params['STATUS'];
714
- if ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT) {
715
  $order->setState(
716
  Mage_Sales_Model_Order::STATE_PROCESSING,
717
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
718
  Mage::helper('ops')->__(
719
- 'Waiting for payment. Ingenico Payment Services status: %s.', Mage::helper('ops')->getStatusText($status)
720
  )
721
  );
722
 
@@ -726,22 +748,24 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
726
  ) {
727
  $order->sendNewOrderEmail();
728
  }
729
- } elseif ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING) {
730
  $order->setState(
731
  Mage_Sales_Model_Order::STATE_PROCESSING,
732
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
733
  Mage::helper('ops')->__(
734
- 'Authorization uncertain. Ingenico Payment Services status: %s.', Mage::helper('ops')->getStatusText($status)
735
  )
736
  );
737
  } else {
738
  // for 3DS payments the order has to be retrieved from the payment review step
739
  if ($this->isInlinePayment($order->getPayment())
740
  && 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER')))
741
- && $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED
742
  ) {
743
-
744
- $order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true)->save();
 
 
745
  }
746
  if ($this->isRedirectPaymentMethod($order) === true
747
  && $order->getEmailSent() != 1
@@ -749,14 +773,14 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
749
  $order->sendNewOrderEmail();
750
  }
751
 
752
- if(!$this->isPaypalSpecialStatus($order->getPayment()->getMethodInstance(), $status)) {
753
 
754
  $payId = $params['PAYID'];
755
  $order->setState(
756
  Mage_Sales_Model_Order::STATE_PROCESSING,
757
  Mage_Sales_Model_Order::STATE_PROCESSING,
758
  Mage::helper('ops')->__(
759
- 'Processed by Ingenico Payment Services. Payment ID: %s. Ingenico Payment Services status: %s.', $payId,
760
  Mage::helper('ops')->getStatusText($status)
761
  )
762
  );
@@ -776,7 +800,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
776
  protected function isPaypalSpecialStatus($pm, $status)
777
  {
778
  return $pm instanceof Netresearch_OPS_Model_Payment_Paypal
779
- && $status == Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING;
780
  }
781
 
782
  /**
@@ -792,9 +816,9 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
792
  return;
793
  }
794
  $transaction = Mage::getModel('sales/order_payment_transaction')
795
- ->getCollection()
796
- ->addAttributeToFilter('txn_id', $transactionId)
797
- ->getLastItem();
798
  if (is_null($transaction->getId())) {
799
  return false;
800
  }
@@ -829,7 +853,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
829
  $cart->save();
830
 
831
  // add coupon code
832
- $coupon = $order->getCouponCode();
833
  $session = Mage::getSingleton('checkout/session');
834
  if (false == is_null($coupon)) {
835
  $session->getQuote()->setCouponCode($coupon)->save();
@@ -840,7 +864,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
840
  * Save OPS Status to Payment
841
  *
842
  * @param Mage_Sales_Model_Order_Payment $payment
843
- * @param array $params OPS-Response
844
  *
845
  * @return void
846
  */
@@ -884,7 +908,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
884
  {
885
  if ($order instanceof Mage_Sales_Model_Order) {
886
  $message = Mage::helper('ops')->__(
887
- 'Unknown Ingenico Payment Services state for this order. Please check Ingenico Payment Services backend for this order.'
888
  );
889
  if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
890
  $order->setState(
@@ -921,7 +945,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
921
  * Save the last used refund operation code to payment
922
  *
923
  * @param Mage_Sales_Model_Order_Payment $payment
924
- * @param string $operationCode
925
  *
926
  * @return void
927
  */
@@ -932,12 +956,14 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
932
  array(
933
  Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
934
  Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL
935
- ))
 
936
  ) {
937
  Mage::helper('ops/data')->log(
938
- sprintf("set last refund operation '%s' code to payment for order '%s'",
939
- $operationCode,
940
- $payment->getOrder()->getIncrementId()
 
941
  )
942
  );
943
  $payment
@@ -959,7 +985,8 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
959
  array(
960
  Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
961
  Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL
962
- ))
 
963
  ) {
964
  /*
965
  * a further refund is possible if the transaction remains open, that means either the merchant
@@ -967,9 +994,10 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
967
  */
968
  $canRefund = ($refundOperationCode == Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL);
969
  Mage::helper('ops/data')->log(
970
- sprintf("set canRefund to '%s' for payment of order '%s'",
971
- var_export($canRefund, true),
972
- $payment->getOrder()->getIncrementId()
 
973
  )
974
  );
975
  $payment
@@ -980,7 +1008,9 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
980
 
981
  /**
982
  * determine whether the payment supports only authorize or not
 
983
  * @param Mage_Sales_Model_Order $order
 
984
  * @return true . if so, false otherwise
985
  */
986
  protected function forceAuthorize(Mage_Sales_Model_Order $order)
@@ -1041,7 +1071,7 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
1041
  */
1042
  public function isInlinePaymentWithOrderId(Mage_Payment_Model_Info $payment)
1043
  {
1044
- return $this->isInlinePayment($payment) && (0 < strlen(trim($payment->getMethodInstance()->getConfigPaymentAction())));
1045
  }
1046
 
1047
  /**
@@ -1053,11 +1083,12 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
1053
  */
1054
  public function isInlinePayment(Mage_Payment_Model_Info $payment)
1055
  {
1056
- $result = false;
1057
  $methodInstance = $payment->getMethodInstance();
1058
  if ($methodInstance instanceof Netresearch_OPS_Model_Payment_DirectDebit
1059
  || ($methodInstance instanceof Netresearch_OPS_Model_Payment_Cc
1060
- && ($methodInstance->hasBrandAliasInterfaceSupport($payment) || Mage::helper('ops/data')->isAdminSession()))
 
1061
  ) {
1062
  $result = true;
1063
  }
@@ -1074,13 +1105,17 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
1074
  */
1075
  public function isInlinePaymentWithQuoteId(Mage_Payment_Model_Info $payment)
1076
  {
1077
- return $this->isInlinePayment($payment) && (0 === strlen(trim($payment->getMethodInstance()->getConfigPaymentAction())));
 
 
 
1078
  }
1079
 
1080
  /**
1081
  * sets the invoices of an order to paid
1082
  *
1083
  * @param Mage_Sales_Model_Order $order
 
1084
  * @return Netresearch_OPS_Helper_Payment
1085
  */
1086
  public function setInvoicesToPaid($order)
@@ -1116,11 +1151,12 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
1116
 
1117
  /**
1118
  * Returns if the current payment status is an invalid one, namely if it is one of the following:
1119
- * Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID,
1120
- * Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_CANCELED_BY_CUSTOMER,
1121
- * Netresearch_OPS_Model_Payment_Abstract::OPS_AUTH_REFUSED,
1122
  *
1123
  * @param $status
 
1124
  * @return bool
1125
  */
1126
  public function isPaymentInvalid($status)
@@ -1128,9 +1164,9 @@ class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
1128
  return in_array(
1129
  $status,
1130
  array(
1131
- Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID,
1132
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_CANCELED_BY_CUSTOMER,
1133
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTH_REFUSED,
1134
  )
1135
  );
1136
  }
11
  */
12
  class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
13
  {
14
+ protected $shaAlgorithm = null;
15
 
16
  /**
17
  * Get checkout session namespace
26
  /**
27
  * Get checkout session namespace
28
  *
29
+ * @return Netresearch_OPS_Model_Config
30
  */
31
  protected function getConfig()
32
  {
33
  return Mage::getSingleton('ops/config');
34
  }
35
 
36
+ /**
37
+ * Get encrypt / decrypt algorithm
38
+ *
39
+ * @return string
40
+ */
41
+ public function getCryptMethod()
42
+ {
43
+ if (null === $this->shaAlgorithm) {
44
+ $this->shaAlgorithm = $this->getConfig()->getConfigData('secret_key_type');
45
+ }
46
+
47
+ return $this->shaAlgorithm;
48
+ }
49
+
50
  /**
51
  * Crypt Data by SHA1 ctypting algorithm by secret key
52
  *
53
+ * @param array $data
54
  * @param string $key
55
  *
56
+ * @return string hash
57
  */
58
  public function shaCrypt($data, $key = '')
59
  {
60
  if (is_array($data)) {
61
+ return hash($this->getCryptMethod(), implode("", $data));
62
  }
63
  if (is_string($data)) {
64
+ return hash($this->getCryptMethod(), $data);
65
  } else {
66
  return "";
67
  }
70
  /**
71
  * Check hash crypted by SHA1 with existing data
72
  *
73
+ * @param array $data
74
  * @param string $hash
75
  * @param string $key
76
  *
82
  $data = implode("", $data);
83
  }
84
 
85
+ $hashUtf8 = strtoupper(hash($this->getCryptMethod(), $data));
86
+ $hashNonUtf8 = strtoupper(hash($this->getCryptMethod(), utf8_encode($data)));
87
 
88
  $helper = Mage::helper('ops');
89
  $helper->log($helper->__("Module Secureset: %s", $data));
102
  $helper = Mage::helper('ops');
103
  $helper->log(
104
  $helper->__(
105
+ "Checking hashes\nHashed String by Magento: %s\nHashed String by Ingenico ePayments: %s",
106
  $actual,
107
  $hashFromOPS
108
  )
120
  /**
121
  * Return set of data which is ready for SHA crypt
122
  *
123
+ * @param array $data
124
  * @param string $key
125
  *
126
  * @return string
127
  */
128
  public function getSHAInSet($params, $SHAkey)
129
  {
130
+ $params = $this->prepareParamsAndSort($params);
131
  $plainHashString = "";
132
  foreach ($params as $paramSet):
133
  if ($paramSet['value'] == '' || $paramSet['key'] == 'SHASIGN') {
197
  * We get some CC info from ops, so we must save it
198
  *
199
  * @param Mage_Sales_Model_Order $order
200
+ * @param array $ccInfo
201
  *
202
  * @return Netresearch_OPS_ApiController
203
  */
224
  {
225
  return in_array(
226
  $status, array(
227
+ Netresearch_OPS_Model_Status::AUTHORIZED,
228
+ Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING,
229
+ Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN,
230
+ Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT,
231
+ Netresearch_OPS_Model_Status::PAYMENT_REQUESTED,
232
+ Netresearch_OPS_Model_Status::PAYMENT_PROCESSING,
233
+ Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN,
234
+ Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION
235
  )
236
  );
237
  }
240
  {
241
  return in_array(
242
  $status, array(
243
+ Netresearch_OPS_Model_Status::AUTHORIZED,
244
+ Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING,
245
+ Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN,
246
+ Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT
247
  )
248
  );
249
  }
252
  {
253
  return in_array(
254
  $status, array(
255
+ Netresearch_OPS_Model_Status::PAYMENT_REQUESTED,
256
+ Netresearch_OPS_Model_Status::PAYMENT_PROCESSING,
257
+ Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN
258
  )
259
  );
260
  }
267
  /**
268
  * apply ops state for order
269
  *
270
+ * @param Mage_Sales_Model_Order $order Order
271
+ * @param array $params Request params
272
  *
273
  * @return void
274
  */
275
  public function applyStateForOrder($order, $params)
276
  {
277
+
278
+ Mage::getModel('ops/response_handler')->processResponse($params, $order->getPayment()->getMethodInstance());
279
+ $order->getPayment()->save();
 
 
 
 
 
280
 
281
  $feedbackStatus = '';
282
 
283
  switch ($params['STATUS']) {
284
+ case Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION : //3D-Secure
 
285
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
286
  break;
287
+ case Netresearch_OPS_Model_Status::AUTHORIZED:
288
+ case Netresearch_OPS_Model_Status::AUTHORIZED_WAITING_EXTERNAL_RESULT:
289
+ case Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING:
290
+ case Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN:
291
+ case Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT:
 
 
292
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
293
  break;
294
+ case Netresearch_OPS_Model_Status::PAYMENT_REQUESTED:
295
+ case Netresearch_OPS_Model_Status::PAYMENT_PROCESSING:
296
+ case Netresearch_OPS_Model_Status::PAYMENT_PROCESSED_BY_MERCHANT:
 
 
297
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
298
  break;
299
+ case Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED:
300
+ case Netresearch_OPS_Model_Status::PAYMENT_REFUSED:
301
+ // $this->declineOrder($order, $params);
302
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_DECLINE;
303
  break;
304
+ case Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER:
 
 
 
 
 
305
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_CANCEL;
306
  break;
307
  default:
308
  //all unknown transaction will accept as exceptional
309
+ // $this->handleException($order, $params);
310
  $feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_EXCEPTION;
311
  }
312
 
316
  /**
317
  * Process success action by accept url
318
  *
319
+ * @param Mage_Sales_Model_Order $order Order
320
+ * @param array $params Request params
321
  */
322
  public function acceptOrder($order, $params, $instantCapture = 0)
323
  {
331
  }
332
 
333
  try {
334
+ if (false === $this->forceAuthorize($order)
335
+ && ($this->getConfig()->getConfigData('payment_action')
336
  == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
337
  || $instantCapture)
338
+ && $params['STATUS'] != Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT
339
  ) {
340
  $this->_processDirectSale($order, $params, $instantCapture);
341
  } else {
351
  * Set Payment Transaction Information
352
  *
353
  * @param Mage_Sales_Model_Order_Payment $payment Sales Payment Model
354
+ * @param array $params Request params
355
+ * @param string $action Action (accept|cancel|decline|wait|exception)
356
  */
357
  protected function setPaymentTransactionInformation(Mage_Sales_Model_Order_Payment $payment, $params, $action)
358
  {
363
 
364
  /* In authorize mode we still have no authorization transaction for CC and DirectDebit payments,
365
  * so capture or cancel won't work. So we need to create a new authorization transaction for them
366
+ * when a payment was accepted by Ingenico ePayments
367
  *
368
  * In exception-case we create the authorization-transaction too because some exception-cases can turn into accepted
369
  */
373
  $payment->setIsTransactionClosed(false);
374
  $isInline = $this->isInlinePayment($payment);
375
  /* create authorization transaction for non-inline pms */
376
+ if (false === $isInline
377
+ || (array_key_exists('HTML_ANSWER', $params)
378
+ || 0 < strlen(
379
+ $payment->getAdditionalInformation('HTML_ANSWER')
380
+ ))
381
+ ) {
382
  $payment->addTransaction("authorization", null, true, $this->__("Process outgoing transaction"));
383
  }
384
  $payment->setLastTransId($params['PAYID']);
385
  }
386
 
387
+ /* Ingenico ePayments sends parameter HTML_ANSWER to trigger 3D secure redirection */
388
  if (isset($params['HTML_ANSWER']) && ('ops_cc' == $code)) {
389
  $payment->setAdditionalInformation('HTML_ANSWER', $params['HTML_ANSWER']);
390
  $payment->setIsTransactionPending(true);
406
  }
407
 
408
  /**
409
+ * add fraud detection of Ingenico ePayments to additional payment data
410
  *
411
  * @param Mage_Sales_Model_Order_Payment $payment
412
+ * @param array $params
413
  */
414
  protected function setFraudDetectionParameters($payment, $params)
415
  {
437
  * Process cancel action by cancel url
438
  *
439
  * @param Mage_Sales_Model_Order $order Order
440
+ * @param string[] $params Request params
441
  * @param string $status Order status
442
  * @param string $comment Order comment
443
+ * @throws Exception
444
+ * @deprecated
445
  */
446
  public function cancelOrder($order, $params, $status, $comment)
447
  {
448
+ //@TODO: remove obsolete function
449
+
450
  try {
451
  Mage::register('ops_auto_void', true); //Set this session value to true to allow cancel
452
  $this->cancelInvoices($order);
472
  /**
473
  * Process decline action by ops decline url
474
  *
475
+ * @param Mage_Sales_Model_Order $order Order
476
+ * @param array $params Request params
477
  */
478
  public function declineOrder($order, $params)
479
  {
480
+ //@TODO: remove obsolete function
481
+
482
  try {
483
  Mage::register('ops_auto_void', true); //Set this session value to true to allow cancel
484
  $this->cancelInvoices($order);
487
  Mage_Sales_Model_Order::STATE_CANCELED,
488
  Mage_Sales_Model_Order::STATE_CANCELED,
489
  Mage::helper('ops')->__(
490
+ 'Order declined on ops side. Ingenico ePayments status: %s, Payment ID: %s.',
491
  Mage::helper('ops')->getStatusText($params['STATUS']),
492
  $params['PAYID']
493
  )
504
  /**
505
  * Wait for 3D secure confirmation
506
  *
507
+ * @param Mage_Sales_Model_Order $order Order
508
+ * @param array $params Request params
509
  */
510
  public function waitOrder($order, $params)
511
  {
512
+
513
+ //@TODO: remove obsolete function
514
  try {
515
  $order->setState(
516
  Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
517
  Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
518
  Mage::helper('ops')->__(
519
+ 'Order is waiting for Ingenico ePayments confirmation of 3D-Secure. Ingenico ePayments status: %s, Payment ID: %s.',
520
  Mage::helper('ops')->getStatusText($params['STATUS']),
521
  $params['PAYID']
522
  )
525
  $this->setPaymentTransactionInformation($order->getPayment(), $params, 'wait');
526
  } catch (Exception $e) {
527
  $this->_getCheckout()->addError(
528
+ Mage::helper('ops')->__('Error during 3D-Secure processing of Ingenico ePayments. Error: %s', $e->getMessage())
529
  );
530
  throw $e;
531
  }
534
  /**
535
  * Process exception action by ops exception url
536
  *
537
+ * @param Mage_Sales_Model_Order $order Order
538
+ * @param array $params Request params
539
  */
540
  public function handleException($order, $params)
541
  {
542
+ //@TODO: remove obsolete function
543
  $exceptionMessage = $this->getPaymentExceptionMessage($params['STATUS']);
544
 
545
  if (!empty($exceptionMessage)) {
574
  {
575
  $exceptionMessage = '';
576
  switch ($ops_status) {
577
+ case Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN :
578
  $exceptionMessage = Mage::helper('ops')->__(
579
+ 'A technical problem arose during payment process, giving unpredictable result. Ingenico ePayments status: %s.',
580
  Mage::helper('ops')->getStatusText($ops_status)
581
  );
582
  break;
583
  default:
584
  $exceptionMessage = Mage::helper('ops')->__(
585
+ 'An unknown exception was thrown in the payment process. Ingenico ePayments status: %s.',
586
  Mage::helper('ops')->getStatusText($ops_status)
587
  );
588
  }
593
  /**
594
  * Process Configured Payment Action: Direct Sale, create invoice if state is Pending
595
  *
596
+ * @param Mage_Sales_Model_Order $order Order
597
+ * @param array $params Request params
598
  */
599
  protected function _processDirectSale($order, $params, $instantCapture = 0)
600
  {
601
+ //@TODO: remove obsolete function
602
+
603
  Mage::register('ops_auto_capture', true);
604
  $status = $params['STATUS'];
605
+ if ($status == Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT) {
606
  $order->setState(
607
  Mage_Sales_Model_Order::STATE_PROCESSING,
608
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
617
  }
618
 
619
  $order->save();
620
+ } elseif ($status == Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING) {
621
  $order->setState(
622
  Mage_Sales_Model_Order::STATE_PROCESSING,
623
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
624
+ Mage::helper('ops')->__('Authorization waiting from Ingenico ePayments')
625
  );
626
  $order->save();
627
  } elseif (($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
628
+ || $instantCapture)
629
  && !$this->isPaypalSpecialStatus($order->getPayment()->getMethodInstance(), $status)
630
  ) {
631
+ if ($status == Netresearch_OPS_Model_Status::AUTHORIZED) {
632
  if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
633
  $order->setState(
634
  Mage_Sales_Model_Order::STATE_PROCESSING,
635
  Mage_Sales_Model_Order::STATE_PROCESSING,
636
+ Mage::helper('ops')->__('Processed by Ingenico ePayments')
637
  );
638
 
639
  }
641
  $order->setState(
642
  Mage_Sales_Model_Order::STATE_PROCESSING,
643
  true,
644
+ Mage::helper('ops')->__('Processed by Ingenico ePayments')
645
  );
646
  $order->save();
647
  }
658
  $this->sendInvoiceToCustomer($invoice);
659
 
660
  $transactionSave = Mage::getModel('core/resource_transaction')
661
+ ->addObject($invoice)
662
+ ->addObject($invoice->getOrder())
663
+ ->save();
664
 
665
  /*
666
  * If the payment method is a redirect-payment-method send the email
677
 
678
  if ($this->isInlinePayment($order->getPayment())
679
  && 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER')))
680
+ && $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Status::PAYMENT_REQUESTED
681
  ) {
682
+ $order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(
683
+ Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true
684
+ )->save();
685
  $this->setInvoicesToPaid($order);
686
  $order->getPayment()->getAuthorizationTransaction()->setIsClosed(true)->save();
687
+ $order->getPayment()->addTransaction(
688
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $order->getPayment()
689
+ )->setIsClosed(true)->save();
690
 
691
+ if ($order->getEmailSent() != 1) {
692
  $order->sendNewOrderEmail();
693
  }
694
 
695
  $order->save();
696
  }
697
+ if ($this->isInlinePayment($order->getPayment()) && Mage::getModel('ops/config')->getSendInvoice()
698
+ && Mage::getModel('ops/config')->getPaymentAction($order->getStoreId())
699
+ === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
700
+ ) {
701
  foreach ($order->getInvoiceCollection() as $invoice) {
702
  $this->sendInvoiceToCustomer($invoice);
703
  }
727
  * Process Configured Payment Actions: Authorized, Default operation
728
  * just place order
729
  *
730
+ * @param Mage_Sales_Model_Order $order Order
731
+ * @param array $params Request params
732
  */
733
  protected function _processAuthorize($order, $params)
734
  {
735
  $status = $params['STATUS'];
736
+ if ($status == Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT) {
737
  $order->setState(
738
  Mage_Sales_Model_Order::STATE_PROCESSING,
739
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
740
  Mage::helper('ops')->__(
741
+ 'Waiting for payment. Ingenico ePayments status: %s.', Mage::helper('ops')->getStatusText($status)
742
  )
743
  );
744
 
748
  ) {
749
  $order->sendNewOrderEmail();
750
  }
751
+ } elseif ($status == Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING) {
752
  $order->setState(
753
  Mage_Sales_Model_Order::STATE_PROCESSING,
754
  Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
755
  Mage::helper('ops')->__(
756
+ 'Authorization uncertain. Ingenico ePayments status: %s.', Mage::helper('ops')->getStatusText($status)
757
  )
758
  );
759
  } else {
760
  // for 3DS payments the order has to be retrieved from the payment review step
761
  if ($this->isInlinePayment($order->getPayment())
762
  && 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER')))
763
+ && $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Status::AUTHORIZED
764
  ) {
765
+
766
+ $order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(
767
+ Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true
768
+ )->save();
769
  }
770
  if ($this->isRedirectPaymentMethod($order) === true
771
  && $order->getEmailSent() != 1
773
  $order->sendNewOrderEmail();
774
  }
775
 
776
+ if (!$this->isPaypalSpecialStatus($order->getPayment()->getMethodInstance(), $status)) {
777
 
778
  $payId = $params['PAYID'];
779
  $order->setState(
780
  Mage_Sales_Model_Order::STATE_PROCESSING,
781
  Mage_Sales_Model_Order::STATE_PROCESSING,
782
  Mage::helper('ops')->__(
783
+ 'Processed by Ingenico ePayments. Payment ID: %s. Ingenico ePayments status: %s.', $payId,
784
  Mage::helper('ops')->getStatusText($status)
785
  )
786
  );
800
  protected function isPaypalSpecialStatus($pm, $status)
801
  {
802
  return $pm instanceof Netresearch_OPS_Model_Payment_Paypal
803
+ && $status == Netresearch_OPS_Model_Status::PAYMENT_PROCESSING;
804
  }
805
 
806
  /**
816
  return;
817
  }
818
  $transaction = Mage::getModel('sales/order_payment_transaction')
819
+ ->getCollection()
820
+ ->addAttributeToFilter('txn_id', $transactionId)
821
+ ->getLastItem();
822
  if (is_null($transaction->getId())) {
823
  return false;
824
  }
853
  $cart->save();
854
 
855
  // add coupon code
856
+ $coupon = $order->getCouponCode();
857
  $session = Mage::getSingleton('checkout/session');
858
  if (false == is_null($coupon)) {
859
  $session->getQuote()->setCouponCode($coupon)->save();
864
  * Save OPS Status to Payment
865
  *
866
  * @param Mage_Sales_Model_Order_Payment $payment
867
+ * @param array $params OPS-Response
868
  *
869
  * @return void
870
  */
908
  {
909
  if ($order instanceof Mage_Sales_Model_Order) {
910
  $message = Mage::helper('ops')->__(
911
+ 'Unknown Ingenico ePayments state for this order. Please check Ingenico ePayments backend for this order.'
912
  );
913
  if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
914
  $order->setState(
945
  * Save the last used refund operation code to payment
946
  *
947
  * @param Mage_Sales_Model_Order_Payment $payment
948
+ * @param string $operationCode
949
  *
950
  * @return void
951
  */
956
  array(
957
  Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
958
  Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL
959
+ )
960
+ )
961
  ) {
962
  Mage::helper('ops/data')->log(
963
+ sprintf(
964
+ "set last refund operation '%s' code to payment for order '%s'",
965
+ $operationCode,
966
+ $payment->getOrder()->getIncrementId()
967
  )
968
  );
969
  $payment
985
  array(
986
  Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
987
  Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL
988
+ )
989
+ )
990
  ) {
991
  /*
992
  * a further refund is possible if the transaction remains open, that means either the merchant
994
  */
995
  $canRefund = ($refundOperationCode == Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL);
996
  Mage::helper('ops/data')->log(
997
+ sprintf(
998
+ "set canRefund to '%s' for payment of order '%s'",
999
+ var_export($canRefund, true),
1000
+ $payment->getOrder()->getIncrementId()
1001
  )
1002
  );
1003
  $payment
1008
 
1009
  /**
1010
  * determine whether the payment supports only authorize or not
1011
+ *
1012
  * @param Mage_Sales_Model_Order $order
1013
+ *
1014
  * @return true . if so, false otherwise
1015
  */
1016
  protected function forceAuthorize(Mage_Sales_Model_Order $order)
1071
  */
1072
  public function isInlinePaymentWithOrderId(Mage_Payment_Model_Info $payment)
1073
  {
1074
+ return $this->isInlinePayment($payment) && $this->getConfig()->getInlineOrderReference() == Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID;
1075
  }
1076
 
1077
  /**
1083
  */
1084
  public function isInlinePayment(Mage_Payment_Model_Info $payment)
1085
  {
1086
+ $result = false;
1087
  $methodInstance = $payment->getMethodInstance();
1088
  if ($methodInstance instanceof Netresearch_OPS_Model_Payment_DirectDebit
1089
  || ($methodInstance instanceof Netresearch_OPS_Model_Payment_Cc
1090
+ && ($methodInstance->hasBrandAliasInterfaceSupport($payment)
1091
+ || Mage::helper('ops/data')->isAdminSession()))
1092
  ) {
1093
  $result = true;
1094
  }
1105
  */
1106
  public function isInlinePaymentWithQuoteId(Mage_Payment_Model_Info $payment)
1107
  {
1108
+ return $this->isInlinePayment($payment)
1109
+ && (0 === strlen(
1110
+ trim($payment->getMethodInstance()->getConfigPaymentAction())
1111
+ ));
1112
  }
1113
 
1114
  /**
1115
  * sets the invoices of an order to paid
1116
  *
1117
  * @param Mage_Sales_Model_Order $order
1118
+ *
1119
  * @return Netresearch_OPS_Helper_Payment
1120
  */
1121
  public function setInvoicesToPaid($order)
1151
 
1152
  /**
1153
  * Returns if the current payment status is an invalid one, namely if it is one of the following:
1154
+ * Netresearch_OPS_Model_Payment_Abstract::INVALID_INCOMPLETE,
1155
+ * Netresearch_OPS_Model_Payment_Abstract::CANCELED_BY_CUSTOMER,
1156
+ * Netresearch_OPS_Model_Payment_Abstract::AUTHORISATION_DECLINED,
1157
  *
1158
  * @param $status
1159
+ *
1160
  * @return bool
1161
  */
1162
  public function isPaymentInvalid($status)
1164
  return in_array(
1165
  $status,
1166
  array(
1167
+ Netresearch_OPS_Model_Status::INVALID_INCOMPLETE,
1168
+ Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER,
1169
+ Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED,
1170
  )
1171
  );
1172
  }
app/code/community/Netresearch/OPS/Helper/Payment/DirectLink/Request.php CHANGED
@@ -285,6 +285,7 @@ abstract class Netresearch_OPS_Helper_Payment_DirectLink_Request
285
  'ORIG' => $this->getDataHelper()->getModuleVersionString(),
286
  'EMAIL' => $order->getCustomerEmail(),
287
  'REMOTE_ADDR' => $quote->getRemoteIp(),
 
288
  );
289
 
290
  $ownerParams = $this->getOwnerParams($quote, $billingAddress, $requestParams);
@@ -303,7 +304,7 @@ abstract class Netresearch_OPS_Helper_Payment_DirectLink_Request
303
  */
304
  protected function getOwnerParams($quote, $billingAddress, $requestParams)
305
  {
306
- $ownerParams = $this->getRequestHelper()->getOwnerParams($quote, $billingAddress);
307
  if (array_key_exists('OWNERADDRESS', $ownerParams) && array_key_exists('OWNERTOWN', $ownerParams)) {
308
  $ownerAddrParams = $this->decodeParamsForDirectLinkCall(
309
  array('OWNERADDRESS' => $ownerParams['OWNERADDRESS'], 'OWNERTOWN' => $ownerParams['OWNERTOWN'])
@@ -317,12 +318,12 @@ abstract class Netresearch_OPS_Helper_Payment_DirectLink_Request
317
  /**
318
  * @return bool
319
  */
320
- protected function canUseOrderId(Varien_Object $payment)
321
  {
322
  $methodInstance = $payment->getMethodInstance();
323
  return
324
  $this->getConfig()->getInlineOrderReference() == Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID
325
- && ($methodInstance instanceof Netresearch_OPS_Model_Payment_DirectLink && 0 < strlen(trim($methodInstance->getConfigPaymentAction())));
326
  }
327
 
328
 
285
  'ORIG' => $this->getDataHelper()->getModuleVersionString(),
286
  'EMAIL' => $order->getCustomerEmail(),
287
  'REMOTE_ADDR' => $quote->getRemoteIp(),
288
+ 'RTIMEOUT' => $this->getConfig()->getTransActionTimeout()
289
  );
290
 
291
  $ownerParams = $this->getOwnerParams($quote, $billingAddress, $requestParams);
304
  */
305
  protected function getOwnerParams($quote, $billingAddress, $requestParams)
306
  {
307
+ $ownerParams = $this->getRequestHelper()->getOwnerParams($billingAddress, $quote);
308
  if (array_key_exists('OWNERADDRESS', $ownerParams) && array_key_exists('OWNERTOWN', $ownerParams)) {
309
  $ownerAddrParams = $this->decodeParamsForDirectLinkCall(
310
  array('OWNERADDRESS' => $ownerParams['OWNERADDRESS'], 'OWNERTOWN' => $ownerParams['OWNERTOWN'])
318
  /**
319
  * @return bool
320
  */
321
+ public function canUseOrderId(Varien_Object $payment)
322
  {
323
  $methodInstance = $payment->getMethodInstance();
324
  return
325
  $this->getConfig()->getInlineOrderReference() == Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID
326
+ && $methodInstance instanceof Netresearch_OPS_Model_Payment_DirectLink;
327
  }
328
 
329
 
app/code/community/Netresearch/OPS/Helper/Payment/Request.php CHANGED
@@ -20,7 +20,7 @@ class Netresearch_OPS_Helper_Payment_Request
20
  }
21
 
22
  /**
23
- * @return null
24
  */
25
  public function getConfig()
26
  {
@@ -64,7 +64,6 @@ class Netresearch_OPS_Helper_Payment_Request
64
  $paramValues['ECOM_SHIPTO_POSTAL_NAME_LAST'] = $address->getLastname();
65
  $paramValues['ECOM_SHIPTO_POSTAL_STREET_LINE1'] = $address->getStreet(1);
66
  $paramValues['ECOM_SHIPTO_POSTAL_STREET_LINE2'] = $address->getStreet(2);
67
- $paramValues['ECOM_SHIPTO_POSTAL_STREET_LINE3'] = $address->getStreet(3);
68
 
69
  return $paramValues;
70
  }
@@ -92,8 +91,8 @@ class Netresearch_OPS_Helper_Payment_Request
92
 
93
  $paramValues['ECOM_BILLTO_POSTAL_CITY'] = $address->getCity();
94
  $paramValues['ECOM_BILLTO_POSTAL_POSTALCODE'] = $address->getPostcode();
95
- $paramValues['ECOM_BILLTO_POSTAL_STATE'] = $this->getIsoRegionCode($address);
96
- $paramValues['ECOM_BILLTO_POSTAL_COUNTRYCODE'] = $this->getCountry();
97
  $paramValues['ECOM_BILLTO_POSTAL_NAME_FIRST'] = $address->getFirstname();
98
  $paramValues['ECOM_BILLTO_POSTAL_NAME_LAST'] = $address->getLastname();
99
  $paramValues['ECOM_BILLTO_POSTAL_POSTALCODE'] = $address->getPostcode();
@@ -105,17 +104,18 @@ class Netresearch_OPS_Helper_Payment_Request
105
  }
106
 
107
  /**
108
- * extraxcts the according Ingenico Payment Services owner* parameter
109
  *
110
- * @param Mage_Sales_Model_Quote $quote
111
  * @param Mage_Customer_Model_Address_Abstract $billingAddress
112
  *
 
 
113
  * @return string[]
114
  */
115
- public function getOwnerParams(Mage_Sales_Model_Quote $quote, Mage_Customer_Model_Address_Abstract $billingAddress)
116
  {
117
  $ownerParams = array();
118
- if ($this->getConfig()->canSubmitExtraParameter($quote->getStoreId())) {
119
  $ownerParams = array(
120
  'OWNERADDRESS' => str_replace("\n", ' ', $billingAddress->getStreet(1)),
121
  'OWNERTOWN' => $billingAddress->getCity(),
@@ -130,6 +130,46 @@ class Netresearch_OPS_Helper_Payment_Request
130
  return $ownerParams;
131
  }
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  /**
134
  * extracts the region code in iso format (if possible)
135
  *
@@ -442,7 +482,7 @@ class Netresearch_OPS_Helper_Payment_Request
442
  }
443
 
444
  /**
445
- * Returns the mandatory fields for requests to Ingenico Payment Services
446
  *
447
  * @param Mage_Sales_Model_Order $order
448
  *
@@ -467,9 +507,24 @@ class Netresearch_OPS_Helper_Payment_Request
467
  $formFields['CANCELURL'] = $this->getConfig()->getCancelUrl();
468
  $formFields['BACKURL'] = $this->getConfig()->getCancelUrl();
469
 
 
 
470
  return $formFields;
471
  }
472
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  /**
474
  * Extracts the order item parameters and puts them in a array like
475
  *
@@ -551,7 +606,7 @@ class Netresearch_OPS_Helper_Payment_Request
551
  }
552
 
553
  /**
554
- * Returns item array for Ingenico Payment Services request for the specified item
555
  *
556
  * @param $count
557
  * @param $item
20
  }
21
 
22
  /**
23
+ * @return Netresearch_OPS_Model_Config
24
  */
25
  public function getConfig()
26
  {
64
  $paramValues['ECOM_SHIPTO_POSTAL_NAME_LAST'] = $address->getLastname();
65
  $paramValues['ECOM_SHIPTO_POSTAL_STREET_LINE1'] = $address->getStreet(1);
66
  $paramValues['ECOM_SHIPTO_POSTAL_STREET_LINE2'] = $address->getStreet(2);
 
67
 
68
  return $paramValues;
69
  }
91
 
92
  $paramValues['ECOM_BILLTO_POSTAL_CITY'] = $address->getCity();
93
  $paramValues['ECOM_BILLTO_POSTAL_POSTALCODE'] = $address->getPostcode();
94
+ $paramValues['ECOM_BILLTO_POSTAL_COUNTY'] = $this->getIsoRegionCode($address);
95
+ $paramValues['ECOM_BILLTO_POSTAL_COUNTRYCODE'] = $address->getCountry();
96
  $paramValues['ECOM_BILLTO_POSTAL_NAME_FIRST'] = $address->getFirstname();
97
  $paramValues['ECOM_BILLTO_POSTAL_NAME_LAST'] = $address->getLastname();
98
  $paramValues['ECOM_BILLTO_POSTAL_POSTALCODE'] = $address->getPostcode();
104
  }
105
 
106
  /**
107
+ * extraxcts the according Ingenico ePayments owner* parameter
108
  *
 
109
  * @param Mage_Customer_Model_Address_Abstract $billingAddress
110
  *
111
+ * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $salesObject
112
+ *
113
  * @return string[]
114
  */
115
+ public function getOwnerParams(Mage_Customer_Model_Address_Abstract $billingAddress, $salesObject)
116
  {
117
  $ownerParams = array();
118
+ if ($this->getConfig()->canSubmitExtraParameter($salesObject->getStoreId())) {
119
  $ownerParams = array(
120
  'OWNERADDRESS' => str_replace("\n", ' ', $billingAddress->getStreet(1)),
121
  'OWNERTOWN' => $billingAddress->getCity(),
130
  return $ownerParams;
131
  }
132
 
133
+ /**
134
+ * Returns the template parameters and their dependencies
135
+ *
136
+ * @return array
137
+ */
138
+
139
+ public function getTemplateParams($storeId = null)
140
+ {
141
+ $formFields = array();
142
+ switch ($this->getConfig()->getConfigData('template')) {
143
+ case Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL:
144
+ $formFields['TP'] = $this->getConfig()->getPayPageTemplate($storeId);
145
+ break;
146
+ case Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE:
147
+ $formFields['TP'] = $this->getConfig()->getTemplateIdentifier($storeId);
148
+ break;
149
+ case Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME:
150
+ $formFields['PARAMPLUS'] = 'IFRAME=1';
151
+ case Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_REDIRECT:
152
+ $formFields['PMLISTTYPE'] = $this->getConfig()->getConfigData('pmlist', $storeId);
153
+ $formFields['TITLE'] = $this->getConfig()->getConfigData('html_title', $storeId);
154
+ $formFields['BGCOLOR'] = $this->getConfig()->getConfigData('bgcolor', $storeId);
155
+ $formFields['TXTCOLOR'] = $this->getConfig()->getConfigData('txtcolor', $storeId);
156
+ $formFields['TBLBGCOLOR'] = $this->getConfig()->getConfigData('tblbgcolor', $storeId);
157
+ $formFields['TBLTXTCOLOR'] = $this->getConfig()->getConfigData('tbltxtcolor', $storeId);
158
+ $formFields['BUTTONBGCOLOR'] = $this->getConfig()->getConfigData('buttonbgcolor', $storeId);
159
+ $formFields['BUTTONTXTCOLOR'] = $this->getConfig()->getConfigData('buttontxtcolor', $storeId);
160
+ $formFields['FONTTYPE'] = $this->getConfig()->getConfigData('fonttype', $storeId);
161
+ $formFields['LOGO'] = $this->getConfig()->getConfigData('logo', $storeId);
162
+ $formFields['HOMEURL'] = $this->getConfig()->hasHomeUrl() ? $this->getConfig()->getContinueUrl(array('redirect' => 'home')) : 'NONE';
163
+ $formFields['CATALOGURL'] = $this->getConfig()->hasCatalogUrl() ? $this->getConfig()->getContinueUrl(array('redirect' => 'catalog')) : '';
164
+ break;
165
+ default:
166
+ break;
167
+ };
168
+
169
+ return $formFields;
170
+
171
+ }
172
+
173
  /**
174
  * extracts the region code in iso format (if possible)
175
  *
482
  }
483
 
484
  /**
485
+ * Returns the mandatory fields for requests to Ingenico ePayments
486
  *
487
  * @param Mage_Sales_Model_Order $order
488
  *
507
  $formFields['CANCELURL'] = $this->getConfig()->getCancelUrl();
508
  $formFields['BACKURL'] = $this->getConfig()->getCancelUrl();
509
 
510
+ $formFields['FP_ACTIV'] = $this->isFingerPrintingActive($order) ? '1' : '0';
511
+
512
  return $formFields;
513
  }
514
 
515
+ /**
516
+ * Will return the combination of activiation via config and the state of consent of the customer
517
+ *
518
+ * @param $order
519
+ *
520
+ * @return bool
521
+ */
522
+ protected function isFingerPrintingActive($order)
523
+ {
524
+ return $this->getConfig()->getDeviceFingerPrinting($order->getStoreId())
525
+ && Mage::getSingleton('customer/session')->getData(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY);
526
+ }
527
+
528
  /**
529
  * Extracts the order item parameters and puts them in a array like
530
  *
606
  }
607
 
608
  /**
609
+ * Returns item array for Ingenico ePayments request for the specified item
610
  *
611
  * @param $count
612
  * @param $item
app/code/community/Netresearch/OPS/Helper/Quote.php CHANGED
@@ -129,7 +129,7 @@ class Netresearch_OPS_Helper_Quote extends Mage_Core_Helper_Abstract
129
  */
130
  public function getQuote()
131
  {
132
- if ($this->getDataHelper()->isAdminSession()) {
133
  return Mage::getSingleton('adminhtml/session_quote')->getQuote();
134
  }
135
 
129
  */
130
  public function getQuote()
131
  {
132
+ if (Mage::app()->getStore()->isAdmin()) {
133
  return Mage::getSingleton('adminhtml/session_quote')->getQuote();
134
  }
135
 
app/code/community/Netresearch/OPS/Helper/Subscription.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Subscription.php
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ class Netresearch_OPS_Helper_Subscription extends Mage_Core_Helper_Abstract
30
+ {
31
+ const SUBSCRIPTION_PREFIX = 'SUB-';
32
+ const TRIAL_SUFFIX = '-TRIAL';
33
+
34
+ /**
35
+ * Generates subscription id in the following pattern:
36
+ *
37
+ * SUB-subscriptionId-TRIAL
38
+ *
39
+ * @param Mage_Payment_Model_Recurring_Profile $profile - the profile itself
40
+ * @param bool $withTrial - if you wish the trial suffix appended in case the profile has a trial subscription
41
+ *
42
+ * @return string
43
+ */
44
+ public function generateSubscriptionId(Mage_Payment_Model_Recurring_Profile $profile, $withTrial = false)
45
+ {
46
+ $config = Mage::getModel('ops/config');
47
+ $devPrefix = $config->getConfigData('devprefix');
48
+
49
+ $subscriptionId = self::SUBSCRIPTION_PREFIX . $profile->getId();
50
+ if ($profile->getTrialPeriodUnit() && $withTrial) {
51
+ $subscriptionId .= self::TRIAL_SUFFIX;
52
+ }
53
+
54
+ return $devPrefix . $subscriptionId;
55
+ }
56
+
57
+ /**
58
+ * Determine if the given request parameters belong to a subscription
59
+ *
60
+ * @param $requestParams
61
+ *
62
+ * @return bool
63
+ */
64
+ public function isSubscriptionFeedback($requestParams)
65
+ {
66
+ $result = false;
67
+ if (is_array($requestParams)
68
+ && array_key_exists('orderID', $requestParams)
69
+ && false != strstr($this->removeDevPrefix($requestParams['orderID']), self::SUBSCRIPTION_PREFIX)
70
+ ) {
71
+ $result = true;
72
+ }
73
+
74
+ return $result;
75
+ }
76
+
77
+ /**
78
+ * Loads the recurring profile for the given ORDERID
79
+ *
80
+ * @param $orderId
81
+ *
82
+ * @throws Mage_Core_Exception if no profile could be found
83
+ *
84
+ * @return Mage_Sales_Model_Order
85
+ * @throws Mage_Core_Exception
86
+ */
87
+ public function getProfileForSubscription($orderId)
88
+ {
89
+ $orderId = $this->removeDevPrefix($orderId);
90
+
91
+ if ($this->isTrialFeedback($orderId)) {
92
+ $orderId = substr($orderId, -0, strlen(self::TRIAL_SUFFIX));
93
+ }
94
+ $orderId = substr($orderId, strlen(self::SUBSCRIPTION_PREFIX));
95
+ $profile = Mage::getModel('sales/recurring_profile')->load($orderId);
96
+ if (!$profile->getId()) {
97
+ Mage::throwException('Could find no subscription for id ' . $orderId);
98
+ }
99
+
100
+ return $profile;
101
+ }
102
+
103
+ /**
104
+ * Determines via the given orderId if the feedback request was a from a trial subscription
105
+ *
106
+ * @param string $orderId
107
+ *
108
+ * @return bool
109
+ */
110
+ public function isTrialFeedback($orderId)
111
+ {
112
+ return (bool)strstr($orderId, self::TRIAL_SUFFIX);
113
+ }
114
+
115
+ /**
116
+ * Determine day of billing according to the period unit of the subscription
117
+ *
118
+ * @param string $periodUnit @see Mage_Payment_Model_Recurring_Profile
119
+ * @param int $storeId
120
+ *
121
+ * @return int
122
+ */
123
+ public function getBillingDayForPeriodUnit($periodUnit, $storeId = null)
124
+ {
125
+ $config = Mage::getModel('ops/config');
126
+ $day = 1;
127
+
128
+ switch ($periodUnit) {
129
+ case Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_MONTH:
130
+ $day = $config->getMonthlyBillingDay($storeId);
131
+ break;
132
+ case Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_WEEK:
133
+ // offset the day by one, since Magento counts from 0, but Ingenico ePayments from 1
134
+ $day = $config->getWeeklyBillingDay($storeId) + 1;
135
+ break;
136
+ }
137
+
138
+ return $day;
139
+ }
140
+
141
+ protected function removeDevPrefix($orderId)
142
+ {
143
+ $config = Mage::getModel('ops/config');
144
+ $devPrefix = $config->getConfigData('devprefix');
145
+ $orderId = substr($orderId, strlen($devPrefix));
146
+ return $orderId;
147
+ }
148
+ }
app/code/community/Netresearch/OPS/Model/Api/Directlink.php CHANGED
@@ -52,7 +52,7 @@ class Netresearch_OPS_Model_Api_DirectLink extends Mage_Core_Model_Abstract
52
  } catch (Exception $e) {
53
  Mage::logException($e);
54
  Mage::throwException(
55
- Mage::helper('ops')->__('Ingenico Payment Services server is temporarily not available, please try again later.')
56
  );
57
  }
58
  }
@@ -71,7 +71,7 @@ class Netresearch_OPS_Model_Api_DirectLink extends Mage_Core_Model_Abstract
71
  array_merge($requestParams,$this->buildAuthenticationParams($storeId)) //Merge Logic Operation Data with Authentication Data
72
  , null, $storeId);
73
  $responseParams = $this->getResponseParams($params, $url);
74
- $helper->log($helper->__("Direct Link Request/Response in Ingenico Payment Services \n\nRequest: %s\nResponse: %s\nMagento-URL: %s\nAPI-URL: %s",
75
  serialize($params),
76
  serialize($responseParams),
77
  Mage::helper('core/url')->getCurrentUrl(),
@@ -86,7 +86,8 @@ class Netresearch_OPS_Model_Api_DirectLink extends Mage_Core_Model_Abstract
86
 
87
  public function getEncodedParametersWithHash($params, $shaCode=null, $storeId)
88
  {
89
- $params['SHASIGN'] = Mage::helper('ops/payment')->shaCrypt(iconv('iso-8859-1', 'utf-8', Mage::helper('ops/payment')->getSHASign($params, $shaCode, $storeId)));
 
90
 
91
  return $params;
92
  }
@@ -100,7 +101,7 @@ class Netresearch_OPS_Model_Api_DirectLink extends Mage_Core_Model_Abstract
100
  * @param array $params - request params
101
  * @param string $url - the url for the request
102
  * @param int $retryCount - current request count
103
- * @return array | null - null if requests were not successful, array containing Ingenico Payment Services payment data otherwise
104
  *
105
  */
106
  protected function getResponseParams($params, $url, $retryCount = 0)
@@ -128,7 +129,7 @@ class Netresearch_OPS_Model_Api_DirectLink extends Mage_Core_Model_Abstract
128
  }
129
  }
130
  } else {
131
- Mage::throwException(Mage::helper('ops')->__('An error occured during the Ingenico Payment Services request. Your action could not be executed.'));
132
  }
133
  return $responseParams;
134
  }
@@ -190,7 +191,7 @@ class Netresearch_OPS_Model_Api_DirectLink extends Mage_Core_Model_Abstract
190
  }
191
 
192
  Mage::throwException(
193
- Mage::helper('ops')->__('An error occured during the Ingenico Payment Services request. Your action could not be executed. Message: "%s".',$responseParams['NCERRORPLUS'])
194
  );
195
  }
196
  }
52
  } catch (Exception $e) {
53
  Mage::logException($e);
54
  Mage::throwException(
55
+ Mage::helper('ops')->__('Ingenico ePayments server is temporarily not available, please try again later.')
56
  );
57
  }
58
  }
71
  array_merge($requestParams,$this->buildAuthenticationParams($storeId)) //Merge Logic Operation Data with Authentication Data
72
  , null, $storeId);
73
  $responseParams = $this->getResponseParams($params, $url);
74
+ $helper->log($helper->__("Direct Link Request/Response in Ingenico ePayments \n\nRequest: %s\nResponse: %s\nMagento-URL: %s\nAPI-URL: %s",
75
  serialize($params),
76
  serialize($responseParams),
77
  Mage::helper('core/url')->getCurrentUrl(),
86
 
87
  public function getEncodedParametersWithHash($params, $shaCode=null, $storeId)
88
  {
89
+ $hash = Mage::helper('ops/payment')->getSHASign($params, $shaCode, $storeId);
90
+ $params['SHASIGN'] = Mage::helper('ops/payment')->shaCrypt(iconv('iso-8859-1', 'utf-8', $hash));
91
 
92
  return $params;
93
  }
101
  * @param array $params - request params
102
  * @param string $url - the url for the request
103
  * @param int $retryCount - current request count
104
+ * @return array | null - null if requests were not successful, array containing Ingenico ePayments payment data otherwise
105
  *
106
  */
107
  protected function getResponseParams($params, $url, $retryCount = 0)
129
  }
130
  }
131
  } else {
132
+ Mage::throwException(Mage::helper('ops')->__('An error occured during the Ingenico ePayments request. Your action could not be executed.'));
133
  }
134
  return $responseParams;
135
  }
191
  }
192
 
193
  Mage::throwException(
194
+ Mage::helper('ops')->__("An error occured during the Ingenico ePayments request. Your action could not be executed. Message: '%s.'",$responseParams['NCERRORPLUS'])
195
  );
196
  }
197
  }
app/code/community/Netresearch/OPS/Model/Backend/Operation/Capture/Parameter.php CHANGED
@@ -7,7 +7,7 @@
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
  class Netresearch_OPS_Model_Backend_Operation_Capture_Parameter
10
- extends Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract
11
  {
12
  /**
13
  * checks whether we need to retrieve additional parameter for the capture request or not
@@ -20,7 +20,8 @@ class Netresearch_OPS_Model_Backend_Operation_Capture_Parameter
20
  {
21
  $opsPaymentMethodClass = get_class($opsPaymentMethod);
22
  $opsPmsRequiringSpecialParams = $this->getOpsConfig()
23
- ->getMethodsRequiringAdditionalParametersFor(Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE);
 
24
 
25
  return (in_array($opsPaymentMethodClass, array_values($opsPmsRequiringSpecialParams)));
26
  }
@@ -36,4 +37,14 @@ class Netresearch_OPS_Model_Backend_Operation_Capture_Parameter
36
  $this->additionalParamsModel = Mage::getModel('ops/backend_operation_capture_additional_openInvoiceNl');
37
  }
38
  }
 
 
 
 
 
 
 
 
 
 
39
  }
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
  class Netresearch_OPS_Model_Backend_Operation_Capture_Parameter
10
+ extends Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract
11
  {
12
  /**
13
  * checks whether we need to retrieve additional parameter for the capture request or not
20
  {
21
  $opsPaymentMethodClass = get_class($opsPaymentMethod);
22
  $opsPmsRequiringSpecialParams = $this->getOpsConfig()
23
+ ->getMethodsRequiringAdditionalParametersFor(Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE
24
+ );
25
 
26
  return (in_array($opsPaymentMethodClass, array_values($opsPmsRequiringSpecialParams)));
27
  }
37
  $this->additionalParamsModel = Mage::getModel('ops/backend_operation_capture_additional_openInvoiceNl');
38
  }
39
  }
40
+
41
+ /**
42
+ * Returns the order helper for the corresponding transaction type
43
+ *
44
+ * @return Netresearch_OPS_Helper_Order_Abstract
45
+ */
46
+ public function getOrderHelper()
47
+ {
48
+ return Mage::helper('ops/order_capture');
49
+ }
50
  }
app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter.php CHANGED
@@ -27,10 +27,9 @@ class Netresearch_OPS_Model_Backend_Operation_Parameter
27
  $operation,
28
  Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
29
  Varien_Object $payment,
30
- $amount,
31
- $arrInfo
32
  ) {
33
- return $this->getParameterModel($operation)->getRequestParams($opsPaymentMethod, $payment, $amount, $arrInfo);
34
  }
35
 
36
  /**
27
  $operation,
28
  Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
29
  Varien_Object $payment,
30
+ $amount
 
31
  ) {
32
+ return $this->getParameterModel($operation)->getRequestParams($opsPaymentMethod, $payment, $amount);
33
  }
34
 
35
  /**
app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Abstract.php CHANGED
@@ -6,8 +6,8 @@
6
  * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
-
10
- abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract implements Netresearch_OPS_Model_Backend_Operation_Parameter_Interface
11
  {
12
  protected $requestParams = array();
13
 
@@ -26,11 +26,9 @@ abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract implem
26
  public function getRequestParams(
27
  Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
28
  Varien_Object $payment,
29
- $amount,
30
- $arrInfo
31
- )
32
- {
33
- $this->getBaseParams($opsPaymentMethod, $payment, $amount, $arrInfo);
34
  $this->addPmSpecificParams($opsPaymentMethod, $payment, $amount);
35
 
36
  return $this->requestParams;
@@ -40,7 +38,7 @@ abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract implem
40
  * retrieves the basic parameters for a capture call
41
  *
42
  * @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
43
- * @param Varien_Object $payment
44
  * @param $amount
45
  * @param $arrInfo
46
  *
@@ -49,15 +47,13 @@ abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract implem
49
  protected function getBaseParams(
50
  Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
51
  Varien_Object $payment,
52
- $amount,
53
- $arrInfo
54
- )
55
- {
56
- $this->requestParams['AMOUNT'] = $this->getDataHelper()->getAmount($amount);
57
- $this->requestParams['PAYID'] = $payment->getAdditionalInformation('paymentId');
58
- $this->requestParams['OPERATION'] = $arrInfo['operation'];
59
- $this->requestParams['CURRENCY'] = Mage::app()->getStore($payment->getOrder()->getStoreId())
60
- ->getBaseCurrencyCode();
61
 
62
  return $this;
63
  }
@@ -85,12 +81,15 @@ abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract implem
85
  *
86
  * @return $this
87
  */
88
- protected function addPmSpecificParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod, Varien_Object $payment, $amount)
89
- {
 
90
  if ($this->isPmRequiringAdditionalParams($opsPaymentMethod)) {
91
  $this->setAdditionalParamsModelFor($opsPaymentMethod);
92
- if ($this->additionalParamsModel instanceof Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_Interface) {
93
- $params = $this->additionalParamsModel->extractAdditionalParams($payment->getInvoice());
 
 
94
  $this->requestParams = array_merge($this->requestParams, $params);
95
  }
96
  }
@@ -122,4 +121,11 @@ abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract implem
122
  return $this->dataHelper;
123
  }
124
 
 
 
 
 
 
 
 
125
  }
6
  * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
+ abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract
10
+ implements Netresearch_OPS_Model_Backend_Operation_Parameter_Interface
11
  {
12
  protected $requestParams = array();
13
 
26
  public function getRequestParams(
27
  Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
28
  Varien_Object $payment,
29
+ $amount
30
+ ) {
31
+ $this->getBaseParams($opsPaymentMethod, $payment, $amount );
 
 
32
  $this->addPmSpecificParams($opsPaymentMethod, $payment, $amount);
33
 
34
  return $this->requestParams;
38
  * retrieves the basic parameters for a capture call
39
  *
40
  * @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
41
+ * @param Varien_Object $payment
42
  * @param $amount
43
  * @param $arrInfo
44
  *
47
  protected function getBaseParams(
48
  Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
49
  Varien_Object $payment,
50
+ $amount
51
+ ) {
52
+ $this->requestParams['AMOUNT'] = $this->getDataHelper()->getAmount($amount);
53
+ $this->requestParams['PAYID'] = $payment->getAdditionalInformation('paymentId');
54
+ $this->requestParams['OPERATION'] = $this->getOrderHelper()->determineOperationCode($payment, $amount);
55
+ $this->requestParams['CURRENCY'] = Mage::app()->getStore($payment->getOrder()->getStoreId())
56
+ ->getBaseCurrencyCode();
 
 
57
 
58
  return $this;
59
  }
81
  *
82
  * @return $this
83
  */
84
+ protected function addPmSpecificParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
85
+ Varien_Object $payment, $amount
86
+ ) {
87
  if ($this->isPmRequiringAdditionalParams($opsPaymentMethod)) {
88
  $this->setAdditionalParamsModelFor($opsPaymentMethod);
89
+ if ($this->additionalParamsModel instanceof
90
+ Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_Interface
91
+ ) {
92
+ $params = $this->additionalParamsModel->extractAdditionalParams($payment->getInvoice());
93
  $this->requestParams = array_merge($this->requestParams, $params);
94
  }
95
  }
121
  return $this->dataHelper;
122
  }
123
 
124
+ /**
125
+ * Returns the order helper for the corresponding transaction type
126
+ *
127
+ * @return Netresearch_OPS_Helper_Order_Abstract
128
+ */
129
+ public abstract function getOrderHelper();
130
+
131
  }
app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Interface.php CHANGED
@@ -11,8 +11,7 @@ interface Netresearch_OPS_Model_Backend_Operation_Parameter_Interface
11
  public function getRequestParams(
12
  Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
13
  Varien_Object $payment,
14
- $amount,
15
- $arrInfo
16
  );
17
 
18
  }
11
  public function getRequestParams(
12
  Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
13
  Varien_Object $payment,
14
+ $amount
 
15
  );
16
 
17
  }
app/code/community/Netresearch/OPS/Model/Backend/Operation/Refund/Parameter.php CHANGED
@@ -6,7 +6,6 @@
6
  * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
-
10
  class Netresearch_OPS_Model_Backend_Operation_Refund_Parameter
11
  extends Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract
12
  {
@@ -21,10 +20,12 @@ class Netresearch_OPS_Model_Backend_Operation_Refund_Parameter
21
  {
22
  $opsPaymentMethodClass = get_class($opsPaymentMethod);
23
  $opsPmsRequiringSpecialParams = $this->getOpsConfig()
24
- ->getMethodsRequiringAdditionalParametersFor(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE);
 
25
 
26
  return (in_array($opsPaymentMethodClass, array_values($opsPmsRequiringSpecialParams)));
27
  }
 
28
  /**
29
  * sets the model which retrieves the additional params for the refund request
30
  *
@@ -37,12 +38,15 @@ class Netresearch_OPS_Model_Backend_Operation_Refund_Parameter
37
  }
38
  }
39
 
40
- protected function addPmSpecificParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod, Varien_Object $payment, $amount)
41
- {
 
42
  if ($this->isPmRequiringAdditionalParams($opsPaymentMethod)) {
43
  $this->setAdditionalParamsModelFor($opsPaymentMethod);
44
- if ($this->additionalParamsModel instanceof Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_Interface) {
45
- $params = $this->additionalParamsModel->extractAdditionalParams(Mage::registry('current_creditmemo'));
 
 
46
  $this->requestParams = array_merge($this->requestParams, $params);
47
  }
48
  }
@@ -50,4 +54,15 @@ class Netresearch_OPS_Model_Backend_Operation_Refund_Parameter
50
  return $this;
51
  }
52
 
53
- }
 
 
 
 
 
 
 
 
 
 
 
6
  * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
 
9
  class Netresearch_OPS_Model_Backend_Operation_Refund_Parameter
10
  extends Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract
11
  {
20
  {
21
  $opsPaymentMethodClass = get_class($opsPaymentMethod);
22
  $opsPmsRequiringSpecialParams = $this->getOpsConfig()
23
+ ->getMethodsRequiringAdditionalParametersFor(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE
24
+ );
25
 
26
  return (in_array($opsPaymentMethodClass, array_values($opsPmsRequiringSpecialParams)));
27
  }
28
+
29
  /**
30
  * sets the model which retrieves the additional params for the refund request
31
  *
38
  }
39
  }
40
 
41
+ protected function addPmSpecificParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
42
+ Varien_Object $payment, $amount
43
+ ) {
44
  if ($this->isPmRequiringAdditionalParams($opsPaymentMethod)) {
45
  $this->setAdditionalParamsModelFor($opsPaymentMethod);
46
+ if ($this->additionalParamsModel instanceof
47
+ Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_Interface
48
+ ) {
49
+ $params = $this->additionalParamsModel->extractAdditionalParams(Mage::registry('current_creditmemo'));
50
  $this->requestParams = array_merge($this->requestParams, $params);
51
  }
52
  }
54
  return $this;
55
  }
56
 
57
+ /**
58
+ * Returns the order helper for the corresponding transaction type
59
+ *
60
+ * @return Netresearch_OPS_Helper_Order_Abstract
61
+ */
62
+ public function getOrderHelper()
63
+ {
64
+ return Mage::helper('ops/order_refund');
65
+ }
66
+
67
+
68
+ }
app/code/community/Netresearch/OPS/Model/Config.php CHANGED
@@ -32,12 +32,13 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
32
  const OPS_PAYMENT_PATH = 'payment_services/ops/';
33
  const OPS_CONTROLLER_ROUTE_API = 'ops/api/';
34
  const OPS_CONTROLLER_ROUTE_PAYMENT = 'ops/payment/';
 
35
 
36
  /**
37
  * Return ops payment config information
38
  *
39
  * @param string $path
40
- * @param int $storeId
41
  *
42
  * @return Simple_Xml
43
  */
@@ -46,6 +47,7 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
46
  if (!empty($path)) {
47
  return Mage::getStoreConfig(self::OPS_PAYMENT_PATH . $path, $storeId);
48
  }
 
49
  return false;
50
  }
51
 
@@ -150,8 +152,10 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
150
  */
151
  public function getPayPageTemplate()
152
  {
153
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'paypage',
154
- array('_nosid' => true, '_secure' => $this->isCurrentlySecure()));
 
 
155
  }
156
 
157
  /**
@@ -161,26 +165,37 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
161
  */
162
  public function getAcceptUrl()
163
  {
164
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'accept',
165
- array('_nosid' => true, '_secure' => $this->isCurrentlySecure()));
 
 
166
  }
167
 
168
  /**
169
  * Return url which ops system will use as accept for alias generation
170
  *
 
 
 
171
  * @return string
172
  */
173
  public function getAliasAcceptUrl($storeId = null, $admin = false)
174
  {
175
  $params = array(
176
  '_secure' => $this->isCurrentlySecure(),
177
- '_nosid' => true
178
  );
179
  if (false === is_null($storeId)) {
180
  $params['_store'] = $storeId;
181
  }
182
- $urlModelKey = $admin ? 'adminhtml/url' : 'core/url';
183
- return Mage::getModel($urlModelKey)->getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'acceptAlias', $params);
 
 
 
 
 
 
184
  }
185
 
186
  /**
@@ -190,8 +205,10 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
190
  */
191
  public function getDeclineUrl()
192
  {
193
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'decline',
194
- array('_nosid' => true, '_secure' => $this->isCurrentlySecure()));
 
 
195
  }
196
 
197
  /**
@@ -201,26 +218,36 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
201
  */
202
  public function getExceptionUrl()
203
  {
204
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'exception',
205
- array('_nosid' => true, '_secure' => $this->isCurrentlySecure()));
 
 
206
  }
207
 
208
  /**
209
  * Return url which ops system will use as exception url for alias generation
210
  *
 
 
 
211
  * @return string
212
  */
213
  public function getAliasExceptionUrl($storeId = null, $admin = false)
214
  {
215
  $params = array(
216
  '_secure' => $this->isCurrentlySecure(),
217
- '_nosid' => true
218
  );
219
  if (false === is_null($storeId)) {
220
  $params['_store'] = $storeId;
221
  }
222
- $urlModelKey = $admin ? 'adminhtml/url' : 'core/url';
223
- return Mage::getModel($urlModelKey)->getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'exceptionAlias', $params);
 
 
 
 
 
224
  }
225
 
226
  /**
@@ -230,8 +257,10 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
230
  */
231
  public function getCancelUrl()
232
  {
233
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'cancel',
234
- array('_nosid' => true, '_secure' => $this->isCurrentlySecure()));
 
 
235
  }
236
 
237
  /**
@@ -244,7 +273,10 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
244
  public function getContinueUrl($redirect = array())
245
  {
246
  $urlParams = array('_nosid' => true, '_secure' => $this->isCurrentlySecure());
247
- if (!empty($redirect)) $urlParams = array_merge($redirect, $urlParams);
 
 
 
248
  return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'continue', $urlParams);
249
  }
250
 
@@ -255,8 +287,10 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
255
  */
256
  public function getPaymentRedirectUrl()
257
  {
258
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'placeform',
259
- array('_secure' => true, '_nosid' => true));
 
 
260
  }
261
 
262
  /**
@@ -266,33 +300,45 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
266
  */
267
  public function get3dSecureRedirectUrl()
268
  {
269
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'placeform3dsecure',
270
- array('_secure' => true, '_nosid' => true));
 
 
271
  }
272
 
273
  public function getSaveCcBrandUrl()
274
  {
275
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'saveCcBrand',
276
- array('_secure' => $this->isCurrentlySecure(), '_nosid' => true));
 
 
277
  }
278
 
279
  public function getGenerateHashUrl($storeId = null, $admin = false)
280
  {
281
  $params = array(
282
  '_secure' => $this->isCurrentlySecure(),
283
- '_nosid' => true
284
  );
285
  if (false === is_null($storeId)) {
286
  $params['_store'] = $storeId;
287
  }
288
- $urlModelKey = $admin ? 'adminhtml/url' : 'core/url';
289
- return Mage::getModel($urlModelKey)->getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'generatehash', $params);
 
 
 
 
 
 
290
  }
291
 
292
  public function getRegisterDirectDebitPaymentUrl()
293
  {
294
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'registerDirectDebitPayment',
295
- array('_secure' => $this->isCurrentlySecure(), '_nosid' => true));
 
 
296
  }
297
 
298
  /**
@@ -315,22 +361,30 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
315
  return Mage::getStoreConfig('payment_services/ops/showhomebutton');
316
  }
317
 
318
- public function getAcceptedCcTypes()
319
  {
320
- return Mage::getStoreConfig('payment/ops_cc/types');
321
  }
322
 
323
- public function getInlinePaymentCcTypes()
 
 
 
 
 
 
 
324
  {
325
- $redirectAll = (bool)(int)Mage::getStoreConfig('payment/ops_cc/redirect_all');
326
  if ($redirectAll) {
327
  return array();
328
  }
329
 
330
- $inlineTypes = Mage::getStoreConfig('payment/ops_cc/inline_types');
331
  if (false == is_array($inlineTypes)) {
332
  $inlineTypes = explode(',', $inlineTypes);
333
  }
 
334
  return $inlineTypes;
335
  }
336
 
@@ -354,9 +408,26 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
354
  return Mage::getStoreConfig('payment/ops_directEbanking/brands');
355
  }
356
 
 
 
 
 
 
 
 
357
  public function getAliasGatewayUrl($storeId = null)
358
  {
359
- return $this->determineOpsUrl('ops_alias_gateway', $storeId);
 
 
 
 
 
 
 
 
 
 
360
  }
361
 
362
  public function getCcSaveAliasUrl($storeId = null, $admin = false)
@@ -370,12 +441,12 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
370
  if ($admin) {
371
  return Mage::getModel('adminhtml/url')->getUrl('ops/admin/saveAlias', $params);
372
  } else {
373
- return Mage::getUrl('ops/payment/saveAlias', $params);
374
  }
375
  }
376
 
377
  /**
378
- * get deeplink to transaction view at Ingenico Payment Services
379
  *
380
  * @param Mage_Sales_Model_Order_Payment $payment
381
  *
@@ -391,13 +462,30 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
391
  return Mage::app()->getStore()->isCurrentlySecure();
392
  }
393
 
394
- public function getIntersolveBrands()
395
  {
396
  $result = array();
397
- $brands = Mage::getStoreConfig('payment/ops_interSolve/brands');
398
  if (!is_null($brands)) {
399
  $result = unserialize($brands);
400
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  return $result;
402
  }
403
 
@@ -406,6 +494,12 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
406
  return explode(',', Mage::getStoreConfig('payment/ops_cc/availableTypes'));
407
  }
408
 
 
 
 
 
 
 
409
  /**
410
  * get keys of parameters to be shown in scoring information block
411
  *
@@ -454,11 +548,14 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
454
  /**
455
  * return config value for Alias Manager enabled
456
  *
 
 
 
457
  * @return bool
458
  */
459
- public function isAliasManagerEnabled()
460
  {
461
- return (bool)Mage::getStoreConfig('payment/ops_cc/active_alias');
462
  }
463
 
464
  /**
@@ -480,18 +577,6 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
480
  return $this->getConfigData('showQuoteIdInOrderGrid', $storeId);
481
  }
482
 
483
- /**
484
- * @param int $storeId - the store id to use
485
- *
486
- * @return bool whether the tracking code fro fraud detection
487
- * is activated or not
488
- */
489
- public function isTrackingCodeActivated($storeId = null)
490
- {
491
- return (bool)$this->getConfigData('enableTrackingCode', $storeId);
492
- }
493
-
494
-
495
  /**
496
  * Check if the current environment is frontend or backend
497
  *
@@ -572,7 +657,7 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
572
  }
573
 
574
  /**
575
- * whether extra parameters needs to be passed to Ingenico Payment Services or not
576
  *
577
  * @param null $storeId
578
  *
@@ -596,8 +681,10 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
596
 
597
  public function getValidationUrl()
598
  {
599
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'validate',
600
- array('_secure' => $this->isCurrentlySecure(), '_nosid' => true));
 
 
601
  }
602
 
603
  public function getInlineOrderReference($storeId = null)
@@ -630,14 +717,14 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
630
  */
631
  public function getOpsBaseUrl($storeId = null)
632
  {
633
- return $this->getOpsUrl('base_'.$this->getMode($storeId));
634
  }
635
 
636
  /**
637
  * Returns the default url for the given gateway, depending on the mode, that is set for the the given store
638
  *
639
  * @param string $path
640
- * @param int $storeId
641
  *
642
  * @return string
643
  */
@@ -649,7 +736,7 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
649
  /**
650
  * Returns the url for the given gateway depending on the set mode for the given store
651
  *
652
- * @param $path
653
  * @param null $storeId
654
  *
655
  * @return string
@@ -683,10 +770,72 @@ class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
683
  return $this->getConfigData('ops_state_restriction');
684
  }
685
 
686
- public function getPaymentRetryUrl($params)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
687
  {
688
- return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'retry',
689
- array('_secure' => true, '_nosid' => true, '_query' => $params));
690
  }
691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
  }
 
32
  const OPS_PAYMENT_PATH = 'payment_services/ops/';
33
  const OPS_CONTROLLER_ROUTE_API = 'ops/api/';
34
  const OPS_CONTROLLER_ROUTE_PAYMENT = 'ops/payment/';
35
+ const OPS_CONTROLLER_ROUTE_ALIAS = 'ops/alias/';
36
 
37
  /**
38
  * Return ops payment config information
39
  *
40
  * @param string $path
41
+ * @param int $storeId
42
  *
43
  * @return Simple_Xml
44
  */
47
  if (!empty($path)) {
48
  return Mage::getStoreConfig(self::OPS_PAYMENT_PATH . $path, $storeId);
49
  }
50
+
51
  return false;
52
  }
53
 
152
  */
153
  public function getPayPageTemplate()
154
  {
155
+ return Mage::getUrl(
156
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'paypage',
157
+ array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
158
+ );
159
  }
160
 
161
  /**
165
  */
166
  public function getAcceptUrl()
167
  {
168
+ return Mage::getUrl(
169
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'accept',
170
+ array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
171
+ );
172
  }
173
 
174
  /**
175
  * Return url which ops system will use as accept for alias generation
176
  *
177
+ * @param int $storeId
178
+ * @param bool $admin
179
+ *
180
  * @return string
181
  */
182
  public function getAliasAcceptUrl($storeId = null, $admin = false)
183
  {
184
  $params = array(
185
  '_secure' => $this->isCurrentlySecure(),
186
+ '_nosid' => true
187
  );
188
  if (false === is_null($storeId)) {
189
  $params['_store'] = $storeId;
190
  }
191
+
192
+ if ($admin) {
193
+ $params['_nosecret'] = true;
194
+
195
+ return Mage::getModel('adminhtml/url')->getUrl('adminhtml/alias/accept', $params);
196
+ } else {
197
+ return Mage::getModel('core/url')->getUrl(self::OPS_CONTROLLER_ROUTE_ALIAS . 'accept', $params);
198
+ }
199
  }
200
 
201
  /**
205
  */
206
  public function getDeclineUrl()
207
  {
208
+ return Mage::getUrl(
209
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'decline',
210
+ array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
211
+ );
212
  }
213
 
214
  /**
218
  */
219
  public function getExceptionUrl()
220
  {
221
+ return Mage::getUrl(
222
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'exception',
223
+ array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
224
+ );
225
  }
226
 
227
  /**
228
  * Return url which ops system will use as exception url for alias generation
229
  *
230
+ * @param int $storeId
231
+ * @param bool $admin
232
+ *
233
  * @return string
234
  */
235
  public function getAliasExceptionUrl($storeId = null, $admin = false)
236
  {
237
  $params = array(
238
  '_secure' => $this->isCurrentlySecure(),
239
+ '_nosid' => true
240
  );
241
  if (false === is_null($storeId)) {
242
  $params['_store'] = $storeId;
243
  }
244
+ if ($admin) {
245
+ $params['_nosecret'] = true;
246
+
247
+ return Mage::getModel('adminhtml/url')->getUrl('adminhtml/alias/exception', $params);
248
+ } else {
249
+ return Mage::getModel('core/url')->getUrl(self::OPS_CONTROLLER_ROUTE_ALIAS . 'exception', $params);
250
+ }
251
  }
252
 
253
  /**
257
  */
258
  public function getCancelUrl()
259
  {
260
+ return Mage::getUrl(
261
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'cancel',
262
+ array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
263
+ );
264
  }
265
 
266
  /**
273
  public function getContinueUrl($redirect = array())
274
  {
275
  $urlParams = array('_nosid' => true, '_secure' => $this->isCurrentlySecure());
276
+ if (!empty($redirect)) {
277
+ $urlParams = array_merge($redirect, $urlParams);
278
+ }
279
+
280
  return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'continue', $urlParams);
281
  }
282
 
287
  */
288
  public function getPaymentRedirectUrl()
289
  {
290
+ return Mage::getUrl(
291
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'placeform',
292
+ array('_secure' => true, '_nosid' => true)
293
+ );
294
  }
295
 
296
  /**
300
  */
301
  public function get3dSecureRedirectUrl()
302
  {
303
+ return Mage::getUrl(
304
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'placeform3dsecure',
305
+ array('_secure' => true, '_nosid' => true)
306
+ );
307
  }
308
 
309
  public function getSaveCcBrandUrl()
310
  {
311
+ return Mage::getUrl(
312
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'saveCcBrand',
313
+ array('_secure' => $this->isCurrentlySecure(), '_nosid' => true)
314
+ );
315
  }
316
 
317
  public function getGenerateHashUrl($storeId = null, $admin = false)
318
  {
319
  $params = array(
320
  '_secure' => $this->isCurrentlySecure(),
321
+ '_nosid' => true,
322
  );
323
  if (false === is_null($storeId)) {
324
  $params['_store'] = $storeId;
325
  }
326
+ if ($admin) {
327
+ $params['_nosecret'] = true;
328
+
329
+ return Mage::getModel('adminhtml/url')->getUrl('adminhtml/alias/generatehash', $params);
330
+ } else {
331
+ return Mage::getModel('core/url')->getUrl(self::OPS_CONTROLLER_ROUTE_ALIAS . 'generatehash', $params);
332
+ }
333
+
334
  }
335
 
336
  public function getRegisterDirectDebitPaymentUrl()
337
  {
338
+ return Mage::getUrl(
339
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'registerDirectDebitPayment',
340
+ array('_secure' => $this->isCurrentlySecure(), '_nosid' => true)
341
+ );
342
  }
343
 
344
  /**
361
  return Mage::getStoreConfig('payment_services/ops/showhomebutton');
362
  }
363
 
364
+ public function getAcceptedCcTypes($code)
365
  {
366
+ return Mage::getStoreConfig('payment/' . $code . '/types');
367
  }
368
 
369
+ /**
370
+ * Returns the cc types for which inline payments are activated
371
+ *
372
+ * @param string $code
373
+ *
374
+ * @return string[]
375
+ */
376
+ public function getInlinePaymentCcTypes($code)
377
  {
378
+ $redirectAll = (bool)(int)Mage::getStoreConfig('payment/' . $code . '/redirect_all');
379
  if ($redirectAll) {
380
  return array();
381
  }
382
 
383
+ $inlineTypes = Mage::getStoreConfig('payment/' . $code . '/inline_types');
384
  if (false == is_array($inlineTypes)) {
385
  $inlineTypes = explode(',', $inlineTypes);
386
  }
387
+
388
  return $inlineTypes;
389
  }
390
 
408
  return Mage::getStoreConfig('payment/ops_directEbanking/brands');
409
  }
410
 
411
+ /**
412
+ * Returns the generated alias (hosted tokenization) url or the special url if needed by vendor
413
+ *
414
+ * @param null $storeId
415
+ *
416
+ * @return mixed|Simple_Xml|string
417
+ */
418
  public function getAliasGatewayUrl($storeId = null)
419
  {
420
+ $url = $this->determineOpsUrl('ops_alias_gateway', $storeId);
421
+
422
+ if ($this->getConfigData('ops_alias_gateway_test') != '') {
423
+ if ($this->getMode($storeId) == Netresearch_OPS_Model_Source_Mode::TEST) {
424
+ return $this->getConfigData('ops_alias_gateway_test');
425
+ } elseif ($this->getMode($storeId) == Netresearch_OPS_Model_Source_Mode::PROD) {
426
+ $url = str_replace('ncol/prod/', '', $url);
427
+ }
428
+ }
429
+
430
+ return $url;
431
  }
432
 
433
  public function getCcSaveAliasUrl($storeId = null, $admin = false)
441
  if ($admin) {
442
  return Mage::getModel('adminhtml/url')->getUrl('ops/admin/saveAlias', $params);
443
  } else {
444
+ return Mage::getUrl('ops/alias/save', $params);
445
  }
446
  }
447
 
448
  /**
449
+ * get deeplink to transaction view at Ingenico ePayments
450
  *
451
  * @param Mage_Sales_Model_Order_Payment $payment
452
  *
462
  return Mage::app()->getStore()->isCurrentlySecure();
463
  }
464
 
465
+ public function getIntersolveBrands($storeId = null)
466
  {
467
  $result = array();
468
+ $brands = Mage::getStoreConfig('payment/ops_interSolve/brands', $storeId);
469
  if (!is_null($brands)) {
470
  $result = unserialize($brands);
471
  }
472
+
473
+ return $result;
474
+ }
475
+
476
+ /**
477
+ * @param int $storeId
478
+ *
479
+ * @return string[][]
480
+ */
481
+ public function getFlexMethods($storeId = null)
482
+ {
483
+ $result = array();
484
+ $methods = Mage::getStoreConfig('payment/ops_flex/methods', $storeId);
485
+ if (!is_null($methods)) {
486
+ $result = unserialize($methods);
487
+ }
488
+
489
  return $result;
490
  }
491
 
494
  return explode(',', Mage::getStoreConfig('payment/ops_cc/availableTypes'));
495
  }
496
 
497
+
498
+ public function getAllDcTypes()
499
+ {
500
+ return explode(',', Mage::getStoreConfig('payment/ops_dc/availableTypes'));
501
+ }
502
+
503
  /**
504
  * get keys of parameters to be shown in scoring information block
505
  *
548
  /**
549
  * return config value for Alias Manager enabled
550
  *
551
+ * @param $code
552
+ * @param $storeId
553
+ *
554
  * @return bool
555
  */
556
+ public function isAliasManagerEnabled($code, $storeId = null)
557
  {
558
+ return (bool)Mage::getStoreConfig('payment/' . $code . '/active_alias', $storeId);
559
  }
560
 
561
  /**
577
  return $this->getConfigData('showQuoteIdInOrderGrid', $storeId);
578
  }
579
 
 
 
 
 
 
 
 
 
 
 
 
 
580
  /**
581
  * Check if the current environment is frontend or backend
582
  *
657
  }
658
 
659
  /**
660
+ * whether extra parameters needs to be passed to Ingenico ePayments or not
661
  *
662
  * @param null $storeId
663
  *
681
 
682
  public function getValidationUrl()
683
  {
684
+ return Mage::getUrl(
685
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'validate',
686
+ array('_secure' => $this->isCurrentlySecure(), '_nosid' => true)
687
+ );
688
  }
689
 
690
  public function getInlineOrderReference($storeId = null)
717
  */
718
  public function getOpsBaseUrl($storeId = null)
719
  {
720
+ return $this->getOpsUrl('base_' . $this->getMode($storeId));
721
  }
722
 
723
  /**
724
  * Returns the default url for the given gateway, depending on the mode, that is set for the the given store
725
  *
726
  * @param string $path
727
+ * @param int $storeId
728
  *
729
  * @return string
730
  */
736
  /**
737
  * Returns the url for the given gateway depending on the set mode for the given store
738
  *
739
+ * @param $path
740
  * @param null $storeId
741
  *
742
  * @return string
770
  return $this->getConfigData('ops_state_restriction');
771
  }
772
 
773
+ public function getPaymentRetryUrl($params, $storeId = null)
774
+ {
775
+ return Mage::getUrl(
776
+ self::OPS_CONTROLLER_ROUTE_PAYMENT . 'retry',
777
+ array('_secure' => true, '_nosid' => true, '_query' => $params, '_store' => $storeId)
778
+ );
779
+ }
780
+
781
+ /**
782
+ * Will return the state of the deviceFingerPrinting:
783
+ * - true if activated in config
784
+ * - false if deactivated in config
785
+ *
786
+ * @param int $storeId
787
+ *
788
+ * @return bool
789
+ */
790
+ public function getDeviceFingerPrinting($storeId = null)
791
+ {
792
+ return (bool)$this->getConfigData('device_fingerprinting', $storeId);
793
+ }
794
+
795
+ public function getTransActionTimeout($storeId = null)
796
+ {
797
+ return (int)$this->getConfigData('ops_rtimeout', $storeId);
798
+ }
799
+
800
+ /**
801
+ *
802
+ * @param int|null $storeId
803
+ *
804
+ * @return bool
805
+ */
806
+ public function getCreditDebitSplit($storeId = null)
807
+ {
808
+ return (bool)$this->getConfigData('creditdebit_split', $storeId);
809
+ }
810
+
811
+ public function getAllRecurringCcTypes()
812
  {
813
+ return explode(',', Mage::getStoreConfig('payment/ops_recurring_cc/availableTypes'));
 
814
  }
815
 
816
+ public function getAcceptedRecurringCcTypes()
817
+ {
818
+ return explode(',', Mage::getStoreConfig('payment/ops_recurring_cc/acceptedTypes'));
819
+ }
820
+
821
+ public function getMonthlyBillingDay($storeId = null)
822
+ {
823
+ return Mage::getStoreConfig(self::OPS_PAYMENT_PATH . 'billing_day_month', $storeId);
824
+ }
825
+
826
+ public function getWeeklyBillingDay($storeId = null)
827
+ {
828
+ return Mage::getStoreConfig(self::OPS_PAYMENT_PATH . 'billing_day_week', $storeId);
829
+ }
830
+
831
+ public function getSuspendSubscriptionTemplate($storeId = null)
832
+ {
833
+ return $this->getConfigData('suspendSubscription_template', $storeId);
834
+ }
835
+
836
+ public function getSuspendSubscriptionIdentity($storeId = null)
837
+ {
838
+ return $this->getConfigData('suspendSubscription_identity', $storeId);
839
+ }
840
  }
841
+
app/code/community/Netresearch/OPS/Model/Observer.php CHANGED
@@ -14,7 +14,6 @@
14
  * @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
17
-
18
  class Netresearch_OPS_Model_Observer
19
  {
20
 
@@ -39,14 +38,16 @@ class Netresearch_OPS_Model_Observer
39
  if ($this->getAdminSession()->getUser()) {
40
  return 0 < $this->getAdminSession()->getUser()->getUserId();
41
  }
 
42
  return false;
43
  }
44
 
45
- public function getHelper($name=null)
46
  {
47
  if (is_null($name)) {
48
  return Mage::helper('ops');
49
  }
 
50
  return Mage::helper('ops/' . $name);
51
  }
52
 
@@ -68,7 +69,11 @@ class Netresearch_OPS_Model_Observer
68
  $code = $quote->getPayment()->getMethodInstance()->getCode();
69
 
70
  try {
71
- if ('ops_directDebit' == $code && Mage::helper('ops/payment')->isInlinePaymentWithQuoteId($quote->getPayment())) {
 
 
 
 
72
  $this->confirmDdPayment($order, $quote, $observer);
73
  } elseif ($quote->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
74
  $requestParams = $quote->getPayment()->getMethodInstance()->getFormFields($order, array(), false);
@@ -130,10 +135,10 @@ class Netresearch_OPS_Model_Observer
130
  /**
131
  * allow null as valid state for creating the order with status 'pending'
132
  */
133
- if (!is_null($response['STATUS'])
134
  && Mage::helper('ops/payment')->isPaymentFailed($response['STATUS'])
135
- ) {
136
- throw new Mage_Core_Exception($this->getHelper()->__('Ingenico Payment Services Payment failed'));
137
  }
138
  $quote->getPayment()->setAdditionalInformation('ops_response', $response)->save();
139
 
@@ -147,17 +152,20 @@ class Netresearch_OPS_Model_Observer
147
  */
148
  protected function isCheckoutWithExistingTxId($code)
149
  {
150
- if ('ops_opsid' == $code)
151
  return true;
152
- else
153
  return false;
 
154
  }
155
 
156
  /**
157
- * Replace order cancel comfirm message of Magento by a custom message from Ingenico Payment Services
158
  *
159
  * @event adminhtml_block_html_before
 
160
  * @param Varien_Event_Observer $observer
 
161
  * @return Netresearch_OPS_Model_Observer
162
  */
163
  public function updateOrderCancelButton(Varien_Event_Observer $observer)
@@ -170,28 +178,32 @@ class Netresearch_OPS_Model_Observer
170
  return $this;
171
  }
172
 
173
- //If payment method is one of the Ingenico Payment Services-ones and order can be cancelled manually
174
  if ($block->getOrder()->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract
175
- && true === $block->getOrder()->getPayment()->getMethodInstance()->canCancelManually($block->getOrder())) {
 
176
  //Build message and update cancel button
177
  $message = Mage::helper('ops')->__(
178
- "Are you sure you want to cancel this order? Warning: Please check the payment status in the back-office of Ingenico Payment Services before. By cancelling this order you won\\'t be able to update the status in Magento anymore."
179
  );
180
  $block->updateButton(
181
  'order_cancel',
182
  'onclick',
183
- 'deleteConfirm(\''.$message.'\', \'' . $block->getCancelUrl() . '\')'
184
  );
185
  }
 
186
  return $this;
187
  }
188
 
189
  /**
190
  *
191
- * appends a checkbox for closing the transaction if it's a Ingenico Payment Services payment
192
  *
193
  * @event core_block_abstract_to_html_after
 
194
  * @param Varien_Event_Observer $observer
 
195
  * @return void
196
  */
197
  public function appendCheckBoxToRefundForm($observer)
@@ -199,24 +211,24 @@ class Netresearch_OPS_Model_Observer
199
  $html = '';
200
  /*
201
  * show the checkbox only if the credit memo create page is displayed and
202
- * the refund can be done online and the payment is done via Ingenico Payment Services
203
  */
204
  if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
205
- && $observer->getBlock()->getParentBlock()
206
- instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items
207
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->getOrder()->getPayment()
208
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->getOrder()->getPayment()->getMethodInstance()
209
- instanceof Netresearch_OPS_Model_Payment_Abstract
210
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->canRefund()
211
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->getInvoice()
212
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->getInvoice()->getTransactionId()
213
  ) {
214
  $transport = $observer->getTransport();
215
- $block = $observer->getBlock();
216
- $layout = $block->getLayout();
217
- $html = $transport->getHtml();
218
  $checkBoxHtml = $layout->createBlock(
219
- 'ops/adminhtml_sales_order_creditmemo_totals_checkbox',
220
  'ops_refund_checkbox'
221
  )
222
  ->setTemplate('ops/sales/order/creditmemo/totals/checkbox.phtml')
@@ -224,6 +236,7 @@ class Netresearch_OPS_Model_Observer
224
  $html = $html . $checkBoxHtml;
225
  $transport->setHtml($html);
226
  }
 
227
  return $html;
228
  }
229
 
@@ -231,11 +244,13 @@ class Netresearch_OPS_Model_Observer
231
  *
232
  * fetch the creation of credit memo event and display warning message when
233
  * - credit memo could be done online
234
- * - payment is a Ingenico Payment Services payment
235
- * - Ingenico Payment Services transaction is closed
236
  *
237
  * @event core_block_abstract_to_html_after
 
238
  * @param Varien_Event_Observer $observer
 
239
  * @return void
240
  */
241
  public function showWarningForClosedTransactions($observer)
@@ -243,35 +258,36 @@ class Netresearch_OPS_Model_Observer
243
  $html = '';
244
  /**
245
  * - credit memo could be done online
246
- * - payment is a Ingenico Payment Services payment
247
- * - Ingenico Payment Services transaction is closed
248
  */
249
  if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create
250
  && $observer->getBlock()->getCreditmemo()->getOrder()->getPayment()
251
  && $observer->getBlock()->getCreditmemo()->getOrder()->getPayment()->getMethodInstance()
252
- instanceof Netresearch_OPS_Model_Payment_Abstract
253
  && $observer->getBlock()->getCreditmemo()->getInvoice()
254
  && $observer->getBlock()->getCreditmemo()->getInvoice()->getTransactionId()
255
  && false === $observer->getBlock()->getCreditmemo()->canRefund()
256
  ) {
257
  $transport = $observer->getTransport();
258
- $block = $observer->getBlock();
259
- $layout = $block->getLayout();
260
- $html = $transport->getHtml();
261
  $warningHtml = $layout->createBlock(
262
- 'ops/adminhtml_sales_order_creditmemo_closedTransaction_warning',
263
  'ops_closed-transaction-warning'
264
- )
265
- ->renderView();
266
- $html = $warningHtml . $html;
267
  $transport->setHtml($html);
268
  }
 
269
  return $html;
270
  }
271
 
272
 
273
  /**
274
  * triggered by cron for deleting old payment data from the additional payment information
 
275
  * @param $observer
276
  */
277
  public function cleanUpOldPaymentData($observer)
@@ -284,7 +300,9 @@ class Netresearch_OPS_Model_Observer
284
  * payment method in the quote's payment before importing the data
285
  *
286
  * @event sales_quote_payment_import_data_before
 
287
  * @param $observer
 
288
  * @return $this
289
  */
290
  public function clearPaymentMethodFromQuote(Varien_Event_Observer $observer)
@@ -299,10 +317,12 @@ class Netresearch_OPS_Model_Observer
299
  }
300
 
301
  /**
302
- * appends the status update button to the order's button in case it's an Ingenico Payment Services payment
303
  *
304
  * @event core_block_abstract_prepare_layout_before
 
305
  * @param Varien_Event_Observer $observer
 
306
  * @return $this
307
  */
308
  public function addStatusUpdateButtonToOrderView(Varien_Event_Observer $observer)
@@ -311,10 +331,14 @@ class Netresearch_OPS_Model_Observer
311
  if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
312
  $paymentMethod = $block->getOrder()->getPayment()->getMethodInstance();
313
  if ($paymentMethod instanceof Netresearch_OPS_Model_Payment_Abstract
314
- && Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/invoice')) {
315
- $block->addButton('ops_refresh', array(
316
- 'label' => Mage::helper('ops/data')->__('Refresh payment status'),
317
- 'onclick' => 'setLocation(\'' . $block->getUrl('adminhtml/opsstatus/update') . '\')'));
 
 
 
 
318
  }
319
  }
320
 
@@ -325,6 +349,7 @@ class Netresearch_OPS_Model_Observer
325
  * @event core_block_abstract_prepare_layout_before
326
  *
327
  * @param Varien_Event_Observer $observer
 
328
  * @return $this
329
  */
330
  public function addCcPaymentMethod(Varien_Event_Observer $observer)
@@ -378,7 +403,7 @@ class Netresearch_OPS_Model_Observer
378
  if (false == $validator->isValid($requestParams)) {
379
  $this->getOnepage()->getCheckout()->setGotoSection('payment');
380
  Mage::throwException(
381
- $this->getHelper()->__('The data you have provided can not be processed by Ingenico Payment Services')
382
  );
383
  }
384
 
@@ -386,33 +411,11 @@ class Netresearch_OPS_Model_Observer
386
  }
387
 
388
 
389
- /**
390
- * @event sales_order_save_before
391
- * @param Varien_Event_Observer $observer
392
- * @return Netresearch_OPS_Model_Observer
393
- */
394
- public function checkForOpsStatus(Varien_Event_Observer $observer)
395
- {
396
- if ($this->getConfig()->getStateRestriction() == 1) {
397
- $order = $observer->getOrder();
398
- $origData = $order->getOrigData();
399
- if (is_array($origData)
400
- && array_key_exists('status', $origData)
401
- && $order->getStatus() != $origData['status']
402
- && $order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract
403
- && Mage::helper('ops/data')->isAdminSession()
404
- ) {
405
- Mage::helper('ops/order')
406
- ->checkForOpsStateOnStatusUpdate($order);
407
- }
408
- }
409
- return $this;
410
- }
411
-
412
  /**
413
  * validates the input fields after the payment step in OPC
414
  *
415
  * @event controller_action_postdispatch_checkout_onepage_savePayment
 
416
  * @param Varien_Event_Observer $event
417
  *
418
  * @return $this
@@ -424,7 +427,7 @@ class Netresearch_OPS_Model_Observer
424
  if ($quote->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
425
  $paramHelper = Mage::helper('ops/payment_request');
426
  $shippingParams = array();
427
- $billingParams = $paramHelper->getOwnerParams($quote, $quote->getBillingAddress());
428
  if ($quote->getShippingAddress()) {
429
  $shippingParams = $paramHelper->extractShipToParameters($quote->getShippingAddress(), $quote);
430
  }
@@ -459,107 +462,202 @@ class Netresearch_OPS_Model_Observer
459
  }
460
 
461
  /**
462
- * @event core_block_abstract_to_html_after
 
 
 
463
  * @param Varien_Event_Observer $event
464
- * @return Netresearch_OPS_Model_Observer
465
  */
466
- public function appendPartialCaptureWarningForOpenInvoice(Varien_Event_Observer $event)
467
  {
468
- $block = $event->getBlock();
469
- if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Invoice_Totals
470
- && $block->getInvoice()->getOrder()->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_OpenInvoice_Abstract
471
- && $block->getInvoice()->getOrder()->getPayment()->getMethodInstance()->canCapturePartial() === true
 
 
 
472
  ) {
473
- $transport = $event->getTransport();
474
- $layout = $block->getLayout();
475
- $html = $transport->getHtml();
476
- $warningHtml = $layout->createBlock(
477
- 'ops/adminhtml_sales_order_invoice_warning_openInvoice',
478
- 'ops_invoice-openInvoice-warning'
479
- )
480
- ->renderView();
481
- $html = $html . $warningHtml ;
482
- $transport->setHtml($html);
483
  }
 
484
 
485
- return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  }
487
-
488
  /**
489
- * resets the order status back to pending payment in case of direct debits nl with order id as merchant ref
490
- * @event sales_order_payment_place_end
491
- * @param Varien_Event_Observer $event
 
 
 
492
  */
493
- public function setOrderStateForDirectDebitsNl(Varien_Event_Observer $event)
494
  {
495
- $payment = $event->getPayment();
496
- if ($payment->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_DirectDebit
497
- && Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment)
498
- && $payment->getAdditionalInformation('PM') == 'Direct Debits NL'
499
- && $payment->getAdditionalInformation('STATUS') == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
  ) {
501
- $payment->getOrder()->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
502
- $payment->getOrder()->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
503
  }
 
 
504
  }
505
 
 
506
  /**
 
507
  *
508
- * @event core_block_abstract_to_html_after
509
- * @param Varien_Event_Observer $event
510
- * @return string
511
  */
512
- public function appendWarningToRefundFormForOpenInvoiceNl(Varien_Event_Observer $event)
513
  {
514
- $html = '';
515
- if ($event->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
516
- && $event->getBlock()->getParentBlock()
517
- instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items
518
- && $event->getBlock()->getParentBlock()->getCreditmemo()->getOrder()->getPayment()
519
- && $event->getBlock()->getParentBlock()->getCreditmemo()->getOrder()->getPayment()->getMethodInstance()
520
- instanceof Netresearch_OPS_Model_Payment_OpenInvoiceNl
521
- && $event->getBlock()->getParentBlock()->getCreditmemo()->canRefund()
522
- && $event->getBlock()->getParentBlock()->getCreditmemo()->getInvoice()
523
- && $event->getBlock()->getParentBlock()->getCreditmemo()->getInvoice()->getTransactionId()
524
  ) {
525
- $transport = $event->getTransport();
526
- $block = $event->getBlock();
527
- $layout = $block->getLayout();
528
- $html = $transport->getHtml();
529
- $warningHtml = $layout->createBlock(
530
- 'ops/adminhtml_sales_order_creditmemo_warning_openInvoiceNl',
531
- 'ops_openinvoice-warning'
532
- )
533
- ->renderView();
534
- $html = $warningHtml . $html;
535
- $transport->setHtml($html);
 
 
 
 
 
 
 
536
  }
537
- return $html;
 
538
  }
539
 
540
  /**
541
- * appends the resend payment info button to the order's button in case it's an Ingenico Payment Services payment
542
- * and the payment status is an authorize status
543
  *
544
- * @event core_block_abstract_prepare_layout_before
545
  * @param Varien_Event_Observer $observer
 
 
546
  * @return $this
547
  */
548
- public function addResendPaymentInfoButtonToOrderView(Varien_Event_Observer $observer)
549
  {
550
- $block = $observer->getBlock();
551
- if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
552
- $payment = $block->getOrder()->getPayment();
553
- $paymentMethod = $payment->getMethodInstance();
554
- if ($paymentMethod instanceof Netresearch_OPS_Model_Payment_Abstract
555
- && Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/invoice')
556
- && is_array($payment->getAdditionalInformation())
557
- && array_key_exists('status', $payment->getAdditionalInformation())
558
- && $this->getHelper('payment')->isPaymentFailed($payment->getAdditionalInformation('status'))) {
559
- $block->addButton('ops_resend_info', array(
560
- 'label' => Mage::helper('ops/data')->__('Resend payment information'),
561
- 'onclick' => 'setLocation(\'' . $block->getUrl('adminhtml/admin/resendInfo') . '\')'));
562
- }
 
563
  }
564
 
565
  return $this;
14
  * @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
 
17
  class Netresearch_OPS_Model_Observer
18
  {
19
 
38
  if ($this->getAdminSession()->getUser()) {
39
  return 0 < $this->getAdminSession()->getUser()->getUserId();
40
  }
41
+
42
  return false;
43
  }
44
 
45
+ public function getHelper($name = null)
46
  {
47
  if (is_null($name)) {
48
  return Mage::helper('ops');
49
  }
50
+
51
  return Mage::helper('ops/' . $name);
52
  }
53
 
69
  $code = $quote->getPayment()->getMethodInstance()->getCode();
70
 
71
  try {
72
+ if ('ops_directDebit' == $code
73
+ && Mage::helper('ops/payment')->isInlinePaymentWithQuoteId(
74
+ $quote->getPayment()
75
+ )
76
+ ) {
77
  $this->confirmDdPayment($order, $quote, $observer);
78
  } elseif ($quote->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
79
  $requestParams = $quote->getPayment()->getMethodInstance()->getFormFields($order, array(), false);
135
  /**
136
  * allow null as valid state for creating the order with status 'pending'
137
  */
138
+ if (!is_null($response['STATUS'])
139
  && Mage::helper('ops/payment')->isPaymentFailed($response['STATUS'])
140
+ ) {
141
+ throw new Mage_Core_Exception($this->getHelper()->__('Ingenico ePayments Payment failed'));
142
  }
143
  $quote->getPayment()->setAdditionalInformation('ops_response', $response)->save();
144
 
152
  */
153
  protected function isCheckoutWithExistingTxId($code)
154
  {
155
+ if ('ops_opsid' == $code) {
156
  return true;
157
+ } else {
158
  return false;
159
+ }
160
  }
161
 
162
  /**
163
+ * Replace order cancel comfirm message of Magento by a custom message from Ingenico ePayments
164
  *
165
  * @event adminhtml_block_html_before
166
+ *
167
  * @param Varien_Event_Observer $observer
168
+ *
169
  * @return Netresearch_OPS_Model_Observer
170
  */
171
  public function updateOrderCancelButton(Varien_Event_Observer $observer)
178
  return $this;
179
  }
180
 
181
+ //If payment method is one of the Ingenico ePayments-ones and order can be cancelled manually
182
  if ($block->getOrder()->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract
183
+ && true === $block->getOrder()->getPayment()->getMethodInstance()->canCancelManually($block->getOrder())
184
+ ) {
185
  //Build message and update cancel button
186
  $message = Mage::helper('ops')->__(
187
+ "Are you sure you want to cancel this order? Warning: Please check the payment status in the back-office of Ingenico ePayments before. By cancelling this order you won\\'t be able to update the status in Magento anymore."
188
  );
189
  $block->updateButton(
190
  'order_cancel',
191
  'onclick',
192
+ 'deleteConfirm(\'' . $message . '\', \'' . $block->getCancelUrl() . '\')'
193
  );
194
  }
195
+
196
  return $this;
197
  }
198
 
199
  /**
200
  *
201
+ * appends a checkbox for closing the transaction if it's a Ingenico ePayments payment
202
  *
203
  * @event core_block_abstract_to_html_after
204
+ *
205
  * @param Varien_Event_Observer $observer
206
+ *
207
  * @return void
208
  */
209
  public function appendCheckBoxToRefundForm($observer)
211
  $html = '';
212
  /*
213
  * show the checkbox only if the credit memo create page is displayed and
214
+ * the refund can be done online and the payment is done via Ingenico ePayments
215
  */
216
  if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
217
+ && $observer->getBlock()->getParentBlock()
218
+ instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items
219
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->getOrder()->getPayment()
220
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->getOrder()->getPayment()->getMethodInstance()
221
+ instanceof Netresearch_OPS_Model_Payment_Abstract
222
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->canRefund()
223
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->getInvoice()
224
  && $observer->getBlock()->getParentBlock()->getCreditmemo()->getInvoice()->getTransactionId()
225
  ) {
226
  $transport = $observer->getTransport();
227
+ $block = $observer->getBlock();
228
+ $layout = $block->getLayout();
229
+ $html = $transport->getHtml();
230
  $checkBoxHtml = $layout->createBlock(
231
+ 'ops/adminhtml_sales_order_creditmemo_totals_checkbox',
232
  'ops_refund_checkbox'
233
  )
234
  ->setTemplate('ops/sales/order/creditmemo/totals/checkbox.phtml')
236
  $html = $html . $checkBoxHtml;
237
  $transport->setHtml($html);
238
  }
239
+
240
  return $html;
241
  }
242
 
244
  *
245
  * fetch the creation of credit memo event and display warning message when
246
  * - credit memo could be done online
247
+ * - payment is a Ingenico ePayments payment
248
+ * - Ingenico ePayments transaction is closed
249
  *
250
  * @event core_block_abstract_to_html_after
251
+ *
252
  * @param Varien_Event_Observer $observer
253
+ *
254
  * @return void
255
  */
256
  public function showWarningForClosedTransactions($observer)
258
  $html = '';
259
  /**
260
  * - credit memo could be done online
261
+ * - payment is a Ingenico ePayments payment
262
+ * - Ingenico ePayments transaction is closed
263
  */
264
  if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create
265
  && $observer->getBlock()->getCreditmemo()->getOrder()->getPayment()
266
  && $observer->getBlock()->getCreditmemo()->getOrder()->getPayment()->getMethodInstance()
267
+ instanceof Netresearch_OPS_Model_Payment_Abstract
268
  && $observer->getBlock()->getCreditmemo()->getInvoice()
269
  && $observer->getBlock()->getCreditmemo()->getInvoice()->getTransactionId()
270
  && false === $observer->getBlock()->getCreditmemo()->canRefund()
271
  ) {
272
  $transport = $observer->getTransport();
273
+ $block = $observer->getBlock();
274
+ $layout = $block->getLayout();
275
+ $html = $transport->getHtml();
276
  $warningHtml = $layout->createBlock(
277
+ 'ops/adminhtml_sales_order_creditmemo_closedTransaction_warning',
278
  'ops_closed-transaction-warning'
279
+ )->renderView();
280
+ $html = $warningHtml . $html;
 
281
  $transport->setHtml($html);
282
  }
283
+
284
  return $html;
285
  }
286
 
287
 
288
  /**
289
  * triggered by cron for deleting old payment data from the additional payment information
290
+ *
291
  * @param $observer
292
  */
293
  public function cleanUpOldPaymentData($observer)
300
  * payment method in the quote's payment before importing the data
301
  *
302
  * @event sales_quote_payment_import_data_before
303
+ *
304
  * @param $observer
305
+ *
306
  * @return $this
307
  */
308
  public function clearPaymentMethodFromQuote(Varien_Event_Observer $observer)
317
  }
318
 
319
  /**
320
+ * appends the status update button to the order's button in case it's an Ingenico ePayments payment
321
  *
322
  * @event core_block_abstract_prepare_layout_before
323
+ *
324
  * @param Varien_Event_Observer $observer
325
+ *
326
  * @return $this
327
  */
328
  public function addStatusUpdateButtonToOrderView(Varien_Event_Observer $observer)
331
  if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
332
  $paymentMethod = $block->getOrder()->getPayment()->getMethodInstance();
333
  if ($paymentMethod instanceof Netresearch_OPS_Model_Payment_Abstract
334
+ && Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/invoice')
335
+ ) {
336
+
337
+ $block->addButton(
338
+ 'ops_refresh', array(
339
+ 'label' => Mage::helper('ops/data')->__('Refresh payment status'),
340
+ 'onclick' => 'setLocation(\'' . $block->getUrl('adminhtml/opsstatus/update') . '\')')
341
+ );
342
  }
343
  }
344
 
349
  * @event core_block_abstract_prepare_layout_before
350
  *
351
  * @param Varien_Event_Observer $observer
352
+ *
353
  * @return $this
354
  */
355
  public function addCcPaymentMethod(Varien_Event_Observer $observer)
403
  if (false == $validator->isValid($requestParams)) {
404
  $this->getOnepage()->getCheckout()->setGotoSection('payment');
405
  Mage::throwException(
406
+ $this->getHelper()->__('The data you have provided can not be processed by Ingenico ePayments')
407
  );
408
  }
409
 
411
  }
412
 
413
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  /**
415
  * validates the input fields after the payment step in OPC
416
  *
417
  * @event controller_action_postdispatch_checkout_onepage_savePayment
418
+ *
419
  * @param Varien_Event_Observer $event
420
  *
421
  * @return $this
427
  if ($quote->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
428
  $paramHelper = Mage::helper('ops/payment_request');
429
  $shippingParams = array();
430
+ $billingParams = $paramHelper->getOwnerParams($quote->getBillingAddress(), $quote);
431
  if ($quote->getShippingAddress()) {
432
  $shippingParams = $paramHelper->extractShipToParameters($quote->getShippingAddress(), $quote);
433
  }
462
  }
463
 
464
  /**
465
+ * resets the order status back to pending payment in case of directlink payments in Ingenico ePayments authorize status
466
+ *
467
+ * @event sales_order_payment_place_end
468
+ *
469
  * @param Varien_Event_Observer $event
 
470
  */
471
+ public function setOrderStateDirectLink(Varien_Event_Observer $event)
472
  {
473
+ /** @var Mage_Sales_Model_Order_Payment $payment */
474
+ $payment = $event->getPayment();
475
+
476
+ if ($payment->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_DirectLink
477
+ && Mage::helper('ops/payment')->isInlinePayment($payment)
478
+ && Netresearch_OPS_Model_Status::AUTHORIZED == $payment->getAdditionalInformation('status')
479
+ && $payment->getOrder()->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
480
  ) {
481
+ $payment->getOrder()->setState(
482
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true,
483
+ $this->getHelper()->__('Payment has been authorized by Ingenico ePayments, but not yet captured.')
484
+ );
 
 
 
 
 
 
485
  }
486
+ }
487
 
488
+
489
+ /**
490
+ * appends the resend payment info button to the order's button in case it's an Ingenico ePayments payment
491
+ * and the payment status is an authorize status
492
+ *
493
+ * @event core_block_abstract_prepare_layout_before
494
+ *
495
+ * @param Varien_Event_Observer $observer
496
+ *
497
+ * @return $this
498
+ */
499
+ public function addResendPaymentInfoButtonToOrderView(Varien_Event_Observer $observer)
500
+ {
501
+ $block = $observer->getBlock();
502
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
503
+ $payment = $block->getOrder()->getPayment();
504
+ $paymentMethod = $payment->getMethodInstance();
505
+ if ($paymentMethod instanceof Netresearch_OPS_Model_Payment_Abstract
506
+ && Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/invoice')
507
+ && Netresearch_OPS_Model_Status::canResendPaymentInfo($payment->getAdditionalInformation('status'))
508
+ && !in_array(
509
+ $block->getOrder()->getState(),
510
+ array(
511
+ Mage_Sales_Model_Order::STATE_CANCELED,
512
+ Mage_Sales_Model_Order::STATE_CLOSED,
513
+ Mage_Sales_Model_Order::STATE_COMPLETE
514
+ )
515
+ )
516
+ ) {
517
+ $block->addButton(
518
+ 'ops_resend_info', array(
519
+ 'label' => Mage::helper('ops/data')->__('Resend payment information'),
520
+ 'onclick' => 'setLocation(\'' . $block->getUrl('adminhtml/admin/resendInfo') . '\')')
521
+ );
522
+ }
523
+ }
524
  }
525
+
526
  /**
527
+ * Adjusts the confirmation message text of the recurring profiles cancel and suspend button to inform the merchant
528
+ * that no call to Ingenico ePayments will happen
529
+ *
530
+ * @event adminhtml_block_html_before
531
+ *
532
+ * @param Varien_Event_Observer $observer
533
  */
534
+ public function updateRecurringProfileButtons(Varien_Event_Observer $observer)
535
  {
536
+ /** @var $block Mage_Sales_Block_Adminhtml_Recurring_Profile_View */
537
+ $block = $observer->getEvent()->getBlock();
538
+
539
+ if ($block->getType() == 'sales/adminhtml_recurring_profile_view') {
540
+ $profile = Mage::registry('current_recurring_profile');
541
+ if ($profile->getMethodCode() == Netresearch_OPS_Model_Payment_Recurring_Cc::CODE) {
542
+ $cancelMessage = Mage::helper('ops')
543
+ ->__(
544
+ 'Are you sure you want to perform this action? Canceling the subscription here will not actually cancel the subscription on Ingenico ePayments side. To stop charging the customer you will have to deactivate the subscription there.'
545
+ );
546
+ $cancelUrl = $block->getUrl(
547
+ '*/*/updateState',
548
+ array('profile' => $profile->getId(), 'action' => 'cancel')
549
+ );
550
+
551
+ $block->updateButton(
552
+ 'cancel',
553
+ 'onclick',
554
+ "confirmSetLocation('{$cancelMessage}', '{$cancelUrl}')"
555
+ );
556
+
557
+ $suspendMessage = Mage::helper('ops')
558
+ ->__(
559
+ 'Are you sure you want to perform this action? Suspending the subscription here will not actually cancel the subscription on Ingenico ePayments side. To stop charging the customer you will have to deactivate the subscription there.'
560
+ );
561
+ $suspendUrl = $block->getUrl(
562
+ '*/*/updateState',
563
+ array('profile' => $profile->getId(), 'action' => 'suspend')
564
+ );
565
+
566
+ $block->updateButton(
567
+ 'suspend',
568
+ 'onclick',
569
+ "confirmSetLocation('{$suspendMessage}', '{$suspendUrl}')"
570
+ );
571
+ }
572
+ }
573
+ }
574
+
575
+ /**
576
+ * Overwrites the state of the recurring profile if necessary
577
+ *
578
+ * @event model_save_before - due to lack of event prefix for recurring profile models
579
+ *
580
+ * @param Varien_Event_Observer $observer
581
+ *
582
+ * @return $this
583
+ */
584
+ public function overrideRecurringProfileState(Varien_Event_Observer $observer)
585
+ {
586
+ $object = $observer->getObject();
587
+
588
+ /** @var $object Mage_Payment_Model_Recurring_Profile */
589
+ if ($object instanceof Mage_Payment_Model_Recurring_Profile
590
+ && $object->getMethodCode() === Netresearch_OPS_Model_Payment_Recurring_Cc::CODE
591
+ && $object->getState() != $object->getNewState()
592
+ && $object->getOverrideState() === true
593
  ) {
594
+ $object->setState($object->getNewState());
 
595
  }
596
+
597
+ return $this;
598
  }
599
 
600
+
601
  /**
602
+ * @event adminhtml_block_html_before
603
  *
604
+ * @param Varien_Event_Observer $observer
605
+ *
606
+ * @return $this
607
  */
608
+ public function updateRecurringProfileEditForm(Varien_Event_Observer $observer)
609
  {
610
+ if ($observer->getBlock() instanceof Mage_Sales_Block_Adminhtml_Recurring_Profile_Edit_Form
611
+ && Mage::getModel('ops/payment_recurring_cc')->getConfigData('active')
 
 
 
 
 
 
 
 
612
  ) {
613
+ /** @var Mage_Sales_Block_Adminhtml_Recurring_Profile_Edit_Form $form */
614
+ $html = $observer->getTransport()->getHtml();
615
+
616
+ $method = Mage::getModel('ops/payment_recurring_cc');
617
+
618
+ $message = Mage::helper('ops')
619
+ ->__(
620
+ "When using %s as payment method the settings for '%s' and '%s' will not be processed.",
621
+ $method->getTitle(),
622
+ Mage::helper('payment')->__('Allow Initial Fee Failure'),
623
+ Mage::helper('payment')->__('Maximum Payment Failures')
624
+ );
625
+
626
+ $message = '<div class="notice-msg" style="padding-left: 26px;"><p style="padding: 7px;">' . $message
627
+ . '</p></div>';
628
+ $observer->getTransport()->setHtml($html . $message);
629
+
630
+
631
  }
632
+
633
+ return $this;
634
  }
635
 
636
  /**
637
+ * Since there is no other way for inline payments to change the order state, we enforce the pending_payment state
638
+ * for only authorized, not yet payed orders
639
  *
 
640
  * @param Varien_Event_Observer $observer
641
+ *
642
+ * @event sales_order_payment_place_end
643
  * @return $this
644
  */
645
+ public function enforcePaymentPendingForAuthorizedOrders(Varien_Event_Observer $observer)
646
  {
647
+ /** @var Mage_Sales_Model_Order_Payment $payment */
648
+ $payment = $observer->getData('payment');
649
+ /** @var Mage_Sales_Model_Order $order */
650
+ $order = $payment->getOrder();
651
+
652
+ $status = $payment->getAdditionalInformation('status');
653
+ if ($this->getConfig()->getPaymentAction($order->getStoreId())
654
+ == Netresearch_OPS_Model_Payment_Abstract::ACTION_AUTHORIZE
655
+ && Netresearch_OPS_Model_Status::isAuthorize($status)
656
+ && $order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
657
+ ) {
658
+ $message = $this->getHelper()->__('Order has been authorized, but not captured/paid yet.');
659
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $message);
660
+
661
  }
662
 
663
  return $this;
app/code/community/Netresearch/OPS/Model/Payment/Abstract.php CHANGED
@@ -24,15 +24,16 @@
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
- /**OPS_PAYMENT_PROCESSING
28
  * OPS payment method model
29
  */
30
  class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
31
  {
 
32
  protected $pm = '';
33
  protected $brand = '';
34
 
35
- protected $_code = 'ops';
36
  protected $_formBlockType = 'ops/form';
37
  protected $_infoBlockType = 'ops/info';
38
  protected $_config = null;
@@ -55,30 +56,31 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
55
  if (null === $this->backendOperationParameterModel) {
56
  $this->backendOperationParameterModel = Mage::getModel('ops/backend_operation_parameter');
57
  }
 
58
  return $this->backendOperationParameterModel;
59
  }
60
 
61
- /**
62
  * Magento Payment Behaviour Settings
63
  */
64
- protected $_isGateway = false;
65
- protected $_canAuthorize = true;
66
- protected $_canCapture = true;
67
- protected $_canCapturePartial = true;
68
- protected $_canRefund = true;
69
  protected $_canRefundInvoicePartial = true;
70
- protected $_canVoid = true;
71
- protected $_canUseInternal = false;
72
- protected $_canUseCheckout = true;
73
- protected $_canUseForMultishipping = false;
74
- protected $_isInitializeNeeded = true;
 
75
 
76
  /**
77
  * OPS behaviour settings
78
  */
79
 
80
- protected $_needsCartDataForRequest = false;
81
-
82
 
83
  protected $_needsShipToParams = true;
84
 
@@ -87,70 +89,25 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
87
  /**
88
  * OPS template modes
89
  */
90
- const TEMPLATE_OPS = 'ops';
91
- const TEMPLATE_MAGENTO = 'magento';
 
 
 
92
 
93
  /**
94
  * redirect references
95
  */
96
 
97
- const REFERENCE_QUOTE_ID = 'quoteId';
98
- const REFERENCE_ORDER_ID = 'orderId';
99
-
100
- /**
101
- * OPS response status
102
- */
103
- const OPS_INVALID = 0;
104
- const OPS_PAYMENT_CANCELED_BY_CUSTOMER = 1;
105
- const OPS_AUTH_REFUSED = 2;
106
-
107
- const OPS_ORDER_SAVED = 4;
108
- const OPS_AWAIT_CUSTOMER_PAYMENT = 41;
109
- const OPS_OPEN_INVOICE_DE_PROCESSED = 41000001;
110
- const OPS_WAITING_FOR_IDENTIFICATION = 46;
111
-
112
- const OPS_AUTHORIZED = 5;
113
- const OPS_AUTHORIZED_KWIXO = 50;
114
- const OPS_AUTHORIZED_WAITING = 51;
115
- const OPS_AUTHORIZED_UNKNOWN = 52;
116
- const OPS_STAND_BY = 55;
117
- const OPS_PAYMENTS_SCHEDULED = 56;
118
- const OPS_AUTHORIZED_TO_GET_MANUALLY = 59;
119
-
120
- const OPS_VOIDED = 6;
121
- const OPS_VOID_WAITING = 61;
122
- const OPS_VOID_UNCERTAIN = 62;
123
- const OPS_VOID_REFUSED = 63;
124
- const OPS_VOIDED_ACCEPTED = 64;
125
-
126
- const OPS_PAYMENT_DELETED = 7;
127
- const OPS_PAYMENT_DELETED_WAITING = 71;
128
- const OPS_PAYMENT_DELETED_UNCERTAIN = 72;
129
- const OPS_PAYMENT_DELETED_REFUSED = 73;
130
- const OPS_PAYMENT_DELETED_OK = 74;
131
- const OPS_PAYMENT_DELETED_PROCESSED_MERCHANT = 75;
132
-
133
- const OPS_REFUNDED = 8;
134
- const OPS_REFUND_WAITING = 81;
135
- const OPS_REFUND_UNCERTAIN_STATUS = 82;
136
- const OPS_REFUND_REFUSED = 83;
137
- const OPS_REFUND_DECLINED_ACQUIRER = 84;
138
- const OPS_REFUND_PROCESSED_MERCHANT = 85;
139
-
140
- const OPS_PAYMENT_REQUESTED = 9;
141
- const OPS_PAYMENT_PROCESSING = 91;
142
- const OPS_PAYMENT_UNCERTAIN = 92;
143
- const OPS_PAYMENT_REFUSED = 93;
144
- const OPS_PAYMENT_DECLINED_ACQUIRER = 94;
145
- const OPS_PAYMENT_PROCESSED_MERCHANT = 95;
146
- const OPS_PAYMENT_IN_PROGRESS = 99;
147
 
148
  /**
149
  * Layout of the payment method
150
  */
151
- const PMLIST_HORIZONTAL_LEFT = 0;
152
- const PMLIST_HORIZONTAL = 1;
153
- const PMLIST_VERTICAL = 2;
154
 
155
  /**
156
  * OPS payment action constant
@@ -177,6 +134,12 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
177
  const OPS_VOID_TRANSACTION_TYPE = 'void';
178
  const OPS_REFUND_TRANSACTION_TYPE = 'refund';
179
  const OPS_DELETE_TRANSACTION_TYPE = 'delete';
 
 
 
 
 
 
180
 
181
  /**
182
  * Return OPS Config
@@ -186,12 +149,17 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
186
  public function getConfig()
187
  {
188
  if (is_null($this->_config)) {
189
- $this->_config = Mage::getSingleton('ops/config');
190
  }
191
 
192
  return $this->_config;
193
  }
194
 
 
 
 
 
 
195
  /**
196
  * return if shipment params are needed for request
197
  *
@@ -230,6 +198,7 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
230
  * if payment method is available
231
  *
232
  * @param Mage_Sales_Model_Quote $quote
 
233
  * @return boolean
234
  */
235
  public function isAvailable($quote = null)
@@ -266,7 +235,7 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
266
  */
267
  public function getOrderPlaceRedirectUrl()
268
  {
269
- return $this->getConfig()->getPaymentRedirectUrl();
270
  }
271
 
272
  protected function getPayment()
@@ -278,27 +247,29 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
278
  }
279
  }
280
 
281
- public function getOpsBrand($payment=null)
282
  {
283
- if(is_null($payment)){
284
  $payment = $this->getInfoInstance();
285
  }
286
  $brand = trim($payment->getAdditionalInformation('BRAND'));
287
- if(!strlen($brand)){
288
- $brand=$this->brand;
289
  }
 
290
  return $brand;
291
  }
292
 
293
- public function getOpsCode($payment=null)
294
  {
295
- if(is_null($payment)){
296
  $payment = $this->getInfoInstance();
297
  }
298
  $pm = trim($payment->getAdditionalInformation('PM'));
299
- if(!strlen($pm)){
300
- $pm=$this->pm;
301
  }
 
302
  return $pm;
303
  }
304
 
@@ -309,10 +280,16 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
309
  */
310
  public function getPaymentAction()
311
  {
312
- return $this->getConfig()->getConfigData('payment_action');
313
  }
314
 
315
- public function getMethodDependendFormFields($order, $requestParams=null)
 
 
 
 
 
 
316
  {
317
  $billingAddress = $order->getBillingAddress();
318
  $shippingAddress = $order->getShippingAddress();
@@ -323,13 +300,13 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
323
  $quote = Mage::helper('ops/order')->getQuote($order->getQuoteId());
324
 
325
  $formFields = array();
326
- $formFields['ORIG'] = Mage::helper("ops")->getModuleVersionString();
327
- $formFields['BRAND'] = $payment->getOpsBrand($order->getPayment());
328
  if ($this->getConfig()->canSubmitExtraParameter($order->getStoreId())) {
329
- $formFields['CN'] = $billingAddress->getFirstname().' '.$billingAddress->getLastname();
330
- $formFields['COM'] = $this->_getOrderDescription($order);
331
- $formFields['ADDMATCH'] = Mage::helper('ops/order')->checkIfAddressesAreSame($order);
332
- $ownerParams = $this->getRequestHelper()->getOwnerParams($quote, $billingAddress);
333
  $formFields['ECOM_BILLTO_POSTAL_POSTALCODE'] = $billingAddress->getPostcode();
334
  $formFields = array_merge($formFields, $ownerParams);
335
  }
@@ -386,10 +363,13 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
386
  *
387
  * @param Mage_Sales_Model_Order
388
  * @param array
 
389
  * @return array
390
  */
391
  public function getFormFields($order, $requestParams, $isRequest = true)
392
  {
 
 
393
  if (empty($order)) {
394
  if (!($order = $this->getOrder())) {
395
  return array();
@@ -405,29 +385,21 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
405
  $formFields = array_merge($formFields, $methodDependendFields);
406
  }
407
 
408
- if ($this->getConfig()->getConfigData('template')=='ops') {
409
- $formFields['TP']= '';
410
- $formFields['PMLISTTYPE'] = $this->getConfig()->getConfigData('pmlist');
411
- } else {
412
- $formFields['TP']= $this->getConfig()->getPayPageTemplate();
413
  }
414
- $formFields['TITLE'] = $this->getConfig()->getConfigData('html_title');
415
- $formFields['BGCOLOR'] = $this->getConfig()->getConfigData('bgcolor');
416
- $formFields['TXTCOLOR'] = $this->getConfig()->getConfigData('txtcolor');
417
- $formFields['TBLBGCOLOR'] = $this->getConfig()->getConfigData('tblbgcolor');
418
- $formFields['TBLTXTCOLOR'] = $this->getConfig()->getConfigData('tbltxtcolor');
419
- $formFields['BUTTONBGCOLOR'] = $this->getConfig()->getConfigData('buttonbgcolor');
420
- $formFields['BUTTONTXTCOLOR'] = $this->getConfig()->getConfigData('buttontxtcolor');
421
- $formFields['FONTTYPE'] = $this->getConfig()->getConfigData('fonttype');
422
- $formFields['LOGO'] = $this->getConfig()->getConfigData('logo');
423
- $formFields['HOMEURL'] = $this->getConfig()->hasHomeUrl() ? $this->getConfig()->getContinueUrl(array('redirect' => 'home')) : 'NONE';
424
- $formFields['CATALOGURL'] = $this->getConfig()->hasCatalogUrl() ? $this->getConfig()->getContinueUrl(array('redirect' => 'catalog')) : '';
425
  $formFields['ACCEPTURL'] = $this->getConfig()->getAcceptUrl();
426
  $formFields['DECLINEURL'] = $this->getConfig()->getDeclineUrl();
427
  $formFields['EXCEPTIONURL'] = $this->getConfig()->getExceptionUrl();
428
  $formFields['CANCELURL'] = $this->getConfig()->getCancelUrl();
429
  $formFields['BACKURL'] = $this->getConfig()->getCancelUrl();
430
 
 
431
  /** @var $order Mage_Sales_Model_Order */
432
  $shipToFormFields = $this->getShipToParams($order->getShippingAddress());
433
  if (is_array($shipToFormFields)) {
@@ -440,23 +412,36 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
440
  }
441
 
442
  $cartDataFormFields = $this->getOrderItemData($order);
443
- if(is_array($cartDataFormFields)){
 
444
  $formFields = array_merge($formFields, $cartDataFormFields);
445
  }
446
 
447
- $shaSign = Mage::helper('ops/payment')->shaCrypt(Mage::helper('ops/payment')->getSHASign($formFields, null, $order->getStoreId()));
 
 
 
 
 
 
 
 
 
448
 
449
- if($isRequest){
450
  $helper = Mage::helper('ops');
451
- $helper->log($helper->__("Register Order %s in Ingenico Payment Services \n\nAll form fields: %s\nIngenico Payment Services String to hash: %s\nHash: %s",
452
- $order->getIncrementId(),
453
- serialize($formFields),
454
- Mage::helper('ops/payment')->getSHASign($formFields, null, $order->getStoreId()),
455
- $shaSign
456
- ));
 
 
 
457
  }
458
 
459
- $formFields['SHASIGN'] = $shaSign;
460
 
461
  return $formFields;
462
  }
@@ -465,21 +450,22 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
465
  * Get OPS Payment Action value
466
  *
467
  * @param string
 
468
  * @return string
469
  */
470
  protected function _getOPSPaymentOperation()
471
  {
472
  $value = $this->getPaymentAction();
473
- if ($value==Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
474
  $value = self::OPS_AUTHORIZE_ACTION;
475
- } elseif ($value==Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
476
  $value = self::OPS_AUTHORIZE_CAPTURE_ACTION;
477
  }
 
478
  return $value;
479
  }
480
 
481
-
482
- protected function convertToLatin1($StringToConvert)
483
  {
484
  $returnString = '';
485
  $chars = str_split($StringToConvert);
@@ -488,6 +474,7 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
488
  $returnString .= $char;
489
  }
490
  }
 
491
  return $returnString;
492
  }
493
 
@@ -495,6 +482,7 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
495
  * get formated order description
496
  *
497
  * @param Mage_Sales_Model_Order
 
498
  * @return string
499
  */
500
  public function _getOrderDescription($order)
@@ -503,9 +491,11 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
503
  $description = '';
504
  $lengs = 0;
505
  foreach ($order->getAllItems() as $item) {
506
- if ($item->getParentItem()) continue;
507
- // we know that Ingenico Payment Services is not able to handle characters that are not available in iso-8859-1
508
- // $descriptionItems[] = mb_ereg_replace("[^a-zA-Z0-9äáàéèíóöõúüûÄÁÀÉÍÓÖÕÚÜÛ_ ]" , "" , $item->getName());
 
 
509
  $descriptionItems[] = $this->convertToLatin1($item->getName());
510
  $description = Mage::helper('core/string')->substr(implode(', ', $descriptionItems), 0, 100);
511
  //COM field is limited to 100 chars max
@@ -513,6 +503,7 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
513
  break;
514
  }
515
  }
 
516
  return $description;
517
  }
518
 
@@ -526,24 +517,111 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
526
  return Mage::helper('ops/data');
527
  }
528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  /**
530
  * Determines if a capture will be processed
531
  *
532
  * @param Varien_Object $payment
533
- * @param float $amount
 
534
  * @throws Mage_Core_Exception
535
  * @return \Mage_Payment_Model_Abstract|void
536
  */
537
  public function capture(Varien_Object $payment, $amount)
538
  {
539
- // disallow Ingenico Payment Services online capture if amount is zero
540
  if ($amount < 0.01) {
541
  return parent::capture($payment, $amount);
542
  }
543
 
544
  if (true === Mage::registry('ops_auto_capture')) {
545
- Mage::unregister('ops_auto_capture');
546
- return parent::capture($payment, $amount);
 
547
  }
548
 
549
  $orderId = $payment->getOrder()->getId();
@@ -562,131 +640,77 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
562
  $arrInfo
563
  );
564
  $response = Mage::getSingleton('ops/api_directlink')->performRequest(
565
- $requestParams,
566
- Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
567
- $storeId
568
- );
569
- Mage::helper('ops/payment')->saveOpsStatusToPayment($payment, $response);
570
-
571
- if ($response['STATUS'] == self::OPS_PAYMENT_PROCESSING ||
572
- $response['STATUS'] == self::OPS_PAYMENT_UNCERTAIN ||
573
- $response['STATUS'] == self::OPS_PAYMENT_IN_PROGRESS
574
- ) {
575
- Mage::helper('ops/directlink')->directLinkTransact(
576
- Mage::getSingleton("sales/order")->loadByIncrementId($payment->getOrder()->getIncrementId()),
577
- $response['PAYID'],
578
- $response['PAYIDSUB'],
579
- $arrInfo,
580
- self::OPS_CAPTURE_TRANSACTION_TYPE,
581
- $this->getHelper()->__('Start Ingenico Payment Services %s capture request',$arrInfo['type']));
582
- $order = Mage::getModel('sales/order')->load($orderId); //Reload order to avoid wrong status
583
- $order->addStatusHistoryComment(
584
- Mage::helper('ops')->__(
585
- 'Invoice will be created automatically as soon as Ingenico Payment Services sends an acknowledgement. Ingenico Payment Services status: %s.',
586
- Mage::helper('ops')->getStatusText($response['STATUS'])
587
- )
588
- );
589
- $order->save();
590
- $this->getHelper()->redirectNoticed(
591
- $orderId,
592
- $this->getHelper()->__(
593
- 'Invoice will be created automatically as soon as Ingenico Payment Services sends an acknowledgement. Ingenico Payment Services status: %s.',
594
- Mage::helper('ops')->getStatusText($response['STATUS'])
595
- )
596
- );
597
- return $this;
598
- }
599
- elseif ($response['STATUS'] == self::OPS_PAYMENT_PROCESSED_MERCHANT || $response['STATUS'] == self::OPS_PAYMENT_REQUESTED) {
600
- return parent::capture($payment, $amount);
601
- } else{
602
- Mage::throwException(
603
- $this->getHelper()->__(
604
- 'The Invoice was not created. Ingenico Payment Services status: %s.',
605
- Mage::helper('ops')->getStatusText($response['STATUS'])
606
- )
607
- );
608
- }
609
- }
610
- catch (Exception $e){
611
  Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
612
- Mage::helper('ops')->log("Exception in capture request:".$e->getMessage());
613
- throw new Mage_Core_Exception($e->getMessage());
614
  }
615
  }
616
 
617
-
618
  /**
619
  * Refund
620
  *
621
  * @param Varien_Object $payment
622
- * @param float $amount
 
623
  * @return \Mage_Payment_Model_Abstract|void
624
  */
625
  public function refund(Varien_Object $payment, $amount)
626
  {
627
- //If the refund will be created by OPS, Refund Create Method to nothing
628
- if (true === Mage::registry('ops_auto_creditmemo')) {
629
- Mage::unregister('ops_auto_creditmemo');
630
- return parent::refund($payment, $amount);
631
  }
632
 
633
- $refundHelper = Mage::helper('ops/order_refund')->setAmount($amount)->setPayment($payment);
634
  $arrInfo = $refundHelper->prepareOperation($payment, $amount);
635
  $storeId = $payment->getOrder()->getStoreId();
636
- $operation = $arrInfo['operation'];
637
 
638
  try {
639
- $requestParams = $this->getBackendOperationParameterModel()->getParameterFor(
640
  self::OPS_REFUND_TRANSACTION_TYPE,
641
  $this,
642
- $payment,
643
- $amount,
644
- $arrInfo
645
  );
646
  $response = Mage::getSingleton('ops/api_directlink')->performRequest(
647
- $requestParams,
648
- Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
649
- $storeId
650
- );
651
- Mage::helper('ops/payment')->saveOpsStatusToPayment($payment, $response);
652
- if (($response['STATUS'] == self::OPS_REFUND_WAITING)
653
- || ($response['STATUS'] == self::OPS_REFUND_UNCERTAIN_STATUS)) {
654
- Mage::helper('ops/payment')->saveOpsRefundOperationCodeToPayment($payment, $operation);
655
- $refundHelper->createRefundTransaction($response);
656
-
657
- } elseif (($response['STATUS'] == self::OPS_REFUNDED)
658
- || ($response['STATUS'] == self::OPS_REFUND_PROCESSED_MERCHANT)) {
659
- //do refund directly if response is ok already
660
- Mage::helper('ops/payment')->saveOpsRefundOperationCodeToPayment($payment, $operation);
661
- $refundHelper->createRefundTransaction($response, 1);
662
- return parent::refund($payment, $amount);
663
- } else {
664
- Mage::throwException($this->getHelper()->__('The CreditMemo was not created. Ingenico Payment Services status: %s.',$response['STATUS']));
665
- }
666
-
667
- Mage::getSingleton('core/session')->addNotice($this->getHelper()->__('The Creditmemo will be created automatically as soon as Ingenico Payment Services sends an acknowledgement.'));
668
- $this->getHelper()->redirect(
669
- Mage::getUrl('*/sales_order/view', array('order_id' => $payment->getOrder()->getId()))
670
  );
671
- }
672
- catch (Exception $e) {
673
  Mage::logException($e);
674
  Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
675
  Mage::throwException($e->getMessage());
676
  }
 
 
677
  }
678
 
679
  /**
680
- * Returns the mandatory fields for requests to Ingenico Payment Services
681
  *
682
  * @param Mage_Sales_Model_Order $order
 
683
  * @return array
684
  */
685
  public function getMandatoryFormFields($order)
686
  {
687
  $formFields = Mage::helper('ops/payment_request')->getMandatoryRequestFields($order);
688
  $paymentAction = $this->_getOPSPaymentOperation();
689
- if ($paymentAction ) {
690
  $formFields['OPERATION'] = $paymentAction;
691
  }
692
 
@@ -704,52 +728,19 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
704
  {
705
  $closeTransaction = false;
706
  if (array_key_exists('ops_close_transaction', $creditMemoData)
707
- && strtolower(trim($creditMemoData['ops_close_transaction'])) == 'on') {
 
708
  $closeTransaction = true;
709
  }
710
- return $closeTransaction;
711
- }
712
-
713
- /**
714
- * Check refund availability
715
- *
716
- * @return bool
717
- */
718
- public function canRefund()
719
- {
720
- try {
721
- $order = Mage::getModel('sales/order')->load(Mage::app()->getRequest()->getParam('order_id'));
722
-
723
- // if Ingenico Payment Services transaction is closed then no online refund is possible
724
- if ($order->getPayment()
725
- && $order->getPayment()->getAdditionalInformation()
726
- && array_key_exists('canRefund', $order->getPayment()->getAdditionalInformation())
727
- && false === $order->getPayment()->getAdditionalInformation('canRefund')
728
- ) {
729
- return false;
730
- }
731
 
732
- if (false === Mage::helper('ops/directlink')->hasPaymentTransactions($order,self::OPS_REFUND_TRANSACTION_TYPE)) {
733
- return $this->_canRefund;
734
- } else {
735
- //Add the notice if no exception was thrown, because in this case there is one creditmemo in the transaction queue
736
- Mage::getSingleton('core/session')->addNotice(
737
- $this->getHelper()->__('There is already one creditmemo in the queue. The Creditmemo will be created automatically as soon as Ingenico Payment Services sends an acknowledgement.')
738
- );
739
- $this->getHelper()->redirect(
740
- Mage::getUrl('*/sales_order/view', array('order_id' => $order->getId()))
741
- );
742
- }
743
- } catch (Exception $e) {
744
- Mage::getSingleton('core/session')->addError($e->getMessage());
745
- return $this->_canRefund;
746
- }
747
  }
748
 
749
  /**
750
  * Custom cancel behavior, deny cancel and force custom to use void instead
751
  *
752
  * @param Varien_Object $payment
 
753
  * @return void
754
  * @throws Mage_Core_Exception
755
  */
@@ -762,15 +753,17 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
762
 
763
  //Proceed parent cancel method in case that regirstry value ops_auto_void is set
764
  if (true === Mage::registry('ops_auto_void')):
765
- Mage::unregister('ops_auto_void');
766
- return parent::cancel($payment);
 
767
  endif;
768
 
769
- //If order has state 'pending_payment' and the payment has Ingenico Payment Services-status 0 or null (unknown) then cancel the order
770
  if (true === $this->canCancelManually($payment->getOrder())) {
771
  $payment->getOrder()->addStatusHistoryComment(
772
- $this->getHelper()->__("The order was cancelled manually. The Ingenico Payment Services-state is 0 or null.")
773
  );
 
774
  return parent::cancel($payment);
775
  }
776
 
@@ -779,29 +772,29 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
779
  }
780
 
781
  /**
782
- * Custom void behavior, trigger Ingenico Payment Services cancel request
 
 
783
  *
784
- * @param Varien_Object $payment
785
  * @return void
786
  * @throws Mage_Core_Exception
787
  */
788
  public function void(Varien_Object $payment)
789
  {
790
- //Proceed parent void method in case that registry value ops_auto_void is set
791
- if (true === Mage::registry('ops_auto_void')) {
792
- Mage::unregister('ops_auto_void');
793
- return parent::void($payment);
 
794
  }
795
 
796
  //Set initital params
797
- $params = Mage::app()->getRequest()->getParams();
798
  $orderID = $payment->getOrder()->getId();
799
  $order = Mage::getModel("sales/order")->load($orderID);
800
 
801
  //Calculate amount which has to be captured
802
- $alreadyCaptured = Mage::helper('ops/order_void')->getCapturedAmount(
803
- $order
804
- );
805
  $grandTotal = Mage::helper('ops/payment')
806
  ->getBaseGrandTotalFromSalesObject($order);
807
  $voidAmount = $grandTotal - $alreadyCaptured;
@@ -819,24 +812,12 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
819
  self::OPS_VOID_TRANSACTION_TYPE, $orderID
820
  )
821
  ) {
822
- $this->getHelper()->redirectNoticed(
823
- $orderID, $this->getHelper()->__(
824
  'You already sent a void request. Please wait until the void request will be acknowledged.'
825
  )
826
  );
827
- return;
828
- }
829
 
830
- //Check if there is already a waiting capture transaction, if yes: redirect to order view
831
- if (Mage::helper('ops/directlink')->checkExistingTransact(
832
- self::OPS_CAPTURE_TRANSACTION_TYPE, $orderID
833
- )
834
- ) {
835
- $this->getHelper()->redirectNoticed(
836
- $orderID, $this->getHelper()->__(
837
- 'There is one capture request waiting. Please wait until this request is acknowledged.'
838
- )
839
- );
840
  return;
841
  }
842
 
@@ -844,79 +825,26 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
844
  //perform ops cancel request
845
  $response = Mage::getSingleton('ops/api_directlink')
846
  ->performRequest(
847
- $requestParams,
848
- Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
849
- $order->getStoreId()
850
- );
851
-
852
- //Save ops response to payment transaction
853
- Mage::helper('ops/payment')->saveOpsStatusToPayment(
854
- $payment, $response
855
- );
856
-
857
- /*
858
- * If the ops response results in a waiting or uncertain state, create a void transaction which is waiting
859
- * for an asynchron directLink-postback
860
- */
861
- if ($response['STATUS'] == self::OPS_VOID_WAITING
862
- || $response['STATUS'] == self::OPS_VOID_UNCERTAIN
863
- ) {
864
- Mage::helper('ops/directlink')->directLinkTransact(
865
- Mage::getSingleton("sales/order")->loadByIncrementId(
866
- $payment->getOrder()->getIncrementId()
867
- ),
868
- // reload order to avoid canceling order before confirmation from ops
869
- $response['PAYID'],
870
- $response['PAYIDSUB'],
871
- array(
872
- 'amount' => $voidAmount,
873
- 'void_request' => Mage::app()->getRequest()->getParams(
874
- ),
875
- 'response' => $response,
876
- ),
877
- self::OPS_VOID_TRANSACTION_TYPE,
878
- Mage::helper('ops')->__(
879
- 'Start Ingenico Payment Services void request. Ingenico Payment Services status: %s.',
880
- $this->getHelper()->getStatusText($response['STATUS'])
881
- )
882
- );
883
- $this->getHelper()->redirectNoticed(
884
- $orderID, $this->getHelper()->__(
885
- 'The void request is sent. Please wait until the void request will be accepted.'
886
- )
887
  );
888
- /*
889
- * If the ops response results directly in accepted state, create a void transaction and execute parent void method
890
- */
891
- } elseif ($response['STATUS'] == self::OPS_VOIDED
892
- || $response['STATUS'] == self::OPS_VOIDED_ACCEPTED
893
  ) {
894
- Mage::helper('ops/directlink')->directLinkTransact(
895
- Mage::getSingleton("sales/order")->loadByIncrementId(
896
- $payment->getOrder()->getIncrementId()
897
- ),
898
- // reload order to avoid canceling order before confirmation from ops
899
- $response['PAYID'],
900
- $response['PAYIDSUB'],
901
- array(),
902
- self::OPS_VOID_TRANSACTION_TYPE,
903
- $this->getHelper()->__(
904
- 'Void order succeed. Ingenico Payment Services status: %s.',
905
- $response['STATUS']
906
- ),
907
- 1
908
- );
909
- return parent::void($payment);
910
- } else {
911
- Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
912
  Mage::throwException(
913
- $this->getHelper()->__(
914
- 'Void order failed. Ingenico Payment Services status: %s.',
915
- $response['STATUS']
916
- )
917
  );
918
  }
919
- ;
 
 
 
 
 
 
 
920
  } catch (Exception $e) {
921
  Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
922
  Mage::helper('ops')->log(
@@ -926,13 +854,13 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
926
  }
927
  }
928
 
929
-
930
  /**
931
  * get question for fields with disputable value
932
- * users are asked to correct the values before redirect to Ingenico Payment Services
933
  *
934
  * @param Mage_Sales_Model_Order $order Current order
935
  * @param array $requestParams Request parameters
 
936
  * @return string
937
  */
938
  public function getQuestion($order, $requestParams)
@@ -942,10 +870,11 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
942
 
943
  /**
944
  * get an array of fields with disputable value
945
- * users are asked to correct the values before redirect to Ingenico Payment Services
946
  *
947
  * @param Mage_Sales_Model_Order $order Current order
948
  * @param array $requestParams Request parameters
 
949
  * @return array
950
  */
951
  public function getQuestionedFormFields($quote, $requestParams)
@@ -955,14 +884,15 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
955
 
956
  /**
957
  * if we need some missing form params
958
- * users are asked to correct the values before redirect to Ingenico Payment Services
959
  *
960
  * @param Mage_Sales_Model_Order $order
961
  * @param array $requestParams Parameters sent in current request
962
- * @param array $formFields Parameters to be sent to Ingenico Payment Services
 
963
  * @return bool
964
  */
965
- public function hasFormMissingParams($order, $requestParams, $formFields=null)
966
  {
967
  if (false == is_array($requestParams)) {
968
  $requestParams = array();
@@ -979,30 +909,36 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
979
  return true;
980
  }
981
  }
 
982
  return false;
983
  }
984
 
985
-
986
  /**
987
  * Check if order can be cancelled manually
988
  *
989
  * @param Mage_Sales_Model_Order $order
 
990
  * @return bool
991
  */
992
  public function canCancelManually($order)
993
  {
994
  $payment = $order->getPayment();
995
 
996
- //If order has state 'pending_payment' and the payment has Ingenico Payment Services-status 0 or null (unknown) then cancel the order
997
- if ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
998
- && (true === is_null($payment->getAdditionalInformation('status')) || ($payment->getAdditionalInformation('status') == '0'))) {
999
- return true;
1000
- } else {
1001
- return false;
1002
- }
 
 
 
 
 
1003
  }
1004
 
1005
- public function getOpsHtmlAnswer($payment=null)
1006
  {
1007
  $returnValue = '';
1008
  if (is_null($payment)) {
@@ -1020,6 +956,7 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
1020
  } elseif ($payment instanceof Mage_Payment_Model_Info) {
1021
  $returnValue = $payment->getAdditionalInformation('HTML_ANSWER');
1022
  }
 
1023
  return $returnValue;
1024
  }
1025
 
@@ -1028,7 +965,6 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
1028
  return $this->getRequestHelper()->getShippingTaxRate($order);
1029
  }
1030
 
1031
-
1032
  protected function isRedirectNoticed($orderId)
1033
  {
1034
  if (Mage::helper('ops/directlink')->checkExistingTransact(self::OPS_CAPTURE_TRANSACTION_TYPE, $orderId)) {
@@ -1051,6 +987,7 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
1051
 
1052
  return true;
1053
  }
 
1054
  return false;
1055
  }
1056
 
@@ -1060,7 +997,7 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
1060
  }
1061
 
1062
  /**
1063
- * If cart Item information has to be transmittet to Ingenico Payment Services
1064
  *
1065
  * @return bool
1066
  */
@@ -1071,18 +1008,94 @@ class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_A
1071
  }
1072
 
1073
  /**
1074
- * Returns array with the order item data formatted in Ingenico Payment Services fashion if payment method implementation
1075
  * needs the data otherwise just returns false.
1076
  *
1077
  * @param Mage_Sales_Model_Order $order
 
1078
  * @return array|false
1079
  */
1080
  public function getOrderItemData(Mage_Sales_Model_Order $order)
1081
  {
1082
- if(!$this->needsOrderItemDataForRequest()){
1083
  return false;
1084
  }
1085
 
1086
- return Mage::helper('ops/payment_request')->extractOrderItemParameters($order);
1087
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1088
  }
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
+ /**PAYMENT_PROCESSING
28
  * OPS payment method model
29
  */
30
  class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
31
  {
32
+
33
  protected $pm = '';
34
  protected $brand = '';
35
 
36
+ protected $_code = 'ops';
37
  protected $_formBlockType = 'ops/form';
38
  protected $_infoBlockType = 'ops/info';
39
  protected $_config = null;
56
  if (null === $this->backendOperationParameterModel) {
57
  $this->backendOperationParameterModel = Mage::getModel('ops/backend_operation_parameter');
58
  }
59
+
60
  return $this->backendOperationParameterModel;
61
  }
62
 
63
+ /**
64
  * Magento Payment Behaviour Settings
65
  */
66
+ protected $_isGateway = false;
67
+ protected $_canAuthorize = true;
68
+ protected $_canCapture = true;
69
+ protected $_canCapturePartial = true;
70
+ protected $_canRefund = true;
71
  protected $_canRefundInvoicePartial = true;
72
+ protected $_canVoid = true;
73
+ protected $_canUseInternal = false;
74
+ protected $_canUseCheckout = true;
75
+ protected $_canUseForMultishipping = false;
76
+ protected $_isInitializeNeeded = true;
77
+ protected $_canManageRecurringProfiles = false;
78
 
79
  /**
80
  * OPS behaviour settings
81
  */
82
 
83
+ protected $_needsCartDataForRequest = false;
 
84
 
85
  protected $_needsShipToParams = true;
86
 
89
  /**
90
  * OPS template modes
91
  */
92
+ const TEMPLATE_OPS_REDIRECT = 'ops';
93
+ const TEMPLATE_OPS_IFRAME = 'ops_iframe';
94
+ const TEMPLATE_OPS_TEMPLATE = 'ops_template';
95
+ const TEMPLATE_MAGENTO_INTERNAL = 'magento';
96
+
97
 
98
  /**
99
  * redirect references
100
  */
101
 
102
+ const REFERENCE_QUOTE_ID = 'quoteId';
103
+ const REFERENCE_ORDER_ID = 'orderId';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  /**
106
  * Layout of the payment method
107
  */
108
+ const PMLIST_HORIZONTAL_LEFT = 0;
109
+ const PMLIST_HORIZONTAL = 1;
110
+ const PMLIST_VERTICAL = 2;
111
 
112
  /**
113
  * OPS payment action constant
134
  const OPS_VOID_TRANSACTION_TYPE = 'void';
135
  const OPS_REFUND_TRANSACTION_TYPE = 'refund';
136
  const OPS_DELETE_TRANSACTION_TYPE = 'delete';
137
+ const OPS_AUTHORIZE_TRANSACTION_TYPE = 'authorize';
138
+
139
+ /**
140
+ * Session key for device fingerprinting consent
141
+ */
142
+ const FINGERPRINT_CONSENT_SESSION_KEY = 'device_fingerprinting_consent';
143
 
144
  /**
145
  * Return OPS Config
149
  public function getConfig()
150
  {
151
  if (is_null($this->_config)) {
152
+ $this->_config = Mage::getSingleton('ops/config');
153
  }
154
 
155
  return $this->_config;
156
  }
157
 
158
+ public function getConfigPaymentAction()
159
+ {
160
+ return $this->getPaymentAction();
161
+ }
162
+
163
  /**
164
  * return if shipment params are needed for request
165
  *
198
  * if payment method is available
199
  *
200
  * @param Mage_Sales_Model_Quote $quote
201
+ *
202
  * @return boolean
203
  */
204
  public function isAvailable($quote = null)
235
  */
236
  public function getOrderPlaceRedirectUrl()
237
  {
238
+ return $this->getConfig()->getPaymentRedirectUrl();
239
  }
240
 
241
  protected function getPayment()
247
  }
248
  }
249
 
250
+ public function getOpsBrand($payment = null)
251
  {
252
+ if (is_null($payment)) {
253
  $payment = $this->getInfoInstance();
254
  }
255
  $brand = trim($payment->getAdditionalInformation('BRAND'));
256
+ if (!strlen($brand)) {
257
+ $brand = $this->brand;
258
  }
259
+
260
  return $brand;
261
  }
262
 
263
+ public function getOpsCode($payment = null)
264
  {
265
+ if (is_null($payment)) {
266
  $payment = $this->getInfoInstance();
267
  }
268
  $pm = trim($payment->getAdditionalInformation('PM'));
269
+ if (!strlen($pm)) {
270
+ $pm = $this->pm;
271
  }
272
+
273
  return $pm;
274
  }
275
 
280
  */
281
  public function getPaymentAction()
282
  {
283
+ return $this->getConfig()->getPaymentAction($this->getStoreId());
284
  }
285
 
286
+ /**
287
+ * @param Mage_Sales_Model_Order $order
288
+ * @param string[]|null $requestParams
289
+ *
290
+ * @return string[]
291
+ */
292
+ public function getMethodDependendFormFields($order, $requestParams = null)
293
  {
294
  $billingAddress = $order->getBillingAddress();
295
  $shippingAddress = $order->getShippingAddress();
300
  $quote = Mage::helper('ops/order')->getQuote($order->getQuoteId());
301
 
302
  $formFields = array();
303
+ $formFields['ORIG'] = Mage::helper("ops")->getModuleVersionString();
304
+ $formFields['BRAND'] = $payment->getOpsBrand($order->getPayment());
305
  if ($this->getConfig()->canSubmitExtraParameter($order->getStoreId())) {
306
+ $formFields['CN'] = $billingAddress->getFirstname() . ' ' . $billingAddress->getLastname();
307
+ $formFields['COM'] = $this->_getOrderDescription($order);
308
+ $formFields['ADDMATCH'] = Mage::helper('ops/order')->checkIfAddressesAreSame($order);
309
+ $ownerParams = $this->getRequestHelper()->getOwnerParams($billingAddress, $quote);
310
  $formFields['ECOM_BILLTO_POSTAL_POSTALCODE'] = $billingAddress->getPostcode();
311
  $formFields = array_merge($formFields, $ownerParams);
312
  }
363
  *
364
  * @param Mage_Sales_Model_Order
365
  * @param array
366
+ *
367
  * @return array
368
  */
369
  public function getFormFields($order, $requestParams, $isRequest = true)
370
  {
371
+ $requestHelper = Mage::helper('ops/payment_request');
372
+
373
  if (empty($order)) {
374
  if (!($order = $this->getOrder())) {
375
  return array();
385
  $formFields = array_merge($formFields, $methodDependendFields);
386
  }
387
 
388
+
389
+ $paymentAction = $this->_getOPSPaymentOperation();
390
+ if ($paymentAction ) {
391
+ $formFields['OPERATION'] = $paymentAction;
 
392
  }
393
+
394
+ $formFields = array_merge($formFields, $requestHelper->getTemplateParams($order->getStoreId()));
395
+
 
 
 
 
 
 
 
 
396
  $formFields['ACCEPTURL'] = $this->getConfig()->getAcceptUrl();
397
  $formFields['DECLINEURL'] = $this->getConfig()->getDeclineUrl();
398
  $formFields['EXCEPTIONURL'] = $this->getConfig()->getExceptionUrl();
399
  $formFields['CANCELURL'] = $this->getConfig()->getCancelUrl();
400
  $formFields['BACKURL'] = $this->getConfig()->getCancelUrl();
401
 
402
+
403
  /** @var $order Mage_Sales_Model_Order */
404
  $shipToFormFields = $this->getShipToParams($order->getShippingAddress());
405
  if (is_array($shipToFormFields)) {
412
  }
413
 
414
  $cartDataFormFields = $this->getOrderItemData($order);
415
+
416
+ if (is_array($cartDataFormFields)) {
417
  $formFields = array_merge($formFields, $cartDataFormFields);
418
  }
419
 
420
+ // get method specific parameters
421
+ $methodDependendFields = $this->getMethodDependendFormFields($order, $requestParams);
422
+ if (is_array($methodDependendFields)) {
423
+ $formFields = array_merge($formFields, $methodDependendFields);
424
+ }
425
+
426
+ $shaSign = Mage::helper('ops/payment')->shaCrypt(
427
+ Mage::helper('ops/payment')
428
+ ->getSHASign($formFields, null, $order->getStoreId())
429
+ );
430
 
431
+ if ($isRequest) {
432
  $helper = Mage::helper('ops');
433
+ $helper->log(
434
+ $helper->__(
435
+ "Register Order %s in Ingenico ePayments \n\nAll form fields: %s\nIngenico ePayments String to hash: %s\nHash: %s",
436
+ $order->getIncrementId(),
437
+ serialize($formFields),
438
+ Mage::helper('ops/payment')->getSHASign($formFields, null, $order->getStoreId()),
439
+ $shaSign
440
+ )
441
+ );
442
  }
443
 
444
+ $formFields['SHASIGN'] = $shaSign;
445
 
446
  return $formFields;
447
  }
450
  * Get OPS Payment Action value
451
  *
452
  * @param string
453
+ *
454
  * @return string
455
  */
456
  protected function _getOPSPaymentOperation()
457
  {
458
  $value = $this->getPaymentAction();
459
+ if ($value == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
460
  $value = self::OPS_AUTHORIZE_ACTION;
461
+ } elseif ($value == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
462
  $value = self::OPS_AUTHORIZE_CAPTURE_ACTION;
463
  }
464
+
465
  return $value;
466
  }
467
 
468
+ protected function convertToLatin1($StringToConvert)
 
469
  {
470
  $returnString = '';
471
  $chars = str_split($StringToConvert);
474
  $returnString .= $char;
475
  }
476
  }
477
+
478
  return $returnString;
479
  }
480
 
482
  * get formated order description
483
  *
484
  * @param Mage_Sales_Model_Order
485
+ *
486
  * @return string
487
  */
488
  public function _getOrderDescription($order)
491
  $description = '';
492
  $lengs = 0;
493
  foreach ($order->getAllItems() as $item) {
494
+ if ($item->getParentItem()) {
495
+ continue;
496
+ }
497
+ // we know that Ingenico ePayments is not able to handle characters that are not available in iso-8859-1
498
+ // $descriptionItems[] = mb_ereg_replace("[^a-zA-Z0-9äáàéèíóöõúüûÄÁÀÉÍÓÖÕÚÜÛ_ ]" , "" , $item->getName());
499
  $descriptionItems[] = $this->convertToLatin1($item->getName());
500
  $description = Mage::helper('core/string')->substr(implode(', ', $descriptionItems), 0, 100);
501
  //COM field is limited to 100 chars max
503
  break;
504
  }
505
  }
506
+
507
  return $description;
508
  }
509
 
517
  return Mage::helper('ops/data');
518
  }
519
 
520
+ /**
521
+ * Method that will be executed instead of authorize or capture
522
+ * if flag isInitializeNeeded set to true
523
+ *
524
+ * @param string $paymentAction
525
+ * @param object $stateObject
526
+ *
527
+ * @return Mage_Payment_Model_Abstract
528
+ */
529
+ public function initialize($paymentAction, $stateObject)
530
+ {
531
+ $stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
532
+ ->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
533
+
534
+ $message = $this->getHelper()
535
+ ->__('Customer got redirected to Ingenico ePayments for %s. Awaiting feedback.', $paymentAction);
536
+
537
+ /** @var Mage_Sales_Model_Order $order */
538
+ $order = $this->getInfoInstance()->getOrder();
539
+
540
+ $order->addStatusHistoryComment($message);
541
+
542
+ return $this;
543
+ }
544
+
545
+ /**
546
+ * accept payment
547
+ *
548
+ * @see \Mage_Sales_Model_Order_Payment::registerPaymentReviewAction
549
+ *
550
+ * @param Mage_Payment_Model_Info $payment
551
+ *
552
+ * @return boolean
553
+ * @throws Mage_Core_Exception
554
+ */
555
+ public function acceptPayment(Mage_Payment_Model_Info $payment)
556
+ {
557
+ parent::acceptPayment($payment);
558
+ $status = $payment->getAdditionalInformation('status');
559
+
560
+ if ($status == Netresearch_OPS_Model_Status::AUTHORIZED || $status == Netresearch_OPS_Model_Status::PAYMENT_REQUESTED) {
561
+ return true;
562
+ }
563
+
564
+ Mage::throwException(
565
+ $this->getHelper()->__(
566
+ 'The order can not be accepted via Magento. For the actual status of the payment check the Ingenico ePayments backend.'
567
+ )
568
+ );
569
+ }
570
+
571
+ /**
572
+ * cancel order if in payment review state
573
+ *
574
+ * @see \Mage_Sales_Model_Order_Payment::registerPaymentReviewAction
575
+ *
576
+ * @param Mage_Payment_Model_Info $payment
577
+ *
578
+ * @return boolean
579
+ * @throws Mage_Core_Exception
580
+ */
581
+ public function denyPayment(Mage_Payment_Model_Info $payment)
582
+ {
583
+ parent::denyPayment($payment);
584
+
585
+ Mage::getSingleton('admin/session')->addNotice(
586
+ $this->getHelper()->__('Order has been canceled permanently in Magento. Changes in Ingenico ePayments platform will no longer be considered.')
587
+ );
588
+
589
+ return true;
590
+ }
591
+
592
+ /**
593
+ * check if payment is in payment review state
594
+ *
595
+ * @param Mage_Payment_Model_Info $payment
596
+ *
597
+ * @return bool
598
+ */
599
+ public function canReviewPayment(Mage_Payment_Model_Info $payment)
600
+ {
601
+ $status = $payment->getAdditionalInformation('status');
602
+ return Netresearch_OPS_Model_Status::canResendPaymentInfo($status);
603
+ }
604
+
605
  /**
606
  * Determines if a capture will be processed
607
  *
608
  * @param Varien_Object $payment
609
+ * @param float $amount
610
+ *
611
  * @throws Mage_Core_Exception
612
  * @return \Mage_Payment_Model_Abstract|void
613
  */
614
  public function capture(Varien_Object $payment, $amount)
615
  {
616
+ // disallow Ingenico ePayments online capture if amount is zero
617
  if ($amount < 0.01) {
618
  return parent::capture($payment, $amount);
619
  }
620
 
621
  if (true === Mage::registry('ops_auto_capture')) {
622
+ Mage::unregister('ops_auto_capture');
623
+
624
+ return parent::capture($payment, $amount);
625
  }
626
 
627
  $orderId = $payment->getOrder()->getId();
640
  $arrInfo
641
  );
642
  $response = Mage::getSingleton('ops/api_directlink')->performRequest(
643
+ $requestParams,
644
+ Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
645
+ $storeId
646
+ );
647
+
648
+ Mage::getModel('ops/response_handler')->processResponse($response, $this, false);
649
+
650
+ return $this;
651
+
652
+ } catch (Exception $e) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
653
  Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
654
+ Mage::helper('ops')->log("Exception in capture request:" . $e->getMessage());
655
+ Mage::throwException($e->getMessage());
656
  }
657
  }
658
 
 
659
  /**
660
  * Refund
661
  *
662
  * @param Varien_Object $payment
663
+ * @param float $amount
664
+ *
665
  * @return \Mage_Payment_Model_Abstract|void
666
  */
667
  public function refund(Varien_Object $payment, $amount)
668
  {
669
+ $refundHelper = Mage::helper('ops/order_refund');
670
+
671
+ if ($refundHelper->getOpenRefundTransaction($payment)->getId()) {
672
+ Mage::throwException($this->getHelper()->__("There is already one creditmemo in the queue. The Creditmemo will be created automatically as soon as Ingenico ePayments sends an acknowledgement."));
673
  }
674
 
675
+ $refundHelper->setAmount($amount)->setPayment($payment);
676
  $arrInfo = $refundHelper->prepareOperation($payment, $amount);
677
  $storeId = $payment->getOrder()->getStoreId();
 
678
 
679
  try {
680
+ $requestParams = $this->getBackendOperationParameterModel()->getParameterFor(
681
  self::OPS_REFUND_TRANSACTION_TYPE,
682
  $this,
683
+ $payment,
684
+ $amount,
685
+ $arrInfo
686
  );
687
  $response = Mage::getSingleton('ops/api_directlink')->performRequest(
688
+ $requestParams,
689
+ Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
690
+ $storeId
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
691
  );
692
+ Mage::getModel('ops/response_handler')->processResponse($response, $this, false);
693
+ } catch (Exception $e) {
694
  Mage::logException($e);
695
  Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
696
  Mage::throwException($e->getMessage());
697
  }
698
+
699
+ return $this;
700
  }
701
 
702
  /**
703
+ * Returns the mandatory fields for requests to Ingenico ePayments
704
  *
705
  * @param Mage_Sales_Model_Order $order
706
+ *
707
  * @return array
708
  */
709
  public function getMandatoryFormFields($order)
710
  {
711
  $formFields = Mage::helper('ops/payment_request')->getMandatoryRequestFields($order);
712
  $paymentAction = $this->_getOPSPaymentOperation();
713
+ if ($paymentAction) {
714
  $formFields['OPERATION'] = $paymentAction;
715
  }
716
 
728
  {
729
  $closeTransaction = false;
730
  if (array_key_exists('ops_close_transaction', $creditMemoData)
731
+ && strtolower(trim($creditMemoData['ops_close_transaction'])) == 'on'
732
+ ) {
733
  $closeTransaction = true;
734
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
735
 
736
+ return $closeTransaction;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
737
  }
738
 
739
  /**
740
  * Custom cancel behavior, deny cancel and force custom to use void instead
741
  *
742
  * @param Varien_Object $payment
743
+ *
744
  * @return void
745
  * @throws Mage_Core_Exception
746
  */
753
 
754
  //Proceed parent cancel method in case that regirstry value ops_auto_void is set
755
  if (true === Mage::registry('ops_auto_void')):
756
+ Mage::unregister('ops_auto_void');
757
+
758
+ return parent::cancel($payment);
759
  endif;
760
 
761
+ //If order has state 'pending_payment' and the payment has Ingenico ePayments-status 0 or null (unknown) then cancel the order
762
  if (true === $this->canCancelManually($payment->getOrder())) {
763
  $payment->getOrder()->addStatusHistoryComment(
764
+ $this->getHelper()->__("The order was cancelled manually. The Ingenico ePayments-state is 0 or null.")
765
  );
766
+
767
  return parent::cancel($payment);
768
  }
769
 
772
  }
773
 
774
  /**
775
+ * Custom void behavior, trigger Ingenico ePayments cancel request
776
+ *
777
+ * @param Mage_Sales_Model_Order_Payment $payment
778
  *
 
779
  * @return void
780
  * @throws Mage_Core_Exception
781
  */
782
  public function void(Varien_Object $payment)
783
  {
784
+
785
+ $status = $payment->getAdditionalInformation('status');
786
+
787
+ if(!Netresearch_OPS_Model_Status::canVoidTransaction($status)){
788
+ Mage::throwException($this->getHelper()->__('Status %s can not be voided.', $status));
789
  }
790
 
791
  //Set initital params
 
792
  $orderID = $payment->getOrder()->getId();
793
  $order = Mage::getModel("sales/order")->load($orderID);
794
 
795
  //Calculate amount which has to be captured
796
+ $alreadyCaptured = $payment->getBaseAmountPaidOnline();
797
+
 
798
  $grandTotal = Mage::helper('ops/payment')
799
  ->getBaseGrandTotalFromSalesObject($order);
800
  $voidAmount = $grandTotal - $alreadyCaptured;
812
  self::OPS_VOID_TRANSACTION_TYPE, $orderID
813
  )
814
  ) {
815
+ $this->getHelper()->getAdminSession()->addError(
816
+ $this->getHelper()->__(
817
  'You already sent a void request. Please wait until the void request will be acknowledged.'
818
  )
819
  );
 
 
820
 
 
 
 
 
 
 
 
 
 
 
821
  return;
822
  }
823
 
825
  //perform ops cancel request
826
  $response = Mage::getSingleton('ops/api_directlink')
827
  ->performRequest(
828
+ $requestParams,
829
+ Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
830
+ $order->getStoreId()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
831
  );
832
+
833
+ if ($response['STATUS'] == Netresearch_OPS_Model_Status::INVALID_INCOMPLETE
834
+ && $payment->getAdditionalInformation('status') == Netresearch_OPS_Model_Status::PAYMENT_REQUESTED
 
 
835
  ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
  Mage::throwException(
837
+ $this->getHelper()->__('Order can no longer be voided. You have to refund the order online.')
 
 
 
838
  );
839
  }
840
+
841
+
842
+ $handler = Mage::getModel('ops/response_handler');
843
+ $handler->processResponse($response, $this, false);
844
+
845
+
846
+ return $this;
847
+
848
  } catch (Exception $e) {
849
  Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
850
  Mage::helper('ops')->log(
854
  }
855
  }
856
 
 
857
  /**
858
  * get question for fields with disputable value
859
+ * users are asked to correct the values before redirect to Ingenico ePayments
860
  *
861
  * @param Mage_Sales_Model_Order $order Current order
862
  * @param array $requestParams Request parameters
863
+ *
864
  * @return string
865
  */
866
  public function getQuestion($order, $requestParams)
870
 
871
  /**
872
  * get an array of fields with disputable value
873
+ * users are asked to correct the values before redirect to Ingenico ePayments
874
  *
875
  * @param Mage_Sales_Model_Order $order Current order
876
  * @param array $requestParams Request parameters
877
+ *
878
  * @return array
879
  */
880
  public function getQuestionedFormFields($quote, $requestParams)
884
 
885
  /**
886
  * if we need some missing form params
887
+ * users are asked to correct the values before redirect to Ingenico ePayments
888
  *
889
  * @param Mage_Sales_Model_Order $order
890
  * @param array $requestParams Parameters sent in current request
891
+ * @param array $formFields Parameters to be sent to Ingenico ePayments
892
+ *
893
  * @return bool
894
  */
895
+ public function hasFormMissingParams($order, $requestParams, $formFields = null)
896
  {
897
  if (false == is_array($requestParams)) {
898
  $requestParams = array();
909
  return true;
910
  }
911
  }
912
+
913
  return false;
914
  }
915
 
 
916
  /**
917
  * Check if order can be cancelled manually
918
  *
919
  * @param Mage_Sales_Model_Order $order
920
+ *
921
  * @return bool
922
  */
923
  public function canCancelManually($order)
924
  {
925
  $payment = $order->getPayment();
926
 
927
+ //If payment has Ingenico ePayments-status 0 or null (unknown) or another offline cancelable status
928
+ $status = $payment->getAdditionalInformation('status');
929
+
930
+ return is_null($status)
931
+ || in_array(
932
+ $status, array(
933
+ Netresearch_OPS_Model_Status::INVALID_INCOMPLETE,
934
+ Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER,
935
+ Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED,
936
+ Netresearch_OPS_Model_Status::PAYMENT_DELETED
937
+ )
938
+ );
939
  }
940
 
941
+ public function getOpsHtmlAnswer($payment = null)
942
  {
943
  $returnValue = '';
944
  if (is_null($payment)) {
956
  } elseif ($payment instanceof Mage_Payment_Model_Info) {
957
  $returnValue = $payment->getAdditionalInformation('HTML_ANSWER');
958
  }
959
+
960
  return $returnValue;
961
  }
962
 
965
  return $this->getRequestHelper()->getShippingTaxRate($order);
966
  }
967
 
 
968
  protected function isRedirectNoticed($orderId)
969
  {
970
  if (Mage::helper('ops/directlink')->checkExistingTransact(self::OPS_CAPTURE_TRANSACTION_TYPE, $orderId)) {
987
 
988
  return true;
989
  }
990
+
991
  return false;
992
  }
993
 
997
  }
998
 
999
  /**
1000
+ * If cart Item information has to be transmitted to Ingenico ePayments
1001
  *
1002
  * @return bool
1003
  */
1008
  }
1009
 
1010
  /**
1011
+ * Returns array with the order item data formatted in Ingenico ePayments fashion if payment method implementation
1012
  * needs the data otherwise just returns false.
1013
  *
1014
  * @param Mage_Sales_Model_Order $order
1015
+ *
1016
  * @return array|false
1017
  */
1018
  public function getOrderItemData(Mage_Sales_Model_Order $order)
1019
  {
1020
+ if (!$this->needsOrderItemDataForRequest()) {
1021
  return false;
1022
  }
1023
 
1024
+ return $this->getRequestHelper()->extractOrderItemParameters($order);
1025
  }
1026
+
1027
+ /**
1028
+ * @inheritDoc
1029
+ */
1030
+ public function canVoid(Varien_Object $payment)
1031
+ {
1032
+
1033
+ if(Netresearch_OPS_Model_Status::canVoidTransaction($payment->getAdditionalInformation('status'))){
1034
+ return parent::canVoid($payment);
1035
+ } else {
1036
+ return false;
1037
+ }
1038
+
1039
+ }
1040
+
1041
+ /**
1042
+ * @inheritDoc
1043
+ */
1044
+ public function assignData($data)
1045
+ {
1046
+ parent::assignData($data);
1047
+
1048
+ $paymentInfo = $this->getInfoInstance();
1049
+ if ($paymentInfo->getData($this->getCode())) {
1050
+ foreach ($paymentInfo->getData($this->getCode()) as $key => $value) {
1051
+ $paymentInfo->setAdditionalInformation($key, $value);
1052
+ }
1053
+ }
1054
+
1055
+ return $this;
1056
+ }
1057
+
1058
+
1059
+ /**
1060
+ * @inheritDoc
1061
+ */
1062
+ public function validate()
1063
+ {
1064
+
1065
+ $paymentInfo = $this->getInfoInstance();
1066
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
1067
+ $billingAddress = $paymentInfo->getOrder()->getBillingAddress();
1068
+ $shippingAddress = $paymentInfo->getOrder()->getShippingAddress();
1069
+ $salesObject = $paymentInfo->getOrder();
1070
+ } else {
1071
+ $salesObject = $paymentInfo->getQuote();
1072
+ $billingAddress = $salesObject->getBillingAddress();
1073
+ $shippingAddress = $salesObject->getShippingAddress();
1074
+ }
1075
+
1076
+ $validator = Mage::getModel('ops/validator_parameter_factory')->getValidatorFor(
1077
+ Netresearch_OPS_Model_Validator_Parameter_Factory::TYPE_REQUEST_PARAMS_VALIDATION
1078
+ );
1079
+
1080
+ $params = $this->getRequestHelper()->getOwnerParams($billingAddress, $salesObject);
1081
+ $billingParams = $this->getBillToParams($billingAddress);
1082
+ $shippingParams = $this->getShipToParams($shippingAddress);
1083
+ if($shippingParams) {
1084
+ $params = array_merge($params, $shippingParams);
1085
+ }
1086
+ if($billingParams){
1087
+ $params = array_merge($params, $billingParams);
1088
+ }
1089
+
1090
+ if(false === $validator->isValid($params)){
1091
+ $result = Mage::helper('ops/validation_result')->getValidationFailedResult(
1092
+ $validator->getMessages(), $salesObject
1093
+ );
1094
+ throw new Mage_Payment_Exception('Validation failed', $result['fields']);
1095
+ }
1096
+
1097
+ return parent::validate();
1098
+ }
1099
+
1100
+
1101
  }
app/code/community/Netresearch/OPS/Model/Payment/Bancontact.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Netresearch OPS
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade this extension to
16
+ * newer versions in the future.
17
+ *
18
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
19
+ * @license Open Software License (OSL 3.0)
20
+ * @link http://opensource.org/licenses/osl-3.0.php
21
+ */
22
+
23
+ /**
24
+ * Netresearch_OPS_Model_Payment_BankContact
25
+ *
26
+ * @category Ingenico
27
+ * @package Netresearch_OPS
28
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
29
+ */
30
+ class Netresearch_OPS_Model_Payment_Bancontact
31
+ extends Netresearch_OPS_Model_Payment_Abstract
32
+ {
33
+ protected $pm = 'CreditCard';
34
+ protected $brand = 'BCMC';
35
+ const CODE = 'ops_BCMC';
36
+
37
+ /** Check if we can capture directly from the backend */
38
+ protected $_canBackendDirectCapture = true;
39
+
40
+ /** info source path */
41
+ protected $_infoBlockType = 'ops/info_redirect';
42
+
43
+ /** payment code */
44
+ protected $_code = self::CODE;
45
+
46
+
47
+ }
48
+
app/code/community/Netresearch/OPS/Model/Payment/Cc.php CHANGED
@@ -10,6 +10,8 @@
10
  */
11
  class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_DirectLink
12
  {
 
 
13
  /** info source path */
14
  protected $_infoBlockType = 'ops/info_cc';
15
 
@@ -17,10 +19,11 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
17
  protected $_formBlockType = 'ops/form_cc';
18
 
19
  /** payment code */
20
- protected $_code = 'ops_cc';
21
 
22
  protected $featureModel = null;
23
 
 
24
  /** ops payment code */
25
  public function getOpsCode($payment = null)
26
  {
@@ -31,11 +34,13 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
31
  if ('UNEUROCOM' == $this->getOpsBrand($payment)) {
32
  return 'UNEUROCOM';
33
  }
 
34
  return 'CreditCard';
35
  }
36
 
37
  /**
38
  * @param null $payment
 
39
  * @return array|mixed|null
40
  */
41
  public function getOpsBrand($payment = null)
@@ -50,11 +55,14 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
50
  public function getOrderPlaceRedirectUrl($payment = null)
51
  {
52
  if ($this->hasBrandAliasInterfaceSupport($payment)) {
53
- if ('' == $this->getOpsHtmlAnswer($payment))
54
- return false; // Prevent redirect on cc payment
55
- else
56
- return Mage::getModel('ops/config')->get3dSecureRedirectUrl();
 
 
57
  }
 
58
  return parent::getOrderPlaceRedirectUrl();
59
  }
60
 
@@ -65,7 +73,8 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
65
  */
66
  public function getBrandsForAliasInterface()
67
  {
68
- $brands = Mage::getModel('ops/config')->getInlinePaymentCcTypes();
 
69
  return $brands;
70
  }
71
 
@@ -74,7 +83,7 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
74
  *
75
  * @param Mage_Payment_Model_Info $payment
76
  *
77
- * @return void
78
  */
79
  public function hasBrandAliasInterfaceSupport($payment = null)
80
  {
@@ -86,8 +95,10 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
86
 
87
  /**
88
  * Validates alias for in quote provided addresses
 
89
  * @param Mage_Sales_Model_Quote $quote
90
- * @param Varien_Object $payment
 
91
  * @throws Mage_Core_Exception
92
  */
93
  protected function validateAlias($quote, $payment)
@@ -123,10 +134,11 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
123
  }
124
 
125
 
126
- protected function performPreDirectLinkCallActions(Mage_Sales_Model_Quote $quote, Varien_Object $payment, $requestParams = array())
127
- {
 
128
  Mage::helper('ops/alias')->cleanUpAdditionalInformation($payment, true);
129
- if (true === Mage::getModel('ops/config')->isAliasManagerEnabled()) {
130
  $this->validateAlias($quote, $payment);
131
  }
132
 
@@ -173,7 +185,7 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
173
  * if Version is CE 1.8 / EE 1.14 use parent method otherwise use our implementation
174
  *
175
  * @param Mage_Sales_Model_Quote $quote
176
- * @param $checksBitMask
177
  *
178
  * @return bool
179
  */
@@ -217,55 +229,40 @@ class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_Dir
217
  }
218
 
219
  /**
220
- * Override the method instead of the _canReviewPayment parameter, because we will only allow it with Ingenico Payment Services status == 0
 
 
221
  *
222
  * @return bool
223
- * @param Mage_Payment_Model_Info $payment
224
  */
225
- public function canReviewPayment(Mage_Payment_Model_Info $payment)
226
  {
227
- if ($payment->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID) {
228
-
229
- return true;
 
 
230
  }
231
 
232
- return false;
233
-
234
  }
235
 
236
- /**
237
- * Enable payment deny when __VENDOR status == 0
238
- *
239
- * @param Mage_Payment_Model_Info $payment
240
- * @return bool
241
- */
242
- public function denyPayment(Mage_Payment_Model_Info $payment)
243
  {
244
- if ($payment->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID) {
245
- // returning true will automatically invoke the payment cancellation process
246
- return true;
247
- }
248
-
249
- return false;
250
  }
251
 
252
  /**
253
- * Check wether payment method is available for quote
254
- *
255
- * @param Mage_Sales_Model_Quote $quote
256
- *
257
- * @return bool
258
  */
259
- public function isAvailable($quote = null)
260
  {
261
- if (!$quote->getItemsCount() > 0 && $this->getDataHelper()->isAdminSession()) {
262
- /* Disable payment method in backend as long as there are no items in quote to
263
- * avoid problems with alias creation in EE1.12 & EE1.13
264
- */
265
- return false;
266
- } else {
267
- return parent::isAvailable($quote);
268
  }
 
 
269
  }
270
  }
271
 
10
  */
11
  class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_DirectLink
12
  {
13
+ const CODE = 'ops_cc';
14
+
15
  /** info source path */
16
  protected $_infoBlockType = 'ops/info_cc';
17
 
19
  protected $_formBlockType = 'ops/form_cc';
20
 
21
  /** payment code */
22
+ protected $_code = self::CODE;
23
 
24
  protected $featureModel = null;
25
 
26
+
27
  /** ops payment code */
28
  public function getOpsCode($payment = null)
29
  {
34
  if ('UNEUROCOM' == $this->getOpsBrand($payment)) {
35
  return 'UNEUROCOM';
36
  }
37
+
38
  return 'CreditCard';
39
  }
40
 
41
  /**
42
  * @param null $payment
43
+ *
44
  * @return array|mixed|null
45
  */
46
  public function getOpsBrand($payment = null)
55
  public function getOrderPlaceRedirectUrl($payment = null)
56
  {
57
  if ($this->hasBrandAliasInterfaceSupport($payment)) {
58
+ if ('' == $this->getOpsHtmlAnswer($payment)) {
59
+ return false;
60
+ } // Prevent redirect on cc payment
61
+ else {
62
+ return $this->getConfig()->get3dSecureRedirectUrl();
63
+ }
64
  }
65
+
66
  return parent::getOrderPlaceRedirectUrl();
67
  }
68
 
73
  */
74
  public function getBrandsForAliasInterface()
75
  {
76
+ $brands = $this->getConfig()->getInlinePaymentCcTypes($this->getCode());
77
+
78
  return $brands;
79
  }
80
 
83
  *
84
  * @param Mage_Payment_Model_Info $payment
85
  *
86
+ * @return bool
87
  */
88
  public function hasBrandAliasInterfaceSupport($payment = null)
89
  {
95
 
96
  /**
97
  * Validates alias for in quote provided addresses
98
+ *
99
  * @param Mage_Sales_Model_Quote $quote
100
+ * @param Varien_Object $payment
101
+ *
102
  * @throws Mage_Core_Exception
103
  */
104
  protected function validateAlias($quote, $payment)
134
  }
135
 
136
 
137
+ protected function performPreDirectLinkCallActions(Mage_Sales_Model_Quote $quote, Varien_Object $payment,
138
+ $requestParams = array()
139
+ ) {
140
  Mage::helper('ops/alias')->cleanUpAdditionalInformation($payment, true);
141
+ if (true === Mage::getModel('ops/config')->isAliasManagerEnabled($this->getCode())) {
142
  $this->validateAlias($quote, $payment);
143
  }
144
 
185
  * if Version is CE 1.8 / EE 1.14 use parent method otherwise use our implementation
186
  *
187
  * @param Mage_Sales_Model_Quote $quote
188
+ * @param $checksBitMask
189
  *
190
  * @return bool
191
  */
229
  }
230
 
231
  /**
232
+ * Check wether payment method is available for quote
233
+ *
234
+ * @param Mage_Sales_Model_Quote $quote
235
  *
236
  * @return bool
 
237
  */
238
+ public function isAvailable($quote = null)
239
  {
240
+ if (!is_null($quote) && !$quote->getItemsCount() > 0 && $this->getDataHelper()->isAdminSession()) {
241
+ /* Disable payment method in backend as long as there are no items in quote to
242
+ * avoid problems with alias creation in EE1.12 & EE1.13
243
+ */
244
+ return false;
245
  }
246
 
247
+ return parent::isAvailable($quote);
 
248
  }
249
 
250
+ public function isInitializeNeeded()
 
 
 
 
 
 
251
  {
252
+ return !$this->getPaymentHelper()->isInlinePayment($this->getInfoInstance());
 
 
 
 
 
253
  }
254
 
255
  /**
256
+ * @inheritdoc
 
 
 
 
257
  */
258
+ public function getMethodDependendFormFields($order, $requestParams = null)
259
  {
260
+ $formFields = parent::getMethodDependendFormFields($order, $requestParams);
261
+ if ($this->getConfig()->getCreditDebitSplit($order->getStoreId())) {
262
+ $formFields['CREDITDEBIT'] = "C";
 
 
 
 
263
  }
264
+
265
+ return $formFields;
266
  }
267
  }
268
 
app/code/community/Netresearch/OPS/Model/Payment/Cod.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- /**
3
- * Netresearch_OPS_Model_Payment_Cod
4
- *
5
- * @package
6
- * @copyright 2011 Netresearch
7
- * @author Thomas Kappel <thomas.kappel@netresearch.de>
8
- * @license OSL 3.0
9
- */
10
- class Netresearch_OPS_Model_Payment_Cod
11
- extends Netresearch_OPS_Model_Payment_Abstract
12
- {
13
- protected $pm = 'Payment on Delivery';
14
- protected $brand = 'Payment on Delivery';
15
-
16
- /** Check if we can capture directly from the backend */
17
- protected $_canBackendDirectCapture = true;
18
-
19
- /** info source path */
20
- protected $_infoBlockType = 'ops/info_redirect';
21
-
22
- /** payment code */
23
- protected $_code = 'ops_cod';
24
- }
25
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Model/Payment/Debitcard.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Netresearch_OPS_Model_Payment_Debitcard
5
+ *
6
+ * @package
7
+ * @copyright 2016 Netresearch
8
+ * @author Paul Siedler <paul.siedler@netresearch.de>
9
+ * @license OSL 3.0
10
+ */
11
+ class Netresearch_OPS_Model_Payment_Debitcard extends Netresearch_OPS_Model_Payment_Cc
12
+ {
13
+
14
+ /** payment code */
15
+ protected $_code = 'ops_dc';
16
+
17
+
18
+ /** ops payment code */
19
+ public function getOpsCode($payment = null)
20
+ {
21
+ return 'CreditCard';
22
+ }
23
+
24
+ /**
25
+ * @inheritdoc
26
+ */
27
+ public function getMethodDependendFormFields($order, $requestParams = null)
28
+ {
29
+ $formFields = parent::getMethodDependendFormFields($order, $requestParams);
30
+ if ($this->getConfig()->getCreditDebitSplit($order->getStoreId())) {
31
+ $formFields['CREDITDEBIT'] = "D";
32
+ }
33
+
34
+ return $formFields;
35
+ }
36
+
37
+ /**
38
+ * @return Netresearch_OPS_Helper_Debitcard
39
+ */
40
+ public function getRequestParamsHelper()
41
+ {
42
+ if (null === $this->requestParamsHelper) {
43
+ $this->requestParamsHelper = Mage::helper('ops/debitcard');
44
+ }
45
+
46
+ return $this->requestParamsHelper;
47
+ }
48
+
49
+
50
+ }
51
+
app/code/community/Netresearch/OPS/Model/Payment/DirectLink.php CHANGED
@@ -1,12 +1,11 @@
1
  <?php
 
2
  /**
3
- * @author Michael Lühr <michael.luehr@netresearch.de>
4
  * @category Netresearch
5
  * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
6
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
  */
8
-
9
-
10
  abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_Model_Payment_Abstract
11
  {
12
  /** Check if we can capture directly from the backend */
@@ -28,6 +27,9 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
28
  protected $validationFactory = null;
29
 
30
  protected $dataHelper = null;
 
 
 
31
  /**
32
  * @param Netresearch_OPS_Helper_Payment_DirectLink_RequestInterface $requestParamsHelper
33
  */
@@ -62,7 +64,6 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
62
  }
63
 
64
 
65
-
66
  /**
67
  * @param Netresearch_OPS_Helper_Directlink $directLinkHelper
68
  */
@@ -79,6 +80,7 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
79
  if (null === $this->directLinkHelper) {
80
  $this->directLinkHelper = MAge::helper('ops/directlink');
81
  }
 
82
  return $this->directLinkHelper;
83
  }
84
 
@@ -103,8 +105,6 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
103
  }
104
 
105
 
106
-
107
-
108
  /**
109
  * @param null $config
110
  */
@@ -125,44 +125,9 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
125
  return $this->config;
126
  }
127
 
128
-
129
-
130
-
131
- /**
132
- * returns the payment action in dependency of the configuration quote id or order's increment id
133
- *
134
- * @return string
135
- */
136
- public function getConfigPaymentAction()
137
- {
138
- $paymentAction = '';
139
-
140
- if ($this->getConfig()->getPaymentAction() == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE
141
- && ($this instanceof Netresearch_OPS_Model_Payment_DirectDebit ||
142
- ($this instanceof Netresearch_OPS_Model_Payment_Cc && $this->hasBrandAliasInterfaceSupport($this->getInfoInstance())))
143
- ) {
144
- $paymentAction = Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
145
- }
146
-
147
- if ($this->getConfig()->getPaymentAction() == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
148
- && ($this instanceof Netresearch_OPS_Model_Payment_DirectDebit ||
149
- ($this instanceof Netresearch_OPS_Model_Payment_Cc && $this->hasBrandAliasInterfaceSupport($this->getInfoInstance())))
150
- ) {
151
- $paymentAction = Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
152
- }
153
-
154
- return $paymentAction;
155
- }
156
-
157
-
158
- public function isInitializeNeeded()
159
- {
160
- return false;
161
- }
162
-
163
  /**
164
  * @param Varien_Object $payment
165
- * @param float $amount
166
  *
167
  * @return Mage_Payment_Model_Abstract|void
168
  */
@@ -179,23 +144,28 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
179
  }
180
 
181
  /**
182
- * Saves the payment model and runs the request to Ingenico Payment Servicess webservice
183
  *
184
  * @param Mage_Sales_Model_Order $order
185
  * @param Mage_Sales_Model_Quote $quote
186
- * @param Varien_Object $payment
 
187
  * @throws Mage_Core_Exception
188
  */
189
 
190
- protected function confirmPayment(Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote, Varien_Object $payment)
191
- {
 
192
  $this->handleAdminPayment($quote);
193
  $requestParams = $this->getRequestParamsHelper()->getDirectLinkRequestParams($quote, $order, $payment);
194
  $this->invokeRequestParamValidation($requestParams);
195
  $this->performPreDirectLinkCallActions($quote, $order);
196
- $response = $this->getDirectLinkHelper()->performDirectLinkRequest($quote, $requestParams, $quote->getStoreId());
 
 
197
  if ($response) {
198
- $this->getPaymentHelper()->applyStateForOrder($order, $response);
 
199
  $this->performPostDirectLinkCallAction($quote, $order);
200
 
201
  } else {
@@ -207,6 +177,7 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
207
  * Handles backend payments on Magento side
208
  *
209
  * @param Mage_Sales_Model_Quote $quote
 
210
  * @return Netresearch_OPS_Model_Payment_DirectLink
211
  */
212
  abstract protected function handleAdminPayment(Mage_Sales_Model_Quote $quote);
@@ -218,29 +189,36 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
218
 
219
 
220
  /**
221
- * Perform necessary preparation before request to Ingenico Payment Services is sent
222
  *
223
  * @param Mage_Sales_Model_Quote $quote
224
- * @param Varien_Object $payment
225
- * @param array $requestParams
 
226
  * @return Netresearch_OPS_Model_Payment_DirectLink
227
  */
228
- abstract protected function performPreDirectLinkCallActions(Mage_Sales_Model_Quote $quote, Varien_Object $payment, $requestParams = array());
 
 
229
 
230
  /**
231
  * Perform necessary work after the Directlink Request was sent and an response was received and processed
232
  *
233
  * @param Mage_Sales_Model_Quote $quote
234
  * @param Mage_Sales_Model_Order $order
 
235
  * @return Netresearch_OPS_Model_Payment_DirectLink
236
  */
237
- abstract protected function performPostDirectLinkCallAction(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order);
 
 
238
 
239
 
240
  /**
241
  * performs direct link request either for inline payments and direct sale mode or the normal maintenance call (invoice)
242
  *
243
  * @override
 
244
  * @param Varien_Object $payment
245
  * @param float $amount
246
  *
@@ -257,9 +235,8 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
257
  $order = $payment->getOrder();
258
  $quote = $this->getQuoteHelper()->getQuote();
259
  $this->confirmPayment($order, $quote, $payment);
260
- }
261
- /**
262
- * invoice request authorize mode if the payment was placed on Ingenico Payment Services side
263
  */
264
  elseif (0 < strlen(trim($payment->getAdditionalInformation('paymentId')))) {
265
  parent::capture($payment, $amount);
@@ -277,16 +254,18 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
277
  protected function isInlinePayment($payment)
278
  {
279
  $result = false;
280
- $code = $payment->getMethodInstance()->getCode();
281
- if (($code == 'ops_cc'
282
- && $payment->getMethodInstance()
283
- ->hasBrandAliasInterfaceSupport(
284
- $payment
285
- ) || $this->getDataHelper()->isAdminSession()
286
- ) || $code == 'ops_directDebit'
 
287
  ) {
288
  $result = true;
289
  }
 
290
  return $result;
291
  }
292
 
@@ -316,7 +295,9 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
316
  );
317
  if (false == $validator->isValid($requestParams)) {
318
  $this->getOnepage()->getCheckout()->setGotoSection('payment');
319
- Mage::throwException($this->getHelper()->__('The data you have provided can not be processed by Ingenico Payment Services'));
 
 
320
  }
321
 
322
  return $this;
@@ -360,7 +341,8 @@ abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_
360
  if (null === $this->dataHelper) {
361
  $this->dataHelper = Mage::helper('ops/data');
362
  }
 
363
  return $this->dataHelper;
364
  }
365
 
366
- }
1
  <?php
2
+
3
  /**
4
+ * @author Michael Lühr <michael.luehr@netresearch.de>
5
  * @category Netresearch
6
  * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
 
 
9
  abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_Model_Payment_Abstract
10
  {
11
  /** Check if we can capture directly from the backend */
27
  protected $validationFactory = null;
28
 
29
  protected $dataHelper = null;
30
+
31
+ protected $_isInitializeNeeded = false;
32
+
33
  /**
34
  * @param Netresearch_OPS_Helper_Payment_DirectLink_RequestInterface $requestParamsHelper
35
  */
64
  }
65
 
66
 
 
67
  /**
68
  * @param Netresearch_OPS_Helper_Directlink $directLinkHelper
69
  */
80
  if (null === $this->directLinkHelper) {
81
  $this->directLinkHelper = MAge::helper('ops/directlink');
82
  }
83
+
84
  return $this->directLinkHelper;
85
  }
86
 
105
  }
106
 
107
 
 
 
108
  /**
109
  * @param null $config
110
  */
125
  return $this->config;
126
  }
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  /**
129
  * @param Varien_Object $payment
130
+ * @param float $amount
131
  *
132
  * @return Mage_Payment_Model_Abstract|void
133
  */
144
  }
145
 
146
  /**
147
+ * Saves the payment model and runs the request to Ingenico ePaymentss webservice
148
  *
149
  * @param Mage_Sales_Model_Order $order
150
  * @param Mage_Sales_Model_Quote $quote
151
+ * @param Varien_Object $payment
152
+ *
153
  * @throws Mage_Core_Exception
154
  */
155
 
156
+ protected function confirmPayment(Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote,
157
+ Varien_Object $payment
158
+ ) {
159
  $this->handleAdminPayment($quote);
160
  $requestParams = $this->getRequestParamsHelper()->getDirectLinkRequestParams($quote, $order, $payment);
161
  $this->invokeRequestParamValidation($requestParams);
162
  $this->performPreDirectLinkCallActions($quote, $order);
163
+ $response = $this->getDirectLinkHelper()->performDirectLinkRequest(
164
+ $quote, $requestParams, $quote->getStoreId()
165
+ );
166
  if ($response) {
167
+ $handler = Mage::getModel('ops/response_handler');
168
+ $handler->processResponse($response, $this, false);
169
  $this->performPostDirectLinkCallAction($quote, $order);
170
 
171
  } else {
177
  * Handles backend payments on Magento side
178
  *
179
  * @param Mage_Sales_Model_Quote $quote
180
+ *
181
  * @return Netresearch_OPS_Model_Payment_DirectLink
182
  */
183
  abstract protected function handleAdminPayment(Mage_Sales_Model_Quote $quote);
189
 
190
 
191
  /**
192
+ * Perform necessary preparation before request to Ingenico ePayments is sent
193
  *
194
  * @param Mage_Sales_Model_Quote $quote
195
+ * @param Varien_Object $payment
196
+ * @param array $requestParams
197
+ *
198
  * @return Netresearch_OPS_Model_Payment_DirectLink
199
  */
200
+ abstract protected function performPreDirectLinkCallActions(Mage_Sales_Model_Quote $quote, Varien_Object $payment,
201
+ $requestParams = array()
202
+ );
203
 
204
  /**
205
  * Perform necessary work after the Directlink Request was sent and an response was received and processed
206
  *
207
  * @param Mage_Sales_Model_Quote $quote
208
  * @param Mage_Sales_Model_Order $order
209
+ *
210
  * @return Netresearch_OPS_Model_Payment_DirectLink
211
  */
212
+ abstract protected function performPostDirectLinkCallAction(Mage_Sales_Model_Quote $quote,
213
+ Mage_Sales_Model_Order $order
214
+ );
215
 
216
 
217
  /**
218
  * performs direct link request either for inline payments and direct sale mode or the normal maintenance call (invoice)
219
  *
220
  * @override
221
+ *
222
  * @param Varien_Object $payment
223
  * @param float $amount
224
  *
235
  $order = $payment->getOrder();
236
  $quote = $this->getQuoteHelper()->getQuote();
237
  $this->confirmPayment($order, $quote, $payment);
238
+ } /**
239
+ * invoice request authorize mode if the payment was placed on Ingenico ePayments side
 
240
  */
241
  elseif (0 < strlen(trim($payment->getAdditionalInformation('paymentId')))) {
242
  parent::capture($payment, $amount);
254
  protected function isInlinePayment($payment)
255
  {
256
  $result = false;
257
+
258
+ $methodInstance = $payment->getMethodInstance();
259
+ if ((
260
+ $methodInstance instanceof Netresearch_OPS_Model_Payment_Cc
261
+ && $methodInstance->hasBrandAliasInterfaceSupport($payment)
262
+ || $this->getDataHelper()->isAdminSession()
263
+ )
264
+ || $methodInstance instanceof Netresearch_OPS_Model_Payment_DirectDebit
265
  ) {
266
  $result = true;
267
  }
268
+
269
  return $result;
270
  }
271
 
295
  );
296
  if (false == $validator->isValid($requestParams)) {
297
  $this->getOnepage()->getCheckout()->setGotoSection('payment');
298
+ Mage::throwException(
299
+ $this->getHelper()->__('The data you have provided can not be processed by Ingenico ePayments')
300
+ );
301
  }
302
 
303
  return $this;
341
  if (null === $this->dataHelper) {
342
  $this->dataHelper = Mage::helper('ops/data');
343
  }
344
+
345
  return $this->dataHelper;
346
  }
347
 
348
+ }
app/code/community/Netresearch/OPS/Model/Payment/Features/PaymentEmail.php CHANGED
@@ -1,14 +1,30 @@
1
  <?php
2
-
3
  /**
4
- * PaymentEmail.php
5
- * @author paul.siedler@netresearch.de
6
- * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  */
9
 
10
  /**
11
- * Class Netresearch_OPS_Model_Payment_Features_PaymentEmail
 
 
 
 
12
  */
13
  class Netresearch_OPS_Model_Payment_Features_PaymentEmail
14
  {
@@ -22,13 +38,15 @@ class Netresearch_OPS_Model_Payment_Features_PaymentEmail
22
  * Check if payment email is available for order
23
  *
24
  * @param $order
 
25
  * @return bool
26
  */
27
  public function isAvailableForOrder($order)
28
  {
29
- if($order instanceof Mage_Sales_Model_Order){
30
  $status = $order->getPayment()->getAdditionalInformation('status');
31
- return Mage::helper('ops/payment')->isPaymentInvalid($status);
 
32
  }
33
 
34
  return false;
@@ -39,6 +57,7 @@ class Netresearch_OPS_Model_Payment_Features_PaymentEmail
39
  * Resends the payment information and returns true/false, depending if succeeded or not
40
  *
41
  * @param Mage_Sales_Model_Order $order
 
42
  * @return boolean success state
43
  */
44
  public function resendPaymentInfo(Mage_Sales_Model_Order $order)
@@ -47,17 +66,19 @@ class Netresearch_OPS_Model_Payment_Features_PaymentEmail
47
  // reset payment method so the customer can choose freely from all available methods
48
  $this->setPaymentMethodToGeneric($order);
49
 
50
- $config = $this->getConfig();
51
- $template = $config->getResendPaymentInfoTemplate($order->getStoreId());
52
- $emailTemplate = Mage::getModel('core/email_template')->loadDefault($config->getResendPaymentInfoTemplate($order->getStoreId()));
53
 
54
- $identity = $config->getResendPaymentInfoIdentity($order->getStoreId());
55
- $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_'.$identity.'/name'))
56
- ->setSenderEmail(Mage::getStoreConfig('trans_email/ident_'.$identity.'/email'));
 
 
 
 
57
 
58
  $parameters = array(
59
- "order" => $order,
60
- "paymentLink" => $this->generatePaymentLink($order)
 
61
  );
62
 
63
  return $emailTemplate->send($order->getCustomerEmail(), $order->getCustomerName(), $parameters);
@@ -68,6 +89,7 @@ class Netresearch_OPS_Model_Payment_Features_PaymentEmail
68
  * Generates the payment url
69
  *
70
  * @param Mage_Sales_Model_Order $order
 
71
  * @return string
72
  */
73
  protected function generatePaymentLink(Mage_Sales_Model_Order $order)
@@ -83,19 +105,93 @@ class Netresearch_OPS_Model_Payment_Features_PaymentEmail
83
 
84
  $params['SHASIGN'] = strtoupper(Mage::helper('ops/payment')->shaCrypt($raw));
85
 
86
- $url = Mage::getModel('ops/config')->getPaymentRetryUrl($params);
 
87
  return $url;
88
  }
89
 
90
  /**
91
- * Set payment method to Netresearch_OPS_Model_Payment_Other
92
  *
93
  * @param Mage_Sales_Model_Order $order
 
94
  * @throws Exception
95
  */
96
  protected function setPaymentMethodToGeneric(Mage_Sales_Model_Order $order)
97
  {
98
- $order->getPayment()->setMethod(Netresearch_OPS_Model_Payment_Other::CODE)->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
  }
1
  <?php
 
2
  /**
3
+ * Netresearch OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
  */
21
 
22
  /**
23
+ * Implements functionality to send Ingenico ePayments specific mails
24
+ *
25
+ * @category Payment method
26
+ * @package Netresearch OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
  */
29
  class Netresearch_OPS_Model_Payment_Features_PaymentEmail
30
  {
38
  * Check if payment email is available for order
39
  *
40
  * @param $order
41
+ *
42
  * @return bool
43
  */
44
  public function isAvailableForOrder($order)
45
  {
46
+ if ($order instanceof Mage_Sales_Model_Order) {
47
  $status = $order->getPayment()->getAdditionalInformation('status');
48
+
49
+ return Netresearch_OPS_Model_Status::canResendPaymentInfo($status);
50
  }
51
 
52
  return false;
57
  * Resends the payment information and returns true/false, depending if succeeded or not
58
  *
59
  * @param Mage_Sales_Model_Order $order
60
+ *
61
  * @return boolean success state
62
  */
63
  public function resendPaymentInfo(Mage_Sales_Model_Order $order)
66
  // reset payment method so the customer can choose freely from all available methods
67
  $this->setPaymentMethodToGeneric($order);
68
 
 
 
 
69
 
70
+ $identity = $this->getIdentity($this->getConfig()->getResendPaymentInfoIdentity($order->getStoreId()));
71
+
72
+ $emailTemplate = $this->prepareTemplate(
73
+ $this->getConfig()->getResendPaymentInfoTemplate($order->getStoreId()),
74
+ $identity->getEmail(),
75
+ $identity->getName()
76
+ );
77
 
78
  $parameters = array(
79
+ "order" => $order,
80
+ "paymentLink" => $this->generatePaymentLink($order),
81
+ "store" => Mage::app()->getStore($order->getStoreId())
82
  );
83
 
84
  return $emailTemplate->send($order->getCustomerEmail(), $order->getCustomerName(), $parameters);
89
  * Generates the payment url
90
  *
91
  * @param Mage_Sales_Model_Order $order
92
+ *
93
  * @return string
94
  */
95
  protected function generatePaymentLink(Mage_Sales_Model_Order $order)
105
 
106
  $params['SHASIGN'] = strtoupper(Mage::helper('ops/payment')->shaCrypt($raw));
107
 
108
+ $url = Mage::getModel('ops/config')->getPaymentRetryUrl($params, $order->getStoreId());
109
+
110
  return $url;
111
  }
112
 
113
  /**
114
+ * Set payment method to Netresearch_OPS_Model_Payment_Flex
115
  *
116
  * @param Mage_Sales_Model_Order $order
117
+ *
118
  * @throws Exception
119
  */
120
  protected function setPaymentMethodToGeneric(Mage_Sales_Model_Order $order)
121
  {
122
+ $order->getPayment()->setMethod(Netresearch_OPS_Model_Payment_Flex::CODE)->save();
123
+ }
124
+
125
+ /**
126
+ * Sends suspend subscription mail to configured store contact via configured mail template
127
+ *
128
+ * @param Mage_Sales_Model_Recurring_Profile $profile
129
+ * @param Mage_Customer_Model_Customer $customer
130
+ *
131
+ * @return bool
132
+ */
133
+ public function sendSuspendSubscriptionMail($profile, $customer)
134
+ {
135
+ if (is_null($profile) || is_null($customer)) {
136
+ Mage::throwException('Could not send mail due to internal error!');
137
+ }
138
+
139
+ $emailTemplate = $this->prepareTemplate(
140
+ $this->getConfig()->getSuspendSubscriptionTemplate($profile->getStoreId()),
141
+ $customer->getEmail(),
142
+ $customer->getName()
143
+ );
144
+
145
+ $emailTemplate->addBcc($customer->getEmail());
146
+
147
+ $parameters = array(
148
+ "profile" => $profile,
149
+ "customer" => $customer,
150
+ "store" => Mage::app()->getStore($profile->getStoreId())
151
+ );
152
+
153
+ $identity = $this->getIdentity($this->getConfig()->getSuspendSubscriptionIdentity($profile->getStoreId()));
154
+
155
+ return $emailTemplate->send($identity->getEmail(), $identity->getName(), $parameters);
156
+
157
+ }
158
+
159
+
160
+ /**
161
+ * Loads email and name of the given store identity
162
+ *
163
+ * @param string $key - identity to load, defaults to sales
164
+ *
165
+ * @return Varien_Object with data name and email
166
+ */
167
+ protected function getIdentity($key = 'sales')
168
+ {
169
+ $identity = new Varien_Object();
170
+ $identity->setName(Mage::getStoreConfig('trans_email/ident_' . $key . '/name'))
171
+ ->setEmail(Mage::getStoreConfig('trans_email/ident_' . $key . '/email'));
172
+
173
+ return $identity;
174
+ }
175
+
176
+ /**
177
+ * Loads the given template by identifier, sets sender mail and name
178
+ *
179
+ * @param string $template
180
+ * @param string $senderMail
181
+ * @param string $senderName
182
+ *
183
+ * @return Mage_Core_Model_Email_Template
184
+ */
185
+ protected function prepareTemplate($template, $senderMail, $senderName)
186
+ {
187
+ $emailTemplate = Mage::getModel('core/email_template')->load($template);
188
+ if (is_null($emailTemplate->getTemplateSubject())) {
189
+ $emailTemplate = $emailTemplate->loadDefault($template);
190
+ }
191
+ $emailTemplate->setSenderName($senderName)
192
+ ->setSenderEmail($senderMail);
193
+
194
+ return $emailTemplate;
195
  }
196
 
197
  }
app/code/community/Netresearch/OPS/Model/Payment/Features/ZeroAmountAuth.php CHANGED
@@ -28,6 +28,7 @@ class Netresearch_OPS_Model_Payment_Features_ZeroAmountAuth
28
  && $opsPaymentMethod instanceof Netresearch_OPS_Model_Payment_Cc
29
  && $opsPaymentMethod->isZeroAmountAuthorizationAllowed($storeId)
30
  && 0 < $quote->getItemsCount()
 
31
 
32
  ) {
33
  $result = true;
28
  && $opsPaymentMethod instanceof Netresearch_OPS_Model_Payment_Cc
29
  && $opsPaymentMethod->isZeroAmountAuthorizationAllowed($storeId)
30
  && 0 < $quote->getItemsCount()
31
+ && !$quote->isNominal()
32
 
33
  ) {
34
  $result = true;
app/code/community/Netresearch/OPS/Model/Payment/Flex.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Flex.php
5
+ *
6
+ * @author paul.siedler@netresearch.de
7
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
9
+ */
10
+ class Netresearch_OPS_Model_Payment_Flex extends Netresearch_OPS_Model_Payment_Abstract
11
+ {
12
+
13
+ const CODE = 'ops_flex';
14
+
15
+ const INFO_KEY_TITLE = 'flex_title';
16
+ const INFO_KEY_PM = 'flex_pm';
17
+ const INFO_KEY_BRAND = 'flex_brand';
18
+
19
+ /** Check if we can capture directly from the backend */
20
+ protected $_canBackendDirectCapture = true;
21
+
22
+ /** info source path */
23
+ protected $_infoBlockType = 'ops/info_flex';
24
+
25
+ protected $_formBlockType = 'ops/form_flex';
26
+
27
+ /** payment code */
28
+ protected $_code = self::CODE;
29
+
30
+ protected $_needsCartDataForRequest = true;
31
+
32
+ public function getOpsCode($payment = null)
33
+ {
34
+ return $this->getInfoInstance()->getAdditionalInformation(self::INFO_KEY_PM);
35
+ }
36
+
37
+ public function getOpsBrand($payment = null)
38
+ {
39
+ return $this->getInfoInstance()->getAdditionalInformation(self::INFO_KEY_BRAND);
40
+ }
41
+ }
app/code/community/Netresearch/OPS/Model/Payment/InterSolve.php CHANGED
@@ -18,6 +18,7 @@ class Netresearch_OPS_Model_Payment_InterSolve
18
 
19
  /** info source path */
20
  protected $_infoBlockType = 'ops/info_redirect';
 
21
 
22
  /** payment code */
23
  protected $_code = 'ops_interSolve';
18
 
19
  /** info source path */
20
  protected $_infoBlockType = 'ops/info_redirect';
21
+ protected $_formBlockType = 'ops/form_interSolve';
22
 
23
  /** payment code */
24
  protected $_code = 'ops_interSolve';
app/code/community/Netresearch/OPS/Model/Payment/Kwixo/Abstract.php CHANGED
@@ -461,7 +461,7 @@ class Netresearch_OPS_Model_Payment_Kwixo_Abstract
461
 
462
  /**
463
  * get question for fields with disputable value
464
- * users are asked to correct the values before redirect to Ingenico Payment Services
465
  *
466
  * @param Mage_Sales_Model_Order $order Current order
467
  * @param array $requestParams Request parameters
@@ -477,7 +477,7 @@ class Netresearch_OPS_Model_Payment_Kwixo_Abstract
477
 
478
  /**
479
  * get an array of fields with disputable value
480
- * users are asked to correct the values before redirect to Ingenico Payment Services
481
  *
482
  * @param Mage_Sales_Model_Order $order Current order
483
  * @param array $requestParams Request parameters
461
 
462
  /**
463
  * get question for fields with disputable value
464
+ * users are asked to correct the values before redirect to Ingenico ePayments
465
  *
466
  * @param Mage_Sales_Model_Order $order Current order
467
  * @param array $requestParams Request parameters
477
 
478
  /**
479
  * get an array of fields with disputable value
480
+ * users are asked to correct the values before redirect to Ingenico ePayments
481
  *
482
  * @param Mage_Sales_Model_Order $order Current order
483
  * @param array $requestParams Request parameters
app/code/community/Netresearch/OPS/Model/Payment/Masterpass.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Netresearch_OPS_Model_Payment_IDeal
5
+ *
6
+ * @package
7
+ * @copyright 2016 Netresearch
8
+ * @author Benjamin Heuer <benjamin.heuer@netresearch.de>
9
+ * @license OSL 3.0
10
+ */
11
+ class Netresearch_OPS_Model_Payment_Masterpass
12
+ extends Netresearch_OPS_Model_Payment_Abstract
13
+ {
14
+ protected $pm = 'MasterPass';
15
+ protected $brand = 'MasterPass';
16
+
17
+ /** Check if we can capture directly from the backend */
18
+ protected $_canBackendDirectCapture = true;
19
+
20
+ /** info source path */
21
+ protected $_infoBlockType = 'ops/info_redirect';
22
+
23
+ /** payment code */
24
+ protected $_code = 'ops_Masterpass';
25
+
26
+ }
27
+
app/code/community/Netresearch/OPS/Model/Payment/MiniTix.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- /**
3
- * Netresearch_OPS_Model_Payment_MiniTix
4
- *
5
- * @package
6
- * @copyright 2011 Netresearch
7
- * @author Thomas Kappel <thomas.kappel@netresearch.de>
8
- * @license OSL 3.0
9
- */
10
- class Netresearch_OPS_Model_Payment_MiniTix
11
- extends Netresearch_OPS_Model_Payment_Abstract
12
- {
13
- protected $pm = 'miniTix';
14
- protected $brand = 'miniTix';
15
-
16
-
17
- /** Check if we can capture directly from the backend */
18
- protected $_canBackendDirectCapture = true;
19
-
20
- /** info source path */
21
- protected $_infoBlockType = 'ops/info_redirect';
22
-
23
- /** payment code */
24
- protected $_code = 'ops_miniTix';
25
- }
26
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Model/Payment/OpenInvoice/Abstract.php CHANGED
@@ -25,14 +25,14 @@
25
  */
26
 
27
  /**
28
- * open invoice payment via Ingenico Payment Services
29
  */
30
  class Netresearch_OPS_Model_Payment_OpenInvoice_Abstract extends Netresearch_OPS_Model_Payment_Abstract
31
  {
32
  protected $_needsCartDataForRequest = true;
33
  protected $_needsShipToParams = false;
34
 
35
- public function getMethodDependendFormFields($order, $requestParams=null)
36
  {
37
  $formFields = parent::getMethodDependendFormFields($order, $requestParams);
38
 
@@ -42,22 +42,23 @@ class Netresearch_OPS_Model_Payment_OpenInvoice_Abstract extends Netresearch_OPS
42
 
43
  $gender = $order->getCustomerGender() == 1 ? 'M' : 'F';
44
 
45
- $billingAddress = $order->getBillingAddress();
46
- $street = str_replace("\n", ' ',$billingAddress->getStreet(-1));
 
47
  $regexp = '/^([^0-9]*)([0-9].*)$/';
48
  if (!preg_match($regexp, $street, $splittedStreet)) {
49
  $splittedStreet[1] = $street;
50
  $splittedStreet[2] = '';
51
  }
52
 
53
- $formFields['OWNERADDRESS'] = trim($splittedStreet[1]);
54
  $formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
55
 
56
  //$formFields['ECOM_SHIPTO_POSTAL_NAME_PREFIX'] = $shippingAddress->getPrefix();
57
- $formFields['ECOM_BILLTO_POSTAL_NAME_FIRST'] = substr($billingAddress->getFirstname(), 0, 50);
58
- $formFields['ECOM_BILLTO_POSTAL_NAME_LAST'] = substr($billingAddress->getLastname(), 0, 50);
59
- $formFields['ECOM_SHIPTO_DOB'] = $birthday->format('d/m/Y');
60
- $formFields['ECOM_CONSUMER_GENDER'] = $gender;
61
 
62
  return $formFields;
63
  }
25
  */
26
 
27
  /**
28
+ * open invoice payment via Ingenico ePayments
29
  */
30
  class Netresearch_OPS_Model_Payment_OpenInvoice_Abstract extends Netresearch_OPS_Model_Payment_Abstract
31
  {
32
  protected $_needsCartDataForRequest = true;
33
  protected $_needsShipToParams = false;
34
 
35
+ public function getMethodDependendFormFields($order, $requestParams = null)
36
  {
37
  $formFields = parent::getMethodDependendFormFields($order, $requestParams);
38
 
42
 
43
  $gender = $order->getCustomerGender() == 1 ? 'M' : 'F';
44
 
45
+
46
+ $billingAddress = $order->getBillingAddress();
47
+ $street = str_replace("\n", ' ', $billingAddress->getStreet(-1));
48
  $regexp = '/^([^0-9]*)([0-9].*)$/';
49
  if (!preg_match($regexp, $street, $splittedStreet)) {
50
  $splittedStreet[1] = $street;
51
  $splittedStreet[2] = '';
52
  }
53
 
54
+ $formFields['OWNERADDRESS'] = trim($splittedStreet[1]);
55
  $formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
56
 
57
  //$formFields['ECOM_SHIPTO_POSTAL_NAME_PREFIX'] = $shippingAddress->getPrefix();
58
+ $formFields['ECOM_BILLTO_POSTAL_NAME_FIRST'] = substr($billingAddress->getFirstname(), 0, 50);
59
+ $formFields['ECOM_BILLTO_POSTAL_NAME_LAST'] = substr($billingAddress->getLastname(), 0, 50);
60
+ $formFields['ECOM_SHIPTO_DOB'] = $birthday->format('d/m/Y');
61
+ $formFields['ECOM_CONSUMER_GENDER'] = $gender;
62
 
63
  return $formFields;
64
  }
app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceAt.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Netresearch_OPS_Model_Payment_OpenInvoiceAt
5
+ *
6
+ * @package
7
+ * @copyright 2016 Netresearch
8
+ * @author Benjamin Heuer <benjamin.heuer@netresearch.de>
9
+ * @license OSL 3.0
10
+ */
11
+ class Netresearch_OPS_Model_Payment_OpenInvoiceAt
12
+ extends Netresearch_OPS_Model_Payment_OpenInvoice_Abstract
13
+ {
14
+ protected $pm = 'Open Invoice AT';
15
+ protected $brand = 'Open Invoice AT';
16
+
17
+ /** if we can capture directly from the backend */
18
+ protected $_canBackendDirectCapture = false;
19
+
20
+ protected $_canCapturePartial = false;
21
+ protected $_canRefundInvoicePartial = false;
22
+
23
+ /** info source path */
24
+ protected $_infoBlockType = 'ops/info_redirect';
25
+
26
+ /** payment code */
27
+ protected $_code = 'ops_openInvoiceAt';
28
+
29
+ /**
30
+ * Open Invoice AT is not available if quote has a coupon
31
+ *
32
+ * @param Mage_Sales_Model_Quote $quote
33
+ *
34
+ * @return boolean
35
+ */
36
+ public function isAvailable( $quote = null ) {
37
+ /* availability depends on quote */
38
+ if( false == $quote instanceof Mage_Sales_Model_Quote ) {
39
+ return false;
40
+ }
41
+
42
+ /* not available if quote contains a coupon and allow_discounted_carts is disabled */
43
+ if( !$this->isAvailableForDiscountedCarts()
44
+ && $quote->getSubtotal() != $quote->getSubtotalWithDiscount()
45
+ ) {
46
+ return false;
47
+ }
48
+
49
+ /* not available if there is no gender or no birthday */
50
+ if( is_null( $quote->getCustomerGender() ) || is_null( $quote->getCustomerDob() ) ) {
51
+ return false;
52
+ }
53
+
54
+ return parent::isAvailable( $quote );
55
+ }
56
+
57
+ public function getPaymentAction() {
58
+ return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
59
+ }
60
+
61
+ /*
62
+ * @param Mage_Sales_Model_Order $order
63
+ * @param array|null $requestParams
64
+ *
65
+ * @return array
66
+ */
67
+ public function getMethodDependendFormFields( $order, $requestParams = null ) {
68
+ $formFields = parent::getMethodDependendFormFields( $order, $requestParams );
69
+
70
+ $shippingAddress = $order->getShippingAddress();
71
+
72
+ $gender = Mage::getSingleton( 'eav/config' )
73
+ ->getAttribute( 'customer', 'gender' )
74
+ ->getSource()
75
+ ->getOptionText( $order->getCustomerGender() );
76
+
77
+ $formFields[ 'CIVILITY' ] = $gender == 'Male' ? 'Herr' : 'Frau';
78
+ $formFields[ 'ECOM_CONSUMER_GENDER' ] = $gender == 'Male' ? 'M' : 'F';
79
+
80
+ if( !$this->getConfig()->canSubmitExtraParameter( $order->getStoreId() ) ) {
81
+ // add the shipto parameters even if the submitOption is false, because they are required for OpenInvoice
82
+ $shipToParams = $this->getRequestHelper()->extractShipToParameters( $shippingAddress, $order );
83
+ $formFields = array_merge( $formFields, $shipToParams );
84
+ }
85
+
86
+ return $formFields;
87
+ }
88
+
89
+ /**
90
+ * getter for the allow_discounted_carts
91
+ *
92
+ * @return array
93
+ */
94
+ protected function isAvailableForDiscountedCarts() {
95
+ return (bool) $this->getConfigData( 'allow_discounted_carts' );
96
+ }
97
+
98
+ }
app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceDe.php CHANGED
@@ -69,7 +69,8 @@ class Netresearch_OPS_Model_Payment_OpenInvoiceDe
69
  ->getSource()
70
  ->getOptionText($order->getCustomerGender());
71
 
72
- $formFields['CIVILITY'] = $gender == 'Male' ? 'Herr' : 'Frau';
 
73
 
74
  if (!$this->getConfig()->canSubmitExtraParameter($order->getStoreId())) {
75
  // add the shipto parameters even if the submitOption is false, because they are required for OpenInvoice
69
  ->getSource()
70
  ->getOptionText($order->getCustomerGender());
71
 
72
+ $formFields[ 'CIVILITY' ] = $gender == 'Male' ? 'Herr' : 'Frau';
73
+ $formFields[ 'ECOM_CONSUMER_GENDER' ] = $gender == 'Male' ? 'M' : 'F';
74
 
75
  if (!$this->getConfig()->canSubmitExtraParameter($order->getStoreId())) {
76
  // add the shipto parameters even if the submitOption is false, because they are required for OpenInvoice
app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceNl.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /**
3
  * Netresearch_OPS_Model_Payment_OpenInvoiceNl
4
- *
5
- * @package
6
  * @copyright 2011 Netresearch
7
- * @author Thomas Kappel <thomas.kappel@netresearch.de>
8
  * @license OSL 3.0
9
  */
10
  class Netresearch_OPS_Model_Payment_OpenInvoiceNl
@@ -46,7 +46,7 @@ class Netresearch_OPS_Model_Payment_OpenInvoiceNl
46
  }
47
 
48
  /**
49
- * get some method dependend form fields
50
  *
51
  * @param Mage_Sales_Model_Quote $order
52
  * @return array
@@ -69,6 +69,7 @@ class Netresearch_OPS_Model_Payment_OpenInvoiceNl
69
  ->getOptionText($order->getCustomerGender());
70
 
71
  $formFields['CIVILITY'] = $gender == 'Male' ? 'M' : 'V';
 
72
  $formFields['OWNERADDRESS'] = trim($splittedStreet[1]);
73
  $formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
74
  $formFields['OWNERZIP'] = $billingAddress->getPostcode();
@@ -113,7 +114,7 @@ class Netresearch_OPS_Model_Payment_OpenInvoiceNl
113
 
114
  /**
115
  * get question for fields with disputable value
116
- * users are asked to correct the values before redirect to Ingenico Payment Services
117
  *
118
  * @param Mage_Sales_Model_Order $order Current order
119
  * @param array $requestParams Request parameters
@@ -126,7 +127,7 @@ class Netresearch_OPS_Model_Payment_OpenInvoiceNl
126
 
127
  /**
128
  * get an array of fields with disputable value
129
- * users are asked to correct the values before redirect to Ingenico Payment Services
130
  *
131
  * @param Mage_Sales_Model_Order $order Current order
132
  * @param array $requestParams Request parameters
1
  <?php
2
  /**
3
  * Netresearch_OPS_Model_Payment_OpenInvoiceNl
4
+ *
5
+ * @package
6
  * @copyright 2011 Netresearch
7
+ * @author Thomas Kappel <thomas.kappel@netresearch.de>
8
  * @license OSL 3.0
9
  */
10
  class Netresearch_OPS_Model_Payment_OpenInvoiceNl
46
  }
47
 
48
  /**
49
+ * get some method dependend form fields
50
  *
51
  * @param Mage_Sales_Model_Quote $order
52
  * @return array
69
  ->getOptionText($order->getCustomerGender());
70
 
71
  $formFields['CIVILITY'] = $gender == 'Male' ? 'M' : 'V';
72
+ $formFields['ECOM_CONSUMER_GENDER'] = $gender == 'Male' ? 'M' : 'V';
73
  $formFields['OWNERADDRESS'] = trim($splittedStreet[1]);
74
  $formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
75
  $formFields['OWNERZIP'] = $billingAddress->getPostcode();
114
 
115
  /**
116
  * get question for fields with disputable value
117
+ * users are asked to correct the values before redirect to Ingenico ePayments
118
  *
119
  * @param Mage_Sales_Model_Order $order Current order
120
  * @param array $requestParams Request parameters
127
 
128
  /**
129
  * get an array of fields with disputable value
130
+ * users are asked to correct the values before redirect to Ingenico ePayments
131
  *
132
  * @param Mage_Sales_Model_Order $order Current order
133
  * @param array $requestParams Request parameters
app/code/community/Netresearch/OPS/Model/Payment/Other.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * Other.php
4
- * @author paul.siedler@netresearch.de
5
- * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
6
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License
7
- */
8
-
9
- class Netresearch_OPS_Model_Payment_Other extends Netresearch_OPS_Model_Payment_Abstract {
10
-
11
- const CODE = 'ops_other';
12
-
13
- /** Check if we can capture directly from the backend */
14
- protected $_canBackendDirectCapture = true;
15
-
16
- /** info source path */
17
- protected $_infoBlockType = 'ops/info_redirect';
18
-
19
- protected $_formBlockType = 'ops/form_other';
20
-
21
- /** payment code */
22
- protected $_code = self::CODE;
23
-
24
- protected $_needsCartDataForRequest = true;
25
-
26
- public function getOpsCode($payment = null)
27
- {
28
- return '';
29
- }
30
-
31
-
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Model/Payment/Recurring/Cc.php ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Implementation of the Cc payment method implementing subscription manager functionality
24
+ * via Magentos recurring profiles
25
+ *
26
+ * @category Payment method
27
+ * @package Netresearch OPS
28
+ * @author Paul Siedler <paul.siedler@netresearch.de>
29
+ */
30
+ class Netresearch_OPS_Model_Payment_Recurring_Cc
31
+ extends Netresearch_OPS_Model_Payment_Cc
32
+ implements Mage_Payment_Model_Recurring_Profile_MethodInterface
33
+ {
34
+ const CODE = 'ops_recurring_cc';
35
+ protected $_code = self::CODE;
36
+
37
+ protected $_canFetchTransactionInfo = false;
38
+ protected $_canManageRecurringProfiles = true;
39
+ protected $_canUseInternal = false;
40
+
41
+ /** info source path */
42
+ protected $_infoBlockType = 'ops/info_recurringCc';
43
+
44
+ /** @var string $_formBlockType define a specific form block */
45
+ protected $_formBlockType = 'ops/form_recurringCc';
46
+
47
+ protected $parameterModel = null;
48
+ protected $subscriptionManager = null;
49
+
50
+ /**
51
+ * @return Netresearch_OPS_Model_Subscription_Manager
52
+ */
53
+ public function getSubscriptionManager()
54
+ {
55
+ if (is_null($this->subscriptionManager)) {
56
+ $this->subscriptionManager = Mage::getModel('ops/subscription_manager');
57
+ }
58
+
59
+ return $this->subscriptionManager;
60
+ }
61
+
62
+ /**
63
+ * @param Netresearch_OPS_Model_Subscription_Manager $subscriptionManager
64
+ *
65
+ * @returns $this
66
+ */
67
+ public function setSubscriptionManager($subscriptionManager)
68
+ {
69
+ $this->subscriptionManager = $subscriptionManager;
70
+
71
+ return $this;
72
+ }
73
+
74
+
75
+ /**
76
+ * @return Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag
77
+ */
78
+ public function getParameterModel()
79
+ {
80
+ if (is_null($this->parameterModel)) {
81
+ $this->parameterModel = Mage::getModel('ops/payment_recurring_cc_parameterBag');
82
+ }
83
+
84
+ return $this->parameterModel;
85
+ }
86
+
87
+ /**
88
+ * @param Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag $parameterModel
89
+ *
90
+ * @returns $this
91
+ */
92
+ public function setParameterModel($parameterModel)
93
+ {
94
+ $this->parameterModel = $parameterModel;
95
+
96
+ return $this;
97
+ }
98
+
99
+
100
+ /**
101
+ * Validate data
102
+ *
103
+ * @param Mage_Payment_Model_Recurring_Profile $profile
104
+ *
105
+ * @throws Mage_Core_Exception
106
+ */
107
+ public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
108
+ {
109
+ if ($profile->getState() === Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN) {
110
+ $this->invokeRequestParamValidation(
111
+ $this->getParameterModel()->collectProfileParameters($profile)->toArray()
112
+ );
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Submits the trial subscription to the Ingenico ePayments webservice
118
+ *
119
+ * @param Mage_Payment_Model_Recurring_Profile $profile
120
+ * @param Mage_Payment_Model_Info $paymentInfo
121
+ *
122
+ * @return string[]
123
+ */
124
+ protected function submitTrialSubscription(
125
+ Mage_Payment_Model_Recurring_Profile $profile,
126
+ Mage_Payment_Model_Info $paymentInfo
127
+ ) {
128
+ if ($profile->getTrialPeriodUnit()) {
129
+ $requestParams = $this->getParameterModel()->collectAllParametersForTrial($paymentInfo, $profile);
130
+ $this->getParameterModel()->unsetData();
131
+ $response = $this->getDirectLinkHelper()->performDirectLinkRequest(
132
+ $profile->getQuote(), $requestParams, $profile->getQuote()->getStoreId()
133
+ );
134
+
135
+ if ($this->getPaymentHelper()->isPaymentFailed($response['STATUS'])
136
+ || $response['creation_status'] == Netresearch_OPS_Model_Subscription_Manager::CREATION_FAILED
137
+ ) {
138
+ Mage::throwException($this->getDataHelper()->__('Placing of trial subscription transaction failed'));
139
+ }
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Submit to the gateway
145
+ *
146
+ * @param Mage_Payment_Model_Recurring_Profile $profile
147
+ * @param Mage_Payment_Model_Info $paymentInfo
148
+ */
149
+ public function submitRecurringProfile(
150
+ Mage_Payment_Model_Recurring_Profile $profile,
151
+ Mage_Payment_Model_Info $paymentInfo
152
+ ) {
153
+ $this->performPreDirectLinkCallActions($profile->getQuote(), $paymentInfo);
154
+
155
+ $this->submitTrialSubscription($profile, $paymentInfo);
156
+
157
+ $this->submitRegularSubscription($profile, $paymentInfo);
158
+
159
+ $this->submitInitialFee($profile, $paymentInfo);
160
+ }
161
+
162
+ /**
163
+ * Fetch details
164
+ *
165
+ * @param string $referenceId
166
+ * @param Varien_Object $result
167
+ */
168
+ public function getRecurringProfileDetails($referenceId, Varien_Object $result)
169
+ {
170
+ Mage::throwException('Fetching profile details from Ingenico ePayments not supported');
171
+ }
172
+
173
+ /**
174
+ * Check whether can get recurring profile details
175
+ *
176
+ * @return bool
177
+ */
178
+ public function canGetRecurringProfileDetails()
179
+ {
180
+ // querying the subscription status via API is not possible
181
+ return false;
182
+ }
183
+
184
+ /**
185
+ * Update data
186
+ *
187
+ * @param Mage_Payment_Model_Recurring_Profile $profile
188
+ */
189
+ public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
190
+ {
191
+ Mage::throwException('Function not supported');
192
+ }
193
+
194
+ /**
195
+ * Manage status update according to given new state on the profile
196
+ *
197
+ * @param Mage_Payment_Model_Recurring_Profile $profile
198
+ */
199
+ public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
200
+ {
201
+ /** @var Mage_Sales_Model_Recurring_Profile $profile */
202
+ switch ($profile->getNewState()) {
203
+ case Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE:
204
+ if (Mage::getSingleton('admin/session')->isLoggedIn()) {
205
+ $this->addAdminNotice('To actually activate the subscription an update in the Ingenico ePayments backend is needed.'
206
+ );
207
+ } else {
208
+ Mage::throwException(
209
+ $this->getDataHelper()->__('Automatic activation not possible. Please contact our support team.')
210
+ );
211
+ }
212
+ break;
213
+ case Mage_Sales_Model_Recurring_Profile::STATE_CANCELED:
214
+ if (Mage::getSingleton('admin/session')->isLoggedIn()) {
215
+ $this->addAdminNotice('To actually cancel the subscription an update in the Ingenico ePayments backend is needed.'
216
+ );
217
+ } else {
218
+ $this->sendSuspendMail($profile);
219
+ }
220
+ break;
221
+ case Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED:
222
+ if (Mage::getSingleton('admin/session')->isLoggedIn()) {
223
+ $this->addAdminNotice('To actually suspend the subscription an update in the Ingenico ePayments backend is needed.'
224
+ );
225
+ } else {
226
+ $this->sendSuspendMail($profile);
227
+ }
228
+ break;
229
+ case Mage_Sales_Model_Recurring_Profile::STATE_EXPIRED:
230
+ Mage::throwException('Expire function not implemented!');
231
+ break;
232
+ default:
233
+ $message = $this->getDataHelper()->__('Action for state %s not supported', $profile->getNewState());
234
+ Mage::throwException($message);
235
+ break;
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Adds translated message to admin session as notice
241
+ *
242
+ * @param string $message
243
+ */
244
+ protected function addAdminNotice($message)
245
+ {
246
+ Mage::getSingleton('adminhtml/session')->addNotice($this->getDataHelper()->__($message));
247
+ }
248
+
249
+ /**
250
+ *
251
+ * @param Mage_Sales_Model_Recurring_Profile $profile
252
+ *
253
+ * @throws Mage_Core_Exception
254
+ */
255
+ protected function sendSuspendMail($profile)
256
+ {
257
+ $session = Mage::getSingleton('customer/session');
258
+ $mailModel = Mage::getModel('ops/payment_features_paymentEmail');
259
+ if ($session->getCustomer()->getId() != $profile->getCustomerId()) {
260
+ // prevent access to subscriptions not of the customers account
261
+ Mage::throwException(
262
+ $this->getDataHelper()->__('You are not allowed to suspend this subscription!')
263
+ );
264
+ }
265
+ $customer = Mage::getModel('customer/customer')->load($profile->getCustomerId());
266
+ $result = $mailModel->sendSuspendSubscriptionMail($profile, $customer);
267
+ if ($result) {
268
+ // mail successfully sent
269
+ $profile->setNewState($profile::STATE_PENDING);
270
+ $profile->setOverrideState(true);
271
+ $session->addSuccess(
272
+ $this->getDataHelper()
273
+ ->__('Your suspend request was successfully sent. A copy of the email will be sent to your address.'
274
+ )
275
+ );
276
+ } else {
277
+ // sending the mail failed
278
+ Mage::throwException(
279
+ $this->getDataHelper()
280
+ ->__('Could not send suspend mail, please try again or contact our support directly.')
281
+ );
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Check wether payment method is available for quote
287
+ *
288
+ * @param Mage_Sales_Model_Quote $quote
289
+ *
290
+ * @return bool
291
+ */
292
+ public function isAvailable($quote = null)
293
+ {
294
+ if ($quote && !$quote->isNominal()) {
295
+ // allow only nominal quotes
296
+ return false;
297
+ }
298
+
299
+ return parent::isAvailable($quote);
300
+
301
+ }
302
+
303
+ public function hasBrandAliasInterfaceSupport($payment = null)
304
+ {
305
+ // only support inline, since we need the alias
306
+ return true;
307
+ }
308
+
309
+ public function getOrderPlaceRedirectUrl($payment = null)
310
+ {
311
+ if ('' == $this->getOpsHtmlAnswer($payment)) {
312
+ // Prevent redirect on cc payment
313
+ return false;
314
+ } else {
315
+ // 3ds redirect
316
+ return Mage::getModel('ops/config')->get3dSecureRedirectUrl();
317
+
318
+ }
319
+ }
320
+
321
+ public function isZeroAmountAuthorizationAllowed($storeId = null)
322
+ {
323
+ return false;
324
+ }
325
+
326
+ public function getBrandsForAliasInterface()
327
+ {
328
+ return $this->getConfigData('availableTypes');
329
+ }
330
+
331
+ /**
332
+ * @param Mage_Payment_Model_Recurring_Profile $profile
333
+ * @param Mage_Payment_Model_Info $paymentInfo
334
+ *
335
+ * @throws Mage_Core_Exception
336
+ */
337
+ protected function submitRegularSubscription(Mage_Payment_Model_Recurring_Profile $profile,
338
+ Mage_Payment_Model_Info $paymentInfo
339
+ ) {
340
+ $requestParams = $this->getParameterModel()->collectAllParameters($paymentInfo, $profile);
341
+ $this->getParameterModel()->unsetData();
342
+ $response = $this->getDirectLinkHelper()->performDirectLinkRequest(
343
+ $profile->getQuote(), $requestParams, $profile->getQuote()->getStoreId()
344
+ );
345
+
346
+ if ($this->getPaymentHelper()->isPaymentFailed($response['STATUS'])
347
+ || $response['creation_status'] == Netresearch_OPS_Model_Subscription_Manager::CREATION_FAILED
348
+ ) {
349
+ Mage::throwException($this->getDataHelper()->__('Placing of subscription transaction failed'));
350
+ }
351
+
352
+ $this->getSubscriptionManager()->processSubscriptionFeedback($response, $profile);
353
+ }
354
+
355
+ protected function submitInitialFee(
356
+ Mage_Payment_Model_Recurring_Profile $profile,
357
+ Mage_Payment_Model_Info $paymentInfo
358
+ ) {
359
+ /** @var $profile Mage_Sales_Model_Recurring_Profile */
360
+ if ($profile->getInitAmount() > 0) {
361
+ $order = $this->getSubscriptionManager()->createInitialOrder($profile);
362
+
363
+ $requestParams = $this->getParameterModel()
364
+ ->collectAllParametersForInitialFee($paymentInfo, $profile, $order);
365
+ $this->getParameterModel()->unsetData();
366
+ try{
367
+
368
+ $response = $this->getDirectLinkHelper()->performDirectLinkRequest(
369
+ $profile->getQuote(), $requestParams, $profile->getQuote()->getStoreId()
370
+ );
371
+ } catch (Exception $e){
372
+ Mage::logException($e);
373
+ }
374
+
375
+ $this->getSubscriptionManager()->processSubscriptionFeedback($response, $profile, $order);
376
+
377
+ }
378
+
379
+ }
380
+
381
+
382
+ }
app/code/community/Netresearch/OPS/Model/Payment/Recurring/Cc/ParameterBag.php ADDED
@@ -0,0 +1,526 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Parameter.php
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag extends Varien_Object
33
+ {
34
+ /**
35
+ * Period units from Ingenico
36
+ */
37
+ const PERIOD_UNIT_WEEK = 'ww';
38
+ const PERIOD_UNIT_DAY = 'd';
39
+ const PERIOD_UNIT_MONTH = 'm';
40
+
41
+ protected $requestHelper = null;
42
+ protected $config = null;
43
+ protected $quoteHelper = null;
44
+ protected $dataHelper = null;
45
+ protected $subscriptionHelper = null;
46
+
47
+ /**
48
+ * @return Netresearch_OPS_Helper_Subscription
49
+ */
50
+ public function getSubscriptionHelper()
51
+ {
52
+ if (is_null($this->subscriptionHelper)) {
53
+ $this->subscriptionHelper = Mage::helper('ops/subscription');
54
+ }
55
+
56
+ return $this->subscriptionHelper;
57
+ }
58
+
59
+ /**
60
+ * @param Netresearch_OPS_Helper_Subscription $subscriptionHelper
61
+ *
62
+ * @returns $this
63
+ */
64
+ public function setSubscriptionHelper($subscriptionHelper)
65
+ {
66
+ $this->subscriptionHelper = $subscriptionHelper;
67
+
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * @return Netresearch_OPS_Helper_Data
73
+ */
74
+ public function getDataHelper()
75
+ {
76
+ if (is_null($this->dataHelper)) {
77
+ $this->dataHelper = Mage::helper('ops');
78
+ }
79
+
80
+ return $this->dataHelper;
81
+ }
82
+
83
+ /**
84
+ * @param Netresearch_OPS_Helper_Data $dataHelper
85
+ *
86
+ * @returns $this
87
+ */
88
+ public function setDataHelper($dataHelper)
89
+ {
90
+ $this->dataHelper = $dataHelper;
91
+
92
+ return $this;
93
+ }
94
+
95
+ /**
96
+ * @return Netresearch_OPS_Helper_Quote
97
+ */
98
+ public function getQuoteHelper()
99
+ {
100
+ if (is_null($this->quoteHelper)) {
101
+ $this->quoteHelper = Mage::helper('ops/quote');
102
+ }
103
+
104
+ return $this->quoteHelper;
105
+ }
106
+
107
+ /**
108
+ * @param Netresearch_OPS_Helper_Quote $quoteHelper
109
+ *
110
+ * @returns $this
111
+ */
112
+ public function setQuoteHelper($quoteHelper)
113
+ {
114
+ $this->quoteHelper = $quoteHelper;
115
+
116
+ return $this;
117
+ }
118
+
119
+ /**
120
+ * @return Netresearch_OPS_Model_Config
121
+ */
122
+ public function getConfig()
123
+ {
124
+ if (is_null($this->config)) {
125
+ $this->config = Mage::getModel('ops/config');
126
+ }
127
+
128
+ return $this->config;
129
+ }
130
+
131
+ /**
132
+ * @param Netresearch_OPS_Model_Config $config
133
+ *
134
+ * @returns $this
135
+ */
136
+ public function setConfig($config)
137
+ {
138
+ $this->config = $config;
139
+
140
+ return $this;
141
+ }
142
+
143
+ /**
144
+ * @return Netresearch_OPS_Helper_Payment_Request
145
+ */
146
+ public function getRequestHelper()
147
+ {
148
+ if (is_null($this->requestHelper)) {
149
+ $this->requestHelper = Mage::helper('ops/payment_request');
150
+ }
151
+
152
+ return $this->requestHelper;
153
+ }
154
+
155
+ /**
156
+ * @param Netresearch_OPS_Helper_Payment_Request $requestHelper
157
+ *
158
+ * @returns $this
159
+ */
160
+ public function setRequestHelper($requestHelper)
161
+ {
162
+ $this->requestHelper = $requestHelper;
163
+
164
+ return $this;
165
+ }
166
+
167
+ /**
168
+ * Maps the Magento recurring profile units to the Ingenico ePayments ones
169
+ *
170
+ * @param string $unit
171
+ *
172
+ * @return string
173
+ */
174
+ protected function mapUnit($unit)
175
+ {
176
+ switch ($unit) {
177
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_DAY:
178
+ return self::PERIOD_UNIT_DAY;
179
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_MONTH:
180
+ return self::PERIOD_UNIT_MONTH;
181
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_WEEK:
182
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH:
183
+ return self::PERIOD_UNIT_WEEK;
184
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR:
185
+ return self::PERIOD_UNIT_MONTH;
186
+ default:
187
+ return '';
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Some period units are not supported by default by Ingenico, therefore we must adjust the frequency for
193
+ * the following period units to match the MONTH unit:
194
+ *
195
+ * Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH
196
+ * Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR
197
+ *
198
+ * @param string $unit
199
+ * @param int $frequency
200
+ *
201
+ * @return int adjusted frequency
202
+ */
203
+ protected function adjustFrequencyToUnitSpecialCases($unit, $frequency)
204
+ {
205
+ switch ($unit) {
206
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH:
207
+ $frequency *= 2;
208
+ break;
209
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR:
210
+ $frequency *= 12;
211
+ break;
212
+ default:
213
+ break;
214
+ }
215
+
216
+ return $frequency;
217
+ }
218
+
219
+ /**
220
+ * Collects parameters specific to customer (addresses) and quote
221
+ *
222
+ * @param Mage_Payment_Model_Info $paymentInfo
223
+ *
224
+ * @return Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag
225
+ */
226
+ public function collectPaymentParameters(Mage_Payment_Model_Info $paymentInfo, $trial = false)
227
+ {
228
+ $this->setData('CN', $paymentInfo->getAdditionalInformation('CC_CN'))
229
+ ->setData('ALIAS', $paymentInfo->getAdditionalInformation('alias'))
230
+ ->setData('BRAND', $paymentInfo->getAdditionalInformation('CC_BRAND'))
231
+ ->setData('CURRENCY', $this->getQuoteHelper()->getQuoteCurrency($paymentInfo->getQuote()))
232
+ ->setData('OPERATION', Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION)
233
+ ->setData('ORIG', $this->getDataHelper()->getModuleVersionString())
234
+ ->setData('REMOTE_ADDR', $paymentInfo->getQuote()->getRemoteIp());
235
+
236
+
237
+ if ($paymentInfo->getMethodInstance()->getConfigData('enabled_3dsecure')) {
238
+ $this->addData(
239
+ array(
240
+ 'FLAG3D' => 'Y',
241
+ 'WIN3DS' => Netresearch_OPS_Model_Payment_Abstract::OPS_DIRECTLINK_WIN3DS,
242
+ 'LANGUAGE' => Mage::app()->getLocale()->getLocaleCode(),
243
+ 'HTTP_ACCEPT' => '*/*',
244
+ 'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)',
245
+ 'ACCEPTURL' => $this->getConfig()->getAcceptUrl(),
246
+ 'DECLINEURL' => $this->getConfig()->getDeclineUrl(),
247
+ 'EXCEPTIONURL' => $this->getConfig()->getExceptionUrl(),
248
+ )
249
+ );
250
+ }
251
+
252
+ return $this;
253
+ }
254
+
255
+ /**
256
+ * Collects profile specific request parameters
257
+ *
258
+ * @see http://payment-services.ingenico.com/int/en/ogone/support/guides/integration%20guides/subscription-manager/via-e-commerce-and-directlink
259
+ *
260
+ * @param Mage_Payment_Model_Recurring_Profile $profile
261
+ * @param boolean $trial - if the array should contain the parameters necessary for the trial period
262
+ *
263
+ * @return $this
264
+ */
265
+ public function collectProfileParameters(Mage_Payment_Model_Recurring_Profile $profile, $trial = false)
266
+ {
267
+ /** @var Mage_Sales_Model_Recurring_Profile $profile */
268
+
269
+ // get subscription amount from profile values
270
+ list($subscriptionAmount) = $this->getProfileValues($profile, $trial);
271
+
272
+ // determine dates and adjust period values depending on trial parameter
273
+ list($startDate, $endDate, $periodUnit, $periodFrequency) = $this->generateDates($profile, $trial);
274
+
275
+ $subOrderId = $this->getSubscriptionHelper()->generateSubscriptionId($profile, $trial);
276
+
277
+ $this->setData('SUB_COM', $profile->getScheduleDescription())
278
+ ->setData('SUB_ORDERID', $subOrderId)
279
+ ->setData('SUB_PERIOD_NUMBER', $periodFrequency)
280
+ ->setData('SUB_PERIOD_UNIT', $periodUnit)
281
+ ->setData('SUB_STARTDATE', $startDate->format('d/m/Y'))
282
+ ->setData('SUB_ENDDATE', $endDate ? $endDate->format('d/m/Y') : '')
283
+ ->setData('SUB_STATUS', 1)
284
+ ->setData('SUBSCRIPTION_ID', $subOrderId)
285
+ ->setData('ORDERID', $subOrderId)
286
+ ->setData('SUB_AMOUNT', $this->getDataHelper()->getAmount($subscriptionAmount))
287
+ // amount is always 0 for subscription transactions
288
+ ->setData('AMOUNT', 0)
289
+ ->setData('SUB_PERIOD_MOMENT',
290
+ $this->getSubscriptionHelper()->getBillingDayForPeriodUnit($periodUnit, $profile->getStoreId())
291
+ );
292
+
293
+ // add OWNER* and ECOM_BILLTO_* and ECOM_SHIPTO_* parameters
294
+ $this->collectAddressParameters($profile);
295
+
296
+ return $this;
297
+ }
298
+
299
+
300
+ /**
301
+ * Calculates the end date of the profile from the start date, frequency, period unit and maximum cycles
302
+ *
303
+ * @param DateTime $startDate | start date of the subscription
304
+ * @param string $periodUnit | unit of the frequency (d, w, m)
305
+ * @param int $frequency | every nth unit the customer will be charged
306
+ * @param int $maxCycles | maximum amount of cycles
307
+ *
308
+ * @return DateTime|null - the end date or null if no maximum cycle amount is set
309
+ */
310
+ public function calculateEndDate(DateTime $startDate, $periodUnit, $frequency, $maxCycles)
311
+ {
312
+ if(!$this->isMappedUnit($periodUnit)){
313
+ $frequency = $this->adjustFrequencyToUnitSpecialCases($periodUnit, $frequency);
314
+ $periodUnit = $this->mapUnit($periodUnit);
315
+ }
316
+
317
+ $endDate = null;
318
+ if ($maxCycles) {
319
+ $endDate = clone $startDate;
320
+ if ($endDate->format('d') > 28 && $periodUnit != self::PERIOD_UNIT_DAY) {
321
+ $endDate->sub(new DateInterval('P3D'));
322
+ }
323
+
324
+ $dateDiff = $frequency * $maxCycles;
325
+ // fix period unit for week, since the payment provider requests a strange unit
326
+ $periodUnit = $periodUnit == self::PERIOD_UNIT_WEEK ? 'w' : $periodUnit;
327
+
328
+ $endDate->add(new DateInterval('P' . $dateDiff . strtoupper($periodUnit)));
329
+ }
330
+ return $endDate;
331
+ }
332
+
333
+ /**
334
+ * Tests if the given unit is already mapped to the Ingenico types
335
+ *
336
+ * @param string $unit - unit to check
337
+ *
338
+ * @return bool
339
+ */
340
+ protected function isMappedUnit($unit){
341
+ return in_array($unit, array(
342
+ self::PERIOD_UNIT_DAY,
343
+ self::PERIOD_UNIT_WEEK,
344
+ self::PERIOD_UNIT_MONTH
345
+ ));
346
+ }
347
+
348
+ /**
349
+ * Collects all parameters from the given objects and returns the parameter array
350
+ *
351
+ * @param Mage_Payment_Model_Info $paymentInfo
352
+ * @param Mage_Payment_Model_Recurring_Profile $profile
353
+ *
354
+ * @return mixed[] - utf8_encoded request parameters
355
+ */
356
+ public function collectAllParameters(Mage_Payment_Model_Info $paymentInfo,
357
+ Mage_Payment_Model_Recurring_Profile $profile
358
+ ) {
359
+ $this->collectProfileParameters($profile)
360
+ ->collectPaymentParameters($paymentInfo);
361
+
362
+ return $this->encodeValues()->toArray();
363
+ }
364
+
365
+ /**
366
+ * Collects all parameters relevant for the trial period from the given objects and returns the parameter array
367
+ *
368
+ * @param Mage_Payment_Model_Info $paymentInfo
369
+ * @param Mage_Payment_Model_Recurring_Profile $profile
370
+ *
371
+ * @return mixed[] - utf8_encoded request parameters
372
+ */
373
+ public function collectAllParametersForTrial(Mage_Payment_Model_Info $paymentInfo,
374
+ Mage_Payment_Model_Recurring_Profile $profile
375
+ ) {
376
+ $this->collectProfileParameters($profile, true)
377
+ ->collectPaymentParameters($paymentInfo, true);
378
+
379
+ return $this->encodeValues()->toArray();
380
+ }
381
+
382
+ /**
383
+ * collects all relevant parameters for the initial fee
384
+ *
385
+ * @param Mage_Payment_Model_Info $paymentInfo
386
+ * @param Mage_Payment_Model_Recurring_Profile $profile
387
+ * @param Mage_Sales_Model_Order $order
388
+ *
389
+ * @return string[] - utf8 encoded request parameters
390
+ */
391
+ public function collectAllParametersForInitialFee(Mage_Payment_Model_Info $paymentInfo,
392
+ Mage_Payment_Model_Recurring_Profile $profile,
393
+ Mage_Sales_Model_Order $order
394
+ ) {
395
+ /** @var $profile Mage_Sales_Model_Recurring_Profile */
396
+ $this->collectPaymentParameters($paymentInfo)->collectAddressParameters($profile);
397
+
398
+ $this->setData('AMOUNT', $this->getDataHelper()->getAmount($profile->getInitAmount()));
399
+ $this->setData('ORDERID', Mage::helper('ops/order')->getOpsOrderId($order));
400
+
401
+ return $this->encodeValues()->toArray();
402
+ }
403
+
404
+ /**
405
+ * utf8_decodes all parameters
406
+ *
407
+ * @return $this
408
+ */
409
+ protected function encodeValues()
410
+ {
411
+ foreach ($this->getData() as $key => $value) {
412
+ $this->setData($key, utf8_decode($value));
413
+ }
414
+
415
+ return $this;
416
+ }
417
+
418
+ /**
419
+ * Determines base values for the subscription depending on the trial parameter
420
+ *
421
+ * @param Mage_Sales_Model_Recurring_Profile $profile
422
+ * @param $trial - if the values for the trial subscription should be used or not
423
+ *
424
+ * @return string[] - containing the following:
425
+ * [0] => amount for the subscription,
426
+ * [1] => period Unit,
427
+ * [2] => periodFrequency,
428
+ * [3] => max
429
+ */
430
+ protected function getProfileValues($profile, $trial)
431
+ {
432
+ // subscription equals shipping for the product + the product amount+tax itself
433
+ if ($trial) {
434
+ $subscriptionAmount = $profile->getTrialBillingAmount() + $profile->getShippingAmount();
435
+ $periodUnit = $this->mapUnit($profile->getTrialPeriodUnit());
436
+ $periodFrequency = $this->adjustFrequencyToUnitSpecialCases(
437
+ $profile->getTrialPeriodUnit(), $profile->getTrialPeriodFrequency()
438
+ );
439
+ $maxCycles = $profile->getTrialPeriodMaxCycles();
440
+
441
+ } else {
442
+ $subscriptionAmount
443
+ = $profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount();
444
+ $periodUnit = $this->mapUnit($profile->getPeriodUnit());
445
+ $periodFrequency = $this->adjustFrequencyToUnitSpecialCases(
446
+ $profile->getPeriodUnit(), $profile->getPeriodFrequency()
447
+ );
448
+ $maxCycles = $profile->getPeriodMaxCycles();
449
+
450
+ }
451
+
452
+ return array($subscriptionAmount, $periodUnit, $periodFrequency, $maxCycles);
453
+ }
454
+
455
+ /**
456
+ * Determines the start and end date from the given values.
457
+ *
458
+ * @param Mage_Sales_Model_Recurring_Profile $profile
459
+ * @param $trial
460
+ *
461
+ * @return string[] - containing the following:
462
+ * 0 => updated start date
463
+ * 1 => updated enddate
464
+ * 2 => updated period unit
465
+ * 3 => updated period frequency
466
+ */
467
+ protected function generateDates($profile, $trial)
468
+ {
469
+ // get profile values - subscription amount is not needed here
470
+ list(, $periodUnit, $periodFrequency, $maxCycles) = $this->getProfileValues($profile, $trial);
471
+
472
+ if (!$profile->getTrialPeriodUnit() && !$trial || $trial) {
473
+ // if we collect the trial parameters, or if we don't have a trial period at all
474
+ $startDate = new DateTime($profile->getStartDateTime());
475
+ $endDate = $this->calculateEndDate(
476
+ $startDate, $periodUnit, $periodFrequency, $maxCycles
477
+ );
478
+ } else {
479
+ // if we collect the regular subscription and a trial is existent
480
+ $trialStartDate = new DateTime($profile->getStartDateTime());
481
+ $trialPeriodUnit = $this->mapUnit($profile->getTrialPeriodUnit());
482
+ $trialPeriodFrequency = $this->adjustFrequencyToUnitSpecialCases(
483
+ $profile->getTrialPeriodUnit(), $profile->getTrialPeriodFrequency()
484
+ );
485
+ // calculate trial end date and use it as start date for the regular subscription
486
+ $trialEndDate = $this->calculateEndDate(
487
+ $trialStartDate, $trialPeriodUnit, $trialPeriodFrequency, $profile->getTrialPeriodMaxCycles()
488
+ );
489
+
490
+ $startDate = clone $trialEndDate;
491
+ $periodUnit = $this->mapUnit($profile->getPeriodUnit());
492
+ $periodFrequency = $this->adjustFrequencyToUnitSpecialCases(
493
+ $profile->getPeriodUnit(), $profile->getPeriodFrequency()
494
+ );
495
+ $maxCycles = $profile->getPeriodMaxCycles();
496
+ $endDate = $this->calculateEndDate(
497
+ $trialEndDate, $periodUnit, $periodFrequency, $maxCycles
498
+ );
499
+ }
500
+
501
+ return array($startDate, $endDate, $periodUnit, $periodFrequency);
502
+ }
503
+
504
+ /**
505
+ * Add address data to the bag if it is available
506
+ *
507
+ * @param Mage_Payment_Model_Recurring_Profile $profile
508
+ */
509
+ protected function collectAddressParameters(Mage_Payment_Model_Recurring_Profile $profile)
510
+ {
511
+ /** @var $profile Mage_Sales_Model_Recurring_Profile */
512
+ if ($profile->getQuote()) {
513
+ $this->addData(
514
+ $this->getRequestHelper()->getOwnerParams(
515
+ $profile->getQuote()->getBillingAddress(), $profile->getQuote()
516
+ )
517
+ )->addData($this->getRequestHelper()->extractBillToParameters($profile->getQuote()->getBillingAddress()));
518
+
519
+ if ($profile->getQuote()->getShippingAddress()) {
520
+ $this->addData(
521
+ $this->getRequestHelper()->extractShipToParameters($profile->getQuote()->getShippingAddress())
522
+ );
523
+ }
524
+ }
525
+ }
526
+ }
app/code/community/Netresearch/OPS/Model/Payment/Tunz.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- /**
3
- * Netresearch_OPS_Model_Payment_Tunz
4
- *
5
- * @package
6
- * @copyright 2011 Netresearch
7
- * @author Thomas Kappel <thomas.kappel@netresearch.de>
8
- * @license OSL 3.0
9
- */
10
- class Netresearch_OPS_Model_Payment_Tunz
11
- extends Netresearch_OPS_Model_Payment_Abstract
12
- {
13
- protected $pm = 'TUNZ';
14
- protected $brand = 'TUNZ';
15
-
16
- /** Check if we can capture directly from the backend */
17
- protected $_canBackendDirectCapture = true;
18
-
19
- /** info source path */
20
- protected $_infoBlockType = 'ops/info_redirect';
21
-
22
- /** payment code */
23
- protected $_code = 'ops_tunz';
24
-
25
- }
26
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Model/Payment/Wallie.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- /**
3
- * Netresearch_OPS_Model_Payment_Wallie
4
- *
5
- * @package
6
- * @copyright 2011 Netresearch
7
- * @author Thomas Kappel <thomas.kappel@netresearch.de>
8
- * @license OSL 3.0
9
- */
10
- class Netresearch_OPS_Model_Payment_Wallie
11
- extends Netresearch_OPS_Model_Payment_Abstract
12
- {
13
- protected $pm = 'Wallie';
14
- protected $brand = 'Wallie';
15
-
16
- /** Check if we can capture directly from the backend */
17
- protected $_canBackendDirectCapture = true;
18
-
19
- /** info source path */
20
- protected $_infoBlockType = 'ops/info_redirect';
21
-
22
- /** payment code */
23
- protected $_code = 'ops_wallie';
24
-
25
- }
26
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Model/Response/Handler.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Handler.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Model_Response_Handler
33
+ {
34
+
35
+ /**
36
+ * @param array $responseArray
37
+ * @param Netresearch_OPS_Model_Payment_Abstract $paymentMethod
38
+ * @param bool $shouldRegisterFeedback
39
+ * determines if the Mage_Sales_Model_Order_Payments register*Feedback
40
+ * functions get called, defaults to true
41
+ *
42
+ */
43
+ public function processResponse(
44
+ $responseArray, Netresearch_OPS_Model_Payment_Abstract $paymentMethod, $shouldRegisterFeedback = true
45
+ ){
46
+ $responseArray = array_change_key_case($responseArray, CASE_LOWER);
47
+ $this->getTypeHandler($responseArray['status'])
48
+ ->handleResponse($responseArray, $paymentMethod, $shouldRegisterFeedback);
49
+ }
50
+
51
+ /**
52
+ * @param $status
53
+ *
54
+ * @return Netresearch_OPS_Model_Response_TypeInterface
55
+ */
56
+ protected function getTypeHandler($status)
57
+ {
58
+ $type = null;
59
+
60
+ if (Netresearch_OPS_Model_Status::isCapture($status)) {
61
+ $type = Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE;
62
+ } elseif (Netresearch_OPS_Model_Status::isRefund($status)) {
63
+ $type = Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE;
64
+ } elseif (Netresearch_OPS_Model_Status::isVoid($status)) {
65
+ $type = Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE;
66
+ } elseif (Netresearch_OPS_Model_Status::isAuthorize($status)) {
67
+ $type = Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_TRANSACTION_TYPE;
68
+ } elseif (Netresearch_OPS_Model_Status::isSpecialStatus($status)) {
69
+ $type = 'special';
70
+ } else {
71
+ Mage::throwException(Mage::helper('ops')->__('Can not handle status %s.', $status));
72
+ }
73
+
74
+ return Mage::getModel('ops/response_type_' . $type);
75
+ }
76
+ }
app/code/community/Netresearch/OPS/Model/Response/Type/Abstract.php ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Abstract.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ /**
33
+ * Class Netresearch_OPS_Model_Response_Type_Abstract
34
+ *
35
+ * @method Netresearch_OPS_Model_Payment_Abstract getMethodInstance()
36
+ * @method Netresearch_OPS_Model_Response_Type_Abstract setMethodInstance(Netresearch_OPS_Model_Payment_Abstract $instance)
37
+ * @method int getStatus()
38
+ * @method int getPayid()
39
+ * @method bool hasPayidsub()
40
+ * @method int getPayidsub()
41
+ * @method float getAmount()
42
+ * @method string getCurrency()
43
+ * @method string getOrderid()
44
+ * @method string getAavaddress()
45
+ * @method string getAavcheck()
46
+ * @method string get Aavzip()
47
+ * @method string getAcceptance()
48
+ * @method string getBin()
49
+ * @method string getBrand()
50
+ * @method string getCardno()
51
+ * @method string getCccty()
52
+ * @method string getCn()
53
+ * @method string getCvccheck()
54
+ * @method string getScoring()
55
+ * @method bool hasScoring()
56
+ * @method string getScoCategory()
57
+ * @method bool hasScoCategory()
58
+ * @method string getShasign()
59
+ * @method string getSubbrand()
60
+ * @method string getTrxdate()
61
+ * @method string getVc()
62
+ * @method int getNcstatus()
63
+ * @method string getNcerror()
64
+ * @method string getNcerrorplus()
65
+ * @method string getHtmlAnswer()
66
+ * @method string getIpcty()
67
+ * @method bool hasAcceptance()
68
+ * @method bool hasBrand()
69
+ * @method bool getShouldRegisterFeedback() if feedback should get registered on payment object
70
+ * @method Netresearch_OPS_Model_Response_Type_Abstract setShouldRegisterFeedback($shouldRegisterFeedback)
71
+ *
72
+ */
73
+ abstract class Netresearch_OPS_Model_Response_Type_Abstract extends Varien_Object
74
+ implements Netresearch_OPS_Model_Response_TypeInterface
75
+ {
76
+
77
+ /**
78
+ * @return Netresearch_OPS_Model_Config
79
+ */
80
+ public function getConfig()
81
+ {
82
+ if (is_null($this->getData('config'))) {
83
+ $this->setData('config', Mage::getModel('ops/config'));
84
+ }
85
+
86
+ return $this->getData('config');
87
+ }
88
+
89
+ /**
90
+ * Performs the necessary actions for Magento to progress the order state correctly and automatically build the
91
+ * create sales objects
92
+ *
93
+ * @param array $responseArray
94
+ * @param Netresearch_OPS_Model_Payment_Abstract $paymentMethod
95
+ * @param bool $shouldRegisterFeedback determines if the Mage_Sales_Model_Order_Payments register*Feedback
96
+ * functions get called, defaults to true
97
+ *
98
+ * @return Netresearch_OPS_Model_Response_TypeInterface
99
+ */
100
+ public function handleResponse($responseArray, Netresearch_OPS_Model_Payment_Abstract $paymentMethod,
101
+ $shouldRegisterFeedback = true
102
+ ) {
103
+ $this->setData(array_change_key_case($responseArray, CASE_LOWER));
104
+ $this->setMethodInstance($paymentMethod);
105
+ $this->setShouldRegisterFeedback($shouldRegisterFeedback);
106
+
107
+ if ($this->getStatus() == $this->getMethodInstance()->getInfoInstance()->getAdditionalInformation('status')
108
+ && $this->getTransactionId() == $paymentMethod->getInfoInstance()->getLastTransId()) {
109
+ return $this;
110
+ }
111
+
112
+ $this->setGeneralTransactionInfo();
113
+ $this->_handleResponse();
114
+ $this->updateAdditionalInformation();
115
+
116
+ return $this;
117
+ }
118
+
119
+ /**
120
+ * Handles the specific actions for the concrete payment status
121
+ */
122
+ protected abstract function _handleResponse();
123
+
124
+
125
+ /**
126
+ * Updates the additional information of the payment info object
127
+ *
128
+ * @see \Netresearch_OPS_Model_Response_Type_Abstract::updateDefaultInformation
129
+ * @see \Netresearch_OPS_Model_Response_Type_Abstract::setFraudDetectionParameters
130
+ */
131
+ protected function updateAdditionalInformation()
132
+ {
133
+ $this->updateDefaultInformation();
134
+ $this->setFraudDetectionParameters();
135
+ }
136
+
137
+ /**
138
+ * Updates default information in additional information of the payment info object
139
+ */
140
+ protected function updateDefaultInformation()
141
+ {
142
+ $payment = $this->getMethodInstance()->getInfoInstance();
143
+
144
+ $payment->setAdditionalInformation('paymentId', $this->getPayid())
145
+ ->setAdditionalInformation('status', $this->getStatus());
146
+
147
+ if ($this->hasAcceptance()) {
148
+ $payment->setAdditionalInformation('acceptence', $this->getAcceptance());
149
+ }
150
+
151
+ if ($this->hasBrand() && $this->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Cc) {
152
+ $payment->setAdditionalInformation('CC_BRAND', $this->getBrand());
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Sets Transaction details (TransactionId etc.)
158
+ */
159
+ protected function setGeneralTransactionInfo()
160
+ {
161
+ $payment = $this->getMethodInstance()->getInfoInstance();
162
+
163
+ $payment->setTransactionParentId($this->getPayid());
164
+ $transId = $this->getTransactionId();
165
+
166
+ $payment->setLastTransId($transId);
167
+ $payment->setTransactionId($transId);
168
+ $payment->setIsTransactionClosed(false);
169
+ }
170
+
171
+ /**
172
+ * Updates fraud detection information on additional information of the payment info object
173
+ */
174
+ protected function setFraudDetectionParameters()
175
+ {
176
+ $payment = $this->getMethodInstance()->getInfoInstance();
177
+ if ($this->hasScoring()) {
178
+ $payment->setAdditionalInformation('scoring', $this->getScoring());
179
+ }
180
+
181
+ if ($this->hasScoCategory()) {
182
+ $payment->setAdditionalInformation('scoringCategory', $this->getScoCategory());
183
+ }
184
+
185
+ $additionalScoringData = array();
186
+ foreach ($this->getConfig()->getAdditionalScoringKeys() as $key) {
187
+ if ($this->hasData(strtolower($key))) {
188
+ if (false === mb_detect_encoding($this->getData(strtolower($key)), 'UTF-8', true)) {
189
+ $additionalScoringData[$key] = utf8_encode($this->getData(strtolower($key)));
190
+ } else {
191
+ $additionalScoringData[$key] = $this->getData(strtolower($key));
192
+ }
193
+
194
+ }
195
+ }
196
+
197
+ $payment->setAdditionalInformation('additionalScoringData', $additionalScoringData);
198
+ }
199
+
200
+ /**
201
+ * @param string $orderComment
202
+ * @param string $additionalInfo
203
+ *
204
+ * @return string
205
+ */
206
+ protected function addOrderComment($orderComment, $additionalInfo = '')
207
+ {
208
+
209
+ $orderComment = $this->getOrderComment($orderComment, $additionalInfo);
210
+ $this->getMethodInstance()->getInfoInstance()->getOrder()->addStatusHistoryComment($orderComment);
211
+ }
212
+
213
+ /**
214
+ * Add order comment about final status
215
+ *
216
+ * @param string $additionalInfo
217
+ */
218
+ protected function addFinalStatusComment($additionalInfo = '')
219
+ {
220
+ $this->addOrderComment($this->getFinalStatusComment($additionalInfo));
221
+ }
222
+
223
+ /**
224
+ * Add order comment about intermediate status
225
+ *
226
+ * @param string $additionalInfo
227
+ */
228
+ protected function addIntermediateStatusComment($additionalInfo = '')
229
+ {
230
+ $this->addOrderComment($this->getIntermediateStatusComment($additionalInfo));
231
+ }
232
+
233
+ /**
234
+ * Add order comment about refused status
235
+ *
236
+ * @param string $additionalInfo
237
+ */
238
+ protected function addRefusedStatusComment($additionalInfo = '')
239
+ {
240
+ $this->addOrderComment($this->getRefusedStatusComment($additionalInfo));
241
+ }
242
+
243
+ /**
244
+ * Add order comment about fraud status
245
+ *
246
+ * @param string $additionalInfo
247
+ */
248
+ protected function addFraudStatusComment($additionalInfo = '')
249
+ {
250
+ $this->addOrderComment($this->getFraudStatusComment($additionalInfo));
251
+ }
252
+
253
+
254
+ /**
255
+ * @param string $additionalInfo
256
+ *
257
+ * @return string
258
+ */
259
+ protected function getFinalStatusComment($additionalInfo = '')
260
+ {
261
+ $orderComment = Mage::helper('ops')->__(
262
+ 'Received Ingenico ePayments feedback status update with final status %s.',
263
+ $this->getStatus()
264
+
265
+ );
266
+ return $this->getOrderComment($orderComment, $additionalInfo);
267
+
268
+ }
269
+
270
+ /**
271
+ * @param string $additionalInfo
272
+ *
273
+ * @return string
274
+ */
275
+ protected function getIntermediateStatusComment($additionalInfo = '')
276
+ {
277
+ $orderComment = Mage::helper('ops')->__(
278
+ 'Received Ingenico ePayments feedback status update with intermediate status %s.',
279
+ $this->getStatus()
280
+ );
281
+ return $this->getOrderComment($orderComment, $additionalInfo);
282
+ }
283
+
284
+ /**
285
+ * @param string $additionalInfo
286
+ *
287
+ * @return string
288
+ */
289
+ protected function getRefusedStatusComment($additionalInfo = '')
290
+ {
291
+ $orderComment = Mage::helper('ops')->__(
292
+ 'Received Ingenico ePayments feedback status update with refused status %s.',
293
+ $this->getStatus()
294
+ );
295
+ return $this->getOrderComment($orderComment, $additionalInfo);
296
+ }
297
+
298
+ /**
299
+ * @param string $additionalInfo
300
+ *
301
+ * @return string
302
+ */
303
+ protected function getFraudStatusComment($additionalInfo = '')
304
+ {
305
+ $orderComment = Mage::helper('ops')->__(
306
+ 'Received Ingenico ePayments feedback status update with suspected fraud status %s.',
307
+ $this->getStatus()
308
+ );
309
+ return $this->getOrderComment($orderComment, $additionalInfo);
310
+ }
311
+
312
+ /**
313
+ * @param string $additionalInfo
314
+ * @param string $orderComment
315
+ *
316
+ * @return string
317
+ */
318
+ protected function getOrderComment($orderComment, $additionalInfo = '')
319
+ {
320
+ if ($additionalInfo) {
321
+ $orderComment .= ' ' . $additionalInfo;
322
+ }
323
+
324
+ return $orderComment;
325
+ }
326
+
327
+ /**
328
+ * Merges the PAYID with the PAYIDSUB, if the latter is present, otherwise just returns the PAYID
329
+ *
330
+ * @return string
331
+ */
332
+ public function getTransactionId()
333
+ {
334
+ $transId = $this->getPayid();
335
+ if ($this->hasPayidsub()) {
336
+ $transId .= '/' . $this->getPayidsub();
337
+ }
338
+
339
+ return $transId;
340
+ }
341
+ }
app/code/community/Netresearch/OPS/Model/Response/Type/Authorize.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Authorize.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Model_Response_Type_Authorize extends Netresearch_OPS_Model_Response_Type_Abstract
33
+ {
34
+ /**
35
+ * Handles the specific actions for the concrete payment status
36
+ */
37
+ protected function _handleResponse()
38
+ {
39
+ if (!Netresearch_OPS_Model_Status::isAuthorize($this->getStatus())) {
40
+ throw new Mage_Core_Exception(Mage::helper('ops')->__('%s is not a authorize status!', $this->getStatus()));
41
+ }
42
+
43
+
44
+ /** @var Mage_Sales_Model_Order $order */
45
+ $order = $this->getMethodInstance()->getInfoInstance()->getOrder();
46
+ /** @var Mage_Sales_Model_Order_Payment $payment */
47
+ $payment = $this->getMethodInstance()->getInfoInstance();
48
+
49
+ // if no parent transaction id has been set yet set the parentTransactionId so we can void
50
+ if (!$payment->getParentTransactionId()) {
51
+ $payment->setParentTransactionId($this->getPayid());
52
+ }
53
+
54
+ if (Netresearch_OPS_Model_Status::isFinal($this->getStatus())) {
55
+ // handle authorization declined
56
+ // thrown exception gets catched by core and order will not been created
57
+ if ($this->getStatus() == Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED
58
+ ) {
59
+ if (!$this->getShouldRegisterFeedback()) {
60
+ Mage::throwException(
61
+ Mage::helper('ops')->__(
62
+ 'Payment failed because the authorization was declined! Please choose another payment method.'
63
+ )
64
+ );
65
+ } elseif ($payment->getAdditionalInformation('status')
66
+ == Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION
67
+ && $order->getState() === Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW
68
+ ) {
69
+ try {
70
+ // if the payment was previously in payment review/has status 46 the identification obviously failed and the order gets canceled
71
+ $payment->setNotificationResult(true);
72
+ $payment->registerPaymentReviewAction(
73
+ Mage_Sales_Model_Order_Payment::REVIEW_ACTION_DENY, false
74
+ );
75
+ } catch (Mage_Core_Exception $e) {
76
+ /**
77
+ * in CE 1.7 Mage_Sales_Model_Order::registerCancellation will always fail with exception if the
78
+ * order is in payment_review state. we therefore cancel the order 'manually'.
79
+ *
80
+ * below code is c&p from Mage_Sales_Model_Order::registerCancellation:
81
+ *
82
+ * @see Mage_Sales_Model_Order::registerCancellation
83
+ */
84
+ if ($e->getMessage() === Mage::helper('sales')->__('Order does not allow to be canceled.')) {
85
+ $cancelState = Mage_Sales_Model_Order::STATE_CANCELED;
86
+ foreach ($order->getAllItems() as $item) {
87
+ if ($cancelState != Mage_Sales_Model_Order::STATE_PROCESSING
88
+ && $item->getQtyToRefund()
89
+ ) {
90
+ if ($item->getQtyToShip() > $item->getQtyToCancel()) {
91
+ $cancelState = Mage_Sales_Model_Order::STATE_PROCESSING;
92
+ } else {
93
+ $cancelState = Mage_Sales_Model_Order::STATE_COMPLETE;
94
+ }
95
+ }
96
+ $item->cancel();
97
+ }
98
+
99
+ $order->setSubtotalCanceled($order->getSubtotal() - $order->getSubtotalInvoiced());
100
+ $order->setBaseSubtotalCanceled(
101
+ $order->getBaseSubtotal() - $order->getBaseSubtotalInvoiced()
102
+ );
103
+
104
+ $order->setTaxCanceled($order->getTaxAmount() - $order->getTaxInvoiced());
105
+ $order->setBaseTaxCanceled($order->getBaseTaxAmount() - $order->getBaseTaxInvoiced());
106
+
107
+ $order->setShippingCanceled($order->getShippingAmount() - $order->getShippingInvoiced());
108
+ $order->setBaseShippingCanceled(
109
+ $order->getBaseShippingAmount() - $order->getBaseShippingInvoiced()
110
+ );
111
+
112
+ $order->setDiscountCanceled(
113
+ abs($order->getDiscountAmount()) - $order->getDiscountInvoiced()
114
+ );
115
+ $order->setBaseDiscountCanceled(
116
+ abs($order->getBaseDiscountAmount()) - $order->getBaseDiscountInvoiced()
117
+ );
118
+
119
+ $order->setTotalCanceled($order->getGrandTotal() - $order->getTotalPaid());
120
+ $order->setBaseTotalCanceled($order->getBaseGrandTotal() - $order->getBaseTotalPaid());
121
+
122
+ $order->setState($cancelState, true, $this->getFinalStatusComment());
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+ if ($this->getShouldRegisterFeedback()) {
129
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
130
+
131
+ $action = Mage_Sales_Model_Order_Payment::REVIEW_ACTION_ACCEPT;
132
+ $targetState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
133
+ if (Netresearch_OPS_Model_Status::canResendPaymentInfo($this->getStatus())
134
+ && Mage::helper('ops/payment')->isInlinePayment($payment)
135
+ ) {
136
+ $targetState = Mage_Sales_Model_Order::STATE_CANCELED;
137
+ $action = Mage_Sales_Model_Order_Payment::REVIEW_ACTION_DENY;
138
+ }
139
+ $payment->setNotificationResult(true);
140
+ $payment->registerPaymentReviewAction($action, false);
141
+ if ($order->getState() != $targetState) {
142
+ $order->setState($targetState, true, $this->getFinalStatusComment());
143
+ }
144
+ } elseif ($order->getState() === Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
145
+ || $order->getState() === Mage_Sales_Model_Order::STATE_NEW
146
+ ) {
147
+ $payment->registerAuthorizationNotification($this->getAmount());
148
+ $order->setState(
149
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $this->getFinalStatusComment()
150
+ );
151
+
152
+ }
153
+ } else {
154
+ $this->addFinalStatusComment();
155
+ }
156
+ } else {
157
+ $payment->setIsTransactionPending(true);
158
+ if ($this->getStatus() == Netresearch_OPS_Model_Status::STAND_BY_SUSPECTED_FRAUD) {
159
+ $payment->setIsFraudDetected(true);
160
+ $order->setState(
161
+ Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
162
+ Mage_Sales_Model_Order::STATUS_FRAUD,
163
+ $this->getFraudStatusComment(
164
+ Mage::helper('ops')->__('Please have a look in Ingenico ePayments backend for more information.')
165
+ )
166
+ );
167
+ } else {
168
+ $order->addStatusHistoryComment($this->getIntermediateStatusComment());
169
+ }
170
+ if ($this->getShouldRegisterFeedback()) {
171
+ $payment->registerAuthorizationNotification($this->getAmount());
172
+ }
173
+ }
174
+
175
+ if ($this->getShouldRegisterFeedback()) {
176
+ $payment->save();
177
+ $order->save();
178
+ }
179
+
180
+ return $this;
181
+ }
182
+ }
app/code/community/Netresearch/OPS/Model/Response/Type/Capture.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Capture.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Model_Response_Type_Capture extends Netresearch_OPS_Model_Response_Type_Abstract
33
+ {
34
+ /**
35
+ * Handles the specific actions for the concrete payment status
36
+ */
37
+ protected function _handleResponse()
38
+ {
39
+ if (!Netresearch_OPS_Model_Status::isCapture($this->getStatus())) {
40
+ throw new Mage_Core_Exception(Mage::helper('ops')->__('%s is not a capture status!', $this->getStatus()));
41
+ }
42
+
43
+ /** @var Mage_Sales_Model_Order_Payment $payment */
44
+ $payment = $this->getMethodInstance()->getInfoInstance();
45
+ /** @var Mage_Sales_Model_Order $order */
46
+ $order = $payment->getOrder();
47
+
48
+
49
+ /**
50
+ * Basically we have to check the following things here:
51
+ *
52
+ * Order state - payment_review suggests an already existing intermediate status
53
+ * - pending_payment or new suggests no feedback yet
54
+ *
55
+ * payment status - intermediate and not failed -> move to payment review or add another comment
56
+ * - intermediate and failed -> if recoverable let the order open and place comment
57
+ * - finished - finish invoice dependent on order state
58
+ */
59
+
60
+ if (Netresearch_OPS_Model_Status::isIntermediate($this->getStatus())) {
61
+
62
+ $message = $this->getIntermediateStatusComment();
63
+ $payment->setIsTransactionPending(true);
64
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
65
+ || $order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING
66
+ ) {
67
+ // transaction was placed on PSP, initial feedback to shop or partial capture case
68
+
69
+ $payment->setPreparedMessage($message);
70
+ if ($this->getShouldRegisterFeedback()) {
71
+ $payment->registerCaptureNotification($this->getAmount());
72
+ }
73
+
74
+ } elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
75
+ // payment was pending and is still pending
76
+ $payment->setIsTransactionApproved(false);
77
+ $payment->setIsTransactionDenied(false);
78
+ $payment->setPreparedMessage($message);
79
+
80
+ if ($this->getShouldRegisterFeedback()) {
81
+ $payment->setNotificationResult(true);
82
+ $payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, false);
83
+ }
84
+
85
+ }
86
+ } else {
87
+ // final status, means 9 or 95
88
+ $message = $this->getFinalStatusComment();
89
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
90
+ $payment->setNotificationResult(true);
91
+ $payment->setPreparedMessage($message);
92
+ if ($this->getShouldRegisterFeedback()) {
93
+ $payment->setNotificationResult(true);
94
+ $payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_ACCEPT, false);
95
+ }
96
+ } else {
97
+ $payment->setPreparedMessage($message);
98
+ if ($this->getShouldRegisterFeedback()) {
99
+ $payment->registerCaptureNotification($this->getAmount());
100
+ }
101
+ }
102
+ }
103
+ if($this->getShouldRegisterFeedback()) {
104
+ $payment->save();
105
+ $order->save();
106
+ }
107
+ }
108
+ }
app/code/community/Netresearch/OPS/Model/Response/Type/Refund.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Refund.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Model_Response_Type_Refund extends Netresearch_OPS_Model_Response_Type_Abstract
33
+ {
34
+ /**
35
+ * Handles the specific actions for the concrete payment status
36
+ */
37
+ protected function _handleResponse()
38
+ {
39
+ if (!Netresearch_OPS_Model_Status::isRefund($this->getStatus())) {
40
+ Mage::throwException(Mage::helper('ops')->__('%s is not a refund status!', $this->getStatus()));
41
+ }
42
+
43
+
44
+ /** @var Mage_Sales_Model_Order_Payment $payment */
45
+ $payment = $this->getMethodInstance()->getInfoInstance();
46
+
47
+ /** @var Mage_Sales_Model_Order $order */
48
+ $order = $payment->getOrder();
49
+
50
+ if (!$this->hasPayidsub()) {
51
+ $creditMemo = $this->determineCreditMemo();
52
+ $payment->setRefundTransactionId($creditMemo->getTransactionId());
53
+ } else {
54
+ $creditMemo = Mage::getModel('sales/order_creditmemo')->load(
55
+ $this->getTransactionId(), 'transaction_id'
56
+ );
57
+ $payment->setRefundTransactionId($this->getTransactionId());
58
+ }
59
+
60
+ if ($creditMemo->getId()) {
61
+ if (Netresearch_OPS_Model_Status::isFinal($this->getStatus())
62
+ && $creditMemo->getState() == Mage_Sales_Model_Order_Creditmemo::STATE_OPEN
63
+ ) {
64
+ $creditMemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED);
65
+ $this->closeRefundTransaction($creditMemo);
66
+ $this->addFinalStatusComment();
67
+ } elseif ($this->getStatus() == Netresearch_OPS_Model_Status::REFUND_REFUSED) {
68
+ $order = $creditMemo->getOrder();
69
+ $creditMemo->cancel()->save();
70
+ $this->closeRefundTransaction($creditMemo);
71
+ $invoice = Mage::getModel('sales/order_invoice')->load($creditMemo->getInvoiceId());
72
+ $invoice->setIsUsedForRefund(0)
73
+ ->setBaseTotalRefunded(
74
+ $invoice->getBaseTotalRefunded() - $creditMemo->getBaseGrandTotal()
75
+ );
76
+ $creditMemo->setInvoice($invoice);
77
+ /** @var Mage_Sales_Model_Order_Creditmemo_Item $item */
78
+ foreach ($creditMemo->getAllItems() as $item) {
79
+ $item->getOrderItem()->setAmountRefunded(
80
+ $item->getOrderItem()->getAmountRefunded() - $item->getRowTotal()
81
+ );
82
+ $item->getOrderItem()->setBaseAmountRefunded(
83
+ $item->getOrderItem()->getBaseAmountRefunded() - $item->getBaseRowTotal()
84
+ );
85
+ }
86
+ $order->setTotalRefunded($order->getTotalRefunded() - $creditMemo->getBaseGrandTotal());
87
+ $order->setBaseTotalRefunded($order->getBaseTotalRefunded() - $creditMemo->getBaseGrandTotal());
88
+
89
+ $this->addRefusedStatusComment();
90
+ $state = Mage_Sales_Model_Order::STATE_COMPLETE;
91
+ if ($order->canShip() || $order->canInvoice()) {
92
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
93
+ }
94
+ $order->setState(
95
+ $state,
96
+ true,
97
+ $this->getRefusedStatusComment(Mage::helper('ops')->__('Refund refused by Ingenico ePayments.'))
98
+ );
99
+ } else {
100
+ $this->addIntermediateStatusComment();
101
+ }
102
+
103
+ } else {
104
+ if ($this->getShouldRegisterFeedback()) {
105
+ $payment->setParentTransactionId($this->getPayid());
106
+ $payment->setTransactionId($this->getTransactionId());
107
+ $payment->setIsTransactionClosed(Netresearch_OPS_Model_Status::isFinal($this->getStatus()));
108
+ $payment->registerRefundNotification($this->getAmount());
109
+ }
110
+ if (Netresearch_OPS_Model_Status::isFinal($this->getStatus())) {
111
+ $this->addFinalStatusComment();
112
+ } else {
113
+ $this->addIntermediateStatusComment();
114
+ $creditMemo = $payment->getCreatedCreditMemo() ?: $payment->getCreditmemo();
115
+ if ($creditMemo) {
116
+ $creditMemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_OPEN);
117
+ }
118
+ }
119
+ }
120
+ if ($this->getShouldRegisterFeedback()) {
121
+ $transactionSave = Mage::getModel('core/resource_transaction')
122
+ ->addObject($order)
123
+ ->addObject($payment)
124
+ ->addObject($creditMemo);
125
+
126
+ if ($creditMemo->getInvoice()) {
127
+ $transactionSave->addObject($creditMemo->getInvoice());
128
+ }
129
+ $transactionSave->save();
130
+ }
131
+
132
+ return;
133
+ }
134
+
135
+ /**
136
+ * Will load the creditmemo by identifying open refund transactions
137
+ *
138
+ * @return Mage_Sales_Model_Order_Creditmemo|null
139
+ */
140
+ protected function determineCreditMemo()
141
+ {
142
+ /** @var Mage_Sales_Model_Order_Payment $payment */
143
+ $payment = $this->getMethodInstance()->getInfoInstance();
144
+ $refundTransaction = Mage::helper('ops/order_refund')->getOpenRefundTransaction($payment);
145
+ /** @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
146
+ $creditmemo = Mage::getModel('sales/order_creditmemo')->load(
147
+ $refundTransaction->getTxnId(), 'transaction_id'
148
+ );
149
+
150
+ return $creditmemo;
151
+ }
152
+
153
+ /**
154
+ * Closes the refund transaction for the given creditmemo
155
+ *
156
+ * @param $creditMemo
157
+ */
158
+ protected function closeRefundTransaction($creditMemo)
159
+ {
160
+ $refundTransaction = $this->getMethodInstance()->getInfoInstance()->lookupTransaction(
161
+ $creditMemo->getTransactionId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND
162
+ );
163
+ if ($refundTransaction) {
164
+ $refundTransaction->setIsClosed(true)
165
+ ->save();
166
+ }
167
+ }
168
+
169
+ }
app/code/community/Netresearch/OPS/Model/Response/Type/Special.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Special.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Model_Response_Type_Special extends Netresearch_OPS_Model_Response_Type_Abstract
33
+ {
34
+ /**
35
+ * Handles the specific actions for the concrete payment statuses
36
+ */
37
+ protected function _handleResponse()
38
+ {
39
+ if (!Netresearch_OPS_Model_Status::isSpecialStatus($this->getStatus())) {
40
+ throw new Mage_Core_Exception(Mage::helper('ops')->__('%s is not a special status!', $this->getStatus()));
41
+ }
42
+
43
+ /** @var Mage_Sales_Model_Order_Payment $payment */
44
+ $payment = $this->getMethodInstance()->getInfoInstance();
45
+ $order = $payment->getOrder();
46
+ $helper = Mage::helper('ops');
47
+
48
+ if ($this->getStatus() == Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION) {
49
+ $payment->setIsTransactionPending(true);
50
+ $payment->setAdditionalInformation('HTML_ANSWER', $this->getHtmlAnswer());
51
+ $order->addStatusHistoryComment(
52
+ $this->getIntermediateStatusComment($helper->__('Customer redirected for 3DS authorization.'))
53
+ );
54
+ }
55
+
56
+ if ($this->getStatus() == Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT) {
57
+ $order->addStatusHistoryComment(
58
+ $this->getIntermediateStatusComment(
59
+ $helper->__(
60
+ 'Customer received your payment instructions, waiting for actual payment.'
61
+ )
62
+ )
63
+
64
+ );
65
+
66
+ if ($this->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_OpenInvoice_Abstract) {
67
+
68
+ }
69
+ }
70
+
71
+ if ($this->getStatus() == Netresearch_OPS_Model_Status::STORED_WAITING_EXTERNAL_RESULT) {
72
+ //TODO handle status 40
73
+ }
74
+
75
+ if ($this->getStatus() == Netresearch_OPS_Model_Status::INVALID_INCOMPLETE) {
76
+ //save status information to order before exception
77
+ $this->updateAdditionalInformation();
78
+ $payment->save();
79
+
80
+ $message = Mage::helper('ops')->__('Ingenico ePayments status 0, the action failed.');
81
+ if ($helper->isAdminSession()) {
82
+ $message .= ' ' . $this->getNcerror() . ' ' . $this->getNcerrorplus();
83
+ }
84
+ Mage::throwException($message);
85
+ }
86
+
87
+ $payment->save();
88
+ $order->save();
89
+ }
90
+
91
+
92
+ }
app/code/community/Netresearch/OPS/Model/Response/Type/Void.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Void.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Model_Response_Type_Void extends Netresearch_OPS_Model_Response_Type_Abstract
33
+ {
34
+ /**
35
+ * Handles the specific actions for the concrete payment status
36
+ */
37
+ protected function _handleResponse()
38
+ {
39
+ if (!Netresearch_OPS_Model_Status::isVoid($this->getStatus())) {
40
+ throw new Mage_Core_Exception(Mage::helper('ops')->__('%s is not a void status!', $this->getStatus()));
41
+ }
42
+
43
+ /** @var Mage_Sales_Model_Order_Payment $payment */
44
+ $payment = $this->getMethodInstance()->getInfoInstance();
45
+ /** @var Mage_Sales_Model_Order $order */
46
+ $order = $payment->getOrder();
47
+ if (Netresearch_OPS_Model_Status::isFinal($this->getStatus())) {
48
+ if ($this->getShouldRegisterFeedback()) {
49
+
50
+ $payment->setMessage(
51
+ Mage::helper('ops')->__('Received Ingenico ePayments status %s. Order cancelled.', $this->getStatus())
52
+ );
53
+ $payment->registerVoidNotification($this->getAmount());
54
+
55
+ // payment void does not cancel the order, but sets it to processing. we therefore need to cancel the order ourselves
56
+ $order->registerCancellation($this->getFinalStatusComment(), true);
57
+ } else {
58
+ $this->addFinalStatusComment();
59
+ }
60
+ } else {
61
+ $payment->setMessage($this->getIntermediateStatusComment());
62
+ }
63
+
64
+ $order->save();
65
+ }
66
+
67
+
68
+ }
app/code/community/Netresearch/OPS/Model/Response/TypeInterface.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * TypeInterface.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ /**
33
+ * Interface Netresearch_OPS_Model_Response_TypeInterface
34
+ */
35
+ interface Netresearch_OPS_Model_Response_TypeInterface
36
+ {
37
+ /**
38
+ * Performs the necessary actions for Magento to progress the order state correctly and automatically build the
39
+ * create sales objects
40
+ *
41
+ * @param array $responseArray
42
+ * @param Netresearch_OPS_Model_Payment_Abstract $paymentMethod
43
+ * @param bool $shouldRegisterFeedback determines if the Mage_Sales_Model_Order_Payments register*Feedback
44
+ * functions get called, defaults to true
45
+ *
46
+ * @return Netresearch_OPS_Model_Response_TypeInterface
47
+ */
48
+ public function handleResponse($responseArray, Netresearch_OPS_Model_Payment_Abstract $paymentMethod,
49
+ $shouldRegisterFeedback
50
+ );
51
+ }
app/code/community/Netresearch/OPS/Model/Source/Cc/RecurringTypes.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * RecurringTypes.php
24
+ *
25
+ * @category payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ class Netresearch_OPS_Model_Source_Cc_RecurringTypes
30
+ {
31
+
32
+ public function toOptionArray()
33
+ {
34
+ $options = array();
35
+ $types = Mage::getModel('ops/config')->getAllRecurringCcTypes();
36
+ $translatedTypes = array();
37
+ foreach ($types as $type) {
38
+ $translatedTypes[Mage::helper('ops')->__($type)] = $type;
39
+ }
40
+ ksort($translatedTypes);
41
+ foreach ($translatedTypes as $label => $value) {
42
+ $options[] = array(
43
+ 'value' => $value,
44
+ 'label' => $label
45
+ );
46
+ }
47
+ return $options;
48
+ }
49
+
50
+ }
app/code/community/Netresearch/OPS/Model/Source/DebitCard/AliasInterfaceEnabledTypes.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Netresearch_OPS
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * OPS credit card types
29
+ */
30
+ class Netresearch_OPS_Model_Source_DebitCard_AliasInterfaceEnabledTypes
31
+ {
32
+ /**
33
+ * @return array
34
+ */
35
+ public function toOptionArray()
36
+ {
37
+ $options = array();
38
+ $types = array_intersect(
39
+ Mage::getModel('ops/config')->getAllDcTypes(),
40
+ $this->getAliasInterfaceCompatibleTypes()
41
+ );
42
+ foreach ($types as $type) {
43
+ $options[] = array(
44
+ 'value' => $type,
45
+ 'label' => Mage::helper('ops')->__($type)
46
+ );
47
+ }
48
+ return $options;
49
+ }
50
+
51
+ public function getAliasInterfaceCompatibleTypes()
52
+ {
53
+ return array(
54
+ 'Maestro',
55
+ 'MaestroUK',
56
+ 'MasterCard',
57
+ 'VISA',
58
+ );
59
+ }
60
+
61
+ }
app/code/community/Netresearch/OPS/Model/Source/DebitCard/Types.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Netresearch_OPS
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * OPS debitcard types
29
+ */
30
+ class Netresearch_OPS_Model_Source_DebitCard_Types
31
+ {
32
+ /**
33
+ * @return array
34
+ */
35
+ public function toOptionArray()
36
+ {
37
+ $options = array();
38
+ $types = Mage::getModel('ops/config')->getAllDcTypes();
39
+ $translatedTypes = array();
40
+ foreach ($types as $type) {
41
+ $translatedTypes[Mage::helper('ops')->__($type)] = $type;
42
+ }
43
+ ksort($translatedTypes);
44
+ foreach ($translatedTypes as $label=>$value) {
45
+ $options[] = array(
46
+ 'value' => $value,
47
+ 'label' => $label
48
+ );
49
+ }
50
+ return $options;
51
+ }
52
+ }
app/code/community/Netresearch/OPS/Model/Source/Template.php CHANGED
@@ -37,8 +37,10 @@ class Netresearch_OPS_Model_Source_Template
37
  public function toOptionArray()
38
  {
39
  return array(
40
- array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS, 'label' => Mage::helper('ops')->__('Ingenico Payment Services')),
41
- array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO, 'label' => Mage::helper('ops')->__('Magento')),
 
 
42
  );
43
  }
44
  }
37
  public function toOptionArray()
38
  {
39
  return array(
40
+ array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_REDIRECT, 'label' => Mage::helper('ops')->__('Ingenico ePayments - Redirect mode')),
41
+ array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL, 'label' => Mage::helper('ops')->__('Magento - internal shop template')),
42
+ array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME, 'label' => Mage::helper('ops')->__('Ingenico ePayments - iFrame mode')),
43
+ array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE, 'label' => Mage::helper('ops')->__('Ingenico ePayments - Dynamic template'))
44
  );
45
  }
46
  }
app/code/community/Netresearch/OPS/Model/Source/TemplateType.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * TemplateType.php
4
+ * @author paul.siedler@netresearch.de
5
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
7
+ */
8
+
9
+ class Netresearch_OPS_Model_Source_TemplateType {
10
+
11
+ const URL = 'url';
12
+ const ID = 'id';
13
+
14
+ public function toOptionArray(){
15
+ return array(
16
+ array('value' => self::URL, 'label' => Mage::helper('ops')->__(self::URL)),
17
+ array('value' => self::ID, 'label' => Mage::helper('ops')->__(self::ID))
18
+ );
19
+ }
20
+
21
+ }
app/code/community/Netresearch/OPS/Model/Status.php ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Status.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ /**
33
+ * OPS response status
34
+ *
35
+ * Statuses in 1 digit are 'normal' statuses:
36
+ *
37
+ * 0 or 1 means the payment entry was not completed either because it is still underway or because interrupted or because
38
+ * a validation error prevented from confirming. If the cause is a validation error, an additional error code (*) (NCERROR) identifies the error.
39
+ *
40
+ * 2 means the acquirer did not authorise the payment.
41
+ *
42
+ * 5 means the acquirer authorised the payment.
43
+ *
44
+ * 9 means the payment was captured.
45
+ *
46
+ * Statuses in 2 digits corresponds either to 'intermediary' situations or to abnormal events. When the second digit is:
47
+ *
48
+ * 1, this means the payment processing is on hold.
49
+ *
50
+ * 2, this means an error occurred during the communication with the acquirer. The result is therefore not determined.
51
+ * You must therefore call the acquirer's helpdesk to find out the actual result of this transaction.
52
+ *
53
+ * 3, this means the payment processing (capture or cancellation) was refused by the acquirer whilst the payment had been authorised beforehand.
54
+ * It can be due to a technical error or to the expiration of the autorisation. You must therefore call the acquirer's helpdesk to find out the actual result of this transaction.
55
+ *
56
+ */
57
+ class Netresearch_OPS_Model_Status
58
+ {
59
+
60
+ const INVALID_INCOMPLETE = 0;
61
+ const CANCELED_BY_CUSTOMER = 1;
62
+ const AUTHORISATION_DECLINED = 2;
63
+
64
+ const ORDER_STORED = 4;
65
+ const STORED_WAITING_EXTERNAL_RESULT = 40;
66
+ const WAITING_CLIENT_PAYMENT = 41;
67
+ const WAITING_FOR_IDENTIFICATION = 46;
68
+
69
+ const AUTHORIZED = 5;
70
+ const AUTHORIZED_WAITING_EXTERNAL_RESULT = 50;
71
+ const AUTHORIZATION_WAITING = 51;
72
+ const AUTHORIZED_UNKNOWN = 52;
73
+ const STAND_BY_SUSPECTED_FRAUD = 55;
74
+ const OK_WITH_SHEDULED_PAYMENTS = 56;
75
+ const NOT_OK_WITH_SHEDULED_PAYMENTS = 57;
76
+ const AUTHORISATION_TO_BE_REQUESTED_MANUALLY = 59;
77
+
78
+ const AUTHORIZED_AND_CANCELLED = 6;
79
+ const DELETION_WAITING = 61;
80
+ const DELETION_UNCERTAIN = 62;
81
+ const DELETION_REFUSED = 63;
82
+ const AUTHORIZED_AND_CANCELLED_OK = 64;
83
+
84
+ const PAYMENT_DELETED = 7;
85
+ const PAYMENT_DELETION_PENDING = 71;
86
+ const PAYMENT_DELETION_UNCERTAIN = 72;
87
+ const PAYMENT_DELETION_REFUSED = 73;
88
+ const PAYMENT_DELETION_OK = 74;
89
+ const DELETION_HANDLED_BY_MERCHANT = 75;
90
+
91
+ const REFUNDED = 8;
92
+ const REFUND_PENDING = 81;
93
+ const REFUND_UNCERTAIN = 82;
94
+ const REFUND_REFUSED = 83;
95
+ const REFUNDED_OK = 84;
96
+ const REFUND_PROCESSED_BY_MERCHANT = 85;
97
+
98
+ const PAYMENT_REQUESTED = 9;
99
+ const PAYMENT_PROCESSING = 91;
100
+ const PAYMENT_UNCERTAIN = 92;
101
+ const PAYMENT_REFUSED = 93;
102
+ const PAYMENT_DECLINED_BY_ACQUIRER = 94;
103
+ const PAYMENT_PROCESSED_BY_MERCHANT = 95;
104
+ const REFUND_REVERSED = 96;
105
+ const PAYMENT_IN_PROGRESS = 99;
106
+
107
+ /**
108
+ * Returns if the given status is a final status (single digit status)
109
+ *
110
+ * @param int $status
111
+ *
112
+ * @return bool
113
+ */
114
+ static function isFinal($status)
115
+ {
116
+ return in_array(
117
+ $status, array(
118
+ self::INVALID_INCOMPLETE,
119
+ self::CANCELED_BY_CUSTOMER,
120
+ self::AUTHORISATION_DECLINED,
121
+ self::ORDER_STORED,
122
+ self::AUTHORIZED,
123
+ self::AUTHORIZED_AND_CANCELLED,
124
+ self::PAYMENT_DELETED,
125
+ self::DELETION_HANDLED_BY_MERCHANT,
126
+ self::REFUNDED,
127
+ self::REFUND_PROCESSED_BY_MERCHANT,
128
+ self::PAYMENT_REQUESTED,
129
+ self::PAYMENT_PROCESSED_BY_MERCHANT
130
+ )
131
+ );
132
+ }
133
+
134
+ /**
135
+ * Checks if the given status is an intermediate one (not single digit)
136
+ *
137
+ * @param int $status
138
+ *
139
+ * @return bool
140
+ */
141
+ static function isIntermediate($status)
142
+ {
143
+ return !self::isFinal($status);
144
+ }
145
+
146
+ /**
147
+ * Checks if the given state belongs to the capture status group (9 and 9x)
148
+ *
149
+ * @param int $status
150
+ *
151
+ * @return bool
152
+ */
153
+ static function isCapture($status)
154
+ {
155
+ return in_array(
156
+ $status,
157
+ array(
158
+ self::PAYMENT_REQUESTED,
159
+ self::PAYMENT_PROCESSING,
160
+ self::PAYMENT_UNCERTAIN,
161
+ self::PAYMENT_REFUSED,
162
+ self::PAYMENT_DECLINED_BY_ACQUIRER,
163
+ self::PAYMENT_PROCESSED_BY_MERCHANT,
164
+ self::REFUND_REVERSED,
165
+ self::PAYMENT_IN_PROGRESS
166
+ )
167
+ );
168
+ }
169
+
170
+ /**
171
+ * Checks if the given status belongs to refund status group (8 and 8x)
172
+ *
173
+ * @param int $status
174
+ *
175
+ * @return bool
176
+ */
177
+ static function isRefund($status)
178
+ {
179
+ return in_array(
180
+ $status,
181
+ array(
182
+ self::REFUNDED,
183
+ self::REFUND_PENDING,
184
+ self::REFUND_UNCERTAIN,
185
+ self::REFUND_REFUSED,
186
+ self::REFUNDED_OK,
187
+ self::REFUND_PROCESSED_BY_MERCHANT,
188
+ )
189
+ );
190
+ }
191
+
192
+ /**
193
+ * Checks if the given status belongs to void/delete status group (6 and 6x)
194
+ *
195
+ * @param int $status
196
+ *
197
+ * @return bool
198
+ */
199
+ static function isVoid($status)
200
+ {
201
+ return in_array(
202
+ $status,
203
+ array(
204
+ self::PAYMENT_DELETED,
205
+ self::AUTHORIZED_AND_CANCELLED,
206
+ self::DELETION_WAITING,
207
+ self::DELETION_UNCERTAIN,
208
+ self::DELETION_REFUSED,
209
+ self::AUTHORIZED_AND_CANCELLED_OK,
210
+ )
211
+ );
212
+ }
213
+
214
+ /**
215
+ * Checks if the given status belongs to authorize status group
216
+ *
217
+ * @param int $status
218
+ *
219
+ * @return bool
220
+ */
221
+ static function isAuthorize($status)
222
+ {
223
+ return in_array(
224
+ $status,
225
+ array(
226
+ self::AUTHORISATION_DECLINED,
227
+ self::AUTHORIZED,
228
+ self::AUTHORIZED_WAITING_EXTERNAL_RESULT,
229
+ self::AUTHORIZATION_WAITING,
230
+ self::AUTHORIZED_UNKNOWN,
231
+ self::STAND_BY_SUSPECTED_FRAUD,
232
+ self::OK_WITH_SHEDULED_PAYMENTS,
233
+ self::NOT_OK_WITH_SHEDULED_PAYMENTS,
234
+ self::AUTHORISATION_TO_BE_REQUESTED_MANUALLY,
235
+ self::CANCELED_BY_CUSTOMER
236
+ )
237
+ );
238
+ }
239
+
240
+ /**
241
+ * Checks if given Status is a special status (waiting for client payment, waiting for authentification, invalid)
242
+ *
243
+ * @param int $status
244
+ *
245
+ * @return bool
246
+ */
247
+ static function isSpecialStatus($status)
248
+ {
249
+ return in_array(
250
+ $status,
251
+ array(
252
+ self::WAITING_CLIENT_PAYMENT,
253
+ self::WAITING_FOR_IDENTIFICATION,
254
+ self::STORED_WAITING_EXTERNAL_RESULT,
255
+ self::INVALID_INCOMPLETE,
256
+ )
257
+ );
258
+ }
259
+
260
+ /**
261
+ * check if for a given status payment info can be resend
262
+ *
263
+ * @param $status
264
+ *
265
+ * @return bool
266
+ */
267
+ static function canResendPaymentInfo($status)
268
+ {
269
+ return in_array(
270
+ $status,
271
+ array(
272
+ self::NOT_OK_WITH_SHEDULED_PAYMENTS,
273
+ self::CANCELED_BY_CUSTOMER,
274
+ self::AUTHORISATION_DECLINED,
275
+ self::AUTHORISATION_TO_BE_REQUESTED_MANUALLY,
276
+ self::PAYMENT_UNCERTAIN,
277
+ self::PAYMENT_REFUSED,
278
+ )
279
+ );
280
+ }
281
+
282
+ /**
283
+ * check if payment with given status can be voided
284
+ *
285
+ * @param $status
286
+ *
287
+ * @return bool
288
+ */
289
+ static function canVoidTransaction($status)
290
+ {
291
+ return in_array(
292
+ $status,
293
+ array(
294
+ self::AUTHORIZED,
295
+ self::REFUNDED
296
+ )
297
+ );
298
+ }
299
+ }
app/code/community/Netresearch/OPS/Model/Status/Mapping.php DELETED
@@ -1,171 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @author Michael Lühr <michael.luehr@netresearch.de>
5
- * @category Netresearch
6
- * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- class Netresearch_OPS_Model_Status_Mapping
10
- {
11
-
12
- protected $orderStatesForOpsState = array();
13
-
14
- protected $transitionModel = null;
15
-
16
- /**
17
- * @param null $transitionModel
18
- */
19
- public function setTransitionModel($transitionModel)
20
- {
21
- $this->transitionModel = $transitionModel;
22
- }
23
-
24
- /**
25
- * @return Netresearch_OPS_Model_Status_Transition
26
- */
27
- public function getTransitionModel()
28
- {
29
- if (null == $this->transitionModel) {
30
- $this->transitionModel = Mage::getModel('ops/status_transition');
31
- }
32
-
33
- return $this->transitionModel;
34
- }
35
-
36
- /**
37
- * retrieves the possible magento order's states for the according Ingenico Payment Services status
38
- *
39
- * @param $opsStatus - the Ingenico Payment Services status
40
- *
41
- * @return array - the order's states
42
- */
43
- public function getStatusForOpsStatus($opsStatus)
44
- {
45
- $this->getTransitionModel()->setOpsResponse(array('STATUS' => $opsStatus));
46
- $this->handleRefundOperations();
47
- $this->handleCaptureOperations();
48
- $this->handleVoidOperations();
49
- $this->handleAuthOperations($opsStatus);
50
- $this->handleRefusedOperations($opsStatus);
51
-
52
- return $this->orderStatesForOpsState;
53
- }
54
-
55
- /**
56
- * retrieves Magento order's states for refund operations
57
- *
58
- * @return $this
59
- */
60
- protected function handleRefundOperations()
61
- {
62
- if ($this->getTransitionModel()->isRefundOperation()) {
63
- $this->orderStatesForOpsState = array(
64
- Mage_Sales_Model_Order::STATE_CLOSED,
65
- Mage_Sales_Model_Order::STATE_PROCESSING
66
- );
67
- }
68
-
69
- return $this;
70
- }
71
-
72
- /**
73
- * retrieves Magento order's states for capture operations
74
- *
75
- * @return $this
76
- */
77
- protected function handleCaptureOperations()
78
- {
79
- if ($this->getTransitionModel()->isCaptureOperation()) {
80
- $this->orderStatesForOpsState = array(
81
- Mage_Sales_Model_Order::STATE_COMPLETE,
82
- Mage_Sales_Model_Order::STATE_PROCESSING
83
- );
84
- }
85
-
86
- return $this;
87
- }
88
-
89
- /**
90
- * retrieves Magento order's states for void operations
91
- *
92
- * @return $this
93
- */
94
- protected function handleVoidOperations()
95
- {
96
- if ($this->getTransitionModel()->isVoidOperation()) {
97
- $this->orderStatesForOpsState = array(
98
- Mage_Sales_Model_Order::STATE_PROCESSING,
99
- Mage_Sales_Model_Order::STATE_COMPLETE,
100
- Mage_Sales_Model_Order::STATE_CANCELED
101
- );
102
- }
103
-
104
- return $this;
105
- }
106
-
107
- /**
108
- * retrieves Magento order's states for auth operations
109
- *
110
- * @param $opsStatus
111
- *
112
- * @return $this
113
- */
114
- protected function handleAuthOperations($opsStatus)
115
- {
116
- if ($this->isOpsAuthorizedStatus($opsStatus)
117
- || 0 == strlen(trim($opsStatus))
118
- || $opsStatus == Netresearch_OPS_Model_Payment_Abstract::OPS_ORDER_SAVED
119
- ) {
120
- $this->orderStatesForOpsState = array(Mage_Sales_Model_Order::STATE_PROCESSING);
121
- if ($opsStatus == Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT
122
- || $opsStatus == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING
123
- ) {
124
- $this->orderStatesForOpsState = array(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
125
- }
126
- }
127
-
128
- return $this;
129
- }
130
-
131
- /**
132
- * retrieves Magento order's states for refused operations
133
- *
134
- * @param $opsStatus
135
- *
136
- * @return $this
137
- */
138
- protected function handleRefusedOperations($opsStatus)
139
- {
140
- if ($this->isRefusedOpsStatus($opsStatus)) {
141
- $this->orderStatesForOpsState = array(Mage_Sales_Model_Order::STATE_CANCELED);
142
- }
143
-
144
- return $this;
145
- }
146
-
147
- /**
148
- * @param $opsStatus
149
- *
150
- * @return bool
151
- */
152
- protected function isOpsAuthorizedStatus($opsStatus)
153
- {
154
- return ($opsStatus >= Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT
155
- && $opsStatus <= Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_TO_GET_MANUALLY)
156
- || $opsStatus == Netresearch_OPS_Model_Payment_Abstract::OPS_OPEN_INVOICE_DE_PROCESSED
157
- || $opsStatus == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED;
158
- }
159
-
160
- /**
161
- * @param $opsStatus
162
- *
163
- * @return bool
164
- */
165
- protected function isRefusedOpsStatus($opsStatus)
166
- {
167
- return $opsStatus == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTH_REFUSED
168
- || $opsStatus == Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED
169
- || $opsStatus == Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_CANCELED_BY_CUSTOMER;
170
- }
171
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Model/Status/Transition.php DELETED
@@ -1,567 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @author Michael Lühr <michael.luehr@netresearch.de>
5
- * @category Netresearch
6
- * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- class Netresearch_OPS_Model_Status_Transition
10
- {
11
-
12
- protected $order = null;
13
-
14
- protected $opsResponse = array();
15
-
16
- protected $infoArr = array();
17
-
18
- protected $captureHelper = null;
19
-
20
- protected $directLinkHelper = null;
21
-
22
- protected $voidHelper = null;
23
-
24
- protected $refundHelper = null;
25
-
26
- protected $paymentHelper = null;
27
-
28
- /**
29
- * @param null $paymentHelper
30
- */
31
- public function setPaymentHelper($paymentHelper)
32
- {
33
- $this->paymentHelper = $paymentHelper;
34
- }
35
-
36
- /**
37
- * @param null $refundHelper
38
- */
39
- public function setRefundHelper($refundHelper)
40
- {
41
- $this->refundHelper = $refundHelper;
42
- }
43
-
44
- /**
45
- * @param null $voidHelper
46
- */
47
- public function setVoidHelper($voidHelper)
48
- {
49
- $this->voidHelper = $voidHelper;
50
- }
51
-
52
- /**
53
- * @return null
54
- */
55
- public function getVoidHelper()
56
- {
57
- if (null == $this->voidHelper) {
58
- $this->voidHelper = Mage::helper("ops/order_void");
59
- }
60
-
61
- return $this->voidHelper;
62
- }
63
-
64
- /**
65
- * @param array $infoArr
66
- */
67
- public function setInfoArr($infoArr)
68
- {
69
- $this->infoArr = $infoArr;
70
- }
71
-
72
- /**
73
- * @return array
74
- */
75
- public function getInfoArr()
76
- {
77
- return $this->infoArr;
78
- }
79
-
80
- /**
81
- * @param array $opsResponse
82
- */
83
- public function setOpsResponse($opsResponse)
84
- {
85
- $this->opsResponse = $opsResponse;
86
- }
87
-
88
- /**
89
- * @return array
90
- */
91
- public function getOpsResponse()
92
- {
93
- return $this->opsResponse;
94
- }
95
-
96
- /**
97
- * @param null $order
98
- */
99
- public function setOrder($order)
100
- {
101
- $this->order = $order;
102
- }
103
-
104
- /**
105
- * @return null
106
- */
107
- public function getOrder()
108
- {
109
- return $this->order;
110
- }
111
-
112
- /**
113
- * processes the Ingenico Payment Services responses
114
- *
115
- * @param array $opsResponse
116
- * @param Mage_Sales_Model_Order $order
117
- *
118
- * @return $this
119
- */
120
- public function processOpsResponse(array $opsResponse, Mage_Sales_Model_Order $order)
121
- {
122
- $this->opsResponse = $opsResponse;
123
- $this->order = $order;
124
- $this->processCaptureFeedback();
125
- $this->processRefundFeedback();
126
- $this->processVoidFeedback();
127
-
128
- return $this;
129
- }
130
-
131
- /**
132
- * process the feedback from Ingenico Payment Services for capture operations
133
- *
134
- * @return $this
135
- */
136
- public function processCaptureFeedback()
137
- {
138
- if ($this->isCaptureOperation()) {
139
- // use direct link helper processFeedback, but need special handling for those status which are handled after setting up the direct link request
140
- if ($this->isCaptureRequestResponse()) {
141
- $this->infoArr = $this->getCaptureOperation();
142
- $this->saveCaptureTxn();
143
- //Reload order to avoid wrong status
144
- $order = $this->reloadOrder();
145
- $order->addStatusHistoryComment(
146
- $this->getDataHelper()->__(
147
- 'Invoice will be created automatically as soon as Ingenico Payment Services sends an acknowledgement. Ingenico Payment Services status: %s.',
148
- $this->getDataHelper()->getStatusText($this->opsResponse['STATUS'])
149
- )
150
- );
151
- $order->save();
152
- $this->setOrder($order);
153
- } else {
154
- $this->processFeedback();
155
- }
156
- }
157
-
158
- return $this;
159
- }
160
-
161
- /**
162
- * processes the feedback from Ingenico Payment Services for void operations
163
- *
164
- * @return $this
165
- */
166
- public function processVoidFeedback()
167
- {
168
- if ($this->isVoidOperation()) {
169
- if ($this->isOpsVoidWaitingOrUncertain()) {
170
- $this->infoArr = array(
171
- 'amount' => $this->opsResponse['AMOUNT'],
172
- 'void_request' => Mage::app()->getRequest()->getParams(),
173
- 'response' => $this->opsResponse,
174
- );
175
- $msg = $this->getDataHelper()->__(
176
- 'Start Ingenico Payment Services void request. Ingenico Payment Services status: %s.',
177
- $this->getDataHelper()->getStatusText($this->opsResponse['STATUS'])
178
- );
179
- $this->createVoidTxn($msg);
180
-
181
- } /*
182
- * If the ops response results directly in accepted state, create a void transaction
183
- */
184
- elseif ($this->isVoidAccepted()) {
185
- $this->infoArr = array();
186
- $msg = $this->getDataHelper()->__(
187
- 'Void order succeed. Ingenico Payment Services status: %s.',
188
- $this->opsResponse['STATUS']
189
- );
190
- $this->createVoidTxn($msg);
191
- $this->getVoidHelper()->acceptVoid($this->getOrder(), $this->getOpsResponse());
192
- } else {
193
- $this->processFeedback();
194
- }
195
- }
196
-
197
- return $this;
198
- }
199
-
200
- /**
201
- * processes the feedback from Ingenico Payment Services for refund operations
202
- *
203
- * @return $this
204
- */
205
- public function processRefundFeedback()
206
- {
207
- if ($this->isRefundOperation()) {
208
- $operation = $this->getRefundHelper()->determineOperationCode(
209
- $this->getOrder()->getPayment(),
210
- $this->opsResponse['AMOUNT']
211
- );
212
-
213
-
214
- if ($this->isRefundWaiting()) {
215
- $this->getPaymentHelper()->saveOpsRefundOperationCodeToPayment(
216
- $this->getOrder()->getPayment(),
217
- $operation
218
- );
219
- $this->getRefundHelper()->setPayment($this->getOrder()->getPayment());
220
- if (false == $this->getDirectlinkHelper()->hasPaymentTransactions($this->getOrder(), 'refund')) {
221
- $this->getRefundHelper()->createRefundTransaction($this->opsResponse);
222
- }
223
-
224
- } elseif ($this->isRefundAccepted()
225
- && $this->getOrder()->getPayment()->getAdditionalInformation('status')
226
- != Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING
227
- ) {
228
- //do refund directly if response is ok already
229
- $this->getPaymentHelper()->saveOpsRefundOperationCodeToPayment(
230
- $this->getOrder()->getPayment(),
231
- $operation
232
- );
233
- $this->getRefundHelper()->setPayment($this->getOrder()->getPayment());
234
- try {
235
- $this->getRefundHelper()->createRefund($this->getOrder(), $this->getOpsResponse(), true);
236
- } catch (Mage_Core_Exception $e) {
237
- Mage::logException($e);
238
- }
239
- } else {
240
- $this->processFeedback();
241
- }
242
- }
243
- return $this;
244
- }
245
-
246
- /**
247
- * retrieves the Ingenico Payment Services status for the payment
248
- *
249
- * @return string | null the Ingenico Payment Services status for the payment
250
- */
251
- protected function getOpsStatus()
252
- {
253
- $status = null;
254
- if (array_key_exists('STATUS', $this->opsResponse)) {
255
- $status = $this->opsResponse['STATUS'];
256
- }
257
-
258
- return $status;
259
- }
260
-
261
- /**
262
- * return the Ingenico Payment Services's payment identifier
263
- *
264
- * @return string | null the Ingenico Payment Services's payment identifier
265
- */
266
- protected function getOpsPayId()
267
- {
268
- $payId = null;
269
- if (array_key_exists('PAYID', $this->opsResponse)) {
270
- $payId = $this->opsResponse['PAYID'];
271
- }
272
-
273
- return $payId;
274
- }
275
-
276
- /**
277
- * retrieves the sub payid from Ingenico Payment Services's response
278
- *
279
- * @return null| string the payment sub identifier from Ingenico Payment Services
280
- */
281
- protected function getOpsPayIdSub()
282
- {
283
- $payIdSub = null;
284
- if (array_key_exists('PAYIDSUB', $this->opsResponse)) {
285
- $payIdSub = $this->opsResponse['PAYIDSUB'];
286
- }
287
-
288
- return $payIdSub;
289
- }
290
-
291
- /**
292
- * checks if the current status is valid for a capture operation
293
- *
294
- * @return bool
295
- */
296
- public function isCaptureOperation()
297
- {
298
- return in_array(
299
- $this->getOpsStatus(),
300
- array(
301
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED,
302
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING,
303
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN,
304
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED,
305
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DECLINED_ACQUIRER,
306
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSED_MERCHANT,
307
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_IN_PROGRESS,
308
- )
309
- );
310
- }
311
-
312
- /**
313
- * checks if the current status is valid for a refund operation
314
- *
315
- * @return bool
316
- */
317
- public function isRefundOperation()
318
- {
319
- return in_array(
320
- $this->getOpsStatus(),
321
- array(
322
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUNDED,
323
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING,
324
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_UNCERTAIN_STATUS,
325
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_REFUSED,
326
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_DECLINED_ACQUIRER,
327
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PROCESSED_MERCHANT,
328
- )
329
- );
330
- }
331
-
332
- /**
333
- * checks if the current status is valid for a void operation
334
- *
335
- * @return bool
336
- */
337
- public function isVoidOperation()
338
- {
339
- return in_array(
340
- $this->getOpsStatus(),
341
- array(
342
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED,
343
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_WAITING,
344
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_UNCERTAIN,
345
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_REFUSED,
346
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED_ACCEPTED,
347
- )
348
- );
349
- }
350
-
351
-
352
- /**
353
- * checks if the response is matching a previous capture request
354
- *
355
- * @return bool
356
- */
357
- public function isCaptureRequestResponse()
358
- {
359
- return in_array(
360
- $this->getOpsStatus(),
361
- array(
362
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING,
363
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN,
364
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_IN_PROGRESS
365
- )
366
- );
367
- }
368
-
369
- /**
370
- * retrieves the capture operation
371
- *
372
- * @return array
373
- */
374
- public function getCaptureOperation()
375
- {
376
- return $this->getCaptureHelper()->prepareOperation(
377
- $this->getOrder()->getPayment(),
378
- $this->opsResponse['AMOUNT']
379
- );
380
- }
381
-
382
- /**
383
- * @return Netresearch_OPS_Helper_Order_Capture
384
- */
385
- public function getCaptureHelper()
386
- {
387
- if (null == $this->captureHelper) {
388
- $this->captureHelper = Mage::helper('ops/order_capture');
389
- }
390
-
391
- return $this->captureHelper;
392
- }
393
-
394
- public function setCaptureHelper(Netresearch_OPS_Helper_Order_Capture $captureHelper)
395
- {
396
- $this->captureHelper = $captureHelper;
397
- }
398
-
399
- /**
400
- * creates a capture transaction
401
- */
402
- protected function saveCaptureTxn()
403
- {
404
- $this->getDirectlinkHelper()->directLinkTransact(
405
- $this->reloadOrder(),
406
- $this->getOpsPayId(),
407
- $this->getOpsPayIdSub(),
408
- $this->infoArr,
409
- Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE,
410
- $this->getDataHelper()->__('Start Ingenico Payment Services %s capture request', $this->infoArr['type'])
411
- );
412
- }
413
-
414
- /**
415
- * @return Netresearch_OPS_Helper_Directlink
416
- */
417
- public function getDirectlinkHelper()
418
- {
419
- if (null == $this->directLinkHelper) {
420
- $this->directLinkHelper = Mage::helper('ops/directlink');
421
- }
422
-
423
- return $this->directLinkHelper;
424
- }
425
-
426
- public function setDirectlinkHelper(Netresearch_OPS_Helper_Directlink $directlinkHelper)
427
- {
428
- $this->directLinkHelper = $directlinkHelper;
429
- }
430
-
431
- /**
432
- * @return Netresearch_OPS_Helper_Data
433
- */
434
- public function getDataHelper()
435
- {
436
- return Mage::helper('ops/data');
437
- }
438
-
439
- /**
440
- * checks if the response is void in waiting or uncertain
441
- *
442
- * @return bool
443
- */
444
- protected function isOpsVoidWaitingOrUncertain()
445
- {
446
- return in_array(
447
- $this->getOpsStatus(),
448
- array(
449
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_WAITING,
450
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_UNCERTAIN
451
- )
452
- );
453
- }
454
-
455
- /**
456
- * checks if the refund is accepted
457
- *
458
- * @return bool
459
- */
460
- protected function isRefundAccepted()
461
- {
462
- return in_array(
463
- $this->getOpsStatus(),
464
- array(
465
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUNDED,
466
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PROCESSED_MERCHANT
467
- )
468
- );
469
- }
470
-
471
- /**
472
- * checks if the void is accepted
473
- *
474
- * @return bool
475
- */
476
- protected function isVoidAccepted()
477
- {
478
- return in_array(
479
- $this->getOpsStatus(),
480
- array(
481
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED,
482
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED_ACCEPTED
483
- )
484
- );
485
- }
486
-
487
- /**
488
- * @return Mage_Sales_Model_Order
489
- */
490
- protected function reloadOrder()
491
- {
492
- return Mage::getSingleton("sales/order")->loadByIncrementId(
493
- $this->getOrder()->getIncrementId()
494
- );
495
- }
496
-
497
- /**
498
- * creates a void transaction
499
- *
500
- * @param $msg - message
501
- * @param int $closed - whether it's closed or not
502
- */
503
- protected function createVoidTxn($msg, $closed = 0)
504
- {
505
- $this->getDirectlinkHelper()->directLinkTransact(
506
- $this->reloadOrder(),
507
- $this->getOpsPayId(),
508
- $this->getOpsPayIdSub(),
509
- $this->infoArr,
510
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE,
511
- $msg,
512
- $closed
513
- );
514
- }
515
-
516
- /**
517
- * checks if the refund is waiting or uncertain
518
- *
519
- * @return bool
520
- */
521
- protected function isRefundWaiting()
522
- {
523
- return in_array(
524
- $this->getOpsStatus(),
525
- array(
526
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING,
527
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_UNCERTAIN_STATUS
528
- )
529
- );
530
- }
531
-
532
- /**
533
- * @return Netresearch_OPS_Helper_Payment
534
- */
535
- public function getPaymentHelper()
536
- {
537
- if (null == $this->paymentHelper) {
538
- $this->paymentHelper = Mage::helper('ops/payment');
539
- }
540
-
541
- return $this->paymentHelper;
542
- }
543
-
544
- /**
545
- * @return Netresearch_OPS_Helper_Order_Refund
546
- */
547
- public function getRefundHelper()
548
- {
549
- if (null == $this->refundHelper) {
550
- $this->refundHelper = Mage::helper('ops/order_refund');
551
- }
552
-
553
- return $this->refundHelper;
554
- }
555
-
556
- /**
557
- * processes the feedback from Ingenico Payment Services
558
- */
559
- protected function processFeedback()
560
- {
561
- try {
562
- $this->getDirectlinkHelper()->processFeedback($this->getOrder(), $this->getOpsResponse());
563
- } catch (Mage_Core_Exception $e) {
564
- Mage::logException($e);
565
- }
566
- }
567
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Model/Status/Update.php CHANGED
@@ -22,8 +22,6 @@ class Netresearch_OPS_Model_Status_Update
22
 
23
  protected $opsResponse = array();
24
 
25
- protected $transitionModel = null;
26
-
27
  protected $paymentHelper = null;
28
 
29
  protected $directLinkHelper = null;
@@ -41,7 +39,7 @@ class Netresearch_OPS_Model_Status_Update
41
  }
42
 
43
  /**
44
- * @return null
45
  */
46
  public function getDataHelper()
47
  {
@@ -52,7 +50,7 @@ class Netresearch_OPS_Model_Status_Update
52
  return $this->dataHelper;
53
  }
54
  /**
55
- * @param null $messageContainer
56
  */
57
  public function setMessageContainer(Mage_Core_Model_Session_Abstract $messageContainer)
58
  {
@@ -186,9 +184,13 @@ class Netresearch_OPS_Model_Status_Update
186
  }
187
  $this->setOrder($order);
188
  $this->buildParams($order->getPayment());
189
- $this->performRequest();
190
- $this->updatePaymentStatus();
191
 
 
 
 
 
 
 
192
  return $this;
193
  }
194
 
@@ -208,6 +210,7 @@ class Netresearch_OPS_Model_Status_Update
208
  }
209
  $this->addPayIdSub($payment);
210
 
 
211
  return $this;
212
  }
213
 
@@ -226,6 +229,8 @@ class Netresearch_OPS_Model_Status_Update
226
  if (array_key_exists('AMOUNT', $this->opsResponse)) {
227
  $this->opsResponse['amount'] = $this->opsResponse['AMOUNT'];
228
  }
 
 
229
  return $this;
230
  }
231
 
@@ -234,35 +239,23 @@ class Netresearch_OPS_Model_Status_Update
234
  if (!array_key_exists('STATUS', $this->getOpsResponse())
235
  || $this->opsResponse['STATUS'] == $this->getOrder()->getPayment()->getAdditionalInformation('status')
236
  ) {
237
- return $this;
 
238
  }
239
 
240
- $this->getPaymentHelper()->saveOpsStatusToPayment($this->getOrder()->getPayment(), $this->getOpsResponse());
241
-
242
- if (0 < strlen(trim($this->getOrder()->getPayment()->getAdditionalInformation('paymentId')))) {
243
- $this->getTransitionModel()->processOpsResponse($this->getOpsResponse(), $this->getOrder());
244
-
245
  } else {
246
  // simulate initial request
247
  $this->getPaymentHelper()->applyStateForOrder($this->getOrder(), $this->getOpsResponse());
248
  }
249
- $this->getMessageContainer()->addSuccess($this->getDataHelper()->__('Ingenico Payment Services status successfully updated'));
250
-
251
- return $this;
252
- }
253
 
254
- public function getTransitionModel()
255
- {
256
- if (null == $this->transitionModel) {
257
- $this->transitionModel = Mage::getModel('ops/status_transition');
258
- }
259
-
260
- return $this->transitionModel;
261
- }
262
 
263
- public function setTransitionModel(Netresearch_OPS_Model_Status_Transition $transitionModel)
264
- {
265
- $this->transitionModel = $transitionModel;
266
  }
267
 
268
  public function getPaymentHelper()
@@ -298,31 +291,12 @@ class Netresearch_OPS_Model_Status_Update
298
  */
299
  protected function addPayIdSub(Mage_Sales_Model_Order_Payment $payment)
300
  {
301
- $txType = null;
302
- if ($payment->getAdditionalInformation('status')
303
- == Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING
304
- ) {
305
- $txType = Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE;
306
- }
307
- if ($payment->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING
308
- ) {
309
- $txType = Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE;
310
- }
311
- if (null !== $txType) {
312
- $transaction = $this->getDirectLinkHelper()->getPaymentTransaction(
313
- $this->getOrder(),
314
- $this->requestParams['PAYID'],
315
- $txType
316
- );
317
- if (0 < $transaction->getTxnId()) {
318
- $historyLevel = str_replace(
319
- $transaction->getParentTxnId() . '/',
320
- '',
321
- $transaction->getTxnId()
322
- );
323
- $this->requestParams['PAYIDSUB'] = $historyLevel;
324
- }
325
  }
 
326
  }
327
 
328
  protected function canNotUseOrderId(Mage_Sales_Model_Order_Payment $payment)
22
 
23
  protected $opsResponse = array();
24
 
 
 
25
  protected $paymentHelper = null;
26
 
27
  protected $directLinkHelper = null;
39
  }
40
 
41
  /**
42
+ * @return Netresearch_OPS_Helper_Data
43
  */
44
  public function getDataHelper()
45
  {
50
  return $this->dataHelper;
51
  }
52
  /**
53
+ * @param Mage_Core_Model_Session_Abstract $messageContainer
54
  */
55
  public function setMessageContainer(Mage_Core_Model_Session_Abstract $messageContainer)
56
  {
184
  }
185
  $this->setOrder($order);
186
  $this->buildParams($order->getPayment());
 
 
187
 
188
+ try {
189
+ $this->performRequest();
190
+ $this->updatePaymentStatus();
191
+ } catch (Mage_Core_Exception $e) {
192
+ $this->getMessageContainer()->addError($e->getMessage());
193
+ }
194
  return $this;
195
  }
196
 
210
  }
211
  $this->addPayIdSub($payment);
212
 
213
+
214
  return $this;
215
  }
216
 
229
  if (array_key_exists('AMOUNT', $this->opsResponse)) {
230
  $this->opsResponse['amount'] = $this->opsResponse['AMOUNT'];
231
  }
232
+
233
+
234
  return $this;
235
  }
236
 
239
  if (!array_key_exists('STATUS', $this->getOpsResponse())
240
  || $this->opsResponse['STATUS'] == $this->getOrder()->getPayment()->getAdditionalInformation('status')
241
  ) {
242
+ $this->getMessageContainer()->addNotice($this->getDataHelper()->__('No update available from Ingenico ePayments.'));
243
+ return $this;
244
  }
245
 
246
+ if (false != strlen(trim($this->getOrder()->getPayment()->getAdditionalInformation('paymentId')))) {
247
+ Mage::getModel('ops/response_handler')->processResponse($this->getOpsResponse(),
248
+ $this->getOrder()->getPayment()->getMethodInstance()
249
+ );
 
250
  } else {
251
  // simulate initial request
252
  $this->getPaymentHelper()->applyStateForOrder($this->getOrder(), $this->getOpsResponse());
253
  }
 
 
 
 
254
 
255
+ $this->getPaymentHelper()->saveOpsStatusToPayment($this->getOrder()->getPayment(), $this->getOpsResponse());
256
+ $this->getMessageContainer()->addSuccess($this->getDataHelper()->__('Ingenico ePayments status successfully updated'));
 
 
 
 
 
 
257
 
258
+ return $this;
 
 
259
  }
260
 
261
  public function getPaymentHelper()
291
  */
292
  protected function addPayIdSub(Mage_Sales_Model_Order_Payment $payment)
293
  {
294
+ $lastTransaction = $payment->getLastTransId();
295
+ $lastTransactionParts = explode('/', $lastTransaction);
296
+ if($lastTransaction && count($lastTransactionParts)>1){
297
+ $this->requestParams['PAYIDSUB'] = $lastTransactionParts[1];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  }
299
+ return $this;
300
  }
301
 
302
  protected function canNotUseOrderId(Mage_Sales_Model_Order_Payment $payment)
app/code/community/Netresearch/OPS/Model/Subscription/Manager.php ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Management endpoint for order creation from subscription feedback
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_Model_Subscription_Manager
33
+ {
34
+ const CREATION_FAILED = 'ERROR';
35
+ const CREATION_SUCCEEDED = 'OK';
36
+
37
+
38
+ protected $subscriptionHelper = null;
39
+ protected $paymentHelper = null;
40
+ protected $dataHelper = null;
41
+
42
+ /**
43
+ * @return Netresearch_OPS_Helper_Data
44
+ */
45
+ public function getDataHelper()
46
+ {
47
+ if (is_null($this->dataHelper)) {
48
+ $this->dataHelper = Mage::helper('ops');
49
+ }
50
+
51
+ return $this->dataHelper;
52
+ }
53
+
54
+ /**
55
+ * @param Netresearch_OPS_Helper_Data $dataHelper
56
+ *
57
+ * @returns $this
58
+ */
59
+ public function setDataHelper($dataHelper)
60
+ {
61
+ $this->dataHelper = $dataHelper;
62
+
63
+ return $this;
64
+ }
65
+
66
+ /**
67
+ * @return Netresearch_OPS_Helper_Payment
68
+ */
69
+ public function getPaymentHelper()
70
+ {
71
+ if (is_null($this->paymentHelper)) {
72
+ $this->paymentHelper = Mage::helper('ops/payment');
73
+ }
74
+
75
+ return $this->paymentHelper;
76
+ }
77
+
78
+ /**
79
+ * @param Netresearch_OPS_Helper_Payment $paymentHelper
80
+ *
81
+ * @returns $this
82
+ */
83
+ public function setPaymentHelper($paymentHelper)
84
+ {
85
+ $this->paymentHelper = $paymentHelper;
86
+
87
+ return $this;
88
+ }
89
+
90
+
91
+ /**
92
+ * @return Netresearch_OPS_Helper_Subscription
93
+ */
94
+ public function getSubscriptionHelper()
95
+ {
96
+ if (is_null($this->subscriptionHelper)) {
97
+ $this->subscriptionHelper = Mage::helper('ops/subscription');
98
+ }
99
+
100
+ return $this->subscriptionHelper;
101
+ }
102
+
103
+ /**
104
+ * @param Netresearch_OPS_Helper_Subscription $subscriptionHelper
105
+ *
106
+ * @returns $this
107
+ */
108
+ public function setSubscriptionHelper($subscriptionHelper)
109
+ {
110
+ $this->subscriptionHelper = $subscriptionHelper;
111
+
112
+ return $this;
113
+ }
114
+
115
+
116
+ /**
117
+ * Process request from Ingenico ePayments automatic subscription payments and initial creations
118
+ *
119
+ *
120
+ * @param mixed[] $responseParams
121
+ * @param Mage_Sales_Model_Recurring_Profile $profile - only has to be provided during the initial setup of
122
+ * the subscription
123
+ * @param Mage_Sales_Model_Order $order
124
+ *
125
+ *
126
+ * @return Mage_Sales_Model_Order | false
127
+ */
128
+ public function processSubscriptionFeedback($responseParams, $profile = null, $order = null)
129
+ {
130
+ $createOrder = true;
131
+ $feedbackType = false;
132
+ $orderId = $responseParams['orderID'];
133
+ if (!is_array($responseParams)) {
134
+ Mage::throwException($this->getDataHelper()->__('No response array provided'));
135
+ }
136
+
137
+ if (is_null($profile)) {
138
+ $profile = $this->getSubscriptionHelper()->getProfileForSubscription($orderId);
139
+ }
140
+
141
+ if (array_key_exists('creation_status', $responseParams)) {
142
+ switch ($responseParams['creation_status']) {
143
+ case self::CREATION_SUCCEEDED:
144
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
145
+ break;
146
+ default:
147
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN);
148
+ break;
149
+ }
150
+ $profile->setReferenceId($responseParams['subscription_id']);
151
+ $profile->setProfileVendorInfo(serialize($responseParams));
152
+ $profile->setAdditionalInfo(serialize($responseParams));
153
+ $feedbackType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_INITIAL;
154
+ // do not create an order since it already got created
155
+ $createOrder = false;
156
+ }
157
+
158
+ if (!$feedbackType) {
159
+ if ($this->getSubscriptionHelper()->isTrialFeedback($orderId)) {
160
+ $feedbackType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
161
+ } else {
162
+ $feedbackType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR;
163
+ }
164
+ }
165
+
166
+ if ($createOrder && is_null($order)) {
167
+ return $this->createOrderFromFeedback($profile, $feedbackType, $responseParams);
168
+ } elseif (!is_null($order)) {
169
+ return $this->processPaymentFeedback($responseParams, $profile, $order);
170
+ }
171
+
172
+ return $createOrder;
173
+ }
174
+
175
+ /**
176
+ * Creates an order for the given item type using the recurring profile model
177
+ *
178
+ * @see Mage_Sales_Model_Recurring_Profile::createOrder()
179
+ *
180
+ * @param Mage_Sales_Model_Recurring_Profile $profile
181
+ * @param string $feedbackType - @see Mage_Sales_Model_Recurring_Profile payment types
182
+ * @param string[] $responseParams
183
+ *
184
+ * @return Mage_Sales_Model_Order the created order
185
+ */
186
+ protected function createOrderFromFeedback($profile, $feedbackType, $responseParams)
187
+ {
188
+ // Just set the payment type, the recurring profile sets the correct amounts automatically
189
+ $orderItem = new Varien_Object();
190
+ $orderItem->setPaymentType($feedbackType);
191
+ if ($feedbackType == Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL) {
192
+ $orderItemInfo = new Varien_Object($profile->getOrderItemInfo());
193
+ $calculator = Mage::getModel('tax/calculation');
194
+ $tax = $calculator->calcTaxAmount($profile->getTrialBillingAmount(),
195
+ $orderItemInfo->getTaxPercent(), true, true
196
+ );
197
+ $price = $profile->getTrialBillingAmount() - $tax;
198
+ $orderItem->setPrice($price)
199
+ ->setTaxAmount($tax);
200
+ }
201
+
202
+ $order = $profile->createOrder($orderItem);
203
+ $billingAddressInfo = $profile->getBillingAddressInfo();
204
+ $order->setQuoteId($billingAddressInfo['quote_id']);
205
+
206
+ $order = $this->processPaymentFeedback($responseParams, $profile, $order);
207
+
208
+ return $order;
209
+ }
210
+
211
+ /**
212
+ * Creates an order for the initial fee. It also fixes the missing data for the order item, so a capture can be
213
+ * properly processed and an invoice created.
214
+ *
215
+ * @param Mage_Payment_Model_Recurring_Profile $profile
216
+ *
217
+ * @return Mage_Sales_Model_Order
218
+ */
219
+ public function createInitialOrder(Mage_Payment_Model_Recurring_Profile $profile)
220
+ {
221
+ /** @var $profile Mage_Sales_Model_Recurring_Profile */
222
+ $item = new Varien_Object();
223
+ $orderItemInfo = new Varien_Object($profile->getOrderItemInfo());
224
+ $calculator = Mage::getModel('tax/calculation');
225
+ $taxAmount = $calculator->calcTaxAmount($profile->getInitAmount(), $orderItemInfo->getTaxPercent(), true,
226
+ true
227
+ );
228
+ $amountWithoutTax = $profile->getInitAmount() - $taxAmount;
229
+ $item->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_INITIAL)
230
+ ->setPrice($amountWithoutTax)
231
+ ->setTaxAmount($taxAmount);
232
+
233
+ $order = $profile->createOrder($item);
234
+ $order->setQuoteId($profile->getQuote()->getId());
235
+
236
+ /** @var $item Mage_Sales_Model_Order_Item */
237
+ list($item) = $order->getAllItems();
238
+ $item->setData('base_discount_amount', 0)
239
+ ->setData('base_discount_calculation_price', $profile->getInitAmount())
240
+ ->setData('base_hidden_tax_amount', 0)
241
+ ->setData('base_original_price', $profile->getInitAmount())
242
+ ->setData('base_price_incl_tax', $profile->getInitAmount())
243
+ ->setData('base_row_tax', $taxAmount)
244
+ ->setData('base_row_total_incl_tax', $profile->getInitAmount())
245
+ ->setData('base_tax_amount', $taxAmount)
246
+ ->setData('base_taxable_amount', $profile->getInitAmount())
247
+ ->setData('calculation_price', $amountWithoutTax)
248
+ ->setData('converted_price', $amountWithoutTax)
249
+ ->setData('discount_calculation_price', $profile->getInitAmount())
250
+ ->setData('price_incl_tax', $profile->getInitAmount())
251
+ ->setData('row_tax', $taxAmount)
252
+ ->setData('row_total_incl_tax', $profile->getInitAmount())
253
+ ->setData('taxable_amount', $profile->getInitAmount());
254
+
255
+ $itemData = $item->getData();
256
+ $item->addData($profile->getOrderItemInfo());
257
+ $item->addData($itemData);
258
+ $item->setId(null);
259
+ $order->getItemsCollection()->removeItemByKey(0);
260
+ $order->addItem($item);
261
+ $order->save();
262
+
263
+ return $order;
264
+ }
265
+
266
+ /**
267
+ * Takes the responseparameters and applies the corresponding action (capture/authorize) on the order payment.
268
+ * Also updates the Ingenico ePayments information on the payment.
269
+ *
270
+ * @param string[] $responseParams
271
+ * @param Mage_Sales_Model_Recurring_Profile $profile
272
+ * @param Mage_Sales_Model_Order $order
273
+ *
274
+ * @return Mage_Sales_Model_Order $order - updated order
275
+ */
276
+ protected function processPaymentFeedback($responseParams, $profile, $order)
277
+ {
278
+ $payment = $order->getPayment();
279
+ foreach ($responseParams as $key => $value) {
280
+ $payment->setTransactionAdditionalInfo($key, $value);
281
+ }
282
+ $payment->setTransactionId($responseParams['PAYID'])
283
+ ->setCurrencyCode($responseParams['currency'])
284
+ ->setIsTransactionClosed(0);
285
+ $order->save();
286
+ $profile->addOrderRelation($order->getId());
287
+ if ($this->getPaymentHelper()->isPaymentAuthorizeType($responseParams['STATUS'])) {
288
+ $payment->registerAuthorizationNotification($responseParams['amount']);
289
+ } elseif ($this->getPaymentHelper()->isPaymentCaptureType($responseParams['STATUS'])) {
290
+ $payment->registerCaptureNotification($responseParams['amount']);
291
+ } elseif ($responseParams['STATUS']
292
+ == Netresearch_OPS_Model_Payment_Abstract::OPS_WAITING_FOR_IDENTIFICATION
293
+ ) {
294
+ // handle 3ds payment - only relevant for initial order creation
295
+ $payment->setIsTransactionPending(1);
296
+ $payment->registerCaptureNotification($responseParams['amount'], true);
297
+ }
298
+ $order->save();
299
+ $this->getPaymentHelper()->applyStateForOrder($order, $responseParams);
300
+
301
+ return $order;
302
+ }
303
+
304
+ }
app/code/community/Netresearch/OPS/Model/System/Config/Backend/Flex/Methods.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Methods.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+
30
+ class Netresearch_OPS_Model_System_Config_Backend_Flex_Methods
31
+ extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
32
+ {
33
+ protected $_eventPrefix = 'ops_config_backend_flex_methods';
34
+
35
+ /**
36
+ * additional validation for unique brands
37
+ *
38
+ * @override
39
+ * @throws Mage_Core_Exception if the brands are not unique -> validation failed
40
+ * @return Netresearch_Ops_Model_System_Config_Backend_Intersolve_Brands
41
+ */
42
+ public function save()
43
+ {
44
+ $methods = $this->getValue();
45
+ if (is_array($methods) && sizeof($methods) > 1) {
46
+ $alreadyProcessedMethods = array();
47
+ foreach ($methods as $method) {
48
+
49
+ if (is_array($method)
50
+ && array_key_exists('pm', $method)
51
+ && array_key_exists('brand', $method)
52
+ ) {
53
+ if(empty($method['title'])||empty($method['pm'])){
54
+ Mage::throwException("Can not save empty title or PM fields");
55
+ }
56
+
57
+
58
+ if (in_array($method['pm'].'_'.$method['brand'], $alreadyProcessedMethods)) {
59
+ Mage::throwException("PM and Brand combination must be unique");
60
+ }
61
+ $alreadyProcessedMethods[] = $method['pm'].'_'.$method['brand'];
62
+ }
63
+ }
64
+ }
65
+ return parent::save();
66
+ }
67
+ }
app/code/community/Netresearch/OPS/Model/System/Config/Backend/HashMethods.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @category Netresearch
18
+ * @package Netresearch_OPS
19
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+
24
+ /**
25
+ *
26
+ *
27
+ * @category Netresearch
28
+ * @package Netresearch_OPS
29
+ * @author Benjamin Heuer <benjamin.heuer@netresearch.de>
30
+ */
31
+
32
+ class Netresearch_Ops_Model_System_Config_Backend_HashMethods
33
+ extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
34
+ {
35
+ /**
36
+ * Options getter
37
+ *
38
+ * @return array
39
+ */
40
+ public function toOptionArray()
41
+ {
42
+ return array(
43
+ array('value' => 'sha1', 'label'=>Mage::helper('ops')->__('SHA-1')),
44
+ array('value' => 'sha256', 'label'=>Mage::helper('ops')->__('SHA-256')),
45
+ array('value' => 'sha512', 'label'=>Mage::helper('ops')->__('SHA-512'))
46
+ );
47
+ }
48
+ }
app/code/community/Netresearch/OPS/Model/System/Config/Mode.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mode.php
4
+ * @author paul.siedler@netresearch.de
5
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
7
+ */
8
+
9
+ class Netresearch_OPS_Model_System_Config_Mode extends Mage_Core_Model_Config_Data
10
+ {
11
+
12
+ public function _afterSave()
13
+ {
14
+
15
+ if($this->getValue() != Netresearch_OPS_Model_Source_Mode::CUSTOM && $this->isValueChanged()){
16
+ $xmlConfig = Mage::getConfig()->loadModulesConfiguration('config.xml');
17
+ foreach($this->getUrlPaths() as $path){
18
+ $default = $xmlConfig->getNode('default/'.$path);
19
+ $newValue = preg_replace('/\/ncol\/\w+/', '/ncol/'.$this->getValue(), $default);
20
+ Mage::getConfig()->saveConfig($path, $newValue, $this->getScope(), $this->getScopeId());
21
+
22
+ }
23
+ }
24
+
25
+ return parent::_afterSave();
26
+ }
27
+
28
+ protected function getUrlPaths(){
29
+ return array(
30
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'ops_gateway',
31
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'ops_alias_gateway',
32
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'frontend_gateway',
33
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'directlink_gateway',
34
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'directlink_gateway_order',
35
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'directlink_maintenance_api'
36
+ );
37
+ }
38
+
39
+ }
app/code/community/Netresearch/OPS/Model/System/Config/Template.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Template.php
5
+ * @author paul.siedler@netresearch.de
6
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
+ */
9
+ class Netresearch_OPS_Model_System_Config_Template extends Mage_Core_Model_Config_Data
10
+ {
11
+ protected function getConfig()
12
+ {
13
+ return Mage::getModel('ops/config');
14
+
15
+ }
16
+
17
+ public function getCommentText(Mage_Core_Model_Config_Element $element, $currentValue)
18
+ {
19
+ $paypageUrl = $this->getConfig()->getPayPageTemplate();
20
+ $paypageInfo = Mage::helper('ops')->__(
21
+ 'With this setting the customer will be redirected to the Ingenico ePayments paypage with the look and feel of your shop. ' .
22
+ '</br> The template used can be seen here: </br>'
23
+ );
24
+ $paypageInfo .= "<a href=\"" . $paypageUrl . "\">" . $paypageUrl . "</a>";
25
+
26
+ $result = "<p class=\"note\"><span id=\"ops_template_comment\"></span></p>";
27
+ $result .= "
28
+ <script type=\"text/javascript\">
29
+ Translator.add(
30
+ '" . Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL . "',
31
+ '" . $paypageInfo . "'
32
+ );
33
+ Translator.add(
34
+ '" . Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE . "',
35
+ '" . Mage::helper('ops')->__('With this setting the customer will be redirected to the Ingenico ePayments paypage. The look and feel of that page will be defined by a dynamically loaded template file whose origin you can define below.') . "'
36
+ );
37
+ Translator.add(
38
+ '" . Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME . "',
39
+ '" . Mage::helper('ops')->__('With this setting the customer will enter the payment details on a page in your shop that hosts the Ingenico ePayments paypage in an iFrame. You can style the paypage through the parameters below.') . "'
40
+ );
41
+ Translator.add(
42
+ '" . Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_REDIRECT . "',
43
+ '" . Mage::helper('ops')->__('With this setting the customer will get redirected to Ingenico ePayments to enter his payment details. You can style the page through the parameters below.') . "'
44
+ );
45
+ selectElement = $('payment_services_ops_template');
46
+
47
+ function updateComment(value){
48
+ var comment = $('ops_template_comment');
49
+ comment.innerHTML = Translator.translate(value);
50
+ }
51
+
52
+ Event.observe(window, 'load', function(){
53
+ updateComment('" . $currentValue . "');
54
+ Event.observe(selectElement, 'change', function(){
55
+ updateComment(selectElement.value);
56
+ });
57
+ });
58
+ </script>";
59
+
60
+ return $result;
61
+ }
62
+
63
+ }
app/code/community/Netresearch/OPS/Test/Block/Adminhtml/Sales/Order/Invoice/Warning/OpenInvoiceTest.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- /**
3
- * @author Michael Lühr <michael.luehr@netresearch.de>
4
- * @category Netresearch
5
- * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
6
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
- */
8
-
9
-
10
- class Netresearch_OPS_Test_Block_Adminhtml_Sales_Order_Invoice_Warning_OpenInvoiceTest extends EcomDev_PHPUnit_Test_Case
11
- {
12
-
13
- public function testGetTemplate()
14
- {
15
- $block = Mage::app()->getLayout()->getBlockSingleton('ops/adminhtml_sales_order_invoice_warning_openInvoice');
16
- $this->assertEquals('ops/sales/order/invoice/warning/open-invoice.phtml', $block->getTemplate());
17
- }
18
-
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Test/Block/Form/CcTest.php CHANGED
@@ -2,6 +2,16 @@
2
 
3
  class Netresearch_OPS_Test_Block_Form_CcTest extends EcomDev_PHPUnit_Test_Case
4
  {
 
 
 
 
 
 
 
 
 
 
5
 
6
  public function testGetAliasBrands()
7
  {
@@ -14,11 +24,14 @@ class Netresearch_OPS_Test_Block_Form_CcTest extends EcomDev_PHPUnit_Test_Case
14
  'VISA',
15
  );
16
 
17
- $ccAliasInterfaceEnabledTypesMock = $this->getModelMock('ops/source_cc_aliasInterfaceEnabledTypes', array('getAliasInterfaceCompatibleTypes'));
 
 
18
  $ccAliasInterfaceEnabledTypesMock->expects($this->any())
19
  ->method('getAliasInterfaceCompatibleTypes')
20
  ->will($this->returnValue($aliasBrands));
21
  $this->replaceByMock('model', 'ops/source_cc_aliasInterfaceEnabledTypes', $ccAliasInterfaceEnabledTypesMock);
 
22
  $ccForm = Mage::app()->getLayout()->getBlockSingleton('ops/form_cc');
23
  $ccAliases = $ccForm->getAliasBrands();
24
  $this->assertEquals($aliasBrands, $ccAliases);
@@ -34,7 +47,7 @@ class Netresearch_OPS_Test_Block_Form_CcTest extends EcomDev_PHPUnit_Test_Case
34
  ->will($this->returnValue(true));
35
  $this->replaceByMock('model', 'ops/config', $modelMock);
36
  $ccForm = new Netresearch_OPS_Block_Form_Cc();
37
- $this->assertEquals(Netresearch_OPS_Block_Form::FRONTEND_TEMPLATE, $ccForm->getTemplate());
38
 
39
  //Backend case
40
  $modelMock = $this->getModelMock('ops/config', array('isFrontendEnvironment'));
@@ -43,6 +56,404 @@ class Netresearch_OPS_Test_Block_Form_CcTest extends EcomDev_PHPUnit_Test_Case
43
  ->will($this->returnValue(false));
44
  $this->replaceByMock('model', 'ops/config', $modelMock);
45
  $ccForm = new Netresearch_OPS_Block_Form_Cc();
46
- $this->assertEquals(Netresearch_OPS_Block_Form_Cc::BACKEND_TEMPLATE, $ccForm->getTemplate());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  }
48
  }
2
 
3
  class Netresearch_OPS_Test_Block_Form_CcTest extends EcomDev_PHPUnit_Test_Case
4
  {
5
+ /** @var Netresearch_OPS_Block_Form_Cc $_block */
6
+ private $_block;
7
+
8
+ public function setUp()
9
+ {
10
+ parent::setup();
11
+ $this->_block = Mage::app()->getLayout()->getBlockSingleton('ops/form_cc');
12
+ $this->_block->setMethod(Mage::getModel('ops/payment_cc'));
13
+ $this->mockSessions();
14
+ }
15
 
16
  public function testGetAliasBrands()
17
  {
24
  'VISA',
25
  );
26
 
27
+ $ccAliasInterfaceEnabledTypesMock = $this->getModelMock(
28
+ 'ops/source_cc_aliasInterfaceEnabledTypes', array('getAliasInterfaceCompatibleTypes')
29
+ );
30
  $ccAliasInterfaceEnabledTypesMock->expects($this->any())
31
  ->method('getAliasInterfaceCompatibleTypes')
32
  ->will($this->returnValue($aliasBrands));
33
  $this->replaceByMock('model', 'ops/source_cc_aliasInterfaceEnabledTypes', $ccAliasInterfaceEnabledTypesMock);
34
+ /** @var Netresearch_OPS_Block_Form_Cc $ccForm */
35
  $ccForm = Mage::app()->getLayout()->getBlockSingleton('ops/form_cc');
36
  $ccAliases = $ccForm->getAliasBrands();
37
  $this->assertEquals($aliasBrands, $ccAliases);
47
  ->will($this->returnValue(true));
48
  $this->replaceByMock('model', 'ops/config', $modelMock);
49
  $ccForm = new Netresearch_OPS_Block_Form_Cc();
50
+ $this->assertEquals(Netresearch_OPS_Block_Form_Cc::FRONTEND_TEMPLATE, $ccForm->getTemplate());
51
 
52
  //Backend case
53
  $modelMock = $this->getModelMock('ops/config', array('isFrontendEnvironment'));
56
  ->will($this->returnValue(false));
57
  $this->replaceByMock('model', 'ops/config', $modelMock);
58
  $ccForm = new Netresearch_OPS_Block_Form_Cc();
59
+ $this->assertEquals(Netresearch_OPS_Block_Form_Cc::FRONTEND_TEMPLATE, $ccForm->getTemplate());
60
+ }
61
+
62
+ public function testGetCcBrands()
63
+ {
64
+ $blockMock = $this->getBlockMock('ops/form_cc', array('getMethod'));
65
+ $method = new Varien_Object();
66
+ $method->setCode('ops_cc');
67
+ $blockMock->expects($this->any())
68
+ ->method('getMethod')
69
+ ->will($this->returnValue($method));
70
+ $this->replaceByMock('block', 'ops/form_cc', $blockMock);
71
+
72
+
73
+ $this->assertInternalType('array', $blockMock->getCcBrands());
74
+ }
75
+
76
+ public function testIsAliasPMEnabled()
77
+ {
78
+ $model = Mage::getModel('ops/config');
79
+ $this->assertEquals(
80
+ $model->isAliasManagerEnabled('ops_cc'), $this->_block->isAliasPMEnabled()
81
+ );
82
+ }
83
+
84
+ public function testGetStoredAliasDataForCustomer()
85
+ {
86
+
87
+ $reflectionClass = new ReflectionClass(get_class($this->_block));
88
+ $method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
89
+ $method->setAccessible(true);
90
+ $this->assertNull($method->invoke($this->_block, 0, 'bla'));
91
+
92
+ $blockMock = $this->getBlockMock(
93
+ 'ops/form_cc', array('getStoredAliasForCustomer')
94
+ );
95
+ $blockMock->expects($this->once())
96
+ ->method('getStoredAliasForCustomer')
97
+ ->will($this->returnValue(array()));
98
+ $reflectionClass = new ReflectionClass(get_class($blockMock));
99
+ $method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
100
+ $method->setAccessible(true);
101
+ $this->assertNull($method->invoke($blockMock, 0, 'bla'));
102
+
103
+
104
+ $blockMock = $this->getBlockMock(
105
+ 'ops/form_cc', array('getStoredAliasForCustomer')
106
+ );
107
+ $blockMock->expects($this->once())
108
+ ->method('getStoredAliasForCustomer')
109
+ ->will($this->returnValue(array(0 => new Varien_Object(array('bla' => 'foo')))));
110
+ $reflectionClass = new ReflectionClass(get_class($blockMock));
111
+ $method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
112
+ $method->setAccessible(true);
113
+ $this->assertEquals(
114
+ 'foo', $method->invoke($blockMock, 0, 'bla')
115
+ );
116
+
117
+ $blockMock = $this->getBlockMock(
118
+ 'ops/form_cc', array('getStoredAliasForCustomer')
119
+ );
120
+ $blockMock->expects($this->once())
121
+ ->method('getStoredAliasForCustomer')
122
+ ->will($this->returnValue(array(0 => new Varien_Object(array('bla' => 'foo')))));
123
+ $reflectionClass = new ReflectionClass(get_class($blockMock));
124
+ $method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
125
+ $method->setAccessible(true);
126
+ $this->assertNull($method->invoke($blockMock, 0, 'foo'));
127
+
128
+ }
129
+
130
+ public function testGetAliasCardNumber()
131
+ {
132
+ $blockMock = $this->getBlockMock(
133
+ 'ops/form_cc', array('getStoredAliasForCustomer')
134
+ );
135
+ $blockMock->expects($this->any())
136
+ ->method('getStoredAliasForCustomer')
137
+ ->will(
138
+ $this->returnValue(
139
+ array(
140
+ 0 => new Varien_Object(
141
+ array(
142
+ 'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
143
+ 'brand' => 'visa'
144
+ )
145
+ )
146
+ )
147
+ )
148
+ );
149
+ $this->assertEquals('XXXX XXXX XXXX 1111', $blockMock->getAliasCardNumber(0));
150
+ }
151
+
152
+ /**
153
+ * @loadFixture aliases.yaml
154
+ */
155
+ public function testGetStoredAliasForCustomer()
156
+ {
157
+
158
+ $reflectionClass = new ReflectionClass(get_class($this->_block));
159
+ $method = $reflectionClass->getMethod("getStoredAliasForCustomer");
160
+ $method->setAccessible(true);
161
+ $this->assertEquals(0, count($method->invoke($this->_block)));
162
+
163
+
164
+ $configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
165
+ $configMock->expects($this->any())
166
+ ->method('isAliasManagerEnabled')
167
+ ->will($this->returnValue(true));
168
+ $this->replaceByMock('model', 'ops/config', $configMock);
169
+
170
+ $aliases = Mage::getModel('ops/alias')
171
+ ->getCollection()
172
+ ->addFieldToFilter('customer_id', 1)
173
+ ->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
174
+ ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
175
+ $alias = $aliases->getFirstItem();
176
+ $aliasHelperMock = $this->getHelperMock('ops/alias', array('getAliasesForAddresses'));
177
+ $aliasHelperMock->expects($this->once())
178
+ ->method('getAliasesForAddresses')
179
+ ->will($this->returnValue($aliases));
180
+ $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
181
+
182
+ $customerMock = $this->getHelperMock('customer/data', array('isLoggedIn'));
183
+ $customerMock->expects($this->once())
184
+ ->method('isLoggedIn')
185
+ ->will($this->returnValue(true));
186
+ $this->replaceByMock('helper', 'customer/data', $customerMock);
187
+
188
+ $fakeCustomer = new Varien_Object();
189
+ $fakeCustomer->setId(1);
190
+
191
+ $fakeQuote = new Varien_Object();
192
+ $fakeQuote->setCustomer($fakeCustomer);
193
+
194
+
195
+ $blockMock = $this->getBlockMock('ops/form_cc', array('getQuote', 'getMethodCode'));
196
+ $blockMock->expects($this->once())
197
+ ->method('getQuote')
198
+ ->will($this->returnValue($fakeQuote));
199
+ $blockMock->expects($this->any())
200
+ ->method('getMethodCode')
201
+ ->will($this->returnValue('ops_cc'));
202
+ $this->replaceByMock('block', 'ops/form_cc', $blockMock);
203
+
204
+ $reflectionClass = new ReflectionClass(get_class($blockMock));
205
+ $method = $reflectionClass->getMethod("getStoredAliasForCustomer");
206
+ $method->setAccessible(true);
207
+ $aliases = $method->invoke($blockMock);
208
+ $this->assertEquals($alias->getData(), $aliases[1]->getData());
209
+
210
+ }
211
+
212
+
213
+ public function testGetExpirationDatePart()
214
+ {
215
+ $blockMock = $this->getBlockMock(
216
+ 'ops/form_cc', array('getStoredAliasForCustomer')
217
+ );
218
+ $blockMock->expects($this->any())
219
+ ->method('getStoredAliasForCustomer')
220
+ ->will($this->returnValue(array(0 => new Varien_Object(array('expiration_date' => '0416')))));
221
+ $this->assertEquals('04', $blockMock->getExpirationDatePart(0, 'month'));
222
+ $this->assertEquals('16', $blockMock->getExpirationDatePart(0, 'year'));
223
+ }
224
+
225
+ public function testGetCardHolderName()
226
+ {
227
+ $configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
228
+ $configMock->expects($this->any())
229
+ ->method('isAliasManagerEnabled')
230
+ ->will($this->returnValue(false));
231
+ $this->replaceByMock('model', 'ops/config', $configMock);
232
+
233
+ $this->assertNull($block = $this->_block->getCardHolderName(2));
234
+
235
+ $configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
236
+ $configMock->expects($this->any())
237
+ ->method('isAliasManagerEnabled')
238
+ ->will($this->returnValue(true));
239
+ $this->replaceByMock('model', 'ops/config', $configMock);
240
+
241
+
242
+ $blockMock = $this->getBlockMock(
243
+ 'ops/form_cc', array('getStoredAliasDataForCustomer', 'getStoredAlias')
244
+ );
245
+
246
+ $blockMock->expects($this->any())
247
+ ->method('getStoredAliasDataForCustomer')
248
+ ->will($this->returnValue('Hubertus von Fürstenberg'));
249
+
250
+ $blockMock->expects($this->any())
251
+ ->method('getStoredAlias')
252
+ ->will($this->returnValue('4711'));
253
+ $this->assertEquals('Hubertus von Fürstenberg', $blockMock->getCardHolderName(2));
254
+
255
+ $blockMock = $this->getBlockMock(
256
+ 'ops/form_cc', array('getStoredAliasDataForCustomer', 'getStoredAlias', 'getMethodCode')
257
+ );
258
+ $blockMock->expects($this->any())
259
+ ->method('getMethodCode')
260
+ ->will($this->returnValue('ops_cc'));
261
+ $blockMock->expects($this->once())
262
+ ->method('getStoredAliasDataForCustomer')
263
+ ->will($this->returnValue(null));
264
+
265
+ $blockMock->expects($this->any())
266
+ ->method('getStoredAlias')
267
+ ->will($this->returnValue('4711'));
268
+
269
+ $customerHelperMock = $this->getHelperMock('customer/data', array('isLoggedIn', 'getCustomerName'));
270
+ $customerHelperMock->expects($this->any())
271
+ ->method('isLoggedIn')
272
+ ->will($this->returnValue(true));
273
+ $customerHelperMock->expects($this->any())
274
+ ->method('getCustomerName')
275
+ ->will($this->returnValue('Hubertus zu Fürstenberg'));
276
+ $this->replaceByMock('helper', 'customer/data', $customerHelperMock);
277
+
278
+
279
+ $this->assertEquals('Hubertus zu Fürstenberg', $blockMock->getCardHolderName(2));
280
+
281
+ $blockMock = $this->getBlockMock(
282
+ 'ops/form_cc', array('getStoredAliasDataForCustomer', 'getStoredAlias', 'getMethodCode')
283
+ );
284
+ $blockMock->expects($this->any())
285
+ ->method('getMethodCode')
286
+ ->will($this->returnValue('ops_cc'));
287
+ $blockMock->expects($this->once())
288
+ ->method('getStoredAliasDataForCustomer')
289
+ ->will($this->returnValue(''));
290
+
291
+ $blockMock->expects($this->any())
292
+ ->method('getStoredAlias')
293
+ ->will($this->returnValue('4711'));
294
+
295
+ $this->assertEquals('Hubertus zu Fürstenberg', $blockMock->getCardHolderName(2));
296
+
297
+ $blockMock = $this->getBlockMock(
298
+ 'ops/form_cc', array('getStoredAliasDataForCustomer', 'getStoredAlias')
299
+ );
300
+ $blockMock->expects($this->once())
301
+ ->method('getStoredAliasDataForCustomer')
302
+ ->will($this->returnValue(null));
303
+
304
+ $blockMock->expects($this->any())
305
+ ->method('getStoredAlias')
306
+ ->will($this->returnValue('4711'));
307
+
308
+ $customerHelperMock = $this->getHelperMock('customer/data', array('isLoggedIn'));
309
+ $customerHelperMock->expects($this->any())
310
+ ->method('isLoggedIn')
311
+ ->will($this->returnValue(false));
312
+ $this->replaceByMock('helper', 'customer/data', $customerHelperMock);
313
+
314
+ $this->assertNull($blockMock->getCardHolderName(2));
315
+
316
+
317
+ }
318
+
319
+ public function testGetStoredAliasBrandWithInlineBrand()
320
+ {
321
+ /** @var Netresearch_OPS_Block_Form_Cc $blockMock */
322
+
323
+ $blockMock = $this->getBlockMock(
324
+ 'ops/form_cc', array('getStoredAliasForCustomer', 'getMethodCode')
325
+ );
326
+ $blockMock->expects($this->any())
327
+ ->method('getStoredAliasForCustomer')
328
+ ->will(
329
+ $this->returnValue(
330
+ array(0 => new Varien_Object(
331
+ array(
332
+ 'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
333
+ 'brand' => 'VISA'
334
+ )
335
+ ))
336
+ )
337
+ );
338
+ $blockMock->expects($this->any())
339
+ ->method('getMethodCode')
340
+ ->will($this->returnValue('ops_cc'));
341
+
342
+ $modelMock = $this->getModelMock(
343
+ 'ops/config', array('getInlinePaymentCcTypes')
344
+ );
345
+ $modelMock->expects($this->any())
346
+ ->method('getInlinePaymentCcTypes')
347
+ ->will(
348
+ $this->returnValue(
349
+ array(
350
+ 'VISA'
351
+ )
352
+ )
353
+ );
354
+
355
+ $this->assertEquals('VISA', $blockMock->getStoredAliasBrand(0));
356
+ }
357
+
358
+
359
+ public function testGetStoredAliasBrandWithNonInlineBrand()
360
+ {
361
+ /** @var Netresearch_OPS_Block_Form_Cc $blockMock */
362
+
363
+ $blockMock = $this->getBlockMock(
364
+ 'ops/form_cc', array('getStoredAliasForCustomer', 'getMethodCode')
365
+ );
366
+ $blockMock->expects($this->any())
367
+ ->method('getStoredAliasForCustomer')
368
+ ->will(
369
+ $this->returnValue(
370
+ array(new Varien_Object(
371
+ array(
372
+ 'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
373
+ 'brand' => 'VISA'
374
+ )
375
+ ))
376
+ )
377
+ );
378
+ $blockMock->expects($this->any())
379
+ ->method('getMethodCode')
380
+ ->will($this->returnValue('ops_cc'));
381
+
382
+ $modelMock = $this->getModelMock(
383
+ 'ops/config', array('getInlinePaymentCcTypes')
384
+ );
385
+ $modelMock->expects($this->any())
386
+ ->method('getInlinePaymentCcTypes')
387
+ ->will(
388
+ $this->returnValue(
389
+ array(
390
+ 'FOO'
391
+ )
392
+ )
393
+ );
394
+
395
+ $this->replaceByMock('model', 'ops/config', $modelMock);
396
+
397
+ $this->assertEquals('', $blockMock->getStoredAliasBrand(0));
398
+ }
399
+
400
+ public function testIsAliasInfoBlockEnabled()
401
+ {
402
+ $configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
403
+ $configMock->expects($this->any())
404
+ ->method('isAliasPMEnabled')
405
+ ->will($this->returnValue(false));
406
+ $configMock->expects($this->any())
407
+ ->method('isAliasInfoBlockEnabled')
408
+ ->will($this->returnValue(false));
409
+ $this->replaceByMock('model', 'ops/config', $configMock);
410
+
411
+ $this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form_cc')->isAliasInfoBlockEnabled());
412
+
413
+ $configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
414
+ $configMock->expects($this->any())
415
+ ->method('isAliasPMEnabled')
416
+ ->will($this->returnValue(false));
417
+ $configMock->expects($this->any())
418
+ ->method('isAliasInfoBlockEnabled')
419
+ ->will($this->returnValue(true));
420
+ $this->replaceByMock('model', 'ops/config', $configMock);
421
+
422
+ $this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form_cc')->isAliasInfoBlockEnabled());
423
+
424
+ $configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
425
+ $configMock->expects($this->any())
426
+ ->method('isAliasPMEnabled')
427
+ ->will($this->returnValue(true));
428
+ $configMock->expects($this->any())
429
+ ->method('isAliasInfoBlockEnabled')
430
+ ->will($this->returnValue(false));
431
+ $this->replaceByMock('model', 'ops/config', $configMock);
432
+
433
+ $this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form_cc')->isAliasInfoBlockEnabled());
434
+
435
+ $configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
436
+ $configMock->expects($this->any())
437
+ ->method('isAliasPMEnabled')
438
+ ->will($this->returnValue(true));
439
+ $configMock->expects($this->any())
440
+ ->method('isAliasInfoBlockEnabled')
441
+ ->will($this->returnValue(true));
442
+ $this->replaceByMock('model', 'ops/config', $configMock);
443
+
444
+ $this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form_cc')->isAliasInfoBlockEnabled());
445
+ }
446
+
447
+ protected function mockSessions()
448
+ {
449
+ $sessionMock = $this->getModelMockBuilder('checkout/session')
450
+ ->disableOriginalConstructor()// This one removes session_start and other methods usage
451
+ ->getMock();
452
+ $this->replaceByMock('singleton', 'core/session', $sessionMock);
453
+
454
+ $sessionMock = $this->getModelMockBuilder('customer/session')
455
+ ->disableOriginalConstructor()// This one removes session_start and other methods usage
456
+ ->getMock();
457
+ $this->replaceByMock('singleton', 'customer/session', $sessionMock);
458
  }
459
  }
app/code/community/Netresearch/OPS/Test/Block/Form/CcTest/fixtures/aliases.yaml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ ops/alias:
3
+ - id: 1
4
+ customer_id: 1
5
+ alias: 4711
6
+ brand: 'VISA'
7
+ billing_address_hash: '0815'
8
+ shipping_address_hash: '2342'
9
+ pseudo_account_or_cc_no: 'xxxx1111'
10
+ expiration_date: '0116'
11
+ payment_method: 'ops_cd'
12
+ state: 'active'
13
+ store_id: 0
14
+ created_at: '2000-01-01 00:00:01'
15
+
16
+ - id: 2
17
+ customer_id: 1
18
+ alias: 4712
19
+ brand: 'VISA'
20
+ billing_address_hash: '0816'
21
+ shipping_address_hash: '2342'
22
+ pseudo_account_or_cc_no: 'xxxx1112'
23
+ expiration_date: '0116'
24
+ payment_method: 'ops_cc'
25
+ state: 'active'
26
+ store_id: 0
27
+ created_at: '1970-01-01 00:00:01'
28
+
29
+ - id: 3
30
+ customer_id: 1
31
+ alias: 4713
32
+ brand: 'VISA'
33
+ billing_address_hash: '0817'
34
+ shipping_address_hash: '0817'
35
+ pseudo_account_or_cc_no: 'xxxx1113'
36
+ expiration_date: '0116'
37
+ payment_method: 'ops_cc'
38
+ state: 'pending'
39
+ store_id: 0
40
+ created_at: '1970-01-01 00:00:02'
41
+
42
+ - id: 4
43
+ customer_id: 2
44
+ alias: 4711
45
+ brand: 'VISA'
46
+ billing_address_hash: '1508'
47
+ shipping_address_hash: '4223'
48
+ pseudo_account_or_cc_no: 'xxxx1111'
49
+ expiration_date: '0117'
50
+ payment_method: 'ops_cc'
51
+ state: 'active'
52
+ store_id: 0
53
+ created_at: '1970-01-01 00:00:02'
54
+
55
+ - id: 5
56
+ customer_id: 1
57
+ alias: 4711
58
+ brand: 'VISA'
59
+ billing_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
60
+ shipping_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
61
+ pseudo_account_or_cc_no: 'xxxx1111'
62
+ expiration_date: '0117'
63
+ payment_method: 'ops_cc'
64
+ state: 'active'
65
+ store_id: 0
66
+ created_at: '1970-01-01 00:00:02'
67
+
68
+ - id: 6
69
+ customer_id: 1
70
+ alias: 4714
71
+ brand: 'VISA'
72
+ billing_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
73
+ shipping_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
74
+ pseudo_account_or_cc_no: 'xxxx1111'
75
+ expiration_date: '0116'
76
+ payment_method: 'ops_cd'
77
+ state: 'pending'
78
+ store_id: 0
79
+ created_at: '2000-11-01 00:00:01'
80
+
81
+ - id: 7
82
+ customer_id: 23
83
+ alias: 4714
84
+ brand: 'VISA'
85
+ billing_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
86
+ shipping_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
87
+ pseudo_account_or_cc_no: 'xxxx1111'
88
+ expiration_date: '0116'
89
+ payment_method: 'ops_cd'
90
+ state: 'active'
91
+ store_id: 0
92
+ created_at: '2000-11-01 00:00:01'
app/code/community/Netresearch/OPS/Test/Block/Form/DirectDebitTest.php CHANGED
@@ -15,7 +15,7 @@ class Netresearch_OPS_Test_Block_Form_DirectDebitTest
15
  $this->replaceByMock('model', 'ops/config', $modelMock);
16
  $ccForm = new Netresearch_OPS_Block_Form_DirectDebit();
17
  $this->assertEquals(
18
- Netresearch_OPS_Block_Form::FRONTEND_TEMPLATE,
19
  $ccForm->getTemplate()
20
  );
21
 
@@ -29,7 +29,7 @@ class Netresearch_OPS_Test_Block_Form_DirectDebitTest
29
  $this->replaceByMock('model', 'ops/config', $modelMock);
30
  $ccForm = new Netresearch_OPS_Block_Form_DirectDebit();
31
  $this->assertEquals(
32
- Netresearch_OPS_Block_Form_DirectDebit::BACKEND_TEMPLATE,
33
  $ccForm->getTemplate()
34
  );
35
  }
@@ -55,7 +55,7 @@ class Netresearch_OPS_Test_Block_Form_DirectDebitTest
55
  'adminhtml/session', array('init', 'save')
56
  );
57
  $this->replaceByMock('model', 'adminhtml/session', $sessionMock);
58
- $block = new Netresearch_OPS_Block_Form_DirectDebit();
59
  $expectedResult = array(
60
  'country' => '',
61
  'CN' => '',
15
  $this->replaceByMock('model', 'ops/config', $modelMock);
16
  $ccForm = new Netresearch_OPS_Block_Form_DirectDebit();
17
  $this->assertEquals(
18
+ Netresearch_OPS_Block_Form_DirectDebit::TEMPLATE,
19
  $ccForm->getTemplate()
20
  );
21
 
29
  $this->replaceByMock('model', 'ops/config', $modelMock);
30
  $ccForm = new Netresearch_OPS_Block_Form_DirectDebit();
31
  $this->assertEquals(
32
+ Netresearch_OPS_Block_Form_DirectDebit::TEMPLATE,
33
  $ccForm->getTemplate()
34
  );
35
  }
55
  'adminhtml/session', array('init', 'save')
56
  );
57
  $this->replaceByMock('model', 'adminhtml/session', $sessionMock);
58
+ $block = new Netresearch_OPS_Block_Form_DirectDebit();
59
  $expectedResult = array(
60
  'country' => '',
61
  'CN' => '',
app/code/community/Netresearch/OPS/Test/Block/Form/Field/MethodTest.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * MethodTest.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Block_Form_Field_MethodTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+ public function testBlockConstruction()
36
+ {
37
+ /** @var Netresearch_OPS_Block_System_Config_Form_Field_Method $block */
38
+ $block = Mage::app()->getLayout()->createBlock('ops/system_config_form_field_method');
39
+ $this->assertTrue($block instanceof Netresearch_OPS_Block_System_Config_Form_Field_Method);
40
+
41
+ }
42
+ }
app/code/community/Netresearch/OPS/Test/Block/Form/FlexTest.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * FlexTest.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Block_Form_FlexTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+ public function testGetFlexMethods()
36
+ {
37
+ Mage::app()->setCurrentStore(0);
38
+ Mage::getConfig()->saveConfig('payment/ops_flex/methods', serialize($this->getMethodArray()));
39
+
40
+ /** @var Netresearch_OPS_Block_Form_Flex $block */
41
+ $block = Mage::app()->getLayout()->createBlock('ops/form_flex');
42
+
43
+ $block->setMethod(Mage::getModel('ops/payment_flex'));
44
+
45
+ $this->assertTrue(is_array($block->getFlexMethods()));
46
+ $this->assertEquals(1, count($block->getFlexMethods()));
47
+ }
48
+
49
+ private function getMethodArray()
50
+ {
51
+ return array(
52
+ array(
53
+ 'title' => 'foo',
54
+ 'brand' => 'bar',
55
+ 'pm' => 'zzz'
56
+ )
57
+ );
58
+ }
59
+
60
+
61
+ public function testGetDefaultOptionTitle()
62
+ {
63
+ Mage::app()->setCurrentStore(0);
64
+ Mage::getConfig()->saveConfig('payment/ops_flex/default_title', 'flex');
65
+ Mage::getConfig()->cleanCache();
66
+
67
+ /** @var Netresearch_OPS_Block_Form_Flex $block */
68
+ $block = Mage::app()->getLayout()->createBlock('ops/form_flex');
69
+
70
+ $block->setMethod(Mage::getModel('ops/payment_flex'));
71
+
72
+ $this->assertEquals('flex', $block->getDefaultOptionTitle());
73
+ }
74
+
75
+ public function testIsDefaultOptionActive()
76
+ {
77
+ Mage::app()->setCurrentStore(0);
78
+ Mage::getConfig()->saveConfig('payment/ops_flex/default', true);
79
+ Mage::getConfig()->cleanCache();
80
+
81
+ /** @var Netresearch_OPS_Block_Form_Flex $block */
82
+ $block = Mage::app()->getLayout()->createBlock('ops/form_flex');
83
+
84
+ $block->setMethod(Mage::getModel('ops/payment_flex'));
85
+
86
+ $this->assertTrue($block->isDefaultOptionActive());
87
+
88
+ }
89
+ }
app/code/community/Netresearch/OPS/Test/Block/Form/InterSolveTest.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * InterSolveTest.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Block_Form_InterSolveTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+ public function testGetInterSolveBrands()
36
+ {
37
+ Mage::getConfig()->saveConfig(
38
+ 'payment/ops_interSolve/brands', serialize($this->getBrandArray())
39
+ );
40
+ Mage::getConfig()->cleanCache();
41
+
42
+ $block = Mage::app()->getLayout()->createBlock('ops/form_interSolve');
43
+ $this->assertEquals($this->getBrandArray(), $block->getInterSolveBrands());
44
+ }
45
+
46
+ private function getBrandArray()
47
+ {
48
+ return array(
49
+ array('brand' => 'foo', 'title' => 'bar')
50
+ );
51
+ }
52
+ }
app/code/community/Netresearch/OPS/Test/Block/FormTest.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  class Netresearch_OPS_Test_Block_FormTest
3
  extends EcomDev_PHPUnit_Test_Case_Controller
4
  {
@@ -10,336 +11,6 @@ class Netresearch_OPS_Test_Block_FormTest
10
  $this->_block = Mage::app()->getLayout()->getBlockSingleton('ops/form');
11
  }
12
 
13
- public function testGetCcBrands()
14
- {
15
- $this->assertInternalType('array', $this->_block->getCcBrands());
16
- }
17
-
18
- public function testGetDirectDebitCountryIds()
19
- {
20
- $this->assertInternalType(
21
- 'array', $this->_block->getDirectDebitCountryIds()
22
- );
23
- }
24
-
25
- public function testIsAliasPMEnabled()
26
- {
27
- $model = Mage::getModel('ops/config');
28
- $this->assertEquals(
29
- $model->isAliasManagerEnabled(), $this->_block->isAliasPMEnabled()
30
- );
31
- }
32
-
33
- public function testGetStoredAliasDataForCustomer()
34
- {
35
-
36
- $reflectionClass = new ReflectionClass(get_class($this->_block));
37
- $method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
38
- $method->setAccessible(true);
39
- $this->assertNull($method->invoke($this->_block, 'bla'));
40
-
41
- $blockMock = $this->getBlockMock(
42
- 'ops/form', array('getStoredAliasForCustomer')
43
- );
44
- $blockMock->expects($this->once())
45
- ->method('getStoredAliasForCustomer')
46
- ->will($this->returnValue(array()));
47
- $reflectionClass = new ReflectionClass(get_class($blockMock));
48
- $method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
49
- $method->setAccessible(true);
50
- $this->assertNull($method->invoke($blockMock, 'bla'));
51
-
52
-
53
- $blockMock = $this->getBlockMock(
54
- 'ops/form', array('getStoredAliasForCustomer')
55
- );
56
- $blockMock->expects($this->once())
57
- ->method('getStoredAliasForCustomer')
58
- ->will($this->returnValue(array('bla' => 'foo')));
59
- $reflectionClass = new ReflectionClass(get_class($blockMock));
60
- $method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
61
- $method->setAccessible(true);
62
- $this->assertEquals(
63
- 'foo', $method->invoke($blockMock, 'bla')
64
- );
65
-
66
- $blockMock = $this->getBlockMock(
67
- 'ops/form', array('getStoredAliasForCustomer')
68
- );
69
- $blockMock->expects($this->once())
70
- ->method('getStoredAliasForCustomer')
71
- ->will($this->returnValue(array('bla' => 'foo')));
72
- $reflectionClass = new ReflectionClass(get_class($blockMock));
73
- $method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
74
- $method->setAccessible(true);
75
- $this->assertNull($method->invoke($blockMock, 'foo'));
76
-
77
- }
78
-
79
-
80
- public function testGetAliasCardNumber()
81
- {
82
- $blockMock = $this->getBlockMock(
83
- 'ops/form', array('getStoredAliasForCustomer')
84
- );
85
- $blockMock->expects($this->any())
86
- ->method('getStoredAliasForCustomer')
87
- ->will(
88
- $this->returnValue(
89
- array(
90
- 'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
91
- 'brand' => 'visa'
92
- )
93
- )
94
- );
95
- $this->assertEquals('XXXX XXXX XXXX 1111', $blockMock->getAliasCardNumber());
96
- }
97
-
98
- /**
99
- * @loadFixture ../../../var/fixtures/aliases.yaml
100
- */
101
- public function testGetStoredAliasForCustomer()
102
- {
103
-
104
- $reflectionClass = new ReflectionClass(get_class($this->_block));
105
- $method = $reflectionClass->getMethod("getStoredAliasForCustomer");
106
- $method->setAccessible(true);
107
- $this->assertNull($method->invoke($this->_block));
108
-
109
-
110
- $configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
111
- $configMock->expects($this->any())
112
- ->method('isAliasManagerEnabled')
113
- ->will($this->returnValue(true));
114
- $this->replaceByMock('model', 'ops/config', $configMock);
115
-
116
- $aliases = Mage::getModel('ops/alias')
117
- ->getCollection()
118
- ->addFieldToFilter('customer_id', 1)
119
- ->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
120
- ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC)
121
- ;
122
- $alias = $aliases->getFirstItem();
123
- $aliasHelperMock = $this->getHelperMock('ops/alias', array('getAliasesForAddresses'));
124
- $aliasHelperMock->expects($this->once())
125
- ->method('getAliasesForAddresses')
126
- ->will($this->returnValue($aliases));
127
- $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
128
-
129
- $customerMock = $this->getHelperMock('customer/data', array('isLoggedIn'));
130
- $customerMock->expects($this->once())
131
- ->method('isLoggedIn')
132
- ->will($this->returnValue(true));
133
- $this->replaceByMock('helper', 'customer/data', $customerMock);
134
-
135
- $fakeCustomer = new Varien_Object();
136
- $fakeCustomer->setId(1);
137
-
138
- $fakeQuote = new Varien_Object();
139
- $fakeQuote->setCustomer($fakeCustomer);
140
-
141
-
142
-
143
- $blockMock = $this->getBlockMock('ops/form', array('getQuote'));
144
- $blockMock->expects($this->once())
145
- ->method('getQuote')
146
- ->will($this->returnValue($fakeQuote));
147
- $this->replaceByMock('block', 'ops/form', $blockMock);
148
-
149
- $reflectionClass = new ReflectionClass(get_class($blockMock));
150
- $method = $reflectionClass->getMethod("getStoredAliasForCustomer");
151
- $method->setAccessible(true);
152
-
153
- $this->assertEquals($alias->getData(), $method->invoke($blockMock));
154
-
155
- }
156
-
157
-
158
- public function testGetExpirationDatePart()
159
- {
160
- $blockMock = $this->getBlockMock(
161
- 'ops/form', array('getStoredAliasForCustomer')
162
- );
163
- $blockMock->expects($this->any())
164
- ->method('getStoredAliasForCustomer')
165
- ->will($this->returnValue(array('expiration_date' => '0416')));
166
- $this->assertEquals('04', $blockMock->getExpirationDatePart('month'));
167
- $this->assertEquals('16', $blockMock->getExpirationDatePart('year'));
168
- }
169
-
170
- public function testGetCardHolderName()
171
- {
172
- $configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
173
- $configMock->expects($this->any())
174
- ->method('isAliasManagerEnabled')
175
- ->will($this->returnValue(false));
176
- $this->replaceByMock('model', 'ops/config', $configMock);
177
-
178
- $this->assertNull($block = $this->_block->getCardHolderName());
179
-
180
- $configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
181
- $configMock->expects($this->any())
182
- ->method('isAliasManagerEnabled')
183
- ->will($this->returnValue(true));
184
- $this->replaceByMock('model', 'ops/config', $configMock);
185
-
186
-
187
- $blockMock = $this->getBlockMock(
188
- 'ops/form', array('getStoredAliasDataForCustomer', 'getStoredAlias')
189
- );
190
- $blockMock->expects($this->any())
191
- ->method('getStoredAliasDataForCustomer')
192
- ->will($this->returnValue('Hubertus von Fürstenberg'));
193
-
194
- $blockMock->expects($this->any())
195
- ->method('getStoredAlias')
196
- ->will($this->returnValue('4711'));
197
- $this->assertEquals('Hubertus von Fürstenberg', $blockMock->getCardHolderName());
198
-
199
- $blockMock = $this->getBlockMock(
200
- 'ops/form', array('getStoredAliasDataForCustomer', 'getStoredAlias')
201
- );
202
- $blockMock->expects($this->once())
203
- ->method('getStoredAliasDataForCustomer')
204
- ->will($this->returnValue(null));
205
-
206
- $blockMock->expects($this->any())
207
- ->method('getStoredAlias')
208
- ->will($this->returnValue('4711'));
209
-
210
- $customerHelperMock = $this->getHelperMock('customer/data', array('isLoggedIn', 'getCustomerName'));
211
- $customerHelperMock->expects($this->any())
212
- ->method('isLoggedIn')
213
- ->will($this->returnValue(true));
214
- $customerHelperMock->expects($this->any())
215
- ->method('getCustomerName')
216
- ->will($this->returnValue('Hubertus zu Fürstenberg'));
217
- $this->replaceByMock('helper', 'customer/data', $customerHelperMock);
218
-
219
- $this->assertEquals('Hubertus zu Fürstenberg', $blockMock->getCardHolderName());
220
-
221
- $blockMock = $this->getBlockMock(
222
- 'ops/form', array('getStoredAliasDataForCustomer', 'getStoredAlias')
223
- );
224
- $blockMock->expects($this->once())
225
- ->method('getStoredAliasDataForCustomer')
226
- ->will($this->returnValue(''));
227
-
228
- $blockMock->expects($this->any())
229
- ->method('getStoredAlias')
230
- ->will($this->returnValue('4711'));
231
-
232
- $this->assertEquals('Hubertus zu Fürstenberg', $blockMock->getCardHolderName());
233
-
234
- $blockMock = $this->getBlockMock(
235
- 'ops/form', array('getStoredAliasDataForCustomer', 'getStoredAlias')
236
- );
237
- $blockMock->expects($this->once())
238
- ->method('getStoredAliasDataForCustomer')
239
- ->will($this->returnValue(null));
240
-
241
- $blockMock->expects($this->any())
242
- ->method('getStoredAlias')
243
- ->will($this->returnValue('4711'));
244
-
245
- $customerHelperMock = $this->getHelperMock('customer/data', array('isLoggedIn'));
246
- $customerHelperMock->expects($this->any())
247
- ->method('isLoggedIn')
248
- ->will($this->returnValue(false));
249
- $this->replaceByMock('helper', 'customer/data', $customerHelperMock);
250
-
251
- $this->assertNull($blockMock->getCardHolderName());
252
-
253
-
254
- }
255
-
256
- public function testGetStoredAliasBrandWithInlineBrand()
257
- {
258
- $blockMock = $this->getBlockMock(
259
- 'ops/form', array('getStoredAliasForCustomer')
260
- );
261
- $blockMock->expects($this->any())
262
- ->method('getStoredAliasForCustomer')
263
- ->will(
264
- $this->returnValue(
265
- array(
266
- 'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
267
- 'brand' => 'VISA'
268
- )
269
- )
270
- );
271
-
272
- $modelMock = $this->getModelMock(
273
- 'ops/config', array('getInlinePaymentCcTypes')
274
- );
275
- $modelMock->expects($this->any())
276
- ->method('getInlinePaymentCcTypes')
277
- ->will(
278
- $this->returnValue(
279
- array(
280
- 'VISA'
281
- )
282
- )
283
- );
284
-
285
- $this->assertEquals('VISA', $blockMock->getStoredAliasBrand());
286
- }
287
-
288
-
289
- public function testGetStoredAliasBrandWithNonInlineBrand()
290
- {
291
- $blockMock = $this->getBlockMock(
292
- 'ops/form', array('getStoredAliasForCustomer')
293
- );
294
- $blockMock->expects($this->any())
295
- ->method('getStoredAliasForCustomer')
296
- ->will(
297
- $this->returnValue(
298
- array(
299
- 'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
300
- 'brand' => 'VISA'
301
- )
302
- )
303
- );
304
-
305
- $modelMock = $this->getModelMock(
306
- 'ops/config', array('getInlinePaymentCcTypes')
307
- );
308
- $modelMock->expects($this->any())
309
- ->method('getInlinePaymentCcTypes')
310
- ->will(
311
- $this->returnValue(
312
- array(
313
- 'FOO'
314
- )
315
- )
316
- );
317
-
318
- $this->replaceByMock('model', 'ops/config', $modelMock);
319
-
320
- $this->assertEquals('', $blockMock->getStoredAliasBrand());
321
- }
322
-
323
- public function testGetStoredAlias()
324
- {
325
- $blockMock = $this->getBlockMock(
326
- 'ops/form', array('getStoredAliasForCustomer')
327
- );
328
- $blockMock->expects($this->once())
329
- ->method('getStoredAliasForCustomer')
330
- ->will(
331
- $this->returnValue(
332
- array(
333
- 'alias' => '4711',
334
- 'brand' => 'VISA'
335
- )
336
- )
337
- );
338
-
339
-
340
- $this->assertEquals('4711', $blockMock->getStoredAlias());
341
- }
342
-
343
  public function testIsUserRegistering()
344
  {
345
  $dataHelperMock = $this->getHelperMock('ops/data', array('checkIfUserIsRegistering'));
@@ -351,8 +22,7 @@ class Netresearch_OPS_Test_Block_FormTest
351
  $block = new Netresearch_OPS_Block_Form();
352
  $this->assertFalse($block->isUserRegistering());
353
  }
354
-
355
-
356
  public function testIsUserNotRegistering()
357
  {
358
  $dataHelperMock = $this->getHelperMock('ops/data', array('checkIfUserIsNotRegistering'));
@@ -365,52 +35,6 @@ class Netresearch_OPS_Test_Block_FormTest
365
  $this->assertFalse($block->isUserNotRegistering());
366
  }
367
 
368
- public function testIsAliasInfoBlockEnabled()
369
- {
370
- $configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
371
- $configMock->expects($this->any())
372
- ->method('isAliasPMEnabled')
373
- ->will($this->returnValue(false));
374
- $configMock->expects($this->any())
375
- ->method('isAliasInfoBlockEnabled')
376
- ->will($this->returnValue(false));
377
- $this->replaceByMock('model', 'ops/config', $configMock);
378
-
379
- $this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form')->isAliasInfoBlockEnabled());
380
-
381
- $configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
382
- $configMock->expects($this->any())
383
- ->method('isAliasPMEnabled')
384
- ->will($this->returnValue(false));
385
- $configMock->expects($this->any())
386
- ->method('isAliasInfoBlockEnabled')
387
- ->will($this->returnValue(true));
388
- $this->replaceByMock('model', 'ops/config', $configMock);
389
-
390
- $this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form')->isAliasInfoBlockEnabled());
391
-
392
- $configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
393
- $configMock->expects($this->any())
394
- ->method('isAliasPMEnabled')
395
- ->will($this->returnValue(true));
396
- $configMock->expects($this->any())
397
- ->method('isAliasInfoBlockEnabled')
398
- ->will($this->returnValue(false));
399
- $this->replaceByMock('model', 'ops/config', $configMock);
400
-
401
- $this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form')->isAliasInfoBlockEnabled());
402
-
403
- $configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
404
- $configMock->expects($this->any())
405
- ->method('isAliasPMEnabled')
406
- ->will($this->returnValue(true));
407
- $configMock->expects($this->any())
408
- ->method('isAliasInfoBlockEnabled')
409
- ->will($this->returnValue(true));
410
- $this->replaceByMock('model', 'ops/config', $configMock);
411
-
412
- $this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form')->isAliasInfoBlockEnabled());
413
- }
414
 
415
  public function testGetPmLogo()
416
  {
@@ -422,7 +46,7 @@ class Netresearch_OPS_Test_Block_FormTest
422
  $quoteMock = Mage::getModel('sales/quote');
423
  $quoteMock->setStoreId(0);
424
  $sessionMock = $this->getModelMockBuilder('checkout/session')
425
- ->disableOriginalConstructor() // This one removes session_start and other methods usage
426
  ->setMethods(array('getQuote'))
427
  ->getMock();
428
  $sessionMock->expects($this->any())
@@ -497,8 +121,13 @@ class Netresearch_OPS_Test_Block_FormTest
497
  ->method('getQuote')
498
  ->will($this->returnValue($quote));
499
  $blockMock->setConfig($configMock);
500
- $this->assertEquals(Mage::helper('core/data')->jsonEncode(array(
501
- 'billing:firstname' => 50, 'billing:lastname' => 50, 'billing:postcode' => 10, 'shipping:postcode' => 10
502
- )), $blockMock->getFrontendValidators());
 
 
 
 
 
503
  }
504
  }
1
  <?php
2
+
3
  class Netresearch_OPS_Test_Block_FormTest
4
  extends EcomDev_PHPUnit_Test_Case_Controller
5
  {
11
  $this->_block = Mage::app()->getLayout()->getBlockSingleton('ops/form');
12
  }
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  public function testIsUserRegistering()
15
  {
16
  $dataHelperMock = $this->getHelperMock('ops/data', array('checkIfUserIsRegistering'));
22
  $block = new Netresearch_OPS_Block_Form();
23
  $this->assertFalse($block->isUserRegistering());
24
  }
25
+
 
26
  public function testIsUserNotRegistering()
27
  {
28
  $dataHelperMock = $this->getHelperMock('ops/data', array('checkIfUserIsNotRegistering'));
35
  $this->assertFalse($block->isUserNotRegistering());
36
  }
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  public function testGetPmLogo()
40
  {
46
  $quoteMock = Mage::getModel('sales/quote');
47
  $quoteMock->setStoreId(0);
48
  $sessionMock = $this->getModelMockBuilder('checkout/session')
49
+ ->disableOriginalConstructor()// This one removes session_start and other methods usage
50
  ->setMethods(array('getQuote'))
51
  ->getMock();
52
  $sessionMock->expects($this->any())
121
  ->method('getQuote')
122
  ->will($this->returnValue($quote));
123
  $blockMock->setConfig($configMock);
124
+ $this->assertEquals(
125
+ Mage::helper('core/data')->jsonEncode(
126
+ array(
127
+ 'billing:firstname' => 50, 'billing:lastname' => 50, 'billing:postcode' => 10,
128
+ 'shipping:postcode' => 10
129
+ )
130
+ ), $blockMock->getFrontendValidators()
131
+ );
132
  }
133
  }
app/code/community/Netresearch/OPS/Test/Block/FrauddetectionTest.php CHANGED
@@ -9,11 +9,18 @@ class Netresearch_OPS_Test_Block_FrauddetectionTest
9
  $block = Mage::app()->getLayout()->getBlockSingleton('ops/frauddetection');
10
  $this->assertEquals(null, $block->toHtml());
11
 
12
- $modelMock = $this->getModelMock('ops/config', array('isTrackingCodeActivated'));
13
- $modelMock->expects($this->once())
14
- ->method('isTrackingCodeActivated')
15
- ->will($this->returnValue(true));
16
- $this->replaceByMock('model', 'ops/config', $modelMock);
 
 
 
 
 
 
 
17
  // for some reason the html is not rendered in the tests
18
  $this->assertNotNull($block->toHtml());
19
  }
@@ -28,13 +35,18 @@ class Netresearch_OPS_Test_Block_FrauddetectionTest
28
 
29
  public function testGetTrackingSid()
30
  {
 
 
 
 
 
31
  $block = Mage::app()->getLayout()->getBlockSingleton('ops/frauddetection');
32
- $modelMock = $this->getModelMock('customer/session', array('getSessionId'));
33
  $modelMock->expects($this->once())
34
- ->method('getSessionId')
35
- ->will($this->returnValue('123456'));
36
- $this->replaceByMock('model', 'customer/session', $modelMock);
37
- $this->assertEquals(md5('123456'), $block->getTrackingSid());
38
  }
39
 
40
  }
9
  $block = Mage::app()->getLayout()->getBlockSingleton('ops/frauddetection');
10
  $this->assertEquals(null, $block->toHtml());
11
 
12
+ $configMock = $this->getModelMock('ops/config', array('getDeviceFingerPrinting'));
13
+ $configMock->expects($this->once())
14
+ ->method('getDeviceFingerPrinting')
15
+ ->will($this->returnValue(true));
16
+ $this->replaceByMock('model', 'ops/config', $configMock);
17
+
18
+ $sessionMock = $this->getModelMock('customer/session', array('getData'));
19
+ $sessionMock->expects($this->once())
20
+ ->method('getData')
21
+ ->with(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY)
22
+ ->will($this->returnValue(true));
23
+ $this->replaceByMock('singleton', 'customer/session', $sessionMock);
24
  // for some reason the html is not rendered in the tests
25
  $this->assertNotNull($block->toHtml());
26
  }
35
 
36
  public function testGetTrackingSid()
37
  {
38
+ $quote = Mage::getModel('sales/quote');
39
+ $quote->setReservedOrderId('123456');
40
+ $quote->getStoreId(0);
41
+ Mage::app(0)->getStore(0)->setConfig(Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH . 'PSPID', 'abc');
42
+
43
  $block = Mage::app()->getLayout()->getBlockSingleton('ops/frauddetection');
44
+ $modelMock = $this->getModelMock('checkout/type_onepage', array('getQuote'));
45
  $modelMock->expects($this->once())
46
+ ->method('getQuote')
47
+ ->will($this->returnValue($quote));
48
+ $this->replaceByMock('singleton', 'checkout/type_onepage', $modelMock);
49
+ $this->assertEquals(md5(Mage::getModel('ops/config')->getPSPID() . '#123456'), $block->getTrackingSid());
50
  }
51
 
52
  }
app/code/community/Netresearch/OPS/Test/Block/Info/FlexTest.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * FlexTest.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Block_Info_FlexTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+ public function testGetFlexTitle()
36
+ {
37
+ $payment = Mage::getModel('sales/order_payment');
38
+ $payment->setAdditionalInformation(Netresearch_OPS_Model_Payment_Flex::INFO_KEY_TITLE, 'FLEX');
39
+
40
+ /** @var Netresearch_OPS_Block_Info_Flex $block */
41
+ $block = Mage::app()->getLayout()->createBlock('ops/info_flex');
42
+ $method = Mage::getModel('ops/payment_flex');
43
+ $method->setData('info_instance', $payment);
44
+ $payment->setMethodInstance($method);
45
+ $block->setInfo($payment);
46
+
47
+ $this->assertEquals('FLEX', $block->getFlexTitle());
48
+ }
49
+
50
+ }
app/code/community/Netresearch/OPS/Test/Controller/AliasControllerTest.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Netresearch_OPS_Test_Controller_AliasControllerTest
3
+ extends EcomDev_PHPUnit_Test_Case_Controller
4
+ {
5
+
6
+ public function testAcceptAliasAction()
7
+ {
8
+ $quote = Mage::getModel('sales/quote');
9
+ $payment = Mage::getModel('sales/quote_payment');
10
+ $quote->setPayment($payment);
11
+ $sessionMock = $this->getModelMock('checkout/session', array('getQuote'));
12
+ $sessionMock->expects($this->any())
13
+ ->method('getQuote')
14
+ ->will($this->returnValue($quote));
15
+ $this->replaceByMock('singleton', 'checkout/session', $sessionMock);
16
+ $aliasHelperMock = $this->getHelperMock('ops/alias', array('saveAlias', 'setAliasToPayment'));
17
+ $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
18
+ $routeToDispatch = 'ops/alias/accept';
19
+ $params = array('Alias_AliasId' => '4711');
20
+ $this->dispatch($routeToDispatch, $params);
21
+ $result = $this->getResponse()->getOutputBody();
22
+ $this->assertEquals($result, "<script type='application/javascript'>window.onload = function() { top.document.fire('alias:success', '4711'); };</script>");
23
+
24
+ $params = array('Alias_AliasId' => '4711', 'Card_CVC' => '123');
25
+ $this->dispatch($routeToDispatch, $params);
26
+ $result = $this->getResponse()->getOutputBody();
27
+ $this->assertEquals($result, "<script type='application/javascript'>window.onload = function() { top.document.fire('alias:success', '4711'); };</script>");
28
+
29
+ }
30
+
31
+ /**
32
+ * @loadFixture orders.yaml
33
+ */
34
+ public function testGenerateHashAction()
35
+ {
36
+
37
+ $fakeQuote = Mage::getModel('sales/order')->load(11);
38
+ $quoteMock = $this->getModelMock('sales/quote', array('load', 'save'));
39
+ $quoteMock->expects($this->any())
40
+ ->method('load')
41
+ ->will($this->returnValue($fakeQuote));
42
+ $this->replaceByMock('model', 'sales/quote', $quoteMock);
43
+ $params = array(
44
+ 'alias' => 4711,
45
+ 'storeId' => 1
46
+ );
47
+
48
+ $configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExceptionUrl'));
49
+ $configHelperMock->expects($this->any())
50
+ ->method('getAliasAcceptUrl')
51
+ ->with(1)
52
+ ->will($this->returnValue(1));
53
+ $configHelperMock->expects($this->any())
54
+ ->method('getAliasExceptionUrl')
55
+ ->with(1)
56
+ ->will($this->returnValue(1));
57
+ $this->replaceByMock('model', 'ops/config', $configHelperMock);
58
+
59
+ $this->dispatch('ops/alias/generateHash', $params);
60
+ $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
61
+ $this->assertArrayHasKey('hash', $result);
62
+
63
+ $params = array(
64
+ 'alias' => 4712,
65
+ 'storeId' => 0
66
+ );
67
+
68
+ $configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExceptionUrl'));
69
+ $configHelperMock->expects($this->any())
70
+ ->method('getAliasAcceptUrl')
71
+ ->with(0)
72
+ ->will($this->returnValue(1));
73
+ $configHelperMock->expects($this->any())
74
+ ->method('getAliasExceptionUrl')
75
+ ->with(0)
76
+ ->will($this->returnValue(1));
77
+ $this->replaceByMock('model', 'ops/config', $configHelperMock);
78
+
79
+ $this->dispatch('ops/alias/generateHash', $params);
80
+ $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
81
+ $this->assertArrayHasKey('hash', $result);
82
+
83
+ $params = array(
84
+ 'alias' => 4713,
85
+ 'storeId' => 1,
86
+ 'isAdmin' => 1,
87
+ 'brand' => 'visa'
88
+ );
89
+
90
+ $configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExecptionUrl'));
91
+ $configHelperMock->expects($this->any())
92
+ ->method('getAliasAcceptUrl')
93
+ ->with(0)
94
+ ->will($this->returnValue(1));
95
+ $configHelperMock->expects($this->any())
96
+ ->method('getAliasExceptionUrl')
97
+ ->with(0)
98
+ ->will($this->returnValue(1));
99
+ $this->replaceByMock('model', 'ops/config', $configHelperMock);
100
+
101
+ $this->dispatch('ops/alias/generateHash', $params);
102
+ $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
103
+ $this->assertArrayHasKey('hash', $result);
104
+
105
+ }
106
+ }
app/code/community/Netresearch/OPS/Test/Controller/AliasControllerTest/fixtures/orders.yaml ADDED
@@ -0,0 +1,595 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 11
4
+ increment_id: 100000011
5
+ shipping_address_id: 42
6
+ base_grand_total: 119.00
7
+ grand_total: 119.00
8
+ currency: 'EUR'
9
+ customer_gender: 1
10
+ shipping_method: 'flatrate_flatrate'
11
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
12
+ state: 'pending_payment'
13
+ status: 'pending_payment'
14
+ quote_id: 23
15
+
16
+ - entity_id: 12
17
+ increment_id: 100000012
18
+ shipping_address_id: 42
19
+ base_grand_total: 119.00
20
+ grand_total: 119.00
21
+ currency: 'EUR'
22
+ customer_gender: 1
23
+ shipping_method: 'flatrate_flatrate'
24
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
25
+ state: 'pending_payment'
26
+ status: 'pending_payment'
27
+ quote_id: 24
28
+
29
+ - entity_id: 13
30
+ increment_id: 100000013
31
+ shipping_address_id: 43
32
+ base_grand_total: 177.55
33
+ grand_total: 177.55
34
+ currency: 'EUR'
35
+ customer_gender: 1
36
+ shipping_method: 'flatrate_flatrate'
37
+ customer_email: 'willi.usa.customer@trash-mail.com'
38
+ state: 'processing'
39
+ status: 'processing'
40
+ quote_id: 25
41
+
42
+ - entity_id: 14
43
+ increment_id: 100000014
44
+ shipping_address_id: 43
45
+ base_grand_total: 177.55
46
+ grand_total: 177.55
47
+ currency: 'EUR'
48
+ customer_gender: 1
49
+ shipping_method: 'flatrate_flatrate'
50
+ customer_email: 'willi.usa.customer@trash-mail.com'
51
+ state: 'pending_payment'
52
+ status: 'pending_payment'
53
+ quote_id: 26
54
+
55
+ - entity_id: 15
56
+ increment_id: 100000015
57
+ shipping_address_id: 43
58
+ base_grand_total: 177.55
59
+ grand_total: 200.00
60
+ currency: '$'
61
+ customer_gender: 1
62
+ shipping_method: 'flatrate_flatrate'
63
+ customer_email: 'willi.usa.customer@trash-mail.com'
64
+ state: 'pending_payment'
65
+ status: 'pending_payment'
66
+ quote_id: 27
67
+
68
+ - entity_id: 16
69
+ increment_id: 100000016
70
+ shipping_address_id: 43
71
+ base_grand_total: 19.99
72
+ grand_total: 19.99
73
+ currency: 'EUR'
74
+ customer_gender: 1
75
+ shipping_method: 'flatrate_flatrate'
76
+ customer_email: 'willi.usa.customer@trash-mail.com'
77
+ state: 'pending_payment'
78
+ status: 'pending_payment'
79
+ quote_id: 28
80
+
81
+ - entity_id: 17
82
+ increment_id: 100000017
83
+ shipping_address_id: 43
84
+ base_grand_total: 19.99
85
+ grand_total: 19.99
86
+ currency: 'EUR'
87
+ customer_gender: 1
88
+ shipping_method: 'flatrate_flatrate'
89
+ customer_email: 'willi.usa.customer@trash-mail.com'
90
+ state: 'pending_payment'
91
+ status: 'pending_payment'
92
+ quote_id: 29
93
+
94
+ - entity_id: 18
95
+ increment_id: 100000018
96
+ shipping_address_id: 43
97
+ base_grand_total: 19.99
98
+ grand_total: 19.99
99
+ currency: 'EUR'
100
+ customer_gender: 1
101
+ shipping_method: 'flatrate_flatrate'
102
+ customer_email: 'willi.usa.customer@trash-mail.com'
103
+ state: 'pending_payment'
104
+ status: 'pending_payment'
105
+ quote_id: 30
106
+
107
+ - entity_id: 19
108
+ increment_id: 100000019
109
+ shipping_address_id: 50
110
+ base_grand_total: 19.99
111
+ grand_total: 19.99
112
+ currency: 'EUR'
113
+ customer_gender: 1
114
+ shipping_method: 'flatrate_flatrate'
115
+ customer_email: 'willi.usa.customer@trash-mail.com'
116
+ state: 'pending_payment'
117
+ status: 'pending_payment'
118
+ quote_id: 43
119
+
120
+ - entity_id: 20
121
+ increment_id: 100000020
122
+ shipping_address_id: 42
123
+ base_grand_total: 119.00
124
+ grand_total: 119.00
125
+ currency: 'EUR'
126
+ customer_gender: 1
127
+ shipping_method: 'flatrate_flatrate'
128
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
129
+ state: 'pending_payment'
130
+ status: 'pending_payment'
131
+ quote_id: 42#
132
+
133
+ - entity_id: 21
134
+ increment_id: 100000021
135
+ shipping_address_id: 42
136
+ base_grand_total: 119.00
137
+ grand_total: 119.00
138
+ currency: 'EUR'
139
+ customer_gender: 1
140
+ shipping_method: 'flatrate_flatrate'
141
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
142
+ state: 'pending_payment'
143
+ status: 'pending_payment'
144
+
145
+ - entity_id: 22
146
+ increment_id: 100000022
147
+ shipping_address_id: 42
148
+ base_grand_total: 119.00
149
+ grand_total: 119.00
150
+ currency: 'EUR'
151
+ customer_gender: 1
152
+ shipping_method: 'flatrate_flatrate'
153
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
154
+ state: 'pending_payment'
155
+ status: 'pending_payment'
156
+
157
+ - entity_id: 23
158
+ increment_id: 100000023
159
+ store_id: 1
160
+ shipping_address_id: 42
161
+ base_grand_total: 119.00
162
+ grand_total: 119.00
163
+ currency: 'EUR'
164
+ customer_gender: 1
165
+ shipping_method: 'flatrate_flatrate'
166
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
167
+ state: 'pending_payment'
168
+ status: 'pending_payment'
169
+
170
+ - entity_id: 24
171
+ increment_id: 100000024
172
+ store_id: 1
173
+ shipping_address_id: 46
174
+ base_grand_total: 119.00
175
+ grand_total: 119.00
176
+ currency: 'EUR'
177
+ customer_gender: 1
178
+ shipping_method: 'flatrate_flatrate'
179
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
180
+ state: 'pending_payment'
181
+ status: 'pending_payment'
182
+
183
+ - entity_id: 24
184
+ increment_id: 100000024
185
+ store_id: 1
186
+ shipping_address_id: 42
187
+ base_grand_total: 119.00
188
+ grand_total: 119.00
189
+ currency: 'EUR'
190
+ customer_gender: 1
191
+ shipping_method: 'flatrate_flatrate'
192
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
193
+ state: 'pending_payment'
194
+ status: 'pending_payment'
195
+
196
+ - entity_id: 25
197
+ increment_id: 100000025
198
+ store_id: 1
199
+ shipping_address_id: 42
200
+ base_grand_total: 119.00
201
+ grand_total: 119.00
202
+ currency: 'EUR'
203
+ customer_gender: 1
204
+ shipping_method: 'flatrate_flatrate'
205
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
206
+ state: 'pending_payment'
207
+ status: 'pending_payment'
208
+
209
+ - entity_id: 26
210
+ increment_id: 100000026
211
+ store_id: 1
212
+ shipping_address_id: 42
213
+ base_grand_total: 119.00
214
+ grand_total: 119.00
215
+ currency: 'EUR'
216
+ customer_gender: 1
217
+ shipping_method: 'flatrate_flatrate'
218
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
219
+ state: 'pending_payment'
220
+ status: 'pending_payment'
221
+
222
+ - entity_id: 27
223
+ increment_id: 100000027
224
+ store_id: 1
225
+ shipping_address_id: 42
226
+ base_grand_total: 119.00
227
+ grand_total: 119.00
228
+ currency: 'EUR'
229
+ customer_gender: 1
230
+ shipping_method: 'flatrate_flatrate'
231
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
232
+ state: 'pending_payment'
233
+ status: 'pending_payment'
234
+
235
+ - entity_id: 28
236
+ increment_id: 100000028
237
+ store_id: 1
238
+ shipping_address_id: 42
239
+ base_grand_total: 119.00
240
+ grand_total: 119.00
241
+ currency: 'EUR'
242
+ customer_gender: 1
243
+ shipping_method: 'flatrate_flatrate'
244
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
245
+ state: 'pending_payment'
246
+ status: 'pending_payment'
247
+
248
+ - entity_id: 29
249
+ increment_id: 100000029
250
+ store_id: 1
251
+ shipping_address_id: 42
252
+ base_grand_total: 119.00
253
+ grand_total: 119.00
254
+ currency: 'EUR'
255
+ customer_gender: 1
256
+ shipping_method: 'flatrate_flatrate'
257
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
258
+ state: 'pending_payment'
259
+ status: 'pending_payment'
260
+
261
+ - entity_id: 30
262
+ increment_id: 100000030
263
+ store_id: 1
264
+ shipping_address_id: 42
265
+ base_grand_total: 119.00
266
+ grand_total: 119.00
267
+ currency: 'EUR'
268
+ customer_gender: 1
269
+ shipping_method: 'flatrate_flatrate'
270
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
271
+ state: 'pending_payment'
272
+ status: 'pending_payment'
273
+
274
+ sales/quote:
275
+ - entity_id: 1
276
+ base_grand_total: 119.00
277
+ grand_total: 119.00
278
+ currency: 'EUR'
279
+ customer_gender: 1
280
+ shipping_method: 'flatrate_flatrate'
281
+
282
+ - entity_id: 2
283
+ base_grand_total: 119.00
284
+ grand_total: 200.00
285
+ currency: '$'
286
+ customer_gender: 1
287
+ shipping_method: 'flatrate_flatrate'
288
+
289
+ - entity_id: 10
290
+ store_id: 0
291
+ customer_id: 23
292
+ created_at: '2013-05-14 14:45:00'
293
+
294
+ - entity_id: 11
295
+ store_id: 0
296
+ created_at: '2013-05-14 14:45:00'
297
+
298
+ - entity_id: 23
299
+ store_id: 0
300
+ created_at: '2013-05-14 14:45:00'
301
+
302
+ - entity_id: 12
303
+ store_id: 0
304
+ created_at: '2013-05-14 14:45:00'
305
+
306
+ sales/quote_payment:
307
+ - payment_id: 1
308
+ quote_id: 10
309
+ updated_at: '1970-01-01'
310
+ method: 'ops_cc'
311
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
312
+
313
+ - payment_id: 2
314
+ quote_id: 11
315
+ updated_at: '1970-01-01'
316
+ method: 'ops_cc'
317
+ quote_id: 11
318
+
319
+ - payment_id: 3
320
+ quote_id: 10
321
+ updated_at: '1970-01-01'
322
+ method: 'ops_cc'
323
+ additional_information: a:7:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:3:"cvc";s:3:"123";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
324
+
325
+ - payment_id: 4
326
+ quote_id: 12
327
+ updated_at: '1970-01-01'
328
+ method: 'ops_paypal'
329
+ additional_information: a:7:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:3:"cvc";s:3:"123";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
330
+
331
+ sales/order_payment:
332
+ - entity_id: 1
333
+ parent_id: 11
334
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
335
+ method: 'ops_bankTransfer'
336
+
337
+ - entity_id: 2
338
+ parent_id: 12
339
+ additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:6:"status";s:1:"5";}
340
+
341
+ - entity_id: 3
342
+ parent_id: 13
343
+ additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:6:"status";s:1:"0";}
344
+
345
+ - entity_id: 4
346
+ parent_id: 14
347
+ additional_information: a:2:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";}
348
+
349
+ - entity_id: 5
350
+ parent_id: 15
351
+ additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFD";}
352
+ method: 'ops_cc'
353
+
354
+ - entity_id: 6
355
+ parent_id: 16
356
+ additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFS";}
357
+
358
+ - entity_id: 7
359
+ parent_id: 17
360
+ additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFS";s:9:"canRefund";b:0;}
361
+
362
+ - entity_id: 8
363
+ parent_id: 18
364
+ additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFD";s:9:"canRefund";b:1;}
365
+
366
+ - entity_id: 9
367
+ parent_id: 19
368
+ method: 'ops_openInvoiceDe'
369
+
370
+ - entity_id: 11
371
+ parent_id: 20
372
+ additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
373
+
374
+ - entity_id: 12
375
+ parent_id: 21
376
+ additional_information: a:4:{s:2:"PM";s:16:"Direct Debits DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
377
+ method: 'ops_directDebit'
378
+
379
+ - entity_id: 13
380
+ parent_id: 22
381
+ additional_information: a:4:{s:2:"PM";s:16:"Direct Debits NL";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
382
+
383
+ - entity_id: 14
384
+ parent_id: 23
385
+ additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
386
+
387
+ - entity_id: 42
388
+ parent_id: 20
389
+
390
+ - entity_id: 15
391
+ parent_id: 24
392
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
393
+ method: 'ops_cc'
394
+
395
+ - entity_id: 16
396
+ parent_id: 25
397
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
398
+ method: 'ops_cc'
399
+
400
+ - entity_id: 17
401
+ parent_id: 26
402
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
403
+ method: 'ops_paypal'
404
+
405
+ - entity_id: 18
406
+ parent_id: 27
407
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
408
+ method: 'ops_kwixoApresReception'
409
+
410
+ - entity_id: 19
411
+ parent_id: 28
412
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
413
+ method: 'ops_kwixoComptant'
414
+
415
+ - entity_id: 20
416
+ parent_id: 29
417
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
418
+ method: 'ops_kwixoCredit'
419
+
420
+ - entity_id: 21
421
+ parent_id: 30
422
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
423
+ method: 'checkmo'
424
+
425
+ sales/shipment:
426
+ - entity_id: 1
427
+ increment_id: 100000077
428
+ order_id: 11
429
+ shipping_address_id: 42
430
+
431
+ - entity_id: 2
432
+ increment_id: 100000078
433
+ order_id: 12
434
+ shipping_address_id: 43
435
+
436
+ sales/order_address:
437
+ - entity_id: 42
438
+ parent_id: 11
439
+ address_type: 'billing'
440
+ firstname: 'Hubertus'
441
+ postcode: '04229'
442
+ lastname: 'Fürstenberg'
443
+ street: 'An der Tabaksmühle 3a'
444
+ city: 'Leipzig'
445
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
446
+ country_id: 'DE'
447
+ prefix: 'Prof. Dr.'
448
+ middlename: 'von'
449
+ suffix: 'MdL'
450
+ company: ''
451
+ fax: 12345678
452
+
453
+ - entity_id: 43
454
+ parent_id: 11
455
+ address_type: 'shipping'
456
+ firstname: 'Hubertus'
457
+ postcode: '04229'
458
+ lastname: 'Fürstenberg'
459
+ street: 'An der Tabaksmühle 3a'
460
+ city: 'Leipzig'
461
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
462
+ country_id: 'DE'
463
+ prefix: 'Prof. Dr.'
464
+ middlename: 'von'
465
+ suffix: 'MdL'
466
+ company: ''
467
+ same_as_billing: 1
468
+
469
+ - entity_id: 44
470
+ parent_id: 12
471
+ address_type: 'billing'
472
+ firstname: 'Hubertus'
473
+ postcode: '04229'
474
+ lastname: 'Fürstenberg'
475
+ street: 'An der Tabaksmühle 3a'
476
+ city: 'Leipzig'
477
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
478
+ country_id: 'DE'
479
+ prefix: 'Prof. Dr.'
480
+ middlename: 'von'
481
+ suffix: 'MdL'
482
+ company: ''
483
+
484
+ - entity_id: 45
485
+ parent_id: 12
486
+ address_type: 'shipping'
487
+ firstname: 'Hubertus'
488
+ postcode: '04227'
489
+ lastname: 'Fürstenberg'
490
+ street: 'An der Tabaksmühle 3a'
491
+ city: 'Leipzig'
492
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
493
+ country_id: 'DE'
494
+ prefix: 'Prof. Dr.'
495
+ middlename: 'von'
496
+ suffix: 'MdL'
497
+ company: ''
498
+ same_as_billing: 1
499
+
500
+ - entity_id: 46
501
+ parent_id: 24
502
+ address_type: 'shipping'
503
+ firstname: 'Hubertus'
504
+ postcode: '04227'
505
+ lastname: 'Fürstenberg'
506
+ street: '44 rue Parmentier'
507
+ city: 'Leipzig'
508
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
509
+ country_id: 'DE'
510
+ prefix: 'Prof. Dr.'
511
+ middlename: 'von'
512
+ suffix: 'MdL'
513
+ company: ''
514
+ same_as_billing: 1
515
+
516
+ - entity_id: 47
517
+ parent_id: 27
518
+ address_type: 'billing'
519
+ firstname: 'Hubertus'
520
+ postcode: '04227'
521
+ lastname: 'Fürstenberg'
522
+ street: '44 rue Parmentier'
523
+ city: 'Leipzig'
524
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
525
+ country_id: 'DE'
526
+ prefix: 'Prof. Dr.'
527
+ middlename: 'von'
528
+ suffix: 'MdL'
529
+ company: ''
530
+ same_as_shipping: 1
531
+
532
+ - entity_id: 48
533
+ parent_id: 28
534
+ address_type: 'billing'
535
+ firstname: 'Hubertus'
536
+ postcode: '04227'
537
+ lastname: 'Fürstenberg'
538
+ street: '44 rue Parmentier'
539
+ city: 'Leipzig'
540
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
541
+ country_id: 'DE'
542
+ prefix: 'Prof. Dr.'
543
+ middlename: 'von'
544
+ suffix: 'MdL'
545
+ company: ''
546
+
547
+ - entity_id: 49
548
+ parent_id: 19
549
+ address_type: 'billing'
550
+ firstname: 'Hubertus'
551
+ postcode: '04227'
552
+ lastname: 'Fürstenberg'
553
+ street: '44 rue Parmentier'
554
+ city: 'Leipzig'
555
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
556
+ country_id: 'DE'
557
+ prefix: 'Prof. Dr.'
558
+ middlename: 'von'
559
+ suffix: 'MdL'
560
+ company: ''
561
+
562
+ - entity_id: 50
563
+ parent_id: 19
564
+ address_type: 'shipping'
565
+ firstname: 'Hubertus'
566
+ postcode: '04227'
567
+ lastname: 'Fürstenberg'
568
+ street: '44 rue Parmentier'
569
+ city: 'Leipzig'
570
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
571
+ country_id: 'DE'
572
+ prefix: 'Prof. Dr.'
573
+ middlename: 'von'
574
+ suffix: 'MdL'
575
+ company: ''
576
+
577
+ sales/order_item:
578
+ - item_id: 11
579
+ order_id: 11
580
+ qty_ordered: 2.0000
581
+ qty_shipped: 2.0000
582
+ sku: 4711
583
+ name: 'some great test item'
584
+ price: 19.99
585
+ tax_amount: 1.99
586
+
587
+ - item_id: 12
588
+ order_id: 11
589
+ qty_ordered: 2.0000
590
+ qty_shipped: 2.0000
591
+ sku: 4711
592
+ name: 'some great test item 2'
593
+ price: 19.99
594
+ tax_amount: 1.99
595
+
app/code/community/Netresearch/OPS/Test/Controller/ApiControllerTest.php CHANGED
@@ -156,7 +156,7 @@ class Netresearch_OPS_Test_Controller_ApiControllerTest
156
  $this->replaceByMock('model', 'core/store', $modelMock);
157
  $this->dispatch('ops/api/postBack', $this->getRequestParams());
158
  $this->assertRedirectTo(
159
- 'ops/api/postBack', array('_query' => $this->getRequestParams(), '_store' => 1)
160
  );
161
 
162
 
156
  $this->replaceByMock('model', 'core/store', $modelMock);
157
  $this->dispatch('ops/api/postBack', $this->getRequestParams());
158
  $this->assertRedirectTo(
159
+ 'ops/payment/accept', array('_query' => $this->getRequestParams(), '_store' => 1)
160
  );
161
 
162
 
app/code/community/Netresearch/OPS/Test/Controller/DeviceControllerTest.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * DeviceControllerTest.php
24
+ *
25
+ * @category ${CATEGORY}
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Controller_DeviceControllerTest extends EcomDev_PHPUnit_Test_Case_Controller
34
+ {
35
+ public function testToggleConsentAction()
36
+ {
37
+
38
+ $params = array('consent' => true, '_store' => 1);
39
+ $this->dispatch('ops/device/toggleConsent', $params);
40
+ $this->assertResponseBodyJson();
41
+ $this->assertResponseBodyJsonMatch(array('consent' => false));
42
+
43
+ Mage::app()->getStore(1)->setConfig(Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'device_fingerprinting', 1);
44
+ $this->dispatch('ops/device/toggleConsent', $params);
45
+ $this->assertResponseBodyJson();
46
+ $this->assertResponseBodyJsonMatch(array('consent' => true));
47
+ }
48
+
49
+ public function testConsentAction()
50
+ {
51
+ $this->dispatch('ops/device/consent');
52
+ $this->assertResponseBodyJson();
53
+ $this->assertResponseBodyJsonMatch(array('consent' => false));
54
+
55
+ $params = array('consent' => true, '_store' => 1);
56
+ Mage::app()->getStore(1)->setConfig(Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'device_fingerprinting', 1);
57
+ $this->dispatch('ops/device/toggleConsent', $params);
58
+ $this->assertResponseBodyJson();
59
+ $this->assertResponseBodyJsonMatch(array('consent' => true));
60
+
61
+ $this->dispatch('ops/device/consent');
62
+ $this->assertResponseBodyJson();
63
+ $this->assertResponseBodyJsonMatch(array('consent' => true));
64
+ }
65
+
66
+ }
app/code/community/Netresearch/OPS/Test/Controller/PaymentControllerTest.php CHANGED
@@ -7,14 +7,16 @@ class Netresearch_OPS_Test_Controller_PaymentControllerTest
7
  public function setUp()
8
  {
9
  parent::setUp();
10
- $helperMock = $this->getHelperMock('ops/payment', array(
 
11
  'shaCryptValidation',
12
  'cancelOrder',
13
  'declineOrder',
14
  'handleException',
15
  'getSHAInSet',
16
  'refillCart'
17
- ));
 
18
  $helperMock->expects($this->any())
19
  ->method('shaCryptValidation')
20
  ->will($this->returnValue(true));
@@ -142,14 +144,14 @@ class Netresearch_OPS_Test_Controller_PaymentControllerTest
142
  $this->assertRedirect('checkout/cart');
143
 
144
  $params = array(
145
- 'orderID' => '#100000011',
146
  'redirect' => 'catalog'
147
  );
148
  $this->dispatch($routeToDispatch, $params);
149
  $this->assertRedirect('/');
150
 
151
  $params = array(
152
- 'orderID' => '23',
153
  'redirect' => 'catalog'
154
  );
155
  $this->dispatch($routeToDispatch, $params);
@@ -158,276 +160,6 @@ class Netresearch_OPS_Test_Controller_PaymentControllerTest
158
 
159
  }
160
 
161
-
162
- public function testAcceptAliasAction()
163
- {
164
- $quote = Mage::getModel('sales/quote');
165
- $payment = Mage::getModel('sales/quote_payment');
166
- $quote->setPayment($payment);
167
- $checkoutMock = $this->getModelMock('checkout/session', array('getQuote'));
168
- $checkoutMock->expects($this->any())
169
- ->method('getQuote')
170
- ->will($this->returnValue($quote));
171
- $this->replaceByMock('singleton', 'checkout/session', $checkoutMock);
172
- $aliasHelperMock = $this->getHelperMock('ops/alias', array('saveAlias', 'setAliasToPayment'));
173
- $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
174
- $routeToDispatch = 'ops/payment/acceptAlias';
175
- $params = array('Alias' => '4711');
176
- $this->dispatch($routeToDispatch, $params);
177
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
178
- $this->assertEquals('4711', $result['alias']);
179
- $this->assertEquals('success', $result['result']);
180
- $this->assertNull($result['CVC']);
181
-
182
- $params = array('Alias' => '4711', 'CVC' => '123');
183
- $this->dispatch($routeToDispatch, $params);
184
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
185
- $this->assertEquals('4711', $result['alias']);
186
- $this->assertEquals('success', $result['result']);
187
- $this->assertEquals('123', $result['CVC']);
188
- // $this->markTestIncomplete();
189
- }
190
-
191
- /**
192
- * @loadFixture ../../../var/fixtures/orders.yaml
193
- *
194
- * due to difficulties with loading the quote from the fixtures
195
- * this test is marked as incomplete
196
- *
197
- */
198
- public function testSaveAliasAction()
199
- {
200
- // $paymentMock = $this->getModelMock('sales/quote_payment', array('save'));
201
- // $quote = $this->getModelMock('sales/quote', array('getPayment','_beforeSave', 'save'));
202
- // $quote->expects($this->any())
203
- // ->method('getPayment')
204
- // ->will($this->returnValue($paymentMock));
205
- // $quote->setPayment($paymentMock);
206
- // Mage::getSingleton('checkout/session')->setQuote($quote);
207
- // $routeToDispatch = 'ops/payment/saveAlias';
208
- // $params = array('alias' => '4711');
209
- //
210
- // $aliasHelperMock = $this->getHelperMock('ops/alias', array('setAliasToPayment'));
211
- // $aliasHelperMock->expects($this->once())
212
- // ->method('setAliasToPayment')
213
- // ->with($paymentMock, $params, false);
214
- // $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
215
- //
216
- // $this->dispatch($routeToDispatch, $params);
217
- $this->markTestIncomplete();
218
- }
219
-
220
- /**
221
- * @loadFixture ../../../var/fixtures/orders.yaml
222
- */
223
- public function testGenerateHashAction()
224
- {
225
-
226
- $fakeQuote = Mage::getModel('sales/order')->load(11);
227
- $quoteMock = $this->getModelMock('sales/quote', array('load', 'save'));
228
- $quoteMock->expects($this->any())
229
- ->method('load')
230
- ->will($this->returnValue($fakeQuote));
231
- $this->replaceByMock('model', 'sales/quote', $quoteMock);
232
- $params = array(
233
- 'alias' => 4711,
234
- 'storeId' => 1
235
- );
236
-
237
- $configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExceptionUrl'));
238
- $configHelperMock->expects($this->any())
239
- ->method('getAliasAcceptUrl')
240
- ->with(1)
241
- ->will($this->returnValue(1));
242
- $configHelperMock->expects($this->any())
243
- ->method('getAliasExceptionUrl')
244
- ->with(1)
245
- ->will($this->returnValue(1));
246
- $this->replaceByMock('model', 'ops/config', $configHelperMock);
247
-
248
- $this->dispatch('ops/payment/generateHash', $params);
249
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
250
- $this->assertArrayHasKey('hash', $result);
251
- $this->assertArrayHasKey('alias', $result);
252
- $this->assertEquals('4711', $result['alias']);
253
-
254
- $params = array(
255
- 'alias' => 4712,
256
- 'storeId' => 0
257
- );
258
-
259
- $configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExceptionUrl'));
260
- $configHelperMock->expects($this->any())
261
- ->method('getAliasAcceptUrl')
262
- ->with(0)
263
- ->will($this->returnValue(1));
264
- $configHelperMock->expects($this->any())
265
- ->method('getAliasExceptionUrl')
266
- ->with(0)
267
- ->will($this->returnValue(1));
268
- $this->replaceByMock('model', 'ops/config', $configHelperMock);
269
-
270
- $this->dispatch('ops/payment/generateHash', $params);
271
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
272
- $this->assertArrayHasKey('hash', $result);
273
- $this->assertArrayHasKey('alias', $result);
274
- $this->assertEquals('4712', $result['alias']);
275
-
276
- $params = array(
277
- 'alias' => 4713,
278
- 'storeId' => 1,
279
- 'isAdmin' => 1,
280
- 'brand' => 'visa'
281
- );
282
-
283
- $configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExecptionUrl'));
284
- $configHelperMock->expects($this->any())
285
- ->method('getAliasAcceptUrl')
286
- ->with(0)
287
- ->will($this->returnValue(1));
288
- $configHelperMock->expects($this->any())
289
- ->method('getAliasExceptionUrl')
290
- ->with(0)
291
- ->will($this->returnValue(1));
292
- $this->replaceByMock('model', 'ops/config', $configHelperMock);
293
-
294
- $this->dispatch('ops/payment/generateHash', $params);
295
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
296
- $this->assertArrayHasKey('hash', $result);
297
- $this->assertArrayHasKey('alias', $result);
298
- $this->assertEquals('4713', $result['alias']);
299
- }
300
-
301
- /**
302
- * @loadFixture ../../../var/fixtures/orders.yaml
303
- */
304
- public function testGenerateHashWithStoredAliasButNewAliasIsUsed()
305
- {
306
- $fakeQuote = Mage::getModel('sales/order')->load(11);
307
- $quoteMock = $this->getModelMock('sales/quote', array('load', 'save'));
308
- $quoteMock->expects($this->any())
309
- ->method('load')
310
- ->will($this->returnValue($fakeQuote));
311
- $this->replaceByMock('model', 'sales/quote', $quoteMock);
312
- $params = array(
313
- 'alias' => 4711,
314
- 'storeId' => 1,
315
- 'storedAlias' => '0815',
316
- );
317
-
318
- $helperMock = $this->getHelperMock('ops/alias', array('isAliasValidForAddresses'));
319
- $helperMock->expects($this->any())
320
- ->method('isAliasValidForAddresses')
321
- ->will($this->returnValue(true));
322
- $this->replaceByMock('helper', 'ops/alias', $helperMock);
323
- $this->dispatch('ops/payment/generateHash', $params);
324
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
325
- $this->assertArrayHasKey('hash', $result);
326
- $this->assertArrayHasKey('alias', $result);
327
- $this->assertEquals('4711', $result['alias']);
328
-
329
- $helperMock = $this->getHelperMock('ops/alias', array('isAliasValidForAddresses'));
330
- $helperMock->expects($this->any())
331
- ->method('isAliasValidForAddresses')
332
- ->will($this->returnValue(false));
333
- $this->replaceByMock('helper', 'ops/alias', $helperMock);
334
- $this->dispatch('ops/payment/generateHash', $params);
335
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
336
- $this->assertArrayHasKey('hash', $result);
337
- $this->assertArrayHasKey('alias', $result);
338
- $this->assertEquals('4711', $result['alias']);
339
- }
340
-
341
- public function testGenerateHashWithStoredAliasOldAliasIsUsed()
342
- {
343
- $fakeQuote = $this->getModelMock('sales/quote', array('save', 'getPayment'));
344
- $fakeQuote->setId(1);
345
- $fakeQuote->setStoreId(1);
346
- $customer = $this->getModelMock('customer/customer', array('save'));
347
- $customer->setId(1);
348
- $billingAddress = new Varien_Object();
349
- $shippingAddress = new Varien_Object();
350
- $fakeQuote->setCustomer($customer);
351
-
352
- $fakePayment = $this->getModelMock('sales/quote_payment', array('save'));
353
- $fakePayment->expects($this->any())
354
- ->method('settAdditionalInformation')
355
- ->with('saveOpsAlias', 1);
356
- $fakeQuote->expects($this->any())
357
- ->method('getPayment')
358
- ->will($this->returnValue($fakePayment));
359
-
360
- $quoteMock = $this->getModelMock('sales/quote', array('load', 'save'));
361
- $quoteMock->expects($this->any())
362
- ->method('load')
363
- ->will($this->returnValue($fakeQuote));
364
- $this->replaceByMock('model', 'sales/quote', $quoteMock);
365
- $params = array(
366
- 'alias' => 4711,
367
- 'storeId' => 1,
368
- 'storedAlias' => '0815',
369
- 'saveAlias' => 1
370
- );
371
-
372
- $helperMock = $this->getHelperMock('ops/alias', array('isAliasValidForAddresses'));
373
- $helperMock->expects($this->any())
374
- ->method('isAliasValidForAddresses')
375
- ->will($this->returnValue(true));
376
- $this->replaceByMock('helper', 'ops/alias', $helperMock);
377
- $this->dispatch('ops/payment/generateHash', $params);
378
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
379
- $this->assertArrayHasKey('hash', $result);
380
- $this->assertArrayHasKey('alias', $result);
381
- $this->assertEquals('0815', $result['alias']);
382
-
383
- $helperMock = $this->getHelperMock('ops/alias', array('isAliasValidForAddresses'));
384
- $helperMock->expects($this->any())
385
- ->method('isAliasValidForAddresses')
386
- ->will($this->returnValue(false));
387
- $this->replaceByMock('helper', 'ops/alias', $helperMock);
388
- $this->dispatch('ops/payment/generateHash', $params);
389
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
390
- $this->assertArrayHasKey('hash', $result);
391
- $this->assertArrayHasKey('alias', $result);
392
- $this->assertEquals('4711', $result['alias']);
393
- }
394
-
395
- public function testGenerateHashActionWithSaveAlias()
396
- {
397
- $fakeQuote = $this->getModelMock('sales/quote', array('save', 'getPayment'));
398
- $fakeQuote->setId(1);
399
- $fakeQuote->setStoreId(1);
400
- $customer = $this->getModelMock('customer/customer', array('save'));
401
- $customer->setId(1);
402
- $billingAddress = new Varien_Object();
403
- $shippingAddress = new Varien_Object();
404
- $fakeQuote->setCustomer($customer);
405
- $fakePayment = $this->getModelMock('sales/quote_payment', array('save'));
406
- $fakePayment->expects($this->any())
407
- ->method('settAdditionalInformation')
408
- ->with('saveOpsAlias', 1);
409
- $fakeQuote->expects($this->any())
410
- ->method('getPayment')
411
- ->will($this->returnValue($fakePayment));
412
-
413
- $quoteMock = $this->getModelMock('sales/quote', array('load', 'save'));
414
- $quoteMock->expects($this->any())
415
- ->method('load')
416
- ->will($this->returnValue($fakeQuote));
417
- $this->replaceByMock('model', 'sales/quote', $quoteMock);
418
- $params = array(
419
- 'alias' => 4711,
420
- 'storeId' => 1,
421
- 'saveAlias' => 1
422
- );
423
-
424
- $this->dispatch('ops/payment/generateHash', $params);
425
- $result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
426
- $this->assertArrayHasKey('hash', $result);
427
- $this->assertArrayHasKey('alias', $result);
428
- $this->assertEquals('4711', $result['alias']);
429
- }
430
-
431
  /**
432
  * @loadFixture ../../../var/fixtures/orders.yaml
433
  */
@@ -478,7 +210,9 @@ class Netresearch_OPS_Test_Controller_PaymentControllerTest
478
  $this->assertRedirectTo('/');
479
  $message = Mage::getSingleton('core/session')->getMessages()->getLastAddedMessage();
480
  $this->assertNotNull($message);
481
- $this->assertEquals($message->getText(), 'Not possible to reenter the payment details for order ' . $order->getIncrementId());
 
 
482
 
483
  }
484
 
7
  public function setUp()
8
  {
9
  parent::setUp();
10
+ $helperMock = $this->getHelperMock(
11
+ 'ops/payment', array(
12
  'shaCryptValidation',
13
  'cancelOrder',
14
  'declineOrder',
15
  'handleException',
16
  'getSHAInSet',
17
  'refillCart'
18
+ )
19
+ );
20
  $helperMock->expects($this->any())
21
  ->method('shaCryptValidation')
22
  ->will($this->returnValue(true));
144
  $this->assertRedirect('checkout/cart');
145
 
146
  $params = array(
147
+ 'orderID' => '#100000011',
148
  'redirect' => 'catalog'
149
  );
150
  $this->dispatch($routeToDispatch, $params);
151
  $this->assertRedirect('/');
152
 
153
  $params = array(
154
+ 'orderID' => '23',
155
  'redirect' => 'catalog'
156
  );
157
  $this->dispatch($routeToDispatch, $params);
160
 
161
  }
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  /**
164
  * @loadFixture ../../../var/fixtures/orders.yaml
165
  */
210
  $this->assertRedirectTo('/');
211
  $message = Mage::getSingleton('core/session')->getMessages()->getLastAddedMessage();
212
  $this->assertNotNull($message);
213
+ $this->assertEquals(
214
+ $message->getText(), 'Not possible to reenter the payment details for order ' . $order->getIncrementId()
215
+ );
216
 
217
  }
218
 
app/code/community/Netresearch/OPS/Test/Helper/AliasTest.php CHANGED
@@ -20,12 +20,35 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
20
  parent::setup();
21
  $this->_helper = Mage::helper('ops/alias');
22
  $this->store = Mage::app()->getStore(0)->load(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
 
25
  /**
26
  * @loadFixture ../../../var/fixtures/orders.yaml
27
  */
28
- public function testgetAliasWithoutAdditionalInformation()
29
  {
30
  $aliasHelperMock = $this->getHelperMock('ops/alias', array('isAdminSession'));
31
  $aliasHelperMock->expects($this->any())
@@ -41,9 +64,6 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
41
  $this->assertTrue(
42
  strpos($aliasHelperMock->getAlias($quote), "99") != false
43
  );
44
- $this->assertEquals(
45
- "051414459911", $aliasHelperMock->getAlias($quote)
46
- );
47
  }
48
 
49
  public function testGetAliasWithAdditionalInformation()
@@ -77,27 +97,35 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
77
 
78
  public function testSaveAliasIfCustomerIsNotLoggedIn()
79
  {
 
80
  $quote = Mage::getModel('sales/quote');
81
  $this->assertEquals(
82
- null, $this->_helper->saveAlias(array('OrderID' => 4711))
 
 
 
 
83
  );
84
  }
85
 
86
  public function testSaveAliasIfCustomerIsLoggedIn()
87
  {
 
 
88
  $quote = $this->getModelMock('sales/quote', array('save'));
89
  $this->replaceByMock('model', 'sales/quote', $quote);
90
  $quote->setBillingAddress($this->getAddressData());
91
  $quote->setShippingAddress($this->getAddressData());
92
  $quote->setId(4711);
93
- $customer = new Varien_Object();
94
  $customer->setId(1);
95
- $aliasData['OrderID'] = 4711;
96
- $aliasData['Alias'] = 4711;
97
- $aliasData['Brand'] = 'Visa';
98
- $aliasData['CardNo'] = 'xxxx0815';
99
- $aliasData['ED'] = '1212';
100
- $aliasData['CN'] = 'Foo Baar';
 
101
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
102
  $payment->setMethod('CreditCard');
103
  $payment->setAdditionalInformation(array('saveOpsAlias' => '1'));
@@ -134,9 +162,8 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
134
  $this->assertEquals(1, $alias->getCustomerId());
135
 
136
  $oldAliasId = $alias->getId();
137
-
138
  $alias = $this->_helper->saveAlias($aliasData, $quote);
139
- $this->assertGreaterThan($oldAliasId, $alias->getId());
140
  }
141
 
142
  /**
@@ -144,6 +171,7 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
144
  */
145
  public function testSaveAliasUpdate()
146
  {
 
147
  $quote = $this->getModelMock('sales/quote', array('save'));
148
  $this->replaceByMock('model', 'sales/quote', $quote);
149
  $quote->setBillingAddress($this->getAddressData());
@@ -151,12 +179,13 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
151
  $quote->setId(4711);
152
  $customer = new Varien_Object();
153
  $customer->setId(1);
154
- $aliasData['OrderID'] = 4711;
155
- $aliasData['Alias'] = 4711;
156
- $aliasData['Brand'] = 'Visa';
157
- $aliasData['CardNo'] = 'xxxx0815';
158
- $aliasData['ED'] = '1212';
159
- $aliasData['CN'] = 'Foo Baar';
 
160
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
161
  $payment->setMethod('CreditCard');
162
  $payment->setAdditionalInformation(array('saveOpsAlias' => '1'));
@@ -179,13 +208,14 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
179
  $oldAlias = $this->_helper->saveAlias($aliasData);
180
  $oldAlias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
181
  $oldAlias->save();
182
-
183
- $aliasData['OrderID'] = 4811;
184
- $aliasData['Alias'] = 4711;
185
- $aliasData['Brand'] = 'Mastercard';
186
- $aliasData['CardNo'] = 'xxxx01111';
187
- $aliasData['ED'] = '1213';
188
- $aliasData['CN'] = 'Max Power';
 
189
 
190
  $updatedAlias = $this->_helper->saveAlias($aliasData);
191
  $this->assertEquals(4711,$updatedAlias->getAlias());
@@ -208,11 +238,12 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
208
 
209
  $quote = Mage::getModel('sales/quote')->load(10);
210
  $aliasData = array(
211
- 'Alias' => 'TestAlias',
212
- 'ED' => '12.12.0012',
213
- 'Brand' => 'Visa',
214
- 'CardNo' => '12345678',
215
- 'CN' => 'Foo'
 
216
  );
217
  $aliasHelper = Mage::helper('ops/alias');
218
  $alias = $method->invoke($aliasHelper, $quote, $aliasData);
@@ -222,10 +253,11 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
222
  $this->assertEquals(Netresearch_OPS_Model_Alias_State::PENDING, $alias->getState());
223
 
224
  $aliasData = array(
225
- 'Alias' => 'TestAlias',
226
- 'ED' => '12.12.0012',
227
- 'Brand' => 'Visa',
228
- 'CardNo' => '12345678'
 
229
  );
230
  $aliasHelper = Mage::helper('ops/alias');
231
  $alias = $method->invoke($aliasHelper, $quote, $aliasData);
@@ -235,11 +267,12 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
235
  $this->assertEquals(Netresearch_OPS_Model_Alias_State::PENDING, $alias->getState());
236
 
237
  $aliasData = array(
238
- 'Alias' => 'TestAlias',
239
- 'ED' => '12.12.0012',
240
- 'Brand' => 'Visa',
241
- 'CardNo' => '12345678',
242
- 'CN' => ''
 
243
  );
244
  $aliasHelper = Mage::helper('ops/alias');
245
  $alias = $method->invoke($aliasHelper, $quote, $aliasData);
@@ -274,10 +307,10 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
274
  $oldAliasSize = count($aliasesForCustomer);
275
 
276
  $aliasData = array(
277
- 'Alias' => '4711',
278
- 'ED' => '0117',
279
- 'Brand' => 'Visa',
280
- 'CardNo' => 'xxxx1111'
281
  );
282
  $aliasHelper = Mage::helper('ops/alias');
283
  $method->invoke($aliasHelper, $quote, $aliasData);
@@ -311,10 +344,10 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
311
  $oldAliasSize = count($aliasesForCustomer);
312
 
313
  $aliasData = array(
314
- 'Alias' => '4711',
315
- 'ED' => '0117',
316
- 'Brand' => 'Visa',
317
- 'CardNo' => 'xxxx1111'
318
  );
319
  $aliasHelper = Mage::helper('ops/alias');
320
  $method->invoke($aliasHelper, $quote, $aliasData);
@@ -474,7 +507,7 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
474
  $this->assertArrayNotHasKey('cvc', $payment->getAdditionalInformation());
475
 
476
  $params = array(
477
- 'alias' => '4711'
478
  );
479
  $quote = Mage::getModel('sales/quote')->load(10);
480
  $helper = Mage::helper('ops/alias');
@@ -486,8 +519,8 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
486
  $this->assertArrayNotHasKey('cvc', $payment->getAdditionalInformation());
487
 
488
  $params = array(
489
- 'alias' => '4712',
490
- 'CVC' => '123'
491
  );
492
 
493
  $dataHelperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
@@ -522,14 +555,14 @@ class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
522
 
523
  $oldAlias = Mage::getModel('ops/alias')->load(7);
524
  $aliasData = array(
525
- 'alias' => '4712',
526
- 'CVC' => '123',
527
- 'CN' => 'Max Muster'
528
  );
529
 
530
  $method->invoke($helperObject, $quote,$aliasData);
531
  $updatedAlias = Mage::getModel('ops/alias')->load(7);
532
- $this->assertEquals($aliasData['CN'], $updatedAlias->getCardHolder());
533
 
534
  }
535
 
20
  parent::setup();
21
  $this->_helper = Mage::helper('ops/alias');
22
  $this->store = Mage::app()->getStore(0)->load(0);
23
+ $this->mockSessions();
24
+ }
25
+
26
+ protected function mockSessions()
27
+ {
28
+ $sessionMock = $this->getModelMockBuilder('checkout/session')
29
+ ->disableOriginalConstructor() // This one removes session_start and other methods usage
30
+ ->getMock();
31
+ $this->replaceByMock('singleton', 'checkout/session', $sessionMock);
32
+
33
+ $sessionMock = $this->getModelMockBuilder('customer/session')
34
+ ->disableOriginalConstructor() // This one removes session_start and other methods usage
35
+ ->getMock();
36
+ $this->replaceByMock('singleton', 'customer/session', $sessionMock);
37
+ }
38
+
39
+ protected function mockCheckoutOnepage($method)
40
+ {
41
+ $onepage = $this->getModelMock('checkout/type_onepage', array('getCheckoutMethod'));
42
+ $onepage->expects($this->any())
43
+ ->method('getCheckoutMehtod')
44
+ ->will($this->returnValue($method));
45
+ $this->replaceByMock('singleton', 'checkout/type_onepage', $onepage);
46
  }
47
 
48
  /**
49
  * @loadFixture ../../../var/fixtures/orders.yaml
50
  */
51
+ public function testGetAliasWithoutAdditionalInformation()
52
  {
53
  $aliasHelperMock = $this->getHelperMock('ops/alias', array('isAdminSession'));
54
  $aliasHelperMock->expects($this->any())
64
  $this->assertTrue(
65
  strpos($aliasHelperMock->getAlias($quote), "99") != false
66
  );
 
 
 
67
  }
68
 
69
  public function testGetAliasWithAdditionalInformation()
97
 
98
  public function testSaveAliasIfCustomerIsNotLoggedIn()
99
  {
100
+ $this->mockCheckoutOnepage(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
101
  $quote = Mage::getModel('sales/quote');
102
  $this->assertEquals(
103
+ null,
104
+ $this->_helper->saveAlias(array(
105
+ 'OrderID' => 4711,
106
+ 'StorePermanently' => 'N'
107
+ ))
108
  );
109
  }
110
 
111
  public function testSaveAliasIfCustomerIsLoggedIn()
112
  {
113
+ $this->mockCheckoutOnepage(Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER);
114
+ /** @var Mage_Sales_Model_Quote $quote */
115
  $quote = $this->getModelMock('sales/quote', array('save'));
116
  $this->replaceByMock('model', 'sales/quote', $quote);
117
  $quote->setBillingAddress($this->getAddressData());
118
  $quote->setShippingAddress($this->getAddressData());
119
  $quote->setId(4711);
120
+ $customer = Mage::getModel('customer/customer');
121
  $customer->setId(1);
122
+ $aliasData['Alias_OrderId'] = 4711;
123
+ $aliasData['Alias_AliasId'] = 4711;
124
+ $aliasData['Card_Brand'] = 'Visa';
125
+ $aliasData['Card_CardNumber'] = 'xxxx0815';
126
+ $aliasData['Card_ExpiryDate'] = '1212';
127
+ $aliasData['Card_CardHolderName'] = 'Foo Baar';
128
+ $aliasData['Alias_StorePermanently'] = 'Y';
129
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
130
  $payment->setMethod('CreditCard');
131
  $payment->setAdditionalInformation(array('saveOpsAlias' => '1'));
162
  $this->assertEquals(1, $alias->getCustomerId());
163
 
164
  $oldAliasId = $alias->getId();
 
165
  $alias = $this->_helper->saveAlias($aliasData, $quote);
166
+ $this->assertNotEquals($oldAliasId, $alias->getId());
167
  }
168
 
169
  /**
171
  */
172
  public function testSaveAliasUpdate()
173
  {
174
+ $this->mockCheckoutOnepage(Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER);
175
  $quote = $this->getModelMock('sales/quote', array('save'));
176
  $this->replaceByMock('model', 'sales/quote', $quote);
177
  $quote->setBillingAddress($this->getAddressData());
179
  $quote->setId(4711);
180
  $customer = new Varien_Object();
181
  $customer->setId(1);
182
+ $aliasData['Alias_OrderId'] = 4711;
183
+ $aliasData['Alias_AliasId'] = 4711;
184
+ $aliasData['Card_Brand'] = 'Visa';
185
+ $aliasData['Card_CardNumber'] = 'xxxx0815';
186
+ $aliasData['Card_ExpiryDate'] = '1212';
187
+ $aliasData['Card_CardHolderName'] = 'Foo Baar';
188
+ $aliasData['Alias_StorePermanently'] = 'Y';
189
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
190
  $payment->setMethod('CreditCard');
191
  $payment->setAdditionalInformation(array('saveOpsAlias' => '1'));
208
  $oldAlias = $this->_helper->saveAlias($aliasData);
209
  $oldAlias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
210
  $oldAlias->save();
211
+
212
+ $aliasData['Alias_OrderId'] = 4711;
213
+ $aliasData['Alias_AliasId'] = 4711;
214
+ $aliasData['Card_Brand'] = 'Mastercard';
215
+ $aliasData['Card_CardNumber'] = 'xxxx01111';
216
+ $aliasData['Card_ExpiryDate'] = '1213';
217
+ $aliasData['Card_CardHolderName'] = 'Max Power';
218
+ $aliasData['Alias_StorePermanently'] = 'Y';
219
 
220
  $updatedAlias = $this->_helper->saveAlias($aliasData);
221
  $this->assertEquals(4711,$updatedAlias->getAlias());
238
 
239
  $quote = Mage::getModel('sales/quote')->load(10);
240
  $aliasData = array(
241
+ 'Alias_AliasId' => 'TestAlias',
242
+ 'Card_ExpiryDate' => '12.12.0012',
243
+ 'Card_Brand' => 'Visa',
244
+ 'Card_CardNumber' => '12345678',
245
+ 'Card_CardHolderName' => 'Foo',
246
+ 'Alias_StorePermanently' => 'Y'
247
  );
248
  $aliasHelper = Mage::helper('ops/alias');
249
  $alias = $method->invoke($aliasHelper, $quote, $aliasData);
253
  $this->assertEquals(Netresearch_OPS_Model_Alias_State::PENDING, $alias->getState());
254
 
255
  $aliasData = array(
256
+ 'Alias_AliasId' => 'TestAlias',
257
+ 'Card_ExpiryDate' => '12.12.0012',
258
+ 'Card_Brand' => 'Visa',
259
+ 'Card_CardNumber' => '12345678',
260
+ 'Alias_StorePermanently' => 'Y'
261
  );
262
  $aliasHelper = Mage::helper('ops/alias');
263
  $alias = $method->invoke($aliasHelper, $quote, $aliasData);
267
  $this->assertEquals(Netresearch_OPS_Model_Alias_State::PENDING, $alias->getState());
268
 
269
  $aliasData = array(
270
+ 'Alias_AliasId' => 'TestAlias',
271
+ 'Card_ExpiryDate' => '12.12.0012',
272
+ 'Card_Brand' => 'Visa',
273
+ 'Card_CardNumber' => '12345678',
274
+ 'Card_CardHolderName' => '',
275
+ 'Alias_StorePermanently' => 'Y'
276
  );
277
  $aliasHelper = Mage::helper('ops/alias');
278
  $alias = $method->invoke($aliasHelper, $quote, $aliasData);
307
  $oldAliasSize = count($aliasesForCustomer);
308
 
309
  $aliasData = array(
310
+ 'Alias_AliasId' => '4711',
311
+ 'Card_ExpiryDate' => '0117',
312
+ 'Card_Brand' => 'Visa',
313
+ 'Card_CardNumber' => 'xxxx1111'
314
  );
315
  $aliasHelper = Mage::helper('ops/alias');
316
  $method->invoke($aliasHelper, $quote, $aliasData);
344
  $oldAliasSize = count($aliasesForCustomer);
345
 
346
  $aliasData = array(
347
+ 'Alias_AliasId' => '4711',
348
+ 'Card_ExpiryDate' => '0117',
349
+ 'Card_Brand' => 'Visa',
350
+ 'Card_CardNumber' => 'xxxx1111'
351
  );
352
  $aliasHelper = Mage::helper('ops/alias');
353
  $method->invoke($aliasHelper, $quote, $aliasData);
507
  $this->assertArrayNotHasKey('cvc', $payment->getAdditionalInformation());
508
 
509
  $params = array(
510
+ 'alias_aliasid' => '4711'
511
  );
512
  $quote = Mage::getModel('sales/quote')->load(10);
513
  $helper = Mage::helper('ops/alias');
519
  $this->assertArrayNotHasKey('cvc', $payment->getAdditionalInformation());
520
 
521
  $params = array(
522
+ 'alias_aliasid' => '4712',
523
+ 'card_cvc' => '123'
524
  );
525
 
526
  $dataHelperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
555
 
556
  $oldAlias = Mage::getModel('ops/alias')->load(7);
557
  $aliasData = array(
558
+ 'alias_aliasid' => '4712',
559
+ 'card_cvc' => '123',
560
+ 'Card_CardHolderName' => 'Max Muster'
561
  );
562
 
563
  $method->invoke($helperObject, $quote,$aliasData);
564
  $updatedAlias = Mage::getModel('ops/alias')->load(7);
565
+ $this->assertEquals($aliasData['Card_CardHolderName'], $updatedAlias->getCardHolder());
566
 
567
  }
568
 
app/code/community/Netresearch/OPS/Test/Helper/DirectDebitTest.php CHANGED
@@ -479,6 +479,7 @@ class Netresearch_OPS_Test_Helper_DirectDebitTest
479
  'OWNERTELNO' => NULL,
480
  'OWNERCTY' => "DE",
481
  'ADDMATCH' => 1,
 
482
  'ECOM_SHIPTO_POSTAL_POSTALCODE' => "04229",
483
  'ECOM_BILLTO_POSTAL_POSTALCODE' => "04229",
484
  'ORIG' => Mage::helper("ops")->getModuleVersionString(),
@@ -487,7 +488,6 @@ class Netresearch_OPS_Test_Helper_DirectDebitTest
487
  'ECOM_SHIPTO_POSTAL_NAME_LAST' => utf8_decode('Fürstenberg'),
488
  'ECOM_SHIPTO_POSTAL_STREET_LINE1' => utf8_decode('An der Tabaksmühle 3a'),
489
  'ECOM_SHIPTO_POSTAL_STREET_LINE2' => '',
490
- 'ECOM_SHIPTO_POSTAL_STREET_LINE3' => '',
491
  'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => 'DE',
492
  'ECOM_SHIPTO_POSTAL_CITY' => 'Leipzig',
493
  'EMAIL' => 'hubertus.von.fuerstenberg@trash-mail.com',
479
  'OWNERTELNO' => NULL,
480
  'OWNERCTY' => "DE",
481
  'ADDMATCH' => 1,
482
+ 'RTIMEOUT' => 45,
483
  'ECOM_SHIPTO_POSTAL_POSTALCODE' => "04229",
484
  'ECOM_BILLTO_POSTAL_POSTALCODE' => "04229",
485
  'ORIG' => Mage::helper("ops")->getModuleVersionString(),
488
  'ECOM_SHIPTO_POSTAL_NAME_LAST' => utf8_decode('Fürstenberg'),
489
  'ECOM_SHIPTO_POSTAL_STREET_LINE1' => utf8_decode('An der Tabaksmühle 3a'),
490
  'ECOM_SHIPTO_POSTAL_STREET_LINE2' => '',
 
491
  'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => 'DE',
492
  'ECOM_SHIPTO_POSTAL_CITY' => 'Leipzig',
493
  'EMAIL' => 'hubertus.von.fuerstenberg@trash-mail.com',
app/code/community/Netresearch/OPS/Test/Helper/DirectLinkTest.php CHANGED
@@ -18,18 +18,19 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
18
 
19
  public function testDeleteActions()
20
  {
21
- $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=>Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED)));
22
- $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=>Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_WAITING)));
23
- $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=>Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_UNCERTAIN)));
24
- $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=>Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_REFUSED)));
25
- $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=>Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_OK)));
26
- $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=>Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED_PROCESSED_MERCHANT)));
27
  }
28
 
29
  public function testRefundActions()
30
  {
 
31
  $opsRequest = array(
32
- 'STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUNDED,
33
  'amount' => '184.90'
34
  );
35
  $this->assertFalse($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Refund should not be possible without open transactions');
@@ -41,7 +42,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
41
  public function testCancelActions()
42
  {
43
  $opsRequest = array(
44
- 'STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED,
45
  'amount' => '184.90'
46
  );
47
  $this->assertFalse($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Cancel should not be possible without open transactions');
@@ -53,7 +54,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
53
  public function testCaptureActions()
54
  {
55
  $opsRequest = array(
56
- 'STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED,
57
  'amount' => '184.90'
58
  );
59
  $this->assertTrue($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Capture should be possible because of no open transactions and matching amount');
@@ -101,7 +102,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
101
  ->method('acceptCapture')
102
  ->will($this->returnCallback($closure));
103
  $this->replaceByMock('helper', 'ops/order_capture', $captureHelper);
104
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED);
105
  $directlinkHelperMock->processFeedback($order, $params);
106
  $this->assertEquals(9, $order->getPayment()->getAdditionalInformation('status'));
107
  }
@@ -112,25 +113,19 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
112
  public function testProcessFeedbackRefundSuccess()
113
  {
114
 
 
 
 
 
 
 
115
  $order = Mage::getModel('sales/order')->load(11);
116
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
117
  $directlinkHelperMock->expects($this->any())
118
  ->method('isValidOpsRequest')
119
  ->will($this->returnValue(true));
120
 
121
-
122
-
123
- $closure = function ($order, $params = array()) {
124
- $order->getPayment()->setAdditionalInformation('status', 8);
125
- return $order->getPayment();
126
- };
127
-
128
- $refundHelper = $this->getHelperMock('ops/order_refund', array('createRefund'));
129
- $refundHelper->expects($this->any())
130
- ->method('createRefund')
131
- ->will($this->returnCallback($closure));
132
- $this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
133
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUNDED, 'PAYID' => '4711');
134
  $directlinkHelperMock->processFeedback($order, $params);
135
  $this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
136
  }
@@ -150,7 +145,9 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
150
 
151
 
152
  $closure = function ($order, $params = array()) {
153
- $order->getPayment()->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PROCESSED_MERCHANT);
 
 
154
  return $order->getPayment();
155
  };
156
 
@@ -159,7 +156,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
159
  ->method('createRefund')
160
  ->will($this->returnCallback($closure));
161
  $this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
162
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PROCESSED_MERCHANT, 'PAYID' => '4711');
163
  $directlinkHelperMock->processFeedback($order, $params);
164
  $this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
165
  }
@@ -169,6 +166,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
169
  */
170
  public function testProcessFeedbackPaymentWaiting()
171
  {
 
172
  /** @var Mage_Sales_Model_Order $order */
173
  $order = Mage::getModel('sales/order')->load(11);
174
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
@@ -180,11 +178,13 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
180
 
181
 
182
  $closure = function ($order, $params = array()) {
183
- $order->getPayment()->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING);
 
 
184
  return $order->getPayment();
185
  };
186
 
187
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING, 'PAYID' => '4711');
188
  $directlinkHelperMock->processFeedback($order, $params);
189
  $cntAfter = $order->getStatusHistoryCollection()->count();
190
  $this->assertTrue($cntBefore < $cntAfter);
@@ -195,6 +195,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
195
  */
196
  public function testProcessFeedbackPaymentRefused()
197
  {
 
198
  /** @var Mage_Sales_Model_Order $order */
199
  $order = Mage::getModel('sales/order')->load(11);
200
  $directlinkHelperMock = $this->getHelperMock(
@@ -208,24 +209,12 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
208
  $closure = function ($order, $params = array()) {
209
  $order->getPayment()->setAdditionalInformation(
210
  'status',
211
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED
212
  );
213
  return $order->getPayment();
214
  };
215
 
216
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED, 'PAYID' => '4711');
217
-
218
- $directlinkHelperMock->expects($this->once())
219
- ->method('closePaymentTransaction')
220
- ->with(
221
- $order,
222
- $params,
223
- Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE,
224
- Mage::helper('ops')->__(
225
- 'Capture was refused. Automatic creation failed. Ingenico Payment Services status: %s.',
226
- Mage::helper('ops')->getStatusText($params['STATUS'])
227
- )
228
- );
229
 
230
  $directlinkHelperMock->processFeedback($order, $params);
231
  }
@@ -235,8 +224,16 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
235
  */
236
  public function testProcessFeedbackRefundWaiting()
237
  {
 
 
 
 
238
  /** @var Mage_Sales_Model_Order $order */
239
  $order = Mage::getModel('sales/order')->load(11);
 
 
 
 
240
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
241
  $directlinkHelperMock->expects($this->any())
242
  ->method('isValidOpsRequest')
@@ -246,7 +243,9 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
246
 
247
 
248
  $closure = function ($order, $params = array()) {
249
- $order->getPayment()->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING);
 
 
250
  return $order->getPayment();
251
  };
252
 
@@ -255,7 +254,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
255
  ->method('createRefund')
256
  ->will($this->returnCallback($closure));
257
  $this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
258
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING, 'PAYID' => '4711');
259
  $directlinkHelperMock->processFeedback($order, $params);
260
  $cntAfter = $order->getStatusHistoryCollection()->count();
261
  $this->assertTrue($cntBefore < $cntAfter);
@@ -267,12 +266,17 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
267
  */
268
  public function testProcessFeedbackRefundRefused()
269
  {
 
 
 
270
  /** @var Mage_Sales_Model_Order $order */
271
  $order = Mage::getModel('sales/order')->load(11);
272
  $directlinkHelperMock = $this->getHelperMock(
273
  'ops/directlink',
274
  array('isValidOpsRequest', 'closePaymentTransaction')
275
  );
 
 
276
  $directlinkHelperMock->expects($this->any())
277
  ->method('isValidOpsRequest')
278
  ->will($this->returnValue(true));
@@ -280,7 +284,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
280
  $closure = function ($order, $params = array()) {
281
  $order->getPayment()->setAdditionalInformation(
282
  'status',
283
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING
284
  );
285
  return $order->getPayment();
286
  };
@@ -290,21 +294,11 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
290
  ->method('createRefund')
291
  ->will($this->returnCallback($closure));
292
  $this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
293
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_REFUSED, 'PAYID' => '4711');
294
-
295
- $directlinkHelperMock->expects($this->once())
296
- ->method('closePaymentTransaction')
297
- ->with(
298
- $order,
299
- $params,
300
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE,
301
- Mage::helper('ops')->__(
302
- 'Refund was refused. Automatic creation failed. Ingenico Payment Services status: %s.',
303
- Mage::helper('ops')->getStatusText($params['STATUS'])
304
- )
305
- );
306
 
307
  $directlinkHelperMock->processFeedback($order, $params);
 
 
308
  }
309
 
310
  /**
@@ -312,6 +306,9 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
312
  */
313
  public function testProcessFeedbackVoidSuccess()
314
  {
 
 
 
315
 
316
  $order = Mage::getModel('sales/order')->load(11);
317
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
@@ -331,7 +328,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
331
  ->method('acceptVoid')
332
  ->will($this->returnCallback($closure));
333
  $this->replaceByMock('helper', 'ops/order_void', $voidHelper);
334
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED, 'PAYID' => '4711');
335
  $directlinkHelperMock->processFeedback($order, $params);
336
  $this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
337
  }
@@ -341,25 +338,18 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
341
  */
342
  public function testProcessFeedbackVoidWaiting()
343
  {
 
344
  /** @var Mage_Sales_Model_Order $order */
345
  $order = Mage::getModel('sales/order')->load(11);
 
346
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
347
  $directlinkHelperMock->expects($this->any())
348
  ->method('isValidOpsRequest')
349
  ->will($this->returnValue(true));
350
 
351
- $cntBefore = $order->getStatusHistoryCollection()->count();
352
-
353
-
354
- $closure = function ($order, $params = array()) {
355
- $order->getPayment()->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_WAITING);
356
- return $order->getPayment();
357
- };
358
-
359
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_WAITING, 'PAYID' => '4711');
360
  $directlinkHelperMock->processFeedback($order, $params);
361
- $cntAfter = $order->getStatusHistoryCollection()->count();
362
- $this->assertTrue($cntBefore < $cntAfter);
363
 
364
  }
365
 
@@ -368,11 +358,12 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
368
  */
369
  public function testProcessFeedbackVoidRefused()
370
  {
 
371
  /** @var Mage_Sales_Model_Order $order */
372
  $order = Mage::getModel('sales/order')->load(11);
373
  $directlinkHelperMock = $this->getHelperMock(
374
  'ops/directlink',
375
- array('isValidOpsRequest', 'closePaymentTransaction')
376
  );
377
  $directlinkHelperMock->expects($this->any())
378
  ->method('isValidOpsRequest')
@@ -381,7 +372,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
381
  $closure = function ($order, $params = array()) {
382
  $order->getPayment()->setAdditionalInformation(
383
  'status',
384
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_REFUSED
385
  );
386
  return $order->getPayment();
387
  };
@@ -391,19 +382,8 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
391
  ->method('acceptVoid')
392
  ->will($this->returnCallback($closure));
393
  $this->replaceByMock('helper', 'ops/order_void', $refundHelper);
394
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_REFUSED, 'PAYID' => '4711');
395
-
396
- $directlinkHelperMock->expects($this->once())
397
- ->method('closePaymentTransaction')
398
- ->with(
399
- $order,
400
- $params,
401
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE,
402
- Mage::helper('ops')->__(
403
- 'Void was refused. Automatic creation failed. Ingenico Payment Services status: %s.',
404
- Mage::helper('ops')->getStatusText($params['STATUS'])
405
- )
406
- );
407
 
408
  $directlinkHelperMock->processFeedback($order, $params);
409
  }
@@ -413,6 +393,8 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
413
  */
414
  public function testProcessFeedbackAuthorizeChanged()
415
  {
 
 
416
  /** @var Mage_Sales_Model_Order $order */
417
  $order = Mage::getModel('sales/order')->load(11);
418
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
@@ -422,7 +404,7 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
422
 
423
  $cntBefore = $order->getStatusHistoryCollection()->count();
424
 
425
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED, 'PAYID' => '4711');
426
  $directlinkHelperMock->processFeedback($order, $params);
427
  $cntAfter = $order->getStatusHistoryCollection()->count();
428
  $this->assertTrue($cntBefore < $cntAfter);
@@ -434,6 +416,8 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
434
  */
435
  public function testProcessFeedbackAuthorizeKwixoAccepted()
436
  {
 
 
437
  /** @var Mage_Sales_Model_Order $order */
438
  $order = Mage::getModel('sales/order')->load(27);
439
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
@@ -445,7 +429,8 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
445
 
446
 
447
  $closure = function ($order, $params = array()) {
448
- $order->getPayment()->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED);
 
449
  return $order->getPayment();
450
  };
451
 
@@ -455,16 +440,19 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
455
  ->will($this->returnCallback($closure));
456
  $this->replaceByMock('helper', 'ops/payment', $paymentHelper);
457
 
458
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED, 'PAYID' => '4711');
459
  $directlinkHelperMock->processFeedback($order, $params);
460
  $this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
461
  }
462
 
463
  /**
464
  * @loadFixture ../../../var/fixtures/orders.yaml
 
 
465
  */
466
  public function testProcessFeedbackUnknownStatus()
467
  {
 
468
  /** @var Mage_Sales_Model_Order $order */
469
  $order = Mage::getModel('sales/order')->load(11);
470
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
@@ -472,58 +460,69 @@ class Netresearch_OPS_Test_Helper_DirectLinkTest extends EcomDev_PHPUnit_Test_Ca
472
  ->method('isValidOpsRequest')
473
  ->will($this->returnValue(true));
474
 
475
- $cntBefore = $order->getStatusHistoryCollection()->count();
476
 
477
  $params = array('STATUS' => 4711, 'PAYID' => '4711');
478
  $directlinkHelperMock->processFeedback($order, $params);
479
- $cntAfter = $order->getStatusHistoryCollection()->count();
480
- $this->assertTrue($cntBefore < $cntAfter);
481
 
482
  }
483
 
484
  /**
485
  * @loadFixture ../../../var/fixtures/orders.yaml
 
 
486
  */
487
  public function testProcessFeedbackInvalidStatus()
488
  {
 
 
 
 
 
 
489
  /** @var Mage_Sales_Model_Order $order */
490
  $order = Mage::getModel('sales/order')->load(11);
 
491
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
492
  $directlinkHelperMock->expects($this->any())
493
  ->method('isValidOpsRequest')
494
  ->will($this->returnValue(true));
495
 
496
- $cntBefore = $order->getStatusHistoryCollection()->count();
497
-
498
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID, 'PAYID' => '4711');
499
  $directlinkHelperMock->processFeedback($order, $params);
500
- $cntAfter = $order->getStatusHistoryCollection()->count();
501
- $this->assertTrue($cntBefore === $cntAfter);
502
 
503
  }
504
 
505
  /**
506
  * @loadFixture ../../../var/fixtures/orders.yaml
 
 
507
  */
508
- public function testIsNoValidOpsRequestWillThrowException()
509
  {
 
 
 
 
 
 
510
  /** @var Mage_Sales_Model_Order $order */
511
  $order = Mage::getModel('sales/order')->load(11);
 
512
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
513
  $directlinkHelperMock->expects($this->any())
514
  ->method('isValidOpsRequest')
515
- ->will($this->returnValue(false));
516
-
517
- $cntBefore = $order->getStatusHistoryCollection()->count();
518
 
519
- $params = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID, 'PAYID' => '4711');
520
- try {
521
- $directlinkHelperMock->processFeedback($order, $params);
522
- } catch (Mage_Core_Exception $e) {
523
 
524
- }
525
- $cntAfter = $order->getStatusHistoryCollection()->count();
526
- $this->assertTrue($cntBefore < $cntAfter);
 
 
 
 
527
  }
528
  }
529
 
18
 
19
  public function testDeleteActions()
20
  {
21
+ $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETED)));
22
+ $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETION_PENDING)));
23
+ $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETION_UNCERTAIN)));
24
+ $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETION_REFUSED)));
25
+ $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETION_OK)));
26
+ $this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::DELETION_HANDLED_BY_MERCHANT)));
27
  }
28
 
29
  public function testRefundActions()
30
  {
31
+
32
  $opsRequest = array(
33
+ 'STATUS' => Netresearch_OPS_Model_Status::REFUNDED,
34
  'amount' => '184.90'
35
  );
36
  $this->assertFalse($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Refund should not be possible without open transactions');
42
  public function testCancelActions()
43
  {
44
  $opsRequest = array(
45
+ 'STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED,
46
  'amount' => '184.90'
47
  );
48
  $this->assertFalse($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Cancel should not be possible without open transactions');
54
  public function testCaptureActions()
55
  {
56
  $opsRequest = array(
57
+ 'STATUS' => Netresearch_OPS_Model_Status::PAYMENT_REQUESTED,
58
  'amount' => '184.90'
59
  );
60
  $this->assertTrue($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Capture should be possible because of no open transactions and matching amount');
102
  ->method('acceptCapture')
103
  ->will($this->returnCallback($closure));
104
  $this->replaceByMock('helper', 'ops/order_capture', $captureHelper);
105
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_REQUESTED);
106
  $directlinkHelperMock->processFeedback($order, $params);
107
  $this->assertEquals(9, $order->getPayment()->getAdditionalInformation('status'));
108
  }
113
  public function testProcessFeedbackRefundSuccess()
114
  {
115
 
116
+ $mock = $this->getModelMock('sales/order', array('getBillingAddress'));
117
+ $mock->expects($this->any())
118
+ ->method('getBillingAddress')
119
+ ->will($this->returnValue(new Varien_Object()));
120
+ $this->replaceByMock('model', 'sales/order', $mock);
121
+
122
  $order = Mage::getModel('sales/order')->load(11);
123
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
124
  $directlinkHelperMock->expects($this->any())
125
  ->method('isValidOpsRequest')
126
  ->will($this->returnValue(true));
127
 
128
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::REFUNDED, 'PAYID' => '4711');
 
 
 
 
 
 
 
 
 
 
 
 
129
  $directlinkHelperMock->processFeedback($order, $params);
130
  $this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
131
  }
145
 
146
 
147
  $closure = function ($order, $params = array()) {
148
+ $order->getPayment()->setAdditionalInformation('status',
149
+ Netresearch_OPS_Model_Status::REFUND_PROCESSED_BY_MERCHANT
150
+ );
151
  return $order->getPayment();
152
  };
153
 
156
  ->method('createRefund')
157
  ->will($this->returnCallback($closure));
158
  $this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
159
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::REFUND_PROCESSED_BY_MERCHANT, 'PAYID' => '4711');
160
  $directlinkHelperMock->processFeedback($order, $params);
161
  $this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
162
  }
166
  */
167
  public function testProcessFeedbackPaymentWaiting()
168
  {
169
+
170
  /** @var Mage_Sales_Model_Order $order */
171
  $order = Mage::getModel('sales/order')->load(11);
172
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
178
 
179
 
180
  $closure = function ($order, $params = array()) {
181
+ $order->getPayment()->setAdditionalInformation('status',
182
+ Netresearch_OPS_Model_Status::PAYMENT_PROCESSING
183
+ );
184
  return $order->getPayment();
185
  };
186
 
187
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_PROCESSING, 'PAYID' => '4711');
188
  $directlinkHelperMock->processFeedback($order, $params);
189
  $cntAfter = $order->getStatusHistoryCollection()->count();
190
  $this->assertTrue($cntBefore < $cntAfter);
195
  */
196
  public function testProcessFeedbackPaymentRefused()
197
  {
198
+
199
  /** @var Mage_Sales_Model_Order $order */
200
  $order = Mage::getModel('sales/order')->load(11);
201
  $directlinkHelperMock = $this->getHelperMock(
209
  $closure = function ($order, $params = array()) {
210
  $order->getPayment()->setAdditionalInformation(
211
  'status',
212
+ Netresearch_OPS_Model_Status::PAYMENT_REFUSED
213
  );
214
  return $order->getPayment();
215
  };
216
 
217
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_REFUSED, 'PAYID' => '4711');
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
  $directlinkHelperMock->processFeedback($order, $params);
220
  }
224
  */
225
  public function testProcessFeedbackRefundWaiting()
226
  {
227
+
228
+ $paymentMock = $this->getModelMock('core/resource_transaction', array('save'));
229
+ $this->replaceByMock('model', 'core/resource_transaction', $paymentMock);
230
+
231
  /** @var Mage_Sales_Model_Order $order */
232
  $order = Mage::getModel('sales/order')->load(11);
233
+
234
+ $creditMemo = $this->getModelMock('sales/order_creditmemo', array('_beforeSave'));
235
+ $order->getPayment()->setCreatedCreditMemo($creditMemo);
236
+ /** @var Netresearch_OPS_Helper_Directlink $directlinkHelperMock */
237
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
238
  $directlinkHelperMock->expects($this->any())
239
  ->method('isValidOpsRequest')
243
 
244
 
245
  $closure = function ($order, $params = array()) {
246
+ $order->getPayment()->setAdditionalInformation('status',
247
+ Netresearch_OPS_Model_Status::REFUND_PENDING
248
+ );
249
  return $order->getPayment();
250
  };
251
 
254
  ->method('createRefund')
255
  ->will($this->returnCallback($closure));
256
  $this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
257
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::REFUND_PENDING, 'PAYID' => '4711');
258
  $directlinkHelperMock->processFeedback($order, $params);
259
  $cntAfter = $order->getStatusHistoryCollection()->count();
260
  $this->assertTrue($cntBefore < $cntAfter);
266
  */
267
  public function testProcessFeedbackRefundRefused()
268
  {
269
+ $transMock = $this->getModelMock('core/resource_transaction', array('save'));
270
+ $this->replaceByMock('model', 'core/resource_transaction', $transMock);
271
+
272
  /** @var Mage_Sales_Model_Order $order */
273
  $order = Mage::getModel('sales/order')->load(11);
274
  $directlinkHelperMock = $this->getHelperMock(
275
  'ops/directlink',
276
  array('isValidOpsRequest', 'closePaymentTransaction')
277
  );
278
+ $creditMemo = $this->getModelMock('sales/order_creditmemo', array('_beforeSave'));
279
+ $order->getPayment()->setCreatedCreditMemo($creditMemo);
280
  $directlinkHelperMock->expects($this->any())
281
  ->method('isValidOpsRequest')
282
  ->will($this->returnValue(true));
284
  $closure = function ($order, $params = array()) {
285
  $order->getPayment()->setAdditionalInformation(
286
  'status',
287
+ Netresearch_OPS_Model_Status::REFUND_PENDING
288
  );
289
  return $order->getPayment();
290
  };
294
  ->method('createRefund')
295
  ->will($this->returnCallback($closure));
296
  $this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
297
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::REFUND_REFUSED, 'PAYID' => '4711');
 
 
 
 
 
 
 
 
 
 
 
 
298
 
299
  $directlinkHelperMock->processFeedback($order, $params);
300
+
301
+ $this->assertEquals(Netresearch_OPS_Model_Status::REFUND_REFUSED, $order->getPayment()->getAdditionalInformation('status'));
302
  }
303
 
304
  /**
306
  */
307
  public function testProcessFeedbackVoidSuccess()
308
  {
309
+ $this->mockOrderConfig();
310
+ $transMock = $this->getModelMock('core/resource_transaction', array('save'));
311
+ $this->replaceByMock('model', 'core/resource_transaction', $transMock);
312
 
313
  $order = Mage::getModel('sales/order')->load(11);
314
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
328
  ->method('acceptVoid')
329
  ->will($this->returnCallback($closure));
330
  $this->replaceByMock('helper', 'ops/order_void', $voidHelper);
331
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED, 'PAYID' => '4711');
332
  $directlinkHelperMock->processFeedback($order, $params);
333
  $this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
334
  }
338
  */
339
  public function testProcessFeedbackVoidWaiting()
340
  {
341
+
342
  /** @var Mage_Sales_Model_Order $order */
343
  $order = Mage::getModel('sales/order')->load(11);
344
+ /** @var Netresearch_OPS_Helper_Directlink $directlinkHelperMock */
345
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
346
  $directlinkHelperMock->expects($this->any())
347
  ->method('isValidOpsRequest')
348
  ->will($this->returnValue(true));
349
 
350
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::DELETION_WAITING, 'PAYID' => '4711');
 
 
 
 
 
 
 
 
351
  $directlinkHelperMock->processFeedback($order, $params);
352
+ $this->assertNotEmpty($order->getPayment()->getMessage());
 
353
 
354
  }
355
 
358
  */
359
  public function testProcessFeedbackVoidRefused()
360
  {
361
+
362
  /** @var Mage_Sales_Model_Order $order */
363
  $order = Mage::getModel('sales/order')->load(11);
364
  $directlinkHelperMock = $this->getHelperMock(
365
  'ops/directlink',
366
+ array('isValidOpsRequest')
367
  );
368
  $directlinkHelperMock->expects($this->any())
369
  ->method('isValidOpsRequest')
372
  $closure = function ($order, $params = array()) {
373
  $order->getPayment()->setAdditionalInformation(
374
  'status',
375
+ Netresearch_OPS_Model_Status::DELETION_REFUSED
376
  );
377
  return $order->getPayment();
378
  };
382
  ->method('acceptVoid')
383
  ->will($this->returnCallback($closure));
384
  $this->replaceByMock('helper', 'ops/order_void', $refundHelper);
385
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::DELETION_REFUSED, 'PAYID' => '4711');
386
+
 
 
 
 
 
 
 
 
 
 
 
387
 
388
  $directlinkHelperMock->processFeedback($order, $params);
389
  }
393
  */
394
  public function testProcessFeedbackAuthorizeChanged()
395
  {
396
+ $this->mockOrderConfig();
397
+
398
  /** @var Mage_Sales_Model_Order $order */
399
  $order = Mage::getModel('sales/order')->load(11);
400
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
404
 
405
  $cntBefore = $order->getStatusHistoryCollection()->count();
406
 
407
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED, 'PAYID' => '4711');
408
  $directlinkHelperMock->processFeedback($order, $params);
409
  $cntAfter = $order->getStatusHistoryCollection()->count();
410
  $this->assertTrue($cntBefore < $cntAfter);
416
  */
417
  public function testProcessFeedbackAuthorizeKwixoAccepted()
418
  {
419
+ $this->mockOrderConfig();
420
+
421
  /** @var Mage_Sales_Model_Order $order */
422
  $order = Mage::getModel('sales/order')->load(27);
423
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
429
 
430
 
431
  $closure = function ($order, $params = array()) {
432
+ $order->getPayment()->setAdditionalInformation('status', Netresearch_OPS_Model_Status::AUTHORIZED
433
+ );
434
  return $order->getPayment();
435
  };
436
 
440
  ->will($this->returnCallback($closure));
441
  $this->replaceByMock('helper', 'ops/payment', $paymentHelper);
442
 
443
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED, 'PAYID' => '4711');
444
  $directlinkHelperMock->processFeedback($order, $params);
445
  $this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
446
  }
447
 
448
  /**
449
  * @loadFixture ../../../var/fixtures/orders.yaml
450
+ * @expectedException Mage_Core_Exception
451
+ * @expectedExceptionMessage Can not handle status 4711.
452
  */
453
  public function testProcessFeedbackUnknownStatus()
454
  {
455
+
456
  /** @var Mage_Sales_Model_Order $order */
457
  $order = Mage::getModel('sales/order')->load(11);
458
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
460
  ->method('isValidOpsRequest')
461
  ->will($this->returnValue(true));
462
 
 
463
 
464
  $params = array('STATUS' => 4711, 'PAYID' => '4711');
465
  $directlinkHelperMock->processFeedback($order, $params);
 
 
466
 
467
  }
468
 
469
  /**
470
  * @loadFixture ../../../var/fixtures/orders.yaml
471
+ * @expectedException Mage_Core_Exception
472
+ * @expectedExceptionMessage Ingenico ePayments status 0, the action failed.
473
  */
474
  public function testProcessFeedbackInvalidStatus()
475
  {
476
+ $helperMock = $this->getHelperMock('ops', array('isAdminSession'));
477
+ $helperMock->expects($this->once())
478
+ ->method('isAdminSession')
479
+ ->will($this->returnValue(false));
480
+ $this->replaceByMock('helper', 'ops', $helperMock);
481
+
482
  /** @var Mage_Sales_Model_Order $order */
483
  $order = Mage::getModel('sales/order')->load(11);
484
+ $order->getPayment()->setAdditionalInformation('status', 500);
485
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
486
  $directlinkHelperMock->expects($this->any())
487
  ->method('isValidOpsRequest')
488
  ->will($this->returnValue(true));
489
 
490
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::INVALID_INCOMPLETE, 'PAYID' => '4711');
 
 
491
  $directlinkHelperMock->processFeedback($order, $params);
 
 
492
 
493
  }
494
 
495
  /**
496
  * @loadFixture ../../../var/fixtures/orders.yaml
497
+ * @expectedException Mage_Core_Exception
498
+ * @expectedExceptionMessage Ingenico ePayments status 0, the action failed.
499
  */
500
+ public function testProcessFeedbackInvalidStatusAsAdmin()
501
  {
502
+ $helperMock = $this->getHelperMock('ops', array('isAdminSession'));
503
+ $helperMock->expects($this->once())
504
+ ->method('isAdminSession')
505
+ ->will($this->returnValue(true));
506
+ $this->replaceByMock('helper', 'ops', $helperMock);
507
+
508
  /** @var Mage_Sales_Model_Order $order */
509
  $order = Mage::getModel('sales/order')->load(11);
510
+ $order->getPayment()->setAdditionalInformation('status', 500);
511
  $directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
512
  $directlinkHelperMock->expects($this->any())
513
  ->method('isValidOpsRequest')
514
+ ->will($this->returnValue(true));
 
 
515
 
516
+ $params = array('STATUS' => Netresearch_OPS_Model_Status::INVALID_INCOMPLETE, 'PAYID' => '4711');
517
+ $directlinkHelperMock->processFeedback($order, $params);
 
 
518
 
519
+ }
520
+ protected function mockOrderConfig(){
521
+ $configMock = $this->getModelMock('sales/order_config',array('getDefaultStatus'));
522
+ $configMock->expects($this->any())
523
+ ->method('getDefaultStatus')
524
+ ->will($this->returnArgument(0));
525
+ $this->replaceByMock('singleton', 'sales/order_config', $configMock);
526
  }
527
  }
528
 
app/code/community/Netresearch/OPS/Test/Helper/Order/VoidTest.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- class Netresearch_OPS_Test_Helper_Order_VoidTest
3
- extends EcomDev_PHPUnit_Test_Case
4
- {
5
-
6
- /**
7
- * @loadFixture ../../../../var/fixtures/orders.yaml
8
- */
9
- public function testVoidAccepted()
10
- {
11
- $paymentMock = $this->getModelMock('sales/order_payment', array('save'));
12
- $this->replaceByMock('model', 'sales/order_payment', $paymentMock);
13
-
14
- Mage::unregister('ops_auto_void');
15
- $helper = Mage::helper('ops/order_void');
16
- $order = Mage::getModel('sales/order')->load(11);
17
- $directLinkHelper = $this->getHelperMock("ops/directlink", array('closePaymentTransaction'));
18
- $this->replaceByMock('helper', 'ops/directlink', $directLinkHelper);
19
- $helper->acceptVoid($order, array('orderID' => 11));
20
- $this->assertTrue(Mage::registry('ops_auto_void'));
21
- Mage::unregister('ops_auto_void');
22
- }
23
-
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Test/Helper/Order/VoidTest/fixtures/.gitkeep DELETED
File without changes
app/code/community/Netresearch/OPS/Test/Helper/OrderTest.php CHANGED
@@ -127,29 +127,6 @@ class Netresearch_OPS_Test_Helper_OrderTest extends EcomDev_PHPUnit_Test_Case
127
  );
128
  }
129
 
130
- public function testCheckForOpsStateOnStatusUpdateWillPassStatusUpdate()
131
- {
132
- $payment = Mage::getModel('sales/order_payment');
133
- $payment->setAdditionalInformation('status', 9);
134
- $order = Mage::getModel('sales/order');
135
- $order->setPayment($payment);
136
- $order->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
137
- $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
138
- Mage::helper('ops/order')->checkForOpsStateOnStatusUpdate($order);
139
- $this->assertEquals(Mage_Sales_Model_Order::STATE_PROCESSING, $order->getStatus());
140
- }
141
-
142
- public function testCheckForOpsStateOnStatusUpdateWillNotPassStatusUpdate()
143
- {
144
- $payment = Mage::getModel('sales/order_payment');
145
- $payment->setAdditionalInformation('status', 9);
146
- $order = Mage::getModel('sales/order');
147
- $order->setPayment($payment);
148
- $order->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
149
- Mage::helper('ops/order')->checkForOpsStateOnStatusUpdate($order);
150
- $this->assertEquals(null, $order->getStatus());
151
- }
152
-
153
  public function testSetDataHelper()
154
  {
155
  $dataHelper = $this->getHelperMock('ops/data');
@@ -157,12 +134,4 @@ class Netresearch_OPS_Test_Helper_OrderTest extends EcomDev_PHPUnit_Test_Case
157
  $helper->setDataHelper($dataHelper);
158
  $this->assertEquals($dataHelper, $helper->getDataHelper());
159
  }
160
-
161
- public function testSetStatusMappingModel()
162
- {
163
- $dataHelper = $this->getModelMock('ops/status_mapping');
164
- $helper = Mage::helper('ops/order');
165
- $helper->setStatusMappingModel($dataHelper);
166
- $this->assertEquals($dataHelper, $helper->getStatusMappingModel());
167
- }
168
  }
127
  );
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  public function testSetDataHelper()
131
  {
132
  $dataHelper = $this->getHelperMock('ops/data');
134
  $helper->setDataHelper($dataHelper);
135
  $this->assertEquals($dataHelper, $helper->getDataHelper());
136
  }
 
 
 
 
 
 
 
 
137
  }
app/code/community/Netresearch/OPS/Test/Helper/Payment/DirectLink/RequestTest.php CHANGED
@@ -31,7 +31,7 @@ class Netresearch_OPS_Test_Helper_Payment_DirectLink_RequestTest extends EcomDev
31
  foreach ($this->getShippingParams() as $shippingParam) {
32
  $this->assertArrayNotHasKey($shippingParam, $params);
33
  }
34
-
35
  }
36
 
37
  /**
@@ -56,6 +56,7 @@ class Netresearch_OPS_Test_Helper_Payment_DirectLink_RequestTest extends EcomDev
56
  foreach ($this->getShippingParams() as $shippingParam) {
57
  $this->assertArrayHasKey($shippingParam, $params);
58
  }
 
59
 
60
  }
61
 
31
  foreach ($this->getShippingParams() as $shippingParam) {
32
  $this->assertArrayNotHasKey($shippingParam, $params);
33
  }
34
+ $this->assertArrayHasKey('RTIMEOUT', $params);
35
  }
36
 
37
  /**
56
  foreach ($this->getShippingParams() as $shippingParam) {
57
  $this->assertArrayHasKey($shippingParam, $params);
58
  }
59
+ $this->assertArrayHasKey('RTIMEOUT', $params);
60
 
61
  }
62
 
app/code/community/Netresearch/OPS/Test/Helper/Payment/RequestTest.php CHANGED
@@ -145,59 +145,53 @@ class Netresearch_OPS_Test_Helper_Payment_RequestTest extends EcomDev_PHPUnit_Te
145
  $this->assertEquals('DF', $this->getRequestHelper()->getIsoRegionCode($address));
146
  }
147
 
148
- public function testGetTemplateParamsTemplateMode()
149
  {
150
- $this->markTestIncomplete('Depends on PCI release');
151
-
152
  $config = $this->getModelMock('ops/config', array('getConfigData'));
153
  $config->expects($this->any())
154
  ->method('getConfigData')
155
- ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE));
156
  $helper = Mage::helper('ops/payment_request');
157
  $helper->setConfig($config);
158
 
159
  $params = $helper->getTemplateParams();
160
- $this->assertArrayNotHasKey('PARAMPLUS', $params);
161
- $this->assertArrayNotHasKey('TITLE', $params);
162
- $this->assertArrayHasKey('TP', $params);
163
 
 
 
 
 
164
  }
165
 
166
- public function testGetTemplateParamsInternalTemplateMode()
167
  {
168
- $this->markTestIncomplete('Depends on PCI release');
169
-
170
  $config = $this->getModelMock('ops/config', array('getConfigData'));
171
  $config->expects($this->any())
172
  ->method('getConfigData')
173
- ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL));
174
  $helper = Mage::helper('ops/payment_request');
175
  $helper->setConfig($config);
176
 
177
  $params = $helper->getTemplateParams();
 
178
  $this->assertArrayNotHasKey('PARAMPLUS', $params);
179
  $this->assertArrayNotHasKey('TITLE', $params);
180
- $this->assertArrayHasKey('TP', $params);
181
- $this->assertEquals($config->getPayPageTemplate(), $params['TP']);
182
 
183
  }
184
 
185
- public function testGetTemplateParamsNoMode()
186
  {
187
- $this->markTestIncomplete('Depends on PCI release');
188
-
189
  $config = $this->getModelMock('ops/config', array('getConfigData'));
190
  $config->expects($this->any())
191
  ->method('getConfigData')
192
- ->will($this->returnValue(null));
193
  $helper = Mage::helper('ops/payment_request');
194
  $helper->setConfig($config);
195
 
196
  $params = $helper->getTemplateParams();
197
  $this->assertArrayNotHasKey('PARAMPLUS', $params);
198
- $this->assertArrayNotHasKey('TITLE', $params);
199
  $this->assertArrayNotHasKey('TP', $params);
200
- $this->isEmpty($params);
201
  }
202
 
203
  public function testExtractOrderItemParametersWithAllItems()
@@ -271,4 +265,56 @@ class Netresearch_OPS_Test_Helper_Payment_RequestTest extends EcomDev_PHPUnit_Te
271
  $this->assertArrayNotHasKey('ITEMID2', $formFields);
272
  $this->assertArrayNotHasKey('ITEMID3', $formFields);
273
  }
274
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  $this->assertEquals('DF', $this->getRequestHelper()->getIsoRegionCode($address));
146
  }
147
 
148
+ public function testGetTemplateParamsIframeMode()
149
  {
 
 
150
  $config = $this->getModelMock('ops/config', array('getConfigData'));
151
  $config->expects($this->any())
152
  ->method('getConfigData')
153
+ ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME));
154
  $helper = Mage::helper('ops/payment_request');
155
  $helper->setConfig($config);
156
 
157
  $params = $helper->getTemplateParams();
 
 
 
158
 
159
+ $this->assertArrayHasKey('PARAMPLUS', $params);
160
+ $this->assertEquals('IFRAME=1', $params['PARAMPLUS']);
161
+ $this->assertArrayHasKey('TITLE', $params);
162
+ $this->assertArrayNotHasKey('TP', $params);
163
  }
164
 
165
+ public function testGetTemplateParamsNoMode()
166
  {
 
 
167
  $config = $this->getModelMock('ops/config', array('getConfigData'));
168
  $config->expects($this->any())
169
  ->method('getConfigData')
170
+ ->will($this->returnValue(null));
171
  $helper = Mage::helper('ops/payment_request');
172
  $helper->setConfig($config);
173
 
174
  $params = $helper->getTemplateParams();
175
+
176
  $this->assertArrayNotHasKey('PARAMPLUS', $params);
177
  $this->assertArrayNotHasKey('TITLE', $params);
178
+ $this->assertArrayNotHasKey('TP', $params);
 
179
 
180
  }
181
 
182
+ public function testGetTemplateParamsRedirectMode()
183
  {
 
 
184
  $config = $this->getModelMock('ops/config', array('getConfigData'));
185
  $config->expects($this->any())
186
  ->method('getConfigData')
187
+ ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_REDIRECT));
188
  $helper = Mage::helper('ops/payment_request');
189
  $helper->setConfig($config);
190
 
191
  $params = $helper->getTemplateParams();
192
  $this->assertArrayNotHasKey('PARAMPLUS', $params);
193
+ $this->assertArrayHasKey('TITLE', $params);
194
  $this->assertArrayNotHasKey('TP', $params);
 
195
  }
196
 
197
  public function testExtractOrderItemParametersWithAllItems()
265
  $this->assertArrayNotHasKey('ITEMID2', $formFields);
266
  $this->assertArrayNotHasKey('ITEMID3', $formFields);
267
  }
268
+
269
+ public function testGetTemplateParamsTemplateMode()
270
+ {
271
+ $config = $this->getModelMock('ops/config', array('getConfigData'));
272
+ $config->expects($this->any())
273
+ ->method('getConfigData')
274
+ ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE));
275
+ $helper = Mage::helper('ops/payment_request');
276
+ $helper->setConfig($config);
277
+
278
+ $params = $helper->getTemplateParams();
279
+ $this->assertArrayNotHasKey('PARAMPLUS', $params);
280
+ $this->assertArrayNotHasKey('TITLE', $params);
281
+ $this->assertArrayHasKey('TP', $params);
282
+
283
+ }
284
+
285
+ public function testGetTemplateParamsInternalTemplateMode()
286
+ {
287
+ $config = $this->getModelMock('ops/config', array('getConfigData'));
288
+ $config->expects($this->any())
289
+ ->method('getConfigData')
290
+ ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL));
291
+ $helper = Mage::helper('ops/payment_request');
292
+ $helper->setConfig($config);
293
+
294
+ $params = $helper->getTemplateParams();
295
+ $this->assertArrayNotHasKey('PARAMPLUS', $params);
296
+ $this->assertArrayNotHasKey('TITLE', $params);
297
+ $this->assertArrayHasKey('TP', $params);
298
+ $this->assertEquals($config->getPayPageTemplate(), $params['TP']);
299
+ }
300
+
301
+ public function testGetMandatoryRequestFieldsWithFPActiveOff()
302
+ {
303
+ $payment = Mage::getModel('sales/order_payment');
304
+ $payment->setMethod('ops_cc');
305
+ $order = Mage::getModel('sales/order');
306
+ $order->setStoreId(0)->setPayment($payment);
307
+ $subject = Mage::helper('ops/payment_request');
308
+ $sessionMock = $this->mockSession('customer/session', array('getData'));
309
+ $sessionMock->expects($this->any())
310
+ ->method('getData')
311
+ ->with(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY)
312
+ ->will($this->returnValue(true));
313
+
314
+ $params = $subject->getMandatoryRequestFields($order);
315
+
316
+ $this->assertEquals(0, $params['FP_ACTIV']);
317
+
318
+ }
319
+
320
+ }
app/code/community/Netresearch/OPS/Test/Helper/PaymentTest.php CHANGED
@@ -17,22 +17,22 @@ class Netresearch_OPS_Test_Helper_PaymentTest
17
  {
18
  $this->assertTrue(
19
  $this->_helper->isPaymentAuthorizeType(
20
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED
21
  )
22
  );
23
  $this->assertTrue(
24
  $this->_helper->isPaymentAuthorizeType(
25
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING
26
  )
27
  );
28
  $this->assertTrue(
29
  $this->_helper->isPaymentAuthorizeType(
30
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_UNKNOWN
31
  )
32
  );
33
  $this->assertTrue(
34
  $this->_helper->isPaymentAuthorizeType(
35
- Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT
36
  )
37
  );
38
  $this->assertFalse($this->_helper->isPaymentAuthorizeType(0));
@@ -42,17 +42,17 @@ class Netresearch_OPS_Test_Helper_PaymentTest
42
  {
43
  $this->assertTrue(
44
  $this->_helper->isPaymentCaptureType(
45
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED
46
  )
47
  );
48
  $this->assertTrue(
49
  $this->_helper->isPaymentCaptureType(
50
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING
51
  )
52
  );
53
  $this->assertTrue(
54
  $this->_helper->isPaymentCaptureType(
55
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN
56
  )
57
  );
58
  $this->assertFalse($this->_helper->isPaymentCaptureType(0));
@@ -386,7 +386,16 @@ class Netresearch_OPS_Test_Helper_PaymentTest
386
  */
387
  public function testApplyStateForOrder()
388
  {
 
 
 
 
 
 
 
 
389
  $order = Mage::getModel('sales/order')->load(19);
 
390
  $paymenthelperMock = $this->getHelperMock(
391
  'ops/payment', array(
392
  'acceptOrder',
@@ -401,109 +410,102 @@ class Netresearch_OPS_Test_Helper_PaymentTest
401
  $this->assertEquals(
402
  'accept', $paymenthelperMock->applyStateForOrder(
403
  $order,
404
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT)
405
  )
406
  );
407
 
408
- // assertion for OPS_WAITING_FOR_IDENTIFICATION = 46
409
  $this->assertEquals(
410
  'accept', $paymenthelperMock->applyStateForOrder(
411
  $order,
412
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_WAITING_FOR_IDENTIFICATION)
413
  )
414
  );
415
 
416
- // assertion for OPS_AUTHORIZED = 5
417
  $this->assertEquals(
418
  'accept', $paymenthelperMock->applyStateForOrder(
419
  $order,
420
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED)
421
  )
422
  );
423
- // assertion for OPS_AUTHORIZED_KWIXO = 50
424
  $this->assertEquals(
425
  'accept', $paymenthelperMock->applyStateForOrder(
426
  $order,
427
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_KWIXO)
428
  )
429
  );
430
 
431
- // assertion for OPS_AUTHORIZED_WAITING = 51
432
  $this->assertEquals(
433
  'accept', $paymenthelperMock->applyStateForOrder(
434
  $order,
435
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING)
436
  )
437
  );
438
 
439
- // assertion for OPS_AUTHORIZED_UNKNOWN = 52
440
  $this->assertEquals(
441
  'accept', $paymenthelperMock->applyStateForOrder(
442
  $order,
443
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_UNKNOWN)
444
  )
445
  );
446
 
447
- // assertion for OPS_AWAIT_CUSTOMER_PAYMENT = 41
448
  $this->assertEquals(
449
  'accept', $paymenthelperMock->applyStateForOrder(
450
  $order,
451
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT)
452
  )
453
  );
454
 
455
- // assertion for OPS_PAYMENT_REQUESTED = 9
456
  $this->assertEquals(
457
  'accept', $paymenthelperMock->applyStateForOrder(
458
  $order,
459
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED)
460
  )
461
  );
462
- // assertion for OPS_PAYMENT_PROCESSING = 91
463
  $this->assertEquals(
464
  'accept', $paymenthelperMock->applyStateForOrder(
465
  $order,
466
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING)
467
  )
468
  );
469
  // assertion for OPS_OPEN_INVOICE_DE_PROCESSED = 41000001
470
  $this->assertEquals(
471
  'accept', $paymenthelperMock->applyStateForOrder(
472
  $order,
473
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_OPEN_INVOICE_DE_PROCESSED)
474
  )
475
  );
476
- // assertion for OPS_AUTH_REFUSED = 2
477
  $this->assertEquals(
478
  'decline', $paymenthelperMock->applyStateForOrder(
479
  $order,
480
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTH_REFUSED)
481
  )
482
  );
483
- // assertion for OPS_PAYMENT_REFUSED = 93
484
  $this->assertEquals(
485
  'decline', $paymenthelperMock->applyStateForOrder(
486
  $order,
487
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED)
488
  )
489
  );
490
- // assertion for OPS_PAYMENT_CANCELED_BY_CUSTOMER = 1
491
  $this->assertEquals(
492
  'cancel', $paymenthelperMock->applyStateForOrder(
493
  $order,
494
  array(
495
- 'STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_CANCELED_BY_CUSTOMER,
496
  'PAYID' => 4711
497
  )
498
  )
499
  );
500
- // assertion for exception case
501
- $this->assertEquals(
502
- 'exception', $paymenthelperMock->applyStateForOrder(
503
- $order,
504
- array('STATUS' => 'default')
505
- )
506
- );
507
  }
508
 
509
  /**
@@ -584,10 +586,14 @@ class Netresearch_OPS_Test_Helper_PaymentTest
584
 
585
  public function testIsInlinePaymentWithOrderIdIsTrueForInlineCcWithOrderId()
586
  {
587
- $ccMock = $this->getModelMock('ops/payment_cc', array('getConfigPaymentAction', 'hasBrandAliasInterfaceSupport'));
588
- $ccMock->expects($this->once())
589
- ->method('getConfigPaymentAction')
590
- ->will($this->returnValue('authorize_capture'));
 
 
 
 
591
  $ccMock->expects($this->once())
592
  ->method('hasBrandAliasInterfaceSupport')
593
  ->will($this->returnValue(true));
@@ -622,14 +628,19 @@ class Netresearch_OPS_Test_Helper_PaymentTest
622
 
623
  public function testIsInlinePaymentWithOrderIdIsFalseIfQuoteIdIsConfigured()
624
  {
625
- $ccMock = $this->getModelMock('ops/payment_cc', array('getConfigPaymentAction', 'hasBrandAliasInterfaceSupport'));
626
- $ccMock->expects($this->once())
627
- ->method('getConfigPaymentAction')
628
- ->will($this->returnValue(''));
 
 
 
 
629
  $ccMock->expects($this->once())
630
  ->method('hasBrandAliasInterfaceSupport')
631
  ->will($this->returnValue(true));
632
 
 
633
  $payment = $this->getModelMock('payment/info', array('getMethodInstance'));
634
  $payment->expects($this->any())
635
  ->method('getMethodInstance')
@@ -640,29 +651,34 @@ class Netresearch_OPS_Test_Helper_PaymentTest
640
 
641
  public function testIsInlinePaymentWithOrderIdIsFalseIfQuoteIdIsConfiguredForDirectDebit()
642
  {
643
- $directDebitMock = $this->getModelMock('ops/payment_directDebit', array('getConfigPaymentAction'));
644
- $directDebitMock->expects($this->once())
645
- ->method('getConfigPaymentAction')
646
- ->will($this->returnValue(''));
 
 
647
 
648
  $payment = $this->getModelMock('payment/info', array('getMethodInstance'));
649
  $payment->expects($this->any())
650
  ->method('getMethodInstance')
651
- ->will($this->returnValue($directDebitMock));
652
 
653
  $this->assertFalse(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
654
  }
655
  public function testIsInlinePaymentWithOrderIdIsTrueIfOrderIdIsConfiguredForDirectDebit()
656
  {
657
- $directDebitMock = $this->getModelMock('ops/payment_directDebit', array('getConfigPaymentAction'));
658
- $directDebitMock->expects($this->once())
659
- ->method('getConfigPaymentAction')
660
- ->will($this->returnValue('authorize'));
 
 
 
661
 
662
  $payment = $this->getModelMock('payment/info', array('getMethodInstance'));
663
  $payment->expects($this->any())
664
  ->method('getMethodInstance')
665
- ->will($this->returnValue($directDebitMock));
666
 
667
  $this->assertTrue(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
668
  }
@@ -694,35 +710,6 @@ class Netresearch_OPS_Test_Helper_PaymentTest
694
  }
695
  }
696
 
697
- public function testCancelOrder()
698
- {
699
- $params = array('status' => 2, 'payid' => 4711);
700
- $status = Mage_Sales_Model_Order::STATE_CANCELED;
701
- $comment = 'TestComment';
702
-
703
- $order = $this->getModelMock('sales/order', array('save', 'cancel', 'setState'));
704
- $order->expects($this->once())
705
- ->method('save');
706
- $order->expects($this->once())
707
- ->method('cancel');
708
- $order->expects($this->once())
709
- ->method('setState')
710
- ->with(Mage_Sales_Model_Order::STATE_CANCELED, $status, $comment)
711
- ;
712
-
713
-
714
- $paymentHelperMock = $this->getHelperMock('ops/payment', array('setPaymentTransactionInformation', '_getCheckout', 'cancelInvoices'));
715
- $paymentHelperMock->expects($this->any())
716
- ->method('setPaymentTransactionInformation');
717
- $paymentHelperMock->expects($this->any())
718
- ->method('_getCheckout')
719
- ->will($this->returnValue($this->getModelMock('checkout/session', array('init', 'save'))))
720
- ;
721
-
722
- $paymentHelperMock->cancelOrder($order, $params, $status, $comment);
723
- Mage::unregister('ops_auto_void');
724
-
725
- }
726
 
727
  /**
728
  * @expectedException Mage_Core_Exception
@@ -812,4 +799,12 @@ class Netresearch_OPS_Test_Helper_PaymentTest
812
  $paymentHelperMock->declineOrder($order, $params);
813
 
814
  }
 
 
 
 
 
 
 
 
815
  }
17
  {
18
  $this->assertTrue(
19
  $this->_helper->isPaymentAuthorizeType(
20
+ Netresearch_OPS_Model_Status::AUTHORIZED
21
  )
22
  );
23
  $this->assertTrue(
24
  $this->_helper->isPaymentAuthorizeType(
25
+ Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING
26
  )
27
  );
28
  $this->assertTrue(
29
  $this->_helper->isPaymentAuthorizeType(
30
+ Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN
31
  )
32
  );
33
  $this->assertTrue(
34
  $this->_helper->isPaymentAuthorizeType(
35
+ Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT
36
  )
37
  );
38
  $this->assertFalse($this->_helper->isPaymentAuthorizeType(0));
42
  {
43
  $this->assertTrue(
44
  $this->_helper->isPaymentCaptureType(
45
+ Netresearch_OPS_Model_Status::PAYMENT_REQUESTED
46
  )
47
  );
48
  $this->assertTrue(
49
  $this->_helper->isPaymentCaptureType(
50
+ Netresearch_OPS_Model_Status::PAYMENT_PROCESSING
51
  )
52
  );
53
  $this->assertTrue(
54
  $this->_helper->isPaymentCaptureType(
55
+ Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN
56
  )
57
  );
58
  $this->assertFalse($this->_helper->isPaymentCaptureType(0));
386
  */
387
  public function testApplyStateForOrder()
388
  {
389
+ $this->mockOrderConfig();
390
+ $helperMock = $this->getHelperMock('ops', array('isAdminSession'));
391
+ $helperMock->expects($this->any())
392
+ ->method('isAdminSession')
393
+ ->will($this->returnValue(false));
394
+ $this->replaceByMock('helper', 'ops', $helperMock);
395
+
396
+
397
  $order = Mage::getModel('sales/order')->load(19);
398
+ /** @var Netresearch_OPS_Helper_Payment $paymenthelperMock */
399
  $paymenthelperMock = $this->getHelperMock(
400
  'ops/payment', array(
401
  'acceptOrder',
410
  $this->assertEquals(
411
  'accept', $paymenthelperMock->applyStateForOrder(
412
  $order,
413
+ array('STATUS' => Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT)
414
  )
415
  );
416
 
417
+ // assertion for WAITING_FOR_IDENTIFICATION = 46
418
  $this->assertEquals(
419
  'accept', $paymenthelperMock->applyStateForOrder(
420
  $order,
421
+ array('STATUS' => Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION)
422
  )
423
  );
424
 
425
+ // assertion for AUTHORIZED = 5
426
  $this->assertEquals(
427
  'accept', $paymenthelperMock->applyStateForOrder(
428
  $order,
429
+ array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED)
430
  )
431
  );
432
+ // assertion for AUTHORIZED_WAITING_EXTERNAL_RESULT = 50
433
  $this->assertEquals(
434
  'accept', $paymenthelperMock->applyStateForOrder(
435
  $order,
436
+ array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED_WAITING_EXTERNAL_RESULT)
437
  )
438
  );
439
 
440
+ // assertion for AUTHORIZATION_WAITING = 51
441
  $this->assertEquals(
442
  'accept', $paymenthelperMock->applyStateForOrder(
443
  $order,
444
+ array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING)
445
  )
446
  );
447
 
448
+ // assertion for AUTHORIZED_UNKNOWN = 52
449
  $this->assertEquals(
450
  'accept', $paymenthelperMock->applyStateForOrder(
451
  $order,
452
+ array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN)
453
  )
454
  );
455
 
456
+ // assertion for WAITING_CLIENT_PAYMENT = 41
457
  $this->assertEquals(
458
  'accept', $paymenthelperMock->applyStateForOrder(
459
  $order,
460
+ array('STATUS' => Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT)
461
  )
462
  );
463
 
464
+ // assertion for PAYMENT_REQUESTED = 9
465
  $this->assertEquals(
466
  'accept', $paymenthelperMock->applyStateForOrder(
467
  $order,
468
+ array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_REQUESTED)
469
  )
470
  );
471
+ // assertion for PAYMENT_PROCESSING = 91
472
  $this->assertEquals(
473
  'accept', $paymenthelperMock->applyStateForOrder(
474
  $order,
475
+ array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_PROCESSING)
476
  )
477
  );
478
  // assertion for OPS_OPEN_INVOICE_DE_PROCESSED = 41000001
479
  $this->assertEquals(
480
  'accept', $paymenthelperMock->applyStateForOrder(
481
  $order,
482
+ array('STATUS' => Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT)
483
  )
484
  );
485
+ // assertion for AUTHORISATION_DECLINED = 2
486
  $this->assertEquals(
487
  'decline', $paymenthelperMock->applyStateForOrder(
488
  $order,
489
+ array('STATUS' => Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED)
490
  )
491
  );
492
+ // assertion for PAYMENT_REFUSED = 93
493
  $this->assertEquals(
494
  'decline', $paymenthelperMock->applyStateForOrder(
495
  $order,
496
+ array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_REFUSED)
497
  )
498
  );
499
+ // assertion for CANCELED_BY_CUSTOMER = 1
500
  $this->assertEquals(
501
  'cancel', $paymenthelperMock->applyStateForOrder(
502
  $order,
503
  array(
504
+ 'STATUS' => Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER,
505
  'PAYID' => 4711
506
  )
507
  )
508
  );
 
 
 
 
 
 
 
509
  }
510
 
511
  /**
586
 
587
  public function testIsInlinePaymentWithOrderIdIsTrueForInlineCcWithOrderId()
588
  {
589
+ $configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
590
+
591
+ $configMock->expects($this->any())
592
+ ->method('getInlineOrderReference')
593
+ ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID));
594
+ $this->replaceByMock('singleton', 'ops/config', $configMock);
595
+
596
+ $ccMock = $this->getModelMock('ops/payment_cc', array('hasBrandAliasInterfaceSupport'));
597
  $ccMock->expects($this->once())
598
  ->method('hasBrandAliasInterfaceSupport')
599
  ->will($this->returnValue(true));
628
 
629
  public function testIsInlinePaymentWithOrderIdIsFalseIfQuoteIdIsConfigured()
630
  {
631
+ $configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
632
+
633
+ $configMock->expects($this->any())
634
+ ->method('getInlineOrderReference')
635
+ ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::REFERENCE_QUOTE_ID));
636
+ $this->replaceByMock('singleton', 'ops/config', $configMock);
637
+
638
+ $ccMock = $this->getModelMock('ops/payment_cc', array('hasBrandAliasInterfaceSupport', 'getConfig'));
639
  $ccMock->expects($this->once())
640
  ->method('hasBrandAliasInterfaceSupport')
641
  ->will($this->returnValue(true));
642
 
643
+
644
  $payment = $this->getModelMock('payment/info', array('getMethodInstance'));
645
  $payment->expects($this->any())
646
  ->method('getMethodInstance')
651
 
652
  public function testIsInlinePaymentWithOrderIdIsFalseIfQuoteIdIsConfiguredForDirectDebit()
653
  {
654
+ $configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
655
+
656
+ $configMock->expects($this->any())
657
+ ->method('getInlineOrderReference')
658
+ ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::REFERENCE_QUOTE_ID));
659
+ $this->replaceByMock('singleton', 'ops/config', $configMock);
660
 
661
  $payment = $this->getModelMock('payment/info', array('getMethodInstance'));
662
  $payment->expects($this->any())
663
  ->method('getMethodInstance')
664
+ ->will($this->returnValue(Mage::getModel('ops/payment_directDebit')));
665
 
666
  $this->assertFalse(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
667
  }
668
  public function testIsInlinePaymentWithOrderIdIsTrueIfOrderIdIsConfiguredForDirectDebit()
669
  {
670
+ $configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
671
+
672
+ $configMock->expects($this->any())
673
+ ->method('getInlineOrderReference')
674
+ ->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID));
675
+ $this->replaceByMock('singleton', 'ops/config', $configMock);
676
+
677
 
678
  $payment = $this->getModelMock('payment/info', array('getMethodInstance'));
679
  $payment->expects($this->any())
680
  ->method('getMethodInstance')
681
+ ->will($this->returnValue(Mage::getModel('ops/payment_directDebit')));
682
 
683
  $this->assertTrue(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
684
  }
710
  }
711
  }
712
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
713
 
714
  /**
715
  * @expectedException Mage_Core_Exception
799
  $paymentHelperMock->declineOrder($order, $params);
800
 
801
  }
802
+
803
+ protected function mockOrderConfig(){
804
+ $configMock = $this->getModelMock('sales/order_config',array('getDefaultStatus'));
805
+ $configMock->expects($this->any())
806
+ ->method('getDefaultStatus')
807
+ ->will($this->returnArgument(0));
808
+ $this->replaceByMock('singleton', 'sales/order_config', $configMock);
809
+ }
810
  }
app/code/community/Netresearch/OPS/Test/Helper/QuoteTest.php CHANGED
@@ -131,11 +131,6 @@ class Netresearch_OPS_Test_Helper_QuoteTest extends EcomDev_PHPUnit_Test_Case
131
 
132
  public function testGetQuoteWithAdminSession()
133
  {
134
- $dataHelperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
135
- $dataHelperMock->expects($this->once())
136
- ->method('isAdminSession')
137
- ->will($this->returnValue(true));
138
-
139
  $fakeQuote = $this->getModelMock('sales/quote');
140
  $this->replaceByMock('model', 'sales/quote', $fakeQuote);
141
 
@@ -146,16 +141,12 @@ class Netresearch_OPS_Test_Helper_QuoteTest extends EcomDev_PHPUnit_Test_Case
146
  $sessionMock->setData('quote', $fakeQuote);
147
  $this->replaceByMock('singleton', 'adminhtml/session_quote', $sessionMock);
148
  $helper = Mage::helper('ops/quote');
149
- $helper->setDataHelper($dataHelperMock);
150
  $this->assertEquals($fakeQuote, $helper->getQuote());
151
  }
152
 
153
  public function testGetQuoteWithCheckoutSession()
154
  {
155
- $dataHelperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
156
- $dataHelperMock->expects($this->once())
157
- ->method('isAdminSession')
158
- ->will($this->returnValue(false));
159
 
160
  $fakeQuote = $this->getModelMock('sales/quote', array('setStoreId'));
161
  $fakeQuote->expects($this->any())
@@ -176,8 +167,8 @@ class Netresearch_OPS_Test_Helper_QuoteTest extends EcomDev_PHPUnit_Test_Case
176
  ->getMock();
177
  $sessionMock->setData('quote', $fakeQuote);
178
  $this->replaceByMock('singleton', 'checkout/session', $sessionMock);
 
179
  $helper = Mage::helper('ops/quote');
180
- $helper->setDataHelper($dataHelperMock);
181
  $this->assertEquals($fakeQuote, $helper->getQuote());
182
  }
183
 
131
 
132
  public function testGetQuoteWithAdminSession()
133
  {
 
 
 
 
 
134
  $fakeQuote = $this->getModelMock('sales/quote');
135
  $this->replaceByMock('model', 'sales/quote', $fakeQuote);
136
 
141
  $sessionMock->setData('quote', $fakeQuote);
142
  $this->replaceByMock('singleton', 'adminhtml/session_quote', $sessionMock);
143
  $helper = Mage::helper('ops/quote');
 
144
  $this->assertEquals($fakeQuote, $helper->getQuote());
145
  }
146
 
147
  public function testGetQuoteWithCheckoutSession()
148
  {
149
+ Mage::app()->setCurrentStore(1);
 
 
 
150
 
151
  $fakeQuote = $this->getModelMock('sales/quote', array('setStoreId'));
152
  $fakeQuote->expects($this->any())
167
  ->getMock();
168
  $sessionMock->setData('quote', $fakeQuote);
169
  $this->replaceByMock('singleton', 'checkout/session', $sessionMock);
170
+ /** @var Netresearch_OPS_Helper_Quote $helper */
171
  $helper = Mage::helper('ops/quote');
 
172
  $this->assertEquals($fakeQuote, $helper->getQuote());
173
  }
174
 
app/code/community/Netresearch/OPS/Test/Helper/SubscriptionTest.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * SubscriptionTest.php
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Helper_SubscriptionTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+
36
+
37
+ public function testGenerateSubscriptionId()
38
+ {
39
+ $subject = Mage::helper('ops/subscription');
40
+ $profile = Mage::getModel('sales/recurring_profile');
41
+ $profile->setId(123)
42
+ ->setTrialPeriodUnit(true);
43
+ $id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . '123';
44
+ $this->assertEquals($id, $subject->generateSubscriptionId($profile));
45
+ $id .= Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX;
46
+ $this->assertEquals($id, $subject->generateSubscriptionId($profile, true));
47
+ }
48
+
49
+ public function testIsSubscriptionFeedback()
50
+ {
51
+ $subject = Mage::helper('ops/subscription');
52
+ $id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . '123'
53
+ . Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX;
54
+ $params = array(
55
+ 'orderID' => $id
56
+ );
57
+ $this->assertTrue($subject->isSubscriptionFeedback($params));
58
+ $params['orderID'] = '#10123123120';
59
+ $this->assertFalse($subject->isSubscriptionFeedback($params));
60
+
61
+ }
62
+
63
+ /**
64
+ * @loadFixture profile.yaml
65
+ */
66
+ public function testGetProfileForSubscription()
67
+ {
68
+ $subject = Mage::helper('ops/subscription');
69
+
70
+ $id = $subject::SUBSCRIPTION_PREFIX . 1;
71
+
72
+ $profile = $subject->getProfileForSubscription($id);
73
+ $this->assertEquals(1, $profile->getId());
74
+
75
+ $id = $subject::SUBSCRIPTION_PREFIX . 1 . $subject::TRIAL_SUFFIX;
76
+
77
+ $profile = $subject->getProfileForSubscription($id);
78
+ $this->assertEquals(1, $profile->getId());
79
+ }
80
+ /**
81
+ * @loadFixture profile.yaml
82
+ * @expectedException Mage_Core_Exception
83
+ * @expectedExceptionMessage Could find no subscription for id 2
84
+ */
85
+ public function testGetProfileForSubscriptionWithException()
86
+ {
87
+ $subject = Mage::helper('ops/subscription');
88
+
89
+ $id = $subject::SUBSCRIPTION_PREFIX . 2;
90
+
91
+ $profile = $subject->getProfileForSubscription($id);
92
+ $this->assertEquals(1, $profile->getId());
93
+ }
94
+
95
+ public function testIsTrialFeedback()
96
+ {
97
+ $subject = Mage::helper('ops/subscription');
98
+ $id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . '123';
99
+ $this->assertFalse($subject->isTrialFeedback($id));
100
+ $id .= Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX;
101
+ $this->assertTrue($subject->isTrialFeedback($id));
102
+
103
+ }
104
+
105
+ public function testGetBillingDayForPeriodUnit(){
106
+ $subject = Mage::helper('ops/subscription');
107
+
108
+ $this->assertEquals(1, $subject->getBillingDayForPeriodUnit('abc'));
109
+ $this->assertEquals(1, $subject->getBillingDayForPeriodUnit(Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_WEEK));
110
+ $this->assertEquals(15, $subject->getBillingDayForPeriodUnit(Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_MONTH));
111
+ }
112
+
113
+
114
+ }
115
+
app/code/community/Netresearch/OPS/Test/Helper/SubscriptionTest/fixtures/profile.yaml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ customer/entity:
3
+ - entity_id: 1
4
+
5
+ sales/recurring_profile:
6
+ - profile_id: 1
7
+ state: 'active'
8
+ customer_id: 1
9
+ store_id: 1
10
+ method_code: 'ops_recurring_cc'
11
+ reference_id: 'SUB-1'
app/code/community/Netresearch/OPS/Test/Model/Api/DirectLinkTest.php CHANGED
@@ -151,7 +151,7 @@ class Netresearch_OPS_Test_Model_Api_DirectLinkTest extends EcomDev_PHPUnit_Test
151
  STATUS="0"
152
  amount=""
153
  currency=""
154
- CN="Max Müller">
155
  <HTML_ANSWER>PGZvcm0gbmFtZT0iZG93bmxvYWRmb3JtM0QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9UZXN0XzNEX0FDUy5hc3AiIG1ldGhvZD0icG9zdCI+DQo8Tk9TQ1JJUFQ+DQpKYXZhU2NyaXB0IGlzIGN1cnJlbnRseSBkaXNhYmxlZCBvciBpcyBub3Qgc3VwcG9ydGVkIGJ5IHlvdXIgYnJvd3Nlci48YnI+DQpQbGVhc2UgY2xpY2sgb24gdGhlICZxdW90O0NvbnRpbnVlJnF1b3Q7IGJ1dHRvbiB0byBjb250aW51ZSB0aGUgcHJvY2Vzc2luZyBvZiB5b3VyIDMtRCBzZWN1cmUgdHJhbnNhY3Rpb24uPGJyPg0KPGlucHV0IGNsYXNzPSJuY29sIiB0eXBlPSJzdWJtaXQiIHZhbHVlPSJDb250aW51ZSIgaWQ9InN1Ym1pdDEiIG5hbWU9InN1Ym1pdDEiIC8+DQo8L05PU0NSSVBUPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRktFWSIgdmFsdWU9IjA0MzA0MzI4NkE0M0ZDM0YyRDhFMDFCOUM2MzYwRTA1Qzg5NkZEMzYiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGVFMiIHZhbHVlPSIyMDExMDkxMjE2MjQ1MCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZTUCIgdmFsdWU9Ii9uY29sL3Rlc3Qvb3JkZXJkaXJlY3QuYXNwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iUGFSZXEiIHZhbHVlPSI8P3htbCB2ZXJzaW9uPSZxdW90OzEuMCZxdW90Oz8+PFRocmVlRFNlY3VyZT48TWVzc2FnZSBpZD0mcXVvdDsxMjMmcXVvdDs+PFBBUmVxPjx2ZXJzaW9uPjEuMDI8L3ZlcnNpb24+PE1lcmNoYW50PjxtZXJJRD5OUk1BR0VOVE8zPC9tZXJJRD48bmFtZT5OZXRyZXNlYXJjaCBHbWJIICZhbXA7YW1wOyBDby5LRzwvbmFtZT48dXJsPmh0dHA6Ly93d3cubmV0cmVzZWFyY2guZGU8L3VybD48L01lcmNoYW50PjxQdXJjaGFzZT48eGlkPjExNjI4OTgzPC94aWQ+PGFtb3VudD4xMjY4Ljc1PC9hbW91bnQ+PHB1cmNoQW1vdW50PjEyNjguNzU8L3B1cmNoQW1vdW50PjxjdXJyZW5jeT5FVVI8L2N1cnJlbmN5PjwvUHVyY2hhc2U+PENIPjxhY2N0SUQ+NDAwMDAwWFhYWFhYMDAwMjwvYWNjdElEPjxleHBpcnk+MDExNjwvZXhwaXJ5PjxzZWxCcmFuZD48L3NlbEJyYW5kPjwvQ0g+PC9QQVJlcT48L01lc3NhZ2U+PC9UaHJlZURTZWN1cmU+DQoiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJUZXJtVXJsIiB2YWx1ZT0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9BM0RTLmFzcCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Ik1EIiB2YWx1ZT0iTUFJTldQVEVTVDAwMDAxMTYyODk4MzAxKjEwNzUyNjIiIC8+DQo8L2Zvcm0+DQo8Zm9ybSBtZXRob2Q9InBvc3QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9hZ3JlZS5hc3AiIG5hbWU9InVwbG9hZEZvcm0zRCI+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGS0VZIiB2YWx1ZT0iMDZGM0MzMUQ2RkI1MzIzODg4NjhFRjlGNTA5RUNGNzlBQzIwRDJGMyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZUUyIgdmFsdWU9IjIwMTEwOTEyMTYyNDUwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRlNQIiB2YWx1ZT0iL25jb2wvdGVzdC9vcmRlcmRpcmVjdC5hc3AiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJicmFuZGluZyIgdmFsdWU9Ik9nb25lIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0icGF5aWQiIHZhbHVlPSIxMTYyODk4MyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0b3JlYWxpYXMiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJoYXNoX3BhcmFtIiB2YWx1ZT0iOTFBMzA1MjFEMEI0QTA1MEFBRDkzRDM5RDY2RkEyM0Y5OEIzRDQ4RCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InhpZF8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0YXR1c18zRCIgdmFsdWU9IlhYIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iZWNpXzNEIiB2YWx1ZT0iNyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhcmRudW1iZXIiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJFY29tX1BheW1lbnRfQ2FyZF9WZXJpZmljYXRpb24iIHZhbHVlPSIqMTA3NTI2MiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNWQ0ZsYWciIHZhbHVlPSIxIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iY2F2dl8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhdnZhbGdvcml0aG1fM0QiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJzaWduYXR1cmVPS18zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Imhhc2hfcGFyYW1fM0QiIHZhbHVlPSIwMzAzREZDMkI1OTM0MjZCQTExRkQ5RjJBNkQ0NDk5ODEwN0JGN0YzIiAvPg0KPC9mb3JtPg0KPFNDUklQVCBMQU5HVUFHRT0iSmF2YXNjcmlwdCIgRk9SPSJ3aW5kb3ciIEVWRU5UPSJvbkxvYWQiPg0KdmFyIHBvcHVwV2luOw0KdmFyIHN1Ym1pdHBvcHVwV2luID0gMDsNCg0KZnVuY3Rpb24gTG9hZFBvcHVwKCkgew0KCWlmIChzZWxmLm5hbWUgPT0gbnVsbCkJew0KCQlzZWxmLm5hbWUgPSAib2dvbmVNYWluIjsNCgl9DQoJcG9wdXBXaW4gPSB3aW5kb3cub3BlbignYWJvdXQ6YmxhbmsnLCAncG9wdXBXaW4nLCAnaGVpZ2h0PTQwMCwgd2lkdGg9MzkwLCBzdGF0dXM9eWVzLCBkZXBlbmRlbnQ9bm8sIHNjcm9sbGJhcnM9eWVzLCByZXNpemFibGU9bm8nKTsNCglpZiAocG9wdXBXaW4gIT0gbnVsbCkgew0KCQlpZiAgKCFwb3B1cFdpbiB8fCBwb3B1cFdpbi5jbG9zZWQpIHsNCgkJCXJldHVybiAxOw0KCQl9IGVsc2Ugew0KCQkJaWYgKCFwb3B1cFdpbi5vcGVuZXIgfHwgcG9wdXBXaW4ub3BlbmVyID09IG51bGwpIHsNCgkJCQlwb3B1cFdpbi5vcGVuZXIgPSBzZWxmOw0KCQkJfQ0KCQkJc2VsZi5kb2N1bWVudC5mb3Jtcy5kb3dubG9hZGZvcm0zRC50YXJnZXQgPSAncG9wdXBXaW4nOw0KCQkJaWYgKHN1Ym1pdHBvcHVwV2luID09IDEpIHsNCgkJCQlzZWxmLmRvY3VtZW50LmZvcm1zLmRvd25sb2FkZm9ybTNELnN1Ym1pdCgpOw0KCQkJfQ0KCQkJcG9wdXBXaW4uZm9jdXMoKTsNCgkJCXJldHVybiAwOw0KCQl9DQoJfSBlbHNlIHsNCgkJcmV0dXJuIDE7DQoJfQ0KfQ0KCXNlbGYuZG9jdW1lbnQuZm9ybXMuZG93bmxvYWRmb3JtM0Quc3VibWl0KCk7DQovLy0tPg0KPC9TQ1JJUFQ+DQo=</HTML_ANSWER>
156
  </ncresponse>';
157
  $xmlExample = utf8_decode($xmlExample);
@@ -178,7 +178,7 @@ class Netresearch_OPS_Test_Model_Api_DirectLinkTest extends EcomDev_PHPUnit_Test
178
  $this->assertTrue(array_key_exists('currency', $result));
179
  $this->assertTrue(array_key_exists('HTML_ANSWER', $result));
180
  $this->assertTrue(array_key_exists('CN', $result));
181
- $this->assertEquals('Max Müller', $result['CN']);
182
  }
183
 
184
  /**
151
  STATUS="0"
152
  amount=""
153
  currency=""
154
+ CN="Max Mueller">
155
  <HTML_ANSWER>PGZvcm0gbmFtZT0iZG93bmxvYWRmb3JtM0QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9UZXN0XzNEX0FDUy5hc3AiIG1ldGhvZD0icG9zdCI+DQo8Tk9TQ1JJUFQ+DQpKYXZhU2NyaXB0IGlzIGN1cnJlbnRseSBkaXNhYmxlZCBvciBpcyBub3Qgc3VwcG9ydGVkIGJ5IHlvdXIgYnJvd3Nlci48YnI+DQpQbGVhc2UgY2xpY2sgb24gdGhlICZxdW90O0NvbnRpbnVlJnF1b3Q7IGJ1dHRvbiB0byBjb250aW51ZSB0aGUgcHJvY2Vzc2luZyBvZiB5b3VyIDMtRCBzZWN1cmUgdHJhbnNhY3Rpb24uPGJyPg0KPGlucHV0IGNsYXNzPSJuY29sIiB0eXBlPSJzdWJtaXQiIHZhbHVlPSJDb250aW51ZSIgaWQ9InN1Ym1pdDEiIG5hbWU9InN1Ym1pdDEiIC8+DQo8L05PU0NSSVBUPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRktFWSIgdmFsdWU9IjA0MzA0MzI4NkE0M0ZDM0YyRDhFMDFCOUM2MzYwRTA1Qzg5NkZEMzYiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGVFMiIHZhbHVlPSIyMDExMDkxMjE2MjQ1MCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZTUCIgdmFsdWU9Ii9uY29sL3Rlc3Qvb3JkZXJkaXJlY3QuYXNwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iUGFSZXEiIHZhbHVlPSI8P3htbCB2ZXJzaW9uPSZxdW90OzEuMCZxdW90Oz8+PFRocmVlRFNlY3VyZT48TWVzc2FnZSBpZD0mcXVvdDsxMjMmcXVvdDs+PFBBUmVxPjx2ZXJzaW9uPjEuMDI8L3ZlcnNpb24+PE1lcmNoYW50PjxtZXJJRD5OUk1BR0VOVE8zPC9tZXJJRD48bmFtZT5OZXRyZXNlYXJjaCBHbWJIICZhbXA7YW1wOyBDby5LRzwvbmFtZT48dXJsPmh0dHA6Ly93d3cubmV0cmVzZWFyY2guZGU8L3VybD48L01lcmNoYW50PjxQdXJjaGFzZT48eGlkPjExNjI4OTgzPC94aWQ+PGFtb3VudD4xMjY4Ljc1PC9hbW91bnQ+PHB1cmNoQW1vdW50PjEyNjguNzU8L3B1cmNoQW1vdW50PjxjdXJyZW5jeT5FVVI8L2N1cnJlbmN5PjwvUHVyY2hhc2U+PENIPjxhY2N0SUQ+NDAwMDAwWFhYWFhYMDAwMjwvYWNjdElEPjxleHBpcnk+MDExNjwvZXhwaXJ5PjxzZWxCcmFuZD48L3NlbEJyYW5kPjwvQ0g+PC9QQVJlcT48L01lc3NhZ2U+PC9UaHJlZURTZWN1cmU+DQoiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJUZXJtVXJsIiB2YWx1ZT0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9BM0RTLmFzcCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Ik1EIiB2YWx1ZT0iTUFJTldQVEVTVDAwMDAxMTYyODk4MzAxKjEwNzUyNjIiIC8+DQo8L2Zvcm0+DQo8Zm9ybSBtZXRob2Q9InBvc3QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9hZ3JlZS5hc3AiIG5hbWU9InVwbG9hZEZvcm0zRCI+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGS0VZIiB2YWx1ZT0iMDZGM0MzMUQ2RkI1MzIzODg4NjhFRjlGNTA5RUNGNzlBQzIwRDJGMyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZUUyIgdmFsdWU9IjIwMTEwOTEyMTYyNDUwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRlNQIiB2YWx1ZT0iL25jb2wvdGVzdC9vcmRlcmRpcmVjdC5hc3AiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJicmFuZGluZyIgdmFsdWU9Ik9nb25lIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0icGF5aWQiIHZhbHVlPSIxMTYyODk4MyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0b3JlYWxpYXMiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJoYXNoX3BhcmFtIiB2YWx1ZT0iOTFBMzA1MjFEMEI0QTA1MEFBRDkzRDM5RDY2RkEyM0Y5OEIzRDQ4RCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InhpZF8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0YXR1c18zRCIgdmFsdWU9IlhYIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iZWNpXzNEIiB2YWx1ZT0iNyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhcmRudW1iZXIiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJFY29tX1BheW1lbnRfQ2FyZF9WZXJpZmljYXRpb24iIHZhbHVlPSIqMTA3NTI2MiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNWQ0ZsYWciIHZhbHVlPSIxIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iY2F2dl8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhdnZhbGdvcml0aG1fM0QiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJzaWduYXR1cmVPS18zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Imhhc2hfcGFyYW1fM0QiIHZhbHVlPSIwMzAzREZDMkI1OTM0MjZCQTExRkQ5RjJBNkQ0NDk5ODEwN0JGN0YzIiAvPg0KPC9mb3JtPg0KPFNDUklQVCBMQU5HVUFHRT0iSmF2YXNjcmlwdCIgRk9SPSJ3aW5kb3ciIEVWRU5UPSJvbkxvYWQiPg0KdmFyIHBvcHVwV2luOw0KdmFyIHN1Ym1pdHBvcHVwV2luID0gMDsNCg0KZnVuY3Rpb24gTG9hZFBvcHVwKCkgew0KCWlmIChzZWxmLm5hbWUgPT0gbnVsbCkJew0KCQlzZWxmLm5hbWUgPSAib2dvbmVNYWluIjsNCgl9DQoJcG9wdXBXaW4gPSB3aW5kb3cub3BlbignYWJvdXQ6YmxhbmsnLCAncG9wdXBXaW4nLCAnaGVpZ2h0PTQwMCwgd2lkdGg9MzkwLCBzdGF0dXM9eWVzLCBkZXBlbmRlbnQ9bm8sIHNjcm9sbGJhcnM9eWVzLCByZXNpemFibGU9bm8nKTsNCglpZiAocG9wdXBXaW4gIT0gbnVsbCkgew0KCQlpZiAgKCFwb3B1cFdpbiB8fCBwb3B1cFdpbi5jbG9zZWQpIHsNCgkJCXJldHVybiAxOw0KCQl9IGVsc2Ugew0KCQkJaWYgKCFwb3B1cFdpbi5vcGVuZXIgfHwgcG9wdXBXaW4ub3BlbmVyID09IG51bGwpIHsNCgkJCQlwb3B1cFdpbi5vcGVuZXIgPSBzZWxmOw0KCQkJfQ0KCQkJc2VsZi5kb2N1bWVudC5mb3Jtcy5kb3dubG9hZGZvcm0zRC50YXJnZXQgPSAncG9wdXBXaW4nOw0KCQkJaWYgKHN1Ym1pdHBvcHVwV2luID09IDEpIHsNCgkJCQlzZWxmLmRvY3VtZW50LmZvcm1zLmRvd25sb2FkZm9ybTNELnN1Ym1pdCgpOw0KCQkJfQ0KCQkJcG9wdXBXaW4uZm9jdXMoKTsNCgkJCXJldHVybiAwOw0KCQl9DQoJfSBlbHNlIHsNCgkJcmV0dXJuIDE7DQoJfQ0KfQ0KCXNlbGYuZG9jdW1lbnQuZm9ybXMuZG93bmxvYWRmb3JtM0Quc3VibWl0KCk7DQovLy0tPg0KPC9TQ1JJUFQ+DQo=</HTML_ANSWER>
156
  </ncresponse>';
157
  $xmlExample = utf8_decode($xmlExample);
178
  $this->assertTrue(array_key_exists('currency', $result));
179
  $this->assertTrue(array_key_exists('HTML_ANSWER', $result));
180
  $this->assertTrue(array_key_exists('CN', $result));
181
+ $this->assertEquals('Max Mueller', $result['CN']);
182
  }
183
 
184
  /**
app/code/community/Netresearch/OPS/Test/Model/Backend/Operation/Capture/ParameterTest.php CHANGED
@@ -10,8 +10,8 @@ class Netresearch_OPS_Test_Model_Backend_Operation_Capture_ParameterTest extends
10
 
11
  public function testGetRequestParams()
12
  {
13
- $fakePayment = new Varien_Object();
14
- $fakePayment->setOrder(new Varien_Object());
15
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
16
  $arrInfo = array('operation' => 'capture');
17
  $amount = 10;
@@ -26,14 +26,14 @@ class Netresearch_OPS_Test_Model_Backend_Operation_Capture_ParameterTest extends
26
 
27
  $this->assertEquals(1000, $requestParams['AMOUNT']);
28
  $this->assertEquals(4711, $requestParams['PAYID']);
29
- $this->assertEquals('capture', $requestParams['OPERATION']);
30
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
31
  }
32
 
33
  public function testGetRequestParamsWithAdditionalParameters()
34
  {
35
  $fakePayment = Mage::getModel('sales/order_payment');
36
- $fakePayment->setOrder(MAge::getModel('sales/order'));
37
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
38
  $fakeInvoice = Mage::getModel('sales/order_invoice');
39
  $fakePayment->setInvoice($fakeInvoice);
@@ -49,7 +49,7 @@ class Netresearch_OPS_Test_Model_Backend_Operation_Capture_ParameterTest extends
49
 
50
  $this->assertEquals(1000, $requestParams['AMOUNT']);
51
  $this->assertEquals(4711, $requestParams['PAYID']);
52
- $this->assertEquals('capture', $requestParams['OPERATION']);
53
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
54
  }
55
 
10
 
11
  public function testGetRequestParams()
12
  {
13
+ $fakePayment = Mage::getModel('sales/order_payment');
14
+ $fakePayment->setOrder(Mage::getModel('sales/order'));
15
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
16
  $arrInfo = array('operation' => 'capture');
17
  $amount = 10;
26
 
27
  $this->assertEquals(1000, $requestParams['AMOUNT']);
28
  $this->assertEquals(4711, $requestParams['PAYID']);
29
+ $this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_PARTIAL, $requestParams['OPERATION']);
30
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
31
  }
32
 
33
  public function testGetRequestParamsWithAdditionalParameters()
34
  {
35
  $fakePayment = Mage::getModel('sales/order_payment');
36
+ $fakePayment->setOrder(Mage::getModel('sales/order'));
37
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
38
  $fakeInvoice = Mage::getModel('sales/order_invoice');
39
  $fakePayment->setInvoice($fakeInvoice);
49
 
50
  $this->assertEquals(1000, $requestParams['AMOUNT']);
51
  $this->assertEquals(4711, $requestParams['PAYID']);
52
+ $this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_PARTIAL, $requestParams['OPERATION']);
53
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
54
  }
55
 
app/code/community/Netresearch/OPS/Test/Model/Backend/Operation/ParameterTest.php CHANGED
@@ -18,18 +18,25 @@ class Netresearch_OPS_Test_Model_Backend_Operation_ParameterTest extends EcomDev
18
  $arrInfo = array();
19
  $amount = 0;
20
  $opsPaymentMethod = Mage::getModel('ops/payment_abstract');
21
- Mage::getModel('ops/backend_operation_parameter')->getParameterFor('NOT SUPPORTED OPERATION TYPE', $opsPaymentMethod, $fakePayment, $amount, $arrInfo);
 
22
  }
23
 
24
  public function testGetParameterForCaptureWillReturnArray()
25
  {
26
- $fakePayment = new Varien_Object();
27
- $fakePayment->setOrder(new Varien_Object());
28
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
29
- $arrInfo = array('operation' => 'capture');
30
  $amount = 10;
31
  $opsPaymentMethod = Mage::getModel('ops/payment_abstract');
32
- $requestParams = Mage::getModel('ops/backend_operation_parameter')->getParameterFor(Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE, $opsPaymentMethod, $fakePayment, $amount, $arrInfo);
 
 
 
 
 
 
33
  $this->assertArrayHasKey('AMOUNT', $requestParams);
34
  $this->assertArrayHasKey('PAYID', $requestParams);
35
  $this->assertArrayHasKey('OPERATION', $requestParams);
@@ -37,7 +44,7 @@ class Netresearch_OPS_Test_Model_Backend_Operation_ParameterTest extends EcomDev
37
 
38
  $this->assertEquals(1000, $requestParams['AMOUNT']);
39
  $this->assertEquals(4711, $requestParams['PAYID']);
40
- $this->assertEquals('capture', $requestParams['OPERATION']);
41
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
42
  }
43
 
18
  $arrInfo = array();
19
  $amount = 0;
20
  $opsPaymentMethod = Mage::getModel('ops/payment_abstract');
21
+ Mage::getModel('ops/backend_operation_parameter')->getParameterFor(
22
+ 'NOT SUPPORTED OPERATION TYPE', $opsPaymentMethod, $fakePayment, $amount, $arrInfo);
23
  }
24
 
25
  public function testGetParameterForCaptureWillReturnArray()
26
  {
27
+ $fakePayment = Mage::getModel('sales/order_payment');
28
+ $fakePayment->setOrder(Mage::getModel('sales/order'));
29
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
30
+ $arrInfo = array('operation' => Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_PARTIAL);
31
  $amount = 10;
32
  $opsPaymentMethod = Mage::getModel('ops/payment_abstract');
33
+ $requestParams = Mage::getModel('ops/backend_operation_parameter')->getParameterFor(
34
+ Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE,
35
+ $opsPaymentMethod,
36
+ $fakePayment,
37
+ $amount,
38
+ $arrInfo
39
+ );
40
  $this->assertArrayHasKey('AMOUNT', $requestParams);
41
  $this->assertArrayHasKey('PAYID', $requestParams);
42
  $this->assertArrayHasKey('OPERATION', $requestParams);
44
 
45
  $this->assertEquals(1000, $requestParams['AMOUNT']);
46
  $this->assertEquals(4711, $requestParams['PAYID']);
47
+ $this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_PARTIAL, $requestParams['OPERATION']);
48
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
49
  }
50
 
app/code/community/Netresearch/OPS/Test/Model/Backend/Operation/Refund/ParameterTest.php CHANGED
@@ -5,8 +5,8 @@ class Netresearch_OPS_Test_Model_Backend_Operation_Refund_ParameterTest extends
5
 
6
  public function testGetRequestParams()
7
  {
8
- $fakePayment = new Varien_Object();
9
- $fakePayment->setOrder(new Varien_Object());
10
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
11
  $arrInfo = array(
12
  'operation' => 'refund',
@@ -24,12 +24,13 @@ class Netresearch_OPS_Test_Model_Backend_Operation_Refund_ParameterTest extends
24
 
25
  $this->assertEquals(1000, $requestParams['AMOUNT']);
26
  $this->assertEquals(4711, $requestParams['PAYID']);
27
- $this->assertEquals('refund', $requestParams['OPERATION']);
28
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
29
  }
30
 
31
  public function testGetRequestParamsWithAdditionalParameters()
32
  {
 
33
  $fakePayment = Mage::getModel('sales/order_payment');
34
  $fakePayment->setOrder(Mage::getModel('sales/order'));
35
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
@@ -51,7 +52,7 @@ class Netresearch_OPS_Test_Model_Backend_Operation_Refund_ParameterTest extends
51
 
52
  $this->assertEquals(1000, $requestParams['AMOUNT']);
53
  $this->assertEquals(4711, $requestParams['PAYID']);
54
- $this->assertEquals('refund', $requestParams['OPERATION']);
55
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
56
  }
57
 
5
 
6
  public function testGetRequestParams()
7
  {
8
+ $fakePayment = Mage::getModel('sales/order_payment');
9
+ $fakePayment->setOrder(Mage::getModel('sales/order'));
10
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
11
  $arrInfo = array(
12
  'operation' => 'refund',
24
 
25
  $this->assertEquals(1000, $requestParams['AMOUNT']);
26
  $this->assertEquals(4711, $requestParams['PAYID']);
27
+ $this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL, $requestParams['OPERATION']);
28
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
29
  }
30
 
31
  public function testGetRequestParamsWithAdditionalParameters()
32
  {
33
+
34
  $fakePayment = Mage::getModel('sales/order_payment');
35
  $fakePayment->setOrder(Mage::getModel('sales/order'));
36
  $fakePayment->setAdditionalInformation(array('paymentId' => '4711'));
52
 
53
  $this->assertEquals(1000, $requestParams['AMOUNT']);
54
  $this->assertEquals(4711, $requestParams['PAYID']);
55
+ $this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL, $requestParams['OPERATION']);
56
  $this->assertEquals(Mage::app()->getStore($fakePayment->getOrder()->getStoreId())->getBaseCurrencyCode(), $requestParams['CURRENCY']);
57
  }
58
 
app/code/community/Netresearch/OPS/Test/Model/ConfigTest.php CHANGED
@@ -14,6 +14,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
14
  $this->_model = Mage::getModel('ops/config');
15
  }
16
 
 
17
  public function testType()
18
  {
19
  $this->assertInstanceOf('Netresearch_OPS_Model_Config', $this->_model);
@@ -21,13 +22,18 @@ class Netresearch_OPS_Test_Model_ConfigTest
21
 
22
  public function testGetIntersolveBrands()
23
  {
 
 
 
 
 
24
  $this->assertTrue(is_array($this->_model->getIntersolveBrands(null)));
 
25
  $this->assertEquals(
26
- 0,
27
- sizeof($this->_model->getIntersolveBrands(null))
28
  );
29
 
30
- $path = 'payment/ops_interSolve/brands';
31
 
32
  $newVouchers = array(
33
  array('brand' => '1234', 'value' => '1234'),
@@ -50,21 +56,21 @@ class Netresearch_OPS_Test_Model_ConfigTest
50
  );
51
 
52
  $pathRedirectAll = 'payment/ops_cc/redirect_all';
53
- $pathSpecific = 'payment/ops_cc/inline_types';
54
- $store = Mage::app()->getStore(0)->load(0);
55
 
56
  $store->resetConfig();
57
  $store->setConfig($pathRedirectAll, 0);
58
  $store->setConfig($pathSpecific, 'MasterCard,VISA');
59
  $this->assertEquals(
60
  array('MasterCard', 'VISA'),
61
- $this->_model->getInlinePaymentCcTypes()
62
  );
63
 
64
  $store->resetConfig();
65
  $store->setConfig($pathRedirectAll, 1);
66
  $store->setConfig($pathSpecific, 'MasterCard,VISA');
67
- $this->assertEquals(array(), $this->_model->getInlinePaymentCcTypes());
68
 
69
  $store->resetConfig();
70
  }
@@ -75,7 +81,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
75
  $urlModel->expects($this->any())
76
  ->method('getUrl')
77
  ->with(
78
- 'ops/payment/generatehash',
79
  array('_secure' => false, '_nosid' => true)
80
  );
81
  $this->replaceByMock('model', 'core/url', $urlModel);
@@ -85,7 +91,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
85
  $urlModel->expects($this->any())
86
  ->method('getUrl')
87
  ->with(
88
- 'ops/payment/generatehash',
89
  array('_secure' => false, '_nosid' => true, '_store' => 1)
90
  );
91
  $this->replaceByMock('model', 'core/url', $urlModel);
@@ -98,7 +104,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
98
  $urlModel->expects($this->any())
99
  ->method('getUrl')
100
  ->with(
101
- 'ops/payment/acceptAlias',
102
  array('_secure' => false, '_nosid' => true)
103
  );
104
  $this->replaceByMock('model', 'core/url', $urlModel);
@@ -108,7 +114,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
108
  $urlModel->expects($this->any())
109
  ->method('getUrl')
110
  ->with(
111
- 'ops/payment/acceptAlias',
112
  array('_secure' => false, '_nosid' => true, '_store' => 1)
113
  );
114
  $this->replaceByMock('model', 'core/url', $urlModel);
@@ -121,7 +127,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
121
  $urlModel->expects($this->any())
122
  ->method('getUrl')
123
  ->with(
124
- 'ops/payment/exceptionAlias',
125
  array('_secure' => false, '_nosid' => true)
126
  );
127
  $this->replaceByMock('model', 'core/url', $urlModel);
@@ -131,7 +137,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
131
  $urlModel->expects($this->any())
132
  ->method('getUrl')
133
  ->with(
134
- 'ops/payment/exceptionAlias',
135
  array('_secure' => false, '_nosid' => true, '_store' => 1)
136
  );
137
  $this->replaceByMock('model', 'core/url', $urlModel);
@@ -143,7 +149,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
143
  $urlModel = $this->getModelMock('core/url', array('getUrl'));
144
  $urlModel->expects($this->any())
145
  ->method('getUrl')
146
- ->with('ops/payment/saveAlias', array('_secure' => false));
147
  $this->replaceByMock('model', 'core/url', $urlModel);
148
  $this->_model->getCcSaveAliasUrl();
149
 
@@ -151,7 +157,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
151
  $urlModel->expects($this->any())
152
  ->method('getUrl')
153
  ->with(
154
- 'ops/payment/saveAlias',
155
  array('_secure' => false, '_store' => 1)
156
  );
157
  $this->replaceByMock('model', 'core/url', $urlModel);
@@ -160,7 +166,7 @@ class Netresearch_OPS_Test_Model_ConfigTest
160
 
161
  public function testIsAliasInfoBlockEnabled()
162
  {
163
- $path = 'payment/ops_cc/show_alias_manager_info_for_guests';
164
  $store = Mage::app()->getStore(0)->load(0);
165
  $store->resetConfig();
166
  $store->setConfig($path, 0);
@@ -219,28 +225,17 @@ class Netresearch_OPS_Test_Model_ConfigTest
219
  $this->assertEquals(0, $this->_model->getShowQuoteIdInOrderGrid());
220
  }
221
 
222
-
223
- public function testIsTrackingCodeActivated()
224
- {
225
- $store = Mage::app()->getStore(0)->load(0);
226
- $this->assertFalse($this->_model->isTrackingCodeActivated());
227
-
228
- $store->setConfig('payment_services/ops/enableTrackingCode', 1);
229
- $this->assertTrue($this->_model->isTrackingCodeActivated());
230
- }
231
-
232
-
233
  public function testIsAliasManagerEnabled()
234
  {
235
- $path = 'payment/ops_cc/active_alias';
236
  $store = Mage::app()->getStore(0)->load(0);
237
  $store->resetConfig();
238
  $store->setConfig($path, 0);
239
- $this->assertFalse($this->_model->isAliasManagerEnabled());
240
 
241
  $store->resetConfig();
242
  $store->setConfig($path, 1);
243
- $this->assertTrue($this->_model->isAliasManagerEnabled());
244
 
245
  }
246
 
@@ -374,11 +369,11 @@ class Netresearch_OPS_Test_Model_ConfigTest
374
  public function testCanSubmitExtraParameters()
375
  {
376
  $this->assertTrue($this->_model->canSubmitExtraParameter());
377
- $path = 'payment_services/ops/submitExtraParameters';
378
  $store = Mage::app()->getStore(0)->load(0);
379
  $store->resetConfig();
380
  $store->setConfig($path, 0);
381
- $this->assertFalse($this->_model->isAliasManagerEnabled());
382
  }
383
 
384
 
@@ -413,16 +408,6 @@ class Netresearch_OPS_Test_Model_ConfigTest
413
 
414
  }
415
 
416
- public function testCheckForOpsStatusEventExists()
417
- {
418
- $this->assertEventObserverDefined(
419
- 'global',
420
- 'sales_order_save_before',
421
- 'ops/observer',
422
- 'checkForOpsStatus'
423
- );
424
- }
425
-
426
  public function testGetInlineOrderReference()
427
  {
428
  $store = Mage::app()->getStore(0)->load(0);
@@ -441,13 +426,13 @@ class Netresearch_OPS_Test_Model_ConfigTest
441
  );
442
  }
443
 
444
- public function testSetOrderStateForDirectDebitsNlExists()
445
  {
446
  $this->assertEventObserverDefined(
447
  'global',
448
  'sales_order_payment_place_end',
449
  'ops/observer',
450
- 'setOrderStateForDirectDebitsNl'
451
  );
452
  }
453
 
@@ -483,8 +468,21 @@ class Netresearch_OPS_Test_Model_ConfigTest
483
  $this->setMode(Netresearch_OPS_Model_Source_Mode::CUSTOM);
484
  $expectedResult = Mage::getStoreConfig('payment_services/ops/ops_alias_gateway');
485
  $this->assertEquals($expectedResult, $this->_model->getAliasGatewayUrl(0));
 
 
 
 
 
486
  $this->setMode(Netresearch_OPS_Model_Source_Mode::TEST);
487
- $this->assertContains('test', $this->_model->getAliasGatewayUrl(0));
 
 
 
 
 
 
 
 
488
  }
489
 
490
  public function testGetDirectLinkMaintenanceApiPath()
@@ -528,5 +526,46 @@ class Netresearch_OPS_Test_Model_ConfigTest
528
  $this->setMode(Netresearch_OPS_Model_Source_Mode::CUSTOM);
529
  $this->assertEmpty($this->_model->getOpsBaseUrl(0));
530
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
531
  }
532
 
14
  $this->_model = Mage::getModel('ops/config');
15
  }
16
 
17
+
18
  public function testType()
19
  {
20
  $this->assertInstanceOf('Netresearch_OPS_Model_Config', $this->_model);
22
 
23
  public function testGetIntersolveBrands()
24
  {
25
+ $path = 'payment/ops_interSolve/brands';
26
+
27
+
28
+ Mage::getConfig()->saveConfig($path, serialize(array()));
29
+ Mage::getConfig()->cleanCache();
30
  $this->assertTrue(is_array($this->_model->getIntersolveBrands(null)));
31
+
32
  $this->assertEquals(
33
+ sizeof(unserialize(Mage::getStoreConfig('payment/ops_interSolve/brands', 0))),
34
+ sizeof($this->_model->getIntersolveBrands(0))
35
  );
36
 
 
37
 
38
  $newVouchers = array(
39
  array('brand' => '1234', 'value' => '1234'),
56
  );
57
 
58
  $pathRedirectAll = 'payment/ops_cc/redirect_all';
59
+ $pathSpecific = 'payment/ops_cc/inline_types';
60
+ $store = Mage::app()->getStore(0)->load(0);
61
 
62
  $store->resetConfig();
63
  $store->setConfig($pathRedirectAll, 0);
64
  $store->setConfig($pathSpecific, 'MasterCard,VISA');
65
  $this->assertEquals(
66
  array('MasterCard', 'VISA'),
67
+ $this->_model->getInlinePaymentCcTypes('ops_cc')
68
  );
69
 
70
  $store->resetConfig();
71
  $store->setConfig($pathRedirectAll, 1);
72
  $store->setConfig($pathSpecific, 'MasterCard,VISA');
73
+ $this->assertEquals(array(), $this->_model->getInlinePaymentCcTypes('ops_cc'));
74
 
75
  $store->resetConfig();
76
  }
81
  $urlModel->expects($this->any())
82
  ->method('getUrl')
83
  ->with(
84
+ 'ops/alias/generatehash',
85
  array('_secure' => false, '_nosid' => true)
86
  );
87
  $this->replaceByMock('model', 'core/url', $urlModel);
91
  $urlModel->expects($this->any())
92
  ->method('getUrl')
93
  ->with(
94
+ 'ops/alias/generatehash',
95
  array('_secure' => false, '_nosid' => true, '_store' => 1)
96
  );
97
  $this->replaceByMock('model', 'core/url', $urlModel);
104
  $urlModel->expects($this->any())
105
  ->method('getUrl')
106
  ->with(
107
+ 'ops/alias/accept',
108
  array('_secure' => false, '_nosid' => true)
109
  );
110
  $this->replaceByMock('model', 'core/url', $urlModel);
114
  $urlModel->expects($this->any())
115
  ->method('getUrl')
116
  ->with(
117
+ 'ops/alias/accept',
118
  array('_secure' => false, '_nosid' => true, '_store' => 1)
119
  );
120
  $this->replaceByMock('model', 'core/url', $urlModel);
127
  $urlModel->expects($this->any())
128
  ->method('getUrl')
129
  ->with(
130
+ 'ops/alias/exception',
131
  array('_secure' => false, '_nosid' => true)
132
  );
133
  $this->replaceByMock('model', 'core/url', $urlModel);
137
  $urlModel->expects($this->any())
138
  ->method('getUrl')
139
  ->with(
140
+ 'ops/alias/exception',
141
  array('_secure' => false, '_nosid' => true, '_store' => 1)
142
  );
143
  $this->replaceByMock('model', 'core/url', $urlModel);
149
  $urlModel = $this->getModelMock('core/url', array('getUrl'));
150
  $urlModel->expects($this->any())
151
  ->method('getUrl')
152
+ ->with('ops/alias/save', array('_secure' => false));
153
  $this->replaceByMock('model', 'core/url', $urlModel);
154
  $this->_model->getCcSaveAliasUrl();
155
 
157
  $urlModel->expects($this->any())
158
  ->method('getUrl')
159
  ->with(
160
+ 'ops/alias/save',
161
  array('_secure' => false, '_store' => 1)
162
  );
163
  $this->replaceByMock('model', 'core/url', $urlModel);
166
 
167
  public function testIsAliasInfoBlockEnabled()
168
  {
169
+ $path = 'payment/ops_cc/show_alias_manager_info_for_guests';
170
  $store = Mage::app()->getStore(0)->load(0);
171
  $store->resetConfig();
172
  $store->setConfig($path, 0);
225
  $this->assertEquals(0, $this->_model->getShowQuoteIdInOrderGrid());
226
  }
227
 
 
 
 
 
 
 
 
 
 
 
 
228
  public function testIsAliasManagerEnabled()
229
  {
230
+ $path = 'payment/ops_cc/active_alias';
231
  $store = Mage::app()->getStore(0)->load(0);
232
  $store->resetConfig();
233
  $store->setConfig($path, 0);
234
+ $this->assertFalse($this->_model->isAliasManagerEnabled('ops_cc'));
235
 
236
  $store->resetConfig();
237
  $store->setConfig($path, 1);
238
+ $this->assertTrue($this->_model->isAliasManagerEnabled('ops_cc'));
239
 
240
  }
241
 
369
  public function testCanSubmitExtraParameters()
370
  {
371
  $this->assertTrue($this->_model->canSubmitExtraParameter());
372
+ $path = 'payment_services/ops/submitExtraParameters';
373
  $store = Mage::app()->getStore(0)->load(0);
374
  $store->resetConfig();
375
  $store->setConfig($path, 0);
376
+ $this->assertFalse($this->_model->isAliasManagerEnabled('ops_cc'));
377
  }
378
 
379
 
408
 
409
  }
410
 
 
 
 
 
 
 
 
 
 
 
411
  public function testGetInlineOrderReference()
412
  {
413
  $store = Mage::app()->getStore(0)->load(0);
426
  );
427
  }
428
 
429
+ public function testSetOrderStateDirectLinkExists()
430
  {
431
  $this->assertEventObserverDefined(
432
  'global',
433
  'sales_order_payment_place_end',
434
  'ops/observer',
435
+ 'setOrderStateDirectLink'
436
  );
437
  }
438
 
468
  $this->setMode(Netresearch_OPS_Model_Source_Mode::CUSTOM);
469
  $expectedResult = Mage::getStoreConfig('payment_services/ops/ops_alias_gateway');
470
  $this->assertEquals($expectedResult, $this->_model->getAliasGatewayUrl(0));
471
+
472
+ // test with standard alias gateway
473
+ Mage::app()->getStore(0)->setConfig(
474
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH . 'ops_alias_gateway_test', ''
475
+ );
476
  $this->setMode(Netresearch_OPS_Model_Source_Mode::TEST);
477
+ $this->assertContains('ncol/test', $this->_model->getAliasGatewayUrl(0));
478
+
479
+ Mage::app()->getStore(0)->setConfig(
480
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH . 'ops_alias_gateway_test', 'abc'
481
+ );
482
+ $this->assertEquals('abc', $this->_model->getAliasGatewayUrl(0));
483
+
484
+ $this->setMode(Netresearch_OPS_Model_Source_Mode::PROD);
485
+ $this->assertNotContains('ncol/prod', $this->_model->getAliasGatewayUrl(0));
486
  }
487
 
488
  public function testGetDirectLinkMaintenanceApiPath()
526
  $this->setMode(Netresearch_OPS_Model_Source_Mode::CUSTOM);
527
  $this->assertEmpty($this->_model->getOpsBaseUrl(0));
528
  }
529
+
530
+ public function testGetAllRecurringCcTypes()
531
+ {
532
+ /** @var Netresearch_OPS_Model_Config $config */
533
+ $config = Mage::getModel('ops/config');
534
+ $ccTypes = $config->getAllRecurringCcTypes();
535
+ $this->assertEquals(
536
+ $ccTypes, array('American Express', 'Diners Club', 'MaestroUK', 'MasterCard', 'VISA', 'JCB')
537
+ );
538
+ }
539
+
540
+ public function testGetAcceptedRecurringCcTypes()
541
+ {
542
+ /** @var Netresearch_OPS_Model_Config $config */
543
+ $config = Mage::getModel('ops/config');
544
+ $ccTypes = $config->getAcceptedRecurringCcTypes();
545
+ $this->assertEquals(
546
+ $ccTypes, array('American Express', 'Diners Club', 'MaestroUK', 'MasterCard', 'VISA', 'JCB')
547
+ );
548
+ }
549
+
550
+ public function testGetDeviceFingerPrinting()
551
+ {
552
+ $config = Mage::getModel('ops/config');
553
+ // default false
554
+ $this->assertFalse($config->getDeviceFingerPrinting(0));
555
+ Mage::app()->getStore(0)->setConfig(
556
+ Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH . 'device_fingerprinting', 1
557
+ );
558
+ $this->assertTrue($config->getDeviceFingerPrinting(0));
559
+ }
560
+
561
+ public function testGetTransActionTimeout()
562
+ {
563
+ $config = Mage::getModel('ops/config');
564
+ // default false
565
+ Mage::app()->getStore(0)->setConfig(Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH . 'ops_rtimeout', 0);
566
+ $this->assertEquals(0, $config->getTransActionTimeout(0));
567
+ Mage::app()->getStore(0)->setConfig(Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH . 'ops_rtimeout', 45);
568
+ $this->assertEquals(45, $config->getTransActionTimeout(0));
569
+ }
570
  }
571
 
app/code/community/Netresearch/OPS/Test/Model/ObserverTest.php CHANGED
@@ -22,15 +22,15 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
22
  $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
23
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
24
  $payment->expects($this->any())
25
- ->method('save')
26
- ->will($this->returnValue(null));
27
  $this->replaceByMock('model', 'sales/quote_payment', $payment);
28
  $quote->setPayment($payment);
29
  $response = null;
30
  $directLinkMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
31
  $directLinkMock->expects($this->any())
32
- ->method('performRequest')
33
- ->will($this->returnValue($response));
34
  $this->replaceByMock('model', 'ops/api_directlink', $directLinkMock);
35
  $observer = Mage::getModel('ops/observer');
36
  $observer->performDirectLinkRequest($quote, array());
@@ -45,15 +45,15 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
45
  $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
46
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
47
  $payment->expects($this->any())
48
- ->method('save')
49
- ->will($this->returnValue(null));
50
  $this->replaceByMock('model', 'sales/quote_payment', $payment);
51
  $quote->setPayment($payment);
52
  $response = '';
53
  $directLinkMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
54
  $directLinkMock->expects($this->any())
55
- ->method('performRequest')
56
- ->will($this->returnValue($response));
57
  $this->replaceByMock('model', 'ops/api_directlink', $directLinkMock);
58
  $observer = Mage::getModel('ops/observer');
59
  $this->assertTrue($this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'));
@@ -68,15 +68,15 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
68
  $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
69
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
70
  $payment->expects($this->any())
71
- ->method('save')
72
- ->will($this->returnValue(null));
73
  $this->replaceByMock('model', 'sales/quote_payment', $payment);
74
  $quote->setPayment($payment);
75
- $response = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED);
76
  $directLinkMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
77
  $directLinkMock->expects($this->any())
78
- ->method('performRequest')
79
- ->will($this->returnValue($response));
80
  $this->replaceByMock('model', 'ops/api_directlink', $directLinkMock);
81
  $observer = Mage::getModel('ops/observer');
82
  $this->assertFalse($this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'));
@@ -91,15 +91,15 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
91
  $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
92
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
93
  $payment->expects($this->any())
94
- ->method('save')
95
- ->will($this->returnValue(null));
96
  $this->replaceByMock('model', 'sales/quote_payment', $payment);
97
  $quote->setPayment($payment);
98
- $response = array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTH_REFUSED);
99
  $directLinkMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
100
  $directLinkMock->expects($this->any())
101
- ->method('performRequest')
102
- ->will($this->returnValue($response));
103
  $this->replaceByMock('model', 'ops/api_directlink', $directLinkMock);
104
  $observer = Mage::getModel('ops/observer');
105
  $this->assertTrue($this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'));
@@ -107,58 +107,6 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
107
  $this->assertFalse(array_key_exists('ops_response', $quote->getPayment()->getAdditionalInformation()));
108
  }
109
 
110
- public function testAppendCheckBoxToRefundForm()
111
- {
112
- $sessionMock = $this->getModelMock('core/session', array('init', 'save'));
113
- $this->replaceByMock('model', 'core/session', $sessionMock);
114
-
115
- Mage::register('current_creditmemo', null, true);
116
- $transport = new Varien_Object();
117
- $transport->setHtml('Foo');
118
- $observer = Mage::getModel('ops/observer');
119
- $event = new Varien_Object();
120
- $event->setBlock('');
121
- $this->assertEquals('', $observer->appendCheckBoxToRefundForm($event));
122
-
123
- $order = new Varien_Object();
124
- $payment = new Varien_Object();
125
- $methodInstance = Mage::getModel('ops/payment_cc');
126
- $payment->setMethodInstance($methodInstance);
127
- $order->setPayment($payment);
128
- $invoice = new Varien_Object();
129
- $invoice->setTransactionId(1);
130
- $creditMemo = $this->getModelMock('sales/order_creditmemo', array('getOrder', 'getInvoice', 'canRefund', 'getOrderId'));
131
- $creditMemo->expects($this->any())
132
- ->method('getOrder')
133
- ->will($this->returnValue($order));
134
- $creditMemo->expects($this->any())
135
- ->method('getInvoice')
136
- ->will($this->returnValue($invoice));
137
- $creditMemo->expects($this->any())
138
- ->method('canRefund')
139
- ->will($this->returnValue(true));
140
- $creditMemo->expects($this->any())
141
- ->method('getOrderId')
142
- ->will($this->returnValue(1));
143
- Mage::register('current_creditmemo', $creditMemo, true);
144
- $block = Mage::app()->getLayout()->getBlockSingleton('adminhtml/sales_order_creditmemo_totals');
145
- $parentBlock = Mage::app()->getLayout()->getBlockSingleton('adminhtml/sales_order_creditmemo_create_items');
146
- $block->setParentBlock($parentBlock);
147
-
148
- $blockMock = $this->getBlockMock('ops/adminhtml_sales_order_creditmemo_totals_checkbox', array('renderView'));
149
- $blockMock->expects($this->once())
150
- ->method('renderView')
151
- ->will($this->returnValue('<b>checkbox</b>'));
152
- $this->replaceByMock('block', 'ops/adminhtml_sales_order_creditmemo_totals_checkbox', $blockMock);
153
- $event->setBlock($block);
154
- $event->setTransport($transport);
155
- $html = $observer->appendCheckBoxToRefundForm($event);
156
- $this->assertEquals('Foo<b>checkbox</b>', $html);
157
- $this->assertNotEquals('Bar<span>checkbox</span>', $html);
158
-
159
- Mage::unregister('current_creditmemo');
160
- }
161
-
162
  public function testShowWarningForClosedTransactions()
163
  {
164
  Mage::register('current_creditmemo', null);
@@ -176,26 +124,30 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
176
  $order->setPayment($payment);
177
  $invoice = new Varien_Object();
178
  $invoice->setTransactionId(1);
179
- $creditMemo = $this->getModelMock('sales/order_creditmemo', array('getOrder', 'getInvoice', 'canRefund', 'getOrderId'));
 
 
180
  $creditMemo->expects($this->any())
181
- ->method('getOrder')
182
- ->will($this->returnValue($order));
183
  $creditMemo->expects($this->any())
184
- ->method('getInvoice')
185
- ->will($this->returnValue($invoice));
186
  $creditMemo->expects($this->any())
187
- ->method('canRefund')
188
- ->will($this->returnValue(false));
189
  $creditMemo->expects($this->any())
190
- ->method('getOrderId')
191
- ->will($this->returnValue(1));
192
  Mage::register('current_creditmemo', $creditMemo);
193
  $block = Mage::app()->getLayout()->getBlockSingleton('adminhtml/sales_order_creditmemo_create');
194
 
195
- $blockMock = $this->getBlockMock('ops/adminhtml_sales_order_creditmemo_closedTransaction_warning', array('renderView'));
 
 
196
  $blockMock->expects($this->once())
197
- ->method('renderView')
198
- ->will($this->returnValue('<b>warning</b>'));
199
  $this->replaceByMock('block', 'ops/adminhtml_sales_order_creditmemo_closedTransaction_warning', $blockMock);
200
  $event->setBlock($block);
201
  $event->setTransport($transport);
@@ -224,89 +176,91 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
224
 
225
  $helperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
226
  $helperMock->expects($this->any())
227
- ->method('isAdminSession')
228
- ->will($this->returnValue(true));
229
  $this->replaceByMock('helper', 'ops/data', $helperMock);
230
 
231
  $quoteHelperMock = $this->getHelperMock('ops/quote', array('getQuoteCurrency'));
232
  $quoteHelperMock->expects($this->any())
233
- ->method('getQuoteCurrency')
234
- ->will($this->returnValue('USD'));
235
  $this->replaceByMock('helper', 'ops/quote', $quoteHelperMock);
236
 
237
- $observerMock = $this->getModelMock('ops/observer', array('performDirectLinkRequest', 'invokeRequestParamValidation'));
 
 
238
  $observerMock->expects($this->any())
239
- ->method('performDirectLinkRequest')
240
- ->with($quote, $requestParams, 1)
241
- ->will($this->returnValue('WuselDusel'));
242
 
243
  $orderHelperMock = $this->getHelperMock('ops/order', array('checkIfAddressesAreSame'));
244
  $orderHelperMock->expects($this->any())
245
- ->method('checkIfAddressesAreSame')
246
- ->will($this->returnValue(1));
247
  $this->replaceByMock('helper', 'ops/order', $orderHelperMock);
248
 
249
  $customerSessionMock = $this->getModelMock('customer/session', array('isLoggedIn'));
250
  $customerSessionMock->expects($this->any())
251
- ->method('isLoggedIn')
252
- ->will($this->returnValue(1));
253
  $this->replaceByMock('model', 'customer/session', $customerSessionMock);
254
 
255
  $configModelMock = $this->getModelMock('ops/config', array(
256
- 'get3dSecureIsActive',
257
- 'getAcceptUrl',
258
- 'getDeclineUrl',
259
- 'getExceptionUrl'
260
  )
261
  );
262
 
263
  $configModelMock->expects($this->any())
264
- ->method('get3dSecureIsActive')
265
- ->will($this->returnValue(true));
266
  $configModelMock->expects($this->any())
267
- ->method('getAcceptUrl')
268
- ->will($this->returnValue('www.abc.com'));
269
  $configModelMock->expects($this->any())
270
- ->method('getDeclineUrl')
271
- ->will($this->returnValue('www.abcd.com'));
272
  $configModelMock->expects($this->any())
273
- ->method('getExceptionUrl')
274
- ->will($this->returnValue('www.abcde.com'));
275
  $this->replaceByMock('model', 'ops/config', $configModelMock);
276
 
277
  $aliashelperMock = $this->getHelperMock('ops/alias', array('getAlias', 'cleanUpAdditionalInformation'));
278
  $aliashelperMock->expects($this->any())
279
- ->method('getAlias')
280
- ->with($quote)
281
- ->will($this->returnValue('99'));
282
  $this->replaceByMock('helper', 'ops/alias', $aliashelperMock);
283
  $this->assertEquals('WuselDusel', $observerMock->confirmAliasPayment($order, $quote));
284
 
285
  $helperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
286
  $helperMock->expects($this->any())
287
- ->method('isAdminSession')
288
- ->will($this->returnValue(true));
289
  $this->replaceByMock('helper', 'ops/data', $helperMock);
290
 
291
- $observerMock = $this->getModelMock('ops/observer', array('performDirectLinkRequest', 'invokeRequestParamValidation'));
 
 
292
 
293
  $requestParams = $this->getRequestParamsWithoutAlias($quote, $order);
294
  $observerMock->expects($this->any())
295
- ->method('performDirectLinkRequest')
296
- ->with($quote, $requestParams, 1)
297
- ->will($this->returnValue('wrong'));
298
  $this->assertEquals('wrong', $observerMock->confirmAliasPayment($order, $quote));
299
 
300
 
301
  $observerMock = $this->getModelMock('ops/observer', array('performDirectLinkRequest'));
302
  $validatorMock = $this->getModelMock('ops/validator_parameter_validator', array('isValid'));
303
  $validatorMock->expects($this->once())
304
- ->method('isValid')
305
- ->will($this->returnValue(false));
306
  $validatorFactoryMock = $this->getModelMock('ops/validator_parameter_factory', array('getValidatorFor'));
307
  $validatorFactoryMock->expects($this->once())
308
- ->method('getValidatorFor')
309
- ->will($this->returnValue($validatorMock));
310
  $this->replaceByMock('model', 'ops/validator_parameter_factory', $validatorFactoryMock);
311
  try {
312
  $observerMock->confirmAliasPayment($order, $quote);
@@ -318,67 +272,74 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
318
 
319
  private function getRequestParamsWithAlias($quote, $order)
320
  {
321
- return array(
322
- 'ALIAS' => '99',
323
- 'AMOUNT' => 0.0,
324
- 'CURRENCY' => 'USD',
325
- 'OPERATION' => 'RES',
326
- 'ORDERID' => Mage::getSingleton('ops/config')->getConfigData('devprefix') . $order->getQuoteId(),
327
- 'EMAIL' => 'hubertus.von.fuerstenberg@trash-mail.com',
328
- 'OWNERADDRESS' => utf8_decode('An der Tabaksmühle 3a'),
329
- 'OWNERZIP' => '04229',
330
- 'OWNERTELNO' => null,
331
- 'OWNERCTY' => 'DE',
332
- 'ADDMATCH' => 1,
333
- 'ECOM_SHIPTO_POSTAL_POSTALCODE' => '04229',
334
- 'ECOM_BILLTO_POSTAL_POSTALCODE' => '04229',
335
- 'CVC' => '123',
336
- 'REMOTE_ADDR' => 'NONE',
337
- 'CUID' => null,
338
- 'ECI' => Netresearch_OPS_Model_Eci_Values::MANUALLY_KEYED_FROM_MOTO,
339
- 'OWNERTOWN' => 'Leipzig',
340
- 'ORIG' => Mage::helper('ops/data')->getModuleVersionString(),
341
- 'ECOM_SHIPTO_POSTAL_NAME_FIRST' => 'Hubertus',
342
- 'ECOM_SHIPTO_POSTAL_NAME_LAST' => utf8_decode('Fürstenberg'),
 
 
 
 
343
  'ECOM_SHIPTO_POSTAL_STREET_LINE1' => utf8_decode('An der Tabaksmühle 3a'),
344
  'ECOM_SHIPTO_POSTAL_STREET_LINE2' => '',
345
  'ECOM_SHIPTO_POSTAL_STREET_LINE3' => '',
346
- 'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => 'DE',
347
- 'ECOM_SHIPTO_POSTAL_CITY' => 'Leipzig',
348
- 'ECOM_SHIPTO_POSTAL_STATE' => '',
349
  );
350
  }
351
 
352
  private function getRequestParamsWithoutAlias($quote, $order)
353
  {
354
  return array(
355
- 'ALIAS' => '99',
356
- 'AMOUNT' => 0.0,
357
- 'CURRENCY' => 'USD',
358
- 'OPERATION' => 'RES',
359
- 'ORDERID' => Mage::getSingleton('ops/config')->getConfigData('devprefix') . $order->getQuoteId(),
360
- 'EMAIL' => 'hubertus.von.fuerstenberg@trash-mail.com',
361
- 'OWNERADDRESS' => utf8_decode('An der Tabaksmühle 3a'),
362
- 'OWNERZIP' => '04229',
363
- 'OWNERTELNO' => null,
364
- 'OWNERCTY' => 'DE',
365
- 'ADDMATCH' => 1,
366
- 'ECOM_SHIPTO_POSTAL_POSTALCODE' => '04229',
367
- 'ECOM_BILLTO_POSTAL_POSTALCODE' => '04229',
368
- 'CVC' => '123',
369
- 'REMOTE_ADDR' => 'NONE',
370
- 'OWNERTOWN' => 'Leipzig',
371
- 'ORIG' => Mage::helper('ops/data')->getModuleVersionString(),
372
- 'ECOM_SHIPTO_POSTAL_NAME_FIRST' => 'Hubertus',
373
- 'ECOM_SHIPTO_POSTAL_NAME_LAST' => utf8_decode('Fürstenberg'),
 
 
 
374
  'ECOM_SHIPTO_POSTAL_STREET_LINE1' => utf8_decode('An der Tabaksmühle 3a'),
375
  'ECOM_SHIPTO_POSTAL_STREET_LINE2' => '',
376
  'ECOM_SHIPTO_POSTAL_STREET_LINE3' => '',
377
- 'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => 'DE',
378
- 'ECOM_SHIPTO_POSTAL_CITY' => 'Leipzig',
379
- 'ECI' => 1,
380
- 'CUID' => null,
381
- 'ECOM_SHIPTO_POSTAL_STATE' => '',
382
  );
383
  }
384
 
@@ -390,40 +351,43 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
390
  $quote = Mage::getModel('sales/quote')->load(10);
391
  $order = Mage::getModel('sales/order')->load(11);
392
 
393
- $observerMock = $this->getModelMock('ops/observer', array('performDirectLinkRequest', 'invokeRequestParamValidation'));
 
 
394
 
395
  $requestParams = array(
396
- 'AMOUNT' => 0.0,
397
- 'CARDNO' => '12335BLZ12345566',
398
- 'CN' => utf8_decode('Hubertus zu Fürstenberg'),
399
- 'CURRENCY' => 'USD',
400
- 'ED' => '9999',
401
- 'OPERATION' => 'RES',
402
- 'ORDERID' => Mage::getSingleton('ops/config')->getConfigData('devprefix') . $quote->getId(),
403
- 'PM' => 'Direct Debits DE',
404
- 'OWNERADDRESS' => utf8_decode('An der Tabaksmühle 3a'),
405
- 'OWNERZIP' => '04229',
406
- 'OWNERTELNO' => null,
407
- 'OWNERCTY' => 'DE',
408
- 'ADDMATCH' => 1,
 
409
  'ECOM_SHIPTO_POSTAL_POSTALCODE' => '04229',
410
  'ECOM_BILLTO_POSTAL_POSTALCODE' => '04229',
411
- 'CUID' => null,
412
- 'BRAND' => 'Direct Debits DE',
413
- 'ECI' => Netresearch_OPS_Model_Eci_Values::MANUALLY_KEYED_FROM_MOTO,
414
- 'OWNERTOWN' => 'Leipzig',
415
  );
416
 
417
  $directDebitHelperMock = $this->getHelperMock('ops/directDebit', array('getDirectLinkRequestParams'));
418
  $directDebitHelperMock->expects($this->any())
419
- ->method('getDirectLinkRequestParams')
420
- ->will($this->returnValue($requestParams));
421
  $this->replaceByMock('helper', 'ops/directDebit', $directDebitHelperMock);
422
 
423
  $observerMock->expects($this->any())
424
- ->method('performDirectLinkRequest')
425
- ->with($quote, $requestParams, 1)
426
- ->will($this->returnValue('MOTO'));
427
  $this->assertEquals('MOTO', $observerMock->confirmDdPayment($order, $quote));
428
  }
429
 
@@ -436,42 +400,44 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
436
  $order = Mage::getModel('sales/order')->load(11);
437
 
438
 
439
-
440
- $observerMock = $this->getModelMock('ops/observer', array('performDirectLinkRequest', 'invokeRequestParamValidation'));
 
441
 
442
 
443
  $requestParams = array(
444
- 'AMOUNT' => 0.0,
445
- 'CARDNO' => '12335BLZ12345566',
446
- 'CN' => utf8_decode('Hubertus zu Fürstenberg'),
447
- 'CURRENCY' => 'USD',
448
- 'ED' => '9999',
449
- 'OPERATION' => 'RES',
450
- 'ORDERID' => Mage::getSingleton('ops/config')->getConfigData('devprefix') . $quote->getId(),
451
- 'PM' => 'Direct Debits DE',
452
- 'OWNERADDRESS' => utf8_decode('An der Tabaksmühle 3a'),
453
- 'OWNERZIP' => '04229',
454
- 'OWNERTELNO' => null,
455
- 'OWNERCTY' => 'DE',
456
- 'ADDMATCH' => 1,
 
457
  'ECOM_SHIPTO_POSTAL_POSTALCODE' => '04229',
458
  'ECOM_BILLTO_POSTAL_POSTALCODE' => '04229',
459
- 'CUID' => null,
460
- 'OWNERTOWN' => 'Leipzig',
461
- 'BRAND' => 'Direct Debits DE'
462
  );
463
 
464
  $directDebitHelperMock = $this->getHelperMock('ops/directDebit', array('getDirectLinkRequestParams'));
465
  $directDebitHelperMock->expects($this->any())
466
- ->method('getDirectLinkRequestParams')
467
- ->will($this->returnValue($requestParams));
468
  $this->replaceByMock('helper', 'ops/directDebit', $directDebitHelperMock);
469
 
470
 
471
  $observerMock->expects($this->any())
472
- ->method('performDirectLinkRequest')
473
- ->with($quote, $requestParams, 1)
474
- ->will($this->returnValue('ECOM'));
475
 
476
  $this->assertEquals('ECOM', $observerMock->confirmDdPayment($order, $quote));
477
  }
@@ -517,8 +483,8 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
517
  {
518
  $adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save'));
519
  $adminSessionMock->expects($this->any())
520
- ->method('isAllowed')
521
- ->will($this->returnValue(true));
522
  $this->replaceByMock('model', 'admin/session', $adminSessionMock);
523
 
524
  $order = Mage::getModel('sales/order')->load(11);
@@ -541,8 +507,8 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
541
  {
542
  $adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save'));
543
  $adminSessionMock->expects($this->any())
544
- ->method('isAllowed')
545
- ->will($this->returnValue(false));
546
  $this->replaceByMock('model', 'admin/session', $adminSessionMock);
547
 
548
  $order = Mage::getModel('sales/order')->load(11);
@@ -559,8 +525,8 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
559
 
560
  $adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save'));
561
  $adminSessionMock->expects($this->any())
562
- ->method('isAllowed')
563
- ->will($this->returnValue(true));
564
  $this->replaceByMock('model', 'admin/session', $adminSessionMock);
565
 
566
  $order = Mage::getModel('sales/order')->load(30);
@@ -589,14 +555,14 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
589
 
590
  $versionHelperMock = $this->getHelperMock('ops/version', array('canUseApplicableForQuote'));
591
  $versionHelperMock->expects($this->any())
592
- ->method('canUseApplicableForQuote')
593
- ->will($this->returnvalue(false));
594
  $this->replaceByMock('helper', 'ops/version', $versionHelperMock);
595
 
596
  $paymentHelperMock = $this->getHelperMock('ops/payment', array('addCCForZeroAmountCheckout'));
597
  $paymentHelperMock->expects($this->once())
598
- ->method('addCCForZeroAmountCheckout')
599
- ->will($this->returnValue($paymentHelperMock));
600
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
601
 
602
  $observer->addCcPaymentMethod($event);
@@ -615,7 +581,7 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
615
  $invoice->setOrder($order);
616
  $observer = Mage::getModel('ops/observer');
617
  $event = new Varien_Event_Observer();
618
- Mage::register('current_invoice',$invoice,true);
619
  $eventData = new Varien_Event();
620
  $event->setEvent($eventData);
621
  $event->getEvent()->setData('block', $block);
@@ -640,8 +606,8 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
640
  $quotePayment->setMethodInstance($pmMock);
641
  $quote = $this->getModelMock('sales/quote', array('getPayment'));
642
  $quote->expects($this->any())
643
- ->method('getPayment')
644
- ->will($this->returnValue($quotePayment));
645
 
646
  $quotePayment->setQuote($quote);
647
  $quote->setPayment($quotePayment);
@@ -650,7 +616,7 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
650
  $event->setQuote($quote);
651
  $observerMock = $this->getModelMock('ops/observer', array('invokeRequestParamValidation'));
652
  $observerMock->expects($this->once())
653
- ->method('invokeRequestParamValidation');
654
  $observerMock->checkoutTypeOnepageSaveOrderBefore($event);
655
  }
656
 
@@ -664,12 +630,12 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
664
  $quotePayment = Mage::getModel('sales/quote_payment')->load(4);
665
  $pmMock = $this->getModelMock('ops/payment_bankTransfer', array('isAvailable'));
666
  $pmMock->expects($this->any())
667
- ->method('isAvailable')
668
- ->will($this->returnValue(true));
669
  $quote = $this->getModelMock('sales/quote', array('getPayment'));
670
  $quote->expects($this->any())
671
- ->method('getPayment')
672
- ->will($this->returnValue($quotePayment));
673
  $quotePayment->setQuote($quote);
674
  $quote->setPayment($quotePayment);
675
  $this->replaceByMock('model', 'ops/payment_bankTransfer', $pmMock);
@@ -680,26 +646,26 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
680
 
681
  $observerMock = $this->getModelMock('ops/observer', array('getOnepage'));
682
  $observerMock->expects($this->once())
683
- ->method('getOnepage')
684
- ->will($this->returnValue($fakeOnePage))
685
- ;
686
  $helperMock = $this->getHelperMock('ops/payment_request', array('getOwnerParams', 'extractShipToParameters'));
687
  $helperMock->expects($this->once())
688
- ->method('getOwnerParams')
689
- ->will($this->returnValue(array()));
690
  $helperMock->expects($this->once())
691
- ->method('extractShipToParameters')
692
- ->will($this->returnValue(array()));
693
  $this->replaceByMock('helper', 'ops/payment_request', $helperMock);
694
  $validatorMock = $this->getModelMock('ops/validator_parameter_validator', array('isValid', 'getMessages'));
695
  $validatorMock->expects($this->once())
696
- ->method('isValid')
697
- ->will($this->returnValue(false));
698
  $validatorMock->expects($this->any())
699
- ->method('getMessages')
700
- ->will($this->returnValue(array('Foo' => 'Not Valid')));
701
  $this->replaceByMock('model', 'ops/validator_parameter_validator', $validatorMock);
702
- $fakeResponse->setBody(Mage::helper('core/data')->jsonEncode(array('error' => false, 'update_section' => 'foo')));
 
703
  $fakeController->setResponse($fakeResponse);
704
  $event = new Varien_Event_Observer();
705
  $event->setControllerAction($fakeController);
@@ -711,22 +677,6 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
711
  $this->assertArrayNotHasKey('update_section', $result);
712
  }
713
 
714
- public function testCheckForOpsStatus()
715
- {
716
- $helperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
717
- $helperMock->expects($this->any())
718
- ->method('isAdminSession')
719
- ->will($this->returnValue(true));
720
- $this->replaceByMock('helper', 'ops/data', $helperMock);
721
- $order = Mage::getModel('sales/order')->load(11);
722
- $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
723
- $observer = new Varien_Event_Observer();
724
- $observer->setOrder($order);
725
- Mage::getModel('ops/observer')->checkForOpsStatus($observer);
726
- $this->assertEquals(Mage_Sales_Model_Order::STATE_PROCESSING, $order->getStatus());
727
- }
728
-
729
-
730
  public function testSalesOrderPaymentCapture()
731
  {
732
  $opsObserver = Mage::getModel('ops/observer');
@@ -748,128 +698,99 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
748
 
749
  }
750
 
751
- public function testShowWarningForOpenInvoicePayments()
752
- {
753
- $transport = new Varien_Object();
754
- $transport->setHtml('Foo');
755
- $observer = Mage::getModel('ops/observer');
756
- $event = new Varien_Event_Observer();
757
- $event->setBlock('');
758
- $observer->appendPartialCaptureWarningForOpenInvoice($event);
759
- $this->assertEquals('Foo', $transport->getHtml());
760
-
761
- $order = new Varien_Object();
762
- $payment = new Varien_Object();
763
- $methodInstance = Mage::getModel('ops/payment_openInvoiceNl');
764
- $payment->setMethodInstance($methodInstance);
765
- $order->setPayment($payment);
766
-
767
- $invoice = $this->getModelMock('sales/order_invoice', array('getOrder'));
768
- $invoice->expects($this->any())
769
- ->method('getOrder')
770
- ->will($this->returnValue($order));
771
-
772
- Mage::register('current_invoice', $invoice);
773
- $block = Mage::app()->getLayout()->getBlockSingleton('adminhtml/sales_order_invoice_totals');
774
-
775
- $blockMock = $this->getBlockMock('ops/adminhtml_sales_order_invoice_warning_openInvoice', array('renderView'));
776
- $blockMock->expects($this->once())
777
- ->method('renderView')
778
- ->will($this->returnValue('<b>warning</b>'));
779
- $this->replaceByMock('block', 'ops/adminhtml_sales_order_invoice_warning_openInvoice', $blockMock);
780
- $event->setBlock($block);
781
- $event->setTransport($transport);
782
- $observer->appendPartialCaptureWarningForOpenInvoice($event);
783
- $this->assertEquals('Foo<b>warning</b>', $transport->getHtml());
784
- $this->assertNotEquals('Bar<span>warning</span>', $transport->getHtml());
785
-
786
- Mage::unregister('current_invoice');
787
- }
788
-
789
- public function testSetOrderStateForDirectDebitsNlDoesNotChangeState()
790
  {
791
  $order = $this->getOrderForDirectDebitNlTest();
792
  $event = $this->getEventForDirectDebitNlTests($order, 'payment/method_cc');
793
  $observer = Mage::getModel('ops/observer');
794
- $observer->setOrderStateForDirectDebitsNl($event);
795
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
796
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
797
  }
798
 
799
 
800
- public function testSetOrderStateForDirectDebitsNlDoesNotChangeStateDueToHelper()
801
  {
802
  $order = $this->getOrderForDirectDebitNlTest();
803
  $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit');
804
  $this->registerPaymentHelperMockForDirectDebitNlTests(false);
805
  $observer = Mage::getModel('ops/observer');
806
- $observer->setOrderStateForDirectDebitsNl($event);
807
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
808
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
809
  }
810
 
811
- public function testSetOrderStateForDirectDebitsNlDoesNotChangeStateDueToMissingInfos()
812
  {
813
  $order = $this->getOrderForDirectDebitNlTest();
814
  $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit');
815
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
816
  $observer = Mage::getModel('ops/observer');
817
- $observer->setOrderStateForDirectDebitsNl($event);
818
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
819
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
820
  }
821
 
822
- public function testSetOrderStateForDirectDebitsNlDoesNotChangeStateDueToMissingPm()
823
  {
824
  $order = $this->getOrderForDirectDebitNlTest();
825
  $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit', array('STATUS' => 51));
826
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
827
  $observer = Mage::getModel('ops/observer');
828
- $observer->setOrderStateForDirectDebitsNl($event);
829
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
830
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
831
  }
832
 
833
- public function testSetOrderStateForDirectDebitsNlDoesNotChangeStateDueToMissingStatus()
834
  {
835
  $order = $this->getOrderForDirectDebitNlTest();
836
- $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit', array('PM' => 'Direct Debits NL'));
 
 
837
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
838
  $observer = Mage::getModel('ops/observer');
839
- $observer->setOrderStateForDirectDebitsNl($event);
840
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
841
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
842
  }
843
 
844
- public function testSetOrderStateForDirectDebitsNlDoesNotChangeStateDueToWrongPm()
845
  {
846
  $order = $this->getOrderForDirectDebitNlTest();
847
- $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit', array('PM' => 'Direct Debits DE', 'STATUS' => 51));
 
 
848
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
849
  $observer = Mage::getModel('ops/observer');
850
- $observer->setOrderStateForDirectDebitsNl($event);
851
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
852
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
853
  }
854
 
855
- public function testSetOrderStateForDirectDebitsNlDoesNotChangeStateDueToWrongStatus()
856
  {
857
  $order = $this->getOrderForDirectDebitNlTest();
858
- $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit', array('PM' => 'Direct Debits NL', 'STATUS' => 5));
 
 
859
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
860
  $observer = Mage::getModel('ops/observer');
861
- $observer->setOrderStateForDirectDebitsNl($event);
862
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
863
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
864
  }
865
 
866
- public function testSetOrderStateForDirectDebitsNlDoesChangeState()
867
  {
868
  $order = $this->getOrderForDirectDebitNlTest();
869
- $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit', array('PM' => 'Direct Debits NL', 'STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING));
 
 
 
870
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
871
  $observer = Mage::getModel('ops/observer');
872
- $observer->setOrderStateForDirectDebitsNl($event);
873
  $this->assertEquals(Mage_sales_Model_Order::STATE_PENDING_PAYMENT, $order->getStatus());
874
  $this->assertEquals(Mage_sales_Model_Order::STATE_PENDING_PAYMENT, $order->getState());
875
  }
@@ -879,14 +800,14 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
879
  */
880
  protected function getEventForDirectDebitNlTests($order, $paymentMethod, array $addInfos = array())
881
  {
882
- $event = new Varien_Event_Observer();
883
  $payment = $this->getModelMock('payment/info', array('getMethodInstance', 'getOrder'));
884
  $payment->expects($this->any())
885
- ->method('getMethodInstance')
886
- ->will($this->returnValue(Mage::getModel($paymentMethod)));
887
  $payment->expects($this->any())
888
- ->method('getOrder')
889
- ->will($this->returnValue($order));
890
  $payment->setAdditionalInformation($addInfos);
891
  $event->setPayment($payment);
892
 
@@ -907,11 +828,55 @@ class Netresearch_OPS_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case_
907
 
908
  protected function registerPaymentHelperMockForDirectDebitNlTests($isInlinePaymentWithOrderIdRetVal = true)
909
  {
910
- $paymentHelperMock = $this->getHelperMock('ops/payment', array('isInlinePaymentWithOrderId'));
911
  $paymentHelperMock->expects($this->once())
912
- ->method('isInlinePaymentWithOrderId')
913
- ->will($this->returnValue($isInlinePaymentWithOrderIdRetVal));
914
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
915
  }
916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
917
  }
22
  $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
23
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
24
  $payment->expects($this->any())
25
+ ->method('save')
26
+ ->will($this->returnValue(null));
27
  $this->replaceByMock('model', 'sales/quote_payment', $payment);
28
  $quote->setPayment($payment);
29
  $response = null;
30
  $directLinkMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
31
  $directLinkMock->expects($this->any())
32
+ ->method('performRequest')
33
+ ->will($this->returnValue($response));
34
  $this->replaceByMock('model', 'ops/api_directlink', $directLinkMock);
35
  $observer = Mage::getModel('ops/observer');
36
  $observer->performDirectLinkRequest($quote, array());
45
  $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
46
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
47
  $payment->expects($this->any())
48
+ ->method('save')
49
+ ->will($this->returnValue(null));
50
  $this->replaceByMock('model', 'sales/quote_payment', $payment);
51
  $quote->setPayment($payment);
52
  $response = '';
53
  $directLinkMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
54
  $directLinkMock->expects($this->any())
55
+ ->method('performRequest')
56
+ ->will($this->returnValue($response));
57
  $this->replaceByMock('model', 'ops/api_directlink', $directLinkMock);
58
  $observer = Mage::getModel('ops/observer');
59
  $this->assertTrue($this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'));
68
  $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
69
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
70
  $payment->expects($this->any())
71
+ ->method('save')
72
+ ->will($this->returnValue(null));
73
  $this->replaceByMock('model', 'sales/quote_payment', $payment);
74
  $quote->setPayment($payment);
75
+ $response = array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED);
76
  $directLinkMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
77
  $directLinkMock->expects($this->any())
78
+ ->method('performRequest')
79
+ ->will($this->returnValue($response));
80
  $this->replaceByMock('model', 'ops/api_directlink', $directLinkMock);
81
  $observer = Mage::getModel('ops/observer');
82
  $this->assertFalse($this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'));
91
  $this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
92
  $payment = $this->getModelMock('sales/quote_payment', array('save'));
93
  $payment->expects($this->any())
94
+ ->method('save')
95
+ ->will($this->returnValue(null));
96
  $this->replaceByMock('model', 'sales/quote_payment', $payment);
97
  $quote->setPayment($payment);
98
+ $response = array('STATUS' => Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED);
99
  $directLinkMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
100
  $directLinkMock->expects($this->any())
101
+ ->method('performRequest')
102
+ ->will($this->returnValue($response));
103
  $this->replaceByMock('model', 'ops/api_directlink', $directLinkMock);
104
  $observer = Mage::getModel('ops/observer');
105
  $this->assertTrue($this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'));
107
  $this->assertFalse(array_key_exists('ops_response', $quote->getPayment()->getAdditionalInformation()));
108
  }
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  public function testShowWarningForClosedTransactions()
111
  {
112
  Mage::register('current_creditmemo', null);
124
  $order->setPayment($payment);
125
  $invoice = new Varien_Object();
126
  $invoice->setTransactionId(1);
127
+ $creditMemo = $this->getModelMock('sales/order_creditmemo',
128
+ array('getOrder', 'getInvoice', 'canRefund', 'getOrderId')
129
+ );
130
  $creditMemo->expects($this->any())
131
+ ->method('getOrder')
132
+ ->will($this->returnValue($order));
133
  $creditMemo->expects($this->any())
134
+ ->method('getInvoice')
135
+ ->will($this->returnValue($invoice));
136
  $creditMemo->expects($this->any())
137
+ ->method('canRefund')
138
+ ->will($this->returnValue(false));
139
  $creditMemo->expects($this->any())
140
+ ->method('getOrderId')
141
+ ->will($this->returnValue(1));
142
  Mage::register('current_creditmemo', $creditMemo);
143
  $block = Mage::app()->getLayout()->getBlockSingleton('adminhtml/sales_order_creditmemo_create');
144
 
145
+ $blockMock = $this->getBlockMock('ops/adminhtml_sales_order_creditmemo_closedTransaction_warning',
146
+ array('renderView')
147
+ );
148
  $blockMock->expects($this->once())
149
+ ->method('renderView')
150
+ ->will($this->returnValue('<b>warning</b>'));
151
  $this->replaceByMock('block', 'ops/adminhtml_sales_order_creditmemo_closedTransaction_warning', $blockMock);
152
  $event->setBlock($block);
153
  $event->setTransport($transport);
176
 
177
  $helperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
178
  $helperMock->expects($this->any())
179
+ ->method('isAdminSession')
180
+ ->will($this->returnValue(true));
181
  $this->replaceByMock('helper', 'ops/data', $helperMock);
182
 
183
  $quoteHelperMock = $this->getHelperMock('ops/quote', array('getQuoteCurrency'));
184
  $quoteHelperMock->expects($this->any())
185
+ ->method('getQuoteCurrency')
186
+ ->will($this->returnValue('USD'));
187
  $this->replaceByMock('helper', 'ops/quote', $quoteHelperMock);
188
 
189
+ $observerMock = $this->getModelMock('ops/observer',
190
+ array('performDirectLinkRequest', 'invokeRequestParamValidation')
191
+ );
192
  $observerMock->expects($this->any())
193
+ ->method('performDirectLinkRequest')
194
+ ->will($this->returnValue('WuselDusel'));
 
195
 
196
  $orderHelperMock = $this->getHelperMock('ops/order', array('checkIfAddressesAreSame'));
197
  $orderHelperMock->expects($this->any())
198
+ ->method('checkIfAddressesAreSame')
199
+ ->will($this->returnValue(1));
200
  $this->replaceByMock('helper', 'ops/order', $orderHelperMock);
201
 
202
  $customerSessionMock = $this->getModelMock('customer/session', array('isLoggedIn'));
203
  $customerSessionMock->expects($this->any())
204
+ ->method('isLoggedIn')
205
+ ->will($this->returnValue(1));
206
  $this->replaceByMock('model', 'customer/session', $customerSessionMock);
207
 
208
  $configModelMock = $this->getModelMock('ops/config', array(
209
+ 'get3dSecureIsActive',
210
+ 'getAcceptUrl',
211
+ 'getDeclineUrl',
212
+ 'getExceptionUrl'
213
  )
214
  );
215
 
216
  $configModelMock->expects($this->any())
217
+ ->method('get3dSecureIsActive')
218
+ ->will($this->returnValue(true));
219
  $configModelMock->expects($this->any())
220
+ ->method('getAcceptUrl')
221
+ ->will($this->returnValue('www.abc.com'));
222
  $configModelMock->expects($this->any())
223
+ ->method('getDeclineUrl')
224
+ ->will($this->returnValue('www.abcd.com'));
225
  $configModelMock->expects($this->any())
226
+ ->method('getExceptionUrl')
227
+ ->will($this->returnValue('www.abcde.com'));
228
  $this->replaceByMock('model', 'ops/config', $configModelMock);
229
 
230
  $aliashelperMock = $this->getHelperMock('ops/alias', array('getAlias', 'cleanUpAdditionalInformation'));
231
  $aliashelperMock->expects($this->any())
232
+ ->method('getAlias')
233
+ ->with($quote)
234
+ ->will($this->returnValue('99'));
235
  $this->replaceByMock('helper', 'ops/alias', $aliashelperMock);
236
  $this->assertEquals('WuselDusel', $observerMock->confirmAliasPayment($order, $quote));
237
 
238
  $helperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
239
  $helperMock->expects($this->any())
240
+ ->method('isAdminSession')
241
+ ->will($this->returnValue(true));
242
  $this->replaceByMock('helper', 'ops/data', $helperMock);
243
 
244
+ $observerMock = $this->getModelMock('ops/observer',
245
+ array('performDirectLinkRequest', 'invokeRequestParamValidation')
246
+ );
247
 
248
  $requestParams = $this->getRequestParamsWithoutAlias($quote, $order);
249
  $observerMock->expects($this->any())
250
+ ->method('performDirectLinkRequest')
251
+ ->will($this->returnValue('wrong'));
 
252
  $this->assertEquals('wrong', $observerMock->confirmAliasPayment($order, $quote));
253
 
254
 
255
  $observerMock = $this->getModelMock('ops/observer', array('performDirectLinkRequest'));
256
  $validatorMock = $this->getModelMock('ops/validator_parameter_validator', array('isValid'));
257
  $validatorMock->expects($this->once())
258
+ ->method('isValid')
259
+ ->will($this->returnValue(false));
260
  $validatorFactoryMock = $this->getModelMock('ops/validator_parameter_factory', array('getValidatorFor'));
261
  $validatorFactoryMock->expects($this->once())
262
+ ->method('getValidatorFor')
263
+ ->will($this->returnValue($validatorMock));
264
  $this->replaceByMock('model', 'ops/validator_parameter_factory', $validatorFactoryMock);
265
  try {
266
  $observerMock->confirmAliasPayment($order, $quote);
272
 
273
  private function getRequestParamsWithAlias($quote, $order)
274
  {
275
+ return array(
276
+ 'ALIAS' => '99',
277
+ 'AMOUNT' => 0.0,
278
+ 'CURRENCY' => 'USD',
279
+ 'OPERATION' => 'RES',
280
+ 'ORDERID' => Mage::getSingleton('ops/config')->getConfigData('devprefix')
281
+ . $order->getQuoteId(),
282
+ 'EMAIL' => 'hubertus.von.fuerstenberg@trash-mail.com',
283
+ 'OWNERADDRESS' => utf8_decode('An der Tabaksmühle 3a'),
284
+ 'OWNERZIP' => '04229',
285
+ 'OWNERTELNO' => null,
286
+ 'OWNERCTY' => 'DE',
287
+ 'ADDMATCH' => 1,
288
+
289
+ 'RTIMEOUT' => 45,
290
+ 'CREDITDEBIT' => 'C',
291
+ 'ECOM_SHIPTO_POSTAL_POSTALCODE' => '04229',
292
+ 'ECOM_BILLTO_POSTAL_POSTALCODE' => '04229',
293
+ 'CVC' => '123',
294
+ 'REMOTE_ADDR' => 'NONE',
295
+ 'CUID' => null,
296
+ 'ECI' => Netresearch_OPS_Model_Eci_Values::MANUALLY_KEYED_FROM_MOTO,
297
+ 'OWNERTOWN' => 'Leipzig',
298
+ 'ORIG' => Mage::helper('ops/data')->getModuleVersionString(),
299
+ 'ECOM_SHIPTO_POSTAL_NAME_FIRST' => 'Hubertus',
300
+ 'ECOM_SHIPTO_POSTAL_NAME_LAST' => utf8_decode('Fürstenberg'),
301
  'ECOM_SHIPTO_POSTAL_STREET_LINE1' => utf8_decode('An der Tabaksmühle 3a'),
302
  'ECOM_SHIPTO_POSTAL_STREET_LINE2' => '',
303
  'ECOM_SHIPTO_POSTAL_STREET_LINE3' => '',
304
+ 'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => 'DE',
305
+ 'ECOM_SHIPTO_POSTAL_CITY' => 'Leipzig',
306
+ 'ECOM_SHIPTO_POSTAL_STATE' => '',
307
  );
308
  }
309
 
310
  private function getRequestParamsWithoutAlias($quote, $order)
311
  {
312
  return array(
313
+ 'ALIAS' => '99',
314
+ 'AMOUNT' => 0.0,
315
+ 'CURRENCY' => 'USD',
316
+ 'OPERATION' => 'RES',
317
+ 'ORDERID' => Mage::getSingleton('ops/config')->getConfigData('devprefix')
318
+ . $order->getQuoteId(),
319
+ 'EMAIL' => 'hubertus.von.fuerstenberg@trash-mail.com',
320
+ 'OWNERADDRESS' => utf8_decode('An der Tabaksmühle 3a'),
321
+ 'OWNERZIP' => '04229',
322
+ 'OWNERTELNO' => null,
323
+ 'OWNERCTY' => 'DE',
324
+ 'ADDMATCH' => 1,
325
+ 'RTIMEOUT' => 45,
326
+ 'CREDITDEBIT' => 'C',
327
+ 'ECOM_SHIPTO_POSTAL_POSTALCODE' => '04229',
328
+ 'ECOM_BILLTO_POSTAL_POSTALCODE' => '04229',
329
+ 'CVC' => '123',
330
+ 'REMOTE_ADDR' => 'NONE',
331
+ 'OWNERTOWN' => 'Leipzig',
332
+ 'ORIG' => Mage::helper('ops/data')->getModuleVersionString(),
333
+ 'ECOM_SHIPTO_POSTAL_NAME_FIRST' => 'Hubertus',
334
+ 'ECOM_SHIPTO_POSTAL_NAME_LAST' => utf8_decode('Fürstenberg'),
335
  'ECOM_SHIPTO_POSTAL_STREET_LINE1' => utf8_decode('An der Tabaksmühle 3a'),
336
  'ECOM_SHIPTO_POSTAL_STREET_LINE2' => '',
337
  'ECOM_SHIPTO_POSTAL_STREET_LINE3' => '',
338
+ 'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => 'DE',
339
+ 'ECOM_SHIPTO_POSTAL_CITY' => 'Leipzig',
340
+ 'ECI' => 1,
341
+ 'CUID' => null,
342
+ 'ECOM_SHIPTO_POSTAL_STATE' => '',
343
  );
344
  }
345
 
351
  $quote = Mage::getModel('sales/quote')->load(10);
352
  $order = Mage::getModel('sales/order')->load(11);
353
 
354
+ $observerMock = $this->getModelMock('ops/observer',
355
+ array('performDirectLinkRequest', 'invokeRequestParamValidation')
356
+ );
357
 
358
  $requestParams = array(
359
+ 'AMOUNT' => 0.0,
360
+ 'CARDNO' => '12335BLZ12345566',
361
+ 'CN' => utf8_decode('Hubertus zu Fürstenberg'),
362
+ 'CURRENCY' => 'USD',
363
+ 'ED' => '9999',
364
+ 'OPERATION' => 'RES',
365
+ 'ORDERID' => Mage::getSingleton('ops/config')->getConfigData('devprefix')
366
+ . $quote->getId(),
367
+ 'PM' => 'Direct Debits DE',
368
+ 'OWNERADDRESS' => utf8_decode('An der Tabaksmühle 3a'),
369
+ 'OWNERZIP' => '04229',
370
+ 'OWNERTELNO' => null,
371
+ 'OWNERCTY' => 'DE',
372
+ 'ADDMATCH' => 1,
373
  'ECOM_SHIPTO_POSTAL_POSTALCODE' => '04229',
374
  'ECOM_BILLTO_POSTAL_POSTALCODE' => '04229',
375
+ 'CUID' => null,
376
+ 'BRAND' => 'Direct Debits DE',
377
+ 'ECI' => Netresearch_OPS_Model_Eci_Values::MANUALLY_KEYED_FROM_MOTO,
378
+ 'OWNERTOWN' => 'Leipzig',
379
  );
380
 
381
  $directDebitHelperMock = $this->getHelperMock('ops/directDebit', array('getDirectLinkRequestParams'));
382
  $directDebitHelperMock->expects($this->any())
383
+ ->method('getDirectLinkRequestParams')
384
+ ->will($this->returnValue($requestParams));
385
  $this->replaceByMock('helper', 'ops/directDebit', $directDebitHelperMock);
386
 
387
  $observerMock->expects($this->any())
388
+ ->method('performDirectLinkRequest')
389
+ ->with($quote, $requestParams, 1)
390
+ ->will($this->returnValue('MOTO'));
391
  $this->assertEquals('MOTO', $observerMock->confirmDdPayment($order, $quote));
392
  }
393
 
400
  $order = Mage::getModel('sales/order')->load(11);
401
 
402
 
403
+ $observerMock = $this->getModelMock('ops/observer',
404
+ array('performDirectLinkRequest', 'invokeRequestParamValidation')
405
+ );
406
 
407
 
408
  $requestParams = array(
409
+ 'AMOUNT' => 0.0,
410
+ 'CARDNO' => '12335BLZ12345566',
411
+ 'CN' => utf8_decode('Hubertus zu Fürstenberg'),
412
+ 'CURRENCY' => 'USD',
413
+ 'ED' => '9999',
414
+ 'OPERATION' => 'RES',
415
+ 'ORDERID' => Mage::getSingleton('ops/config')->getConfigData('devprefix')
416
+ . $quote->getId(),
417
+ 'PM' => 'Direct Debits DE',
418
+ 'OWNERADDRESS' => utf8_decode('An der Tabaksmühle 3a'),
419
+ 'OWNERZIP' => '04229',
420
+ 'OWNERTELNO' => null,
421
+ 'OWNERCTY' => 'DE',
422
+ 'ADDMATCH' => 1,
423
  'ECOM_SHIPTO_POSTAL_POSTALCODE' => '04229',
424
  'ECOM_BILLTO_POSTAL_POSTALCODE' => '04229',
425
+ 'CUID' => null,
426
+ 'OWNERTOWN' => 'Leipzig',
427
+ 'BRAND' => 'Direct Debits DE'
428
  );
429
 
430
  $directDebitHelperMock = $this->getHelperMock('ops/directDebit', array('getDirectLinkRequestParams'));
431
  $directDebitHelperMock->expects($this->any())
432
+ ->method('getDirectLinkRequestParams')
433
+ ->will($this->returnValue($requestParams));
434
  $this->replaceByMock('helper', 'ops/directDebit', $directDebitHelperMock);
435
 
436
 
437
  $observerMock->expects($this->any())
438
+ ->method('performDirectLinkRequest')
439
+ ->with($quote, $requestParams, 1)
440
+ ->will($this->returnValue('ECOM'));
441
 
442
  $this->assertEquals('ECOM', $observerMock->confirmDdPayment($order, $quote));
443
  }
483
  {
484
  $adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save'));
485
  $adminSessionMock->expects($this->any())
486
+ ->method('isAllowed')
487
+ ->will($this->returnValue(true));
488
  $this->replaceByMock('model', 'admin/session', $adminSessionMock);
489
 
490
  $order = Mage::getModel('sales/order')->load(11);
507
  {
508
  $adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save'));
509
  $adminSessionMock->expects($this->any())
510
+ ->method('isAllowed')
511
+ ->will($this->returnValue(false));
512
  $this->replaceByMock('model', 'admin/session', $adminSessionMock);
513
 
514
  $order = Mage::getModel('sales/order')->load(11);
525
 
526
  $adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save'));
527
  $adminSessionMock->expects($this->any())
528
+ ->method('isAllowed')
529
+ ->will($this->returnValue(true));
530
  $this->replaceByMock('model', 'admin/session', $adminSessionMock);
531
 
532
  $order = Mage::getModel('sales/order')->load(30);
555
 
556
  $versionHelperMock = $this->getHelperMock('ops/version', array('canUseApplicableForQuote'));
557
  $versionHelperMock->expects($this->any())
558
+ ->method('canUseApplicableForQuote')
559
+ ->will($this->returnvalue(false));
560
  $this->replaceByMock('helper', 'ops/version', $versionHelperMock);
561
 
562
  $paymentHelperMock = $this->getHelperMock('ops/payment', array('addCCForZeroAmountCheckout'));
563
  $paymentHelperMock->expects($this->once())
564
+ ->method('addCCForZeroAmountCheckout')
565
+ ->will($this->returnValue($paymentHelperMock));
566
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
567
 
568
  $observer->addCcPaymentMethod($event);
581
  $invoice->setOrder($order);
582
  $observer = Mage::getModel('ops/observer');
583
  $event = new Varien_Event_Observer();
584
+ Mage::register('current_invoice', $invoice, true);
585
  $eventData = new Varien_Event();
586
  $event->setEvent($eventData);
587
  $event->getEvent()->setData('block', $block);
606
  $quotePayment->setMethodInstance($pmMock);
607
  $quote = $this->getModelMock('sales/quote', array('getPayment'));
608
  $quote->expects($this->any())
609
+ ->method('getPayment')
610
+ ->will($this->returnValue($quotePayment));
611
 
612
  $quotePayment->setQuote($quote);
613
  $quote->setPayment($quotePayment);
616
  $event->setQuote($quote);
617
  $observerMock = $this->getModelMock('ops/observer', array('invokeRequestParamValidation'));
618
  $observerMock->expects($this->once())
619
+ ->method('invokeRequestParamValidation');
620
  $observerMock->checkoutTypeOnepageSaveOrderBefore($event);
621
  }
622
 
630
  $quotePayment = Mage::getModel('sales/quote_payment')->load(4);
631
  $pmMock = $this->getModelMock('ops/payment_bankTransfer', array('isAvailable'));
632
  $pmMock->expects($this->any())
633
+ ->method('isAvailable')
634
+ ->will($this->returnValue(true));
635
  $quote = $this->getModelMock('sales/quote', array('getPayment'));
636
  $quote->expects($this->any())
637
+ ->method('getPayment')
638
+ ->will($this->returnValue($quotePayment));
639
  $quotePayment->setQuote($quote);
640
  $quote->setPayment($quotePayment);
641
  $this->replaceByMock('model', 'ops/payment_bankTransfer', $pmMock);
646
 
647
  $observerMock = $this->getModelMock('ops/observer', array('getOnepage'));
648
  $observerMock->expects($this->once())
649
+ ->method('getOnepage')
650
+ ->will($this->returnValue($fakeOnePage));
 
651
  $helperMock = $this->getHelperMock('ops/payment_request', array('getOwnerParams', 'extractShipToParameters'));
652
  $helperMock->expects($this->once())
653
+ ->method('getOwnerParams')
654
+ ->will($this->returnValue(array()));
655
  $helperMock->expects($this->once())
656
+ ->method('extractShipToParameters')
657
+ ->will($this->returnValue(array()));
658
  $this->replaceByMock('helper', 'ops/payment_request', $helperMock);
659
  $validatorMock = $this->getModelMock('ops/validator_parameter_validator', array('isValid', 'getMessages'));
660
  $validatorMock->expects($this->once())
661
+ ->method('isValid')
662
+ ->will($this->returnValue(false));
663
  $validatorMock->expects($this->any())
664
+ ->method('getMessages')
665
+ ->will($this->returnValue(array('Foo' => 'Not Valid')));
666
  $this->replaceByMock('model', 'ops/validator_parameter_validator', $validatorMock);
667
+ $fakeResponse->setBody(Mage::helper('core/data')->jsonEncode(array('error' => false, 'update_section' => 'foo'))
668
+ );
669
  $fakeController->setResponse($fakeResponse);
670
  $event = new Varien_Event_Observer();
671
  $event->setControllerAction($fakeController);
677
  $this->assertArrayNotHasKey('update_section', $result);
678
  }
679
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
680
  public function testSalesOrderPaymentCapture()
681
  {
682
  $opsObserver = Mage::getModel('ops/observer');
698
 
699
  }
700
 
701
+ public function testSetOrderStateForDirectLinkDoesNotChangeState()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
702
  {
703
  $order = $this->getOrderForDirectDebitNlTest();
704
  $event = $this->getEventForDirectDebitNlTests($order, 'payment/method_cc');
705
  $observer = Mage::getModel('ops/observer');
706
+ $observer->setOrderStateDirectLink($event);
707
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
708
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
709
  }
710
 
711
 
712
+ public function testSetOrderStateForDirectLinkDoesNotChangeStateDueToHelper()
713
  {
714
  $order = $this->getOrderForDirectDebitNlTest();
715
  $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit');
716
  $this->registerPaymentHelperMockForDirectDebitNlTests(false);
717
  $observer = Mage::getModel('ops/observer');
718
+ $observer->setOrderStateDirectLink($event);
719
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
720
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
721
  }
722
 
723
+ public function testSetOrderStateForDirectLinkDoesNotChangeStateDueToMissingInfos()
724
  {
725
  $order = $this->getOrderForDirectDebitNlTest();
726
  $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit');
727
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
728
  $observer = Mage::getModel('ops/observer');
729
+ $observer->setOrderStateDirectLink($event);
730
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
731
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
732
  }
733
 
734
+ public function testSetOrderStateForDirectLinkDoesNotChangeStateDueToMissingPm()
735
  {
736
  $order = $this->getOrderForDirectDebitNlTest();
737
  $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit', array('STATUS' => 51));
738
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
739
  $observer = Mage::getModel('ops/observer');
740
+ $observer->setOrderStateDirectLink($event);
741
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
742
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
743
  }
744
 
745
+ public function testSetOrderStateForDirectLinkDoesNotChangeStateDueToMissingStatus()
746
  {
747
  $order = $this->getOrderForDirectDebitNlTest();
748
+ $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit',
749
+ array('PM' => 'Direct Debits NL')
750
+ );
751
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
752
  $observer = Mage::getModel('ops/observer');
753
+ $observer->setOrderStateDirectLink($event);
754
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
755
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
756
  }
757
 
758
+ public function testSetOrderStateForDirectLinkDoesNotChangeStateDueToWrongPm()
759
  {
760
  $order = $this->getOrderForDirectDebitNlTest();
761
+ $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit',
762
+ array('PM' => 'Direct Debits DE', 'STATUS' => 51)
763
+ );
764
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
765
  $observer = Mage::getModel('ops/observer');
766
+ $observer->setOrderStateDirectLink($event);
767
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
768
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
769
  }
770
 
771
+ public function testSetOrderStateForDirectLinkDoesNotChangeStateDueToWrongStatus()
772
  {
773
  $order = $this->getOrderForDirectDebitNlTest();
774
+ $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit',
775
+ array('PM' => 'Direct Debits NL', 'STATUS' => 5)
776
+ );
777
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
778
  $observer = Mage::getModel('ops/observer');
779
+ $observer->setOrderStateDirectLink($event);
780
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getStatus());
781
  $this->assertEquals(Mage_sales_Model_Order::STATE_PROCESSING, $order->getState());
782
  }
783
 
784
+ public function testSetOrderStateForDirectLinkDoesChangeState()
785
  {
786
  $order = $this->getOrderForDirectDebitNlTest();
787
+ $event = $this->getEventForDirectDebitNlTests($order, 'ops/payment_directDebit',
788
+ array('PM' => 'Direct Debits NL',
789
+ 'status' => Netresearch_OPS_Model_Status::AUTHORIZED)
790
+ );
791
  $this->registerPaymentHelperMockForDirectDebitNlTests(true);
792
  $observer = Mage::getModel('ops/observer');
793
+ $observer->setOrderStateDirectLink($event);
794
  $this->assertEquals(Mage_sales_Model_Order::STATE_PENDING_PAYMENT, $order->getStatus());
795
  $this->assertEquals(Mage_sales_Model_Order::STATE_PENDING_PAYMENT, $order->getState());
796
  }
800
  */
801
  protected function getEventForDirectDebitNlTests($order, $paymentMethod, array $addInfos = array())
802
  {
803
+ $event = new Varien_Event_Observer();
804
  $payment = $this->getModelMock('payment/info', array('getMethodInstance', 'getOrder'));
805
  $payment->expects($this->any())
806
+ ->method('getMethodInstance')
807
+ ->will($this->returnValue(Mage::getModel($paymentMethod)));
808
  $payment->expects($this->any())
809
+ ->method('getOrder')
810
+ ->will($this->returnValue($order));
811
  $payment->setAdditionalInformation($addInfos);
812
  $event->setPayment($payment);
813
 
828
 
829
  protected function registerPaymentHelperMockForDirectDebitNlTests($isInlinePaymentWithOrderIdRetVal = true)
830
  {
831
+ $paymentHelperMock = $this->getHelperMock('ops/payment', array('isInlinePayment'));
832
  $paymentHelperMock->expects($this->once())
833
+ ->method('isInlinePayment')
834
+ ->will($this->returnValue($isInlinePaymentWithOrderIdRetVal));
835
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
836
  }
837
 
838
+ public function testUpdateRecurringProfileButtons()
839
+ {
840
+ $profile = Mage::getModel('sales/recurring_profile');
841
+ $profile->setMethodCode(Netresearch_OPS_Model_Payment_Recurring_Cc::CODE)
842
+ ->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE)
843
+ ->setId(1);
844
+
845
+ $this->replaceRegistry('current_recurring_profile', $profile);
846
+
847
+ /** @var $block Mage_Sales_Block_Adminhtml_Recurring_Profile_View */
848
+ $block = Mage::app()->getLayout()->createBlock('sales/adminhtml_recurring_profile_view');
849
+ $block->setLayout(Mage::app()->getLayout());
850
+ $observer = new Varien_Event_Observer();
851
+ $event = new Varien_Event();
852
+ $event->setData('block', $block);
853
+ $observer->setEvent($event);
854
+
855
+ $subject = Mage::getModel('ops/observer');
856
+ $subject->updateRecurringProfileButtons($observer);
857
+ $html = $block->getButtonsHtml('header');
858
+
859
+ $this->assertContains('Suspending the subscription here will not actually cancel the subscription on Ingenico ePayments side.',
860
+ $html
861
+ );
862
+ }
863
+
864
+ public function overrideRecurringProfileState()
865
+ {
866
+ $profile = Mage::getModel('sales/recurring_profile');
867
+ $profile->setMethodCode(Netresearch_OPS_Model_Payment_Recurring_Cc::CODE)
868
+ ->setState('abc')
869
+ ->setNewState('def')
870
+ ->setOverrideState(true);
871
+
872
+ $event = new Varien_Event_Observer();
873
+ $event->setObject($profile);
874
+
875
+ $observer = Mage::getModel('ops/observer');
876
+ $observer->overrideRecurringProfileState($event);
877
+
878
+ $this->assertEquals($profile->getNewState(), $profile->getState());
879
+ $this->assertEquals('def', $profile->getState());
880
+ }
881
+
882
  }
app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractCaptureTest.php CHANGED
@@ -74,6 +74,8 @@ class Netresearch_OPS_Test_Model_Payment_AbstractCaptureTest
74
 
75
  public function testCaptureWillPerformRequest()
76
  {
 
 
77
  $testOrder = $this->getOrderMock();
78
  $testPayment = $this->preparePayment($testOrder);
79
  $testPayment->setAdditionalInformation('paymentId', 'payID');
@@ -81,32 +83,30 @@ class Netresearch_OPS_Test_Model_Payment_AbstractCaptureTest
81
  $this->mockOrderCaptureHelper();
82
  $requestParams = $this->getCaptureRequestParams($amount, $testPayment);
83
  $testOpsResponse = $this->returnValue(
84
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSED_MERCHANT)
85
  );
86
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
87
  $paymentHelperMock = $this->getHelperMock('ops/payment', array('saveOpsStatusToPayment'));
88
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
89
-
90
  $this->testObject->capture($testPayment, $amount);
91
  }
92
 
93
 
94
  public function testCaptureWillPerformRequestWithPaymentProcessing()
95
  {
 
 
96
  $testOrder = $this->getOrderMock();
97
  $testPayment = $this->preparePayment($testOrder);
98
  $amount = 10;
99
  $this->mockDirectlinkHelperCheckDirectLinkTransact($this->returnValue(false));
100
- $message = Mage::helper('ops/data')->__(
101
- 'Invoice will be created automatically as soon as Ingenico Payment Services sends an acknowledgement. Ingenico Payment Services status: %s.',
102
- Mage::helper('ops')->getStatusText(Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING)
103
- );
104
- $this->mockDataHelperMockRedirectNoticed($testOrder->getId(), $message);
105
  $this->mockOrderCaptureHelper(array('operation' => 'SAS', 'type' => 'capture'));
106
  $requestParams = $this->getCaptureRequestParams($amount, $testPayment);
107
  $testOpsResponse = $this->returnValue(
108
  array(
109
- 'STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING,
110
  'PAYID' => 4711,
111
  'PAYIDSUB' => 1
112
  )
@@ -114,7 +114,7 @@ class Netresearch_OPS_Test_Model_Payment_AbstractCaptureTest
114
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
115
  $paymentHelperMock = $this->getHelperMock('ops/payment', array('saveOpsStatusToPayment'));
116
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
117
-
118
  $this->testObject->capture($testPayment, $amount);
119
  }
120
 
@@ -129,14 +129,14 @@ class Netresearch_OPS_Test_Model_Payment_AbstractCaptureTest
129
  $amount = 10;
130
  $this->mockOrderCaptureHelper();
131
  $requestParams = $this->getCaptureRequestParams($amount, $testPayment);
132
- $testOpsResponse = $this->returnValue(array('STATUS' => 0));
133
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
134
  $paymentHelperMock = $this->getHelperMock('ops/payment', array('saveOpsStatusToPayment'));
135
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
136
 
137
  $statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
138
  $this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
139
-
140
  $this->testObject->capture($testPayment, $amount);
141
  }
142
 
@@ -157,7 +157,7 @@ class Netresearch_OPS_Test_Model_Payment_AbstractCaptureTest
157
  $statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
158
  $this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
159
 
160
-
161
  $this->testObject->capture($testPayment, $amount);
162
  }
163
 
@@ -188,12 +188,14 @@ class Netresearch_OPS_Test_Model_Payment_AbstractCaptureTest
188
  /**
189
  * @return array
190
  */
191
- protected function preparePayment($order)
192
  {
193
  $payment = Mage::getModel('sales/order_payment');
194
  $payment->setOrder($order);
 
195
  $payment->setAdditionalInformation('paymentId', 'payID');
196
 
 
197
  return $payment;
198
  }
199
 
@@ -225,7 +227,7 @@ class Netresearch_OPS_Test_Model_Payment_AbstractCaptureTest
225
  $requestParams = array(
226
  'AMOUNT' => Mage::helper('ops/data')->getAmount($amount),
227
  'PAYID' => $testPayment->getAdditionalInformation('paymentId'),
228
- 'OPERATION' => 'SAS',
229
  'CURRENCY' => Mage::app()->getStore()->getBaseCurrencyCode()
230
  );
231
 
74
 
75
  public function testCaptureWillPerformRequest()
76
  {
77
+ // $this->markTestIncomplete();
78
+
79
  $testOrder = $this->getOrderMock();
80
  $testPayment = $this->preparePayment($testOrder);
81
  $testPayment->setAdditionalInformation('paymentId', 'payID');
83
  $this->mockOrderCaptureHelper();
84
  $requestParams = $this->getCaptureRequestParams($amount, $testPayment);
85
  $testOpsResponse = $this->returnValue(
86
+ array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_PROCESSED_BY_MERCHANT)
87
  );
88
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
89
  $paymentHelperMock = $this->getHelperMock('ops/payment', array('saveOpsStatusToPayment'));
90
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
91
+ $this->testObject->setInfoInstance($testPayment);
92
  $this->testObject->capture($testPayment, $amount);
93
  }
94
 
95
 
96
  public function testCaptureWillPerformRequestWithPaymentProcessing()
97
  {
98
+ // $this->markTestIncomplete();
99
+
100
  $testOrder = $this->getOrderMock();
101
  $testPayment = $this->preparePayment($testOrder);
102
  $amount = 10;
103
  $this->mockDirectlinkHelperCheckDirectLinkTransact($this->returnValue(false));
104
+
 
 
 
 
105
  $this->mockOrderCaptureHelper(array('operation' => 'SAS', 'type' => 'capture'));
106
  $requestParams = $this->getCaptureRequestParams($amount, $testPayment);
107
  $testOpsResponse = $this->returnValue(
108
  array(
109
+ 'STATUS' => Netresearch_OPS_Model_Status::PAYMENT_PROCESSING,
110
  'PAYID' => 4711,
111
  'PAYIDSUB' => 1
112
  )
114
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
115
  $paymentHelperMock = $this->getHelperMock('ops/payment', array('saveOpsStatusToPayment'));
116
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
117
+ $this->testObject->setInfoInstance($testPayment);
118
  $this->testObject->capture($testPayment, $amount);
119
  }
120
 
129
  $amount = 10;
130
  $this->mockOrderCaptureHelper();
131
  $requestParams = $this->getCaptureRequestParams($amount, $testPayment);
132
+ $testOpsResponse = $this->returnValue(array('STATUS' => 320));
133
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
134
  $paymentHelperMock = $this->getHelperMock('ops/payment', array('saveOpsStatusToPayment'));
135
  $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
136
 
137
  $statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
138
  $this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
139
+ $this->testObject->setInfoInstance($testPayment);
140
  $this->testObject->capture($testPayment, $amount);
141
  }
142
 
157
  $statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
158
  $this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
159
 
160
+ $this->testObject->setInfoInstance($testPayment);
161
  $this->testObject->capture($testPayment, $amount);
162
  }
163
 
188
  /**
189
  * @return array
190
  */
191
+ protected function preparePayment($order, $method = 'ops_iDeal')
192
  {
193
  $payment = Mage::getModel('sales/order_payment');
194
  $payment->setOrder($order);
195
+ $payment->setMethod($method);
196
  $payment->setAdditionalInformation('paymentId', 'payID');
197
 
198
+ $order->setPayment($payment);
199
  return $payment;
200
  }
201
 
227
  $requestParams = array(
228
  'AMOUNT' => Mage::helper('ops/data')->getAmount($amount),
229
  'PAYID' => $testPayment->getAdditionalInformation('paymentId'),
230
+ 'OPERATION' => Mage::helper('ops/order_capture')->determineOperationCode($testPayment, $amount),
231
  'CURRENCY' => Mage::app()->getStore()->getBaseCurrencyCode()
232
  );
233
 
app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractRefundTest.php CHANGED
@@ -12,7 +12,7 @@ class Netresearch_OPS_Test_Model_Payment_AbstractRefundTest extends EcomDev_PHPU
12
  public function setUp()
13
  {
14
  parent::setUp();
15
- $this->testObject = $this->getModelMock('ops/payment_abstract', array('canRefund'));
16
  $this->testObject->expects($this->any())
17
  ->method('canRefund')
18
  ->will($this->returnValue(true));
@@ -32,14 +32,6 @@ class Netresearch_OPS_Test_Model_Payment_AbstractRefundTest extends EcomDev_PHPU
32
  Mage::unregister('ops_auto_creditmemo');
33
  }
34
 
35
- public function testRefundWithAutoCreditmemo()
36
- {
37
- Mage::register('ops_auto_creditmemo', true);
38
- $payment = new Varien_Object();
39
- $amount = null;
40
- $this->testObject->refund($payment, $amount);
41
- }
42
-
43
  /**
44
  *
45
  */
@@ -51,10 +43,10 @@ class Netresearch_OPS_Test_Model_Payment_AbstractRefundTest extends EcomDev_PHPU
51
  $amount = 10;
52
  $requestParams = $this->getRequestParams($amount, $testPayment);
53
  $testOpsResponse = $this->returnValue(
54
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_UNCERTAIN_STATUS)
55
  );
56
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
57
-
58
  $this->testObject->refund($testPayment, $amount);
59
  }
60
 
@@ -69,10 +61,10 @@ class Netresearch_OPS_Test_Model_Payment_AbstractRefundTest extends EcomDev_PHPU
69
  $amount = 10;
70
  $requestParams = $this->getRequestParams($amount, $testPayment);
71
  $testOpsResponse = $this->returnValue(
72
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PROCESSED_MERCHANT)
73
  );
74
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
75
-
76
  $this->testObject->refund($testPayment, $amount);
77
 
78
  }
@@ -88,13 +80,13 @@ class Netresearch_OPS_Test_Model_Payment_AbstractRefundTest extends EcomDev_PHPU
88
  $amount = 10;
89
  $requestParams = $this->getRequestParams($amount, $testPayment);
90
  $testOpsResponse = $this->returnValue(
91
- array('STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DELETED)
92
  );
93
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
94
 
95
  $statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
96
  $this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
97
-
98
  $this->testObject->refund($testPayment, $amount);
99
  }
100
 
@@ -114,7 +106,7 @@ class Netresearch_OPS_Test_Model_Payment_AbstractRefundTest extends EcomDev_PHPU
114
 
115
  $statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
116
  $this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
117
-
118
  $this->testObject->refund($testPayment, $amount);
119
  }
120
 
@@ -155,11 +147,13 @@ class Netresearch_OPS_Test_Model_Payment_AbstractRefundTest extends EcomDev_PHPU
155
  /**
156
  * @return array
157
  */
158
- protected function preparePayment($order)
159
  {
160
  $payment = Mage::getModel('sales/order_payment');
161
  $payment->setOrder($order);
 
162
  $payment->setAdditionalInformation('paymentId', 'payID');
 
163
 
164
  return $payment;
165
  }
@@ -218,4 +212,3 @@ class Netresearch_OPS_Test_Model_Payment_AbstractRefundTest extends EcomDev_PHPU
218
  $this->replaceByMock('helper', 'ops/payment', $helperMock);
219
  }
220
  }
221
-
12
  public function setUp()
13
  {
14
  parent::setUp();
15
+ $this->testObject = $this->getModelMock('ops/payment_cc', array('canRefund'));
16
  $this->testObject->expects($this->any())
17
  ->method('canRefund')
18
  ->will($this->returnValue(true));
32
  Mage::unregister('ops_auto_creditmemo');
33
  }
34
 
 
 
 
 
 
 
 
 
35
  /**
36
  *
37
  */
43
  $amount = 10;
44
  $requestParams = $this->getRequestParams($amount, $testPayment);
45
  $testOpsResponse = $this->returnValue(
46
+ array('STATUS' => Netresearch_OPS_Model_Status::REFUND_UNCERTAIN)
47
  );
48
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
49
+ $this->testObject->setInfoInstance($testPayment);
50
  $this->testObject->refund($testPayment, $amount);
51
  }
52
 
61
  $amount = 10;
62
  $requestParams = $this->getRequestParams($amount, $testPayment);
63
  $testOpsResponse = $this->returnValue(
64
+ array('STATUS' => Netresearch_OPS_Model_Status::REFUND_PROCESSED_BY_MERCHANT)
65
  );
66
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
67
+ $this->testObject->setInfoInstance($testPayment);
68
  $this->testObject->refund($testPayment, $amount);
69
 
70
  }
80
  $amount = 10;
81
  $requestParams = $this->getRequestParams($amount, $testPayment);
82
  $testOpsResponse = $this->returnValue(
83
+ array('STATUS' => 500)
84
  );
85
  $this->mockApiDirectLink($requestParams, $testOpsResponse);
86
 
87
  $statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
88
  $this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
89
+ $this->testObject->setInfoInstance($testPayment);
90
  $this->testObject->refund($testPayment, $amount);
91
  }
92
 
106
 
107
  $statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
108
  $this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
109
+ $this->testObject->setInfoInstance($testPayment);
110
  $this->testObject->refund($testPayment, $amount);
111
  }
112
 
147
  /**
148
  * @return array
149
  */
150
+ protected function preparePayment($order, $method = 'ops_cc')
151
  {
152
  $payment = Mage::getModel('sales/order_payment');
153
  $payment->setOrder($order);
154
+ $order->setPayment($payment);
155
  $payment->setAdditionalInformation('paymentId', 'payID');
156
+ $payment->setMethod($method);
157
 
158
  return $payment;
159
  }
212
  $this->replaceByMock('helper', 'ops/payment', $helperMock);
213
  }
214
  }
 
app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractTest.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
- class Netresearch_OPS_Test_Model_Payment_AbstractTest
3
- extends EcomDev_PHPUnit_Test_Case_Controller
4
  {
5
  protected $model = null;
6
 
@@ -174,7 +173,7 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
174
 
175
  //Check for denied can cancel (processing and payment status 0)
176
  $order = Mage::getModel("sales/order")->load(13);
177
- $this->assertFalse($opsAbstractPayment->canCancelManually($order));
178
  }
179
 
180
 
@@ -226,63 +225,6 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
226
  }
227
 
228
 
229
- /**
230
- * @test
231
- * @loadFixture ../../../../var/fixtures/orders.yaml
232
- */
233
- public function testCanRefund()
234
- {
235
- $paymentModel = Mage::getModel('ops/payment_abstract');
236
- Mage::app()->getRequest()->setParam('order_id', 17);
237
- $this->assertFalse($paymentModel->canRefund());
238
-
239
- Mage::app()->getRequest()->setParam('order_id', 18);
240
- $this->assertTrue($paymentModel->canRefund());
241
-
242
- Mage::app()->getRequest()->setParam('order_id', 11);
243
- $helperMock = $this->getHelperMock(
244
- 'ops/directlink', array('hasPaymentTransactions')
245
- );
246
- $helperMock->expects($this->any())
247
- ->method('hasPaymentTransactions')
248
- ->will($this->returnValue(false));
249
- $this->replaceByMock('helper', 'ops/directlink', $helperMock);
250
-
251
- $this->assertTrue($paymentModel->canRefund());
252
-
253
- $helperMock = $this->getHelperMock(
254
- 'ops/directlink', array('hasPaymentTransactions')
255
- );
256
- $helperMock->expects($this->any())
257
- ->method('hasPaymentTransactions')
258
- ->will($this->returnValue(true));
259
- $this->replaceByMock('helper', 'ops/directlink', $helperMock);
260
-
261
- $helperMock = $this->getHelperMock('ops/data', array('redirect'));
262
- $this->replaceByMock('helper', 'ops/data', $helperMock);
263
-
264
- $paymentModel->canRefund();
265
- $messages = Mage::getSingleton('core/session')->getMessages();
266
- $messageItems = $messages->getItems();
267
- $message = array_pop($messageItems);
268
- $this->assertEquals(
269
- Mage::helper('ops/data')->__(
270
- 'There is already one creditmemo in the queue. The Creditmemo will be created automatically as soon as Ingenico Payment Services sends an acknowledgement.'
271
- ), $message->getText()
272
- );
273
-
274
-
275
- $helperMock = $this->getHelperMock(
276
- 'ops/directlink', array('hasPaymentTransactions')
277
- );
278
- $helperMock->expects($this->any())
279
- ->method('hasPaymentTransactions')
280
- ->will($this->throwException(new Exception('foo')));
281
- $this->replaceByMock('helper', 'ops/directlink', $helperMock);
282
- $this->assertTrue($paymentModel->canRefund());
283
- }
284
-
285
-
286
  /**
287
  * @test
288
  * @loadFixture ../../../../var/fixtures/orders.yaml
@@ -441,53 +383,9 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
441
  $this->assertArrayHasKey('EXCEPTIONURL', $formFields);
442
  $this->assertArrayHasKey('CANCELURL', $formFields);
443
  $this->assertEquals('NRMAGENTO', $formFields['PSPID']);
444
- $this->assertEquals(
445
- '2d9f92d6f3955847ab2db427be75fe7eb0cde045', $formFields['SHASIGN']
446
- );
447
  }
448
 
449
- public function testGetFormFieldsWithTPParam()
450
- {
451
- $this->markTestIncomplete('Depends on PCI release');
452
-
453
- $paymentModel = $this->getModelMock(
454
- 'ops/payment_abstract', array('getMethodDependendFormFields')
455
- );
456
- $configMock = $this->getModelMock(
457
- 'ops/config', array('getPSPID', 'getconfigData')
458
- );
459
- $configMock->expects($this->once())
460
- ->method('getPSPID')
461
- ->with(null)
462
- ->will($this->returnValue('NRMAGENTO'));
463
- $configMock->expects($this->any())
464
- ->method('getConfigData')
465
- // ->with('template')
466
- ->will($this->returnValue('spo'));
467
- $this->replaceByMock('model', 'ops/config', $configMock);
468
- $helperMock = $this->getHelperMock('ops/payment', array('getShaSign'));
469
- $helperMock->expects($this->any())
470
- ->method('getSHASign')
471
- ->with(
472
- $this->anything(),
473
- $this->anything(),
474
- null
475
- )
476
- ->will($this->returnValue('SHA123'));
477
- $this->replaceByMock('helper', 'ops/payment', $helperMock);
478
- $order = new Varien_Object();
479
- $payment = new Varien_Object();
480
- $payment->setMethodInstance(Mage::getModel('ops/payment_cc'));
481
- $order->setPayment($payment);
482
- $formFields = $paymentModel->getFormFields($order, array());
483
- $this->assertArrayHasKey('PSPID', $formFields);
484
- $this->assertArrayHasKey('SHASIGN', $formFields);
485
- $this->assertArrayHasKey('TP', $formFields);
486
- $this->assertEquals('NRMAGENTO', $formFields['PSPID']);
487
- $this->assertEquals(
488
- '2d9f92d6f3955847ab2db427be75fe7eb0cde045', $formFields['SHASIGN']
489
- );
490
- }
491
  /**
492
  * @loadFixture ../../../../var/fixtures/orders.yaml
493
  */
@@ -584,24 +482,6 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
584
  );
585
  }
586
 
587
- /**
588
- * @loadFixture ../../../../var/fixtures/orders.yaml
589
- */
590
- public function testVoidWithOpsAutoVoid()
591
- {
592
- Mage::register('ops_auto_void', true);
593
- $paymentModel = $this->getModelMock(
594
- 'ops/payment_abstract',
595
- array('canVoid')
596
- );
597
- $paymentModel->expects($this->any())
598
- ->method('canVoid')
599
- ->will($this->returnValue(true));
600
- $payment = Mage::getModel('sales/order_payment');
601
- $paymentModel->void($payment, 11.90);
602
- $this->assertNull(Mage::registry('ops_auto_void'));
603
- }
604
-
605
  /**
606
  * @loadFixture ../../../../var/fixtures/orders.yaml
607
  */
@@ -615,7 +495,7 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
615
  ->will($this->returnValue(true));
616
  $this->replaceByMock('helper', 'ops/directlink', $helperMock);
617
  $order = Mage::getModel('sales/order')->load(11);
618
-
619
  $paymentModel = $this->getModelMock(
620
  'ops/payment_abstract',
621
  array('canVoid')
@@ -628,13 +508,13 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
628
  $dataHelperMock = $this->getHelperMock('ops/data', array('redirect'));
629
  $this->replaceByMock('helper', 'ops/data', $dataHelperMock);
630
 
631
- Mage::getSingleton('core/session')->getMessages(true);
632
  $noticeCountBefore = sizeof(
633
- Mage::getSingleton('core/session')->getItemsByType('notice')
634
  );
635
  $paymentModel->void($order->getPayment());
636
- $notices = Mage::getSingleton('core/session')->getMessages()->getItemsByType(
637
- 'notice'
638
  );
639
  $noticeCountAfter = sizeof($notices);
640
  $this->assertGreaterThan($noticeCountBefore, $noticeCountAfter);
@@ -647,64 +527,13 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
647
 
648
  }
649
 
650
- /**
651
- * @loadFixture ../../../../var/fixtures/orders.yaml
652
- */
653
- public function testVoidWithExistingCaptureLeadsToRedirect()
654
- {
655
-
656
- $paymentModel = $this->getModelMock(
657
- 'ops/payment_abstract',
658
- array('canVoid')
659
- );
660
- $paymentModel->expects($this->any())
661
- ->method('canVoid')
662
- ->will($this->returnValue(true));
663
-
664
-
665
- $dataHelperMock = $this->getHelperMock('ops/data', array('redirect'));
666
- $this->replaceByMock('helper', 'ops/data', $dataHelperMock);
667
-
668
-
669
- $helperMock = $this->getHelperMock('ops/directlink', array('checkExistingTransact'));
670
- $closure = function ($transactionType, $orderId) {
671
- $result = false;
672
- if ($transactionType == Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE) {
673
- $result = true;
674
- }
675
- return $result;
676
- };
677
-
678
- $helperMock
679
- ->expects($this->any())
680
- ->method('checkExistingTransact')
681
- ->will($this->returnCallback($closure));
682
- $this->replaceByMock('helper', 'ops/directlink', $helperMock);
683
-
684
- Mage::getSingleton('core/session')->getMessages(true);
685
- $noticeCountBefore = sizeof(
686
- Mage::getSingleton('core/session')->getItemsByType('notice')
687
- );
688
-
689
- $order = Mage::getModel('sales/order')->load(11);
690
-
691
- $paymentModel->void($order->getPayment());
692
- $notices = Mage::getSingleton('core/session')->getMessages()->getItemsByType(
693
- 'notice'
694
- );
695
- $noticeCountAfter = sizeof($notices);
696
- $this->assertGreaterThan($noticeCountBefore, $noticeCountAfter);
697
- $this->assertEquals(
698
- $dataHelperMock->__('There is one capture request waiting. Please wait until this request is acknowledged.'),
699
- current($notices)->getText()
700
- );
701
- }
702
 
703
  /**
704
  * @loadFixture ../../../../var/fixtures/orders.yaml
705
  */
706
  public function testVoidFailsWhenRequestThrowsException()
707
  {
 
708
  $paymentModel = $this->getModelMock(
709
  'ops/payment_abstract',
710
  array('canVoid')
@@ -730,6 +559,7 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
730
  );
731
  $this->replaceByMock('model', 'ops/api_directlink', $apiClientMock);
732
  $order = Mage::getModel('sales/order')->load(11);
 
733
  try {
734
  $paymentModel->void($order->getPayment());
735
  } catch (Exception $e) {
@@ -767,12 +597,13 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
767
  )));
768
  $this->replaceByMock('model', 'ops/api_directlink', $apiClientMock);
769
  $order = Mage::getModel('sales/order')->load(11);
 
770
  try {
771
  $paymentModel->void($order->getPayment());
772
  } catch (Exception $e) {
773
- $this->assertEquals(666, $order->getPayment()->getAdditionalInformation('status'));
774
  $helper = Mage::helper('ops/data');
775
- $this->assertEquals($helper->__('Void order failed. Ingenico Payment Services status: %s.', 666), $e->getMessage());
776
  }
777
  }
778
 
@@ -810,29 +641,18 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
810
  ->method('performRequest')
811
  ->will(
812
  $this->returnValue(array(
813
- 'STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_WAITING,
814
  'PAYID' => '4711',
815
  'PAYIDSUB' => '0815'
816
  )));
817
  $this->replaceByMock('model', 'ops/api_directlink', $apiClientMock);
818
  $order = Mage::getModel('sales/order')->load(11);
 
819
 
820
- Mage::getSingleton('core/session')->getMessages(true);
821
- $noticeCountBefore = sizeof(
822
- Mage::getSingleton('core/session')->getItemsByType('notice')
823
- );
824
-
825
  $paymentModel->void($order->getPayment());
826
- $notices = Mage::getSingleton('core/session')->getMessages()->getItemsByType(
827
- 'notice'
828
- );
829
- $noticeCountAfter = sizeof($notices);
830
- $this->assertGreaterThan($noticeCountBefore, $noticeCountAfter);
831
- $this->assertEquals(
832
- $dataHelperMock->__('The void request is sent. Please wait until the void request will be accepted.'),
833
- current($notices)->getText()
834
- );
835
-
836
  }
837
 
838
  /**
@@ -869,17 +689,18 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
869
  ->method('performRequest')
870
  ->will(
871
  $this->returnValue(array(
872
- 'STATUS' => Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED_ACCEPTED,
873
  'PAYID' => '4711',
874
  'PAYIDSUB' => '0815'
875
  )));
876
  $this->replaceByMock('model', 'ops/api_directlink', $apiClientMock);
877
  $order = Mage::getModel('sales/order')->load(11);
878
-
 
879
  $paymentModel->void($order->getPayment());
880
 
881
  $this->assertEquals(
882
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED_ACCEPTED,
883
  $order->getPayment()->getAdditionalInformation('status')
884
  );
885
 
@@ -925,6 +746,78 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
925
  $this->assertEquals('HTML', Mage::getModel('ops/payment_abstract')->getOpsHtmlAnswer($order->getPayment()));
926
  }
927
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
928
  protected function getOwnerParams()
929
  {
930
  return $ownerParams = array(
@@ -954,4 +847,5 @@ class Netresearch_OPS_Test_Model_Payment_AbstractTest
954
  }
955
 
956
 
 
957
  }
1
  <?php
2
+ class Netresearch_OPS_Test_Model_Payment_AbstractTest extends EcomDev_PHPUnit_Test_Case_Controller
 
3
  {
4
  protected $model = null;
5
 
173
 
174
  //Check for denied can cancel (processing and payment status 0)
175
  $order = Mage::getModel("sales/order")->load(13);
176
+ $this->assertTrue($opsAbstractPayment->canCancelManually($order));
177
  }
178
 
179
 
225
  }
226
 
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  /**
229
  * @test
230
  * @loadFixture ../../../../var/fixtures/orders.yaml
383
  $this->assertArrayHasKey('EXCEPTIONURL', $formFields);
384
  $this->assertArrayHasKey('CANCELURL', $formFields);
385
  $this->assertEquals('NRMAGENTO', $formFields['PSPID']);
386
+ $this->assertEquals('2d9f92d6f3955847ab2db427be75fe7eb0cde045', $formFields['SHASIGN']);
 
 
387
  }
388
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
  /**
390
  * @loadFixture ../../../../var/fixtures/orders.yaml
391
  */
482
  );
483
  }
484
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  /**
486
  * @loadFixture ../../../../var/fixtures/orders.yaml
487
  */
495
  ->will($this->returnValue(true));
496
  $this->replaceByMock('helper', 'ops/directlink', $helperMock);
497
  $order = Mage::getModel('sales/order')->load(11);
498
+ $order->getPayment()->setAdditionalInformation('status', 5);
499
  $paymentModel = $this->getModelMock(
500
  'ops/payment_abstract',
501
  array('canVoid')
508
  $dataHelperMock = $this->getHelperMock('ops/data', array('redirect'));
509
  $this->replaceByMock('helper', 'ops/data', $dataHelperMock);
510
 
511
+ Mage::getSingleton('admin/session')->getMessages(true);
512
  $noticeCountBefore = sizeof(
513
+ Mage::getSingleton('admin/session')->getItemsByType('error')
514
  );
515
  $paymentModel->void($order->getPayment());
516
+ $notices = Mage::getSingleton('admin/session')->getMessages()->getItemsByType(
517
+ 'error'
518
  );
519
  $noticeCountAfter = sizeof($notices);
520
  $this->assertGreaterThan($noticeCountBefore, $noticeCountAfter);
527
 
528
  }
529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
 
531
  /**
532
  * @loadFixture ../../../../var/fixtures/orders.yaml
533
  */
534
  public function testVoidFailsWhenRequestThrowsException()
535
  {
536
+ /** @var Netresearch_OPS_Model_Payment_Abstract $paymentModel */
537
  $paymentModel = $this->getModelMock(
538
  'ops/payment_abstract',
539
  array('canVoid')
559
  );
560
  $this->replaceByMock('model', 'ops/api_directlink', $apiClientMock);
561
  $order = Mage::getModel('sales/order')->load(11);
562
+ $order->getPayment()->setAdditionalInformation('status', 5);
563
  try {
564
  $paymentModel->void($order->getPayment());
565
  } catch (Exception $e) {
597
  )));
598
  $this->replaceByMock('model', 'ops/api_directlink', $apiClientMock);
599
  $order = Mage::getModel('sales/order')->load(11);
600
+ $order->getPayment()->setAdditionalInformation('status', 5);
601
  try {
602
  $paymentModel->void($order->getPayment());
603
  } catch (Exception $e) {
604
+ $this->assertEquals(5, $order->getPayment()->getAdditionalInformation('status'));
605
  $helper = Mage::helper('ops/data');
606
+ $this->assertEquals($helper->__('Can not handle status %s.', 666), $e->getMessage());
607
  }
608
  }
609
 
641
  ->method('performRequest')
642
  ->will(
643
  $this->returnValue(array(
644
+ 'STATUS' => Netresearch_OPS_Model_Status::DELETION_WAITING,
645
  'PAYID' => '4711',
646
  'PAYIDSUB' => '0815'
647
  )));
648
  $this->replaceByMock('model', 'ops/api_directlink', $apiClientMock);
649
  $order = Mage::getModel('sales/order')->load(11);
650
+ $order->getPayment()->setAdditionalInformation('status', 5);
651
 
652
+ $paymentModel->setInfoInstance($order->getPayment());
 
 
 
 
653
  $paymentModel->void($order->getPayment());
654
+ $this->assertTrue($order->getPayment()->hasMessage());
655
+ $this->assertNotEmpty($order->getPayment()->getMessage());
 
 
 
 
 
 
 
 
656
  }
657
 
658
  /**
689
  ->method('performRequest')
690
  ->will(
691
  $this->returnValue(array(
692
+ 'STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED,
693
  'PAYID' => '4711',
694
  'PAYIDSUB' => '0815'
695
  )));
696
  $this->replaceByMock('model', 'ops/api_directlink', $apiClientMock);
697
  $order = Mage::getModel('sales/order')->load(11);
698
+ $order->getPayment()->setAdditionalInformation('status', 5);
699
+ $paymentModel->setInfoInstance($order->getPayment());
700
  $paymentModel->void($order->getPayment());
701
 
702
  $this->assertEquals(
703
+ Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED,
704
  $order->getPayment()->getAdditionalInformation('status')
705
  );
706
 
746
  $this->assertEquals('HTML', Mage::getModel('ops/payment_abstract')->getOpsHtmlAnswer($order->getPayment()));
747
  }
748
 
749
+ /**
750
+ * @loadFixture orders.yaml
751
+ * @expectedException Mage_Core_Exception
752
+ * @expectedExceptionMessage The payment review action is unavailable.
753
+ */
754
+ public function testAcceptPaymentNotSupportedState()
755
+ {
756
+ $payment = Mage::getModel('payment/info');
757
+ $payment->setAdditionalInformation('status', 99);
758
+ Mage::getModel('ops/payment_abstract')->acceptPayment($payment);
759
+ }
760
+
761
+
762
+ /**
763
+ * @loadFixture orders.yaml
764
+ * @expectedException Mage_Core_Exception
765
+ * @expectedExceptionMessage The order can not be accepted via Magento. For the actual status of the payment check the Ingenico ePayments backend.
766
+ */
767
+ public function testAcceptPaymentSupportedState()
768
+ {
769
+ $order = Mage::getModel('sales/order')->load(25);
770
+ $order->getPayment()->setAdditionalInformation('status', 57);
771
+
772
+ $result = Mage::getModel('ops/payment_abstract')->acceptPayment($order->getPayment());
773
+ }
774
+
775
+ /**
776
+ * @loadFixture orders.yaml
777
+ * @expectedException Mage_Core_Exception
778
+ * @expectedExceptionMessage The payment review action is unavailable.
779
+ */
780
+ public function testDenyPaymentNotSupportedState()
781
+ {
782
+ $payment = Mage::getModel('payment/info');
783
+ $payment->setAdditionalInformation('status', 99);
784
+ Mage::getModel('ops/payment_abstract')->denyPayment($payment);
785
+ }
786
+
787
+
788
+ /**
789
+ * @loadFixture orders.yaml
790
+ */
791
+ public function testDenyPaymentSupportedState()
792
+ {
793
+ $order = Mage::getModel('sales/order')->load(25);
794
+ $order->getPayment()->setAdditionalInformation('status', 57);
795
+
796
+ $result = Mage::getModel('ops/payment_abstract')->denyPayment($order->getPayment());
797
+ $this->assertTrue($result);
798
+ }
799
+
800
+
801
+ /**
802
+ * @loadFixture orders.yaml
803
+ */
804
+ public function testCanReviewPaymentFalse()
805
+ {
806
+ $order = Mage::getModel('sales/order')->load(25);
807
+ $order->getPayment()->setAdditionalInformation('status', 5);
808
+ $this->assertFalse(Mage::getModel('ops/payment_abstract')->canReviewPayment($order->getPayment()));
809
+ }
810
+
811
+ /**
812
+ * @loadFixture orders.yaml
813
+ */
814
+ public function testCanReviewPaymentTrue()
815
+ {
816
+ $order = Mage::getModel('sales/order')->load(25);
817
+ $order->getPayment()->setAdditionalInformation('status', 57);
818
+ $this->assertTrue(Mage::getModel('ops/payment_abstract')->canReviewPayment($order->getPayment()));
819
+ }
820
+
821
  protected function getOwnerParams()
822
  {
823
  return $ownerParams = array(
847
  }
848
 
849
 
850
+
851
  }
app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractTest/expectations/paymentMethods.yaml CHANGED
@@ -40,7 +40,7 @@ ops_CreditCard:
40
  ops_CreditCard:
41
  pm: CreditCard
42
    brand: VISA
43
- ops_CreditCard:
44
  pm: CreditCard
45
    brand: BCMC
46
  ops_CreditCard:
@@ -163,6 +163,9 @@ ops_fortisPayButton:
163
  ops_giroPay:
164
  pm: giropay
165
  brand: giropay
 
 
 
166
  ops_iDeal:
167
  pm: iDEAL
168
  brand: iDEAL
@@ -235,6 +238,9 @@ ops_openInvoiceFi:
235
  ops_openInvoiceNl:
236
  pm: Open Invoice NL
237
  brand: Open Invoice NL
 
 
 
238
  ops_openInvoiceNo:
239
  pm: Open Invoice NO
240
  brand: Open Invoice NO
40
  ops_CreditCard:
41
  pm: CreditCard
42
    brand: VISA
43
+ ops_BCMC:
44
  pm: CreditCard
45
    brand: BCMC
46
  ops_CreditCard:
163
  ops_giroPay:
164
  pm: giropay
165
  brand: giropay
166
+ ops_Masterpass:
167
+ pm: Masterpass
168
+ brand: Masterpass
169
  ops_iDeal:
170
  pm: iDEAL
171
  brand: iDEAL
238
  ops_openInvoiceNl:
239
  pm: Open Invoice NL
240
  brand: Open Invoice NL
241
+ ops_openInvoiceAT:
242
+ pm: Open Invoice AT
243
+ brand: Open Invoice AT
244
  ops_openInvoiceNo:
245
  pm: Open Invoice NO
246
  brand: Open Invoice NO
app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractTest/fixtures/.gitkeep DELETED
File without changes
app/code/community/Netresearch/OPS/Test/Model/Payment/AbstractTest/fixtures/orders.yaml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 25
4
+ increment_id: 100000025
5
+ shipping_address_id: 42
6
+ base_grand_total: 119.00
7
+ grand_total: 119.00
8
+ currency: 'EUR'
9
+ customer_gender: 1
10
+ shipping_method: 'flatrate_flatrate'
11
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
12
+ state: 'pending_payment'
13
+ status: 'pending_payment'
14
+ quote_id: 10
15
+
16
+ - entity_id: 26
17
+ increment_id: 100000026
18
+ shipping_address_id: 43
19
+ base_grand_total: 119.00
20
+ grand_total: 119.00
21
+ currency: 'EUR'
22
+ customer_gender: 1
23
+ shipping_method: 'flatrate_flatrate'
24
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
25
+ state: 'payment_review'
26
+ status: 'payment_review'
27
+ quote_id: 26
28
+
29
+ - entity_id: 27
30
+ increment_id: 100000027
31
+ shipping_address_id: 42
32
+ base_grand_total: 119.00
33
+ grand_total: 119.00
34
+ currency: 'EUR'
35
+ customer_gender: 1
36
+ shipping_method: 'flatrate_flatrate'
37
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
38
+ state: 'pending_payment'
39
+ status: 'pending_payment'
40
+ quote_id: 27
41
+
42
+
43
+
44
+ sales/quote:
45
+ - entity_id: 25
46
+ parent_id: 25
47
+ customer_id: 23
48
+ created_at: '2013-05-14 14:45:00'
49
+
50
+ - entity_id: 26
51
+ parent_id: 26
52
+ customer_id: 23
53
+ created_at: '2013-05-14 14:45:00'
54
+
55
+ - entity_id: 27
56
+ parent_id: 27
57
+ customer_id: 23
58
+ created_at: '2013-05-14 14:45:00'
59
+
60
+
61
+
62
+ sales/quote_payment:
63
+ - payment_id: 25
64
+ quote_id: 25
65
+ updated_at: '1970-01-01'
66
+ method: 'ops_iDeal'
67
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
68
+
69
+ - payment_id: 26
70
+ quote_id: 26
71
+ updated_at: '1970-01-01'
72
+ method: 'ops_iDeal'
73
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
74
+
75
+ - payment_id: 27
76
+ quote_id: 27
77
+ updated_at: '1970-01-01'
78
+ method: 'ops_iDeal'
79
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:9:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
80
+
81
+
82
+
83
+ sales/order_payment:
84
+ - entity_id: 25
85
+ parent_id: 25
86
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
87
+ method: 'ops_iDeal'
88
+
89
+ - entity_id: 26
90
+ parent_id: 26
91
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
92
+ method: 'ops_iDeal'
93
+
94
+ - entity_id: 27
95
+ parent_id: 27
96
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
97
+ method: 'ops_iDeal'
98
+
99
+
100
+
101
+ sales/order_address:
102
+ - entity_id: 42
103
+ parent_id: 25
104
+ address_type: 'billing'
105
+ firstname: 'Hubertus'
106
+ postcode: '04229'
107
+ lastname: 'Fürstenberg'
108
+ street: 'An der Tabaksmühle 3a'
109
+ city: 'Leipzig'
110
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
111
+ country_id: 'DE'
112
+ prefix: 'Prof. Dr.'
113
+ middlename: 'von'
114
+ suffix: 'MdL'
115
+ company: ''
116
+ fax: 12345678
117
+
118
+ - entity_id: 43
119
+ parent_id: 26
120
+ address_type: 'billing'
121
+ firstname: 'Hubertus'
122
+ postcode: '04229'
123
+ lastname: 'Fürstenberg'
124
+ street: 'An der Tabaksmühle 3a'
125
+ city: 'Leipzig'
126
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
127
+ country_id: 'DE'
128
+ prefix: 'Prof. Dr.'
129
+ middlename: 'von'
130
+ suffix: 'MdL'
131
+ company: ''
132
+ fax: 12345678
133
+
134
+
135
+
app/code/community/Netresearch/OPS/Test/Model/Payment/BancontactTest.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Netresearch_OPS_Test_Model_Payment_BancontactTest extends EcomDev_PHPUnit_Test_Case
5
+ {
6
+
7
+ protected $model = null;
8
+
9
+ public function setUp()
10
+ {
11
+ parent::setUp();
12
+ $this->model = Mage::getModel('ops/payment_bancontact');
13
+ $this->model->setInfoInstance(Mage::getModel('payment/info'));
14
+ }
15
+
16
+ public function testCanCapturePartial()
17
+ {
18
+ $this->assertTrue($this->model->canCapturePartial());
19
+ }
20
+
21
+ public function testGetOpsCode()
22
+ {
23
+ $this->assertEquals('CreditCard', $this->model->getOpsCode());
24
+ }
25
+
26
+ public function testGetOpsBrand()
27
+ {
28
+ $this->assertEquals('BCMC', $this->model->getOpsBrand());
29
+ }
30
+
31
+ }
app/code/community/Netresearch/OPS/Test/Model/Payment/CcTest.php CHANGED
@@ -123,13 +123,16 @@ class Netresearch_OPS_Test_Model_Payment_CcTest extends EcomDev_PHPUnit_Test_Cas
123
  ->will($this->returnValue(true));
124
  $this->replaceByMock('helper', 'ops/version', $helperMock);
125
 
126
- $quote = $this->getModelMock('sales/quote', array('getItemsCount', 'getBaseGrandTotal'));
127
  $quote->expects($this->once())
128
  ->method('getItemsCount')
129
  ->will($this->returnValue(1));
130
  $quote->expects($this->any())
131
  ->method('getBaseGrandTotal')
132
  ->will($this->returnValue(0.0));
 
 
 
133
  $this->assertTrue($this->_model->isApplicableToQuote($quote, 128));
134
  }
135
  }
@@ -192,26 +195,6 @@ class Netresearch_OPS_Test_Model_Payment_CcTest extends EcomDev_PHPUnit_Test_Cas
192
 
193
  }
194
 
195
- public function testCanReviewPayment(){
196
- $payment = Mage::getModel('sales/order_payment');
197
- $payment->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID);
198
- $ccMethod = Mage::getModel('ops/payment_cc');
199
- $this->assertTrue($ccMethod->canReviewPayment($payment));
200
-
201
- $payment->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING);
202
- $this->assertFalse($ccMethod->canReviewPayment($payment));
203
- }
204
-
205
- public function testDenyPayment(){
206
- $payment = Mage::getModel('sales/order_payment');
207
- $payment->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID);
208
- $ccMethod = Mage::getModel('ops/payment_cc');
209
- $this->assertTrue($ccMethod->denyPayment($payment));
210
-
211
- $payment->setAdditionalInformation('status', Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING);
212
- $this->assertFalse($ccMethod->denyPayment($payment));
213
- }
214
-
215
  public function testIsAvailable()
216
  {
217
  $helperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
123
  ->will($this->returnValue(true));
124
  $this->replaceByMock('helper', 'ops/version', $helperMock);
125
 
126
+ $quote = $this->getModelMock('sales/quote', array('getItemsCount', 'getBaseGrandTotal', 'isNominal'));
127
  $quote->expects($this->once())
128
  ->method('getItemsCount')
129
  ->will($this->returnValue(1));
130
  $quote->expects($this->any())
131
  ->method('getBaseGrandTotal')
132
  ->will($this->returnValue(0.0));
133
+ $quote->expects($this->any())
134
+ ->method('isNominal')
135
+ ->will($this->returnValue(false));
136
  $this->assertTrue($this->_model->isApplicableToQuote($quote, 128));
137
  }
138
  }
195
 
196
  }
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  public function testIsAvailable()
199
  {
200
  $helperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
app/code/community/Netresearch/OPS/Test/Model/Payment/ChinaUnionPayTest.php CHANGED
@@ -14,7 +14,7 @@ class Netresearch_OPS_Test_Model_Payment_ChinaUnionPayTest extends EcomDev_PHPUn
14
  }
15
 
16
  /**
17
- * assure that openInvoiceNL can not capture partial, because invoice is always created on feedback in this case
18
  */
19
  public function testCanCapturePartial()
20
  {
14
  }
15
 
16
  /**
17
+ * assure that CUP can not capture partial, because invoice is always created on feedback in this case
18
  */
19
  public function testCanCapturePartial()
20
  {
app/code/community/Netresearch/OPS/Test/Model/Payment/DebitcardTest.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * DebitcardTest.php
24
+ *
25
+ * @category test
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Model_Payment_DebitcardTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+ /** @var Netresearch_OPS_Model_Payment_Debitcard model */
36
+ protected $model;
37
+
38
+ protected function setUp()
39
+ {
40
+ parent::setUp();
41
+ $this->model = Mage::getModel('ops/payment_debitcard');
42
+ }
43
+
44
+ public function testGetOpsCode()
45
+ {
46
+ $this->assertEquals('CreditCard', $this->model->getOpsCode());
47
+ }
48
+
49
+ public function testGetRequestParamsHelper()
50
+ {
51
+ $this->assertTrue($this->model->getRequestParamsHelper() instanceof Netresearch_OPS_Helper_Debitcard);
52
+ }
53
+ }
app/code/community/Netresearch/OPS/Test/Model/Payment/DirectLinkTest.php CHANGED
@@ -17,9 +17,12 @@ class Netresearch_OPS_Test_Model_Payment_DirectLinkTest extends EcomDev_PHPUnit_
17
  {
18
  parent::setUp();
19
  $payment = Mage::getModel('sales/order_payment');
20
- $payment->setAdditionalInformation('CC_BRAND', 'VISA');
 
21
  $this->testObjects[] = Mage::getModel('ops/payment_cc')->setInfoInstance($payment);
22
- $this->testObjects[] = Mage::getModel('ops/payment_directDebit');
 
 
23
  }
24
 
25
 
@@ -30,17 +33,6 @@ class Netresearch_OPS_Test_Model_Payment_DirectLinkTest extends EcomDev_PHPUnit_
30
  }
31
  }
32
 
33
- public function testGetConfigPaymentActionReturnsEmptyStringAsDefault()
34
- {
35
- $configMock = $this->getModelMock('ops/config', array('getPaymentAction'));
36
- $configMock->expects($this->any())
37
- ->method('getPaymentAction')
38
- ->will($this->returnValue('foo'));
39
- foreach ($this->testObjects as $testObject) {
40
- $testObject->setConfig($configMock);
41
- $this->assertEquals('', $testObject->getConfigPaymentAction());
42
- }
43
- }
44
 
45
  public function testGetConfigPaymentActionReturnsMageAuthorizeWithOrderIdAsMerchRef()
46
  {
@@ -112,6 +104,7 @@ class Netresearch_OPS_Test_Model_Payment_DirectLinkTest extends EcomDev_PHPUnit_
112
 
113
  public function testIsInitializeNeededReturnsFalse()
114
  {
 
115
  $configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
116
  $configMock->expects($this->any())
117
  ->method('getInlineOrderReference')
@@ -171,7 +164,7 @@ class Netresearch_OPS_Test_Model_Payment_DirectLinkTest extends EcomDev_PHPUnit_
171
  ->method('confirmPayment')
172
  ->with($fakeOrder, $fakeQuote, $payment)
173
  ;
174
- $testMock->expects($this->once())
175
  ->method('hasBrandAliasInterfaceSupport')
176
  ->will($this->returnValue(true));
177
  ;
@@ -184,13 +177,16 @@ class Netresearch_OPS_Test_Model_Payment_DirectLinkTest extends EcomDev_PHPUnit_
184
  public function testConfirmPaymentWithResponse()
185
  {
186
  $configMock = $this->getConfigMockWithOrderId();
 
187
  $fakeOrder = $this->getFakeOrder();
 
188
  $payment = $this->getFakePayment($fakeOrder);
189
 
190
  $fakeQuote = $this->getFakeQuote();
191
  $quoteHelperMock = $this->getQuoteHelperMock($fakeQuote);
 
192
  $testMock = $this->getModelMock('ops/payment_directDebit', array('handleAdminPayment', 'performPreDirectLinkCallActions', 'performPostDirectLinkCallActions'));
193
-
194
  $dataHelperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
195
  $dataHelperMock->expects($this->once())
196
  ->method('isAdminSession')
@@ -214,14 +210,12 @@ class Netresearch_OPS_Test_Model_Payment_DirectLinkTest extends EcomDev_PHPUnit_
214
  ->will($this->returnValue($response));
215
  $testMock->setDirectLinkHelper($directLinkHelperMock);
216
  $testMock->setQuoteHelper($quoteHelperMock);
217
- $paymentHelperMock = $this->getHelperMock('ops/payment', array('applyStateForOrder'));
218
- $paymentHelperMock->expects($this->once())
219
- ->method('applyStateForOrder')
220
- ->with($fakeOrder, $response);
221
- $testMock->setPaymentHelper($paymentHelperMock);
222
  $testMock->setConfig($configMock);
223
  $testMock->authorize($payment, 100);
224
 
 
 
225
  }
226
 
227
  public function testConfirmPaymentWithInvalidResponse()
@@ -352,6 +346,7 @@ class Netresearch_OPS_Test_Model_Payment_DirectLinkTest extends EcomDev_PHPUnit_
352
  protected function getFakeOrder()
353
  {
354
  $fakeOrder = $this->getModelMock('sales/order', array('save', '_beforeSave'));
 
355
  return $fakeOrder;
356
  }
357
 
@@ -365,6 +360,7 @@ class Netresearch_OPS_Test_Model_Payment_DirectLinkTest extends EcomDev_PHPUnit_
365
  $payment = $this->getModelMock('sales/order_payment', array('save'));
366
  $payment->setMethodInstance(Mage::getModel('ops/payment_directDebit'));
367
  $payment->setOrder($fakeOrder);
 
368
  return $payment;
369
  }
370
 
17
  {
18
  parent::setUp();
19
  $payment = Mage::getModel('sales/order_payment');
20
+ $payment->setAdditionalInformation('CC_BRAND', 'VISA')
21
+ ->setMethod('ops_cc');
22
  $this->testObjects[] = Mage::getModel('ops/payment_cc')->setInfoInstance($payment);
23
+ $payment2 = clone($payment);
24
+ $payment2->setMethod('ops_directDebit');
25
+ $this->testObjects[] = Mage::getModel('ops/payment_directDebit')->setInfoInstance($payment2);
26
  }
27
 
28
 
33
  }
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  public function testGetConfigPaymentActionReturnsMageAuthorizeWithOrderIdAsMerchRef()
38
  {
104
 
105
  public function testIsInitializeNeededReturnsFalse()
106
  {
107
+
108
  $configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
109
  $configMock->expects($this->any())
110
  ->method('getInlineOrderReference')
164
  ->method('confirmPayment')
165
  ->with($fakeOrder, $fakeQuote, $payment)
166
  ;
167
+ $testMock->expects($this->any())
168
  ->method('hasBrandAliasInterfaceSupport')
169
  ->will($this->returnValue(true));
170
  ;
177
  public function testConfirmPaymentWithResponse()
178
  {
179
  $configMock = $this->getConfigMockWithOrderId();
180
+ /** @var Mage_Sales_Model_Order $fakeOrder */
181
  $fakeOrder = $this->getFakeOrder();
182
+ /** @var Mage_Sales_Model_Order_Payment $payment */
183
  $payment = $this->getFakePayment($fakeOrder);
184
 
185
  $fakeQuote = $this->getFakeQuote();
186
  $quoteHelperMock = $this->getQuoteHelperMock($fakeQuote);
187
+ /** @var Netresearch_OPS_Model_Payment_DirectDebit $testMock */
188
  $testMock = $this->getModelMock('ops/payment_directDebit', array('handleAdminPayment', 'performPreDirectLinkCallActions', 'performPostDirectLinkCallActions'));
189
+ $testMock->setInfoInstance($payment);
190
  $dataHelperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
191
  $dataHelperMock->expects($this->once())
192
  ->method('isAdminSession')
210
  ->will($this->returnValue($response));
211
  $testMock->setDirectLinkHelper($directLinkHelperMock);
212
  $testMock->setQuoteHelper($quoteHelperMock);
213
+
 
 
 
 
214
  $testMock->setConfig($configMock);
215
  $testMock->authorize($payment, 100);
216
 
217
+ $this->assertEquals(5,$payment->getAdditionalInformation('status'));
218
+ $this->assertNotEmpty($fakeOrder->getAllStatusHistory());
219
  }
220
 
221
  public function testConfirmPaymentWithInvalidResponse()
346
  protected function getFakeOrder()
347
  {
348
  $fakeOrder = $this->getModelMock('sales/order', array('save', '_beforeSave'));
349
+ $fakeOrder->setState(Mage_Sales_Model_Order::STATE_NEW);
350
  return $fakeOrder;
351
  }
352
 
360
  $payment = $this->getModelMock('sales/order_payment', array('save'));
361
  $payment->setMethodInstance(Mage::getModel('ops/payment_directDebit'));
362
  $payment->setOrder($fakeOrder);
363
+ $fakeOrder->setPayment($payment);
364
  return $payment;
365
  }
366
 
app/code/community/Netresearch/OPS/Test/Model/Payment/Features/PaymentEmailTest.php CHANGED
@@ -1,12 +1,14 @@
1
  <?php
 
2
  /**
3
  * PaymentEmailTest.php
4
- * @author paul.siedler@netresearch.de
 
5
  * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
6
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License
7
  */
8
-
9
- class Netresearch_OPS_Test_Model_Payment_Features_PaymentEmailTest extends EcomDev_PHPUnit_Test_Case {
10
 
11
  /** @var Netresearch_OPS_Model_Payment_Features_PaymentEmail $testSubject */
12
  protected $testSubject;
@@ -29,8 +31,8 @@ class Netresearch_OPS_Test_Model_Payment_Features_PaymentEmailTest extends EcomD
29
  $payment->setAdditionalInformation(array('status' => 9));
30
  $order = $this->getModelMock('sales/order', array('getPayment'));
31
  $order->expects($this->once())
32
- ->method('getPayment')
33
- ->will($this->returnValue($payment));
34
  $this->assertFalse($this->testSubject->isAvailableForOrder($order));
35
 
36
  // payment has relevant status -> returns true
@@ -38,30 +40,55 @@ class Netresearch_OPS_Test_Model_Payment_Features_PaymentEmailTest extends EcomD
38
  $payment->setAdditionalInformation(array('status' => 1));
39
  $order = $this->getModelMock('sales/order', array('getPayment'));
40
  $order->expects($this->once())
41
- ->method('getPayment')
42
- ->will($this->returnValue($payment));
43
  $this->assertTrue($this->testSubject->isAvailableForOrder($order));
44
 
45
  }
46
 
47
  public function testResendPaymentInfo()
48
  {
49
- $genericMethod = Mage::getModel('ops/payment_other');
50
 
51
 
52
  $payment = $this->getModelMock('sales/order_payment', array('save'));
53
  $payment->expects($this->once())
54
- ->method('save')
55
- ->will($this->returnValue(null));
56
 
 
 
 
 
 
 
57
 
58
- $order = $this->getModelMock('sales/order', array('getPayment'));
59
- $order->expects($this->any())
60
- ->method('getPayment')
61
- ->will($this->returnValue($payment));
62
-
63
- $this->assertFalse($this->testSubject->resendPaymentInfo($order));
64
  $this->assertNotEquals($order->getPayment()->getMethod(), 'foobar');
65
- $this->assertEquals($order->getPayment()->getMethod(), Netresearch_OPS_Model_Payment_Other::CODE);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
  }
1
  <?php
2
+
3
  /**
4
  * PaymentEmailTest.php
5
+ *
6
+ * @author paul.siedler@netresearch.de
7
  * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
9
  */
10
+ class Netresearch_OPS_Test_Model_Payment_Features_PaymentEmailTest extends EcomDev_PHPUnit_Test_Case
11
+ {
12
 
13
  /** @var Netresearch_OPS_Model_Payment_Features_PaymentEmail $testSubject */
14
  protected $testSubject;
31
  $payment->setAdditionalInformation(array('status' => 9));
32
  $order = $this->getModelMock('sales/order', array('getPayment'));
33
  $order->expects($this->once())
34
+ ->method('getPayment')
35
+ ->will($this->returnValue($payment));
36
  $this->assertFalse($this->testSubject->isAvailableForOrder($order));
37
 
38
  // payment has relevant status -> returns true
40
  $payment->setAdditionalInformation(array('status' => 1));
41
  $order = $this->getModelMock('sales/order', array('getPayment'));
42
  $order->expects($this->once())
43
+ ->method('getPayment')
44
+ ->will($this->returnValue($payment));
45
  $this->assertTrue($this->testSubject->isAvailableForOrder($order));
46
 
47
  }
48
 
49
  public function testResendPaymentInfo()
50
  {
51
+ $genericMethod = Mage::getModel('ops/payment_flex');
52
 
53
 
54
  $payment = $this->getModelMock('sales/order_payment', array('save'));
55
  $payment->expects($this->once())
56
+ ->method('save')
57
+ ->will($this->returnValue(null));
58
 
59
+ $order = Mage::getModel('sales/order');
60
+ $order->setData('customer_email', 'a@bc.de')
61
+ ->setData('customer_firstname', 'Hans')
62
+ ->setData('customer_lastname', 'Wurst')
63
+ ->setStoreId(0)
64
+ ->setPayment($payment);
65
 
66
+ $this->assertTrue($this->testSubject->resendPaymentInfo($order));
 
 
 
 
 
67
  $this->assertNotEquals($order->getPayment()->getMethod(), 'foobar');
68
+ $this->assertEquals($order->getPayment()->getMethod(), Netresearch_OPS_Model_Payment_Flex::CODE);
69
+ }
70
+
71
+ /**
72
+ * @expectedException Exception
73
+ * @expectedExceptionMessage Could not send mail due to internal error!
74
+ */
75
+ public function testSendSuspendSubscriptionMailWithException()
76
+ {
77
+ $this->testSubject->sendSuspendSubscriptionMail(null, null);
78
+ }
79
+
80
+ public function testSendSuspendSubscriptionMail()
81
+ {
82
+ $profile = Mage::getModel('sales/recurring_profile');
83
+ $profile->setReferenceId('SUB-123')
84
+ ->setStoreId(0);
85
+
86
+ $customer = Mage::getModel('customer/customer');
87
+ $customer->setEmail('a@bc.de')
88
+ ->setFirstName('Hans')
89
+ ->setLastName('Wurst');
90
+
91
+ $this->assertTrue($this->testSubject->sendSuspendSubscriptionMail($profile, $customer));
92
+
93
  }
94
  }
app/code/community/Netresearch/OPS/Test/Model/Payment/Features/ZeroAmountAuthTest.php CHANGED
@@ -36,10 +36,13 @@ class Netresearch_OPS_Test_Model_Payment_Features_ZeroAmountAuthTest extends Eco
36
  public function testIsCCAndZeroAmountAuthAllowedTrue()
37
  {
38
  $ccModelMock = $this->getCCMock(true);
39
- $quote = $this->getModelMock('sales/quote', array('getItemsCount'));
40
  $quote->expects($this->once())
41
  ->method('getItemsCount')
42
  ->will($this->returnValue(1));
 
 
 
43
  $this->assertTrue($this->featureModel->isCCAndZeroAmountAuthAllowed($ccModelMock, $quote));
44
  }
45
 
36
  public function testIsCCAndZeroAmountAuthAllowedTrue()
37
  {
38
  $ccModelMock = $this->getCCMock(true);
39
+ $quote = $this->getModelMock('sales/quote', array('getItemsCount', 'isNominal'));
40
  $quote->expects($this->once())
41
  ->method('getItemsCount')
42
  ->will($this->returnValue(1));
43
+ $quote->expects($this->once())
44
+ ->method('isNominal')
45
+ ->will($this->returnValue(false));
46
  $this->assertTrue($this->featureModel->isCCAndZeroAmountAuthAllowed($ccModelMock, $quote));
47
  }
48
 
app/code/community/Netresearch/OPS/Test/Model/Payment/FlexTest.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * FlexTest.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Model_Payment_FlexTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+
36
+ protected function getAdditionalInfo()
37
+ {
38
+ return array(
39
+
40
+ Netresearch_OPS_Model_Payment_Flex::INFO_KEY_TITLE => 'Foobar',
41
+ Netresearch_OPS_Model_Payment_Flex::INFO_KEY_PM => 'foo',
42
+ Netresearch_OPS_Model_Payment_Flex::INFO_KEY_BRAND => 'bar'
43
+ );
44
+ }
45
+
46
+ public function testGetOpsCode()
47
+ {
48
+ $payment = Mage::getModel('sales/order_payment');
49
+ $additionalInfo = $this->getAdditionalInfo();
50
+ $payment->setMethod(Netresearch_OPS_Model_Payment_Flex::CODE)
51
+ ->setAdditionalInformation(
52
+ $additionalInfo
53
+ );
54
+ /** @var Netresearch_OPS_Model_Payment_Flex $subject */
55
+ $subject = $payment->getMethodInstance();
56
+
57
+ $this->assertEquals($additionalInfo[Netresearch_OPS_Model_Payment_Flex::INFO_KEY_PM], $subject->getOpsCode());
58
+ }
59
+
60
+ public function testGetOpsBrand()
61
+ {
62
+ $payment = Mage::getModel('sales/order_payment');
63
+ $additionalInfo = $this->getAdditionalInfo();
64
+ $payment->setMethod(Netresearch_OPS_Model_Payment_Flex::CODE)
65
+ ->setAdditionalInformation(
66
+ $additionalInfo
67
+ );
68
+ /** @var Netresearch_OPS_Model_Payment_Flex $subject */
69
+ $subject = $payment->getMethodInstance();
70
+
71
+ $this->assertEquals(
72
+ $additionalInfo[Netresearch_OPS_Model_Payment_Flex::INFO_KEY_BRAND], $subject->getOpsBrand()
73
+ );
74
+
75
+ }
76
+
77
+ }
app/code/community/Netresearch/OPS/Test/Model/Payment/Kwixo/AbstractTest.php CHANGED
@@ -6,7 +6,7 @@ class Netresearch_OPS_Test_Model_Payment_Kwixo_AbstractTest
6
 
7
  /**
8
  * @test
9
- * @loadFixture ../../../../../var/fixtures/orders.yaml
10
  */
11
  public function testGetMethodDependendFormFields()
12
  {
@@ -30,6 +30,8 @@ class Netresearch_OPS_Test_Model_Payment_Kwixo_AbstractTest
30
 
31
  $formFields = Mage::getModel('ops/payment_kwixo_abstract')
32
  ->getMethodDependendFormFields($order);
 
 
33
  $this->assertTrue(array_key_exists('CN', $formFields));
34
  $this->assertTrue(array_key_exists('OWNERZIP', $formFields));
35
  $this->assertTrue(array_key_exists('OWNERCTY', $formFields));
6
 
7
  /**
8
  * @test
9
+ * @loadFixture orders.yaml
10
  */
11
  public function testGetMethodDependendFormFields()
12
  {
30
 
31
  $formFields = Mage::getModel('ops/payment_kwixo_abstract')
32
  ->getMethodDependendFormFields($order);
33
+
34
+
35
  $this->assertTrue(array_key_exists('CN', $formFields));
36
  $this->assertTrue(array_key_exists('OWNERZIP', $formFields));
37
  $this->assertTrue(array_key_exists('OWNERCTY', $formFields));
app/code/community/Netresearch/OPS/Test/Model/Payment/Kwixo/AbstractTest/expectations/paymentMethods.yaml CHANGED
@@ -40,7 +40,7 @@ ops_CreditCard:
40
  ops_CreditCard:
41
  pm: CreditCard
42
    brand: VISA
43
- ops_CreditCard:
44
  pm: CreditCard
45
    brand: BCMC
46
  ops_CreditCard:
@@ -163,6 +163,9 @@ ops_fortisPayButton:
163
  ops_giroPay:
164
  pm: giropay
165
  brand: giropay
 
 
 
166
  ops_iDeal:
167
  pm: iDEAL
168
  brand: iDEAL
@@ -235,6 +238,9 @@ ops_openInvoiceFi:
235
  ops_openInvoiceNl:
236
  pm: Open Invoice NL
237
  brand: Open Invoice NL
 
 
 
238
  ops_openInvoiceNo:
239
  pm: Open Invoice NO
240
  brand: Open Invoice NO
40
  ops_CreditCard:
41
  pm: CreditCard
42
    brand: VISA
43
+ ops_BCMC:
44
  pm: CreditCard
45
    brand: BCMC
46
  ops_CreditCard:
163
  ops_giroPay:
164
  pm: giropay
165
  brand: giropay
166
+ ops_Masterpass:
167
+ pm: Masterpass
168
+ brand: Masterpass
169
  ops_iDeal:
170
  pm: iDEAL
171
  brand: iDEAL
238
  ops_openInvoiceNl:
239
  pm: Open Invoice NL
240
  brand: Open Invoice NL
241
+ ops_openInvoiceAT:
242
+ pm: Open Invoice AT
243
+ brand: Open Invoice AT
244
  ops_openInvoiceNo:
245
  pm: Open Invoice NO
246
  brand: Open Invoice NO
app/code/community/Netresearch/OPS/Test/Model/Payment/Kwixo/AbstractTest/fixtures/orders.yaml ADDED
@@ -0,0 +1,633 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ config:
2
+ default/payment_services/ops/submitExtraParameters: 1
3
+
4
+ tables:
5
+ sales/order:
6
+ - entity_id: 11
7
+ increment_id: 100000011
8
+ shipping_address_id: 42
9
+ base_grand_total: 119.00
10
+ grand_total: 119.00
11
+ currency: 'EUR'
12
+ customer_gender: 1
13
+ shipping_method: 'flatrate_flatrate'
14
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
15
+ state: 'pending_payment'
16
+ status: 'pending_payment'
17
+ quote_id: 23
18
+ store_id: 0
19
+
20
+ - entity_id: 12
21
+ increment_id: 100000012
22
+ shipping_address_id: 42
23
+ base_grand_total: 119.00
24
+ grand_total: 119.00
25
+ currency: 'EUR'
26
+ customer_gender: 1
27
+ shipping_method: 'flatrate_flatrate'
28
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
29
+ state: 'pending_payment'
30
+ status: 'pending_payment'
31
+ quote_id: 24
32
+
33
+ - entity_id: 13
34
+ increment_id: 100000013
35
+ shipping_address_id: 43
36
+ base_grand_total: 177.55
37
+ grand_total: 177.55
38
+ currency: 'EUR'
39
+ customer_gender: 1
40
+ shipping_method: 'flatrate_flatrate'
41
+ customer_email: 'willi.usa.customer@trash-mail.com'
42
+ state: 'processing'
43
+ status: 'processing'
44
+ quote_id: 25
45
+ store_id: 0
46
+
47
+ - entity_id: 14
48
+ increment_id: 100000014
49
+ shipping_address_id: 43
50
+ base_grand_total: 177.55
51
+ grand_total: 177.55
52
+ currency: 'EUR'
53
+ customer_gender: 1
54
+ shipping_method: 'flatrate_flatrate'
55
+ customer_email: 'willi.usa.customer@trash-mail.com'
56
+ state: 'pending_payment'
57
+ status: 'pending_payment'
58
+ quote_id: 26
59
+
60
+ - entity_id: 15
61
+ increment_id: 100000015
62
+ shipping_address_id: 43
63
+ base_grand_total: 177.55
64
+ grand_total: 200.00
65
+ currency: '$'
66
+ customer_gender: 1
67
+ shipping_method: 'flatrate_flatrate'
68
+ customer_email: 'willi.usa.customer@trash-mail.com'
69
+ state: 'pending_payment'
70
+ status: 'pending_payment'
71
+ quote_id: 27
72
+
73
+ - entity_id: 16
74
+ increment_id: 100000016
75
+ shipping_address_id: 43
76
+ base_grand_total: 19.99
77
+ grand_total: 19.99
78
+ currency: 'EUR'
79
+ customer_gender: 1
80
+ shipping_method: 'flatrate_flatrate'
81
+ customer_email: 'willi.usa.customer@trash-mail.com'
82
+ state: 'pending_payment'
83
+ status: 'pending_payment'
84
+ quote_id: 28
85
+
86
+ - entity_id: 17
87
+ increment_id: 100000017
88
+ shipping_address_id: 43
89
+ base_grand_total: 19.99
90
+ grand_total: 19.99
91
+ currency: 'EUR'
92
+ customer_gender: 1
93
+ shipping_method: 'flatrate_flatrate'
94
+ customer_email: 'willi.usa.customer@trash-mail.com'
95
+ state: 'pending_payment'
96
+ status: 'pending_payment'
97
+ quote_id: 29
98
+
99
+ - entity_id: 18
100
+ increment_id: 100000018
101
+ shipping_address_id: 43
102
+ base_grand_total: 19.99
103
+ grand_total: 19.99
104
+ currency: 'EUR'
105
+ customer_gender: 1
106
+ shipping_method: 'flatrate_flatrate'
107
+ customer_email: 'willi.usa.customer@trash-mail.com'
108
+ state: 'pending_payment'
109
+ status: 'pending_payment'
110
+ quote_id: 30
111
+
112
+ - entity_id: 19
113
+ increment_id: 100000019
114
+ shipping_address_id: 50
115
+ base_grand_total: 19.99
116
+ grand_total: 19.99
117
+ currency: 'EUR'
118
+ customer_gender: 1
119
+ shipping_method: 'flatrate_flatrate'
120
+ customer_email: 'willi.usa.customer@trash-mail.com'
121
+ state: 'pending_payment'
122
+ status: 'pending_payment'
123
+ quote_id: 43
124
+
125
+ - entity_id: 20
126
+ increment_id: 100000020
127
+ shipping_address_id: 42
128
+ base_grand_total: 119.00
129
+ grand_total: 119.00
130
+ currency: 'EUR'
131
+ customer_gender: 1
132
+ shipping_method: 'flatrate_flatrate'
133
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
134
+ state: 'pending_payment'
135
+ status: 'pending_payment'
136
+ quote_id: 42#
137
+
138
+ - entity_id: 21
139
+ increment_id: 100000021
140
+ shipping_address_id: 42
141
+ base_grand_total: 119.00
142
+ grand_total: 119.00
143
+ currency: 'EUR'
144
+ customer_gender: 1
145
+ shipping_method: 'flatrate_flatrate'
146
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
147
+ state: 'pending_payment'
148
+ status: 'pending_payment'
149
+
150
+ - entity_id: 22
151
+ increment_id: 100000022
152
+ shipping_address_id: 42
153
+ base_grand_total: 119.00
154
+ grand_total: 119.00
155
+ currency: 'EUR'
156
+ customer_gender: 1
157
+ shipping_method: 'flatrate_flatrate'
158
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
159
+ state: 'pending_payment'
160
+ status: 'pending_payment'
161
+
162
+ - entity_id: 23
163
+ increment_id: 100000023
164
+ store_id: 1
165
+ shipping_address_id: 42
166
+ base_grand_total: 119.00
167
+ grand_total: 119.00
168
+ currency: 'EUR'
169
+ customer_gender: 1
170
+ shipping_method: 'flatrate_flatrate'
171
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
172
+ state: 'pending_payment'
173
+ status: 'pending_payment'
174
+
175
+ - entity_id: 24
176
+ increment_id: 100000024
177
+ store_id: 1
178
+ shipping_address_id: 46
179
+ base_grand_total: 119.00
180
+ grand_total: 119.00
181
+ currency: 'EUR'
182
+ customer_gender: 1
183
+ shipping_method: 'flatrate_flatrate'
184
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
185
+ state: 'pending_payment'
186
+ status: 'pending_payment'
187
+
188
+ - entity_id: 24
189
+ increment_id: 100000024
190
+ store_id: 1
191
+ shipping_address_id: 42
192
+ base_grand_total: 119.00
193
+ grand_total: 119.00
194
+ currency: 'EUR'
195
+ customer_gender: 1
196
+ shipping_method: 'flatrate_flatrate'
197
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
198
+ state: 'pending_payment'
199
+ status: 'pending_payment'
200
+
201
+ - entity_id: 25
202
+ increment_id: 100000025
203
+ store_id: 1
204
+ shipping_address_id: 42
205
+ base_grand_total: 119.00
206
+ grand_total: 119.00
207
+ currency: 'EUR'
208
+ customer_gender: 1
209
+ shipping_method: 'flatrate_flatrate'
210
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
211
+ state: 'pending_payment'
212
+ status: 'pending_payment'
213
+
214
+ - entity_id: 26
215
+ increment_id: 100000026
216
+ store_id: 1
217
+ shipping_address_id: 42
218
+ base_grand_total: 119.00
219
+ grand_total: 119.00
220
+ currency: 'EUR'
221
+ customer_gender: 1
222
+ shipping_method: 'flatrate_flatrate'
223
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
224
+ state: 'pending_payment'
225
+ status: 'pending_payment'
226
+
227
+ - entity_id: 27
228
+ increment_id: 100000027
229
+ store_id: 1
230
+ shipping_address_id: 42
231
+ base_grand_total: 119.00
232
+ grand_total: 119.00
233
+ currency: 'EUR'
234
+ customer_gender: 1
235
+ shipping_method: 'flatrate_flatrate'
236
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
237
+ state: 'pending_payment'
238
+ status: 'pending_payment'
239
+
240
+ - entity_id: 28
241
+ increment_id: 100000028
242
+ store_id: 1
243
+ shipping_address_id: 42
244
+ base_grand_total: 119.00
245
+ grand_total: 119.00
246
+ currency: 'EUR'
247
+ customer_gender: 1
248
+ shipping_method: 'flatrate_flatrate'
249
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
250
+ state: 'pending_payment'
251
+ status: 'pending_payment'
252
+
253
+ - entity_id: 29
254
+ increment_id: 100000029
255
+ store_id: 1
256
+ shipping_address_id: 42
257
+ base_grand_total: 119.00
258
+ grand_total: 119.00
259
+ currency: 'EUR'
260
+ customer_gender: 1
261
+ shipping_method: 'flatrate_flatrate'
262
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
263
+ state: 'pending_payment'
264
+ status: 'pending_payment'
265
+
266
+ - entity_id: 30
267
+ increment_id: 100000030
268
+ store_id: 1
269
+ shipping_address_id: 42
270
+ base_grand_total: 119.00
271
+ grand_total: 119.00
272
+ currency: 'EUR'
273
+ customer_gender: 1
274
+ shipping_method: 'flatrate_flatrate'
275
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
276
+ state: 'pending_payment'
277
+ status: 'pending_payment'
278
+
279
+ sales/quote:
280
+ - entity_id: 1
281
+ base_grand_total: 119.00
282
+ grand_total: 119.00
283
+ currency: 'EUR'
284
+ customer_gender: 1
285
+ shipping_method: 'flatrate_flatrate'
286
+
287
+ - entity_id: 2
288
+ base_grand_total: 119.00
289
+ grand_total: 200.00
290
+ currency: '$'
291
+ customer_gender: 1
292
+ shipping_method: 'flatrate_flatrate'
293
+
294
+ - entity_id: 10
295
+ store_id: 0
296
+ customer_id: 23
297
+ created_at: '2013-05-14 14:45:00'
298
+ store_id: 0
299
+
300
+ - entity_id: 11
301
+ store_id: 0
302
+ created_at: '2013-05-14 14:45:00'
303
+
304
+ - entity_id: 23
305
+ store_id: 0
306
+ created_at: '2013-05-14 14:45:00'
307
+
308
+ - entity_id: 12
309
+ store_id: 0
310
+ created_at: '2013-05-14 14:45:00'
311
+
312
+ sales/quote_payment:
313
+ - payment_id: 1
314
+ quote_id: 10
315
+ updated_at: '1970-01-01'
316
+ method: 'ops_cc'
317
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
318
+
319
+ - payment_id: 2
320
+ quote_id: 11
321
+ updated_at: '1970-01-01'
322
+ method: 'ops_cc'
323
+ quote_id: 11
324
+
325
+ - payment_id: 3
326
+ quote_id: 10
327
+ updated_at: '1970-01-01'
328
+ method: 'ops_cc'
329
+ additional_information: a:7:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:3:"cvc";s:3:"123";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
330
+
331
+ - payment_id: 4
332
+ quote_id: 12
333
+ updated_at: '1970-01-01'
334
+ method: 'ops_paypal'
335
+ additional_information: a:7:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:3:"cvc";s:3:"123";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
336
+
337
+ sales/order_payment:
338
+ - entity_id: 1
339
+ parent_id: 11
340
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
341
+ method: 'ops_bankTransfer'
342
+
343
+ - entity_id: 2
344
+ parent_id: 12
345
+ additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:6:"status";s:1:"5";}
346
+
347
+ - entity_id: 3
348
+ parent_id: 13
349
+ additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:6:"status";s:1:"0";}
350
+ method: 'ops_bankTransfer'
351
+
352
+ - entity_id: 4
353
+ parent_id: 14
354
+ additional_information: a:2:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";}
355
+
356
+ - entity_id: 5
357
+ parent_id: 15
358
+ additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFD";}
359
+ method: 'ops_cc'
360
+
361
+ - entity_id: 6
362
+ parent_id: 16
363
+ additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFS";}
364
+
365
+ - entity_id: 7
366
+ parent_id: 17
367
+ additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFS";s:9:"canRefund";b:0;}
368
+
369
+ - entity_id: 8
370
+ parent_id: 18
371
+ additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFD";s:9:"canRefund";b:1;}
372
+
373
+ - entity_id: 9
374
+ parent_id: 19
375
+ method: 'ops_openInvoiceDe'
376
+
377
+ - entity_id: 11
378
+ parent_id: 20
379
+ additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
380
+
381
+ - entity_id: 12
382
+ parent_id: 21
383
+ additional_information: a:4:{s:2:"PM";s:16:"Direct Debits DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
384
+ method: 'ops_directDebit'
385
+
386
+ - entity_id: 13
387
+ parent_id: 22
388
+ additional_information: a:4:{s:2:"PM";s:16:"Direct Debits NL";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
389
+
390
+ - entity_id: 14
391
+ parent_id: 23
392
+ additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
393
+
394
+ - entity_id: 42
395
+ parent_id: 20
396
+
397
+ - entity_id: 15
398
+ parent_id: 24
399
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
400
+ method: 'ops_cc'
401
+
402
+ - entity_id: 16
403
+ parent_id: 25
404
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
405
+ method: 'ops_cc'
406
+
407
+ - entity_id: 17
408
+ parent_id: 26
409
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
410
+ method: 'ops_paypal'
411
+
412
+ - entity_id: 18
413
+ parent_id: 27
414
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
415
+ method: 'ops_kwixoApresReception'
416
+
417
+ - entity_id: 19
418
+ parent_id: 28
419
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
420
+ method: 'ops_kwixoComptant'
421
+
422
+ - entity_id: 20
423
+ parent_id: 29
424
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
425
+ method: 'ops_kwixoCredit'
426
+
427
+ - entity_id: 21
428
+ parent_id: 30
429
+ additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
430
+ method: 'checkmo'
431
+
432
+ sales/shipment:
433
+ - entity_id: 1
434
+ increment_id: 100000077
435
+ order_id: 11
436
+ shipping_address_id: 42
437
+
438
+ - entity_id: 2
439
+ increment_id: 100000078
440
+ order_id: 12
441
+ shipping_address_id: 43
442
+
443
+ sales/order_address:
444
+ - entity_id: 42
445
+ parent_id: 11
446
+ address_type: 'billing'
447
+ firstname: 'Hubertus'
448
+ postcode: '04229'
449
+ lastname: 'Fürstenberg'
450
+ street: 'An der Tabaksmühle 3a'
451
+ city: 'Leipzig'
452
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
453
+ country_id: 'DE'
454
+ prefix: 'Prof. Dr.'
455
+ middlename: 'von'
456
+ suffix: 'MdL'
457
+ company: ''
458
+ fax: 12345678
459
+
460
+ - entity_id: 43
461
+ parent_id: 11
462
+ address_type: 'shipping'
463
+ firstname: 'Hubertus'
464
+ postcode: '04229'
465
+ lastname: 'Fürstenberg'
466
+ street: 'An der Tabaksmühle 3a'
467
+ city: 'Leipzig'
468
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
469
+ country_id: 'DE'
470
+ prefix: 'Prof. Dr.'
471
+ middlename: 'von'
472
+ suffix: 'MdL'
473
+ company: ''
474
+ same_as_billing: 1
475
+
476
+ - entity_id: 44
477
+ parent_id: 12
478
+ address_type: 'billing'
479
+ firstname: 'Hubertus'
480
+ postcode: '04229'
481
+ lastname: 'Fürstenberg'
482
+ street: 'An der Tabaksmühle 3a'
483
+ city: 'Leipzig'
484
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
485
+ country_id: 'DE'
486
+ prefix: 'Prof. Dr.'
487
+ middlename: 'von'
488
+ suffix: 'MdL'
489
+ company: ''
490
+
491
+ - entity_id: 45
492
+ parent_id: 12
493
+ address_type: 'shipping'
494
+ firstname: 'Hubertus'
495
+ postcode: '04227'
496
+ lastname: 'Fürstenberg'
497
+ street: 'An der Tabaksmühle 3a'
498
+ city: 'Leipzig'
499
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
500
+ country_id: 'DE'
501
+ prefix: 'Prof. Dr.'
502
+ middlename: 'von'
503
+ suffix: 'MdL'
504
+ company: ''
505
+ same_as_billing: 1
506
+
507
+ - entity_id: 46
508
+ parent_id: 24
509
+ address_type: 'shipping'
510
+ firstname: 'Hubertus'
511
+ postcode: '04227'
512
+ lastname: 'Fürstenberg'
513
+ street: '44 rue Parmentier'
514
+ city: 'Leipzig'
515
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
516
+ country_id: 'DE'
517
+ prefix: 'Prof. Dr.'
518
+ middlename: 'von'
519
+ suffix: 'MdL'
520
+ company: ''
521
+ same_as_billing: 1
522
+
523
+ - entity_id: 47
524
+ parent_id: 27
525
+ address_type: 'billing'
526
+ firstname: 'Hubertus'
527
+ postcode: '04227'
528
+ lastname: 'Fürstenberg'
529
+ street: '44 rue Parmentier'
530
+ city: 'Leipzig'
531
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
532
+ country_id: 'DE'
533
+ prefix: 'Prof. Dr.'
534
+ middlename: 'von'
535
+ suffix: 'MdL'
536
+ company: ''
537
+ same_as_shipping: 1
538
+
539
+ - entity_id: 147
540
+ parent_id: 27
541
+ address_type: 'shipping'
542
+ firstname: 'Hubertus'
543
+ postcode: '04229'
544
+ lastname: 'Fürstenberg'
545
+ street: '44 rue Parmentier'
546
+ city: 'Leipzig'
547
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
548
+ country_id: 'DE'
549
+ prefix: 'Prof. Dr.'
550
+ middlename: 'von'
551
+ suffix: 'MdL'
552
+ company: ''
553
+
554
+
555
+ - entity_id: 48
556
+ parent_id: 28
557
+ address_type: 'billing'
558
+ firstname: 'Hubertus'
559
+ postcode: '04227'
560
+ lastname: 'Fürstenberg'
561
+ street: '44 rue Parmentier'
562
+ city: 'Leipzig'
563
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
564
+ country_id: 'DE'
565
+ prefix: 'Prof. Dr.'
566
+ middlename: 'von'
567
+ suffix: 'MdL'
568
+ company: ''
569
+
570
+ - entity_id: 49
571
+ parent_id: 19
572
+ address_type: 'billing'
573
+ firstname: 'Hubertus'
574
+ postcode: '04227'
575
+ lastname: 'Fürstenberg'
576
+ street: '44 rue Parmentier'
577
+ city: 'Leipzig'
578
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
579
+ country_id: 'DE'
580
+ prefix: 'Prof. Dr.'
581
+ middlename: 'von'
582
+ suffix: 'MdL'
583
+ company: ''
584
+
585
+ - entity_id: 50
586
+ parent_id: 19
587
+ address_type: 'shipping'
588
+ firstname: 'Hubertus'
589
+ postcode: '04227'
590
+ lastname: 'Fürstenberg'
591
+ street: '44 rue Parmentier'
592
+ city: 'Leipzig'
593
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
594
+ country_id: 'DE'
595
+ prefix: 'Prof. Dr.'
596
+ middlename: 'von'
597
+ suffix: 'MdL'
598
+ company: ''
599
+
600
+ - entity_id: 51
601
+ parent_id: 15
602
+ address_type: 'shipping'
603
+ firstname: 'Hubertus'
604
+ postcode: '04227'
605
+ lastname: 'Fürstenberg'
606
+ street: '44 rue Parmentier'
607
+ city: 'Leipzig'
608
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
609
+ country_id: 'DE'
610
+ prefix: 'Prof. Dr.'
611
+ middlename: 'von'
612
+ suffix: 'MdL'
613
+ company: ''
614
+
615
+ sales/order_item:
616
+ - item_id: 11
617
+ order_id: 11
618
+ qty_ordered: 2.0000
619
+ qty_shipped: 2.0000
620
+ sku: 4711
621
+ name: 'some great test item'
622
+ price: 19.99
623
+ tax_amount: 1.99
624
+
625
+ - item_id: 12
626
+ order_id: 11
627
+ qty_ordered: 2.0000
628
+ qty_shipped: 2.0000
629
+ sku: 4711
630
+ name: 'some great test item 2'
631
+ price: 19.99
632
+ tax_amount: 1.99
633
+
app/code/community/Netresearch/OPS/Test/Model/Payment/OpenInvoiceAtTest.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @author Michael Lühr <michael.luehr@netresearch.de>
5
+ * @category Netresearch
6
+ * @package Netresearch/OPS
7
+ * @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class Netresearch_OPS_Test_Model_Payment_OpenInvoiceAtTest extends EcomDev_PHPUnit_Test_Case
11
+ {
12
+
13
+ protected $model = null;
14
+
15
+ public function setUp()
16
+ {
17
+ parent::setUp();
18
+ $this->model = Mage::getModel('ops/payment_openInvoiceAt');
19
+ }
20
+
21
+ /**
22
+ * assure that openInvoiceAT can not capture partial, because invoice is always created on feedback in this case
23
+ */
24
+ public function testCanCapturePartial()
25
+ {
26
+ $this->assertFalse($this->model->canCapturePartial());
27
+ }
28
+
29
+ public function testIsAvailableNoQuoteGiven()
30
+ {
31
+ $quote = new Varien_Object();
32
+ $this->assertFalse($this->model->isAvailable($quote));
33
+ }
34
+
35
+ public function testIsAvailableNoDiscountAllowed()
36
+ {
37
+
38
+ $quote = Mage::getModel('sales/quote');
39
+ $quote->setSubtotal(5);
40
+ $quote->setSubtotalWithDiscount(10);
41
+ $store = Mage::app()->getStore(0)->load(0);
42
+ $store->resetConfig();
43
+ $store->setConfig('payment/ops_openInvoiceAt/allow_discounted_carts', 0);
44
+
45
+ $this->assertFalse($this->model->isAvailable($quote));
46
+ }
47
+
48
+ public function testIsAvailableNoGender()
49
+ {
50
+
51
+ $quote = Mage::getModel('sales/quote');
52
+ $quote->setSubtotal(10);
53
+ $quote->setSubtotalWithDiscount(10);
54
+ $store = Mage::app()->getStore(0)->load(0);
55
+ $store->resetConfig();
56
+ $store->setConfig('payment/ops_openInvoiceAt/allow_discounted_carts', 1);
57
+
58
+ $this->assertFalse($this->model->isAvailable($quote));
59
+ }
60
+ }
app/code/community/Netresearch/OPS/Test/Model/Payment/Recurring/Cc/ParameterBagTest.php ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBagTest.php
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Model_Payment_Recurring_Cc_ParameterBagTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+
36
+
37
+ public function testcalculateEndDate()
38
+ {
39
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag $subject */
40
+ $subject = Mage::getModel('ops/payment_recurring_cc_parameterBag');
41
+ $startDate = new DateTime('01.01.2015');
42
+ $periodUnit = Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_DAY;
43
+ $frequency = 1;
44
+ $maxCycles = 2;
45
+
46
+ $endDate = $subject->calculateEndDate($startDate, $periodUnit, $frequency, $maxCycles);
47
+ $startDate = new DateTime('03.01.2015');
48
+ $this->assertEquals($startDate->format('d.M.Y'), $endDate->format('d.M.Y'));
49
+
50
+ $startDate = new DateTime('01.01.2015');
51
+ $periodUnit = Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_MONTH;
52
+ $frequency = 1;
53
+ $maxCycles = 2;
54
+
55
+ $endDate = $subject->calculateEndDate($startDate, $periodUnit, $frequency, $maxCycles);
56
+ $startDate = new DateTime('01.03.2015');
57
+ $this->assertEquals($startDate->format('d.M.Y'), $endDate->format('d.M.Y'));
58
+
59
+ $startDate = new DateTime('31.01.2015');
60
+ $periodUnit = Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_MONTH;
61
+ $frequency = 1;
62
+ $maxCycles = 2;
63
+
64
+ $endDate = $subject->calculateEndDate($startDate, $periodUnit, $frequency, $maxCycles);
65
+ $startDate = new DateTime('28.03.2015');
66
+ $this->assertEquals($startDate->format('d.M.Y'), $endDate->format('d.M.Y'));
67
+
68
+ $startDate = new DateTime('01.01.2015');
69
+ $periodUnit = Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_WEEK;
70
+ $frequency = 1;
71
+ $maxCycles = 2;
72
+
73
+ $endDate = $subject->calculateEndDate($startDate, $periodUnit, $frequency, $maxCycles);
74
+ $startDate = new DateTime('15.01.2015');
75
+ $this->assertEquals($startDate->format('d.M.Y'), $endDate->format('d.M.Y'));
76
+
77
+ $endDate = $subject->calculateEndDate($startDate, $periodUnit, $frequency, '');
78
+ $this->assertNull($endDate);
79
+ }
80
+
81
+ public function testHelperFunctions()
82
+ {
83
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag $subject */
84
+ $subject = Mage::getModel('ops/payment_recurring_cc_parameterBag');
85
+ $testString = 'abc';
86
+ $this->assertTrue($subject->getSubscriptionHelper() instanceof Netresearch_OPS_Helper_Subscription);
87
+ $subject->setSubscriptionHelper($testString);
88
+ $this->assertEquals($subject->getSubscriptionHelper(), $testString);
89
+
90
+ $this->assertTrue($subject->getQuoteHelper() instanceof Netresearch_OPS_Helper_Quote);
91
+ $subject->setQuoteHelper($testString);
92
+ $this->assertEquals($subject->getQuoteHelper(), $testString);
93
+
94
+ $this->assertTrue($subject->getDataHelper() instanceof Netresearch_OPS_Helper_Data);
95
+ $subject->setDataHelper($testString);
96
+ $this->assertEquals($subject->getDataHelper(), $testString);
97
+
98
+ $this->assertTrue($subject->getRequestHelper() instanceof Netresearch_OPS_Helper_Payment_Request);
99
+ $subject->setRequestHelper($testString);
100
+ $this->assertEquals($subject->getRequestHelper(), $testString);
101
+
102
+ $this->assertTrue($subject->getConfig() instanceof Netresearch_OPS_Model_Config);
103
+ $subject->setConfig($testString);
104
+ $this->assertEquals($subject->getConfig(), $testString);
105
+ }
106
+
107
+ /**
108
+ * @return Mage_Sales_Model_Recurring_Profile
109
+ */
110
+ protected function getTestProfile($withTrial = false)
111
+ {
112
+ $profile = Mage::getModel('sales/recurring_profile');
113
+ $address = Mage::getModel('sales/quote_address');
114
+ $address->setCity('Leipzig');
115
+ $quote = Mage::getModel('sales/quote');
116
+ $quote->setShippingAddress($address);
117
+ $quote->setBillingAddress($address);
118
+
119
+ $profile->setScheduleDescription('abc')
120
+ ->setPeriodFrequency(1)
121
+ ->setPeriodMaxCycles(1)
122
+ ->setPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_WEEK)
123
+ ->setInitAmount(10)
124
+ ->setBillingAmount(15)
125
+ ->setTaxAmount(5)
126
+ ->setShippingAmount(5)
127
+ ->setStartDatetime('')
128
+ ->setQuote($quote)
129
+ ->setId(0);
130
+
131
+ if ($withTrial) {
132
+ $profile->setTrialPeriodMaxCycles(1)
133
+ ->setTrialPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_DAY)
134
+ ->setTrialPeriodFrequency(1)
135
+ ->setTrialBillingAmount(15);
136
+ }
137
+ return $profile;
138
+ }
139
+
140
+ public function testCollectProfileParameters()
141
+ {
142
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag $subject */
143
+ $subject = Mage::getModel('ops/payment_recurring_cc_parameterBag');
144
+ $profile = $this->getTestProfile();
145
+ $profile->setPeriodMaxCycles(0);
146
+
147
+ $params = $subject->collectProfileParameters($profile)->toArray();
148
+
149
+ $startDate = new DateTime();
150
+ $this->assertArrayHasKey('SUB_STARTDATE', $params);
151
+ $this->assertEquals($params['SUB_STARTDATE'], $startDate->format('d/m/Y'));
152
+
153
+ $id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . $profile->getId();
154
+ $this->assertArrayHasKey('SUBSCRIPTION_ID', $params);
155
+ $this->assertEquals($id, $params['SUBSCRIPTION_ID']);
156
+
157
+ $this->assertArrayHasKey('SUB_ORDERID', $params);
158
+ $this->assertEquals($id, $params['SUB_ORDERID']);
159
+
160
+ $this->assertArrayHasKey('ORDERID', $params);
161
+ $this->assertEquals($id, $params['ORDERID']);
162
+
163
+ $this->assertArrayHasKey('SUB_COM', $params);
164
+ $this->assertEquals($params['SUB_COM'], 'abc');
165
+
166
+ $this->assertEquals(0, $params['AMOUNT']);
167
+ $subAmount = $profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount();
168
+ $this->assertEquals($subAmount, $params['SUB_AMOUNT'] / 100);
169
+
170
+ $this->assertArrayHasKey('ECOM_SHIPTO_POSTAL_CITY', $params);
171
+ $this->assertEquals('Leipzig', $params['ECOM_SHIPTO_POSTAL_CITY']);
172
+
173
+ $this->assertArrayHasKey('ECOM_BILLTO_POSTAL_CITY', $params);
174
+ $this->assertEquals('Leipzig', $params['ECOM_BILLTO_POSTAL_CITY']);
175
+
176
+ $this->assertArrayHasKey('OWNERTOWN', $params);
177
+ $this->assertEquals('Leipzig', $params['OWNERTOWN']);
178
+
179
+ $this->assertArrayHasKey('SUB_ENDDATE', $params);
180
+ $this->assertEquals('', $params['SUB_ENDDATE']);
181
+
182
+
183
+ // test map unit and adjust frequency:
184
+
185
+ $profile->setPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_YEAR)
186
+ ->setPeriodFrequency(1);
187
+ $params = $subject->collectProfileParameters($profile);
188
+
189
+ $this->assertEquals(12, $params['SUB_PERIOD_NUMBER']);
190
+ $this->assertEquals(
191
+ Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_MONTH, $params['SUB_PERIOD_UNIT']
192
+ );
193
+
194
+ $profile->setPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH);
195
+
196
+ $params = $subject->collectProfileParameters($profile);
197
+ $this->assertEquals(2, $params['SUB_PERIOD_NUMBER']);
198
+ $this->assertEquals(
199
+ Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_WEEK, $params['SUB_PERIOD_UNIT']
200
+ );
201
+
202
+ $profile->setPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_MONTH);
203
+
204
+ $params = $subject->collectProfileParameters($profile);
205
+ $this->assertEquals(1, $params['SUB_PERIOD_NUMBER']);
206
+ $this->assertEquals(
207
+ Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_MONTH, $params['SUB_PERIOD_UNIT']
208
+ );
209
+
210
+ $profile->setPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_DAY);
211
+
212
+ $params = $subject->collectProfileParameters($profile);
213
+ $this->assertEquals(1, $params['SUB_PERIOD_NUMBER']);
214
+ $this->assertEquals(
215
+ Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_DAY, $params['SUB_PERIOD_UNIT']
216
+ );
217
+
218
+
219
+ //test trial use-cases
220
+
221
+ $profile = $this->getTestProfile(true);
222
+
223
+ $params = $subject->collectProfileParameters($profile, true);
224
+
225
+ $this->assertEquals(Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_DAY, $params['SUB_PERIOD_UNIT']);
226
+
227
+ $id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . $profile->getId() . Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX ;
228
+ $this->assertArrayHasKey('SUBSCRIPTION_ID', $params);
229
+ $this->assertEquals($id, $params['SUBSCRIPTION_ID']);
230
+
231
+ $this->assertArrayHasKey('SUB_ORDERID', $params);
232
+ $this->assertEquals($id, $params['SUB_ORDERID']);
233
+
234
+ $this->assertArrayHasKey('ORDERID', $params);
235
+ $this->assertEquals($id, $params['ORDERID']);
236
+
237
+ $this->assertEquals($profile->getTrialBillingAmount()+$profile->getShippingAmount(), $params['SUB_AMOUNT']/100);
238
+ }
239
+
240
+ public function testCollectPaymentParameters()
241
+ {
242
+ $subject = Mage::getModel('ops/payment_recurring_cc_parameterBag');
243
+
244
+ $payment = $this->getTestPayment();
245
+
246
+ $params = $subject->collectPaymentParameters($payment)->toArray();
247
+
248
+ $this->assertEquals($params['CN'], 'Olaf');
249
+ $this->assertEquals($params['ALIAS'], '123');
250
+ $this->assertEquals($params['OPERATION'], Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION);
251
+ $this->assertEquals($params['FLAG3D'], 'Y');
252
+ }
253
+
254
+ /**
255
+ * @return Mage_Sales_Model_Quote_Payment
256
+ */
257
+ protected function getTestPayment()
258
+ {
259
+ $quote = Mage::getModel('sales/quote');
260
+ $quote->setRemoteIp('127.0.0.1');
261
+ $payment = Mage::getModel('sales/quote_payment');
262
+ $payment->setAdditionalInformation('alias', '123')
263
+ ->setAdditionalInformation('CC_CN', 'Olaf')
264
+ ->setAdditionalInformation('CC_BRAND', 'VISA')
265
+ ->setMethod(Netresearch_OPS_Model_Payment_Recurring_Cc::CODE)
266
+ ->setQuote($quote);
267
+ Mage::app()->getStore()->setConfig('payment/ops_recurring_cc/enabled_3dsecure', 1);
268
+ return $payment;
269
+ }
270
+
271
+ public function testCollectAllParameters()
272
+ {
273
+ $subject = Mage::getModel('ops/payment_recurring_cc_parameterBag');
274
+ $payment = $this->getTestPayment();
275
+ $profile = $this->getTestProfile();
276
+
277
+ $params = $subject->collectAllParameters($payment, $profile);
278
+
279
+ $startDate = new DateTime();
280
+ $this->assertArrayHasKey('SUB_STARTDATE', $params);
281
+ $this->assertEquals($startDate->format('d/m/Y'), $params['SUB_STARTDATE']);
282
+
283
+ $id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . $profile->getId();
284
+ $this->assertArrayHasKey('SUBSCRIPTION_ID', $params);
285
+ $this->assertEquals($id, $params['SUBSCRIPTION_ID']);
286
+
287
+ $this->assertArrayHasKey('SUB_ORDERID', $params);
288
+ $this->assertEquals($id, $params['SUB_ORDERID']);
289
+
290
+ $this->assertArrayHasKey('SUB_COM', $params);
291
+ $this->assertEquals($params['SUB_COM'], 'abc');
292
+
293
+ $this->assertEquals(0, $params['AMOUNT']);
294
+ $subAmount = $profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount();
295
+ $this->assertEquals($subAmount, $params['SUB_AMOUNT'] / 100);
296
+
297
+ $this->assertArrayHasKey('ECOM_SHIPTO_POSTAL_CITY', $params);
298
+ $this->assertEquals('Leipzig', $params['ECOM_SHIPTO_POSTAL_CITY']);
299
+
300
+ $this->assertArrayHasKey('ECOM_BILLTO_POSTAL_CITY', $params);
301
+ $this->assertEquals('Leipzig', $params['ECOM_BILLTO_POSTAL_CITY']);
302
+
303
+ $this->assertArrayHasKey('OWNERTOWN', $params);
304
+ $this->assertEquals('Leipzig', $params['OWNERTOWN']);
305
+ $this->assertEquals($params['CN'], 'Olaf');
306
+ $this->assertEquals($params['ALIAS'], '123');
307
+ $this->assertEquals($params['ORDERID'], $id);
308
+ $this->assertEquals($params['OPERATION'], Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION);
309
+ $this->assertEquals($params['FLAG3D'], 'Y');
310
+ }
311
+
312
+ public function testCollectAllParametersWithTrial()
313
+ {
314
+ $subject = Mage::getModel('ops/payment_recurring_cc_parameterBag');
315
+ // test dry run with trial data
316
+ $payment = $this->getTestPayment();
317
+ $profile = $this->getTestProfile(true);
318
+
319
+ $params = $subject->collectAllParameters($payment, $profile);
320
+
321
+ $startDate = new DateTime();
322
+ $startDate->add(new DateInterval('P1D'));
323
+ $this->assertArrayHasKey('SUB_STARTDATE', $params);
324
+ $this->assertEquals($params['SUB_STARTDATE'], $startDate->format('d/m/Y'));
325
+
326
+ $id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . $profile->getId();
327
+ $this->assertArrayHasKey('SUBSCRIPTION_ID', $params);
328
+ $this->assertEquals($id, $params['SUBSCRIPTION_ID']);
329
+
330
+ $this->assertArrayHasKey('SUB_ORDERID', $params);
331
+ $this->assertEquals($id, $params['SUB_ORDERID']);
332
+
333
+ $this->assertArrayHasKey('SUB_COM', $params);
334
+ $this->assertEquals($params['SUB_COM'], 'abc');
335
+
336
+ $this->assertEquals(0, $params['AMOUNT']);
337
+ $subAmount = $profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount();
338
+ $this->assertEquals($subAmount, $params['SUB_AMOUNT'] / 100);
339
+
340
+ $this->assertArrayHasKey('ECOM_SHIPTO_POSTAL_CITY', $params);
341
+ $this->assertEquals('Leipzig', $params['ECOM_SHIPTO_POSTAL_CITY']);
342
+
343
+ $this->assertArrayHasKey('ECOM_BILLTO_POSTAL_CITY', $params);
344
+ $this->assertEquals('Leipzig', $params['ECOM_BILLTO_POSTAL_CITY']);
345
+
346
+ $this->assertArrayHasKey('OWNERTOWN', $params);
347
+ $this->assertEquals('Leipzig', $params['OWNERTOWN']);
348
+ $this->assertEquals($params['CN'], 'Olaf');
349
+ $this->assertEquals($params['ALIAS'], '123');
350
+ $this->assertEquals($params['ORDERID'], $id);
351
+ $this->assertEquals($params['OPERATION'], Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION);
352
+ $this->assertEquals($params['FLAG3D'], 'Y');
353
+ }
354
+
355
+ public function testCollectAllParametersForTrial()
356
+ {
357
+ $subject = Mage::getModel('ops/payment_recurring_cc_parameterBag');
358
+ $payment = $this->getTestPayment();
359
+ $profile = $this->getTestProfile(true);
360
+
361
+ $params = $subject->collectAllParametersForTrial($payment, $profile);
362
+
363
+ $startDate = new DateTime();
364
+ $this->assertArrayHasKey('SUB_STARTDATE', $params);
365
+ $this->assertEquals($params['SUB_STARTDATE'], $startDate->format('d/m/Y'));
366
+
367
+ $id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . $profile->getId() . Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX;
368
+ $this->assertArrayHasKey('SUBSCRIPTION_ID', $params);
369
+ $this->assertEquals($id, $params['SUBSCRIPTION_ID']);
370
+
371
+ $this->assertArrayHasKey('SUB_ORDERID', $params);
372
+ $this->assertEquals($id, $params['SUB_ORDERID']);
373
+
374
+ $this->assertArrayHasKey('SUB_COM', $params);
375
+ $this->assertEquals($params['SUB_COM'], 'abc');
376
+
377
+ $this->assertEquals(0, $params['AMOUNT']);
378
+ $subAmount = $profile->getTrialBillingAmount() + $profile->getShippingAmount();
379
+ $this->assertEquals($subAmount, $params['SUB_AMOUNT'] / 100);
380
+
381
+ $this->assertArrayHasKey('ECOM_SHIPTO_POSTAL_CITY', $params);
382
+ $this->assertEquals('Leipzig', $params['ECOM_SHIPTO_POSTAL_CITY']);
383
+
384
+ $this->assertArrayHasKey('ECOM_BILLTO_POSTAL_CITY', $params);
385
+ $this->assertEquals('Leipzig', $params['ECOM_BILLTO_POSTAL_CITY']);
386
+
387
+ $this->assertArrayHasKey('OWNERTOWN', $params);
388
+ $this->assertEquals('Leipzig', $params['OWNERTOWN']);
389
+ $this->assertEquals($params['CN'], 'Olaf');
390
+ $this->assertEquals($params['ALIAS'], '123');
391
+ $this->assertEquals($params['ORDERID'], $id);
392
+ $this->assertEquals($params['OPERATION'], Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION);
393
+ $this->assertEquals($params['FLAG3D'], 'Y');
394
+ }
395
+ }
app/code/community/Netresearch/OPS/Test/Model/Payment/Recurring/CcTest.php ADDED
@@ -0,0 +1,579 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * CcTest.php
24
+ *
25
+ * @category payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ class Netresearch_OPS_Test_Model_Payment_Recurring_CcTest extends EcomDev_PHPUnit_Test_Case
30
+ {
31
+ /**
32
+ * @return Mage_Sales_Model_Recurring_Profile
33
+ */
34
+ protected function getTestProfile()
35
+ {
36
+ /** @var Mage_Sales_Model_Recurring_Profile $profile */
37
+ $profile = Mage::getModel('sales/recurring_profile');
38
+ $address = Mage::getModel('sales/quote_address');
39
+ $address->setCity('Leipzig');
40
+ $quote = Mage::getModel('sales/quote');
41
+ $quote->setShippingAddress($address);
42
+ $quote->setBillingAddress($address);
43
+ $quote->setPayment($this->getTestPayment());
44
+
45
+ $profile->setScheduleDescription('abc')
46
+ ->setPeriodFrequency(1)
47
+ ->setPeriodMaxCycles(1)
48
+ ->setMethodCode('ops_recurring_cc')
49
+ ->setPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_WEEK)
50
+ ->setOrderItemInfo(array())
51
+ ->setInitAmount(10)
52
+ ->setBillingAmount(15)
53
+ ->setTaxAmount(5)
54
+ ->setShippingAmount(5)
55
+ ->setStartDatetime('')
56
+ ->setQuote($quote)
57
+ ->setCurrencyCode('EUR')
58
+ ->setState(Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN)
59
+ ->setId(0);
60
+
61
+ return $profile;
62
+ }
63
+
64
+ protected function getResponseParams($success)
65
+ {
66
+ $params = array(
67
+ 'subscription_id' => 'SUB-0',
68
+ 'orderID' => 'SUB-0',
69
+ 'PAYID' => 12345,
70
+ 'currency' => 'EUR',
71
+ 'amount' => 1000
72
+ );
73
+ if ($success) {
74
+ $params['STATUS'] = 9;
75
+ $params['creation_status'] = Netresearch_OPS_Model_Subscription_Manager::CREATION_SUCCEEDED;
76
+ } else {
77
+ $params['STATUS'] = 2;
78
+ $params['creation_status'] = Netresearch_OPS_Model_Subscription_Manager::CREATION_FAILED;
79
+ }
80
+
81
+ return $params;
82
+ }
83
+
84
+ /**
85
+ * @return Mage_Sales_Model_Quote_Payment
86
+ */
87
+ protected function getTestPayment()
88
+ {
89
+ $quote = Mage::getModel('sales/quote');
90
+ $quote->setRemoteIp('127.0.0.1');
91
+ $payment = Mage::getModel('sales/quote_payment');
92
+ $payment->setAdditionalInformation('alias', '123')
93
+ ->setAdditionalInformation('CC_CN', 'Olaf')
94
+ ->setAdditionalInformation('CC_BRAND', 'VISA')
95
+ ->setMethod(Netresearch_OPS_Model_Payment_Recurring_Cc::CODE)
96
+ ->setQuote($quote);
97
+ Mage::app()->getStore()->setConfig('payment/ops_recurring_cc/enabled_3dsecure', 1);
98
+
99
+ return $payment;
100
+ }
101
+
102
+ public function testValidateRecurringProfile()
103
+ {
104
+ $subject = Mage::getModel('ops/payment_recurring_cc');
105
+
106
+ $profile = $this->getTestProfile();
107
+
108
+ $subject->validateRecurringProfile($profile);
109
+ }
110
+
111
+
112
+ public function testSubmitRecurringProfileOnlyRegular()
113
+ {
114
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
115
+ $subject = Mage::getModel('ops/payment_recurring_cc');
116
+
117
+ $params = $this->getResponseParams(true);
118
+ $this->mockDirectLinkRequest($params);
119
+
120
+ $profile = $this->getTestProfile();
121
+
122
+ $profile->setInitAmount(0);
123
+ $paymentInfo = $this->getTestPayment();
124
+ $subject->submitRecurringProfile($profile, $paymentInfo);
125
+
126
+ $this->assertEquals($profile->getReferenceId(), 'SUB-0');
127
+ $this->assertEquals(serialize($params), $profile->getProfileVendorInfo());
128
+ }
129
+
130
+ /**
131
+ * @test
132
+ * @expectedException Exception
133
+ */
134
+ public function testSubmitRecurringProfileOnlyRegularWithException()
135
+ {
136
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
137
+ $subject = Mage::getModel('ops/payment_recurring_cc');
138
+
139
+ $params = $this->getResponseParams(false);
140
+ $this->mockDirectLinkRequest($params);
141
+
142
+ $profile = $this->getTestProfile();
143
+
144
+ $profile->setInitAmount(0);
145
+ $paymentInfo = $this->getTestPayment();
146
+ $subject->submitRecurringProfile($profile, $paymentInfo);
147
+
148
+ $this->assertEquals($profile->getReferenceId(), 'SUB-0');
149
+ $this->assertEquals(serialize($params), $profile->getProfileVendorInfo());
150
+ }
151
+
152
+ public function testSubmitRecurringProfileWithTrial()
153
+ {
154
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
155
+ $subject = Mage::getModel('ops/payment_recurring_cc');
156
+
157
+ $params = $this->getResponseParams(true);
158
+ $this->mockDirectLinkRequest($params);
159
+
160
+ $profile = $this->getTestProfile();
161
+ $profile->setInitAmount(0)
162
+ ->setTrialBillingAmount(1)
163
+ ->setTrialPeriodFrequency(5)
164
+ ->setTrialPeriodMaxCycles(10)
165
+ ->setTrialPeriodMaxCycles(5)
166
+ ->setTrialPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_DAY);
167
+
168
+ $paymentInfo = $this->getTestPayment();
169
+ $subject->submitRecurringProfile($profile, $paymentInfo);
170
+
171
+ $this->assertEquals($profile->getReferenceId(), 'SUB-0');
172
+ $this->assertEquals(serialize($params), $profile->getProfileVendorInfo());
173
+ }
174
+
175
+ /**
176
+ * @test
177
+ * @expectedException Exception
178
+ */
179
+ public function testSubmitRecurringProfileWithTrialWithException()
180
+ {
181
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
182
+ $subject = Mage::getModel('ops/payment_recurring_cc');
183
+
184
+ $params = $this->getResponseParams(false);
185
+ $this->mockTwoDirectLinkRequests($this->getResponseParams(true), $params);
186
+
187
+ $profile = $this->getTestProfile();
188
+ $profile->setInitAmount(0)
189
+ ->setTrialBillingAmount(1)
190
+ ->setTrialPeriodFrequency(5)
191
+ ->setTrialPeriodMaxCycles(10)
192
+ ->setTrialPeriodMaxCycles(5)
193
+ ->setTrialPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_DAY);
194
+
195
+ $paymentInfo = $this->getTestPayment();
196
+ $subject->submitRecurringProfile($profile, $paymentInfo);
197
+
198
+ $this->assertEquals($profile->getReferenceId(), 'SUB-0');
199
+ $this->assertEquals(serialize($params), $profile->getProfileVendorInfo());
200
+ }
201
+
202
+ public function testSubmitRecurringProfileWithInitialFee()
203
+ {
204
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
205
+ $subject = Mage::getModel('ops/payment_recurring_cc');
206
+
207
+ $profileMock = $this->getModelMock('sales/recurring_profile', array('getChildOrderIds', 'addOrderRelation'));
208
+ $profileMock->expects($this->any())
209
+ ->method('getChildOrderIds')
210
+ ->will($this->returnSelf());
211
+ $profileMock->expects($this->any())
212
+ ->method('addOrderRelation')
213
+ ->will($this->returnSelf());
214
+ $this->replaceByMock('model', 'sales/recurring_profile', $profileMock);
215
+
216
+ $paymentHelperMock = $this->getHelperMock('ops/payment', array('applyStateForOrder'));
217
+ $paymentHelperMock->expects($this->any())
218
+ ->method('applyStateForOrder')
219
+ ->will($this->returnSelf());
220
+ $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
221
+
222
+ $params = $this->getResponseParams(true);
223
+ $this->mockDirectLinkRequest($params);
224
+
225
+ $profile = $this->getTestProfile();
226
+ $profile->setTrialBillingAmount(1)
227
+ ->setTrialPeriodFrequency(5)
228
+ ->setTrialPeriodMaxCycles(10)
229
+ ->setTrialPeriodMaxCycles(5);
230
+
231
+ $paymentInfo = $this->getTestPayment();
232
+ $subject->submitRecurringProfile($profile, $paymentInfo);
233
+
234
+ $this->assertEquals($profile->getReferenceId(), 'SUB-0');
235
+ $this->assertEquals(serialize($params), $profile->getProfileVendorInfo());
236
+ }
237
+
238
+ /**
239
+ * @test
240
+ * @expectedException Exception
241
+ */
242
+ public function testGetRecurringProfileDetails()
243
+ {
244
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
245
+ $subject = Mage::getModel('ops/payment_recurring_cc');
246
+ $subject->getRecurringProfileDetails('abc', new Varien_Object());
247
+ }
248
+
249
+ public function testCanGetRecurringProfileDetails()
250
+ {
251
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
252
+ $subject = Mage::getModel('ops/payment_recurring_cc');
253
+ $this->assertFalse($subject->canGetRecurringProfileDetails());
254
+ }
255
+
256
+ /**
257
+ * @test
258
+ * @expectedException Mage_Core_Exception
259
+ * @expectedExceptionMessage Function not supported
260
+ */
261
+ public function testUpdateRecurringProfile()
262
+ {
263
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
264
+ $subject = Mage::getModel('ops/payment_recurring_cc');
265
+ $subject->updateRecurringProfile($this->getTestProfile());
266
+ }
267
+
268
+ /**
269
+ * @test
270
+ * @expectedException Mage_Core_Exception
271
+ * @expectedExceptionMessage Automatic activation not possible. Please contact our support team.
272
+ */
273
+ public function testUpdateRecurringProfileStatusWithActivateException()
274
+ {
275
+ $adminMock = $this->getModelMock('admin/session', array('isLoggedIn', 'init'));
276
+ $this->replaceByMock('singleton', 'admin/session', $adminMock);
277
+
278
+ $subject = Mage::getModel('ops/payment_recurring_cc');
279
+ $profile = Mage::getModel('sales/recurring_profile');
280
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
281
+ $subject->updateRecurringProfileStatus($profile);
282
+
283
+ }
284
+
285
+ public function testUpdateRecurringProfileStatusWithActivate()
286
+ {
287
+ $adminMock = $this->getModelMock('admin/session', array('isLoggedIn', 'init'));
288
+ $adminMock->expects($this->once())
289
+ ->method('isLoggedIn')
290
+ ->will($this->returnValue(true));
291
+ $this->replaceByMock('singleton', 'admin/session', $adminMock);
292
+
293
+ $adminHtmlMock = $this->getModelMock('adminhtml/session', array('addNotice', 'init'));
294
+ $adminHtmlMock->expects($this->once())
295
+ ->method('addNotice');
296
+ $this->replaceByMock('singleton', 'adminhtml/session', $adminHtmlMock);
297
+
298
+ $subject = Mage::getModel('ops/payment_recurring_cc');
299
+ $profile = Mage::getModel('sales/recurring_profile');
300
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
301
+ $subject->updateRecurringProfileStatus($profile);
302
+ }
303
+
304
+ /**
305
+ * @test
306
+ */
307
+ public function testUpdateRecurringProfileStatusWithCancelAsCustomer()
308
+ {
309
+ $adminMock = $this->getModelMock('admin/session', array('isLoggedIn', 'init'));
310
+ $this->replaceByMock('singleton', 'admin/session', $adminMock);
311
+
312
+ $sessionMock = $this->getModelMock('customer/session', array('getCustomer', 'init'));
313
+ $customer = new Varien_Object(array('id' => 1));
314
+ $sessionMock->expects($this->once())
315
+ ->method('getCustomer')
316
+ ->will($this->returnValue($customer));
317
+ $this->replaceByMock('singleton', 'customer/session', $sessionMock);
318
+
319
+ $mailModelMock = $this->getModelMock('ops/payment_features_paymentEmail', array('sendSuspendSubscriptionMail'));
320
+ $mailModelMock->expects($this->once())
321
+ ->method('sendSuspendSubscriptionMail')
322
+ ->will($this->returnValue(true));
323
+ $this->replaceByMock('model', 'ops/payment_features_paymentEmail', $mailModelMock);
324
+
325
+
326
+ $profile = Mage::getModel('sales/recurring_profile');
327
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
328
+ $profile->setCustomerId(1);
329
+
330
+ $subject = Mage::getModel('ops/payment_recurring_cc');
331
+ $subject->updateRecurringProfileStatus($profile);
332
+
333
+ $this->assertTrue($profile->getOverrideState());
334
+ $this->assertEquals(Mage_Sales_Model_Recurring_Profile::STATE_PENDING, $profile->getNewState());
335
+ $this->assertNotNull($sessionMock->getMessages()->getLastAddedMessage());
336
+ }
337
+
338
+ public function testUpdateRecurringProfileStatusWithCancel()
339
+ {
340
+ $adminMock = $this->getModelMock('admin/session', array('isLoggedIn', 'init'));
341
+ $adminMock->expects($this->once())
342
+ ->method('isLoggedIn')
343
+ ->will($this->returnValue(true));
344
+ $this->replaceByMock('singleton', 'admin/session', $adminMock);
345
+
346
+ $adminHtmlMock = $this->getModelMock('adminhtml/session', array('addNotice', 'init'));
347
+ $adminHtmlMock->expects($this->once())
348
+ ->method('addNotice');
349
+ $this->replaceByMock('singleton', 'adminhtml/session', $adminHtmlMock);
350
+
351
+ $subject = Mage::getModel('ops/payment_recurring_cc');
352
+ $profile = Mage::getModel('sales/recurring_profile');
353
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
354
+ $subject->updateRecurringProfileStatus($profile);
355
+ }
356
+
357
+ public function testUpdateRecurringProfileStatusWithSuspendAsCustomer()
358
+ {
359
+ $adminMock = $this->getModelMock('admin/session', array('isLoggedIn', 'init'));
360
+ $this->replaceByMock('singleton', 'admin/session', $adminMock);
361
+
362
+ $sessionMock = $this->getModelMock('customer/session', array('getCustomer', 'init'));
363
+ $customer = new Varien_Object(array('id' => 1));
364
+ $sessionMock->expects($this->once())
365
+ ->method('getCustomer')
366
+ ->will($this->returnValue($customer));
367
+ $this->replaceByMock('singleton', 'customer/session', $sessionMock);
368
+
369
+ $mailModelMock = $this->getModelMock('ops/payment_features_paymentEmail', array('sendSuspendSubscriptionMail'));
370
+ $mailModelMock->expects($this->once())
371
+ ->method('sendSuspendSubscriptionMail')
372
+ ->will($this->returnValue(true));
373
+ $this->replaceByMock('model', 'ops/payment_features_paymentEmail', $mailModelMock);
374
+
375
+
376
+ $profile = Mage::getModel('sales/recurring_profile');
377
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED);
378
+ $profile->setCustomerId(1);
379
+
380
+ $subject = Mage::getModel('ops/payment_recurring_cc');
381
+ $subject->updateRecurringProfileStatus($profile);
382
+
383
+ $this->assertTrue($profile->getOverrideState());
384
+ $this->assertEquals(Mage_Sales_Model_Recurring_Profile::STATE_PENDING, $profile->getNewState());
385
+ $this->assertNotNull($sessionMock->getMessages()->getLastAddedMessage());
386
+ }
387
+
388
+ /**
389
+ * @expectedException Mage_Core_Exception
390
+ * @expectedExceptionMessage You are not allowed to suspend this subscription!
391
+ */
392
+ public function testUpdateRecurringProfileStatusWithSuspendAsCustomerWithUnAllowedException()
393
+ {
394
+ $adminMock = $this->getModelMock('admin/session', array('isLoggedIn', 'init'));
395
+ $this->replaceByMock('singleton', 'admin/session', $adminMock);
396
+
397
+ $sessionMock = $this->getModelMock('customer/session', array('getCustomer', 'init'));
398
+ $customer = new Varien_Object(array('id' => 2));
399
+ $sessionMock->expects($this->once())
400
+ ->method('getCustomer')
401
+ ->will($this->returnValue($customer));
402
+ $this->replaceByMock('singleton', 'customer/session', $sessionMock);
403
+
404
+ $profile = Mage::getModel('sales/recurring_profile');
405
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED);
406
+ $profile->setCustomerId(1);
407
+
408
+ $subject = Mage::getModel('ops/payment_recurring_cc');
409
+ $subject->updateRecurringProfileStatus($profile);
410
+ }
411
+
412
+ /**
413
+ * @expectedException Mage_Core_Exception
414
+ * @expectedExceptionMessage Could not send suspend mail, please try again or contact our support directly.
415
+ */
416
+ public function testUpdateRecurringProfileStatusWithSuspendAsCustomerWithFailedException()
417
+ {
418
+ $adminMock = $this->getModelMock('admin/session', array('isLoggedIn', 'init'));
419
+ $this->replaceByMock('singleton', 'admin/session', $adminMock);
420
+
421
+ $sessionMock = $this->getModelMock('customer/session', array('getCustomer', 'init'));
422
+ $customer = new Varien_Object(array('id' => 1));
423
+ $sessionMock->expects($this->once())
424
+ ->method('getCustomer')
425
+ ->will($this->returnValue($customer));
426
+ $this->replaceByMock('singleton', 'customer/session', $sessionMock);
427
+
428
+ $mailModelMock = $this->getModelMock('ops/payment_features_paymentEmail', array('sendSuspendSubscriptionMail'));
429
+ $mailModelMock->expects($this->once())
430
+ ->method('sendSuspendSubscriptionMail')
431
+ ->will($this->returnValue(false));
432
+ $this->replaceByMock('model', 'ops/payment_features_paymentEmail', $mailModelMock);
433
+
434
+
435
+ $profile = Mage::getModel('sales/recurring_profile');
436
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED);
437
+ $profile->setCustomerId(1);
438
+
439
+ $subject = Mage::getModel('ops/payment_recurring_cc');
440
+ $subject->updateRecurringProfileStatus($profile);
441
+ }
442
+
443
+ public function testUpdateRecurringProfileStatusWithSuspendAsAdmin()
444
+ {
445
+ $adminMock = $this->getModelMock('admin/session', array('isLoggedIn', 'init'));
446
+ $adminMock->expects($this->once())
447
+ ->method('isLoggedIn')
448
+ ->will($this->returnValue(true));
449
+ $this->replaceByMock('singleton', 'admin/session', $adminMock);
450
+
451
+ $adminHtmlMock = $this->getModelMock('adminhtml/session', array('addNotice', 'init'));
452
+ $adminHtmlMock->expects($this->once())
453
+ ->method('addNotice');
454
+ $this->replaceByMock('singleton', 'adminhtml/session', $adminHtmlMock);
455
+
456
+ $subject = Mage::getModel('ops/payment_recurring_cc');
457
+ $profile = Mage::getModel('sales/recurring_profile');
458
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED);
459
+ $subject->updateRecurringProfileStatus($profile);
460
+ }
461
+
462
+ /**
463
+ * @test
464
+ * @expectedException Mage_Core_Exception
465
+ * @expectedExceptionMessage Expire function not implemented!
466
+ */
467
+ public function testUpdateRecurringProfileStatusWithExpireException()
468
+ {
469
+ $subject = Mage::getModel('ops/payment_recurring_cc');
470
+ $profile = Mage::getModel('sales/recurring_profile');
471
+ $profile->setNewState(Mage_Sales_Model_Recurring_Profile::STATE_EXPIRED);
472
+ $subject->updateRecurringProfileStatus($profile);
473
+ }
474
+
475
+ /**
476
+ * @test
477
+ * @expectedException Mage_Core_Exception
478
+ * @expectedExceptionMessage Action for state abc not supported
479
+ */
480
+ public function testUpdateRecurringProfileStatusWithNotSupportedException()
481
+ {
482
+ $subject = Mage::getModel('ops/payment_recurring_cc');
483
+ $profile = Mage::getModel('sales/recurring_profile');
484
+ $profile->setNewState('abc');
485
+ $subject->updateRecurringProfileStatus($profile);
486
+ }
487
+
488
+ public function testIsAvailable()
489
+ {
490
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
491
+ $subject = Mage::getModel('ops/payment_recurring_cc');
492
+ $items = array();
493
+ $item1 = Mage::getModel('sales/quote_item');
494
+ $item1->setData('is_nominal', false);
495
+ $items[] = $item1;
496
+ $quote2 = $this->getModelMock('sales/quote', array('getAllVisibleItems'));
497
+ $quote2->expects($this->any())
498
+ ->method('getAllVisibleItems')
499
+ ->will($this->returnValue($items));
500
+
501
+ $this->assertFalse($subject->isAvailable($quote2));
502
+ }
503
+
504
+ public function testHasBrandAliasInterfaceSupport()
505
+ {
506
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
507
+ $subject = Mage::getModel('ops/payment_recurring_cc');
508
+ $this->assertTrue($subject->hasBrandAliasInterfaceSupport());
509
+ }
510
+
511
+ public function testGetOrderPlaceRedirectUrl()
512
+ {
513
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
514
+ $subject = Mage::getModel('ops/payment_recurring_cc');
515
+ $payment = Mage::getModel('payment/info');
516
+ $payment->setAdditionalInformation('HTML_ANSWER', 'abc');
517
+ $this->assertEquals($subject->getOrderPlaceRedirectUrl($payment),
518
+ Mage::getModel('ops/config')->get3dSecureRedirectUrl()
519
+ );
520
+
521
+ $payment->setAdditionalInformation('HTML_ANSWER', '');
522
+ $this->assertFalse($subject->getOrderPlaceRedirectUrl($payment));
523
+ }
524
+
525
+ public function testIsZeroAmountAuthorizationAllowed()
526
+ {
527
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
528
+ $subject = Mage::getModel('ops/payment_recurring_cc');
529
+ $this->assertFalse($subject->isZeroAmountAuthorizationAllowed());
530
+ }
531
+
532
+ public function testGetBrandsForAliasInterface()
533
+ {
534
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
535
+ $subject = Mage::getModel('ops/payment_recurring_cc');
536
+ $this->assertEquals($subject->getBrandsForAliasInterface(),
537
+ 'American Express,Diners Club,MaestroUK,MasterCard,VISA,JCB'
538
+ );
539
+ }
540
+
541
+ public function testGetterSetters()
542
+ {
543
+ /** @var Netresearch_OPS_Model_Payment_Recurring_Cc $subject */
544
+ $subject = Mage::getModel('ops/payment_recurring_cc');
545
+
546
+ $this->assertTrue($subject->getSubscriptionManager() instanceof Netresearch_OPS_Model_Subscription_Manager);
547
+ $subject->setSubscriptionManager('abc');
548
+ $this->assertTrue($subject->getSubscriptionManager() === 'abc');
549
+
550
+ $this->assertTrue($subject->getParameterModel() instanceof
551
+ Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag
552
+ );
553
+ $subject->setParameterModel('abc');
554
+ $this->assertTrue($subject->getParameterModel() === 'abc');
555
+ }
556
+
557
+ /**
558
+ * @param $params
559
+ */
560
+ protected function mockDirectLinkRequest($params)
561
+ {
562
+ $helperMock = $this->getHelperMock('ops/directlink', array('performDirectLinkRequest'));
563
+ $helperMock->expects($this->any())
564
+ ->method('performDirectLinkRequest')
565
+ ->will($this->returnValue($params));
566
+ $this->replaceByMock('helper', 'ops/directlink', $helperMock);
567
+ }
568
+
569
+
570
+ protected function mockTwoDirectLinkRequests($params1, $params2)
571
+ {
572
+ $helperMock = $this->getHelperMock('ops/directlink', array('performDirectLinkRequest'));
573
+ $helperMock->expects($this->any())
574
+ ->method('performDirectLinkRequest')
575
+ ->will($this->onConsecutiveCalls($params1, $params2));
576
+ $this->replaceByMock('helper', 'ops/directlink', $helperMock);
577
+ }
578
+
579
+ }
app/code/community/Netresearch/OPS/Test/Model/Response/Type/AuthorizeTest.php ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: sebastian
5
+ * Date: 24.11.15
6
+ * Time: 12:51
7
+ */
8
+
9
+ class Netresearch_OPS_Test_Model_Response_Type_AuthorizeTest extends EcomDev_PHPUnit_Test_Case
10
+ {
11
+
12
+ /**
13
+ * @test
14
+ * @loadFixture orders.yaml
15
+ * @expectedException Mage_Core_Exception
16
+ */
17
+ public function testExceptionThrown()
18
+ {
19
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
20
+
21
+ $order = Mage::getModel('sales/order')->load(25);
22
+ $response = array(
23
+ 'status' => 2,
24
+ 'payid' => 1234567,
25
+ 'payidsub' => 3,
26
+ 'amount' => 33.33
27
+ );
28
+
29
+ /** @var Netresearch_OPS_Model_Response_Type_Capture $handler */
30
+ $handler = Mage::getModel('ops/response_type_authorize');
31
+ $handler->handleResponse($response, $order->getPayment()->getMethodInstance(), false);
32
+ }
33
+
34
+ /**
35
+ * @test
36
+ * @loadFixture orders.yaml
37
+ * @expectedException Mage_Core_Exception
38
+ * @expectedExceptionMessage 500 is not a authorize status!
39
+ */
40
+ public function testExceptionThrownForNoAuthorizeStatus()
41
+ {
42
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
43
+
44
+ $order = Mage::getModel('sales/order')->load(25);
45
+ $response = array(
46
+ 'status' => 500,
47
+ 'payid' => 1234567,
48
+ 'payidsub' => 3,
49
+ 'amount' => 33.33
50
+ );
51
+
52
+ /** @var Netresearch_OPS_Model_Response_Type_Capture $handler */
53
+ $handler = Mage::getModel('ops/response_type_authorize');
54
+ $handler->handleResponse($response, $order->getPayment()->getMethodInstance(), false);
55
+ }
56
+
57
+
58
+ /**
59
+ * @test
60
+ * @loadFixture orders.yaml
61
+ */
62
+ public function testHandleResponseWithPendingPaymentAndIntermediate()
63
+ {
64
+ $this->mockOrderConfig();
65
+
66
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
67
+ $order = Mage::getModel('sales/order')->load(28);
68
+
69
+ $response = array(
70
+ 'status' => 51,
71
+ 'payid' => 1234567,
72
+ 'payidsub' => 3,
73
+ 'amount' => 33.33
74
+ );
75
+
76
+
77
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
78
+ $handler = Mage::getModel('ops/response_handler');
79
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
80
+
81
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, $order->getState());
82
+ $this->assertNotEmpty($order->getAllStatusHistory());
83
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
84
+ }
85
+
86
+ /**
87
+ * @test
88
+ * @loadFixture orders.yaml
89
+ */
90
+ public function testHandleResponseWithPaymentReviewAndFinal()
91
+ {
92
+ $this->mockOrderConfig();
93
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
94
+ $order = Mage::getModel('sales/order')->load(26);
95
+
96
+ $response = array(
97
+ 'status' => 5,
98
+ 'payid' => 1234567,
99
+ 'payidsub' => 3,
100
+ 'amount' => 33.33
101
+ );
102
+
103
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
104
+ $handler = Mage::getModel('ops/response_handler');
105
+ $payment = $order->getPayment()->getMethodInstance();
106
+ $handler->processResponse($response, $payment);
107
+
108
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, $order->getState());
109
+ $this->assertNotEmpty($order->getAllStatusHistory());
110
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
111
+ }
112
+
113
+ /**
114
+ * @test
115
+ * @loadFixture orders.yaml
116
+ */
117
+ public function testHandleResponseWithPaymentReviewAndIntermediate()
118
+ {
119
+
120
+ $this->mockOrderConfig();
121
+
122
+ $order = Mage::getModel('sales/order')->load(26);
123
+
124
+ $response = array(
125
+ 'status' => 51,
126
+ 'payid' => 1234567,
127
+ 'payidsub' => 3,
128
+ 'amount' => 33.33
129
+ );
130
+
131
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
132
+ $handler = Mage::getModel('ops/response_handler');
133
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
134
+
135
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, $order->getState());
136
+ $this->assertNotEmpty($order->getAllStatusHistory());
137
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
138
+ }
139
+
140
+ /**
141
+ * @test
142
+ * @loadFixture orders.yaml
143
+ */
144
+ public function testHandleResponseWithPaymentReviewAndFinalDeclined()
145
+ {
146
+ $this->mockOrderConfig();
147
+
148
+ $order = Mage::getModel('sales/order')->load(26);
149
+ $this->mockOrderConfig();
150
+
151
+ $response = array(
152
+ 'status' => 2,
153
+ 'payid' => 1234567,
154
+ 'payidsub' => 3,
155
+ 'amount' => 33.33
156
+ );
157
+
158
+ $order->getPayment()->setAdditionalInformation('status', 46);
159
+
160
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
161
+ $handler = Mage::getModel('ops/response_handler');
162
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
163
+
164
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_CANCELED, $order->getState());
165
+ $this->assertNotEmpty($order->getAllStatusHistory());
166
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
167
+ }
168
+
169
+
170
+ /**
171
+ * @test
172
+ * @loadFixture orders.yaml
173
+ */
174
+ public function testHandleResponseWithPendingPaymentAndFinal()
175
+ {
176
+ $this->mockOrderConfig();
177
+ $order = Mage::getModel('sales/order')->load(29);
178
+ $response = array(
179
+ 'status' => 5,
180
+ 'payid' => 1234567,
181
+ 'payidsub' => 3,
182
+ 'amount' => 33.33
183
+ );
184
+
185
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
186
+ $handler = Mage::getModel('ops/response_handler');
187
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
188
+
189
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, $order->getState());
190
+ $this->assertNotEmpty($order->getAllStatusHistory());
191
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
192
+ }
193
+
194
+
195
+ /**
196
+ * @test
197
+ * @loadFixture orders.yaml
198
+ */
199
+ public function testHandleResponseWithPendingPaymentAndSuspectedFraudStatus()
200
+ {
201
+ $order = Mage::getModel('sales/order')->load(30);
202
+ $response = array(
203
+ 'status' => 55,
204
+ 'payid' => 12345678,
205
+ 'payidsub' => 3,
206
+ 'amount' => 33.33
207
+ );
208
+
209
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
210
+ $handler = Mage::getModel('ops/response_handler');
211
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
212
+
213
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, $order->getState());
214
+ $this->assertEquals(Mage_Sales_Model_Order::STATUS_FRAUD, $order->getStatus());
215
+ $this->assertNotEmpty($order->getAllStatusHistory());
216
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
217
+ }
218
+
219
+ /**
220
+ * @test
221
+ * @loadFixture orders.yaml
222
+ */
223
+ public function testHandleResponseWithPaymentReviewAndSuspectedFraudStatus()
224
+ {
225
+ $order = Mage::getModel('sales/order')->load(31);
226
+ $response = array(
227
+ 'status' => 55,
228
+ 'payid' => 1234567897,
229
+ 'payidsub' => 3,
230
+ 'amount' => 33.33
231
+ );
232
+
233
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
234
+ $handler = Mage::getModel('ops/response_handler');
235
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
236
+
237
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, $order->getState());
238
+ $this->assertEquals(Mage_Sales_Model_Order::STATUS_FRAUD, $order->getStatus());
239
+ $this->assertNotEmpty($order->getAllStatusHistory());
240
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
241
+ }
242
+
243
+ protected function mockOrderConfig(){
244
+ $configMock = $this->getModelMock('sales/order_config',array('getDefaultStatus'));
245
+ $configMock->expects($this->any())
246
+ ->method('getDefaultStatus')
247
+ ->will($this->returnArgument(0));
248
+ $this->replaceByMock('singleton', 'sales/order_config', $configMock);
249
+ }
250
+
251
+ public function testStatusAuthorizationUnclear(){
252
+ $order = Mage::getModel('sales/order')->setState(Mage_Sales_Model_Order::STATE_NEW);
253
+ $payment = Mage::getModel('sales/order_payment')->setMethod('ops_cc');
254
+ $order->setPayment($payment);
255
+ $response = array(
256
+ 'status' => 52,
257
+ 'payid' => 12345678,
258
+ 'payidsub' => 3,
259
+ 'amount' => 33.33
260
+ );
261
+ $handler = Mage::getModel('ops/response_handler');
262
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance(), false);
263
+ $this->assertEquals(true, $payment->getIsTransactionPending());
264
+
265
+ }
266
+ }
app/code/community/Netresearch/OPS/Test/Model/Response/Type/AuthorizeTest/fixtures/orders.yaml ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 25
4
+ increment_id: 100000025
5
+ shipping_address_id: 42
6
+ base_grand_total: 119.00
7
+ grand_total: 119.00
8
+ currency: 'EUR'
9
+ customer_gender: 1
10
+ shipping_method: 'flatrate_flatrate'
11
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
12
+ state: 'pending_payment'
13
+ status: 'pending_payment'
14
+ quote_id: 10
15
+
16
+ - entity_id: 26
17
+ increment_id: 100000026
18
+ shipping_address_id: 43
19
+ base_grand_total: 119.00
20
+ grand_total: 119.00
21
+ currency: 'EUR'
22
+ customer_gender: 1
23
+ shipping_method: 'flatrate_flatrate'
24
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
25
+ state: 'payment_review'
26
+ status: 'payment_review'
27
+ quote_id: 26
28
+
29
+ - entity_id: 27
30
+ increment_id: 100000027
31
+ shipping_address_id: 42
32
+ base_grand_total: 119.00
33
+ grand_total: 119.00
34
+ currency: 'EUR'
35
+ customer_gender: 1
36
+ shipping_method: 'flatrate_flatrate'
37
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
38
+ state: 'pending_payment'
39
+ status: 'pending_payment'
40
+ quote_id: 27
41
+
42
+
43
+ - entity_id: 28
44
+ increment_id: 100000028
45
+ shipping_address_id: 42
46
+ base_grand_total: 119.00
47
+ grand_total: 119.00
48
+ currency: 'EUR'
49
+ customer_gender: 1
50
+ shipping_method: 'flatrate_flatrate'
51
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
52
+ state: 'pending_payment'
53
+ status: 'pending_payment'
54
+ quote_id: 28
55
+
56
+ - entity_id: 29
57
+ increment_id: 100000029
58
+ shipping_address_id: 42
59
+ base_grand_total: 119.00
60
+ grand_total: 119.00
61
+ currency: 'EUR'
62
+ customer_gender: 1
63
+ shipping_method: 'flatrate_flatrate'
64
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
65
+ state: 'pending_payment'
66
+ status: 'pending_payment'
67
+ quote_id: 29
68
+
69
+ - entity_id: 30
70
+ increment_id: 100000030
71
+ shipping_address_id: 42
72
+ base_grand_total: 119.00
73
+ grand_total: 119.00
74
+ currency: 'EUR'
75
+ customer_gender: 1
76
+ shipping_method: 'flatrate_flatrate'
77
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
78
+ state: 'pending_payment'
79
+ status: 'pending_payment'
80
+ quote_id: 30
81
+
82
+ - entity_id: 31
83
+ increment_id: 100000031
84
+ shipping_address_id: 42
85
+ base_grand_total: 119.00
86
+ grand_total: 119.00
87
+ currency: 'EUR'
88
+ customer_gender: 1
89
+ shipping_method: 'flatrate_flatrate'
90
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
91
+ state: 'payment_review'
92
+ status: 'payment_review'
93
+ quote_id: 31
94
+
95
+
96
+
97
+ sales/quote:
98
+ - entity_id: 25
99
+ parent_id: 25
100
+ customer_id: 23
101
+ created_at: '2013-05-14 14:45:00'
102
+
103
+ - entity_id: 26
104
+ parent_id: 26
105
+ customer_id: 23
106
+ created_at: '2013-05-14 14:45:00'
107
+
108
+ - entity_id: 27
109
+ parent_id: 27
110
+ customer_id: 23
111
+ created_at: '2013-05-14 14:45:00'
112
+
113
+ - entity_id: 28
114
+ parent_id: 28
115
+ customer_id: 23
116
+ created_at: '2013-05-14 14:45:00'
117
+
118
+ - entity_id: 29
119
+ parent_id: 29
120
+ customer_id: 23
121
+ created_at: '2013-05-14 14:45:00'
122
+
123
+ - entity_id: 30
124
+ parent_id: 30
125
+ customer_id: 23
126
+ created_at: '2013-05-14 14:45:00'
127
+
128
+ - entity_id: 31
129
+ parent_id: 31
130
+ customer_id: 23
131
+ created_at: '2013-05-14 14:45:00'
132
+
133
+
134
+
135
+
136
+
137
+
138
+ sales/quote_payment:
139
+ - payment_id: 25
140
+ quote_id: 25
141
+ updated_at: '1970-01-01'
142
+ method: 'ops_iDeal'
143
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
144
+
145
+ - payment_id: 26
146
+ quote_id: 26
147
+ updated_at: '1970-01-01'
148
+ method: 'ops_iDeal'
149
+
150
+ - payment_id: 27
151
+ quote_id: 27
152
+ updated_at: '1970-01-01'
153
+ method: 'ops_iDeal'
154
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:9:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
155
+
156
+ - payment_id: 30
157
+ quote_id: 30
158
+ updated_at: '1970-01-01'
159
+ method: 'ops_iDeal'
160
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:9:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
161
+
162
+ - payment_id: 31
163
+ quote_id: 31
164
+ updated_at: '1970-01-01'
165
+ method: 'ops_iDeal'
166
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:9:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
167
+
168
+
169
+
170
+ sales/order_payment:
171
+ - entity_id: 25
172
+ parent_id: 25
173
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
174
+ method: 'ops_iDeal'
175
+
176
+ - entity_id: 26
177
+ parent_id: 26
178
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
179
+ method: 'ops_iDeal'
180
+
181
+ - entity_id: 27
182
+ parent_id: 27
183
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
184
+ method: 'ops_iDeal'
185
+
186
+ - entity_id: 28
187
+ parent_id: 28
188
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
189
+ method: 'ops_iDeal'
190
+
191
+ - entity_id: 29
192
+ parent_id: 29
193
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
194
+ method: 'ops_iDeal'
195
+
196
+ - entity_id: 30
197
+ parent_id: 30
198
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
199
+ method: 'ops_iDeal'
200
+
201
+ - entity_id: 31
202
+ parent_id: 31
203
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
204
+ method: 'ops_iDeal'
205
+
206
+
207
+
208
+ sales/order_address:
209
+ - entity_id: 42
210
+ parent_id: 25
211
+ address_type: 'billing'
212
+ firstname: 'Hubertus'
213
+ postcode: '04229'
214
+ lastname: 'Fürstenberg'
215
+ street: 'An der Tabaksmühle 3a'
216
+ city: 'Leipzig'
217
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
218
+ country_id: 'DE'
219
+ prefix: 'Prof. Dr.'
220
+ middlename: 'von'
221
+ suffix: 'MdL'
222
+ company: ''
223
+ fax: 12345678
224
+
225
+ - entity_id: 43
226
+ parent_id: 26
227
+ address_type: 'billing'
228
+ firstname: 'Hubertus'
229
+ postcode: '04229'
230
+ lastname: 'Fürstenberg'
231
+ street: 'An der Tabaksmühle 3a'
232
+ city: 'Leipzig'
233
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
234
+ country_id: 'DE'
235
+ prefix: 'Prof. Dr.'
236
+ middlename: 'von'
237
+ suffix: 'MdL'
238
+ company: ''
239
+ fax: 12345678
app/code/community/Netresearch/OPS/Test/Model/Response/Type/CaptureTest.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * CaptureTest.php
24
+ *
25
+ * @category OPS
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Model_Response_Type_CaptureTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+ /**
36
+ * @test
37
+ * @loadFixture orders.yaml
38
+ */
39
+ public function testHandleResponseWithPaymentReviewAndIntermediate()
40
+ {
41
+ $order = Mage::getModel('sales/order')->load(26);
42
+
43
+ $response = array(
44
+ 'status' => 91,
45
+ 'payid' => 1234567,
46
+ 'payidsub' => 3,
47
+ 'amount' => 33.33
48
+ );
49
+
50
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
51
+ $handler = Mage::getModel('ops/response_handler');
52
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
53
+
54
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, $order->getState());
55
+ $this->assertNotEmpty($order->getAllStatusHistory());
56
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
57
+ }
58
+
59
+ /**
60
+ * @test
61
+ * @loadFixture orders.yaml
62
+ */
63
+ public function testHandleResponseWithPendingPaymentAndIntermediate()
64
+ {
65
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
66
+ $order = Mage::getModel('sales/order')->load(25);
67
+
68
+ $response = array(
69
+ 'status' => 91,
70
+ 'payid' => 1234567,
71
+ 'payidsub' => 3,
72
+ 'amount' => 33.33
73
+ );
74
+
75
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
76
+ $handler = Mage::getModel('ops/response_handler');
77
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
78
+
79
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, $order->getState());
80
+ $this->assertNotEmpty($order->getAllStatusHistory());
81
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
82
+ }
83
+
84
+ /**
85
+ * @test
86
+ * @loadFixture orders.yaml
87
+ */
88
+ public function testHandleResponseWithPaymentReviewAndFinal()
89
+ {
90
+ $this->mockOrderConfig();
91
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
92
+ $order = Mage::getModel('sales/order')->load(26);
93
+
94
+ $response = array(
95
+ 'status' => 9,
96
+ 'payid' => 1234567,
97
+ 'payidsub' => 3,
98
+ 'amount' => 33.33
99
+ );
100
+
101
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
102
+ $handler = Mage::getModel('ops/response_handler');
103
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
104
+
105
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PROCESSING, $order->getState());
106
+ $this->assertNotEmpty($order->getAllStatusHistory());
107
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
108
+ }
109
+
110
+ /**
111
+ * @test
112
+ * @loadFixture orders.yaml
113
+ */
114
+ public function testHandleResponseWithPendingPaymentAndFinal()
115
+ {
116
+ $this->mockOrderConfig();
117
+ $order = Mage::getModel('sales/order')->load(25);
118
+ $order->setBaseGrandTotal(33.33);
119
+
120
+ $response = array(
121
+ 'status' => 9,
122
+ 'payid' => 1234567,
123
+ 'payidsub' => 3,
124
+ 'amount' => 33.33
125
+ );
126
+
127
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
128
+ $handler = Mage::getModel('ops/response_handler');
129
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
130
+
131
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PROCESSING, $order->getState());
132
+ $this->assertNotEmpty($order->getAllStatusHistory());
133
+ $this->assertNotEmpty($order->getInvoiceCollection());
134
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
135
+ }
136
+
137
+ /**
138
+ * @test
139
+ * @loadFixture orders.yaml
140
+ * @expectedException Mage_Core_Exception
141
+ */
142
+ public function testExceptionThrown()
143
+ {
144
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
145
+
146
+ $order = Mage::getModel('sales/order')->load(25);
147
+ $response = array(
148
+ 'status' => 43,
149
+ 'payid' => 1234567,
150
+ 'payidsub' => 3,
151
+ 'amount' => 33.33
152
+ );
153
+
154
+ /** @var Netresearch_OPS_Model_Response_Type_Capture $handler */
155
+ $handler = Mage::getModel('ops/response_type_capture');
156
+ $handler->handleResponse($response, $order->getPayment()->getMethodInstance());
157
+ }
158
+
159
+ /**
160
+ * @test
161
+ * @loadFixture orders.yaml
162
+ */
163
+ public function testAbortBecauseSameStatus()
164
+ {
165
+ $order = Mage::getModel('sales/order')->load(27);
166
+ $order->getPayment()->setAdditionalInformation('status', 9);
167
+
168
+
169
+
170
+ $response = array(
171
+ 'status' => 9,
172
+ 'payid' => 1234567,
173
+ 'payidsub' => 3,
174
+ 'amount' => 33.33
175
+ );
176
+
177
+ $order->getPayment()->setLastTransId($response['payid'].'/'.$response['payidsub']);
178
+
179
+ /** @var Netresearch_OPS_Model_Response_Type_Capture $handler */
180
+ $handler = Mage::getModel('ops/response_type_capture');
181
+ $handler->handleResponse($response, $order->getPayment()->getMethodInstance());
182
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, $order->getState());
183
+ }
184
+
185
+ protected function mockOrderConfig(){
186
+ $configMock = $this->getModelMock('sales/order_config',array('getDefaultStatus'));
187
+ $configMock->expects($this->any())
188
+ ->method('getDefaultStatus')
189
+ ->will($this->returnArgument(0));
190
+ $this->replaceByMock('singleton', 'sales/order_config', $configMock);
191
+ }
192
+ }
app/code/community/Netresearch/OPS/Test/Model/Response/Type/CaptureTest/fixtures/orders.yaml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 25
4
+ increment_id: 100000025
5
+ shipping_address_id: 42
6
+ base_grand_total: 119.00
7
+ grand_total: 119.00
8
+ currency: 'EUR'
9
+ customer_gender: 1
10
+ shipping_method: 'flatrate_flatrate'
11
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
12
+ state: 'pending_payment'
13
+ status: 'pending_payment'
14
+ quote_id: 10
15
+
16
+ - entity_id: 26
17
+ increment_id: 100000026
18
+ shipping_address_id: 43
19
+ base_grand_total: 119.00
20
+ grand_total: 119.00
21
+ currency: 'EUR'
22
+ customer_gender: 1
23
+ shipping_method: 'flatrate_flatrate'
24
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
25
+ state: 'payment_review'
26
+ status: 'payment_review'
27
+ quote_id: 26
28
+
29
+ - entity_id: 27
30
+ increment_id: 100000027
31
+ shipping_address_id: 42
32
+ base_grand_total: 119.00
33
+ grand_total: 119.00
34
+ currency: 'EUR'
35
+ customer_gender: 1
36
+ shipping_method: 'flatrate_flatrate'
37
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
38
+ state: 'pending_payment'
39
+ status: 'pending_payment'
40
+ quote_id: 27
41
+
42
+
43
+
44
+ sales/quote:
45
+ - entity_id: 25
46
+ parent_id: 25
47
+ customer_id: 23
48
+ created_at: '2013-05-14 14:45:00'
49
+
50
+ - entity_id: 26
51
+ parent_id: 26
52
+ customer_id: 23
53
+ created_at: '2013-05-14 14:45:00'
54
+
55
+ - entity_id: 27
56
+ parent_id: 27
57
+ customer_id: 23
58
+ created_at: '2013-05-14 14:45:00'
59
+
60
+
61
+
62
+ sales/quote_payment:
63
+ - payment_id: 25
64
+ quote_id: 25
65
+ updated_at: '1970-01-01'
66
+ method: 'ops_iDeal'
67
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
68
+
69
+ - payment_id: 26
70
+ quote_id: 26
71
+ updated_at: '1970-01-01'
72
+ method: 'ops_iDeal'
73
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
74
+
75
+ - payment_id: 27
76
+ quote_id: 27
77
+ updated_at: '1970-01-01'
78
+ method: 'ops_iDeal'
79
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:9:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
80
+
81
+
82
+
83
+ sales/order_payment:
84
+ - entity_id: 25
85
+ parent_id: 25
86
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
87
+ method: 'ops_iDeal'
88
+
89
+ - entity_id: 26
90
+ parent_id: 26
91
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
92
+ method: 'ops_iDeal'
93
+
94
+ - entity_id: 27
95
+ parent_id: 27
96
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
97
+ method: 'ops_iDeal'
98
+
99
+
100
+
101
+ sales/order_address:
102
+ - entity_id: 42
103
+ parent_id: 25
104
+ address_type: 'billing'
105
+ firstname: 'Hubertus'
106
+ postcode: '04229'
107
+ lastname: 'Fürstenberg'
108
+ street: 'An der Tabaksmühle 3a'
109
+ city: 'Leipzig'
110
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
111
+ country_id: 'DE'
112
+ prefix: 'Prof. Dr.'
113
+ middlename: 'von'
114
+ suffix: 'MdL'
115
+ company: ''
116
+ fax: 12345678
117
+
118
+ - entity_id: 43
119
+ parent_id: 26
120
+ address_type: 'billing'
121
+ firstname: 'Hubertus'
122
+ postcode: '04229'
123
+ lastname: 'Fürstenberg'
124
+ street: 'An der Tabaksmühle 3a'
125
+ city: 'Leipzig'
126
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
127
+ country_id: 'DE'
128
+ prefix: 'Prof. Dr.'
129
+ middlename: 'von'
130
+ suffix: 'MdL'
131
+ company: ''
132
+ fax: 12345678
133
+
134
+
135
+
app/code/community/Netresearch/OPS/Test/Model/Response/Type/RefundTest.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * CaptureTest.php
24
+ *
25
+ * @category OPS
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Model_Response_Type_RefundTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+
36
+
37
+ /**
38
+ * @test
39
+ * @loadFixture orders.yaml
40
+ * @expectedException Mage_Core_Exception
41
+ */
42
+ public function testExceptionThrown()
43
+ {
44
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
45
+
46
+ $order = Mage::getModel('sales/order')->load(25);
47
+ $response = array(
48
+ 'status' => 43,
49
+ 'payid' => 1234567,
50
+ 'payidsub' => 3,
51
+ 'amount' => 33.33
52
+ );
53
+
54
+ /** @var Netresearch_OPS_Model_Response_Type_Capture $handler */
55
+ $handler = Mage::getModel('ops/response_handler');
56
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
57
+ }
58
+
59
+ /**
60
+ * @test
61
+ * @loadFixture orders.yaml
62
+ * @expectedException Mage_Core_Exception
63
+ * @expectedExceptionMessage 2 is not a refund status!
64
+ */
65
+ public function testExceptionThrownDueToNoRefundStatus()
66
+ {
67
+ /** @var Netresearch_OPS_Model_Payment_IDeal $instance */
68
+
69
+ $order = Mage::getModel('sales/order')->load(25);
70
+ $response = array(
71
+ 'status' => Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED,
72
+ 'payid' => 1234567,
73
+ 'payidsub' => 3,
74
+ 'amount' => 33.33
75
+ );
76
+
77
+ /** @var Netresearch_OPS_Model_Response_Type_Capture $handler */
78
+ $handler = Mage::getModel('ops/response_type_refund');
79
+ $handler->handleResponse($response, $order->getPayment()->getMethodInstance());
80
+ }
81
+
82
+
83
+ /**
84
+ * @test
85
+ * @loadFixture orders.yaml
86
+ */
87
+ public function testAbortBecauseSameStatus()
88
+ {
89
+ $order = Mage::getModel('sales/order')->load(27);
90
+ $order->getPayment()->setAdditionalInformation('status', 8);
91
+ $response = array(
92
+ 'status' => Netresearch_OPS_Model_Status::REFUNDED,
93
+ 'payid' => 1234567,
94
+ 'payidsub' => 3,
95
+ 'amount' => 33.33
96
+ );
97
+ $order->getPayment()->setLastTransId($response['payid'].'/'.$response['payidsub']);
98
+ /** @var Netresearch_OPS_Model_Response_Type_Capture $handler */
99
+ $handler = Mage::getModel('ops/response_type_refund');
100
+ $handler->handleResponse($response, $order->getPayment()->getMethodInstance());
101
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, $order->getState());
102
+ }
103
+
104
+ /**
105
+ * @test
106
+ * @loadFixture orders.yaml
107
+ */
108
+ public function testCreditMemoStateOpenRefundSuccess()
109
+ {
110
+ $this->mockOrderConfig();
111
+
112
+ $order = Mage::getModel('sales/order')->load(27);
113
+ $response = array(
114
+ 'status' => Netresearch_OPS_Model_Status::REFUNDED,
115
+ 'payid' => 1234567,
116
+ 'payidsub' => 3,
117
+ 'amount' => 33.33
118
+ );
119
+ $order->setBillingAddress(Mage::getModel('sales/order_address'));
120
+ $invoice = Mage::getModel('sales/order_invoice');
121
+ $invoice->setOrder($order);
122
+ $creditMemo = Mage::getModel('sales/order_creditmemo');
123
+ $creditMemo->setInvoice($invoice);
124
+ $creditMemo->setId('1234567/3');
125
+ $creditMemo->setOrder($order);
126
+ $creditMemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_OPEN);
127
+ $creditMemoMock = $this->getModelMock('sales/order_creditmemo', array('load'));
128
+ $creditMemoMock->expects($this->any())
129
+ ->method('load')
130
+ ->will($this->returnValue($creditMemo));
131
+ $order->getPayment()->setOrder($order);
132
+
133
+ $this->replaceByMock('model', 'sales/order_creditmemo', $creditMemoMock);
134
+
135
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
136
+ $handler = Mage::getModel('ops/response_handler');
137
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
138
+
139
+ $this->assertEquals(Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED, $creditMemo->getState());
140
+
141
+ }
142
+
143
+
144
+ /**
145
+ * @test
146
+ * @loadFixture orders.yaml
147
+ */
148
+ public function testCreditMemoStateOpenRefundRefused()
149
+ {
150
+ $this->mockOrderConfig();
151
+
152
+ $creditMemo = Mage::getModel('sales/order_creditmemo')->load(122);
153
+ $response = array(
154
+ 'status' => Netresearch_OPS_Model_Status::REFUND_REFUSED,
155
+ 'payid' => 1234567,
156
+ 'payidsub' => 3,
157
+ 'amount' => 33.33
158
+ );
159
+
160
+ $creditMemoMock = $this->getModelMock('sales/order_creditmemo', array('save', 'cancel', 'load'));
161
+ $creditMemoMock->expects($this->any())
162
+ ->method('save')
163
+ ->will($this->returnSelf());
164
+ $creditMemoMock->expects($this->any())
165
+ ->method('cancel')
166
+ ->will($this->returnSelf());
167
+ $creditMemoMock->expects($this->any())
168
+ ->method('load')
169
+ ->will($this->returnValue($creditMemo));
170
+ $this->replaceByMock('model', 'sales/order_creditmemo', $creditMemoMock);
171
+
172
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
173
+ $handler = Mage::getModel('ops/response_handler');
174
+ $handler->processResponse($response, $creditMemo->getOrder()->getPayment()->getMethodInstance());
175
+
176
+ $this->assertEquals(Mage_Sales_Model_Order::STATE_PROCESSING, $creditMemo->getOrder()->getState());
177
+ $this->assertEquals(Mage_Sales_Model_Order_Creditmemo::STATE_CANCELED, $creditMemo->getState());
178
+ }
179
+
180
+
181
+ /**
182
+ * @test
183
+ * @loadFixture orders.yaml
184
+ */
185
+ public function testCreditMemoRefundFinalState()
186
+ {
187
+ $this->mockOrderConfig();
188
+
189
+ $order = Mage::getModel('sales/order')->load(25);
190
+
191
+ $response = array(
192
+ 'status' => Netresearch_OPS_Model_Status::REFUNDED,
193
+ 'payid' => 12345679,
194
+ 'payidsub' => 3,
195
+ 'amount' => 33.33
196
+ );
197
+
198
+ /** @var Mage_Sales_Model_Order_Invoice $invoice */
199
+ $invoice = $order->getInvoiceCollection()->getFirstItem();
200
+ $creditMemoMock = $this->getModelMock('sales/order_creditmemo', array('getInvoice'));
201
+ $creditMemoMock->expects($this->any())
202
+ ->method('getInvoice')
203
+ ->will($this->returnValue($invoice));
204
+
205
+ $this->replaceByMock('model', 'sales/order_creditmemo', $creditMemoMock);
206
+
207
+
208
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
209
+ $handler = Mage::getModel('ops/response_handler');
210
+ $handler->processResponse($response, $order->getPayment()->getMethodInstance());
211
+
212
+ $this->assertNotEmpty($order->getAllStatusHistory());
213
+ $this->assertNotEmpty($order->getInvoiceCollection());
214
+ $this->assertEquals($response['status'], $order->getPayment()->getAdditionalInformation('status'));
215
+
216
+ }
217
+
218
+
219
+ /**
220
+ * @test
221
+ * @loadFixture orders.yaml
222
+ */
223
+ public function testCreditMemoRefundPendingState()
224
+ {
225
+ $this->mockOrderConfig();
226
+
227
+ $creditMemo = Mage::getModel('sales/order_creditmemo');
228
+
229
+ $paymentMock = $this->getModelMock('sales/order_payment', array('getCreatedCreditMemo'));
230
+ $paymentMock->expects($this->any())
231
+ ->method('getCreatedCreditMemo')
232
+ ->will($this->returnValue($creditMemo));
233
+ $this->replaceByMock('model', 'sales/order_payment', $paymentMock);
234
+
235
+
236
+ $payment = Mage::getModel('sales/order_payment')->load(25);
237
+ $order = Mage::getModel('sales/order')->load(25);
238
+ $payment->setOrder($order);
239
+
240
+ $response = array(
241
+ 'status' => Netresearch_OPS_Model_Status::REFUND_PENDING,
242
+ 'payid' => 1234567534,
243
+ 'payidsub' => 3,
244
+ 'amount' => 33.33
245
+ );
246
+
247
+ /** @var Mage_Sales_Model_Order_Invoice $invoice */
248
+ $invoice = Mage::getModel('sales/order_invoice');
249
+ $creditMemoMock = $this->getModelMock('sales/order_creditmemo', array('getInvoice'));
250
+ $creditMemoMock->expects($this->any())
251
+ ->method('getInvoice')
252
+ ->will($this->returnValue($invoice));
253
+
254
+ $this->replaceByMock('model', 'sales/order_creditmemo', $creditMemoMock);
255
+
256
+
257
+ $transactionMock = $this->getModelMock('core/resource_transaction', array('save'));
258
+ $transactionMock->expects($this->any())
259
+ ->method('save')
260
+ ->will($this->returnSelf());
261
+ $this->replaceByMock('model', 'core/resource_transaction', $transactionMock);
262
+
263
+
264
+
265
+ /** @var Netresearch_OPS_Model_Response_Handler $handler */
266
+ $handler = Mage::getModel('ops/response_handler');
267
+ $handler->processResponse($response, $payment->getMethodInstance());
268
+
269
+
270
+ $this->assertNotEmpty($order->getAllStatusHistory());
271
+ $this->assertNotEmpty($order->getInvoiceCollection());
272
+ $this->assertEquals($response['status'], $payment->getAdditionalInformation('status'));
273
+ $this->assertEquals(Mage_Sales_Model_Order_Creditmemo::STATE_OPEN, $creditMemo->getState());
274
+
275
+ }
276
+
277
+ protected function mockOrderConfig(){
278
+ $configMock = $this->getModelMock('sales/order_config',array('getDefaultStatus'));
279
+ $configMock->expects($this->any())
280
+ ->method('getDefaultStatus')
281
+ ->will($this->returnArgument(0));
282
+ $this->replaceByMock('singleton', 'sales/order_config', $configMock);
283
+ }
284
+ }
app/code/community/Netresearch/OPS/Test/Model/Response/Type/RefundTest/fixtures/orders.yaml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 25
4
+ increment_id: 100000025
5
+ shipping_address_id: 42
6
+ base_grand_total: 119.00
7
+ grand_total: 119.00
8
+ currency: 'EUR'
9
+ customer_gender: 1
10
+ shipping_method: 'flatrate_flatrate'
11
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
12
+ state: 'pending_payment'
13
+ status: 'pending_payment'
14
+ quote_id: 10
15
+
16
+ - entity_id: 26
17
+ increment_id: 100000026
18
+ shipping_address_id: 43
19
+ base_grand_total: 119.00
20
+ grand_total: 119.00
21
+ currency: 'EUR'
22
+ customer_gender: 1
23
+ shipping_method: 'flatrate_flatrate'
24
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
25
+ state: 'payment_review'
26
+ status: 'payment_review'
27
+ quote_id: 26
28
+
29
+ - entity_id: 27
30
+ increment_id: 100000027
31
+ shipping_address_id: 42
32
+ base_grand_total: 119.00
33
+ grand_total: 119.00
34
+ currency: 'EUR'
35
+ customer_gender: 1
36
+ shipping_method: 'flatrate_flatrate'
37
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
38
+ state: 'pending_payment'
39
+ status: 'pending_payment'
40
+ quote_id: 27
41
+
42
+
43
+
44
+ sales/quote:
45
+ - entity_id: 25
46
+ parent_id: 25
47
+ customer_id: 23
48
+ created_at: '2013-05-14 14:45:00'
49
+
50
+ - entity_id: 26
51
+ parent_id: 26
52
+ customer_id: 23
53
+ created_at: '2013-05-14 14:45:00'
54
+
55
+ - entity_id: 27
56
+ parent_id: 27
57
+ customer_id: 23
58
+ created_at: '2013-05-14 14:45:00'
59
+
60
+
61
+
62
+ sales/quote_payment:
63
+ - payment_id: 25
64
+ quote_id: 25
65
+ updated_at: '1970-01-01'
66
+ method: 'ops_iDeal'
67
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
68
+
69
+ - payment_id: 26
70
+ quote_id: 26
71
+ updated_at: '1970-01-01'
72
+ method: 'ops_iDeal'
73
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
74
+
75
+ - payment_id: 27
76
+ quote_id: 27
77
+ updated_at: '1970-01-01'
78
+ method: 'ops_iDeal'
79
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:9:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
80
+
81
+
82
+
83
+ sales/order_payment:
84
+ - entity_id: 25
85
+ parent_id: 25
86
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
87
+ method: 'ops_iDeal'
88
+
89
+ - entity_id: 26
90
+ parent_id: 26
91
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
92
+ method: 'ops_iDeal'
93
+
94
+ - entity_id: 27
95
+ parent_id: 27
96
+ additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
97
+ method: 'ops_iDeal'
98
+
99
+
100
+
101
+ sales/order_address:
102
+ - entity_id: 42
103
+ parent_id: 25
104
+ address_type: 'billing'
105
+ firstname: 'Hubertus'
106
+ postcode: '04229'
107
+ lastname: 'Fürstenberg'
108
+ street: 'An der Tabaksmühle 3a'
109
+ city: 'Leipzig'
110
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
111
+ country_id: 'DE'
112
+ prefix: 'Prof. Dr.'
113
+ middlename: 'von'
114
+ suffix: 'MdL'
115
+ company: ''
116
+ fax: 12345678
117
+
118
+ - entity_id: 43
119
+ parent_id: 26
120
+ address_type: 'billing'
121
+ firstname: 'Hubertus'
122
+ postcode: '04229'
123
+ lastname: 'Fürstenberg'
124
+ street: 'An der Tabaksmühle 3a'
125
+ city: 'Leipzig'
126
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
127
+ country_id: 'DE'
128
+ prefix: 'Prof. Dr.'
129
+ middlename: 'von'
130
+ suffix: 'MdL'
131
+ company: ''
132
+ fax: 12345678
133
+
134
+ sales/order_item:
135
+ - item_id: 1
136
+ order_id: 27
137
+ qty_ordered: 1
138
+
139
+ sales/invoice:
140
+ - entity_id: 27
141
+ order_id: 27
142
+
143
+ - entity_id: 25
144
+ order_id: 25
145
+
146
+ sales/creditmemo:
147
+ - entity_id: 122
148
+ order_id: 27
149
+ state: 'open'
150
+ transaction_id: '1234567/3'
151
+ invoice_id: 27
152
+
153
+ sales/creditmemo_item:
154
+ - entity_id: 1
155
+ parent_id: 122
156
+ order_item_id: 1
157
+ qty: 1
app/code/community/Netresearch/OPS/Test/Model/Source/Cc/RecurringTypesTest.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * RecurringTypesTest.php
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Model_Source_Cc_RecurringTypesTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+
36
+ public function testToOptionArray()
37
+ {
38
+ $subject = Mage::getModel('ops/source_cc_recurringTypes');
39
+ $this->assertArrayHasKey('VISA', $subject->toOptionArray());
40
+ }
41
+ }
app/code/community/Netresearch/OPS/Test/Model/Status/MappingTest.php DELETED
@@ -1,135 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @author Michael Lühr <michael.luehr@netresearch.de>
5
- * @category Netresearch
6
- * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- class Netresearch_OPS_Test_Model_Status_MappingTest extends EcomDev_PHPUnit_Test_Case
10
- {
11
-
12
- protected $mappingModel = null;
13
-
14
- protected $opsStates = array();
15
-
16
- protected $expectedOrderStates = array();
17
-
18
- public function setUp()
19
- {
20
- parent::setUp();
21
- $this->mappingModel = Mage::getModel('ops/status_mapping');
22
- }
23
-
24
- protected function assertStatusMapping()
25
- {
26
- foreach ($this->opsStates as $opsState) {
27
- $this->assertEquals($this->expectedOrderStates, $this->mappingModel->getStatusForOpsStatus($opsState));
28
- }
29
- }
30
-
31
- public function testVoidStatus()
32
- {
33
- $this->opsStates = array(
34
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED,
35
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_WAITING,
36
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_UNCERTAIN,
37
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_REFUSED,
38
- Netresearch_OPS_Model_Payment_Abstract::OPS_VOIDED_ACCEPTED,
39
- );
40
-
41
- $this->expectedOrderStates = array(
42
- Mage_Sales_Model_Order::STATE_PROCESSING,
43
- Mage_Sales_Model_Order::STATE_COMPLETE,
44
- Mage_Sales_Model_Order::STATE_CANCELED
45
- );
46
-
47
- $this->assertStatusMapping();
48
-
49
- }
50
-
51
- public function testCaptureStatus()
52
- {
53
- $this->opsStates = array(
54
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED,
55
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSING,
56
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_UNCERTAIN,
57
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_DECLINED_ACQUIRER,
58
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_PROCESSED_MERCHANT,
59
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_IN_PROGRESS,
60
- );
61
-
62
- $this->expectedOrderStates = array(
63
- Mage_Sales_Model_Order::STATE_COMPLETE,
64
- Mage_Sales_Model_Order::STATE_PROCESSING
65
- );
66
-
67
- $this->assertStatusMapping();
68
- }
69
-
70
- public function testRefundStatus()
71
- {
72
- $this->opsStates = array(
73
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUNDED,
74
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_WAITING,
75
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_UNCERTAIN_STATUS,
76
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_REFUSED,
77
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_DECLINED_ACQUIRER,
78
- Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PROCESSED_MERCHANT,
79
- );
80
-
81
- $this->expectedOrderStates = array(
82
- Mage_Sales_Model_Order::STATE_CLOSED,
83
- Mage_Sales_Model_Order::STATE_PROCESSING
84
- );
85
-
86
- $this->assertStatusMapping();
87
- }
88
-
89
- public function testAuthStatusProcessingStateInMagento()
90
- {
91
- $this->opsStates = array(
92
- Netresearch_OPS_Model_Payment_Abstract::OPS_ORDER_SAVED,
93
- Netresearch_OPS_Model_Payment_Abstract::OPS_OPEN_INVOICE_DE_PROCESSED,
94
- Netresearch_OPS_Model_Payment_Abstract::OPS_WAITING_FOR_IDENTIFICATION,
95
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED,
96
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_KWIXO,
97
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_UNKNOWN,
98
- Netresearch_OPS_Model_Payment_Abstract::OPS_STAND_BY,
99
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENTS_SCHEDULED,
100
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_TO_GET_MANUALLY,
101
- ''
102
- );
103
- $this->expectedOrderStates = array(Mage_Sales_Model_Order::STATE_PROCESSING);
104
- $this->assertStatusMapping();
105
- }
106
-
107
- public function testAuthStatusPendingPaymentStateInMagento()
108
- {
109
- $this->opsStates = array(
110
- Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT,
111
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING
112
-
113
- );
114
- $this->expectedOrderStates = array(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
115
- $this->assertStatusMapping();
116
- }
117
-
118
- public function testRefusedStatus()
119
- {
120
- $this->opsStates = array(
121
- Netresearch_OPS_Model_Payment_Abstract::OPS_AUTH_REFUSED,
122
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REFUSED,
123
- Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_CANCELED_BY_CUSTOMER
124
- );
125
- $this->expectedOrderStates = array(Mage_Sales_Model_Order::STATE_CANCELED);
126
- $this->assertStatusMapping();
127
- }
128
-
129
- public function testSetTransitionModel()
130
- {
131
- $transitionModel = $this->getModelMock('ops/status_transition');
132
- $this->mappingModel->setTransitionModel($transitionModel);
133
- $this->assertEquals($this->mappingModel->getTransitionModel(), $transitionModel);
134
- }
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Test/Model/Status/TransitionTest.php DELETED
@@ -1,270 +0,0 @@
1
- <?php
2
- /**
3
- * @author Michael Lühr <michael.luehr@netresearch.de>
4
- * @category Netresearch
5
- * @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
6
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
- */
8
-
9
-
10
- class Netresearch_OPS_Test_Model_Status_TransitionTest extends EcomDev_PHPUnit_Test_Case
11
- {
12
-
13
- public function testProcessOpsResponse()
14
- {
15
- $transitionModelMock = $this->getModelMock('ops/status_transition', array('processCaptureFeedback', 'processRefundFeedback', 'processVoidFeedback'));
16
- $order = Mage::getModel('sales/order');
17
- $opsResponse = array('STATUS' => 5);
18
- $transitionModelMock->processOpsResponse($opsResponse, $order);
19
- $this->assertEquals($opsResponse, $transitionModelMock->getOpsResponse());
20
- $this->assertEquals($order, $transitionModelMock->getOrder());
21
- }
22
-
23
-
24
- public function testCaptureFeedbackWithDirectFeedback()
25
- {
26
- $order = $this->getModelMock('sales/order', array('save', '_beforeSave', '_afterSave', 'load'));
27
- $payment = Mage::getModel('sales/order_payment');
28
- $methodInstance = Mage::getModel('ops/payment_cc');
29
- $payment->setMethod($methodInstance);
30
- $order->setPayment($payment);
31
- $opsResponse = array('STATUS' => 91, 'PAYID' => 1, 'PAYIDSUB' => 1, 'AMOUNT' => 1);
32
- $txData = array('operation' => Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_FULL,
33
- 'type' => "full");
34
- $captureHelperMock = $this->getHelperMock('ops/order_capture', array('prepareOperation'));
35
- $captureHelperMock->expects($this->once())
36
- ->method('prepareOperation')
37
- ->will($this->returnValue($txData));
38
-
39
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('directLinkTransact'));
40
- $directLinkHelperMock->expects($this->once())
41
- ->method('directLinkTransact')
42
- ;
43
-
44
- $transitionModel = $this->getModelMock('ops/status_transition', array('reloadOrder'));
45
- $transitionModel->expects($this->any())
46
- ->method('reloadOrder')
47
- ->will($this->returnValue($order));
48
- $transitionModel->setOrder($order);
49
- $transitionModel->setOpsResponse($opsResponse);
50
- $transitionModel->setCaptureHelper($captureHelperMock);
51
- $transitionModel->setDirectlinkHelper($directLinkHelperMock);
52
- $cntBefore = $order->getStatusHistoryCollection()->count();
53
- $transitionModel->processCaptureFeedback();
54
- $cntAfter = $order->getStatusHistoryCollection()->count();
55
- $this->assertTrue($cntBefore < $cntAfter);
56
- }
57
-
58
- public function testCaptureFeedbackWithPostbackFeedback()
59
- {
60
- $order = $this->getModelMock('sales/order', array('save', '_beforeSave', '_afterSave', 'load'));
61
- $payment = Mage::getModel('sales/order_payment');
62
- $methodInstance = Mage::getModel('ops/payment_cc');
63
- $payment->setMethod($methodInstance);
64
- $order->setPayment($payment);
65
- $opsResponse = array('STATUS' => 9, 'PAYID' => 1, 'PAYIDSUB' => 1, 'AMOUNT' => 1);
66
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('processFeedback'));
67
- $directLinkHelperMock->expects($this->once())
68
- ->method('processFeedback')
69
- ->with($order, $opsResponse);
70
- $transitionModel = $this->getModelMock('ops/status_transition', array('reloadOrder'));
71
- $transitionModel->setDirectlinkHelper($directLinkHelperMock);
72
- $transitionModel->setOrder($order);
73
- $transitionModel->setOpsResponse($opsResponse);
74
- $transitionModel->processCaptureFeedback();
75
- }
76
-
77
- public function testVoidFeedBackWithUncertainStatus()
78
- {
79
- $order = $this->getModelMock('sales/order', array('save', '_beforeSave', '_afterSave', 'load'));
80
- $payment = Mage::getModel('sales/order_payment');
81
- $methodInstance = Mage::getModel('ops/payment_cc');
82
- $payment->setMethod($methodInstance);
83
- $order->setPayment($payment);
84
- $opsResponse = array('STATUS' => 61, 'PAYID' => 1, 'PAYIDSUB' => 1, 'AMOUNT' => 1);
85
-
86
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('directLinkTransact'));
87
- $directLinkHelperMock->expects($this->once())
88
- ->method('directLinkTransact')
89
- ;
90
-
91
- $transitionModel = $this->getModelMock('ops/status_transition', array('reloadOrder'));
92
- $transitionModel->expects($this->any())
93
- ->method('reloadOrder')
94
- ->will($this->returnValue($order));
95
-
96
- $transitionModel->setDirectlinkHelper($directLinkHelperMock);
97
- $transitionModel->setOrder($order);
98
- $transitionModel->setOpsResponse($opsResponse);
99
- $transitionModel->processVoidFeedback();
100
- }
101
-
102
- public function testVoidFeedBackWithSuccessStatus()
103
- {
104
- $order = $this->getModelMock('sales/order', array('save', '_beforeSave', '_afterSave', 'load'));
105
- $payment = Mage::getModel('sales/order_payment');
106
- $methodInstance = Mage::getModel('ops/payment_cc');
107
- $payment->setMethod($methodInstance);
108
- $order->setPayment($payment);
109
- $opsResponse = array('STATUS' => 6, 'PAYID' => 1, 'PAYIDSUB' => 1, 'AMOUNT' => 1);
110
-
111
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('directLinkTransact'));
112
- $directLinkHelperMock->expects($this->once())
113
- ->method('directLinkTransact')
114
- ;
115
-
116
- $voidHelper = $this->getHelperMock('ops/order_void', array('acceptVoid'));
117
- $voidHelper->expects($this->once())
118
- ->method('acceptVoid')
119
- ->with($order, $opsResponse)
120
- ;
121
-
122
- $transitionModel = $this->getModelMock('ops/status_transition', array('reloadOrder'));
123
- $transitionModel->expects($this->any())
124
- ->method('reloadOrder')
125
- ->will($this->returnValue($order));
126
-
127
- $transitionModel->setDirectlinkHelper($directLinkHelperMock);
128
- $transitionModel->setOrder($order);
129
- $transitionModel->setOpsResponse($opsResponse);
130
- $transitionModel->setVoidHelper($voidHelper);
131
- $transitionModel->processVoidFeedback();
132
- }
133
-
134
- public function testVoidFeedBackWithDeniedStatus()
135
- {
136
- $order = $this->getModelMock('sales/order', array('save', '_beforeSave', '_afterSave', 'load'));
137
- $payment = Mage::getModel('sales/order_payment');
138
- $methodInstance = Mage::getModel('ops/payment_cc');
139
- $payment->setMethod($methodInstance);
140
- $order->setPayment($payment);
141
- $opsResponse = array('STATUS' => 63, 'PAYID' => 1, 'PAYIDSUB' => 1, 'AMOUNT' => 1);
142
-
143
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('processFeedback'));
144
- $directLinkHelperMock->expects($this->once())
145
- ->method('processFeedback')
146
- ->with($order, $opsResponse);
147
-
148
-
149
-
150
- $transitionModel = $this->getModelMock('ops/status_transition', array('reloadOrder'));
151
- $transitionModel->expects($this->any())
152
- ->method('reloadOrder')
153
- ->will($this->returnValue($order));
154
-
155
- $transitionModel->setDirectlinkHelper($directLinkHelperMock);
156
- $transitionModel->setOrder($order);
157
- $transitionModel->setOpsResponse($opsResponse);
158
- $transitionModel->processVoidFeedback();
159
- }
160
-
161
- public function testRefundFeedBackWithWaitingStatus()
162
- {
163
- $order = $this->getModelMock('sales/order', array('save', '_beforeSave', '_afterSave', 'load'));
164
- $payment = Mage::getModel('sales/order_payment');
165
- $methodInstance = Mage::getModel('ops/payment_cc');
166
- $payment->setMethod($methodInstance);
167
- $order->setPayment($payment);
168
- $opsResponse = array('STATUS' => 81, 'PAYID' => 1, 'PAYIDSUB' => 1, 'AMOUNT' => 1);
169
-
170
- $refundHelper = $this->getHelperMock('ops/order_refund', array('determineOperationCode', 'createRefundTransaction'));
171
- $refundHelper->expects($this->once())
172
- ->method('determineOperationCode')
173
- ->will($this->returnValue('RFS'));
174
- $refundHelper->expects($this->once())
175
- ->method('createRefundTransaction')
176
- ->with($opsResponse);
177
-
178
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('hasPaymentTransactions'));
179
- $directLinkHelperMock->expects($this->once())
180
- ->method('hasPaymentTransactions')
181
- ->will($this->returnValue(false));
182
-
183
- $paymentHelperMock = $this->getHelperMock('ops/payment', array('saveOpsRefundOperationCodeToPayment'));
184
- $paymentHelperMock->expects($this->once())
185
- ->method('saveOpsRefundOperationCodeToPayment')
186
- ->with($payment, 'RFS');
187
-
188
-
189
- $transitionModel = $this->getModelMock('ops/status_transition', array('reloadOrder'));
190
- $transitionModel->expects($this->any())
191
- ->method('reloadOrder')
192
- ->will($this->returnValue($order));
193
- $transitionModel->setRefundHelper($refundHelper);
194
- $transitionModel->setPaymentHelper($paymentHelperMock);
195
- $transitionModel->setDirectlinkHelper($directLinkHelperMock);
196
- $transitionModel->setOrder($order);
197
- $transitionModel->setOpsResponse($opsResponse);
198
- $transitionModel->processRefundFeedback();
199
- }
200
-
201
- public function testRefundFeedBackWithAcceptedStatus()
202
- {
203
- $order = $this->getModelMock('sales/order', array('save', '_beforeSave', '_afterSave', 'load'));
204
- $payment = Mage::getModel('sales/order_payment');
205
- $methodInstance = Mage::getModel('ops/payment_cc');
206
- $payment->setMethod($methodInstance);
207
- $order->setPayment($payment);
208
- $opsResponse = array('STATUS' => 8, 'PAYID' => 1, 'PAYIDSUB' => 1, 'AMOUNT' => 1);
209
-
210
- $refundHelper = $this->getHelperMock('ops/order_refund', array('determineOperationCode', 'createRefund'));
211
- $refundHelper->expects($this->once())
212
- ->method('determineOperationCode')
213
- ->will($this->returnValue('RFS'));
214
- $refundHelper->expects($this->once())
215
- ->method('createRefund')
216
- ->with($order, $opsResponse);
217
-
218
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('hasPaymentTransactions'));
219
-
220
-
221
- $paymentHelperMock = $this->getHelperMock('ops/payment', array('saveOpsRefundOperationCodeToPayment'));
222
- $paymentHelperMock->expects($this->once())
223
- ->method('saveOpsRefundOperationCodeToPayment')
224
- ->with($payment, 'RFS');
225
-
226
-
227
- $transitionModel = $this->getModelMock('ops/status_transition', array('reloadOrder'));
228
- $transitionModel->expects($this->any())
229
- ->method('reloadOrder')
230
- ->will($this->returnValue($order));
231
- $transitionModel->setRefundHelper($refundHelper);
232
- $transitionModel->setPaymentHelper($paymentHelperMock);
233
- $transitionModel->setDirectlinkHelper($directLinkHelperMock);
234
- $transitionModel->setOrder($order);
235
- $transitionModel->setOpsResponse($opsResponse);
236
- $transitionModel->processRefundFeedback();
237
- }
238
-
239
- public function testRefundFeedBackWithDeniedStatus()
240
- {
241
- $order = $this->getModelMock('sales/order', array('save', '_beforeSave', '_afterSave', 'load'));
242
- $payment = Mage::getModel('sales/order_payment');
243
- $methodInstance = Mage::getModel('ops/payment_cc');
244
- $payment->setMethod($methodInstance);
245
- $order->setPayment($payment);
246
- $opsResponse = array('STATUS' => 83, 'PAYID' => 1, 'PAYIDSUB' => 1, 'AMOUNT' => 1);
247
-
248
- $refundHelper = $this->getHelperMock('ops/order_refund', array('determineOperationCode'));
249
- $refundHelper->expects($this->once())
250
- ->method('determineOperationCode')
251
- ->will($this->returnValue('RFS'));
252
-
253
-
254
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('processFeedback'));
255
- $directLinkHelperMock->expects($this->once())
256
- ->method('processFeedback')
257
- ->with($order, $opsResponse);
258
-
259
- $transitionModel = $this->getModelMock('ops/status_transition', array('reloadOrder'));
260
- $transitionModel->expects($this->any())
261
- ->method('reloadOrder')
262
- ->will($this->returnValue($order));
263
- $transitionModel->setRefundHelper($refundHelper);
264
- $transitionModel->setDirectlinkHelper($directLinkHelperMock);
265
- $transitionModel->setOrder($order);
266
- $transitionModel->setOpsResponse($opsResponse);
267
- $transitionModel->processRefundFeedback();
268
- }
269
-
270
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Netresearch/OPS/Test/Model/Status/UpdateTest.php CHANGED
@@ -8,6 +8,12 @@
8
  class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_Case
9
  {
10
 
 
 
 
 
 
 
11
  public function testNoUpdateForNonOpsPayments()
12
  {
13
  $order = Mage::getModel('sales/order');
@@ -109,16 +115,9 @@ class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_
109
  $payment->setMethod('ops_directDebit');
110
  $payment->setAdditionalInformation('paymentId', 4711);
111
  $payment->setAdditionalInformation('status', 91);
 
112
  $order->setPayment($payment);
113
 
114
- $fakeTransaction = new Varien_Object();
115
- $fakeTransaction->setTxnId(1);
116
-
117
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('getPaymentTransaction'));
118
- $directLinkHelperMock->expects($this->once())
119
- ->method('getPaymentTransaction')
120
- ->will($this->returnValue($fakeTransaction));
121
-
122
  $statusUpdateApiMock = $this->getModelMock('ops/status_update', array('updatePaymentStatus'));
123
  $directLinkApiMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
124
  $directLinkApiMock->expects($this->once())
@@ -132,7 +131,6 @@ class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_
132
  )
133
  ->will($this->returnValue(array('STATUS' => 5)))
134
  ;
135
- $statusUpdateApiMock->setDirectLinkHelper($directLinkHelperMock);
136
  $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
137
  $statusUpdateApiMock->updateStatusFor($order);
138
  $opsResponse = $statusUpdateApiMock->getOpsResponse();
@@ -147,16 +145,9 @@ class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_
147
  $payment->setMethod('ops_directDebit');
148
  $payment->setAdditionalInformation('paymentId', 4711);
149
  $payment->setAdditionalInformation('status', 81);
 
150
  $order->setPayment($payment);
151
 
152
- $fakeTransaction = new Varien_Object();
153
- $fakeTransaction->setTxnId(1);
154
-
155
- $directLinkHelperMock = $this->getHelperMock('ops/directlink', array('getPaymentTransaction'));
156
- $directLinkHelperMock->expects($this->once())
157
- ->method('getPaymentTransaction')
158
- ->will($this->returnValue($fakeTransaction));
159
-
160
  $statusUpdateApiMock = $this->getModelMock('ops/status_update', array('updatePaymentStatus'));
161
  $directLinkApiMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
162
  $directLinkApiMock->expects($this->once())
@@ -171,7 +162,6 @@ class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_
171
  ->will($this->returnValue(array('STATUS' => 8, 'AMOUNT' => 1,)))
172
  ;
173
 
174
- $statusUpdateApiMock->setDirectLinkHelper($directLinkHelperMock);
175
  $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
176
  $statusUpdateApiMock->updateStatusFor($order);
177
  $opsResponse = $statusUpdateApiMock->getOpsResponse();
@@ -212,6 +202,9 @@ class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_
212
  )
213
  ->will($this->returnValue(array('STATUS' => 8,)))
214
  ;
 
 
 
215
  $statusUpdateApiMock->setPaymentHelper($paymentHelperMock);
216
  $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
217
  $statusUpdateApiMock->updateStatusFor($order);
@@ -224,7 +217,7 @@ class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_
224
  public function testUpdatePaymentStatusWithStatusChange()
225
  {
226
  $order = Mage::getModel('sales/order');
227
- $payment = Mage::getModel('sales/order_payment');
228
  $payment->setMethod('ops_directDebit');
229
  $payment->setAdditionalInformation('paymentId', 4711);
230
  $payment->setAdditionalInformation('status', 5);
@@ -252,13 +245,6 @@ class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_
252
  ->will($this->returnValue($response))
253
  ;
254
 
255
- $transitionModelMock = $this->getModelMock('ops/status_transition', array('processOpsResponse'));
256
- $transitionModelMock->expects($this->once())
257
- ->method('processOpsResponse')
258
- ->with($response, $order)
259
- ;
260
-
261
- $statusUpdateApiMock->setTransitionModel($transitionModelMock);
262
  $statusUpdateApiMock->setPaymentHelper($paymentHelperMock);
263
  $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
264
 
8
  class Netresearch_OPS_Test_Model_Status_UpdateTest extends EcomDev_PHPUnit_Test_Case
9
  {
10
 
11
+ protected function mockSessions(){
12
+ $sessionMock = $this->getModelMock('admin/session', array());
13
+ $sessionMock->disableOriginalConstructor();
14
+ $this->replaceByMock('singleton', 'admin/session', $sessionMock);
15
+ }
16
+
17
  public function testNoUpdateForNonOpsPayments()
18
  {
19
  $order = Mage::getModel('sales/order');
115
  $payment->setMethod('ops_directDebit');
116
  $payment->setAdditionalInformation('paymentId', 4711);
117
  $payment->setAdditionalInformation('status', 91);
118
+ $payment->setLastTransId('4711/1');
119
  $order->setPayment($payment);
120
 
 
 
 
 
 
 
 
 
121
  $statusUpdateApiMock = $this->getModelMock('ops/status_update', array('updatePaymentStatus'));
122
  $directLinkApiMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
123
  $directLinkApiMock->expects($this->once())
131
  )
132
  ->will($this->returnValue(array('STATUS' => 5)))
133
  ;
 
134
  $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
135
  $statusUpdateApiMock->updateStatusFor($order);
136
  $opsResponse = $statusUpdateApiMock->getOpsResponse();
145
  $payment->setMethod('ops_directDebit');
146
  $payment->setAdditionalInformation('paymentId', 4711);
147
  $payment->setAdditionalInformation('status', 81);
148
+ $payment->setLastTransId('4711/1');
149
  $order->setPayment($payment);
150
 
 
 
 
 
 
 
 
 
151
  $statusUpdateApiMock = $this->getModelMock('ops/status_update', array('updatePaymentStatus'));
152
  $directLinkApiMock = $this->getModelMock('ops/api_directlink', array('performRequest'));
153
  $directLinkApiMock->expects($this->once())
162
  ->will($this->returnValue(array('STATUS' => 8, 'AMOUNT' => 1,)))
163
  ;
164
 
 
165
  $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
166
  $statusUpdateApiMock->updateStatusFor($order);
167
  $opsResponse = $statusUpdateApiMock->getOpsResponse();
202
  )
203
  ->will($this->returnValue(array('STATUS' => 8,)))
204
  ;
205
+
206
+ $adminSessionMock = $this->getModelMock('adminhtml/session', array('init', 'save', 'addNotice'));
207
+ $statusUpdateApiMock->setMessageContainer($adminSessionMock);
208
  $statusUpdateApiMock->setPaymentHelper($paymentHelperMock);
209
  $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
210
  $statusUpdateApiMock->updateStatusFor($order);
217
  public function testUpdatePaymentStatusWithStatusChange()
218
  {
219
  $order = Mage::getModel('sales/order');
220
+ $payment = $this->getModelMock('sales/order_payment', array('save'));
221
  $payment->setMethod('ops_directDebit');
222
  $payment->setAdditionalInformation('paymentId', 4711);
223
  $payment->setAdditionalInformation('status', 5);
245
  ->will($this->returnValue($response))
246
  ;
247
 
 
 
 
 
 
 
 
248
  $statusUpdateApiMock->setPaymentHelper($paymentHelperMock);
249
  $statusUpdateApiMock->setDirectLinkApi($directLinkApiMock);
250
 
app/code/community/Netresearch/OPS/Test/Model/Status/UpdateTest/fixtures/orders.yaml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 25
4
+ increment_id: 100000025
5
+ shipping_address_id: 42
6
+ base_grand_total: 119.00
7
+ grand_total: 119.00
8
+ currency: 'EUR'
9
+ customer_gender: 1
10
+ shipping_method: 'flatrate_flatrate'
11
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
12
+ state: 'payment_review'
13
+ status: 'payment_review'
14
+ quote_id: 10
15
+
16
+ - entity_id: 26
17
+ increment_id: 100000026
18
+ shipping_address_id: 43
19
+ base_grand_total: 119.00
20
+ grand_total: 119.00
21
+ currency: 'EUR'
22
+ customer_gender: 1
23
+ shipping_method: 'flatrate_flatrate'
24
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
25
+ state: 'payment_review'
26
+ status: 'payment_review'
27
+ quote_id: 26
28
+
29
+ - entity_id: 27
30
+ increment_id: 100000027
31
+ shipping_address_id: 42
32
+ base_grand_total: 119.00
33
+ grand_total: 119.00
34
+ currency: 'EUR'
35
+ customer_gender: 1
36
+ shipping_method: 'flatrate_flatrate'
37
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
38
+ state: 'pending_payment'
39
+ status: 'pending_payment'
40
+ quote_id: 27
41
+
42
+
43
+
44
+ sales/quote:
45
+ - entity_id: 25
46
+ parent_id: 25
47
+ customer_id: 23
48
+ created_at: '2013-05-14 14:45:00'
49
+
50
+ - entity_id: 26
51
+ parent_id: 26
52
+ customer_id: 23
53
+ created_at: '2013-05-14 14:45:00'
54
+
55
+ - entity_id: 27
56
+ parent_id: 27
57
+ customer_id: 23
58
+ created_at: '2013-05-14 14:45:00'
59
+
60
+
61
+
62
+ sales/quote_payment:
63
+ - payment_id: 25
64
+ quote_id: 25
65
+ updated_at: '1970-01-01'
66
+ method: 'ops_iDeal'
67
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
68
+
69
+ - payment_id: 26
70
+ quote_id: 26
71
+ updated_at: '1970-01-01'
72
+ method: 'ops_iDeal'
73
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
74
+
75
+ - payment_id: 27
76
+ quote_id: 27
77
+ updated_at: '1970-01-01'
78
+ method: 'ops_iDeal'
79
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:9:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
80
+
81
+
82
+
83
+ sales/order_payment:
84
+ - entity_id: 25
85
+ parent_id: 25
86
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
87
+ method: 'ops_iDeal'
88
+
89
+ - entity_id: 26
90
+ parent_id: 26
91
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
92
+ method: 'ops_iDeal'
93
+
94
+ - entity_id: 27
95
+ parent_id: 27
96
+ additional_information: 'a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}'
97
+ method: 'ops_iDeal'
98
+
99
+
100
+
101
+ sales/order_address:
102
+ - entity_id: 42
103
+ parent_id: 25
104
+ address_type: 'billing'
105
+ firstname: 'Hubertus'
106
+ postcode: '04229'
107
+ lastname: 'Fürstenberg'
108
+ street: 'An der Tabaksmühle 3a'
109
+ city: 'Leipzig'
110
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
111
+ country_id: 'DE'
112
+ prefix: 'Prof. Dr.'
113
+ middlename: 'von'
114
+ suffix: 'MdL'
115
+ company: ''
116
+ fax: 12345678
117
+
118
+ - entity_id: 43
119
+ parent_id: 26
120
+ address_type: 'billing'
121
+ firstname: 'Hubertus'
122
+ postcode: '04229'
123
+ lastname: 'Fürstenberg'
124
+ street: 'An der Tabaksmühle 3a'
125
+ city: 'Leipzig'
126
+ email: 'hubertus.von.fuerstenberg@trash-mail.com'
127
+ country_id: 'DE'
128
+ prefix: 'Prof. Dr.'
129
+ middlename: 'von'
130
+ suffix: 'MdL'
131
+ company: ''
132
+ fax: 12345678
133
+
134
+
135
+
app/code/community/Netresearch/OPS/Test/Model/StatusTest.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Netresearch_OPS_Test_Model_StatusTest extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ public function testIsFinal()
6
+ {
7
+ $status = Netresearch_OPS_Model_Status::AUTHORIZED;
8
+ $this->assertTrue(Netresearch_OPS_Model_Status::isFinal($status));
9
+ $status = Netresearch_OPS_Model_Status::AUTHORIZED_WAITING_EXTERNAL_RESULT;
10
+ $this->assertFalse(Netresearch_OPS_Model_Status::isFinal($status));
11
+
12
+ }
13
+
14
+ public function testIsIntermediate()
15
+ {
16
+ $status = Netresearch_OPS_Model_Status::AUTHORIZED_WAITING_EXTERNAL_RESULT;
17
+ $this->assertTrue(Netresearch_OPS_Model_Status::isIntermediate($status));
18
+ $status = Netresearch_OPS_Model_Status::AUTHORIZED;
19
+ $this->assertFalse(Netresearch_OPS_Model_Status::isIntermediate($status));
20
+ }
21
+
22
+
23
+ public function testIsCapture()
24
+ {
25
+ $captureStatus = array(
26
+ Netresearch_OPS_Model_Status::PAYMENT_REQUESTED,
27
+ Netresearch_OPS_Model_Status::PAYMENT_PROCESSING,
28
+ Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN,
29
+ Netresearch_OPS_Model_Status::PAYMENT_REFUSED,
30
+ Netresearch_OPS_Model_Status::PAYMENT_DECLINED_BY_ACQUIRER,
31
+ Netresearch_OPS_Model_Status::PAYMENT_PROCESSED_BY_MERCHANT,
32
+ Netresearch_OPS_Model_Status::REFUND_REVERSED,
33
+ Netresearch_OPS_Model_Status::PAYMENT_IN_PROGRESS
34
+ );
35
+ foreach ($captureStatus as $status) {
36
+ $this->assertTrue(Netresearch_OPS_Model_Status::isCapture($status));
37
+ }
38
+ $this->assertFalse(Netresearch_OPS_Model_Status::isCapture(Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED));
39
+ }
40
+
41
+ public function testIsRefund()
42
+ {
43
+ $refundStatus = array(
44
+ Netresearch_OPS_Model_Status::REFUNDED,
45
+ Netresearch_OPS_Model_Status::REFUND_PENDING,
46
+ Netresearch_OPS_Model_Status::REFUND_UNCERTAIN,
47
+ Netresearch_OPS_Model_Status::REFUND_REFUSED,
48
+ Netresearch_OPS_Model_Status::REFUNDED_OK,
49
+ Netresearch_OPS_Model_Status::REFUND_PROCESSED_BY_MERCHANT,
50
+ );
51
+ foreach ($refundStatus as $status) {
52
+ $this->assertTrue(Netresearch_OPS_Model_Status::isRefund($status));
53
+ }
54
+ $this->assertFalse(Netresearch_OPS_Model_Status::isCapture(Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED));
55
+ }
56
+
57
+ public function testIsVoid()
58
+ {
59
+ $voidStatus = array(
60
+ Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED,
61
+ Netresearch_OPS_Model_Status::DELETION_WAITING,
62
+ Netresearch_OPS_Model_Status::DELETION_UNCERTAIN,
63
+ Netresearch_OPS_Model_Status::DELETION_REFUSED,
64
+ Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED_OK,
65
+ );
66
+ foreach ($voidStatus as $status) {
67
+ $this->assertTrue(Netresearch_OPS_Model_Status::isVoid($status));
68
+ }
69
+ $this->assertFalse(Netresearch_OPS_Model_Status::isVoid(Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED));
70
+ }
71
+
72
+
73
+ public function testIsAuthorize()
74
+ {
75
+ $authStatus = array(
76
+ Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED,
77
+ Netresearch_OPS_Model_Status::AUTHORIZED,
78
+ Netresearch_OPS_Model_Status::AUTHORIZED_WAITING_EXTERNAL_RESULT,
79
+ Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING,
80
+ Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN,
81
+ Netresearch_OPS_Model_Status::STAND_BY_SUSPECTED_FRAUD,
82
+ Netresearch_OPS_Model_Status::OK_WITH_SHEDULED_PAYMENTS,
83
+ Netresearch_OPS_Model_Status::NOT_OK_WITH_SHEDULED_PAYMENTS,
84
+ Netresearch_OPS_Model_Status::AUTHORISATION_TO_BE_REQUESTED_MANUALLY
85
+ );
86
+ foreach ($authStatus as $status) {
87
+ $this->assertTrue(Netresearch_OPS_Model_Status::isAuthorize($status));
88
+ }
89
+ $this->assertFalse(Netresearch_OPS_Model_Status::isAuthorize(Netresearch_OPS_Model_Status::REFUND_PENDING));
90
+ }
91
+
92
+ public function testIsWaitingStatus()
93
+ {
94
+ $waitingStatus = array(
95
+ Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT,
96
+ Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION,
97
+ Netresearch_OPS_Model_Status::STORED_WAITING_EXTERNAL_RESULT
98
+ );
99
+ foreach ($waitingStatus as $status) {
100
+ $this->assertTrue(Netresearch_OPS_Model_Status::isSpecialStatus($status));
101
+ }
102
+ $this->assertFalse(Netresearch_OPS_Model_Status::isSpecialStatus(Netresearch_OPS_Model_Status::REFUND_PENDING));
103
+ }
104
+
105
+
106
+ public function testCanResendPaymentInfo()
107
+ {
108
+ $canResendInfoStatus = array(
109
+ Netresearch_OPS_Model_Status::NOT_OK_WITH_SHEDULED_PAYMENTS,
110
+ Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER,
111
+ Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED,
112
+ Netresearch_OPS_Model_Status::AUTHORISATION_TO_BE_REQUESTED_MANUALLY,
113
+ Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN,
114
+ Netresearch_OPS_Model_Status::PAYMENT_REFUSED,
115
+ );
116
+ foreach ($canResendInfoStatus as $status) {
117
+ $this->assertTrue(Netresearch_OPS_Model_Status::canResendPaymentInfo($status));
118
+ }
119
+ $this->assertFalse(Netresearch_OPS_Model_Status::canResendPaymentInfo(Netresearch_OPS_Model_Status::REFUND_PENDING));
120
+ }
121
+ }
122
+
app/code/community/Netresearch/OPS/Test/Model/Subscription/ManagerTest.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * ManagerTest.php
24
+ *
25
+ * @category Payment provider
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Model_Subscription_ManagerTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+
36
+ public function testHelperFunctions()
37
+ {
38
+ /** @var Netresearch_OPS_Model_Subscription_Manager $subject */
39
+ $subject = Mage::getModel('ops/subscription_manager');
40
+ $testString = 'abc';
41
+ $this->assertTrue($subject->getSubscriptionHelper() instanceof Netresearch_OPS_Helper_Subscription);
42
+ $subject->setSubscriptionHelper($testString);
43
+ $this->assertEquals($subject->getSubscriptionHelper(), $testString);
44
+
45
+ $this->assertTrue($subject->getPaymentHelper() instanceof Netresearch_OPS_Helper_Payment);
46
+ $subject->setPaymentHelper($testString);
47
+ $this->assertEquals($subject->getPaymentHelper(), $testString);
48
+ }
49
+
50
+ /**
51
+ * @return Mage_Sales_Model_Recurring_Profile
52
+ */
53
+ protected function getTestProfile()
54
+ {
55
+ $profile = Mage::getModel('sales/recurring_profile');
56
+ $profile->setScheduleDescription('abc')
57
+ ->setPeriodFrequency(1)
58
+ ->setPeriodMaxCycles(1)
59
+ ->setPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_WEEK)
60
+ ->setInitAmount(10)
61
+ ->setBillingAmount(15)
62
+ ->setTaxAmount(5)
63
+ ->setShippingAmount(5)
64
+ ->setStartDatetime('')
65
+ ->setBillingAddressInfo(array('quote_id' => 1))
66
+ ->setMethodCode(Netresearch_OPS_Model_Payment_Recurring_Cc::CODE)
67
+ ->setId(0);
68
+
69
+ return $profile;
70
+ }
71
+
72
+ /**
73
+ * @return string[]
74
+ */
75
+ protected function getResponseParams()
76
+ {
77
+
78
+ $responseParams = array(
79
+ 'PAYID' => '123',
80
+ 'currency' => 'EUR',
81
+ 'STATUS' => '5',
82
+ 'orderID' => 'SUB-123',
83
+ 'amount' => '0'
84
+ );
85
+
86
+ return $responseParams;
87
+
88
+ }
89
+
90
+ protected function mockDependencies()
91
+ {
92
+
93
+ $profileMock = $this->getModelMock('sales/recurring_profile', array('addOrderRelation'));
94
+ $profileMock->expects($this->once())
95
+ ->method('addOrderRelation')
96
+ ->will($this->returnValue(''));
97
+ $this->replaceByMock('model', 'sales/recurring_profile', $profileMock);
98
+
99
+ $paymentHelperMock = $this->getHelperMock('ops/payment', array('applyStateForOrder'));
100
+ $paymentHelperMock->expects($this->once())
101
+ ->method('applyStateForOrder')
102
+ ->will($this->returnValue(''));
103
+ $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
104
+
105
+ $orderMock = $this->getModelMock('sales/order', array('save'));
106
+ $orderMock->expects($this->any())
107
+ ->method('save')
108
+ ->will($this->returnValue(''));
109
+ $this->replaceByMock('model', 'sales/order', $orderMock);
110
+
111
+ $paymentMock = $this->getModelMock('sales/order_payment',
112
+ array('registerAuthorizationNotification', 'registerCaptureNotification')
113
+ );
114
+ $paymentMock->expects($this->any())
115
+ ->method('registerCaptureNotification')
116
+ ->will($this->returnValue(''));
117
+ $paymentMock->expects($this->any())
118
+ ->method('registerAuthorizationNotification')
119
+ ->will($this->returnValue(''));
120
+ $this->replaceByMock('model', 'sales/order_payment', $paymentMock);
121
+ }
122
+
123
+ public function testProcessSubscriptionFeedbackWithInitialCreation()
124
+ {
125
+ $subject = Mage::getModel('ops/subscription_manager');
126
+ $profile = $this->getTestProfile();
127
+ $responseParams = $this->getResponseParams();
128
+
129
+ $responseParams['creation_status'] = Netresearch_OPS_Model_Subscription_Manager::CREATION_SUCCEEDED;
130
+ $responseParams['subscription_id'] = 'test';
131
+ $result = $subject->processSubscriptionFeedback($responseParams, $profile);
132
+
133
+ $this->assertFalse($result);
134
+ $this->assertEquals($profile->getReferenceId(), 'test');
135
+ $this->assertEquals($profile->getState(), Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
136
+ }
137
+
138
+ public function testProcessSubscriptionFeedbackWithRegularSubscriptionFeedback()
139
+ {
140
+ $this->mockDependencies();
141
+ $subject = Mage::getModel('ops/subscription_manager');
142
+ $profile = $this->getTestProfile();
143
+ $responseParams = $this->getResponseParams();
144
+
145
+ $result = $subject->processSubscriptionFeedback($responseParams, $profile);
146
+
147
+ $this->assertTrue($result instanceof Mage_Sales_Model_Order);
148
+ $this->assertEquals($result->getShippingAmount(), $profile->getShippingAmount());
149
+ $this->assertEquals($result->getTaxAmount(), $profile->getTaxAmount());
150
+ $this->assertEquals($result->getSubtotal(), $profile->getBillingAmount());
151
+ }
152
+
153
+ public function testProcessSubscriptionFeedbackWithTrialSubscriptionFeedback()
154
+ {
155
+ /** @var $subject Netresearch_OPS_Model_Subscription_Manager */
156
+ $this->mockDependencies();
157
+ $subject = Mage::getModel('ops/subscription_manager');
158
+ $profile = $this->getTestProfile();
159
+ $responseParams = $this->getResponseParams();
160
+ $responseParams['orderID'] = $responseParams['orderID'] . Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX;
161
+ $profile->setTrialPeriodUnit(Mage_Sales_Model_Recurring_Profile::PERIOD_UNIT_MONTH)
162
+ ->setTrialBillingAmount(5)
163
+ ->setTrialPeriodFrequency(3)
164
+ ->setTrialPeriodMaxCycles(4)
165
+ ->setInitAmount(0)
166
+ ->setOrderItemInfo(array('tax_percent' => 7));
167
+
168
+
169
+ $result = $subject->processSubscriptionFeedback($responseParams, $profile);
170
+
171
+ $this->assertTrue($result instanceof Mage_Sales_Model_Order);
172
+ $this->assertEquals($result->getShippingAmount(), $profile->getShippingAmount());
173
+ $this->assertEquals($result->getBaseGrandTotal(), $profile->getTrialBillingAmount() + $profile->getShippingAmount());
174
+ }
175
+ }
app/code/community/Netresearch/OPS/Test/Model/System/Config/Backend/Flex/MethodsTest.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * MethodsTest.php
24
+ *
25
+ * @category Payment
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+
33
+ class Netresearch_OPS_Test_Model_System_Config_Backend_Flex_MethodsTest extends EcomDev_PHPUnit_Test_Case
34
+ {
35
+
36
+ /**
37
+ * @expectedException Mage_Core_Exception
38
+ * @expectedExceptionMessage Can not save empty title or PM fields
39
+ */
40
+ public function testSaveWithEmptyException()
41
+ {
42
+ /** @var Netresearch_OPS_Model_System_Config_Backend_Flex_Methods $model */
43
+ $model = Mage::getModel('ops/system_config_backend_flex_methods');
44
+ $model->setValue($this->getEmpty());
45
+
46
+ $model->save();
47
+ }
48
+
49
+ /**
50
+ * @expectedException Mage_Core_Exception
51
+ * @expectedExceptionMessage PM and Brand combination must be unique
52
+ */
53
+ public function testSaveWithDuplicateException()
54
+ {
55
+ $model = Mage::getModel('ops/system_config_backend_flex_methods');
56
+ $model->setValue($this->getDuplicate());
57
+
58
+ $model->save();
59
+
60
+ }
61
+
62
+ public function testSave()
63
+ {
64
+ $model = Mage::getModel('ops/system_config_backend_flex_methods');
65
+ $model->setValue(array($this->getSimpleData()));
66
+ $model->setScope('default')
67
+ ->setScopeId(0)
68
+ ->setPath('payment/ops_flex/methods');
69
+
70
+ $model->save();
71
+ Mage::getConfig()->cleanCache();
72
+ $methods = unserialize(Mage::getStoreConfig('payment/ops_flex/methods'));
73
+
74
+ $this->assertTrue(is_array($methods));
75
+ $this->assertEquals(1, count($methods));
76
+ }
77
+
78
+ protected function getDuplicate()
79
+ {
80
+ return array(
81
+ $this->getSimpleData(),
82
+ $this->getSimpleData()
83
+ );
84
+ }
85
+
86
+ protected function getEmpty()
87
+ {
88
+ return array(
89
+ $this->getSimpleData(),
90
+ array(
91
+ 'title' => '',
92
+ 'brand' => '',
93
+ 'pm' => ''
94
+ )
95
+ );
96
+ }
97
+
98
+ protected function getSimpleData()
99
+ {
100
+ return array(
101
+ 'title' => 'foo',
102
+ 'brand' => 'bar',
103
+ 'pm' => 'zzz'
104
+ );
105
+ }
106
+ }
app/code/community/Netresearch/OPS/Trait/AliasController.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * AliasController.php
24
+ *
25
+ * @package Netresearch_OPS
26
+ * @author Paul Siedler <paul.siedler@netresearch.de>
27
+ */
28
+ ?>
29
+ <?php
30
+
31
+ trait Netresearch_OPS_Trait_AliasController
32
+ {
33
+ use Netresearch_OPS_Trait_PaymentHelper;
34
+
35
+ /**
36
+ * @return Netresearch_OPS_Model_Config
37
+ */
38
+ protected function getConfig()
39
+ {
40
+ return Mage::getSingleton('ops/config');
41
+ }
42
+
43
+ /**
44
+ * accept-action for Alias-generating iframe-response
45
+ *
46
+ */
47
+ public function acceptAction()
48
+ {
49
+ $params = $this->getRequest()->getParams();
50
+ $helper = Mage::helper('ops');
51
+ $helper->log(
52
+ $helper->__(
53
+ "Incoming accepted Ingenico ePayments Alias Feedback\n\nRequest Path: %s\nParams: %s\n",
54
+ $this->getRequest()->getPathInfo(),
55
+ serialize($params)
56
+ )
57
+ );
58
+ Mage::helper('ops/alias')->saveAlias($params);
59
+
60
+
61
+ if (array_key_exists('Alias_OrderId', $params)) {
62
+ $quote = Mage::getModel('sales/quote')->load($params['Alias_OrderId']);
63
+ $this->updateAdditionalInformation($quote, $params);
64
+ } else {
65
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
66
+ }
67
+
68
+ // OGNH-7 special handling for admin orders
69
+ Mage::helper('ops/alias')->setAliasToPayment(
70
+ $quote->getPayment(),
71
+ array_change_key_case($params, CASE_LOWER),
72
+ false
73
+ );
74
+
75
+ $result
76
+ = sprintf(
77
+ "<script type='application/javascript'>window.onload = function() { top.document.fire('alias:success', '%s'); };</script>",
78
+ $params['Alias_AliasId']
79
+ );
80
+
81
+ return $this->getResponse()->setBody($result);
82
+ }
83
+
84
+ /**
85
+ * exception-action for Alias-generating iframe-response
86
+ *
87
+ */
88
+ public function exceptionAction()
89
+ {
90
+ $params = $this->getRequest()->getParams();
91
+ $errors = array();
92
+
93
+ foreach ($params as $key => $value) {
94
+ if (stristr($key, 'error') && 0 != $value) {
95
+ $errors[] = $value;
96
+ }
97
+ }
98
+
99
+ $helper = Mage::helper('ops');
100
+ $helper->log(
101
+ $helper->__(
102
+ "Incoming exception Ingenico ePayments Alias Feedback\n\nRequest Path: %s\nParams: %s\n",
103
+ $this->getRequest()->getPathInfo(),
104
+ serialize($params)
105
+ )
106
+ );
107
+
108
+ $result
109
+ = "<script type='application/javascript'>window.onload = function() { top.document.fire('alias:failure'); };</script>";
110
+
111
+ return $this->getResponse()->setBody($result);
112
+ }
113
+
114
+ /**
115
+ * Generates the hash for the hosted tokenization page request
116
+ *
117
+ * @throws Exception
118
+ */
119
+ public function generateHashAction()
120
+ {
121
+ $storeId = $this->getStoreId();
122
+
123
+ $result = $this->generateHash($storeId);
124
+
125
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
126
+ }
127
+
128
+ /**
129
+ * Get store id from quote or request
130
+ *
131
+ * @return int
132
+ */
133
+ protected function getStoreId()
134
+ {
135
+ $storeId = null;
136
+
137
+ if (Mage::app()->getStore()->isAdmin()) {
138
+ $quote = Mage::getSingleton('adminhtml/session_quote');
139
+ $storeId = $quote->getStoreId();
140
+ } else {
141
+ $quoteId = $this->_request->getParam('orderid');
142
+
143
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
144
+
145
+ if (is_null($quote->getId())) {
146
+ $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
147
+ }
148
+
149
+ if (!is_null($quote->getId())) {
150
+ $storeId = $quote->getStoreId();
151
+ }
152
+ if (false == is_null($this->_request->getParam('storeId'))) {
153
+ $storeId = $this->_request->getParam('storeId');
154
+ }
155
+ }
156
+
157
+ return $storeId;
158
+ }
159
+
160
+ /**
161
+ * updates the additional information from payment, thats needed for backend reOrders
162
+ *
163
+ * @param Mage_Sales_Model_Quote $quote
164
+ * @param array $params
165
+ */
166
+ public function updateAdditionalInformation(Mage_Sales_Model_Quote $quote, $params)
167
+ {
168
+ if (!is_null($quote->getId()) && $quote->getPayment() && !is_null($quote->getPayment()->getId())) {
169
+ $payment = $quote->getPayment();
170
+ if (array_key_exists('Alias', $params)) {
171
+ $payment->setAdditionalInformation('alias', $params['Alias_AliasId']);
172
+ }
173
+ if (array_key_exists('Brand', $params)) {
174
+ $payment->setAdditionalInformation('CC_BRAND', $params['Card_Brand']);
175
+ }
176
+ if (array_key_exists('CN', $params)) {
177
+ $payment->setAdditionalInformation('CC_CN', $params['Card_CardHolderName']);
178
+ }
179
+ if ($this->userIsRegistering()) {
180
+ $payment->setAdditionalInformation('userIsRegistering', true);
181
+ }
182
+ $quote->setPayment($payment)->setDataChanges(true)->save();
183
+ $quote->setDataChanges(true)->save();
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Checks if checkout method is registering
189
+ *
190
+ * @return bool
191
+ */
192
+ protected function userIsRegistering()
193
+ {
194
+ return Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod()
195
+ === Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
196
+ }
197
+
198
+ /**
199
+ * Generate hash from request parameters
200
+ *
201
+ * @param $storeId
202
+ *
203
+ * @return array
204
+ */
205
+ protected function generateHash($storeId)
206
+ {
207
+ $data = $this->cleanParamKeys();
208
+
209
+ $secret = $this->getConfig()->getShaOutCode($storeId);
210
+ $raw = $this->getPaymentHelper()->getSHAInSet($data, $secret);
211
+ $result = array('hash' => Mage::helper('ops/payment')->shaCrypt($raw));
212
+
213
+ return $result;
214
+ }
215
+
216
+ /**
217
+ * Cleans param array from magentos admin params, fixes underscored keys
218
+ *
219
+ * @return array
220
+ */
221
+ protected function cleanParamKeys()
222
+ {
223
+ $data = array();
224
+ foreach ($this->_request->getParams() as $key => $value) {
225
+ if ($key == 'form_key' || $key == 'isAjax' || $key == 'key') {
226
+ continue;
227
+ }
228
+ $data[str_replace('_', '.', $key)] = $value;
229
+ }
230
+
231
+ return $data;
232
+ }
233
+ }
app/code/community/Netresearch/OPS/Trait/PaymentHelper.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * PaymentHelper.php
24
+ *
25
+ * @package Netresearch_OPS
26
+ * @author Paul Siedler <paul.siedler@netresearch.de>
27
+ */
28
+ ?>
29
+ <?php
30
+
31
+ trait Netresearch_OPS_Trait_PaymentHelper
32
+ {
33
+ protected $paymentHelper = null;
34
+
35
+ /**
36
+ * @return Netresearch_OPS_Helper_Payment
37
+ */
38
+ public function getPaymentHelper()
39
+ {
40
+ if (is_null($this->paymentHelper)) {
41
+ $this->paymentHelper = Mage::helper('ops/payment');
42
+ }
43
+
44
+ return $this->paymentHelper;
45
+ }
46
+
47
+ /**
48
+ * @param Netresearch_OPS_Helper_Payment $paymentHelper
49
+ *
50
+ * @returns $this
51
+ */
52
+ public function setPaymentHelper($paymentHelper)
53
+ {
54
+ $this->paymentHelper = $paymentHelper;
55
+
56
+ return $this;
57
+ }
58
+
59
+
60
+ }
app/code/community/Netresearch/OPS/controllers/Adminhtml/AliasController.php CHANGED
@@ -9,6 +9,10 @@
9
  */
10
  class Netresearch_OPS_Adminhtml_AliasController extends Mage_Adminhtml_Controller_Action
11
  {
 
 
 
 
12
  protected function _isAllowed()
13
  {
14
  return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
9
  */
10
  class Netresearch_OPS_Adminhtml_AliasController extends Mage_Adminhtml_Controller_Action
11
  {
12
+ use Netresearch_OPS_Trait_AliasController;
13
+
14
+ protected $_publicActions = array('accept', 'exception');
15
+
16
  protected function _isAllowed()
17
  {
18
  return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
app/code/community/Netresearch/OPS/controllers/Adminhtml/OpsstatusController.php CHANGED
@@ -16,7 +16,7 @@ class Netresearch_OPS_Adminhtml_OpsstatusController extends Mage_Adminhtml_Contr
16
  }
17
 
18
  /**
19
- * performs the status update call to Ingenico Payment Services
20
  */
21
  public function updateAction()
22
  {
16
  }
17
 
18
  /**
19
+ * performs the status update call to Ingenico ePayments
20
  */
21
  public function updateAction()
22
  {
app/code/community/Netresearch/OPS/controllers/AliasController.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * AliasController.php
5
+ *
6
+ * @author paul.siedler@netresearch.de
7
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
9
+ */
10
+ class Netresearch_OPS_AliasController extends Netresearch_OPS_Controller_Abstract
11
+ {
12
+ use Netresearch_OPS_Trait_AliasController;
13
+ }
app/code/community/Netresearch/OPS/controllers/ApiController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Netresearch_OPS_ApiController
4
  *
@@ -22,7 +23,10 @@ class Netresearch_OPS_ApiController extends Netresearch_OPS_Controller_Abstract
22
  {
23
  parent::preDispatch();
24
  if (!$this->_validateOPSData()) {
25
- throw new Exception ("Hash not valid");
 
 
 
26
  }
27
  }
28
 
@@ -33,18 +37,7 @@ class Netresearch_OPS_ApiController extends Netresearch_OPS_Controller_Abstract
33
  public function postBackAction()
34
  {
35
  $params = $this->getRequest()->getParams();
36
- if (Mage::app()->getStore()->getId() != $this->_getOrder()->getStoreId()) {
37
- $redirectRoute = Mage::getUrl(
38
- 'ops/api/postBack',
39
- array(
40
- '_store' => $this->_getOrder()->getStoreId(),
41
- '_nosid' => true,
42
- '_query' => $params
43
- )
44
- );
45
- $this->_redirectUrl($redirectRoute);
46
- return;
47
- }
48
  try {
49
  $status = $this->getPaymentHelper()->applyStateForOrder(
50
  $this->_getOrder(),
@@ -52,7 +45,14 @@ class Netresearch_OPS_ApiController extends Netresearch_OPS_Controller_Abstract
52
  );
53
  $redirectRoute = Mage::helper('ops/api')
54
  ->getRedirectRouteFromStatus($status);
55
- $this->_redirect($redirectRoute, array('_query' => $params));
 
 
 
 
 
 
 
56
  } catch (Exception $e) {
57
  Mage::helper('ops')->log(
58
  "Run into exception '{$e->getMessage()}' in postBackAction"
@@ -67,17 +67,28 @@ class Netresearch_OPS_ApiController extends Netresearch_OPS_Controller_Abstract
67
  */
68
  public function directLinkPostBackAction()
69
  {
 
70
  $params = $this->getRequest()->getParams();
 
 
 
 
 
 
71
  try {
72
- $this->getDirectlinkHelper()->processFeedback(
73
- $this->_getOrder(),
74
- $params
75
- );
 
 
 
 
76
  } catch (Exception $e) {
77
  Mage::helper('ops')->log(
78
  "Run into exception '{$e->getMessage()}' in directLinkPostBackAction"
79
  );
80
- throw ($e);
81
  }
82
  }
83
  }
1
  <?php
2
+
3
  /**
4
  * Netresearch_OPS_ApiController
5
  *
23
  {
24
  parent::preDispatch();
25
  if (!$this->_validateOPSData()) {
26
+ $this->getResponse()->setHttpResponseCode(422);
27
+ $this->setFlag('', self::FLAG_NO_DISPATCH, 1);
28
+
29
+ return;
30
  }
31
  }
32
 
37
  public function postBackAction()
38
  {
39
  $params = $this->getRequest()->getParams();
40
+
 
 
 
 
 
 
 
 
 
 
 
41
  try {
42
  $status = $this->getPaymentHelper()->applyStateForOrder(
43
  $this->_getOrder(),
45
  );
46
  $redirectRoute = Mage::helper('ops/api')
47
  ->getRedirectRouteFromStatus($status);
48
+
49
+ $this->_redirect(
50
+ $redirectRoute, array(
51
+ '_store' => $this->_getOrder()->getStoreId(),
52
+ '_query' => $params,
53
+ '_nosid' => true
54
+ )
55
+ );
56
  } catch (Exception $e) {
57
  Mage::helper('ops')->log(
58
  "Run into exception '{$e->getMessage()}' in postBackAction"
67
  */
68
  public function directLinkPostBackAction()
69
  {
70
+
71
  $params = $this->getRequest()->getParams();
72
+ Mage::log(
73
+ "Incoming Request on Directlink: " . serialize($params),
74
+ null,
75
+ 'incoming.log',
76
+ true
77
+ );
78
  try {
79
+ if (Mage::helper('ops/subscription')->isSubscriptionFeedback($params)) {
80
+ $this->getSubscriptionManager()->processSubscriptionFeedback($params);
81
+ } else {
82
+ $this->getDirectlinkHelper()->processFeedback(
83
+ $this->_getOrder(),
84
+ $params
85
+ );
86
+ }
87
  } catch (Exception $e) {
88
  Mage::helper('ops')->log(
89
  "Run into exception '{$e->getMessage()}' in directLinkPostBackAction"
90
  );
91
+ $this->getResponse()->setHttpResponseCode(500);
92
  }
93
  }
94
  }
app/code/community/Netresearch/OPS/controllers/DeviceController.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Netresearch_OPS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to
15
+ * newer versions in the future.
16
+ *
17
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
18
+ * @license Open Software License (OSL 3.0)
19
+ * @link http://opensource.org/licenses/osl-3.0.php
20
+ */
21
+
22
+ /**
23
+ * DeviceController.php
24
+ *
25
+ * @category controller
26
+ * @package Netresearch_OPS
27
+ * @author Paul Siedler <paul.siedler@netresearch.de>
28
+ */
29
+ ?>
30
+ <?php
31
+
32
+ class Netresearch_OPS_DeviceController extends Mage_Core_Controller_Front_Action
33
+ {
34
+
35
+ const CONSENT_PARAMETER_KEY = 'consent';
36
+
37
+ protected $config = null;
38
+
39
+ /**
40
+ * @return Netresearch_OPS_Model_Config
41
+ */
42
+ public function getConfig()
43
+ {
44
+ if (is_null($this->config)) {
45
+ $this->config = Mage::getModel('ops/config');
46
+ }
47
+
48
+ return $this->config;
49
+ }
50
+
51
+ /**
52
+ * Toggles the customers consent to transmit the generated deviceid to Ingenico ePayments
53
+ * to the value specified in request parameter consent
54
+ *
55
+ */
56
+ public function toggleConsentAction()
57
+ {
58
+ if ($this->getConfig()->getDeviceFingerPrinting()) {
59
+ $consent = (bool)$this->getRequest()->getParam(self::CONSENT_PARAMETER_KEY);
60
+ Mage::getSingleton('customer/session')
61
+ ->setData(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY, $consent);
62
+ }
63
+
64
+ $this->consentAction();
65
+ }
66
+
67
+ /**
68
+ * Returns the state of consent of the customer
69
+ */
70
+ public function consentAction()
71
+ {
72
+ $resultArray = array(self::CONSENT_PARAMETER_KEY => false);
73
+
74
+ if ($this->getConfig()->getDeviceFingerPrinting()) {
75
+ $resultArray[self::CONSENT_PARAMETER_KEY] = (bool)Mage::getSingleton('customer/session')
76
+ ->getData(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY);
77
+ }
78
+
79
+ $this->getResponse()->setHeader('Content-type', 'application/json');
80
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($resultArray));
81
+ }
82
+ }
app/code/community/Netresearch/OPS/controllers/PaymentController.php CHANGED
@@ -24,20 +24,6 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
24
  if ($lastIncrementId) {
25
  $order = Mage::getModel('sales/order');
26
  $order->loadByIncrementId($lastIncrementId);
27
-
28
- if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
29
- // update transactions, order state and add comments
30
- $order->getPayment()->setTransactionId($order->getQuoteId());
31
- $order->getPayment()->setIsTransactionClosed(false);
32
- $transaction = $order->getPayment()->addTransaction("authorization", null, true, $this->__("Process outgoing transaction"));
33
-
34
- if ($order->getId()) {
35
- $order->setState(
36
- Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('ops')->__('Start Ingenico Payment Services processing')
37
- );
38
- $order->save();
39
- }
40
- }
41
  }
42
 
43
  $this->_getCheckout()->getQuote()->setIsActive(false)->save();
@@ -76,66 +62,27 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
76
  */
77
  public function acceptAction()
78
  {
 
79
  try {
80
  $order = $this->_getOrder();
 
 
 
81
  $this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
82
  $this->_getCheckout()->setLastQuoteId($order->getQuoteId());
83
  $this->_getCheckout()->setLastOrderId($order->getId());
84
  } catch (Exception $e) {
 
85
  $helper = Mage::helper('ops');
86
  $helper->log($helper->__("Exception in acceptAction: " . $e->getMessage()));
87
  $this->getPaymentHelper()->refillCart($this->_getOrder());
88
- $this->_redirect('checkout/cart');
89
- return;
90
  }
91
- $this->_redirect('checkout/onepage/success');
92
- }
93
-
94
- /**
95
- * accept-action for Alias-generating iframe-response
96
- *
97
- */
98
- public function acceptAliasAction()
99
- {
100
- $helper = Mage::helper('ops');
101
- $helper->log($helper->__("Incoming accepted Ingenico Payment Services Alias Feedback\n\nRequest Path: %s\nParams: %s\n", $this->getRequest()->getPathInfo(), serialize($this->getRequest()->getParams())
102
- ));
103
- Mage::helper('ops/alias')->saveAlias($this->getRequest()->getParams());
104
- $result = array('result' => 'success', 'alias' => $this->_request->getParam('Alias'), 'CVC' => $this->_request->getParam('CVC'));
105
- $params = $this->getRequest()->getParams();
106
-
107
- if (array_key_exists('OrderID', $params)) {
108
- $quote = Mage::getModel('sales/quote')->load($params['OrderID']);
109
- $this->updateAdditionalInformation($quote, $params);
110
  }
111
 
112
- // OGNH-7 special handling for admin orders
113
- Mage::helper('ops/alias')->setAliasToPayment($this->getQuote()->getPayment(), array_change_key_case($this->getRequest()->getParams(), CASE_LOWER), false);
114
-
115
- return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
116
- }
117
-
118
- /**
119
- * updates the additional information from payment, thats needed for backend reOrders
120
- *
121
- * @param Mage_Sales_Model_Quote $quote
122
- * @param array $params
123
- */
124
- public function updateAdditionalInformation(Mage_Sales_Model_Quote $quote, $params)
125
- {
126
- if (!is_null($quote->getId()) && $quote->getPayment() && !is_null($quote->getPayment()->getId())) {
127
- $payment = $quote->getPayment();
128
- if (array_key_exists('Alias', $params)) {
129
- $payment->setAdditionalInformation('alias', $params['Alias']);
130
- }
131
- if (array_key_exists('Brand', $params)) {
132
- $payment->setAdditionalInformation('CC_BRAND', $params['Brand']);
133
- }
134
- if (array_key_exists('CN', $params)) {
135
- $payment->setAdditionalInformation('CC_CN', $params['CN']);
136
- }
137
- $quote->setPayment($payment)->save();
138
- }
139
  }
140
 
141
  /**
@@ -151,30 +98,8 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
151
  $this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
152
  $this->_getCheckout()->setLastQuoteId($order->getQuoteId());
153
  $this->_getCheckout()->setLastOrderId($order->getId());
154
- $this->_redirect('checkout/onepage/success');
155
- }
156
 
157
- /**
158
- * exception-action for Alias-generating iframe-response
159
- *
160
- */
161
- public function exceptionAliasAction()
162
- {
163
- $params = $this->getRequest()->getParams();
164
- $errors = array();
165
-
166
- foreach ($params as $key => $value) {
167
- if (stristr($key, 'error') && 0 != $value) {
168
- $errors[] = $value;
169
- }
170
- }
171
-
172
- $helper = Mage::helper('ops');
173
- $helper->log($helper->__("Incoming exception Ingenico Payment Services Alias Feedback\n\nRequest Path: %s\nParams: %s\n", $this->getRequest()->getPathInfo(), serialize($params)
174
- ));
175
-
176
- $result = array('result' => 'failure', 'errors' => $errors);
177
- return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
178
  }
179
 
180
  /**
@@ -193,10 +118,12 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
193
 
194
  $this->getPaymentHelper()->refillCart($this->_getOrder());
195
 
196
- $message = Mage::helper('ops')->__('Your payment information was declined. Please select another payment method.');
 
 
197
  Mage::getSingleton('core/session')->addNotice($message);
198
-
199
- $this->_redirect('checkout/onepage');
200
  }
201
 
202
  /**
@@ -219,7 +146,10 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
219
  }
220
 
221
  $this->getPaymentHelper()->refillCart($this->_getOrder());
222
- $this->_redirect('checkout/cart');
 
 
 
223
  }
224
 
225
  /**
@@ -235,10 +165,11 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
235
  $this->getPaymentHelper()->refillCart($order);
236
  $redirect = $this->getRequest()->getParam('redirect');
237
  if ($redirect == 'catalog'): //In Case of "Back to Catalog" Button in OPS
238
- $this->_redirect('/');
239
  else: //In Case of Cancel Auto-Redirect or "Back to Merchant Shop" Button
240
- $this->_redirect('checkout/cart');
241
  endif;
 
242
  }
243
 
244
  /*
@@ -252,85 +183,6 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
252
  }
253
  }
254
 
255
- public function generateHashAction()
256
- {
257
- $config = Mage::getModel('ops/config');
258
- $storeId = null;
259
- $quoteId = $this->_request->getParam('orderid');
260
-
261
- $quote = Mage::getModel('sales/quote')->load($quoteId);
262
-
263
- if (is_null($quote->getId())) {
264
- $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
265
- }
266
-
267
- if (!is_null($quote->getId())) {
268
- $storeId = $quote->getStoreId();
269
- }
270
- if (false == is_null($this->_request->getParam('storeId'))) {
271
- $storeId = $this->_request->getParam('storeId');
272
- }
273
-
274
- if (!is_null($quote->getId()) && $quote->getPayment()) {
275
- $payment = $quote->getPayment();
276
- $payment->setAdditionalInformation('saveOpsAlias', 0);
277
- $payment->save();
278
- $quote->setPayment($payment)->save();
279
- }
280
-
281
- // OGNC-3 use main store id for orders from backend, since the feedback from Ingenico Payment Services could not be parsed in magento backend
282
- $aliasStoreId = $storeId;
283
- if (false == is_null($this->_request->getParam('isAdmin')) && $this->_request->getParam('isAdmin') == 1) {
284
- $aliasStoreId = 0;
285
- }
286
-
287
- $alias = $this->_request->getParam('alias');
288
- if (0 < strlen(trim($this->_request->getParam('storedAlias'))) && $this->_request->getParam('saveAlias')) {
289
- $isAliasValid = Mage::helper('ops/alias')->isAliasValidForAddresses(
290
- $quote->getCustomer()->getId(),
291
- trim($this->_request->getParam('storedAlias')),
292
- $quote->getBillingAddress(),
293
- $quote->getShippingAddress(),
294
- $quote->getStoreId()
295
- );
296
-
297
- if (true === $isAliasValid) {
298
- $alias = trim($this->_request->getParam('storedAlias'));
299
- }
300
- }
301
- $data = array(
302
- 'ACCEPTURL' => $config->getAliasAcceptUrl($aliasStoreId),
303
- 'ALIAS' => $alias,
304
- 'EXCEPTIONURL' => $config->getAliasExceptionUrl($aliasStoreId),
305
- 'ORDERID' => $quoteId,
306
- 'PARAMPLUS' => $this->_request->getParam('paramplus'),
307
- 'PSPID' => $config->getPSPID($storeId),
308
- );
309
- if (false == is_null($this->_request->getParam('brand'))) {
310
- $data['BRAND'] = $this->_request->getParam('brand');
311
- }
312
- if (array_key_exists('saveAlias', $this->getRequest()->getParams())) {
313
- $data['ALIASPERSISTEDAFTERUSE'] = $this->_request->getParam('saveAlias') ? 'Y' : 'N';
314
- }
315
-
316
- $secret = $config->getShaOutCode($storeId);
317
- $paymentHelper = Mage::helper('ops/payment');
318
- $raw = $paymentHelper->getSHAInSet($data, $secret);
319
-
320
- /* set wish to save payment information (Alias Manager) */
321
-
322
- if (!is_null($quote->getId()) && $quote->getPayment() && $this->_request->getParam('saveAlias')) {
323
- $payment = $quote->getPayment();
324
- $payment->setAdditionalInformation(
325
- 'saveOpsAlias', 1
326
- );
327
- $payment->save();
328
- $quote->setPayment($payment)->save();
329
- }
330
- $result = array('hash' => Mage::helper('ops/payment')->shaCrypt($raw), 'alias' => $alias);
331
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
332
- }
333
-
334
  public function registerDirectDebitPaymentAction()
335
  {
336
  $params = $this->getRequest()->getParams();
@@ -340,63 +192,32 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
340
  ->setHttpResponseCode(406)
341
  ->setBody($this->__(implode(PHP_EOL, $validator->getMessages())))
342
  ->sendHeaders();
 
343
  return;
344
  }
345
  $payment = $this->_getCheckout()->getQuote()->getPayment();
346
  $helper = Mage::helper('ops/directDebit');
347
  $payment = $helper->setDirectDebitDataToPayment($payment, $params);
348
 
349
-
350
  $payment->save();
351
 
352
  $this->getResponse()->sendHeaders();
353
  }
354
 
355
- public function saveAliasAction()
356
- {
357
-
358
- $userIsRegistering = false;
359
- if ($this->getQuote()->getCheckoutMethod() === Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER) {
360
- $userIsRegistering = true;
361
- }
362
- Mage::helper('ops/alias')->setAliasToPayment($this->getQuote()->getPayment(), $this->getRequest()->getParams(), $userIsRegistering, true);
363
- }
364
 
365
  public function saveCcBrandAction()
366
  {
367
  $brand = $this->_request->getParam('brand');
368
- $cn = $this->_request->getParam('cn');
369
-
370
  $payment = $this->getQuote()->getPayment();
371
  $payment->setAdditionalInformation('CC_BRAND', $brand);
372
- $payment->setAdditionalInformation('CC_CN', $cn);
373
  $payment->setDataChanges(true);
374
  $payment->save();
375
  Mage::helper('ops')->log('saved cc brand ' . $brand . ' for quote #' . $this->getQuote()->getId());
376
  $this->getResponse()->sendHeaders();
377
  }
378
 
379
- public function validateAction()
380
- {
381
- $quote = $this->_getCheckout()->getQuote();
382
- if ($quote->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
383
- $paramHelper = Mage::helper('ops/payment_request');
384
- $shippingParams = array();
385
- $billingParams = $paramHelper->getOwnerParams($quote, $quote->getBillingAddress());
386
- if ($quote->getShippingAddress()) {
387
- $shippingParams = $paramHelper->extractShipToParameters($quote->getShippingAddress(), $quote);
388
- }
389
- $params = array_merge($billingParams, $shippingParams);
390
- $validator = Mage::getModel('ops/validator_parameter_factory')->getValidatorFor(
391
- Netresearch_OPS_Model_Validator_Parameter_Factory::TYPE_REQUEST_PARAMS_VALIDATION
392
- );
393
- if (false == $validator->isValid($params)) {
394
- $result = Mage::helper('ops/validation_result')->getValidationFailedResult($validator->getMessages(), $quote);
395
- $this->getResponse()->setBody(Mage::helper('core/data')->jsonEncode($result));
396
- }
397
- }
398
- }
399
-
400
  /**
401
  * Action to retry paying the order on Ingenico
402
  *
@@ -422,13 +243,54 @@ class Netresearch_OPS_PaymentController extends Netresearch_OPS_Controller_Abstr
422
  $this->renderLayout();
423
 
424
  } else {
425
- $message = Mage::helper('ops')->__('Not possible to reenter the payment details for order %s', $order->getIncrementId());
 
 
426
  }
427
  }
428
  if ($message) {
429
  Mage::getSingleton('core/session')->addNotice($message);
430
- $this->_redirect('/');
431
  }
 
 
 
 
 
 
 
432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  }
434
  }
24
  if ($lastIncrementId) {
25
  $order = Mage::getModel('sales/order');
26
  $order->loadByIncrementId($lastIncrementId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
 
29
  $this->_getCheckout()->getQuote()->setIsActive(false)->save();
62
  */
63
  public function acceptAction()
64
  {
65
+ $redirect = '';
66
  try {
67
  $order = $this->_getOrder();
68
+ if($this->getQuote()){
69
+ $this->getQuote()->setIsActive(false)->save();
70
+ }
71
  $this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
72
  $this->_getCheckout()->setLastQuoteId($order->getQuoteId());
73
  $this->_getCheckout()->setLastOrderId($order->getId());
74
  } catch (Exception $e) {
75
+ /** @var Netresearch_OPS_Helper_Data $helper */
76
  $helper = Mage::helper('ops');
77
  $helper->log($helper->__("Exception in acceptAction: " . $e->getMessage()));
78
  $this->getPaymentHelper()->refillCart($this->_getOrder());
79
+ $redirect = 'checkout/cart';
 
80
  }
81
+ if ($redirect === '') {
82
+ $redirect = 'checkout/onepage/success';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
 
85
+ $this->redirectOpsRequest($redirect);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
 
88
  /**
98
  $this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
99
  $this->_getCheckout()->setLastQuoteId($order->getQuoteId());
100
  $this->_getCheckout()->setLastOrderId($order->getId());
 
 
101
 
102
+ $this->redirectOpsRequest('checkout/onepage/success');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
 
105
  /**
118
 
119
  $this->getPaymentHelper()->refillCart($this->_getOrder());
120
 
121
+ $message = Mage::helper('ops')->__(
122
+ 'Your payment information was declined. Please select another payment method.'
123
+ );
124
  Mage::getSingleton('core/session')->addNotice($message);
125
+ $redirect = 'checkout/onepage';
126
+ $this->redirectOpsRequest($redirect);
127
  }
128
 
129
  /**
146
  }
147
 
148
  $this->getPaymentHelper()->refillCart($this->_getOrder());
149
+
150
+ $redirect = 'checkout/cart';
151
+ $this->redirectOpsRequest($redirect);
152
+
153
  }
154
 
155
  /**
165
  $this->getPaymentHelper()->refillCart($order);
166
  $redirect = $this->getRequest()->getParam('redirect');
167
  if ($redirect == 'catalog'): //In Case of "Back to Catalog" Button in OPS
168
+ $redirect = '/';
169
  else: //In Case of Cancel Auto-Redirect or "Back to Merchant Shop" Button
170
+ $redirect = 'checkout/cart';
171
  endif;
172
+ $this->redirectOpsRequest($redirect);
173
  }
174
 
175
  /*
183
  }
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  public function registerDirectDebitPaymentAction()
187
  {
188
  $params = $this->getRequest()->getParams();
192
  ->setHttpResponseCode(406)
193
  ->setBody($this->__(implode(PHP_EOL, $validator->getMessages())))
194
  ->sendHeaders();
195
+
196
  return;
197
  }
198
  $payment = $this->_getCheckout()->getQuote()->getPayment();
199
  $helper = Mage::helper('ops/directDebit');
200
  $payment = $helper->setDirectDebitDataToPayment($payment, $params);
201
 
 
202
  $payment->save();
203
 
204
  $this->getResponse()->sendHeaders();
205
  }
206
 
 
 
 
 
 
 
 
 
 
207
 
208
  public function saveCcBrandAction()
209
  {
210
  $brand = $this->_request->getParam('brand');
211
+ $alias = $this->_request->getParam('alias');
 
212
  $payment = $this->getQuote()->getPayment();
213
  $payment->setAdditionalInformation('CC_BRAND', $brand);
214
+ $payment->setAdditionalInformation('alias', $alias);
215
  $payment->setDataChanges(true);
216
  $payment->save();
217
  Mage::helper('ops')->log('saved cc brand ' . $brand . ' for quote #' . $this->getQuote()->getId());
218
  $this->getResponse()->sendHeaders();
219
  }
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  /**
222
  * Action to retry paying the order on Ingenico
223
  *
243
  $this->renderLayout();
244
 
245
  } else {
246
+ $message = Mage::helper('ops')->__(
247
+ 'Not possible to reenter the payment details for order %s', $order->getIncrementId()
248
+ );
249
  }
250
  }
251
  if ($message) {
252
  Mage::getSingleton('core/session')->addNotice($message);
253
+ $this->redirectOpsRequest('/');
254
  }
255
+ }
256
+
257
+ protected function wasIframeRequest()
258
+ {
259
+ return $this->getConfig()->getConfigData('template', $this->_getOrder()->getStoreId())
260
+ === Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME;
261
+ }
262
 
263
+ /**
264
+ * Generates the Javascript snippet that move the redirect to the parent frame in iframe mode.
265
+ *
266
+ * @param $redirect
267
+ *
268
+ * @return string javascript snippet
269
+ */
270
+ protected function generateJavaScript($redirect)
271
+ {
272
+ $javascript
273
+ = "
274
+ <script type=\"text/javascript\">
275
+ window.top.location.href = '" . Mage::getUrl($redirect) . "'
276
+ </script>";
277
+
278
+ return $javascript;
279
+ }
280
+
281
+
282
+ /**
283
+ * Redirects the customer to the given redirect path or inserts the js-snippet needed for iframe template mode into
284
+ * the response instead
285
+ *
286
+ * @param $redirect
287
+ */
288
+ protected function redirectOpsRequest($redirect)
289
+ {
290
+ if ($this->wasIframeRequest()) {
291
+ $this->getResponse()->setBody($this->generateJavaScript($redirect));
292
+ } else {
293
+ $this->_redirect($redirect);
294
+ }
295
  }
296
  }
app/code/community/Netresearch/OPS/data/ops_setup/data-upgrade-15.11.09-16.03.09.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * data-upgrade-14.12.03-15.02.25.php
4
+ * @author paul.siedler@netresearch.de
5
+ * @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License
7
+ */
8
+
9
+ $aliasUrlPath = 'payment_services/ops/ops_alias_gateway';
10
+
11
+ $oldAliasUrl = Mage::getStoreConfig($aliasUrlPath, 0);
12
+ $newAliasUrl = str_replace('alias_gateway_utf8.asp', 'Tokenization/HostedPage', $oldAliasUrl);
13
+ Mage::getConfig()->saveConfig($aliasUrlPath, $newAliasUrl);
14
+
15
+ $websites = Mage::app()->getWebsites();
16
+
17
+ /** @var Mage_Core_Model_Website $website */
18
+ foreach($websites as $website){
19
+ $oldWebsiteAliasUrl = $website->getConfig($aliasUrlPath);
20
+ if(strlen($oldWebsiteAliasUrl) > 0 && $oldWebsiteAliasUrl != $oldAliasUrl){
21
+
22
+ $newWebsiteAliasUrl = str_replace('alias_gateway_utf8.asp', 'Tokenization/HostedPage', $oldWebsiteAliasUrl);
23
+ Mage::getConfig()->saveConfig($aliasUrlPath, $newWebsiteAliasUrl, 'websites', $website->getId());
24
+ }
25
+ /** @var Mage_Core_Model_Store $store */
26
+ foreach($website->getStores() as $store){
27
+ $oldStoreAliasUrl = Mage::getStoreConfig($aliasUrlPath, $store->getId());
28
+ if(strlen($oldStoreAliasUrl) > 0 && $oldStoreAliasUrl != $oldAliasUrl) {
29
+ $newStoreAliasUrl = str_replace('alias_gateway_utf8.asp', 'Tokenization/HostedPage', $oldStoreAliasUrl);
30
+ Mage::getConfig()->saveConfig($aliasUrlPath, $newStoreAliasUrl, 'stores', $store->getId());
31
+ }
32
+ }
33
+ }
34
+
35
+ Mage::getConfig()->cleanCache();
36
+
37
+
app/code/community/Netresearch/OPS/etc/config.xml CHANGED
@@ -19,7 +19,7 @@
19
  * versions in the future. If you wish to customize Magento for your
20
  * needs please refer to http://www.magentocommerce.com for more information.
21
  *
22
- * @category Mage
23
  * @package Netresearch_OPS
24
  * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
25
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
@@ -28,7 +28,7 @@
28
  <config>
29
  <modules>
30
  <Netresearch_OPS>
31
- <version>15.11.09</version>
32
  </Netresearch_OPS>
33
  </modules>
34
  <global>
@@ -63,7 +63,7 @@
63
  </ops>
64
  </blocks>
65
  <events>
66
- <!--frontend AND backend-->
67
  <checkout_type_onepage_save_order>
68
  <observers>
69
  <ops_observer>
@@ -75,13 +75,14 @@
75
  </checkout_type_onepage_save_order>
76
  <sales_order_payment_place_end>
77
  <observers>
78
- <ops_observer>
79
  <type>singleton</type>
80
  <class>ops/observer</class>
81
- <method>setOrderStateForDirectDebitsNl</method>
82
- </ops_observer>
83
  </observers>
84
  </sales_order_payment_place_end>
 
85
  <adminhtml_block_html_before>
86
  <observers>
87
  <ops_observer>
@@ -89,6 +90,11 @@
89
  <class>ops/observer</class>
90
  <method>updateOrderCancelButton</method>
91
  </ops_observer>
 
 
 
 
 
92
  </observers>
93
  </adminhtml_block_html_before>
94
 
@@ -118,14 +124,6 @@
118
  </add_cc_payment_method>
119
  </observers>
120
  </core_block_abstract_prepare_layout_before>
121
- <sales_order_save_before>
122
- <observers>
123
- <check_for_ops_status>
124
- <class>ops/observer</class>
125
- <method>checkForOpsStatus</method>
126
- </check_for_ops_status>
127
- </observers>
128
- </sales_order_save_before>
129
  </events>
130
  <resources>
131
  <!-- initialize sql upgrade setup -->
@@ -140,10 +138,15 @@
140
  <template>
141
  <email>
142
  <payment_services_ops_resendPaymentInfo_template module="ops" translate="label">
143
- <label>Ingenico Payment Services resend payment information</label>
144
  <file>ops/ops_email_resend_payment_info.html</file>
145
  <type>html</type>
146
  </payment_services_ops_resendPaymentInfo_template>
 
 
 
 
 
147
  </email>
148
  </template>
149
  </global>
@@ -152,7 +155,7 @@
152
  <adminhtml>
153
  <args>
154
  <modules>
155
- <ops before="Mage_Adminhtml">Netresearch_OPS_Adminhtml</ops>
156
  </modules>
157
  </args>
158
  </adminhtml>
@@ -173,18 +176,15 @@
173
  <class>ops/observer</class>
174
  <method>appendCheckBoxToRefundForm</method>
175
  </append_check_box_to_refund_form>
176
- <append_warning_for_openinvoice_refunds>
177
- <class>ops/observer</class>
178
- <method>appendWarningToRefundFormForOpenInvoiceNl</method>
179
- </append_warning_for_openinvoice_refunds>
180
  <show_warning_if_ops_transaction_is_closed>
181
  <class>ops/observer</class>
182
  <method>showWarningForClosedTransactions</method>
183
  </show_warning_if_ops_transaction_is_closed>
184
- <append_warning_for_openInvoice_payments>
 
185
  <class>ops/observer</class>
186
- <method>appendPartialCaptureWarningForOpenInvoice</method>
187
- </append_warning_for_openInvoice_payments>
188
  </observers>
189
  </core_block_abstract_to_html_after>
190
 
@@ -261,122 +261,130 @@
261
  </controller_action_postdispatch>
262
  </observers>
263
  </controller_action_postdispatch_checkout_onepage_savePayment>
 
 
 
 
 
 
 
 
264
  </events>
265
  </frontend>
266
 
267
  <default>
268
  <payment_services>
269
  <ops>
270
- <model>ops/payment_abstract</model>
271
- <title>Ingenico Payment Services</title>
272
- <secret_key backend_model="adminhtml/system_config_backend_encrypted"/>
273
- <payment_action>authorize</payment_action>
274
- <send_invoice>0</send_invoice>
275
- <template>ops</template>
276
- <mode>custom</mode>
 
277
  <url>
278
- <base_prod>https://secure.ogone.com/ncol/prod</base_prod>
279
  <base_test>https://secure.ogone.com/ncol/test</base_test>
 
280
  <ops_gateway>/orderstandard_utf8.asp</ops_gateway>
281
- <ops_alias_gateway>/alias_gateway_utf8.asp</ops_alias_gateway>
282
  <frontend_gateway>/orderstandard_utf8.asp</frontend_gateway>
283
  <directlink_gateway>/maintenancedirect.asp</directlink_gateway>
284
  <directlink_gateway_order>/orderdirect.asp</directlink_gateway_order>
285
  <directlink_maintenance_api>/querydirect.asp</directlink_maintenance_api>
286
  </url>
287
- <ops_gateway>https://secure.ogone.com/ncol/test/orderstandard_utf8.asp</ops_gateway>
288
- <ops_alias_gateway>https://secure.ogone.com/ncol/test/alias_gateway_utf8.asp</ops_alias_gateway>
289
- <frontend_gateway>https://secure.ogone.com/ncol/test/orderstandard_utf8.asp</frontend_gateway>
290
- <directlink_gateway>https://secure.ogone.com/ncol/test/maintenancedirect.asp</directlink_gateway>
291
- <directlink_gateway_order>https://secure.ogone.com/ncol/test/orderdirect.asp</directlink_gateway_order>
292
- <directlink_maintenance_api>https://secure.ogone.com/ncol/test/querydirect.asp</directlink_maintenance_api>
293
- <showcatalogbutton>1</showcatalogbutton>
294
- <showhomebutton>1</showhomebutton>
295
- <support_mail>support@ecom.ingenico.com</support_mail>
296
- <doc_link_de></doc_link_de>
297
- <doc_link_en>http://payment-services.ingenico.com/en/ogone/support/guides/integration%20guides/magento-extension</doc_link_en>
298
- <faq_link_de>http://de.nr-apps.com/faq/ingenico</faq_link_de>
299
- <faq_link_en>http://www.nr-apps.com/faq/ingenico</faq_link_en>
300
- <redirectOrderReference>orderId</redirectOrderReference>
301
- <inlineOrderReference>orderId</inlineOrderReference>
302
- <showQuoteIdInOrderGrid>1</showQuoteIdInOrderGrid>
303
- <enableTrackingCode>0</enableTrackingCode>
304
- <devprefix></devprefix>
305
- <submitExtraParameters>1</submitExtraParameters>
306
- <paramLength>
307
- <ECOM_SHIPTO_POSTAL_NAME_FIRST>50</ECOM_SHIPTO_POSTAL_NAME_FIRST>
308
- <ECOM_SHIPTO_POSTAL_NAME_LAST>50</ECOM_SHIPTO_POSTAL_NAME_LAST>
309
- <ECOM_SHIPTO_POSTAL_STREET_LINE1>35</ECOM_SHIPTO_POSTAL_STREET_LINE1>
310
- <ECOM_SHIPTO_POSTAL_STREET_LINE2>35</ECOM_SHIPTO_POSTAL_STREET_LINE2>
311
- <ECOM_SHIPTO_POSTAL_STREET_LINE3>35</ECOM_SHIPTO_POSTAL_STREET_LINE3>
312
- <ECOM_SHIPTO_POSTAL_COUNTRYCODE>2</ECOM_SHIPTO_POSTAL_COUNTRYCODE>
313
- <ECOM_SHIPTO_POSTAL_COUNTY>25</ECOM_SHIPTO_POSTAL_COUNTY>
314
- <ECOM_SHIPTO_POSTAL_POSTALCODE>10</ECOM_SHIPTO_POSTAL_POSTALCODE>
315
- <ECOM_SHIPTO_POSTAL_CITY>25</ECOM_SHIPTO_POSTAL_CITY>
316
- <ECOM_SHIPTO_POSTAL_STREET_NUMBER>10</ECOM_SHIPTO_POSTAL_STREET_NUMBER>
317
- <CN>35</CN>
318
- <OWNERZIP>10</OWNERZIP>
319
- <OWNERCTY>2</OWNERCTY>
320
- <OWNERTOWN>40</OWNERTOWN>
321
- <OWNERTELNO>30</OWNERTELNO>
322
- <OWNERADDRESS>35</OWNERADDRESS>
323
- <ECOM_BILLTO_POSTAL_POSTALCODE>10</ECOM_BILLTO_POSTAL_POSTALCODE>
324
- </paramLength>
325
- <frontendFieldMapping>
326
- <CN>
327
- <firstname>billing:firstname</firstname>
328
- <lastname>billing:lastname</lastname>
329
- </CN>
330
- <OWNERZIP>billing:postcode</OWNERZIP>
331
- <OWNERCTY>billing:region_id</OWNERCTY>
332
- <OWNERTOWN>billing:city</OWNERTOWN>
333
- <OWNERTELNO>OWNERTELNO</OWNERTELNO>
334
- <OWNERADDRESS>billing:street1</OWNERADDRESS>
335
- <ECOM_BILLTO_POSTAL_POSTALCODE>billing:postcode</ECOM_BILLTO_POSTAL_POSTALCODE>
336
- <ECOM_SHIPTO_POSTAL_NAME_FIRST>shipping:firstname</ECOM_SHIPTO_POSTAL_NAME_FIRST>
337
- <ECOM_SHIPTO_POSTAL_NAME_LAST>shipping:lastname</ECOM_SHIPTO_POSTAL_NAME_LAST>
338
- <ECOM_SHIPTO_POSTAL_STREET1>shipping:street1</ECOM_SHIPTO_POSTAL_STREET1>
339
- <ECOM_SHIPTO_POSTAL_STREET2>shipping:street2</ECOM_SHIPTO_POSTAL_STREET2>
340
- <ECOM_SHIPTO_POSTAL_STREET3>shipping:street3</ECOM_SHIPTO_POSTAL_STREET3>
341
- <ECOM_SHIPTO_POSTAL_COUNTRYCODE>shipping:country_id</ECOM_SHIPTO_POSTAL_COUNTRYCODE>
342
- <ECOM_SHIPTO_POSTAL_COUNTY>shipping:region_id</ECOM_SHIPTO_POSTAL_COUNTY>
343
- <ECOM_SHIPTO_POSTAL_POSTALCODE>shipping:postcode</ECOM_SHIPTO_POSTAL_POSTALCODE>
344
- <ECOM_SHIPTO_POSTAL_CITY>shipping:city</ECOM_SHIPTO_POSTAL_CITY>
345
- <ECOM_SHIPTO_POSTAL_STREET_NUMBER>shipping:street</ECOM_SHIPTO_POSTAL_STREET_NUMBER>
346
- <ECOM_SHIPTO_POSTAL_POSTAL_STATE>shipping:region_id</ECOM_SHIPTO_POSTAL_POSTAL_STATE>
347
- </frontendFieldMapping>
348
- <resendPaymentInfo_identity>sales</resendPaymentInfo_identity>
349
- <resendPaymentInfo_template>payment_services_ops_resendPaymentInfo_template</resendPaymentInfo_template>
350
- <ops_state_restriction>1</ops_state_restriction>
 
 
 
 
 
 
 
351
  </ops>
352
  </payment_services>
353
  <payment>
354
- <ops_wallie>
355
- <title>Ingenico Payment Services Wallie</title>
356
- <model>ops/payment_wallie</model>
357
- </ops_wallie>
358
  <ops_directDebit>
359
- <title>Ingenico Payment Services DirectDebit</title>
360
  <model>ops/payment_directDebit</model>
361
  </ops_directDebit>
362
- <ops_tunz>
363
- <title>Ingenico Payment Services Tunz</title>
364
- <model>ops/payment_tunz</model>
365
- </ops_tunz>
366
  <ops_postFinanceEFinance>
367
- <title>Ingenico Payment Services PostFinanceEFinance</title>
368
  <model>ops/payment_postFinanceEFinance</model>
369
  </ops_postFinanceEFinance>
370
  <ops_eDankort>
371
- <title>Ingenico Payment Services EDankort</title>
372
  <model>ops/payment_eDankort</model>
373
  </ops_eDankort>
374
  <ops_kbcOnline>
375
- <title>Ingenico Payment Services KbcOnline</title>
376
  <model>ops/payment_kbcOnline</model>
377
  </ops_kbcOnline>
378
  <ops_iDeal>
379
- <title>Ingenico Payment Services IDeal</title>
380
  <model>ops/payment_iDeal</model>
381
  <issuer>
382
  <ABNANL2A>ABN AMRO</ABNANL2A>
@@ -385,17 +393,18 @@
385
  <SNSBNL2A>SNS Bank</SNSBNL2A>
386
  <RBRBNL21>Regio Bank</RBRBNL21>
387
  <ASNBNL21>ASN Bank</ASNBNL21>
 
388
  <TRIONL2U>Triodos Bank</TRIONL2U>
389
  <FVLBNL22>Van Lanschot Bankiers</FVLBNL22>
390
  <KNABNL2H>Knab Bank</KNABNL2H>
391
  </issuer>
392
  </ops_iDeal>
393
  <ops_belfiusDirectNet>
394
- <title>Ingenico Payment Services Belfius Direct Net</title>
395
  <model>ops/payment_belfiusDirectNet</model>
396
  </ops_belfiusDirectNet>
397
  <ops_bankTransfer>
398
- <title>Ingenico Payment Services BankTransfer</title>
399
  <model>ops/payment_bankTransfer</model>
400
  </ops_bankTransfer>
401
  <ops_openInvoiceDe>
@@ -411,89 +420,101 @@
411
  <allowspecific>1</allowspecific>
412
  <specificcountry>NL</specificcountry>
413
  </ops_openInvoiceNl>
 
 
 
 
 
 
 
414
  <ops_cbcOnline>
415
- <title>Ingenico Payment Services CbcOnline</title>
416
  <model>ops/payment_cbcOnline</model>
417
  </ops_cbcOnline>
418
  <ops_giroPay>
419
- <title>Ingenico Payment Services GiroPay</title>
420
  <model>ops/payment_giroPay</model>
421
  </ops_giroPay>
 
 
 
 
422
  <ops_interSolve>
423
- <title>Ingenico Payment Services InterSolve</title>
424
  <model>ops/payment_interSolve</model>
425
  </ops_interSolve>
426
  <ops_cashU>
427
- <title>Ingenico Payment Services CashU</title>
428
  <model>ops/payment_cashU</model>
429
  </ops_cashU>
430
  <ops_mpass>
431
- <title>Ingenico Payment Services Mpass</title>
432
  <model>ops/payment_mpass</model>
433
  </ops_mpass>
434
- <ops_miniTix>
435
- <title>Ingenico Payment Services MiniTix</title>
436
- <model>ops/payment_miniTix</model>
437
- </ops_miniTix>
438
- <ops_cod>
439
- <title>Ingenico Payment Services Cod</title>
440
- <model>ops/payment_cod</model>
441
- </ops_cod>
442
  <ops_paypal>
443
- <title>Ingenico Payment Services Paypal</title>
444
  <model>ops/payment_paypal</model>
445
  </ops_paypal>
446
  <ops_eps>
447
- <title>Ingenico Payment Services Eps</title>
448
  <model>ops/payment_eps</model>
449
  </ops_eps>
450
  <ops_pingPing>
451
- <title>Ingenico Payment Services PingPing</title>
452
  <model>ops/payment_pingPing</model>
453
  </ops_pingPing>
454
  <ops_fortisPayButton>
455
- <title>Ingenico Payment Services FortisPayButton</title>
456
  <model>ops/payment_fortisPayButton</model>
457
  </ops_fortisPayButton>
458
  <ops_directEbanking>
459
- <title>Ingenico Payment Services DirectEbanking</title>
460
  <model>ops/payment_directEbanking</model>
461
  </ops_directEbanking>
462
  <ops_cc>
463
- <title>Ingenico Payment Services Cc</title>
464
  <model>ops/payment_cc</model>
465
  <enabled_3dsecure>0</enabled_3dsecure>
466
  <redirect_all>0</redirect_all>
467
- <inline_types>American Express,Diners Club,MaestroUK,MasterCard,VISA,JCB</inline_types>
468
- <availableTypes>AIRPLUS,American Express,Aurore,BCMC,CB,Cofinoga,Dankort,Diners Club,JCB,Maestro,MaestroUK,MasterCard,PRIVILEGE,PostFinance card,UATP,UNEUROCOM,VISA</availableTypes>
469
  <show_alias_manager_info_for_guests>0</show_alias_manager_info_for_guests>
470
  </ops_cc>
 
 
 
 
 
 
 
 
 
471
  <ops_ingHomePay>
472
- <title>Ingenico Payment Services IngHomePay</title>
473
  <model>ops/payment_ingHomePay</model>
474
  </ops_ingHomePay>
475
  <ops_paysafecard>
476
- <title>Ingenico Payment Services Paysafecard</title>
477
  <model>ops/payment_paysafecard</model>
478
  </ops_paysafecard>
479
  <ops_kwixoCredit>
480
- <title>Ingenico Payment Services Kwixo Credit</title>
481
  <model>ops/payment_kwixoCredit</model>
482
  </ops_kwixoCredit>
483
  <ops_kwixoApresReception>
484
- <title>Ingenico Payment Services Kwixo Apres Reception</title>
485
  <model>ops/payment_KwixoApresReception</model>
486
  </ops_kwixoApresReception>
487
  <ops_kwixoComptant>
488
- <title>Ingenico Payment Services Kwixo Comptant</title>
489
  <model>ops/payment_KwixoComptant</model>
490
  </ops_kwixoComptant>
491
- <ops_other>
492
- <title>Additional Ingenico Payment Services payment methods</title>
493
- <model>ops/payment_Other</model>
494
- </ops_other>
495
  <ops_opsid>
496
- <title>Existing Ingenico Payment Services Transaction</title>
497
  <model>ops/payment_backend_opsId</model>
498
  </ops_opsid>
499
  <additional_params_required>
@@ -505,9 +526,22 @@
505
  </refund>
506
  </additional_params_required>
507
  <ops_chinaUnionPay>
508
- <title>VENDOR__ ChinaUnionPay</title>
509
  <model>ops/payment_chinaUnionPay</model>
510
  </ops_chinaUnionPay>
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  </payment>
512
 
513
  </default>
@@ -526,7 +560,7 @@
526
  <phpunit>
527
  <suite>
528
  <modules>
529
- <Netresearch_OPS />
530
  </modules>
531
  </suite>
532
  </phpunit>
19
  * versions in the future. If you wish to customize Magento for your
20
  * needs please refer to http://www.magentocommerce.com for more information.
21
  *
22
+ * @category Netresearch
23
  * @package Netresearch_OPS
24
  * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
25
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
28
  <config>
29
  <modules>
30
  <Netresearch_OPS>
31
+ <version>16.04.13</version>
32
  </Netresearch_OPS>
33
  </modules>
34
  <global>
63
  </ops>
64
  </blocks>
65
  <events>
66
+ <!--frontend AND backend-->
67
  <checkout_type_onepage_save_order>
68
  <observers>
69
  <ops_observer>
75
  </checkout_type_onepage_save_order>
76
  <sales_order_payment_place_end>
77
  <observers>
78
+ <ops_directLinkOrderState>
79
  <type>singleton</type>
80
  <class>ops/observer</class>
81
+ <method>setOrderStateDirectLink</method>
82
+ </ops_directLinkOrderState>
83
  </observers>
84
  </sales_order_payment_place_end>
85
+
86
  <adminhtml_block_html_before>
87
  <observers>
88
  <ops_observer>
90
  <class>ops/observer</class>
91
  <method>updateOrderCancelButton</method>
92
  </ops_observer>
93
+ <ops_profile_observer>
94
+ <type>singleton</type>
95
+ <class>ops/observer</class>
96
+ <method>updateRecurringProfileButtons</method>
97
+ </ops_profile_observer>
98
  </observers>
99
  </adminhtml_block_html_before>
100
 
124
  </add_cc_payment_method>
125
  </observers>
126
  </core_block_abstract_prepare_layout_before>
 
 
 
 
 
 
 
 
127
  </events>
128
  <resources>
129
  <!-- initialize sql upgrade setup -->
138
  <template>
139
  <email>
140
  <payment_services_ops_resendPaymentInfo_template module="ops" translate="label">
141
+ <label>Ingenico ePayments resend payment information</label>
142
  <file>ops/ops_email_resend_payment_info.html</file>
143
  <type>html</type>
144
  </payment_services_ops_resendPaymentInfo_template>
145
+ <payment_services_ops_suspendSubscription_template module="ops" translate="label">
146
+ <label>Ingenico ePayments suspend subscription request</label>
147
+ <file>ops/suspend_subscription.html</file>
148
+ <type>html</type>
149
+ </payment_services_ops_suspendSubscription_template>
150
  </email>
151
  </template>
152
  </global>
155
  <adminhtml>
156
  <args>
157
  <modules>
158
+ <ops after="Mage_Adminhtml">Netresearch_OPS_Adminhtml</ops>
159
  </modules>
160
  </args>
161
  </adminhtml>
176
  <class>ops/observer</class>
177
  <method>appendCheckBoxToRefundForm</method>
178
  </append_check_box_to_refund_form>
 
 
 
 
179
  <show_warning_if_ops_transaction_is_closed>
180
  <class>ops/observer</class>
181
  <method>showWarningForClosedTransactions</method>
182
  </show_warning_if_ops_transaction_is_closed>
183
+ <ops_profile_edit_observer>
184
+ <type>singleton</type>
185
  <class>ops/observer</class>
186
+ <method>updateRecurringProfileEditForm</method>
187
+ </ops_profile_edit_observer>
188
  </observers>
189
  </core_block_abstract_to_html_after>
190
 
261
  </controller_action_postdispatch>
262
  </observers>
263
  </controller_action_postdispatch_checkout_onepage_savePayment>
264
+ <model_save_before>
265
+ <observers>
266
+ <overwrite_recurring_profile_state>
267
+ <class>ops/observer</class>
268
+ <method>overrideRecurringProfileState</method>
269
+ </overwrite_recurring_profile_state>
270
+ </observers>
271
+ </model_save_before>
272
  </events>
273
  </frontend>
274
 
275
  <default>
276
  <payment_services>
277
  <ops>
278
+ <model>ops/payment_abstract</model>
279
+ <title>Ingenico ePayments</title>
280
+ <secret_key backend_model="adminhtml/system_config_backend_encrypted"/>
281
+ <secret_key_type>sha1</secret_key_type>
282
+ <payment_action>authorize</payment_action>
283
+ <send_invoice>0</send_invoice>
284
+ <template>ops</template>
285
+ <mode>custom</mode>
286
  <url>
 
287
  <base_test>https://secure.ogone.com/ncol/test</base_test>
288
+ <base_prod>https://secure.ogone.com/ncol/prod</base_prod>
289
  <ops_gateway>/orderstandard_utf8.asp</ops_gateway>
290
+ <ops_alias_gateway>/Tokenization/HostedPage</ops_alias_gateway>
291
  <frontend_gateway>/orderstandard_utf8.asp</frontend_gateway>
292
  <directlink_gateway>/maintenancedirect.asp</directlink_gateway>
293
  <directlink_gateway_order>/orderdirect.asp</directlink_gateway_order>
294
  <directlink_maintenance_api>/querydirect.asp</directlink_maintenance_api>
295
  </url>
296
+ <ops_gateway>https://secure.ogone.com/ncol/test/orderstandard_utf8.asp</ops_gateway>
297
+ <ops_alias_gateway>https://secure.ogone.com/ncol/test/Tokenization/HostedPage</ops_alias_gateway>
298
+ <frontend_gateway>https://secure.ogone.com/ncol/test/orderstandard_utf8.asp</frontend_gateway>
299
+ <directlink_gateway>https://secure.ogone.com/ncol/test/maintenancedirect.asp</directlink_gateway>
300
+ <directlink_gateway_order>https://secure.ogone.com/ncol/test/orderdirect.asp</directlink_gateway_order>
301
+ <directlink_maintenance_api>https://secure.ogone.com/ncol/test/querydirect.asp</directlink_maintenance_api>
302
+ <ops_alias_gateway_test>https://ogone.test.v-psp.com/Tokenization/HostedPage</ops_alias_gateway_test>
303
+ <showcatalogbutton>1</showcatalogbutton>
304
+ <showhomebutton>1</showhomebutton>
305
+ <support_mail>support@ecom.ingenico.com</support_mail>
306
+ <doc_link_de></doc_link_de>
307
+ <doc_link_en>http://payment-services.ingenico.com/en/ogone/support/guides/integration%20guides/magento-extension</doc_link_en>
308
+ <faq_link_de>http://de.nr-apps.com/faq/ingenico</faq_link_de>
309
+ <faq_link_en>http://www.nr-apps.com/faq/ingenico</faq_link_en>
310
+ <redirectOrderReference>orderId</redirectOrderReference>
311
+ <inlineOrderReference>orderId</inlineOrderReference>
312
+ <showQuoteIdInOrderGrid>1</showQuoteIdInOrderGrid>
313
+ <enableTrackingCode>0</enableTrackingCode>
314
+ <devprefix></devprefix>
315
+ <submitExtraParameters>1</submitExtraParameters>
316
+ <paramLength>
317
+ <ECOM_SHIPTO_POSTAL_NAME_FIRST>50</ECOM_SHIPTO_POSTAL_NAME_FIRST>
318
+ <ECOM_SHIPTO_POSTAL_NAME_LAST>50</ECOM_SHIPTO_POSTAL_NAME_LAST>
319
+ <ECOM_SHIPTO_POSTAL_STREET_LINE1>35</ECOM_SHIPTO_POSTAL_STREET_LINE1>
320
+ <ECOM_SHIPTO_POSTAL_STREET_LINE2>35</ECOM_SHIPTO_POSTAL_STREET_LINE2>
321
+ <ECOM_SHIPTO_POSTAL_STREET_LINE3>35</ECOM_SHIPTO_POSTAL_STREET_LINE3>
322
+ <ECOM_SHIPTO_POSTAL_COUNTRYCODE>2</ECOM_SHIPTO_POSTAL_COUNTRYCODE>
323
+ <ECOM_SHIPTO_POSTAL_COUNTY>25</ECOM_SHIPTO_POSTAL_COUNTY>
324
+ <ECOM_SHIPTO_POSTAL_POSTALCODE>10</ECOM_SHIPTO_POSTAL_POSTALCODE>
325
+ <ECOM_SHIPTO_POSTAL_CITY>25</ECOM_SHIPTO_POSTAL_CITY>
326
+ <ECOM_SHIPTO_POSTAL_STREET_NUMBER>10</ECOM_SHIPTO_POSTAL_STREET_NUMBER>
327
+ <CN>35</CN>
328
+ <OWNERZIP>10</OWNERZIP>
329
+ <OWNERCTY>2</OWNERCTY>
330
+ <OWNERTOWN>40</OWNERTOWN>
331
+ <OWNERTELNO>30</OWNERTELNO>
332
+ <OWNERADDRESS>35</OWNERADDRESS>
333
+ <ECOM_BILLTO_POSTAL_POSTALCODE>10</ECOM_BILLTO_POSTAL_POSTALCODE>
334
+ </paramLength>
335
+ <frontendFieldMapping>
336
+ <CN>
337
+ <firstname>billing:firstname</firstname>
338
+ <lastname>billing:lastname</lastname>
339
+ </CN>
340
+ <OWNERZIP>billing:postcode</OWNERZIP>
341
+ <OWNERCTY>billing:region_id</OWNERCTY>
342
+ <OWNERTOWN>billing:city</OWNERTOWN>
343
+ <OWNERTELNO>OWNERTELNO</OWNERTELNO>
344
+ <OWNERADDRESS>billing:street1</OWNERADDRESS>
345
+ <ECOM_BILLTO_POSTAL_POSTALCODE>billing:postcode</ECOM_BILLTO_POSTAL_POSTALCODE>
346
+ <ECOM_SHIPTO_POSTAL_NAME_FIRST>shipping:firstname</ECOM_SHIPTO_POSTAL_NAME_FIRST>
347
+ <ECOM_SHIPTO_POSTAL_NAME_LAST>shipping:lastname</ECOM_SHIPTO_POSTAL_NAME_LAST>
348
+ <ECOM_SHIPTO_POSTAL_STREET1>shipping:street1</ECOM_SHIPTO_POSTAL_STREET1>
349
+ <ECOM_SHIPTO_POSTAL_STREET2>shipping:street2</ECOM_SHIPTO_POSTAL_STREET2>
350
+ <ECOM_SHIPTO_POSTAL_STREET3>shipping:street3</ECOM_SHIPTO_POSTAL_STREET3>
351
+ <ECOM_SHIPTO_POSTAL_COUNTRYCODE>shipping:country_id</ECOM_SHIPTO_POSTAL_COUNTRYCODE>
352
+ <ECOM_SHIPTO_POSTAL_COUNTY>shipping:region_id</ECOM_SHIPTO_POSTAL_COUNTY>
353
+ <ECOM_SHIPTO_POSTAL_POSTALCODE>shipping:postcode</ECOM_SHIPTO_POSTAL_POSTALCODE>
354
+ <ECOM_SHIPTO_POSTAL_CITY>shipping:city</ECOM_SHIPTO_POSTAL_CITY>
355
+ <ECOM_SHIPTO_POSTAL_STREET_NUMBER>shipping:street</ECOM_SHIPTO_POSTAL_STREET_NUMBER>
356
+ <ECOM_SHIPTO_POSTAL_POSTAL_STATE>shipping:region_id</ECOM_SHIPTO_POSTAL_POSTAL_STATE>
357
+ </frontendFieldMapping>
358
+ <resendPaymentInfo_identity>sales</resendPaymentInfo_identity>
359
+ <resendPaymentInfo_template>payment_services_ops_resendPaymentInfo_template</resendPaymentInfo_template>
360
+ <billing_day_month>15</billing_day_month>
361
+ <billing_day_week>0</billing_day_week>
362
+ <suspendSubscription_identity>sales</suspendSubscription_identity>
363
+ <suspendSubscription_template>payment_services_ops_suspendSubscription_template</suspendSubscription_template>
364
+ <device_fingerprinting>0</device_fingerprinting>
365
+ <ops_rtimeout>45</ops_rtimeout>
366
+ <creditdebit_split>0</creditdebit_split>
367
  </ops>
368
  </payment_services>
369
  <payment>
 
 
 
 
370
  <ops_directDebit>
371
+ <title>Ingenico ePayments DirectDebit</title>
372
  <model>ops/payment_directDebit</model>
373
  </ops_directDebit>
 
 
 
 
374
  <ops_postFinanceEFinance>
375
+ <title>Ingenico ePayments PostFinanceEFinance</title>
376
  <model>ops/payment_postFinanceEFinance</model>
377
  </ops_postFinanceEFinance>
378
  <ops_eDankort>
379
+ <title>Ingenico ePayments EDankort</title>
380
  <model>ops/payment_eDankort</model>
381
  </ops_eDankort>
382
  <ops_kbcOnline>
383
+ <title>Ingenico ePayments KbcOnline</title>
384
  <model>ops/payment_kbcOnline</model>
385
  </ops_kbcOnline>
386
  <ops_iDeal>
387
+ <title>Ingenico ePayments iDEAL</title>
388
  <model>ops/payment_iDeal</model>
389
  <issuer>
390
  <ABNANL2A>ABN AMRO</ABNANL2A>
393
  <SNSBNL2A>SNS Bank</SNSBNL2A>
394
  <RBRBNL21>Regio Bank</RBRBNL21>
395
  <ASNBNL21>ASN Bank</ASNBNL21>
396
+ <BUNQNL2A>Bunq</BUNQNL2A>
397
  <TRIONL2U>Triodos Bank</TRIONL2U>
398
  <FVLBNL22>Van Lanschot Bankiers</FVLBNL22>
399
  <KNABNL2H>Knab Bank</KNABNL2H>
400
  </issuer>
401
  </ops_iDeal>
402
  <ops_belfiusDirectNet>
403
+ <title>Ingenico ePayments Belfius Direct Net</title>
404
  <model>ops/payment_belfiusDirectNet</model>
405
  </ops_belfiusDirectNet>
406
  <ops_bankTransfer>
407
+ <title>Ingenico ePayments BankTransfer</title>
408
  <model>ops/payment_bankTransfer</model>
409
  </ops_bankTransfer>
410
  <ops_openInvoiceDe>
420
  <allowspecific>1</allowspecific>
421
  <specificcountry>NL</specificcountry>
422
  </ops_openInvoiceNl>
423
+ <ops_openInvoiceAt>
424
+ <title>Rechnung (Österreich)</title>
425
+ <model>ops/payment_openInvoiceAt</model>
426
+ <allow_discounted_carts>0</allow_discounted_carts>
427
+ <allowspecific>1</allowspecific>
428
+ <specificcountry>AT</specificcountry>
429
+ </ops_openInvoiceAt>
430
  <ops_cbcOnline>
431
+ <title>Ingenico ePayments CbcOnline</title>
432
  <model>ops/payment_cbcOnline</model>
433
  </ops_cbcOnline>
434
  <ops_giroPay>
435
+ <title>Ingenico ePayments GiroPay</title>
436
  <model>ops/payment_giroPay</model>
437
  </ops_giroPay>
438
+ <ops_Masterpass>
439
+ <title>Ingenico ePayments Masterpass</title>
440
+ <model>ops/payment_masterpass</model>
441
+ </ops_Masterpass>
442
  <ops_interSolve>
443
+ <title>Ingenico ePayments InterSolve</title>
444
  <model>ops/payment_interSolve</model>
445
  </ops_interSolve>
446
  <ops_cashU>
447
+ <title>Ingenico ePayments CashU</title>
448
  <model>ops/payment_cashU</model>
449
  </ops_cashU>
450
  <ops_mpass>
451
+ <title>Ingenico ePayments Mpass</title>
452
  <model>ops/payment_mpass</model>
453
  </ops_mpass>
 
 
 
 
 
 
 
 
454
  <ops_paypal>
455
+ <title>Ingenico ePayments Paypal</title>
456
  <model>ops/payment_paypal</model>
457
  </ops_paypal>
458
  <ops_eps>
459
+ <title>Ingenico ePayments Eps</title>
460
  <model>ops/payment_eps</model>
461
  </ops_eps>
462
  <ops_pingPing>
463
+ <title>Ingenico ePayments PingPing</title>
464
  <model>ops/payment_pingPing</model>
465
  </ops_pingPing>
466
  <ops_fortisPayButton>
467
+ <title>Ingenico ePayments FortisPayButton</title>
468
  <model>ops/payment_fortisPayButton</model>
469
  </ops_fortisPayButton>
470
  <ops_directEbanking>
471
+ <title>Ingenico ePayments SofortÜberweisung</title>
472
  <model>ops/payment_directEbanking</model>
473
  </ops_directEbanking>
474
  <ops_cc>
475
+ <title>Ingenico ePayments Cc</title>
476
  <model>ops/payment_cc</model>
477
  <enabled_3dsecure>0</enabled_3dsecure>
478
  <redirect_all>0</redirect_all>
479
+ <inline_types>American Express,Diners Club,Maestro,MaestroUK,MasterCard,VISA,JCB</inline_types>
480
+ <availableTypes>AIRPLUS,American Express,Aurore,CB,Cofinoga,Dankort,Diners Club,JCB,Maestro,MaestroUK,MasterCard,PRIVILEGE,PostFinance card,UATP,UNEUROCOM,VISA</availableTypes>
481
  <show_alias_manager_info_for_guests>0</show_alias_manager_info_for_guests>
482
  </ops_cc>
483
+ <ops_dc>
484
+ <title>Ingenico ePayments DebitCard</title>
485
+ <model>ops/payment_debitcard</model>
486
+ <enabled_3dsecure>0</enabled_3dsecure>
487
+ <redirect_all>0</redirect_all>
488
+ <inline_types>Maestro,MaestroUK,MasterCard,VISA</inline_types>
489
+ <availableTypes>Maestro,MaestroUK,MasterCard,VISA</availableTypes>
490
+ <show_alias_manager_info_for_guests>0</show_alias_manager_info_for_guests>
491
+ </ops_dc>
492
  <ops_ingHomePay>
493
+ <title>Ingenico ePayments IngHomePay</title>
494
  <model>ops/payment_ingHomePay</model>
495
  </ops_ingHomePay>
496
  <ops_paysafecard>
497
+ <title>Ingenico ePayments Paysafecard</title>
498
  <model>ops/payment_paysafecard</model>
499
  </ops_paysafecard>
500
  <ops_kwixoCredit>
501
+ <title>Ingenico ePayments Kwixo Credit</title>
502
  <model>ops/payment_kwixoCredit</model>
503
  </ops_kwixoCredit>
504
  <ops_kwixoApresReception>
505
+ <title>Ingenico ePayments Kwixo Apres Reception</title>
506
  <model>ops/payment_KwixoApresReception</model>
507
  </ops_kwixoApresReception>
508
  <ops_kwixoComptant>
509
+ <title>Ingenico ePayments Kwixo Comptant</title>
510
  <model>ops/payment_KwixoComptant</model>
511
  </ops_kwixoComptant>
512
+ <ops_flex>
513
+ <title>Additional Ingenico ePayments payment methods</title>
514
+ <model>ops/payment_Flex</model>
515
+ </ops_flex>
516
  <ops_opsid>
517
+ <title>Existing Ingenico ePayments Transaction</title>
518
  <model>ops/payment_backend_opsId</model>
519
  </ops_opsid>
520
  <additional_params_required>
526
  </refund>
527
  </additional_params_required>
528
  <ops_chinaUnionPay>
529
+ <title>Ingenico ePayments ChinaUnionPay</title>
530
  <model>ops/payment_chinaUnionPay</model>
531
  </ops_chinaUnionPay>
532
+ <ops_recurring_cc>
533
+ <active>0</active>
534
+ <title>Ingenico ePayments Subscription Manager via Cc</title>
535
+ <model>ops/payment_recurring_cc</model>
536
+ <enabled_3dsecure>0</enabled_3dsecure>
537
+ <availableTypes>American Express,Diners Club,MaestroUK,MasterCard,VISA,JCB</availableTypes>
538
+ <acceptedTypes>American Express,Diners Club,MaestroUK,MasterCard,VISA,JCB</acceptedTypes>
539
+ <show_alias_manager_info_for_guests>0</show_alias_manager_info_for_guests>
540
+ </ops_recurring_cc>
541
+ <ops_BCMC>
542
+ <title><![CDATA[Ingenico ePayments Bancontact/MisterCash]]></title>
543
+ <model>ops/payment_bancontact</model>
544
+ </ops_BCMC>
545
  </payment>
546
 
547
  </default>
560
  <phpunit>
561
  <suite>
562
  <modules>
563
+ <Netresearch_OPS/>
564
  </modules>
565
  </suite>
566
  </phpunit>
app/code/community/Netresearch/OPS/etc/system.xml CHANGED
@@ -37,7 +37,7 @@
37
  <show_in_store>1</show_in_store>
38
  <groups>
39
  <ops_support translate="label">
40
- <label>Ingenico Payment Services Information</label>
41
  <frontend_type>text</frontend_type>
42
  <frontend_model>ops/system_config_support</frontend_model>
43
  <sort_order>0</sort_order>
@@ -46,7 +46,7 @@
46
  <show_in_store>1</show_in_store>
47
  </ops_support>
48
  <ops translate="label comment" module="ops">
49
- <label>Ingenico Payment Services Account</label>
50
  <frontend_type>text</frontend_type>
51
  <sort_order>1</sort_order>
52
  <show_in_default>1</show_in_default>
@@ -81,10 +81,20 @@
81
  <show_in_website>1</show_in_website>
82
  <show_in_store>1</show_in_store>
83
  </pspid>
 
 
 
 
 
 
 
 
 
 
84
  <secret_key_in translate="label comment tooltip">
85
  <label>SHA-IN Pass phrase</label>
86
- <comment><![CDATA[Refer to Ingenico Payment Services's backend in section <em>Technical Information</em> on tab <em>Data and origin verification</em>.]]></comment>
87
- <tooltip><![CDATA[This must be identical to the value in the Ingenico Payment Services backend in section <em>Technical information</em> on tab <em>Data and origin verification</em>.]]></tooltip>
88
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
89
  <frontend_type>obscure</frontend_type>
90
  <sort_order>50</sort_order>
@@ -94,8 +104,8 @@
94
  </secret_key_in>
95
  <secret_key_out translate="label comment tooltip">
96
  <label>SHA-OUT Pass phrase</label>
97
- <comment><![CDATA[Refer to Ingenico Payment Services's backend in section <em>Technical Information</em> on tab <em>Transaction feedback</em>.]]></comment>
98
- <tooltip><![CDATA[This must be identical to the value in the Ingenico Payment Services backend in section <em>Technical information</em> on tab <em>Transaction feedback</em>.]]></tooltip>
99
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
100
  <frontend_type>obscure</frontend_type>
101
  <sort_order>60</sort_order>
@@ -105,7 +115,7 @@
105
  </secret_key_out>
106
  <mode translate="label comment tooltip">
107
  <label>Mode</label>
108
- <tooltip><![CDATA[Depending on the selection the extension will communicate with the Ingenico Payment Services test or production service. Choose custom, if you have to use special urls for the gateway.]]></tooltip>
109
  <sort_order>69</sort_order>
110
  <frontend_type>select</frontend_type>
111
  <source_model>ops/source_mode</source_model>
@@ -130,7 +140,7 @@
130
  <ops_alias_gateway translate="label comment">
131
  <label>Alias Gateway URL</label>
132
  <frontend_type>text</frontend_type>
133
- <comment><![CDATA[Test url example: https://secure.ogone.com/ncol/test/alias_gateway_utf8.asp<br />Production url example: https://secure.ogone.com/ncol/prod/alias_gateway_utf8.asp]]></comment>
134
  <sort_order>71</sort_order>
135
  <show_in_default>1</show_in_default>
136
  <show_in_website>1</show_in_website>
@@ -177,7 +187,7 @@
177
  </directlink_maintenance_api>
178
  <api_userid translate="label tooltip">
179
  <label>API User</label>
180
- <tooltip><![CDATA[Special user for API must be created in the Ingenico Payment Services backend in section <em>Users</em>.]]></tooltip>
181
  <frontend_type>text</frontend_type>
182
  <sort_order>85</sort_order>
183
  <show_in_default>1</show_in_default>
@@ -186,7 +196,7 @@
186
  </api_userid>
187
  <api_pswd translate="label tooltip">
188
  <label>API Password</label>
189
- <tooltip><![CDATA[Password which has been set in the Ingenico Payment Services backend for above API user.]]></tooltip>
190
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
191
  <frontend_type>obscure</frontend_type>
192
  <sort_order>88</sort_order>
@@ -196,7 +206,7 @@
196
  </api_pswd>
197
  <payment_action translate="label comment tooltip">
198
  <label>Payment Action</label>
199
- <tooltip><![CDATA[This setting will override the configuration in the Ingenico Payment Services backend in section <em>Technical information</em> on tab <em>Global transaction parameters</em>.]]></tooltip>
200
  <frontend_type>select</frontend_type>
201
  <source_model>ops/source_paymentAction</source_model>
202
  <sort_order>90</sort_order>
@@ -220,26 +230,42 @@
220
  <label>Payment Template</label>
221
  <frontend_type>select</frontend_type>
222
  <source_model>ops/source_template</source_model>
223
- <comment>If you choose "Ingenico Payment Services", you will need to fill in all the following fields.</comment>
 
 
224
  <sort_order>100</sort_order>
225
  <show_in_default>1</show_in_default>
226
  <show_in_website>1</show_in_website>
227
- <show_in_store>0</show_in_store>
 
228
  </template>
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  <html_title translate="label comment">
230
- <label>Title of the Ingenico Payment Services Template</label>
231
  <frontend_type>text</frontend_type>
232
  <sort_order>110</sort_order>
233
  <show_in_default>1</show_in_default>
234
  <show_in_website>1</show_in_website>
235
  <show_in_store>1</show_in_store>
236
  <depends>
237
- <template separator=",">ops</template>
238
  </depends>
239
  <validate>required-entry</validate>
240
  </html_title>
241
  <bgcolor translate="label comment">
242
- <label>Background Color of Ingenico Payment Services Template</label>
243
  <frontend_type>text</frontend_type>
244
  <comment><![CDATA[e.g: white]]></comment>
245
  <sort_order>130</sort_order>
@@ -247,12 +273,12 @@
247
  <show_in_website>1</show_in_website>
248
  <show_in_store>1</show_in_store>
249
  <depends>
250
- <template separator=",">ops</template>
251
  </depends>
252
  <validate>required-entry</validate>
253
  </bgcolor>
254
  <txtcolor translate="label comment">
255
- <label>Text Color of the Ingenico Payment Services Template</label>
256
  <frontend_type>text</frontend_type>
257
  <comment><![CDATA[e.g: black]]></comment>
258
  <sort_order>140</sort_order>
@@ -260,12 +286,12 @@
260
  <show_in_website>1</show_in_website>
261
  <show_in_store>1</show_in_store>
262
  <depends>
263
- <template separator=",">ops</template>
264
  </depends>
265
  <validate>required-entry</validate>
266
  </txtcolor>
267
  <tblbgcolor translate="label comment">
268
- <label>Table Background Color of the Ingenico Payment Services Template</label>
269
  <frontend_type>text</frontend_type>
270
  <comment><![CDATA[e.g: white]]></comment>
271
  <sort_order>150</sort_order>
@@ -273,12 +299,12 @@
273
  <show_in_website>1</show_in_website>
274
  <show_in_store>1</show_in_store>
275
  <depends>
276
- <template separator=",">ops</template>
277
  </depends>
278
  <validate>required-entry</validate>
279
  </tblbgcolor>
280
  <tbltxtcolor translate="label comment">
281
- <label>Table Text Color of the Ingenico Payment Services Template</label>
282
  <frontend_type>text</frontend_type>
283
  <comment><![CDATA[e.g: black]]></comment>
284
  <sort_order>160</sort_order>
@@ -286,7 +312,7 @@
286
  <show_in_website>1</show_in_website>
287
  <show_in_store>1</show_in_store>
288
  <depends>
289
- <template separator=",">ops</template>
290
  </depends>
291
  <validate>required-entry</validate>
292
  </tbltxtcolor>
@@ -299,7 +325,7 @@
299
  <show_in_website>1</show_in_website>
300
  <show_in_store>1</show_in_store>
301
  <depends>
302
- <template separator=",">ops</template>
303
  </depends>
304
  <validate>required-entry</validate>
305
  </showcatalogbutton>
@@ -312,24 +338,24 @@
312
  <show_in_website>1</show_in_website>
313
  <show_in_store>1</show_in_store>
314
  <depends>
315
- <template separator=",">ops</template>
316
  </depends>
317
  <validate>required-entry</validate>
318
  </showhomebutton>
319
  <buttonbgcolor translate="label">
320
- <label>Button Background Color of the Ingenico Payment Services Template</label>
321
  <frontend_type>text</frontend_type>
322
  <sort_order>170</sort_order>
323
  <show_in_default>1</show_in_default>
324
  <show_in_website>1</show_in_website>
325
  <show_in_store>1</show_in_store>
326
  <depends>
327
- <template separator=",">ops</template>
328
  </depends>
329
  <validate>required-entry</validate>
330
  </buttonbgcolor>
331
  <buttontxtcolor translate="label comment">
332
- <label>Button Text Color of the Ingenico Payment Services Template</label>
333
  <frontend_type>text</frontend_type>
334
  <comment><![CDATA[e.g: white]]></comment>
335
  <sort_order>180</sort_order>
@@ -337,12 +363,12 @@
337
  <show_in_website>1</show_in_website>
338
  <show_in_store>1</show_in_store>
339
  <depends>
340
- <template separator=",">ops</template>
341
  </depends>
342
  <validate>required-entry</validate>
343
  </buttontxtcolor>
344
  <fonttype translate="label comment">
345
- <label>Font Family of the Ingenico Payment Services Template</label>
346
  <frontend_type>text</frontend_type>
347
  <comment><![CDATA[e.g: Verdana]]></comment>
348
  <sort_order>190</sort_order>
@@ -350,12 +376,12 @@
350
  <show_in_website>1</show_in_website>
351
  <show_in_store>1</show_in_store>
352
  <depends>
353
- <template separator=",">ops</template>
354
  </depends>
355
  <validate>required-entry</validate>
356
  </fonttype>
357
  <logo translate="label comment">
358
- <label>Logo of the Ingenico Payment Services Template</label>
359
  <frontend_type>text</frontend_type>
360
  <comment>URL/filename of the logo. The URL must be absolute and stored on a secure server.</comment>
361
  <sort_order>200</sort_order>
@@ -363,7 +389,7 @@
363
  <show_in_website>1</show_in_website>
364
  <show_in_store>1</show_in_store>
365
  <depends>
366
- <template separator=",">ops</template>
367
  </depends>
368
  <validate>required-entry</validate>
369
  </logo>
@@ -376,7 +402,7 @@
376
  <show_in_website>1</show_in_website>
377
  <show_in_store>1</show_in_store>
378
  <depends>
379
- <template separator=",">ops</template>
380
  </depends>
381
  <validate>required-entry</validate>
382
  </pmlist>
@@ -409,15 +435,6 @@
409
  <show_in_website>1</show_in_website>
410
  <show_in_store>1</show_in_store>
411
  </showQuoteIdInOrderGrid>
412
- <enableTrackingCode translate="label">
413
- <label>Device ID</label>
414
- <frontend_type>select</frontend_type>
415
- <source_model>adminhtml/system_config_source_yesno</source_model>
416
- <sort_order>240</sort_order>
417
- <show_in_default>1</show_in_default>
418
- <show_in_website>1</show_in_website>
419
- <show_in_store>1</show_in_store>
420
- </enableTrackingCode>
421
  <submitExtraParameters translate="label comment tooltip">
422
  <label>Submit extra parameters</label>
423
  <tooltip><![CDATA[Only enable this if you wish to use Fraud Detection.]]></tooltip>
@@ -429,7 +446,7 @@
429
  <show_in_website>1</show_in_website>
430
  <show_in_store>1</show_in_store>
431
  </submitExtraParameters>
432
- <resendPaymentInfo_identity translate="label">
433
  <label>Resend payment information identity</label>
434
  <frontend_type>select</frontend_type>
435
  <source_model>adminhtml/system_config_source_email_identity</source_model>
@@ -439,7 +456,7 @@
439
  <show_in_store>1</show_in_store>
440
  <tooltip>Sender identity. See 'Store Email Adresses'.</tooltip>
441
  </resendPaymentInfo_identity>
442
- <resendPaymentInfo_template translate="label">
443
  <label>Resend payment information template</label>
444
  <frontend_type>select</frontend_type>
445
  <source_model>adminhtml/system_config_source_email_template</source_model>
@@ -447,61 +464,89 @@
447
  <show_in_default>1</show_in_default>
448
  <show_in_website>1</show_in_website>
449
  <show_in_store>1</show_in_store>
450
- <tooltip>The email template to use. Choose 'Default Template from Locale' to use Ingenico Payment Services extensions default template.</tooltip>
451
  </resendPaymentInfo_template>
452
- <ops_state_restriction translate="label tooltip">
453
- <label>Enable state restriction</label>
 
 
454
  <frontend_type>select</frontend_type>
455
  <source_model>adminhtml/system_config_source_yesno</source_model>
456
- <sort_order>270</sort_order>
457
- <tooltip>If enabled the order status changes that differ from the expected status of the order for the Ingenico Payment Services status will get reverted. This can cause conflicts if you use custom order statuses.</tooltip>
458
  <show_in_default>1</show_in_default>
459
  <show_in_website>0</show_in_website>
460
  <show_in_store>0</show_in_store>
461
- </ops_state_restriction>
462
- </fields>
463
- </ops>
464
- </groups>
465
- </payment_services>
466
- <payment>
467
- <groups>
468
- <ops_wallie translate="label">
469
- <label>Ingenico Payment Services Wallie</label>
470
- <sort_order>12</sort_order>
471
- <show_in_default>1</show_in_default>
472
- <show_in_website>1</show_in_website>
473
- <show_in_store>1</show_in_store>
474
- <fields>
475
- <active translate="label">
476
- <label>Enabled</label>
477
  <frontend_type>select</frontend_type>
478
  <source_model>adminhtml/system_config_source_yesno</source_model>
479
- <sort_order>1</sort_order>
480
  <show_in_default>1</show_in_default>
481
  <show_in_website>1</show_in_website>
482
- <show_in_store>0</show_in_store>
483
- </active>
484
- <title translate="label">
485
- <label>Title</label>
486
  <frontend_type>text</frontend_type>
487
- <sort_order>10</sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
  <show_in_default>1</show_in_default>
489
  <show_in_website>1</show_in_website>
490
  <show_in_store>1</show_in_store>
491
- <validate>required-entry</validate>
492
- </title>
493
- <sort_order translate="label">
494
- <label>Sort Order</label>
495
- <frontend_type>text</frontend_type>
496
- <sort_order>20</sort_order>
 
497
  <show_in_default>1</show_in_default>
498
  <show_in_website>1</show_in_website>
499
  <show_in_store>1</show_in_store>
500
- </sort_order>
 
501
  </fields>
502
- </ops_wallie>
 
 
 
 
 
503
  <ops_directDebit translate="label">
504
- <label>Ingenico Payment Services DirectDebit</label>
505
  <sort_order>12</sort_order>
506
  <show_in_default>1</show_in_default>
507
  <show_in_website>1</show_in_website>
@@ -557,43 +602,8 @@
557
  </backend_enabled>
558
  </fields>
559
  </ops_directDebit>
560
- <ops_tunz translate="label">
561
- <label>Ingenico Payment Services Tunz</label>
562
- <sort_order>12</sort_order>
563
- <show_in_default>1</show_in_default>
564
- <show_in_website>1</show_in_website>
565
- <show_in_store>1</show_in_store>
566
- <fields>
567
- <active translate="label">
568
- <label>Enabled</label>
569
- <frontend_type>select</frontend_type>
570
- <source_model>adminhtml/system_config_source_yesno</source_model>
571
- <sort_order>1</sort_order>
572
- <show_in_default>1</show_in_default>
573
- <show_in_website>1</show_in_website>
574
- <show_in_store>0</show_in_store>
575
- </active>
576
- <title translate="label">
577
- <label>Title</label>
578
- <frontend_type>text</frontend_type>
579
- <sort_order>10</sort_order>
580
- <show_in_default>1</show_in_default>
581
- <show_in_website>1</show_in_website>
582
- <show_in_store>1</show_in_store>
583
- <validate>required-entry</validate>
584
- </title>
585
- <sort_order translate="label">
586
- <label>Sort Order</label>
587
- <frontend_type>text</frontend_type>
588
- <sort_order>20</sort_order>
589
- <show_in_default>1</show_in_default>
590
- <show_in_website>1</show_in_website>
591
- <show_in_store>1</show_in_store>
592
- </sort_order>
593
- </fields>
594
- </ops_tunz>
595
  <ops_postFinanceEFinance translate="label">
596
- <label>Ingenico Payment Services PostFinanceEFinance</label>
597
  <sort_order>12</sort_order>
598
  <show_in_default>1</show_in_default>
599
  <show_in_website>1</show_in_website>
@@ -628,7 +638,7 @@
628
  </fields>
629
  </ops_postFinanceEFinance>
630
  <ops_eDankort translate="label">
631
- <label>Ingenico Payment Services EDankort</label>
632
  <sort_order>12</sort_order>
633
  <show_in_default>1</show_in_default>
634
  <show_in_website>1</show_in_website>
@@ -663,7 +673,7 @@
663
  </fields>
664
  </ops_eDankort>
665
  <ops_kbcOnline translate="label">
666
- <label>Ingenico Payment Services KbcOnline</label>
667
  <sort_order>12</sort_order>
668
  <show_in_default>1</show_in_default>
669
  <show_in_website>1</show_in_website>
@@ -698,7 +708,7 @@
698
  </fields>
699
  </ops_kbcOnline>
700
  <ops_iDeal translate="label">
701
- <label>Ingenico Payment Services IDeal</label>
702
  <sort_order>12</sort_order>
703
  <show_in_default>1</show_in_default>
704
  <show_in_website>1</show_in_website>
@@ -733,7 +743,7 @@
733
  </fields>
734
  </ops_iDeal>
735
  <ops_belfiusDirectNet translate="label">
736
- <label>Ingenico Payment Services Belfius Direct Net</label>
737
  <sort_order>12</sort_order>
738
  <show_in_default>1</show_in_default>
739
  <show_in_website>1</show_in_website>
@@ -768,7 +778,7 @@
768
  </fields>
769
  </ops_belfiusDirectNet>
770
  <ops_bankTransfer translate="label">
771
- <label>Ingenico Payment Services BankTransfer</label>
772
  <sort_order>12</sort_order>
773
  <show_in_default>1</show_in_default>
774
  <show_in_website>1</show_in_website>
@@ -816,7 +826,7 @@
816
  </fields>
817
  </ops_bankTransfer>
818
  <ops_openInvoiceDe translate="label">
819
- <label>Ingenico Payment Services Open Invoice DE</label>
820
  <sort_order>12</sort_order>
821
  <show_in_default>1</show_in_default>
822
  <show_in_website>1</show_in_website>
@@ -842,7 +852,7 @@
842
  <validate>required-entry</validate>
843
  </title>
844
  <allow_discounted_carts translate="label">
845
- <label>Title</label>
846
  <comment>Allow payment method for discounted carts. Please note that not all aquirers support transmission of discount items.</comment>
847
  <frontend_type>select</frontend_type>
848
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -861,8 +871,8 @@
861
  </sort_order>
862
  </fields>
863
  </ops_openInvoiceDe>
864
- <ops_openInvoiceNl translate="label">
865
- <label>Ingenico Payment Services Open Invoice NL</label>
866
  <sort_order>12</sort_order>
867
  <show_in_default>1</show_in_default>
868
  <show_in_website>1</show_in_website>
@@ -872,7 +882,7 @@
872
  <label>Enabled</label>
873
  <frontend_type>select</frontend_type>
874
  <source_model>adminhtml/system_config_source_yesno</source_model>
875
- <comment><![CDATA[Make sure that <em>gender</em> and <em>date of birth</em> are required fields in the checkout. Otherwise this payment method will not be displayed.<br />If AfterPay is the acquirer, it is not possible to perform partial captures.]]></comment>
876
  <sort_order>1</sort_order>
877
  <show_in_default>1</show_in_default>
878
  <show_in_website>1</show_in_website>
@@ -887,6 +897,16 @@
887
  <show_in_store>1</show_in_store>
888
  <validate>required-entry</validate>
889
  </title>
 
 
 
 
 
 
 
 
 
 
890
  <sort_order translate="label">
891
  <label>Sort Order</label>
892
  <frontend_type>text</frontend_type>
@@ -896,18 +916,19 @@
896
  <show_in_store>1</show_in_store>
897
  </sort_order>
898
  </fields>
899
- </ops_openInvoiceNl>
900
- <ops_cbcOnline translate="label">
901
- <label>Ingenico Payment Services CbcOnline</label>
902
  <sort_order>12</sort_order>
903
  <show_in_default>1</show_in_default>
904
  <show_in_website>1</show_in_website>
905
  <show_in_store>1</show_in_store>
906
  <fields>
907
- <active translate="label">
908
  <label>Enabled</label>
909
  <frontend_type>select</frontend_type>
910
  <source_model>adminhtml/system_config_source_yesno</source_model>
 
911
  <sort_order>1</sort_order>
912
  <show_in_default>1</show_in_default>
913
 
37
  <show_in_store>1</show_in_store>
38
  <groups>
39
  <ops_support translate="label">
40
+ <label>Ingenico ePayments Information</label>
41
  <frontend_type>text</frontend_type>
42
  <frontend_model>ops/system_config_support</frontend_model>
43
  <sort_order>0</sort_order>
46
  <show_in_store>1</show_in_store>
47
  </ops_support>
48
  <ops translate="label comment" module="ops">
49
+ <label>Ingenico ePayments Account</label>
50
  <frontend_type>text</frontend_type>
51
  <sort_order>1</sort_order>
52
  <show_in_default>1</show_in_default>
81
  <show_in_website>1</show_in_website>
82
  <show_in_store>1</show_in_store>
83
  </pspid>
84
+ <secret_key_type translate="label comment tooltip">
85
+ <label>Hash algorithm</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>ops/system_config_backend_hashMethods</source_model>
88
+ <sort_order>49</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>1</show_in_store>
92
+ <tooltip><![CDATA[This must be identical to the value in the Ingenico ePayments backend in section <em>Technical information</em> on tab <em>Global security parameters</em>.]]></tooltip>
93
+ </secret_key_type>
94
  <secret_key_in translate="label comment tooltip">
95
  <label>SHA-IN Pass phrase</label>
96
+ <comment><![CDATA[Refer to Ingenico ePayments's backend in section <em>Technical Information</em> on tab <em>Data and origin verification</em>.]]></comment>
97
+ <tooltip><![CDATA[This must be identical to the value in the Ingenico ePayments backend in section <em>Technical information</em> on tab <em>Data and origin verification</em>.]]></tooltip>
98
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
99
  <frontend_type>obscure</frontend_type>
100
  <sort_order>50</sort_order>
104
  </secret_key_in>
105
  <secret_key_out translate="label comment tooltip">
106
  <label>SHA-OUT Pass phrase</label>
107
+ <comment><![CDATA[Refer to Ingenico ePayments's backend in section <em>Technical Information</em> on tab <em>Transaction feedback</em>.]]></comment>
108
+ <tooltip><![CDATA[This must be identical to the value in the Ingenico ePayments backend in section <em>Technical information</em> on tab <em>Transaction feedback</em>.]]></tooltip>
109
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
110
  <frontend_type>obscure</frontend_type>
111
  <sort_order>60</sort_order>
115
  </secret_key_out>
116
  <mode translate="label comment tooltip">
117
  <label>Mode</label>
118
+ <tooltip><![CDATA[Depending on the selection the extension will communicate with the Ingenico ePayments test or production service. Choose custom, if you have to use special urls for the gateway.]]></tooltip>
119
  <sort_order>69</sort_order>
120
  <frontend_type>select</frontend_type>
121
  <source_model>ops/source_mode</source_model>
140
  <ops_alias_gateway translate="label comment">
141
  <label>Alias Gateway URL</label>
142
  <frontend_type>text</frontend_type>
143
+ <comment><![CDATA[Test url example: https://ogone.test.v-psp.com/Tokenization/HostedPage<br />Production url example: https://secure.ogone.com/Tokenization/HostedPage]]></comment>
144
  <sort_order>71</sort_order>
145
  <show_in_default>1</show_in_default>
146
  <show_in_website>1</show_in_website>
187
  </directlink_maintenance_api>
188
  <api_userid translate="label tooltip">
189
  <label>API User</label>
190
+ <tooltip><![CDATA[Special user for API must be created in the Ingenico ePayments backend in section <em>Users</em>.]]></tooltip>
191
  <frontend_type>text</frontend_type>
192
  <sort_order>85</sort_order>
193
  <show_in_default>1</show_in_default>
196
  </api_userid>
197
  <api_pswd translate="label tooltip">
198
  <label>API Password</label>
199
+ <tooltip><![CDATA[Password which has been set in the Ingenico ePayments backend for above API user.]]></tooltip>
200
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
201
  <frontend_type>obscure</frontend_type>
202
  <sort_order>88</sort_order>
206
  </api_pswd>
207
  <payment_action translate="label comment tooltip">
208
  <label>Payment Action</label>
209
+ <tooltip><![CDATA[This setting will override the configuration in the Ingenico ePayments backend in section <em>Technical information</em> on tab <em>Global transaction parameters</em>.]]></tooltip>
210
  <frontend_type>select</frontend_type>
211
  <source_model>ops/source_paymentAction</source_model>
212
  <sort_order>90</sort_order>
230
  <label>Payment Template</label>
231
  <frontend_type>select</frontend_type>
232
  <source_model>ops/source_template</source_model>
233
+ <comment>
234
+ <model>ops/system_config_template</model>
235
+ </comment>
236
  <sort_order>100</sort_order>
237
  <show_in_default>1</show_in_default>
238
  <show_in_website>1</show_in_website>
239
+ <show_in_store>1</show_in_store>
240
+ <tooltip><![CDATA[For an easier PCI compliance we recommend redirect mode, iFrame mode or dynamic template with the template hosted on Ingenico ePayments servers.]]></tooltip>
241
  </template>
242
+ <template_identifier translate="label comment">
243
+ <label>Template Identifier/Url</label>
244
+ <tooltip>Enter the TemplateRootId you received from Ingenico ePayments or the url to an external template.</tooltip>
245
+ <frontend_type>text</frontend_type>
246
+ <sort_order>102</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>1</show_in_store>
250
+ <depends>
251
+ <template>ops_template</template>
252
+ </depends>
253
+ <validate>required-entry</validate>
254
+ </template_identifier>
255
  <html_title translate="label comment">
256
+ <label>Title of the Ingenico ePayments Template</label>
257
  <frontend_type>text</frontend_type>
258
  <sort_order>110</sort_order>
259
  <show_in_default>1</show_in_default>
260
  <show_in_website>1</show_in_website>
261
  <show_in_store>1</show_in_store>
262
  <depends>
263
+ <template separator=",">ops,ops_iframe</template>
264
  </depends>
265
  <validate>required-entry</validate>
266
  </html_title>
267
  <bgcolor translate="label comment">
268
+ <label>Background Color of Ingenico ePayments Template</label>
269
  <frontend_type>text</frontend_type>
270
  <comment><![CDATA[e.g: white]]></comment>
271
  <sort_order>130</sort_order>
273
  <show_in_website>1</show_in_website>
274
  <show_in_store>1</show_in_store>
275
  <depends>
276
+ <template separator=",">ops,ops_iframe</template>
277
  </depends>
278
  <validate>required-entry</validate>
279
  </bgcolor>
280
  <txtcolor translate="label comment">
281
+ <label>Text Color of the Ingenico ePayments Template</label>
282
  <frontend_type>text</frontend_type>
283
  <comment><![CDATA[e.g: black]]></comment>
284
  <sort_order>140</sort_order>
286
  <show_in_website>1</show_in_website>
287
  <show_in_store>1</show_in_store>
288
  <depends>
289
+ <template separator=",">ops,ops_iframe</template>
290
  </depends>
291
  <validate>required-entry</validate>
292
  </txtcolor>
293
  <tblbgcolor translate="label comment">
294
+ <label>Table Background Color of the Ingenico ePayments Template</label>
295
  <frontend_type>text</frontend_type>
296
  <comment><![CDATA[e.g: white]]></comment>
297
  <sort_order>150</sort_order>
299
  <show_in_website>1</show_in_website>
300
  <show_in_store>1</show_in_store>
301
  <depends>
302
+ <template separator=",">ops,ops_iframe</template>
303
  </depends>
304
  <validate>required-entry</validate>
305
  </tblbgcolor>
306
  <tbltxtcolor translate="label comment">
307
+ <label>Table Text Color of the Ingenico ePayments Template</label>
308
  <frontend_type>text</frontend_type>
309
  <comment><![CDATA[e.g: black]]></comment>
310
  <sort_order>160</sort_order>
312
  <show_in_website>1</show_in_website>
313
  <show_in_store>1</show_in_store>
314
  <depends>
315
+ <template separator=",">ops,ops_iframe</template>
316
  </depends>
317
  <validate>required-entry</validate>
318
  </tbltxtcolor>
325
  <show_in_website>1</show_in_website>
326
  <show_in_store>1</show_in_store>
327
  <depends>
328
+ <template separator=",">ops,ops_iframe</template>
329
  </depends>
330
  <validate>required-entry</validate>
331
  </showcatalogbutton>
338
  <show_in_website>1</show_in_website>
339
  <show_in_store>1</show_in_store>
340
  <depends>
341
+ <template separator=",">ops,ops_iframe</template>
342
  </depends>
343
  <validate>required-entry</validate>
344
  </showhomebutton>
345
  <buttonbgcolor translate="label">
346
+ <label>Button Background Color of the Ingenico ePayments Template</label>
347
  <frontend_type>text</frontend_type>
348
  <sort_order>170</sort_order>
349
  <show_in_default>1</show_in_default>
350
  <show_in_website>1</show_in_website>
351
  <show_in_store>1</show_in_store>
352
  <depends>
353
+ <template separator=",">ops,ops_iframe</template>
354
  </depends>
355
  <validate>required-entry</validate>
356
  </buttonbgcolor>
357
  <buttontxtcolor translate="label comment">
358
+ <label>Button Text Color of the Ingenico ePayments Template</label>
359
  <frontend_type>text</frontend_type>
360
  <comment><![CDATA[e.g: white]]></comment>
361
  <sort_order>180</sort_order>
363
  <show_in_website>1</show_in_website>
364
  <show_in_store>1</show_in_store>
365
  <depends>
366
+ <template separator=",">ops,ops_iframe</template>
367
  </depends>
368
  <validate>required-entry</validate>
369
  </buttontxtcolor>
370
  <fonttype translate="label comment">
371
+ <label>Font Family of the Ingenico ePayments Template</label>
372
  <frontend_type>text</frontend_type>
373
  <comment><![CDATA[e.g: Verdana]]></comment>
374
  <sort_order>190</sort_order>
376
  <show_in_website>1</show_in_website>
377
  <show_in_store>1</show_in_store>
378
  <depends>
379
+ <template separator=",">ops,ops_iframe</template>
380
  </depends>
381
  <validate>required-entry</validate>
382
  </fonttype>
383
  <logo translate="label comment">
384
+ <label>Logo of the Ingenico ePayments Template</label>
385
  <frontend_type>text</frontend_type>
386
  <comment>URL/filename of the logo. The URL must be absolute and stored on a secure server.</comment>
387
  <sort_order>200</sort_order>
389
  <show_in_website>1</show_in_website>
390
  <show_in_store>1</show_in_store>
391
  <depends>
392
+ <template separator=",">ops,ops_iframe</template>
393
  </depends>
394
  <validate>required-entry</validate>
395
  </logo>
402
  <show_in_website>1</show_in_website>
403
  <show_in_store>1</show_in_store>
404
  <depends>
405
+ <template separator=",">ops,ops_iframe</template>
406
  </depends>
407
  <validate>required-entry</validate>
408
  </pmlist>
435
  <show_in_website>1</show_in_website>
436
  <show_in_store>1</show_in_store>
437
  </showQuoteIdInOrderGrid>
 
 
 
 
 
 
 
 
 
438
  <submitExtraParameters translate="label comment tooltip">
439
  <label>Submit extra parameters</label>
440
  <tooltip><![CDATA[Only enable this if you wish to use Fraud Detection.]]></tooltip>
446
  <show_in_website>1</show_in_website>
447
  <show_in_store>1</show_in_store>
448
  </submitExtraParameters>
449
+ <resendPaymentInfo_identity translate="label tooltip">
450
  <label>Resend payment information identity</label>
451
  <frontend_type>select</frontend_type>
452
  <source_model>adminhtml/system_config_source_email_identity</source_model>
456
  <show_in_store>1</show_in_store>
457
  <tooltip>Sender identity. See 'Store Email Adresses'.</tooltip>
458
  </resendPaymentInfo_identity>
459
+ <resendPaymentInfo_template translate="label tooltip">
460
  <label>Resend payment information template</label>
461
  <frontend_type>select</frontend_type>
462
  <source_model>adminhtml/system_config_source_email_template</source_model>
464
  <show_in_default>1</show_in_default>
465
  <show_in_website>1</show_in_website>
466
  <show_in_store>1</show_in_store>
467
+ <tooltip>The email template to use. Choose 'Default Template from Locale' to use Ingenico ePayments extensions default template.</tooltip>
468
  </resendPaymentInfo_template>
469
+ <device_fingerprinting translate="label tooltip comment">
470
+ <label>Enable device fingerprinting</label>
471
+ <comment>When enabling this, you still need to request the explicit consent of the customer in the checkout to transmit this data.</comment>
472
+ <tooltip>This functionality will transmit specific customer data as hash to Ingenico ePayments to identify the device from which the transaction was sent can be identified with the highest probability.</tooltip>
473
  <frontend_type>select</frontend_type>
474
  <source_model>adminhtml/system_config_source_yesno</source_model>
475
+ <sort_order>280</sort_order>
 
476
  <show_in_default>1</show_in_default>
477
  <show_in_website>0</show_in_website>
478
  <show_in_store>0</show_in_store>
479
+ </device_fingerprinting>
480
+ <ops_rtimeout translate="label tooltip comment">
481
+ <label>Timeout for transactions</label>
482
+ <comment>This value specifies the request timeout for that transaction. A value between 30 and 60 is possible.</comment>
483
+ <frontend_type>text</frontend_type>
484
+ <validate>validate-digits-range digits-range-30-60</validate>
485
+ <sort_order>290</sort_order>
486
+ <show_in_default>1</show_in_default>
487
+ <show_in_website>0</show_in_website>
488
+ <show_in_store>0</show_in_store>
489
+ </ops_rtimeout>
490
+ <creditdebit_split translate="label tooltip comment">
491
+ <label>Credit/Debit card Split</label>
492
+ <tooltip><![CDATA[If activated an extra parameter is transmitted to Ingenico ePayments for the Creditcard/Debitcard payment methods.]]></tooltip>
493
+ <comment><![CDATA[See also <a title='Split credit/debit cards' target='_blank' href='https://payment-services.ingenico.com/int/en/ogone/support/guides/integration%20guides/split-credit-debit-cards'>Ingenico ePayments documentation</a>.]]></comment>
 
494
  <frontend_type>select</frontend_type>
495
  <source_model>adminhtml/system_config_source_yesno</source_model>
496
+ <sort_order>300</sort_order>
497
  <show_in_default>1</show_in_default>
498
  <show_in_website>1</show_in_website>
499
+ <show_in_store>1</show_in_store>
500
+ </creditdebit_split>
501
+ <billing_day_month translate="label tooltip">
502
+ <label>Billing day for monthly subscriptions</label>
503
  <frontend_type>text</frontend_type>
504
+ <validate>validate-digits validate-digits-range digits-range-1-31</validate>
505
+ <sort_order>300</sort_order>
506
+ <tooltip>Determines the day of the month when a monthly subscription gets triggered.</tooltip>
507
+ <show_in_default>1</show_in_default>
508
+ <show_in_website>1</show_in_website>
509
+ <show_in_store>0</show_in_store>
510
+ </billing_day_month>
511
+ <billing_day_week translate="label tooltip">
512
+ <label>Billing day for weekly subscriptions</label>
513
+ <frontend_type>select</frontend_type>
514
+ <source_model>adminhtml/system_config_source_locale_weekdays</source_model>
515
+ <sort_order>310</sort_order>
516
+ <tooltip>Determines the day of the week when a weekly subscription gets triggered.</tooltip>
517
+ <show_in_default>1</show_in_default>
518
+ <show_in_website>1</show_in_website>
519
+ <show_in_store>0</show_in_store>
520
+ </billing_day_week>
521
+ <suspendSubscription_identity translate="label tooltip">
522
+ <label>Store contact responsible for subscription handling</label>
523
+ <frontend_type>select</frontend_type>
524
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
525
+ <sort_order>320</sort_order>
526
  <show_in_default>1</show_in_default>
527
  <show_in_website>1</show_in_website>
528
  <show_in_store>1</show_in_store>
529
+ <tooltip>This contact will receive the suspend/cancel requests for the subscriptions. See 'Store Email Adresses'.</tooltip>
530
+ </suspendSubscription_identity>
531
+ <suspendSubscription_template translate="label tooltip">
532
+ <label>E-Mail template for suspending/canceling a subscription</label>
533
+ <frontend_type>select</frontend_type>
534
+ <source_model>adminhtml/system_config_source_email_template</source_model>
535
+ <sort_order>330</sort_order>
536
  <show_in_default>1</show_in_default>
537
  <show_in_website>1</show_in_website>
538
  <show_in_store>1</show_in_store>
539
+ <tooltip>This e-mail template is used for the automatically generated e-mail that is getting sent to the corresponding contact, if a customer wants to cancel a subscription.</tooltip>
540
+ </suspendSubscription_template>
541
  </fields>
542
+ </ops>
543
+ </groups>
544
+ </payment_services>
545
+ <payment>
546
+ <groups>
547
+
548
  <ops_directDebit translate="label">
549
+ <label>Ingenico ePayments DirectDebit</label>
550
  <sort_order>12</sort_order>
551
  <show_in_default>1</show_in_default>
552
  <show_in_website>1</show_in_website>
602
  </backend_enabled>
603
  </fields>
604
  </ops_directDebit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
605
  <ops_postFinanceEFinance translate="label">
606
+ <label>Ingenico ePayments PostFinanceEFinance</label>
607
  <sort_order>12</sort_order>
608
  <show_in_default>1</show_in_default>
609
  <show_in_website>1</show_in_website>
638
  </fields>
639
  </ops_postFinanceEFinance>
640
  <ops_eDankort translate="label">
641
+ <label>Ingenico ePayments EDankort</label>
642
  <sort_order>12</sort_order>
643
  <show_in_default>1</show_in_default>
644
  <show_in_website>1</show_in_website>
673
  </fields>
674
  </ops_eDankort>
675
  <ops_kbcOnline translate="label">
676
+ <label>Ingenico ePayments KbcOnline</label>
677
  <sort_order>12</sort_order>
678
  <show_in_default>1</show_in_default>
679
  <show_in_website>1</show_in_website>
708
  </fields>
709
  </ops_kbcOnline>
710
  <ops_iDeal translate="label">
711
+ <label>Ingenico ePayments iDEAL</label>
712
  <sort_order>12</sort_order>
713
  <show_in_default>1</show_in_default>
714
  <show_in_website>1</show_in_website>
743
  </fields>
744
  </ops_iDeal>
745
  <ops_belfiusDirectNet translate="label">
746
+ <label>Ingenico ePayments Belfius Direct Net</label>
747
  <sort_order>12</sort_order>
748
  <show_in_default>1</show_in_default>
749
  <show_in_website>1</show_in_website>
778
  </fields>
779
  </ops_belfiusDirectNet>
780
  <ops_bankTransfer translate="label">
781
+ <label>Ingenico ePayments BankTransfer</label>
782
  <sort_order>12</sort_order>
783
  <show_in_default>1</show_in_default>
784
  <show_in_website>1</show_in_website>
826
  </fields>
827
  </ops_bankTransfer>
828
  <ops_openInvoiceDe translate="label">
829
+ <label>Ingenico ePayments Open Invoice DE</label>
830
  <sort_order>12</sort_order>
831
  <show_in_default>1</show_in_default>
832
  <show_in_website>1</show_in_website>
852
  <validate>required-entry</validate>
853
  </title>
854
  <allow_discounted_carts translate="label">
855
+ <label>Allow for discounted carts</label>
856
  <comment>Allow payment method for discounted carts. Please note that not all aquirers support transmission of discount items.</comment>
857
  <frontend_type>select</frontend_type>
858
  <source_model>adminhtml/system_config_source_yesno</source_model>
871
  </sort_order>
872
  </fields>
873
  </ops_openInvoiceDe>
874
+ <ops_openInvoiceAt translate="label">
875
+ <label>Ingenico ePayments Open Invoice AT</label>
876
  <sort_order>12</sort_order>
877
  <show_in_default>1</show_in_default>
878
  <show_in_website>1</show_in_website>
882
  <label>Enabled</label>
883
  <frontend_type>select</frontend_type>
884
  <source_model>adminhtml/system_config_source_yesno</source_model>
885
+ <comment><![CDATA[Make sure that <em>gender</em> and <em>date of birth</em> are required fields in the checkout. Otherwise this payment method will not be displayed.]]></comment>
886
  <sort_order>1</sort_order>
887
  <show_in_default>1</show_in_default>
888
  <show_in_website>1</show_in_website>
897
  <show_in_store>1</show_in_store>
898
  <validate>required-entry</validate>
899
  </title>
900
+ <allow_discounted_carts translate="label">
901
+ <label>Allow for discounted carts</label>
902
+ <comment>Allow payment method for discounted carts. Please note that not all aquirers support transmission of discount items.</comment>
903
+ <frontend_type>select</frontend_type>
904
+ <source_model>adminhtml/system_config_source_yesno</source_model>
905
+ <sort_order>10</sort_order>
906
+ <show_in_default>1</show_in_default>
907
+ <show_in_website>1</show_in_website>
908
+ <show_in_store>1</show_in_store>
909
+ </allow_discounted_carts>
910
  <sort_order translate="label">
911
  <label>Sort Order</label>
912
  <frontend_type>text</frontend_type>
916
  <show_in_store>1</show_in_store>
917
  </sort_order>
918
  </fields>
919
+ </ops_openInvoiceAt>
920
+ <ops_openInvoiceNl translate="label">
921
+ <label>Ingenico ePayments Open Invoice NL</label>
922
  <sort_order>12</sort_order>
923
  <show_in_default>1</show_in_default>
924
  <show_in_website>1</show_in_website>
925
  <show_in_store>1</show_in_store>
926
  <fields>
927
+ <active translate="label comment">
928
  <label>Enabled</label>
929
  <frontend_type>select</frontend_type>
930
  <source_model>adminhtml/system_config_source_yesno</source_model>
931
+ <comment><![CDATA[Make sure that <em>gender</em> and <em>date of birth</em> are required fields in the checkout. Otherwise this payment method will not be displayed.]]></comment>
932
  <sort_order>1</sort_order>
933
  <show_in_default>1</show_in_default>
934