symmetrics_cashticket - Version 0.1.8

Version Notes

keine

Download this release

Release Info

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


Code changes from version 0.1.4 to 0.1.8

Files changed (31) hide show
  1. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config.php +51 -26
  2. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Edit.php +96 -59
  3. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Edit/Form.php +225 -145
  4. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Grid.php +158 -117
  5. app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Renderer.php +58 -29
  6. app/code/community/Symmetrics/CashTicket/Block/Error.php +60 -34
  7. app/code/community/Symmetrics/CashTicket/Block/Form.php +48 -23
  8. app/code/community/Symmetrics/CashTicket/Block/Info.php +156 -124
  9. app/code/community/Symmetrics/CashTicket/Helper/Data.php +37 -13
  10. app/code/community/Symmetrics/CashTicket/Model/Api.php +98 -40
  11. app/code/community/Symmetrics/CashTicket/Model/Cashticket.php +277 -237
  12. app/code/community/Symmetrics/CashTicket/Model/Item.php +84 -44
  13. app/code/community/Symmetrics/CashTicket/Model/Mysql4/Item.php +46 -16
  14. app/code/community/Symmetrics/CashTicket/Model/Mysql4/Item/Collection.php +47 -17
  15. app/code/community/Symmetrics/CashTicket/Model/Source/Businesstype.php +49 -24
  16. app/code/community/Symmetrics/CashTicket/Model/Source/Currency.php +56 -31
  17. app/code/community/Symmetrics/CashTicket/Model/Source/Locale.php +51 -26
  18. app/code/community/Symmetrics/CashTicket/controllers/Adminhtml/CashticketController.php +164 -121
  19. app/code/community/Symmetrics/CashTicket/controllers/Adminhtml/ConfigController.php +212 -173
  20. app/code/community/Symmetrics/CashTicket/controllers/ProcessingController.php +246 -200
  21. app/code/community/Symmetrics/CashTicket/etc/config.xml +40 -8
  22. app/code/community/Symmetrics/CashTicket/etc/system.xml +20 -6
  23. app/code/community/Symmetrics/CashTicket/sql/cashticket_setup/mysql4-install-0.1.0.php +50 -36
  24. app/design/adminhtml/default/default/layout/cashticket.xml +21 -7
  25. app/design/adminhtml/default/default/template/cashticket/info.phtml +33 -20
  26. app/design/frontend/default/default/template/cashticket/form.phtml +19 -6
  27. app/design/frontend/default/default/template/cashticket/info.phtml +20 -7
  28. app/etc/modules/Symmetrics_CashTicket.xml +24 -1
  29. app/locale/de_DE/Symmetrics_Cashticket.csv +1 -0
  30. js/symmetrics/adminhtml/cashticket.js +58 -37
  31. package.xml +6 -6
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config.php CHANGED
@@ -1,26 +1,51 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Block_Adminhtml_Config
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Block_Adminhtml_Config extends Mage_Adminhtml_Block_Widget_Grid_Container
36
+ {
37
+ /**
38
+ * Prepare the page with
39
+ * the grid on it
40
+ *
41
+ * @return object
42
+ */
43
+ public function __construct()
44
+ {
45
+ $this->_controller = 'adminhtml_config';
46
+ $this->_blockGroup = 'cashticket';
47
+ $this->_headerText = Mage::helper('cashticket')->__('Cash-Ticket Configuration');
48
+ $this->_addButtonLabel = Mage::helper('cashticket')->__('Add Item');
49
+ parent::__construct();
50
+ }
51
+ }
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Edit.php CHANGED
@@ -1,59 +1,96 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Block_Adminhtml_Config_Edit
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Block_Adminhtml_Config_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
36
+ {
37
+ /**
38
+ * Add buttons to the edit form
39
+ *
40
+ * @return void
41
+ */
42
+ public function __construct()
43
+ {
44
+ parent::__construct();
45
+
46
+ $this->_objectId = 'id';
47
+ $this->_blockGroup = 'cashticket';
48
+ $this->_controller = 'adminhtml_config';
49
+
50
+ $this->_updateButton(
51
+ 'save',
52
+ 'label',
53
+ Mage::helper('cashticket')->__('Save')
54
+ );
55
+ $this->_updateButton(
56
+ 'delete',
57
+ 'label',
58
+ Mage::helper('cashticket')->__('Delete')
59
+ );
60
+
61
+ // add "save and continue" button
62
+ $this->_addButton(
63
+ 'saveandcontinue',
64
+ array(
65
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
66
+ 'onclick' => 'saveAndContinueEdit()',
67
+ 'class' => 'save',
68
+ ),
69
+ -100
70
+ );
71
+
72
+ // js needed for "save and continue"
73
+ $this->_formScripts[] = "
74
+ function saveAndContinueEdit(){
75
+ editForm.submit($('edit_form').action+'back/edit/');
76
+ }
77
+ ";
78
+ }
79
+
80
+ /**
81
+ * Set page header
82
+ *
83
+ * @return string
84
+ */
85
+ public function getHeaderText()
86
+ {
87
+ // if editing an item - set "Edit" as a page header
88
+ if (Mage::registry('cashticket_data') && Mage::registry('cashticket_data')->getId()) {
89
+ $currencyCode = Mage::registry('cashticket_data')->getCurrencyCode();
90
+ return Mage::helper('cashticket')->__('Edit Item "%s"', $this->htmlEscape($currencyCode));
91
+ } else {
92
+ // ohterwise set "Add"
93
+ return Mage::helper('cashticket')->__('Add Item');
94
+ }
95
+ }
96
+ }
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Edit/Form.php CHANGED
@@ -1,145 +1,225 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Block_Adminhtml_Config_Edit_Form
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Block_Adminhtml_Config_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ /**
38
+ * set editForm id
39
+ *
40
+ * @return void
41
+ */
42
+ public function __construct()
43
+ {
44
+ parent::__construct();
45
+ $this->setId('editForm');
46
+ }
47
+
48
+ /**
49
+ * Preparing the form and adding
50
+ * fields to it
51
+ *
52
+ * @return object
53
+ */
54
+ protected function _prepareForm()
55
+ {
56
+ $form = new Varien_Data_Form(array(
57
+ 'id' => 'edit_form',
58
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
59
+ 'method' => 'post',
60
+ 'enctype' => 'multipart/form-data'
61
+ ));
62
+
63
+ $fieldset = $form->addFieldset(
64
+ 'cashticket_form',
65
+ array(
66
+ 'legend' => Mage::helper('cashticket')->__('Cash-Ticket Configuration')
67
+ )
68
+ );
69
+
70
+ if ($this->getRequest()->getParam('id')) {
71
+ $fieldset->addField(
72
+ 'item_id',
73
+ 'hidden',
74
+ array(
75
+ 'name' => 'item_id',
76
+ )
77
+ );
78
+ }
79
+
80
+ $fieldset->addField(
81
+ 'enable',
82
+ 'select',
83
+ array(
84
+ 'label' => Mage::helper('cashticket')->__('Enable'),
85
+ 'class' => 'required-entry',
86
+ 'required' => true,
87
+ 'name' => 'enable',
88
+ 'options' => array(
89
+ 0 => Mage::helper('cashticket')->__('No'),
90
+ 1 => Mage::helper('cashticket')->__('Yes'),
91
+ )
92
+ )
93
+ );
94
+
95
+ $fieldset->addField(
96
+ 'currency_code',
97
+ 'select',
98
+ array(
99
+ 'label' => Mage::helper('cashticket')->__('Currency'),
100
+ 'class' => 'required-entry',
101
+ 'required' => true,
102
+ 'name' => 'currency_code',
103
+ 'options' => Mage::getModel('cashticket/source_currency')->getOptionArray()
104
+ )
105
+ );
106
+
107
+ $fieldset->addField(
108
+ 'merchant_id',
109
+ 'text',
110
+ array(
111
+ 'label' => Mage::helper('cashticket')->__('Merchant ID'),
112
+ 'class' => 'required-entry',
113
+ 'required' => true,
114
+ 'name' => 'merchant_id',
115
+ )
116
+ );
117
+
118
+ $fieldset->addField(
119
+ 'business_type',
120
+ 'select',
121
+ array(
122
+ 'label' => Mage::helper('cashticket')->__('Business Type'),
123
+ 'class' => 'required-entry',
124
+ 'required' => true,
125
+ 'name' => 'business_type',
126
+ 'options' => Mage::getModel('cashticket/source_businesstype')->getOptionArray()
127
+ )
128
+ );
129
+
130
+ $fieldset->addField(
131
+ 'reporting_criteria',
132
+ 'text',
133
+ array(
134
+ 'label' => Mage::helper('cashticket')->__('Reporting Criteria'),
135
+ 'required' => false,
136
+ 'name' => 'reporting_criteria',
137
+ )
138
+ );
139
+
140
+ $fieldset->addField(
141
+ 'locale',
142
+ 'select',
143
+ array(
144
+ 'label' => Mage::helper('cashticket')->__('Language'),
145
+ 'class' => 'required-entry',
146
+ 'required' => true,
147
+ 'name' => 'locale',
148
+ 'options' => Mage::getModel('cashticket/source_locale')->getOptionArray()
149
+ )
150
+ );
151
+
152
+ $fieldset->addField(
153
+ 'path_pem_test',
154
+ 'text',
155
+ array(
156
+ 'label' => Mage::helper('cashticket')->__('Path to PEM Certificate (Test)'),
157
+ 'class' => 'required-entry',
158
+ 'required' => true,
159
+ 'name' => 'path_pem_test',
160
+ )
161
+ );
162
+
163
+ $fieldset->addField(
164
+ 'path_pem_live',
165
+ 'text',
166
+ array(
167
+ 'label' => Mage::helper('cashticket')->__('Path to PEM Certificate (Live)'),
168
+ 'class' => 'required-entry',
169
+ 'required' => true,
170
+ 'name' => 'path_pem_live',
171
+ )
172
+ );
173
+
174
+ $fieldset->addField(
175
+ 'path_cert',
176
+ 'text',
177
+ array(
178
+ 'label' => Mage::helper('cashticket')->__('Path to the Server Certificate'),
179
+ 'class' => 'required-entry',
180
+ 'required' => true,
181
+ 'name' => 'path_cert',
182
+ )
183
+ );
184
+
185
+ $fieldset->addField(
186
+ 'sslcert_pass',
187
+ 'text',
188
+ array(
189
+ 'label' => Mage::helper('cashticket')->__('Keyring Password'),
190
+ 'class' => 'required-entry',
191
+ 'required' => true,
192
+ 'name' => 'sslcert_pass',
193
+ )
194
+ );
195
+
196
+ $fieldset->addField(
197
+ 'sandbox',
198
+ 'select',
199
+ array(
200
+ 'label' => Mage::helper('cashticket')->__('Sandbox'),
201
+ 'class' => 'required-entry',
202
+ 'required' => true,
203
+ 'name' => 'sandbox',
204
+ 'options' => array(
205
+ 0 => Mage::helper('cashticket')->__('No'),
206
+ 1 => Mage::helper('cashticket')->__('Yes'),
207
+ )
208
+ )
209
+ );
210
+
211
+ // get form values from the session
212
+ if (Mage::getSingleton('adminhtml/session')->getCashticketData()) {
213
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getCashticketData());
214
+ Mage::getSingleton('adminhtml/session')->setCashticketData(null);
215
+ } elseif (Mage::registry('cashticket_data')) {
216
+ $form->setValues(Mage::registry('cashticket_data')->getData());
217
+ }
218
+
219
+ $form->setAction($this->getUrl('*/*/save'));
220
+ $form->setUseContainer(true);
221
+ $this->setForm($form);
222
+
223
+ return parent::_prepareForm();
224
+ }
225
+ }
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Grid.php CHANGED
@@ -1,117 +1,158 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Block_Adminhtml_Config_Grid
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Block_Adminhtml_Config_Grid extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ /**
38
+ * Prepare the grid
39
+ *
40
+ * @return void
41
+ */
42
+ public function __construct()
43
+ {
44
+ parent::__construct();
45
+
46
+ $this->setId('cashticketGrid');
47
+ $this->setDefaultSort('currency_id');
48
+ $this->setDefaultDir('ASC');
49
+ $this->setSaveParametersInSession(true);
50
+ }
51
+
52
+ /**
53
+ * Get collection of config items
54
+ * and set it into the grid object
55
+ *
56
+ * @return string
57
+ */
58
+ protected function _prepareCollection()
59
+ {
60
+ $collection = Mage::getModel('cashticket/item')->getCollection();
61
+
62
+ $this->setCollection($collection);
63
+ return parent::_prepareCollection();
64
+ }
65
+
66
+ /**
67
+ * Set grid columns
68
+ *
69
+ * @return object
70
+ */
71
+ protected function _prepareColumns()
72
+ {
73
+ $this->addColumn(
74
+ 'enable',
75
+ array(
76
+ 'header' => Mage::helper('cashticket')->__('Enabled'),
77
+ 'type' => 'options',
78
+ 'index' => 'enable',
79
+ 'sortable' => true,
80
+ 'options' => array(
81
+ '1' => Mage::helper('cashticket')->__('Yes'),
82
+ '0' => Mage::helper('cashticket')->__('No')
83
+ ),
84
+ 'width' => '100px'
85
+ )
86
+ );
87
+
88
+ $this->addColumn(
89
+ 'currency_code',
90
+ array(
91
+ 'header' => Mage::helper('cashticket')->__('Currency'),
92
+ 'type' => 'text',
93
+ 'index' => 'currency_code',
94
+ 'sortable' => true
95
+ )
96
+ );
97
+
98
+ $this->addColumn(
99
+ 'merchant_id',
100
+ array(
101
+ 'header' => Mage::helper('cashticket')->__('Merchant ID'),
102
+ 'type' => 'text',
103
+ 'index' => 'merchant_id',
104
+ 'sortable' => true
105
+ )
106
+ );
107
+
108
+ $this->addColumn(
109
+ 'sandbox',
110
+ array(
111
+ 'header' => Mage::helper('cashticket')->__('Sanbox'),
112
+ 'type' => 'options',
113
+ 'index' => 'sandbox',
114
+ 'sortable' => true,
115
+ 'options' => array(
116
+ '1' => Mage::helper('cashticket')->__('Yes'),
117
+ '0' => Mage::helper('cashticket')->__('No')
118
+ ),
119
+ 'width' => '100px'
120
+ )
121
+ );
122
+
123
+ // add "edit" link into the action column
124
+ $this->addColumn(
125
+ 'action',
126
+ array(
127
+ 'header' => Mage::helper('cashticket')->__('Action'),
128
+ 'type' => 'action',
129
+ 'getter' => 'getId',
130
+ 'actions' => array(array(
131
+ 'caption' => Mage::helper('catalog')->__('Edit'),
132
+ 'url' => array(
133
+ 'base' => '*/*/edit'
134
+ ),
135
+ 'field' => 'id'
136
+ )),
137
+ 'filter' => false,
138
+ 'sortable' => false,
139
+ 'index' => 'config',
140
+ 'width' => '100px'
141
+ )
142
+ );
143
+
144
+ return parent::_prepareColumns();
145
+ }
146
+
147
+ /**
148
+ * Set the edit url
149
+ *
150
+ * @param object $row row
151
+ *
152
+ * @return string
153
+ */
154
+ public function getRowUrl($row)
155
+ {
156
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
157
+ }
158
+ }
app/code/community/Symmetrics/CashTicket/Block/Adminhtml/Config/Renderer.php CHANGED
@@ -1,29 +1,58 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Block_Adminhtml_Config_Renderer
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Block_Adminhtml_Config_Renderer
36
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
37
+ {
38
+ /**
39
+ * Rendering of the grid column
40
+ *
41
+ * @param Varien_Object $row row
42
+ *
43
+ * @return string
44
+ */
45
+ public function render(Varien_Object $row)
46
+ {
47
+ $values = array();
48
+ foreach (Mage::getModel('cashticket/item')->getSizeOptions() as $option) {
49
+ foreach ($option as $key => $val) {
50
+ if ($val['value'] == $row->getSize()) {
51
+ return $val['label'];
52
+
53
+ $values[$val['value']] = $val['label'];
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
app/code/community/Symmetrics/CashTicket/Block/Error.php CHANGED
@@ -1,34 +1,60 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Block_Error
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Block_Error extends Mage_Core_Block_Abstract
36
+ {
37
+ /**
38
+ * This block is shown when the customer
39
+ * cancels the payment process from
40
+ * CashTicket page
41
+ *
42
+ * @return string
43
+ */
44
+ protected function _toHtml()
45
+ {
46
+ $url = Mage::getUrl('checkout/onepage');
47
+
48
+ $html = '';
49
+ $message = 'Cash-Ticket payment was canceled. Redirecting to checkout...';
50
+ $html .= '<p>' . Mage::helper('cashticket')->__($message) . '</p>';
51
+ $html .= '<p><a href="' . $url . '">';
52
+ $html .= Mage::helper('cashticket')->__('Click here to return to checkout') . '</a></p>';
53
+
54
+ $html .= '<script language="javascript">';
55
+ $html .= 'document.location.href="' . $url . '";';
56
+ $html .= '</script>';
57
+
58
+ return $html;
59
+ }
60
+ }
app/code/community/Symmetrics/CashTicket/Block/Form.php CHANGED
@@ -1,23 +1,48 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Block_Form
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Block_Form extends Mage_Payment_Block_Form
36
+ {
37
+ /**
38
+ * Set template for payment info
39
+ * below the radio selector
40
+ *
41
+ * @return object
42
+ */
43
+ protected function _construct()
44
+ {
45
+ parent::_construct();
46
+ $this->setTemplate('cashticket/form.phtml');
47
+ }
48
+ }
app/code/community/Symmetrics/CashTicket/Block/Info.php CHANGED
@@ -1,124 +1,156 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Block_Info
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Block_Info extends Mage_Payment_Block_Info
36
+ {
37
+ /**
38
+ * Result of the API call
39
+ *
40
+ * @var object
41
+ */
42
+ protected $_response;
43
+
44
+ /**
45
+ * API object
46
+ *
47
+ * @var object
48
+ */
49
+ protected $_api;
50
+
51
+ /**
52
+ * Set template for payment info
53
+ * on the right side of the
54
+ * checkout page
55
+ *
56
+ * @return void
57
+ */
58
+ protected function _construct()
59
+ {
60
+ parent::_construct();
61
+ $this->setTemplate('cashticket/info.phtml');
62
+ }
63
+
64
+ /**
65
+ * Get the API object
66
+ *
67
+ * @param int $transactionId transactionId
68
+ *
69
+ * @return object
70
+ */
71
+ public function getApi($transactionId)
72
+ {
73
+ if (is_null($this->_api)) {
74
+ $cashticketModel = Mage::getModel('cashticket/cashticket');
75
+ $this->_api = $cashticketModel->getApi($transactionId);
76
+ $this->_api->setOrder($this->getInfo()->getOrder());
77
+ }
78
+ return $this->_api;
79
+ }
80
+
81
+ /**
82
+ * Get disposition state from Cash-Ticket
83
+ * and set the response for later use
84
+ *
85
+ * @return object
86
+ */
87
+ public function callGetSerialNumbers()
88
+ {
89
+ if (is_null($this->_response)) {
90
+ $this->_response = $this->_api->call('GetSerialNumbers', array());
91
+
92
+ if ($this->_response->errCode != '0') {
93
+ Mage::throwException(Mage::helper('cashticket')->__('Error getting Cash-Ticket status.'));
94
+ return $this;
95
+ }
96
+ }
97
+ return $this->_response;
98
+ }
99
+
100
+ /**
101
+ * Map status codes to strings
102
+ *
103
+ * @return string
104
+ */
105
+ public function getPaymentStatus()
106
+ {
107
+ if (is_null($this->_response)) {
108
+ return $this;
109
+ }
110
+
111
+ switch ($this->_response->TransactionState) {
112
+ case 'R':
113
+ $status = $this->helper('cashticket')->__('Created (R)');
114
+ break;
115
+ case 'S':
116
+ $status = $this->helper('cashticket')->__('Disposed (S)');
117
+ break;
118
+ case 'E':
119
+ $status = $this->helper('cashticket')->__('Debited (E)');
120
+ break;
121
+ case 'O':
122
+ $status = $this->helper('cashticket')->__('Consumed (O)');
123
+ break;
124
+ case 'L':
125
+ $status = $this->helper('cashticket')->__('Canceled (L)');
126
+ break;
127
+ case 'I':
128
+ $status = $this->helper('cashticket')->__('Invalid (I)');
129
+ break;
130
+ case 'X':
131
+ $status = $this->helper('cashticket')->__('Expired (X)');
132
+ break;
133
+ default:
134
+ $message = Mage::helper('cashticket')->__('Unknown status (%s)', $this->_response->TransactionState);
135
+ $status = $this->helper('cashticket')->__($message);
136
+ break;
137
+ }
138
+
139
+ return $status;
140
+ }
141
+
142
+ /**
143
+ * Get status codes allowed to
144
+ * continue transactions and debiting
145
+ *
146
+ * @return array
147
+ */
148
+ public function getAllowedStats()
149
+ {
150
+ return array(
151
+ 'R',
152
+ 'S',
153
+ 'E'
154
+ );
155
+ }
156
+ }
app/code/community/Symmetrics/CashTicket/Helper/Data.php CHANGED
@@ -1,13 +1,37 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Helper_Data
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Helper_Data extends Mage_Core_Helper_Abstract
36
+ {
37
+ }
app/code/community/Symmetrics/CashTicket/Model/Api.php CHANGED
@@ -1,13 +1,38 @@
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
@@ -41,6 +66,9 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
41
  * Main method for calling API functions
42
  * on Cash-Ticket
43
  *
 
 
 
44
  * @return object
45
  */
46
  public function call($functionName, array $params)
@@ -48,26 +76,35 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
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();
@@ -83,23 +120,29 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
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
  }
@@ -138,6 +181,7 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
138
  public function read()
139
  {
140
  $response = curl_exec($this->_getResource());
 
141
  return $response;
142
  }
143
 
@@ -153,6 +197,7 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
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
  }
@@ -161,6 +206,8 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
161
  * Get URL to redirect the customer
162
  * after finishing the order
163
  *
 
 
164
  * @return string
165
  */
166
  public function getCustomerRedirectUrl(array $params)
@@ -169,8 +216,7 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
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
  }
@@ -179,12 +225,15 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
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) {
@@ -197,6 +246,8 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
197
  /**
198
  * Set transactionId
199
  *
 
 
200
  * @return void
201
  */
202
  public function setTransactionId($id)
@@ -217,6 +268,8 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
217
  /**
218
  * Set order
219
  *
 
 
220
  * @return void
221
  */
222
  public function setOrder($order)
@@ -248,14 +301,14 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
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
 
@@ -263,6 +316,8 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
263
  * Get value from active configuration
264
  * for current currency
265
  *
 
 
266
  * @return string
267
  */
268
  public function getConfigValue($key)
@@ -284,17 +339,16 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
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) {
@@ -308,6 +362,8 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
308
  /**
309
  * Get configuration from XML
310
  *
 
 
311
  * @return string
312
  */
313
  public function getDefaultConfigValue($key)
@@ -346,6 +402,8 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
346
  /**
347
  * Format price for Cash-Ticket (format 0.00)
348
  *
 
 
349
  * @return string
350
  */
351
  public function formatPrice($amount)
@@ -354,4 +412,4 @@ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
354
  $formatted = sprintf('%.2f', $formatted);
355
  return $formatted;
356
  }
357
- }
1
  <?php
