Securetrading_Stpp - Version 3.0.0.0

Version Notes

The development version of the SecureTrading STPP Magento integration.

Download this release

Release Info

Developer PeteST
Extension Securetrading_Stpp
Version 3.0.0.0
Comparing to
See all releases


Version 3.0.0.0

Files changed (153) hide show
  1. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Order/View/Tab/Modifier.php +10 -0
  2. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Order/View/Tab/Transactions.php +22 -0
  3. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions.php +11 -0
  4. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Children.php +20 -0
  5. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Data/Abstract.php +49 -0
  6. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Data/Request.php +7 -0
  7. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Data/Response.php +7 -0
  8. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Grid.php +65 -0
  9. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Single.php +96 -0
  10. app/code/local/Securetrading/Stpp/Block/Adminhtml/System/Config/Fieldset/Fields.php +211 -0
  11. app/code/local/Securetrading/Stpp/Block/Adminhtml/System/Config/Group.php +10 -0
  12. app/code/local/Securetrading/Stpp/Block/Adminhtml/Widget/Grid/Column/Renderer/Parenttransactionreference.php +14 -0
  13. app/code/local/Securetrading/Stpp/Block/Payment/Direct/Form.php +81 -0
  14. app/code/local/Securetrading/Stpp/Block/Payment/Direct/Info.php +8 -0
  15. app/code/local/Securetrading/Stpp/Block/Payment/Direct/Post.php +23 -0
  16. app/code/local/Securetrading/Stpp/Block/Payment/Iframe.php +28 -0
  17. app/code/local/Securetrading/Stpp/Block/Payment/Info/Abstract.php +115 -0
  18. app/code/local/Securetrading/Stpp/Block/Payment/Location.php +13 -0
  19. app/code/local/Securetrading/Stpp/Block/Payment/Redirect/Form.php +12 -0
  20. app/code/local/Securetrading/Stpp/Block/Payment/Redirect/Info.php +8 -0
  21. app/code/local/Securetrading/Stpp/Block/Payment/Redirect/Post.php +32 -0
  22. app/code/local/Securetrading/Stpp/Helper/Data.php +5 -0
  23. app/code/local/Securetrading/Stpp/Model/Actions/Abstract.php +177 -0
  24. app/code/local/Securetrading/Stpp/Model/Actions/Direct.php +5 -0
  25. app/code/local/Securetrading/Stpp/Model/Actions/Redirect.php +64 -0
  26. app/code/local/Securetrading/Stpp/Model/Adminhtml/System/Config/Backend/Multiselect.php +15 -0
  27. app/code/local/Securetrading/Stpp/Model/Cron.php +32 -0
  28. app/code/local/Securetrading/Stpp/Model/Integration.php +265 -0
  29. app/code/local/Securetrading/Stpp/Model/Observer.php +65 -0
  30. app/code/local/Securetrading/Stpp/Model/Payment/Abstract.php +122 -0
  31. app/code/local/Securetrading/Stpp/Model/Payment/Direct.php +137 -0
  32. app/code/local/Securetrading/Stpp/Model/Payment/Direct/Session.php +7 -0
  33. app/code/local/Securetrading/Stpp/Model/Payment/Redirect.php +81 -0
  34. app/code/local/Securetrading/Stpp/Model/Payment/Redirect/Notification.php +7 -0
  35. app/code/local/Securetrading/Stpp/Model/Payment/Redirect/Request.php +29 -0
  36. app/code/local/Securetrading/Stpp/Model/Resource/Payment/Redirect/Notification.php +7 -0
  37. app/code/local/Securetrading/Stpp/Model/Resource/Payment/Redirect/Request.php +7 -0
  38. app/code/local/Securetrading/Stpp/Model/Resource/Payment/Redirect/Request/Collection.php +7 -0
  39. app/code/local/Securetrading/Stpp/Model/Resource/Transaction.php +9 -0
  40. app/code/local/Securetrading/Stpp/Model/Resource/Transaction/Collection.php +7 -0
  41. app/code/local/Securetrading/Stpp/Model/Resource/Transaction/Types.php +16 -0
  42. app/code/local/Securetrading/Stpp/Model/Resource/Transaction/Types/Collection.php +17 -0
  43. app/code/local/Securetrading/Stpp/Model/Source/Cardtypes.php +17 -0
  44. app/code/local/Securetrading/Stpp/Model/Source/Connection.php +17 -0
  45. app/code/local/Securetrading/Stpp/Model/Source/Paymentaction.php +12 -0
  46. app/code/local/Securetrading/Stpp/Model/Source/Settleduedate.php +17 -0
  47. app/code/local/Securetrading/Stpp/Model/Source/Settlestatus.php +19 -0
  48. app/code/local/Securetrading/Stpp/Model/Transaction.php +63 -0
  49. app/code/local/Securetrading/Stpp/Model/Transaction/Types.php +16 -0
  50. app/code/local/Securetrading/Stpp/Model/Transport.php +5 -0
  51. app/code/local/Securetrading/Stpp/controllers/Direct/PostController.php +33 -0
  52. app/code/local/Securetrading/Stpp/controllers/DirectController.php +19 -0
  53. app/code/local/Securetrading/Stpp/controllers/PaymentController.php +10 -0
  54. app/code/local/Securetrading/Stpp/controllers/Redirect/PostController.php +51 -0
  55. app/code/local/Securetrading/Stpp/controllers/RedirectController.php +22 -0
  56. app/code/local/Securetrading/Stpp/controllers/Sales/Order/CreateController.php +89 -0
  57. app/code/local/Securetrading/Stpp/controllers/Securetrading/TransactionsController.php +29 -0
  58. app/code/local/Securetrading/Stpp/etc/adminhtml.xml +28 -0
  59. app/code/local/Securetrading/Stpp/etc/config.xml +157 -0
  60. app/code/local/Securetrading/Stpp/etc/system.xml +546 -0
  61. app/code/local/Securetrading/Stpp/lib/Securetrading.php +79 -0
  62. app/code/local/Securetrading/Stpp/lib/code/core/Stpp.php +15 -0
  63. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Actions/Abstract.php +43 -0
  64. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Actions/BaseInterface.php +13 -0
  65. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/ActionsInterface.php +5 -0
  66. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Base.php +69 -0
  67. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/BaseInterface.php +6 -0
  68. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/BaseInterface.php +9 -0
  69. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/Stapi.php +69 -0
  70. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/Store.php +51 -0
  71. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/StoreInterface.php +9 -0
  72. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/Webservices.php +124 -0
  73. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Context.php +53 -0
  74. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/ContextInterface.php +9 -0
  75. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Facade.php +170 -0
  76. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Helper.php +174 -0
  77. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/HelperInterface.php +9 -0
  78. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Log.php +61 -0
  79. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/LogInterface.php +7 -0
  80. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Process.php +250 -0
  81. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/ProcessInterface.php +5 -0
  82. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Result.php +60 -0
  83. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/ResultInterface.php +14 -0
  84. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Send.php +121 -0
  85. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/SendInterface.php +5 -0
  86. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/Reader.php +182 -0
  87. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/ReaderInterface.php +5 -0
  88. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/Writer.php +540 -0
  89. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/WriterInterface.php +18 -0
  90. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Component/Abstract.php +33 -0
  91. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Component/BaseInterface.php +9 -0
  92. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Component/Store.php +31 -0
  93. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Config.php +54 -0
  94. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Data/Abstract.php +142 -0
  95. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Data/AbstractInterface.php +5 -0
  96. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Data/Request.php +183 -0
  97. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Data/Response.php +24 -0
  98. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Exception.php +31 -0
  99. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Facade.php +21 -0
  100. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Admin.php +200 -0
  101. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/AdminInterface.php +6 -0
  102. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Facade.php +11 -0
  103. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Frontend.php +103 -0
  104. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/FrontendInterface.php +7 -0
  105. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Helper.php +30 -0
  106. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/HelperInterface.php +6 -0
  107. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/ActionsInterface.php +8 -0
  108. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/Base.php +306 -0
  109. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/BaseInterface.php +8 -0
  110. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/Facade.php +65 -0
  111. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/Helper.php +45 -0
  112. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/HelperInterface.php +7 -0
  113. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/Result.php +17 -0
  114. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/ResultInterface.php +6 -0
  115. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Result/Abstract.php +36 -0
  116. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Result/AbstractInterface.php +10 -0
  117. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Types.php +230 -0
  118. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/TypesInterface.php +11 -0
  119. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Facade.php +33 -0
  120. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/Base.php +18 -0
  121. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/BaseInterface.php +5 -0
  122. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/User/Abstract.php +17 -0
  123. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/UserInterface.php +6 -0
  124. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/Writer/File.php +79 -0
  125. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/WriterInterface.php +5 -0
  126. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Translator/Base.php +150 -0
  127. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Translator/BaseInterface.php +5 -0
  128. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Xml/Writer.php +9 -0
  129. app/code/local/Securetrading/Stpp/lib/code/overrides/Magento/Utility/Facade.php +10 -0
  130. app/code/local/Securetrading/Stpp/lib/code/overrides/Magento/Utility/Log/Writer.php +7 -0
  131. app/code/local/Securetrading/Stpp/lib/stpp_logs/api.txt +0 -0
  132. app/code/local/Securetrading/Stpp/lib/stpp_logs/exception.txt +0 -0
  133. app/code/local/Securetrading/Stpp/lib/stpp_translations/core.php +166 -0
  134. app/code/local/Securetrading/Stpp/sql/securetrading_stpp/install-3.0.0.php +202 -0
  135. app/design/adminhtml/default/default/layout/securetrading.xml +31 -0
  136. app/design/adminhtml/default/default/template/securetrading/stpp/payment/direct/form.phtml +77 -0
  137. app/design/adminhtml/default/default/template/securetrading/stpp/payment/direct/info.phtml +15 -0
  138. app/design/adminhtml/default/default/template/securetrading/stpp/payment/redirect/form.phtml +0 -0
  139. app/design/adminhtml/default/default/template/securetrading/stpp/payment/redirect/info.phtml +15 -0
  140. app/design/adminhtml/default/default/template/securetrading/stpp/payment/redirect/post.phtml +14 -0
  141. app/design/adminhtml/default/default/template/securetrading/stpp/sales/transactions/single.phtml +102 -0
  142. app/design/adminhtml/default/default/template/securetrading/stpp/system/config/fieldset/fields.phtml +3 -0
  143. app/design/frontend/base/default/layout/securetrading.xml +62 -0
  144. app/design/frontend/base/default/template/securetrading/stpp/payment/direct/form.phtml +94 -0
  145. app/design/frontend/base/default/template/securetrading/stpp/payment/direct/info.phtml +13 -0
  146. app/design/frontend/base/default/template/securetrading/stpp/payment/direct/post.phtml +14 -0
  147. app/design/frontend/base/default/template/securetrading/stpp/payment/iframe.phtml +7 -0
  148. app/design/frontend/base/default/template/securetrading/stpp/payment/location.phtml +12 -0
  149. app/design/frontend/base/default/template/securetrading/stpp/payment/redirect/form.phtml +5 -0
  150. app/design/frontend/base/default/template/securetrading/stpp/payment/redirect/info.phtml +12 -0
  151. app/design/frontend/base/default/template/securetrading/stpp/payment/redirect/post.phtml +20 -0
  152. app/etc/modules/SecureTrading_Stpp.xml +8 -0
  153. package.xml +18 -0
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Order/View/Tab/Modifier.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Sales_Order_View_Tab_Modifier extends Mage_Core_Block_Abstract {
4
+ protected function _prepareLayout() {
5
+ if ($this->getLayout()->getBlock('sales_order_tabs')->getOrder()->getPayment()->getMethodInstance()->getIsSecuretradingPaymentMethod()) {
6
+ $this->getLayout()->getBlock('sales_order_tabs')->removeTab('order_transactions');
7
+ $this->getLayout()->getBlock('sales_order_tabs')->addTab('securetrading_order_transactions', 'securetrading_stpp/adminhtml_sales_order_view_tab_transactions');
8
+ }
9
+ }
10
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Order/View/Tab/Transactions.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Sales_Order_View_Tab_Transactions
4
+ extends Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Grid
5
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
+ {
7
+ public function getTabLabel() {
8
+ return Mage::helper('securetrading_stpp')->__('SecureTrading Transactions');
9
+ }
10
+
11
+ public function getTabTitle() {
12
+ return Mage::helper('securetrading_stpp')->__('SecureTrading Transactions');
13
+ }
14
+
15
+ public function isHidden() {
16
+ return false;
17
+ }
18
+
19
+ public function canShowTab() {
20
+ return true;
21
+ }
22
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+ public function __construct() {
5
+ $this->_blockGroup = 'securetrading_stpp';
6
+ $this->_controller = 'adminhtml_sales_transactions';
7
+ $this->_headerText = Mage::helper('securetrading_stpp')->__('Transactions');
8
+ parent::__construct();
9
+ $this->_removeButton('add');
10
+ }
11
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Children.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Children extends Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Grid {
4
+ public function _construct() {
5
+ $this->setPagerVisibility(false);
6
+ $this->setFilterVisibility(false);
7
+ }
8
+
9
+ protected function _prepareCollection() {
10
+ $transaction = Mage::registry('current_transaction');
11
+
12
+ if ($transaction === null) {
13
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('A transaction has not been set.'));
14
+ }
15
+
16
+ $collection = Mage::getResourceModel('securetrading_stpp/transaction_collection');
17
+ $collection->addFieldToFilter('parent_transaction_id', $transaction->getTransactionId());
18
+ $this->setCollection($collection);
19
+ }
20
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Data/Abstract.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Data_Abstract extends Mage_Adminhtml_Block_Widget_Grid {
4
+ protected function _construct() {
5
+ $this->setPagerVisibility(false);
6
+ $this->setFilterVisibility(false);
7
+ }
8
+
9
+ protected function _getTransaction() {
10
+ $transaction = Mage::registry('current_transaction');
11
+
12
+ if ($transaction === null) {
13
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('A transaction has not been set.'));
14
+ }
15
+ return $transaction;
16
+ }
17
+
18
+ protected function _prepareCollection() {
19
+ $collection = new Varien_Data_Collection();
20
+ foreach ($this->getTransactionAdditionalInfo() as $key => $value) {
21
+ $data = new Varien_Object(array('key' => $key, 'value' => $value));
22
+ $collection->addItem($data);
23
+ }
24
+
25
+ $this->setCollection($collection);
26
+ return parent::_prepareCollection();
27
+ }
28
+
29
+ protected function _prepareColumns() {
30
+ $this->addColumn('key', array(
31
+ 'header' => Mage::helper('securetrading_stpp')->__('Key'),
32
+ 'index' => 'key',
33
+ 'sortable' => false,
34
+ 'type' => 'text',
35
+ 'width' => '50%'
36
+ ));
37
+
38
+ $this->addColumn('value', array(
39
+ 'header' => Mage::helper('securetrading_stpp')->__('Value'),
40
+ 'index' => 'value',
41
+ 'sortable' => false,
42
+ 'type' => 'text',
43
+ 'escape' => true
44
+ ));
45
+ return parent::_prepareColumns();
46
+ }
47
+
48
+ abstract public function getTransactionAdditionalInfo();
49
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Data/Request.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Data_Request extends Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Data_Abstract {
4
+ public function getTransactionAdditionalInfo() {
5
+ return $this->_getTransaction()->getRequestData();
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Data/Response.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Data_Response extends Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Data_Abstract {
4
+ public function getTransactionAdditionalInfo() {
5
+ return $this->_getTransaction()->getResponseData();
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Grid.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+ public function __construct() {
5
+ parent::__construct();
6
+ $this->setId('securetrading_order_transactions');
7
+ $this->setUseAjax(true);
8
+ $this->setDefaultSort('transaction_id');
9
+ $this->setDefaultDir('DESC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+ protected function _prepareCollection() {
13
+ $collection = Mage::getResourceModel('securetrading_stpp/transaction_collection');
14
+
15
+ $order = Mage::registry('current_order');
16
+ if ($order) {
17
+ $collection->addFieldToFilter('order_id', $order->getId());
18
+ }
19
+
20
+ $this->setCollection($collection);
21
+ parent::_prepareCollection();
22
+ }
23
+
24
+ protected function _prepareColumns() {
25
+ $this->addColumn('transaction_id', array(
26
+ 'header' => Mage::helper('securetrading_stpp')->__('Transaction ID'),
27
+ 'index' => 'transaction_id',
28
+ ));
29
+ $this->addColumn('transaction_reference', array(
30
+ 'header' => Mage::helper('securetrading_stpp')->__('Transaction Reference'),
31
+ 'index' => 'transaction_reference',
32
+ ));
33
+ $this->addColumn('parent_transaction_reference', array(
34
+ 'header' => Mage::helper('securetrading_stpp')->__('Parent Transaction Reference'),
35
+ 'index' => 'parent_transaction_reference',
36
+ 'renderer' => 'securetrading_stpp/adminhtml_widget_grid_column_renderer_parenttransactionreference',
37
+ ));
38
+ $this->addColumn('request_type', array(
39
+ 'header' => Mage::helper('securetrading_stpp')->__('Request Type'),
40
+ 'index' => 'request_type',
41
+ 'type' => 'options',
42
+ 'options' => Mage::getModel('securetrading_stpp/transaction_types')->getCollection()->toSingleDimensionArray(),
43
+ ));
44
+ $this->addColumn('response_type', array(
45
+ 'header' => Mage::helper('securetrading_stpp')->__('Response Type'),
46
+ 'index' => 'response_type',
47
+ 'type' => 'options',
48
+ 'options' => Mage::getModel('securetrading_stpp/transaction_types')->getCollection()->toSingleDimensionArray(),
49
+ ));
50
+ $this->addColumn('error_code', array(
51
+ 'header' => Mage::helper('securetrading_stpp')->__('Error Code'),
52
+ 'index' => 'error_code',
53
+ 'type' => 'number',
54
+ ));
55
+ $this->addColumn('last_updated_at', array(
56
+ 'header' => Mage::helper('securetrading_stpp')->__('Last Updated At'),
57
+ 'index' => 'last_updated_at',
58
+ 'type' => 'datetime',
59
+ ));
60
+ }
61
+
62
+ public function getRowUrl($item) {
63
+ return $this->getUrl('*/securetrading_transactions/single', array('transaction_id' => $item->getId()));
64
+ }
65
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Single.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Single extends Mage_Adminhtml_Block_Widget_Container { //extends Mage_Page_Block_Html {//Mage_Core_Block_Abstract {
4
+ protected $_transaction;
5
+
6
+ protected function _construct() {
7
+ $transaction = Mage::registry('current_transaction');
8
+
9
+ if ($transaction === null) {
10
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('A transaction has not been set.'));
11
+ }
12
+
13
+ $this->setTransaction($transaction);
14
+
15
+ $backUrl = $this->getOrderId() ? $this->getUrl('*/sales_order/view/', array('order_id' => $this->getOrderId())) : $this->getUrl('*/securetrading_transactions');
16
+
17
+ $this->_addButton('back', array(
18
+ 'label' => Mage::helper('sales')->__('Back'),
19
+ 'onclick' => "setLocation('{$backUrl}')",
20
+ 'class' => 'back'
21
+ ));
22
+ }
23
+
24
+ public function getHeaderText() {
25
+ return sprintf('Transaction #%s', $this->getTransaction()->getTransactionReference());
26
+ }
27
+
28
+ public function getTransaction() {
29
+ if ($this->_transaction === null) {
30
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('The transaction has not been set.'));
31
+ }
32
+ return $this->_transaction;
33
+ }
34
+
35
+ public function setTransaction(Securetrading_Stpp_Model_Transaction $transaction) {
36
+ $this->_transaction = $transaction;
37
+ }
38
+
39
+ public function getTransactionReference() {
40
+ return $this->getTransaction()->getTransactionReference();
41
+ }
42
+
43
+ public function hasParentTransaction() {
44
+ return $this->getTransaction()->getParentTransactionId();
45
+ }
46
+
47
+ public function getParentTransactionId() {
48
+ return $this->getTransaction()->getParentTransactionId();
49
+ }
50
+
51
+ public function getParentTransactionReference() {
52
+ return $this->getTransaction()->getParentTransactionReference();
53
+ }
54
+
55
+ public function getRequestType() {
56
+ $requestType = $this->getTransaction()->getRequestType();
57
+ return Mage::getModel('securetrading_stpp/transaction_types')->load($requestType)->getTypeName();
58
+ }
59
+
60
+ public function getResponseType() {
61
+ $responseType = $this->getTransaction()->getResponseType();
62
+ return Mage::getModel('securetrading_stpp/transaction_types')->load($responseType)->getTypeName();
63
+ }
64
+
65
+ public function getErrorCode() {
66
+ return $this->getTransaction()->getErrorCode();
67
+ }
68
+
69
+ public function getLastUpdatedAt() {
70
+ return $this->getTransaction()->getLastUpdatedAt();
71
+ }
72
+
73
+ public function getOrderId() {
74
+ return $this->getTransaction()->getOrderId();
75
+ }
76
+
77
+ public function getOrderIncrementId() {
78
+ $orderId = $this->getOrderId();
79
+ $order = Mage::getModel('sales/order')->load($orderId);
80
+ return $order->getIncrementId();
81
+ }
82
+
83
+ public function getOrderUrl($orderId = '') {
84
+ $orderId = empty($orderId) ? $this->getOrderId() : $orderId;
85
+ return Mage::getUrl('*/sales_order/view', array('order_id' => $orderId));
86
+ }
87
+
88
+ public function getMystUrl() {
89
+ return 'https://myst.securetrading.net/transactions/singletransaction?transactionreference=' . urlencode($this->getTransactionReference());
90
+ }
91
+
92
+ public function getParentTransactionIdUrl($parentTransactionId = '') {
93
+ $parentTransactionId = empty($parentTransactionId) ? $this->getParentTransactionId() : $parentTransactionId;
94
+ return Mage::getModel('adminhtml/url')->getUrl('adminhtml/securetrading_transactions/single/', array('transaction_id' => $parentTransactionId));
95
+ }
96
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/System/Config/Fieldset/Fields.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_System_Config_Fieldset_Fields
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
5
+ implements Varien_Data_Form_Element_Renderer_Interface {
6
+
7
+ protected $_template = 'securetrading/stpp/system/config/fieldset/fields.phtml';
8
+
9
+ protected function _getCollapseState($element) {
10
+ return false;
11
+ }
12
+
13
+ protected function _getHeaderTitleHtml($element) {
14
+ return '
15
+ <div class="config-heading" >
16
+ <div class="heading">
17
+ <strong>' . $element->getLegend() . '</strong>
18
+ <span class="heading-intro">' . $element->getComment() . '</span>
19
+ </div>
20
+ <div class="button-container">
21
+ <button
22
+ type="button"
23
+ class="button"
24
+ id="' . $element->getHtmlId() . '-head"
25
+ onclick="paypalToggleSolution.call(this, \'' . $element->getHtmlId() . '\', \'' . $this->getUrl('*/*/state') . '\'); return false;"
26
+ >
27
+ <span class="state-closed">' . $this->__('Configure') . '</span>
28
+ <span class="state-opened">' . $this->__('Close') . '</span>
29
+ </button>
30
+ </div>
31
+ </div>
32
+ ';
33
+ }
34
+
35
+ protected function _getHeaderCommentHtml($element) {
36
+ return '';
37
+ }
38
+
39
+ public function render(Varien_Data_Form_Element_Abstract $element) {
40
+ $fields = Mage::getModel('securetrading_stpp/integration')->getAdminFields();
41
+ $matches = null;
42
+ foreach($element->getElements() as $e) {
43
+ if (preg_match('/^groups\[[^\[\]]+\]\[fields\]\[(.+)\]\[value\]/', $e->getName(), $matches)) {// removed $ in regex for groups[securetrading_stpp][fields][accepted_cards][value][]
44
+ $name = $matches[1];
45
+ switch($name) {
46
+ case 'site_reference':
47
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_ALL_SITE_REFERENCE);
48
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_ALL_SITE_REFERENCE);
49
+ break;
50
+ case 'payment_action':
51
+ $label = $this->__('Payment Action');
52
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_ALL_ENABLE_AUTHORIZE_ONLY);
53
+ break;
54
+ case 'settle_due_date':
55
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_ALL_SETTLE_DUE_DATE);
56
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_ALL_SETTLE_DUE_DATE);
57
+ break;
58
+ case 'settle_status':
59
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_ALL_SETTLE_STATUS);
60
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_ALL_SETTLE_STATUS);
61
+ break;
62
+ case 'interface':
63
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_ALL_INTERFACE);
64
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_ALL_INTERFACE);
65
+ break;
66
+ case 'use_site_security':
67
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_USE_SITE_SECURITY);
68
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_USE_SITE_SECURITY);
69
+ break;
70
+ case 'site_security_password':
71
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_SITE_SECURITY_PASSWORD);
72
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_SITE_SECURITY_PASSWORD);
73
+ break;
74
+ case 'use_notification_password':
75
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_USE_NOTIFICATION_HASH);
76
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_USE_NOTIFICATION_HASH);
77
+ break;
78
+ case 'notification_password':
79
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_NOTIFICATION_HASH_PASSWORD);
80
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_NOTIFICATION_HASH_PASSWORD);
81
+ break;
82
+ case 'parent_css':
83
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_PARENT_CSS);
84
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_PARENT_CSS);
85
+ break;
86
+ case 'child_css':
87
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_CHILD_CSS);
88
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_CHILD_CSS);
89
+ break;
90
+ case 'parent_js':
91
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_PARENT_JS);
92
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_PARENT_JS);
93
+ break;
94
+ case 'child_js':
95
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_CHILD_JS);
96
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_CHILD_JS);
97
+ break;
98
+ case 'use_api':
99
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_USE_API);
100
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_USE_API);
101
+ break;
102
+ case 'ppg_use_iframe':
103
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_USE_IFRAME);
104
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_USE_IFRAME);
105
+ break;
106
+ case 'connection':
107
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_CONNECTION);
108
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_CONNECTION);
109
+ break;
110
+ case 'use_3d_secure':
111
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_3D_SECURE);
112
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_3D_SECURE);
113
+ break;
114
+ case 'use_risk_decision':
115
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_RISK_DECISION);
116
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_RISK_DECISION);
117
+ break;
118
+ case 'use_card_store':
119
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_CARD_STORE);
120
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_CARD_STORE);
121
+ break;
122
+ case 'use_auto_card_store':
123
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_AUTO_CARD_STORE);
124
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_AUTO_CARD_STORE);
125
+ break;
126
+ case 'delay_risk_decision':
127
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_DELAY_RISK_DECISION);
128
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_DELAY_RISK_DECISION);
129
+ break;
130
+ case 'accepted_cards':
131
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_ACCEPTED_CARDS);
132
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_ACCEPTED_CARDS);
133
+ break;
134
+ case 'api_use_iframe':
135
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_IFRAME);
136
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_IFRAME);
137
+ break;
138
+ case 'stapi_alias':
139
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_STAPI_ALIAS);
140
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_STAPI_ALIAS);
141
+ break;
142
+ case 'stapi_host':
143
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_STAPI_HOST);
144
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_STAPI_HOST);
145
+ break;
146
+ case 'stapi_port':
147
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_STAPI_PORT);
148
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_STAPI_PORT);
149
+ break;
150
+ case 'ws_alias':
151
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_WS_ALIAS);
152
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_WS_ALIAS);
153
+ break;
154
+ case 'ws_username':
155
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_WS_USERNAME);
156
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_WS_USERNAME);
157
+ break;
158
+ case 'ws_password':
159
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_WS_PASSWORD);
160
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_WS_PASSWORD);
161
+ break;
162
+ case 'ws_verify_ca':
163
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_WS_VERIFY_SSL_CA);
164
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_WS_VERIFY_SSL_CA);
165
+ break;
166
+ case 'ws_ca_file':
167
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_WS_CA_FILE);
168
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_WS_CA_FILE);
169
+ break;
170
+ // The following are not retrieved from the framework but are here so the text is not duplicated across the different interfaces in system.xml.
171
+ case 'active':
172
+ $label = $this->__('Enabled');
173
+ $tooltip = $this->__('Enable or disable this payment method.');
174
+ break;
175
+ case 'title':
176
+ $label = $this->__('Title');
177
+ $tooltip = $this->__('The name of this payment method shown to your customers.');
178
+ break;
179
+ case 'description':
180
+ $label = $this->__('Description');
181
+ $tooltip = $this->__('The description of this payment method shown to your customers.');
182
+ break;
183
+ case 'allowspecific':
184
+ $label = $this->__('Applicable Countries');
185
+ $tooltip = $this->__('This payment method can be enabled for all countries or for a specified subset of countries.');
186
+ break;
187
+ case 'specificcountry':
188
+ $label = $this->__('Specific Countries');
189
+ $tooltip = $this->__('If \'Applicable Countries\' is set to \'Specific Countries\' this list will determine which country this payment method can be used in.');
190
+ break;
191
+ case 'ppg_iframe_height':
192
+ case 'api_iframe_height':
193
+ $label = $this->__('Iframe Height');
194
+ $tooltip = $this->__('The height of the iframe. Enter one or more numbers followed by "px" or "%".');
195
+ break;
196
+ case 'ppg_iframe_width':
197
+ case 'api_iframe_width':
198
+ $label = $this->__('Iframe Width');
199
+ $tooltip = $this->__('The width of the iframe. Enter one or more numbers followed by "px" or "%".');
200
+ break;
201
+ default:
202
+ $label = $e->getLabel();
203
+ $tooltip = $e->getTooltip();
204
+ break;
205
+ }
206
+ $e->setLabel($label)->setTooltip($tooltip);
207
+ }
208
+ }
209
+ return parent::render($element);
210
+ }
211
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/System/Config/Group.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_System_Config_Group extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
4
+ protected function _getHeaderCommentHtml($element) {
5
+ $image = $this->getSkinUrl('images/securetrading/stpp/st_logo_strapline_200_63.png');
6
+ $version = (string) Mage::getConfig()->getModuleConfig('Securetrading_Stpp')->version;
7
+ $comment = sprintf('<img src="%s" alt="SecureTrading" style="display: block; margin: 0 auto;" /><div class="comment"><b>Module Version:</b> %s</div>', $image, $version);
8
+ return $comment .= parent::_getHeaderCommentHtml($element);
9
+ }
10
+ }
app/code/local/Securetrading/Stpp/Block/Adminhtml/Widget/Grid/Column/Renderer/Parenttransactionreference.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Adminhtml_Widget_Grid_Column_Renderer_Parenttransactionreference extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+ protected function _getValue(Varien_Object $row) {
5
+ $ptr = '';
6
+ if ($row->getParentTransactionId()) {
7
+ $temp = Mage::getModel('securetrading_stpp/transaction')->load($row->getParentTransactionId())->getTransactionReference();
8
+ if (!empty($temp)) {
9
+ $ptr = $temp;
10
+ }
11
+ }
12
+ return $ptr;
13
+ }
14
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Direct/Form.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Direct_Form extends Mage_Payment_Block_Form {
4
+ public function _construct() {
5
+ $this->setTemplate('securetrading/stpp/payment/direct/form.phtml');
6
+ parent::_construct();
7
+ }
8
+
9
+ protected function _getIntegration() {
10
+ return $this->getMethod()->getIntegration();
11
+ }
12
+
13
+ public function getDescription() {
14
+ return $this->getMethod()->getConfigData('description');
15
+ }
16
+
17
+ public function getAcceptedCards() {
18
+ $method = $this->getMethod();
19
+ return $method->getIntegration()->getAcceptedCards($method->getConfigData('use_3d_secure'), $method->getConfigData('accepted_cards'));
20
+ }
21
+
22
+ public function getMonths() {
23
+ return $this->_getIntegration()->getMonths();
24
+ }
25
+
26
+ public function getStartYears() {
27
+ return $this->_getIntegration()->getStartYears();
28
+ }
29
+
30
+ public function getExpiryYears() {
31
+ return $this->_getIntegration()->getExpiryYears();
32
+ }
33
+
34
+ public function getCardTypeLabel() {
35
+ return $this->_getIntegration()->getCardTypeLabel();
36
+ }
37
+
38
+ public function getCardTypeDescription() {
39
+ return $this->_getIntegration()->getCardTypeDescription();
40
+ }
41
+
42
+ public function getCardNumberLabel() {
43
+ return $this->_getIntegration()->getCardNumberLabel();
44
+ }
45
+
46
+ public function getCardNumberDescription() {
47
+ return $this->_getIntegration()->getCardNumberDescription();
48
+ }
49
+
50
+ public function getCardStartDateLabel() {
51
+ return $this->_getIntegration()->getCardStartDateLabel();
52
+ }
53
+
54
+ public function getCardStartDateDescription() {
55
+ return $this->_getIntegration()->getCardStartDateDescription();
56
+ }
57
+
58
+ public function getCardExpiryDateLabel() {
59
+ return $this->_getIntegration()->getCardExpiryDateLabel();
60
+ }
61
+
62
+ public function getCardExpiryDateDescription() {
63
+ return $this->_getIntegration()->getCardExpiryDateDescription();
64
+ }
65
+
66
+ public function getCardSecurityCodeLabel() {
67
+ return $this->_getIntegration()->getCardSecurityCodeLabel();
68
+ }
69
+
70
+ public function getCardSecurityCodeDescription() {
71
+ return $this->_getIntegration()->getCardSecurityCodeDescription();
72
+ }
73
+
74
+ public function getCardIssueNumberLabel() {
75
+ return $this->_getIntegration()->getCardIssueNumberLabel();
76
+ }
77
+
78
+ public function getCardIssueNumberDescription() {
79
+ return $this->_getIntegration()->getCardIssueNumberDescription();
80
+ }
81
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Direct/Info.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Direct_Info extends Securetrading_Stpp_Block_Payment_Info_Abstract {
4
+ public function _construct() {
5
+ parent::_construct();
6
+ $this->setTemplate('securetrading/stpp/payment/direct/info.phtml');
7
+ }
8
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Direct/Post.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Direct_Post extends Mage_Core_Block_Template {
4
+ protected $_params;
5
+
6
+ protected function _construct() {
7
+ $session = Mage::getSingleton('securetrading_stpp/payment_direct_session');
8
+
9
+ if (!$session->hasAcsRedirectParams() || !($session->getAcsRedirectParams() instanceof Varien_Object)) {
10
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('The ACS parameters could not be retrieved correctly.'));
11
+ }
12
+
13
+ $this->_params = $session->getAcsRedirectParams();
14
+ }
15
+
16
+ public function getRedirectUrl() {
17
+ return $this->_params->getRedirectUrl();
18
+ }
19
+
20
+ public function getRedirectData() {
21
+ return $this->_params->getRedirectData();
22
+ }
23
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Iframe.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Iframe extends Mage_Page_Block_Html {
4
+ const REGISTRY_IFRAME_HEIGHT_KEY = 'securetrading_stpp_block_payment_redirect_post_iframe_height';
5
+ const REGISTRY_IFRAME_WIDTH_KEY = 'securetrading_stpp_block_payment_redirect_post_iframe_width';
6
+
7
+ protected $_src;
8
+
9
+ public function setSrcByRoute($route) {
10
+ $this->_src = Mage::getUrl($route);
11
+ return $this;
12
+ }
13
+
14
+ public function getSrc() {
15
+ if ($this->_src === null) {
16
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('The iframe source has not been set.'));
17
+ }
18
+ return $this->_src;
19
+ }
20
+
21
+ public function getWidth() {
22
+ return Mage::registry(self::REGISTRY_IFRAME_WIDTH_KEY);
23
+ }
24
+
25
+ public function getHeight() {
26
+ return Mage::registry(self::REGISTRY_IFRAME_HEIGHT_KEY);
27
+ }
28
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Info/Abstract.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Securetrading_Stpp_Block_Payment_Info_Abstract extends Mage_Payment_Block_Info {
4
+ public function _construct() {
5
+ parent::_construct();
6
+ }
7
+
8
+ public function getSpecific($key, $default = null) {
9
+ $specific = $this->getSpecificInformation();
10
+ if (array_key_exists($key, $specific) && !empty($specific[$key])) {
11
+ return $specific[$key];
12
+ }
13
+ return $default;
14
+ }
15
+
16
+ public function getAccountTypeDescription() {
17
+ return $this->getSpecific('account_type_description');
18
+ }
19
+
20
+ protected function _getSecurityCodeStyle($securityCode) {
21
+ if ($securityCode === '2') {
22
+ return 'color: #00AA00;';
23
+ }
24
+ return 'color: #FF0000;';
25
+ }
26
+
27
+ public function getSecurityAddress() {
28
+ return $this->getInfo()->getMethodInstance()->getIntegration()->getAvsString($this->getSpecific('security_address'));
29
+ }
30
+
31
+ public function getSecurityAddressStyle() {
32
+ return $this->_getSecurityCodeStyle($this->getSpecific('security_address'));
33
+ }
34
+
35
+ public function getSecurityPostcode() {
36
+ return $this->getInfo()->getMethodInstance()->getIntegration()->getAvsString($this->getSpecific('security_postcode'));
37
+ }
38
+
39
+ public function getSecurityPostcodeStyle() {
40
+ return $this->_getSecurityCodeStyle($this->getSpecific('security_postcode'));
41
+ }
42
+
43
+ public function getSecurityCode() {
44
+ return $this->getInfo()->getMethodInstance()->getIntegration()->getAvsString($this->getSpecific('security_code'));
45
+ }
46
+
47
+ public function getSecurityCodeStyle() {
48
+ return $this->_getSecurityCodeStyle($this->getSpecific('security_code'));
49
+ }
50
+
51
+ public function getTitle() {
52
+ return $this->getInfo()->getMethodInstance()->getTitle();
53
+ }
54
+
55
+ public function getTransactionReference() {
56
+ return $this->getSpecific('transaction_reference');
57
+ }
58
+
59
+ public function getTransactionReferenceUrl() {
60
+ $transaction = Mage::getModel('securetrading_stpp/transaction')->load($this->getTransactionReference(), 'transaction_reference');
61
+ return Mage::getModel('adminhtml/url')->getUrl('*/securetrading_transactions/single', array('transaction_id' => $transaction->getTransactionId()));
62
+ }
63
+
64
+ public function getEnrolled() {
65
+ return $this->getSpecific('enrolled', 'N/A');
66
+ }
67
+
68
+ public function getStatus() {
69
+ return $this->getSpecific('status', 'N/A');
70
+ }
71
+
72
+ public function getMystUrl() {
73
+ return 'https://myst.securetrading.net/transactions/singletransaction?transactionreference=' . urlencode($this->getTransactionReference());
74
+ }
75
+
76
+ public function getPaymentType() {
77
+ return $this->getInfo()->getMethodInstance()->getIntegration()->getCardString($this->getSpecific('payment_type'));
78
+ }
79
+
80
+ public function getMaskedPan() {
81
+ return $this->getSpecific('masked_pan');
82
+ }
83
+
84
+ public function getCcLast4() {
85
+ return $this->getSpecific('cc_last_4');
86
+ }
87
+
88
+ public function getStartMonth() {
89
+ return $this->getSpecific('start_month');
90
+ }
91
+
92
+ public function getStartYear() {
93
+ return $this->getSpecific('start_year');
94
+ }
95
+
96
+ public function getStartDate() {
97
+ return $this->getStartMonth() . '/' . $this->getStartYear();
98
+ }
99
+
100
+ public function getExpiryMonth() {
101
+ return $this->getSpecific('expiry_month');
102
+ }
103
+
104
+ public function getExpiryYear() {
105
+ return $this->getSpecific('expiry_year');
106
+ }
107
+
108
+ public function getExpiryDate() {
109
+ return $this->getExpiryMonth() . '/' . $this->getExpiryYear();
110
+ }
111
+
112
+ public function getIssueNumber() {
113
+ return $this->getSpecific('issue_number');
114
+ }
115
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Location.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Location extends Mage_Page_Block_Html {
4
+ const URL_REGISTRY_KEY = 'securetrading_stpp_block_payment_location_url';
5
+
6
+ public function getRedirectUrl() {
7
+ $redirectUrl = Mage::registry(self::URL_REGISTRY_KEY);
8
+ if (!$redirectUrl) {
9
+ $redirectUrl = Mage::getUrl();
10
+ }
11
+ return $redirectUrl;
12
+ }
13
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Redirect/Form.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Redirect_Form extends Mage_Payment_Block_Form {
4
+ public function _construct() {
5
+ $this->setTemplate('securetrading/stpp/payment/redirect/form.phtml');
6
+ parent::_construct();
7
+ }
8
+
9
+ public function getDescription() {
10
+ return Mage::getModel('securetrading_stpp/payment_redirect')->getConfigData('description');
11
+ }
12
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Redirect/Info.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Redirect_Info extends Securetrading_Stpp_Block_Payment_Info_Abstract {
4
+ public function _construct() {
5
+ parent::_construct();
6
+ $this->setTemplate('securetrading/stpp/payment/redirect/info.phtml');
7
+ }
8
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Redirect/Post.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Redirect_Post extends Mage_Core_Block_Template {
4
+ const REGISTRY_TRANSPORT_KEY = 'securetrading_stpp_block_payment_redirect_post_transport';
5
+
6
+ protected $_transport;
7
+
8
+ public function _construct() {
9
+ parent::_construct();
10
+ $transport = Mage::registry(SecureTrading_Stpp_Block_Payment_Redirect_Post::REGISTRY_TRANSPORT_KEY);
11
+ $this->_setTransport($transport);
12
+ }
13
+
14
+ protected function _setTransport(Varien_Object $transport) {
15
+ $this->_transport = $transport;
16
+ }
17
+
18
+ public function getTransport() {
19
+ if ($this->_transport === null) {
20
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('The transport object could not be retrieved.'));
21
+ }
22
+ return $this->_transport;
23
+ }
24
+
25
+ public function getRedirectUrl() {
26
+ return $this->getTransport()->getRedirectUrl();
27
+ }
28
+
29
+ public function getRedirectData() {
30
+ return $this->getTransport()->getRedirectData();
31
+ }
32
+ }
app/code/local/Securetrading/Stpp/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ }
app/code/local/Securetrading/Stpp/Model/Actions/Abstract.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Securetrading_Stpp_Model_Actions_Abstract extends Stpp_Actions_Abstract {
4
+ protected $_orderIncrementId = '';
5
+
6
+ public function getOrderIncrementId(Stpp_Data_Response $response) {
7
+ if ($response->has('orderreference')) {
8
+ return $response->get('orderreference');
9
+ }
10
+ elseif ($response->getRequest()->has('orderreference')) {
11
+ return $response->getRequest()->get('orderreference');
12
+ }
13
+ elseif ($this->_orderIncrementId) {
14
+ return $this->_orderIncrementId;
15
+ }
16
+ else {
17
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('The order increment ID could not be obtained.'));
18
+ }
19
+ }
20
+
21
+ public function setOrderIncrementId($orderIncrementId) {
22
+ $this->_orderIncrementId = $orderIncrementId;
23
+ return $this;
24
+ }
25
+
26
+ public function processAuth(Stpp_Data_Response $response) {
27
+ $this->_log($response, sprintf('In %s.', __METHOD__));
28
+ $errorCode = $response->get('errorcode');
29
+
30
+ $state = $status = $message = null;
31
+
32
+ if ($errorCode === '0') {
33
+ if (in_array($response->get('settlestatus'), array('0', '1', '100'), true)) {
34
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
35
+ $status = Mage::getModel('sales/order')->getConfig()->getStateDefaultStatus($state);
36
+ $message = 'Payment captured.';
37
+ }
38
+ elseif ($response->get('settlestatus') === '2') {
39
+ if ($response->getRequest()->get('settlestatus') !== 2) {
40
+ $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
41
+ $status = Securetrading_Stpp_Model_Payment_Abstract::STATUS_SUSPENDED;
42
+ $message = 'Payment suspended. Request and response settle status mismatch.';
43
+ }
44
+ else {
45
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
46
+ $status = Securetrading_Stpp_Model_Payment_Abstract::STATUS_AUTHORIZED;
47
+ $message = 'Payment authorized.';
48
+ }
49
+ }
50
+ else {
51
+ throw new Stpp_Exception(sprintf(Mage::helper('securetrading_stpp')->__('Unhandled settle status: "%s".'), $response->get('settlestatus')));
52
+ }
53
+ }
54
+ elseif($errorCode === '60107') {
55
+ $status = Securetrading_Stpp_Model_Payment_Abstract::STATUS_SUSPENDED;
56
+ $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
57
+ $message = 'Payment suspended by parent Risk Decision.';
58
+ }
59
+ else {
60
+ $message = sprintf('Payment failed: %s - %s.', $response->get('errorcode'), $response->get('errormessage'));
61
+ $order = Mage::getModel('sales/order')->loadByIncrementId($response->get('orderreference'));
62
+ $order->addStatusHistoryComment($message, false);
63
+ $order->save();
64
+ }
65
+
66
+ $additionalInformation = array(
67
+ 'account_type_description' => $response->get('accounttypedescription'),
68
+ 'security_address' => $response->get('securityresponseaddress'),
69
+ 'security_postcode' => $response->get('securityresponsepostcode'),
70
+ 'security_code' => $response->get('securityresponsesecuritycode'),
71
+ 'enrolled' => $response->get('enrolled'),
72
+ 'status' => $response->get('status'),
73
+ );
74
+
75
+ $transactionReference = $response->get('transactionreference');
76
+ $maskedPan = $response->get('maskedpan');
77
+ Mage::getSingleton('securetrading_stpp/transport')->setState($state)->setStatus($status)->setMessage($message)->setOrderReference($response->get("orderreference"))->setAdditionalInformation($additionalInformation)->setTransactionReference($transactionReference)->setMaskedPan($maskedPan);
78
+ $this->_addTransaction(Securetrading_Stpp_Model_Transaction_Types::TYPE_AUTH, $response);
79
+
80
+ return parent::processAuth($response);
81
+ }
82
+
83
+ public function process3dQuery(Stpp_Data_Response $response) {
84
+ $this->_log($response, sprintf('In %s.', __METHOD__));
85
+ $this->_addTransaction(Securetrading_Stpp_Model_Transaction_Types::TYPE_THREEDQUERY, $response);
86
+ Mage::getSingleton('checkout/session')
87
+ ->setAcsUrl($response->get('acsurl'))
88
+ ->setPaReq($response->get('pareq'))
89
+ ->setTermUrl($response->getRequest()->get('termurl'))
90
+ ->setMd($response->get('md'))
91
+ ;
92
+ return parent::process3dQuery($response);
93
+ }
94
+
95
+ public function processRiskDecision(Stpp_Data_Response $response) {
96
+ $this->_log($response, sprintf('In %s.', __METHOD__));
97
+ $this->_addTransaction(Securetrading_Stpp_Model_Transaction_Types::TYPE_RISKDEC, $response);
98
+ return parent::processRiskDecision($response);
99
+ }
100
+
101
+ public function processTransactionUpdate(Stpp_Data_Response $response) {
102
+ $this->_log($response, sprintf('In %s.', __METHOD__));
103
+ $this->_addTransaction(Securetrading_Stpp_Model_Transaction_Types::TYPE_TRANSACTIONUPDATE, $response);
104
+ return parent::processTransactionUpdate($response);
105
+ }
106
+
107
+ public function processRefund(Stpp_Data_Response $response) {
108
+ $this->_log($response, sprintf('In %s.', __METHOD__));
109
+ $this->_addTransaction(Securetrading_Stpp_Model_Transaction_Types::TYPE_REFUND, $response);
110
+ return parent::processRefund($response);
111
+ }
112
+
113
+ public function processAccountCheck(Stpp_Data_Response $response) {
114
+ $this->_log($response, sprintf('In %s.', __METHOD__));
115
+ $this->_addTransaction(Securetrading_Stpp_Model_Transaction_Types::TYPE_ACCOUNTCHECK, $response);
116
+ return parent::processAccountCheck($response);
117
+ }
118
+
119
+ protected function _log(Stpp_Data_Response $response, $message) {
120
+ Mage::getModel('sales/order')->loadByIncrementId($this->getOrderIncrementId($response))->getPayment()->getMethodInstance()->log($message);
121
+ }
122
+
123
+ protected function _addTransaction($responseType, $response) {
124
+ $orderId = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderIncrementId($response))->getId();
125
+ $errorCode = $response->get('errorcode');
126
+ $transactionReference = $response->get('transactionreference');
127
+ $parentTransactionReference = $response->get('parenttransactionreference');
128
+ $parentTransactionId = null;
129
+
130
+ if ($parentTransactionReference) {
131
+ $transaction = Mage::getModel('securetrading_stpp/transaction')->loadByParentTransactionReference($parentTransactionReference, true);
132
+ if ($transaction) {
133
+ $parentTransactionId = $transaction->getTransactionId();
134
+ }
135
+ }
136
+ $responseData = $response->toArray();
137
+ $requestData = $response->getRequest()->toArray();
138
+
139
+ $requestTypeDescription = $response->getRequest()->get('requesttypedescription') ?: $response->get('requesttypedescription'); // look in request object for api, response object for ppg.
140
+ $requestType = $this->_mapRequestType($requestTypeDescription);
141
+
142
+ Mage::getModel('securetrading_stpp/transaction')
143
+ ->setTransactionReference($transactionReference)
144
+ ->setParentTransactionId($parentTransactionId)
145
+ ->setRequestType($requestType)
146
+ ->setResponseType($responseType)
147
+ ->setRequestData($requestData)
148
+ ->setResponseData($responseData)
149
+ ->setErrorCode($errorCode)
150
+ ->setOrderId($orderId)
151
+ ->save()
152
+ ;
153
+ }
154
+
155
+ protected function _mapRequestType($requestType) {
156
+ switch($requestType) {
157
+ case Stpp_Types::API_AUTH:
158
+ $return = Securetrading_Stpp_Model_Transaction_Types::TYPE_AUTH;
159
+ break;
160
+ case Stpp_Types::API_THREEDQUERY:
161
+ $return = Securetrading_Stpp_Model_Transaction_Types::TYPE_THREEDQUERY;
162
+ break;
163
+ case Stpp_Types::API_RISKDEC:
164
+ $return = Securetrading_Stpp_Model_Transaction_Types::TYPE_RISKDEC;
165
+ break;
166
+ case Stpp_Types::API_TRANSACTIONUPDATE:
167
+ $return = Securetrading_Stpp_Model_Transaction_Types::TYPE_TRANSACTIONUPDATE;
168
+ break;
169
+ case Stpp_Types::API_ACCOUNTCHECK:
170
+ $return = Securetrading_Stpp_Model_Transaction_Types::TYPE_ACCOUNTCHECK;
171
+ break;
172
+ default:
173
+ $return = '';
174
+ }
175
+ return $return;
176
+ }
177
+ }
app/code/local/Securetrading/Stpp/Model/Actions/Direct.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Actions_Direct extends Securetrading_Stpp_Model_Actions_Abstract implements Stpp_Api_ActionsInterface {
4
+
5
+ }
app/code/local/Securetrading/Stpp/Model/Actions/Redirect.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model_Actions_Abstract implements Stpp_PaymentPages_ActionsInterface {
4
+ public function processAuth(Stpp_Data_Response $response) {
5
+ parent::processAuth($response);
6
+ if ($response->get('errorcode') === '0') {
7
+ Mage::getModel('securetrading_stpp/payment_redirect')->registerSuccessfulOrderAfterExternalRedirect();
8
+ }
9
+
10
+ $payment = Mage::getModel('sales/order')->loadByIncrementId($response->get('orderreference'))->getPayment();
11
+ $payment->setCcType($response->get('paymenttypedescription'));
12
+ $payment->setCcLast4($payment->getMethodInstance()->getIntegration()->getCcLast4($response->get('maskedpan')));
13
+ $payment->save();
14
+
15
+ return $this->_isErrorCodeZero($response);
16
+ }
17
+
18
+ public function validateNotification(Stpp_Data_Response $response) {
19
+ $fields = array(
20
+ 'accounttypedescription',
21
+ 'enrolled',
22
+ 'errorcode',
23
+ 'errormessage',
24
+ 'maskedpan',
25
+ 'orderreference',
26
+ 'parenttransactionreference',
27
+ 'paymenttypedescription',
28
+ 'requesttypedescription',
29
+ 'securityresponseaddress',
30
+ 'securityresponsepostcode',
31
+ 'securityresponsesecuritycode',
32
+ 'settlestatus',
33
+ 'status',
34
+ 'transactionreference',
35
+ );
36
+
37
+ foreach($fields as $field) {
38
+ if (!$response->has($field)) {
39
+ throw new Stpp_Exception(sprintf(Mage::helper('securetrading_stpp')->__('The "%s" is required.'), $field));
40
+ }
41
+ }
42
+ }
43
+
44
+ public function checkIsNotificationProcessed($notificationReference) {
45
+ $model = Mage::getModel('securetrading_stpp/payment_redirect_notification')->load($notificationReference, 'notification_reference');
46
+ return (bool) $model->getNotificationId();
47
+ }
48
+
49
+ public function saveNotificationReference($notificationReference) {
50
+ Mage::getModel('securetrading_stpp/payment_redirect_notification')->setNotificationReference($notificationReference)->save();
51
+ }
52
+
53
+ public function prepareResponse(Stpp_Data_Response $response) {
54
+ $orderReference = $response->get('orderreference');
55
+ if ($orderReference) {
56
+ $request = Mage::getModel('securetrading_stpp/payment_redirect_request')->loadRequestByOrderIncrementId($orderReference);
57
+
58
+ if (!$request) {
59
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('This orderreference does not have a mapped request.'));
60
+ }
61
+ $response->setRequest($request);
62
+ }
63
+ }
64
+ }
app/code/local/Securetrading/Stpp/Model/Adminhtml/System/Config/Backend/Multiselect.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Adminhtml_System_Config_Backend_Multiselect extends Mage_Core_Model_Config_Data {
4
+ protected function _afterLoad() {
5
+ if (!is_array($this->getValue())) {
6
+ $this->setValue(unserialize($this->getValue()));
7
+ }
8
+ }
9
+
10
+ protected function _beforeSave() {
11
+ if (is_array($this->getValue())) {
12
+ $this->setValue(serialize($this->getValue()));
13
+ }
14
+ }
15
+ }
app/code/local/Securetrading/Stpp/Model/Cron.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Cron {
4
+ const EXPIRED_ORDER_HOURS = 24;
5
+
6
+ public function abandonedOrderCleanup() {
7
+ $expiredOrderTime = date('Y-m-d H:i:s', strtotime('-' . self::EXPIRED_ORDER_HOURS . ' hours'));
8
+
9
+ $collection = Mage::getResourceModel('sales/order_collection')
10
+ ->addFieldToFilter('status', array('in', array(Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES, Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_3DSECURE)))
11
+ ->addFieldToFilter('updated_at', array('lt' => $expiredOrderTime))
12
+ ;
13
+
14
+ foreach($collection->getItems() as $order) {
15
+ if (!$order->getPayment()->getMethodInstance()->getIsSecuretradingPaymentMethod()) {
16
+ continue;
17
+ }
18
+ $order->cancel();
19
+ $order->save();
20
+ }
21
+ }
22
+
23
+ public function requestTableCleanup() {
24
+ $collection = Mage::getModel('securetrading_stpp/payment_redirect_request')->getCollection();
25
+ $collection->join(array('orders' => 'sales/order'),'orders.increment_id = main_table.order_increment_id', array('status'));
26
+ $collection->addFieldToFilter('orders.status', array('neq' => Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES));
27
+
28
+ foreach($collection->getItems() as $item) {
29
+ $item->delete();
30
+ }
31
+ }
32
+ }
app/code/local/Securetrading/Stpp/Model/Integration.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Integration extends Mage_Core_Model_Abstract {
4
+ protected $_facade;
5
+
6
+ protected $_ppagesFacade;
7
+
8
+ protected $_apiFacade;
9
+
10
+ protected $_ppagesActionInstance;
11
+
12
+ protected $_apiActionInstance;
13
+
14
+ protected $_frontendFields;
15
+
16
+ protected $_adminFields;
17
+
18
+ protected $_debugLog;
19
+
20
+ public function _construct() {
21
+ require_once(Mage::getModuleDir('', 'Securetrading_Stpp') . DS . 'lib' . DS . 'Securetrading.php');
22
+ Securetrading::init();
23
+
24
+ $config = array();
25
+ $paymentMethod = $this->getPaymentMethod();
26
+
27
+ if ($paymentMethod) {
28
+ $this->_ppagesActionInstance = Mage::getModel('securetrading_stpp/actions_redirect');
29
+ $this->_apiActionInstance = Mage::getModel('securetrading_stpp/actions_direct');
30
+
31
+ $config = array(
32
+ 'connections' => array(
33
+ 'web_services' => array(
34
+ 'username' => $paymentMethod->getConfigData('ws_username'),
35
+ 'password' => $paymentMethod->getConfigData('ws_password'),
36
+ 'alias' => $paymentMethod->getConfigData('ws_alias'),
37
+ 'verifyssl' => $paymentMethod->getConfigData('ws_verify_ca'),
38
+ 'cacertfile' => $paymentMethod->getConfigData('ws_ca_file'),
39
+ ),
40
+ 'stapi' => array(
41
+ 'host' => $paymentMethod->getConfigData('stapi_host'),
42
+ 'port' => $paymentMethod->getConfigData('stapi_port'),
43
+ ),
44
+ ),
45
+ 'interfaces' => array(
46
+ 'ppages' => array(
47
+ 'action_instance' => $this->_ppagesActionInstance,
48
+ 'notificationhash' => array(
49
+ 'password' => $paymentMethod->getConfigData('notification_password'),
50
+ 'algorithm' => 'sha256',
51
+ 'use' => $paymentMethod->getConfigData('use_notification_password'),
52
+ ),
53
+ 'sitesecurity' => array(
54
+ 'password' => $paymentMethod->getConfigData('site_security_password'),
55
+ 'algorithm' => 'sha256',
56
+ 'use' => $paymentMethod->getConfigData('use_site_security'),
57
+ ),
58
+ 'use_authenticated_moto' => false,
59
+ 'use_http_post' => true,
60
+ ),
61
+ 'api' => array(
62
+ 'action_instance' => $this->_apiActionInstance,
63
+ 'active_connection' => $paymentMethod->getConfigData('connection'),
64
+ 'use_3d_secure' => $paymentMethod->getConfigData('use_3d_secure'),
65
+ 'use_risk_decision' => $paymentMethod->getConfigData('use_risk_decision'),
66
+ 'use_card_store' => $paymentMethod->getConfigData('use_card_store'),
67
+ 'use_risk_decision_after_auth' => $paymentMethod->getConfigData('delay_risk_decision'),
68
+ 'use_auto_card_store' => $paymentMethod->getConfigData('use_auto_card_store'),
69
+ )
70
+ ),
71
+ );
72
+ }
73
+
74
+ $utilityFacade = Magento_Utility_Facade::instance($config); // Must be done before using any other parts of the STPP framework.
75
+ $fieldFacade = Stpp_Fields_Facade::instance($config);
76
+
77
+ $this->_facade = Stpp_Facade::instance($config);
78
+ $this->_ppagesFacade = Stpp_PaymentPages_Facade::instance($config);
79
+ $this->_apiFacade = Stpp_Api_Facade::instance($config);
80
+
81
+ $this->_frontendFields = $fieldFacade->newFrontendFields();
82
+ $this->_adminFields = $fieldFacade->newAdminFields();
83
+ $this->_debugLog = $utilityFacade->newDebugLog();
84
+ }
85
+
86
+ public function getPaymentMethod() {
87
+ $paymentMethod = $this->getData('payment_method');
88
+
89
+ if (!($paymentMethod instanceof Securetrading_Stpp_Model_Payment_Abstract)) {
90
+ return false;
91
+ }
92
+ return $paymentMethod;
93
+ }
94
+
95
+ protected function _getFrontendFields() {
96
+ if ($this->_frontendFields === null) {
97
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('An instance of the frontend fields has not been set.'));
98
+ }
99
+ return $this->_frontendFields;
100
+ }
101
+
102
+ public function getDebugLog() {
103
+ if ($this->_debugLog === null) {
104
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('An instance of the debug log has not been set.'));
105
+ }
106
+ return $this->_debugLog;
107
+ }
108
+
109
+ public function getAdminFields() {
110
+ if ($this->_adminFields === null) {
111
+ throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('An instance of the admin fields has not been set.'));
112
+ }
113
+ return $this->_adminFields;
114
+ }
115
+
116
+ public function getSettleDueDates() {
117
+ return Stpp_Types::getSettleDueDates();
118
+ }
119
+
120
+ public function getSettleStatuses() {
121
+ return Stpp_Types::getSettleStatuses(true);
122
+ }
123
+
124
+ public function getCardTypes() {
125
+ return Stpp_Types::getCardTypes();
126
+ }
127
+
128
+ public function getConnections() {
129
+ $connections = array();
130
+ foreach($this->_apiFacade->newConnectionStore()->getAll() as $k => $v) {
131
+ $connections[$k] = $v::getName();
132
+ }
133
+ return $connections;
134
+ }
135
+
136
+ protected function _setOrderIncrementId($orderIncrementId) {
137
+ $this->_ppagesActionInstance->setOrderIncrementId($orderIncrementId);
138
+ $this->_apiActionInstance->setOrderIncrementId($orderIncrementId);
139
+ }
140
+
141
+ public function runApiStandard(Mage_Sales_Model_Order_Payment $payment, $isMoto = false) {
142
+ $isMoto = $payment->getOrder()->getQuote()->getIsSuperMode();
143
+ $this->_setOrderIncrementId($payment->getOrder()->getIncrementId());
144
+ $data = $this->getPaymentMethod()->prepareOrderData($payment);
145
+ $request = Stpp_Data_Request::instance()->setMultiple($data);
146
+ return $this->_apiFacade->runApiStandard($request, $isMoto);
147
+ }
148
+
149
+ public function runApi3dAuth() {
150
+ return $this->_apiFacade->runApi3dAuth(new Stpp_Data_Request());
151
+ }
152
+
153
+ public function runPaymentPages(array $data, $isMoto = false) {
154
+ $request = Stpp_Data_Request::instance()->setMultiple($data);
155
+ $result = $this->_ppagesFacade->runPaymentPagesStandard($request, $isMoto);
156
+ Mage::getModel('securetrading_stpp/payment_redirect_request')->addRequest($this->getPaymentMethod()->getInfoInstance(), $result->getRequest());
157
+
158
+ $transport = new Varien_Object();
159
+ $transport->setRedirectIsPost($result->getRedirectIsPost());
160
+ $transport->setRedirectUrl($result->getRedirectUrl());
161
+ $transport->setRedirectData($result->getRedirectData());
162
+ return $transport;
163
+ }
164
+
165
+ public function runRedirect() {
166
+ $this->_ppagesFacade->newPaymentPages()->validateRedirect();
167
+ }
168
+
169
+ public function runNotification() {
170
+ $this->_ppagesFacade->newPaymentPages()->runNotification();
171
+ }
172
+
173
+ public function getAcceptedCards($use3dSecure, array $acceptedCards = array()) {
174
+ $helper = $this->_facade->newHelper();
175
+ return $helper->getFilteredCardTypes($use3dSecure, $acceptedCards);
176
+ }
177
+
178
+ public function getCcLast4($pan) {
179
+ $helper = $this->_facade->newHelper();
180
+ return $helper->getCcLast4($pan);
181
+ }
182
+
183
+ public function getCardString($cardKey) {
184
+ $cards = Stpp_Types::getCardTypes();
185
+ if (array_key_exists($cardKey, $cards)) {
186
+ return $cards[$cardKey];
187
+ }
188
+ else {
189
+ return '';
190
+ }
191
+ }
192
+
193
+ public function getAvsString($avsKey) {
194
+ $avsCodes = Stpp_Types::getAvsCodes();
195
+ if (array_key_exists($avsKey, $avsCodes)) {
196
+ return $avsCodes[$avsKey];
197
+ }
198
+ return $avsKey;
199
+ }
200
+
201
+ public function getMonths() {
202
+ $months = Stpp_Types::getMonths();
203
+ $array = array();
204
+ foreach($months as $month) {
205
+ $array[$month['numeric']] = $month['short'];
206
+ }
207
+ return $array;
208
+ }
209
+
210
+ public function getStartYears() {
211
+ return Stpp_Types::getStartYears();
212
+ }
213
+
214
+ public function getExpiryYears() {
215
+ return Stpp_Types::getExpiryYears();
216
+ }
217
+
218
+ public function getCardTypeLabel() {
219
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_PAYMENT_TYPE);
220
+ }
221
+
222
+ public function getCardTypeDescription() {
223
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_PAYMENT_TYPE);
224
+ }
225
+
226
+ public function getCardNumberLabel() {
227
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_PAN);
228
+ }
229
+
230
+ public function getCardNumberDescription() {
231
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_PAN);
232
+ }
233
+
234
+ public function getCardStartDateLabel() {
235
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_START_DATE);
236
+ }
237
+
238
+ public function getCardStartDateDescription() {
239
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_START_DATE);
240
+ }
241
+
242
+ public function getCardExpiryDateLabel() {
243
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_EXPIRY_DATE);
244
+ }
245
+
246
+ public function getCardExpiryDateDescription() {
247
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_EXPIRY_DATE);
248
+ }
249
+
250
+ public function getCardSecurityCodeLabel() {
251
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_SECURITY_CODE);
252
+ }
253
+
254
+ public function getCardSecurityCodeDescription() {
255
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_SECURITY_CODE);
256
+ }
257
+
258
+ public function getCardIssueNumberLabel() {
259
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_ISSUE_NUMBER);
260
+ }
261
+
262
+ public function getCardIssueNumberDescription() {
263
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_ISSUE_NUMBER);
264
+ }
265
+ }
app/code/local/Securetrading/Stpp/Model/Observer.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Observer {
4
+ public function onCheckoutSubmitAllAfter(Varien_Event_Observer $observer) {
5
+ $quote = $observer->getEvent()->getQuote();
6
+ $methodInstance = $quote->getPayment()->getMethodInstance();
7
+
8
+ if ($methodInstance->getIsSecuretradingPaymentMethod()) {
9
+ $methodInstance->log(sprintf('In %s.', __METHOD__));
10
+
11
+ $order = $observer->getEvent()->getOrder();
12
+
13
+ $collection = $order->getStatusHistoryCollection(true);
14
+ foreach($collection as $c) {
15
+ $c->delete();
16
+ }
17
+
18
+ $orderIncomplete = (bool) $quote->getPayment()->getOrderPlaceRedirectUrl();
19
+ $methodInstance->log(sprintf('In %s. Order incomplete: %s.', __METHOD__, $orderIncomplete));
20
+
21
+ if ($orderIncomplete) {
22
+ $stateObject = Mage::getSingleton('securetrading_stpp/transport');
23
+ $order->setState($stateObject->getState(), $stateObject->getStatus(), $stateObject->getMessage());
24
+ $order->save();
25
+
26
+ $quote->setIsActive(true);//note - quote saved after this observer called (in onepagecontroller)
27
+ }
28
+ else {
29
+ Mage::getModel('securetrading_stpp/payment_direct')->handleSuccessfulPayment($order);
30
+ }
31
+ }
32
+ }
33
+
34
+ public function onPaymentInfoBlockPrepareSpecificInformation(Varien_Event_Observer $observer) {
35
+ if (!$observer->getEvent()->getPayment()->getMethodInstance()->getIsSecuretradingPaymentMethod()) {
36
+ return;
37
+ }
38
+
39
+ $data = array(
40
+ 'account_type_description',
41
+ 'security_address',
42
+ 'security_postcode',
43
+ 'security_code',
44
+ 'enrolled',
45
+ 'status',
46
+ );
47
+
48
+ $payment = $observer->getEvent()->getPayment();
49
+
50
+ foreach($data as $key) {
51
+ $transport = $observer->getEvent()->getTransport();
52
+ $value = $payment->getAdditionalInformation($key) ?: '';
53
+ $transport->setData($key, $value);
54
+ }
55
+
56
+ $transport->setData('payment_type', $payment->getCcType());
57
+ $transport->setData('cc_last_4', $payment->getCcLast4());
58
+ $transport->setData('expiry_month', $payment->getCcExpMonth());
59
+ $transport->setData('expiry_year', $payment->getCcExpYear());
60
+ $transport->setData('start_month', $payment->getCcSsStartMonth());
61
+ $transport->setData('start_year', $payment->getCcSsStartYear());
62
+ $transport->setData('issue_number', $payment->getCcSsIssue());
63
+ $transport->setData('transaction_reference', $payment->getCcTransId());
64
+ }
65
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Abstract.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Securetrading_Stpp_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract {
4
+ const STATUS_AUTHORIZED = 'authorized';
5
+ const STATUS_SUSPENDED = 'suspended';
6
+ const STATUS_PENDING_PPAGES = 'pending_ppages';
7
+ const STATUS_PENDING_3DSECURE = 'pending_3dsecure';
8
+
9
+ final public function getIsSecuretradingPaymentMethod() {
10
+ return true;
11
+ }
12
+
13
+ public function getIntegration() {
14
+ return Mage::getModel('securetrading_stpp/integration', array('payment_method' => $this));
15
+ }
16
+
17
+ public function log($message) {
18
+ try {
19
+ $order = $this->getInfoInstance()->getOrder();
20
+ }
21
+ catch (Exception $e) {
22
+ // Do nothing here intentionally.
23
+ }
24
+ $sidToken = md5(Mage::getModel('core/session')->getSessionId());
25
+ $orderIncrementId = isset($order) && $order ? $order->getIncrementId() : 'N/A';
26
+ $message = $this->_code . ' - ' .$orderIncrementId . ' - ' . $sidToken . ' - ' . $message;
27
+ $this->getIntegration()->getDebugLog()->log($message);
28
+ return $this;
29
+ }
30
+
31
+ public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment) {
32
+ $order = $payment->getOrder();
33
+ $billingAddress = $order->getBillingAddress();
34
+ $billingCounty = $billingAddress->getCountry() == 'US' ? $billingAddress->getRegionCode() : $billingAddress->getRegion();
35
+ $billingTelephoneNumber = $billingAddress->getTelephone();
36
+ $billingTelephoneType = !empty($billingTelephoneNumber) ? 'H' : '';
37
+ $customerDobFull = $order->getCustomerDob();
38
+ $customerDobArray = explode(' ', $customerDobFull);
39
+ $customerDob = $customerDobArray[0];
40
+
41
+ $data = array(
42
+ 'sitereference' => $this->getConfigData("site_reference"),
43
+ 'currencyiso3a' => $order->getBaseCurrencyCode(),
44
+ 'mainamount' => $order->getBaseTotalDue(),
45
+
46
+ 'billingprefixname' => $billingAddress->getPrefix(),
47
+ 'billingfirstname' => $billingAddress->getFirstname(),
48
+ 'billingmiddlename' => $billingAddress->getMiddlename(),
49
+ 'billinglastname' => $billingAddress->getLastname(),
50
+ 'billingsuffixname' => $billingAddress->getSuffix(),
51
+ 'billingemail' => $order->getCustomerEmail(),
52
+ 'billingtelephone' => $billingTelephoneNumber,
53
+ 'billingtelephonetype' => $billingTelephoneType,
54
+ 'billingpremise' => $billingAddress->getStreet(1),
55
+ 'billingstreet' => $billingAddress->getStreet(2),
56
+ 'billingtown' => $billingAddress->getCity(),
57
+ 'billingcounty' => $billingCounty,
58
+ 'billingpostcode' => $billingAddress->getPostcode(),
59
+ 'billingcountryiso2a' => $billingAddress->getCountry(),
60
+ 'billingdob' => $customerDob,
61
+
62
+ 'settleduedate' => $this->getConfigData('settle_due_date'),
63
+ 'settlestatus' => $this->getConfigData('payment_action') === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE ? 2 : $this->getConfigData('settle_status'),
64
+ 'orderreference' => $order->getIncrementId(),
65
+ );
66
+
67
+ if ($order->getShippingMethod()) {
68
+ $customerAddress = $order->getShippingAddress();
69
+ $customerCounty = $customerAddress->getCountry() == 'US' ? $customerAddress->getRegionCode() : $customerAddress->getRegion();
70
+ $customerTelephoneNumber = $customerAddress->getTelephone();
71
+ $customerTelephoneType = !empty($customerTelephoneNumber) ? 'H' : '';
72
+
73
+ $data += array(
74
+ 'customerprefixname' => $customerAddress->getPrefix(),
75
+ 'customerfirstname' => $customerAddress->getFirstname(),
76
+ 'customermiddlename' => $customerAddress->getMiddlename(),
77
+ 'customerlastname' => $customerAddress->getLastname(),
78
+ 'customersuffixname' => $customerAddress->getSuffix(),
79
+ 'customeremail' => '',
80
+ 'customertelephone' => $customerTelephoneNumber,
81
+ 'customertelephonetype' => $customerTelephoneType,
82
+ 'customerpremise' => $customerAddress->getStreet(1),
83
+ 'customerstreet' => $customerAddress->getStreet(2),
84
+ 'customertown' => $customerAddress->getCity(),
85
+ 'customercounty' => $customerCounty,
86
+ 'customerpostcode' => $customerAddress->getPostcode(),
87
+ 'customercountryiso2a' => $customerAddress->getCountry(),
88
+ );
89
+ }
90
+ return $data;
91
+ }
92
+
93
+ public function registerSuccessfulOrderAfterExternalRedirect() {
94
+ $this->log(sprintf('In %s.', __METHOD__));
95
+ $stateObject = Mage::getSingleton('securetrading_stpp/transport');
96
+ $order = Mage::getModel('sales/order')->loadByIncrementId($stateObject->getOrderReference());
97
+ $this->handleSuccessfulPayment($order);
98
+ }
99
+
100
+ public function handleSuccessfulPayment(Mage_Sales_Model_Order $order) {
101
+ $this->log(sprintf('In %s.', __METHOD__));
102
+ $quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
103
+ $stateObject = Mage::getSingleton('securetrading_stpp/transport');
104
+ if ($quote->getIsActive()) {
105
+ $quote->setIsActive(false)->save();
106
+ }
107
+ $order->setState($stateObject->getState(), $stateObject->getStatus(), $stateObject->getMessage());
108
+ $order->save();
109
+
110
+ if ($stateObject->getState() === Mage_Sales_Model_Order::STATE_PROCESSING && $stateObject->getStatus() === Mage::getModel('sales/order')->getConfig()->getStateDefaultStatus($stateObject->getState())) {
111
+ $invoice = $order->prepareInvoice()->register()->pay();
112
+ $order->addRelatedObject($invoice)->save();
113
+ }
114
+
115
+ $order->getPayment()
116
+ ->setAdditionalInformation($stateObject->getAdditionalInformation())
117
+ ->setCcTransId($stateObject->getTransactionReference())
118
+ ->setCcLast4($this->getIntegration()->getCcLast4($stateObject->getMaskedPan()))
119
+ ->save()
120
+ ;
121
+ }
122
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Direct.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Direct extends Securetrading_Stpp_Model_Payment_Abstract {
4
+ protected $_code = 'securetrading_stpp_direct';
5
+ protected $_formBlockType = 'securetrading_stpp/payment_direct_form';
6
+ protected $_infoBlockType = 'securetrading_stpp/payment_direct_info';
7
+
8
+ protected $_isGateway = false;
9
+ protected $_canOrder = false;
10
+ protected $_canAuthorize = true;
11
+ protected $_canCapture = false;
12
+ protected $_canCapturePartial = false;
13
+ protected $_canRefund = false;
14
+ protected $_canRefundInvoicePartial = false;
15
+ protected $_canVoid = false;
16
+ protected $_canUseInternal = true;
17
+ protected $_canUseCheckout = true;
18
+ protected $_canUseForMultishipping = false;
19
+ protected $_isInitializeNeeded = true;
20
+ protected $_canFetchTransactionInfo = false;
21
+ protected $_canReviewPayment = false;
22
+ protected $_canCreateBillingAgreement = false;
23
+ protected $_canManageRecurringProfiles = false;
24
+
25
+ public function initialize($action, $stateObject) {
26
+ $this->log(sprintf('In %s. Action is %s.', __METHOD__, $action));
27
+ $payment = $this->getInfoInstance();
28
+ $order = $payment->getOrder();
29
+
30
+ switch ($action) {
31
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
32
+ $payment->authorize(true, $order->getBaseTotalDue());
33
+ $payment->setAmountAuthorized($order->getTotalDue());
34
+ break;
35
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
36
+ $payment->setAmountAuthorized($order->getTotalDue());
37
+ $payment->setBaseAmountAuthorized($order->getBaseTotalDue());
38
+ $payment->capture(null);
39
+ break;
40
+ default:
41
+ break;
42
+ }
43
+ return $this;
44
+ }
45
+
46
+ public function authorize(Varien_Object $payment, $amount) {
47
+ $this->log(sprintf('In %s.', __METHOD__));
48
+ parent::authorize($payment, $amount);
49
+ $result = $this->getIntegration()->runApiStandard($payment);
50
+ $this->handleStandardPaymentResult($result);
51
+ return $this;
52
+ }
53
+
54
+ public function capture(Varien_Object $payment, $amount) {
55
+ $this->log(sprintf('In %s.', __METHOD__));
56
+ parent::capture($payment, $amount);
57
+ $result = $this->getIntegration()->runApiStandard($payment);
58
+ $this->handleStandardPaymentResult($result);
59
+ return $this;
60
+ }
61
+
62
+ public function getOrderPlaceRedirectUrl() {
63
+ $session = Mage::getSingleton('securetrading_stpp/payment_direct_session');
64
+ $acsParamsExist = $session->hasAcsRedirectParams();
65
+ $this->log(sprintf('In %s. ACS Params exist: %s.', __METHOD__, $acsParamsExist));
66
+
67
+ if ($acsParamsExist) {
68
+ return $session->getAcsRedirectParams()->getOrderPlaceRedirectUrl();
69
+ }
70
+ return null;
71
+ }
72
+
73
+ public function assignData($data) {
74
+ $payment = $this->getInfoInstance();
75
+ $payment->setCcType($data->getSecuretradingStppPaymentType());
76
+ $payment->setCcNumberEnc($payment->encrypt($data->getSecuretradingStppCardNumber()));
77
+ $payment->setCcLast4($this->getIntegration()->getCcLast4($data->getSecuretradingStppCardNumber()));
78
+ $payment->setCcExpMonth($data->getSecuretradingStppExpiryDateMonth());
79
+ $payment->setCcExpYear($data->getSecuretradingStppExpiryDateYear());
80
+ $payment->setCcSsStartMonth($data->getSecuretradingStppStartDateMonth());
81
+ $payment->setCcSsStartYear($data->getSecuretradingStppStartDateYear());
82
+ $payment->setCcSsIssue($data->getSecuretradingStppIssueNumber());
83
+ Mage::getModel('securetrading_stpp/payment_direct_session')->setSecurityCode($payment->encrypt($data->getSecuretradingStppSecurityCode())); // Cannot save CC CID due to PCI requirements.
84
+ return $this;
85
+ }
86
+
87
+ public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment) {
88
+ $data = parent::prepareOrderData($payment);
89
+ $payment = $this->getInfoInstance();
90
+
91
+ return $data += array(
92
+ 'termurl' => Mage::getUrl('securetrading/direct/return'),
93
+ 'paymenttype' => $payment->getCcType(),
94
+ 'pan' => $payment->decrypt($payment->getCcNumberEnc()),
95
+ 'startdate' => $payment->getCcSsStartMonth() . '/' . $payment->getCcSsStartYear(),
96
+ 'expirydate' => $payment->getCcExpMonth() . '/' . $payment->getCcExpYear(),
97
+ 'securitycode' => $payment->decrypt(Mage::getModel('securetrading_stpp/payment_direct_session')->getSecurityCode()),
98
+ 'issuenumber' => $payment->getCcSsIssue(),
99
+ );
100
+ }
101
+
102
+ public function handleStandardPaymentResult(Stpp_Api_ResultInterface $result) {
103
+ $this->log(sprintf('In %s.', __METHOD__));
104
+ if ($result->getRedirectRequired()) {
105
+ Mage::getSingleton('securetrading_stpp/transport')->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)->setStatus(Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_3DSECURE)->setMessage("Customer redirected to the 3D Secure ACS URL.");
106
+ $redirectPath = $this->getConfigData('api_use_iframe') ? 'securetrading/direct_post/iframe' : 'securetrading/direct_post/container';
107
+ $params = new Varien_Object();
108
+ $params
109
+ ->setOrderPlaceRedirectUrl(Mage::getUrl($redirectPath))
110
+ ->setRedirectIsPost($result->getRedirectIsPost())
111
+ ->setRedirectUrl($result->getRedirectUrl())
112
+ ->setRedirectData($result->getRedirectData())
113
+ ;
114
+ Mage::getSingleton('securetrading_stpp/payment_direct_session')->setAcsRedirectParams($params);
115
+ }
116
+ elseif(!$result->getIsTransactionSuccessful()) {
117
+ throw new Mage_Payment_Model_Info_Exception($result->getCustomerErrorMessage());
118
+ }
119
+ return $this;
120
+ }
121
+
122
+ public function run3dAuth() {
123
+ $this->log(sprintf('In %s.', __METHOD__));
124
+ $result = $this->getIntegration()->runApi3dAuth();
125
+
126
+ if($result->getIsTransactionSuccessful()) {
127
+ $this->registerSuccessfulOrderAfterExternalRedirect();
128
+ return true;
129
+ }
130
+ return false;
131
+ }
132
+
133
+ public function handleSuccessfulPayment(Mage_Sales_Model_Order $order) {
134
+ parent::handleSuccessfulPayment($order);
135
+ Mage::getSingleton('securetrading_stpp/payment_direct_session')->clear();
136
+ }
137
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Direct/Session.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Direct_Session extends Mage_Core_Model_Session_Abstract {
4
+ public function __construct() {
5
+ $this->init('securetrading_stpp_payment_direct');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Redirect.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Redirect extends Securetrading_Stpp_Model_Payment_Abstract {
4
+ protected $_code = 'securetrading_stpp_redirect';
5
+ protected $_formBlockType = 'securetrading_stpp/payment_redirect_form';
6
+ protected $_infoBlockType = 'securetrading_stpp/payment_redirect_info';
7
+
8
+ protected $_isGateway = false;
9
+ protected $_canOrder = false;
10
+ protected $_canAuthorize = false;
11
+ protected $_canCapture = true;
12
+ protected $_canCapturePartial = false;
13
+ protected $_canRefund = false;
14
+ protected $_canRefundInvoicePartial = false;
15
+ protected $_canVoid = false;
16
+ protected $_canUseInternal = true;
17
+ protected $_canUseCheckout = true;
18
+ protected $_canUseForMultishipping = false;
19
+ protected $_isInitializeNeeded = true;
20
+ protected $_canFetchTransactionInfo = false;
21
+ protected $_canReviewPayment = true;
22
+ protected $_canCreateBillingAgreement = false;
23
+ protected $_canManageRecurringProfiles = false;
24
+
25
+ public function initialize($action, $stateObject) {
26
+ $this->log(sprintf('In %s.', __METHOD__));
27
+ parent::initialize($action, $stateObject);
28
+ Mage::getSingleton('securetrading_stpp/transport')->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)->setStatus(Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES)->setMessage("Customer redirect to the SecureTrading Payment Pages.");
29
+ }
30
+
31
+ public function acceptPayment(Mage_Payment_Model_Info $payment) {
32
+ $this->log(sprintf('In %s.', __METHOD__));
33
+ parent::acceptPayment($payment);
34
+ $invoice = $payment->getOrder()->prepareInvoice()->register()->pay();
35
+ $payment->getOrder()->addRelatedObject($invoice)->save();
36
+ return true;
37
+ }
38
+
39
+ public function denyPayment(Mage_Payment_Model_Info $payment) {
40
+ $this->log(sprintf('In %s.', __METHOD__));
41
+ parent::denyPayment($payment);
42
+ return true;
43
+ }
44
+
45
+ public function getOrderPlaceRedirectUrl() {
46
+ $this->log(sprintf('In %s.', __METHOD__));
47
+ if ($this->getConfigData('ppg_use_iframe')) {
48
+ return Mage::getUrl('securetrading/redirect_post/iframe');
49
+ }
50
+ return Mage::getUrl('securetrading/redirect_post/container');
51
+ }
52
+
53
+ public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment) {
54
+ $this->log(sprintf('In %s.', __METHOD__));
55
+ $data = parent::prepareOrderData($payment);
56
+ return $data += array(
57
+ 'parentcss' => $this->getConfigData('parent_css'),
58
+ 'childcss' => $this->getConfigData('child_css'),
59
+ 'parentjs' => $this->getConfigData('parent_js'),
60
+ 'childjs' => $this->getConfigData('child_js'),
61
+ );
62
+ }
63
+
64
+ public function prepareData($isMoto = false) {
65
+ $this->log(sprintf('In %s.', __METHOD__));
66
+ $payment = $this->getInfoInstance();
67
+ $data = $this->prepareOrderData($payment);
68
+ $transport = $this->getIntegration()->runPaymentPages($data, $isMoto);
69
+ return $transport;
70
+ }
71
+
72
+ public function runRedirect() {
73
+ $this->log(sprintf('In %s.', __METHOD__));
74
+ return $this->getIntegration()->runRedirect();
75
+ }
76
+
77
+ public function runNotification() {
78
+ $this->log(sprintf('In %s.', __METHOD__));
79
+ $this->getIntegration()->runNotification();
80
+ }
81
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Redirect/Notification.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Redirect_Notification extends Mage_Core_Model_Abstract {
4
+ protected function _construct() {
5
+ $this->_init('securetrading_stpp/payment_redirect_notification');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Redirect/Request.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Redirect_Request extends Mage_Core_Model_Abstract {
4
+ protected function _construct() {
5
+ $this->_init('securetrading_stpp/payment_redirect_request');
6
+ }
7
+
8
+ public function setRequest(Stpp_Data_Request $request) {
9
+ $this->setData('request', serialize($request));
10
+ return $this;
11
+ }
12
+
13
+ public function getRequest() {
14
+ return unserialize($this->getData('request'));
15
+ }
16
+
17
+ public function addRequest(Mage_Payment_Model_Info $payment, Stpp_Data_Request $request) {
18
+ $orderIncrementId = $payment->getOrder()->getIncrementId();
19
+ $this->load($orderIncrementId, 'order_increment_id')
20
+ ->setOrderIncrementId($orderIncrementId)
21
+ ->setRequest($request)
22
+ ->save();
23
+ return $this;
24
+ }
25
+
26
+ public function loadRequestByOrderIncrementId($orderIncrementId) {
27
+ return $this->load($orderIncrementId, 'order_increment_id')->getRequest();
28
+ }
29
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Payment/Redirect/Notification.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Payment_Redirect_Notification extends Mage_Core_Model_Resource_Db_Abstract {
4
+ protected function _construct() {
5
+ $this->_init('securetrading_stpp/notifications', 'notification_id');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Payment/Redirect/Request.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Payment_Redirect_Request extends Mage_Core_Model_Resource_Db_Abstract {
4
+ protected function _construct() {
5
+ $this->_init('securetrading_stpp/requests', 'request_id');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Payment/Redirect/Request/Collection.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Payment_Redirect_Request_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
4
+ protected function _construct() {
5
+ $this->_init('securetrading_stpp/payment_redirect_request');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Transaction.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Transaction extends Mage_Core_Model_Resource_Db_Abstract {
4
+ protected $_isPkAutoIncrement = false;
5
+
6
+ protected function _construct() {
7
+ $this->_init('securetrading_stpp/transactions', 'transaction_id');
8
+ }
9
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Transaction/Collection.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Transaction_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
4
+ protected function _construct() {
5
+ $this->_init('securetrading_stpp/transaction');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Transaction/Types.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Transaction_Types extends Mage_Core_Model_resource_Db_Abstract {
4
+ const TYPE_AUTH = 'auth';
5
+ const TYPE_THREEDQUERY = 'threedquery';
6
+ const TYPE_RISKDEC = 'riskdec';
7
+ const TYPE_CARDSTORE = 'cardstore';
8
+ const TYPE_TRANSACTIONUPDATE = 'transactionupdate';
9
+ const TYPE_TRANSACTIONQUERY = 'transactionquery';
10
+ const TYPE_ACCOUNTCHECK = 'accountcheck';
11
+ const TYPE_ERROR = 'error';
12
+
13
+ protected function _construct() {
14
+ $this->_init('securetrading_stpp/transaction_types', 'type_id');
15
+ }
16
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Transaction/Types/Collection.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Transaction_Types_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
4
+ protected function _construct() {
5
+ $this->_init('securetrading_stpp/transaction_types');
6
+ }
7
+
8
+ public function toSingleDimensionArray() {
9
+ $array = $this->toArray();
10
+ $finalArray = array();
11
+
12
+ foreach($array['items'] as $item) {
13
+ $finalArray[$item['type_id']] = $item['type_name'];
14
+ }
15
+ return $finalArray;
16
+ }
17
+ }
app/code/local/Securetrading/Stpp/Model/Source/Cardtypes.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Source_Cardtypes {
4
+ public function toOptionArray()
5
+ {
6
+ $cardTypes = Mage::getModel('securetrading_stpp/integration')->getCardTypes();
7
+ $newArray = array();
8
+
9
+ foreach($cardTypes as $cardKey => $cardString) {
10
+ $newArray[] = array(
11
+ 'value' => $cardKey,
12
+ 'label' => $cardString,
13
+ );
14
+ }
15
+ return $newArray;
16
+ }
17
+ }
app/code/local/Securetrading/Stpp/Model/Source/Connection.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Source_Connection {
4
+ public function toOptionArray()
5
+ {
6
+ $connections = Mage::getModel('securetrading_stpp/integration')->getConnections();
7
+ $newArray = array();
8
+
9
+ foreach($connections as $key => $name) {
10
+ $newArray[] = array(
11
+ 'value' => $key,
12
+ 'label' => $name,
13
+ );
14
+ }
15
+ return $newArray;
16
+ }
17
+ }
app/code/local/Securetrading/Stpp/Model/Source/Paymentaction.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Source_Paymentaction
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE, 'label' => 'Authorize Only'),
9
+ array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE, 'label' => 'Authorize & Capture'),
10
+ );
11
+ }
12
+ }
app/code/local/Securetrading/Stpp/Model/Source/Settleduedate.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Source_Settleduedate {
4
+ public function toOptionArray()
5
+ {
6
+ $settleDueDates = Mage::getModel('securetrading_stpp/integration')->getSettleDueDates();
7
+ $newArray = array();
8
+
9
+ foreach($settleDueDates as $date => $dateString) {
10
+ $newArray[] = array(
11
+ 'value' => $date,
12
+ 'label' => $dateString,
13
+ );
14
+ }
15
+ return $newArray;
16
+ }
17
+ }
app/code/local/Securetrading/Stpp/Model/Source/Settlestatus.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SecureTrading_Stpp_Model_Source_Settlestatus {
4
+ public function toOptionArray()
5
+ {
6
+ $settleStatuses = Mage::getModel('securetrading_stpp/integration')->getSettleStatuses();
7
+ unset($settleStatuses['2'], $settleStatuses['3']);
8
+
9
+ $newArray = array();
10
+
11
+ foreach($settleStatuses as $settleStatus => $settleStatusString) {
12
+ $newArray[] = array(
13
+ 'value' => $settleStatus,
14
+ 'label' => $settleStatusString,
15
+ );
16
+ }
17
+ return $newArray;
18
+ }
19
+ }
app/code/local/Securetrading/Stpp/Model/Transaction.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Transaction extends Mage_Core_Model_Abstract {
4
+ protected function _construct() {
5
+ $this->_init('securetrading_stpp/transaction');
6
+ }
7
+
8
+ protected function _beforeSave() {
9
+ $this->setLastUpdatedAt(Mage::getModel('core/date')->gmtDate());
10
+ return parent::_beforeSave();
11
+ }
12
+
13
+ protected function _setApiData($key, array $data = array()) {
14
+ $this->setData($key, serialize($data));
15
+ return $this;
16
+ }
17
+
18
+ protected function _getApiData($key) {
19
+ $array = unserialize($this->getData($key));
20
+ $return = is_array($array) ? $array : array();
21
+ return $return;
22
+ }
23
+
24
+ public function getRequestData() {
25
+ return $this->_getApiData('request_data');
26
+ }
27
+
28
+ public function setRequestData(array $data = array()) {
29
+ return $this->_setApiData('request_data', $data);
30
+ }
31
+
32
+ public function getResponseData() {
33
+ return $this->_getApiData('response_data');
34
+ }
35
+
36
+ public function setResponseData(array $data = array()) {
37
+ if (array_key_exists('maskedpan', $data)) {
38
+ unset($data['maskedpan']);
39
+ }
40
+ return $this->_setApiData('response_data', $data);
41
+ }
42
+
43
+ public function getParentTransactionReference() {
44
+ $transaction = Mage::getModel('securetrading_stpp/transaction')->load($this->getParentTransactionId());
45
+
46
+ if ($transaction) {
47
+ return $transaction->getTransactionReference();
48
+ }
49
+ return '';
50
+ }
51
+
52
+ public function loadByParentTransactionReference($parentTransactionReference, $graceful = false) {
53
+ $this->load($parentTransactionReference, 'transaction_reference');
54
+
55
+ if (!$this->getTransactionId()) {
56
+ if ($graceful) {
57
+ return false;
58
+ }
59
+ throw new Stpp_Exception(sprintf(Mage::helper('securetrading_stpp')->__('A transaction with parent transaction reference "%s" cannot be found.'), $parentTransactionReference));
60
+ }
61
+ return $this;
62
+ }
63
+ }
app/code/local/Securetrading/Stpp/Model/Transaction/Types.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Transaction_Types extends Mage_Core_Model_Abstract {
4
+ const TYPE_AUTH = 'auth';
5
+ const TYPE_THREEDQUERY = 'threedquery';
6
+ const TYPE_RISKDEC = 'riskdec';
7
+ const TYPE_CARDSTORE = 'cardstore';
8
+ const TYPE_TRANSACTIONUPDATE ='transactionupdate';
9
+ const TYPE_TRANSACTIONQUERY = 'transactionquery';
10
+ const TYPE_ACCOUNTCHECK = 'accountcheck';
11
+ const TYPE_ERROR = 'error';
12
+
13
+ function _construct() {
14
+ $this->_init('securetrading_stpp/transaction_types');
15
+ }
16
+ }
app/code/local/Securetrading/Stpp/Model/Transport.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Transport extends Mage_Core_Model_Abstract {
4
+
5
+ }
app/code/local/Securetrading/Stpp/controllers/Direct/PostController.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Direct_PostController extends Mage_Core_Controller_Front_Action {
4
+ protected $_methodInstance;
5
+
6
+ public function preDispatch() {
7
+ parent::preDispatch();
8
+
9
+ $orderIncrementId = Mage::getModel('checkout/session')->getLastRealOrderId();
10
+ $this->_methodInstance = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId)->getPayment()->getMethodInstance();
11
+
12
+ if ($this->_methodInstance->getCode() !== Mage::getModel('securetrading_stpp/payment_direct')->getCode()) {
13
+ throw new Exception(Mage::helper('securetrading_stpp')->__('Cannot access payment method.'));
14
+ }
15
+ }
16
+
17
+ public function rawAction() {
18
+ $this->loadLayout();;
19
+ $this->renderLayout();
20
+ }
21
+
22
+ public function containerAction() {
23
+ $this->loadLayout();
24
+ $this->renderLayout();
25
+ }
26
+
27
+ public function iframeAction() {
28
+ Mage::register(Securetrading_Stpp_Block_Payment_Iframe::REGISTRY_IFRAME_HEIGHT_KEY, $this->_methodInstance->getConfigData('api_iframe_height'));
29
+ Mage::register(Securetrading_Stpp_Block_Payment_Iframe::REGISTRY_IFRAME_WIDTH_KEY, $this->_methodInstance->getConfigData('api_iframe_width'));
30
+ $this->loadLayout();
31
+ $this->renderLayout();
32
+ }
33
+ }
app/code/local/Securetrading/Stpp/controllers/DirectController.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_DirectController extends Mage_Core_Controller_Front_Action {
4
+ public function returnAction() {
5
+ $result = Mage::getModel('securetrading_stpp/payment_direct')->run3dAuth();
6
+
7
+ if ($result) {
8
+ $path = 'checkout/onepage/success';
9
+ $arguments = array();
10
+ }
11
+ else {
12
+ $path = 'checkout/onepage/index';
13
+ $arguments = array();
14
+ }
15
+
16
+ $queryArgs = array('url' => Mage::getUrl($path, $arguments));
17
+ $this->_redirect('securetrading/payment/location', array('_query' => $queryArgs));
18
+ }
19
+ }
app/code/local/Securetrading/Stpp/controllers/PaymentController.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_PaymentController extends Mage_Core_Controller_Front_Action {
4
+ public function locationAction() {
5
+ $url = $this->getRequest()->getParam('url');
6
+ Mage::register(Securetrading_Stpp_Block_Payment_Location::URL_REGISTRY_KEY, $url);
7
+ $this->loadLayout();
8
+ $this->renderLayout();
9
+ }
10
+ }
app/code/local/Securetrading/Stpp/controllers/Redirect/PostController.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Redirect_PostController extends Mage_Core_Controller_Front_Action {
4
+ protected $_methodInstance;
5
+
6
+ public function preDispatch() {
7
+ parent::preDispatch();
8
+
9
+ $orderIncrementId = Mage::getModel('checkout/session')->getLastRealOrderId();
10
+
11
+ if ($orderIncrementId === null) {
12
+ throw new Exception(Mage::helper('securetrading_stpp')->__('No order ID.'));
13
+ }
14
+
15
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
16
+
17
+ $this->_methodInstance = $order->getPayment()->getMethodInstance();
18
+
19
+ if ($this->_methodInstance->getCode() !== Mage::getModel('securetrading_stpp/payment_redirect')->getCode()) {
20
+ throw new Exception(Mage::helper('securetrading_stpp')->__('Cannot access payment method.'));
21
+ }
22
+
23
+ if ($order->getStatus() !== Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES) {
24
+ throw new Exception(Mage::helper('securetrading_stpp')->__('Order not pending payment pages.'));
25
+ }
26
+ }
27
+
28
+ protected function _prepareResult() {
29
+ $transport = $this->_methodInstance->prepareData();
30
+ Mage::register(Securetrading_Stpp_Block_Payment_Redirect_Post::REGISTRY_TRANSPORT_KEY, $transport);
31
+ }
32
+
33
+ public function rawAction() {
34
+ $this->_prepareResult();
35
+ $this->loadLayout();
36
+ $this->renderLayout();
37
+ }
38
+
39
+ public function containerAction() {
40
+ $this->_prepareResult();
41
+ $this->loadLayout();
42
+ $this->renderLayout();
43
+ }
44
+
45
+ public function iframeAction() {
46
+ Mage::register(Securetrading_Stpp_Block_Payment_Iframe::REGISTRY_IFRAME_HEIGHT_KEY, $this->_methodInstance->getConfigData('ppg_iframe_height'));
47
+ Mage::register(Securetrading_Stpp_Block_Payment_Iframe::REGISTRY_IFRAME_WIDTH_KEY, $this->_methodInstance->getConfigData('ppg_iframe_width'));
48
+ $this->loadLayout();
49
+ $this->renderLayout();
50
+ }
51
+ }
app/code/local/Securetrading/Stpp/controllers/RedirectController.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_RedirectController extends Mage_Core_Controller_Front_Action {
4
+ public function redirectAction() {
5
+ Mage::getModel('securetrading_stpp/payment_redirect')
6
+ ->log(sprintf('In %s.', __METHOD__))
7
+ ->runRedirect();
8
+
9
+ $path = 'checkout/onepage/success';
10
+ $arguments = array();
11
+
12
+ $queryArgs = array('url' => Mage::getUrl($path, $arguments));
13
+ $this->_redirect('securetrading/payment/location', array('_query' => $queryArgs));
14
+ }
15
+
16
+ public function notificationAction() {
17
+ $model = Mage::getModel('securetrading_stpp/payment_redirect')
18
+ ->log(sprintf('In %s.', __METHOD__))
19
+ ->runNotification();
20
+ exit($this->__("Notification complete."));
21
+ }
22
+ }
app/code/local/Securetrading/Stpp/controllers/Sales/Order/CreateController.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once(Mage::getModuleDir('controllers', 'Mage_Adminhtml') . DS . 'Sales' . DS . 'Order' . DS . 'CreateController.php');
4
+
5
+ class Securetrading_Stpp_Sales_Order_CreateController extends Mage_Adminhtml_Sales_Order_CreateController{
6
+ public $_publicActions = array('redirect');
7
+
8
+ protected function _isAllowed() {
9
+ $action = strtolower($this->getRequest()->getActionName());
10
+ if (in_array($action, array('post', 'redirect'))) {
11
+ return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/create');
12
+ }
13
+ else {
14
+ return parent::_isAllowed();
15
+ }
16
+ }
17
+
18
+ public function saveAction() {
19
+ try {
20
+ // Start ST added.
21
+ if ($tempPaymentData = $this->getRequest()->getPost('payment')) {
22
+ if ($tempPaymentData['method'] !== Mage::getModel('securetrading_stpp/payment_redirect')->getCode()) {
23
+ return parent::saveAction();
24
+ }
25
+ }
26
+ // End ST added.
27
+
28
+ $this->_processActionData('save');
29
+ if ($paymentData = $this->getRequest()->getPost('payment')) {
30
+ $this->_getOrderCreateModel()->setPaymentData($paymentData);
31
+ $this->_getOrderCreateModel()->getQuote()->getPayment()->addData($paymentData);
32
+ }
33
+
34
+ $order = $this->_getOrderCreateModel()
35
+ ->setIsValidate(true)
36
+ ->importPostData($this->getRequest()->getPost('order'))
37
+ ->createOrder();
38
+
39
+ // Start ST added.
40
+ $this->_getSession()->setLastOrderIncrementId($order->getIncrementId());
41
+ $this->_redirect('*/sales_order_create/post', array('order_increment_id' => $order->getIncrementId()));
42
+ return;
43
+ // end ST added.
44
+ $this->_getSession()->clear();
45
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The order has been created.'));
46
+ $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
47
+ } catch (Mage_Payment_Model_Info_Exception $e) {
48
+ $this->_getOrderCreateModel()->saveQuote();
49
+ $message = $e->getMessage();
50
+ if( !empty($message) ) {
51
+ $this->_getSession()->addError($message);
52
+ }
53
+ $this->_redirect('*/*/');
54
+ } catch (Mage_Core_Exception $e){
55
+ $message = $e->getMessage();
56
+ if( !empty($message) ) {
57
+ $this->_getSession()->addError($message);
58
+ }
59
+ $this->_redirect('*/*/');
60
+ }
61
+ catch (Exception $e){
62
+ $this->_getSession()->addException($e, $this->__('Order saving error: %s', $e->getMessage()));
63
+ $this->_redirect('*/*/');
64
+ }
65
+ }
66
+
67
+ public function postAction() {
68
+ $orderIncrementId = $this->getRequest()->get('order_increment_id');
69
+ $transport = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId)->getPayment()->getMethodInstance()->prepareData(true);
70
+ Mage::register(Securetrading_Stpp_Block_Payment_Redirect_Post::REGISTRY_TRANSPORT_KEY, $transport);
71
+ $this->loadLayout();
72
+ $this->renderLayout();
73
+ }
74
+
75
+ public function redirectAction() {
76
+ Mage::getModel('securetrading_stpp/payment_redirect')->runRedirect();
77
+
78
+ $orderIncrementId = $this->_getSession()->getLastOrderIncrementId();
79
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
80
+
81
+ $path = '*/sales_order/view';
82
+ $arguments = array('order_id' => $order->getId());
83
+ $queryArgs = array('url' => Mage::getUrl($path, $arguments));
84
+ $this->_redirect('securetrading/payment/location', array('_query' => $queryArgs));
85
+
86
+ $this->_getSession()->clear();
87
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The order has been created.'));
88
+ }
89
+ }
app/code/local/Securetrading/Stpp/controllers/Securetrading/TransactionsController.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Securetrading_TransactionsController extends Mage_Adminhtml_Controller_Action {
4
+ public function indexAction() {
5
+ $this
6
+ ->_title($this->__('Sales'))
7
+ ->_title($this->__('SecureTrading Transactions'));
8
+
9
+ $this->loadLayout()->_setActiveMenu('sales/securetrading_transactions');
10
+ $this->renderlayout();
11
+ }
12
+
13
+ public function singleAction() {
14
+ $tid = $this->getRequest()->getParam('transaction_id');
15
+ $transaction = Mage::getModel('securetrading_stpp/transaction')->load($tid);
16
+
17
+ Mage::register('current_transaction', $transaction);
18
+
19
+ $tRef = $transaction->getTransactionReference() ?: 'No Ref';
20
+
21
+ $this
22
+ ->_title($this->__('Sales'))
23
+ ->_title($this->__('SecureTrading Transactions'))
24
+ ->_title('#' . $transaction->getTransactionId() . ' (' . $tRef . ')');
25
+
26
+ $this->loadLayout()->_setActiveMenu('sales/securetrading_transactions');
27
+ $this->renderLayout();
28
+ }
29
+ }
app/code/local/Securetrading/Stpp/etc/adminhtml.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <menu>
3
+ <sales>
4
+ <children>
5
+ <securetrading_transactions translate="title" module="securetrading_stpp">
6
+ <title>ST Transactions</title>
7
+ <action>adminhtml/securetrading_transactions/index</action>
8
+ <sort_order>999</sort_order>
9
+ </securetrading_transactions>
10
+ </children>
11
+ </sales>
12
+ </menu>
13
+ <acl>
14
+ <resources>
15
+ <admin>
16
+ <children>
17
+ <sales>
18
+ <children>
19
+ <securetrading_transactions translate="title" module="securetrading_stpp">
20
+ <title>ST Transactions</title>
21
+ </securetrading_transactions>
22
+ </children>
23
+ </sales>
24
+ </children>
25
+ </admin>
26
+ </resources>
27
+ </acl>
28
+ </config>
app/code/local/Securetrading/Stpp/etc/config.xml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Securetrading_Stpp>
6
+ <version>3.0.0</version>
7
+ </Securetrading_Stpp>
8
+ </modules>
9
+
10
+ <frontend>
11
+ <layout>
12
+ <updates>
13
+ <securetrading>
14
+ <file module="Securetrading_Stpp">securetrading.xml</file>
15
+ </securetrading>
16
+ </updates>
17
+ </layout>
18
+
19
+ <routers>
20
+ <securetrading_stpp>
21
+ <use>standard</use>
22
+ <args>
23
+ <module>Securetrading_Stpp</module>
24
+ <frontName>securetrading</frontName>
25
+ </args>
26
+ </securetrading_stpp>
27
+ </routers>
28
+ </frontend>
29
+
30
+ <adminhtml>
31
+ <layout>
32
+ <updates>
33
+ <securetrading>
34
+ <file module="Securetrading_Stpp">securetrading.xml</file>
35
+ </securetrading>
36
+ </updates>
37
+ </layout>
38
+ </adminhtml>
39
+
40
+ <admin>
41
+ <routers>
42
+ <adminhtml>
43
+ <args>
44
+ <modules>
45
+ <Securetrading_Stpp before="Mage_Adminhtml">Securetrading_Stpp</Securetrading_Stpp>
46
+ </modules>
47
+ </args>
48
+ </adminhtml>
49
+ </routers>
50
+ </admin>
51
+
52
+ <global>
53
+ <resources>
54
+ <securetrading_stpp>
55
+ <setup>
56
+ <module>Securetrading_Stpp</module>
57
+ </setup>
58
+ </securetrading_stpp>
59
+ </resources>
60
+ <helpers>
61
+ <securetrading_stpp>
62
+ <class>Securetrading_Stpp_Helper</class>
63
+ </securetrading_stpp>
64
+ </helpers>
65
+ <blocks>
66
+ <securetrading_stpp>
67
+ <class>Securetrading_Stpp_Block</class>
68
+ </securetrading_stpp>
69
+ </blocks>
70
+ <models>
71
+ <securetrading_stpp>
72
+ <resourceModel>securetrading_stpp_resource</resourceModel>
73
+ <class>Securetrading_Stpp_Model</class>
74
+ </securetrading_stpp>
75
+ <securetrading_stpp_resource>
76
+ <class>Securetrading_Stpp_Model_Resource</class>
77
+ <entities>
78
+ <requests>
79
+ <table>securetrading_stpp_requests</table>
80
+ </requests>
81
+ <notifications>
82
+ <table>securetrading_stpp_notifications</table>
83
+ </notifications>
84
+ <transactions>
85
+ <table>securetrading_stpp_transactions</table>
86
+ </transactions>
87
+ <transaction_types>
88
+ <table>securetrading_stpp_transaction_types</table>
89
+ </transaction_types>
90
+ </entities>
91
+ </securetrading_stpp_resource>
92
+ </models>
93
+ <events>
94
+ <checkout_submit_all_after>
95
+ <observers>
96
+ <securetrading_stpp>
97
+ <class>Securetrading_Stpp_Model_Observer</class>
98
+ <method>onCheckoutSubmitAllAfter</method>
99
+ </securetrading_stpp>
100
+ </observers>
101
+ </checkout_submit_all_after>
102
+ <payment_info_block_prepare_specific_information>
103
+ <observers>
104
+ <securetrading_stpp>
105
+ <class>Securetrading_Stpp_Model_Observer</class>
106
+ <method>onPaymentInfoBlockPrepareSpecificInformation</method>
107
+ </securetrading_stpp>
108
+ </observers>
109
+ </payment_info_block_prepare_specific_information>
110
+ </events>
111
+ </global>
112
+
113
+ <crontab>
114
+ <jobs>
115
+ <securetrading_stpp_abandoned_order_cleanup>
116
+ <schedule>
117
+ <cron_expr>0 * * * *</cron_expr>
118
+ </schedule>
119
+ <run>
120
+ <model>securetrading_stpp/cron::abandonedOrderCleanup</model>
121
+ </run>
122
+ </securetrading_stpp_abandoned_order_cleanup>
123
+ <securetrading_Stpp_Data_Request_table_cleanup>
124
+ <schedule>
125
+ <cron_expr>0 * * * *</cron_expr>
126
+ </schedule>
127
+ <run>
128
+ <model>securetrading_stpp/cron::requestTableCleanup</model>
129
+ </run>
130
+ </securetrading_Stpp_Data_Request_table_cleanup>
131
+ </jobs>
132
+ </crontab>
133
+
134
+ <default>
135
+ <payment>
136
+ <securetrading_stpp_direct>
137
+ <model>securetrading_stpp/payment_direct</model>
138
+ <accepted_cards backend_model="securetrading_stpp/adminhtml_system_config_backend_multiselect" />
139
+ <stapi_alias backend_model="adminhtml/system_config_backend_encrypted" />
140
+ <stapi_host backend_model="adminhtml/system_config_backend_encrypted" />
141
+ <stapi_port backend_model="adminhtml/system_config_backend_encrypted" />
142
+ <ws_alias backend_model="adminhtml/system_config_backend_encrypted" />
143
+ <ws_username backend_model="adminhtml/system_config_backend_encrypted" />
144
+ <ws_password backend_model="adminhtml/system_config_backend_encrypted" />
145
+ <api_iframe_width>100%</api_iframe_width>
146
+ <api_iframe_height>600px</api_iframe_height>
147
+ </securetrading_stpp_direct>
148
+ <securetrading_stpp_redirect>
149
+ <model>securetrading_stpp/payment_redirect</model>
150
+ <site_security_password backend_model="adminhtml/system_config_backend_encrypted" />
151
+ <notification_password backend_model="adminhtml/system_config_backend_encrypted" />
152
+ <ppg_iframe_width>100%</ppg_iframe_width>
153
+ <ppg_iframe_height>600px</ppg_iframe_height>
154
+ </securetrading_stpp_redirect>
155
+ </payment>
156
+ </default>
157
+ </config>
app/code/local/Securetrading/Stpp/etc/system.xml ADDED
@@ -0,0 +1,546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <securetrading_stpp_group translate="label comment" module="securetrading_stpp">
7
+ <label>SecureTrading STPP</label>
8
+ <comment>Please configure the interface you wish to use.</comment>
9
+ <frontend_class>complex</frontend_class>
10
+ <frontend_model>securetrading_stpp/adminhtml_system_config_group</frontend_model>
11
+ <expanded>1</expanded>
12
+ <sort_order>1</sort_order>
13
+ <show_in_default>1</show_in_default>
14
+ <show_in_website>1</show_in_website>
15
+ <show_in_store>1</show_in_store>
16
+ <fields>
17
+ <securetrading_stpp_redirect type="group" translate="label comment" module="securetrading_stpp">
18
+ <label>SecureTrading Payment Pages</label>
19
+ <comment>Redirects your customers to SecureTrading's secure payment servers.</comment>
20
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
21
+ <expanded>0</expanded>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <securetrading_stpp_redirect_config_basic type="group" translate="label comment" module="securetrading_stpp">
27
+ <label>Basic Configuration</label>
28
+ <comment>Affects how Magento works with your payment method.</comment>
29
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
30
+ <expanded>0</expanded>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <fields>
36
+ <active>
37
+ <config_path>payment/securetrading_stpp_redirect/active</config_path>
38
+ <frontend_type>select</frontend_type>
39
+ 1 <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>0</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </active>
45
+ <title>
46
+ <config_path>payment/securetrading_stpp_redirect/title</config_path>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>1</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </title>
53
+ <description>
54
+ <config_path>payment/securetrading_stpp_redirect/description</config_path>
55
+ <frontend_type>textarea</frontend_type>
56
+ <sort_order>2</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </description>
61
+ <allowspecific>
62
+ <config_path>payment/securetrading_stpp_redirect/allowspecific</config_path>
63
+ <frontend_type>allowspecific</frontend_type>
64
+ <sort_order>3</sort_order>
65
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </allowspecific>
70
+ <specificcountry>
71
+ <config_path>payment/securetrading_stpp_redirect/specificcountry</config_path>
72
+ <frontend_type>multiselect</frontend_type>
73
+ <sort_order>4</sort_order>
74
+ <source_model>adminhtml/system_config_source_country</source_model>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </specificcountry>
79
+ <ppg_use_iframe>
80
+ <config_path>payment/securetrading_stpp_redirect/ppg_use_iframe</config_path>
81
+ <frontend_type>select</frontend_type>
82
+ <source_model>adminhtml/system_config_source_yesno</source_model>
83
+ <sort_order>5</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </ppg_use_iframe>
88
+ <ppg_iframe_height>
89
+ <config_path>payment/securetrading_stpp_redirect/ppg_iframe_height</config_path>
90
+ <frontend_type>text</frontend_type>
91
+ <sort_order>6</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ </ppg_iframe_height>
96
+ <ppg_iframe_width>
97
+ <config_path>payment/securetrading_stpp_redirect/ppg_iframe_width</config_path>
98
+ <frontend_type>text</frontend_type>
99
+ <sort_order>7</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ </ppg_iframe_width>
104
+ </fields>
105
+ </securetrading_stpp_redirect_config_basic>
106
+ <securetrading_stpp_redirect_config_gateway type="group" translate="label comment" module="securetrading_stpp">
107
+ <label>Gateway Configuration</label>
108
+ <comment>Affect how requests to and responses from the SecureTrading gateway are processed.</comment>
109
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
110
+ <expanded>0</expanded>
111
+ <sort_order>1</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ <fields>
116
+ <site_reference>
117
+ <config_path>payment/securetrading_stpp_redirect/site_reference</config_path>
118
+ <frontend_type>text</frontend_type>
119
+ <sort_order>0</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>1</show_in_store>
123
+ </site_reference>
124
+ <use_site_security>
125
+ <config_path>payment/securetrading_stpp_redirect/use_site_security</config_path>
126
+ <frontend_type>select</frontend_type>
127
+ <source_model>adminhtml/system_config_source_yesno</source_model>
128
+ <sort_order>1</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ </use_site_security>
133
+ <site_security_password>
134
+ <config_path>payment/securetrading_stpp_redirect/site_security_password</config_path>
135
+ <frontend_type>text</frontend_type>
136
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
137
+ <sort_order>2</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ </site_security_password>
142
+ <use_notification_password>
143
+ <config_path>payment/securetrading_stpp_redirect/use_notification_password</config_path>
144
+ <frontend_type>select</frontend_type>
145
+ <source_model>adminhtml/system_config_source_yesno</source_model>
146
+ <sort_order>3</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>1</show_in_store>
150
+ </use_notification_password>
151
+ <notification_password>
152
+ <config_path>payment/securetrading_stpp_redirect/notification_password</config_path>
153
+ <frontend_type>text</frontend_type>
154
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
155
+ <sort_order>4</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ </notification_password>
160
+ <parent_css>
161
+ <config_path>payment/securetrading_stpp_redirect/parent_css</config_path>
162
+ <frontend_type>text</frontend_type>
163
+ <sort_order>5</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ </parent_css>
168
+ <child_css>
169
+ <config_path>payment/securetrading_stpp_redirect/child_css</config_path>
170
+ <frontend_type>text</frontend_type>
171
+ <sort_order>6</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>1</show_in_store>
175
+ </child_css>
176
+ <parent_js>
177
+ <config_path>payment/securetrading_stpp_redirect/parent_js</config_path>
178
+ <frontend_type>text</frontend_type>
179
+ <sort_order>7</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>1</show_in_store>
183
+ </parent_js>
184
+ <child_js>
185
+ <config_path>payment/securetrading_stpp_redirect/child_js</config_path>
186
+ <frontend_type>text</frontend_type>
187
+ <sort_order>8</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>1</show_in_website>
190
+ <show_in_store>1</show_in_store>
191
+ </child_js>
192
+ <use_api>
193
+ <config_path>payment/securetrading_stpp_redirect/use_api</config_path>
194
+ <frontend_type>select</frontend_type>
195
+ <source_model>adminhtml/system_config_source_yesno</source_model>
196
+ <sort_order>9</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ </use_api>
201
+ <payment_action>
202
+ <config_path>payment/securetrading_stpp_redirect/payment_action</config_path>
203
+ <frontend_type>select</frontend_type>
204
+ <source_model>securetrading_stpp/source_paymentaction</source_model>
205
+ <sort_order>10</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ <show_in_store>1</show_in_store>
209
+ </payment_action>
210
+ <settle_due_date>
211
+ <config_path>payment/securetrading_stpp_redirect/settle_due_date</config_path>
212
+ <frontend_type>select</frontend_type>
213
+ <source_model>securetrading_stpp/source_settleduedate</source_model>
214
+ <sort_order>11</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ </settle_due_date>
219
+ <settle_status>
220
+ <config_path>payment/securetrading_stpp_redirect/settle_status</config_path>
221
+ <frontend_type>select</frontend_type>
222
+ <source_model>securetrading_stpp/source_settlestatus</source_model>
223
+ <sort_order>12</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ </settle_status>
228
+ </fields>
229
+ </securetrading_stpp_redirect_config_gateway>
230
+ </fields>
231
+ </securetrading_stpp_redirect>
232
+ <securetrading_stpp_direct type="group" translate="label comment" module="securetrading_stpp">
233
+ <label>SecureTrading API</label>
234
+ <comment>Allows your store to capture credit card details. Your store must be PCI compliant to use this payment method.</comment>
235
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
236
+ <expanded>0</expanded>
237
+ <sort_order>1</sort_order>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>1</show_in_store>
241
+ <fields>
242
+ <securetrading_stpp_direct_config_basic type="group" translate="label comment" module="securetrading_stpp">
243
+ <label>Basic Configuration</label>
244
+ <comment>Affects how Magento works with your payment method.</comment>
245
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
246
+ <expanded>0</expanded>
247
+ <sort_order>0</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ <fields>
252
+ <active>
253
+ <config_path>payment/securetrading_stpp_direct/active</config_path>
254
+ <frontend_type>select</frontend_type>
255
+ <source_model>adminhtml/system_config_source_yesno</source_model>
256
+ <sort_order>0</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>1</show_in_store>
260
+ </active>
261
+ <title>
262
+ <config_path>payment/securetrading_stpp_direct/title</config_path>
263
+ <frontend_type>text</frontend_type>
264
+ <sort_order>1</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ </title>
269
+ <description>
270
+ <config_path>payment/securetrading_stpp_direct/description</config_path>
271
+ <frontend_type>textarea</frontend_type>
272
+ <sort_order>2</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>1</show_in_store>
276
+ </description>
277
+ <allowspecific>
278
+ <config_path>payment/securetrading_stpp_direct/allowspecific</config_path>
279
+ <frontend_type>allowspecific</frontend_type>
280
+ <sort_order>3</sort_order>
281
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
282
+ <show_in_default>1</show_in_default>
283
+ <show_in_website>1</show_in_website>
284
+ <show_in_store>1</show_in_store>
285
+ </allowspecific>
286
+ <specificcountry>
287
+ <config_path>payment/securetrading_stpp_direct/specificcountry</config_path>
288
+ <frontend_type>multiselect</frontend_type>
289
+ <sort_order>4</sort_order>
290
+ <source_model>adminhtml/system_config_source_country</source_model>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>1</show_in_website>
293
+ <show_in_store>1</show_in_store>
294
+ </specificcountry>
295
+ <api_use_iframe>
296
+ <config_path>payment/securetrading_stpp_direct/api_use_iframe</config_path>
297
+ <frontend_type>select</frontend_type>
298
+ <source_model>adminhtml/system_config_source_yesno</source_model>
299
+ <sort_order>6</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>1</show_in_website>
302
+ <show_in_store>1</show_in_store>
303
+ </api_use_iframe>
304
+ <api_iframe_height>
305
+ <config_path>payment/securetrading_stpp_direct/api_iframe_height</config_path>
306
+ <frontend_type>text</frontend_type>
307
+ <sort_order>7</sort_order>
308
+ <show_in_default>1</show_in_default>
309
+ <show_in_website>1</show_in_website>
310
+ <show_in_store>1</show_in_store>
311
+ </api_iframe_height>
312
+ <api_iframe_width>
313
+ <config_path>payment/securetrading_stpp_direct/api_iframe_width</config_path>
314
+ <frontend_type>text</frontend_type>
315
+ <sort_order>8</sort_order>
316
+ <show_in_default>1</show_in_default>
317
+ <show_in_website>1</show_in_website>
318
+ <show_in_store>1</show_in_store>
319
+ </api_iframe_width>
320
+ </fields>
321
+ </securetrading_stpp_direct_config_basic>
322
+ <securetrading_stpp_direct_config_gateway type="group" translate="label comment" module="securetrading_stpp">
323
+ <label>Gateway Configuration</label>
324
+ <comment>Affect how requests to and responses from the SecureTrading gateway are processed.</comment>
325
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
326
+ <expanded>0</expanded>
327
+ <sort_order>1</sort_order>
328
+ <show_in_default>1</show_in_default>
329
+ <show_in_website>1</show_in_website>
330
+ <show_in_store>1</show_in_store>
331
+ <fields>
332
+ <site_reference>
333
+ <config_path>payment/securetrading_stpp_direct/site_reference</config_path>
334
+ <frontend_type>text</frontend_type>
335
+ <sort_order>0</sort_order>
336
+ <show_in_default>1</show_in_default>
337
+ <show_in_website>1</show_in_website>
338
+ <show_in_store>1</show_in_store>
339
+ </site_reference>
340
+ <connection>
341
+ <config_path>payment/securetrading_stpp_direct/connection</config_path>
342
+ <comment>You must configure the appropriate connection in the 'Connection Configuration' fieldset after selecting the connection method here.</comment>
343
+ <frontend_type>select</frontend_type>
344
+ <source_model>securetrading_stpp/source_connection</source_model>
345
+ <sort_order>1</sort_order>
346
+ <show_in_default>1</show_in_default>
347
+ <show_in_website>1</show_in_website>
348
+ <show_in_store>1</show_in_store>
349
+ </connection>
350
+ <use_3d_secure>
351
+ <config_path>payment/securetrading_stpp_direct/use_3d_secure</config_path>
352
+ <frontend_type>select</frontend_type>
353
+ <source_model>adminhtml/system_config_source_yesno</source_model>
354
+ <sort_order>2</sort_order>
355
+ <show_in_default>1</show_in_default>
356
+ <show_in_website>1</show_in_website>
357
+ <show_in_store>1</show_in_store>
358
+ </use_3d_secure>
359
+ <use_risk_decision>
360
+ <config_path>payment/securetrading_stpp_direct/use_risk_decision</config_path>
361
+ <frontend_type>select</frontend_type>
362
+ <source_model>adminhtml/system_config_source_yesno</source_model>
363
+ <sort_order>3</sort_order>
364
+ <show_in_default>1</show_in_default>
365
+ <show_in_website>1</show_in_website>
366
+ <show_in_store>1</show_in_store>
367
+ </use_risk_decision>
368
+ <use_card_store>
369
+ <config_path>payment/securetrading_stpp_direct/use_card_store</config_path>
370
+ <frontend_type>select</frontend_type>
371
+ <source_model>adminhtml/system_config_source_yesno</source_model>
372
+ <sort_order>4</sort_order>
373
+ <show_in_default>1</show_in_default>
374
+ <show_in_website>1</show_in_website>
375
+ <show_in_store>1</show_in_store>
376
+ </use_card_store>
377
+ <use_auto_card_store>
378
+ <config_path>payment/securetrading_stpp_direct/use_auto_card_store</config_path>
379
+ <frontend_type>select</frontend_type>
380
+ <source_model>adminhtml/system_config_source_yesno</source_model>
381
+ <sort_order>5</sort_order>
382
+ <show_in_default>1</show_in_default>
383
+ <show_in_website>1</show_in_website>
384
+ <show_in_store>1</show_in_store>
385
+ </use_auto_card_store>
386
+ <delay_risk_decision>
387
+ <config_path>payment/securetrading_stpp_direct/delay_risk_decision</config_path>
388
+ <frontend_type>select</frontend_type>
389
+ <source_model>adminhtml/system_config_source_yesno</source_model>
390
+ <sort_order>6</sort_order>
391
+ <show_in_default>1</show_in_default>
392
+ <show_in_website>1</show_in_website>
393
+ <show_in_store>1</show_in_store>
394
+ </delay_risk_decision>
395
+ <accepted_cards>
396
+ <config_path>payment/securetrading_stpp_direct/accepted_cards</config_path>
397
+ <frontend_type>multiselect</frontend_type>
398
+ <backend_model>securetrading_stpp/adminhtml_system_config_backend_multiselect</backend_model>
399
+ <source_model>securetrading_stpp/source_cardtypes</source_model>
400
+ <sort_order>7</sort_order>
401
+ <show_in_default>1</show_in_default>
402
+ <show_in_website>1</show_in_website>
403
+ <show_in_store>1</show_in_store>
404
+ </accepted_cards>
405
+ <payment_action>
406
+ <config_path>payment/securetrading_stpp_direct/payment_action</config_path>
407
+ <frontend_type>select</frontend_type>
408
+ <source_model>securetrading_stpp/source_paymentaction</source_model>
409
+ <sort_order>8</sort_order>
410
+ <show_in_default>1</show_in_default>
411
+ <show_in_website>1</show_in_website>
412
+ <show_in_store>1</show_in_store>
413
+ </payment_action>
414
+ <settle_due_date>
415
+ <config_path>payment/securetrading_stpp_direct/settle_due_date</config_path>
416
+ <frontend_type>select</frontend_type>
417
+ <source_model>securetrading_stpp/source_settleduedate</source_model>
418
+ <sort_order>9</sort_order>
419
+ <show_in_default>1</show_in_default>
420
+ <show_in_website>1</show_in_website>
421
+ <show_in_store>1</show_in_store>
422
+ </settle_due_date>
423
+ <settle_status>
424
+ <config_path>payment/securetrading_stpp_direct/settle_status</config_path>
425
+ <frontend_type>select</frontend_type>
426
+ <source_model>securetrading_stpp/source_settlestatus</source_model>
427
+ <sort_order>10</sort_order>
428
+ <show_in_default>1</show_in_default>
429
+ <show_in_website>1</show_in_website>
430
+ <show_in_store>1</show_in_store>
431
+ </settle_status>
432
+ </fields>
433
+ </securetrading_stpp_direct_config_gateway>
434
+ <securetrading_stpp_direct_config_connections type="group" translate="label comment" module="securetrading_stpp">
435
+ <label>Connection Configuration</label>
436
+ <comment>Aggregates the configuration for all connection methods provided by this module.</comment>
437
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
438
+ <expanded>0</expanded>
439
+ <sort_order>2</sort_order>
440
+ <show_in_default>1</show_in_default>
441
+ <show_in_website>1</show_in_website>
442
+ <show_in_store>1</show_in_store>
443
+ <fields>
444
+ <securetrading_stpp_api_stapi_group type="group" translate="label comment">
445
+ <label>ST API Settings</label>
446
+ <comment>Contains ST API connection configuration.</comment>
447
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
448
+ <show_in_default>1</show_in_default>
449
+ <show_in_website>1</show_in_website>
450
+ <show_in_store>1</show_in_store>
451
+ <sort_order>0</sort_order>
452
+ <fields>
453
+ <stapi_alias>
454
+ <config_path>payment/securetrading_stpp_direct/stapi_alias</config_path>
455
+ <frontend_type>text</frontend_type>
456
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
457
+ <sort_order>0</sort_order>
458
+ <show_in_default>1</show_in_default>
459
+ <show_in_website>1</show_in_website>
460
+ <show_in_store>1</show_in_store>
461
+ </stapi_alias>
462
+ <stapi_host>
463
+ <config_path>payment/securetrading_stpp_direct/stapi_host</config_path>
464
+ <frontend_type>text</frontend_type>
465
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
466
+ <sort_order>1</sort_order>
467
+ <show_in_default>1</show_in_default>
468
+ <show_in_website>1</show_in_website>
469
+ <show_in_store>1</show_in_store>
470
+ </stapi_host>
471
+ <stapi_port>
472
+ <config_path>payment/securetrading_stpp_direct/stapi_port</config_path>
473
+ <frontend_type>text</frontend_type>
474
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
475
+ <sort_order>2</sort_order>
476
+ <show_in_default>1</show_in_default>
477
+ <show_in_website>1</show_in_website>
478
+ <show_in_store>1</show_in_store>
479
+ </stapi_port>
480
+ </fields>
481
+ </securetrading_stpp_api_stapi_group>
482
+ <securetrading_stpp_api_webservices_group type="group" translate="label comment">
483
+ <label>Web Services Connections</label>
484
+ <comment>Contains Web Services connection configuration.</comment>
485
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
486
+ <show_in_default>1</show_in_default>
487
+ <show_in_website>1</show_in_website>
488
+ <show_in_store>1</show_in_store>
489
+ <sort_order>1</sort_order>
490
+ <fields>
491
+ <ws_alias>
492
+ <config_path>payment/securetrading_stpp_direct/ws_alias</config_path>
493
+ <frontend_type>text</frontend_type>
494
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
495
+ <sort_order>0</sort_order>
496
+ <show_in_default>1</show_in_default>
497
+ <show_in_website>1</show_in_website>
498
+ <show_in_store>1</show_in_store>
499
+ </ws_alias>
500
+ <ws_username>
501
+ <config_path>payment/securetrading_stpp_direct/ws_username</config_path>
502
+ <frontend_type>text</frontend_type>
503
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
504
+ <sort_order>1</sort_order>
505
+ <show_in_default>1</show_in_default>
506
+ <show_in_website>1</show_in_website>
507
+ <show_in_store>1</show_in_store>
508
+ </ws_username>
509
+ <ws_password>
510
+ <config_path>payment/securetrading_stpp_direct/ws_password</config_path>
511
+ <frontend_type>text</frontend_type>
512
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
513
+ <sort_order>2</sort_order>
514
+ <show_in_default>1</show_in_default>
515
+ <show_in_website>1</show_in_website>
516
+ <show_in_store>1</show_in_store>
517
+ </ws_password>
518
+ <ws_verify_ca>
519
+ <config_path>payment/securetrading_stpp_direct/ws_verify_ca</config_path>
520
+ <frontend_type>select</frontend_type>
521
+ <source_model>adminhtml/system_config_source_yesno</source_model>
522
+ <sort_order>3</sort_order>
523
+ <show_in_default>1</show_in_default>
524
+ <show_in_website>1</show_in_website>
525
+ <show_in_store>1</show_in_store>
526
+ </ws_verify_ca>
527
+ <ws_ca_file>
528
+ <config_path>payment/securetrading_stpp_direct/ws_ca_file</config_path>
529
+ <frontend_type>text</frontend_type>
530
+ <sort_order>4</sort_order>
531
+ <show_in_default>1</show_in_default>
532
+ <show_in_website>1</show_in_website>
533
+ <show_in_store>1</show_in_store>
534
+ </ws_ca_file>
535
+ </fields>
536
+ </securetrading_stpp_api_webservices_group>
537
+ </fields>
538
+ </securetrading_stpp_direct_config_connections>
539
+ </fields>
540
+ </securetrading_stpp_direct>
541
+ </fields>
542
+ </securetrading_stpp_group>
543
+ </groups>
544
+ </payment>
545
+ </sections>
546
+ </config>
app/code/local/Securetrading/Stpp/lib/Securetrading.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading {
4
+ protected static $_init = false;
5
+
6
+ protected static $_rootPath;
7
+
8
+ protected static $_codePath;
9
+
10
+ protected static $_corePath;
11
+
12
+ protected static $_overridesPath;
13
+
14
+ public static function init() {
15
+ if (static::$_init === false) {
16
+ static::_init();
17
+ static::$_init = true;
18
+ }
19
+ }
20
+
21
+ public static function cleanup() {
22
+ if (static::$_init === true) {
23
+ spl_autoload_unregister(array('static', '_autoload'));
24
+ static::$_init = false;
25
+ }
26
+ }
27
+
28
+ public static function getRootPath() {
29
+ static::init();
30
+ return static::$_rootPath;
31
+ }
32
+
33
+ public static function getCodePath() {
34
+ static::init();
35
+ return static::$_codePath;
36
+ }
37
+
38
+ public static function getCorePath() {
39
+ static::init();
40
+ return static::$_corePath;
41
+ }
42
+
43
+ public static function getOverridesPath() {
44
+ static::init();
45
+ return static::$_overridesPath;
46
+ }
47
+
48
+ protected static function _init() {
49
+ static::$_rootPath = __DIR__ . DIRECTORY_SEPARATOR;
50
+ static::$_codePath = realpath(static::$_rootPath . 'code') . DIRECTORY_SEPARATOR;
51
+ static::$_corePath = realpath(static::$_codePath . 'core') . DIRECTORY_SEPARATOR;
52
+ static::$_overridesPath = realpath(static::$_codePath . 'overrides') . DIRECTORY_SEPARATOR;
53
+
54
+ $paths = array(
55
+ static::$_rootPath,
56
+ static::$_codePath,
57
+ static::$_corePath,
58
+ static::$_overridesPath,
59
+ );
60
+
61
+ foreach($paths as $k => $path) {
62
+ if ($path === DIRECTORY_SEPARATOR) {
63
+ throw new Exception(sprintf('Invald path: "%s".', $k));
64
+ }
65
+ }
66
+
67
+ spl_autoload_register(array('static', '_autoload'), true, true);
68
+ }
69
+
70
+ protected static function _autoload($class) {
71
+ foreach(array(static::$_corePath, static::$_overridesPath) as $folder) {
72
+ $filePath = $folder . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
73
+ if (file_exists($filePath)) {
74
+ require_once($filePath);
75
+ break;
76
+ }
77
+ }
78
+ }
79
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp {
4
+ public static function getLogsPath() {
5
+ return Securetrading::getRootPath() . 'stpp_logs' . DIRECTORY_SEPARATOR;
6
+ }
7
+
8
+ public static function getLogsArchivePath() {
9
+ return static::getLogsPath() . 'archive' . DIRECTORY_SEPARATOR;
10
+ }
11
+
12
+ public static function getTranslationsPath() {
13
+ return Securetrading::getRootPath() . 'stpp_translations' . DIRECTORY_SEPARATOR;
14
+ }
15
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Actions/Abstract.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Stpp_Actions_Abstract implements Stpp_Actions_BaseInterface {
4
+ public function processError(Stpp_Data_Response $response) {
5
+ return false;
6
+ }
7
+
8
+ public function processAuth(Stpp_Data_Response $response) {
9
+ return $this->_isErrorCodeZero($response);
10
+ }
11
+
12
+ public function process3dQuery(Stpp_Data_Response $response) {
13
+ return $this->_isErrorCodeZero($response);
14
+ }
15
+
16
+ public function processRiskDecision(Stpp_Data_Response $response) {
17
+ return $this->_isErrorCodeZero($response);
18
+ }
19
+
20
+ public function processAccountCheck(Stpp_Data_Response $response) {
21
+ return $this->_isErrorCodeZero($response);
22
+ }
23
+
24
+ public function processCardStore(Stpp_Data_Response $response) {
25
+ return $this->_isErrorCodeZero($response);
26
+ }
27
+
28
+ public function processTransactionUpdate(Stpp_Data_Response $response) {
29
+ return $this->_isErrorCodeZero($response);
30
+ }
31
+
32
+ public function processRefund(Stpp_Data_Response $response) {
33
+ return $this->_isErrorCodeZero($response);
34
+ }
35
+
36
+ public function calculateIsTransactionSuccessful(array $responses, $transactionSuccessful) {
37
+ return $transactionSuccessful;
38
+ }
39
+
40
+ protected function _isErrorCodeZero($response) {
41
+ return $response->get('errorcode') === '0';
42
+ }
43
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Actions/BaseInterface.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Actions_BaseInterface {
4
+ function processError(Stpp_Data_Response $response);
5
+ function processAuth(Stpp_Data_Response $response);
6
+ function process3dQuery(Stpp_Data_Response $response);
7
+ function processRiskDecision(Stpp_Data_Response $response);
8
+ function processAccountCheck(Stpp_Data_Response $response);
9
+ function processCardStore(Stpp_Data_Response $response);
10
+ function processTransactionUpdate(Stpp_Data_Response $response);
11
+ function processRefund(Stpp_Data_Response $response);
12
+ function calculateIsTransactionSuccessful(array $responses, $transactionSuccessful);
13
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/ActionsInterface.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_ActionsInterface extends Stpp_Actions_BaseInterface {
4
+
5
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Base.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Base extends Stpp_Component_Abstract implements Stpp_Api_BaseInterface {
4
+ const INTERFACE_NAME = 'SecureTrading API';
5
+
6
+ public static function getName() {
7
+ return static::INTERFACE_NAME;
8
+ }
9
+
10
+ public function getSend() {
11
+ if ($this->_apiSend === null) {
12
+ throw new Stpp_Exception($this->__('The sender has not been set.'));
13
+ }
14
+ return $this->_apiSend;
15
+ }
16
+
17
+ public function setSend(Stpp_Api_SendInterface $apiSend) {
18
+ $this->_apiSend = $apiSend;
19
+ }
20
+
21
+ public function getProcess() {
22
+ if ($this->_apiProcess === null) {
23
+ throw new Stpp_Exception($this->__('The processor has not been set.'));
24
+ }
25
+ return $this->_apiProcess;
26
+ }
27
+
28
+ public function setProcess(Stpp_Api_ProcessInterface $apiProcess) {
29
+ $this->_apiProcess = $apiProcess;
30
+ }
31
+
32
+ public function run($requests) {
33
+ if (!is_array($requests)) {
34
+ $requests = array($requests);
35
+ }
36
+
37
+ list($cardStoreRequest, $requests) = $this->_startCardStoreHack($requests); // CARDSTORE HACK.
38
+
39
+ $context = $this->getSend()->run($requests);
40
+ $result = $this->getProcess()->run($context);
41
+
42
+ $this->_endCardStoreHack($cardStoreRequest); // CARDSTORE HACK.
43
+
44
+ return $result;
45
+ }
46
+
47
+ // START CARDSTORE HACK.
48
+ protected function _startCardStoreHack(array $requests) {
49
+ $cardStoreRequest = null;
50
+
51
+ foreach($requests as $k => $request) {
52
+ if ($request->get('requesttypedescription') === Stpp_Types::API_CARDSTORE) {
53
+ $cardStoreRequest = $request;
54
+ unset($requests[$k]);
55
+ $requests = array_values($requests);
56
+ }
57
+ }
58
+ return array($cardStoreRequest, $requests);
59
+ }
60
+
61
+ protected function _endCardStoreHack(Stpp_Data_Request $cardStoreRequest = null) {
62
+ if ($cardStoreRequest) {
63
+ $requests = array($cardStoreRequest);
64
+ $context = $this->getSend()->run($requests);
65
+ $this->getProcess()->run($context);
66
+ }
67
+ }
68
+ // END CARDSTORE HACK.
69
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/BaseInterface.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_BaseInterface {
4
+ static function getName();
5
+ function run($requests);
6
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/BaseInterface.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_Connection_BaseInterface {
4
+ static function getKey();
5
+ static function getName();
6
+ function setAlias($alias);
7
+ function getAlias();
8
+ function sendAndReceiveData($xmlString);
9
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/Stapi.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Connection_Stapi extends Stpp_Component_Abstract implements Stpp_Api_Connection_BaseInterface {
4
+ const CONNECTION_KEY = 'Stpp_Connection_Stapi';
5
+
6
+ const CONNECTION_NAME = 'Stpp ST API';
7
+
8
+ protected $_host = '127.0.0.1'; // ST API Default
9
+
10
+ protected $_port = 5000; // ST API Default
11
+
12
+ protected $_alias;
13
+
14
+ public static function getKey() {
15
+ return static::CONNECTION_KEY;
16
+ }
17
+
18
+ public static function getName() {
19
+ return static::CONNECTION_NAME;
20
+ }
21
+
22
+ public function setAlias($alias) {
23
+ $this->_alias = $alias;
24
+ }
25
+
26
+ public function getAlias() {
27
+ return $this->_alias;
28
+ }
29
+
30
+ public function setHost($host) {
31
+ if (!is_string($host)) {
32
+ throw new Stpp_Exception($this->__('The host parameter must be a string.'));
33
+ }
34
+ $this->_host = $host;
35
+ }
36
+
37
+ public function setPort($port) {
38
+ if (!is_string($port) && !is_int($port)) {
39
+ throw new Stpp_Exception($this->__('The port parameter must be a string or an integer.'));
40
+ }
41
+ $this->_port = $port;
42
+ }
43
+
44
+ public function sendAndReceiveData($requestString) {
45
+ if (($socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
46
+ throw new Stpp_Exception(sprintf($this->__('Unable to create socket. Reason: "%s".'), socket_strerror(socket_last_error())));
47
+ }
48
+
49
+ if (socket_connect($socket, $this->_host, $this->_port) === false) {
50
+ throw new Stpp_Exception(sprintf($this->__('Socket unable to connect to %s:%s. Reason: "%s".'), $this->_host, $this->_port, socket_strerror(socket_last_error())));
51
+ }
52
+
53
+ if (socket_write($socket,$requestString) === false) {
54
+ throw new Stpp_Exception(sprintf($this->__('Unable to write to socket. Reason: "%s".'), socket_strerror(socket_last_error())));
55
+ }
56
+
57
+ $responseString = '';
58
+
59
+ while ($buffer = socket_read($socket, 2048)) {
60
+ if ($buffer === false) {
61
+ throw new Stpp_Exception(sprintf($this->__('Unable to read from socket. Reason: "%s".'), socket_strerror(socket_last_error())));
62
+ }
63
+ $responseString .= $buffer;
64
+ }
65
+ socket_close($socket);
66
+
67
+ return $responseString;
68
+ }
69
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/Store.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Connection_Store extends Stpp_Component_Abstract implements Stpp_Api_Connection_StoreInterface {
4
+ protected $_store = array();
5
+
6
+ protected $_active;
7
+
8
+ public function registerConnection(Stpp_Api_Connection_BaseInterface $connection) {
9
+ $key = $connection::getKey();
10
+ if (array_key_exists($key, $this->_store)) {
11
+ throw new Stpp_Exception(sprintf($this->__('An object with the key "%s" already exists.'), $key));
12
+ }
13
+ $this->_store[$key] = $connection;
14
+ return $this;
15
+ }
16
+
17
+ public function setActive($key) {
18
+ $store = $this->getAll();
19
+
20
+ if (!isset($store[$key])) {
21
+ throw new Stpp_Exception(sprintf($this->__('Invalid key specified: "%s".'), $key));
22
+ }
23
+ $this->_active = $store[$key];
24
+ return $this;
25
+ }
26
+
27
+ public function getActive() {
28
+ if ($this->_active === null) {
29
+ throw new Stpp_Exception($this->__('The active connection has not been set.'));
30
+ }
31
+ return $this->_active;
32
+ }
33
+
34
+ public function get($key) {
35
+ if (!array_key_exists($key, $this->_store)) {
36
+ throw new Stpp_Exception(sprintf($this->__('The object with key "%s" does not exist.'), $key));
37
+ }
38
+ return $this->_store[$key];
39
+ }
40
+
41
+ public function getAll() {
42
+ if (!is_array($this->_store)) {
43
+ throw new Stpp_Exception($this->__('The connection store must be an array.'));
44
+ }
45
+
46
+ if (empty($this->_store)) {
47
+ throw new Stpp_Exception($this->__('The connection store is empty.'));
48
+ }
49
+ return $this->_store;
50
+ }
51
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/StoreInterface.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_Connection_StoreInterface {
4
+ function registerConnection(Stpp_Api_Connection_BaseInterface $connection);
5
+ function setActive($key);
6
+ function getActive();
7
+ function get($key);
8
+ function getAll();
9
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Connection/Webservices.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Stpp_Api_Connection_Webservices extends Stpp_Component_Abstract implements Stpp_Api_Connection_BaseInterface {
5
+ const CONNECTION_KEY = 'Stpp_Connection_Webservices';
6
+
7
+ const CONNECTION_NAME = 'Stpp Web Services';
8
+
9
+ protected $_actionUrl = 'https://webservices.securetrading.net:443/xml/';
10
+
11
+ protected $_username;
12
+
13
+ protected $_password;
14
+
15
+ protected $_alias;
16
+
17
+ protected $_verifySsl;
18
+
19
+ protected $_caCertFile;
20
+
21
+ protected $_rawCustomContextOptions;
22
+
23
+ public static function getKey() {
24
+ return static::CONNECTION_KEY;
25
+ }
26
+
27
+ public static function getName() {
28
+ return static::CONNECTION_NAME;
29
+ }
30
+
31
+ public function setAlias($alias) {
32
+ $this->_alias = $alias;
33
+ }
34
+
35
+ public function getAlias() {
36
+ return $this->_alias;
37
+ }
38
+
39
+ public function setUsername($username) {
40
+ $this->_username = $username;
41
+ }
42
+
43
+ public function setPassword($password) {
44
+ $this->_password = $password;
45
+ }
46
+
47
+ public function setVerifySsl($bool) {
48
+ $this->_verifySsl = (bool) $bool;
49
+ }
50
+
51
+ public function setCaCertFile($file) {
52
+ $this->_caCertFile = $file;
53
+ }
54
+
55
+ public function setRawCustomContextOptions($options) {
56
+ $this->_rawCustomContextOptions = $options;
57
+ }
58
+
59
+ public function sendAndReceiveData($requestString) {
60
+ $requestString = trim(preg_replace('/>[\s]+</', '><', $requestString)); // Remove all whitespace between elements.
61
+
62
+ $httpHeaders = array(
63
+ 'Host: ' . parse_url($this->_actionUrl, PHP_URL_HOST),
64
+ 'Content-type: text/xml;charset=utf-8',
65
+ 'Content-Length: ' . strlen($requestString),
66
+ 'Authorization: Basic ' . base64_encode($this->_username . ':' . $this->_password),
67
+ 'Accept: text/xml',
68
+ 'Connection: close',
69
+ 'User-Agent: ',
70
+ );
71
+
72
+ $contextOptions = array(
73
+ 'http' => array(
74
+ 'protocol_version' => '1.1',
75
+ 'method' => 'POST',
76
+ 'content' => $requestString,
77
+ 'follow_location' => 0,
78
+ 'timeout' => 30,
79
+ 'ignore_errors' => false,
80
+ 'header' => $httpHeaders,
81
+ ),
82
+ );
83
+
84
+ if ($this->_verifySsl) {
85
+ $contextOptions['ssl'] = array(
86
+ 'cafile' => $this->_caCertFile,
87
+ 'CN_match' => 'webservices.securetrading.net', // CN_match will only be checked if 'verify_peer' is set to TRUE. See https://bugs.php.net/bug.php?id=47030.
88
+ 'verify_peer' => true,
89
+ );
90
+ }
91
+
92
+ if ($this->_rawCustomContextOptions) {
93
+ array_merge_recursive($contextOptions, $this->_rawCustomContextOptions);
94
+ }
95
+
96
+ $streamContext = stream_context_create($contextOptions);
97
+
98
+ if (false === ($socket = fopen($this->_actionUrl, 'rb', false, $streamContext))) {
99
+ throw new Stpp_Exception(sprintf($this->__('Could not open socket to "%s".'), $this->_actionUrl));
100
+ }
101
+
102
+ if (fwrite($socket, $requestString) === false) {
103
+ throw new Stpp_Exception($this->__('The write operation failed.'));
104
+ }
105
+
106
+ $metaData = stream_get_meta_data($socket);
107
+ $responseHeaders = $metaData['wrapper_data'];
108
+ $responseBody = stream_get_contents($socket);
109
+
110
+ $match = null;
111
+
112
+ if (!preg_match("!HTTP/1\.. (\d{3})!", $responseHeaders[0], $match)) {
113
+ throw new Stpp_Exception($this->__('An HTTP response code could not be found.'));
114
+ }
115
+
116
+ $httpResponseCode = $match[1];
117
+
118
+ if ($httpResponseCode != 200) {
119
+ throw new Stpp_Exception(sprintf($this->__('Unexpected HTTP response code %s returned.'), $httpResponseCode));
120
+ }
121
+
122
+ return $responseBody;
123
+ }
124
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Context.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Context extends Stpp_Component_Abstract implements Stpp_Api_ContextInterface {
4
+ protected $_requests = array();
5
+
6
+ protected $_responses = array();
7
+
8
+ public function setRequests(array $requests) {
9
+ $this->_requests = $requests;
10
+ return $this;
11
+ }
12
+
13
+ public function &getRequests() {
14
+ if (empty($this->_requests)) {
15
+ throw new Stpp_Exception($this->__('No requests have been set.'));
16
+ }
17
+ return $this->_requests;
18
+ }
19
+
20
+ public function &getRequest($index) {
21
+ $requests = $this->getRequests();
22
+
23
+ if(!array_key_exists($index, $requests)) {
24
+ throw new Stpp_Exception($this->__('The array index does not exist.'));
25
+ }
26
+ return $requests[$index];
27
+ }
28
+
29
+ public function setResponses(array $responses) {
30
+ $this->_responses = $responses;
31
+ return $this;
32
+ }
33
+
34
+ public function &getResponses() {
35
+ if (!is_array($this->_responses)) {
36
+ throw new Stpp_Exception($this->__('The responses must be an array.'));
37
+ }
38
+
39
+ if (empty($this->_responses)) {
40
+ throw new Stpp_Exception($this->__('No responses have been set.'));
41
+ }
42
+ return $this->_responses;
43
+ }
44
+
45
+ public function &getResponse($index) {
46
+ $responses = $this->getResponses();
47
+
48
+ if(!array_key_exists($index, $responses)) {
49
+ throw new Stpp_Exception($this->__('The array index does not exist.'));
50
+ }
51
+ return $responses[$index];
52
+ }
53
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/ContextInterface.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_ContextInterface {
4
+ function setRequests(array $requests);
5
+ function &getRequests();
6
+ function getRequest($index);
7
+ function setResponses(array $responses);
8
+ function &getResponses();
9
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Facade.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Facade extends Stpp_Facade {
4
+ public function newApi() {
5
+ $api = new Stpp_Api_Base();
6
+ $api->setSend($this->newApiSend());
7
+ $api->setProcess($this->newApiProcess());
8
+ return $api;
9
+ }
10
+
11
+ public function newApiSend() {
12
+ $apiSend = new Stpp_Api_Send();
13
+ $apiSend->setXmlWriter($this->newApiXmlWriter());
14
+ $apiSend->setXmlReader($this->newApiXmlReader());
15
+ $apiSend->setContext($this->newApiContext());
16
+
17
+ if ($this->_config->has('interfaces/api/active_connection')) {
18
+ $connectionStore = $this->newApiConnectionStore();
19
+ $activeConnection = $this->_config->get('interfaces/api/active_connection');
20
+ $apiSend->setConnection($connectionStore->get($activeConnection));
21
+ }
22
+ return $apiSend;
23
+ }
24
+
25
+ public function newApiProcess() {
26
+ $apiProcess = new Stpp_Api_Process();
27
+
28
+ $apiProcess->setResult($this->newApiResult());
29
+ $apiProcess->setApiLog($this->newApiLog());
30
+
31
+ if ($this->_config->has('interfaces/api/action_instance')) {
32
+ $apiProcess->setActionInstance($this->_config->get('interfaces/api/action_instance'));
33
+ }
34
+ return $apiProcess;
35
+ }
36
+
37
+ public function newApiHelper() {
38
+ $helper = new Stpp_Api_Helper();
39
+
40
+ if ($this->_config->has('interfaces/api/use_3d_secure')) {
41
+ $helper->setUse3dSecure($this->_config->get('interfaces/api/use_3d_secure'));
42
+ }
43
+
44
+ if ($this->_config->has('interfaces/api/use_risk_decision')) {
45
+ $helper->setUseRiskDecision($this->_config->get('interfaces/api/use_risk_decision'));
46
+ }
47
+
48
+ if ($this->_config->has('interfaces/api/use_card_store')) {
49
+ $helper->setUseCardStore($this->_config->get('interfaces/api/use_card_store'));
50
+ }
51
+
52
+ if ($this->_config->has('interfaces/api/use_risk_decision_after_auth')) {
53
+ $helper->setUseRiskDecisionAfterAuth($this->_config->get('interfaces/api/use_risk_decision_after_auth'));
54
+ }
55
+ return $helper;
56
+ }
57
+
58
+ public function newApiResult() {
59
+ return new Stpp_Api_Result();
60
+ }
61
+
62
+ public function newApiContext() {
63
+ return new Stpp_Api_Context();
64
+ }
65
+
66
+ public function newApiLog() {
67
+ $logWriter = new Stpp_Utility_Log_Writer_File('api', Stpp::getLogsPath(), Stpp::getLogsArchivePath());
68
+ $apiLog = new Stpp_Api_Log();
69
+ $apiLog->setLogWriter($logWriter);
70
+ return $apiLog;
71
+ }
72
+
73
+ public function newApiConnectionStore() {
74
+ $stApiConnection = $this->newApiConnectionStApi();
75
+ $webServicesConnection = $this->newApiConnectionWebServices();
76
+
77
+ $connectionStore = new Stpp_Api_Connection_Store();
78
+ $connectionStore->registerConnection($stApiConnection);
79
+ $connectionStore->registerConnection($webServicesConnection);
80
+ return $connectionStore;
81
+ }
82
+
83
+ public function newApiConnectionStApi() {
84
+ $stApiConnection = new Stpp_Api_Connection_Stapi();
85
+
86
+ if ($this->_config->has('connections/api/host')) {
87
+ $stApiConnection->setHost($this->_config->get('connections/api/host'));
88
+ }
89
+
90
+ if ($this->_config->has('connections/api/port')) {
91
+ $stApiConnection->setPort($this->_config->get('connections/api/port'));
92
+ }
93
+
94
+ if ($this->_config->has('connections/api/alias')) {
95
+ $stApiConnection->setAlias($this->_config->get('connections/api/alias'));
96
+ }
97
+ return $stApiConnection;
98
+ }
99
+
100
+ public function newApiConnectionWebServices() {
101
+ $webServicesConnection = new Stpp_Api_Connection_Webservices();
102
+
103
+ if ($this->_config->has('connections/web_services/username')) {
104
+ $webServicesConnection->setUsername($this->_config->get('connections/web_services/username'));
105
+ }
106
+
107
+ if ($this->_config->has('connections/web_services/password')) {
108
+ $webServicesConnection->setPassword($this->_config->get('connections/web_services/password'));
109
+ }
110
+
111
+ if ($this->_config->has('connections/web_services/alias')) {
112
+ $webServicesConnection->setAlias($this->_config->get('connections/web_services/alias'));
113
+ }
114
+
115
+ if ($this->_config->has('connections/web_services/verifyssl')) {
116
+ $webServicesConnection->setVerifySsl($this->_config->get('connections/web_services/verifyssl'));
117
+ }
118
+
119
+ if ($this->_config->has('connections/web_services/cacertfile')) {
120
+ $webServicesConnection->setCaCertFile($this->_config->get('connections/web_services/cacertfile'));
121
+ }
122
+
123
+ if ($this->_config->has('connections/web_services/contextoptions')) {
124
+ $webServicesConnection->setRawCustomContextOptions($this->_config->get('connections/web_services/contextoptions'));
125
+ }
126
+ return $webServicesConnection;
127
+ }
128
+
129
+ public function newApiXmlWriter() {
130
+ $xmlWriter = new Stpp_Api_Xml_Writer();
131
+
132
+ if ($this->_config->has('interfaces/api/xmlwriter/version')) {
133
+ $xmlWriter->setXmlVersion($this->_config->get('interfaces/api/xmlwriter/version'));
134
+ }
135
+
136
+ if ($this->_config->has('interfaces/api/xmlwriter/encoding')) {
137
+ $xmlWriter->setXmlEncoding($this->_config->get('interfaces/api/xmlwriter/encoding'));
138
+ }
139
+ return $xmlWriter;
140
+ }
141
+
142
+ public function newApiXmlReader() {
143
+ return new Stpp_Api_Xml_Reader('Stpp_Data_Response');
144
+ }
145
+
146
+ public function runApiStandard(Stpp_Data_Request $request, $adminAction = false) {
147
+ $helper = $this->newApiHelper()->setAdminAction($adminAction);
148
+ $requests = $helper->prepareStandard($request);
149
+ $result = $this->newApi()->run($requests);
150
+ return $result;
151
+ }
152
+
153
+ public function runApi3dAuth(Stpp_Data_Request $request) {
154
+ $requests = $this->newApiHelper()->prepare3dAuth($request);
155
+ $result = $this->newApi()->run($requests);
156
+ return $result;
157
+ }
158
+
159
+ public function runApiTransactionUpdate(Stpp_Data_Request $request) {
160
+ $requests = $this->newApiHelper()->prepareTransactionUpdate($request);
161
+ $result = $this->newApi()->run($requests);
162
+ return $result;
163
+ }
164
+
165
+ public function runApiRefund(Stpp_Data_Request $request) {
166
+ $requests = $this->newApiHelper()->prepareRefund($request);
167
+ $result = $this->newApi()->run($requests);
168
+ return $result;
169
+ }
170
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Helper.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Helper extends Stpp_Component_Abstract implements Stpp_Api_HelperInterface {
4
+ protected $_use3dSecure = false;
5
+
6
+ protected $_useRiskDecision = false;
7
+
8
+ protected $_useCardStore = false;
9
+
10
+ protected $_useRiskDecisionAfterAuth = false;
11
+
12
+ protected $_adminAction = false;
13
+
14
+ public function setUse3dSecure($bool) {
15
+ $this->_use3dSecure = (bool) $bool;
16
+ return $this;
17
+ }
18
+
19
+ public function setUseRiskDecision($bool) {
20
+ $this->_useRiskDecision = (bool) $bool;
21
+ return $this;
22
+ }
23
+
24
+ public function setUseCardStore($bool) {
25
+ $this->_useCardStore = (bool) $bool;
26
+ return $this;
27
+ }
28
+
29
+ public function setUseRiskDecisionAfterAuth($bool) {
30
+ $this->_useRiskDecisionAfterAuth = (bool) $bool;
31
+ return $this;
32
+ }
33
+
34
+ public function setAdminAction($bool) {
35
+ $this->_adminAction = (bool) $bool;
36
+ return $this;
37
+ }
38
+
39
+ public function generateRequests(Stpp_Data_Request $originalRequest, array $requestTypes) {
40
+ $requests = array();
41
+ foreach($requestTypes as $requestType) {
42
+ $request = $originalRequest->cloneObject()->setMultiple(
43
+ array(
44
+ 'requesttypedescription' => $requestType,
45
+ 'accounttypedescription' => $this->_calculateAccountTypeDescription($requestType),
46
+ )
47
+ );
48
+ $requests[] = $request;
49
+ }
50
+ return $requests;
51
+ }
52
+
53
+ public function prepareStandard(Stpp_Data_Request $originalRequest) {
54
+ $requestTypes = array();
55
+
56
+ if ($this->_useCardStore) {
57
+ $requestTypes[] = Stpp_Types::API_CARDSTORE;
58
+ }
59
+
60
+ if ($this->_useRiskDecision && !$this->_useRiskDecisionAfterAuth) {
61
+ $requestTypes[] = Stpp_Types::API_RISKDEC;
62
+ }
63
+
64
+ if ($this->_use3dSecure && !$this->_adminAction) {
65
+ $requestTypes[] = Stpp_Types::API_THREEDQUERY;
66
+ }
67
+
68
+ $requestTypes[] = Stpp_Types::API_AUTH;
69
+
70
+ if ($this->_useRiskDecision && $this->_useRiskDecisionAfterAuth) {
71
+ $requestTypes[] = Stpp_Types::API_RISKDEC;
72
+ }
73
+
74
+ return $this->generateRequests($originalRequest, $requestTypes);
75
+ }
76
+
77
+ public function prepare3dAuth(Stpp_Data_Request $request) {
78
+ if (!isset($_POST['MD'])) {
79
+ throw new Stpp_Exception($this->__('The MD has not been set.'));
80
+ }
81
+
82
+ if (!isset($_POST['PaRes'])) {
83
+ throw new Stpp_Exception($this->__('The PaRes has not been set.'));
84
+ }
85
+
86
+ $request->set('requesttypedescription', Stpp_Types::API_AUTH);
87
+ $request->set('md', $_POST['MD']);
88
+ $request->set('pares', $_POST['PaRes']);
89
+ $request->set('accounttypedescription', $this->_calculateAccountTypeDescription(Stpp_Types::API_AUTH));
90
+ return array($request);
91
+ }
92
+
93
+ public function prepareRefund(Stpp_Data_Request $originalRequest) {
94
+ $originalOrderTotal = $originalRequest->get('original_order_total', null);
95
+ $currentOrderTotal = $originalRequest->get('current_order_total', null);
96
+ $amountToRefund = $originalRequest->get('amount_to_refund', null);
97
+ $transactionReference = $originalRequest->get('transaction_reference', null);
98
+ $partialRefundAlreadyProcessed = $originalRequest->get('partial_refund_already_processed', null);
99
+
100
+ if (in_array(null, array($originalOrderTotal, $currentOrderTotal, $amountToRefund, $transactionReference, $partialRefundAlreadyProcessed), true)) {
101
+ throw new Stpp_Exception($this->__('Not all parameters were passed to the refund function.'));
102
+ }
103
+
104
+ $partialRefund = $originalOrderTotal - $amountToRefund > 0;
105
+ $settleBaseAmount = $currentOrderTotal - $amountToRefund;
106
+
107
+ if (!$partialRefundAlreadyProcessed) {
108
+ $filter = Stpp_Data_Request::instance()->set('transactionreference', $transactionReference);
109
+
110
+ $updates = Stpp_Data_Request::instance();
111
+
112
+ if ($settleBaseAmount > 0) {
113
+ $updates->set('settlebaseamount', $settleBaseAmount);
114
+ }
115
+ else {
116
+ $updates->set('settlestatus', 3);
117
+ }
118
+
119
+ $transactionUpdate = Stpp_Data_Request::instance()
120
+ ->set('requesttypedescription', Stpp_Types::API_TRANSACTIONUPDATE)
121
+ ->set('filter', $filter)
122
+ ->set('updates', $updates);
123
+ }
124
+
125
+ $refund = Stpp_Data_Request::instance()
126
+ ->set('requesttypedescription', Stpp_Types::API_REFUND)
127
+ ->set('parenttransactionreference', $transactionReference);
128
+
129
+ if ($partialRefund) {
130
+ $refund->set('baseamount', $amountToRefund);
131
+ }
132
+
133
+ return array(
134
+ $transactionUpdate,
135
+ $refund,
136
+ );
137
+ }
138
+
139
+ public function prepareTransactionUpdate(Stpp_Data_Request $request) {
140
+ $request->set('requesttypedescription', Stpp_Types::API_TRANSACTIONUPDATE);
141
+
142
+ if (!$request->has('filter')) {
143
+ throw new Stpp_Exception($this->__('The filters do not exist.'));
144
+ }
145
+
146
+ if (!$request->has('updates')) {
147
+ throw new Stpp_Exception($this->__('The updates do not exist.'));
148
+ }
149
+ return array($request);
150
+ }
151
+
152
+ protected function _calculateAccountTypeDescription($requestType) {
153
+ $accountType = null;
154
+ switch($requestType) {
155
+ case Stpp_Types::API_AUTH:
156
+ $accountType = $this->_adminAction ? Stpp_Types::ACCOUNT_MOTO : Stpp_Types::ACCOUNT_ECOM;
157
+ break;
158
+ case Stpp_Types::API_THREEDQUERY:
159
+ $accountType = Stpp_Types::ACCOUNT_ECOM;
160
+ break;
161
+ case Stpp_Types::API_RISKDEC:
162
+ $accountType = Stpp_Types::ACCOUNT_FRAUDCONTROL;
163
+ break;
164
+ case Stpp_Types::API_CARDSTORE:
165
+ $accountType = Stpp_Types::ACCOUNT_CARDSTORE;
166
+ case Stpp_Types::API_REFUND:
167
+ case Stpp_Types::API_TRANSACTIONUPDATE:
168
+ break;
169
+ default:
170
+ throw new Stpp_Exception(sprintf($this->__('Unhandled request type "%s" provided.'), $requestType));
171
+ }
172
+ return $accountType;
173
+ }
174
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/HelperInterface.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_HelperInterface {
4
+ function generateRequests(Stpp_Data_Request $originalRequest, array $requestTypes);
5
+ function prepareStandard(Stpp_Data_Request $originalRequest);
6
+ function prepare3dAuth(Stpp_Data_Request $request);
7
+ function prepareRefund(Stpp_Data_Request $originalRequest);
8
+ function prepareTransactionUpdate(Stpp_Data_Request $request);
9
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Log.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Log extends Stpp_Utility_Log_User_Abstract implements Stpp_Api_LogInterface {
4
+ protected $_doNotLog = array(
5
+ '*' => array('0', '30000', '70000'),
6
+ );
7
+
8
+ public function setDoNotLog(array $array = array()) {
9
+ $this->_doNotLog = $array;
10
+ }
11
+
12
+ public function getDoNotLog() {
13
+ return $this->_doNotLog;
14
+ }
15
+
16
+ public function log(Stpp_Data_Response $response) {
17
+ if (!$this->_canLogError($response->get('responsetype'), $response->get('errorcode', false))) {
18
+ return;
19
+ }
20
+ $request = $response->getRequest();
21
+ $request->removeSecureData();
22
+
23
+ $message = 'Request' . ':';
24
+ $message .= PHP_EOL;
25
+ $message .= print_r($request->toArray(),1);
26
+ $message .= PHP_EOL;
27
+ $message .= 'Response' . ':';
28
+ $message .= PHP_EOL;
29
+ $message .= print_r($response->toArray(),1);
30
+ $message .= PHP_EOL . PHP_EOL;
31
+
32
+ $indentedMessage = preg_replace('/^/m', "\t", $message);
33
+ $this->getLogWriter()->log($indentedMessage);
34
+ }
35
+
36
+ protected function _canLogError($responseType, $errorCode) {
37
+ $canLog = true;
38
+
39
+ if (!array_key_exists($responseType, $this->_doNotLog)) {
40
+ $responseType = '*';
41
+ }
42
+
43
+ if (array_key_exists($responseType, $this->_doNotLog)) {
44
+
45
+ if (!in_array($errorCode, $this->_doNotLog[$responseType])) {
46
+ $errorCode = '*';
47
+ }
48
+
49
+ if (in_array($errorCode, $this->_doNotLog[$responseType])) {
50
+ $canLog = false;
51
+ }
52
+ }
53
+ return $canLog;
54
+ }
55
+
56
+ protected function _formatMessage($message) {
57
+ $messageHeader = $this->_getDate() . ': ' . 'Logging gateway transaction.';
58
+ $line = str_repeat('#', strlen($messageHeader));
59
+ return $line . PHP_EOL .$messageHeader . PHP_EOL . $line . PHP_EOL . PHP_EOL . $message;
60
+ }
61
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/LogInterface.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_LogInterface {
4
+ function setDoNotLog(array $array = array());
5
+ function getDoNotLog();
6
+ function log(Stpp_Data_Response $request);
7
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Process.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Process extends Stpp_Component_Abstract implements Stpp_Api_ProcessInterface {
4
+ protected $_actionInstance;
5
+
6
+ protected $_context;
7
+
8
+ protected $_result;
9
+
10
+ protected $_apiLog;
11
+
12
+ public function setActionInstance(Stpp_Api_ActionsInterface $actionInstance) {
13
+ $this->_actionInstance = $actionInstance;
14
+ return $this;
15
+ }
16
+
17
+ protected function _getActionInstance() {
18
+ if ($this->_actionInstance === null) {
19
+ throw new Stpp_Exception($this->__('The action instance has not been set.'));
20
+ }
21
+ return $this->_actionInstance;
22
+ }
23
+
24
+ public function _setContext(Stpp_Api_ContextInterface $context) {
25
+ $this->_context = $context;
26
+ }
27
+
28
+ protected function _getContext() {
29
+ if ($this->_context === null) {
30
+ throw new Stpp_Exception($this->__('The context object is null.'));
31
+ }
32
+ return $this->_context;
33
+ }
34
+
35
+ public function setResult(Stpp_Api_ResultInterface $result) {
36
+ $this->_result = $result;
37
+ }
38
+
39
+ protected function _getResult() {
40
+ if ($this->_result === null) {
41
+ throw new Stpp_Exception($this->__('The result object is null.'));
42
+ }
43
+ return $this->_result;
44
+ }
45
+
46
+ public function setApiLog(Stpp_Api_LogInterface $log) {
47
+ $this->_apiLog = $log;
48
+ return $this;
49
+ }
50
+
51
+ public function getApiLog() {
52
+ if ($this->_apiLog === null) {
53
+ throw new Stpp_Exception($this->__('The api log has not been set.'));
54
+ }
55
+ return $this->_apiLog;
56
+ }
57
+
58
+ public function run(Stpp_Api_ContextInterface $context) {
59
+ $this->_setContext($context);
60
+ $this->_handleResponses();
61
+ $this->_calculateIsTransactionSuccessful();
62
+ $this->_getResult()->setContext($this->_getContext());
63
+ return $this->_getResult();
64
+ }
65
+
66
+ protected function _handleResponses() {
67
+ $responses = $this->_getContext()->getResponses();
68
+
69
+ $this->_runStandardRoutines($responses);
70
+
71
+ $lastResponseResponseType = $responses[count($responses)-1]->get('responsetype');
72
+
73
+ foreach($responses as $response) {
74
+ switch($response->get('responsetype')) {
75
+ case Stpp_Types::API_ERROR:
76
+ $result = $this->_handleError($response);
77
+ break;
78
+ case Stpp_Types::API_AUTH:
79
+ $result = $this->_handleAuth($response);
80
+ break;
81
+ case Stpp_Types::API_THREEDQUERY:
82
+ $redirToAcsUrl = ($lastResponseResponseType === Stpp_Types::API_THREEDQUERY && $response->get('errorcode') === '0' && $response->get('enrolled') === 'Y');
83
+ $result = $this->_handle3dQuery($response, $redirToAcsUrl);
84
+ break;
85
+ case Stpp_Types::API_RISKDEC:
86
+ $result = $this->_handleRiskDecision($response);
87
+ break;
88
+ case Stpp_Types::API_ACCOUNTCHECK:
89
+ $result = $this->_handleAccountCheck($response);
90
+ break;
91
+ case Stpp_Types::API_CARDSTORE:
92
+ $result = $this->_handleCardStore($response);
93
+ break;
94
+ case Stpp_Types::API_TRANSACTIONUPDATE:
95
+ $result = $this->_handleTransactionUpdate($response);
96
+ break;
97
+ case Stpp_Types::API_REFUND:
98
+ $result = $this->_handleRefund($response);
99
+ break;
100
+ default:
101
+ throw new Stpp_Exception(sprintf($this->__('Unsupported response: "%s".'), $response->getResponseType()));
102
+ }
103
+ $response->getRequest()->setIsSuccessful($result);
104
+ }
105
+ return $this;
106
+ }
107
+
108
+ protected function _runStandardRoutines($responses) {
109
+ foreach($responses as $response) {
110
+ $this->getApiLog()->log($response);
111
+
112
+ $this->_formatErrorMessages(
113
+ $response->get('errorcode'),
114
+ $response->get('errormessage'),
115
+ $response->get('errordata')
116
+ );
117
+ }
118
+ return $this;
119
+ }
120
+
121
+ protected function _formatErrorMessages($errorCode, $errorMessage, $errorData) {
122
+ $errorCode = (string) $errorCode;
123
+ $errorMessage = (string) $errorMessage;
124
+ $errorData = (string) $errorData;
125
+
126
+ switch($errorCode) {
127
+ case "0":
128
+ $customerMessage = $merchantMessage = $this->__('Transaction successful.');
129
+ break;
130
+ case "30000":
131
+ $errorData = $errorData === 'pan' ? $this->__('credit/debit card number') : $errorData; // Replace 'pan' with 'card number'.
132
+ $customerMessage = $merchantMessage = sprintf($this->__('The %s was not provided or was incorrect.'), $errorData);
133
+ break;
134
+ case "70000":
135
+ $customerMessage = $this->__('Your credit/debit card was declined. Please try again using a different card.');
136
+ $merchantMessage = $this->__('The customer\'s credit/debit card was declined.');
137
+ break;
138
+ default:
139
+ $customerMessage = $this->__('An unexpected error occurred. Please try again.');
140
+ $merchantMessage = $errorMessage;
141
+ }
142
+ $this->_getResult()->setCustomerErrorMessage($customerMessage)->setMerchantErrorMessage($merchantMessage);
143
+ }
144
+
145
+ protected function _handleError(Stpp_Data_Response $response) {
146
+ return $this->_getActionInstance()->processError($response);
147
+ }
148
+
149
+ protected function _handleAuth(Stpp_Data_Response $response) {
150
+ return $this->_getActionInstance()->processAuth($response);
151
+ }
152
+
153
+ protected function _handle3dQuery(Stpp_Data_Response $response, $performAcsUrlRedirect) {
154
+ if ($performAcsUrlRedirect) {
155
+ $hiddenInputElements = array(
156
+ 'PaReq' => $response->get('pareq'),
157
+ 'TermUrl' => $response->getRequest()->get('termurl'),
158
+ 'MD' => $response->get('md'),
159
+ );
160
+
161
+ $this->_getResult()
162
+ ->setRedirectRequired(true)
163
+ ->setRedirectIsPost(true)
164
+ ->setRedirectUrl($response->get('acsurl'))
165
+ ->setRedirectData($hiddenInputElements)
166
+ ->setIsTransactionSuccessful(null)
167
+ ;
168
+ }
169
+ return $this->_getActionInstance()->process3dQuery($response);
170
+ }
171
+
172
+ protected function _handleRiskDecision(Stpp_Data_Response $response) {
173
+ return $this->_getActionInstance()->processRiskDecision($response);
174
+ }
175
+
176
+ protected function _handleAccountCheck(Stpp_Data_Response $response) {
177
+ return $this->_getActionInstance()->processAccountCheck($response);
178
+ }
179
+
180
+ protected function _handleCardStore(Stpp_Data_Response $response) {
181
+ return $this->_getActionInstance()->processCardStore($response);
182
+ }
183
+
184
+ protected function _handleTransactionUpdate(Stpp_Data_Response $response) {
185
+ return $this->_getActionInstance()->processTransactionUpdate($response);
186
+ }
187
+
188
+ protected function _handleRefund(Stpp_Data_Response $response) {
189
+ return $this->_getActionInstance()->processRefund($response);
190
+ }
191
+
192
+ protected function _calculateIsTransactionSuccessful() {
193
+ $requests = $this->_getContext()->getRequests();
194
+ $transactionSuccessful = false;
195
+
196
+ $cardStore = $this->_findRequests(array(Stpp_Types::API_CARDSTORE));
197
+ $nonCardStore = $this->_findRequests(array(Stpp_Types::API_CARDSTORE), true);
198
+
199
+ $riskDecision = $this->_findRequests(array(Stpp_Types::API_RISKDEC));
200
+ $nonRiskDecision = $this->_findRequests(array(Stpp_Types::API_RISKDEC), true);
201
+
202
+ if ($cardStore && !$this->_validateAllRequestsAreSuccessful($cardStore)) {
203
+ if ($nonCardStore && $this->_validateAllRequestsAreSuccessful($nonCardStore)) {
204
+ $transactionSuccessful = true; // If one or more CARDSTORE requests failed but other request types exist and are all successful.
205
+ }
206
+ }
207
+ elseif ($riskDecision && !$this->_validateAllRequestsAreSuccessful($riskDecision)) {
208
+ if ($nonRiskDecision && $this->_validateAllRequestsAreSuccessful($nonRiskDecision)) {
209
+ $transactionSuccessful = true; // If one or more RISKDEC requests failed but other request types exist and are all successful.
210
+ }
211
+ }
212
+ else {
213
+ $transactionSuccessful = $this->_validateAllRequestsAreSuccessful($requests);
214
+ }
215
+
216
+ $isTransactionSuccessful = $this->_getActionInstance()->calculateIsTransactionSuccessful($requests, $transactionSuccessful);
217
+ $this->_getResult()->setIsTransactionSuccessful($isTransactionSuccessful);
218
+ return $this;
219
+ }
220
+
221
+ protected function _validateAllRequestsAreSuccessful(array $requests) {
222
+ $result = true;
223
+ foreach($requests as $request) {
224
+ if ($request->getIsSuccessful() !== true) {
225
+ $result = false;
226
+ break;
227
+ }
228
+ }
229
+ return $result;
230
+ }
231
+
232
+ protected function _findRequests(array $requestTypes, $not = false) {
233
+ $requests = $this->_getContext()->getRequests();
234
+ $filteredRequests = array();
235
+
236
+ foreach($requests as $key => $request) {
237
+ if ($not === false) {
238
+ if (in_array($request->get('requesttypedescription'), $requestTypes)) {
239
+ $filteredRequests[] = $requests[$key];
240
+ }
241
+ }
242
+ else {
243
+ if (!in_array($request->get('requesttypedescription'), $requestTypes)) {
244
+ $filteredRequests[] = $requests[$key];
245
+ }
246
+ }
247
+ }
248
+ return $filteredRequests;
249
+ }
250
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/ProcessInterface.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_ProcessInterface {
4
+ function run(Stpp_Api_ContextInterface $context);
5
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Result.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Result extends Stpp_Result_Abstract implements Stpp_Api_ResultInterface {
4
+ protected $_context;
5
+
6
+ protected $_isRedirectRequired = false;
7
+
8
+ protected $_isTransactionSuccessful = false;
9
+
10
+ protected $_customerErrorMessage = '';
11
+
12
+ protected $_merchantErrorMessage = '';
13
+
14
+ public function getContext() {
15
+ if ($this->_context === null) {
16
+ throw new Stpp_Exception('The context object is null.');
17
+ }
18
+ return $this->_context;
19
+ }
20
+
21
+ public function setContext(Stpp_Api_ContextInterface $context) {
22
+ $this->_context = $context;
23
+ }
24
+
25
+ public function getRedirectRequired() {
26
+ return $this->_isRedirectRequired;
27
+ }
28
+
29
+ public function setRedirectRequired($bool) {
30
+ $this->_isRedirectRequired = (bool) $bool;
31
+ return $this;
32
+ }
33
+
34
+ public function getIsTransactionSuccessful() {
35
+ return $this->_isTransactionSuccessful;
36
+ }
37
+
38
+ public function setIsTransactionSuccessful($bool) {
39
+ $this->_isTransactionSuccessful = (bool) $bool;
40
+ return $this;
41
+ }
42
+
43
+ public function getCustomerErrorMessage() {
44
+ return $this->_customerMessage;
45
+ }
46
+
47
+ public function setCustomerErrorMessage($message) {
48
+ $this->_customerMessage = $message;
49
+ return $this;
50
+ }
51
+
52
+ public function getMerchantErrorMessage() {
53
+ return $this->_merchantMessage;
54
+ }
55
+
56
+ public function setMerchantErrorMessage($message) {
57
+ $this->_merchantMessage = $message;
58
+ return $this;
59
+ }
60
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/ResultInterface.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_ResultInterface extends Stpp_Result_AbstractInterface {
4
+ function getContext();
5
+ function setContext(Stpp_Api_ContextInterface $context);
6
+ function getRedirectRequired();
7
+ function setRedirectRequired($bool);
8
+ function getIsTransactionSuccessful();
9
+ function setIsTransactionSuccessful($bool);
10
+ function getCustomerErrorMessage();
11
+ function setCustomerErrorMessage($message);
12
+ function getMerchantErrorMessage();
13
+ function setMerchantErrorMessage($message);
14
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Send.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Send extends Stpp_Component_Abstract implements Stpp_Api_SendInterface {
4
+ const API_VERSION = '3.67';
5
+
6
+ protected $_connection;
7
+
8
+ protected $_xmlWriter;
9
+
10
+ protected $_xmlReader;
11
+
12
+ protected $_context;
13
+
14
+ public function setConnection(Stpp_Api_Connection_BaseInterface $connection) {
15
+ $this->_connection = $connection;
16
+ }
17
+
18
+ public function getConnection() {
19
+ if ($this->_connection === null) {
20
+ throw new Stpp_Exception($this->__('The active connection has not been set.'));
21
+ }
22
+ return $this->_connection;
23
+ }
24
+
25
+ public function setXmlWriter(Stpp_Api_Xml_WriterInterface $xmlWriter) {
26
+ $this->_xmlWriter = $xmlWriter;
27
+ return $this;
28
+ }
29
+
30
+ protected function _getXmlWriter() {
31
+ if ($this->_xmlWriter === null) {
32
+ throw new Stpp_Exception($this->__('The XmlWriter has not been set.'));
33
+ }
34
+ return $this->_xmlWriter;
35
+ }
36
+
37
+ public function setXmlReader(Stpp_Api_Xml_ReaderInterface $xmlReader) {
38
+ $this->_xmlReader = $xmlReader;
39
+ return $this;
40
+ }
41
+
42
+ protected function _getXmlReader() {
43
+ if ($this->_xmlReader === null) {
44
+ throw new Stpp_Exception($this->__('The XmlReader has not been set.'));
45
+ }
46
+ return $this->_xmlReader;
47
+ }
48
+
49
+ public function setContext(Stpp_Api_ContextInterface $context) {
50
+ $this->_context = $context;
51
+ }
52
+
53
+ protected function _getContext() {
54
+ if ($this->_context === null) {
55
+ throw new Stpp_Exception($this->__('The context object is null.'));
56
+ }
57
+ return $this->_context;
58
+ }
59
+
60
+ public function run(array $requestArray) {
61
+ $xmlRequestString = $this->_formXmlRequests($requestArray);
62
+ $xmlResponseString = $this->getConnection()->sendAndReceiveData($xmlRequestString);
63
+ $responseArray = $this->_getXmlReader()->parseResponses($xmlResponseString);
64
+ $this->_mapRequestsToResponses($requestArray, $responseArray);
65
+ $this->_getContext()->setRequests($requestArray)->setResponses($responseArray);
66
+ return $this->_getContext();
67
+ }
68
+
69
+ protected function _formXmlRequests(array $requests) {
70
+ $xmlWriter = $this->_getXmlWriter();
71
+
72
+ $xmlWriter->startRequestBlock(static::API_VERSION, $this->getConnection()->getAlias());
73
+
74
+ foreach($requests as $request) {
75
+ $xmlWriter->startRequest($request);
76
+
77
+ $requestType = $request->get('requesttypedescription');
78
+
79
+ switch($requestType) {
80
+ case Stpp_Types::API_AUTH:
81
+ if ($request->has('md')) {
82
+ $xmlWriter->prepare3dAuth($request);
83
+ }
84
+ else {
85
+ $xmlWriter->prepareAuth($request);
86
+ }
87
+ break;
88
+ case Stpp_Types::API_THREEDQUERY:
89
+ $xmlWriter->prepare3dQuery($request);
90
+ break;
91
+ case Stpp_Types::API_RISKDEC:
92
+ $xmlWriter->prepareRiskDecision($request);
93
+ break;
94
+ case Stpp_Types::API_ACCOUNTCHECK:
95
+ $xmlWriter->prepareAccountCheck($request);
96
+ break;
97
+ case Stpp_Types::API_CARDSTORE:
98
+ $xmlWriter->prepareCardStore($request);
99
+ break;
100
+ case Stpp_Types::API_TRANSACTIONUPDATE:
101
+ $xmlWriter->prepareTransactionUpdate($request);
102
+ break;
103
+ case Stpp_Types::API_REFUND:
104
+ $xmlWriter->prepareRefund($request);
105
+ break;
106
+ default:
107
+ throw new Stpp_Exception(sprintf($this->__('Invalid request type: "%s".'), $requestType));
108
+ }
109
+ $xmlWriter->endRequest();
110
+ }
111
+ return $xmlWriter->endRequestBlock();
112
+ }
113
+
114
+ protected function _mapRequestsToResponses(array &$requests, array &$responses) {
115
+ for ($i = 0; $i < count($responses); $i++) {
116
+ $requests[$i]->setResponse($responses[$i]);
117
+ $responses[$i]->setRequest($requests[$i]);
118
+ }
119
+ return $this;
120
+ }
121
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/SendInterface.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_SendInterface {
4
+ public function run(array $requestArray);
5
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/Reader.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Xml_Reader extends Stpp_Component_Abstract implements Stpp_Api_Xml_ReaderInterface {
4
+ protected $_reader;
5
+
6
+ protected $_responseClassName;
7
+
8
+ public function __construct($responseClassName) {
9
+ $this->_responseClassName = $responseClassName;
10
+ }
11
+
12
+ protected function _newResponseObject() {
13
+ $responseClassName = $this->_responseClassName;
14
+ return $responseClassName::instance();
15
+ }
16
+
17
+ public function parseResponses($xmlString) {
18
+ $this->_reader = new SimpleXmlElement($xmlString);
19
+
20
+ $xmlResponses = $this->_reader->xpath('response');
21
+
22
+ $responseBlockVersion = (string) $this->_reader->attributes()->version;
23
+ $responseBlockRequestReference = (string) $this->_reader->requestreference;
24
+
25
+ if (empty($xmlResponses)) {
26
+ throw new Stpp_Exception($this->__('No response element in response XML.'));
27
+ }
28
+
29
+ $responses = array();
30
+
31
+ foreach($xmlResponses as $xmlResponse) {
32
+ $responseType = (string) $xmlResponse->attributes()->type;
33
+
34
+ if (!in_array($responseType, Stpp_Types::getRequestAndResponseTypes())) {
35
+ throw new Stpp_Exception(sprintf($this->__('Unsupported response type "%s" returned.'), $responseType));
36
+ }
37
+
38
+ $response = $this->_parseStandardInformation($xmlResponse, $responseType);
39
+ $response->set('responseblockversion', $responseBlockVersion);
40
+ $response->set('responseblockrequestreference', $responseBlockRequestReference);
41
+
42
+ switch($responseType) {
43
+ case Stpp_Types::API_ERROR:
44
+ $this->_parseErrorResponse($xmlResponse, $response);
45
+ break;
46
+ case Stpp_Types::API_AUTH:
47
+ $this->_parseAuthResponse($xmlResponse, $response);
48
+ break;
49
+ case Stpp_Types::API_THREEDQUERY:
50
+ $this->_parse3dQueryResponse($xmlResponse, $response);
51
+ break;
52
+ case Stpp_Types::API_RISKDEC:
53
+ $this->_parseRiskDecisionResponse($xmlResponse, $response);
54
+ break;
55
+ case Stpp_Types::API_CARDSTORE:
56
+ $this->_parseCardStoreResponse($xmlResponse, $response);
57
+ break;
58
+ case Stpp_Types::API_TRANSACTIONUPDATE:
59
+ // The _parseStandardInformation() method sets everything returned in a TRANSACTIONUPDATE response so no method call is needed here.
60
+ break;
61
+ case Stpp_Types::API_REFUND:
62
+ $this->_parseRefundResponse($xmlResponse, $response);
63
+ break;
64
+ default:
65
+ throw new Stpp_Exception(sprintf($this->__('Response type "%s" unhandled.'), $responseType));
66
+ }
67
+ $responses[] = $response;
68
+ }
69
+ return $responses;
70
+ }
71
+
72
+ protected function _parseStandardInformation($xmlResponse, $responseType) {
73
+ $response = $this->_newResponseObject();
74
+ $response->set('responsetype', $responseType);
75
+
76
+ $response->set('timestamp', (string)$xmlResponse->timestamp);
77
+ $response->set('errorcode', (string) $xmlResponse->error->code);
78
+ $response->set('errormessage', (string) $xmlResponse->error->message); // May not be present.
79
+ $response->set('errordata', (string) $xmlResponse->error->data); // May not be present.
80
+
81
+ return $response;
82
+ }
83
+
84
+ protected function _parseErrorResponse($xmlResponse, &$response) {
85
+ $response->set('transactionreference', (string) $xmlResponse->transactionreference);
86
+ }
87
+
88
+ protected function _parseRiskDecisionResponse($xmlResponse, &$response) {
89
+ $response->set('orderreference', (string) $xmlResponse->merchant->orderreference);
90
+ $response->set('transactionreference', (string) $xmlResponse->transactionreference);
91
+ $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
92
+
93
+ $response->set('fraudcontrolreference', (string) $xmlResponse->fraudcontrol->reference);
94
+ $response->set('fraudcontrolshieldstatuscode', (string) $xmlResponse->fraudcontrol->shieldstatuscode);
95
+ $response->set('fraudcontrolrecommendedaction', (string) $xmlResponse->fraudcontrol->recommendedaction);
96
+ $response->set('fraudcontrolcategoryflag', (string) $xmlResponse->fraudcontrol->categoryflag);
97
+ $response->set('fraudcontrolcategorymessage', (string) $xmlResponse->fraudcontrol->categorymessage);
98
+ $response->set('fraudcontrolcode', (string) $xmlResponse->fraudcontrolcode);
99
+ $response->set('fraudcontrollive', (string) $xmlResponse->live);
100
+
101
+ $response->set('parenttransactionreference', (string) $xmlResponse->operation->parenttransactionreference);
102
+ $response->set('accounttypedescription', (string) $xmlResponse->operation->accounttypedescription);
103
+ }
104
+
105
+ protected function _parseAuthResponse($xmlResponse, &$response) {
106
+ $this->_parseAuthOr3dQueryResponse($xmlResponse, $response, false);
107
+ }
108
+
109
+ protected function _parse3dQueryResponse($xmlResponse, &$response) {
110
+ $this->_parseAuthOr3dQueryResponse($xmlResponse, $response, true);
111
+ }
112
+
113
+ protected function _parseAuthOr3dQueryResponse($xmlResponse, &$response, $is3dResponse) {
114
+ $response->set('merchantname', (string) $xmlResponse->merchant->merchantname);
115
+ $response->set('orderreference', (string) $xmlResponse->merchant->orderreference);
116
+ $response->set('tid', (string) $xmlResponse->merchant->tid);
117
+ $response->set('merchantnumber', (string) $xmlResponse->merchant->merchantnumber);
118
+ $response->set('merchantcountryiso2a', (string) $xmlResponse->merchant->merchantcountryiso2a);
119
+ $response->set('transactionreference', (string) $xmlResponse->transactionreference);
120
+ $response->set('securityresponsesecuritycode', (string) $xmlResponse->security->securitycode);
121
+ $response->set('securityresponsepostcode', (string) $xmlResponse->security->postcode);
122
+ $response->set('securityresponseaddress', (string) $xmlResponse->security->address);
123
+
124
+ if (isset($xmlResponse->billing->amount)) { // Not present in THREEDQUERY response.
125
+ $response->set('baseamount', (string) $xmlResponse->billing->amount);
126
+ $response->set('currencyiso3a', (string) $xmlResponse->billing->amount->attributes()->currencycode);
127
+ }
128
+
129
+ $response->set('paymenttype', (string) $xmlResponse->billing->payment->attributes()->type);
130
+ $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
131
+ $response->set('authcode', (string) $xmlResponse->authcode);
132
+
133
+ $response->set('acsurl', (string) $xmlResponse->threedsecure->acsurl);
134
+ $response->set('cavv', (string) $xmlResponse->threedsecure->cavv);
135
+ $response->set('3dstatus', (string) $xmlResponse->threedsecure->status);
136
+ $response->set('xid', (string) $xmlResponse->threedsecure->xid);
137
+ $response->set('eci', (string) $xmlResponse->threedsecure->eci);
138
+ $response->set('enrolled', (string) $xmlResponse->threedsecure->enrolled);
139
+ $response->set('termurl', (string) $xmlResponse->threedsecure->termurl);
140
+ $response->set('md', (string) $xmlResponse->threedsecure->md);
141
+ $response->set('pareq', (string) $xmlResponse->threedsecure->pareq);
142
+
143
+ $response->set('live', (string) $xmlResponse->live);
144
+
145
+ $response->set('parenttransactionreference', (string) $xmlResponse->operation->parenttransactionreference);
146
+ $response->set('accounttypedescription', (string) $xmlResponse->operation->accounttypedescription);
147
+ $response->set('settleduedate', (string) $xmlResponse->settlement->settleduedate);
148
+ $response->set('settlestatus', (string) $xmlResponse->settlement->settlestatus);
149
+ }
150
+
151
+ protected function _parseCardStoreResponse($xmlResponse, &$response) {
152
+ $response->set('merchantname', (string) $xmlResponse->merchant->merchantname);
153
+ $response->set('orderreference', (string) $xmlResponse->merchant->orderreference);
154
+ $response->set('transactionreference', (string) $xmlResponse->transactionreference);
155
+ $response->set('paymenttype', (string) $xmlResponse->billing->payment->attributes()->type);
156
+ $response->set('paymentactive', (string) $xmlResponse->billing->payment->active);
157
+ $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
158
+ $response->set('live', (string) $xmlResponse->live);
159
+ $response->set('accounttypedescription', (string) $xmlResponse->operation->accounttypedescription);
160
+ }
161
+
162
+ protected function _parseRefundResponse($xmlResponse, &$response) {
163
+ $response->set('merchantname', (string) $xmlResponse->response->merchant->merchantname);
164
+ $response->set('orderreference', (string) $xmlResponse->response->merchant->orderreference);
165
+ $response->set('tid', (string) $xmlResponse->response->merchant->tid);
166
+ $response->set('merchantnumber', (string) $xmlResponse->response->merchant->merchantnumber);
167
+ $response->set('merchantcountryiso2a', (string) $xmlResponse->response->merchant->merchantcountryiso2a);
168
+ $response->set('transactionreference', (string) $xmlResponse->response->transactionreference);
169
+ $response->set('baseamount', (string) $xmlResponse->response->billing->amount);
170
+ $response->set('currencyiso3a', (string) $xmlResponse->response->billing->amount->attributes()->currencycode);
171
+ $response->set('paymenttype', (string) $xmlResponse->response->billing->payment->attributes()->type);
172
+ $response->set('maskedpan', (string) $xmlResponse->response->billing->payment->pan);
173
+ $response->set('authcode', (string) $xmlResponse->response->authcode);
174
+ $response->set('securityresponsecode', (string) $xmlResponse->response->security->securitycode);
175
+ $response->set('securityresponsepostcode', (string) $xmlResponse->response->security->postcode);
176
+ $response->set('securityresponseaddress', (string) $xmlResponse->response->security->address);
177
+ $response->set('parenttransactionreference', (string) $xmlResponse->response->operation->parenttransactionreference);
178
+ $response->set('accounttypedescription', (string) $xmlResponse->response->operation->accounttypedescription);
179
+ $response->set('settleduedate', (string) $xmlResponse->response->settlement->settleduedate);
180
+ $response->set('settlestatus', (string) $xmlResponse->response->settlement->settlestatus);
181
+ }
182
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/ReaderInterface.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_Xml_ReaderInterface {
4
+ function parseResponses($xmlString);
5
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/Writer.php ADDED
@@ -0,0 +1,540 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Api_Xml_Writer extends Stpp_Component_Abstract implements Stpp_Api_Xml_WriterInterface {
4
+ protected $_writer;
5
+
6
+ protected $_xmlVersion = "1.0";
7
+
8
+ protected $_xmlEncoding = 'UTF-8';
9
+
10
+ public function __construct() {
11
+ $this->_initWriter();
12
+ parent::__construct();
13
+ }
14
+
15
+ protected function _initWriter() {
16
+ $this->_writer = new Stpp_Xml_Writer();
17
+ $this->_writer->openMemory();
18
+
19
+ $this->_writer->setIndent(true);
20
+ $this->_writer->setIndentString("\t");
21
+ }
22
+
23
+ public function setXmlVersion($version) {
24
+ $this->_xmlVersion = $version;
25
+ return $this;
26
+ }
27
+
28
+ public function setXmlEncoding($encoding) {
29
+ $this->_xmlEncoding = $encoding;
30
+ return $this;
31
+ }
32
+
33
+ public function startRequestBlock($apiVersion, $alias) {
34
+ $this->_writer->startDocument($this->_xmlVersion, $this->_xmlEncoding);
35
+
36
+ // <requestblock version="">
37
+ $this->_writer->startElement('requestblock');
38
+ $this->_writer->writeAttribute('version', $apiVersion);
39
+
40
+ // <alias></alias>
41
+ $this->_writer->writeElement('alias', $alias);
42
+
43
+ return $this;
44
+ }
45
+
46
+ public function endRequestBlock() {
47
+ $this->_writer->endElement(); // </requestblock>
48
+ $this->_writer->endDocument();
49
+ return $this->_writer->flush();
50
+ }
51
+
52
+ public function startRequest(Stpp_Data_Request $request) {
53
+ // <request>
54
+ $this->_writer->startElement('request');
55
+ $this->_writer->writeAttribute('type', $request->get('requesttypedescription'));
56
+
57
+ return $this;
58
+ }
59
+
60
+ public function endRequest() {
61
+ // </request>
62
+ $this->_writer->endElement();
63
+
64
+ return $this;
65
+ }
66
+
67
+ public function prepareAuth(Stpp_Data_Request $request) {
68
+ return $this->_prepareFullParentTransaction($request);
69
+ }
70
+
71
+ public function prepare3dQuery(Stpp_Data_Request $request) {
72
+ return $this->_prepareFullParentTransaction($request);
73
+ }
74
+
75
+ public function prepare3dAuth(Stpp_Data_Request $request) {
76
+ $xmlWriter = $this->_writer;
77
+
78
+ // <operation>
79
+ $xmlWriter->startElement('operation');
80
+
81
+ // <md></md>
82
+ $xmlWriter->writeElement('md', $request->get('md'));
83
+
84
+ // <pares></pares>
85
+ $xmlWriter->writeElement('pares', $request->get('pares'));
86
+
87
+ // </operation>
88
+ $xmlWriter->endElement();
89
+
90
+ return $this;
91
+ }
92
+
93
+ public function prepareRiskDecision(Stpp_Data_Request $request) {
94
+ return $this->_prepareFullParentTransaction($request);
95
+ }
96
+
97
+ public function prepareAccountCheck(Stpp_Data_Request $request) {
98
+ return $this->_prepareFullParentTransaction($request);
99
+ }
100
+
101
+ public function prepareCardStore(Stpp_Data_Request $request) {
102
+ $xmlWriter = $this->_writer;
103
+
104
+ // <merchant>
105
+ $xmlWriter->startElement('merchant');
106
+
107
+ // <orderreference></orderreference>
108
+ $xmlWriter->writeElement('orderreference', $request->get('orderreference'));
109
+
110
+ // </merchant>
111
+ $xmlWriter->endElement();
112
+
113
+ // <operation>
114
+ $xmlWriter->startElement('operation');
115
+
116
+ // <sitereference></sitereference>
117
+ $xmlWriter->writeElement('sitereference', $request->get('sitereference'));
118
+
119
+ // <accounttypedescription></accounttypedescription>
120
+ $xmlWriter->writeElement('accounttypedescription', $request->get('accounttypedescription'));
121
+
122
+ // </operation>
123
+ $xmlWriter->endElement();
124
+
125
+ // <billing>
126
+ $xmlWriter->startElement('billing');
127
+
128
+ // <telephone type=''></telephone>
129
+ $xmlWriter->startElement('telephone');
130
+ $xmlWriter->writeAttribute('type', $request->get('billingtelephonetype'));
131
+ $xmlWriter->text($request->get('billingtelephone'));
132
+ $xmlWriter->endElement();
133
+
134
+ // <street></street>
135
+ $xmlWriter->writeElement('street', $request->get('billingstreet'));
136
+
137
+ // <postcode></postcode>
138
+ $xmlWriter->writeElement('postcode', $request->get('billingpostcode'));
139
+
140
+ // <premise></premise>
141
+ $xmlWriter->writeElement('premise', $request->get('billingpremise'));
142
+
143
+ // <town></town>
144
+ $xmlWriter->writeElement('town', $request->get('billingtown'));
145
+
146
+ // <country></country>
147
+ $xmlWriter->writeElement('country', $request->get('billingcountryiso2a'));
148
+
149
+ // <payment type=''>
150
+ $xmlWriter->startElement('payment');
151
+ $xmlWriter->writeAttribute('type', $request->get('paymenttype'));
152
+
153
+ // <startdate></startdate>
154
+ $xmlWriter->writeElement('startdate', $request->get('startdate'));
155
+
156
+ // <expirydate></expirydate>
157
+ $xmlWriter->writeElement('expirydate', $request->get('expirydate'));
158
+
159
+ // <pan></pan>
160
+ $xmlWriter->writeElement('pan', $request->get('pan'));
161
+
162
+ // <securitycode></securitycode>
163
+ $xmlWriter->writeElement('securitycode', $request->get('securitycode'));
164
+
165
+ // <issuenumber></issuenumber>
166
+ $xmlWriter->writeElement('issuenumber', $request->get('issuenumber'));
167
+
168
+ // </payment>
169
+ $xmlWriter->endElement();
170
+
171
+ // <name>
172
+ $xmlWriter->startElement('name');
173
+
174
+ // <middle></middle>
175
+ $xmlWriter->writeElement('middle', $request->get('billingmiddlename'));
176
+
177
+ // <prefix></prefix>
178
+ $xmlWriter->writeElement('prefix', $request->get('billingprefix'));
179
+
180
+ // <last></last>
181
+ $xmlWriter->writeElement('last', $request->get('billinglastname'));
182
+
183
+ // <first></first>
184
+ $xmlWriter->writeElement('first', $request->get('billingfirstname'));
185
+
186
+ // <suffix></suffix>
187
+ $xmlWriter->writeElement('suffix', $request->get('billingsuffix'));
188
+
189
+ // </name>
190
+ $xmlWriter->endElement();
191
+
192
+ // <email></email>
193
+ $xmlWriter->writeElement('email', $request->get('billingemail'));
194
+
195
+ // </billing>
196
+ $xmlWriter->endElement();
197
+
198
+ return $this;
199
+ }
200
+
201
+ public function prepareTransactionUpdate(Stpp_Data_Request $request) {
202
+ $xmlWriter = $this->_writer;
203
+
204
+ // <filter>
205
+ $xmlWriter->startElement('filter');
206
+
207
+ // <transactionreference></transactionreference>
208
+ $xmlWriter->writeElement('transactionreference', $request->get('filter')->get('transactionreference'));
209
+
210
+ // <sitereference></sitereference>
211
+ $xmlWriter->writeElement('sitereference', $request->get('filter')->get('sitereference'));
212
+
213
+ // </filter>
214
+ $xmlWriter->endElement();
215
+
216
+ // <updates>
217
+ $xmlWriter->startElement('updates');
218
+
219
+ // <merchant>
220
+ $xmlWriter->startElement('merchant');
221
+
222
+ // <orderreference></orderreference>
223
+ $xmlWriter->writeElement('orderreference', $request->get('updates')->get('orderreference'));
224
+
225
+ // </merchant>
226
+ $xmlWriter->fullEndElement();
227
+
228
+ // <billing>
229
+ $xmlWriter->startElement('billing');
230
+
231
+ if ($request->get('updates')->has('billingtelephonetype') || $request->get('updates')->has('billingtelephone')) {
232
+ // <telephone type=''></telephone>
233
+ $xmlWriter->startElement('telephone');
234
+ $xmlWriter->writeAttribute('type', $request->get('updates')->get('billingtelephonetype'));
235
+ $xmlWriter->text($request->get('updates')->get('billingtelephone'));
236
+ $xmlWriter->endElement();
237
+ }
238
+
239
+ // <street></street>
240
+ $xmlWriter->writeElement('street', $request->get('updates')->get('billingstreet'));
241
+
242
+ // <postcode></postcode>
243
+ $xmlWriter->writeElement('postcode', $request->get('updates')->get('billingpostcode'));
244
+
245
+ // <premise></premise>
246
+ $xmlWriter->writeElement('premise', $request->get('updates')->get('billingpremise'));
247
+
248
+ // <town></town>
249
+ $xmlWriter->writeElement('town', $request->get('updates')->get('billingtown'));
250
+
251
+ // <country></country>
252
+ $xmlWriter->writeElement('country', $request->get('updates')->get('billingcountryiso2a'));
253
+
254
+ // <payment type=''>
255
+ $xmlWriter->startElement('payment');
256
+
257
+ // <startdate></startdate>
258
+ $xmlWriter->writeElement('startdate', $request->get('updates')->get('startdate'));
259
+
260
+ // <expirydate></expirydate>
261
+ $xmlWriter->writeElement('expirydate', $request->get('updates')->get('expirydate'));
262
+
263
+ // <issuenumber></issuenumber>
264
+ $xmlWriter->writeElement('issuenumber', $request->get('updates')->get('issuenumber'));
265
+
266
+ // </payment>
267
+ $xmlWriter->fullEndElement();
268
+
269
+ // <name>
270
+ $xmlWriter->startElement('name');
271
+
272
+ // <middle></middle>
273
+ $xmlWriter->writeElement('middle', $request->get('updates')->get('billingmiddlename'));
274
+
275
+ // <prefix></prefix>
276
+ $xmlWriter->writeElement('prefix', $request->get('updates')->get('billingprefix'));
277
+
278
+ // <last></last>
279
+ $xmlWriter->writeElement('last', $request->get('updates')->get('billinglastname'));
280
+
281
+ // <first></first>
282
+ $xmlWriter->writeElement('first', $request->get('updates')->get('billingfirstname'));
283
+
284
+ // <suffix></suffix>
285
+ $xmlWriter->writeElement('suffix', $request->get('updates')->get('billingsuffix'));
286
+
287
+ // </name>
288
+ $xmlWriter->fullEndElement();
289
+
290
+ // <email></email>
291
+ $xmlWriter->writeElement('email', $request->get('updates')->get('billingemail'));
292
+
293
+ // </billing>
294
+ $xmlWriter->endElement();
295
+
296
+ // <settlement>
297
+ $xmlWriter->startElement('settlement');
298
+
299
+ // <settlebaseamount></settlebaseamount>
300
+ $xmlWriter->writeElement('settlebaseamount', $request->get('updates')->get('settlebaseamount'));
301
+
302
+ // <settleduedate></settleduedate>
303
+ $xmlWriter->writeElement('settleduedate', $request->get('updates')->get('settleduedate'));
304
+
305
+ // <settlestatus></settlestatus>
306
+ $xmlWriter->writeElement('settlestatus', $request->get('updates')->get('settlestatus'));
307
+
308
+ // </settlement>
309
+ $xmlWriter->endElement();
310
+
311
+ // </updates>
312
+ $xmlWriter->endElement();
313
+
314
+ return $this;
315
+ }
316
+
317
+ public function prepareRefund(Stpp_Data_Request $request) {
318
+ $xmlWriter = $this->_writer;
319
+
320
+ // <operation>
321
+ $xmlWriter->startElement('operation');
322
+
323
+ // <sitereference></sitereference>
324
+ $xmlWriter->writeElement('sitereference', $request->get('sitereference'));
325
+
326
+ // <parenttransactionreference></parenttransactionreference>
327
+ $xmlWriter->writeElement('parenttransactionreference', $request->get('parenttransactionreference'));
328
+
329
+ // </operation>
330
+ $xmlWriter->endElement();
331
+
332
+ // <billing>
333
+ $xmlWriter->startElement('billing');
334
+
335
+ // <amount></amount>
336
+ $xmlWriter->writeElement('amount', $request->get('baseamount'));
337
+
338
+ // </billing>
339
+ $xmlWriter->endElement();
340
+
341
+ return $this;
342
+ }
343
+
344
+ protected function _prepareFullParentTransaction(Stpp_Data_Request $request) {
345
+ $xmlWriter = $this->_writer;
346
+
347
+ // <merchant>
348
+ $xmlWriter->startElement('merchant');
349
+
350
+ // <orderreference></orderreference>
351
+ $xmlWriter->writeElement('orderreference', $request->get('orderreference'));
352
+
353
+ // If request type is 'threedquery':
354
+ if ($request->get('requesttypedescription') === Stpp_Types::API_THREEDQUERY) {
355
+
356
+ // <termurl></termurl>
357
+ $xmlWriter->writeElement('termurl', $request->get('termurl'));
358
+ }
359
+
360
+ // </merchant>
361
+ $xmlWriter->endElement();
362
+
363
+ // <customer>
364
+ $xmlWriter->startElement('customer');
365
+ // <ip></ip>
366
+ $xmlWriter->writeElement('ip', $request->get('customerip'));
367
+
368
+ // <telephone type=''></telephone>
369
+ $xmlWriter->startElement('telephone');
370
+ $xmlWriter->writeAttribute('type', $request->get('customertelephonetype'));
371
+ $xmlWriter->text($request->get('customertelephone'));
372
+ $xmlWriter->endElement();
373
+
374
+ // <street></street>
375
+ $xmlWriter->writeElement('street', $request->get('customerstreet'));
376
+
377
+ // <postcode></postcode>
378
+ $xmlWriter->writeElement('postcode', $request->get('customerpostcode'));
379
+
380
+ // <premise></premise>
381
+ $xmlWriter->writeElement('premise', $request->get('customerpremise'));
382
+
383
+ // <town></town>
384
+ $xmlWriter->writeElement('town', $request->get('customertown'));
385
+
386
+ // <country></country>
387
+ $xmlWriter->writeElement('country', $request->get('customercountryiso2a'));
388
+
389
+ // <name>
390
+ $xmlWriter->startElement('name');
391
+
392
+ // <middle></middle>
393
+ $xmlWriter->writeElement('middle', $request->get('customermiddlename'));
394
+
395
+ // <prefix></prefix>
396
+ $xmlWriter->writeElement('prefix', $request->get('customerprefix'));
397
+
398
+ // <last></last>
399
+ $xmlWriter->writeElement('last', $request->get('customerlastname'));
400
+
401
+ // <first></first>
402
+ $xmlWriter->writeElement('first', $request->get('customerfirstname'));
403
+
404
+ // <suffix></suffix>
405
+ $xmlWriter->writeElement('suffix', $request->get('customersuffix'));
406
+
407
+ // </name>
408
+ $xmlWriter->endElement();
409
+
410
+ // <email></email>
411
+ $xmlWriter->writeElement('email', $request->get('customeremail'));
412
+
413
+ // <customershippingmethod></customershippingmethod>
414
+ if ($request->get('requesttypedescription') === Stpp_Types::API_RISKDEC) {
415
+ $xmlWriter->writeElement('shippingmethod', $request->get('customershippingmethod'));
416
+ }
417
+
418
+ // </customer>
419
+ $xmlWriter->endElement();
420
+
421
+ // <billing>
422
+ $xmlWriter->startElement('billing');
423
+
424
+ // <telephone type=''></telephone>
425
+ $xmlWriter->startElement('telephone');
426
+ $xmlWriter->writeAttribute('type', $request->get('billingtelephonetype'));
427
+ $xmlWriter->text($request->get('billingtelephone'));
428
+ $xmlWriter->endElement();
429
+
430
+ // <street></street>
431
+ $xmlWriter->writeElement('street', $request->get('billingstreet'));
432
+
433
+ // <postcode></postcode>
434
+ $xmlWriter->writeElement('postcode', $request->get('billingpostcode'));
435
+
436
+ // <premise></premise>
437
+ $xmlWriter->writeElement('premise', $request->get('billingpremise'));
438
+
439
+ // <town></town>
440
+ $xmlWriter->writeElement('town', $request->get('billingtown'));
441
+
442
+ // <country></country>
443
+ $xmlWriter->writeElement('country', $request->get('billingcountryiso2a'));
444
+
445
+ // <payment type=''>
446
+ $xmlWriter->startElement('payment');
447
+ $xmlWriter->writeAttribute('type', $request->get('paymenttype'));
448
+
449
+ // <startdate></startdate>
450
+ $xmlWriter->writeElement('startdate', $request->get('startdate'));
451
+
452
+ // <expirydate></expirydate>
453
+ $xmlWriter->writeElement('expirydate', $request->get('expirydate'));
454
+
455
+ // <pan></pan>
456
+ $xmlWriter->writeElement('pan', $request->get('pan'));
457
+
458
+ // <securitycode></securitycode>
459
+ $xmlWriter->writeElement('securitycode', $request->get('securitycode'));
460
+
461
+ // <issuenumber></issuenumber>
462
+ $xmlWriter->writeElement('issuenumber', $request->get('issuenumber'));
463
+
464
+ // </payment>
465
+ $xmlWriter->endElement();
466
+
467
+ // <name>
468
+ $xmlWriter->startElement('name');
469
+
470
+ // <middle></middle>
471
+ $xmlWriter->writeElement('middle', $request->get('middlename'));
472
+
473
+ // <prefix></prefix>
474
+ $xmlWriter->writeElement('prefix', $request->get('billingprefix'));
475
+
476
+ // <last></last>
477
+ $xmlWriter->writeElement('last', $request->get('billinglastname'));
478
+
479
+ // <first></first>
480
+ $xmlWriter->writeElement('first', $request->get('billingfirstname'));
481
+
482
+ // <suffix></suffix>
483
+ $xmlWriter->writeElement('suffix', $request->get('billingsuffix'));
484
+
485
+ // </name>
486
+ $xmlWriter->endElement();
487
+
488
+ // <amount currencycode=''></amount>
489
+ $xmlWriter->startElement('amount');
490
+ $xmlWriter->writeAttribute('currencycode', $request->get('currencyiso3a'));
491
+ $xmlWriter->text($request->get('baseamount'));
492
+ $xmlWriter->endElement();
493
+
494
+ // <mainamount></mainamount>
495
+ $xmlWriter->startElement('mainamount');
496
+ $xmlWriter->writeAttribute('currencycode', $request->get('currencyiso3a'));
497
+ $xmlWriter->text($request->get('mainamount'));
498
+ $xmlWriter->endElement();
499
+
500
+ // <email></email>
501
+ $xmlWriter->writeElement('email', $request->get('billingemail'));
502
+
503
+ // <dob</dob>
504
+ if ($request->get('requesttypedescription') === Stpp_Types::API_RISKDEC) {
505
+ $xmlWriter->writeElement('dob', $request->get('billingdob'));
506
+ }
507
+
508
+ // </billing>
509
+ $xmlWriter->endElement();
510
+
511
+ // <operation>
512
+ $xmlWriter->startElement('operation');
513
+
514
+ // <sitereference></sitereference>
515
+ $xmlWriter->writeElement('sitereference', $request->get('sitereference'));
516
+
517
+ // <accounttypedescription></accounttypedescription>
518
+ $xmlWriter->writeElement('accounttypedescription', $request->get('accounttypedescription'));
519
+
520
+ // <parenttransactionreference></parenttransactionreference>
521
+ $xmlWriter->writeElement('parenttransactionreference', $request->get('parenttransactionreference'));
522
+
523
+ // </operation>
524
+ $xmlWriter->endElement();
525
+
526
+ // <settlement>
527
+ $xmlWriter->startElement('settlement');
528
+
529
+ // <settleduedate></settleduedate>
530
+ $xmlWriter->writeElement('settleduedate', $request->get('settleduedate'));
531
+
532
+ // <settlestatus></settlestatus>
533
+ $xmlWriter->writeElement('settlestatus', $request->get('settlestatus'));
534
+
535
+ // </settlement>
536
+ $xmlWriter->endElement();
537
+
538
+ return $this;
539
+ }
540
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/WriterInterface.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Api_Xml_WriterInterface {
4
+ function startRequestBlock($apiVersion, $alias);
5
+ function endRequestBlock();
6
+
7
+ function startRequest(Stpp_Data_Request $request);
8
+ function endRequest();
9
+
10
+ function prepareAuth(Stpp_Data_Request $request);
11
+ function prepare3dQuery(Stpp_Data_Request $request);
12
+ function prepare3dAuth(Stpp_Data_Request $request);
13
+ function prepareRiskDecision(Stpp_Data_Request $request);
14
+ function prepareAccountCheck(Stpp_Data_Request $request);
15
+ function prepareCardStore(Stpp_Data_Request $request);
16
+ function prepareTransactionUpdate(Stpp_Data_Request $request);
17
+ function prepareRefund(Stpp_Data_Request $request);
18
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Component/Abstract.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Stpp_Component_Abstract implements Stpp_Component_BaseInterface {
4
+ protected $_debugLog;
5
+
6
+ protected $_translator;
7
+
8
+ public function __construct() {
9
+ Stpp_Component_Store::registerComponent($this);
10
+ }
11
+
12
+ public function setDebugLog(Stpp_Utility_Log_BaseInterface $log) {
13
+ $this->_debugLog = $log;
14
+ return $this;
15
+ }
16
+
17
+ public function setTranslator(Stpp_Utility_Translator_BaseInterface $translator) {
18
+ $this->_translator = $translator;
19
+ return $this;
20
+ }
21
+
22
+ public function getDebugLog() {
23
+ return $this->_debugLog;
24
+ }
25
+
26
+ public function getTranslator() {
27
+ return $this->_translator;
28
+ }
29
+
30
+ public function __($message) {
31
+ return $this->getTranslator()->translate($message);
32
+ }
33
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Component/BaseInterface.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Component_BaseInterface {
4
+ function setTranslator(Stpp_Utility_Translator_BaseInterface $translator);
5
+ function setDebugLog(Stpp_Utility_Log_BaseInterface $log);
6
+ function getTranslator();
7
+ function getDebugLog();
8
+ function __($message);
9
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Component/Store.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Component_Store {
4
+ protected static $_components = array();
5
+
6
+ protected static $_translator;
7
+
8
+ protected static $_debugLog;
9
+
10
+ public static function registerComponent(Stpp_Component_BaseInterface $component) {
11
+ $component->setTranslator(self::$_translator);
12
+ $component->setDebugLog(self::$_debugLog);
13
+ self::$_components[] = $component;
14
+ }
15
+
16
+ public static function registerTranslator(Stpp_Utility_Translator_BaseInterface $translator) {
17
+ self::$_translator = $translator;
18
+
19
+ foreach(self::$_components as $component) {
20
+ $component->setTranslator($translator);
21
+ }
22
+ }
23
+
24
+ public static function registerDebugLog(Stpp_Utility_Log_BaseInterface $log) {
25
+ self::$_debugLog = $log;
26
+
27
+ foreach(self::$_components as $component) {
28
+ $component->setDebugLog($log);
29
+ }
30
+ }
31
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Config.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Config {
4
+ protected $_config = array();
5
+
6
+ public function __construct(array $config = array()) {
7
+ $this->_config = $config;
8
+ }
9
+
10
+ public function has($key) {
11
+ $config = &$this->_config;
12
+ $array = explode('/', $key);
13
+
14
+ foreach($array as $keySegment) {
15
+ if (array_key_exists($keySegment, $config)) {
16
+ $config = &$config[$keySegment];
17
+ continue;
18
+ }
19
+ return false;
20
+ }
21
+ return true;
22
+ }
23
+
24
+ public function get($key) {
25
+ $config = &$this->_config;
26
+ $array = explode('/', $key);
27
+
28
+ foreach($array as $keySegment) {
29
+ if (array_key_exists($keySegment, $config)) {
30
+ $config = &$config[$keySegment];
31
+ continue;
32
+ }
33
+ throw new Stpp_Exception(sprintf('Could not retrieve the key "%s".', $key));
34
+ }
35
+ return $config;
36
+ }
37
+
38
+ public function set($key, $value) {
39
+ $config = &$this->_config;
40
+ $array = explode('/', $key);
41
+ $lastIndex = array_pop($array);
42
+
43
+ foreach($array as $keySegment) {
44
+ if (array_key_exists($keySegment, $config)) {
45
+ $config = &$config[$keySegment];
46
+ continue;
47
+ }
48
+ $config[$keySegment] = array();
49
+ $config = &$config[$keySegment];
50
+ }
51
+ $config[$lastIndex] = $value;
52
+ return $this;
53
+ }
54
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Data/Abstract.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Stpp_Data_Abstract extends Stpp_Component_Abstract implements Stpp_Data_AbstractInterface, ArrayAccess, Countable, Iterator {
4
+ protected $_data = array();
5
+
6
+ protected $_position = 0; // Required by our implementation of Iterator.
7
+
8
+ protected $_count = 0; // Used by our implementation of Countable and Iterator.
9
+
10
+ protected $_skipNextIteration = false; // Used by our implementation of Iterator.
11
+
12
+ public static function instance() {
13
+ return new static();
14
+ }
15
+
16
+ public function cloneObject() {
17
+ return clone $this;
18
+ }
19
+
20
+ public function getAll() {
21
+ $keys = array_keys($this->_data);
22
+ return $this->getMultiple($keys);
23
+ }
24
+
25
+ public function setMultiple(array $values = array()) {
26
+ foreach($values as $k => $v) {
27
+ $this->set($k, $v);
28
+ }
29
+ return $this;
30
+ }
31
+
32
+ public function getMultiple(array $keys = array(), $default = null) {
33
+ $array = array();
34
+ foreach($keys as $key) {
35
+ $array[$key] = $this->get($key, $default);
36
+ }
37
+ return $array;
38
+ }
39
+
40
+ protected function _set($key, $value) {
41
+ $this->_data[$key] = $value;
42
+ }
43
+
44
+ public function set($key, $value) {
45
+ $setterMethod = '_set' . $key;
46
+ if (method_exists($this, $setterMethod)) {
47
+ $this->$setterMethod($value);
48
+ }
49
+ else {
50
+ $this->_set($key, $value);
51
+ }
52
+ $this->_count = count($this->_data);
53
+ return $this;
54
+ }
55
+
56
+ public function get($key, $default = null) {
57
+ $value = array_key_exists($key, $this->_data) ? $this->_data[$key] : $default;
58
+ $getterMethod = '_get' . $key;
59
+
60
+ if (method_exists($this, $getterMethod)) {
61
+ $value = $this->$getterMethod($value);
62
+ }
63
+ return $value;
64
+ }
65
+
66
+ public function has($key) {
67
+ return array_key_exists($key, $this->_data);
68
+ }
69
+
70
+ public function uns($key) {
71
+ unset($this->_data[$key]);
72
+ $this->_skipNextIteration = true;
73
+ $this->_count = count($this->_data);
74
+ }
75
+
76
+ public function toArray() {
77
+ $array = array();
78
+ foreach($this->_data as $k => $v) {
79
+ if ($v instanceof A_Stpp_Data) {
80
+ $array[$k] = $this->_data[$k]->toArray();
81
+ }
82
+ else {
83
+ $array[$k] = $v;
84
+ }
85
+ }
86
+ return $array;
87
+ }
88
+
89
+ // Countable:
90
+
91
+ function count() {
92
+ return $this->_count;
93
+ }
94
+
95
+ // Iterable:
96
+
97
+ public function current() {
98
+ $this->_skipNextIteration = false;
99
+ return current($this->_data);
100
+ }
101
+
102
+ public function key() {
103
+ return key($this->_data);
104
+ }
105
+
106
+ public function next() {
107
+ if ($this->_skipNextIteration) {
108
+ $this->_skipNextIteration = false;
109
+ return;
110
+ }
111
+ $this->_position++;
112
+ next($this->_data);
113
+ }
114
+
115
+ public function rewind() {
116
+ $this->_skipNextIteration = false;
117
+ $this->_position = 0;
118
+ reset($this->_data);
119
+ }
120
+
121
+ public function valid() {
122
+ return $this->_position < $this->_count;
123
+ }
124
+
125
+ // ArrayAccess
126
+
127
+ public function offsetExists($offset) {
128
+ return $this->has($offset);
129
+ }
130
+
131
+ public function offsetGet($offset) {
132
+ return $this->get($offset);
133
+ }
134
+
135
+ public function offsetSet($offset, $value) {
136
+ return $this->set($offset, $value);
137
+ }
138
+
139
+ public function offsetUnset($offset) {
140
+ return $this->unset($offset);
141
+ }
142
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Data/AbstractInterface.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Data_AbstractInterface {
4
+ static public function instance();
5
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Data/Request.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Data_Request extends Stpp_Data_Abstract {
4
+ protected $_frameworkLogic;
5
+
6
+ protected $_response;
7
+
8
+ protected $_isSuccessful;
9
+
10
+ public function __construct() {
11
+ if(isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR'])) {
12
+ $this->set('customerip', $_SERVER['REMOTE_ADDR']);
13
+ }
14
+ parent::__construct();
15
+ }
16
+
17
+ public function setUseFrameworkLogic($string) {
18
+ $this->_frameworkLogic = $string;
19
+ return $this;
20
+ }
21
+
22
+ public function getUseFrameworkLogic() {
23
+ return $this->_frameworkLogic;
24
+ }
25
+
26
+ public function setResponse(Stpp_Data_Response $response) {
27
+ $this->_response = $response;
28
+ return $this;
29
+ }
30
+
31
+ public function getResponse() {
32
+ return $this->_response;
33
+ }
34
+
35
+ public function setIsSuccessful($bool) {
36
+ $this->_isSuccessful = $bool;
37
+ return $this;
38
+ }
39
+
40
+ public function getIsSuccessful() {
41
+ return $this->_isSuccessful;
42
+ }
43
+
44
+ public function removeSecureData() {
45
+ if ($this->has('pan')) {
46
+ $this->set('pan', $this->__('Removed.'));
47
+ }
48
+ if ($this->has('securitycode')) {
49
+ $this->set('securitycode', $this->__('Removed.'));
50
+ }
51
+ return $this;
52
+ }
53
+
54
+ protected function _setAccounttypedescription($accountTypeDescription) {
55
+ if (!in_array($accountTypeDescription, Stpp_Types::getAccountTypeDescriptions())) {
56
+ throw new Stpp_Exception(sprintf($this->__("Invalid accounttypedescription: '%s'."), $accountTypeDescription));
57
+ }
58
+ $this->_set('accounttypedescription', $accountTypeDescription);
59
+ }
60
+
61
+ protected function _setRequesttypedescription($requestTypeDescription) {
62
+ if (!in_array($requestTypeDescription, Stpp_Types::getRequestAndResponseTypes())) {
63
+ throw new Stpp_Exception(sprintf($this->__("Invalid request type description: '%s'."), $requestTypeDescription));
64
+ }
65
+ $this->_set('requesttypedescription', $requestTypeDescription);
66
+ }
67
+
68
+ protected function _setPaymenttype($paymentType) {
69
+ if (!array_key_exists($paymentType, Stpp_Types::getCardTypes())) {
70
+ throw new Exception(sprintf($this->__("Invalid paymenttype: '%s'."), $paymentType));
71
+ }
72
+ $this->_set('paymenttype', $paymentType);
73
+ }
74
+
75
+ protected function _setSettleduedate($settleDueDate) {
76
+ $settleDueDate = (int) $settleDueDate;
77
+ if (!array_key_exists($settleDueDate, Stpp_Types::getSettleDueDates())) {
78
+ throw new Stpp_Exception(sprintf($this->__('An invalid settleduedate ("%s") has been provided.'), $settleDueDate));
79
+ }
80
+ $daysToAdd = '+ ' . $settleDueDate . ' days';
81
+ $formattedSettleDueDate = date('Y-m-d', strtotime($daysToAdd));
82
+ $this->_set('settleduedate', $formattedSettleDueDate);
83
+ }
84
+
85
+ protected function _setSettlestatus($settleStatus) {
86
+ $settleStatusArray = Stpp_Types::getSettleStatuses();
87
+ unset($settleStatusArray['3']);
88
+ if (!array_key_exists($settleStatus, $settleStatusArray)) {
89
+ throw new Stpp_Exception(sprintf($this->__('An invalid settle status ("%s") has been provided.'), $settleStatus));
90
+ }
91
+ $this->_set('settlestatus', $settleStatus);
92
+ }
93
+
94
+ protected function _setBillingtelephonetype($type) {
95
+ if ($this->has('billingtelephone')) {
96
+ $this->_validateTelType($type);
97
+ }
98
+ $this->_set('billingtelephonetype', $type);
99
+ }
100
+
101
+ protected function _setCustomertelephonetype($type) {
102
+ if ($this->has('customertelephone')) {
103
+ $this->_validateTelType($type);
104
+ }
105
+ $this->_set('customertelephonetype', $type);
106
+ }
107
+
108
+ protected function _setBillingcountryiso2a($country) {
109
+ if ($country === 'US') { // For Payment Pages.
110
+ $this->set('locale', 'en_US');
111
+ }
112
+ $this->_set('billingcountryiso2a', $country);
113
+ }
114
+
115
+ protected function _setCustomershippingmethod($customerShippingMethod) {
116
+ if (!array_key_exists($customerShippingMethod, Stpp_Types::getCustomerShippingMethods())) {
117
+ throw new Stpp_Exception(sprintf($this->__('Invalid shipping method provided; "%s".'), $customerShippingMethod));
118
+ }
119
+ $this->_set('customershippingmethod', $customerShippingMethod);
120
+ }
121
+
122
+ protected function _setParentcss($filePath) {
123
+ $fileName = $this->_stripFileExtension($filePath);
124
+
125
+ if ($fileName) {
126
+ $this->_set('parentcss', $fileName);
127
+ }
128
+ }
129
+
130
+ protected function _setChildcss($filePath) {
131
+ $fileName = $this->_stripFileExtension($filePath);
132
+
133
+ if ($fileName) {
134
+ $this->_set('childcss', $fileName);
135
+ }
136
+ }
137
+
138
+ protected function _setParentjs($filePath) {
139
+ $fileName = $this->_stripFileExtension($filePath);
140
+
141
+ if ($fileName) {
142
+ $this->_set('parentjs', $fileName);
143
+ }
144
+ }
145
+
146
+ protected function _setChildjs($filePath) {
147
+ $fileName = $this->_stripFileExtension($filePath);
148
+
149
+ if ($fileName) {
150
+ $this->_set('childjs', $fileName);
151
+ }
152
+ }
153
+
154
+ protected function _validateTelType($type) {
155
+ if (!in_array($type, Stpp_Types::getTelTypes())) {
156
+ throw new Stpp_Exception(sprintf($this->__('Invalid telephone type provided: "%s".'), $type));
157
+ }
158
+ return $type;
159
+ }
160
+
161
+ protected function _getFilter($filter) {
162
+ if (!($filter instanceof Stpp_Data_Request)) {
163
+ throw new Stpp_Exception($this->__('The filter has not been set correctly.'));
164
+ }
165
+ return $filter;
166
+ }
167
+
168
+ protected function _getUpdates($updates) {
169
+ if (!($updates instanceof Stpp_Data_Request)) {
170
+ throw new Stpp_Exception($this->__('The updates have not been set correctly.'));
171
+ }
172
+ return $updates;
173
+ }
174
+
175
+ protected function _stripFileExtension($filePath) {
176
+ $pos = strpos($filePath, '.');
177
+
178
+ if ($pos !== false) {
179
+ return substr($filePath, 0, strpos($filePath, '.'));
180
+ }
181
+ return $filePath;
182
+ }
183
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Data/Response.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Data_Response extends Stpp_Data_Abstract {
4
+ protected $_request;
5
+
6
+ public function setRequest(Stpp_Data_Request $request) {
7
+ $this->_request = $request;
8
+ return $this;
9
+ }
10
+
11
+ public function getRequest($graceful = false) {
12
+ if ($this->_request === null) {
13
+ if ($graceful) {
14
+ return false;
15
+ }
16
+ throw new Stpp_Exception($this->__('The request is null.'));
17
+ }
18
+ return $this->_request;
19
+ }
20
+
21
+ public function hasRequest() {
22
+ return $this->_request !== null;
23
+ }
24
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Exception.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Exception extends Exception {
4
+ protected static $_logInstance;
5
+
6
+ public static function getExceptionLog() {
7
+ return static::$_logInstance;
8
+ }
9
+
10
+ public static function setExceptionLog(Stpp_Utility_Log_BaseInterface $exceptionLog) {
11
+ static::$_logInstance = $exceptionLog;
12
+ }
13
+
14
+ public static function hasExceptionLog() {
15
+ return self::$_logInstance !== null;
16
+ }
17
+
18
+ public function log() {
19
+ try {
20
+ if ($this::hasExceptionLog()) {
21
+ $this::getExceptionLog()->log($this->__toString());
22
+ }
23
+ else {
24
+ throw $this;
25
+ }
26
+ }
27
+ catch (Exception $e) {
28
+ trigger_error($e->__toString(), E_USER_WARNING); // Production servers should have display_errors set to 0.
29
+ }
30
+ }
31
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Facade.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Facade {
4
+ protected $_config;
5
+
6
+ public function __construct(array $config = array()) {
7
+ $this->_config = $this->newStppConfig($config);
8
+ }
9
+
10
+ public static function instance(array $config = array()) {
11
+ return new static($config);
12
+ }
13
+
14
+ public function newStppConfig(array $config) {
15
+ return new Stpp_Config($config);
16
+ }
17
+
18
+ public function newHelper() {
19
+ return new Stpp_Helper();
20
+ }
21
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Admin.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Fields_Admin extends Stpp_Component_Abstract implements Stpp_Fields_AdminInterface {
4
+ const FIELD_ALL_SITE_REFERENCE = 'f_all_sref';
5
+ const FIELD_ALL_ENABLE_AUTHORIZE_ONLY = 'f_all_authonly';
6
+ const FIELD_ALL_SETTLE_DUE_DATE = 'f_all_sduedate';
7
+ const FIELD_ALL_SETTLE_STATUS = 'f_all_sstatus';
8
+
9
+ const FIELD_PPG_USE_SITE_SECURITY = 'f_ppg_usesitesec';
10
+ const FIELD_PPG_SITE_SECURITY_PASSWORD = 'f_ppg_sitesecpw';
11
+ const FIELD_PPG_SITE_SECURITY_ALGORITHM = 'f_ppg_ssecal';
12
+ const FIELD_PPG_USE_NOTIFICATION_HASH = 'f_ppg_usenhash';
13
+ const FIELD_PPG_NOTIFICATION_HASH_PASSWORD = 'f_ppg_nhashpw';
14
+ const FIELD_PPG_NOTIFICATION_HASH_ALGORITHM = 'f_ppg_nhashal';
15
+ const FIELD_PPG_PARENT_CSS = 'f_ppg_pcss';
16
+ const FIELD_PPG_CHILD_CSS = 'f_ppg_ccss';
17
+ const FIELD_PPG_PARENT_JS = 'f_ppg_pjs';
18
+ const FIELD_PPG_CHILD_JS = 'f_ppg_cjs';
19
+ const FIELD_PPG_USE_IFRAME = 'f_ppg_iframe';
20
+ const FIELD_PPG_USE_API = 'f_ppg_useapi';
21
+
22
+ const FIELD_API_ALL_CONNECTION = 'f_api_a_con';
23
+ const FIELD_API_ALL_USE_3D_SECURE = 'f_api_a_use3d';
24
+ const FIELD_API_ALL_USE_RISK_DECISION = 'f_api_a_userd';
25
+ const FIELD_API_ALL_USE_CARD_STORE = 'f_api_a_usecs';
26
+ const FIELD_API_ALL_USE_AUTO_CARD_STORE = 'f_api_a_autocs';
27
+ const FIELD_API_ALL_DELAY_RISK_DECISION = 'f_api_a_delayrd';
28
+ const FIELD_API_ALL_ACCEPTED_CARDS = 'f_api_a_cards';
29
+ const FIELD_API_ALL_USE_IFRAME = 'f_api_a_iframe';
30
+
31
+ const FIELD_API_STAPI_ALIAS = 'f_api_s_alias';
32
+ const FIELD_API_STAPI_HOST = 'f_api_s_hsot';
33
+ const FIELD_API_STAPI_PORT = 'f_api_s_port';
34
+
35
+ const FIELD_API_WS_ALIAS = 'f_api_ws_alias';
36
+ const FIELD_API_WS_USERNAME = 'f_api_ws_un';
37
+ const FIELD_API_WS_PASSWORD = 'f_api_ws_pw';
38
+ const FIELD_API_WS_VERIFY_SSL_CA = 'f_api_ws_verifyssl';
39
+ const FIELD_API_WS_CA_FILE = 'f_api_ws_cafile';
40
+
41
+ const FIELD_TYPE_NAME = 'name';
42
+ const FIELD_TYPE_DESCRIPTION = 'desc';
43
+
44
+ protected $_array = array();
45
+
46
+ public function __construct() {
47
+ parent::__construct();
48
+ $this->_array = array(
49
+ self::FIELD_ALL_SITE_REFERENCE => array(
50
+ self::FIELD_TYPE_NAME => $this->__('Site Reference'),
51
+ self::FIELD_TYPE_DESCRIPTION => $this->__('You must obtain a site reference from SecureTrading before you can use this module. This module can accept either a test site reference or a live site reference.'),
52
+ ),
53
+ self::FIELD_ALL_ENABLE_AUTHORIZE_ONLY => array(
54
+ self::FIELD_TYPE_NAME => $this->__('Enable Authorize Only'),
55
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling authorize only payments will set the settlestatus of the order to 2. This means the payment will be suspended in the SecureTrading system and will not be captured by your aquiring bank.'),
56
+ ),
57
+ self::FIELD_ALL_SETTLE_DUE_DATE => array(
58
+ self::FIELD_TYPE_NAME => $this->__('Settle Due Date'),
59
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The settle due date is the day that funds held against your customers\' account will be aquired.'),
60
+ ),
61
+ self::FIELD_ALL_SETTLE_STATUS => array(
62
+ self::FIELD_TYPE_NAME => $this->__('Settle Status'),
63
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the settle status that will be applied to this transaction. This should normally be set to 0.'),
64
+ ),
65
+ self::FIELD_PPG_USE_SITE_SECURITY => array(
66
+ self::FIELD_TYPE_NAME => $this->__('Use Site Security'),
67
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Site security should always be enabled on a live site. It allows payments to be taken to the Payment Pages safely. It should only be disabled for testing purposes when using a test site reference. The site security must be configured correctly both here and on your SecureTrading account.'),
68
+ ),
69
+ self::FIELD_PPG_SITE_SECURITY_PASSWORD => array(
70
+ self::FIELD_TYPE_NAME => $this->__('Site Security Password'),
71
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the password that will be used as part of the site security configuration. It must match the password configured on your SecureTrading account.'),
72
+ ),
73
+ self::FIELD_PPG_SITE_SECURITY_ALGORITHM => array(
74
+ self::FIELD_TYPE_NAME => $this->__('Site Security Algorithm'),
75
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the hash algorithm that will be used as part of the site security configuration. It must match the algorithm configured on your SecureTrading account.'),
76
+ ),
77
+ self::FIELD_PPG_USE_NOTIFICATION_HASH => array(
78
+ self::FIELD_TYPE_NAME => $this->__('Use Notification Hash'),
79
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The notification hash should always be enabled on a live site. It allows notifications to be sent from SecureTrading to your store securely. It should only be disabled for testing purposes when using a test site reference. The notification hash must be configured correctly both here and on your SecureTrading account in MyST.'),
80
+ ),
81
+ self::FIELD_PPG_NOTIFICATION_HASH_PASSWORD => array(
82
+ self::FIELD_TYPE_NAME => $this->__('Notification Hash Password'),
83
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the password that will be used as part of the notification hash configuration. It must match the password configured on your SecureTrading account in MyST.'),
84
+ ),
85
+ self::FIELD_PPG_NOTIFICATION_HASH_ALGORITHM => array(
86
+ self::FIELD_TYPE_NAME => $this->__('Notification Hash Algorithm'),
87
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the hash algorithm that will be used as part of the notification hash configuration. It must match the algorithm configured on your SecureTrading account in MyST.'),
88
+ ),
89
+ self::FIELD_PPG_PARENT_CSS => array(
90
+ self::FIELD_TYPE_NAME => $this->__('Parent CSS'),
91
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The parent CSS file allows you to make the Payment Pages look the same as your own website by overriding the main CSS stylesheet loaded on the SecureTrading Payment Pages. Upload this stylesheet to the MyST File Manager and then enter the filename of the file you uploaded to the File Manager here, without the file path or the extension.'),
92
+ ),
93
+ self::FIELD_PPG_CHILD_CSS => array(
94
+ self::FIELD_TYPE_NAME => $this->__('Child CSS'),
95
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The child CSS file allows you to alter the appearance of certain parts of the Payment Pages by extending the main CSS stylesheet loaded on the SecureTrading Payment Pages (CSS Inheritance). This is useful when you wish to make minor changes to the default look of the Payment Pages. Upload this stylesheet to the MyST File Manager and then enter the filename of the file you uploaded to the File Manager here, without the file path or the extension.'),
96
+ ),
97
+ self::FIELD_PPG_PARENT_JS => array(
98
+ self::FIELD_TYPE_NAME => $this->__('Parent JS'),
99
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The parent JS file, if provided, replaces the JavaScript file that is loaded when the Payment Pages are viewed by your customers. You should provide this file when you wish to drastically alter the front-end validation and user-experience provided by the default SecureTrading javascript file. Upload this file to the MyST File Manager and then enter the filename of the file you uploaded to the File Manager here, without the file path or the extension.'),
100
+ ),
101
+ self::FIELD_PPG_CHILD_JS => array(
102
+ self::FIELD_TYPE_NAME => $this->__('Child JS'),
103
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The child JS file is loaded after the default Payment Pages Javascript file has been loaded. You can use a child JS file to make small alterations to the default Payment Pages behaviour. Upload this file to the MyST File Manager and then enter the filename of the file you uploaded to the File Manager here, without the file path or the extension.'),
104
+ ),
105
+ self::FIELD_PPG_USE_IFRAME => array(
106
+ self::FIELD_TYPE_NAME => $this->__('Use Iframe'),
107
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling this option will make the Payment Pages load in an HTML iframe element. Using an iframe in combination with parent/child CSS allows you to make it appear as if the Payment Pages are part of your own website.'),
108
+ ),
109
+ self::FIELD_PPG_USE_API => array(
110
+ self::FIELD_TYPE_NAME => $this->__('Use API with Payment Pages'),
111
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling this option will allow your shopping cart to interact with the SecureTrading API using ST API or our WebServices. This allows you to perform TRANSACTIONUPDATE and REFUND requests from the shopping cart without using MyST.'),
112
+ ),
113
+
114
+ self::FIELD_API_ALL_CONNECTION => array(
115
+ self::FIELD_TYPE_NAME => $this->__('Connection'),
116
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This lets you choose which connection method to use when connecting to the SecureTrading API.'),
117
+ ),
118
+ self::FIELD_API_ALL_USE_3D_SECURE => array(
119
+ self::FIELD_TYPE_NAME => $this->__('Use 3D Secure'),
120
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling 3D Secure will reduce the possibility of fraudulent transactions being processed on your store and can shift the liability of chargebacks from you (the merchant) to your aquiring bank . 3D Secure must be enabled on your SecureTrading account before you can use this feature.'),
121
+ ),
122
+ self::FIELD_API_ALL_USE_RISK_DECISION => array(
123
+ self::FIELD_TYPE_NAME => $this->__('Use Risk Decision'),
124
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling Risk Decision requests will reduce the possibility of fraudulent transactions by comparing a customer transaction against a fraud-check database and suspending suspicious transactions. Risk Decision requests must be enabled on your SecureTrading account before you can use this feature.'),
125
+ ),
126
+ self::FIELD_API_ALL_USE_CARD_STORE => array(
127
+ self::FIELD_TYPE_NAME => $this->__('Use Card Store'),
128
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Using Card Store will allow your customers to store their debit/credit card information for easy repeat purchasing. Card information is stored on the SecureTrading servers, not on your own website (a maskedpan and transactionreference only are stored on your site). Card Store requests must be enabled on your SecureTrading account before you can use this feature.'),
129
+ ),
130
+ self::FIELD_API_ALL_DELAY_RISK_DECISION => array(
131
+ self::FIELD_TYPE_NAME => $this->__('Use Risk Decision After Auth'),
132
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The usual scenario is that a Risk Decision request is sent before an Auth request. This allows the Auth to be suspended (settlestatus 2) if the Risk Decision reports that the transaction may be fraudulent. Running a Risk Decision after an Auth (as opposed to before an Auth) provides the risk decision with more information (CC details) to use when determining when a transaction may be fraudulent, but this stops the auth from automatically being suspended if the transaction may be fraudulent.'),
133
+ ),
134
+ self::FIELD_API_ALL_USE_AUTO_CARD_STORE => array(
135
+ self::FIELD_TYPE_NAME => $this->__('Use Auto Card Store'),
136
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling this will make your store automatically process Card Store requests when taking payment: users will not be given the choice to store their card details or not. Card Store requests must be enabled on your SecureTrading account before you use this feature. You must also have selected "Enable Card Store".'),
137
+ ),
138
+ self::FIELD_API_ALL_ACCEPTED_CARDS => array(
139
+ self::FIELD_TYPE_NAME => $this->__('Accepted Cards'),
140
+ self::FIELD_TYPE_DESCRIPTION => $this->__('These are the payment types that you wish to show when a user makes payment with SecureTrading.'),
141
+ ),
142
+ self::FIELD_API_ALL_USE_IFRAME => array(
143
+ self::FIELD_TYPE_NAME => $this->__('Use Iframe'),
144
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling this option will make the 3D Secure ACS URL load in an HTML iframe element (if 3D Secure is enabled). Using an iframe allows you to make it appear as if the ACS URL is part of your own website.'),
145
+ ),
146
+
147
+ self::FIELD_API_STAPI_ALIAS => array(
148
+ self::FIELD_TYPE_NAME => $this->__('ST API Alias'),
149
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the alias to use when connecting to SecureTrading through ST API. Usually this is the same as your site reference.'),
150
+ ),
151
+ self::FIELD_API_STAPI_HOST => array(
152
+ self::FIELD_TYPE_NAME => $this->__('ST API Host'),
153
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the host on which the ST API client is running. This should usually be set to "localhost".'),
154
+ ),
155
+ self::FIELD_API_STAPI_PORT => array(
156
+ self::FIELD_TYPE_NAME => $this->__('ST API Port'),
157
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the port on which the ST API client is listening. The default port for ST API is 5000.'),
158
+ ),
159
+
160
+ self::FIELD_API_WS_ALIAS => array(
161
+ self::FIELD_TYPE_NAME => $this->__('Web Services Alias'),
162
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the alias to use when connecting to SecureTrading through our WebServices. Usually this is the same as your site reference.'),
163
+ ),
164
+ self::FIELD_API_WS_USERNAME => array(
165
+ self::FIELD_TYPE_NAME => $this->__('Web Services Username'),
166
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the username used for server authentication when connecting to the SecureTrading API using our Web Services.'),
167
+ ),
168
+ self::FIELD_API_WS_PASSWORD => array(
169
+ self::FIELD_TYPE_NAME => $this->__('Web Services Password'),
170
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the password used for server authentication when connecting to the SecureTrading API using our Web Services'),
171
+ ),
172
+ self::FIELD_API_WS_VERIFY_SSL_CA => array(
173
+ self::FIELD_TYPE_NAME => $this->__('Verify SSL CA (Web Services)'),
174
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Enable this option to verify that the CA signing the SecureTrading Web Services SSL certificate is one you trust. This should always be used in a production environment and should only be disabled for testing purposes when using a test site reference.'),
175
+ ),
176
+ self::FIELD_API_WS_CA_FILE => array(
177
+ self::FIELD_TYPE_NAME => $this->__('SSL CA FILE (Web Services)'),
178
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The full filepath containing trusted CAs. The file should be in .PEM/.CRT format. This is required when verifying SSL CAs with our Web Services connection method.'),
179
+ ),
180
+ );
181
+ }
182
+
183
+ public function getLabel($field) {
184
+ return $this->_getFieldValue($field, self::FIELD_TYPE_NAME);
185
+ }
186
+
187
+ public function getDescription($field) {
188
+ return $this->_getFieldValue($field, self::FIELD_TYPE_DESCRIPTION);
189
+ }
190
+
191
+ protected function _getFieldValue($field, $type) {
192
+ if (!array_key_exists($field, $this->_array)) {
193
+ return false;
194
+ }
195
+ if (!array_key_exists($type, $this->_array[$field])) {
196
+ return false;
197
+ }
198
+ return $this->_array[$field][$type];
199
+ }
200
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/AdminInterface.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Fields_AdminInterface {
4
+ function getLabel($field);
5
+ function getDescription($field);
6
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Facade.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Fields_Facade extends Stpp_Facade {
4
+ public function newAdminFields() {
5
+ return new Stpp_Fields_Admin();
6
+ }
7
+
8
+ public function newFrontendFields() {
9
+ return new Stpp_Fields_Frontend();
10
+ }
11
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Frontend.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Fields_Frontend extends Stpp_Component_Abstract implements Stpp_Fields_FrontendInterface {
4
+ const FIELD_PAYMENT_TYPE = 'f_paymenttype';
5
+ const FIELD_PAN = 'f_pan';
6
+ const FIELD_EXPIRY_DATE = 'f_expirydate';
7
+ const FIELD_EXPIRY_MONTH = 'f_expirymonth';
8
+ const FIELD_EXPIRY_YEAR = 'f_expiryyear';
9
+ const FIELD_START_DATE = 'f_startdate';
10
+ const FIELD_START_MONTH = 'f_startmonth';
11
+ const FIELD_START_YEAR = 'f_startyear';
12
+ const FIELD_SECURITY_CODE = 'f_securitycode';
13
+ const FIELD_ISSUE_NUMBER = 'f_issuenumber';
14
+ const FIELD_USE_SAVED_CARD_0 = 'f_usesavedcard0';
15
+ const FIELD_USE_SAVED_CARD_1 = 'f_usesavedcard1';
16
+ const FIELD_SAVE_CARD_0 = 'f_savecard0';
17
+ const FIELD_SAVE_CARD_1 = 'f_savecard1';
18
+
19
+ const FIELD_TYPE_LABEL = 'label';
20
+ const FIELD_TYPE_DESCRIPTION = 'desc';
21
+
22
+ protected $_array = array();
23
+
24
+ public function __construct() {
25
+ parent::__construct();
26
+ $this->_array = array(
27
+ self::FIELD_PAYMENT_TYPE => array(
28
+ self::FIELD_TYPE_LABEL => $this->__('Card Type'),
29
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the bank that issued you with your credit/debit card. The issuer logo/details are shown on your card.'),
30
+ ),
31
+ self::FIELD_PAN => array(
32
+ self::FIELD_TYPE_LABEL => $this->__('Card Number'),
33
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This is the long 15 or 16 digit number on the front of your card.'),
34
+ ),
35
+ self::FIELD_START_DATE => array(
36
+ self::FIELD_TYPE_LABEL => $this->__('Start Date'),
37
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The month and year that your card was issued. This can be found on the front of your card.'),
38
+ ),
39
+ self::FIELD_START_MONTH => array(
40
+ self::FIELD_TYPE_LABEL => $this->__('Start Month'),
41
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The month that your card was issued. This can be found on the front of your card.'),
42
+ ),
43
+ self::FIELD_START_YEAR => array(
44
+ self::FIELD_TYPE_LABEL => $this->__('Start Year'),
45
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The year that your card was issued. This can be found on the front of your card.'),
46
+ ),
47
+ self::FIELD_EXPIRY_DATE => array(
48
+ self::FIELD_TYPE_LABEL => $this->__('Expiry Date'),
49
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The month and year that your card expires. This can be found on the front of your card.'),
50
+ ),
51
+ self::FIELD_EXPIRY_MONTH => array(
52
+ self::FIELD_TYPE_LABEL => $this->__('Expiry Month'),
53
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The month that your card expires. This can be found on the front of your card.'),
54
+ ),
55
+ self::FIELD_EXPIRY_YEAR => array(
56
+ self::FIELD_TYPE_LABEL => $this->__('Expiry Year'),
57
+ self::FIELD_TYPE_DESCRIPTION => $this->__('The year that your card expires. This can be found on the front of your card.'),
58
+ ),
59
+ self::FIELD_SECURITY_CODE => array(
60
+ self::FIELD_TYPE_LABEL => $this->__('Security Code'),
61
+ self::FIELD_TYPE_DESCRIPTION => $this->__('This can be found on the back of your card. It is a 3 or 4 digit number.'),
62
+ ),
63
+ self::FIELD_ISSUE_NUMBER => array(
64
+ self::FIELD_TYPE_LABEL => $this->__('Issue Number'),
65
+ self::FIELD_TYPE_DESCRIPTION => $this->__('If present, this will be on the front of your card. Not all credit/debit cards have an issue number.'),
66
+ ),
67
+ self::FIELD_USE_SAVED_CARD_0 => array(
68
+ self::FIELD_TYPE_LABEL => $this->__('Pay with a new card.'),
69
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Select this option to enter new credit/debit card details.'),
70
+ ),
71
+ self::FIELD_USE_SAVED_CARD_1 => array(
72
+ self::FIELD_TYPE_LABEL => $this->__('Pay with a saved card.'),
73
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Select this option to choose from one of your saved credit/debit cards.'),
74
+ ),
75
+ self::FIELD_SAVE_CARD_0 => array(
76
+ self::FIELD_TYPE_LABEL => $this->__('Do not save my card details.'),
77
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Select this option to not save your card details with us. By selecting this option you will not be able to take advantage of our easier and faster checkout process when placing future orders.'),
78
+ ),
79
+ self::FIELD_SAVE_CARD_1 => array(
80
+ self::FIELD_TYPE_LABEL => $this->__('Save my card details securely.'),
81
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Select this option to securely save your card details with us. This allows you to make future purchases quickly and easily.'),
82
+ ),
83
+ );
84
+ }
85
+
86
+ public function getLabel($field) {
87
+ return $this->_getFieldValue($field, self::FIELD_TYPE_LABEL);
88
+ }
89
+
90
+ public function getDescription($field) {
91
+ return $this->_getFieldValue($key, self::FIELD_TYPE_DESCRIPTION);
92
+ }
93
+
94
+ protected function _getFieldValue($field, $type) {
95
+ if (!array_key_exists($field, $this->_array)) {
96
+ return false;
97
+ }
98
+ if (!array_key_exists($type, $this->_array[$field])) {
99
+ return false;
100
+ }
101
+ return $this->_array[$field][$type];
102
+ }
103
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/FrontendInterface.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Fields_FrontendInterface {
4
+ function getLabel($field);
5
+ function getDescription($field);
6
+
7
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Helper.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Helper extends Stpp_Component_Abstract implements Stpp_HelperInterface {
4
+ public function getFilteredCardTypes($use3dSecure, $enabledCardTypes = array()) {
5
+ $allCardTypes = Stpp_Types::getCardTypes();
6
+ $filteredCardTypes = array();
7
+
8
+ foreach($enabledCardTypes as $cardKey) {
9
+ if (!array_key_exists($cardKey, $allCardTypes)) {
10
+ continue;
11
+ }
12
+ if ($cardKey === Stpp_Types::CARD_MAESTRO && !$use3dSecure) {
13
+ continue;
14
+ }
15
+ $filteredCardTypes[$cardKey] = $allCardTypes[$cardKey];
16
+ }
17
+
18
+ if (empty($filteredCardTypes)) {
19
+ throw new Stpp_Exception($this->__('No payment types are available for selection.'));
20
+ }
21
+ return $filteredCardTypes;
22
+ }
23
+
24
+ public function getCcLast4($cardNumber) {
25
+ if (strlen($cardNumber) <= 4) {
26
+ return $cardNumber;
27
+ }
28
+ return substr($cardNumber, strlen($cardNumber)-4, 4);
29
+ }
30
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/HelperInterface.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_HelperInterface{
4
+ function getFilteredCardTypes($use3dSecure, $enabledCardTypes = array());
5
+ function getCcLast4($cardNumber);
6
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/ActionsInterface.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_PaymentPages_ActionsInterface extends Stpp_Actions_BaseInterface {
4
+ function prepareResponse(Stpp_Data_Response $response);
5
+ function checkIsNotificationProcessed($notificationReference);
6
+ function validateNotification(Stpp_Data_Response $response);
7
+ function saveNotificationReference($notificationReference);
8
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/Base.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_PaymentPages_Base extends Stpp_Component_Abstract implements Stpp_PaymentPages_BaseInterface {
4
+ const INTERFACE_NAME = 'SecureTrading Payment Pages';
5
+
6
+ const PPAGES_CHOICE_URL = 'https://payments.securetrading.net/process/payments/choice';
7
+
8
+ const PPAGES_DETAILS_URL = 'https://payments.securetrading.net/process/payments/details';
9
+
10
+ const PPAGES_MOTO_CHOICE_URL = 'https://payments.securetrading.net/login/payments/choice';
11
+
12
+ const PPAGES_MOTO_DETAILS_URL = 'https://payments.securetrading.net/login/payments/details';
13
+
14
+ const PPAGES_VERSION = 1;
15
+
16
+ protected $_actionInstance;
17
+
18
+ protected $_request;
19
+
20
+ protected $_result;
21
+
22
+ protected $_context;
23
+
24
+ protected $_usePost = true;
25
+
26
+ protected $_useSiteSecurity = true;
27
+
28
+ protected $_siteSecurityPassword = '';
29
+
30
+ protected $_siteSecurityHashAlgorithm = 'sha256';
31
+
32
+ protected $_siteSecurityHashFields = array(
33
+ 'currencyiso3a',
34
+ 'mainamount',
35
+ 'sitereference',
36
+ 'settlestatus',
37
+ 'settleduedate',
38
+ 'orderreference',
39
+ 'accounttypedescription',
40
+ );
41
+
42
+ protected $_useNotificationHash = true;
43
+
44
+ protected $_notificationPassword = '';
45
+
46
+ protected $_notificationHashAlgorithm = 'sha256';
47
+
48
+ protected $_bypassChoicePage = false;
49
+
50
+ protected $_useAuthenticatedMoto = true;
51
+
52
+ public static function getName() {
53
+ return static::INTERFACE_NAME;
54
+ }
55
+
56
+ public function setActionInstance(Stpp_PaymentPages_ActionsInterface $actions) {
57
+ $this->_actionInstance = $actions;
58
+ return $this;
59
+ }
60
+
61
+ protected function _getActionInstance() {
62
+ if ($this->_actionInstance === null) {
63
+ throw new Stpp_Exception($this->__('The action instance was null.'));
64
+ }
65
+ return $this->_actionInstance;
66
+ }
67
+
68
+ public function setResult(Stpp_PaymentPages_ResultInterface $result) {
69
+ $this->_result = $result;
70
+ }
71
+
72
+ protected function _getResult() {
73
+ if ($this->_result === null) {
74
+ throw new Stpp_Exception($this->__('The result object is null.'));
75
+ }
76
+ return $this->_result;
77
+ }
78
+
79
+ public function setUseHttpPost($bool) {
80
+ $this->_usePost = (bool) $bool;
81
+ }
82
+
83
+ public function setUseSiteSecurityHash($bool) {
84
+ $this->_useSiteSecurity = (bool) $bool;
85
+ }
86
+
87
+ public function setSiteSecurityHashAlgorithm($siteSecurityHashAlgorithm) {
88
+ $this->_siteSecurityHashAlgorithm = $siteSecurityHashAlgorithm;
89
+ return $this;
90
+ }
91
+
92
+ public function setSiteSecurityPassword($password) {
93
+ $this->_siteSecurityPassword = $password;
94
+ }
95
+
96
+ public function setSiteSecurityFields($fields) {
97
+ $this->_siteSecurityHashFields = array_unique(
98
+ array_merge(
99
+ $this->_siteSecurityHashFields,
100
+ $fields
101
+ )
102
+ );
103
+ return $this;
104
+ }
105
+
106
+ public function setUseNotificationHash($bool) {
107
+ $this->_useNotificationHash = (bool) $bool;
108
+ }
109
+
110
+ public function setNotificationHashAlgorithm($notificationAlgorithm) {
111
+ $this->_notificationHashAlgorithm = $notificationAlgorithm;
112
+ return $this;
113
+ }
114
+
115
+ public function setNotificationHashPassword($password) {
116
+ $this->_notificationPassword = $password;
117
+ }
118
+
119
+ public function setBypassChoicePage($bool) {
120
+ $this->_bypassChoicePage = (bool) $bool;
121
+ }
122
+
123
+ public function setUseAuthenticatedMoto($bool) {
124
+ $this->_useAuthenticatedMoto = (bool) $bool;
125
+ }
126
+
127
+ public function run(Stpp_Data_Request $request) {
128
+ $this->_request = $request;
129
+
130
+ if ($this->_useSiteSecurity) {
131
+ $this->_request->set("sitesecurity", $this->_createSiteSecurityHash());
132
+ }
133
+ $this->_request->set("version", self::PPAGES_VERSION);
134
+
135
+ $data = $this->_request->toArray();
136
+ $redirectUrl = $this->_usePost ? $this->_getHttpPostUrl($data) : $this->_getHttpGetUrl($data);
137
+
138
+ $result = $this->_getResult()
139
+ ->setRedirectIsPost($this->_usePost)
140
+ ->setRedirectUrl($redirectUrl)
141
+ ->setRedirectData($data)
142
+ ->setRequest($this->_request)
143
+ ;
144
+ return $result;
145
+ }
146
+
147
+ protected function _createSiteSecurityHash() {
148
+ $valuesToHash = array();
149
+
150
+ foreach($this->_siteSecurityHashFields as $field) {
151
+ $valuesToHash[] = $this->_request->get($field);
152
+ }
153
+ $valuesToHash[] = $this->_siteSecurityPassword;
154
+ return 'g' . hash($this->_siteSecurityHashAlgorithm, implode('', $valuesToHash));
155
+ }
156
+
157
+ protected function _getHttpPostUrl() {
158
+ return $this->_getPaymentPagesUrl();
159
+ }
160
+
161
+ protected function _getHttpGetUrl() {
162
+ $urlArray = array();
163
+
164
+ foreach($this->_gatewayData as $k => $v) {
165
+ $urlArray[] = urlencode($k) . '=' . urlencode($v);
166
+ }
167
+ return $this->_getPaymentPagesUrl() . '?' . implode('&', $urlArray);
168
+ }
169
+
170
+ protected function _getPaymentPagesUrl() {
171
+ if (($this->_request->get('accounttypedescription') === Stpp_Types::ACCOUNT_MOTO) && $this->_useAuthenticatedMoto) {
172
+ if ($this->_bypassChoicePage) {
173
+ return self::PPAGES_MOTO_DETAILS_URL;
174
+ }
175
+ else {
176
+ return self::PPAGES_MOTO_CHOICE_URL;
177
+ }
178
+ }
179
+ else {
180
+ if ($this->_bypassChoicePage) {
181
+ return self::PPAGES_DETAILS_URL;
182
+ }
183
+ else {
184
+ return self::PPAGES_CHOICE_URL;
185
+ }
186
+ }
187
+ }
188
+
189
+ public function runNotification() {
190
+ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
191
+ throw new Stpp_Exception(sprintf($this->__('%s has been called with the request method "%s".'), __CLASS__ . '::' . __METHOD__, $_SERVER['REQUEST_METHOD']));
192
+ }
193
+
194
+ if (!isset($_POST['notificationreference'])) {
195
+ throw new Stpp_Exception($this->__('The notificationreference was not posted to the notification.'));
196
+ }
197
+
198
+ if (!is_string($_POST['notificationreference'])) {
199
+ throw new Stpp_Exception($this->__('The notificationreference was not a string.'));
200
+ }
201
+
202
+ if ($this->_getActionInstance()->checkIsNotificationProcessed($_POST['notificationreference'])) {
203
+ throw new Stpp_Exception(sprintf($this->__('The notification with notificationereference "%s" has already been processed.'), $_POST['notificationreference']));
204
+ }
205
+
206
+ if (!isset($_POST['requesttypedescription'])) {
207
+ throw new Stpp_Exception($this->__('The requesttypedescription has not been posted to the notification.'));
208
+ }
209
+
210
+ $response = $this->_mapResponse();
211
+
212
+ $this->_getActionInstance()->validateNotification($response);
213
+
214
+ if ($this->_useNotificationHash) {
215
+ if (!isset($_POST['responsesitesecurity'])) {
216
+ throw new Stpp_Exception($this->__("The notification hash is enabled but the 'responsesitesecurity' field was not posted to the notification script."));
217
+ }
218
+
219
+ if (!is_string($_POST['responsesitesecurity'])) {
220
+ throw new Stpp_Exception($this->__("The posted responsesitesecurity field was not a string."));
221
+ }
222
+
223
+ $notificationHash = $this->_createNotificationHash();
224
+
225
+ if($_POST['responsesitesecurity'] !== $notificationHash) {
226
+ throw new Stpp_Exception(sprintf($this->__("The notification hashes did not match: %s !== %s."), $_POST['responsesitesecurity'], $notificationHash));
227
+ }
228
+ }
229
+
230
+ switch($_POST['requesttypedescription']) {
231
+ case Stpp_Types::API_AUTH:
232
+ $this->_getActionInstance()->processAuth($response);
233
+ break;
234
+ case Stpp_Types::API_THREEDQUERY:
235
+ $this->_getActionInstance()->process3dQuery($response);
236
+ break;
237
+ case Stpp_Types::API_RISKDEC:
238
+ $this->_getActionInstance()->processRiskDecision($response);
239
+ break;
240
+ case Stpp_Types::API_REFUND:
241
+ $this->_getActionInstance()->processRefund($response);
242
+ break;
243
+ case Stpp_Types::API_ACCOUNTCHECK:
244
+ $this->_getActionInstance()->processAccountCheck($response);
245
+ break;
246
+ case Stpp_Types::API_TRANSACTIONUPDATE:
247
+ $this->_getActionInstance()->processTransactionUpdate($response);
248
+ break;
249
+ default:
250
+ throw new Stpp_Exception(sprintf($this->__('An unhandled responsetype has been provided: "%s".'), $_POST['requesttypedescription']));
251
+ }
252
+
253
+ $this->_getActionInstance()->saveNotificationReference($_POST['notificationreference']);
254
+ return $this;
255
+ }
256
+
257
+ protected function _createNotificationHash() {
258
+ $fields = $_POST;
259
+ unset($fields['responsesitesecurity'], $fields['notificationreference']);
260
+ ksort($fields);
261
+ array_push($fields, $this->_notificationPassword);
262
+ return hash($this->_notificationHashAlgorithm, implode('', $fields));
263
+ }
264
+
265
+ protected function _mapResponse() {
266
+ $response = new Stpp_Data_Response();
267
+
268
+ foreach($_POST as $k => $v) {
269
+ $response->set($k, $v);
270
+ }
271
+
272
+ $this->_getActionInstance()->prepareResponse($response);
273
+ return $response;
274
+ }
275
+
276
+ public function validateRedirect() {
277
+ if ($_SERVER['REQUEST_METHOD'] !== "GET") {
278
+ throw new Stpp_Exception(sprintf($this->__("The redirect has been run for request method '%s'.")));
279
+ }
280
+
281
+ if ($this->_useSiteSecurity) {
282
+ if (!isset($_GET['responsesitesecurity'])) {
283
+ throw new Stpp_Exception($this->__("The responsesitesecurity was not sent to the redirect."));
284
+ }
285
+
286
+ if (!is_string($_GET['responsesitesecurity'])) {
287
+ throw new Stpp_Exception($this->__("The responsesitesecurity sent to the redirect was not a string."));
288
+ }
289
+
290
+ $redirectHash = $this->_createRedirectHash();
291
+
292
+ if ($_GET['responsesitesecurity'] !== $redirectHash) {
293
+ throw new Stpp_Exception(sprintf($this->__("The redirect hashes did not match: %s and %s."), $_GET['responsesitesecurity'], $redirectHash));
294
+ }
295
+ }
296
+ return $this;
297
+ }
298
+
299
+ protected function _createRedirectHash() {
300
+ $fields = $_GET;
301
+ unset($fields['responsesitesecurity']);
302
+ ksort($fields);
303
+ array_push($fields, $this->_siteSecurityPassword);
304
+ return hash($this->_siteSecurityHashAlgorithm, implode('', $fields));
305
+ }
306
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/BaseInterface.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_PaymentPages_BaseInterface {
4
+ static function getName();
5
+ function run(Stpp_Data_Request $request);
6
+ function runNotification();
7
+ function validateRedirect();
8
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/Facade.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_PaymentPages_Facade extends Stpp_Facade {
4
+ public function newPaymentPages() {
5
+ $ppages = new Stpp_PaymentPages_Base();
6
+
7
+ if ($this->_config->has('interfaces/ppages/action_instance')) {
8
+ $ppages->setActionInstance($this->_config->get('interfaces/ppages/action_instance'));
9
+ }
10
+
11
+ if ($this->_config->has('interfaces/ppages/use_http_post')) {
12
+ $ppages->setUseHttpPost($this->_config->get('interfaces/ppages/use_http_post'));
13
+ }
14
+
15
+ if ($this->_config->has('interfaces/ppages/sitesecurity/use')) {
16
+ $ppages->setUseSiteSecurityHash($this->_config->get('interfaces/ppages/sitesecurity/use'));
17
+ }
18
+
19
+ if ($this->_config->has('interfaces/ppages/sitesecurity/algorithm')) {
20
+ $ppages->setSiteSecurityHashAlgorithm($this->_config->get('interfaces/ppages/sitesecurity/algorithm'));
21
+ }
22
+
23
+ if ($this->_config->has('interfaces/ppages/sitesecurity/password')) {
24
+ $ppages->setSiteSecurityPassword($this->_config->get('interfaces/ppages/sitesecurity/password'));
25
+ }
26
+
27
+ if ($this->_config->has('interfaces/ppages/sitesecurity/fields')) {
28
+ $ppages->setSiteSecurityFields($this->_config->get('interfaces/ppages/sitesecurity/fields'));
29
+ }
30
+
31
+ if ($this->_config->has('interfaces/ppages/notificationhash/use')) {
32
+ $ppages->setUseNotificationHash($this->_config->get('interfaces/ppages/notificationhash/use'));
33
+ }
34
+
35
+ if ($this->_config->has('interfaces/ppages/notificationhash/algorithm')) {
36
+ $ppages->setNotificationHashAlgorithm($this->_config->get('interfaces/ppages/notificationhash/algorithm'));
37
+ }
38
+
39
+ if ($this->_config->has('interfaces/ppages/notificationhash/password')) {
40
+ $ppages->setNotificationHashPassword($this->_config->get('interfaces/ppages/notificationhash/password'));
41
+ }
42
+
43
+ if ($this->_config->has('interfaces/ppages/use_authenticated_moto')) {
44
+ $ppages->setUseAuthenticatedMoto($this->_config->get('interfaces/ppages/use_authenticated_moto'));
45
+ }
46
+
47
+ $ppages->setResult($this->newPaymentPagesResult());
48
+ return $ppages;
49
+ }
50
+
51
+ public function newPaymentPagesHelper() {
52
+ $helper = new Stpp_PaymentPages_Helper();
53
+ return $helper;
54
+ }
55
+
56
+ public function newPaymentPagesResult() {
57
+ return new Stpp_PaymentPages_Result();
58
+ }
59
+
60
+ public function runPaymentPagesStandard(Stpp_Data_Request $request, $adminAction = false) {
61
+ $request = $this->newPaymentPagesHelper()->setAdminAction($adminAction)->prepareStandard($request);
62
+ $result = $this->newPaymentPages()->run($request);
63
+ return $result;
64
+ }
65
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/Helper.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_PaymentPages_Helper extends Stpp_Component_Abstract implements Stpp_PaymentPages_HelperInterface {
4
+ protected $_adminAction;
5
+
6
+ protected $_use3dSecure;
7
+
8
+ protected $_useRiskDecision;
9
+
10
+ protected $_useAccountCheck;
11
+
12
+ public function setAdminAction($bool) {
13
+ $this->_adminAction = $bool;
14
+ return $this;
15
+ }
16
+
17
+ public function prepareStandard(Stpp_Data_Request $request) {
18
+ $accountTypeDescription = $this->_adminAction ? Stpp_Types::ACCOUNT_MOTO : Stpp_Types::ACCOUNT_ECOM;
19
+ $request->set('accounttypedescription', $accountTypeDescription);
20
+ return $request;
21
+ }
22
+
23
+ public function prepareExtended(Stpp_Data_Request $request) {
24
+ $requestTypeDescriptions = array(Stpp_Types::API_AUTH);
25
+
26
+ if ($this->_use3dSecure && !$this->_adminAction) {
27
+ $requestTypeDescriptions[] = Stpp_Types::API_THREEDQUERY;
28
+ }
29
+
30
+ if ($this->_useRiskDecision) {
31
+ $requestTypeDescriptions[] = Stpp_Types::API_RISKDEC;
32
+ }
33
+
34
+ if ($this->_useAccountCheck) {
35
+ $requestTypeDescriptions[] = Stpp_Types::API_ACCOUNTCHECK;
36
+ }
37
+
38
+ $accountTypeDescription = $this->_adminAction ? Stpp_Types::ACCOUNT_MOTO : Stpp_Types::ACCOUNT_ECOM;
39
+
40
+ $request->set('accounttypedescription', $accountTypeDescription);
41
+ $request->set('requesttypedescriptions', $requestTypeDescriptions);
42
+
43
+ return $request;
44
+ }
45
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/HelperInterface.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_PaymentPages_HelperInterface {
4
+ function setAdminAction($bool);
5
+ function prepareStandard(Stpp_Data_Request $request);
6
+ function prepareExtended(Stpp_Data_Request $request);
7
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/Result.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_PaymentPages_Result extends Stpp_Result_Abstract implements Stpp_PaymentPages_ResultInterface {
4
+ protected $_request;
5
+
6
+ public function getRequest() {
7
+ if ($this->_request === null) {
8
+ throw new Stpp_Exception('The request has not been set.');
9
+ }
10
+ return $this->_request;
11
+ }
12
+
13
+ public function setRequest(Stpp_Data_Request $request) {
14
+ $this->_request = $request;
15
+ return $this;
16
+ }
17
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/PaymentPages/ResultInterface.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_PaymentPages_ResultInterface extends Stpp_Result_AbstractInterface {
4
+ function getRequest();
5
+ function setRequest(Stpp_Data_Request $request);
6
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Result/Abstract.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Result_Abstract extends Stpp_Component_Abstract implements Stpp_Result_AbstractInterface {
4
+ protected $_isRedirectPost = true;
5
+
6
+ protected $_redirectUrl = '';
7
+
8
+ protected $_redirectData = array();
9
+
10
+ public function getRedirectIsPost() {
11
+ return $this->_isRedirectPost;
12
+ }
13
+
14
+ public function setRedirectIsPost($bool) {
15
+ $this->_isRedirectPost = (bool) $bool;
16
+ return $this;
17
+ }
18
+
19
+ public function getRedirectUrl() {
20
+ return $this->_redirectUrl;
21
+ }
22
+
23
+ public function setRedirectUrl($url) {
24
+ $this->_redirectUrl = $url;
25
+ return $this;
26
+ }
27
+
28
+ public function getRedirectData() {
29
+ return $this->_redirectData;
30
+ }
31
+
32
+ public function setRedirectData(array $data) {
33
+ $this->_redirectData = $data;
34
+ return $this;
35
+ }
36
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Result/AbstractInterface.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Result_AbstractInterface {
4
+ function getRedirectIsPost();
5
+ function setRedirectIsPost($bool);
6
+ function getRedirectUrl();
7
+ function setRedirectUrl($url);
8
+ function getRedirectData();
9
+ function setRedirectData(array $data);
10
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Types.php ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Types implements Stpp_TypesInterface {
4
+ // DOCUMENT: These match the req/response names used in the STPP gateway.
5
+ const API_ERROR = 'ERROR';
6
+ const API_AUTH = 'AUTH';
7
+ const API_THREEDQUERY = 'THREEDQUERY';
8
+ const API_RISKDEC = 'RISKDEC';
9
+ const API_TRANSACTIONUPDATE = 'TRANSACTIONUPDATE';
10
+ const API_REFUND = 'REFUND';
11
+ const API_CARDSTORE = 'STORE';
12
+ const API_ACCOUNTCHECK = 'ACCOUNTCHECK';
13
+
14
+ const ACCOUNT_ECOM = 'ECOM';
15
+ const ACCOUNT_MOTO = 'MOTO';
16
+ const ACCOUNT_FRAUDCONTROL = 'FRAUDCONTROL';
17
+ const ACCOUNT_CARDSTORE = 'CARDSTORE';
18
+
19
+ const CARD_AMEX = 'AMEX';
20
+ const CARD_ASTROPAYCARD = 'ASTROPAYCARD';
21
+ const CARD_COAST = 'COAST';
22
+ const CARD_DELTA = 'DELTA';
23
+ const CARD_DINERS = 'DINERS';
24
+ const CARD_DISCOVER = 'DISCOVER';
25
+ const CARD_ELECTRON = 'ELECTRON';
26
+ const CARD_JCB = 'JCB';
27
+ const CARD_KARENMILLER = 'KARENMILLER';
28
+ const CARD_LASER = 'LASER';
29
+ const CARD_MAESTRO = 'MAESTRO';
30
+ const CARD_MASTERCARD = 'MASTERCARD';
31
+ const CARD_MASTERCARDDEBIT = 'MASTERCARDDEBIT';
32
+ const CARD_OASIS = 'OASIS';
33
+ const CARD_PIBA = 'PIBA';
34
+ const CARD_PRINCIPLE = 'PRINCIPLE';
35
+ const CARD_PURCHASING = 'PURCHASING';
36
+ const CARD_SHOESTUDIO = 'SHOESTUDIO';
37
+ const CARD_SOLO = 'SOLO';
38
+ const CARD_SWITCH = 'SWITCH';
39
+ const CARD_VISA = 'VISA';
40
+ const CARD_VPAY = 'VPAY';
41
+ const CARD_WAREHOUSE = 'WAREHOUSE';
42
+
43
+ public static function getRequestAndResponseTypes() {
44
+ return array(
45
+ self::API_ERROR,
46
+ self::API_AUTH,
47
+ self::API_THREEDQUERY,
48
+ self::API_RISKDEC,
49
+ self::API_TRANSACTIONUPDATE,
50
+ self::API_REFUND,
51
+ self::API_CARDSTORE,
52
+ );
53
+ }
54
+
55
+ public static function getAccountTypeDescriptions() {
56
+ return array(
57
+ self::ACCOUNT_ECOM,
58
+ self::ACCOUNT_MOTO,
59
+ self::ACCOUNT_FRAUDCONTROL,
60
+ self::ACCOUNT_CARDSTORE,
61
+ );
62
+ }
63
+
64
+ public static function getCardTypes() {
65
+ return array(
66
+ self::CARD_AMEX => 'American Express',
67
+ self::CARD_ASTROPAYCARD => 'Astropay',
68
+ self::CARD_COAST => 'Coast',
69
+ self::CARD_DELTA => 'Delta',
70
+ self::CARD_DINERS => 'Diners',
71
+ self::CARD_DISCOVER => 'Discover',
72
+ self::CARD_ELECTRON => 'Electron',
73
+ self::CARD_JCB => 'JCB',
74
+ self::CARD_KARENMILLER => 'Karen Miller',
75
+ self::CARD_LASER => 'Laser',
76
+ self::CARD_MAESTRO => 'Maestro',
77
+ self::CARD_MASTERCARD => 'Mastercard',
78
+ self::CARD_MASTERCARDDEBIT => 'Mastercard Debit',
79
+ self::CARD_OASIS => 'Oasis',
80
+ self::CARD_PIBA => 'PIBA',
81
+ self::CARD_PRINCIPLE => 'Principle',
82
+ self::CARD_PURCHASING => 'Purchasing',
83
+ self::CARD_SHOESTUDIO => 'Shoe Studio',
84
+ self::CARD_SOLO => 'Solo',
85
+ self::CARD_SWITCH => 'Switch',
86
+ self::CARD_VISA => 'Visa',
87
+ self::CARD_VPAY => 'VPay',
88
+ self::CARD_WAREHOUSE => 'Warehouse',
89
+ );
90
+ }
91
+
92
+ public static function getTelTypes() {
93
+ return array(
94
+ 'H',
95
+ 'M',
96
+ 'W',
97
+ );
98
+ }
99
+
100
+ public static function getCustomerShippingMethods() {
101
+ return array(
102
+ 'C' => 'Low Cost',
103
+ 'D' => 'Designated by Customer',
104
+ 'I' => 'International',
105
+ 'M' => 'Military',
106
+ 'N' => 'Next Day/Overnight',
107
+ 'O' => 'Other',
108
+ 'P' => 'Store Pickup',
109
+ 'T' => '2 day Service',
110
+ 'W' => '3 day Service',
111
+ );
112
+ }
113
+
114
+ public static function getSettleStatuses() {
115
+ return array(
116
+ '0' => '0 - Pending Settlement',
117
+ '1' => '1 - Pending Settlement (Manually Overridden)',
118
+ '2' => '2 - Suspended',
119
+ '3' => '3 - Cancelled',
120
+ '100' => '100 - Settled (Only available for certain aquirers)'
121
+ );
122
+ }
123
+
124
+ public static function getSettleDueDates() {
125
+ return array(
126
+ 0 => 'Process immediately',
127
+ 1 => 'Wait 1 day',
128
+ 2 => 'Wait 2 days',
129
+ 3 => 'Wait 3 days',
130
+ 4 => 'Wait 4 days',
131
+ 5 => 'Wait 5 days',
132
+ 6 => 'Wait 6 days',
133
+ 7 => 'Wait 7 days',
134
+ );
135
+ }
136
+
137
+ public static function getMonths() {
138
+ return array(
139
+ array(
140
+ 'numeric' => '01',
141
+ 'short' => 'Jan',
142
+ 'long' => 'January',
143
+ ),
144
+ array(
145
+ 'numeric' => '02',
146
+ 'short' => 'Feb',
147
+ 'long' => 'February',
148
+ ),
149
+ array(
150
+ 'numeric' => '03',
151
+ 'short' => 'Mar',
152
+ 'long' => 'March',
153
+ ),
154
+ array(
155
+ 'numeric' => '04',
156
+ 'short' => 'Apr',
157
+ 'long' => 'April',
158
+ ),
159
+ array(
160
+ 'numeric' => '05',
161
+ 'short' => 'May',
162
+ 'long' => 'May',
163
+ ),
164
+ array(
165
+ 'numeric' => '06',
166
+ 'short' => 'Jun',
167
+ 'long' => 'June',
168
+ ),
169
+ array(
170
+ 'numeric' => '07',
171
+ 'short' => 'Jul',
172
+ 'long' => 'July',
173
+ ),
174
+ array(
175
+ 'numeric' => '08',
176
+ 'short' => 'Aug',
177
+ 'long' => 'August',
178
+ ),
179
+ array(
180
+ 'numeric' => '09',
181
+ 'short' => 'Sep',
182
+ 'long' => 'September',
183
+ ),
184
+ array(
185
+ 'numeric' => '10',
186
+ 'short' => 'Oct',
187
+ 'long' => 'October',
188
+ ),
189
+ array(
190
+ 'numeric' => '11',
191
+ 'short' => 'Nov',
192
+ 'long' => 'November',
193
+ ),
194
+ array(
195
+ 'numeric' => '12',
196
+ 'short' => 'Dec',
197
+ 'long' => 'December',
198
+ ),
199
+ );
200
+ }
201
+
202
+ public static function getStartYears() {
203
+ $startYears = array();
204
+
205
+ for ($i = 20; $i > 0; $i--) {
206
+ $year = date('Y', time() - ($i * (60 * 60 * 24 * 365)));
207
+ $startYears[$i] = $year;
208
+ }
209
+ return $startYears;
210
+ }
211
+
212
+ public static function getExpiryYears() {
213
+ $expiryYears = array();
214
+
215
+ for ($i = 0; $i <= 20; $i++) {
216
+ $year = date('Y', time() + ($i * (60 * 60 * 24 * 365)));
217
+ $expiryYears[$i] = $year;
218
+ }
219
+ return $expiryYears;
220
+ }
221
+
222
+ public static function getAvsCodes() {
223
+ return array(
224
+ '0' => 'Not Given',
225
+ '1' => 'Not Checked',
226
+ '2' => 'Matched',
227
+ '4' => 'Not Matched',
228
+ );
229
+ }
230
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/TypesInterface.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_TypesInterface {
4
+ static function getRequestAndResponseTypes();
5
+ static function getAccountTypeDescriptions();
6
+ static function getCardTypes();
7
+ static function getTelTypes();
8
+ static function getCustomerShippingMethods();
9
+ static function getSettleStatuses();
10
+ static function getSettleDueDates();
11
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Facade.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Utility_Facade extends Stpp_Facade {
4
+ public function __construct(array $config = array()) {
5
+ parent::__construct($config);
6
+
7
+ Stpp_Exception::setExceptionLog($this->newExceptionLog());
8
+
9
+ $translator = $this->newTranslator();
10
+ $debugLog = $this->newDebugLog();
11
+
12
+ Stpp_Component_Store::registerTranslator($translator);
13
+ Stpp_Component_Store::registerDebugLog($debugLog);
14
+ }
15
+
16
+ public function newTranslator() {
17
+ return new Stpp_Utility_Translator_Base(Securetrading::getRootPath(), Stpp::getTranslationsPath());
18
+ }
19
+
20
+ public function newDebugLog() {
21
+ $logWriter = new Stpp_Utility_Log_Writer_File('debug', Stpp::getLogsPath(), Stpp::getLogsArchivePath());
22
+ $debugLog = new Stpp_Utility_Log_Base();
23
+ $debugLog->setLogWriter($logWriter);
24
+ return $debugLog;
25
+ }
26
+
27
+ public function newExceptionLog() {
28
+ $logWriter = new Stpp_Utility_Log_Writer_File('exception', Stpp::getLogsPath(), Stpp::getLogsArchivePath());
29
+ $exceptionLog = new Stpp_Utility_Log_Base();
30
+ $exceptionLog->setLogWriter($logWriter);
31
+ return $exceptionLog;
32
+ }
33
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/Base.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Utility_Log_Base extends Stpp_Utility_Log_User_Abstract implements Stpp_Utility_Log_BaseInterface {
4
+ protected $_logLevel;
5
+
6
+ public function setLogLevel($logLevel) {
7
+ $this->_logLevel = $logLevel;
8
+ return $this;
9
+ }
10
+
11
+ public function getLogLevel() {
12
+ return $this->_logLevel;
13
+ }
14
+
15
+ public function log($message) {
16
+ $this->getLogWriter()->log($message);
17
+ }
18
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/BaseInterface.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Utility_Log_BaseInterface {
4
+ function log($message);
5
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/User/Abstract.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Stpp_Utility_Log_User_Abstract implements Stpp_Utility_Log_UserInterface {
4
+ protected $_logger;
5
+
6
+ public function setLogWriter(Stpp_Utility_Log_WriterInterface $logger) {
7
+ $this->_logger = $logger;
8
+ return $this;
9
+ }
10
+
11
+ public function getLogWriter() {
12
+ if ($this->_logger === null) {
13
+ throw new Stpp_Exception('The log writer has not been set.');
14
+ }
15
+ return $this->_logger;
16
+ }
17
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/UserInterface.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Utility_Log_UserInterface {
4
+ public function setLogWriter(Stpp_Utility_Log_WriterInterface $logger);
5
+ public function getLogWriter();
6
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/Writer/File.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Utility_Log_Writer_File implements Stpp_Utility_Log_WriterInterface {
4
+ protected $_logFilePath;
5
+
6
+ protected $_logFileDirectory;
7
+
8
+ protected $_archiveDirectory;
9
+
10
+ public function __construct($logFileName, $logFileDirectory, $archiveDirectory = null) {
11
+ $this->_logFilePath = $logFileDirectory . $logFileName . '.txt';
12
+ $this->_logFileDirectory = $logFileDirectory;
13
+ $this->_archiveDirectory = ($archiveDirectory ?: $logFileDirectory . 'archive' . DIRECTORY_SEPARATOR);
14
+
15
+ if (!file_exists($this->_logFileDirectory)) {
16
+ mkdir($this->_logFileDirectory);
17
+ }
18
+
19
+ if (!file_exists($this->_logFilePath)) {
20
+ file_put_contents($this->_logFilePath, '');
21
+ }
22
+
23
+ if (!file_exists($this->_archiveDirectory)) {
24
+ mkdir($this->_archiveDirectory);
25
+ }
26
+
27
+ if ($this->_mustMoveToArchive($this->_logFilePath)) {
28
+ $this->_moveToArchive($this->_logFilePath);
29
+ }
30
+ }
31
+
32
+ protected function _mustMoveToArchive($filePath) {
33
+ $mTime = filemtime($filePath);
34
+ $currentMonthAndYear = date('m_Y');
35
+ $logFileMonthAndYear = date('m_Y', $mTime);
36
+ $fileSize = filesize($filePath);
37
+ return ($logFileMonthAndYear !== $currentMonthAndYear) && $fileSize > 0;
38
+ }
39
+
40
+ protected function _moveToArchive($filePath) {
41
+ // Get the filename (the text between the last DIRECTORY_SEPARATOR and the first '.').
42
+ $fileNameWithExtension = array_pop(explode(DIRECTORY_SEPARATOR, $filePath));
43
+ $fileName = substr($fileNameWithExtension, 0, strrpos($fileNameWithExtension, '.'));
44
+
45
+ // Calculate the full filepath to the log file:
46
+ $mTime = filemtime($filePath);
47
+ $logFileMonthAndYear = date('m_Y', $mTime);
48
+ $newFilePath = $this->_archiveDirectory . $fileName . '_' . $logFileMonthAndYear . '.txt';
49
+
50
+ // Ensure we do not overwrite an archive entry that already exists:
51
+ if (file_exists($newFilePath)) {
52
+ throw new Stpp_Exception(sprintf('The file "%s" already exists.', $newFilePath));
53
+ }
54
+
55
+ // Copy the log file to the archive and truncate the main log file:
56
+ copy($filePath, $newFilePath);
57
+ file_put_contents($filePath, '');
58
+ return $this;
59
+ }
60
+
61
+ protected function _formatMessage($message) {
62
+ if (is_array($message) || is_object($message)) {
63
+ $message = print_r($message,1);
64
+ }
65
+ return $this->_getDate() .':' . trim($message) . PHP_EOL;
66
+ }
67
+
68
+ protected function _getDate() {
69
+ return date('d-m-Y H:i:s T');
70
+ }
71
+
72
+ public function log($message) {
73
+ $message = $this->_formatMessage($message);
74
+ $file = fopen($this->_logFilePath, 'a');
75
+ fwrite($file, $message);
76
+ fclose($file);
77
+ return $this;
78
+ }
79
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Log/WriterInterface.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Utility_Log_WriterInterface {
4
+ function log($message);
5
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Translator/Base.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Utility_Translator_Base implements Stpp_Utility_Translator_BaseInterface {
4
+ const METHOD_STPP_CORE = 1;
5
+ const METHOD_USER_FUNC = 2;
6
+
7
+ protected $_fileUtility;
8
+
9
+ protected $_config = array();
10
+
11
+ protected $_translationMethod = self::METHOD_STPP_CORE;
12
+
13
+ protected $_targetLanguage;
14
+
15
+ protected $_translations = array();
16
+
17
+ public function __construct($sourcePhpDirectory, $translationsDirectory) {
18
+ if (!file_exists($translationsDirectory)) {
19
+ mkdir($translationsDirectory);
20
+ }
21
+
22
+ $baseTranslationFile = $translationsDirectory . 'core.php';
23
+
24
+ if (!file_exists($baseTranslationFile)) {
25
+ $directory = new RecursiveDirectoryIterator($sourcePhpDirectory);
26
+ $iterator = new RecursiveIteratorIterator($directory);
27
+ $regex = new RegexIterator($iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
28
+
29
+ foreach($regex as $file) {
30
+ $files[] = $file[0];
31
+ }
32
+
33
+ $matches = null;
34
+ $translatableStrings = array();
35
+
36
+ foreach($files as $file) {
37
+ $fileContents = file_get_contents($file);
38
+ preg_match_all('!\$this->__\((\'|")(.+)(?:\1)\)!', $fileContents, $matches);
39
+ $translatableStrings = array_merge($matches[2], $translatableStrings);
40
+ }
41
+
42
+ $finalTranslatableStrings = array_unique($translatableStrings); // Remove duplicate text strings.
43
+
44
+ $code = "<?php" . PHP_EOL . PHP_EOL . '$translations = array(' . PHP_EOL;
45
+
46
+ foreach($finalTranslatableStrings as $string) {
47
+ $string = str_replace("\'", "'", $string);
48
+ $replacedString = str_replace("'", "\'", $string);
49
+ $code .= sprintf("\t'%s' => '',", $replacedString) . PHP_EOL;
50
+ }
51
+
52
+ $code .= ');';
53
+
54
+ file_put_contents($baseTranslationFile, $code);
55
+ }
56
+ }
57
+
58
+ public function setConfig(array $config = array()) {
59
+ $this->_config = $config;
60
+ }
61
+
62
+ public function setTranslationMethod($method) {
63
+ $this->_translationMethod = $method;
64
+ return $this;
65
+ }
66
+
67
+ public function setTargetLanguage($string) {
68
+ $this->_targetLanguage = $string;
69
+ }
70
+
71
+ public function translate($message) {
72
+ if ($this->_translationMethod === self::METHOD_USER_FUNC) {
73
+ if (!isset($this->_config["method"])) {
74
+ throw new Stpp_Exception("Method name was not set.");
75
+ }
76
+
77
+ if (!is_string($this->_config["method"])) {
78
+ throw new Stpp_Exception("The method name must be a string.");
79
+ }
80
+
81
+ // validate params
82
+ if (!isset($this->_config["params"])) {
83
+ throw new Stpp_Exception("Parameters not set.");
84
+ }
85
+
86
+ if (!is_array($this->_config["params"])) {
87
+ throw new Stpp_Exception("The parameters must be an array.");
88
+ }
89
+
90
+ // validate params message (we put $message var into this param)
91
+ if (!array_key_exists("message", $this->_config["params"])) {
92
+ throw new Stpp_Exception("The message index does not exist in the parameters array.");
93
+ }
94
+
95
+ $this->_config["params"]["message"] = $message;
96
+
97
+ if (isset($this->_config["class"])) {
98
+ if (is_string($this->_config["class"])) {
99
+ if (!class_exists($this->_config["class"])) {
100
+ throw new Stpp_Exception(sprintf('Class name "%s" does not exist.'));
101
+ }
102
+ }
103
+ else {
104
+ if (!is_object($this->_config["class"])) {
105
+ throw new Stpp_Exception('The class is not a string or an object reference.');
106
+ }
107
+ }
108
+ $func = array($this->_config["class"], $this->_config["method"]);
109
+ }
110
+ else {
111
+ $func = $this->_config["method"];
112
+ }
113
+
114
+ return call_user_func_array($func, $this->_config["params"]);
115
+ }
116
+ elseif ($this->_translationMethod === self::METHOD_STPP_CORE) {
117
+ return $this->_translate($message);
118
+ }
119
+ else {
120
+ throw new Stpp_Exception('Invalid translation method specified.');
121
+ }
122
+ }
123
+
124
+ protected function _translate($message) {
125
+ $targetLanguage = $this->_targetLanguage;
126
+
127
+ if (!isset($targetLanguage) || empty($targetLanguage) || !is_string($targetLanguage)) {
128
+ return $message;
129
+ }
130
+
131
+ $frameworkDirectory = realpath(dirname(dirname(__FILE__)));
132
+ $targetLanguageTranslationFile = $frameworkDirectory . DIRECTORY_SEPARATOR . 'translations' . DIRECTORY_SEPARATOR . $this->_targetLanguage . '.php';
133
+
134
+ if (!isset($this->_translations[$targetLanguage])) {
135
+ if (file_exists($targetLanguageTranslationFile)) {// load the file and put its contents into $this->_translations.
136
+ $translations = array();
137
+ require_once($targetLanguageTranslationFile);
138
+
139
+ if (!empty($translations)) { // $translations should be populated by $targetLanguageTranslationFile.
140
+ $this->_translations[$targetLanguage] = $translations;
141
+ }
142
+ }
143
+ }
144
+
145
+ if (isset($this->_translations[$targetLanguage][$message])) {;
146
+ return $this->_translations[$targetLanguage][$message];
147
+ }
148
+ return $message;
149
+ }
150
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Utility/Translator/BaseInterface.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Stpp_Utility_Translator_BaseInterface {
4
+ function translate($string);
5
+ }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Xml/Writer.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Stpp_Xml_Writer extends XmlWriter {
4
+ public function writeElement($name, $content = null, $allowVoid = false) {
5
+ if ($content !== null || $allowVoid) {
6
+ parent::writeElement($name, $content);
7
+ }
8
+ }
9
+ }
app/code/local/Securetrading/Stpp/lib/code/overrides/Magento/Utility/Facade.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magento_Utility_Facade extends Stpp_Utility_Facade {
4
+ public function newDebugLog() {
5
+ $logWriter = new Magento_Utility_Log_Writer();
6
+ $debugLog = new Stpp_Utility_Log_Base();
7
+ $debugLog->setLogWriter($logWriter);
8
+ return $debugLog;
9
+ }
10
+ }
app/code/local/Securetrading/Stpp/lib/code/overrides/Magento/Utility/Log/Writer.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magento_Utility_Log_Writer implements Stpp_Utility_Log_WriterInterface {
4
+ public function log($message) {
5
+ Mage::log($message, null, 'securetrading.log');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/lib/stpp_logs/api.txt ADDED
File without changes
app/code/local/Securetrading/Stpp/lib/stpp_logs/exception.txt ADDED
File without changes
app/code/local/Securetrading/Stpp/lib/stpp_translations/core.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $translations = array(
4
+ 'The action instance was null.' => '',
5
+ 'The result object is null.' => '',
6
+ '%s has been called with the request method "%s".' => '',
7
+ 'The notificationreference was not posted to the notification.' => '',
8
+ 'The notificationreference was not a string.' => '',
9
+ 'The notification with notificationereference "%s" has already been processed.' => '',
10
+ 'The requesttypedescription has not been posted to the notification.' => '',
11
+ 'The notification hash is enabled but the \'responsesitesecurity\' field was not posted to the notification script.' => '',
12
+ 'The posted responsesitesecurity field was not a string.' => '',
13
+ 'The notification hashes did not match: %s !== %s.' => '',
14
+ 'An unhandled responsetype has been provided: "%s".' => '',
15
+ 'The redirect has been run for request method \'%s\'.' => '',
16
+ 'The responsesitesecurity was not sent to the redirect.' => '',
17
+ 'The responsesitesecurity sent to the redirect was not a string.' => '',
18
+ 'The redirect hashes did not match: %s and %s.' => '',
19
+ 'No payment types are available for selection.' => '',
20
+ 'Card Type' => '',
21
+ 'This is the bank that issued you with your credit/debit card. The issuer logo/details are shown on your card.' => '',
22
+ 'Card Number' => '',
23
+ 'This is the long 15 or 16 digit number on the front of your card.' => '',
24
+ 'Start Date' => '',
25
+ 'The month and year that your card was issued. This can be found on the front of your card.' => '',
26
+ 'Start Month' => '',
27
+ 'The month that your card was issued. This can be found on the front of your card.' => '',
28
+ 'Start Year' => '',
29
+ 'The year that your card was issued. This can be found on the front of your card.' => '',
30
+ 'Expiry Date' => '',
31
+ 'The month and year that your card expires. This can be found on the front of your card.' => '',
32
+ 'Expiry Month' => '',
33
+ 'The month that your card expires. This can be found on the front of your card.' => '',
34
+ 'Expiry Year' => '',
35
+ 'The year that your card expires. This can be found on the front of your card.' => '',
36
+ 'Security Code' => '',
37
+ 'This can be found on the back of your card. It is a 3 or 4 digit number.' => '',
38
+ 'Issue Number' => '',
39
+ 'If present, this will be on the front of your card. Not all credit/debit cards have an issue number.' => '',
40
+ 'Pay with a new card.' => '',
41
+ 'Select this option to enter new credit/debit card details.' => '',
42
+ 'Pay with a saved card.' => '',
43
+ 'Select this option to choose from one of your saved credit/debit cards.' => '',
44
+ 'Do not save my card details.' => '',
45
+ 'Select this option to not save your card details with us. By selecting this option you will not be able to take advantage of our easier and faster checkout process when placing future orders.' => '',
46
+ 'Save my card details securely.' => '',
47
+ 'Select this option to securely save your card details with us. This allows you to make future purchases quickly and easily.' => '',
48
+ 'Site Reference' => '',
49
+ 'You must obtain a site reference from SecureTrading before you can use this module. This module can accept either a test site reference or a live site reference.' => '',
50
+ 'Enable Authorize Only' => '',
51
+ 'Enabling authorize only payments will set the settlestatus of the order to 2. This means the payment will be suspended in the SecureTrading system and will not be captured by your aquiring bank.' => '',
52
+ 'Settle Due Date' => '',
53
+ 'The settle due date is the day that funds held against your customers\' account will be aquired.' => '',
54
+ 'Settle Status' => '',
55
+ 'This is the settle status that will be applied to this transaction. This should normally be set to 0.' => '',
56
+ 'Use Site Security' => '',
57
+ 'Site security should always be enabled on a live site. It allows payments to be taken to the Payment Pages safely. It should only be disabled for testing purposes when using a test site reference. The site security must be configured correctly both here and on your SecureTrading account.' => '',
58
+ 'Site Security Password' => '',
59
+ 'This is the password that will be used as part of the site security configuration. It must match the password configured on your SecureTrading account.' => '',
60
+ 'Site Security Algorithm' => '',
61
+ 'This is the hash algorithm that will be used as part of the site security configuration. It must match the algorithm configured on your SecureTrading account.' => '',
62
+ 'Use Notification Hash' => '',
63
+ 'The notification hash should always be enabled on a live site. It allows notifications to be sent from SecureTrading to your store securely. It should only be disabled for testing purposes when using a test site reference. The notification hash must be configured correctly both here and on your SecureTrading account in MyST.' => '',
64
+ 'Notification Hash Password' => '',
65
+ 'This is the password that will be used as part of the notification hash configuration. It must match the password configured on your SecureTrading account in MyST.' => '',
66
+ 'Notification Hash Algorithm' => '',
67
+ 'This is the hash algorithm that will be used as part of the notification hash configuration. It must match the algorithm configured on your SecureTrading account in MyST.' => '',
68
+ 'Parent CSS' => '',
69
+ 'The parent CSS file allows you to make the Payment Pages look the same as your own website by overriding the main CSS stylesheet loaded on the SecureTrading Payment Pages. Upload this stylesheet to the MyST File Manager and then enter the filename of the file you uploaded to the File Manager here, without the file path or the extension.' => '',
70
+ 'Child CSS' => '',
71
+ 'The child CSS file allows you to alter the appearance of certain parts of the Payment Pages by extending the main CSS stylesheet loaded on the SecureTrading Payment Pages (CSS Inheritance). This is useful when you wish to make minor changes to the default look of the Payment Pages. Upload this stylesheet to the MyST File Manager and then enter the filename of the file you uploaded to the File Manager here, without the file path or the extension.' => '',
72
+ 'Parent JS' => '',
73
+ 'The parent JS file, if provided, replaces the JavaScript file that is loaded when the Payment Pages are viewed by your customers. You should provide this file when you wish to drastically alter the front-end validation and user-experience provided by the default SecureTrading javascript file. Upload this file to the MyST File Manager and then enter the filename of the file you uploaded to the File Manager here, without the file path or the extension.' => '',
74
+ 'Child JS' => '',
75
+ 'The child JS file is loaded after the default Payment Pages Javascript file has been loaded. You can use a child JS file to make small alterations to the default Payment Pages behaviour. Upload this file to the MyST File Manager and then enter the filename of the file you uploaded to the File Manager here, without the file path or the extension.' => '',
76
+ 'Use Iframe' => '',
77
+ 'Enabling this option will make the Payment Pages load in an HTML iframe element. Using an iframe in combination with parent/child CSS allows you to make it appear as if the Payment Pages are part of your own website.' => '',
78
+ 'Use API with Payment Pages' => '',
79
+ 'Enabling this option will allow your shopping cart to interact with the SecureTrading API using ST API or our WebServices. This allows you to perform TRANSACTIONUPDATE and REFUND requests from the shopping cart without using MyST.' => '',
80
+ 'Connection' => '',
81
+ 'This lets you choose which connection method to use when connecting to the SecureTrading API.' => '',
82
+ 'Use 3D Secure' => '',
83
+ 'Enabling 3D Secure will reduce the possibility of fraudulent transactions being processed on your store and can shift the liability of chargebacks from you (the merchant) to your aquiring bank . 3D Secure must be enabled on your SecureTrading account before you can use this feature.' => '',
84
+ 'Use Risk Decision' => '',
85
+ 'Enabling Risk Decision requests will reduce the possibility of fraudulent transactions by comparing a customer transaction against a fraud-check database and suspending suspicious transactions. Risk Decision requests must be enabled on your SecureTrading account before you can use this feature.' => '',
86
+ 'Use Card Store' => '',
87
+ 'Using Card Store will allow your customers to store their debit/credit card information for easy repeat purchasing. Card information is stored on the SecureTrading servers, not on your own website (a maskedpan and transactionreference only are stored on your site). Card Store requests must be enabled on your SecureTrading account before you can use this feature.' => '',
88
+ 'Use Risk Decision After Auth' => '',
89
+ 'The usual scenario is that a Risk Decision request is sent before an Auth request. This allows the Auth to be suspended (settlestatus 2) if the Risk Decision reports that the transaction may be fraudulent. Running a Risk Decision after an Auth (as opposed to before an Auth) provides the risk decision with more information (CC details) to use when determining when a transaction may be fraudulent, but this stops the auth from automatically being suspended if the transaction may be fraudulent.' => '',
90
+ 'Use Auto Card Store' => '',
91
+ 'Enabling this will make your store automatically process Card Store requests when taking payment: users will not be given the choice to store their card details or not. Card Store requests must be enabled on your SecureTrading account before you use this feature. You must also have selected "Enable Card Store".' => '',
92
+ 'Accepted Cards' => '',
93
+ 'These are the payment types that you wish to show when a user makes payment with SecureTrading.' => '',
94
+ 'Enabling this option will make the 3D Secure ACS URL load in an HTML iframe element (if 3D Secure is enabled). Using an iframe allows you to make it appear as if the ACS URL is part of your own website.' => '',
95
+ 'ST API Alias' => '',
96
+ 'This is the alias to use when connecting to SecureTrading through ST API. Usually this is the same as your site reference.' => '',
97
+ 'ST API Host' => '',
98
+ 'This is the host on which the ST API client is running. This should usually be set to "localhost".' => '',
99
+ 'ST API Port' => '',
100
+ 'This is the port on which the ST API client is listening. The default port for ST API is 5000.' => '',
101
+ 'Web Services Alias' => '',
102
+ 'This is the alias to use when connecting to SecureTrading through our WebServices. Usually this is the same as your site reference.' => '',
103
+ 'Web Services Username' => '',
104
+ 'This is the username used for server authentication when connecting to the SecureTrading API using our Web Services.' => '',
105
+ 'Web Services Password' => '',
106
+ 'This is the password used for server authentication when connecting to the SecureTrading API using our Web Services' => '',
107
+ 'Verify SSL CA (Web Services)' => '',
108
+ 'Enable this option to verify that the CA signing the SecureTrading Web Services SSL certificate is one you trust. This should always be used in a production environment and should only be disabled for testing purposes when using a test site reference.' => '',
109
+ 'SSL CA FILE (Web Services)' => '',
110
+ 'The full filepath containing trusted CAs. The file should be in .PEM/.CRT format. This is required when verifying SSL CAs with our Web Services connection method.' => '',
111
+ 'The request is null.' => '',
112
+ 'Removed.' => '',
113
+ 'Invalid accounttypedescription: \'%s\'.' => '',
114
+ 'Invalid request type description: \'%s\'.' => '',
115
+ 'Invalid paymenttype: \'%s\'.' => '',
116
+ 'An invalid settleduedate ("%s") has been provided.' => '',
117
+ 'An invalid settle status ("%s") has been provided.' => '',
118
+ 'Invalid shipping method provided; "%s".' => '',
119
+ 'Invalid telephone type provided: "%s".' => '',
120
+ 'The filter has not been set correctly.' => '',
121
+ 'The updates have not been set correctly.' => '',
122
+ 'No response element in response XML.' => '',
123
+ 'Unsupported response type "%s" returned.' => '',
124
+ 'Response type "%s" unhandled.' => '',
125
+ 'The sender has not been set.' => '',
126
+ 'The processor has not been set.' => '',
127
+ 'The active connection has not been set.' => '',
128
+ 'The XmlWriter has not been set.' => '',
129
+ 'The XmlReader has not been set.' => '',
130
+ 'The context object is null.' => '',
131
+ 'Invalid request type: "%s".' => '',
132
+ 'The action instance has not been set.' => '',
133
+ 'The api log has not been set.' => '',
134
+ 'Unsupported response: "%s".' => '',
135
+ 'Transaction successful.' => '',
136
+ 'credit/debit card number' => '',
137
+ 'The %s was not provided or was incorrect.' => '',
138
+ 'Your credit/debit card was declined. Please try again using a different card.' => '',
139
+ 'The customer\'s credit/debit card was declined.' => '',
140
+ 'An unexpected error occurred. Please try again.' => '',
141
+ 'The MD has not been set.' => '',
142
+ 'The PaRes has not been set.' => '',
143
+ 'Not all parameters were passed to the refund function.' => '',
144
+ 'The filters do not exist.' => '',
145
+ 'The updates do not exist.' => '',
146
+ 'Unhandled request type "%s" provided.' => '',
147
+ 'No requests have been set.' => '',
148
+ 'The array index does not exist.' => '',
149
+ 'The responses must be an array.' => '',
150
+ 'No responses have been set.' => '',
151
+ 'Could not open socket to "%s".' => '',
152
+ 'The write operation failed.' => '',
153
+ 'An HTTP response code could not be found.' => '',
154
+ 'Unexpected HTTP response code %s returned.' => '',
155
+ 'An object with the key "%s" already exists.' => '',
156
+ 'Invalid key specified: "%s".' => '',
157
+ 'The object with key "%s" does not exist.' => '',
158
+ 'The connection store must be an array.' => '',
159
+ 'The connection store is empty.' => '',
160
+ 'The host parameter must be a string.' => '',
161
+ 'The port parameter must be a string or an integer.' => '',
162
+ 'Unable to create socket. Reason: "%s".' => '',
163
+ 'Socket unable to connect to %s:%s. Reason: "%s".' => '',
164
+ 'Unable to write to socket. Reason: "%s".' => '',
165
+ 'Unable to read from socket. Reason: "%s".' => '',
166
+ );
app/code/local/Securetrading/Stpp/sql/securetrading_stpp/install-3.0.0.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $this->startSetup();
5
+
6
+ // Request data table:
7
+
8
+ $table = $installer->getConnection()
9
+ ->newTable($installer->getTable('securetrading_stpp/requests'))
10
+ ->addColumn('request_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
11
+ 'identity' => true,
12
+ 'unsigned' => true,
13
+ 'nullable' => false,
14
+ 'primary' => true,
15
+ ), 'Request ID')
16
+ ->addColumn('order_increment_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, array(
17
+ 'nullable' => false,
18
+ ), 'Order Increment ID')
19
+ ->addColumn('request', Varien_Db_Ddl_Table::TYPE_BLOB, null, array(
20
+ 'nullable' => false,
21
+ ), 'Request (Serialized)')
22
+ ->addForeignKey($installer->getFkName('securetrading_stpp/requests', 'order_increment_id', 'sales/order', 'increment_id'),
23
+ 'order_increment_id', $installer->getTable('sales/order'), 'increment_id',
24
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
25
+ ->addIndex($installer->getIdxName('securetrading_stpp/requests', array('order_increment_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
26
+ array('order_increment_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
27
+ ->setComment('Stores SecureTrading STPP Payment Pages request data. This data is mapped to the response object in the notification.')
28
+ ;
29
+ $installer->getConnection()->createTable($table);
30
+
31
+ // Notifications table:
32
+
33
+ $table = $installer->getConnection()
34
+ ->newTable($installer->getTable('securetrading_stpp/notifications'))
35
+ ->addColumn('notification_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
36
+ 'identity' => true,
37
+ 'unsigned' => true,
38
+ 'nullable' => false,
39
+ 'primary' => true,
40
+ ), 'Notification ID')
41
+ ->addColumn('notification_reference', Varien_Db_Ddl_Table::TYPE_CHAR, 11, array(
42
+ 'nullable' => false,
43
+ ), 'Notification Reference')
44
+ ->addIndex($installer->getIdxName('securetrading_stpp/notifications', array('notification_reference')),
45
+ array('notification_reference'))
46
+ ->setComment('Stores Payment Pages notification references.')
47
+ ;
48
+ $installer->getConnection()->createTable($table);
49
+
50
+ // Transaction types table:
51
+
52
+ $table = $installer->getConnection()
53
+ ->newTable($installer->getTable('securetrading_stpp/transaction_types'))
54
+ ->addColumn('type_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 32, array(
55
+ 'nullable' => false,
56
+ 'primary' => true,
57
+ ), 'ID')
58
+ ->addColumn('type_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 32, array(
59
+ 'nullable' => false,
60
+ ), 'Name')
61
+ ->setComment('SecureTrading API transaction types (e.g. AUTH, RISKDEC)')
62
+ ;
63
+ $installer->getConnection()->createTable($table);
64
+
65
+ $data = array(
66
+ array(
67
+ 'type_id' => 'auth',
68
+ 'type_name' => 'Auth',
69
+ ),
70
+ array(
71
+ 'type_id' => 'threedquery',
72
+ 'type_name' => '3D Query',
73
+ ),
74
+ array(
75
+ 'type_id' => 'riskdec',
76
+ 'type_name' => 'Risk Decision',
77
+ ),
78
+ array(
79
+ 'type_id' => 'cardstore',
80
+ 'type_name' => 'Card Store',
81
+ ),
82
+ array(
83
+ 'type_id' => 'error',
84
+ 'type_name' => 'Error',
85
+ ),
86
+ array(
87
+ 'type_id' => 'transactionupdate',
88
+ 'type_name' => 'Transaction Update',
89
+ ),
90
+ array(
91
+ 'type_id' => 'transactionquery',
92
+ 'type_name' => 'Transaction Query',
93
+ ),
94
+ array(
95
+ 'type_id' => 'accountcheck',
96
+ 'type_name' => 'Account Check',
97
+ ),
98
+ );
99
+
100
+ $transactionTypesTable = $installer->getTable('securetrading_stpp/transaction_types');
101
+ $installer->getConnection()->insertArray($transactionTypesTable, array('type_id', 'type_name'), $data);
102
+
103
+ // Transactions table:
104
+
105
+ $table = $installer->getConnection()
106
+ ->newTable($installer->getTable('securetrading_stpp/transactions'))
107
+ ->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
108
+ 'nullable' => false,
109
+ 'primary' => true,
110
+ 'identity' => true,
111
+ 'unsigned' => true,
112
+ ), 'Transaction ID')
113
+ ->addColumn('transaction_reference', Varien_Db_Ddl_Table::TYPE_VARCHAR, 25, array(
114
+ 'nullable' => true, //e.g. for PPG saving data before post.
115
+ ), 'Transaction Reference')
116
+ ->addColumn('parent_transaction_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
117
+ 'nullable' => true, //e.g. if transaction has no parent
118
+ 'unsigned' => true,
119
+ ), 'Parent Transaction ID')
120
+ ->addColumn('request_type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 32, array(
121
+ 'nullable' => false,
122
+ ), 'Request Type')
123
+ ->addColumn('response_type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 32, array(
124
+ 'nullable' => false,
125
+ ), 'Response Type')
126
+ ->addColumn('request_data', Varien_Db_Ddl_Table::TYPE_BLOB, null, array(
127
+ 'nullable' => false,
128
+ ), 'Request Data')
129
+ ->addColumn('response_data', Varien_Db_Ddl_Table::TYPE_BLOB, null, array(
130
+ 'nullable' => false,
131
+ ), 'Response Data')
132
+ ->addColumn('error_code', Varien_Db_Ddl_Table::TYPE_VARCHAR, 5, array(
133
+ 'nullable' => false,
134
+ ), 'Error Code')
135
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
136
+ ), 'Order ID')
137
+ ->addColumn('last_updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
138
+ 'nullable' => false,
139
+ ), 'Last Updated At')
140
+ ->addForeignKey($installer->getFkName('securetrading_stpp/transactions', 'order_id', 'sales/order', 'entity_id'),
141
+ 'order_id', $installer->getTable('sales/order'), 'entity_id',
142
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
143
+ ->addForeignKey($installer->getFkName('securetrading_stpp/transactions', 'parent_transaction_id', 'securetrading_stpp/transactions', 'transaction_id'),
144
+ 'parent_transaction_id', $installer->getTable('securetrading_stpp/transactions'), 'transaction_id',
145
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
146
+ ->addIndex($installer->getIdxName('securetrading_stpp/transactions', array('transaction_reference'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
147
+ array('transaction_reference'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
148
+ ->setComment('Stores SecureTrading STPP transaction details.')
149
+ ;
150
+ $installer->getConnection()->createTable($table);
151
+
152
+ // Order statuses/states:
153
+
154
+ $data = array(
155
+ array(
156
+ 'status' => 'authorized',
157
+ 'label' => 'Authorized',
158
+ ),
159
+ array(
160
+ 'status' => 'suspended',
161
+ 'label' => 'Suspended',
162
+ ),
163
+ array(
164
+ 'status' => 'pending_ppages',
165
+ 'label' => 'Payment Pages',
166
+ ),
167
+ array(
168
+ 'status' => 'pending_3dsecure',
169
+ 'label' => '3D Secure',
170
+ ),
171
+ );
172
+
173
+ $statusTable = $installer->getTable('sales/order_status');
174
+ $installer->getConnection()->insertArray($statusTable, array('status', 'label'), $data);
175
+
176
+ $data = array(
177
+ array(
178
+ 'status' => 'authorized',
179
+ 'state' => 'processing',
180
+ 'is_default' => 0,
181
+ ),
182
+ array(
183
+ 'status' => 'suspended',
184
+ 'state' => 'payment_review',
185
+ 'is_default' => 0,
186
+ ),
187
+ array(
188
+ 'status' => 'pending_ppages',
189
+ 'state' => 'pending_payment',
190
+ 'is_default' => 0,
191
+ ),
192
+ array(
193
+ 'status' => 'pending_3dsecure',
194
+ 'state' => 'pending_payment',
195
+ 'is_default' => 0,
196
+ ),
197
+ );
198
+
199
+ $statusStateTable = $installer->getTable('sales/order_status_state');
200
+ $installer->getConnection()->insertArray($statusStateTable, array('status', 'state', 'is_default'), $data);
201
+
202
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/securetrading.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+ <adminhtml_securetrading_transactions_index>
3
+ <reference name="content">
4
+ <block type="securetrading_stpp/adminhtml_sales_transactions" name="securetrading_stpp.adminhtml.sales.transactions" output="toHtml" />
5
+ </reference>
6
+ </adminhtml_securetrading_transactions_index>
7
+
8
+ <adminhtml_securetrading_transactions_single>
9
+ <reference name="content">
10
+ <block type="securetrading_stpp/adminhtml_sales_transactions_single" name="securetrading_stpp.adminhtml.sales.transactions.single" template="securetrading/stpp/sales/transactions/single.phtml">
11
+ <block type="securetrading_stpp/adminhtml_sales_transactions_data_request" name="securetrading_stpp.adminhtml.sales.transactions.data.request" as="request_data" />
12
+ <block type="securetrading_stpp/adminhtml_sales_transactions_data_response" name="securetrading_stpp.adminhtml.sales.transactions.data.response" as="response_data" />
13
+ <block type="securetrading_stpp/adminhtml_sales_transactions_children" name="securetrading_stpp.adminhtml.sales.transactions.children" as="child_transactions" />
14
+ </block>
15
+ </reference>
16
+ </adminhtml_securetrading_transactions_single>
17
+
18
+ <adminhtml_sales_order_view>
19
+ <reference name="left">
20
+ <reference name="sales_order_tabs">
21
+ <block type="securetrading_stpp/adminhtml_sales_order_view_tab_modifier" name="tab_modifier" />
22
+ </reference>
23
+ </reference>
24
+ </adminhtml_sales_order_view>
25
+
26
+ <adminhtml_sales_order_create_post>
27
+ <reference name="content">
28
+ <block type="securetrading_stpp/payment_redirect_post" name="securetrading_stpp.payment.redirect.post" template="securetrading/stpp/payment/redirect/post.phtml" output="toHtml" />
29
+ </reference>
30
+ </adminhtml_sales_order_create_post>
31
+ </layout>
app/design/adminhtml/default/default/template/securetrading/stpp/payment/direct/form.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_code=$this->getMethodCode() ?>
2
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
3
+ <li>
4
+ <label for="<?php print $_code; ?>_payment_type">
5
+ <?php print $this->getCardTypeLabel(); ?>
6
+ <em class="required">*</em>
7
+ </label>
8
+ <div class="input-box">
9
+ <select name="payment[securetrading_stpp_payment_type]" id="<?php print $_code; ?>_payment_type" class="required-entry">
10
+ <option value=""><?php print $this->__('Please select an option...'); ?></option>
11
+ <?php foreach($this->getAcceptedCards() as $key => $value): ?>
12
+ <option value="<?php print $key; ?>"><?php print $value; ?></option>
13
+ <?php endforeach; ?>
14
+ </select>
15
+ </div>
16
+ </li>
17
+ <li>
18
+ <label for="<?php print $_code; ?>_card_number">
19
+ <?php print $this->getCardNumberLabel(); ?>
20
+ <em class="required">*</em>
21
+ </label>
22
+ <div class="input-box">
23
+ <input type="text" name="payment[securetrading_stpp_card_number]" id="<?php print $_code; ?>_card_number" class="required-entry" />
24
+ </div>
25
+ </li>
26
+ <li>
27
+ <label for="<?php print $_code; ?>_start_date_month">
28
+ <?php print $this->getCardStartDateLabel(); ?>
29
+ </label>
30
+ <div class="input-box">
31
+ <select name="payment[securetrading_stpp_start_date_month]" id="<?php print $_code; ?>_start_date_month" class="month">
32
+ <?php foreach($this->getMonths() as $k => $v): ?>
33
+ <option value="<?php print $k; ?>"><?php print $v; ?></option>
34
+ <?php endforeach; ?>
35
+ </select>
36
+ <select name="payment[securetrading_stpp_start_date_year]" id="<?php print $_code; ?>_start_date_year" class="year">
37
+ <?php foreach($this->getStartYears() as $year): ?>
38
+ <option value="<?php print $year; ?>"><?php print $year; ?></option>
39
+ <?php endforeach; ?>
40
+ </select>
41
+ </div>
42
+ </li>
43
+ <li>
44
+ <label for="<?php print $_code; ?>_expiry_date_month">
45
+ <?php print $this->getCardExpiryDateLabel(); ?>
46
+ <em class="required">*</em>
47
+ </label>
48
+ <div class="input-box">
49
+ <select name="payment[securetrading_stpp_expiry_date_month]" id="<?php print $_code; ?>_expiry_date_month" class="month required-entry">
50
+ <?php foreach($this->getMonths() as $k => $v): ?>
51
+ <option value="<?php print $k; ?>"><?php print $v; ?></option>
52
+ <?php endforeach; ?>
53
+ </select>
54
+ <select name="payment[securetrading_stpp_expiry_date_year]" id="<?php print $_code; ?>_expiry_date_year" class="year required-entry">
55
+ <?php foreach($this->getExpiryYears() as $year): ?>
56
+ <option value="<?php print $year; ?>"><?php print $year; ?></option>
57
+ <?php endforeach; ?>
58
+ </select>
59
+ </div>
60
+ </li>
61
+ <li>
62
+ <label for="<?php print $_code; ?>_security_code">
63
+ <?php print $this->getCardSecurityCodeLabel(); ?>
64
+ <em class=required">*</em>
65
+ </label>
66
+ <div class="input-box">
67
+ <input type="text" name="payment[securetrading_stpp_security_code]" id="<?php print $_code; ?>_security_code" class="required-entry" maxlength="4" />
68
+ </div>
69
+
70
+ <label for="<?php print $_code; ?>_issue_number">
71
+ <?php print $this->getCardIssueNumberLabel(); ?>
72
+ </label>
73
+ <div class="input-box">
74
+ <input type="text" name="payment[securetrading_stpp_issue_number]" id="<?php print $_code; ?>_issue_number" />
75
+ </div>
76
+ </li>
77
+ </ul>
app/design/adminhtml/default/default/template/securetrading/stpp/payment/direct/info.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <b><?php print $this->getTitle(); ?></b>
2
+ <br /><br />
3
+ <ul>
4
+ <li>Account Type Description: <?php print $this->getAccountTypeDescription(); ?></li>
5
+ <li>Transaction Reference: <a href="<?php print $this->getTransactionReferenceUrl(); ?>"><?php print $this->getTransactionReference(); ?></a></li>
6
+ <li>Security Response Address: <span style="<?php print $this->getSecurityAddressStyle(); ?>"><?php print $this->getSecurityAddress(); ?></span></li>
7
+ <li>Security Response Postcode: <span style="<?php print $this->getSecurityPostcodeStyle(); ?>"><?php print $this->getSecurityPostcode(); ?></span></li>
8
+ <li>Security Response Security Code: <span style="<?php print $this->getSecurityCodeStyle(); ?>"><?php print $this->getSecurityCode(); ?></span></li>
9
+ <li>Payment Type: <?php print $this->getPaymentType(); ?></li>
10
+ <li>Last 4 Card Digits: <?php print $this->getCcLast4(); ?></li>
11
+ <li>3D Enrolled: <?php print $this->getEnrolled(); ?></li>
12
+ <li>3D Status: <?php print $this->getStatus(); ?></li>
13
+ </ul>
14
+ <a href="<?php print $this->getMystUrl(); ?>" target="_blank">View in MyST</a>
15
+ <br /><br />
app/design/adminhtml/default/default/template/securetrading/stpp/payment/redirect/form.phtml ADDED
File without changes
app/design/adminhtml/default/default/template/securetrading/stpp/payment/redirect/info.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <b><?php print $this->getTitle(); ?></b>
2
+ <br /><br />
3
+ <ul>
4
+ <li>Account Type Description: <?php print $this->getAccountTypeDescription(); ?></li>
5
+ <li>Transaction Reference: <a href="<?php print $this->getTransactionReferenceUrl(); ?>"><?php print $this->getTransactionReference(); ?></a></li>
6
+ <li>Security Response Address: <span style="<?php print $this->getSecurityAddressStyle(); ?>"><?php print $this->getSecurityAddress(); ?></span></li>
7
+ <li>Security Response Postcode: <span style="<?php print $this->getSecurityPostcodeStyle(); ?>"><?php print $this->getSecurityPostcode(); ?></span></li>
8
+ <li>Security Response Security Code: <span style="<?php print $this->getSecurityCodeStyle(); ?>"><?php print $this->getSecurityCode(); ?></span></li>
9
+ <li>Payment Type: <?php print $this->getPaymentType(); ?></li>
10
+ <li>Last 4 Card Digits: <?php print $this->getCcLast4(); ?></li>
11
+ <li>3D Enrolled: <?php print $this->getEnrolled(); ?></li>
12
+ <li>3D Status: <?php print $this->getStatus(); ?></li>
13
+ </ul>
14
+ <a href="<?php print $this->getMystUrl(); ?>" target="_blank">View in MyST</a>
15
+ <br /><br />
app/design/adminhtml/default/default/template/securetrading/stpp/payment/redirect/post.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form action="<?php print $this->getRedirectUrl(); ?>" method="post" id="securetrading_stpp_redirect_form">
2
+ <?php foreach($this->getRedirectData() as $k => $v): ?>
3
+ <input type="hidden" name="<?php print $k; ?>" value="<?php print $v; ?>" />
4
+ <?php endforeach; ?>
5
+ <input type="submit" value="Pay" />
6
+ </form>
7
+ <script type="text/javascript">
8
+ document.body.onload = function() {
9
+ document.getElementById("securetrading_stpp_redirect_form").submit();
10
+ };
11
+ </script>
12
+ <noscript>
13
+ <p>You are seeing this message because JavaScript is disabled. Click "Pay" to continue with your transaction.</p>
14
+ </noscript>
app/design/adminhtml/default/default/template/securetrading/stpp/sales/transactions/single.phtml ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0">
3
+ <tr>
4
+ <td style="<?php echo $this->getHeaderWidth() ?>"><?php echo $this->getHeaderHtml() ?></td>
5
+ <td class="form-buttons"><?php echo $this->getButtonsHtml() ?></td>
6
+ </tr>
7
+ </table>
8
+ </div>
9
+
10
+ <div class="entry-edit">
11
+ <div class="entry-edit">
12
+ <div class="entry-edit-head">
13
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Transaction Data'); ?></h4>
14
+ </div>
15
+ <div id="log_details_fieldset" class="log-details">
16
+ <table cellspacing="0" class="log-info table">
17
+ <col width="25%" />
18
+ <col />
19
+ <tbody>
20
+ <tr>
21
+ <th><?php echo $this->__('Transaction Reference'); ?></th>
22
+ <td><?php echo $this->getTransactionReference() ?></td>
23
+ </tr>
24
+ <tr>
25
+ <th><?php echo $this->__('Parent Transaction Reference'); ?></th>
26
+ <td>
27
+ <?php if ($this->hasParentTransaction()): ?>
28
+ <a href="<?php print $this->getParentTransactionIdUrl(); ?>">
29
+ <?php print $this->getParentTransactionReference(); ?>
30
+ </a>
31
+ <?php else: ?>
32
+ None
33
+ <?php endif; ?>
34
+ </td>
35
+ </tr>
36
+ <tr>
37
+ <th><?php echo $this->__('Request Type'); ?></th>
38
+ <td><?php echo $this->getRequestType() ?></td>
39
+ </tr>
40
+ <tr>
41
+ <th><?php echo $this->__('Response Type'); ?></th>
42
+ <td><?php echo $this->getResponseType() ?></td>
43
+ </tr>
44
+ <tr>
45
+ <th><?php echo $this->__('Error Code'); ?></th>
46
+ <td><?php echo $this->getErrorCode() ?></td>
47
+ </tr>
48
+ <tr>
49
+ <th><?php echo $this->__('Last Updated At'); ?></th>
50
+ <td><?php echo $this->getLastUpdatedAt() ?></td>
51
+ </tr>
52
+ <tr>
53
+ <th><?php echo $this->__('Order ID'); ?></th>
54
+ <td>
55
+ <a href="<?php print $this->getOrderUrl(); ?>">
56
+ <?php echo $this->getOrderId() ?>
57
+ </a>
58
+ </td>
59
+ </tr>
60
+ <tr>
61
+ <th><?php echo $this->__('MyST'); ?></th>
62
+ <td><a href="<?php print $this->getMystUrl(); ?>">View in MyST</a></td>
63
+ </tr>
64
+ </tbody>
65
+ </table>
66
+ </div>
67
+ </div>
68
+ </div>
69
+
70
+ <div class="entry-edit">
71
+ <div class="entry-edit">
72
+ <div class="entry-edit-head">
73
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Child Transactions'); ?></h4>
74
+ </div>
75
+ <div class="log-details-grid">
76
+ <?php print $this->getChildHtml('child_transactions'); ?>
77
+ </div>
78
+ </div>
79
+ </div>
80
+
81
+ <div class="entry-edit">
82
+ <div class="entry-edit">
83
+ <div class="entry-edit-head">
84
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Request Data'); ?></h4>
85
+ </div>
86
+ <div class="log-details-grid">
87
+ <?php print $this->getChildHtml('request_data'); ?>
88
+ </div>
89
+ </div>
90
+ </div>
91
+
92
+
93
+ <div class="entry-edit">
94
+ <div class="entry-edit">
95
+ <div class="entry-edit-head">
96
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Response Data'); ?></h4>
97
+ </div>
98
+ <div class="log-details-grid">
99
+ <?php print $this->getChildHtml('response_data'); ?>
100
+ </div>
101
+ </div>
102
+ </div>
app/design/adminhtml/default/default/template/securetrading/stpp/system/config/fieldset/fields.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php ?>
2
+
3
+ in my template
app/design/frontend/base/default/layout/securetrading.xml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+ <securetrading_stpp_payment>
3
+ <reference name="root">
4
+ <remove name="left" />
5
+ <remove name="right" />
6
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
7
+ <reference name="content" />
8
+ </reference>
9
+ </securetrading_stpp_payment>
10
+
11
+
12
+ <securetrading_stpp_redirect_post_raw>
13
+ <remove name="root" />
14
+ <block type="securetrading_stpp/payment_redirect_post" name="securetrading_stpp.payment.redirect.post" template="securetrading/stpp/payment/redirect/post.phtml" output="toHtml" />
15
+ </securetrading_stpp_redirect_post_raw>
16
+
17
+ <securetrading_stpp_direct_post_raw>
18
+ <remove name="root" />
19
+ <block type="securetrading_stpp/payment_direct_post" name="securetrading_stpp.payment.direct.post" template="securetrading/stpp/payment/direct/post.phtml" output="toHtml" />
20
+ </securetrading_stpp_direct_post_raw>
21
+
22
+
23
+ <securetrading_stpp_redirect_post_container>
24
+ <update handle="securetrading_stpp_payment" />
25
+ <reference name="content">
26
+ <block type="securetrading_stpp/payment_redirect_post" name="securetrading_stpp.payment.redirect.post" template="securetrading/stpp/payment/redirect/post.phtml" />
27
+ </reference>
28
+ </securetrading_stpp_redirect_post_container>
29
+
30
+ <securetrading_stpp_direct_post_container>
31
+ <update handle="securetrading_stpp_payment" />
32
+ <reference name="content"><!--TODO - does below block exist!? -->
33
+ <block type="securetrading_stpp/payment_direct_acs" name="securetrading_stpp.payment.direct.acs" template="securetrading/stpp/payment/direct/acs.phtml" />
34
+ </reference>
35
+ </securetrading_stpp_direct_post_container>
36
+
37
+
38
+ <securetrading_stpp_redirect_post_iframe>
39
+ <update handle="securetrading_stpp_payment" />
40
+ <reference name="content">
41
+ <block type="securetrading_stpp/payment_iframe" name="securetrading_stpp.payment.iframe" as="iframe" template="securetrading/stpp/payment/iframe.phtml">
42
+ <action method="setSrcByRoute"><route>securetrading_stpp/redirect_post/raw</route></action>
43
+ </block>
44
+ </reference>
45
+ </securetrading_stpp_redirect_post_iframe>
46
+
47
+ <securetrading_stpp_direct_post_iframe>
48
+ <update handle="securetrading_stpp_payment" />
49
+ <reference name="content">
50
+ <block type="securetrading_stpp/payment_iframe" name="securetrading_stpp.payment.iframe" as="iframe" template="securetrading/stpp/payment/iframe.phtml">
51
+ <action method="setSrcByRoute"><route>securetrading_stpp/direct_post/raw</route></action>
52
+ </block>
53
+ </reference>
54
+ </securetrading_stpp_direct_post_iframe>
55
+
56
+
57
+
58
+ <securetrading_stpp_payment_location>
59
+ <remove name="root" />
60
+ <block type="securetrading_stpp/payment_location" name="securetrading_stpp.payment.location" as="location" template="securetrading/stpp/payment/location.phtml" output="toHtml" />
61
+ </securetrading_stpp_payment_location>
62
+ </layout>
app/design/frontend/base/default/template/securetrading/stpp/payment/direct/form.phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset class="form-list">
2
+ <?php $_code=$this->getMethodCode() ?>
3
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
4
+ <li>
5
+ <span id="<?php print $_code; ?>_description"><?php print $this->getDescription(); ?></span>
6
+ </li>
7
+ <li>
8
+ <label for="<?php print $_code; ?>_payment_type" class="required">
9
+ <?php print $this->getCardTypeLabel(); ?>
10
+ <em>*</em>
11
+ </label>
12
+ <div class="input-box">
13
+ <select name="payment[securetrading_stpp_payment_type]" id="<?php print $_code; ?>_payment_type" class="required-entry">
14
+ <option value=""><?php print $this->__('Please select an option...'); ?></option>
15
+ <?php foreach($this->getAcceptedCards() as $key => $value): ?>
16
+ <option value="<?php print $key; ?>"><?php print $value; ?></option>
17
+ <?php endforeach; ?>
18
+ </select>
19
+ <?php //print $this->getCardTypeDescription(); ?>
20
+ </div>
21
+ </li>
22
+ <li>
23
+ <label for="<?php print $_code; ?>_card_number" class="required">
24
+ <?php print $this->getCardNumberLabel(); ?>
25
+ <em>*</em>
26
+ </label>
27
+ <div class="input-box">
28
+ <input type="text" name="payment[securetrading_stpp_card_number]" id="<?php print $_code; ?>_card_number" class="required-entry" />
29
+ <?php //print $this->getCardNumberDescription(); ?>
30
+ </div>
31
+ </li>
32
+ <li>
33
+ <label for="<?php print $_code; ?>_start_date_month">
34
+ <?php print $this->getCardStartDateLabel(); ?>
35
+ </label>
36
+ <div class="input-box">
37
+ <div class="v-fix">
38
+ <select name="payment[securetrading_stpp_start_date_month]" id="<?php print $_code; ?>_start_date_month" class="month">
39
+ <?php foreach($this->getMonths() as $k => $v): ?>
40
+ <option value="<?php print $k; ?>"><?php print $v; ?></option>
41
+ <?php endforeach; ?>
42
+ </select>
43
+ </div>
44
+ <div class="v-fix">
45
+ <select name="payment[securetrading_stpp_start_date_year]" id="<?php print $_code; ?>_start_date_year" class="year">
46
+ <?php foreach($this->getStartYears() as $year): ?>
47
+ <option value="<?php print $year; ?>"><?php print $year; ?></option>
48
+ <?php endforeach; ?>
49
+ </select>
50
+ </div>
51
+ </div>
52
+ </li>
53
+ <li>
54
+ <label for="<?php print $_code; ?>_expiry_date_month" class="required">
55
+ <?php print $this->getCardExpiryDateLabel(); ?>
56
+ <em>*</em>
57
+ </label>
58
+ <div class="input-box">
59
+ <div class="v-fix">
60
+ <select name="payment[securetrading_stpp_expiry_date_month]" id="<?php print $_code; ?>_expiry_date_month" class="month required-entry">
61
+ <?php foreach($this->getMonths() as $k => $v): ?>
62
+ <option value="<?php print $k; ?>"><?php print $v; ?></option>
63
+ <?php endforeach; ?>
64
+ </select>
65
+ </div>
66
+ <div class="v-fix">
67
+ <select name="payment[securetrading_stpp_expiry_date_year]" id="<?php print $_code; ?>_expiry_date_year" class="year required-entry">
68
+ <?php foreach($this->getExpiryYears() as $year): ?>
69
+ <option value="<?php print $year; ?>"><?php print $year; ?></option>
70
+ <?php endforeach; ?>
71
+ </select>
72
+ </div>
73
+ </div>
74
+ </li>
75
+ <li>
76
+ <label for="<?php print $_code; ?>_security_code" class="required">
77
+ <?php print $this->getCardSecurityCodeLabel(); ?>
78
+ <em>*</em>
79
+ </label>
80
+ <div class="input-box">
81
+ <input type="text" name="payment[securetrading_stpp_security_code]" id="<?php print $_code; ?>_security_code" class="required-entry" maxlength="4" />
82
+ <?php //print $this->getCardSecurityCodeDescription(); ?>
83
+ </div>
84
+
85
+ <label for="<?php print $_code; ?>_issue_number">
86
+ <?php print $this->getCardIssueNumberLabel(); ?>
87
+ </label>
88
+ <div class="input-box">
89
+ <input type="text" name="payment[securetrading_stpp_issue_number]" id="<?php print $_code; ?>_issue_number" />
90
+ <?php //print $this->getCardIssueNumberDescription(); ?>
91
+ </div>
92
+ </li>
93
+ </ul>
94
+ </fieldset>
app/design/frontend/base/default/template/securetrading/stpp/payment/direct/info.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php print $this->getTitle(); ?>
2
+ <br /><br />
3
+ <ul>
4
+ <li>Payment Type: <?php print $this->getPaymentType(); ?></li>
5
+ <li>Last 4 Card Digits: <?php print $this->getCcLast4(); ?></li>
6
+ <?php if ($this->getStartDate()): ?>
7
+ <li>Start Date: <?php print $this->getStartDate(); ?></li>
8
+ <?php endif; ?>
9
+ <li>Expiry Date: <?php print $this->getExpiryDate(); ?></li>
10
+ <?php if ($this->getIssueNumber()): ?>
11
+ <li>Issue Number: <?php print $this->getIssueNumber(); ?></li>
12
+ <?php endif; ?>
13
+ </ul>
app/design/frontend/base/default/template/securetrading/stpp/payment/direct/post.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form action="<?php print $this->getRedirectUrl(); ?>" method="post" id="securetrading_stpp_direct_form">
2
+ <?php foreach($this->getRedirectData() as $k => $v): ?>
3
+ <input type="hidden" name="<?php print $k; ?>" value="<?php print $v; ?>" />
4
+ <?php endforeach; ?>
5
+ <input type="submit" value="Pay" />
6
+ </form>
7
+ <script type="text/javascript">
8
+ document.body.onload = function() {
9
+ document.getElementById("securetrading_stpp_direct_form").submit();
10
+ };
11
+ </script>
12
+ <noscript>
13
+ <p>You are seeing this message because JavaScript is disabled. Click "Pay" to continue with your transaction.</p>
14
+ </noscript>
app/design/frontend/base/default/template/securetrading/stpp/payment/iframe.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <iframe
2
+ src="<?php print $this->getSrc(); ?>"
3
+ width="<?php print $this->getWidth(); ?>"
4
+ height="<?php print $this->getHeight(); ?>"
5
+ frameborder="0"
6
+ allowtransparency=”true”
7
+ ></iframe>
app/design/frontend/base/default/template/securetrading/stpp/payment/location.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <head>
3
+ <title><?php print $this->__('Redirecting...'); ?></title>
4
+ </head>
5
+ <body>
6
+ <script type="text/javascript">
7
+ //<![CDATA[
8
+ window.top.location.href='<?php print $this->getRedirectUrl() ?>';
9
+ //]]>
10
+ </script>
11
+ </body>
12
+ </html>
app/design/frontend/base/default/template/securetrading/stpp/payment/redirect/form.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <fieldset class="form-list">
2
+ <ul id="payment_form_<?php echo $this->getMethodCode(); ?>" style="display:none">
3
+ <?php print $this->getDescription(); ?>
4
+ </ul>
5
+ </fieldset>
app/design/frontend/base/default/template/securetrading/stpp/payment/redirect/info.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php print $this->getTitle(); ?>
2
+ <?php if ($this->getPaymentType() || $this->getCcLast4()): ?>
3
+ <br /><br />
4
+ <ul>
5
+ <?php if ($this->getPaymentType()): ?>
6
+ <li>Payment Type: <?php print $this->getPaymentType(); ?></li>
7
+ <?php endif; ?>
8
+ <?php if ($this->getCcLast4()): ?>
9
+ <li>Last 4 Card Digits: <?php print $this->getCcLast4(); ?></li>
10
+ <?php endif; ?>
11
+ </ul>
12
+ <?php endif; ?>
app/design/frontend/base/default/template/securetrading/stpp/payment/redirect/post.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form action="<?php print $this->getRedirectUrl(); ?>" method="post" id="securetrading_stpp_redirect_form">
2
+ <?php foreach($this->getRedirectData() as $k => $v): ?>
3
+ <?php if ($k == 'requesttypedescriptions'): ?>
4
+ <?php foreach($v as $requestTypeDescription): ?>
5
+ <input type="hidden" name="requesttypedescriptions" value="<?php print $requestTypeDescription; ?>" />
6
+ <?php endforeach; ?>
7
+ <?php else: ?>
8
+ <input type="hidden" name="<?php print $k; ?>" value="<?php print $v; ?>" />
9
+ <?php endif; ?>
10
+ <?php endforeach; ?>
11
+ <input type="submit" value="Pay" />
12
+ </form>
13
+ <script type="text/javascript">
14
+ document.body.onload = function() {
15
+ document.getElementById("securetrading_stpp_redirect_form").submit();
16
+ };
17
+ </script>
18
+ <noscript>
19
+ <p>You are seeing this message because JavaScript is disabled. Click "Pay" to continue with your transaction.</p>
20
+ </noscript>
app/etc/modules/SecureTrading_Stpp.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Securetrading_Stpp>
4
+ <codePool>local</codePool>
5
+ <active>true</active>
6
+ </Securetrading_Stpp>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Securetrading_Stpp</name>
4
+ <version>3.0.0.0</version>
5
+ <stability>devel</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Integrates Magento with the SecureTrading STPP payment gateway.</summary>
10
+ <description>Integrates Magento with the SecureTrading STPP payment gateway.</description>
11
+ <notes>The development version of the SecureTrading STPP Magento integration.</notes>
12
+ <authors><author><name>PeteST</name><user>PeteST</user><email>peter.barrow@securetrading.com</email></author></authors>
13
+ <date>2014-01-21</date>
14
+ <time>17:11:53</time>
15
+ <contents><target name="magelocal"><dir name="Securetrading"><dir name="Stpp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Modifier.php" hash="23617edc4641c7e3525faae08e11e818"/><file name="Transactions.php" hash="fe4007125601a39b75047f974d25b58e"/></dir></dir></dir><dir name="Transactions"><file name="Children.php" hash="0b35ac5e3a5640ef299797f2cc2928cb"/><dir name="Data"><file name="Abstract.php" hash="d742570fd2d000e7ea5ef57471e194db"/><file name="Request.php" hash="277498a5a058aec448bd32b9433fc5b8"/><file name="Response.php" hash="50afef623df120b8895769528b0174d9"/></dir><file name="Grid.php" hash="ee54a8357af7ea6322b4a1288a443452"/><file name="Single.php" hash="579c91c55d0bda1a557d30eb6c03eb9c"/></dir><file name="Transactions.php" hash="ef8d946452081c50ea50a2f56d9ff168"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Fields.php" hash="0310bae31c21c3d4df46107fbce3cdfa"/></dir><file name="Group.php" hash="7f36f8de6918d4d75a1ba059194a31df"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Parenttransactionreference.php" hash="2d1ef69a9554457d150e0064f24a02b2"/></dir></dir></dir></dir></dir><dir name="Payment"><dir name="Direct"><file name="Form.php" hash="7ac72932a0af03d8ee0f039238325e1e"/><file name="Info.php" hash="96b45fd3a2530d32ad5b762d30adb349"/><file name="Post.php" hash="5e76814c5156accd9fc45c6f8925e553"/></dir><file name="Iframe.php" hash="66c50091fa6f2bc7282c79b38959dd02"/><dir name="Info"><file name="Abstract.php" hash="af4f1d3a7931583df564ce58bd4b9658"/></dir><file name="Location.php" hash="95461da6e144559bb26b56fcb5733c29"/><dir name="Redirect"><file name="Form.php" hash="4a5c80135121a495a94e193b0d7f1982"/><file name="Info.php" hash="5172a488856a167205abab64819062d5"/><file name="Post.php" hash="00d05d0064ecbc5bdc75b615bdfc4894"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7a5e840b55cd85810bbb5670d884913d"/></dir><dir name="Model"><dir name="Actions"><file name="Abstract.php" hash="800051473f2baac8a390d10e094c8127"/><file name="Direct.php" hash="1806c9720199162fb939c7e2f4260074"/><file name="Redirect.php" hash="4f4239b0d28c7b532303806cbd9d6411"/></dir><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Multiselect.php" hash="65ca6dd7b6b597aada4978b7c6e803c2"/></dir></dir></dir></dir><file name="Cron.php" hash="57c166a645f9b0309c9be7c9e0e2ecb0"/><file name="Integration.php" hash="6884ad9b4336916a6e4b368376bfade4"/><file name="Observer.php" hash="e579c0c411e109445fbcaf2f3be4bdf5"/><dir name="Payment"><file name="Abstract.php" hash="0f9831e179dc3d381a3ed5b29823eebc"/><dir name="Direct"><file name="Session.php" hash="981654031f061f1e04efc80b4a57b428"/></dir><file name="Direct.php" hash="8568304cbe5a5e37a140b100257ae475"/><dir name="Redirect"><file name="Notification.php" hash="22e2a3366aa294f83aabe94decdbc47f"/><file name="Request.php" hash="cb3b90d9bb7a31bec42ae94ae83770cb"/></dir><file name="Redirect.php" hash="4f5277216d0f5dc6fa41d571cfe3691a"/></dir><dir name="Resource"><dir name="Payment"><dir name="Redirect"><file name="Notification.php" hash="251daf3860785e6aab8b5a6594bf397a"/><dir name="Request"><file name="Collection.php" hash="ce960dbcdf4c40f08782750b3e7ec4d4"/></dir><file name="Request.php" hash="9a51ce8b5aa2bf188e39afcd099225d1"/></dir></dir><dir name="Transaction"><file name="Collection.php" hash="c48174c935a30b1df2e545ff3ad71adc"/><dir name="Types"><file name="Collection.php" hash="efc344d22f5b19ad8a239ec3acb20e77"/></dir><file name="Types.php" hash="abbde61e4d29e19bb3a67ad1959b388f"/></dir><file name="Transaction.php" hash="a864a129f03751920262b847a1711f4d"/></dir><dir name="Source"><file name="Cardtypes.php" hash="bdac2842ee54f15d4deab2cd1e0caea6"/><file name="Connection.php" hash="b281807c740f8a79f591789a3d8792d7"/><file name="Paymentaction.php" hash="0f05df5d7e5248808c96700e102a2b11"/><file name="Settleduedate.php" hash="b5acc4d4eae0a22d4bf25e5fd5f2cda0"/><file name="Settlestatus.php" hash="c65d0810ffa5e4cfe7d086a489303eda"/></dir><dir name="Transaction"><file name="Types.php" hash="d704d79ee9cf90d6c678fdbbb5d66b6d"/></dir><file name="Transaction.php" hash="4d0ef347983194e026b5746f7a6ddd41"/><file name="Transport.php" hash="c0694f56126c89de202c6adb0108082c"/></dir><dir name="controllers"><dir name="Direct"><file name="PostController.php" hash="fdaf2cacc8bbbc123948686b7616b5c2"/></dir><file name="DirectController.php" hash="b10baf3ed1a40d6f80e2f639370d8be3"/><file name="PaymentController.php" hash="a1fb4d11fa71c75180af3ca6bea99f25"/><dir name="Redirect"><file name="PostController.php" hash="a2b871ac797b47f39af31a5c8222442b"/></dir><file name="RedirectController.php" hash="96e3ce21b02eba1e3494aa975ea5b8f9"/><dir name="Sales"><dir name="Order"><file name="CreateController.php" hash="32b9fceafff37332beb3142c649b9f0d"/></dir></dir><dir name="Securetrading"><file name="TransactionsController.php" hash="36723e25ecbab66e27b27cd011d08e1a"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="4893ab9fecad1a67037bdabd7bb5aa96"/><file name="config.xml" hash="7ae341d3ea088590d82c622b74cb9022"/><file name="system.xml" hash="bdaae9bdba4549ee18f201c47015b03c"/></dir><dir name="lib"><file name="Securetrading.php" hash="740260870e77fd6fffa597ec11fbd540"/><dir name="code"><dir name="core"><dir name="Stpp"><dir name="Actions"><file name="Abstract.php" hash="fce4b439f195bb866983180fe57e3bf7"/><file name="BaseInterface.php" hash="cd3004a4734c99499b41f9442d8406f4"/></dir><dir name="Api"><file name="ActionsInterface.php" hash="20feaa9eaefa912efb02d3cd33212fa2"/><file name="Base.php" hash="4d21e40c7af399c15521ff122c7b0d67"/><file name="BaseInterface.php" hash="252e16b85c0e7e230934b02c3e16728d"/><dir name="Connection"><file name="BaseInterface.php" hash="8638cb072cf263abd8687e87cdc81fb5"/><file name="Stapi.php" hash="107a6a41d31b021ddbd84739499b1830"/><file name="Store.php" hash="3909b4aa2b618816c4380d4b41d2d375"/><file name="StoreInterface.php" hash="6e8bfff449b86b145ae5b138dde91d50"/><file name="Webservices.php" hash="6eb6f7d1a29de997b957eb72ba5de59c"/></dir><file name="Context.php" hash="4b4471af376dbb0023f9836a9e8557fc"/><file name="ContextInterface.php" hash="b3e9edfa4fe8776140eafce41da98709"/><file name="Facade.php" hash="d5b1f579af75a6ad07dbae25e0f23dd2"/><file name="Helper.php" hash="1fa61f567d149594e02bb4e5ee9c23ed"/><file name="HelperInterface.php" hash="aa6f9747d5c2f242455d5c11be51b66b"/><file name="Log.php" hash="8f9df624ea7e440f7d074be07a98e511"/><file name="LogInterface.php" hash="fce5c3d966eaf5885f3575bd800c6d46"/><file name="Process.php" hash="7db529c5ebb80b21ad6e2b8fe07b8089"/><file name="ProcessInterface.php" hash="76117fc893006c7a927eda90596261f3"/><file name="Result.php" hash="8146ff3cd41bc1c23eb9cad8192d8cec"/><file name="ResultInterface.php" hash="eb062e7e941172e6258eb3fe6eb25c71"/><file name="Send.php" hash="ec79e21c81a6521a7813267cad1d9103"/><file name="SendInterface.php" hash="0a13ea22e3d2f556be7f02d5b8568e43"/><dir name="Xml"><file name="Reader.php" hash="36baf335da8050798ccf3eda63b78606"/><file name="ReaderInterface.php" hash="3a148a5b88af125d766877f33dd882b7"/><file name="Writer.php" hash="3832c9b19967873aa7683bc86e0595dd"/><file name="WriterInterface.php" hash="1700903ae09c5dec1a8b6c215a6f0a97"/></dir></dir><dir name="Component"><file name="Abstract.php" hash="ab8f75478d9b11383d2e4cf39f99f92d"/><file name="BaseInterface.php" hash="a7a21448d576cba4921a17e3c4c63e26"/><file name="Store.php" hash="8afe5baa023a117085dfca51d8d6d0c4"/></dir><file name="Config.php" hash="e62fcc26e717a67051abd0873998c3d7"/><dir name="Data"><file name="Abstract.php" hash="20a4f4c90e1b0536a53bb47dd02f7013"/><file name="AbstractInterface.php" hash="511f49db6045b20b299ac27a123b0ee1"/><file name="Request.php" hash="6d534dcc55b23cd80f3ae57c53d2fdf3"/><file name="Response.php" hash="61ad719240e67b23e5cec2083c83d4ae"/></dir><file name="Exception.php" hash="ddef67bc724764d3fa455b3f246e670d"/><file name="Facade.php" hash="b044ddd9a1c2e0097bea099efa1f6bd5"/><dir name="Fields"><file name="Admin.php" hash="dad214c2f8b8c9300316abe10073dc3d"/><file name="AdminInterface.php" hash="d60603c6fe6ac4393edc3e699d11cfa2"/><file name="Facade.php" hash="4f00cf6fb606175bb8c1a98988504cb7"/><file name="Frontend.php" hash="e558224f8c3adf54733c1df71e14a8f1"/><file name="FrontendInterface.php" hash="9e7e760b58d9b1aea5169199f85055b8"/></dir><file name="Helper.php" hash="1b9e5cda59cab32904f41a1137732889"/><file name="HelperInterface.php" hash="e74c27a61169ac2dbad549178635b652"/><dir name="PaymentPages"><file name="ActionsInterface.php" hash="477836396b30505fd77e2edab9228eb9"/><file name="Base.php" hash="e681b4552d4d7a21235cd3e7b75a700c"/><file name="BaseInterface.php" hash="8e88b88ea80bbc678275b545f5a0ca0e"/><file name="Facade.php" hash="6592fe506f9b11f2bc5d59290c2089ac"/><file name="Helper.php" hash="0f299510045851097ddb2f5e5999130b"/><file name="HelperInterface.php" hash="92cb7856303a054852856f84fce59ab8"/><file name="Result.php" hash="516d99ad6325d3688cb6cf9d96611bad"/><file name="ResultInterface.php" hash="6331633ee01a8f801e6aa92bc4b21a79"/></dir><dir name="Result"><file name="Abstract.php" hash="e101a37e53b02217d9f71896724fc464"/><file name="AbstractInterface.php" hash="67f281eeb616125a6730c9d0bdcdefbf"/></dir><file name="Types.php" hash="59e63b0ced6b2d25236be04bafca392c"/><file name="TypesInterface.php" hash="01535df4e4e7bb7075a06050841594f0"/><dir name="Utility"><file name="Facade.php" hash="a87ccac18a334e151e109cf07b5338f0"/><dir name="Log"><file name="Base.php" hash="6d4a4ac38eeb8747199ae932caab713b"/><file name="BaseInterface.php" hash="8df2532e217b93725ab15e5a76dfd6e7"/><dir name="User"><file name="Abstract.php" hash="622318fca2ae84a50f50f65153036528"/></dir><file name="UserInterface.php" hash="f88f34cb0338ab4d98c3f5ebcbb22f7d"/><dir name="Writer"><file name="File.php" hash="ac8301a7c10222459cdd0f789783a2bc"/></dir><file name="WriterInterface.php" hash="0e4e743dd4c8da74fea389c8f728b0b4"/></dir><dir name="Translator"><file name="Base.php" hash="4ff1233235a2b58886da2a3b07247d9a"/><file name="BaseInterface.php" hash="f76d5808b75e190bb6499da9608c9efb"/></dir></dir><dir name="Xml"><file name="Writer.php" hash="97a246a7642179bd346cfce33f523c87"/></dir></dir><file name="Stpp.php" hash="2b593e5ee83d4272bb4efac0fb09c88b"/></dir><dir name="overrides"><dir name="Magento"><dir name="Utility"><file name="Facade.php" hash="efbd45016fa27108d3b8dbeb4f085b25"/><dir name="Log"><file name="Writer.php" hash="ac55bea5883c26734f7fcd71d0a63445"/></dir></dir></dir></dir></dir><dir name="stpp_logs"><file name="api.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="exception.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="stpp_translations"><file name="core.php" hash="8de46a7cce58eadbff4ae9b294e20aec"/></dir></dir><dir name="sql"><dir name="securetrading_stpp"><file name="install-3.0.0.php" hash="c5e0924c2e113343856d35c25d85fa26"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="securetrading"><dir><dir name="stpp"><dir name="payment"><dir name="direct"><file name="form.phtml" hash="1ebafc1b8fe9b5534c79e838187ca93a"/><file name="info.phtml" hash="e6537fa0b3ff758b694f40d5f6437da8"/></dir><dir name="redirect"><file name="form.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="info.phtml" hash="e6537fa0b3ff758b694f40d5f6437da8"/><file name="post.phtml" hash="fd3a12a59a88b643d2e363bf6695555f"/></dir></dir><dir name="sales"><dir name="transactions"><file name="single.phtml" hash="42f46e7ce305f376b38a33374088f62e"/></dir></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="fields.phtml" hash="0c0aff08f256a5cfd2c644e7f629c9d7"/></dir></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="securetrading.xml" hash="0d1ce35ba1cc1ccdae68c3bd959d5dbb"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="securetrading"><dir><dir name="stpp"><dir name="payment"><dir name="direct"><file name="form.phtml" hash="84793faa4856fa0a5f1d31777507f257"/><file name="info.phtml" hash="990e48a8f00f86691a64f5f9cf371b05"/><file name="post.phtml" hash="d8643b7e67de32c311c30b531b0c6392"/></dir><file name="iframe.phtml" hash="550f6904467d71a368b03b2ba6852841"/><file name="location.phtml" hash="e790bf7d7f7c453f98cd9e03e0b74ab1"/><dir name="redirect"><file name="form.phtml" hash="7590b97c94ac8a7058606c82a2bd3766"/><file name="info.phtml" hash="4eaf8674c2de27618920fdcd65d61ade"/><file name="post.phtml" hash="f582913b9162f29ef7fb91a54194c2e1"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="securetrading.xml" hash="f7a0c78bf59b2631cf4d52710665e04a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SecureTrading_Stpp.xml" hash="92a8948ac28f1ca221b1743e710a97d1"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>5.5.8</max></php></required></dependencies>
18
+ </package>