Dotsource_Computop - Version 1.0.0.16623

Version Notes

Released at Revision 16623

Download this release

Release Info

Developer Magento Core Team
Extension Dotsource_Computop
Version 1.0.0.16623
Comparing to
See all releases


Version 1.0.0.16623

Files changed (165) hide show
  1. DEPLOYED_REVISION +2 -0
  2. app/code/community/Dotsource/Computop/Block/Adminhtml/Block/Sales/Order/Grid.php +130 -0
  3. app/code/community/Dotsource/Computop/Block/Adminhtml/Notification/Secureurl.php +76 -0
  4. app/code/community/Dotsource/Computop/Block/Adminhtml/Sales/Order/View.php +69 -0
  5. app/code/community/Dotsource/Computop/Block/Adminhtml/Sales/Order/View/Tab/Action.php +281 -0
  6. app/code/community/Dotsource/Computop/Block/Checkout/Iframe.php +15 -0
  7. app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Review.php +195 -0
  8. app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Review/Details.php +41 -0
  9. app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Shortcut.php +85 -0
  10. app/code/community/Dotsource/Computop/Block/Config/Form/Abstract.php +265 -0
  11. app/code/community/Dotsource/Computop/Block/Config/Form/Merchant.php +76 -0
  12. app/code/community/Dotsource/Computop/Block/Config/Form/Renderer/Select.php +166 -0
  13. app/code/community/Dotsource/Computop/Block/Form/Abstract.php +93 -0
  14. app/code/community/Dotsource/Computop/Block/Form/Cc.php +193 -0
  15. app/code/community/Dotsource/Computop/Block/Form/Directpay.php +44 -0
  16. app/code/community/Dotsource/Computop/Block/Form/Eft.php +143 -0
  17. app/code/community/Dotsource/Computop/Block/Form/Giropay.php +44 -0
  18. app/code/community/Dotsource/Computop/Block/Form/Ideal.php +24 -0
  19. app/code/community/Dotsource/Computop/Block/Form/Mpass.php +25 -0
  20. app/code/community/Dotsource/Computop/Block/Form/Paypalexpress.php +39 -0
  21. app/code/community/Dotsource/Computop/Block/Form/Paypalstandard.php +48 -0
  22. app/code/community/Dotsource/Computop/Block/Info/Cc.php +90 -0
  23. app/code/community/Dotsource/Computop/Block/Info/Directpay.php +25 -0
  24. app/code/community/Dotsource/Computop/Block/Info/Eft.php +35 -0
  25. app/code/community/Dotsource/Computop/Block/Info/Giropay.php +25 -0
  26. app/code/community/Dotsource/Computop/Block/Info/Ideal.php +25 -0
  27. app/code/community/Dotsource/Computop/Block/Info/Mpass.php +28 -0
  28. app/code/community/Dotsource/Computop/Block/Info/Paypalstandard.php +25 -0
  29. app/code/community/Dotsource/Computop/Block/Widget/Grid/Column/Renderer/Zerofill.php +40 -0
  30. app/code/community/Dotsource/Computop/Controller/Callback.php +143 -0
  31. app/code/community/Dotsource/Computop/Controller/Computopcallback.php +334 -0
  32. app/code/community/Dotsource/Computop/Controller/Expresscallback.php +528 -0
  33. app/code/community/Dotsource/Computop/Helper/Config.php +345 -0
  34. app/code/community/Dotsource/Computop/Helper/Converter.php +298 -0
  35. app/code/community/Dotsource/Computop/Helper/Data.php +636 -0
  36. app/code/community/Dotsource/Computop/Helper/Feature.php +50 -0
  37. app/code/community/Dotsource/Computop/Helper/Payment.php +454 -0
  38. app/code/community/Dotsource/Computop/Helper/Paypal/Config.php +87 -0
  39. app/code/community/Dotsource/Computop/Model/Action.php +114 -0
  40. app/code/community/Dotsource/Computop/Model/Cancelprocess.php +584 -0
  41. app/code/community/Dotsource/Computop/Model/Connection.php +187 -0
  42. app/code/community/Dotsource/Computop/Model/Encryption.php +166 -0
  43. app/code/community/Dotsource/Computop/Model/Error/Handler/Abstract.php +57 -0
  44. app/code/community/Dotsource/Computop/Model/Error/Handler/Exception.php +32 -0
  45. app/code/community/Dotsource/Computop/Model/Error/Handler/Message.php +321 -0
  46. app/code/community/Dotsource/Computop/Model/Error/Handler/Session.php +64 -0
  47. app/code/community/Dotsource/Computop/Model/Error/Handler/Translate.php +62 -0
  48. app/code/community/Dotsource/Computop/Model/Error/Manager.php +267 -0
  49. app/code/community/Dotsource/Computop/Model/Error/Observer.php +102 -0
  50. app/code/community/Dotsource/Computop/Model/Exception.php +17 -0
  51. app/code/community/Dotsource/Computop/Model/Mysql4/Action.php +19 -0
  52. app/code/community/Dotsource/Computop/Model/Mysql4/Action/Collection.php +20 -0
  53. app/code/community/Dotsource/Computop/Model/Mysql4/Setup.php +116 -0
  54. app/code/community/Dotsource/Computop/Model/Mysql4/Transaction.php +46 -0
  55. app/code/community/Dotsource/Computop/Model/Mysql4/Transaction/Collection.php +20 -0
  56. app/code/community/Dotsource/Computop/Model/Observer.php +176 -0
  57. app/code/community/Dotsource/Computop/Model/Observer/Session.php +39 -0
  58. app/code/community/Dotsource/Computop/Model/Payment/Abstract.php +982 -0
  59. app/code/community/Dotsource/Computop/Model/Payment/Cc.php +122 -0
  60. app/code/community/Dotsource/Computop/Model/Payment/Directpay.php +61 -0
  61. app/code/community/Dotsource/Computop/Model/Payment/Eft.php +177 -0
  62. app/code/community/Dotsource/Computop/Model/Payment/Giropay.php +115 -0
  63. app/code/community/Dotsource/Computop/Model/Payment/Ideal.php +46 -0
  64. app/code/community/Dotsource/Computop/Model/Payment/Mpass.php +57 -0
  65. app/code/community/Dotsource/Computop/Model/Payment/Paypalexpress.php +216 -0
  66. app/code/community/Dotsource/Computop/Model/Payment/Paypalstandard.php +54 -0
  67. app/code/community/Dotsource/Computop/Model/Payment/Request/Cc/Authorize.php +138 -0
  68. app/code/community/Dotsource/Computop/Model/Payment/Request/Cc/Capture/New.php +61 -0
  69. app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Capture.php +38 -0
  70. app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Refund.php +41 -0
  71. app/code/community/Dotsource/Computop/Model/Payment/Request/Default/Reverse.php +42 -0
  72. app/code/community/Dotsource/Computop/Model/Payment/Request/Directpay/Authorize.php +65 -0
  73. app/code/community/Dotsource/Computop/Model/Payment/Request/Eft/Authorize.php +98 -0
  74. app/code/community/Dotsource/Computop/Model/Payment/Request/Giropay/Authorize.php +96 -0
  75. app/code/community/Dotsource/Computop/Model/Payment/Request/Giropay/Check.php +54 -0
  76. app/code/community/Dotsource/Computop/Model/Payment/Request/Ideal/Authorize.php +46 -0
  77. app/code/community/Dotsource/Computop/Model/Payment/Request/Mpass/Authorize.php +102 -0
  78. app/code/community/Dotsource/Computop/Model/Payment/Request/Paypal/Authorize.php +131 -0
  79. app/code/community/Dotsource/Computop/Model/Payment/Request/Paypalexpress/Authorize.php +114 -0
  80. app/code/community/Dotsource/Computop/Model/Payment/Request/Request.php +835 -0
  81. app/code/community/Dotsource/Computop/Model/Payment/Response/Giropay/Check.php +32 -0
  82. app/code/community/Dotsource/Computop/Model/Payment/Response/Response.php +205 -0
  83. app/code/community/Dotsource/Computop/Model/Rewrite/Sales/Order/Payment.php +86 -0
  84. app/code/community/Dotsource/Computop/Model/Session.php +91 -0
  85. app/code/community/Dotsource/Computop/Model/System/Config/Backend/Orderdesc.php +37 -0
  86. app/code/community/Dotsource/Computop/Model/System/Config/Backend/Serialized/Merchant.php +54 -0
  87. app/code/community/Dotsource/Computop/Model/System/Config/Source/Abstract.php +26 -0
  88. app/code/community/Dotsource/Computop/Model/System/Config/Source/AllowedcountriesAction.php +38 -0
  89. app/code/community/Dotsource/Computop/Model/System/Config/Source/AllowedipzonesAction.php +38 -0
  90. app/code/community/Dotsource/Computop/Model/System/Config/Source/Baseurl.php +33 -0
  91. app/code/community/Dotsource/Computop/Model/System/Config/Source/Countryiso3.php +44 -0
  92. app/code/community/Dotsource/Computop/Model/System/Config/Source/Logos.php +81 -0
  93. app/code/community/Dotsource/Computop/Model/System/Config/Source/Modus.php +35 -0
  94. app/code/community/Dotsource/Computop/Model/System/Config/Source/Paymentaction.php +41 -0
  95. app/code/community/Dotsource/Computop/Model/System/Config/Source/Paypalpaymentaction.php +37 -0
  96. app/code/community/Dotsource/Computop/Model/System/Config/Source/Txtype.php +34 -0
  97. app/code/community/Dotsource/Computop/Model/Transaction.php +99 -0
  98. app/code/community/Dotsource/Computop/Object.php +349 -0
  99. app/code/community/Dotsource/Computop/controllers/Adminhtml/ActionController.php +52 -0
  100. app/code/community/Dotsource/Computop/controllers/Adminhtml/MassactionController.php +238 -0
  101. app/code/community/Dotsource/Computop/controllers/Callback/CcController.php +62 -0
  102. app/code/community/Dotsource/Computop/controllers/Callback/DirectpayController.php +23 -0
  103. app/code/community/Dotsource/Computop/controllers/Callback/GiropayController.php +23 -0
  104. app/code/community/Dotsource/Computop/controllers/Callback/IdealController.php +23 -0
  105. app/code/community/Dotsource/Computop/controllers/Callback/MpassController.php +27 -0
  106. app/code/community/Dotsource/Computop/controllers/Callback/PaypalController.php +28 -0
  107. app/code/community/Dotsource/Computop/controllers/Callback/PaypalexpressController.php +80 -0
  108. app/code/community/Dotsource/Computop/controllers/IframeController.php +127 -0
  109. app/code/community/Dotsource/Computop/controllers/IndexController.php +77 -0
  110. app/code/community/Dotsource/Computop/etc/adminhtml.xml +23 -0
  111. app/code/community/Dotsource/Computop/etc/config.xml +303 -0
  112. app/code/community/Dotsource/Computop/etc/errors.xml +254 -0
  113. app/code/community/Dotsource/Computop/etc/system.xml +776 -0
  114. app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-install-1.4.0.1.1.php +56 -0
  115. app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.0.1.1-1.4.1.1.2.php +83 -0
  116. app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.2-1.4.1.1.3.php +8 -0
  117. app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.3-1.4.1.1.4.php +8 -0
  118. app/code/community/Dotsource/Computop/sql/computop_setup/mysql4-upgrade-1.4.1.1.4-1.4.1.1.5.php +8 -0
  119. app/code/community/Dotsource/Dsrevision/Block/Adminhtml/System/Revision.php +60 -0
  120. app/code/community/Dotsource/Dsrevision/etc/config.xml +25 -0
  121. app/code/community/Dotsource/Dsrevision/etc/system.xml +38 -0
  122. app/code/community/Mage/Sales/Model/Order/Payment-1.4.0.X.php +964 -0
  123. app/code/community/Mage/Sales/Model/Order/Payment-1.4.1.X.php +1294 -0
  124. app/code/community/Mage/Sales/Model/Order/Payment.php +10 -0
  125. app/design/adminhtml/default/default/layout/computop.xml +58 -0
  126. app/design/adminhtml/default/default/template/computop/config/form/field/form.phtml +178 -0
  127. app/design/adminhtml/default/default/template/computop/depends/allallowedcountries.phtml +120 -0
  128. app/design/adminhtml/default/default/template/computop/depends/ipzones.phtml +114 -0
  129. app/design/adminhtml/default/default/template/computop/form/eft.phtml +32 -0
  130. app/design/adminhtml/default/default/template/computop/info/callback.phtml +25 -0
  131. app/design/adminhtml/default/default/template/computop/notification/secureurl.phtml +18 -0
  132. app/design/frontend/base/default/layout/computop.xml +55 -0
  133. app/design/frontend/base/default/template/computop/checkout/iframe.phtml +21 -0
  134. app/design/frontend/base/default/template/computop/checkout/paypal/review.phtml +130 -0
  135. app/design/frontend/base/default/template/computop/checkout/paypal/review/details.phtml +52 -0
  136. app/design/frontend/base/default/template/computop/checkout/paypal/shortcut.phtml +20 -0
  137. app/design/frontend/base/default/template/computop/form/cc.phtml +19 -0
  138. app/design/frontend/base/default/template/computop/form/directpay.phtml +35 -0
  139. app/design/frontend/base/default/template/computop/form/eft.phtml +32 -0
  140. app/design/frontend/base/default/template/computop/form/giropay.phtml +35 -0
  141. app/design/frontend/base/default/template/computop/form/ideal.phtml +19 -0
  142. app/design/frontend/base/default/template/computop/form/mpass.phtml +21 -0
  143. app/design/frontend/base/default/template/computop/form/paypalstandard.phtml +16 -0
  144. app/design/frontend/base/default/template/computop/info/callback.phtml +27 -0
  145. app/etc/modules/Dotsource_Computop.xml +16 -0
  146. app/etc/modules/Dotsource_Dsrevision.xml +20 -0
  147. app/locale/de_DE/Dotsource_Computop.csv +189 -0
  148. package.xml +27 -0
  149. skin/frontend/base/default/images/computop/computop_cc/computop_american_express.png +0 -0
  150. skin/frontend/base/default/images/computop/computop_cc/computop_cartebleue.png +0 -0
  151. skin/frontend/base/default/images/computop/computop_cc/computop_dankort.png +0 -0
  152. skin/frontend/base/default/images/computop/computop_cc/computop_jcb.png +0 -0
  153. skin/frontend/base/default/images/computop/computop_cc/computop_maestro.png +0 -0
  154. skin/frontend/base/default/images/computop/computop_cc/computop_mastercard.png +0 -0
  155. skin/frontend/base/default/images/computop/computop_cc/computop_mastercard_secure_code.png +0 -0
  156. skin/frontend/base/default/images/computop/computop_cc/computop_verified_by_visa.png +0 -0
  157. skin/frontend/base/default/images/computop/computop_cc/computop_visa.png +0 -0
  158. skin/frontend/base/default/images/computop/computop_directpay.gif +0 -0
  159. skin/frontend/base/default/images/computop/computop_eft.gif +0 -0
  160. skin/frontend/base/default/images/computop/computop_giropay.gif +0 -0
  161. skin/frontend/base/default/images/computop/computop_ideal.gif +0 -0
  162. skin/frontend/base/default/images/computop/computop_mpass.gif +0 -0
  163. skin/frontend/base/default/images/computop/computop_o2.gif +0 -0
  164. skin/frontend/base/default/images/computop/computop_paypal.gif +0 -0
  165. skin/frontend/base/default/images/computop/computop_vodafone.gif +0 -0