2
  /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
  */
23
 
24
+ /**
25
+ * Symmetrics_CashTicket_Model_Api
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Model_Api extends Varien_Http_Adapter_Curl
36
  {
37
  /**
38
  * Id of the Cash-Ticket transaction
66
  * Main method for calling API functions
67
  * on Cash-Ticket
68
  *
69
+ * @param string $functionName Function name
70
+ * @param array $params Params
71
+ *
72
  * @return object
73
  */
74
  public function call($functionName, array $params)
76
  $callParams = '';
77
 
78
  // merge set params with standard params
79
+ $params = array_merge(
80
+ array(
81
+ 'currency' => $this->getConfigValue('currency_code'),
82
+ 'mid' => $this->getConfigValue('merchant_id'),
83
+ 'businesstype' => $this->getConfigValue('business_type'),
84
+ 'reportingcriteria' => $this->getConfigValue('reporting_criteria'),
85
+ 'okurl' => Mage::getUrl('cashticket/processing/success'),
86
+ 'nokurl' => Mage::getUrl('cashticket/processing/error'),
87
+ 'locale' => $this->getConfigValue('locale'),
88
+ 'outputFormat' => 'xml_v1',
89
+ 'mtid' => $this->getTransactionId()
90
+ ),
91
+ $params
92
+ );
93
 
