symmetrics_cashticket - Version 0.1.4

Version Notes

keine

Download this release

Release Info

Developer Magento Core Team
Extension symmetrics_cashticket
Version 0.1.4
Comparing to
See all releases


Version 0.1.4

Files changed (32) hide show
  1. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config.php +26 -0
  2. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Edit.php +59 -0
  3. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Edit/Form.php +145 -0
  4. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Grid.php +117 -0
  5. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Renderer.php +29 -0
  6. app/code/community/Symmetrics/CashTicket/Block/Error.php +34 -0
  7. app/code/community/Symmetrics/CashTicket/Block/Form.php +23 -0
  8. app/code/community/Symmetrics/CashTicket/Block/Info.php +124 -0
  9. app/code/community/Symmetrics/CashTicket/Helper/Data.php +13 -0
  10. app/code/community/Symmetrics/CashTicket/Model/Api.php +357 -0
  11. app/code/community/Symmetrics/CashTicket/Model/Cashticket.php +237 -0
  12. app/code/community/Symmetrics/CashTicket/Model/Item.php +44 -0
  13. app/code/community/Symmetrics/CashTicket/Model/Mysql4/Item.php +16 -0
  14. app/code/community/Symmetrics/CashTicket/Model/Mysql4/Item/Collection.php +17 -0
  15. app/code/community/Symmetrics/CashTicket/Model/Source/Businesstype.php +24 -0
  16. app/code/community/Symmetrics/CashTicket/Model/Source/Currency.php +31 -0
  17. app/code/community/Symmetrics/CashTicket/Model/Source/Locale.php +26 -0
  18. app/code/community/Symmetrics/CashTicket/controllers/Adminhtml/CashticketController.php +121 -0
  19. app/code/community/Symmetrics/CashTicket/controllers/Adminhtml/ConfigController.php +173 -0
  20. app/code/community/Symmetrics/CashTicket/controllers/ProcessingController.php +200 -0
  21. app/code/community/Symmetrics/CashTicket/etc/config.xml +146 -0
  22. app/code/community/Symmetrics/CashTicket/etc/system.xml +103 -0
  23. app/code/community/Symmetrics/CashTicket/sql/cashticket_setup/mysql4-install-0.1.0.php +36 -0
  24. app/design/adminhtml/default/default/layout/cashticket.xml +22 -0
  25. app/design/adminhtml/default/default/template/cashticket/info.phtml +55 -0
  26. app/design/frontend/default/default/template/cashticket/form.phtml +19 -0
  27. app/design/frontend/default/default/template/cashticket/info.phtml +11 -0
  28. app/etc/modules/Symmetrics_CashTicket.xml +12 -0
  29. js/symmetrics/adminhtml/cashticket.js +38 -0
  30. package.xml +18 -0
  31. skin/frontend/default/default/images/cashticket/cashticket-logo.png +0 -0
  32. var/cashticket/paysafecard-CA.pem +227 -0
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Block_Adminhtml_Config extends Mage_Adminhtml_Block_Widget_Grid_Container
11
+ {
12
+ /**
13
+ * Prepare the page with
14
+ * the grid on it
15
+ *
16
+ * @return object
17
+ */
18
+ public function __construct()
19
+ {
20
+ $this->_controller = 'adminhtml_config';
21
+ $this->_blockGroup = 'cashticket';
22
+ $this->_headerText = Mage::helper('cashticket')->__('Cash-Ticket Configuration');
23
+ $this->_addButtonLabel = Mage::helper('cashticket')->__('Add Item');
24
+ parent::__construct();
25
+ }
26
+ }
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Edit.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Block_Adminhtml_Config_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
11
+ {
12
+ /**
13
+ * Add buttons to the edit form
14
+ *
15
+ * @return void
16
+ */
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+
21
+ $this->_objectId = 'id';
22
+ $this->_blockGroup = 'cashticket';
23
+ $this->_controller = 'adminhtml_config';
24
+
25
+ $this->_updateButton('save', 'label', Mage::helper('cashticket')->__('Save'));
26
+ $this->_updateButton('delete', 'label', Mage::helper('cashticket')->__('Delete'));
27
+
28
+ // add "save and continue" button
29
+ $this->_addButton('saveandcontinue', array(
30
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
31
+ 'onclick' => 'saveAndContinueEdit()',
32
+ 'class' => 'save',
33
+ ), -100);
34
+
35
+ // js needed for "save and continue"
36
+ $this->_formScripts[] = "
37
+ function saveAndContinueEdit(){
38
+ editForm.submit($('edit_form').action+'back/edit/');
39
+ }
40
+ ";
41
+ }
42
+
43
+ /**
44
+ * Set page header
45
+ *
46
+ * @return string
47
+ */
48
+ public function getHeaderText()
49
+ {
50
+ // if editing an item - set "Edit" as a page header
51
+ if (Mage::registry('cashticket_data') && Mage::registry('cashticket_data')->getId()) {
52
+ return Mage::helper('cashticket')->__('Edit Item "%s"', $this->htmlEscape(Mage::registry('cashticket_data')->getCurrencyCode()));
53
+ }
54
+ else {
55
+ // ohterwise set "Add"
56
+ return Mage::helper('cashticket')->__('Add Item');
57
+ }
58
+ }
59
+ }
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Edit/Form.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Block_Adminhtml_Config_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
11
+ {
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('editForm');
16
+ }
17
+
18
+ /**
19
+ * Preparing the form and adding
20
+ * fields to it
21
+ *
22
+ * @return object
23
+ */
24
+ protected function _prepareForm()
25
+ {
26
+ $form = new Varien_Data_Form(array(
27
+ 'id' => 'edit_form',
28
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
29
+ 'method' => 'post',
30
+ 'enctype' => 'multipart/form-data'
31
+ ));
32
+
33
+ $fieldset = $form->addFieldset('cashticket_form', array(
34
+ 'legend' => Mage::helper('cashticket')->__('Cash-Ticket Configuration'))
35
+ );
36
+
37
+ if ($this->getRequest()->getParam('id')) {
38
+ $fieldset->addField('item_id', 'hidden', array(
39
+ 'name' => 'item_id',
40
+ ));
41
+ }
42
+
43
+ $fieldset->addField('enable', 'select', array(
44
+ 'label' => Mage::helper('cashticket')->__('Enable'),
45
+ 'class' => 'required-entry',
46
+ 'required' => true,
47
+ 'name' => 'enable',
48
+ 'options' => array(
49
+ 0 => Mage::helper('cashticket')->__('No'),
50
+ 1 => Mage::helper('cashticket')->__('Yes'),
51
+ )
52
+ ));
53
+
54
+ $fieldset->addField('currency_code', 'select', array(
55
+ 'label' => Mage::helper('cashticket')->__('Currency'),
56
+ 'class' => 'required-entry',
57
+ 'required' => true,
58
+ 'name' => 'currency_code',
59
+ 'options' => Mage::getModel('cashticket/source_currency')->getOptionArray()
60
+ ));
61
+
62
+ $fieldset->addField('merchant_id', 'text', array(
63
+ 'label' => Mage::helper('cashticket')->__('Merchant ID'),
64
+ 'class' => 'required-entry',
65
+ 'required' => true,
66
+ 'name' => 'merchant_id',
67
+ ));
68
+
69
+ $fieldset->addField('business_type', 'select', array(
70
+ 'label' => Mage::helper('cashticket')->__('Business Type'),
71
+ 'class' => 'required-entry',
72
+ 'required' => true,
73
+ 'name' => 'business_type',
74
+ 'options' => Mage::getModel('cashticket/source_businesstype')->getOptionArray()
75
+ ));
76
+
77
+ $fieldset->addField('reporting_criteria', 'text', array(
78
+ 'label' => Mage::helper('cashticket')->__('Reporting Criteria'),
79
+ 'required' => false,
80
+ 'name' => 'reporting_criteria',
81
+ ));
82
+
83
+ $fieldset->addField('locale', 'select', array(
84
+ 'label' => Mage::helper('cashticket')->__('Language'),
85
+ 'class' => 'required-entry',
86
+ 'required' => true,
87
+ 'name' => 'locale',
88
+ 'options' => Mage::getModel('cashticket/source_locale')->getOptionArray()
89
+ ));
90
+
91
+ $fieldset->addField('path_pem_test', 'text', array(
92
+ 'label' => Mage::helper('cashticket')->__('Path to PEM Certificate (Test)'),
93
+ 'class' => 'required-entry',
94
+ 'required' => true,
95
+ 'name' => 'path_pem_test',
96
+ ));
97
+
98
+ $fieldset->addField('path_pem_live', 'text', array(
99
+ 'label' => Mage::helper('cashticket')->__('Path to PEM Certificate (Live)'),
100
+ 'class' => 'required-entry',
101
+ 'required' => true,
102
+ 'name' => 'path_pem_live',
103
+ ));
104
+
105
+ $fieldset->addField('path_cert', 'text', array(
106
+ 'label' => Mage::helper('cashticket')->__('Path to the Server Certificate'),
107
+ 'class' => 'required-entry',
108
+ 'required' => true,
109
+ 'name' => 'path_cert',
110
+ ));
111
+
112
+ $fieldset->addField('sslcert_pass', 'text', array(
113
+ 'label' => Mage::helper('cashticket')->__('Keyring Password'),
114
+ 'class' => 'required-entry',
115
+ 'required' => true,
116
+ 'name' => 'sslcert_pass',
117
+ ));
118
+
119
+ $fieldset->addField('sandbox', 'select', array(
120
+ 'label' => Mage::helper('cashticket')->__('Sandbox'),
121
+ 'class' => 'required-entry',
122
+ 'required' => true,
123
+ 'name' => 'sandbox',
124
+ 'options' => array(
125
+ 0 => Mage::helper('cashticket')->__('No'),
126
+ 1 => Mage::helper('cashticket')->__('Yes'),
127
+ )
128
+ ));
129
+
130
+ // get form values from the session
131
+ if (Mage::getSingleton('adminhtml/session')->getCashticketData()) {
132
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getCashticketData());
133
+ Mage::getSingleton('adminhtml/session')->setCashticketData(null);
134
+ }
135
+ elseif (Mage::registry('cashticket_data')) {
136
+ $form->setValues(Mage::registry('cashticket_data')->getData());
137
+ }
138
+
139
+ $form->setAction($this->getUrl('*/*/save'));
140
+ $form->setUseContainer(true);
141
+ $this->setForm($form);
142
+
143
+ return parent::_prepareForm();
144
+ }
145
+ }
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Grid.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Block_Adminhtml_Config_Grid extends Mage_Adminhtml_Block_Widget_Grid
11
+ {
12
+ /**
13
+ * Prepare the grid
14
+ *
15
+ * @return void
16
+ */
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+
21
+ $this->setId('cashticketGrid');
22
+ $this->setDefaultSort('currency_id');
23
+ $this->setDefaultDir('ASC');
24
+ $this->setSaveParametersInSession(true);
25
+ }
26
+
27
+ /**
28
+ * Get collection of config items
29
+ * and set it into the grid object
30
+ *
31
+ * @return string
32
+ */
33
+ protected function _prepareCollection()
34
+ {
35
+ $collection = Mage::getModel('cashticket/item')->getCollection();
36
+
37
+ $this->setCollection($collection);
38
+ return parent::_prepareCollection();
39
+ }
40
+
41
+ /**
42
+ * Set grid columns
43
+ *
44
+ * @return object
45
+ */
46
+ protected function _prepareColumns()
47
+ {
48
+ $this->addColumn('enable', array(
49
+ 'header' => Mage::helper('cashticket')->__('Enabled'),
50
+ 'type' => 'options',
51
+ 'index' => 'enable',
52
+ 'sortable' => true,
53
+ 'options' => array(
54
+ '1' => Mage::helper('cashticket')->__('Yes'),
55
+ '0' => Mage::helper('cashticket')->__('No')
56
+ ),
57
+ 'width' => '100px'
58
+ ));
59
+
60
+ $this->addColumn('currency_code', array(
61
+ 'header' => Mage::helper('cashticket')->__('Currency'),
62
+ 'type' => 'text',
63
+ 'index' => 'currency_code',
64
+ 'sortable' => true
65
+ ));
66
+
67
+ $this->addColumn('merchant_id', array(
68
+ 'header' => Mage::helper('cashticket')->__('Merchant ID'),
69
+ 'type' => 'text',
70
+ 'index' => 'merchant_id',
71
+ 'sortable' => true
72
+ ));
73
+
74
+ $this->addColumn('sandbox', array(
75
+ 'header' => Mage::helper('cashticket')->__('Sanbox'),
76
+ 'type' => 'options',
77
+ 'index' => 'sandbox',
78
+ 'sortable' => true,
79
+ 'options' => array(
80
+ '1' => Mage::helper('cashticket')->__('Yes'),
81
+ '0' => Mage::helper('cashticket')->__('No')
82
+ ),
83
+ 'width' => '100px'
84
+ ));
85
+
86
+ // add "edit" link into the action column
87
+ $this->addColumn('action',
88
+ array(
89
+ 'header' => Mage::helper('cashticket')->__('Action'),
90
+ 'type' => 'action',
91
+ 'getter' => 'getId',
92
+ 'actions' => array(array(
93
+ 'caption' => Mage::helper('catalog')->__('Edit'),
94
+ 'url' => array(
95
+ 'base' => '*/*/edit'
96
+ ),
97
+ 'field' => 'id'
98
+ )),
99
+ 'filter' => false,
100
+ 'sortable' => false,
101
+ 'index' => 'config',
102
+ 'width' => '100px'
103
+ ));
104
+
105
+ return parent::_prepareColumns();
106
+ }
107
+
108
+ /**
109
+ * Set the edit url
110
+ *
111
+ * @return string
112
+ */
113
+ public function getRowUrl($row)
114
+ {
115
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
116
+ }
117
+ }
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Renderer.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Block_Adminhtml_Config_Renderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
11
+ {
12
+ /**
13
+ * Rendering of the grid column
14
+ *
15
+ * @return string
16
+ */
17
+ public function render(Varien_Object $row)
18
+ {
19
+ $values = array();
20
+ foreach (Mage::getModel('cashticket/item')->getSizeOptions() as $option) {
21
+ foreach ($option as $key => $val) {
22
+ if ($val['value'] == $row->getSize()) {
23
+ return $val['label'];
24
+ $values[$val['value']] = $val['label'];
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
app/code/community/Symmetrics/CashTicket/Block/Error.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Block_Error extends Mage_Core_Block_Abstract
11
+ {
12
+ /**
13
+ * This block is shown when the customer
14
+ * cancels the payment process from
15
+ * CashTicket page
16
+ *
17
+ * @return string
18
+ */
19
+ protected function _toHtml()
20
+ {
21
+ $url = Mage::getUrl('checkout/onepage');
22
+
23
+ $html = '';
24
+
25
+ $html .= '<p>'.Mage::helper('cashticket')->__('Cash-Ticket payment was canceled. Redirecting to checkout...').'</p>';
26
+ $html .= '<p><a href="'.$url.'">'.Mage::helper('cashticket')->__('Click here to return to checkout').'</a></p>';
27
+
28
+ $html .= '<script language="javascript">';
29
+ $html .= 'document.location.href="'.$url.'";';
30
+ $html .= '</script>';
31
+
32
+ return $html;
33
+ }
34
+ }
app/code/community/Symmetrics/CashTicket/Block/Form.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Block_Form extends Mage_Payment_Block_Form
11
+ {
12
+ /**
13
+ * Set template for payment info
14
+ * below the radio selector
15
+ *
16
+ * @return object
17
+ */
18
+ protected function _construct()
19
+ {
20
+ $this->setTemplate('cashticket/form.phtml');
21
+ parent::_construct();
22
+ }
23
+ }
app/code/community/Symmetrics/CashTicket/Block/Info.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Block_Info extends Mage_Payment_Block_Info
11
+ {
12
+ /**
13
+ * Result of the API call
14
+ *
15
+ * @var object
16
+ */
17
+ protected $_response;
18
+
19
+ /**
20
+ * API object
21
+ *
22
+ * @var object
23
+ */
24
+ protected $_api;
25
+
26
+ /**
27
+ * Set template for payment info
28
+ * on the right side of the
29
+ * checkout page
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ parent::_construct();
36
+ $this->setTemplate('cashticket/info.phtml');
37
+ }
38
+
39
+ /**
40
+ * Get the API object
41
+ *
42
+ * @return object
43
+ */
44
+ public function getApi($transactionId)
45
+ {
46
+ if (is_null($this->_api)) {
47
+ $cashticketModel = Mage::getModel('cashticket/cashticket');
48
+ $this->_api = $cashticketModel->getApi($transactionId);
49
+ $this->_api->setOrder($this->getInfo()->getOrder());
50
+ }
51
+ return $this->_api;
52
+ }
53
+
54
+ /**
55
+ * Get disposition state from Cash-Ticket
56
+ * and set the response for later use
57
+ *
58
+ * @return object
59
+ */
60
+ public function callGetSerialNumbers()
61
+ {
62
+ if (is_null($this->_response)) {
63
+ $this->_response = $this->_api->call('GetSerialNumbers', array());
64
+
65
+ if ($this->_response->errCode != '0') {
66
+ Mage::throwException(Mage::helper('cashticket')->__('Error getting Cash-Ticket status.'));
67
+ return $this;
68
+ }
69
+ }
70
+ return $this->_response;
71
+ }
72
+
73
+ /**
74
+ * Map status codes to strings
75
+ *
76
+ * @return string
77
+ */
78
+ public function getPaymentStatus()
79
+ {
80
+ if (is_null($this->_response)) {
81
+ return $this;
82
+ }
83
+
84
+ switch ($this->_response->TransactionState) {
85
+ case 'R':
86
+ $status = $this->helper('cashticket')->__('Created (R)');
87
+ break;
88
+ case 'S':
89
+ $status = $this->helper('cashticket')->__('Disposed (S)');
90
+ break;
91
+ case 'E':
92
+ $status = $this->helper('cashticket')->__('Debited (E)');
93
+ break;
94
+ case 'O':
95
+ $status = $this->helper('cashticket')->__('Consumed (O)');
96
+ break;
97
+ case 'L':
98
+ $status = $this->helper('cashticket')->__('Canceled (L)');
99
+ break;
100
+ case 'I':
101
+ $status = $this->helper('cashticket')->__('Invalid (I)');
102
+ break;
103
+ case 'X':
104
+ $status = $this->helper('cashticket')->__('Expired (X)');
105
+ break;
106
+ default:
107
+ $status = $this->helper('cashticket')->__(sprintf(Mage::helper('cashticket')->__('Unknown status (%s)'), $response->TransactionState));
108
+ break;
109
+ }
110
+
111
+ return $status;
112
+ }
113
+
114
+ /**
115
+ * Get status codes allowed to
116
+ * continue transactions and debiting
117
+ *
118
+ * @return array
119
+ */
120
+ public function getAllowedStats()
121
+ {
122
+ return array('R', 'S', 'E');
123
+ }
124
+ }
app/code/community/Symmetrics/CashTicket/Helper/Data.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+
13
+ }
app/code/community/Symmetrics/CashTicket/Model/Api.php ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
11
+ {
12
+ /**
13
+ * Id of the Cash-Ticket transaction
14
+ *
15
+ * @var string
16
+ */
17
+ protected $_transactionId = '';
18
+
19
+ /**
20
+ * Use testing server or not
21
+ *
22
+ * @var boolean
23
+ */
24
+ protected $_sandbox = null;
25
+
26
+ /**
27
+ * Current order
28
+ *
29
+ * @var object
30
+ */
31
+ protected $_order = null;
32
+
33
+ /**
34
+ * Configuration array
35
+ *
36
+ * @var array
37
+ */
38
+ protected $_config = null;
39
+
40
+ /**
41
+ * Main method for calling API functions
42
+ * on Cash-Ticket
43
+ *
44
+ * @return object
45
+ */
46
+ public function call($functionName, array $params)
47
+ {
48
+ $callParams = '';
49
+
50
+ // merge set params with standard params
51
+ $params = array_merge(array(
52
+ 'currency' => $this->getConfigValue('currency_code'),
53
+ 'mid' => $this->getConfigValue('merchant_id'),
54
+ 'businesstype' => $this->getConfigValue('business_type'),
55
+ 'reportingcriteria' => $this->getConfigValue('reporting_criteria'),
56
+ 'okurl' => Mage::getUrl('cashticket/processing/success'),
57
+ 'nokurl' => Mage::getUrl('cashticket/processing/error'),
58
+ 'locale' => $this->getConfigValue('locale'),
59
+ 'outputFormat' => 'xml_v1',
60
+ 'mtid' => $this->getTransactionId()
61
+ ), $params);
62
+
63
+ // format params for curl
64
+ foreach ($params as $key => $value) {
65
+ $callParams .= '&'.$key.'='.urlencode($value);
66
+ }
67
+
68
+ try {
69
+ // do curl post
70
+ $this->write(Zend_Http_Client::POST, $this->getCashTicketUrl().$functionName . 'Servlet', '1.1', array(), $callParams);
71
+
72
+ // read response and convert it to XML
73
+ $response = $this->read();
74
+ $response = new Varien_Simplexml_Element($response);
75
+ }
76
+ catch (Exception $e) {
77
+ Mage::throwException(Mage::helper('cashticket')->__('CURL connection failed. Reason: ') . $e->getMessage());
78
+ }
79
+
80
+ return $response;
81
+ }
82
+
83
+ /**
84
+ * Writing a method to curl api
85
+ *
86
+ * @return string
87
+ */
88
+ public function write($method, $url, $http_ver = '1.1', $headers = array(), $body = '')
89
+ {
90
+ // get keyring password
91
+ $sslpass = $this->getConfigValue('sslcert_pass');
92
+
93
+ // can not process if no keyring password is set
94
+ if (empty($sslpass)) {
95
+ Mage::throwException(Mage::helper('cashticket')->__('SSL Certificate Password is empty. Please set the passwort in the configuration settings.'));
96
+ }
97
+ // if testing
98
+ if ($this->isSandbox()) {
99
+ // set PEM certificate of the test server
100
+ $pemCert = Mage::getBaseDir() . $this->getConfigValue('path_pem_test');
101
+ }
102
+ else {
103
+ // set PEM certificate of the live server
104
+ $pemCert = Mage::getBaseDir() . $this->getConfigValue('path_pem_live');
105
+ }
106
+ // if PEM certificate not found
107
+ if (!file_exists($pemCert)) {
108
+ Mage::throwException(Mage::helper('cashticket')->__('File with PEM Certificate does not exist'));
109
+ }
110
+ // if server certificate not found
111
+ if (!file_exists(Mage::getBaseDir() . $this->getConfigValue('path_cert'))) {
112
+ Mage::throwException(Mage::helper('cashticket')->__('File with Server Certificate does not exist'));
113
+ }
114
+
115
+ // set curl connection options
116
+ curl_setopt($this->_getResource(), CURLOPT_URL, $url);
117
+ curl_setopt($this->_getResource(), CURLOPT_POST, true);
118
+ curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body);
119
+ curl_setopt($this->_getResource(), CURLOPT_FOLLOWLOCATION, false);
120
+ curl_setopt($this->_getResource(), CURLOPT_RETURNTRANSFER, true);
121
+ curl_setopt($this->_getResource(), CURLOPT_TIMEOUT, 30);
122
+ curl_setopt($this->_getResource(), CURLOPT_SSLCERT, $pemCert);
123
+ curl_setopt($this->_getResource(), CURLOPT_SSLCERTTYPE, 'PEM');
124
+ curl_setopt($this->_getResource(), CURLOPT_SSLCERTPASSWD, $sslpass);
125
+ curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYPEER, 1);
126
+ curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYHOST, 2);
127
+ curl_setopt($this->_getResource(), CURLOPT_CAINFO, Mage::getBaseDir() . $this->getConfigValue('path_cert'));
128
+
129
+ return $body;
130
+ }
131
+
132
+ /**
133
+ * Exec curl function and
134
+ * get the response
135
+ *
136
+ * @return resource
137
+ */
138
+ public function read()
139
+ {
140
+ $response = curl_exec($this->_getResource());
141
+ return $response;
142
+ }
143
+
144
+ /**
145
+ * Get Cash-Ticket API URL
146
+ *
147
+ * @return string
148
+ */
149
+ public function getCashTicketUrl()
150
+ {
151
+ // if testing server
152
+ if ($this->isSandbox()) {
153
+ // return URL for the testing server
154
+ return $this->getDefaultConfigValue('url_test');
155
+ }
156
+ // otherwise return live URL
157
+ return $this->getDefaultConfigValue('url_live');
158
+ }
159
+
160
+ /**
161
+ * Get URL to redirect the customer
162
+ * after finishing the order
163
+ *
164
+ * @return string
165
+ */
166
+ public function getCustomerRedirectUrl(array $params)
167
+ {
168
+ // if testing
169
+ if ($this->isSandbox()) {
170
+ // get test url
171
+ $url = $this->getDefaultConfigValue('customer_url_test');
172
+ }
173
+ else {
174
+ // get live url
175
+ $url = $this->getDefaultConfigValue('customer_url_live');
176
+ }
177
+
178
+ $url .= 'GetCustomerPanelServlet?';
179
+ $urlParams = '';
180
+
181
+ // merge set and standard params
182
+ $params = array_merge(array(
183
+ 'currency' => $this->getConfigValue('currency_code'),
184
+ 'mid' => $this->getConfigValue('merchant_id'),
185
+ 'locale' => $this->getConfigValue('locale'),
186
+ 'mtid' => $this->getTransactionId()
187
+ ), $params);
188
+
189
+ // format params for curl call
190
+ foreach ($params as $key => $value) {
191
+ $urlParams .= '&' . $key . '=' . urlencode($value);
192
+ }
193
+
194
+ return $url . $urlParams;
195
+ }
196
+
197
+ /**
198
+ * Set transactionId
199
+ *
200
+ * @return void
201
+ */
202
+ public function setTransactionId($id)
203
+ {
204
+ $this->_transactionId = $id;
205
+ }
206
+
207
+ /**
208
+ * Get transactionId
209
+ *
210
+ * @return string
211
+ */
212
+ public function getTransactionId()
213
+ {
214
+ return $this->_transactionId;
215
+ }
216
+
217
+ /**
218
+ * Set order
219
+ *
220
+ * @return void
221
+ */
222
+ public function setOrder($order)
223
+ {
224
+ $this->_order = $order;
225
+ }
226
+
227
+ /**
228
+ * Get order
229
+ *
230
+ * @return object
231
+ */
232
+ public function getOrder()
233
+ {
234
+ return $this->_order;
235
+ }
236
+
237
+ /**
238
+ * Check if woring on
239
+ * the test server
240
+ *
241
+ * @return boolean
242
+ */
243
+ public function isSandbox()
244
+ {
245
+ // check if testing flag has been set
246
+ if (is_null($this->_sandbox)) {
247
+ // check if testing flag has been set in current
248
+ // configuration and set the flag for this api instance
249
+ if ($this->getConfigValue('sandbox')) {
250
+ $this->_sandbox = true;
251
+ }
252
+ else {
253
+ $this->_sandbox = false;
254
+ }
255
+ }
256
+ if ($this->_sandbox == true) {
257
+ return true;
258
+ }
259
+ return false;
260
+ }
261
+
262
+ /**
263
+ * Get value from active configuration
264
+ * for current currency
265
+ *
266
+ * @return string
267
+ */
268
+ public function getConfigValue($key)
269
+ {
270
+ $config = $this->getItemConfig();
271
+
272
+ try {
273
+ // if not set load from db
274
+ if (is_null($config)) {
275
+ // get model
276
+ $model = Mage::getModel('cashticket/item');
277
+ // load configuration for current currency
278
+ $collection = $model->getItemsCollection($this->getCurrency());
279
+ // if no active configurations found ..
280
+ if ($collection->getSize() <= 0) {
281
+ // throw error
282
+ Mage::throwException(Mage::helper('cashticket')->__('No active configuration for this currency.'));
283
+ }
284
+ // if more then 1 active configuration found ..
285
+ if ($collection->getSize() > 1) {
286
+ // throw error
287
+ Mage::throwException(Mage::helper('cashticket')->__('Multiply active configuration for this currency.'));
288
+ }
289
+ // set the config with loaded data
290
+ $this->_config = $model->getConfigItem($this->getCurrency());
291
+ $value = $this->_config[$key];
292
+ }
293
+ // if already set - load from model
294
+ elseif (is_array($config)) {
295
+ $value = $config[$key];
296
+ }
297
+ else {
298
+ $value = null;
299
+ }
300
+ } catch (Exception $e) {
301
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
302
+ return;
303
+ }
304
+
305
+ return $value;
306
+ }
307
+
308
+ /**
309
+ * Get configuration from XML
310
+ *
311
+ * @return string
312
+ */
313
+ public function getDefaultConfigValue($key)
314
+ {
315
+ return Mage::getStoreConfig('payment/cashticket/' . $key);
316
+ }
317
+
318
+ /**
319
+ * Get current currency code
320
+ *
321
+ * @return string
322
+ */
323
+ public function getCurrency()
324
+ {
325
+ $order = $this->getOrder();
326
+ // get currency info from current order
327
+ $currency = $order->getData('order_currency_code');
328
+ // if no currency set for the order - get currency info from store
329
+ if (empty($currency)) {
330
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
331
+ }
332
+
333
+ return $currency;
334
+ }
335
+
336
+ /**
337
+ * Get config array
338
+ *
339
+ * @return array
340
+ */
341
+ public function getItemConfig()
342
+ {
343
+ return $this->_config;
344
+ }
345
+
346
+ /**
347
+ * Format price for Cash-Ticket (format 0.00)
348
+ *
349
+ * @return string
350
+ */
351
+ public function formatPrice($amount)
352
+ {
353
+ $formatted = number_format($amount, 2, '.', '');
354
+ $formatted = sprintf('%.2f', $formatted);
355
+ return $formatted;
356
+ }
357
+ }
app/code/community/Symmetrics/CashTicket/Model/Cashticket.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Model_CashTicket extends Mage_Payment_Model_Method_Abstract
11
+ {
12
+ /**
13
+ * Internal payment code
14
+ *
15
+ * @var string
16
+ */
17
+ protected $_code = 'cashticket';
18
+
19
+ /**
20
+ * If gateway
21
+ *
22
+ * @var boolean
23
+ */
24
+ protected $_isGateway = true;
25
+
26
+ /**
27
+ * If use authorization
28
+ *
29
+ * @var boolean
30
+ */
31
+ protected $_canAuthorize = true;
32
+
33
+ /**
34
+ * If use capturing
35
+ *
36
+ * @var boolean
37
+ */
38
+ protected $_canCapture = true;
39
+
40
+ /**
41
+ * If capture partial amounts
42
+ *
43
+ * @var boolean
44
+ */
45
+ protected $_canCapturePartial = false;
46
+
47
+ /**
48
+ * If using refund
49
+ *
50
+ * @var boolean
51
+ */
52
+ protected $_canRefund = false;
53
+
54
+ /**
55
+ * If can void
56
+ *
57
+ * @var boolean
58
+ */
59
+ protected $_canVoid = false;
60
+
61
+ /**
62
+ * If using for internal
63
+ *
64
+ * @var boolean
65
+ */
66
+ protected $_canUseInternal = true;
67
+
68
+ /**
69
+ * If using on checkout
70
+ *
71
+ * @var boolean
72
+ */
73
+ protected $_canUseCheckout = true;
74
+
75
+ /**
76
+ * If using on multishipping
77
+ *
78
+ * @var boolean
79
+ */
80
+ protected $_canUseForMultishipping = true;
81
+
82
+ /**
83
+ * If saving creditcards
84
+ *
85
+ * @var boolean
86
+ */
87
+ protected $_canSaveCc = false;
88
+
89
+ /**
90
+ * If validating
91
+ *
92
+ * @var boolean
93
+ */
94
+ protected $_canValidate = true;
95
+
96
+ /**
97
+ * Define block for payment form
98
+ *
99
+ * @var string
100
+ */
101
+ protected $_formBlockType = 'cashticket/form';
102
+
103
+ /**
104
+ * Define block for payment info
105
+ *
106
+ * @var string
107
+ */
108
+ protected $_infoBlockType = 'cashticket/info';
109
+
110
+ /**
111
+ * Id of the transaction for
112
+ * current API call
113
+ *
114
+ * @var string
115
+ */
116
+ protected $_transactionId = '';
117
+
118
+ public function _construct()
119
+ {
120
+ parent::_construct();
121
+ $this->_init('cashticket/item');
122
+ }
123
+
124
+ /**
125
+ * Get API object
126
+ *
127
+ * @return object
128
+ */
129
+ public function getApi($transactionId)
130
+ {
131
+ $api = Mage::getModel('cashticket/api');
132
+ $api->setTransactionId($transactionId);
133
+ $api->setOrder($this->getQuote());
134
+
135
+ return $api;
136
+ }
137
+
138
+ /**
139
+ * Get checkout from session
140
+ *
141
+ * @return object
142
+ */
143
+ public function getCheckout()
144
+ {
145
+ return Mage::getModel('checkout/session');
146
+ }
147
+
148
+ /**
149
+ * Get session for Cash-Ticket
150
+ *
151
+ * @return object
152
+ */
153
+ public function getSession()
154
+ {
155
+ return Mage::getModel('cashticket/session');
156
+ }
157
+
158
+ /**
159
+ * Get quote
160
+ *
161
+ * @return object
162
+ */
163
+ public function getQuote()
164
+ {
165
+ return $this->getCheckout()->getQuote();
166
+ }
167
+
168
+ /**
169
+ * Check if payment method is available
170
+ *
171
+ * @return bool
172
+ */
173
+ public function isAvailable($quote = null)
174
+ {
175
+ // if quote is not set - something went wrong
176
+ if (is_null($quote)) {
177
+ return false;
178
+ }
179
+
180
+ // if cart value > 1000 - cancel
181
+ // cash-ticket does not support orders
182
+ // with value > 1000 at this time
183
+ if (Mage::app()->getStore()->roundPrice($quote->getGrandTotal()) <= 1000) {
184
+ return true;
185
+ }
186
+
187
+ return false;
188
+ }
189
+
190
+ /**
191
+ * Create disposition on Cash-Ticket
192
+ *
193
+ * @return object
194
+ */
195
+ public function authorize(Varien_Object $payment, $amount)
196
+ {
197
+ // generate random transaction number (number from 100 to 999 + orderid)
198
+ $transactionId = rand(100, 999) . $payment->getOrder()->increment_id;
199
+ $api = $this->getApi($transactionId);
200
+
201
+ // override the amount to get the really order amount
202
+ // needed for currency operations
203
+ $amount = $api->formatPrice($this->getQuote()->getGrandTotal());
204
+
205
+ $params = array(
206
+ 'amount' => $amount
207
+ );
208
+
209
+ // save transactionid in payment data
210
+ $payment->setAdditionalData($transactionId);
211
+
212
+ // get response from api
213
+ $response = $api->call('CreateDisposition', $params);
214
+
215
+ // if response could be parsed and no error happened
216
+ if (is_object($response) && $response->errCode == '0')
217
+ {
218
+ return $this;
219
+ }
220
+ else {
221
+ // TODO: Translate
222
+ Mage::throwException(Mage::helper('cashticket')->__('Bei der Bezahlung ist ein Fehler aufgetreten. Vermutlich ist dies ein temporärer Fehler und die Bezahlung kann durch Neu-Laden der Seite abgeschlossen werden. Falls dieses Problem weiterhin besteht, kontaktieren Sie bitte unseren Support.'));
223
+ }
224
+
225
+ return $this;
226
+ }
227
+
228
+ /**
229
+ * Get redirect URL
230
+ *
231
+ * @return string
232
+ */
233
+ public function getOrderPlaceRedirectUrl()
234
+ {
235
+ return Mage::getUrl('cashticket/processing/redirect');
236
+ }
237
+ }
app/code/community/Symmetrics/CashTicket/Model/Item.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Model_Item extends Mage_Core_Model_Abstract
11
+ {
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('cashticket/item');
16
+ }
17
+
18
+ /**
19
+ * Get config item object
20
+ * and load by currency
21
+ *
22
+ * @return string
23
+ */
24
+ public function getConfigItem($currency)
25
+ {
26
+ $ids = $this->getItemsCollection($currency)->getAllIds();
27
+ return $this->load($ids[0])->toArray();
28
+ }
29
+
30
+ /**
31
+ * Get all enabled config items
32
+ * for current currency
33
+ *
34
+ * @return string
35
+ */
36
+ public function getItemsCollection($currency)
37
+ {
38
+ $collection = $this->getCollection()
39
+ ->addFieldToFilter('currency_code', $currency)
40
+ ->addFieldToFilter('enable', 1);
41
+
42
+ return $collection;
43
+ }
44
+ }
app/code/community/Symmetrics/CashTicket/Model/Mysql4/Item.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Model_Mysql4_Item extends Mage_Core_Model_Mysql4_Abstract
11
+ {
12
+ public function _construct()
13
+ {
14
+ $this->_init('cashticket/item', 'item_id');
15
+ }
16
+ }
app/code/community/Symmetrics/CashTicket/Model/Mysql4/Item/Collection.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Model_Mysql4_Item_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
11
+ {
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('cashticket/item');
16
+ }
17
+ }
app/code/community/Symmetrics/CashTicket/Model/Source/Businesstype.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Model_Source_BusinessType
11
+ {
12
+ /**
13
+ * Get possible business types
14
+ *
15
+ * @return array
16
+ */
17
+ public function getOptionArray()
18
+ {
19
+ return array(
20
+ 'T' => Mage::helper('cashticket')->__('Tangible'),
21
+ 'I' => Mage::helper('cashticket')->__('Intangible')
22
+ );
23
+ }
24
+ }
app/code/community/Symmetrics/CashTicket/Model/Source/Currency.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Model_Source_Currency
11
+ {
12
+ /**
13
+ * Get possible currencies
14
+ *
15
+ * @return array
16
+ */
17
+ public function getOptionArray()
18
+ {
19
+ return array(
20
+ 'CHF' => 'CHF',
21
+ 'DKK' => 'DKK',
22
+ 'SEK' => 'SEK',
23
+ 'SEK' => 'SEK',
24
+ 'PLN' => 'PLN',
25
+ 'GBP' => 'GBP',
26
+ 'EUR' => 'EUR',
27
+ 'USD' => 'USD',
28
+ 'CZK' => 'CZK'
29
+ );
30
+ }
31
+ }
app/code/community/Symmetrics/CashTicket/Model/Source/Locale.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Symmetrics
4
+ * @package Symmetrics_CashTicket
5
+ * @author symmetrics gmbh <info@symmetrics.de>, Eugen Gitin <eg@symmetrics.de>
6
+ * @copyright symmetrics gmbh
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Symmetrics_CashTicket_Model_Source_Locale
11
+ {
12
+ /**
13
+ * Get locales
14
+ *
15
+ * @return array
16
+ */
17
+ public function getOptionArray()
18
+ {
19
+ return array(
20
+ 'de_de' => Mage::helper('cashticket')->__('German Germany'),
21
+ 'de_at' => Mage::helper('cashticket')->__('German Austria'),
22
+ 'en_uk' => Mage::helper('cashticket')->__('British English'),
23
+ 'en_us' => Mage::helper('cashticket')->__('American English')
24
+ );
25
+ }
26
+ }
app/code/community/Symmetrics/CashTicket/controllers/Adminhtml/CashticketController.php ADDED
@@ -0,0 +1,121 @@