DEPLOYED_REVISION ADDED
@@ -0,0 +1,2 @@
1
+ Date: 2010-09-01 16:45
2
+ Revision: 16623
app/code/community/Dotsource/Computop/Block/Adminhtml/Block/Sales/Order/Grid.php ADDED
@@ -0,0 +1,130 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ */
10
+ class Dotsource_Computop_Block_Adminhtml_Block_Sales_Order_Grid
11
+ extends Mage_Adminhtml_Block_Sales_Order_Grid
12
+ {
13
+
14
+ /**
15
+ * Extends the order grid cols.
16
+ */
17
+ protected function _prepareColumns()
18
+ {
19
+ //Only need for magento version < 1.4.1.0
20
+ if ($this->_getHelper()->getFeatureHelper()->hasGridTables()) {
21
+ return parent::_prepareColumns();
22
+ }
23
+
24
+ //Add the computop RefNr
25
+ $this->addColumnAfter('computop_transaction_id',
26
+ array(
27
+ 'header' => 'CT RefNr',
28
+ 'title' => 'Computop Reference Number',
29
+ 'index' => 'computop_transaction_id',
30
+ 'type' => 'text',
31
+ 'width' => '65px',
32
+ 'renderer' => 'computop/widget_grid_column_renderer_zerofill',
33
+ 'filter_condition_callback' => array($this, '_filterComputopTransactionId')
34
+ ),
35
+ 'real_order_id'
36
+ );
37
+
38
+ //Add the magentodefault cols
39
+ return parent::_prepareColumns();
40
+ }
41
+
42
+
43
+ /**
44
+ * Extends the collection with the computop_transaction_id attribute from the
45
+ * order payment entity.
46
+ */
47
+ protected function _prepareCollection()
48
+ {
49
+ //Only need for magento version < 1.4.1.0
50
+ if ($this->_getHelper()->getFeatureHelper()->hasGridTables()) {
51
+ return parent::_prepareCollection();
52
+ }
53
+
54
+ //Default magento logic
55
+ $collection = Mage::getResourceModel('sales/order_collection')
56
+ ->addAttributeToSelect('*')
57
+ ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
58
+ ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
59
+ ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
60
+ ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
61
+ ->addExpressionAttributeToSelect('billing_name',
62
+ 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
63
+ array('billing_firstname', 'billing_lastname'))
64
+ ->addExpressionAttributeToSelect('shipping_name',
65
+ 'CONCAT({{shipping_firstname}}, IFNULL(CONCAT(\' \', {{shipping_lastname}}), \'\'))',
66
+ array('shipping_firstname', 'shipping_lastname'));
67
+
68
+
69
+ //Join the EAV attribute
70
+ $attributeModel = Mage::getModel('eav/config');
71
+ $refNrAttribute = $attributeModel->getAttribute('order_payment', 'computop_transaction_id');
72
+
73
+ $collection->getSelect()
74
+ ->joinLeft( //Join the payment entity id
75
+ array('payment' => $collection->getTable('sales/order_entity')),
76
+ 'e.entity_id=payment.parent_id AND payment.entity_type_id=' . $refNrAttribute->getEntityTypeId(),
77
+ null
78
+ )
79
+ ->joinLeft( //Join the computop transaction id
80
+ array('ct_refnr' => $refNrAttribute->getBackendTable()),
81
+ 'payment.entity_id=ct_refnr.entity_id AND ct_refnr.attribute_id=' . $refNrAttribute->getId(),
82
+ array('computop_transaction_id' => 'ct_refnr.value')
83
+ );
84
+
85
+ //Add the sort order
86
+ switch($this->getParam($this->getVarNameSort())) {
87
+ case 'computop_transaction_id':
88
+ $sortOrder = trim(strtoupper($this->getParam($this->getVarNameDir())));
89
+
90
+ if (Zend_Db_Select::SQL_DESC == $sortOrder) {
91
+ $sortOrder = Zend_Db_Select::SQL_DESC;
92
+ } else {
93
+ $sortOrder = Zend_Db_Select::SQL_ASC;
94
+ }
95
+
96
+ $collection->getSelect()->order("ct_refnr.value $sortOrder");
97
+ break;
98
+ }
99
+
100
+ $this->setCollection($collection);
101
+ return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
102
+ }
103
+
104
+
105
+ /**
106
+ * Filter callback for computop_transaction_id.
107
+ *
108
+ * @param unknown_type $collection
109
+ * @param unknown_type $column
110
+ */
111
+ protected function _filterComputopTransactionId($collection, $column)
112
+ {
113
+ if (!$value = $column->getFilter()->getValue()) {
114
+ return;
115
+ }
116
+
117
+ $collection->getSelect()->where('ct_refnr.value = ?', $value);
118
+ }
119
+
120
+
121
+ /**
122
+ * Return the computop helper.
123
+ *
124
+ * @return Dotsource_Computop_Helper_Data
125
+ */
126
+ protected function _getHelper()
127
+ {
128
+ return Mage::helper('computop');
129
+ }
130
+ }
app/code/community/Dotsource/Computop/Block/Adminhtml/Notification/Secureurl.php ADDED
@@ -0,0 +1,76 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ */
10
+ class Dotsource_Computop_Block_Adminhtml_Notification_Secureurl
11
+ extends Mage_Adminhtml_Block_Notification_Baseurl
12
+ {
13
+
14
+ /**
15
+ * @see Mage_Adminhtml_Block_Notification_Baseurl::getConfigUrl()
16
+ *
17
+ * @return string
18
+ */
19
+ public function getConfigUrl()
20
+ {
21
+ //Holds the route to the setting
22
+ $route = 'adminhtml/system_config/edit';
23
+ $param = array('section' => 'web');
24
+
25
+ //check for default settings
26
+ $defaultSecureUrl = (string) Mage::getConfig()->getNode('default/'.Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);
27
+
28
+ if (!$this->_getHelper()->isHttpsUrl($defaultSecureUrl)) {
29
+ return $this->getUrl($route, $param);
30
+ }
31
+
32
+ //Find all secure urls for checking the https
33
+ /* @var $dataCollection Mage_Core_Model_Mysql4_Config_Data_Collection */
34
+ $dataCollection = Mage::getResourceModel('core/config_data_collection')
35
+ ->addFieldToFilter('path', array('eq' => Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL));
36
+
37
+ //Add filter for start with https
38
+ $dataCollection
39
+ ->getSelect()
40
+ ->where(new Zend_Db_Expr("LOWER(main_table.value) NOT LIKE ?"), 'https://%')
41
+ ->limit(1);
42
+
43
+ //Check for the right section
44
+ foreach ($dataCollection as $data) {
45
+ //Check if the given url is an https url
46
+ if ($this->_getHelper()->isHttpsUrl($data->getValue())) {
47
+ continue;
48
+ }
49
+
50
+ //Build the right url
51
+ switch ($data->getScope()) {
52
+ case 'default' :
53
+ return $this->getUrl($route, $param);
54
+ case 'stores' :
55
+ $param['store'] = Mage::app()->getStore($data->getScopeId())->getCode();
56
+ return $this->getUrl($route, $param);
57
+ case 'websites' :
58
+ $param['website'] = Mage::app()->getWebsite($data->getScopeId())->getCode();
59
+ return $this->getUrl($route, $param);
60
+ }
61
+ }
62
+
63
+ return "";
64
+ }
65
+
66
+
67
+ /**
68
+ * Return the computop helper.
69
+ *
70
+ * @return Dotsource_Computop_Helper_Data
71
+ */
72
+ protected function _getHelper()
73
+ {
74
+ return Mage::helper('computop');
75
+ }
76
+ }
app/code/community/Dotsource/Computop/Block/Adminhtml/Sales/Order/View.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ */
10
+ class Dotsource_Computop_Block_Adminhtml_Sales_Order_View
11
+ extends Mage_Adminhtml_Block_Sales_Order_View
12
+ {
13
+
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+
18
+ //Only need for computop payment
19
+ if (!$this->getOrder()->getPayment()->getMethodInstance() instanceof Dotsource_Computop_Model_Payment_Abstract) {
20
+ return;
21
+ }
22
+
23
+ //Refresh the onclick message
24
+ if ($this->_hasButton('order_cancel')) {
25
+ $message = Mage::helper('computop')->__(
26
+ 'Are you sure you want to cancel this order and refund an amount of %s?',
27
+ $this->getOrder()->getPayment()->getMethodInstance()->getCancelAmount($this->getOrder(), true)
28
+ );
29
+
30
+ $this->_updateButton('order_cancel', 'onclick', 'deleteConfirm(\''.$message.'\', \'' . $this->getCancelUrl() . '\')');
31
+ }
32
+ }
33
+
34
+
35
+ /**
36
+ * Return true if the given button already exists.
37
+ *
38
+ * @param string $id
39
+ * @return boolean
40
+ */
41
+ protected function _hasButton($id)
42
+ {
43
+ foreach ($this->_buttons as $level => $buttons) {
44
+ if (isset($buttons[$id])) {
45
+ return true;
46
+ }
47
+ }
48
+
49
+ return false;
50
+ }
51
+
52
+
53
+ /**
54
+ * Return the button data from the given button id.
55
+ *
56
+ * @param string $id
57
+ * @return array
58
+ */
59
+ protected function _getButtonData($id)
60
+ {
61
+ foreach ($this->_buttons as $level => $buttons) {
62
+ if (isset($buttons[$id])) {
63
+ return $buttons[$id];
64
+ }
65
+ }
66
+
67
+ return array();
68
+ }
69
+ }
app/code/community/Dotsource/Computop/Block/Adminhtml/Sales/Order/View/Tab/Action.php ADDED
@@ -0,0 +1,281 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Created:
8
+ * 05.05.2010 14:44:15
9
+ *
10
+ * Contributors:
11
+ * dcarl - initial contents
12
+ */
13
+
14
+ /**
15
+ * Order Shipments grid
16
+ *
17
+ * @category Mage
18
+ * @package Mage_Adminhtml
19
+ * @author Magento Core Team <core@magentocommerce.com>
20
+ */
21
+ class Dotsource_Computop_Block_Adminhtml_Sales_Order_View_Tab_Action
22
+ extends Mage_Adminhtml_Block_Widget_Grid
23
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
24
+ {
25
+
26
+ public function __construct()
27
+ {
28
+ parent::__construct();
29
+ $this->setId('computop_action');
30
+ $this->setDefaultSort('created_at');
31
+ $this->setDefaultDir('desc');
32
+ $this->setUseAjax(true);
33
+ }
34
+
35
+
36
+ /**
37
+ * Prepares the collection to be sholwn in the computop action grid.
38
+ *
39
+ * @return Mage_Adminhtml_Block_Widget_Grid
40
+ */
41
+ protected function _prepareCollection()
42
+ {
43
+ /* @var $collection Dotsource_Computop_Model_Mysql4_Action_Collection */
44
+ $collection = Mage::getResourceModel('computop/action_collection');
45
+ $collection
46
+ ->addFieldToFilter(
47
+ 'transaction_id',
48
+ $this->_getComputopTransactionId()
49
+ );
50
+
51
+ $this->setCollection($collection);
52
+ return parent::_prepareCollection();
53
+ }
54
+
55
+
56
+ /**
57
+ * Override for format the transaction number.
58
+ *
59
+ * @return unknown
60
+ */
61
+ protected function _afterLoadCollection()
62
+ {
63
+ //Format the as transaction_id as transaction_code
64
+ foreach ($this->getCollection() as $item) {
65
+ $item->setData(
66
+ 'transaction_code',
67
+ sprintf("%09s", $this->_getHelper()->getConverter()->formatAsTransactionCode(
68
+ $item->getData('transaction_id')
69
+ ))
70
+ );
71
+ }
72
+
73
+ //Process parent action
74
+ parent::_afterLoadCollection();
75
+
76
+ return $this;
77
+ }
78
+
79
+
80
+ /**
81
+ * Prepares the backend grid that shows the computop transactions
82
+ * of the current order.
83
+ *
84
+ * @return Mage_Adminhtml_Block_Widget_Grid
85
+ */
86
+ protected function _prepareColumns()
87
+ {
88
+ $this->addColumn(
89
+ 'transaction_code',
90
+ array(
91
+ 'header' => Mage::helper('computop')->__('RefNr'),
92
+ 'index' => 'transaction_code',
93
+ )
94
+ );
95
+
96
+ $this->addColumn(
97
+ 'request_payid',
98
+ array(
99
+ 'header' => Mage::helper('computop')->__('Request PayID'),
100
+ 'index' => 'request_payid',
101
+ )
102
+ );
103
+
104
+ $this->addColumn(
105
+ 'response_payid',
106
+ array(
107
+ 'header' => Mage::helper('computop')->__('Response PayID'),
108
+ 'index' => 'response_payid',
109
+ )
110
+ );
111
+
112
+ $this->addColumn(
113
+ 'action',
114
+ array(
115
+ 'header' => Mage::helper('computop')->__('Action'),
116
+ 'index' => 'action',
117
+ )
118
+ );
119
+
120
+ $this->addColumn(
121
+ 'created_at',
122
+ array(
123
+ 'header' => Mage::helper('computop')->__('Created At'),
124
+ 'index' => 'created_at',
125
+ 'type' => 'datetime'
126
+ )
127
+ );
128
+
129
+ $this->addColumn(
130
+ 'error_description',
131
+ array(
132
+ 'header' => Mage::helper('computop')->__('Description'),
133
+ 'index' => 'error_description',
134
+ 'frame_callback' => array($this, 'decorateErrorDescription')
135
+ )
136
+ );
137
+
138
+ $this->addColumn(
139
+ 'error_code',
140
+ array(
141
+ 'header' => Mage::helper('computop')->__('Error Code'),
142
+ 'index' => 'error_code',
143
+ 'width' => '50px',
144
+ )
145
+ );
146
+
147
+ $this->addColumn(
148
+ 'error',
149
+ array(
150
+ 'header' => Mage::helper('computop')->__('Successful'),
151
+ 'index' => 'error',
152
+ 'type' => 'options',
153
+ 'options' => array(
154
+ 1 => $this->__('No'),
155
+ 0 => $this->__('Yes')
156
+ ),
157
+ 'frame_callback' => array($this, 'decorateError')
158
+ )
159
+ );
160
+
161
+ return parent::_prepareColumns();
162
+ }
163
+
164
+
165
+ /**
166
+ * Decorate error column values
167
+ *
168
+ * @param string $value
169
+ * @param Dotsource_Computop_Model_Action $row
170
+ * @param Mage_Adminhtml_Block_Widget_GridColumn $column
171
+ * @param boolean $isExport
172
+ * @return string
173
+ */
174
+ public function decorateError($value, $row, $column, $isExport)
175
+ {
176
+ if (isset($this->_invalidatedTypes[$row->getId()])) {
177
+ $cell = '<span class="grid-severity-minor"><span>'.$this->__('Invalidated').'</span></span>';
178
+ } else {
179
+ if ($row->getError()) {
180
+ $cell = '<span class="grid-severity-critical"><span>'.$value.'</span></span>';
181
+ } else {
182
+ $cell = '<span class="grid-severity-notice"><span>'.$value.'</span></span>';
183
+ }
184
+ }
185
+ return $cell;
186
+ }
187
+
188
+
189
+ /**
190
+ * Truncates the content of the error_description column.
191
+ *
192
+ * @param string $value
193
+ * @param Dotsource_Computop_Model_Action $row
194
+ * @param Mage_Adminhtml_Block_Widget_GridColumn $column
195
+ * @param boolean $isExport
196
+ * @return string
197
+ */
198
+ public function decorateErrorDescription($value, $row, $column, $isExport)
199
+ {
200
+ $noNeed = '';
201
+ return Mage::helper('core/string')->truncate($value, 255, '...', $noNeed, false);
202
+ }
203
+
204
+
205
+ /**
206
+ * Retreives teh grid url that is used for resorting and searching
207
+ * in the action grid.
208
+ *
209
+ * @return string
210
+ */
211
+ public function getGridUrl()
212
+ {
213
+ return $this->getUrl('computop/adminhtml_action/grid', array('_current' => true));
214
+ }
215
+
216
+
217
+ /**
218
+ * Retrieves the label for the tab in the sales view.
219
+ *
220
+ * @return string
221
+ */
222
+ public function getTabLabel()
223
+ {
224
+ return Mage::helper('computop')->__('Computop Transaction');
225
+ }
226
+
227
+
228
+ /**
229
+ * Retrieves the title for the tab in the sales view.
230
+ *
231
+ * @return string
232
+ */
233
+ public function getTabTitle()
234
+ {
235
+ return Mage::helper('computop')->__('Computop Transaction');
236
+ }
237
+
238
+
239
+ /**
240
+ * Indicates if it's possilbe to show the tab.
241
+ *
242
+ * @return boolean
243
+ */
244
+ public function canShowTab()
245
+ {
246
+ return true;
247
+ }
248
+
249
+
250
+ /**
251
+ * Indicates if the tab should be hidden.
252
+ *
253
+ * @return boolean
254
+ */
255
+ public function isHidden()
256
+ {
257
+ return false;
258
+ }
259
+
260
+
261
+ /**
262
+ * Retrieves the transaction id of the computop transaction.
263
+ *
264
+ * @return integer
265
+ */
266
+ protected function _getComputopTransactionId()
267
+ {
268
+ return (int)Mage::registry('current_order')->getPayment()->getComputopTransactionId();
269
+ }
270
+
271
+
272
+ /**
273
+ * Return the computop helper.
274
+ *
275
+ * @return Dotsource_Computop_Helper_Data
276
+ */
277
+ protected function _getHelper()
278
+ {
279
+ return Mage::helper('computop');
280
+ }
281
+ }
app/code/community/Dotsource/Computop/Block/Checkout/Iframe.php ADDED
@@ -0,0 +1,15 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ */
10
+
11
+ class Dotsource_Computop_Block_Checkout_Iframe
12
+ extends Mage_Core_Block_Template
13
+ {
14
+
15
+ }
app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Review.php ADDED
@@ -0,0 +1,195 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Created:
8
+ * 18.05.2010 10:27:46
9
+ *
10
+ * Contributors:
11
+ * dcarl - initial contents
12
+ */
13
+
14
+ class Dotsource_Computop_Block_Checkout_Paypal_Review
15
+ extends Mage_Core_Block_Template
16
+ {
17
+ /**
18
+ * Holds the current processed quote.
19
+ *
20
+ * @var Mage_Sales_Model_Quote
21
+ */
22
+ protected $_quote;
23
+
24
+ /**
25
+ * Paypal action prefix.
26
+ *
27
+ * @var string
28
+ */
29
+ protected $_paypalActionPrefix = 'paypal';
30
+
31
+ /**
32
+ * Holds the address based on the shipping address.
33
+ *
34
+ * @var Mage_Sales_Model_Quote_Address
35
+ */
36
+ protected $_address;
37
+
38
+ /**
39
+ * Holds the shippingsrates as array.
40
+ *
41
+ * @var array
42
+ */
43
+ protected $_rates;
44
+
45
+
46
+ /**
47
+ * Set quote for internal use.
48
+ *
49
+ * @param Mage_Sales_Model_Quote $quote
50
+ * @return Dotsource_Computop_Block_Checkout_Paypal_Review
51
+ */
52
+ public function setQuote(Mage_Sales_Model_Quote $quote)
53
+ {
54
+ $this->_quote = $quote;
55
+ return $this;
56
+ }
57
+
58
+
59
+ /**
60
+ * Retrieves the billing address of the current quote.
61
+ *
62
+ * @return Mage_Sales_Model_Quote_Address|false
63
+ */
64
+ public function getBillingAddress()
65
+ {
66
+ return $this->_quote->getBillingAddress();
67
+ }
68
+
69
+
70
+ /**
71
+ * Retrieves the shipping address of the current quote.
72
+ *
73
+ * @return Mage_Sales_Model_Quote_Address|false
74
+ */
75
+ public function getShippingAddress()
76
+ {
77
+ if ($this->_quote->getIsVirtual()) {
78
+ return false;
79
+ }
80
+ return $this->_quote->getShippingAddress();
81
+ }
82
+
83
+
84
+ /**
85
+ * Return address base on quote shipping address
86
+ *
87
+ * @return Mage_Sales_Quote_Address
88
+ */
89
+ public function getAddress()
90
+ {
91
+ if (null === $this->_address) {
92
+ $this->_address = $this->_quote->getShippingAddress();
93
+ }
94
+ return $this->_address;
95
+ }
96
+
97
+
98
+ /**
99
+ * Retrieves the shipping rates.
100
+ *
101
+ * @return array
102
+ */
103
+ public function getShippingRates()
104
+ {
105
+ if (null === $this->_rates) {
106
+ $this->_rates = (array)$this->getAddress()->getGroupedAllShippingRates();
107
+ }
108
+ return $this->_rates;
109
+ }
110
+
111
+
112
+ /**
113
+ * Retrieves carrier name from config, base on carrier code
114
+ *
115
+ * @param $carrierCode string
116
+ * @return string
117
+ */
118
+ public function getCarrierName($carrierCode)
119
+ {
120
+ if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title')) {
121
+ return $name;
122
+ }
123
+ return $carrierCode;
124
+ }
125
+
126
+
127
+ /**
128
+ * get shipping method
129
+ *
130
+ * @return string
131
+ */
132
+ public function getAddressShippingMethod()
133
+ {
134
+ return $this->getAddress()->getShippingMethod();
135
+ }
136
+
137
+
138
+ /**
139
+ * Retrieves the formated shipping price.
140
+ *
141
+ * @param float $price
142
+ * @param boolean $flag
143
+ *
144
+ * @return string
145
+ */
146
+ public function getShippingPrice($price, $flag)
147
+ {
148
+ return $this->formatPrice($this->helper('tax')->getShippingPrice($price, $flag, $this->getAddress()));
149
+ }
150
+
151
+
152
+ /**
153
+ * Format price base on store convert price method.
154
+ *
155
+ * @param float $price
156
+ * @return string
157
+ */
158
+ public function formatPrice($price)
159
+ {
160
+ return $this->_quote->getStore()->convertPrice($price, true);
161
+ }
162
+
163
+
164
+ /**
165
+ * Indicates if the quote is virtual.
166
+ *
167
+ * @return boolean
168
+ */
169
+ public function isVirtual()
170
+ {
171
+ return (bool)$this->_quote->getIsVirtual();
172
+ }
173
+
174
+
175
+ /**
176
+ * Retrieves the url to the saveShippingMethodAction.
177
+ *
178
+ * @return string
179
+ */
180
+ public function getSaveShippingMethodUrl()
181
+ {
182
+ return $this->getUrl('computop/callback_paypalexpress/saveShippingMethod');
183
+ }
184
+
185
+
186
+ /**
187
+ * Retrieves the url to the saveShippingMethodAction.
188
+ *
189
+ * @return string
190
+ */
191
+ public function getPlaceOrderUrl()
192
+ {
193
+ return $this->getUrl('computop/callback_paypalexpress/placeOrder');
194
+ }
195
+ }
app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Review/Details.php ADDED
@@ -0,0 +1,41 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Created:
8
+ * 18.05.2010 14:31:10
9
+ *
10
+ * Contributors:
11
+ * dcarl - initial contents
12
+ */
13
+
14
+ class Dotsource_Computop_Block_Checkout_Paypal_Review_Details
15
+ extends Mage_Checkout_Block_Cart_Totals
16
+ {
17
+ protected $_address;
18
+
19
+ /**
20
+ * Return review shipping address
21
+ *
22
+ * @return Mage_Sales_Model_Order_Address
23
+ */
24
+ public function getAddress()
25
+ {
26
+ if (empty($this->_address)) {
27
+ $this->_address = $this->getQuote()->getShippingAddress();
28
+ }
29
+ return $this->_address;
30
+ }
31
+
32
+ /**
33
+ * Return review quote totals
34
+ *
35
+ * @return array
36
+ */
37
+ public function getTotals()
38
+ {
39
+ return $this->getQuote()->getTotals();
40
+ }
41
+ }
app/code/community/Dotsource/Computop/Block/Checkout/Paypal/Shortcut.php ADDED
@@ -0,0 +1,85 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Created:
8
+ * 17.05.2010 10:27:46
9
+ *
10
+ * Contributors:
11
+ * dcarl - initial contents
12
+ */
13
+
14
+ class Dotsource_Computop_Block_Checkout_Paypal_Shortcut
15
+ extends Mage_Core_Block_Template
16
+ {
17
+
18
+
19
+ /**
20
+ * Retreives the paypal express chechout url.
21
+ *
22
+ * @return string
23
+ */
24
+ public function getCheckoutUrl()
25
+ {
26
+ return $this->getUrl('computop/callback_paypalexpress/start');
27
+ }
28
+
29
+
30
+ /**
31
+ * Get checkout button image url.
32
+ *
33
+ * @return string
34
+ */
35
+ public function getImageUrl()
36
+ {
37
+ return Mage::getModel(
38
+ 'paypal/express_checkout',
39
+ array(
40
+ 'quote' => Mage::getSingleton('checkout/session')->getQuote(),
41
+ 'config' => $this->_getMethod()->getConfig(),
42
+ )
43
+ )->getCheckoutShortcutImageUrl();
44
+ }
45
+
46
+
47
+ /**
48
+ * Check whether method is available and render HTML.
49
+ *
50
+ * @return string
51
+ */
52
+ protected function _toHtml()
53
+ {
54
+ if ($this->_getHelper()->isGlobalActive(true)) {
55
+ $method = $this->_getMethod();
56
+ if ($method && $method->getConfigData('active')) {
57
+ return parent::_toHtml();
58
+ }
59
+ }
60
+
61
+ return '';
62
+ }
63
+
64
+
65
+ /**
66
+ * Retrieve payment method model.
67
+ *
68
+ * @return Dotsource_Computop_Model_Payment_Paypalexpress
69
+ */
70
+ protected function _getMethod()
71
+ {
72
+ return Mage::getModel('computop/payment_paypalexpress');
73
+ }
74
+
75
+
76
+ /**
77
+ * Return the computop helper.
78
+ *
79
+ * @return Dotsource_Computop_Helper_Data
80
+ */
81
+ protected function _getHelper()
82
+ {
83
+ return Mage::helper('computop');
84
+ }
85
+ }
app/code/community/Dotsource/Computop/Block/Config/Form/Abstract.php ADDED
@@ -0,0 +1,265 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ **/
10
+
11
+ class Dotsource_Computop_Block_Config_Form_Abstract
12
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
13
+ {
14
+
15
+ /**
16
+ * @see Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract::addColumn()
17
+ *
18
+ * @param string $name
19
+ * @param array $params
20
+ */
21
+ public function addColumn($name, $params)
22
+ {
23
+ //check for multi html elements in one column
24
+ if ($this->_hasMultipleElementsInColumn($params)) {
25
+ $multipleElements = array();
26
+
27
+ foreach ($params as $columnPart) {
28
+ if (is_array($columnPart)) {
29
+ $this->addColumn($name, $columnPart);
30
+ $multipleElements[] = $this->_columns[$name];
31
+ unset($this->_columns[$name]);
32
+ }
33
+ }
34
+
35
+ //Set the column attributes
36
+ foreach ($params as $key => $value) {
37
+ if ($this->_isColumnAttribute($key)) {
38
+ $multipleElements[$key] = $value;
39
+ }
40
+ }
41
+
42
+ //Set the multiple columns
43
+ $this->_columns[$name] = $multipleElements;
44
+
45
+ return;
46
+ }
47
+
48
+
49
+ //First do the parent stuff
50
+ parent::addColumn($name, $params);
51
+
52
+ $hasInputType = array_key_exists('input-type', $params) && !empty($params['input-type']);
53
+ $hasValidation = array_key_exists('validate', $params) && !empty($params['validate']);
54
+ $hasMultipleSelect = array_key_exists('multiple-select', $params) && is_bool($params['multiple-select']);
55
+ $hasValues = array_key_exists('values', $params)
56
+ && !empty($params['values'])
57
+ && is_array($params['values']);
58
+ //Content before or after the element
59
+ $hasContentBefor = array_key_exists('content-before-element', $params) && !empty($params['content-before-element']);
60
+ $hasContentAfter = array_key_exists('content-after-element', $params) && !empty($params['content-after-element']);
61
+
62
+ //Check for column title
63
+ $hasTitle = array_key_exists('title', $params) && !empty($params['title']);
64
+
65
+ //Check for an other name for the form element
66
+ $hasName = array_key_exists('name', $params) && !empty($params['name']);
67
+
68
+ //Join the old an the new settings
69
+ $this->_columns[$name] = array_merge($this->_columns[$name], array(
70
+ 'input-type' => ($hasInputType)? $params['input-type'] : 'text',
71
+ 'multiple-select' => ($hasMultipleSelect)? $params['multiple-select'] : false,
72
+ 'values' => ($hasValues)? $params['values'] : array(),
73
+ 'validate' => ($hasValidation)? $params['validate'] : '',
74
+ 'content-before-element' => ($hasContentBefor)? $params['content-before-element'] : '',
75
+ 'content-after-element' => ($hasContentAfter)? $params['content-after-element'] : '',
76
+ 'title' => ($hasTitle)? $params['title'] : '',
77
+ 'name' => ($hasName)? $params['name'] : '',
78
+ ));
79
+ }
80
+
81
+
82
+ /**
83
+ * @see Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract::_renderCellTemplate()
84
+ *
85
+ * @param string $columnName
86
+ * @return string
87
+ */
88
+ protected function _renderCellTemplate($columnName)
89
+ {
90
+ if (empty($this->_columns[$columnName])) {
91
+ throw new Exception('Wrong column name specified.');
92
+ }
93
+
94
+ $column = $this->_columns[$columnName];
95
+
96
+ //Check for multi html elements in one column
97
+ if ($this->_hasMultipleElementsInColumn($column)) {
98
+ $defaultColumn = $column;
99
+ $htmlCode = '';
100
+
101
+ foreach ($column as $columnPart) {
102
+ if (is_array($columnPart)) {
103
+ $this->_columns[$columnName] = $columnPart;
104
+ $htmlCode .= $this->_renderCellTemplate($columnName);
105
+ unset($this->_columns[$columnName]);
106
+ }
107
+ }
108
+
109
+ //Set the multiple columns
110
+ $this->_columns[$columnName] = $defaultColumn;
111
+ return $htmlCode;
112
+ }
113
+
114
+ //Check for custom name
115
+ if (array_key_exists('name', $column) && !empty($column['name'])) {
116
+ $columnName = $column['name'];
117
+ }
118
+
119
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
120
+
121
+ if (array_key_exists('renderer', $column) && $column['renderer']) {
122
+ return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column)
123
+ ->toHtml();
124
+ }
125
+
126
+ //Build the input
127
+ $input = "";
128
+
129
+ if (array_key_exists('content-before-element', $column)) {
130
+ $input = $column['content-before-element'];
131
+ }
132
+
133
+ $input .= '<input name="'. $inputName .'" value="#{'. $columnName .'}"';
134
+
135
+ //Set type
136
+ if (array_key_exists('input-type', $column) && !empty($column['input-type'])) {
137
+ $input .= ' type="'. $column['input-type'] .'" ';
138
+ }
139
+
140
+ //Set size
141
+ if (array_key_exists('size', $column) && !empty($column['size'])) {
142
+ $input .= ' size="'. $column['size'] .'" ';
143
+ }
144
+
145
+ $hasClass = array_key_exists('class', $column) && !empty($column['class']);
146
+ $hasValidation = array_key_exists('validate', $column) && !empty($column['validate']);
147
+
148
+ //Start class tag
149
+ $input .= ' class="';
150
+
151
+ //Add the class
152
+ if ($hasClass) {
153
+ $input .= " {$column['class']} ";
154
+ } else {
155
+ //Add default
156
+ $input .= ' input-text ';
157
+ }
158
+
159
+ //Add validation
160
+ if ($hasValidation) {
161
+ $input .= " {$column['validate']} ";
162
+ }
163
+
164
+ //End class
165
+ $input .= '" ';
166
+
167
+ //Add style
168
+ if (array_key_exists('style', $column) && !empty($column['style'])) {
169
+ $input .= ' style="'. $column['style'] .'"';
170
+ }
171
+
172
+ //End input
173
+ $input .= ' />';
174
+
175
+ //Add the after html
176
+ if (array_key_exists('content-after-element', $column)) {
177
+ $input .= $column['content-after-element'];
178
+ }
179
+
180
+ //Return the input
181
+ return $input;
182
+ }
183
+
184
+
185
+ /**
186
+ * Check if the given $column has multiple html elements.
187
+ *
188
+ * @param array $columnName
189
+ */
190
+ protected function _hasMultipleElementsInColumn($column)
191
+ {
192
+ //check if we can work with the given data
193
+ if (!is_array($column) || empty($column)) {
194
+ return false;
195
+ }
196
+
197
+ //If all children an array we have multiple elements
198
+ foreach ($column as $key => $testColumn) {
199
+ if ((!$this->_isColumnAttribute($key) && !is_array($testColumn))) {
200
+ return false;
201
+ }
202
+ }
203
+
204
+ return true;
205
+ }
206
+
207
+
208
+ /**
209
+ * Check if the given key is an column attribute.
210
+ *
211
+ * @param string $key
212
+ * @return boolean
213
+ */
214
+ protected function _isColumnAttribute($key) {
215
+ $attributes = array('label', 'title');
216
+
217
+ return in_array($key, $attributes);
218
+ }
219
+
220
+
221
+ /**
222
+ * Return all elements from the form.
223
+ *
224
+ * @param array $columns
225
+ * @param array $collectedElements
226
+ * @return array
227
+ */
228
+ public function getAllFormElements(array $columns = array())
229
+ {
230
+ //Element for collecting all html elements
231
+ if (empty($columns)) {
232
+ $columns = $this->_columns;
233
+ }
234
+
235
+ $collectedElements = array();
236
+
237
+ //Iterate over all columns
238
+ foreach ($columns as $column) {
239
+ //Check for multi elements in column
240
+ if ($this->_hasMultipleElementsInColumn($column)) {
241
+ foreach ($column as $columnPart) {
242
+ if (is_array($columnPart) && !empty($columnPart)) {
243
+ $collectedElements = array_merge($collectedElements, $this->getAllFormElements(array($columnPart)));
244
+ }
245
+ }
246
+ } else {
247
+ //Normal element
248
+ $collectedElements[] = $column;
249
+ }
250
+ }
251
+
252
+ return $collectedElements;
253
+ }
254
+
255
+
256
+ /**
257
+ * Return the computop helper
258
+ *
259
+ * @return Dotsource_Computop_Helper_Data
260
+ */
261
+ protected function _getHelper()
262
+ {
263
+ return Mage::helper('computop');
264
+ }
265
+ }
app/code/community/Dotsource/Computop/Block/Config/Form/Merchant.php ADDED
@@ -0,0 +1,76 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ **/
10
+
11
+ class Dotsource_Computop_Block_Config_Form_Merchant
12
+ extends Dotsource_Computop_Block_Config_Form_Abstract
13
+ {
14
+
15
+ public function __construct()
16
+ {
17
+ //Country for option key mapping
18
+ $this->addColumn('currency', array(
19
+ 'label' => $this->_getHelper()->__('Currency'),
20
+ 'title' => $this->_getHelper()->__('Currency'),
21
+ 'style' => 'width:160px',
22
+ 'renderer' => new Dotsource_Computop_Block_Config_Form_Renderer_Select(),
23
+ 'values' => Mage::getSingleton('adminhtml/system_config_source_currency')->toOptionArray(true),
24
+ 'class' => 'currency',
25
+ 'validate' => 'validate-select',
26
+ ));
27
+
28
+ //Merchant id
29
+ $this->addColumn('id', array(
30
+ 'label' => $this->_getHelper()->__('Merchant ID'),
31
+ 'title' => $this->_getHelper()->__('Merchant ID'),
32
+ 'style' => 'width:100px',
33
+ 'validate' => 'required-entry',
34
+ ));
35
+
36
+ //Merchant password
37
+ $this->addColumn('password', array(
38
+ 'label' => $this->_getHelper()->__('Merchant Password'),
39
+ 'title' => $this->_getHelper()->__('Merchant Encryption Password'),
40
+ array(
41
+ 'name' => 'password',
42
+ 'style' => 'width:120px',
43
+ 'input-type' => 'password',
44
+ 'validate' => 'required-entry',
45
+ ),
46
+ array(
47
+ 'name' => 'original_password',
48
+ 'input-type' => 'hidden',
49
+ ))
50
+ );
51
+
52
+ //Merchant hmac
53
+ $this->addColumn('hmac', array(
54
+ 'label' => $this->_getHelper()->__('Merchant Hmac'),
55
+ 'title' => $this->_getHelper()->__('Merchant Hmac'),
56
+ array(
57
+ 'name' => 'hmac',
58
+ 'style' => 'width:120px',
59
+ 'input-type' => 'password',
60
+ 'validate' => 'required-entry',
61
+ ),
62
+ array(
63
+ 'name' => 'original_hmac',
64
+ 'input-type' => 'hidden',
65
+ ))
66
+ );
67
+
68
+ $this->_addAfter = false;
69
+ $this->_addButtonLabel = $this->_getHelper()->__('Add New Merchant');
70
+
71
+ parent::__construct();
72
+
73
+ //Set the right template
74
+ $this->setTemplate('computop/config/form/field/form.phtml');
75
+ }
76
+ }
app/code/community/Dotsource/Computop/Block/Config/Form/Renderer/Select.php ADDED
@@ -0,0 +1,166 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ **/
10
+
11
+ class Dotsource_Computop_Block_Config_Form_Renderer_Select
12
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
13
+ {
14
+
15
+ /**
16
+ * @see Mage_Core_Block_Template::_toHtml()
17
+ *
18
+ * @return string
19
+ */
20
+ protected function _toHtml()
21
+ {
22
+ $select = '';
23
+ $column = $this->getColumn();
24
+
25
+ //check for content before html element
26
+ if (array_key_exists('content-before-element', $column) && !empty($column['content-before-element'])) {
27
+ $select .= $column['content-before-element'];
28
+ }
29
+
30
+ //Is multiple select?
31
+ if ($this->isMultipleSelect()) {
32
+ $select .= '<select name="'. $this->getInputName() .'[]" ';
33
+ } else {
34
+ $select .= '<select name="'. $this->getInputName() .'" ';
35
+ }
36
+
37
+
38
+ //Multiple select?
39
+ if ($this->isMultipleSelect()) {
40
+ $select .= ' multiple="multiple"';
41
+ }
42
+
43
+ //Set size
44
+ if (array_key_exists('size', $column) && !empty($column['size'])) {
45
+ $select .= ' size="'. $column['size'] .'" ';
46
+ }
47
+
48
+ $hasClass = array_key_exists('class', $column) && !empty($column['class']);
49
+ $hasValidation = array_key_exists('validate', $column) && !empty($column['validate']);
50
+
51
+ //Start class tag
52
+ $select .= ' class="';
53
+
54
+ //Add the class
55
+ if ($hasClass) {
56
+ $select .= " {$column['class']} ";
57
+ } else {
58
+ //Add default
59
+ $select .= ' input-text ';
60
+ }
61
+
62
+ //Add validation
63
+ if ($hasValidation) {
64
+ $select .= " {$column['validate']} ";
65
+ }
66
+
67
+ //End class
68
+ $select .= '" ';
69
+
70
+ //Add style
71
+ if (array_key_exists('style', $column) && !empty($column['style'])) {
72
+ $select .= ' style="'. $column['style'] .'"';
73
+ }
74
+
75
+ //End the select
76
+ $select .= '>';
77
+
78
+ //Build the options
79
+ if (array_key_exists('values', $column)
80
+ && !empty($column['values'])
81
+ && is_array($column['values'])
82
+ ) {
83
+ foreach ($column['values'] as $country) {
84
+ $select .= '<option value="'.$country['value'].'">'.$country['label'].'</option>';
85
+ }
86
+ }
87
+
88
+ $select .= '</select>';
89
+
90
+ if (array_key_exists('content-after-element', $column) && !empty($column['content-after-element'])) {
91
+ $select .= $column['content-after-element'];
92
+ }
93
+
94
+ return $select;
95
+ }
96
+
97
+
98
+ /**
99
+ * Return true is the select is an multiple select box.
100
+ *
101
+ * @return boolean
102
+ */
103
+ public function isMultipleSelect()
104
+ {
105
+ //Get the column
106
+ $column = $this->getColumn();
107
+
108
+ //Get the result
109
+ return array_key_exists('multiple-select', $column)
110
+ && is_bool($column['multiple-select'])
111
+ && $column['multiple-select'];
112
+ }
113
+
114
+
115
+ /**
116
+ * Check if the select box has a class.
117
+ *
118
+ * @return boolean
119
+ */
120
+ public function hasClass()
121
+ {
122
+ //Get the column
123
+ $column = $this->getColumn();
124
+
125
+ //Build the result
126
+ return array_key_exists('class', $column)
127
+ && !empty($column['class']);
128
+ }
129
+
130
+
131
+ /**
132
+ * Return javascript code which call when a new element add to the form.
133
+ *
134
+ * @return string
135
+ */
136
+ public function getCodeForAddActionFormManipulation()
137
+ {
138
+ $column = $this->getColumn();
139
+ $columnName = $this->getColumnName();
140
+ $js = '';
141
+
142
+ if ($this->isMultipleSelect()) {
143
+ $js .= "var tmpObject = arrayToObject(templateData.$columnName);";
144
+ }
145
+
146
+ //Select the operator
147
+ $js .= "$(templateData._id).select('.{$column['class']} option').each(function(option) {";
148
+
149
+ //Build the
150
+ if ($this->isMultipleSelect()) {
151
+ $js .= "if (tmpObject[option.value] != undefined && tmpObject[option.value]) {";
152
+ $js .= "option.selected = true;";
153
+ $js .= "}";
154
+ } else {
155
+ $js .= "if (option.value == templateData.$columnName) {";
156
+ $js .= "option.selected = true;";
157
+ $js .= "return;";
158
+ $js .= "}";
159
+ }
160
+
161
+ $js .= "});";
162
+
163
+ //Return the javascript code
164
+ return $js;
165
+ }
166
+ }
app/code/community/Dotsource/Computop/Block/Form/Abstract.php ADDED
@@ -0,0 +1,93 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Created:
8
+ * 26.05.2010 14:48:25
9
+ *
10
+ * Contributors:
11
+ * dcarl - initial contents
12
+ */
13
+
14
+ abstract class Dotsource_Computop_Block_Form_Abstract
15
+ extends Mage_Payment_Block_Form
16
+ {
17
+
18
+ /**
19
+ * Holds the URL of the payment logo.
20
+ *
21
+ * @var string
22
+ */
23
+ protected $_logoUrl;
24
+
25
+
26
+ /**
27
+ * Holds the alt attribute of the payment logo.
28
+ *
29
+ * @var string
30
+ */
31
+ protected $_logoAlt;
32
+
33
+ protected function _construct()
34
+ {
35
+ parent::_construct();
36
+
37
+ //Add the logo to the payment method
38
+ $this->setMethodLabelAfterHtml($this->_getLogoHtml());
39
+ }
40
+
41
+
42
+ /**
43
+ * Retreives the html of the logo.
44
+ *
45
+ * @return string
46
+ */
47
+ protected function _getLogoHtml()
48
+ {
49
+ if (!$this->_getLogoUrl() || !Mage::helper('computop')->canShowPaymentLogo()) {
50
+ return '';
51
+ }
52
+ if ( is_array($this->_getLogoUrl()) ) {
53
+ $logoHtml = '';
54
+ foreach ( $this->_getLogoUrl() as $logoAlt => $logoUrl ) {
55
+ $logoHtml .= sprintf(
56
+ '<img src="%s" alt="%s" class="v-middle" />',
57
+ $logoUrl,
58
+ $logoAlt
59
+ );
60
+ }
61
+ if ( $logoHtml != '' ) {
62
+ return $logoHtml;
63
+ }
64
+ }
65
+ return sprintf(
66
+ '<img src="%s" alt="%s" class="v-middle" />',
67
+ $this->_getLogoUrl(),
68
+ $this->_getLogoAlt()
69
+ );
70
+ }
71
+
72
+
73
+ /**
74
+ * Retrieves the alt attribute for the logo of the payment method.
75
+ *
76
+ * @return string
77
+ */
78
+ protected function _getLogoAlt()
79
+ {
80
+ return $this->_logoAlt;
81
+ }
82
+
83
+
84
+ /**
85
+ * Retrieves the url to the logo of the payment method.
86
+ *
87
+ * @return string
88
+ */
89
+ protected function _getLogoUrl()
90
+ {
91
+ return $this->_logoUrl;
92
+ }
93
+ }
app/code/community/Dotsource/Computop/Block/Form/Cc.php ADDED
@@ -0,0 +1,193 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ */
10
+
11
+ class Dotsource_Computop_Block_Form_Cc
12
+ extends Dotsource_Computop_Block_Form_Abstract
13
+ {
14
+
15
+ const DANKORT_AVAIABLE_COUNTRY = 'DK';
16
+
17
+ const CARTE_BLEUE_NATIONALE_AVAIABLE_COUNTRY = 'FR';
18
+
19
+ /**
20
+ * add logos
21
+ * set template
22
+ *
23
+ */
24
+ protected function _construct()
25
+ {
26
+ $allLogos = Mage::getModel('computop/system_config_source_logos')->toOptionArray();
27
+ $availableLogos = explode(',', Mage::helper('computop/config')->getAvailableCcLogos());
28
+ foreach ( $allLogos as $logo ) {
29
+ if ( !isset($logo['value']) || !isset($logo['label']) || !isset($logo['file']) ) continue;
30
+ if ( in_array($logo['value'], $availableLogos) && $this->_isLogoAvailable($logo) )
31
+ $this->_logoUrl[$logo['label']] =
32
+ $this->getSkinUrl('images/computop/computop_cc/' . $logo['file']);
33
+ }
34
+ parent::_construct();
35
+ $this->setTemplate('computop/form/cc.phtml');
36
+ }
37
+
38
+ /**
39
+ * Retrieve payment configuration object.
40
+ *
41
+ * @return Mage_Payment_Model_Config
42
+ */
43
+ protected function _getConfig()
44
+ {
45
+ return Mage::getSingleton('payment/config');
46
+ }
47
+
48
+ /**
49
+ * Retrieve availables credit card types.
50
+ *
51
+ * @return array
52
+ */
53
+ public function getCcAvailableTypes()
54
+ {
55
+ $types = $this->_getConfig()->getCcTypes();
56
+ if ($method = $this->getMethod()) {
57
+ $availableTypes = $method->getConfigData('cctypes');
58
+ if ($availableTypes) {
59
+ $availableTypes = explode(',', $availableTypes);
60
+ foreach ($types as $code=>$name) {
61
+ if (!in_array($code, $availableTypes)) {
62
+ unset($types[$code]);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ return $types;
68
+ }
69
+
70
+ /**
71
+ * Retrieve credit card expire months.
72
+ *
73
+ * @return array
74
+ */
75
+ public function getCcMonths()
76
+ {
77
+ $months = $this->getData('cc_months');
78
+ if (is_null($months)) {
79
+ $months[0] = $this->__('Month');
80
+ $months = array_merge($months, $this->_getConfig()->getMonths());
81
+ $this->setData('cc_months', $months);
82
+ }
83
+ return $months;
84
+ }
85
+
86
+ /**
87
+ * Retrieve credit card expire years.
88
+ *
89
+ * @return array
90
+ */
91
+ public function getCcYears()
92
+ {
93
+ $years = $this->getData('cc_years');
94
+ if (is_null($years)) {
95
+ $years = $this->_getConfig()->getYears();
96
+ $years = array(0 => $this->__('Year')) + $years;
97
+ $this->setData('cc_years', $years);
98
+ }
99
+ return $years;
100
+ }
101
+
102
+ /**
103
+ * Retrive has verification configuration.
104
+ *
105
+ * @return boolean
106
+ */
107
+ public function hasVerification()
108
+ {
109
+ if ($this->getMethod()) {
110
+ $configData = $this->getMethod()->getConfigData('useccv');
111
+ if (null === $configData) {
112
+ return true;
113
+ }
114
+ return (bool)$configData;
115
+ }
116
+ return true;
117
+ }
118
+
119
+ /**
120
+ * Whether switch/solo card type available.
121
+ *
122
+ * @return boolean
123
+ */
124
+ public function hasSsCardType()
125
+ {
126
+ $availableTypes =$this->getMethod()->getConfigData('cctypes');
127
+ if ($availableTypes && in_array('SS', explode(',', $availableTypes))) {
128
+ return true;
129
+ }
130
+ return false;
131
+ }
132
+
133
+ /**
134
+ * Solo/switch card start year.
135
+ *
136
+ * @return array
137
+ */
138
+ public function getSsStartYears()
139
+ {
140
+ $years = array();
141
+ $first = date('Y');
142
+
143
+ for ($index = 5; $index >= 0; $index--) {
144
+ $year = $first - $index;
145
+ $years[$year] = $year;
146
+ }
147
+ $years = array(0 => $this->__('Year')) + $years;
148
+ return $years;
149
+ }
150
+
151
+ /**
152
+ * returns true if logo is available
153
+ *
154
+ */
155
+ protected function _isLogoAvailable($logo)
156
+ {
157
+ if ( isset($logo['value']) && $logo['value'] == 'dankort' ) {
158
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
159
+ if ( !$quote ) return false;
160
+ $address = $quote->getBillingAddress();
161
+ if ( !$address ) return false;
162
+ if ( $address->getCountryId() !== self::DANKORT_AVAIABLE_COUNTRY ) {
163
+ return false;
164
+ }
165
+ }
166
+ if ( isset($logo['value']) && $logo['value'] == 'carte_bleue_nationale' ) {
167
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
168
+ if ( !$quote ) return false;
169
+ $address = $quote->getBillingAddress();
170
+ if ( !$address ) return false;
171
+ if ( $address->getCountryId() !== self::CARTE_BLEUE_NATIONALE_AVAIABLE_COUNTRY ) {
172
+ return false;
173
+ }
174
+ }
175
+ return true;
176
+ }
177
+
178
+ /**
179
+ * Render block HTML.
180
+ *
181
+ * @return string
182
+ */
183
+ protected function _toHtml()
184
+ {
185
+ Mage::dispatchEvent(
186
+ 'payment_form_block_to_html_before',
187
+ array(
188
+ 'block' => $this
189
+ )
190
+ );
191
+ return parent::_toHtml();
192
+ }
193
+ }
app/code/community/Dotsource/Computop/Block/Form/Directpay.php ADDED
@@ -0,0 +1,44 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Contributors:
8
+ * ewohllebe - initial contents
9
+ **/
10
+
11
+ class Dotsource_Computop_Block_Form_Directpay
12
+ extends Dotsource_Computop_Block_Form_Eft
13
+ {
14
+
15
+ protected function _construct()
16
+ {
17
+ parent::_construct();
18
+
19
+ //Change the template
20
+ $this->setTemplate('computop/form/directpay.phtml');
21
+ }
22
+
23
+
24
+ /**
25
+ * Retrieves the url to the logo of the payment method.
26
+ *
27
+ * @return string
28
+ */
29
+ protected function _getLogoUrl()
30
+ {
31
+ return $this->getSkinUrl('images/computop/computop_directpay.gif');
32
+ }
33
+
34
+
35
+ /**
36
+ * Retrieves the alt attribute for the logo of the payment method.
37
+ *
38
+ * @return string
39
+ */
40
+ protected function _getLogoAlt()
41
+ {
42
+ return Mage::helper('computop')->__('Directpay Logo');
43
+ }
44
+ }
app/code/community/Dotsource/Computop/Block/Form/Eft.php ADDED
@@ -0,0 +1,143 @@
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2008-2010 dotSource GmbH.
4
+ * All rights reserved.
5
+ * http://www.dotsource.de
6
+ *
7
+ * Cont