94
  // format params for curl
95
  foreach ($params as $key => $value) {
96
+ $callParams .= '&' . $key . '=' . urlencode($value);
97
  }
98
 
99
  try {
100
  // do curl post
101
+ $this->write(
102
+ Zend_Http_Client::POST,
103
+ $this->getCashTicketUrl() . $functionName . 'Servlet',
104
+ '1.1',
105
+ array(),
106
+ $callParams
107
+ );
108
 
109
  // read response and convert it to XML
110
  $response = $this->read();
120
  /**
121
  * Writing a method to curl api
122
  *
123
+ * @param string $method Method
124
+ * @param string $url Url
125
+ * @param string $httpVer httpVer
126
+ * @param array $headers Headers
127
+ * @param string $body Body
128
+ *
129
  * @return string
130
  */
131
+ public function write($method, $url, $httpVer = '1.1', $headers = array(), $body = '')
132
  {
133
  // get keyring password
134
  $sslpass = $this->getConfigValue('sslcert_pass');
135
 
136
  // can not process if no keyring password is set
137
  if (empty($sslpass)) {
138
+ $message = 'SSL Certificate Password is empty. Please set the passwort in the configuration settings.';
139
+ Mage::throwException(Mage::helper('cashticket')->__($message));
140
  }
141
  // if testing
142
  if ($this->isSandbox()) {
143
  // set PEM certificate of the test server
144
  $pemCert = Mage::getBaseDir() . $this->getConfigValue('path_pem_test');
145
+ } else {
 
146
  // set PEM certificate of the live server
147
  $pemCert = Mage::getBaseDir() . $this->getConfigValue('path_pem_live');
148
  }
181
  public function read()
182
  {
183
  $response = curl_exec($this->_getResource());
184
+
185
  return $response;
186
  }
187
 
197
  // return URL for the testing server
198
  return $this->getDefaultConfigValue('url_test');
199
  }
200
+
201
  // otherwise return live URL
202
  return $this->getDefaultConfigValue('url_live');
203
  }
206
  * Get URL to redirect the customer
207
  * after finishing the order
208
  *
209
+ * @param array $params Params
210
+ *
211
  * @return string
212
  */
213
  public function getCustomerRedirectUrl(array $params)
216
  if ($this->isSandbox()) {
217
  // get test url
218
  $url = $this->getDefaultConfigValue('customer_url_test');
219
+ } else {
 
220
  // get live url
221
  $url = $this->getDefaultConfigValue('customer_url_live');
222
  }
225
  $urlParams = '';
226
 
227
  // merge set and standard params
228
+ $params = array_merge(
229
+ array(
230
+ 'currency' => $this->getConfigValue('currency_code'),
231
+ 'mid' => $this->getConfigValue('merchant_id'),
232
+ 'locale' => $this->getConfigValue('locale'),
233
+ 'mtid' => $this->getTransactionId()
234
+ ),
235
+ $params
236
+ );
237
 
238
  // format params for curl call
239
  foreach ($params as $key => $value) {
246
  /**
247
  * Set transactionId
248
  *
249
+ * @param int $id Id
250
+ *
251
  * @return void
252
  */
253
  public function setTransactionId($id)
268
  /**
269
  * Set order
270
  *
271
+ * @param object $order Order object
272
+ *
273
  * @return void
274
  */
275
  public function setOrder($order)
301
  // configuration and set the flag for this api instance
302
  if ($this->getConfigValue('sandbox')) {
303
  $this->_sandbox = true;
304
+ } else {
 
305
  $this->_sandbox = false;
306
  }
307
  }
308
  if ($this->_sandbox == true) {
309
  return true;
310
  }
311
+
312
  return false;
313
  }
314
 
316
  * Get value from active configuration
317
  * for current currency
318
  *
319
+ * @param string $key Key
320
+ *
321
  * @return string
322
  */
323
  public function getConfigValue($key)
339
  // if more then 1 active configuration found ..
340
  if ($collection->getSize() > 1) {
341
  // throw error
342
+ $errorMessage = 'Multiply active configuration for this currency.';
343
+ Mage::throwException(Mage::helper('cashticket')->__($errorMessage));
344
  }
345
  // set the config with loaded data
346
  $this->_config = $model->getConfigItem($this->getCurrency());
347
  $value = $this->_config[$key];
348
+ // if already set - load from model
349
+ } elseif (is_array($config)) {
 
350
  $value = $config[$key];
351
+ } else {
 
352
  $value = null;
353
  }
354
  } catch (Exception $e) {
362
  /**
363
  * Get configuration from XML
364
  *
365
+ * @param string $key key
366
+ *
367
  * @return string
368
  */
369
  public function getDefaultConfigValue($key)
402
  /**
403
  * Format price for Cash-Ticket (format 0.00)
404
  *
405
+ * @param string $amount Amount
406
+ *
407
  * @return string
408
  */
409
  public function formatPrice($amount)
412
  $formatted = sprintf('%.2f', $formatted);
413
  return $formatted;
414
  }
415
+ }
app/code/community/Symmetrics/CashTicket/Model/Cashticket.php CHANGED
@@ -1,237 +1,277 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Symmetrics
16
+ * @package Symmetrics_CashTicket
17
+ * @author symmetrics gmbh <info@symmetrics.de>
18
+ * @author Eugen Gitin <eg@symmetrics.de>
19
+ * @copyright 2010 symmetrics gmbh
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ * @link http://www.symmetrics.de/
22
+ */
23
+
24
+ /**
25
+ * Symmetrics_CashTicket_Model_CashTicket
26
+ *
27
+ * @category Symmetrics
28
+ * @package Symmetrics_CashTicket
29
+ * @author symmetrics gmbh <info@symmetrics.de>
30
+ * @author Eugen Gitin <eg@symmetrics.de>
31
+ * @copyright 2010 symmetrics gmbh
32
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
+ * @link http://www.symmetrics.de/
34
+ */
35
+ class Symmetrics_CashTicket_Model_CashTicket extends Mage_Payment_Model_Method_Abstract
36
+ {
37
+ /**
38
+ * Internal payment code
39
+ *
40
+ * @var string
41
+ */
42
+ protected $_code = 'cashticket';
43
+
44
+ /**
45
+ * If gateway
46
+ *
47
+ * @var boolean
48
+ */
49
+ protected $_isGateway = true;
50
+
51
+ /**
52
+ * If use authorization
53
+ *
54
+ * @var boolean
55
+ */
56
+ protected $_canAuthorize = true;
57
+
58
+ /**
59
+ * If use capturing
60
+ *
61
+ * @var boolean
62
+ */
63
+ protected $_canCapture = true;
64
+
65
+ /**
66
+ * If capture partial amounts
67
+ *
68
+ * @var boolean
69
+ */
70
+ protected $_canCapturePartial = false;
71
+
72
+ /**
73
+ * If using refund
74
+ *
75
+ * @var boolean
76
+ */
77
+ protected $_canRefund = false;
78
+
79
+ /**
80
+ * If can void
81
+ *
82
+ * @var boolean
83
+ */
84
+ protected $_canVoid = false;
85
+
86
+ /**
87
+ * If using for internal
88
+ *
89
+ * @var boolean
90
+ */
91
+ protected $_canUseInternal = true;
92
+
93
+ /**
94
+ * If using on checkout
95
+ *
96
+ * @var boolean
97
+ */
98
+ protected $_canUseCheckout = true;
99
+
100
+ /**
101
+ * If using on multishipping
102
+ *
103
+ * @var boolean
104
+ */
105
+ protected $_canUseForMultishipping = true;
106
+
107
+ /**
108
+ * If saving creditcards
109
+ *
110
+ * @var boolean
111
+ */
112
+ protected $_canSaveCc = false;
113
+
114
+ /**
115
+ * If validating
116
+ *
117
+ * @var boolean
118
+ */
119
+ protected $_canValidate = true;
120
+
121
+ /**
122
+ * Define block for payment form
123
+ *
124
+ * @var string
125
+ */
126
+ protected $_formBlockType = 'cashticket/form';
127
+
128
+ /**
129
+ * Define block for payment info
130
+ *
131
+ * @var string
132
+ */
133
+ protected $_infoBlockType = 'cashticket/info';
134
+
135
+ /**
136
+ * Id of the transaction for
137
+ * current API call
138
+ *
139
+ * @var string
140
+ */
141
+ protected $_transactionId = '';
142
+
143
+ /**
144
+ * Construct
145
+ *
146
+ * @return void
147
+ */
148
+ public function _construct()
149
+ {
150
+ parent::_construct();
151
+ $this->_init('cashticket/item');
152
+ }
153
+
154
+ /**
155
+ * Get API object
156
+ *
157
+ * @param int $transactionId Transaction Id
158
+ *
159
+ * @return object
160
+ */
161
+ public function getApi($transactionId)
162
+ {
163
+ $api = Mage::getModel('cashticket/api');
164
+ $api->setTransactionId($transactionId);
165
+ $api->setOrder($this->getQuote());
166
+
167
+ return $api;
168
+ }
169
+
170
+ /**
171
+ * Get checkout from session
172
+ *
173
+ * @return object
174
+ */
175
+ public function getCheckout()
176
+ {
177
+ return Mage::getSingleton('checkout/session');
178
+ }
179
+
180
+ /**
181
+ * Get session for Cash-Ticket
182
+ *
183
+ * @return object
184
+ */
185
+ public function getSession()
186
+ {
187
+ return Mage::getSingleton('cashticket/session');
188
+ }
189
+
190
+ /**
191
+ * Get quote
192
+ *
193
+ * @return object
194
+ */
195
+ public function getQuote()
196
+ {
197
+ return $this->getCheckout()->getQuote();
198
+ }
199
+
200
+ /**
201