yapital - Version 1.0.0

Version Notes

Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.

Download this release

Release Info

Developer code-x GmbH
Extension yapital
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (90) hide show
  1. app/code/community/Codex/Yapital/.gitignore +0 -0
  2. app/code/community/Codex/Yapital/Block/AbstractBlock.php +19 -0
  3. app/code/community/Codex/Yapital/Block/Adminhtml/Report/Yapital/Payment.php +24 -0
  4. app/code/community/Codex/Yapital/Block/Adminhtml/Report/Yapital/Payment/Grid.php +227 -0
  5. app/code/community/Codex/Yapital/Block/Base.php +12 -0
  6. app/code/community/Codex/Yapital/Block/Config/Credentials/Sandbox.php +75 -0
  7. app/code/community/Codex/Yapital/Block/Config/Notification/Sandbox.php +75 -0
  8. app/code/community/Codex/Yapital/Block/Standard/Iframe.php +34 -0
  9. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Live/Secret.php +53 -0
  10. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Notification.php +75 -0
  11. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox.php +75 -0
  12. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Secret.php +53 -0
  13. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Validate.php +91 -0
  14. app/code/community/Codex/Yapital/ErrorException.php +28 -0
  15. app/code/community/Codex/Yapital/Exception.php +26 -0
  16. app/code/community/Codex/Yapital/Helper/Data.php +20 -0
  17. app/code/community/Codex/Yapital/Model/Abstract.php +5 -0
  18. app/code/community/Codex/Yapital/Model/Api/Abstract.php +97 -0
  19. app/code/community/Codex/Yapital/Model/Api/Basket/Transaction.php +53 -0
  20. app/code/community/Codex/Yapital/Model/Api/Notification.php +92 -0
  21. app/code/community/Codex/Yapital/Model/Api/Restclient.php +222 -0
  22. app/code/community/Codex/Yapital/Model/Api/ReturnBasket.php +26 -0
  23. app/code/community/Codex/Yapital/Model/Api/Token.php +100 -0
  24. app/code/community/Codex/Yapital/Model/Config.php +179 -0
  25. app/code/community/Codex/Yapital/Model/Datatype/Abstract.php +159 -0
  26. app/code/community/Codex/Yapital/Model/Datatype/AbstractSimpleType.php +134 -0
  27. app/code/community/Codex/Yapital/Model/Datatype/Airlinedata.php +222 -0
  28. app/code/community/Codex/Yapital/Model/Datatype/Amount.php +99 -0
  29. app/code/community/Codex/Yapital/Model/Datatype/Basket.php +338 -0
  30. app/code/community/Codex/Yapital/Model/Datatype/Basketstransaction.php +128 -0
  31. app/code/community/Codex/Yapital/Model/Datatype/Baskettransactioncreated.php +131 -0
  32. app/code/community/Codex/Yapital/Model/Datatype/Currency.php +37 -0
  33. app/code/community/Codex/Yapital/Model/Datatype/EventType.php +32 -0
  34. app/code/community/Codex/Yapital/Model/Datatype/Interface.php +39 -0
  35. app/code/community/Codex/Yapital/Model/Datatype/Item.php +341 -0
  36. app/code/community/Codex/Yapital/Model/Datatype/Merchantitem.php +75 -0
  37. app/code/community/Codex/Yapital/Model/Datatype/Notification.php +179 -0
  38. app/code/community/Codex/Yapital/Model/Datatype/Postaladdress.php +326 -0
  39. app/code/community/Codex/Yapital/Model/Datatype/Qrcodebinary.php +122 -0
  40. app/code/community/Codex/Yapital/Model/Datatype/Returnbasket.php +41 -0
  41. app/code/community/Codex/Yapital/Model/Datatype/Shoprestresponse.php +217 -0
  42. app/code/community/Codex/Yapital/Model/Datatype/Token.php +119 -0
  43. app/code/community/Codex/Yapital/Model/Datatype/Transaction.php +340 -0
  44. app/code/community/Codex/Yapital/Model/Datatype/Transactionstatus.php +40 -0
  45. app/code/community/Codex/Yapital/Model/Datatype/Yapitalpublicid.php +118 -0
  46. app/code/community/Codex/Yapital/Model/Log.php +113 -0
  47. app/code/community/Codex/Yapital/Model/Notification.php +218 -0
  48. app/code/community/Codex/Yapital/Model/Observer.php +14 -0
  49. app/code/community/Codex/Yapital/Model/Order/Transaction.php +72 -0
  50. app/code/community/Codex/Yapital/Model/Payment/Standard.php +76 -0
  51. app/code/community/Codex/Yapital/Model/Resource/Notification.php +11 -0
  52. app/code/community/Codex/Yapital/Model/Resource/Notification/Collection.php +11 -0
  53. app/code/community/Codex/Yapital/Model/Resource/Order/Transaction.php +11 -0
  54. app/code/community/Codex/Yapital/Model/Resource/Order/Transaction/Collection.php +11 -0
  55. app/code/community/Codex/Yapital/Model/Resource/Report/Paymentmethod.php +237 -0
  56. app/code/community/Codex/Yapital/Model/Resource/Report/Paymentmethod/Collection.php +97 -0
  57. app/code/community/Codex/Yapital/Model/System/Config/Payment/Credentials/Switch.php +29 -0
  58. app/code/community/Codex/Yapital/controllers/Adminhtml/Report/YapitalController.php +120 -0
  59. app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/ConfigController.php +123 -0
  60. app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/NotificationController.php +101 -0
  61. app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/SandboxController.php +105 -0
  62. app/code/community/Codex/Yapital/controllers/NotificationController.php +44 -0
  63. app/code/community/Codex/Yapital/controllers/StandardController.php +139 -0
  64. app/code/community/Codex/Yapital/doc/phpdoc.xml +20 -0
  65. app/code/community/Codex/Yapital/etc/adminhtml.xml +39 -0
  66. app/code/community/Codex/Yapital/etc/config.xml +161 -0
  67. app/code/community/Codex/Yapital/etc/system.xml +234 -0
  68. app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-install-0.1.0.php +44 -0
  69. app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-0.1.0-0.2.0.php +66 -0
  70. app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-0.2.0-0.3.0.php +116 -0
  71. app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-0.3.0-1.0.0.php +9 -0
  72. app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-1.0.0-1.1.0.php +9 -0
  73. app/design/adminhtml/default/default/layout/yapital.xml +37 -0
  74. app/design/adminhtml/default/default/template/yapital/.gitignore +0 -0
  75. app/design/adminhtml/default/default/template/yapital/config/credentials/sandbox.phtml +152 -0
  76. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/live/secret.phtml +21 -0
  77. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/notification.phtml +145 -0
  78. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox.phtml +144 -0
  79. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox/notification.phtml +144 -0
  80. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox/secret.phtml +11 -0
  81. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/validate.phtml +148 -0
  82. app/design/frontend/base/default/layout/yapital.xml +42 -0
  83. app/design/frontend/base/default/template/yapital/.gitignore +0 -0
  84. app/design/frontend/base/default/template/yapital/standard/accessdenied.phtml +1 -0
  85. app/design/frontend/base/default/template/yapital/standard/error.phtml +14 -0
  86. app/design/frontend/base/default/template/yapital/standard/iframe.phtml +10 -0
  87. app/etc/modules/Codex_Yapital.xml +13 -0
  88. package.xml +18 -0
  89. skin/frontend/base/default/css/yapital/.gitignore +0 -0
  90. skin/frontend/base/default/css/yapital/iframe.css +3 -0
app/code/community/Codex/Yapital/.gitignore ADDED
File without changes
app/code/community/Codex/Yapital/Block/AbstractBlock.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Codex_Yapital_Block_AbstractBlock.
5
+ *
6
+ * @category Yapital
7
+ * @package Codex_Yapital_Block
8
+ */
9
+ abstract class Codex_Yapital_Block_AbstractBlock extends Mage_Core_Block_Template
10
+ {
11
+
12
+ /**
13
+ * @return Codex_Yapital_Model_Config
14
+ */
15
+ function _getConfig()
16
+ {
17
+ return $config = Mage::getSingleton('yapital/config');
18
+ }
19
+ }
app/code/community/Codex/Yapital/Block/Adminhtml/Report/Yapital/Payment.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_Adminhtml_Report_Yapital_Payment extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'yapital';
8
+ $this->_controller = 'adminhtml_report_yapital_payment';
9
+ $this->_headerText = Mage::helper('yapital')->__('Yapital Payment Method Report');
10
+ parent::__construct();
11
+ $this->setTemplate('report/grid/container.phtml');
12
+ $this->_removeButton('add');
13
+ $this->addButton('filter_form_submit', array(
14
+ 'label' => Mage::helper('yapital')->__('Show Report'),
15
+ 'onclick' => 'filterFormSubmit()'
16
+ ));
17
+ }
18
+
19
+ public function getFilterUrl()
20
+ {
21
+ $this->getRequest()->setParam('filter', null);
22
+ return $this->getUrl('*/*/payment', array('_current' => true));
23
+ }
24
+ }
app/code/community/Codex/Yapital/Block/Adminhtml/Report/Yapital/Payment/Grid.php ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_Adminhtml_Report_Yapital_Payment_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract
4
+ {
5
+ protected $_rcollection = null;
6
+
7
+ protected $_columnGroupBy = 'period, method';
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setCountTotals(true);
13
+ }
14
+
15
+ public function getResourceCollectionName()
16
+ {
17
+ return 'yapital/report_paymentmethod_collection';
18
+ }
19
+
20
+ /**
21
+ * @param Mage_Reports_Model_Resource_Report_Collection_Abstract $collection
22
+ * @param Varien_Object $filterData
23
+ * @return $this|Mage_Adminhtml_Block_Report_Grid_Abstract
24
+ */
25
+ protected function _addCustomFilter($collection, $filterData)
26
+ {
27
+ $this->_rcollection = $collection;
28
+
29
+ //$collection->getSelect()->where("method = 'yapital_standard'");
30
+
31
+ return $this;
32
+ }
33
+
34
+ protected function _prepareColumns()
35
+ {
36
+ $this->addColumn('period', array(
37
+ 'header' => Mage::helper('sales')->__('Period'),
38
+ 'index' => 'period',
39
+ 'width' => 100,
40
+ 'sortable' => false,
41
+ 'period_type' => $this->getPeriodType(),
42
+ 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
43
+ 'totals_label' => Mage::helper('sales')->__('Total'),
44
+ 'html_decorators' => array('nobr'),
45
+ ));
46
+
47
+ $this->addColumn('payment_method', array(
48
+ 'header' => Mage::helper('sales')->__('Payment Method'),
49
+ 'index' => 'method',
50
+ 'width' => 100,
51
+ 'sortable' => false,
52
+ 'html_decorators' => array('nobr'),
53
+ ));
54
+
55
+ $this->addColumn('orders_count', array(
56
+ 'header' => Mage::helper('sales')->__('Orders'),
57
+ 'index' => 'orders_count',
58
+ 'type' => 'number',
59
+ 'total' => 'sum',
60
+ 'sortable' => false
61
+ ));
62
+
63
+ $this->addColumn('total_qty_ordered', array(
64
+ 'header' => Mage::helper('sales')->__('Sales Items'),
65
+ 'index' => 'total_qty_ordered',
66
+ 'type' => 'number',
67
+ 'total' => 'sum',
68
+ 'sortable' => false
69
+ ));
70
+
71
+ $this->addColumn('total_qty_invoiced', array(
72
+ 'header' => Mage::helper('sales')->__('Items'),
73
+ 'index' => 'total_qty_invoiced',
74
+ 'type' => 'number',
75
+ 'total' => 'sum',
76
+ 'sortable' => false,
77
+ 'visibility_filter' => array('show_actual_columns')
78
+ ));
79
+
80
+ if ($this->getFilterData()->getStoreIds()) {
81
+ $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
82
+ }
83
+ $currencyCode = $this->getCurrentCurrencyCode();
84
+ $rate = $this->getRate($currencyCode);
85
+
86
+ $this->addColumn('total_income_amount', array(
87
+ 'header' => Mage::helper('sales')->__('Sales Total'),
88
+ 'type' => 'currency',
89
+ 'currency_code' => $currencyCode,
90
+ 'index' => 'total_income_amount',
91
+ 'total' => 'sum',
92
+ 'sortable' => false,
93
+ 'rate' => $rate,
94
+ ));
95
+
96
+ $this->addColumn('total_revenue_amount', array(
97
+ 'header' => Mage::helper('sales')->__('Revenue'),
98
+ 'type' => 'currency',
99
+ 'currency_code' => $currencyCode,
100
+ 'index' => 'total_revenue_amount',
101
+ 'total' => 'sum',
102
+ 'sortable' => false,
103
+ 'visibility_filter' => array('show_actual_columns'),
104
+ 'rate' => $rate,
105
+ ));
106
+
107
+ $this->addColumn('total_profit_amount', array(
108
+ 'header' => Mage::helper('sales')->__('Profit'),
109
+ 'type' => 'currency',
110
+ 'currency_code' => $currencyCode,
111
+ 'index' => 'total_profit_amount',
112
+ 'total' => 'sum',
113
+ 'sortable' => false,
114
+ 'visibility_filter' => array('show_actual_columns'),
115
+ 'rate' => $rate,
116
+ ));
117
+
118
+ $this->addColumn('total_invoiced_amount', array(
119
+ 'header' => Mage::helper('sales')->__('Invoiced'),
120
+ 'type' => 'currency',
121
+ 'currency_code' => $currencyCode,
122
+ 'index' => 'total_invoiced_amount',
123
+ 'total' => 'sum',
124
+ 'sortable' => false,
125
+ 'rate' => $rate,
126
+ ));
127
+
128
+ $this->addColumn('total_paid_amount', array(
129
+ 'header' => Mage::helper('sales')->__('Paid'),
130
+ 'type' => 'currency',
131
+ 'currency_code' => $currencyCode,
132
+ 'index' => 'total_paid_amount',
133
+ 'total' => 'sum',
134
+ 'sortable' => false,
135
+ 'visibility_filter' => array('show_actual_columns'),
136
+ 'rate' => $rate,
137
+ ));
138
+
139
+ $this->addColumn('total_refunded_amount', array(
140
+ 'header' => Mage::helper('sales')->__('Refunded'),
141
+ 'type' => 'currency',
142
+ 'currency_code' => $currencyCode,
143
+ 'index' => 'total_refunded_amount',
144
+ 'total' => 'sum',
145
+ 'sortable' => false,
146
+ 'rate' => $rate,
147
+ ));
148
+
149
+ $this->addColumn('total_tax_amount', array(
150
+ 'header' => Mage::helper('sales')->__('Sales Tax'),
151
+ 'type' => 'currency',
152
+ 'currency_code' => $currencyCode,
153
+ 'index' => 'total_tax_amount',
154
+ 'total' => 'sum',
155
+ 'sortable' => false,
156
+ 'rate' => $rate,
157
+ ));
158
+
159
+ $this->addColumn('total_tax_amount_actual', array(
160
+ 'header' => Mage::helper('sales')->__('Tax'),
161
+ 'type' => 'currency',
162
+ 'currency_code' => $currencyCode,
163
+ 'index' => 'total_tax_amount_actual',
164
+ 'total' => 'sum',
165
+ 'sortable' => false,
166
+ 'visibility_filter' => array('show_actual_columns'),
167
+ 'rate' => $rate,
168
+ ));
169
+
170
+ $this->addColumn('total_shipping_amount', array(
171
+ 'header' => Mage::helper('sales')->__('Sales Shipping'),
172
+ 'type' => 'currency',
173
+ 'currency_code' => $currencyCode,
174
+ 'index' => 'total_shipping_amount',
175
+ 'total' => 'sum',
176
+ 'sortable' => false,
177
+ 'rate' => $rate,
178
+ ));
179
+
180
+ $this->addColumn('total_shipping_amount_actual', array(
181
+ 'header' => Mage::helper('sales')->__('Shipping'),
182
+ 'type' => 'currency',
183
+ 'currency_code' => $currencyCode,
184
+ 'index' => 'total_shipping_amount_actual',
185
+ 'total' => 'sum',
186
+ 'sortable' => false,
187
+ 'visibility_filter' => array('show_actual_columns'),
188
+ 'rate' => $rate,
189
+ ));
190
+
191
+ $this->addColumn('total_discount_amount', array(
192
+ 'header' => Mage::helper('sales')->__('Sales Discount'),
193
+ 'type' => 'currency',
194
+ 'currency_code' => $currencyCode,
195
+ 'index' => 'total_discount_amount',
196
+ 'total' => 'sum',
197
+ 'sortable' => false,
198
+ 'rate' => $rate,
199
+ ));
200
+
201
+ $this->addColumn('total_discount_amount_actual', array(
202
+ 'header' => Mage::helper('sales')->__('Discount'),
203
+ 'type' => 'currency',
204
+ 'currency_code' => $currencyCode,
205
+ 'index' => 'total_discount_amount_actual',
206
+ 'total' => 'sum',
207
+ 'sortable' => false,
208
+ 'visibility_filter' => array('show_actual_columns'),
209
+ 'rate' => $rate,
210
+ ));
211
+
212
+ $this->addColumn('total_canceled_amount', array(
213
+ 'header' => Mage::helper('sales')->__('Canceled'),
214
+ 'type' => 'currency',
215
+ 'currency_code' => $currencyCode,
216
+ 'index' => 'total_canceled_amount',
217
+ 'total' => 'sum',
218
+ 'sortable' => false,
219
+ 'rate' => $rate,
220
+ ));
221
+
222
+ $this->addExportType('*/*/exportPaymentCsv', Mage::helper('yapital')->__('CSV'));
223
+ $this->addExportType('*/*/exportPaymentExcel', Mage::helper('yapital')->__('Excel XML'));
224
+
225
+ return parent::_prepareColumns();
226
+ }
227
+ }
app/code/community/Codex/Yapital/Block/Base.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Codex_Yapital_Block_Base.
5
+ *
6
+ * @category Yapital
7
+ * @package Codex_Yapital_Block
8
+ */
9
+ class Codex_Yapital_Block_Base extends Mage_Core_Block_Template {
10
+
11
+
12
+ }
app/code/community/Codex/Yapital/Block/Config/Credentials/Sandbox.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_Config_Credentials_Sandbox
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ /*
7
+ * Set template
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('yapital/config/credentials/sandbox.phtml');
13
+ }
14
+
15
+ /**
16
+ * Remove scope label
17
+ *
18
+ * @param Varien_Data_Form_Element_Abstract $element
19
+ * @return string
20
+ */
21
+ public function render(Varien_Data_Form_Element_Abstract $element)
22
+ {
23
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
+ return parent::render($element);
25
+ }
26
+
27
+ /**
28
+ * Return element html
29
+ *
30
+ * @param Varien_Data_Form_Element_Abstract $element
31
+ * @return string
32
+ */
33
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
+ {
35
+ return $this->_toHtml();
36
+ }
37
+
38
+ /**
39
+ * Return ajax url for synchronize button
40
+ *
41
+ * @return string
42
+ */
43
+ public function getAjaxValidateUpdateUrl()
44
+ {
45
+ // @todo yapital_system_config_system_storage/validate
46
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/validateSandbox');
47
+ }
48
+
49
+ /**
50
+ * Return ajax url for synchronize button
51
+ *
52
+ * @return string
53
+ */
54
+ public function getAjaxStatusUpdateUrl()
55
+ {
56
+ // @todo yapital_system_config_system_storage/status
57
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/statusSandbox');
58
+ }
59
+
60
+ /**
61
+ * Generate synchronize button html
62
+ *
63
+ * @return string
64
+ */
65
+ public function getButtonHtml()
66
+ {
67
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'id' => 'validate_button',
70
+ 'label' => $this->helper('yapital/data')->__('Validate sandbox credentials'),
71
+ 'onclick' => 'javascript:validateSandboxYapital(); return false;'
72
+ ));
73
+ return $button->toHtml();
74
+ }
75
+ }
app/code/community/Codex/Yapital/Block/Config/Notification/Sandbox.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_Config_Notification_Sandbox
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ /*
7
+ * Set template
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('yapital/system/config/storage/credentials/sandbox/notification.phtml');
13
+ }
14
+
15
+ /**
16
+ * Remove scope label
17
+ *
18
+ * @param Varien_Data_Form_Element_Abstract $element
19
+ * @return string
20
+ */
21
+ public function render(Varien_Data_Form_Element_Abstract $element)
22
+ {
23
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
+ return parent::render($element);
25
+ }
26
+
27
+ /**
28
+ * Return ajax url for synchronize button
29
+ *
30
+ * @return string
31
+ */
32
+ public function getAjaxRegisterUrl()
33
+ {
34
+ // @todo yapital_system_config_system_storage/validate
35
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_sandbox/register');
36
+ }
37
+
38
+ /**
39
+ * Return ajax url for synchronize button
40
+ *
41
+ * @return string
42
+ */
43
+ public function getAjaxStatusUpdateUrl()
44
+ {
45
+ // @todo yapital_system_config_system_storage/status
46
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_sandbox/status');
47
+ }
48
+
49
+ /**
50
+ * Return element html
51
+ *
52
+ * @param Varien_Data_Form_Element_Abstract $element
53
+ * @return string
54
+ */
55
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
56
+ {
57
+ return $this->_toHtml();
58
+ }
59
+
60
+ /**
61
+ * Generate synchronize button html
62
+ *
63
+ * @return string
64
+ */
65
+ public function getButtonHtml()
66
+ {
67
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'id' => 'notification_button',
70
+ 'label' => $this->helper('yapital/data')->__('Register sandbox notification'),
71
+ 'onclick' => 'javascript:yapitalSandboxNotificationRegister(); return false;'
72
+ ));
73
+ return $button->toHtml();
74
+ }
75
+ }
app/code/community/Codex/Yapital/Block/Standard/Iframe.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_Standard_Iframe extends Codex_Yapital_Block_AbstractBlock {
4
+
5
+ protected $_order_transaction;
6
+
7
+ public function setOrderTransaction( Codex_Yapital_Model_Order_Transaction $order_transaction ) {
8
+ $this->_order_transaction = $order_transaction;
9
+
10
+ $order = $this->_order_transaction->getOrder();
11
+ $this->_getConfig()->importOrder( $order );
12
+ }
13
+
14
+ /**
15
+ * @return Codex_Yapital_Model_Order_Transaction
16
+ */
17
+ public function getOrderTransaction() {
18
+ return $this->_order_transaction;
19
+ }
20
+
21
+ public function getApiUrl() {
22
+ return $this->_getConfig()->getApiUrl();
23
+ }
24
+
25
+ public function getApiIFrameScript()
26
+ {
27
+ return $this->_getConfig()->getApiUrl() . $this->_getConfig()->getApiIFrameScript();
28
+ }
29
+
30
+ public function getTransactionId() {
31
+ return $this->getOrderTransaction()->getTransactionId();
32
+ }
33
+
34
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Live/Secret.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Live_Secret
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ /*
7
+ * Set template
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('yapital/system/config/storage/credentials/live/secret.phtml');
13
+ }
14
+
15
+ /**
16
+ * Remove scope label
17
+ *
18
+ * @param Varien_Data_Form_Element_Abstract $element
19
+ * @return string
20
+ */
21
+ public function render(Varien_Data_Form_Element_Abstract $element)
22
+ {
23
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
+ return parent::render($element);
25
+ }
26
+
27
+ /**
28
+ * Return element html
29
+ *
30
+ * @param Varien_Data_Form_Element_Abstract $element
31
+ * @return string
32
+ */
33
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
+ {
35
+ return $this->_toHtml();
36
+ }
37
+
38
+ /**
39
+ * Generate synchronize button html
40
+ *
41
+ * @return string
42
+ */
43
+ public function getButtonHtml()
44
+ {
45
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
46
+ ->setData(array(
47
+ 'id' => 'notification_generate_secret_button',
48
+ 'label' => $this->helper('yapital/data')->__('Generate a new notification secret'),
49
+ 'onclick' => 'javascript:yapitalLiveGenerateNotificationSecret(); return false;'
50
+ ));
51
+ return $button->toHtml();
52
+ }
53
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Notification.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Notification
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ /*
7
+ * Set template
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('yapital/system/config/storage/credentials/notification.phtml');
13
+ }
14
+
15
+ /**
16
+ * Remove scope label
17
+ *
18
+ * @param Varien_Data_Form_Element_Abstract $element
19
+ * @return string
20
+ */
21
+ public function render(Varien_Data_Form_Element_Abstract $element)
22
+ {
23
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
+ return parent::render($element);
25
+ }
26
+
27
+ /**
28
+ * Return ajax url for synchronize button
29
+ *
30
+ * @return string
31
+ */
32
+ public function getAjaxRegisterUrl()
33
+ {
34
+ // @todo yapital_system_config_system_storage/validate
35
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_notification/register');
36
+ }
37
+
38
+ /**
39
+ * Return ajax url for synchronize button
40
+ *
41
+ * @return string
42
+ */
43
+ public function getAjaxStatusUpdateUrl()
44
+ {
45
+ // @todo yapital_system_config_system_storage/status
46
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_notification/status');
47
+ }
48
+
49
+ /**
50
+ * Return element html
51
+ *
52
+ * @param Varien_Data_Form_Element_Abstract $element
53
+ * @return string
54
+ */
55
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
56
+ {
57
+ return $this->_toHtml();
58
+ }
59
+
60
+ /**
61
+ * Generate synchronize button html
62
+ *
63
+ * @return string
64
+ */
65
+ public function getButtonHtml()
66
+ {
67
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'id' => 'notification_button',
70
+ 'label' => $this->helper('yapital/data')->__('Register live notification'),
71
+ 'onclick' => 'javascript:yapitalNotificationRegister(); return false;'
72
+ ));
73
+ return $button->toHtml();
74
+ }
75
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ /*
7
+ * Set template
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('yapital/system/config/storage/credentials/sandbox/notification.phtml');
13
+ }
14
+
15
+ /**
16
+ * Remove scope label
17
+ *
18
+ * @param Varien_Data_Form_Element_Abstract $element
19
+ * @return string
20
+ */
21
+ public function render(Varien_Data_Form_Element_Abstract $element)
22
+ {
23
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
+ return parent::render($element);
25
+ }
26
+
27
+ /**
28
+ * Return ajax url for synchronize button
29
+ *
30
+ * @return string
31
+ */
32
+ public function getAjaxRegisterUrl()
33
+ {
34
+ // @todo yapital_system_config_system_storage/validate
35
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_sandbox/register');
36
+ }
37
+
38
+ /**
39
+ * Return ajax url for synchronize button
40
+ *
41
+ * @return string
42
+ */
43
+ public function getAjaxStatusUpdateUrl()
44
+ {
45
+ // @todo yapital_system_config_system_storage/status
46
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_sandbox/status');
47
+ }
48
+
49
+ /**
50
+ * Return element html
51
+ *
52
+ * @param Varien_Data_Form_Element_Abstract $element
53
+ * @return string
54
+ */
55
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
56
+ {
57
+ return $this->_toHtml();
58
+ }
59
+
60
+ /**
61
+ * Generate synchronize button html
62
+ *
63
+ * @return string
64
+ */
65
+ public function getButtonHtml()
66
+ {
67
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'id' => 'notification_button',
70
+ 'label' => $this->helper('yapital/data')->__('Register sandbox notification'),
71
+ 'onclick' => 'javascript:yapitalSandboxNotificationRegister(); return false;'
72
+ ));
73
+ return $button->toHtml();
74
+ }
75
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Secret.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox_Secret
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ /*
7
+ * Set template
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('yapital/system/config/storage/credentials/sandbox/secret.phtml');
13
+ }
14
+
15
+ /**
16
+ * Remove scope label
17
+ *
18
+ * @param Varien_Data_Form_Element_Abstract $element
19
+ * @return string
20
+ */
21
+ public function render(Varien_Data_Form_Element_Abstract $element)
22
+ {
23
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
+ return parent::render($element);
25
+ }
26
+
27
+ /**
28
+ * Return element html
29
+ *
30
+ * @param Varien_Data_Form_Element_Abstract $element
31
+ * @return string
32
+ */
33
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
+ {
35
+ return $this->_toHtml();
36
+ }
37
+
38
+ /**
39
+ * Generate synchronize button html
40
+ *
41
+ * @return string
42
+ */
43
+ public function getButtonHtml()
44
+ {
45
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
46
+ ->setData(array(
47
+ 'id' => 'notification_generate_secret_button',
48
+ 'label' => $this->helper('yapital/data')->__('Generate a new notification secret'),
49
+ 'onclick' => 'javascript:yapitalSandboxGenerateNotificationSecret(); return false;'
50
+ ));
51
+ return $button->toHtml();
52
+ }
53
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Validate.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Validate
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ /*
7
+ * Set template
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('yapital/system/config/storage/credentials/validate.phtml');
13
+ }
14
+
15
+ /**
16
+ * Remove scope label
17
+ *
18
+ * @param Varien_Data_Form_Element_Abstract $element
19
+ * @return string
20
+ */
21
+ public function render(Varien_Data_Form_Element_Abstract $element)
22
+ {
23
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
+ return parent::render($element);
25
+ }
26
+
27
+ /**
28
+ * Return element html
29
+ *
30
+ * @param Varien_Data_Form_Element_Abstract $element
31
+ * @return string
32
+ */
33
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
+ {
35
+ return $this->_toHtml();
36
+ }
37
+
38
+ /**
39
+ * Return ajax url for synchronize button
40
+ *
41
+ * @return string
42
+ */
43
+ public function getAjaxValidateUpdateUrl()
44
+ {
45
+ // @todo yapital_system_config_system_storage/validate
46
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/validate');
47
+ }
48
+
49
+ /**
50
+ * Return ajax url for synchronize button
51
+ *
52
+ * @return string
53
+ */
54
+ public function getAjaxStatusUpdateUrl()
55
+ {
56
+ // @todo yapital_system_config_system_storage/status
57
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/status');
58
+ }
59
+
60
+ /**
61
+ * Generate synchronize button html
62
+ *
63
+ * @return string
64
+ */
65
+ public function getButtonHtml()
66
+ {
67
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'id' => 'validate_button',
70
+ 'label' => $this->helper('yapital/data')->__('Validate live credentials'),
71
+ 'onclick' => 'javascript:validateYapital(); return false;'
72
+ ));
73
+ return $button->toHtml();
74
+ }
75
+
76
+ /**
77
+ * Generate switch button html
78
+ *
79
+ * @return string
80
+ */
81
+ public function getSwitchButtonHtml()
82
+ {
83
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
84
+ ->setData(array(
85
+ 'id' => 'validate_button',
86
+ 'label' => $this->helper('yapital/data')->__('Switch'),
87
+ 'onclick' => 'javascript:yapitalSwitch(); return false;'
88
+ ));
89
+ return $button->toHtml();
90
+ }
91
+ }
app/code/community/Codex/Yapital/ErrorException.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contains the Exception-Class for Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Yapital
10
+ * @package Codex_Yapital
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * An exception class for the Yapital API to catch errors that are thrown by this extension.
18
+ *
19
+ *
20
+ * @category Yapital
21
+ * @package Codex_Yapital
22
+ * @copyright 2013 Code-X GmbH
23
+ * @link http://code-x.de
24
+ * @since Class available since Release 0.1.0
25
+ */
26
+ class Codex_Yapital_ErrorException extends ErrorException {
27
+ const UNKNOWN_STORE_ID = 0x100;
28
+ }
app/code/community/Codex/Yapital/Exception.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contains the Exception-Class for Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Yapital
10
+ * @package Codex_Yapital
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * An exception class for the Yapital API to catch errors that are thrown by this extension.
18
+ *
19
+ *
20
+ * @category Yapital
21
+ * @package Codex_Yapital
22
+ * @copyright 2013 Code-X GmbH
23
+ * @link http://code-x.de
24
+ * @since Class available since Release 0.1.0
25
+ */
26
+ class Codex_Yapital_Exception extends Exception {}
app/code/community/Codex/Yapital/Helper/Data.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ public function getOrderHash( Mage_Sales_Model_Order $order )
7
+ {
8
+ return md5( $order->getId() . $this->_getConfig()->getNotificationSecret() );
9
+ }
10
+
11
+ /**
12
+ * Gets the Config model
13
+ *
14
+ * @return \Codex_Yapital_Model_Config
15
+ */
16
+ protected function _getConfig() {
17
+ return Mage::getSingleton('yapital/config');
18
+ }
19
+
20
+ }
app/code/community/Codex/Yapital/Model/Abstract.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Abstract
4
+ {
5
+ }
app/code/community/Codex/Yapital/Model/Api/Abstract.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Api_Abstract
4
+ {
5
+
6
+ /* @var Codex_Yapital_Model_Api_Restclient */
7
+ protected $_client;
8
+
9
+ protected $_yapitalConfig;
10
+
11
+ const URL = '/';
12
+
13
+
14
+ /**
15
+ * @return Codex_Yapital_Model_Api_Restclient
16
+ */
17
+ public function getClient()
18
+ {
19
+ if (!$this->_client)
20
+ {
21
+ $config = $this->_getConfig();
22
+ /**
23
+ * @var $config Codex_Yapital_Model_Config
24
+ */
25
+ $this->_client = Mage::getModel('yapital/api_restclient', $config->getApiUrl());
26
+ }
27
+
28
+ return $this->_client;
29
+ }
30
+
31
+
32
+ /**
33
+ * Gets the Config model
34
+ *
35
+ * @return \Codex_Yapital_Model_Config
36
+ */
37
+ protected function _getConfig()
38
+ {
39
+ if (null == $this->_yapitalConfig)
40
+ {
41
+ $this->_yapitalConfig = Mage::getSingleton('yapital/config');
42
+ }
43
+
44
+ return $this->_yapitalConfig;
45
+ }
46
+
47
+
48
+ protected function _getQuery($data = array())
49
+ {
50
+ /** @var $tokenModel Codex_Yapital_Model_Api_Token */
51
+ $tokenModel = Mage::getModel("yapital/api_token");
52
+
53
+ $token = $tokenModel->getTokenByCredentials(
54
+ $this->_getConfig()->getApiClientId(),
55
+ $this->_getConfig()->getApiSecret()
56
+ );
57
+
58
+ $data['access_token'] = $token->getAccessToken();
59
+
60
+ return $data;
61
+ }
62
+
63
+
64
+ protected function _makeUrl()
65
+ {
66
+ $args = func_get_args();
67
+
68
+ foreach( $args AS &$arg ) {
69
+ $arg = urlencode($arg);
70
+ }
71
+
72
+ return vsprintf(static::URL, $args);
73
+ }
74
+
75
+
76
+ /***
77
+ * @see Codex_Yapital_Model_Log
78
+ *
79
+ * @param $url
80
+ * @param $data array
81
+ *
82
+ * @return string
83
+ */
84
+ protected function _send($path, $data)
85
+ {
86
+ $querydata = $this->_getQuery();
87
+
88
+ $path = $this->_getConfig()->getApiUrlPath() . $path;
89
+ Codex_Yapital_Model_Log::log("Send request to " . $path );
90
+ Codex_Yapital_Model_Log::debug("Data:" . $data->toJSON() );
91
+
92
+ $this->getClient()->resetHttpClient();
93
+ $response = $this->getClient()->restPostQuery($path, $querydata, $data->toJSON())->getBody();
94
+
95
+ return $response;
96
+ }
97
+ }
app/code/community/Codex/Yapital/Model/Api/Basket/Transaction.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Api_Basket_Transaction extends Codex_Yapital_Model_Api_Abstract
4
+ {
5
+
6
+ /* @var Codex_Yapital_Model_Order_Transaction */
7
+ protected $_orderTransaction;
8
+
9
+ /**
10
+ * Submit the BasketsTransaction
11
+ *
12
+ * @return Codex_Yapital_Model_Datatype_Shoprestresponse
13
+ */
14
+ public function sendOrder ( Mage_Sales_Model_Order $order )
15
+ {
16
+ Codex_Yapital_Model_Log::log("Sending BasketTransaction");
17
+
18
+ /* @var $basketTransaction Codex_Yapital_Model_DataType_BasketsTransaction */
19
+ $basketTransaction = Mage::getModel('yapital/datatype_basketstransaction');
20
+ $basketTransaction->importOrder($order);
21
+
22
+
23
+ $url = '/shops/' . $this->_getConfig()->getYapitalShopId() . '/basket_transaction';
24
+ $response = $this->_send($url, $basketTransaction);
25
+
26
+ /**
27
+ * @var $shopRestResponse Codex_Yapital_Model_Datatype_Shoprestresponse
28
+ */
29
+ $shopRestResponse = Mage::getModel("yapital/datatype_shoprestresponse");
30
+ $shopRestResponse->importRawResponse($response);
31
+
32
+ $order_transaction = $this->getOrderTransaction();
33
+ $order_transaction->importShopRestResponse($order, $shopRestResponse);
34
+
35
+ $order_transaction->save();
36
+
37
+ return $shopRestResponse;
38
+ }
39
+
40
+ /**
41
+ * @return Codex_Yapital_Model_Order_Transaction
42
+ */
43
+ public function getOrderTransaction ()
44
+ {
45
+ if ( !$this->_orderTransaction )
46
+ {
47
+ $this->_orderTransaction = Mage::getModel("yapital/order_transaction");
48
+ }
49
+
50
+ return $this->_orderTransaction;
51
+ }
52
+
53
+ }
app/code/community/Codex/Yapital/Model/Api/Notification.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Api_Notification extends Codex_Yapital_Model_Api_Abstract {
4
+
5
+ /**
6
+ * @param Codex_Yapital_Model_Datatype_Notification $data
7
+ *
8
+ * @return Codex_Yapital_Model_Datatype_Shoprestresponse
9
+ */
10
+ public function register( Codex_Yapital_Model_Datatype_Notification $data ) {
11
+
12
+ Codex_Yapital_Model_Log::log("Registering new notification.");
13
+
14
+ $url = "/shops/" . $this->_getConfig()->getYapitalShopId() . "/notifications";
15
+
16
+ $send = $this->_send($url, $data);
17
+
18
+ /**
19
+ * @var $register Codex_Yapital_Model_Datatype_Shoprestresponse
20
+ */
21
+ $register = Mage::getModel("yapital/datatype_shoprestresponse");
22
+ $register->importRawResponse($send);
23
+
24
+ return $register;
25
+ }
26
+
27
+ public function delete( $notification_id )
28
+ {
29
+ if ( $this->get( $notification_id ) )
30
+ {
31
+ $query_data = $this->_getQuery();
32
+ $url = $this->_getConfig()->getApiUrlPath().'/shops/'.$this->_getConfig()->getYapitalShopId().'/notifications/'.$notification_id;
33
+
34
+ $this->getClient()->resetHttpClient();
35
+ $response = $this->getClient()->restDeleteQuery( $url, $query_data );
36
+
37
+ if ( $response->isError() )
38
+ {
39
+ throw new Codex_Yapital_ErrorException("could not delete notification $notification_id");
40
+ }
41
+ }
42
+
43
+ return $this;
44
+ }
45
+
46
+ public function getAll()
47
+ {
48
+ $result = array();
49
+
50
+ $query_data = $this->_getQuery();
51
+ $url = $this->_getConfig()->getApiUrlPath().'/shops/'.$this->_getConfig()->getYapitalShopId().'/notifications';
52
+
53
+ $this->getClient()->resetHttpClient();
54
+ $response = $this->getClient()->restGet( $url, $query_data )->getBody();
55
+
56
+ if ( $data = json_decode($response,1) )
57
+ {
58
+
59
+ foreach( $data['payload'] AS $payload ) {
60
+ $notification = Mage::getModel('yapital/datatype_notification');
61
+ /* @var $notification Codex_Yapital_Model_Datatype_Notification */
62
+
63
+ $notification->importPayload( $payload );
64
+
65
+ $result[] = $notification;
66
+ }
67
+
68
+ }
69
+
70
+ return $result;
71
+ }
72
+
73
+ public function get( $notification_id )
74
+ {
75
+ $query_data = $this->_getQuery();
76
+ $url = $this->_getConfig()->getApiUrlPath().'/shops/'.$this->_getConfig()->getYapitalShopId().'/notifications/'.$notification_id;
77
+
78
+ $this->getClient()->resetHttpClient();
79
+ $response = $this->getClient()->restGet( $url, $query_data )->getBody();
80
+
81
+ if ( $data = json_decode($response,1) ) {
82
+ $notification = Mage::getModel('yapital/datatype_notification');
83
+ /* @var $notification Codex_Yapital_Model_Datatype_Notification */
84
+
85
+ $notification->importPayload( $data['payload'] );
86
+ return $notification;
87
+ }
88
+
89
+ throw new Codex_Yapital_ErrorException('could not get notification_id '.$notification_id);
90
+ }
91
+
92
+ }
app/code/community/Codex/Yapital/Model/Api/Restclient.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Api_Restclient extends Zend_Service_Abstract
4
+ {
5
+
6
+ /**
7
+ * Data for the query
8
+ * @var array
9
+ */
10
+ protected $_data = array();
11
+
12
+ /**
13
+ * Zend_Uri of this web service
14
+ * @var Zend_Uri_Http
15
+ */
16
+ protected $_uri = null;
17
+
18
+ public function __construct ( $uri = null )
19
+ {
20
+ if (!empty($uri)) {
21
+ $this->setUri($uri);
22
+ }
23
+
24
+ $adapter = new Zend_Http_Client_Adapter_Curl();
25
+
26
+ $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
27
+ $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
28
+ $adapter->setCurlOption(CURLOPT_SSLVERSION, 3);
29
+
30
+ self::getHttpClient()->setAdapter($adapter);
31
+
32
+ }
33
+
34
+
35
+ /**
36
+ * Send a REST POST Query.
37
+ *
38
+ * @param $path
39
+ * @param array $query
40
+ * @param string $data
41
+ *
42
+ * @return Zend_Http_Response
43
+ */
44
+ public function restPostQuery( $path, $query = array(), $data = '' )
45
+ {
46
+ $this->_prepareRest($path);
47
+ $client = self::getHttpClient();
48
+ $client->setParameterGet($query);
49
+ $client->setRawData($data);
50
+
51
+ self::getHttpClient()->setEncType(false);
52
+
53
+ return $client->request('POST');
54
+ }
55
+
56
+ public function restDeleteQuery($path, $query)
57
+ {
58
+ $this->_prepareRest($path);
59
+ $client = self::getHttpClient();
60
+ $client->setParameterGet($query);
61
+ return $client->request('DELETE');
62
+ }
63
+
64
+ public function resetHttpClient()
65
+ {
66
+ /**
67
+ * Get the HTTP client and configure it for the endpoint URI. Do this each time
68
+ * because the Zend_Http_Client instance is shared among all Zend_Service_Abstract subclasses.
69
+ */
70
+ self::getHttpClient()->resetParameters(true);
71
+
72
+ //
73
+ // Only Accept JSON
74
+ self::getHttpClient()->setHeaders('Accept','application/json');
75
+
76
+ //
77
+ // Only send json
78
+ self::getHttpClient()->setHeaders('Content-Type','application/json');
79
+
80
+ }
81
+
82
+ /**
83
+ * Set the URI to use in the request
84
+ *
85
+ * @param string|Zend_Uri_Http $uri URI for the web service
86
+ * @return Zend_Rest_Client
87
+ */
88
+ public function setUri($uri)
89
+ {
90
+ if ($uri instanceof Zend_Uri_Http) {
91
+ $this->_uri = $uri;
92
+ } else {
93
+ $this->_uri = Zend_Uri::factory($uri);
94
+ }
95
+
96
+ return $this;
97
+ }
98
+
99
+ /**
100
+ * Retrieve the current request URI object
101
+ *
102
+ * @return Zend_Uri_Http
103
+ */
104
+ public function getUri()
105
+ {
106
+ return $this->_uri;
107
+ }
108
+
109
+ /**
110
+ * Call a remote REST web service URI and return the Zend_Http_Response object
111
+ *
112
+ * @param string $path The path to append to the URI
113
+ * @throws Zend_Rest_Client_Exception
114
+ * @return void
115
+ */
116
+ private function _prepareRest($path)
117
+ {
118
+ // Get the URI object and configure it
119
+ if (!$this->_uri instanceof Zend_Uri_Http) {
120
+ #require_once 'Zend/Rest/Client/Exception.php';
121
+ throw new Zend_Rest_Client_Exception('URI object must be set before performing call');
122
+ }
123
+
124
+ $uri = $this->_uri->getUri();
125
+
126
+ if ($path[0] != '/' && $uri[strlen($uri)-1] != '/') {
127
+ $path = '/' . $path;
128
+ }
129
+
130
+ $this->_uri->setPath($path);
131
+
132
+ $this->getHttpClient()->setUri($this->_uri);
133
+ }
134
+
135
+ /**
136
+ * Performs an HTTP GET request to the $path.
137
+ *
138
+ * @param string $path
139
+ * @param array $query Array of GET parameters
140
+ * @throws Zend_Http_Client_Exception
141
+ * @return Zend_Http_Response
142
+ */
143
+ public function restGet($path, array $query = null)
144
+ {
145
+ $this->_prepareRest($path);
146
+ $client = self::getHttpClient();
147
+ $client->setParameterGet($query);
148
+ return $client->request('GET');
149
+ }
150
+
151
+ /**
152
+ * Perform a POST or PUT
153
+ *
154
+ * Performs a POST or PUT request. Any data provided is set in the HTTP
155
+ * client. String data is pushed in as raw POST data; array or object data
156
+ * is pushed in as POST parameters.
157
+ *
158
+ * @param mixed $method
159
+ * @param mixed $data
160
+ * @return Zend_Http_Response
161
+ */
162
+ function _performPost($method, $data = null)
163
+ {
164
+ $client = self::getHttpClient();
165
+ if (is_string($data)) {
166
+ $client->setRawData($data);
167
+ } elseif (is_array($data) || is_object($data)) {
168
+ $client->setParameterPost((array) $data);
169
+ }
170
+
171
+ $_performPost = $client->request($method);
172
+ $status = $_performPost->getStatus();
173
+
174
+ if (substr($status, 0, 1) != 2) {
175
+ Codex_Yapital_Model_Log::error("Unable to communicate with api. " . $_performPost->getMessage());
176
+ }
177
+ return $_performPost;
178
+ }
179
+
180
+ /**
181
+ * Performs an HTTP POST request to $path.
182
+ *
183
+ * @param string $path
184
+ * @param mixed $data Raw data to send
185
+ * @throws Zend_Http_Client_Exception
186
+ * @return Zend_Http_Response
187
+ */
188
+ final public function restPost($path, $data = null)
189
+ {
190
+ $this->_prepareRest($path);
191
+ return $this->_performPost('POST', $data);
192
+ }
193
+
194
+ /**
195
+ * Performs an HTTP PUT request to $path.
196
+ *
197
+ * @param string $path
198
+ * @param mixed $data Raw data to send in request
199
+ * @throws Zend_Http_Client_Exception
200
+ * @return Zend_Http_Response
201
+ */
202
+ public function restPut($path, $data = null)
203
+ {
204
+ $this->_prepareRest($path);
205
+ return $this->_performPost('PUT', $data);
206
+ }
207
+
208
+ /**
209
+ * Performs an HTTP DELETE request to $path.
210
+ *
211
+ * @param string $path
212
+ * @throws Zend_Http_Client_Exception
213
+ * @return Zend_Http_Response
214
+ */
215
+ public function restDelete($path)
216
+ {
217
+ $this->_prepareRest($path);
218
+ return self::getHttpClient()->request('DELETE');
219
+ }
220
+
221
+
222
+ }
app/code/community/Codex/Yapital/Model/Api/ReturnBasket.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contains class.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ */
8
+
9
+ /**
10
+ * Class ReturnBasket.
11
+ *
12
+ * @category yapital-magento
13
+ */
14
+ class Codex_Yapital_Model_Api_ReturnBasket extends Codex_Yapital_Model_Api_Abstract
15
+ {
16
+ const URL = '/shops/%s/transactions/%s/return_basket';
17
+
18
+ public function send($shopId, $transactionId, $returnBasket)
19
+ {
20
+ $url = $this->_makeUrl($shopId, $transactionId);
21
+
22
+ return $this->_send($url, $returnBasket);
23
+ }
24
+
25
+
26
+ }
app/code/community/Codex/Yapital/Model/Api/Token.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Api_Token extends Codex_Yapital_Model_Api_Abstract
4
+ {
5
+
6
+ /**
7
+ * @uses Codex_Yapital_Model_Log , Mage
8
+ *
9
+ * @param string $client_id
10
+ * @param string $secret
11
+ *
12
+ * @return Codex_Yapital_Model_Datatype_Token
13
+ */
14
+ public function getTokenByCredentials($client_id, $secret)
15
+ {
16
+ \Codex_Yapital_Model_Log::log(
17
+ "Get new token from authentication server for shop " . $this->_getConfig()->getYapitalShopId()
18
+ );
19
+
20
+ $config = $this->_getConfig();
21
+ $client = $this->getClient();
22
+
23
+ if (null == $client_id || null == $secret)
24
+ {
25
+ throw new LogicException('ClientId and Secret can not be null');
26
+ }
27
+
28
+ $auth = "Basic " . base64_encode($client_id . ":" . $secret);
29
+ $client->resetHttpClient();
30
+ $client->getHttpClient()->setHeaders(
31
+ array(
32
+ 'Accept' => 'application/json',
33
+ 'Accept-Encoding' => 'gzip,deflate',
34
+ 'Authorization' => $auth,
35
+ 'Content-Type' => 'application/x-www-form-urlencoded',
36
+ 'Connection' => 'keepalive',
37
+ )
38
+ );
39
+
40
+ $response = $client->restPost(
41
+ $config->getApiUrlPath() . '/oauth/token',
42
+ 'grant_type=client_credentials'
43
+ );
44
+
45
+ /** @var $token Codex_Yapital_Model_Datatype_Token */
46
+ $token = Mage::getModel("yapital/datatype_token");
47
+
48
+ $token->importArray(json_decode($response->getBody(), true));
49
+
50
+ if ($token->getAccessToken() == "")
51
+ {
52
+ Codex_Yapital_Model_Log::error("Could not receive token");
53
+ }
54
+ else
55
+ {
56
+ Codex_Yapital_Model_Log::verbose('Received token.');
57
+ }
58
+
59
+
60
+ return $token;
61
+ }
62
+
63
+
64
+ /**
65
+ * @param string $storeId
66
+ * @param string $clientId
67
+ * @param string $secret
68
+ *
69
+ * @return Codex_Yapital_Model_Datatype_Token
70
+ */
71
+ public function getTokenByFullCredentials($storeId, $clientId, $secret)
72
+ {
73
+ $config = $this->_getConfig();
74
+ /**
75
+ * @var $config Codex_Yapital_Model_Config
76
+ */
77
+ $config->setStoreId($storeId);
78
+
79
+ return $this->getTokenByCredentials(
80
+ $clientId,
81
+ $secret
82
+ );
83
+ }
84
+
85
+
86
+ public function getTokenByStoreConfig($store_id = null)
87
+ {
88
+ $config = $this->_getConfig();
89
+ /**
90
+ * @var $config Codex_Yapital_Model_Config
91
+ */
92
+ $config->setStoreId($store_id);
93
+
94
+ return
95
+ $this->getTokenByCredentials(
96
+ $config->getApiClientId(),
97
+ $config->getApiSecret()
98
+ );
99
+ }
100
+ }
app/code/community/Codex/Yapital/Model/Config.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Config
4
+ {
5
+
6
+ protected $_storeId = null;
7
+ protected $_force_sandbox = false;
8
+
9
+ /**
10
+ * Helps forcing Sandbox Settings
11
+ * @param $bool
12
+ */
13
+ public function setSandbox( $bool )
14
+ {
15
+ $this->_force_sandbox = $bool;
16
+ }
17
+
18
+ /**
19
+ * Get the IFrame Script
20
+ *
21
+ * This script is used at the end of the payment process.
22
+ * After checkout.
23
+ *
24
+ * @return Mage_Core_Model_Config_Element
25
+ */
26
+ public function getApiIFrameScript()
27
+ {
28
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
29
+ {
30
+ // sandbox
31
+ return Mage::getConfig()->getNode('default/yapital_sandbox/url/iframe_script');
32
+ } else {
33
+ // live
34
+ return Mage::getConfig()->getNode('default/yapital/url/iframe_script');
35
+ }
36
+ }
37
+
38
+
39
+ /**
40
+ * Get the base URL of the api
41
+ *
42
+ * @return Mage_Core_Model_Config_Element
43
+ */
44
+ public function getApiUrl()
45
+ {
46
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
47
+ {
48
+ // sandbox
49
+ return Mage::getConfig()->getNode('default/yapital_sandbox/url/base');
50
+ } else {
51
+ // live
52
+ return Mage::getConfig()->getNode('default/yapital/url/base');
53
+ }
54
+ }
55
+
56
+
57
+ public function getApiClientId()
58
+ {
59
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
60
+ { // sandbox is selected: return sandbox setting
61
+ $clientId = Mage::getStoreConfig('payment/yapital_standard/sandbox_client_id', $this->getStoreId());
62
+ }
63
+ else
64
+ { // default: live
65
+ $clientId = Mage::getStoreConfig('payment/yapital_standard/client_id', $this->getStoreId());
66
+ }
67
+
68
+ return $clientId;
69
+ }
70
+
71
+
72
+ public function getApiSecret()
73
+ {
74
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
75
+ { // sandbox is selected: return sandbox setting
76
+ $apiSecret = Mage::getStoreConfig('payment/yapital_standard/sandbox_secret_key', $this->getStoreId());
77
+ }
78
+ else
79
+ { // default: live
80
+ $apiSecret = Mage::getStoreConfig('payment/yapital_standard/secret_key', $this->getStoreId());
81
+ }
82
+
83
+ return $apiSecret;
84
+ }
85
+
86
+
87
+ /**
88
+ * Get the path to the api
89
+ *
90
+ * @return Mage_Core_Model_Config_Element
91
+ */
92
+ public function getApiUrlPath()
93
+ {
94
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
95
+ {
96
+ // sandbox
97
+ return Mage::getConfig()->getNode('default/yapital_sandbox/url/api');
98
+ } else {
99
+ // live
100
+ return Mage::getConfig()->getNode('default/yapital/url/api');
101
+ }
102
+ }
103
+
104
+
105
+ public function getCredentialsSwitch()
106
+ {
107
+ if( $this->_force_sandbox )
108
+ {
109
+ return Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX;
110
+ }
111
+ return Mage::getStoreConfig('payment/yapital_standard/credentials_switch', $this->getStoreId());
112
+ }
113
+
114
+
115
+ public function getNotificationSecret()
116
+ {
117
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
118
+ { // sandbox is selected: return sandbox setting
119
+ $notificationSecret = Mage::getStoreConfig(
120
+ 'payment/yapital_standard/sandbox_notification_secret',
121
+ $this->getStoreId()
122
+ );
123
+ }
124
+ else
125
+ {
126
+ $notificationSecret = Mage::getStoreConfig(
127
+ 'payment/yapital_standard/notification_secret',
128
+ $this->getStoreId()
129
+ );
130
+ }
131
+
132
+ return $notificationSecret;
133
+ }
134
+
135
+
136
+ public function getOrderPaidState()
137
+ {
138
+ return Mage::getStoreConfig('payment/yapital_standard/order_status', $this->getStoreId());
139
+ }
140
+
141
+
142
+ public function getStoreId()
143
+ {
144
+ if (null === $this->_storeId)
145
+ {
146
+ $this->_storeId = Mage::app()->getStore()->getStoreId();
147
+ }
148
+
149
+ return $this->_storeId;
150
+ }
151
+
152
+
153
+ public function getYapitalShopId()
154
+ {
155
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
156
+ { // sandbox is selected: use sandbox setting
157
+ $shopId = Mage::getStoreConfig('payment/yapital_standard/sandbox_shop_id', $this->getStoreId());
158
+ }
159
+ else
160
+ { // default: live
161
+ $shopId = Mage::getStoreConfig('payment/yapital_standard/shop_id', $this->getStoreId());
162
+ }
163
+
164
+ return $shopId;
165
+ }
166
+
167
+
168
+ public function importOrder(Mage_Sales_Model_Order $order)
169
+ {
170
+ $this->setStoreId($order->getStoreId());
171
+ }
172
+
173
+
174
+ public function setStoreId($store_id)
175
+ {
176
+ $this->_storeId = $store_id;
177
+ return $this;
178
+ }
179
+ }
app/code/community/Codex/Yapital/Model/Datatype/Abstract.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the abstract datatype for all other datatypes of the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5.2
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital
11
+ */
12
+
13
+ /**
14
+ * The abstract type specifies the common operations on all other datatypes for the Yapital API.
15
+ *
16
+ * This would be generating a JSON or XML output.
17
+ *
18
+ * @category Datatype
19
+ * @package Codex_Yapital
20
+ */
21
+ abstract class Codex_Yapital_Model_Datatype_Abstract extends Varien_Object
22
+ implements Codex_Yapital_Model_Datatype_Interface
23
+ {
24
+
25
+ protected $_yapitalConfig;
26
+
27
+ /**
28
+ * Gets the Config model
29
+ *
30
+ * @return \Codex_Yapital_Model_Config
31
+ */
32
+ protected function _getConfig() {
33
+ if (null == $this->_yapitalConfig) {
34
+ $this->_yapitalConfig = Mage::getSingleton('yapital/config');
35
+ }
36
+ return $this->_yapitalConfig;
37
+ }
38
+
39
+ /**
40
+ * Get an JSON representation of this data type.
41
+ *
42
+ * This will make an multidimensional JSON-Object which contains all fields and their values
43
+ * down to simple strings, floats or integer.
44
+ *
45
+ * @runtime O(n)
46
+ *
47
+ * @return string
48
+ */
49
+ public function toJSON ()
50
+ {
51
+
52
+ $theArray = $this->toArray(); // pull as variable for faster handling
53
+
54
+ return json_encode($theArray);
55
+ }
56
+
57
+ /**
58
+ * Get an XML representation of this data type.
59
+ *
60
+ * This will generate XML-Source with the fields as Container and their value as CDATA in it.
61
+ *
62
+ * @runtime O(n)
63
+ *
64
+ * @return bool
65
+ */
66
+ public function toXML ()
67
+ {
68
+
69
+ $toXML = "";
70
+
71
+ // init xml parser and data
72
+ $xmlSerializer = new XML_Serializer( XML_SERIALIZER_OPTION_RETURN_RESULT );
73
+ $theArray = $this->toArray(); // pull as variable for faster handling
74
+
75
+ // parse the data
76
+ $toXML = $xmlSerializer->serialize($theArray);
77
+
78
+ return $toXML;
79
+ }
80
+
81
+ public function toArray ()
82
+ {
83
+ return $this->_toArray($this->getData());
84
+ }
85
+
86
+ /**
87
+ * Get an array representation of this data type.
88
+ *
89
+ * This will make an multidimensional array which contains all fields and their values
90
+ * down to simple strings, floats or integer.
91
+ *
92
+ * @runtime O(n)
93
+ *
94
+ * @throws Codex_Yapital_ErrorException
95
+ *
96
+ * @return array
97
+ */
98
+ protected function _toArray ( $theData )
99
+ {
100
+ $toArray = array();
101
+
102
+ // iterate over fields and values
103
+ foreach ( $theData as $key => $value )
104
+ {
105
+
106
+ if ( $value instanceof Codex_Yapital_Model_Datatype_Interface )
107
+ {
108
+ // it is another yapital data type: get it's array representation
109
+ $toArray[$key] = $value->toArray();
110
+ }
111
+ else if ( is_array($value) )
112
+ {
113
+ $tmp = $this->_toArray($value);
114
+
115
+ // export only those with data in it
116
+ if ( 0 < count($tmp) )
117
+ {
118
+ $toArray[$key] = $tmp;
119
+ }
120
+ }
121
+ else if ( is_scalar($value) )
122
+ {
123
+ $toArray[$key] = $value;
124
+ }
125
+ else if ( $value === null )
126
+ {
127
+ // has no data: don't export it
128
+ }
129
+ else
130
+ {
131
+ // it is unknown: throw error
132
+ throw new Codex_Yapital_ErrorException(
133
+ "Unhandled type of data in key $key: "
134
+ . ( is_object($value) ) ? get_class($value) : gettype($value)
135
+ );
136
+ }
137
+ }
138
+
139
+ return $toArray;
140
+ }
141
+
142
+ /**
143
+ * Get the field-names that can be set by the data type
144
+ *
145
+ * Notice: This can not be called from the method "getData()".
146
+ *
147
+ * @uses getData
148
+ *
149
+ * @return array enum array with fields
150
+ */
151
+ public function getFields ()
152
+ {
153
+
154
+ return array_keys($this->getData());
155
+ }
156
+
157
+
158
+
159
+ }
app/code/community/Codex/Yapital/Model/Datatype/AbstractSimpleType.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the abstract datatype for all other datatypes of the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5.2
7
+ *
8
+ *
9
+ * @category Yapital
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The abstract type specifies the common operations on all other datatypes for the Yapital API.
18
+ *
19
+ * This would be generating a JSON or XML output.
20
+ *
21
+ * @category Yapital
22
+ * @package Codex_Yapital_Model_Datatype
23
+ * @copyright 2013 Code-X GmbH
24
+ * @version Release: @package_version@
25
+ * @link http://code-x.de
26
+ * @since Class available since Release 0.1.0
27
+ */
28
+ abstract class Codex_Yapital_Model_Datatype_AbstractSimpleType
29
+ implements Codex_Yapital_Model_Datatype_Interface
30
+ {
31
+
32
+ protected $_yapitalConfig;
33
+ protected $_value;
34
+
35
+ /**
36
+ * Gets the Config model
37
+ *
38
+ * @return \Codex_Yapital_Model_Config
39
+ */
40
+ protected function _getConfig() {
41
+ if (null == $this->_yapitalConfig) {
42
+ $this->_yapitalConfig = Mage::getSingleton('yapital/config');
43
+ }
44
+ return $this->_yapitalConfig;
45
+ }
46
+
47
+ /**
48
+ * Empty constructor for magento
49
+ */
50
+ function __construct ()
51
+ {
52
+
53
+ }
54
+
55
+ /**
56
+ * Get an JSON representation of this data type.
57
+ *
58
+ * This will make an multidimensional JSON-Object which contains all fields and their values
59
+ * down to simple strings, floats or integer.
60
+ *
61
+ * @runtime O(n)
62
+ *
63
+ * @return string
64
+ */
65
+ public function toJSON ()
66
+ {
67
+
68
+ $theArray = $this->toString(); // pull as variable for faster handling
69
+
70
+ return json_encode($theArray);
71
+ }
72
+
73
+ /**
74
+ * Get an XML representation of this data type.
75
+ *
76
+ * This will generate XML-Source with the fields as Container and their value as CDATA in it.
77
+ *
78
+ * @runtime O(n)
79
+ *
80
+ * @return bool
81
+ */
82
+ public function toXML ()
83
+ {
84
+
85
+ $toXML = "";
86
+
87
+ // init xml parser and data
88
+ $xmlSerializer = new XML_Serializer( XML_SERIALIZER_OPTION_RETURN_RESULT );
89
+ $theArray = $this->toArray(); // pull as variable for faster handling
90
+
91
+ // parse the data
92
+ $toXML = $xmlSerializer->serialize($theArray);
93
+
94
+ return $toXML;
95
+ }
96
+
97
+ function toString() {
98
+ return $this->getData();
99
+ }
100
+
101
+ function setValue($value) {
102
+ $this->_value = $value;
103
+ }
104
+
105
+ function getValue() {
106
+ return $this->_value;
107
+ }
108
+
109
+ function toArray() {
110
+ return $this->getData();
111
+ }
112
+
113
+ /**
114
+ * Get the field-names that can be set by the data type
115
+ *
116
+ * Notice: This can not be called from the method "getData()".
117
+ *
118
+ * @uses getData
119
+ *
120
+ * @return array enum array with fields
121
+ */
122
+ public function getFields ()
123
+ {
124
+
125
+ return array_keys($this->getData());
126
+ }
127
+
128
+ public function getData() {
129
+ return $this->toString();
130
+ }
131
+
132
+
133
+
134
+ }
app/code/community/Codex/Yapital/Model/Datatype/Airlinedata.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the AirlineData datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Yapital
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The AirlineData type specifies the details of an airline ticket purchase.
18
+ *
19
+ * Used by methods
20
+ *
21
+ * Note: The methods are not implemented yet.
22
+ * - POST shops/{id}/baskets/{id}/airline_data
23
+ * - GET shops/{id}/baskets/{id}/airline_data
24
+ * - PUT shops/{id}/baskets/{id}/airline_data
25
+ * - DELETE shops/{id}/baskets/{id}/airline_data
26
+ *
27
+ *
28
+ * @category Yapital
29
+ * @package Codex_Yapital_Model_Datatype
30
+ * @copyright 2013 Code-X GmbH
31
+ * @version Release: @package_version@
32
+ * @link http://code-x.de
33
+ * @since Class available since Release 0.1.0
34
+ */
35
+ class Codex_Yapital_Model_Datatype_AirlineData extends Codex_Yapital_Model_Datatype_Abstract
36
+ implements Codex_Yapital_Model_Datatype_Interface
37
+ {
38
+
39
+ /**
40
+ * @var string
41
+ */
42
+ protected $_ticketDocumentNumber = "";
43
+ /**
44
+ * @var string
45
+ */
46
+ protected $_passengerName = "";
47
+ /**
48
+ * @var string
49
+ */
50
+ protected $_flightDate = "";
51
+ /**
52
+ * @var string
53
+ */
54
+ protected $_flightCoupon = "";
55
+ /**
56
+ * @var string
57
+ */
58
+ protected $_originAirportCityCode = "";
59
+ /**
60
+ * @var string
61
+ */
62
+ protected $_destinationAirportCityCode = "";
63
+ /**
64
+ * @var string
65
+ */
66
+ protected $_carrier = "";
67
+
68
+ /**
69
+ * @param string $carrier
70
+ */
71
+ public function setCarrier ( $carrier )
72
+ {
73
+
74
+ $this->_carrier = $carrier;
75
+
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * @return string
81
+ */
82
+ public function getCarrier ()
83
+ {
84
+
85
+ return $this->_carrier;
86
+ }
87
+
88
+ /**
89
+ * @param string $destinationAirportCityCode
90
+ */
91
+ public function setDestinationAirportCityCode ( $destinationAirportCityCode )
92
+ {
93
+
94
+ $this->_destinationAirportCityCode = $destinationAirportCityCode;
95
+
96
+ return $this;
97
+ }
98
+
99
+ /**
100
+ * @return string
101
+ */
102
+ public function getDestinationAirportCityCode ()
103
+ {
104
+
105
+ return $this->_destinationAirportCityCode;
106
+ }
107
+
108
+ /**
109
+ * @param string $flightCoupon
110
+ */
111
+ public function setFlightCoupon ( $flightCoupon )
112
+ {
113
+
114
+ $this->_flightCoupon = $flightCoupon;
115
+
116
+ return $this;
117
+ }
118
+
119
+ /**
120
+ * @return string
121
+ */
122
+ public function getFlightCoupon ()
123
+ {
124
+
125
+ return $this->_flightCoupon;
126
+ }
127
+
128
+ /**
129
+ * @param string $flightDate
130
+ */
131
+ public function setFlightDate ( $flightDate )
132
+ {
133
+
134
+ $this->_flightDate = $flightDate;
135
+
136
+ return $this;
137
+ }
138
+
139
+ /**
140
+ * @return string
141
+ */
142
+ public function getFlightDate ()
143
+ {
144
+
145
+ return $this->_flightDate;
146
+ }
147
+
148
+ /**
149
+ * @param string $originAirportCityCode
150
+ */
151
+ public function setOriginAirportCityCode ( $originAirportCityCode )
152
+ {
153
+
154
+ $this->_originAirportCityCode = $originAirportCityCode;
155
+
156
+ return $this;
157
+ }
158
+
159
+ /**
160
+ * @return string
161
+ */
162
+ public function getOriginAirportCityCode ()
163
+ {
164
+
165
+ return $this->_originAirportCityCode;
166
+ }
167
+
168
+ /**
169
+ * @param string $passengerName
170
+ */
171
+ public function setPassengerName ( $passengerName )
172
+ {
173
+
174
+ $this->_passengerName = $passengerName;
175
+
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * @return string
181
+ */
182
+ public function getPassengerName ()
183
+ {
184
+
185
+ return $this->_passengerName;
186
+ }
187
+
188
+ /**
189
+ * @param string $ticketDocumentNumber
190
+ */
191
+ public function setTicketDocumentNumber ( $ticketDocumentNumber )
192
+ {
193
+
194
+ $this->_ticketDocumentNumber = $ticketDocumentNumber;
195
+
196
+ return $this;
197
+ }
198
+
199
+ /**
200
+ * @return string
201
+ */
202
+ public function getTicketDocumentNumber ()
203
+ {
204
+
205
+ return $this->_ticketDocumentNumber;
206
+ }
207
+
208
+
209
+ function getData ()
210
+ {
211
+
212
+ return array(
213
+ "ticket_document_number" => $this->getTicketDocumentNumber(),
214
+ "passenger_name" => $this->getPassengerName(),
215
+ "flight_date" => $this->getFlightDate(),
216
+ "flight_coupon" => $this->getFlightCoupon(),
217
+ "origin_airport_city_code" => $this->getOriginAirportCityCode(),
218
+ "destination_airport_city_code" => $this->getDestinationAirportCityCode(),
219
+ "carrier" => $this->getCarrier(),
220
+ );
221
+ }
222
+ }
app/code/community/Codex/Yapital/Model/Datatype/Amount.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the Amount datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Amount type specifies a money amount and a currency.
18
+ *
19
+ *
20
+ * @category Datatype
21
+ * @package Codex_Yapital_Model_Datatype
22
+ * @copyright 2013 Code-X GmbH
23
+ * @version Release: @package_version@
24
+ * @link http://code-x.de
25
+ * @since Class available since Release 0.1.0
26
+ */
27
+ class Codex_Yapital_Model_Datatype_Amount extends Codex_Yapital_Model_Datatype_Abstract
28
+ implements Codex_Yapital_Model_Datatype_Interface
29
+ {
30
+
31
+ /**
32
+ * Indicates the currency of a current amount.
33
+ *
34
+ * @var string
35
+ */
36
+ protected $_currency;
37
+
38
+ /**
39
+ * The amount value
40
+ *
41
+ * @var float
42
+ */
43
+ protected $_value;
44
+
45
+ /**
46
+ * @param string $currency
47
+ */
48
+ public function setCurrency ( $currency )
49
+ {
50
+
51
+ $this->_currency = $currency;
52
+
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * @return string
58
+ */
59
+ public function getCurrency ()
60
+ {
61
+
62
+ return $this->_currency;
63
+ }
64
+
65
+ /**
66
+ * @param float $value
67
+ */
68
+ public function setValue ( $value )
69
+ {
70
+
71
+ $this->_value = $value;
72
+
73
+ return $this;
74
+ }
75
+
76
+ /**
77
+ * @return float
78
+ */
79
+ public function getValue ()
80
+ {
81
+
82
+ return $this->_value;
83
+ }
84
+
85
+
86
+ /**
87
+ * Generate a assoc array representation of the Amount
88
+ *
89
+ * @return array
90
+ */
91
+ public function getData ()
92
+ {
93
+
94
+ return array(
95
+ "currency" => $this->getCurrency(),
96
+ "value" => $this->getValue(),
97
+ );
98
+ }
99
+ }
app/code/community/Codex/Yapital/Model/Datatype/Basket.php ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the Basket datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Basket type specifies the details of the basket an its contents.
18
+ *
19
+ * Contains the data about the items in the basket, including the item price and other details.
20
+ *
21
+ * @category Datatype
22
+ * @package Codex_Yapital_Model_Datatype
23
+ * @copyright 2013 Code-X GmbH
24
+ * @link http://code-x.de
25
+ * @since Class available since Release 0.1.0
26
+ */
27
+ class Codex_Yapital_Model_Datatype_Basket extends Codex_Yapital_Model_Datatype_Abstract
28
+ implements Codex_Yapital_Model_Datatype_Interface
29
+ {
30
+
31
+ /**
32
+ * A unique public ID of a basket. Generated by Yapital.
33
+ *
34
+ * @var Codex_Yapital_Model_Datatype_YapitalPublicId
35
+ */
36
+ protected $_basketId = null;
37
+
38
+ /**
39
+ * The referenced transaction that is used during the ordering and purchasing process.
40
+ *
41
+ * @var Codex_Yapital_Model_Datatype_Transaction
42
+ */
43
+ protected $_transaction = null;
44
+
45
+ /**
46
+ * The customer's shipping address.
47
+ *
48
+ * @var Codex_Yapital_Model_Datatype_PostalAddress
49
+ */
50
+ protected $_shippingAddress = null;
51
+
52
+ /**
53
+ * The customer's billing address.
54
+ *
55
+ * @var Codex_Yapital_Model_Datatype_PostalAddress
56
+ */
57
+ protected $_billingAddress = null;
58
+
59
+ /**
60
+ * The total price of items. Calculated automatically by Yapital.
61
+ *
62
+ * @var float
63
+ */
64
+ protected $_price = null;
65
+
66
+ protected $_currency = null;
67
+
68
+ /**
69
+ * This field can be used by a Web shop to store its custom data, e.g. items description.
70
+ *
71
+ * @var Codex_Yapital_Model_Datatype_MerchantItem
72
+ */
73
+ protected $_merchantItems = null;
74
+
75
+ /**
76
+ * Flight data for card payments.
77
+ *
78
+ * @var array
79
+ */
80
+ protected $_airlineData = array();
81
+
82
+ /**
83
+ * The array of Items put into the basket.
84
+ *
85
+ * @var array
86
+ */
87
+ protected $_items = array();
88
+
89
+ /**
90
+ * @return array
91
+ */
92
+ public function getAirlineData ()
93
+ {
94
+
95
+ return $this->_airlineData;
96
+ }
97
+
98
+ /**
99
+ * @param \Codex_Yapital_Model_Datatype_YapitalPublicId $basketId
100
+ */
101
+ public function setBasketId ( $basketId )
102
+ {
103
+
104
+ $this->_basketId = $basketId;
105
+
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * @return \Codex_Yapital_Model_Datatype_YapitalPublicId
111
+ */
112
+ public function getBasketId ()
113
+ {
114
+
115
+ return $this->_basketId;
116
+ }
117
+
118
+ /**
119
+ * @param \Codex_Yapital_Model_Datatype_PostalAddress $billingAddress
120
+ */
121
+ public function setBillingAddress ( $billingAddress )
122
+ {
123
+
124
+ $this->_billingAddress = $billingAddress;
125
+
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ * @return \Codex_Yapital_Model_Datatype_PostalAddress
131
+ */
132
+ public function getBillingAddress ()
133
+ {
134
+
135
+ return $this->_billingAddress;
136
+ }
137
+
138
+ public function setCurrency ( $currency )
139
+ {
140
+
141
+ $this->_currency = $currency;
142
+
143
+ return $this;
144
+ }
145
+
146
+ /**
147
+ * @return string
148
+ */
149
+ public function getCurrency ()
150
+ {
151
+
152
+ return (string) $this->_currency;
153
+ }
154
+
155
+ /**
156
+ * @return array
157
+ */
158
+ public function getItems ()
159
+ {
160
+
161
+ return $this->_items;
162
+ }
163
+
164
+ /**
165
+ * @param \Codex_Yapital_Model_Datatype_MerchantItem $merchantItems
166
+ */
167
+ public function setMerchantItems ( $merchantItems )
168
+ {
169
+
170
+ $this->_merchantItems = $merchantItems;
171
+
172
+ return $this;
173
+ }
174
+
175
+ /**
176
+ * @return \Codex_Yapital_Model_Datatype_MerchantItem
177
+ */
178
+ public function getMerchantItems ()
179
+ {
180
+
181
+ return $this->_merchantItems;
182
+ }
183
+
184
+ /**
185
+ * @param float $price
186
+ */
187
+ public function setPrice ( $price )
188
+ {
189
+
190
+ $this->_price = $price;
191
+
192
+ return $this;
193
+ }
194
+
195
+ /**
196
+ * @return float
197
+ */
198
+ public function getPrice ()
199
+ {
200
+
201
+ return (float) $this->_price;
202
+ }
203
+
204
+ /**
205
+ * @param \Codex_Yapital_Model_Datatype_PostalAddress $shippingAddress
206
+ */
207
+ public function setShippingAddress ( $shippingAddress )
208
+ {
209
+
210
+ $this->_shippingAddress = $shippingAddress;
211
+
212
+ return $this;
213
+ }
214
+
215
+ /**
216
+ * @return \Codex_Yapital_Model_Datatype_PostalAddress
217
+ */
218
+ public function getShippingAddress ()
219
+ {
220
+
221
+ return $this->_shippingAddress;
222
+ }
223
+
224
+ /**
225
+ * @param \Codex_Yapital_Model_Datatype_Transaction $transaction
226
+ */
227
+ public function setTransaction ( $transaction )
228
+ {
229
+
230
+ $this->_transaction = $transaction;
231
+
232
+ return $this;
233
+ }
234
+
235
+ /**
236
+ * @return \Codex_Yapital_Model_Datatype_Transaction
237
+ */
238
+ public function getTransaction ()
239
+ {
240
+
241
+ return $this->_transaction;
242
+ }
243
+
244
+
245
+ public function addAirlineData ( Codex_Yapital_Model_Datatype_AirlineData $airlineData )
246
+ {
247
+
248
+ $this->_airlineData = $airlineData;
249
+
250
+ return $this;
251
+ }
252
+
253
+ public function addItem ( $item )
254
+ {
255
+
256
+ $this->_items[] = $item;
257
+
258
+ return $this;
259
+ }
260
+
261
+
262
+ /**
263
+ *
264
+ * @param $order Mage_Sales_Model_Order
265
+ *
266
+ * @return Codex_Yapital_Model_Datatype_Basket
267
+ */
268
+ function importOrder ( Mage_Sales_Model_Order $order )
269
+ {
270
+ /** @var $yapitalBilling Codex_Yapital_Model_Datatype_PostalAddress */
271
+ $yapitalBilling = Mage::getModel("yapital/datatype_postaladdress");
272
+ $yapitalBilling->importOrderAddress($order->getBillingAddress());
273
+
274
+ /** @var $yapitalShipping Codex_Yapital_Model_Datatype_PostalAddress */
275
+ $yapitalShipping = Mage::getModel("yapital/datatype_postaladdress");
276
+ $yapitalShipping->importOrderAddress($order->getShippingAddress());
277
+
278
+ $this->setShippingAddress($yapitalShipping);
279
+ $this->setBillingAddress($yapitalBilling);
280
+
281
+ $this->setPrice($order->getGrandTotal());
282
+ $this->setCurrency($order->getBaseCurrency()->getCode());
283
+
284
+ // Extract items for cart
285
+ $items = $order->getAllVisibleItems();
286
+ foreach ( $items as $item )
287
+ {
288
+ /**
289
+ * Generate new item for cart
290
+ *
291
+ * @var $yapitalItem Codex_Yapital_Model_Datatype_Item
292
+ */
293
+ $yapitalItem = Mage::getModel(
294
+ "yapital/datatype_item"
295
+ );
296
+
297
+ // import mage data and add to cart
298
+ $yapitalItem->importItem($item);
299
+ $this->addItem(clone $yapitalItem);
300
+
301
+ }
302
+
303
+ /**
304
+ * Generate shipping as item
305
+ *
306
+ * @var $deliveryItem Codex_Yapital_Model_Datatype_Item
307
+ */
308
+ $deliveryItem = Mage::getModel("yapital/datatype_item");
309
+ $deliveryItem->setShopItemId($order->getShippingAddressId());
310
+ $deliveryItem->setItemTitle($order->getShippingDescription());
311
+ $deliveryItem->setItemMinAge(0);
312
+
313
+ $deliveryItem->setQuantity(1);
314
+ $deliveryItem->setItemPrice($order->getShippingInclTax());
315
+ $deliveryItem->setItemTaxAmountIncluded($order->getShippingInclTax());
316
+ $deliveryItem->setTotalItemPrice($order->getShippingInclTax());
317
+ $deliveryItem->setTotalItemTaxIncluded($order->getShippingInclTax());
318
+ $deliveryItem->setItemId($order->getShippingAddressId()); // @todo proper id
319
+ $this->addItem($deliveryItem);
320
+
321
+ return $this;
322
+ }
323
+
324
+ function getData ()
325
+ {
326
+ return array(
327
+ //"basket_id" => $this->getBasketId(),
328
+ "items" => $this->getItems(),
329
+ //"transaction" => $this->getTransaction(),
330
+ "shipping_address" => $this->getShippingAddress(),
331
+ "billing_address" => $this->getBillingAddress(),
332
+ "price" => $this->getPrice(),
333
+ "airline_data" => $this->getAirlineData(),
334
+ "merchant_items" => $this->getMerchantItems(),
335
+ "currency" => $this->getCurrency(),
336
+ );
337
+ }
338
+ }
app/code/community/Codex/Yapital/Model/Datatype/Basketstransaction.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the BasketsTransaction datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Yapital
10
+ * @package Codex_Yapital_Model_DataType
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The BasketsTransaction type is a composite object that contains a Basket and a Transaction.
18
+ *
19
+ * ## Description
20
+ *
21
+ * The BasketsTransaction type is a composite object that contains data about both a transaction and a
22
+ * basket.
23
+ * This data type is used to create both a new basket and a new transaction by a single API call.
24
+ *
25
+ * ## Used by methods
26
+ *
27
+ * Requests:
28
+ * - POST shops/{shopId}/basket_transaction
29
+ *
30
+ *
31
+ * @category Yapital
32
+ * @package Codex_Yapital_Model_DataType
33
+ * @copyright 2013 Code-X GmbH
34
+ * @link http://code-x.de
35
+ * @since Class available since Release 0.1.0
36
+ */
37
+ class Codex_Yapital_Model_Datatype_Basketstransaction extends Codex_Yapital_Model_Datatype_Abstract
38
+ implements Codex_Yapital_Model_Datatype_Interface
39
+ {
40
+
41
+ /**
42
+ * @var Codex_Yapital_Model_Datatype_Basket
43
+ */
44
+ protected $_basket;
45
+
46
+ /**
47
+ * @var Codex_Yapital_Model_Datatype_Transaction
48
+ */
49
+ protected $_transaction;
50
+
51
+ /**
52
+ * @param \Codex_Yapital_Model_Datatype_Transaction $transaction
53
+ */
54
+ public function setTransaction ( $transaction )
55
+ {
56
+ $this->_transaction = $transaction;
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * @return \Codex_Yapital_Model_Datatype_Transaction
62
+ */
63
+ public function getTransaction ()
64
+ {
65
+ return $this->_transaction;
66
+ }
67
+
68
+ /**
69
+ * @param \Codex_Yapital_Model_Datatype_Basket $basket
70
+ */
71
+ public function setBasket ( $basket )
72
+ {
73
+ $this->_basket = $basket;
74
+ return $this;
75
+ }
76
+
77
+ /**
78
+ * @return \Codex_Yapital_Model_Datatype_Basket
79
+ */
80
+ public function getBasket ()
81
+ {
82
+ return $this->_basket;
83
+ }
84
+
85
+
86
+ public function importOrder ( Mage_Sales_Model_Order $order )
87
+ {
88
+ /**
89
+ * @var $basket Codex_Yapital_Model_Datatype_Basket
90
+ */
91
+ $basket = Mage::getModel(
92
+ "yapital/datatype_basket"
93
+ );
94
+ $basket->importOrder($order);
95
+
96
+ /**
97
+ * @var $transaction Codex_Yapital_Model_Datatype_Transaction
98
+ */
99
+ $transaction = Mage::getModel(
100
+ "yapital/datatype_transaction"
101
+ );
102
+ $transaction->importOrder($order);
103
+
104
+ $this->setBasket($basket);
105
+ $this->setTransaction($transaction);
106
+
107
+ return $this;
108
+
109
+ }
110
+
111
+ /**
112
+ * Generate assoc array with all possible fields and their value
113
+ *
114
+ * @return array
115
+ */
116
+ public function getData ()
117
+ {
118
+ return array(
119
+ "basket_transaction" =>
120
+ array(
121
+ "basket" => $this->getBasket(),
122
+ "transaction" => $this->getTransaction(),
123
+ )
124
+ );
125
+ }
126
+
127
+
128
+ }
app/code/community/Codex/Yapital/Model/Datatype/Baskettransactioncreated.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the BasketTransactionCreated datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The BasketTransactionCreated type is used to return data about a newly created basket.
18
+ *
19
+ * ## Description
20
+ *
21
+ * The BasketTransactionCreated type is used to return data about a newly created basket:
22
+ * - basket ID
23
+ * - transaction ID
24
+ * - redirect URL
25
+ *
26
+ * ## Used by methods
27
+ *
28
+ * Request:
29
+ * - POST shops/{shopId}/basket_transaction
30
+ *
31
+ * @category Datatype
32
+ * @package Codex_Yapital_Model_Datatype
33
+ * @copyright 2013 Code-X GmbH
34
+ * @link http://code-x.de
35
+ * @since Class available since Release 0.1.0
36
+ */
37
+ class Codex_Yapital_Model_Datatype_BasketTransactionCreated extends Codex_Yapital_Model_Datatype_Abstract
38
+ implements Codex_Yapital_Model_Datatype_Interface
39
+ {
40
+
41
+ /**
42
+ * @var Codex_Yapital_Model_Datatype_YapitalPublicId
43
+ */
44
+ protected $_basketId;
45
+
46
+ /**
47
+ * @var Codex_Yapital_Model_Datatype_YapitalPublicId
48
+ */
49
+ protected $_transactionId;
50
+
51
+ /**
52
+ * @var string
53
+ */
54
+ protected $_redirectUrl;
55
+
56
+ /**
57
+ * @return \Codex_Yapital_Model_Datatype_YapitalPublicId
58
+ */
59
+ public function getBasketId ()
60
+ {
61
+
62
+ return $this->_basketId;
63
+ }
64
+
65
+ /**
66
+ * @return string
67
+ */
68
+ public function getRedirectUrl ()
69
+ {
70
+
71
+ return $this->_redirectUrl;
72
+ }
73
+
74
+ /**
75
+ * @return \Codex_Yapital_Model_Datatype_YapitalPublicId
76
+ */
77
+ public function getTransactionId ()
78
+ {
79
+
80
+ return $this->_transactionId;
81
+ }
82
+
83
+ /**
84
+ * @param \Codex_Yapital_Model_Datatype_YapitalPublicId $basketId
85
+ */
86
+ public function setBasketId ( $basketId )
87
+ {
88
+
89
+ $this->_basketId = $basketId;
90
+
91
+ return $this;
92
+ }
93
+
94
+ /**
95
+ * @param string $redirectUrl
96
+ */
97
+ public function setRedirectUrl ( $redirectUrl )
98
+ {
99
+
100
+ $this->_redirectUrl = $redirectUrl;
101
+
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * @param \Codex_Yapital_Model_Datatype_YapitalPublicId $transactionId
107
+ */
108
+ public function setTransactionId ( $transactionId )
109
+ {
110
+
111
+ $this->_transactionId = $transactionId;
112
+
113
+ return $this;
114
+ }
115
+
116
+
117
+ /**
118
+ * Generate associative array that containts the fields with its values
119
+ *
120
+ * @return array
121
+ */
122
+ public function getData ()
123
+ {
124
+
125
+ return array(
126
+ "basket_id" => $this->getBasketId(),
127
+ "transaction_id" => $this->getTransactionId(),
128
+ "redirect_url" => $this->getRedirectUrl(),
129
+ );
130
+ }
131
+ }
app/code/community/Codex/Yapital/Model/Datatype/Currency.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the Currency datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Currency type specifies the currency that is used for a basket.
18
+ *
19
+ * Enumeration values:
20
+ *
21
+ * Value Type Description
22
+ * EUR string The basket currency is Euro.
23
+ * USD string The basket currency is US Dollars (not supported in the current implementation).
24
+ *
25
+ * @category Datatype
26
+ * @package Codex_Yapital_Model_Datatype
27
+ * @copyright 2013 Code-X GmbH
28
+ * @link http://code-x.de
29
+ * @since Class available since Release 0.1.0
30
+ */
31
+ class Codex_Yapital_Model_Datatype_Currency extends Codex_Yapital_Model_Datatype_AbstractSimpleType
32
+ {
33
+
34
+ const EUR = "EUR";
35
+ //const USD = "USD";
36
+ }
37
+
app/code/community/Codex/Yapital/Model/Datatype/EventType.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the EventType simple datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The EventType type defines the event types for which a notification can be created.
18
+ *
19
+ * In the current implementation, the Yapital Shop API supports only the payment_processed notifications.
20
+ *
21
+ * @category Datatype
22
+ * @package Codex_Yapital_Model_Datatype
23
+ * @copyright 2013 code-x GmbH
24
+ * @link http://code-x.de
25
+ * @since Class available since Release 0.1.0
26
+ */
27
+ class Codex_Yapital_Model_Datatype_EventType extends Codex_Yapital_Model_Datatype_AbstractSimpleType
28
+ implements Codex_Yapital_Model_Datatype_Interface
29
+ {
30
+
31
+ const PAYMENT_PROCESSED = "PAYMENT_PROCESSED";
32
+ }
app/code/community/Codex/Yapital/Model/Datatype/Interface.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the interface for datatypes of the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * This is the interface of Yapital API datatypes that must be given in every container and datanode.
18
+ *
19
+ * @category Datatype
20
+ * @package Codex_Yapital_Model_Datatype
21
+ * @copyright 2013 Code-X GmbH
22
+ * @link http://code-x.de
23
+ * @since Class available since Release 0.1.0
24
+ */
25
+ interface Codex_Yapital_Model_Datatype_Interface
26
+ {
27
+
28
+ public function __construct ();
29
+
30
+ public function getFields ();
31
+
32
+ public function getData ();
33
+
34
+ public function toArray ();
35
+
36
+ public function toJSON ();
37
+
38
+ public function toXML ();
39
+ }
app/code/community/Codex/Yapital/Model/Datatype/Item.php ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the Item datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Item type specifies the details of a Web shop item.
18
+ *
19
+ *
20
+ *
21
+ * @category Datatype
22
+ * @package Codex_Yapital_Model_Datatype
23
+ * @copyright 2013 Code-X GmbH
24
+ * @version Release: @package_version@
25
+ * @link http://code-x.de
26
+ * @since Class available since Release 0.1.0
27
+ */
28
+ class Codex_Yapital_Model_Datatype_Item extends Codex_Yapital_Model_Datatype_Abstract
29
+ implements Codex_Yapital_Model_Datatype_Interface
30
+ {
31
+
32
+ /**
33
+ * The item public ID generated by Yapital.
34
+ *
35
+ * @var Codex_Yapital_Model_Datatype_YapitalPublicId
36
+ */
37
+ protected $_itemId;
38
+
39
+ /**
40
+ * The item name, specified by the client side (the Web shop).
41
+ *
42
+ * @var string
43
+ */
44
+ protected $_itemTitle;
45
+
46
+ /**
47
+ * The item price, specified by the client side (the Web shop).
48
+ *
49
+ * @var float
50
+ */
51
+ protected $_itemPrice;
52
+
53
+ /**
54
+ * The tax added to the item price, specified by the client side (the Web shop).
55
+ *
56
+ * @var float
57
+ */
58
+ protected $_itemTaxAmountIncluded;
59
+
60
+ /**
61
+ * The minimum age in years a Web shop customer must be to buy the item.
62
+ *
63
+ * @var int unsigned
64
+ */
65
+ protected $_itemMinAge;
66
+
67
+ /**
68
+ * The total price of the item without a tax (net value).
69
+ *
70
+ * @var float
71
+ */
72
+ protected $_totalItemPrice;
73
+
74
+ /**
75
+ * The total price of the item including a tax (gross value).
76
+ *
77
+ * @var float
78
+ */
79
+ protected $_totalItemTaxIncluded;
80
+
81
+ /**
82
+ * Item ID provided by the Web shop that owns it.
83
+ *
84
+ * @var string
85
+ */
86
+ protected $_shopItemId;
87
+
88
+ /**
89
+ * Number of items.
90
+ *
91
+ * @var int positive
92
+ */
93
+ protected $_quantity;
94
+
95
+ /**
96
+ * This field can be used by a shop to provide any custom data, e.g. a description
97
+ *
98
+ * @var array
99
+ */
100
+ protected $_merchantItems = array();
101
+
102
+ /**
103
+ * @param \Codex_Yapital_Model_Datatype_YapitalPublicId $itemId
104
+ */
105
+ public function setItemId ( $itemId )
106
+ {
107
+ $this->_itemId = $itemId;
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * @return \Codex_Yapital_Model_Datatype_YapitalPublicId
113
+ */
114
+ public function getItemId ()
115
+ {
116
+
117
+ return $this->_itemId;
118
+ }
119
+
120
+ /**
121
+ * @param int $itemMinAge
122
+ */
123
+ public function setItemMinAge ( $itemMinAge )
124
+ {
125
+
126
+ $this->_itemMinAge = $itemMinAge;
127
+
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * @return int
133
+ */
134
+ public function getItemMinAge ()
135
+ {
136
+
137
+ return (int) $this->_itemMinAge;
138
+ }
139
+
140
+ /**
141
+ * @param float $itemPrice
142
+ */
143
+ public function setItemPrice ( $itemPrice )
144
+ {
145
+
146
+ $this->_itemPrice = $itemPrice;
147
+
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * @return float
153
+ */
154
+ public function getItemPrice ()
155
+ {
156
+
157
+ return (float) $this->_itemPrice;
158
+ }
159
+
160
+ /**
161
+ * @param float $itemTaxAmountIncluded
162
+ */
163
+ public function setItemTaxAmountIncluded ( $itemTaxAmountIncluded )
164
+ {
165
+
166
+ $this->_itemTaxAmountIncluded = $itemTaxAmountIncluded;
167
+
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * @return float
173
+ */
174
+ public function getItemTaxAmountIncluded ()
175
+ {
176
+
177
+ return (float) $this->_itemTaxAmountIncluded;
178
+ }
179
+
180
+ /**
181
+ * @param string $itemTitle
182
+ */
183
+ public function setItemTitle ( $itemTitle )
184
+ {
185
+
186
+ $this->_itemTitle = $itemTitle;
187
+
188
+ return $this;
189
+ }
190
+
191
+ /**
192
+ * @return string
193
+ */
194
+ public function getItemTitle ()
195
+ {
196
+
197
+ return $this->_itemTitle;
198
+ }
199
+
200
+ /**
201
+ * @param array $merchantItems
202
+ */
203
+ public function setMerchantItems ( $merchantItems )
204
+ {
205
+
206
+ $this->_merchantItems = $merchantItems;
207
+
208
+ return $this;
209
+ }
210
+
211
+ /**
212
+ * @return array
213
+ */
214
+ public function getMerchantItems ()
215
+ {
216
+
217
+ return $this->_merchantItems;
218
+ }
219
+
220
+ /**
221
+ * @param int $quantity
222
+ */
223
+ public function setQuantity ( $quantity )
224
+ {
225
+
226
+ $this->_quantity = $quantity;
227
+
228
+ return $this;
229
+ }
230
+
231
+ /**
232
+ * @return int
233
+ */
234
+ public function getQuantity ()
235
+ {
236
+
237
+ return (int) $this->_quantity;
238
+ }
239
+
240
+ /**
241
+ * @param string $shopItemId
242
+ */
243
+ public function setShopItemId ( $shopItemId )
244
+ {
245
+
246
+ $this->_shopItemId = $shopItemId;
247
+
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * @return string
253
+ */
254
+ public function getShopItemId ()
255
+ {
256
+
257
+ return $this->_shopItemId;
258
+ }
259
+
260
+ /**
261
+ * @param float $totalItemPrice
262
+ */
263
+ public function setTotalItemPrice ( $totalItemPrice )
264
+ {
265
+
266
+ $this->_totalItemPrice = $totalItemPrice;
267
+
268
+ return $this;
269
+ }
270
+
271
+ /**
272
+ * @return float
273
+ */
274
+ public function getTotalItemPrice ()
275
+ {
276
+
277
+ return (float) $this->_totalItemPrice;
278
+ }
279
+
280
+ /**
281
+ * @param float $totalItemTaxIncluded
282
+ */
283
+ public function setTotalItemTaxIncluded ( $totalItemTaxIncluded )
284
+ {
285
+
286
+ $this->_totalItemTaxIncluded = $totalItemTaxIncluded;
287
+
288
+ return $this;
289
+ }
290
+
291
+ /**
292
+ * @return float
293
+ */
294
+ public function getTotalItemTaxIncluded ()
295
+ {
296
+
297
+ return (float) $this->_totalItemTaxIncluded;
298
+ }
299
+
300
+ function importItem ( Mage_Sales_Model_Order_Item $item )
301
+ {
302
+
303
+ $name = $item->name;
304
+ /// @todo min age -> config
305
+ $minAge = 0;
306
+ $shopItemId = $item->item_id;
307
+
308
+ $this->setShopItemId($shopItemId);
309
+ $this->setItemTitle($name);
310
+ $this->setItemMinAge($minAge);
311
+
312
+ /* @todo right fields selected from Order_Item? */
313
+ $this->setItemPrice($item->getBasePrice());
314
+ $this->setItemTaxAmountIncluded($item->getBasePriceInclTax());
315
+
316
+ $this->setTotalItemPrice($item->getPrice());
317
+ $this->setTotalItemTaxIncluded($item->getPriceInclTax());
318
+
319
+ $this->setQuantity($item->getQtyOrdered());
320
+
321
+ return $this;
322
+ }
323
+
324
+
325
+ function getData ()
326
+ {
327
+
328
+ return array(
329
+ // "item_id" => $this->getItemId(),
330
+ "item_title" => $this->getItemTitle(),
331
+ "item_price" => (float) $this->getItemPrice(),
332
+ "item_tax_amount_included" => (float) $this->getItemTaxAmountIncluded(),
333
+ "item_min_age" => $this->getItemMinAge(),
334
+ "total_item_price" => (float) ($this->getItemPrice() * $this->getQuantity()),
335
+ "total_item_tax_included" => (float) $this->getTotalItemTaxIncluded(),
336
+ "shop_item_id" => $this->getShopItemId(),
337
+ "quantity" => $this->getQuantity(),
338
+ // "merchant_items" => $this->getMerchantItems(),
339
+ );
340
+ }
341
+ }
app/code/community/Codex/Yapital/Model/Datatype/Merchantitem.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the MerchantItem datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The MerchantItem type specifies the data the Web shop would like to route through the Yapital Shop API.
18
+ *
19
+ * This gives the Web shop customer an option to add personal data for personal purposes to the Basket.
20
+ * All the data provided is ignored by Yapital but stored with the Basket.
21
+ *
22
+ *
23
+ * @category Datatype
24
+ * @package Codex_Yapital_Model_Datatype
25
+ * @copyright 2013 Code-X GmbH
26
+ * @link http://code-x.de
27
+ * @since Class available since Release 0.1.0
28
+ */
29
+ class Codex_Yapital_Model_Datatype_MerchantItem extends Codex_Yapital_Model_Datatype_Abstract
30
+ implements Codex_Yapital_Model_Datatype_Interface
31
+ {
32
+
33
+ /**
34
+ * @var string
35
+ */
36
+ protected $_merchantData;
37
+
38
+ /**
39
+ * @param string $merchantData
40
+ */
41
+ public function setMerchantData ( $merchantData )
42
+ {
43
+
44
+ $this->_merchantData = $merchantData;
45
+
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * @return string
51
+ */
52
+ public function getMerchantData ()
53
+ {
54
+
55
+ return $this->_merchantData;
56
+ }
57
+
58
+ /**
59
+ * Gets all fields of MerchantData as associative array
60
+ *
61
+ * @return array
62
+ */
63
+ public function getData ()
64
+ {
65
+
66
+ if ( "" == $this->getMerchantData() )
67
+ {
68
+ return null;
69
+ }
70
+
71
+ return array(
72
+ "merchant_data" => $this->getMerchantData()
73
+ );
74
+ }
75
+ }
app/code/community/Codex/Yapital/Model/Datatype/Notification.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the Notification datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Notification type defines the data structure of a notification.
18
+ *
19
+ * ## Used by methods
20
+ *
21
+ * Requests:
22
+ * - Create a new notification endpoint : POST shops/{shopId}/notifications
23
+ * - Update the notification: PUT shops/{shopId}/notifications/{notificationId}
24
+ *
25
+ * Response:
26
+ * - Get the notification by the Public ID: GET shops/{shopId}/notifications/{notificationId}
27
+ * - Get all notifications for the specified Web shop: GET shops/{shopId}/notifications
28
+ *
29
+ *
30
+ * @category Datatype
31
+ * @package Codex_Yapital_Model_Datatype
32
+ * @copyright 2013 Code-X GmbH
33
+ * @link http://code-x.de
34
+ * @since Class available since Release 0.1.0
35
+ */
36
+ class Codex_Yapital_Model_Datatype_Notification extends Codex_Yapital_Model_Datatype_Abstract
37
+ implements Codex_Yapital_Model_Datatype_Interface
38
+ {
39
+
40
+ /**
41
+ * @var Codex_Yapital_Model_Datatype_YapitalPublicId
42
+ */
43
+ protected $_notificationId;
44
+
45
+ /**
46
+ * @var string
47
+ */
48
+ protected $_eventType;
49
+
50
+ /**
51
+ * @var string
52
+ */
53
+ protected $_callbackUrl;
54
+
55
+ /**
56
+ * @var string
57
+ */
58
+ protected $_validationStatus;
59
+
60
+ /**
61
+ * @var string
62
+ */
63
+ protected $_acceptType;
64
+
65
+ /**
66
+ * @param \Codex_Yapital_Model_Datatype_YapitalPublicId $notificationId
67
+ */
68
+ public function setNotificationId ( $notificationId )
69
+ {
70
+
71
+ $this->_notificationId = $notificationId;
72
+ }
73
+
74
+ /**
75
+ * @return \Codex_Yapital_Model_Datatype_YapitalPublicId
76
+ */
77
+ public function getNotificationId ()
78
+ {
79
+
80
+ return $this->_notificationId;
81
+ }
82
+
83
+ /**
84
+ * @param string $eventType
85
+ */
86
+ public function setEventType ( $eventType )
87
+ {
88
+
89
+ $this->_eventType = $eventType;
90
+ }
91
+
92
+ /**
93
+ * @return string
94
+ */
95
+ public function getEventType ()
96
+ {
97
+
98
+ return (string) $this->_eventType;
99
+ }
100
+
101
+ /**
102
+ * @param string $callbackUrl
103
+ */
104
+ public function setCallbackUrl ( $callbackUrl )
105
+ {
106
+ $this->_callbackUrl = $callbackUrl;
107
+ }
108
+
109
+ /**
110
+ * @return string
111
+ */
112
+ public function getCallbackUrl ()
113
+ {
114
+
115
+ return (string) $this->_callbackUrl;
116
+ }
117
+
118
+ /**
119
+ * @param string $acceptType
120
+ */
121
+ public function setAcceptType ( $acceptType )
122
+ {
123
+
124
+ $this->_acceptType = $acceptType;
125
+ }
126
+
127
+ /**
128
+ * @return string
129
+ */
130
+ public function getAcceptType ()
131
+ {
132
+
133
+ return (string) $this->_acceptType;
134
+ }
135
+
136
+ /**
137
+ * @param string $validationStatus
138
+ */
139
+ public function setValidationStatus ( $validationStatus )
140
+ {
141
+
142
+ $this->_validationStatus = $validationStatus;
143
+ }
144
+
145
+ /**
146
+ * @return string
147
+ */
148
+ public function getValidationStatus ()
149
+ {
150
+
151
+ return $this->_validationStatus;
152
+ }
153
+
154
+ public function importPayload( array $payload )
155
+ {
156
+ $this->setNotificationId( $payload['notification_id'] );
157
+ $this->setEventType( $payload['event_type'] );
158
+ $this->setCallbackUrl( $payload['callback_url'] );
159
+ $this->setValidationStatus( $payload['validation_status'] );
160
+ $this->setAcceptType( $payload['accept_type'] );
161
+
162
+ return $this;
163
+ }
164
+
165
+ public function getData ()
166
+ {
167
+
168
+ return array(
169
+ "notification" =>
170
+ array(
171
+ //"notification_id" => $this->getNotificationId(),
172
+ "event_type" => $this->getEventType(),
173
+ "callback_url" => $this->getCallbackUrl(),
174
+ "validation_status" => $this->getValidationStatus(),
175
+ "accept_type" => $this->getAcceptType(),
176
+ )
177
+ );
178
+ }
179
+ }
app/code/community/Codex/Yapital/Model/Datatype/Postaladdress.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the PostalAddress datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The PostalAddress type specifies the billing or the shipping addresses.
18
+ *
19
+ * The PostalAddress type specifies the billing or the shipping addresses of the Web shop customer who
20
+ * makes a purchase. This data type is used for both the billing and the shipping address objects.
21
+ *
22
+ * Used by methods
23
+ *
24
+ * Requests:
25
+ * - POST shops/{shopId}/baskets/{basketId}/billing_address
26
+ * - POST shops/{shopId}/baskets/{basketId}/shipping_address
27
+ * - PUT shops/{shopId}/baskets/{basketId}/billing_address
28
+ * - PUT shops/{shopId}/baskets/{basketId}/shipping_address
29
+ *
30
+ * Responses:
31
+ * - GET shops/{shopId}/baskets/{basketId}/billing_address
32
+ * - GET shops/{shopId}/baskets/{basketId}/shipping_address
33
+ *
34
+ *
35
+ * @category Datatype
36
+ * @package Codex_Yapital_Model_Datatype
37
+ * @copyright 2013 Code-X GmbH
38
+ * @link http://code-x.de
39
+ * @since Class available since Release 0.1.0
40
+ */
41
+ class Codex_Yapital_Model_Datatype_PostalAddress extends Codex_Yapital_Model_Datatype_Abstract
42
+ implements Codex_Yapital_Model_Datatype_Interface
43
+ {
44
+
45
+ /**
46
+ * @var string
47
+ */
48
+ protected $_title;
49
+ /**
50
+ * @var string
51
+ */
52
+ protected $_firstName;
53
+ /**
54
+ * @var string
55
+ */
56
+ protected $_lastName;
57
+ /**
58
+ * @var string
59
+ */
60
+ protected $_adress1;
61
+ /**
62
+ * @var string
63
+ */
64
+ protected $_address2;
65
+ /**
66
+ * @var string
67
+ */
68
+ protected $_city;
69
+ /**
70
+ * @var string
71
+ */
72
+ protected $_zip;
73
+ /**
74
+ * @var string
75
+ */
76
+ protected $_country;
77
+ /**
78
+ * @var string
79
+ */
80
+ protected $_state;
81
+ /**
82
+ * @var boolean
83
+ */
84
+ protected $_readonly;
85
+
86
+ /**
87
+ * @param string $address2
88
+ */
89
+ public function setAddress2 ( $address2 )
90
+ {
91
+
92
+ $this->_address2 = $address2;
93
+
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * @return string
99
+ */
100
+ public function getAddress2 ()
101
+ {
102
+
103
+ return $this->_address2;
104
+ }
105
+
106
+ /**
107
+ * @param string $adress1
108
+ */
109
+ public function setAddress1 ( $adress1 )
110
+ {
111
+
112
+ $this->_adress1 = $adress1;
113
+
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * @return string
119
+ */
120
+ public function getAdress1 ()
121
+ {
122
+
123
+ return $this->_adress1;
124
+ }
125
+
126
+ /**
127
+ * @param string $city
128
+ */
129
+ public function setCity ( $city )
130
+ {
131
+
132
+ $this->_city = $city;
133
+
134
+ return $this;
135
+ }
136
+
137
+ /**
138
+ * @return string
139
+ */
140
+ public function getCity ()
141
+ {
142
+
143
+ return $this->_city;
144
+ }
145
+
146
+ /**
147
+ * @param string $country
148
+ */
149
+ public function setCountry ( $country )
150
+ {
151
+
152
+ $this->_country = $country;
153
+
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * @return string
159
+ */
160
+ public function getCountry ()
161
+ {
162
+
163
+ return $this->_country;
164
+ }
165
+
166
+ /**
167
+ * @param string $firstName
168
+ */
169
+ public function setFirstName ( $firstName )
170
+ {
171
+
172
+ $this->_firstName = $firstName;
173
+
174
+ return $this;
175
+ }
176
+
177
+ /**
178
+ * @return string
179
+ */
180
+ public function getFirstName ()
181
+ {
182
+
183
+ return $this->_firstName;
184
+ }
185
+
186
+ /**
187
+ * @param string $lastName
188
+ */
189
+ public function setLastName ( $lastName )
190
+ {
191
+
192
+ $this->_lastName = $lastName;
193
+
194
+ return $this;
195
+ }
196
+
197
+ /**
198
+ * @return string
199
+ */
200
+ public function getLastName ()
201
+ {
202
+
203
+ return $this->_lastName;
204
+ }
205
+
206
+ /**
207
+ * @param boolean $readonly
208
+ */
209
+ public function setReadonly ( $readonly )
210
+ {
211
+
212
+ $this->_readonly = $readonly;
213
+
214
+ return $this;
215
+ }
216
+
217
+ /**
218
+ * @return boolean
219
+ */
220
+ public function getReadonly ()
221
+ {
222
+
223
+ return $this->_readonly;
224
+ }
225
+
226
+ /**
227
+ * @param string $state
228
+ */
229
+ public function setState ( $state )
230
+ {
231
+
232
+ $this->_state = $state;
233
+
234
+ return $this;
235
+ }
236
+
237
+ /**
238
+ * @return string
239
+ */
240
+ public function getState ()
241
+ {
242
+
243
+ return $this->_state;
244
+ }
245
+
246
+ /**
247
+ * @param string $title
248
+ */
249
+ public function setTitle ( $title )
250
+ {
251
+
252
+ $this->_title = $title;
253
+
254
+ return $this;
255
+ }
256
+
257
+ /**
258
+ * @return string
259
+ */
260
+ public function getTitle ()
261
+ {
262
+
263
+ return $this->_title;
264
+ }
265
+
266
+ /**
267
+ * @param string $zip
268
+ */
269
+ public function setZip ( $zip )
270
+ {
271
+
272
+ $this->_zip = $zip;
273
+
274
+ return $this;
275
+ }
276
+
277
+ /**
278
+ * @return string
279
+ */
280
+ public function getZip ()
281
+ {
282
+
283
+ return $this->_zip;
284
+ }
285
+
286
+ /**
287
+ * Imports an order address into the Yapital Postaladdress
288
+ *
289
+ * @param Mage_Sales_Model_Order_Address $address
290
+ *
291
+ * @todo street3 ? street4 ? unhandled by api
292
+ *
293
+ * @return \Codex_Yapital_Model_Datatype_PostalAddress
294
+ */
295
+ public function importOrderAddress ( Mage_Sales_Model_Order_Address $address )
296
+ {
297
+
298
+ $this->setTitle($address->getPrefix());
299
+ $this->setFirstName($address->getFirstname());
300
+ $this->setLastName($address->getLastname());
301
+ $this->setAddress1($address->getStreet1());
302
+ $this->setAddress2($address->getStreet2());
303
+ $this->setCity($address->getCity());
304
+ $this->setZip($address->getPostcode());
305
+ $this->setCountry($address->getCountry());
306
+ $this->setReadonly(true);
307
+
308
+ return $this;
309
+ }
310
+
311
+ function getData ()
312
+ {
313
+ return array(
314
+ "title" => (string) $this->getTitle(),
315
+ "first_name" => $this->getFirstName(),
316
+ "last_name" => $this->getLastName(),
317
+ "address_1" => $this->getAdress1(),
318
+ "address_2" => $this->getAddress2(),
319
+ "city" => $this->getCity(),
320
+ "zip" => $this->getZip(),
321
+ "country" => $this->getCountry(),
322
+ "state" => $this->getState(),
323
+ // "readonly" => $this->getReadonly(),
324
+ );
325
+ }
326
+ }
app/code/community/Codex/Yapital/Model/Datatype/Qrcodebinary.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the QRCodeBinary datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Basket type specifies the details of the basket an its contents.
18
+ *
19
+ * Contains the data about the items in the basket, including the item price and other details.
20
+ *
21
+ * @category Datatype
22
+ * @package Codex_Yapital_Model_Datatype
23
+ * @copyright 2013 Code-X GmbH
24
+ * @link http://code-x.de
25
+ * @since Class available since Release 0.1.0
26
+ */
27
+ class Codex_Yapital_Model_Datatype_QRCodeBinary extends Codex_Yapital_Model_Datatype_Abstract
28
+ implements Codex_Yapital_Model_Datatype_Interface
29
+ {
30
+
31
+ /**
32
+ * Base64 encode QR code image.
33
+ *
34
+ * @var string
35
+ */
36
+ protected $_value;
37
+
38
+ /**
39
+ * Additional metainformation (empty array at the current stage of implementation).
40
+ *
41
+ * @var array
42
+ */
43
+ protected $_metadata = array();
44
+
45
+ /**
46
+ * Application/octet-stream.
47
+ *
48
+ * @var string
49
+ */
50
+ protected $_mimetype = "application/octet-stream";
51
+
52
+ /**
53
+ * @return array
54
+ */
55
+ public function getMetadata ()
56
+ {
57
+
58
+ return $this->_metadata;
59
+ }
60
+
61
+ /**
62
+ * @return string
63
+ */
64
+ public function getMimetype ()
65
+ {
66
+
67
+ return $this->_mimetype;
68
+ }
69
+
70
+ /**
71
+ * @param string $value
72
+ */
73
+ public function setValue ( $value )
74
+ {
75
+
76
+ $this->_value = $value;
77
+
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * @return string
83
+ */
84
+ public function getValue ()
85
+ {
86
+
87
+ return $this->_value;
88
+ }
89
+
90
+ /**
91
+ * @param array $metadata
92
+ */
93
+ public function setMetadata ( $metadata )
94
+ {
95
+
96
+ $this->_metadata = $metadata;
97
+
98
+ return $this;
99
+ }
100
+
101
+ /**
102
+ * @param string $mimetype
103
+ */
104
+ public function setMimetype ( $mimetype )
105
+ {
106
+
107
+ $this->_mimetype = $mimetype;
108
+
109
+ return $this;
110
+ }
111
+
112
+
113
+ public function getData ()
114
+ {
115
+
116
+ return array(
117
+ "mimetype" => $this->getMimetype(),
118
+ "metadata" => $this->getMetadata(),
119
+ "value" => $this->getValue(),
120
+ );
121
+ }
122
+ }
app/code/community/Codex/Yapital/Model/Datatype/Returnbasket.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the PostalAddress datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital
11
+ */
12
+
13
+ /**
14
+ * The ReturnBasket type specifies the amount to credit to a Web shop customer in a basket return transaction.
15
+ *
16
+ * Request:
17
+ *
18
+ * - POST shops/{shopId}/transactions/{transactionId}/return_basket
19
+ *
20
+ *
21
+ * @category Datatype
22
+ * @package Codex_Yapital
23
+ *
24
+ * @method Codex_Yapital_Model_DataType_Amount getAmountToCredit() The amount of money a Web shop wants to return to its customer.
25
+ * @method int setAmountToCredit(Codex_Yapital_Model_DataType_Amount $value) The amount of money a Web shop wants to return to its customer.
26
+ */
27
+ class Codex_Yapital_Model_Datatype_Returnbasket extends Codex_Yapital_Model_Datatype_Abstract
28
+ implements Codex_Yapital_Model_Datatype_Interface
29
+ {
30
+ const AMOUNT_TO_CREDIT = 'amount_to_credit';
31
+
32
+ const ID = 'basket_to_return';
33
+
34
+
35
+ public function toArray()
36
+ {
37
+ $toArray = array(self::ID => parent::toArray());
38
+
39
+ return $toArray;
40
+ }
41
+ }
app/code/community/Codex/Yapital/Model/Datatype/Shoprestresponse.php ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the ShopRestResponse datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The ShopRestResponse type specifies the data format used for any response generated by the Yapital Shop API.
18
+ *
19
+ * Fields
20
+ * Element name Type Description
21
+ * status integer HTTP Status code of the response.
22
+ * code long Shop API specific code.
23
+ * message string Description of the status. Note: might be empty.
24
+ * payload anyType Payload content.
25
+ *
26
+ * @category Datatype
27
+ * @package Codex_Yapital_Model_Datatype
28
+ * @copyright 2013 Code-X GmbH
29
+ * @link http://code-x.de
30
+ * @since Class available since Release 0.1.0
31
+ */
32
+ class Codex_Yapital_Model_Datatype_Shoprestresponse extends Codex_Yapital_Model_Datatype_Abstract
33
+ implements Codex_Yapital_Model_Datatype_Interface
34
+ {
35
+
36
+ /**
37
+ * @var int
38
+ */
39
+ protected $_code;
40
+
41
+ /**
42
+ * @var string
43
+ */
44
+ protected $_message;
45
+
46
+ /**
47
+ * @var mixed
48
+ */
49
+ protected $_payload;
50
+
51
+ /**
52
+ * @var int
53
+ */
54
+ protected $_status;
55
+
56
+
57
+ /**
58
+ * @return int
59
+ */
60
+ public function getCode()
61
+ {
62
+
63
+ return $this->_code;
64
+ }
65
+
66
+
67
+ /**
68
+ * Generate array representation of this data type with it's fields and values
69
+ *
70
+ * @return array
71
+ */
72
+ public function getData()
73
+ {
74
+ return array(
75
+ "status" => $this->getStatus(),
76
+ "code" => $this->getCode(),
77
+ "message" => $this->getMessage(),
78
+ "payload" => $this->getPayload(),
79
+ );
80
+ }
81
+
82
+
83
+ /**
84
+ * @return string
85
+ */
86
+ public function getMessage()
87
+ {
88
+ return $this->_message;
89
+ }
90
+
91
+
92
+ /**
93
+ * @return ArrayObject
94
+ */
95
+ public function getPayload()
96
+ {
97
+ return $this->_payload;
98
+ }
99
+
100
+
101
+ /**
102
+ * @return int
103
+ */
104
+ public function getStatus()
105
+ {
106
+ return $this->_status;
107
+ }
108
+
109
+
110
+ /**
111
+ * @param $string string
112
+ */
113
+ public function importRawResponse($string)
114
+ {
115
+ $data = json_decode($string, true);
116
+
117
+ $this->setStatus($data["status"]);
118
+ $this->setCode($data["code"]);
119
+ $this->setMessage($data["message"]);
120
+ $this->setPayload($data["payload"]);
121
+
122
+ Codex_Yapital_Model_Log::log(
123
+ "Response {$this->getStatus()} (code {$this->getCode()}) for basket {$this->getPayload()->basket_id} "
124
+ . " with transaction {$this->getPayload()->transaction_id}."
125
+ );
126
+
127
+ Codex_Yapital_Model_Log::debug($this->getPayload());
128
+
129
+ if ($this->isError() || !is_array($data))
130
+ {
131
+ throw new Codex_Yapital_ErrorException("Rest-Request failed: " . $this->getMessage(), $this->getCode());
132
+ }
133
+
134
+ return $this;
135
+ }
136
+
137
+
138
+ public function importZendResponse(Zend_Http_Response $response)
139
+ {
140
+ $body = $response->getBody();
141
+ $this->importRawResponse($body);
142
+
143
+ return $this;
144
+ }
145
+
146
+
147
+ /**
148
+ * Check for errors in response
149
+ *
150
+ * @return bool
151
+ */
152
+ public function isError()
153
+ {
154
+ $status = $this->getStatus();
155
+ $isError = (
156
+ 0 != $this->getCode() // code not zero: so it is not a success
157
+ || substr($status, 0, 1) != 2 // response not 2xx status code: something went wrong
158
+ );
159
+
160
+ return $isError;
161
+ }
162
+
163
+
164
+ /**
165
+ * @param int $code
166
+ *
167
+ * @return $this
168
+ */
169
+ public function setCode($code)
170
+ {
171
+
172
+ $this->_code = $code;
173
+
174
+ return $this;
175
+ }
176
+
177
+
178
+ /**
179
+ * @param string $message
180
+ *
181
+ * @return $this
182
+ */
183
+ public function setMessage($message)
184
+ {
185
+
186
+ $this->_message = $message;
187
+
188
+ return $this;
189
+ }
190
+
191
+
192
+ /**
193
+ * @param mixed $payload
194
+ *
195
+ * @return $this
196
+ */
197
+ public function setPayload($payload)
198
+ {
199
+ $this->_payload = new ArrayObject((array)$payload, ArrayObject::ARRAY_AS_PROPS);
200
+
201
+ return $this;
202
+ }
203
+
204
+
205
+ /**
206
+ * @param int $status
207
+ *
208
+ * @return $this
209
+ */
210
+ public function setStatus($status)
211
+ {
212
+
213
+ $this->_status = $status;
214
+
215
+ return $this;
216
+ }
217
+ }
app/code/community/Codex/Yapital/Model/Datatype/Token.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the Token datatype for the Yapital API used (only) by the plugin
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Token type specifies the information about the received tokens
18
+ *
19
+ * Note: Not part of the specification. Only used in this plugin.
20
+ *
21
+ * @category Datatype
22
+ * @package Codex_Yapital_Model_Datatype
23
+ * @copyright 2013 Code-X GmbH
24
+ * @link http://code-x.de
25
+ * @since Class available since Release 0.1.0
26
+ */
27
+ class Codex_Yapital_Model_Datatype_Token extends Codex_Yapital_Model_Datatype_Abstract
28
+ implements Codex_Yapital_Model_Datatype_Interface
29
+ {
30
+
31
+ /**
32
+ * @var string
33
+ */
34
+ protected $_accessToken;
35
+
36
+ /**
37
+ * @var string
38
+ */
39
+ protected $_tokenType;
40
+
41
+ /**
42
+ * @var int
43
+ */
44
+ protected $_expiresIn;
45
+
46
+ /**
47
+ * @param string $accessToken
48
+ */
49
+ public function setAccessToken ( $accessToken )
50
+ {
51
+
52
+ $this->_accessToken = $accessToken;
53
+ }
54
+
55
+ /**
56
+ * @return string
57
+ */
58
+ public function getAccessToken ()
59
+ {
60
+
61
+ return $this->_accessToken;
62
+ }
63
+
64
+ /**
65
+ * @param int $expiresIn
66
+ */
67
+ public function setExpiresIn ( $expiresIn )
68
+ {
69
+
70
+ $this->_expiresIn = $expiresIn;
71
+ }
72
+
73
+ /**
74
+ * @return int
75
+ */
76
+ public function getExpiresIn ()
77
+ {
78
+
79
+ return $this->_expiresIn;
80
+ }
81
+
82
+ /**
83
+ * @param string $tokenType
84
+ */
85
+ public function setTokenType ( $tokenType )
86
+ {
87
+
88
+ $this->_tokenType = $tokenType;
89
+ }
90
+
91
+ /**
92
+ * @return string
93
+ */
94
+ public function getTokenType ()
95
+ {
96
+
97
+ return $this->_tokenType;
98
+ }
99
+
100
+ /**
101
+ * @param array $associativeArray
102
+ */
103
+ public function importArray ( $associativeArray )
104
+ {
105
+ $this->setAccessToken($associativeArray["access_token"]);
106
+ $this->setTokenType($associativeArray["token_type"]);
107
+ $this->setExpiresIn($associativeArray["expires_in"]);
108
+ }
109
+
110
+
111
+ public function getData ()
112
+ {
113
+ return array(
114
+ "access_token" => $this->getAccessToken(),
115
+ "token_type" => $this->getTokenType(),
116
+ "expires_in" => $this->getExpiresIn(),
117
+ );
118
+ }
119
+ }
app/code/community/Codex/Yapital/Model/Datatype/Transaction.php ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the Transaction datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Transaction type specifies the details of a transaction.
18
+ *
19
+ * Used by methods
20
+ *
21
+ * Request:
22
+ * - POST shops/{id}/baskets/{id}/transaction
23
+ * Response:
24
+ * - GET shops/{shopId}/baskets/{basketId}/transaction
25
+ *
26
+ *
27
+ * @category Datatype
28
+ * @package Codex_Yapital_Model_Datatype
29
+ * @copyright 2013 Code-X GmbH
30
+ * @link http://code-x.de
31
+ * @since Class available since Release 0.1.0
32
+ */
33
+ class Codex_Yapital_Model_Datatype_Transaction extends Codex_Yapital_Model_Datatype_Abstract
34
+ implements Codex_Yapital_Model_Datatype_Interface
35
+ {
36
+
37
+ /**
38
+ * @var Codex_Yapital_Model_Datatype_YapitalPublicId
39
+ */
40
+ protected $_transactionId;
41
+
42
+ /**
43
+ * @var string
44
+ */
45
+ protected $_qrCodeUrl;
46
+
47
+ /**
48
+ * @var Codex_Yapital_Model_Datatype_QRCodeBinary
49
+ */
50
+ protected $_qrCodeBin;
51
+
52
+ /**
53
+ * @var string
54
+ */
55
+ protected $_transactionStatus;
56
+
57
+ /**
58
+ * @var string
59
+ */
60
+ protected $_transactionDate;
61
+
62
+ /**
63
+ * @var string
64
+ */
65
+ protected $_orderNumber;
66
+
67
+ /**
68
+ * @var string
69
+ */
70
+ protected $_invoiceNumber;
71
+
72
+ /**
73
+ * @var string
74
+ */
75
+ protected $_returnUrl;
76
+
77
+ /**
78
+ * @var string
79
+ */
80
+ protected $_cancelUrl;
81
+
82
+ /**
83
+ * @var string
84
+ */
85
+ protected $_errorUrl;
86
+
87
+ /**
88
+ * @param string $cancelUrl
89
+ */
90
+ public function setCancelUrl ( $cancelUrl )
91
+ {
92
+
93
+ $this->_cancelUrl = $cancelUrl;
94
+
95
+ return $this;
96
+ }
97
+
98
+ /**
99
+ * @return string
100
+ */
101
+ public function getCancelUrl ()
102
+ {
103
+
104
+ return (string) $this->_cancelUrl;
105
+ }
106
+
107
+ /**
108
+ * @param string $errorUrl
109
+ */
110
+ public function setErrorUrl ( $errorUrl )
111
+ {
112
+
113
+ $this->_errorUrl = $errorUrl;
114
+
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * @return string
120
+ */
121
+ public function getErrorUrl ()
122
+ {
123
+
124
+ return (string) $this->_errorUrl;
125
+ }
126
+
127
+ /**
128
+ * @param string $invoiceNumber
129
+ */
130
+ public function setInvoiceNumber ( $invoiceNumber )
131
+ {
132
+
133
+ $this->_invoiceNumber = $invoiceNumber;
134
+
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * @return string
140
+ */
141
+ public function getInvoiceNumber ()
142
+ {
143
+
144
+ return (string) $this->_invoiceNumber;
145
+ }
146
+
147
+ /**
148
+ * @param string $orderNumber
149
+ */
150
+ public function setOrderNumber ( $orderNumber )
151
+ {
152
+
153
+ $this->_orderNumber = $orderNumber;
154
+
155
+ return $this;
156
+ }
157
+
158
+ /**
159
+ * @return string
160
+ */
161
+ public function getOrderNumber ()
162
+ {
163
+
164
+ return (string) $this->_orderNumber;
165
+ }
166
+
167
+ /**
168
+ * @param \Codex_Yapital_Model_Datatype_QRCodeBinary $qrCodeBin
169
+ */
170
+ public function setQrCodeBin ( $qrCodeBin )
171
+ {
172
+
173
+ $this->_qrCodeBin = $qrCodeBin;
174
+
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * @return \Codex_Yapital_Model_Datatype_QRCodeBinary
180
+ */
181
+ public function getQrCodeBin ()
182
+ {
183
+
184
+ return $this->_qrCodeBin;
185
+ }
186
+
187
+ /**
188
+ * @param string $qrCodeUrl
189
+ */
190
+ public function setQrCodeUrl ( $qrCodeUrl )
191
+ {
192
+
193
+ $this->_qrCodeUrl = $qrCodeUrl;
194
+
195
+ return $this;
196
+ }
197
+
198
+ /**
199
+ * @return string
200
+ */
201
+ public function getQrCodeUrl ()
202
+ {
203
+
204
+ return (string) $this->_qrCodeUrl;
205
+ }
206
+
207
+ /**
208
+ * @param string $returnUrl
209
+ */
210
+ public function setReturnUrl ( $returnUrl )
211
+ {
212
+
213
+ $this->_returnUrl = $returnUrl;
214
+
215
+ return $this;
216
+ }
217
+
218
+ /**
219
+ * @return string
220
+ */
221
+ public function getReturnUrl ()
222
+ {
223
+
224
+ return (string) $this->_returnUrl;
225
+ }
226
+
227
+ /**
228
+ * @param \Codex_Yapital_Model_Datatype_YapitalPublicId $transactionId
229
+ */
230
+ public function setTransactionId ( $transactionId )
231
+ {
232
+
233
+ $this->_transactionId = $transactionId;
234
+
235
+ return $this;
236
+ }
237
+
238
+ /**
239
+ * @return \Codex_Yapital_Model_Datatype_YapitalPublicId
240
+ */
241
+ public function getTransactionId ()
242
+ {
243
+
244
+ return $this->_transactionId;
245
+ }
246
+
247
+ /**
248
+ * @param string $transactionStatus
249
+ */
250
+ public function setTransactionStatus ( $transactionStatus )
251
+ {
252
+
253
+ $this->_transactionStatus = $transactionStatus;
254
+
255
+ return $this;
256
+ }
257
+
258
+ /**
259
+ * @return \Codex_Yapital_Model_Datatype_TransactionStatus
260
+ */
261
+ public function getTransactionStatus ()
262
+ {
263
+
264
+ return $this->_transactionStatus;
265
+ }
266
+
267
+ /**
268
+ * @param string $transationDate
269
+ */
270
+ public function setTransactionDate ( $transationDate )
271
+ {
272
+
273
+ $this->_transactionDate = $transationDate;
274
+
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * @return string
280
+ */
281
+ public function getTransactionDate ()
282
+ {
283
+
284
+ return $this->_transactionDate;
285
+ }
286
+
287
+ /**
288
+ * Imports an order into this transaction
289
+ *
290
+ * @todo import correct?
291
+ *
292
+ * @param Mage_Sales_Model_Order $order
293
+ *
294
+ * @return Codex_Yapital_Model_Datatype_Transaction
295
+ */
296
+ public function importOrder ( Mage_Sales_Model_Order $order )
297
+ {
298
+ $this->_getConfig()->setStoreId( $order->getStoreId() );
299
+
300
+ $this->setOrderNumber($order->getRealOrderId());
301
+ $this->setInvoiceNumber($order->getQuoteId());
302
+
303
+ $this->setReturnUrl( $this->_getUrl('success', $order) );
304
+ $this->setCancelUrl( $this->_getUrl('cancel', $order) );
305
+ $this->setErrorUrl( $this->_getUrl('error', $order) );
306
+
307
+ return $this;
308
+ }
309
+
310
+ protected function _getUrl( $action, Mage_Sales_Model_Order $order )
311
+ {
312
+ $this->_getConfig()->setStoreId( $order->getStoreId() );
313
+
314
+ $helper = Mage::helper('yapital');
315
+ /* @var $helper Codex_Yapital_Helper_Data */
316
+
317
+ return Mage::getUrl ('yapital/standard/'.$action,
318
+ array( 'order_id' => $order->getId(),
319
+ 'secret' => $helper->getOrderHash( $order )
320
+ )
321
+ );
322
+ }
323
+
324
+ function getData ()
325
+ {
326
+
327
+ return array(
328
+ // "transaction_id" => $this->getTransactionId(),
329
+ "qr_code_url" => $this->getQrCodeUrl(),
330
+ // "qr_code_bin" => $this->getQrCodeBin(),
331
+ // "transaction_status" => $this->getTransactionStatus(),
332
+ // "transaction_date" => $this->getTransactionDate(),
333
+ "order_number" => $this->getOrderNumber(),
334
+ "invoice_number" => $this->getInvoiceNumber(),
335
+ "return_url" => $this->getReturnUrl(),
336
+ "cancel_url" => $this->getCancelUrl(),
337
+ "error_url" => $this->getErrorUrl(),
338
+ );
339
+ }
340
+ }
app/code/community/Codex/Yapital/Model/Datatype/Transactionstatus.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the TransactionStatus datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The TransactionStatus type specifies the details of a transaction.
18
+ *
19
+ * Used by methods
20
+ *
21
+ * Request:
22
+ * - POST shops/{id}/baskets/{id}/transaction
23
+ * Response:
24
+ * - GET shops/{shopId}/baskets/{basketId}/transaction
25
+ *
26
+ *
27
+ * @category Datatype
28
+ * @package Codex_Yapital_Model_Datatype
29
+ * @copyright 2013 Code-X GmbH
30
+ * @link http://code-x.de
31
+ * @since Class available since Release 0.1.0
32
+ */
33
+ class Codex_Yapital_Model_Datatype_TransactionStatus
34
+ {
35
+
36
+ const REQUESTED = "REQUESTED";
37
+ const INVALID = "INVALID";
38
+ const CANCELLED = "CANCELLED";
39
+ const PAID = "PAID";
40
+ }
app/code/community/Codex/Yapital/Model/Datatype/Yapitalpublicid.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the YapitalPublicId datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The YapitalPublicId type is used as a unique ID for any object in the Yapital system.
18
+ *
19
+ * The YapitalPublicId is used for Baskets, Transactions, Web shops, etc.
20
+ *
21
+ * The YapitalPublicId consists of two parts separated by the "-" character:
22
+ * - prefix that specifies the type of the object, referenced by the public ID.
23
+ * - suffix that specifies the specific object.
24
+ *
25
+ * Samples IDs:
26
+ * - S1000-AZ21
27
+ * - SO100-J08
28
+ *
29
+ * Contains the data about the items in the basket, including the item price and other details.
30
+ *
31
+ * @category Datatype
32
+ * @package Codex_Yapital_Model_Datatype
33
+ * @copyright 2013 Code-X GmbH
34
+ * @link http://code-x.de
35
+ * @see Codex_Yapital_Model_Datatype_Basket, Codex_Yapital_Model_Datatype_Transaction, ...
36
+ * @since Class available since Release 0.1.0
37
+ */
38
+ class Codex_Yapital_Model_Datatype_YapitalPublicId extends Codex_Yapital_Model_Datatype_Abstract
39
+ implements Codex_Yapital_Model_Datatype_Interface
40
+ {
41
+
42
+ private $_infix = "-";
43
+
44
+ /**
45
+ * prefix that specifies the type of the object, referenced by the public ID.
46
+ *
47
+ * @var string
48
+ */
49
+ protected $_prefix = "";
50
+
51
+ /**
52
+ * suffix that specifies the specific object
53
+ *
54
+ * @var string
55
+ */
56
+ protected $_suffix = "";
57
+
58
+ /**
59
+ * @param string $prefix
60
+ */
61
+ public function setPrefix ( $prefix )
62
+ {
63
+
64
+ $this->_prefix = (string) $prefix;
65
+
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * @return string
71
+ */
72
+ public function getPrefix ()
73
+ {
74
+
75
+ return $this->_prefix;
76
+ }
77
+
78
+ /**
79
+ * @param string $suffix
80
+ */
81
+ public function setSuffix ( $suffix )
82
+ {
83
+
84
+ $this->_suffix = (string) $suffix;
85
+
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * @return string
91
+ */
92
+ public function getSuffix ()
93
+ {
94
+
95
+ return $this->_suffix;
96
+ }
97
+
98
+ public function importString ( $text )
99
+ {
100
+
101
+ list( $prefix, $suffix ) = explode($this->_infix, $text);
102
+
103
+ $this->setPrefix($prefix);
104
+ $this->setSuffix($suffix);
105
+
106
+ return $this;
107
+ }
108
+
109
+
110
+ /**
111
+ * @return string
112
+ */
113
+ public function getData ()
114
+ {
115
+
116
+ return (string) $this->getPrefix() . $this->_infix . $this->getSuffix();
117
+ }
118
+ }
app/code/community/Codex/Yapital/Model/Log.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Delivers a log that is used in the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Yapital
10
+ * @package Codex_Yapital_Model
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Log stores system messages to Magento
18
+ *
19
+ * @category Yapital
20
+ * @package Codex_Yapital_Model
21
+ * @copyright 2013 Code-X GmbH
22
+ * @link http://code-x.de
23
+ * @since Class available since Release 0.1.0
24
+ */
25
+ class Codex_Yapital_Model_Log
26
+ {
27
+
28
+ public static $isDebugMode = true;
29
+
30
+ public static $isVerboseMode = true;
31
+
32
+ /**
33
+ * Decide when to print the error message (true) or not (false)
34
+ * @var bool
35
+ */
36
+ protected static $_print = false;
37
+
38
+
39
+ /**
40
+ * Send a debug message to the log
41
+ *
42
+ * @param string $message
43
+ */
44
+ public static function debug($message = "~~~")
45
+ {
46
+ if (static::$isDebugMode)
47
+ {
48
+ if (!is_scalar($message))
49
+ {
50
+ $message = var_export($message, true);
51
+ }
52
+
53
+ self::_logAdapter($message, Zend_Log::DEBUG);
54
+ }
55
+ }
56
+
57
+
58
+ /**
59
+ * Send an error message to the log
60
+ *
61
+ * @param $message
62
+ */
63
+ public static function error($message)
64
+ {
65
+ $message = "ERROR! " . $message;
66
+ self::_logAdapter($message, Zend_Log::WARN);
67
+ }
68
+
69
+
70
+ /**
71
+ * Send a message to log
72
+ *
73
+ * @param $message
74
+ */
75
+ public static function log($message)
76
+ {
77
+ self::_logAdapter($message, Zend_Log::INFO);
78
+ }
79
+
80
+
81
+ public static function setPrint($bool = true)
82
+ {
83
+ self::$_print = $bool;
84
+ }
85
+
86
+
87
+ public static function verbose($message)
88
+ {
89
+ if (static::$isVerboseMode)
90
+ {
91
+ self::_logAdapter($message, Zend_Log::NOTICE);
92
+ }
93
+ }
94
+
95
+
96
+ protected static function _logAdapter($message, $level = null, $file = 'codex_yapital.log', $forceLog = false)
97
+ {
98
+ static $firstInit = true;
99
+
100
+ if ($firstInit)
101
+ {
102
+ $firstInit = false;
103
+ Mage::log('-------------', Zend_Log::INFO, $file, $forceLog);
104
+ }
105
+
106
+ $message = "Yapital: " . $message;
107
+ if (self::$_print)
108
+ {
109
+ echo "\n" . $message . "\n";
110
+ }
111
+ Mage::log($message, $level, $file, $forceLog);
112
+ }
113
+ }
app/code/community/Codex/Yapital/Model/Notification.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Notification extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ const YAPITAL_STATUS_PAID = 'PAID';
7
+ const YAPITAL_STATUS_FAILED = 'FAILED';
8
+ const YAPITAL_STATUS_CANCELLED = 'CANCELLED';
9
+
10
+ /*
11
+ entity_id
12
+ notification_id
13
+ transaction_id
14
+ status_code
15
+ status_information
16
+ customer_data
17
+ amount
18
+ currency
19
+ */
20
+
21
+ /* @var Codex_Yapital_Model_Order_Transaction */
22
+ protected $_transaction;
23
+
24
+ protected $_eventPrefix = 'yapital_notification';
25
+
26
+ protected $_eventObject = 'yapital_notification';
27
+
28
+ protected function _construct()
29
+ {
30
+ $this->_init('yapital/notification');
31
+ }
32
+
33
+ /**
34
+ * Import an array
35
+ *
36
+ * @param array $data
37
+ *
38
+ * @return Codex_Yapital_Model_Notification
39
+ */
40
+ public function import( Array $data )
41
+ {
42
+ $payment_processed_body = $data['body']['payment_processed_body'];
43
+
44
+ $this->setData( 'notification_id', $payment_processed_body['notification_id'] );
45
+ $this->setData( 'transaction_id', $payment_processed_body['transaction_id'] );
46
+ $this->setData( 'status_code', $payment_processed_body['status_code'] );
47
+ $this->setData( 'status_information', $payment_processed_body['status_information'] );
48
+ $this->setData( 'customer_data', $payment_processed_body['customer_data'] );
49
+ $this->setData( 'amount', $payment_processed_body['amount'] );
50
+ $this->setData( 'currency', $payment_processed_body['currency'] );
51
+
52
+ $this->setData('event_type', $data['event_type']);
53
+ $this->setData('event_id', $data['event_id']);
54
+ $this->setData('event_timestamp', $data['event_timestamp']);
55
+
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * @return Codex_Yapital_Model_Order_Transaction
61
+ */
62
+ public function getTransaction()
63
+ {
64
+ if ( !$this->_transaction )
65
+ {
66
+ $this->_transaction = Mage::getModel('yapital/order_transaction');
67
+ $this->_transaction->load($this->getTransactionId(), 'transaction_id' );
68
+ }
69
+ return $this->_transaction;
70
+ }
71
+
72
+ /**
73
+ * Create a new notification
74
+ *
75
+ * @return Codex_Yapital_Model_Notification
76
+ */
77
+ public function register ()
78
+ {
79
+ Codex_Yapital_Model_Log::log("Creating new notification");
80
+
81
+ /* @var $notification Codex_Yapital_Model_Datatype_Notification */
82
+ $notification = Mage::getModel("yapital/datatype_notification");
83
+
84
+ $notification->setNotificationId(""); /// @todo id
85
+ $notification->setEventType(Codex_Yapital_Model_Datatype_EventType::PAYMENT_PROCESSED);
86
+ $notification->setCallbackUrl( $this->getCallbackUrl() );
87
+ $notification->setValidationStatus("UNDEFINED"); /// @todo NotificationValidationStatus
88
+ $notification->setAcceptType("JSON"); /// @todo NotificationAcceptType as
89
+
90
+ $api = Mage::getModel("yapital/api_notification");
91
+ /* @var $api Codex_Yapital_Model_Api_Notification */
92
+
93
+ $result = $api->register($notification);
94
+
95
+ return $this;
96
+ }
97
+
98
+ public function getCallbackUrl() {
99
+ return Mage::getUrl('yapital/notification/receive', array('_forced_secure' => true, 'secret' => $this->getSecret() ) );
100
+ }
101
+
102
+ public function getSecret() {
103
+ return $this->_getConfig()->getNotificationSecret();
104
+ }
105
+
106
+ public function processOrder()
107
+ {
108
+ $_order = $this->getTransaction()->getOrder();
109
+
110
+ switch ( $this->getStatusCode() ) {
111
+
112
+ case self::YAPITAL_STATUS_PAID:
113
+ $this->_processOrderPaid();
114
+ break;
115
+
116
+ case self::YAPITAL_STATUS_FAILED:
117
+ $this->_processOrderFailed();
118
+ break;
119
+
120
+ case self::YAPITAL_STATUS_CANCELLED:
121
+ $this->_processOrderCancelled();
122
+ break;
123
+
124
+ }
125
+
126
+ return $this;
127
+ }
128
+
129
+ protected function _processOrderPaid()
130
+ {
131
+ /** @var $order Mage_Sales_Model_Order */
132
+ $order = $this->getTransaction()->getOrder();
133
+ $payment = $order->getPayment();
134
+ $translations = Mage::helper('yapital');
135
+
136
+ // TODO: Validate amount and currency
137
+ $config = $this->_getConfig();
138
+ $config->importOrder($this->getTransaction()->getOrder());
139
+
140
+ $order->setState($this->_getConfig()->getOrderPaidState(), true, $translations->__('Order paid'), false);
141
+
142
+ $this->_createInvoice();
143
+ $order->getPayment()->setLastTransId( $this->getTransaction()->getId() );
144
+
145
+ $this->_closeTransaction();
146
+
147
+ $order->save();
148
+
149
+ return $this;
150
+ }
151
+
152
+ /**
153
+ * Builds invoice for order
154
+ */
155
+ protected function _createInvoice()
156
+ {
157
+ /** @var $order Mage_Sales_Model_Order */
158
+ $order = $this->getTransaction()->getOrder();
159
+
160
+ if (!$order->canInvoice()) {
161
+ return null;
162
+ }
163
+
164
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
165
+ $invoice = $order->prepareInvoice();
166
+
167
+ $invoice->register()->capture();
168
+ $order->addRelatedObject($invoice);
169
+
170
+ return $this;
171
+ }
172
+
173
+ protected function _processOrderCancelled()
174
+ {
175
+
176
+ $translations = Mage::helper('yapital');
177
+
178
+ $order = $this->getTransaction()->getOrder();
179
+ $order->registerCancellation($translations->__('Order cancelled'),false);
180
+
181
+ $this->_closeTransaction();
182
+
183
+ $order->save();
184
+
185
+ return $this;
186
+ }
187
+
188
+ protected function _processOrderFailed()
189
+ {
190
+ $order = $this->getTransaction()->getOrder();
191
+ $order->registerCancellation('',false);
192
+
193
+ $this->_closeTransaction();
194
+
195
+ $order->save();
196
+
197
+ return $this;
198
+ }
199
+
200
+ protected function _closeTransaction() {
201
+ $this->getTransaction()->close();
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Gets the Config model
207
+ *
208
+ * @return \Codex_Yapital_Model_Config
209
+ */
210
+ protected function _getConfig() {
211
+
212
+ /* @var $config Codex_Yapital_Model_Config */
213
+ $config = Mage::getSingleton('yapital/config');
214
+
215
+ return $config;
216
+ }
217
+
218
+ }
app/code/community/Codex/Yapital/Model/Observer.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Observer
4
+ {
5
+ public function aggregateYapitalReportOrderPaymentData($schedule)
6
+ {
7
+ Mage::app()->getLocale()->emulate(0);
8
+ $currentDate = Mage::app()->getLocale()->date();
9
+ $date = $currentDate->subHour(25);
10
+ Mage::getResourceModel('yapital/report_paymentmethod')->aggregate($date);
11
+ Mage::app()->getLocale()->revert();
12
+ return $this;
13
+ }
14
+ }
app/code/community/Codex/Yapital/Model/Order/Transaction.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Codex_Yapital_Model_Order_Transaction.
5
+ *
6
+ * @category Yapital
7
+ *
8
+ * @method void setOrderId(int $id) Set the order id
9
+ * @method void setTransactionId(int $id) Set the order id
10
+ */
11
+ class Codex_Yapital_Model_Order_Transaction extends Mage_Core_Model_Abstract
12
+ {
13
+
14
+ protected $_eventPrefix = 'yapital_order_transaction';
15
+
16
+ protected $_eventObject = 'yapital_order_transaction';
17
+
18
+ /* @var Mage_Sales_Model_Order */
19
+ protected $_order;
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('yapital/order_transaction');
24
+ }
25
+
26
+ public function importShopRestResponse( Mage_Sales_Model_Order $order, Codex_Yapital_Model_Datatype_Shoprestresponse $response)
27
+ {
28
+ $this->setOrderId( $order->getId() );
29
+ $this->setTransactionId( $response->getPayload()->transaction_id );
30
+
31
+ return $this;
32
+ }
33
+
34
+ /*
35
+ * @return Mage_Sales_Model_Order
36
+ */
37
+ public function getOrder() {
38
+
39
+ if ( !$this->_order ) {
40
+ $this->_order = Mage::getModel('sales/order');
41
+ $this->_order->load( $this->getOrderId() );
42
+ }
43
+ return $this->_order;
44
+ }
45
+
46
+ protected function _afterSave()
47
+ {
48
+ $order = $this->getOrder();
49
+ $payment = $order->getPayment();
50
+
51
+ $payment->setTransactionId( $this->getTransactionId() );
52
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, "Yapital-Payment-Auth");
53
+
54
+ $transaction->setIsClosed(0);
55
+
56
+ $order->save();
57
+
58
+ return parent::_afterSave();
59
+ }
60
+
61
+ public function close() {
62
+ $payment = $this->getOrder()->getPayment();
63
+ $transaction = $payment->getTransaction( $this->getTransactionId() );
64
+ if ( $transaction ) {
65
+ $transaction->setIsClosed(1);
66
+ $transaction->save();
67
+ }
68
+ return $this;
69
+ }
70
+
71
+
72
+ }
app/code/community/Codex/Yapital/Model/Payment/Standard.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Payment_Standard extends Mage_Payment_Model_Method_Abstract
4
+ {
5
+ /**
6
+ * unique internal payment method identifier
7
+ *
8
+ * @var string [a-z0-9_]
9
+ */
10
+ protected $_code = 'yapital_standard';
11
+
12
+ protected $_isGateway = false;
13
+ protected $_canOrder = false;
14
+ protected $_canAuthorize = false;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = true;
19
+ protected $_canVoid = false;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_isInitializeNeeded = true;
24
+ protected $_canFetchTransactionInfo = false;
25
+ protected $_canReviewPayment = false;
26
+ protected $_canCreateBillingAgreement = false;
27
+ protected $_canManageRecurringProfiles = true;
28
+ protected $_canCancelInvoice = false;
29
+
30
+ public function initialize($paymentAction, $stateObject)
31
+ {
32
+ $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
33
+ $stateObject->setState($state);
34
+ $stateObject->setStatus('pending_payment');
35
+ $stateObject->setIsNotified(false);
36
+ }
37
+
38
+ public function getOrderPlaceRedirectUrl()
39
+ {
40
+ return Mage::getUrl('yapital/standard/redirect', array('_secure' => true));
41
+ }
42
+
43
+
44
+ public function refund(Varien_Object $payment, $amount)
45
+ {
46
+ /** @var $payment Mage_Sales_Model_Order_Payment */
47
+
48
+ /* @var $api Codex_Yapital_Model_Api_ReturnBasket */
49
+ $api = Mage::getModel('yapital/api_returnBasket');
50
+
51
+ /** @var Codex_Yapital_Model_Datatype_Returnbasket $basket */
52
+ $basket = Mage::getModel('yapital/datatype_returnbasket');
53
+
54
+ /* @var $amount Codex_Yapital_Model_Datatype_Amount */
55
+ $amountModel = Mage::getModel('yapital/datatype_amount');
56
+
57
+ $amountModel->setCurrency(Codex_Yapital_Model_Datatype_Currency::EUR);
58
+ $amountModel->setValue($amount);
59
+
60
+ $basket->setAmountToCredit($amountModel);
61
+
62
+ /** @var $config Codex_Yapital_Model_Config */
63
+ $config = Mage::getSingleton('yapital/config');
64
+ $config->importOrder( $payment->getOrder() );
65
+
66
+ $response = $api->send($config->getYapitalShopId(), $payment->getAuthorizationTransaction()->getTxnId(), $basket);
67
+ Codex_Yapital_Model_Log::log("ReturnBasket-Response:". $response);
68
+
69
+ if (!$api->getClient()->getHttpClient()->getLastResponse()->isSuccessful())
70
+ {
71
+ throw new Exception('could not process refund');
72
+ }
73
+
74
+ return $this;
75
+ }
76
+ }
app/code/community/Codex/Yapital/Model/Resource/Notification.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Resource_Notification extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ protected function _construct ()
7
+ {
8
+ $this->_init('yapital/notification', 'entity_id');
9
+ }
10
+
11
+ }
app/code/community/Codex/Yapital/Model/Resource/Notification/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Resource_Notification_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('yapital/notification');
9
+ }
10
+
11
+ }
app/code/community/Codex/Yapital/Model/Resource/Order/Transaction.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Resource_Order_Transaction extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ protected function _construct()
7
+ {
8
+ $this->_init('yapital/order_transaction', 'entity_id');
9
+ }
10
+
11
+ }
app/code/community/Codex/Yapital/Model/Resource/Order/Transaction/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Resource_Order_Transaction_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('yapital/order_transaction');
9
+ }
10
+
11
+ }
app/code/community/Codex/Yapital/Model/Resource/Report/Paymentmethod.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Resource_Report_Paymentmethod extends Mage_Sales_Model_Resource_Report_Abstract
4
+ {
5
+ /**
6
+ * Model initialization
7
+ *
8
+ */
9
+ protected function _construct()
10
+ {
11
+ $this->_init('sales/order_aggregated_payment', 'id');
12
+ }
13
+
14
+ /**
15
+ * Aggregate Orders data by order created at
16
+ *
17
+ * @param mixed $from
18
+ * @param mixed $to
19
+ * @return Mage_Sales_Model_Resource_Report_Order_Createdat
20
+ */
21
+ public function aggregate($from = null, $to = null)
22
+ {
23
+ return $this->_aggregateByField('created_at', $from, $to);
24
+ }
25
+
26
+ /**
27
+ * Aggregate Orders data by custom field
28
+ *
29
+ * @throws Exception
30
+ * @param string $aggregationField
31
+ * @param mixed $from
32
+ * @param mixed $to
33
+ * @return Mage_Sales_Model_Resource_Report_Order_Createdat
34
+ */
35
+ protected function _aggregateByField($aggregationField, $from, $to)
36
+ {
37
+ // convert input dates to UTC to be comparable with DATETIME fields in DB
38
+ $from = $this->_dateToUtc($from);
39
+ $to = $this->_dateToUtc($to);
40
+
41
+ $this->_checkDates($from, $to);
42
+ $adapter = $this->_getWriteAdapter();
43
+
44
+ $adapter->beginTransaction();
45
+ try {
46
+
47
+ if ($from !== null || $to !== null) {
48
+ $subSelect = $this->_getTableDateRangeSelect(
49
+ $this->getTable('sales/order'),
50
+ 'created_at', 'updated_at', $from, $to
51
+ );
52
+ } else {
53
+ $subSelect = null;
54
+ }
55
+ $this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect);
56
+
57
+ $periodExpr = $adapter->getDatePartSql($this->getStoreTZOffsetQuery(
58
+ array('o' => $this->getTable('sales/order')),
59
+ 'o.' . $aggregationField,
60
+ $from, $to
61
+ ));
62
+ // Columns list
63
+ $columns = array(
64
+ // convert dates from UTC to current admin timezone
65
+ 'period' => $periodExpr,
66
+ 'method' => 'op.method',
67
+ 'store_id' => 'o.store_id',
68
+ 'order_status' => 'o.status',
69
+ 'orders_count' => new Zend_Db_Expr('COUNT(o.entity_id)'),
70
+ 'total_qty_ordered' => new Zend_Db_Expr('SUM(oi.total_qty_ordered)'),
71
+ 'total_qty_invoiced' => new Zend_Db_Expr('SUM(oi.total_qty_invoiced)'),
72
+ 'total_income_amount' => new Zend_Db_Expr(
73
+ sprintf('SUM((%s - %s) * %s)',
74
+ $adapter->getIfNullSql('o.base_grand_total', 0),
75
+ $adapter->getIfNullSql('o.base_total_canceled',0),
76
+ $adapter->getIfNullSql('o.base_to_global_rate',0)
77
+ )
78
+ ),
79
+ 'total_revenue_amount' => new Zend_Db_Expr(
80
+ sprintf('SUM((%s - %s - %s - (%s - %s - %s)) * %s)',
81
+ $adapter->getIfNullSql('o.base_total_invoiced', 0),
82
+ $adapter->getIfNullSql('o.base_tax_invoiced', 0),
83
+ $adapter->getIfNullSql('o.base_shipping_invoiced', 0),
84
+ $adapter->getIfNullSql('o.base_total_refunded', 0),
85
+ $adapter->getIfNullSql('o.base_tax_refunded', 0),
86
+ $adapter->getIfNullSql('o.base_shipping_refunded', 0),
87
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
88
+ )
89
+ ),
90
+ 'total_profit_amount' => new Zend_Db_Expr(
91
+ sprintf('SUM((%s - %s - %s - %s - %s) * %s)',
92
+ $adapter->getIfNullSql('o.base_total_paid', 0),
93
+ $adapter->getIfNullSql('o.base_total_refunded', 0),
94
+ $adapter->getIfNullSql('o.base_tax_invoiced', 0),
95
+ $adapter->getIfNullSql('o.base_shipping_invoiced', 0),
96
+ $adapter->getIfNullSql('o.base_total_invoiced_cost', 0),
97
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
98
+ )
99
+ ),
100
+ 'total_invoiced_amount' => new Zend_Db_Expr(
101
+ sprintf('SUM(%s * %s)',
102
+ $adapter->getIfNullSql('o.base_total_invoiced', 0),
103
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
104
+ )
105
+ ),
106
+ 'total_canceled_amount' => new Zend_Db_Expr(
107
+ sprintf('SUM(%s * %s)',
108
+ $adapter->getIfNullSql('o.base_total_canceled', 0),
109
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
110
+ )
111
+ ),
112
+ 'total_paid_amount' => new Zend_Db_Expr(
113
+ sprintf('SUM(%s * %s)',
114
+ $adapter->getIfNullSql('o.base_total_paid', 0),
115
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
116
+ )
117
+ ),
118
+ 'total_refunded_amount' => new Zend_Db_Expr(
119
+ sprintf('SUM(%s * %s)',
120
+ $adapter->getIfNullSql('o.base_total_refunded', 0),
121
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
122
+ )
123
+ ),
124
+ 'total_tax_amount' => new Zend_Db_Expr(
125
+ sprintf('SUM((%s - %s) * %s)',
126
+ $adapter->getIfNullSql('o.base_tax_amount', 0),
127
+ $adapter->getIfNullSql('o.base_tax_canceled', 0),
128
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
129
+ )
130
+ ),
131
+ 'total_tax_amount_actual' => new Zend_Db_Expr(
132
+ sprintf('SUM((%s -%s) * %s)',
133
+ $adapter->getIfNullSql('o.base_tax_invoiced', 0),
134
+ $adapter->getIfNullSql('o.base_tax_refunded', 0),
135
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
136
+ )
137
+ ),
138
+ 'total_shipping_amount' => new Zend_Db_Expr(
139
+ sprintf('SUM((%s - %s) * %s)',
140
+ $adapter->getIfNullSql('o.base_shipping_amount', 0),
141
+ $adapter->getIfNullSql('o.base_shipping_canceled', 0),
142
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
143
+ )
144
+ ),
145
+ 'total_shipping_amount_actual' => new Zend_Db_Expr(
146
+ sprintf('SUM((%s - %s) * %s)',
147
+ $adapter->getIfNullSql('o.base_shipping_invoiced', 0),
148
+ $adapter->getIfNullSql('o.base_shipping_refunded', 0),
149
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
150
+ )
151
+ ),
152
+ 'total_discount_amount' => new Zend_Db_Expr(
153
+ sprintf('SUM((ABS(%s) - %s) * %s)',
154
+ $adapter->getIfNullSql('o.base_discount_amount', 0),
155
+ $adapter->getIfNullSql('o.base_discount_canceled', 0),
156
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
157
+ )
158
+ ),
159
+ 'total_discount_amount_actual' => new Zend_Db_Expr(
160
+ sprintf('SUM((%s - %s) * %s)',
161
+ $adapter->getIfNullSql('o.base_discount_invoiced', 0),
162
+ $adapter->getIfNullSql('o.base_discount_refunded', 0),
163
+ $adapter->getIfNullSql('o.base_to_global_rate', 0)
164
+ )
165
+ )
166
+ );
167
+
168
+ $select = $adapter->select();
169
+ $selectOrderItem = $adapter->select();
170
+ $selectOrderPayment = $adapter->select();
171
+
172
+ $qtyCanceledExpr = $adapter->getIfNullSql('qty_canceled', 0);
173
+ $cols = array(
174
+ 'order_id' => 'order_id',
175
+ 'total_qty_ordered' => new Zend_Db_Expr("SUM(qty_ordered - {$qtyCanceledExpr})"),
176
+ 'total_qty_invoiced' => new Zend_Db_Expr('SUM(qty_invoiced)'),
177
+ );
178
+ $selectOrderItem->from($this->getTable('sales/order_item'), $cols)
179
+ ->where('parent_item_id IS NULL')
180
+ ->group('order_id');
181
+
182
+ $selectOrderPayment->from($this->getTable('sales/order_payment'), array('method', 'parent_id'))
183
+ ->group('parent_id');
184
+
185
+ $select->from(array('o' => $this->getTable('sales/order')), $columns)
186
+ ->join(array('oi' => $selectOrderItem), 'oi.order_id = o.entity_id', array())
187
+ ->join(array('op' => $selectOrderPayment), 'op.parent_id = o.entity_id', array())
188
+ ->where('o.state NOT IN (?)', array(
189
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
190
+ Mage_Sales_Model_Order::STATE_NEW
191
+ ));
192
+
193
+ if ($subSelect !== null) {
194
+ $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period'));
195
+ }
196
+
197
+ $select->group(array(
198
+ $periodExpr,
199
+ 'op.method',
200
+ 'o.store_id',
201
+ 'o.status',
202
+ ));
203
+
204
+ $adapter->query($select->insertFromSelect($this->getMainTable(), array_keys($columns)));
205
+
206
+ // setup all columns to select SUM() except period, store_id and order_status
207
+ foreach ($columns as $k => $v) {
208
+ $columns[$k] = new Zend_Db_Expr('SUM(' . $k . ')');
209
+ }
210
+ $columns['period'] = 'period';
211
+ $columns['method'] = 'method';
212
+ $columns['store_id'] = new Zend_Db_Expr(Mage_Core_Model_App::ADMIN_STORE_ID);
213
+ $columns['order_status'] = 'order_status';
214
+
215
+ $select->reset();
216
+ $select->from($this->getMainTable(), $columns)
217
+ ->where('store_id <> 0');
218
+
219
+ if ($subSelect !== null) {
220
+ $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'period'));
221
+ }
222
+
223
+ $select->group(array(
224
+ 'period',
225
+ 'method',
226
+ 'order_status'
227
+ ));
228
+ $adapter->query($select->insertFromSelect($this->getMainTable(), array_keys($columns)));
229
+ $adapter->commit();
230
+ } catch (Exception $e) {
231
+ $adapter->rollBack();
232
+ throw $e;
233
+ }
234
+
235
+ return $this;
236
+ }
237
+ }
app/code/community/Codex/Yapital/Model/Resource/Report/Paymentmethod/Collection.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Resource_Report_Paymentmethod_Collection extends Mage_Sales_Model_Resource_Report_Collection_Abstract
4
+ {
5
+ /**
6
+ * Period format
7
+ *
8
+ * @var string
9
+ */
10
+ protected $_periodFormat;
11
+
12
+ /**
13
+ * Aggregated Data Table
14
+ *
15
+ * @var string
16
+ */
17
+ protected $_aggregationTable = 'sales/order_aggregated_payment';
18
+
19
+ /**
20
+ * Selected columns
21
+ *
22
+ * @var array
23
+ */
24
+ protected $_selectedColumns = array();
25
+
26
+ /**
27
+ * Initialize custom resource model
28
+ *
29
+ */
30
+ public function __construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setModel('adminhtml/report_item');
34
+ $this->_resource = Mage::getResourceModel('sales/report')->init($this->_aggregationTable);
35
+ $this->setConnection($this->getResource()->getReadConnection());
36
+ }
37
+
38
+ /**
39
+ * Get selected columns
40
+ *
41
+ * @return array
42
+ */
43
+ protected function _getSelectedColumns()
44
+ {
45
+ $adapter = $this->getConnection();
46
+ if ('month' == $this->_period) {
47
+ $this->_periodFormat = $adapter->getDateFormatSql('period', '%Y-%m');
48
+ } elseif ('year' == $this->_period) {
49
+ $this->_periodFormat = $adapter->getDateExtractSql('period', Varien_Db_Adapter_Interface::INTERVAL_YEAR);
50
+ } else {
51
+ $this->_periodFormat = $adapter->getDateFormatSql('period', '%Y-%m-%d');
52
+ }
53
+
54
+ if (!$this->isTotals()) {
55
+ $this->_selectedColumns = array(
56
+ 'period' => $this->_periodFormat,
57
+ 'method' => 'method',
58
+ 'orders_count' => 'SUM(orders_count)',
59
+ 'total_qty_ordered' => 'SUM(total_qty_ordered)',
60
+ 'total_qty_invoiced' => 'SUM(total_qty_invoiced)',
61
+ 'total_income_amount' => 'SUM(total_income_amount)',
62
+ 'total_revenue_amount' => 'SUM(total_revenue_amount)',
63
+ 'total_profit_amount' => 'SUM(total_profit_amount)',
64
+ 'total_invoiced_amount' => 'SUM(total_invoiced_amount)',
65
+ 'total_canceled_amount' => 'SUM(total_canceled_amount)',
66
+ 'total_paid_amount' => 'SUM(total_paid_amount)',
67
+ 'total_refunded_amount' => 'SUM(total_refunded_amount)',
68
+ 'total_tax_amount' => 'SUM(total_tax_amount)',
69
+ 'total_tax_amount_actual' => 'SUM(total_tax_amount_actual)',
70
+ 'total_shipping_amount' => 'SUM(total_shipping_amount)',
71
+ 'total_shipping_amount_actual' => 'SUM(total_shipping_amount_actual)',
72
+ 'total_discount_amount' => 'SUM(total_discount_amount)',
73
+ 'total_discount_amount_actual' => 'SUM(total_discount_amount_actual)',
74
+ );
75
+ }
76
+
77
+ if ($this->isTotals()) {
78
+ $this->_selectedColumns = $this->getAggregatedColumns();
79
+ }
80
+
81
+ return $this->_selectedColumns;
82
+ }
83
+
84
+ /**
85
+ * Add selected data
86
+ *
87
+ * @return Mage_Sales_Model_Resource_Report_Order_Collection
88
+ */
89
+ protected function _initSelect()
90
+ {
91
+ $this->getSelect()->from($this->getResource()->getMainTable(), $this->_getSelectedColumns());
92
+ if (!$this->isTotals()) {
93
+ $this->getSelect()->group($this->_periodFormat);
94
+ }
95
+ return $this;
96
+ }
97
+ }
app/code/community/Codex/Yapital/Model/System/Config/Payment/Credentials/Switch.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_System_Config_Payment_Credentials_Switch
4
+ {
5
+
6
+ const LIVE = 1;
7
+ const SANDBOX = 2;
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray ()
15
+ {
16
+ return array(
17
+ array( 'value' => self::LIVE, 'label' => Mage::helper('yapital/data')->__('Live') ),
18
+ array( 'value' => self::SANDBOX, 'label' => Mage::helper('yapital/data')->__('Sandbox') ),
19
+ );
20
+ }
21
+
22
+ public function toArray ()
23
+ {
24
+ return array(
25
+ self::LIVE => Mage::helper('yapital/data')->__('Live'),
26
+ self::SANDBOX => Mage::helper('yapital/data')->__('Sandbox'),
27
+ );
28
+ }
29
+ }
app/code/community/Codex/Yapital/controllers/Adminhtml/Report/YapitalController.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Adminhtml_Report_YapitalController extends Mage_Adminhtml_Controller_Report_Abstract
4
+ {
5
+ /**
6
+ * Add report/sales breadcrumbs
7
+ *
8
+ * @return Mage_Adminhtml_Report_SalesController
9
+ */
10
+ public function _initAction()
11
+ {
12
+ parent::_initAction();
13
+ $this->_addBreadcrumb(Mage::helper('yapital')->__('Yapital'), Mage::helper('yapital')->__('Yapital'));
14
+ return $this;
15
+ }
16
+
17
+ /**
18
+ * Retrieve array of collection names by code specified in request
19
+ *
20
+ * @deprecated after 1.4.0.1
21
+ * @return array
22
+ */
23
+ protected function _getCollectionNames()
24
+ {
25
+ return array();
26
+ }
27
+
28
+ /**
29
+ * Refresh statistics for last 25 hours
30
+ *
31
+ * @deprecated after 1.4.0.1
32
+ * @return Mage_Adminhtml_Report_SalesController
33
+ */
34
+ public function refreshRecentAction()
35
+ {
36
+ return $this->_forward('refreshRecent', 'report_statistics');
37
+ }
38
+
39
+ /**
40
+ * Refresh statistics for all period
41
+ *
42
+ * @deprecated after 1.4.0.1
43
+ * @return Mage_Adminhtml_Report_SalesController
44
+ */
45
+ public function refreshLifetimeAction()
46
+ {
47
+ try {
48
+ Mage::getResourceModel('yapital/report_paymentmethod')->aggregate(null, null);
49
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Lifetime statistics have been updated.'));
50
+ } catch (Mage_Core_Exception $e) {
51
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
52
+ } catch (Exception $e) {
53
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Unable to refresh lifetime statistics.'));
54
+ Mage::logException($e);
55
+ }
56
+ }
57
+
58
+ public function paymentAction()
59
+ {
60
+ $this->_title($this->__('Reports'))->_title($this->__('Yapital'))->_title($this->__('Payment'));
61
+
62
+ //$this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_SHIPPING_FLAG_CODE, 'shipping');
63
+
64
+ $this->_initAction()
65
+ ->_setActiveMenu('report/yapital/payment')
66
+ ->_addBreadcrumb(Mage::helper('yapital')->__('Payment'), Mage::helper('yapital')->__('Payment'));
67
+
68
+ $gridBlock = $this->getLayout()->getBlock('adminhtml_report_yapital_payment.grid');
69
+ $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
70
+
71
+ $this->_initReportAction(array(
72
+ $gridBlock,
73
+ $filterFormBlock
74
+ ));
75
+
76
+ $this->renderLayout();
77
+ }
78
+
79
+ /**
80
+ * Export payment report grid to CSV format
81
+ */
82
+ public function exportPaymentCsvAction()
83
+ {
84
+ $fileName = 'payment.csv';
85
+ $grid = $this->getLayout()->createBlock('yapital/adminhtml_report_yapital_payment_grid');
86
+ $this->_initReportAction($grid);
87
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
88
+ }
89
+
90
+ /**
91
+ * Export payment report grid to Excel XML format
92
+ */
93
+ public function exportPaymentExcelAction()
94
+ {
95
+ $fileName = 'payment.xml';
96
+ $grid = $this->getLayout()->createBlock('yapital/adminhtml_report_yapital_payment_grid');
97
+ $this->_initReportAction($grid);
98
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
99
+ }
100
+
101
+ /**
102
+ * @deprecated after 1.4.0.1
103
+ */
104
+ public function refreshStatisticsAction()
105
+ {
106
+ return $this->_forward('index', 'report_statistics');
107
+ }
108
+
109
+ protected function _isAllowed()
110
+ {
111
+ switch ($this->getRequest()->getActionName()) {
112
+ case 'payment':
113
+ return $this->_getSession()->isAllowed('report/yapital/payment');
114
+ break;
115
+ default:
116
+ return $this->_getSession()->isAllowed('report/yapital');
117
+ break;
118
+ }
119
+ }
120
+ }
app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/ConfigController.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Adminhtml_Yapital_ConfigController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ public function validateAction ()
7
+ {
8
+ session_write_close();
9
+
10
+ Codex_Yapital_Model_Log::log("Validating user given credentials");
11
+
12
+ $dataHelper = Mage::helper('yapital/data');
13
+ $result = array();
14
+ $result["message"] = $dataHelper->__('We are sorry! Something went wrong.');
15
+ $result["has_errors"] = true;
16
+
17
+ try
18
+ {
19
+
20
+ if ( isset( $_REQUEST['shop_id'] ) )
21
+ {
22
+ /**
23
+ * @var $tokenModel Codex_Yapital_Model_Api_Token
24
+ */
25
+ $tokenModel = Mage::getModel("yapital/api_token");
26
+ $token = $tokenModel->getTokenByFullCredentials(
27
+ $_REQUEST['shop_id'],
28
+ $_REQUEST['client_id'],
29
+ $_REQUEST['secret_key']
30
+ );
31
+
32
+ if ( "" != $token->getAccessToken() )
33
+ {
34
+ $result["message"] = $dataHelper->__(
35
+ 'Congratulations! Store this config to let your customer pay easily with yapital.'
36
+ );
37
+ $result["has_errors"] = false;
38
+ }
39
+ else
40
+ {
41
+ $result["message"] = $dataHelper->__('No access token received');
42
+ }
43
+ }
44
+
45
+ }
46
+ catch ( Exception $e )
47
+ {
48
+ $result["message"] = "Error: " . $e->getMessage();
49
+ }
50
+
51
+ if (true == $result["has_errors"]) {
52
+ Codex_Yapital_Model_Log::log("Unable to validate user given credentials.");
53
+ }
54
+
55
+ $resultJSON = Mage::helper('core')->jsonEncode($result);
56
+
57
+ $this->getResponse()->setBody($resultJSON);
58
+
59
+ }
60
+
61
+ public function validateSandboxAction ()
62
+ {
63
+ session_write_close();
64
+
65
+ /** @var $config Codex_Yapital_Model_Config */
66
+ $config = Mage::getSingleton('yapital/config');
67
+ $config->setSandbox( true );
68
+
69
+ Codex_Yapital_Model_Log::log("Validating user given credentials");
70
+
71
+ $dataHelper = Mage::helper('yapital/data');
72
+ $result = array();
73
+ $result["message"] = $dataHelper->__('We are sorry! Something went wrong.');
74
+ $result["has_errors"] = true;
75
+
76
+ try
77
+ {
78
+
79
+ if ( isset( $_REQUEST['shop_id'] ) )
80
+ {
81
+ /**
82
+ * @var $tokenModel Codex_Yapital_Model_Api_Token
83
+ */
84
+ $tokenModel = Mage::getModel("yapital/api_token");
85
+ $token = $tokenModel->getTokenByFullCredentials(
86
+ $_REQUEST['shop_id'],
87
+ $_REQUEST['client_id'],
88
+ $_REQUEST['secret_key']
89
+ );
90
+
91
+ if ( "" != $token->getAccessToken() )
92
+ {
93
+ $result["message"] = $dataHelper->__(
94
+ 'Congratulations! Store this config to let your customer pay easily with yapital.'
95
+ );
96
+ $result["has_errors"] = false;
97
+ }
98
+ }
99
+
100
+ }
101
+ catch ( Exception $e )
102
+ {
103
+ $result["message"] = "Error: " . $e->getMessage();
104
+ }
105
+
106
+ if (true == $result["has_errors"]) {
107
+ Codex_Yapital_Model_Log::log("Unable to validate user given credentials.");
108
+ }
109
+
110
+ $resultJSON = Mage::helper('core')->jsonEncode($result);
111
+
112
+ $this->getResponse()->setBody($resultJSON);
113
+
114
+ }
115
+
116
+ public function statusAction ()
117
+ {
118
+ $result = array();
119
+
120
+ $result = Mage::helper('core')->jsonEncode($result);
121
+ Mage::app()->getResponse()->setBody($result);
122
+ }
123
+ }
app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/NotificationController.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Adminhtml_Yapital_NotificationController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ /**
7
+ * @return Codex_Yapital_Model_Notification
8
+ */
9
+ protected function _getNotificationModel ()
10
+ {
11
+ return Mage::getModel('yapital/notification');
12
+ }
13
+
14
+ protected function _getDataHelper ()
15
+ {
16
+ return Mage::helper('yapital/data');
17
+ }
18
+
19
+ protected function _getStandardResult ()
20
+ {
21
+ return array(
22
+ "message" => $this->_getDataHelper()->__('We are sorry! Something went wrong.'),
23
+ "has_errors" => true,
24
+ );
25
+ }
26
+
27
+ public function registerAction ()
28
+ {
29
+ session_write_close();
30
+
31
+ $dataHelper = Mage::helper('yapital/data');
32
+ $result = $this->_getStandardResult();
33
+
34
+ if ( isset( $_REQUEST['notification_secret'] ) )
35
+ {
36
+ /** @ var $config Codex_Yapital_Model_Config */
37
+ $config = Mage::getSingleton('yapital/config');
38
+ $config->setStoreId(1);
39
+
40
+ $notificationModel = $this->_getNotificationModel();
41
+
42
+ try
43
+ {
44
+ $notificationModel->register();
45
+
46
+ $result["has_errors"] = false;
47
+ $result["message"] = $this->_getDataHelper()->__('Notification has been registered.');
48
+
49
+ }
50
+ catch ( Codex_Yapital_ErrorException $e )
51
+ {
52
+ $config = Mage::getModel('yapital/config');
53
+
54
+ if ( $e->getMessage() == "Rest-Request failed: Duplicate entry found." )
55
+ {
56
+ $result["has_errors"] = false;
57
+ $result["message"] = $this->_getDataHelper()->__('Notification was already registered.');
58
+ }
59
+ else
60
+ {
61
+ $result["message"] = $this->__("Internal error [%d]: ", $e->getCode()) . $e->getMessage();
62
+ }
63
+ }
64
+
65
+ }
66
+
67
+ $resultJSON = Mage::helper('core')->jsonEncode($result);
68
+
69
+ $this->getResponse()->setBody($resultJSON);
70
+
71
+ }
72
+
73
+ public function statusAction ()
74
+ {
75
+ $dataHelper = Mage::helper('yapital/data');
76
+ $result = $this->_getStandardResult();
77
+
78
+ $api = Mage::getModel('yapital/api_notification');
79
+ /* @var $api Codex_Yapital_Model_Api_Notification */
80
+
81
+ /* @var $notification Codex_Yapital_Model_Datatype_Notification */
82
+ $tmpNotification = current($api->getAll());
83
+
84
+ $notificationId = $tmpNotification->getNotificationId();
85
+
86
+ if ( null !== $notificationId )
87
+ {
88
+ $notification = $api->get($notificationId);
89
+
90
+ if ( $notification instanceof Codex_Yapital_Model_Datatype_Notification
91
+ && $notificationId == $notification->getNotificationId()
92
+ )
93
+ {
94
+ $result["message"] = $dataHelper->__('Valid.');
95
+ }
96
+ }
97
+
98
+ $result = Mage::helper('core')->jsonEncode($result);
99
+ Mage::app()->getResponse()->setBody($result);
100
+ }
101
+ }
app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/SandboxController.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Adminhtml_Yapital_SandboxController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ /**
7
+ * @return Codex_Yapital_Model_Notification
8
+ */
9
+ protected function _getNotificationModel ()
10
+ {
11
+ return Mage::getModel('yapital/notification');
12
+ }
13
+
14
+ protected function _getDataHelper ()
15
+ {
16
+ return Mage::helper('yapital/data');
17
+ }
18
+
19
+ protected function _getStandardResult ()
20
+ {
21
+ return array(
22
+ "message" => $this->_getDataHelper()->__('We are sorry! Something went wrong.'),
23
+ "has_errors" => true,
24
+ );
25
+ }
26
+
27
+ public function preDispatch()
28
+ {
29
+ /** @var $config Codex_Yapital_Model_Config */
30
+ $config = Mage::getSingleton('yapital/config');
31
+ $config->setSandbox( true );
32
+ }
33
+
34
+ public function registerAction ()
35
+ {
36
+ session_write_close();
37
+
38
+ $dataHelper = Mage::helper('yapital/data');
39
+ $result = $this->_getStandardResult();
40
+
41
+ if ( isset( $_REQUEST['notification_secret'] ) )
42
+ {
43
+ $notificationModel = $this->_getNotificationModel();
44
+
45
+ try
46
+ {
47
+ $notificationModel->register();
48
+
49
+ $result["has_errors"] = false;
50
+ $result["message"] = $this->_getDataHelper()->__('Notification has been registered.');
51
+
52
+ }
53
+ catch ( Codex_Yapital_ErrorException $e )
54
+ {
55
+ $config = Mage::getModel('yapital/config');
56
+
57
+ if ( $e->getMessage() == "Rest-Request failed: Duplicate entry found." )
58
+ {
59
+ $result["has_errors"] = false;
60
+ $result["message"] = $this->_getDataHelper()->__('Notification was already registered.');
61
+ }
62
+ else
63
+ {
64
+ throw $e;
65
+ $result["message"] = $this->__("Internal error [%d]: ", $e->getCode()) . $e->getMessage();
66
+ }
67
+ }
68
+
69
+ }
70
+
71
+ $resultJSON = Mage::helper('core')->jsonEncode($result);
72
+
73
+ $this->getResponse()->setBody($resultJSON);
74
+
75
+ }
76
+
77
+ public function statusAction ()
78
+ {
79
+ $dataHelper = Mage::helper('yapital/data');
80
+ $result = $this->_getStandardResult();
81
+
82
+ $api = Mage::getModel('yapital/api_notification');
83
+ /* @var $api Codex_Yapital_Model_Api_Notification */
84
+
85
+ /* @var $notification Codex_Yapital_Model_Datatype_Notification */
86
+ $tmpNotification = current($api->getAll());
87
+
88
+ $notificationId = $tmpNotification->getNotificationId();
89
+
90
+ if ( null !== $notificationId )
91
+ {
92
+ $notification = $api->get($notificationId);
93
+
94
+ if ( $notification instanceof Codex_Yapital_Model_Datatype_Notification
95
+ && $notificationId == $notification->getNotificationId()
96
+ )
97
+ {
98
+ $result["message"] = $dataHelper->__('Valid.');
99
+ }
100
+ }
101
+
102
+ $result = Mage::helper('core')->jsonEncode($result);
103
+ Mage::app()->getResponse()->setBody($result);
104
+ }
105
+ }
app/code/community/Codex/Yapital/controllers/NotificationController.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_NotificationController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function receiveAction() {
6
+
7
+ $notification = Mage::getModel('yapital/notification');
8
+ /* @var $notification Codex_Yapital_Model_Notification */
9
+
10
+ $json = $this->getRequest()->getRawBody();
11
+ if ( $this->getRequest()->getParam('debug_json') != '' ) {
12
+ $json = $this->getRequest()->getParam('debug_json');
13
+ }
14
+
15
+ $data = json_decode( $json , true );
16
+ if ( is_array( $data ) || true ) {
17
+ $notification->import( $data );
18
+
19
+ if ( $notification->getSecret() != '' && $notification->getSecret() == $this->getRequest()->getParam('secret') )
20
+ {
21
+ try {
22
+ $notification->save();
23
+ $notification->processOrder();
24
+ $this->getResponse()->setHttpResponseCode(200); // OK
25
+ } catch ( Exception $e ) {
26
+ Codex_Yapital_Model_Log::error( "notification:" .$e->getMessage() );
27
+ $this->getResponse()->setHttpResponseCode(500); // Internal Server Error (Exception)
28
+ }
29
+
30
+ } else {
31
+ Codex_Yapital_Model_Log::error('notification: invalid secret');
32
+ $this->getResponse()->setHttpResponseCode(403); // Invalid Secret, Forbidden
33
+ }
34
+
35
+
36
+ } else {
37
+ Codex_Yapital_Model_Log::error('notification: empty request');
38
+ $this->getResponse()->setHttpResponseCode(200); // To validate Notifications
39
+ }
40
+
41
+ $this->getResponse()->setBody('fin');
42
+ }
43
+
44
+ }
app/code/community/Codex/Yapital/controllers/StandardController.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_StandardController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ /* @var $_order Mage_Sales_Model_Order */
7
+ protected $_order;
8
+
9
+ /**
10
+ * @return Mage_Checkout_Model_Session
11
+ */
12
+ protected function _getSession()
13
+ {
14
+ return Mage::getSingleton('checkout/session');
15
+ }
16
+
17
+ /**
18
+ * Get order
19
+ *
20
+ * @return Mage_Sales_Model_Order
21
+ */
22
+ protected function _getOrder()
23
+ {
24
+ if ( !$this->_order )
25
+ {
26
+ $order_id = $this->getRequest()->getParam('order_id');
27
+ $secret = $this->getRequest()->getParam('secret');
28
+
29
+ $this->_order = Mage::getModel('sales/order')->load( $order_id );
30
+ if ( $this->_order->getId() ) {
31
+
32
+ $helper = Mage::helper('yapital');
33
+ /* @var $helper Codex_Yapital_Helper_Data */
34
+
35
+ if ( $secret != $helper->getOrderHash($this->_order) || empty($secret) ) {
36
+ Codex_Yapital_Model_Log::error("access to order $order_id denied");
37
+ $this->_forward('accessdenied');
38
+ $this->_order->reset();
39
+ }
40
+
41
+ }
42
+
43
+ }
44
+ return $this->_order;
45
+ }
46
+
47
+ public function accessdeniedAction() {
48
+ $this->_response->clearHeader('Location'); // no redirect to basket
49
+
50
+ $this->loadLayout();
51
+ $this->renderLayout();
52
+ }
53
+
54
+ /**
55
+ * When a customer cancel payment from yapital.
56
+ */
57
+ public function cancelAction()
58
+ {
59
+ if ( $order = $this->_getOrder() ) {
60
+ if ($order->getId()) {
61
+ $order->addStatusHistoryComment('Customer canceled order at yapital');
62
+ $order->cancel()->save();
63
+ }
64
+ }
65
+ $this->_redirect('checkout/cart');
66
+ }
67
+
68
+ /**
69
+ * when yapital-customer returns
70
+ */
71
+ public function successAction()
72
+ {
73
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
74
+ $this->_redirect('checkout/onepage/success', array('_secure'=>true));
75
+ }
76
+
77
+ /**
78
+ * wenn yapital-customer got an error
79
+ */
80
+ public function errorAction ()
81
+ {
82
+ if ( $order = $this->_getOrder() ) {
83
+ if ($order->getId()) {
84
+ $order->addStatusHistoryComment('Error during checkout with yapital');
85
+ $order->cancel()->save();
86
+ }
87
+ }
88
+
89
+ $this->loadLayout();
90
+ $this->renderLayout();
91
+ }
92
+
93
+ /**
94
+ * when customer checkout using yapital payment method
95
+ */
96
+ public function redirectAction()
97
+ {
98
+ $order = Mage::getModel('sales/order');
99
+ /* @var $order Mage_Sales_Model_Order */
100
+
101
+ $order_id = $this->getRequest()->getParam('order_id');
102
+ if ( !$order_id ) {
103
+ $order_id = $this->_getSession()->getLastOrderId();
104
+ }
105
+
106
+ $order->load( $order_id );
107
+
108
+ if ( $order->getId() ) {
109
+
110
+ $api = Mage::getModel('yapital/api_basket_transaction');
111
+ /* @var $api Codex_Yapital_Model_Api_Basket_Transaction */
112
+
113
+ try {
114
+ $response = $api->sendOrder( $order );
115
+ $order_transaction = $api->getOrderTransaction();
116
+
117
+ $this->loadLayout();
118
+ if ( $iframe_block = $this->getLayout()->getBlock('yapital.standard.iframe') ) {
119
+ /* @var $iframe_block Codex_Yapital_Block_Standard_Iframe */
120
+ $iframe_block->setOrderTransaction( $order_transaction );
121
+ }
122
+ $this->renderLayout();
123
+
124
+ } catch ( Exception $e ) {
125
+ $order = $this->_getOrder();
126
+ $order->addStatusHistoryComment( $e->getMessage() );
127
+ Codex_Yapital_Model_Log::error( $e->getMessage() );
128
+ $this->_forward('error');
129
+ }
130
+
131
+ } else {
132
+
133
+ $this->_forward('accessdenied');
134
+
135
+ }
136
+
137
+ }
138
+
139
+ }
app/code/community/Codex/Yapital/doc/phpdoc.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <phpdoc>
3
+ <title>Yapital</title>
4
+ <parser>
5
+ <target>output</target>
6
+ <markers>
7
+ <item>TODO</item>
8
+ <item>FIXME</item>
9
+ </markers>
10
+ </parser>
11
+ <transformer>
12
+ <target>output</target>
13
+ </transformer>
14
+ <transformations>
15
+ <template name="responsive" />
16
+ </transformations>
17
+ <files>
18
+ <directory>..</directory>
19
+ </files>
20
+ </phpdoc>
app/code/community/Codex/Yapital/etc/adminhtml.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <menu>
5
+ <report>
6
+ <children>
7
+ <yapital translate="title" module="yapital">
8
+ <title>Yapital</title>
9
+ <sort_order>10</sort_order>
10
+ <children>
11
+ <payment translate="title" module="yapital">
12
+ <title>Payment</title>
13
+ <action>adminhtml/report_yapital/payment</action>
14
+ </payment>
15
+ </children>
16
+ </yapital>
17
+ </children>
18
+ </report>
19
+ </menu>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <report>
25
+ <children>
26
+ <yapital>
27
+ <children>
28
+ <payment translate="title" module="yapital">
29
+ <title>Payment</title>
30
+ </payment>
31
+ </children>
32
+ </yapital>
33
+ </children>
34
+ </report>
35
+ </children>
36
+ </admin>
37
+ </resources>
38
+ </acl>
39
+ </config>
app/code/community/Codex/Yapital/etc/config.xml ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Codex_Yapital>
5
+ <version>1.0.0.0</version>
6
+ </Codex_Yapital>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <yapital>
12
+ <class>Codex_Yapital_Block</class>
13
+ </yapital>
14
+ </blocks>
15
+
16
+ <helpers>
17
+ <yapital>
18
+ <class>Codex_Yapital_Helper</class>
19
+ </yapital>
20
+ </helpers>
21
+
22
+ <models>
23
+ <yapital>
24
+ <class>Codex_Yapital_Model</class>
25
+ <resourceModel>yapital_resource</resourceModel>
26
+ </yapital>
27
+
28
+ <yapital_resource>
29
+ <class>Codex_Yapital_Model_Resource</class>
30
+ <entities>
31
+ <order_transaction>
32
+ <table>yapital_order_transaction</table>
33
+ </order_transaction>
34
+ <notification>
35
+ <table>yapital_notification</table>
36
+ </notification>
37
+ </entities>
38
+ </yapital_resource>
39
+
40
+ <sales_resource>
41
+ <entities>
42
+ <order_aggregated_payment>
43
+ <table>sales_order_aggregated_payment</table>
44
+ </order_aggregated_payment>
45
+ </entities>
46
+ </sales_resource>
47
+ </models>
48
+
49
+ <resources>
50
+ <yapital_setup>
51
+ <setup>
52
+ <module>Codex_Yapital</module>
53
+ </setup>
54
+ <connection>
55
+ <use>core_setup</use>
56
+ </connection>
57
+ </yapital_setup>
58
+ </resources>
59
+
60
+ </global>
61
+
62
+ <phpunit>
63
+ <suite>
64
+ <modules>
65
+ <Codex_Yapital/>
66
+ </modules>
67
+ </suite>
68
+ </phpunit>
69
+
70
+ <frontend>
71
+ <routers>
72
+ <yapital>
73
+ <use>standard</use>
74
+ <args>
75
+ <module>Codex_Yapital</module>
76
+ <frontName>yapital</frontName>
77
+ </args>
78
+ </yapital>
79
+ </routers>
80
+ <layout>
81
+ <updates>
82
+ <yapital>
83
+ <file>yapital.xml</file>
84
+ </yapital>
85
+ </updates>
86
+ </layout>
87
+ <translate>
88
+ <modules>
89
+ <Codex_Yapital>
90
+ <files>
91
+ <default>Codex_Yapital.csv</default>
92
+ </files>
93
+ </Codex_Yapital>
94
+ </modules>
95
+ </translate>
96
+ </frontend>
97
+
98
+ <adminhtml>
99
+ <layout>
100
+ <updates>
101
+ <yapital>
102
+ <file>yapital.xml</file>
103
+ </yapital>
104
+ </updates>
105
+ </layout>
106
+ </adminhtml>
107
+
108
+ <admin>
109
+ <routers>
110
+ <adminhtml>
111
+ <args>
112
+ <modules>
113
+ <config before="Mage_Adminhtml">Codex_Yapital_Adminhtml</config>
114
+ </modules>
115
+ </args>
116
+ </adminhtml>
117
+ </routers>
118
+ </admin>
119
+
120
+ <crontab>
121
+ <jobs>
122
+ <aggregate_yapital_report_order_payment_data>
123
+ <schedule>
124
+ <cron_expr>0 0 * * *</cron_expr>
125
+ </schedule>
126
+ <run>
127
+ <model>yapital/observer::aggregateYapitalReportOrderPaymentData</model>
128
+ </run>
129
+ </aggregate_yapital_report_order_payment_data>
130
+ </jobs>
131
+ </crontab>
132
+
133
+ <default>
134
+ <yapital>
135
+ <url>
136
+ <base>https://secure.yapital.com</base>
137
+ <api>api/v0.1</api>
138
+ <iframe_script>/beta/js/widget/script.js</iframe_script>
139
+ </url>
140
+ </yapital>
141
+
142
+ <yapital_sandbox>
143
+ <url>
144
+ <base>https://demo.dev.yapital.com</base>
145
+ <api>/3pnext/api/v0.1</api>
146
+ <iframe_script>/3pnext/web-ui/js/widget/script.js</iframe_script>
147
+ </url>
148
+ </yapital_sandbox>
149
+
150
+ <payment>
151
+ <yapital_standard>
152
+ <active>0</active>
153
+ <model>yapital/payment_standard</model>
154
+ <order_status>pending</order_status>
155
+ <title>Yapital Standard Payment</title>
156
+ <payment_action>authorize</payment_action>
157
+ <allowspecific>0</allowspecific>
158
+ </yapital_standard>
159
+ </payment>
160
+ </default>
161
+ </config>
app/code/community/Codex/Yapital/etc/system.xml ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <yapital_standard translate="label" module="yapital">
7
+ <label>Yapital</label>
8
+ <sort_order>670</sort_order>
9
+ <!-- do not show this configuration options in store scope -->
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>0</show_in_store>
13
+ <comment><![CDATA[
14
+ Please fill out the information below. Read this documentation of
15
+ tests you need to run before going online: <a href="http://code-x.de">Documentation</a>
16
+ ]]></comment>
17
+ <fields>
18
+ <active translate="label">
19
+ <label>Enabled</label>
20
+ <frontend_type>select</frontend_type>
21
+ <source_model>adminhtml/system_config_source_yesno</source_model>
22
+ <sort_order>100</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ </active>
27
+
28
+ <title translate="label">
29
+ <label>Title</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>200</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>0</show_in_store>
35
+ </title>
36
+
37
+ <order_status translate="label">
38
+ <label>Paid order status</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
41
+ <sort_order>400</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>0</show_in_store>
45
+ </order_status>
46
+
47
+ <credentials_switch translate="label">
48
+ <label>Use this credentials:</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>yapital/system_config_payment_credentials_switch</source_model>
51
+ <sort_order>500</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </credentials_switch>
56
+
57
+ <!-- LIVE -->
58
+
59
+ <heading_credentials translate="label">
60
+ <label>Live-System</label>
61
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
62
+ <sort_order>600</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ </heading_credentials>
66
+
67
+ <shop_id translate="label">
68
+ <label>Shop-Id</label>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>610</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ </shop_id>
74
+
75
+ <client_id translate="label">
76
+ <label>Client-Id</label>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>630</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ </client_id>
82
+
83
+ <secret_key translate="label">
84
+ <label>Secret key</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>660</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ </secret_key>
90
+
91
+ <check_credentials translate="comment">
92
+ <label>Test credentials</label>
93
+ <frontend_type>button</frontend_type>
94
+ <frontend_model>yapital/system_config_storage_credentials_validate</frontend_model>
95
+ <sort_order>690</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <comment><![CDATA[
99
+ Please fill out your credentials given by
100
+ <a href="http://www.yapital.com" target="_new">Yapital</a>
101
+ and test them here.
102
+ ]]></comment>
103
+ </check_credentials>
104
+
105
+ <notification_secret translate="label">
106
+ <label>Secret</label>
107
+ <frontend_type>text</frontend_type>
108
+ <sort_order>692</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>0</show_in_website>
111
+ <comment>Secret that Yapital will use.</comment>
112
+ </notification_secret>
113
+
114
+ <notifcation_secret_button>
115
+ <!-- "Generate a new secret"-Button -->
116
+ <label></label>
117
+ <frontend_type>button</frontend_type>
118
+ <frontend_model>yapital/system_config_storage_credentials_live_secret</frontend_model>
119
+ <sort_order>694</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ </notifcation_secret_button>
123
+
124
+ <notification_id translate="label">
125
+ <label>Yapital Notification Id</label>
126
+ <!-- TDOO readonly -->
127
+ <frontend_type>text</frontend_type>
128
+ <sort_order>696</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>0</show_in_website>
131
+ </notification_id>
132
+
133
+ <notifcation_button>
134
+ <label></label>
135
+ <frontend_type>button</frontend_type>
136
+ <frontend_model>yapital/system_config_storage_credentials_notification</frontend_model>
137
+ <sort_order>698</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ </notifcation_button>
141
+
142
+ <!-- SANDBOX -->
143
+
144
+ <heading_sandbox translate="label">
145
+ <label>Sandbox (test environment)</label>
146
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
147
+ <sort_order>800</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ </heading_sandbox>
151
+
152
+ <sandbox_shop_id translate="label">
153
+ <label>Shop-Id</label>
154
+ <frontend_type>text</frontend_type>
155
+ <sort_order>810</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ </sandbox_shop_id>
159
+
160
+ <sandbox_client_id translate="label">
161
+ <label>Client-Id</label>
162
+ <frontend_type>text</frontend_type>
163
+ <sort_order>830</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ </sandbox_client_id>
167
+
168
+ <sandbox_secret_key translate="label">
169
+ <label>Secret key</label>
170
+ <frontend_type>text</frontend_type>
171
+ <sort_order>860</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ </sandbox_secret_key>
175
+
176
+ <sandbox_check_credentials translate="comment">
177
+ <!--"validate sandbox"-button-->
178
+ <label>Test credentials</label>
179
+ <frontend_type>button</frontend_type>
180
+ <frontend_model>yapital/config_credentials_sandbox</frontend_model>
181
+ <sort_order>865</sort_order>
182
+ <show_in_default>1</show_in_default>
183
+ <show_in_website>1</show_in_website>
184
+ <comment><![CDATA[
185
+ Please fill out your credentials given by
186
+ <a href="http://www.yapital.com" target="_new">Yapital</a>
187
+ and test them here.
188
+ ]]></comment>
189
+ </sandbox_check_credentials>
190
+
191
+ <sandbox_notification_secret translate="label">
192
+ <label>Notification Secret</label>
193
+ <frontend_type>text</frontend_type>
194
+ <sort_order>870</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>0</show_in_website>
197
+ <comment>Secret that Yapital will use in your sandbox.</comment>
198
+ </sandbox_notification_secret>
199
+
200
+ <sandbox_notifcation_secret_button>
201
+ <!-- "Generate a new secret"-button -->
202
+ <label></label>
203
+ <frontend_type>button</frontend_type>
204
+ <frontend_model>yapital/system_config_storage_credentials_sandbox_secret</frontend_model>
205
+ <sort_order>875</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ </sandbox_notifcation_secret_button>
209
+
210
+ <sandbox_notification_id translate="label">
211
+ <label>Yapital Sandbox-Notification Id</label>
212
+ <!-- TODO readonly -->
213
+ <frontend_type>text</frontend_type>
214
+ <sort_order>880</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>0</show_in_website>
217
+ </sandbox_notification_id>
218
+
219
+ <sandbox_button>
220
+ <label></label>
221
+ <frontend_type>button</frontend_type>
222
+ <!-- "Register sandbox notification"-Button -->
223
+ <frontend_model>yapital/config_notification_sandbox</frontend_model>
224
+ <sort_order>890</sort_order>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_website>1</show_in_website>
227
+ </sandbox_button>
228
+
229
+ </fields>
230
+ </yapital_standard>
231
+ </groups>
232
+ </payment>
233
+ </sections>
234
+ </config>
app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ Mage::log('codex_yapital install 0.1.0', null, '', true);
9
+
10
+ /**
11
+ * Create table 'yapital/order_transaction'
12
+ */
13
+ $orderTransactionTable = $installer->getTable('yapital/order_transaction');
14
+ $table = $installer->getConnection()
15
+ ->newTable($orderTransactionTable)
16
+
17
+ ->addColumn('entity_id',
18
+ Varien_Db_Ddl_Table::TYPE_INTEGER, null,
19
+ array(
20
+ 'identity' => true,
21
+ 'unsigned' => true,
22
+ 'nullable' => false,
23
+ 'primary' => true,
24
+ ),
25
+ 'Entity Id')
26
+
27
+ ->addColumn('order_id',
28
+ Varien_Db_Ddl_Table::TYPE_INTEGER, null,
29
+ array(
30
+ 'identity' => false,
31
+ 'unsigned' => true,
32
+ 'nullable' => false,
33
+ 'primary' => false,
34
+ ),
35
+ 'Order Id')
36
+
37
+ ->addColumn('transaction_id',
38
+ Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(), 'Yapital Transaction Id')
39
+ ;
40
+
41
+ $installer->getConnection()->createTable($table);
42
+ Mage::log("Yapital: Created Table $orderTransactionTable.", null, '', true);
43
+
44
+ $installer->endSetup();
app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-0.1.0-0.2.0.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ Mage::log('codex_yapital update to 0.2.0', null, '', true);
9
+
10
+ /**
11
+ * Create table 'yapital/notification'
12
+ */
13
+ $yapitalNotificationTable = $installer->getTable('yapital/notification');
14
+ $table = $installer->getConnection()
15
+ ->newTable($yapitalNotificationTable)
16
+
17
+ ->addColumn('entity_id',
18
+ Varien_Db_Ddl_Table::TYPE_INTEGER, null,
19
+ array(
20
+ 'identity' => true,
21
+ 'unsigned' => true,
22
+ 'nullable' => false,
23
+ 'primary' => true,
24
+ ),
25
+ 'Entity Id')
26
+
27
+ ->addColumn('event_type',
28
+ Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(), 'event_type')
29
+
30
+ ->addColumn('event_id',
31
+ Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(), 'event_id')
32
+
33
+ ->addColumn('event_timestamp',
34
+ Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(), 'event_timestamp')
35
+
36
+ ->addColumn('notification_id',
37
+ Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(), 'The unique notification ID, generated by Yapital.')
38
+
39
+ ->addColumn('transaction_id',
40
+ Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(), 'The unique transaction ID, for which the notification is sent.')
41
+
42
+ ->addColumn('status_code',
43
+ Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(), 'The status code.')
44
+
45
+ ->addColumn('status_information',
46
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), 'The status description.')
47
+
48
+ ->addColumn('customer_data',
49
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), 'The customers name.')
50
+
51
+ ->addColumn('amount',
52
+ Varien_Db_Ddl_Table::TYPE_FLOAT, null, array( 'default' => '0.0000' ), 'The payment amount.')
53
+
54
+ ->addColumn('currency',
55
+ Varien_Db_Ddl_Table::TYPE_TEXT, 3, array(), 'The currency used in the transaction.')
56
+
57
+ ->addIndex('transaction_id_idx', array('transaction_id') )
58
+
59
+ ;
60
+
61
+
62
+
63
+ $installer->getConnection()->createTable($table);
64
+ Mage::log("Yapital: Created Table $yapitalNotificationTable.", null, '', true);
65
+
66
+ $installer->endSetup();
app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-0.2.0-0.3.0.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** @var $installer Mage_Sales_Model_Entity_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup();
6
+
7
+ Mage::log('codex_yapital update to 0.3.0', null, '', true);
8
+
9
+ /**
10
+ * Create table 'sales/order_aggregated_payment'
11
+ */
12
+ $orderAggregatedPaymentTable = $installer->getTable('sales/order_aggregated_payment');
13
+ $table = $installer->getConnection()
14
+ ->newTable($orderAggregatedPaymentTable)
15
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
16
+ 'identity' => true,
17
+ 'unsigned' => true,
18
+ 'nullable' => false,
19
+ 'primary' => true
20
+ ), 'Id')
21
+ ->addColumn('period', Varien_Db_Ddl_Table::TYPE_DATE, null, array(), 'Period')
22
+ ->addColumn('method', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), 'Method')
23
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
24
+ 'unsigned' => true
25
+ ), 'Store Id')
26
+ ->addColumn('order_status', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
27
+ 'nullable' => false,
28
+ 'default' => ''
29
+ ), 'Order Status')
30
+ ->addColumn('orders_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
31
+ 'nullable' => false,
32
+ 'default' => '0'
33
+ ), 'Orders Count')
34
+ ->addColumn('total_qty_ordered', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
35
+ 'nullable' => false,
36
+ 'default' => '0.0000'
37
+ ), 'Total Qty Ordered')
38
+ ->addColumn('total_qty_invoiced', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
39
+ 'nullable' => false,
40
+ 'default' => '0.0000'
41
+ ), 'Total Qty Invoiced')
42
+ ->addColumn('total_income_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
43
+ 'nullable' => false,
44
+ 'default' => '0.0000',
45
+ ), 'Total Income Amount')
46
+ ->addColumn('total_revenue_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
47
+ 'nullable' => false,
48
+ 'default' => '0.0000'
49
+ ), 'Total Revenue Amount')
50
+ ->addColumn('total_profit_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
51
+ 'nullable' => false,
52
+ 'default' => '0.0000'
53
+ ), 'Total Profit Amount')
54
+ ->addColumn('total_invoiced_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
55
+ 'nullable' => false,
56
+ 'default' => '0.0000'
57
+ ), 'Total Invoiced Amount')
58
+ ->addColumn('total_canceled_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
59
+ 'nullable' => false,
60
+ 'default' => '0.0000'
61
+ ), 'Total Canceled Amount')
62
+ ->addColumn('total_paid_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
63
+ 'nullable' => false,
64
+ 'default' => '0.0000'
65
+ ), 'Total Paid Amount')
66
+ ->addColumn('total_refunded_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
67
+ 'nullable' => false,
68
+ 'default' => '0.0000'
69
+ ), 'Total Refunded Amount')
70
+ ->addColumn('total_tax_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
71
+ 'nullable' => false,
72
+ 'default' => '0.0000'
73
+ ), 'Total Tax Amount')
74
+ ->addColumn('total_tax_amount_actual', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
75
+ 'nullable' => false,
76
+ 'default' => '0.0000'
77
+ ), 'Total Tax Amount Actual')
78
+ ->addColumn('total_shipping_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
79
+ 'nullable' => false,
80
+ 'default' => '0.0000'
81
+ ), 'Total Shipping Amount')
82
+ ->addColumn('total_shipping_amount_actual', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
83
+ 'nullable' => false,
84
+ 'default' => '0.0000'
85
+ ), 'Total Shipping Amount Actual')
86
+ ->addColumn('total_discount_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
87
+ 'nullable' => false,
88
+ 'default' => '0.0000'
89
+ ), 'Total Discount Amount')
90
+ ->addColumn('total_discount_amount_actual', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
91
+ 'nullable' => false,
92
+ 'default' => '0.0000'
93
+ ), 'Total Discount Amount Actual')
94
+ ->addIndex(
95
+ $installer->getIdxName(
96
+ 'sales/order_aggregated_payment',
97
+ array('period', 'method', 'store_id', 'order_status'),
98
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
99
+ ),
100
+ array('period', 'method', 'store_id', 'order_status'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
101
+ )
102
+ ->addIndex(
103
+ $installer->getIdxName('sales/order_aggregated_payment', array('store_id')),
104
+ array('store_id')
105
+ )
106
+ ->addForeignKey(
107
+ $installer->getFkName('sales/order_aggregated_payment', 'store_id', 'core/store', 'store_id'),
108
+ 'store_id', $installer->getTable('core/store'), 'store_id',
109
+ Varien_Db_Ddl_Table::ACTION_SET_NULL, Varien_Db_Ddl_Table::ACTION_CASCADE
110
+ )
111
+ ->setComment('Sales Order Aggregated Payment');
112
+
113
+ $installer->getConnection()->createTable($table);
114
+ Mage::log("Yapital: Created Table $orderAggregatedPaymentTable.", null, '', true);
115
+
116
+ $installer->endSetup();
app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-0.3.0-1.0.0.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** @var $installer Mage_Sales_Model_Entity_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup();
6
+
7
+ Mage::log('codex_yapital update to 1.0.0', null, '', true);
8
+
9
+ $installer->endSetup();
app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-1.0.0-1.1.0.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** @var $installer Mage_Sales_Model_Entity_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup();
6
+
7
+ Mage::log('codex_yapital update to 1.1.0', null, '', true);
8
+
9
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/yapital.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <report_yapital>
5
+ <reference name="messages">
6
+ <action method="addNotice" translate="message">
7
+ <message>This report depends on timezone configuration. Once timezone is changed, the lifetime statistics need to be refreshed.</message>
8
+ </action>
9
+ </reference>
10
+ </report_yapital>
11
+
12
+ <adminhtml_report_yapital_payment>
13
+ <update handle="report_yapital"/>
14
+ <reference name="content">
15
+ <block type="yapital/adminhtml_report_yapital_payment" template="report/grid/container.phtml" name="yapital.report.grid.container">
16
+ <block type="adminhtml/store_switcher" template="report/store/switcher/enhanced.phtml" name="store.switcher">
17
+ <action method="setStoreVarName"><var_name>store_ids</var_name></action>
18
+ </block>
19
+ <block type="sales/adminhtml_report_filter_form_order" name="grid.filter.form">
20
+ <action method="addReportTypeOption" translate="value">
21
+ <key>created_at_order</key>
22
+ <value>Order Created Date</value>
23
+ </action>
24
+ <action method="addReportTypeOption" translate="value">
25
+ <key>updated_at_order</key>
26
+ <value>Order Updated Date</value>
27
+ </action>
28
+ <action method="setFieldOption" translate="value">
29
+ <field>report_type</field>
30
+ <option>note</option>
31
+ <value>Order Updated Date report is real-time, does not need statistics refreshing.</value>
32
+ </action>
33
+ </block>
34
+ </block>
35
+ </reference>
36
+ </adminhtml_report_yapital_payment>
37
+ </layout>
app/design/adminhtml/default/default/template/yapital/.gitignore ADDED
File without changes
app/design/adminhtml/default/default/template/yapital/config/credentials/sandbox.phtml ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Validate */ ?>
2
+
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ <!-- Validation.add('required-validation', '--><?php //echo $this->__('Validation is required.') ?><!--', function () {-->
6
+ <!-- storage = getConnectionName(-->
7
+ <!-- $('payment_yapital_standard_sandbox_client_id').value,-->
8
+ <!-- $('payment_yapital_standard_sandbox_secret_key').value-->
9
+ <!-- );-->
10
+ <!---->
11
+ <!-- console.log(allowedNotifications);-->
12
+ <!---->
13
+ <!-- return allowedNotifications.include(storage);-->
14
+ <!-- });-->
15
+
16
+ defaultValues = [];
17
+ defaultValues['payment_yapital_standard_sandbox_client_id'] = $('payment_yapital_standard_sandbox_client_id').value;
18
+ defaultValues['system_media_storage_configuration_media_database'] = $('payment_yapital_standard_sandbox_secret_key').value;
19
+
20
+ allowedNotifications = [];
21
+ addAllowedStorage(
22
+ $('payment_yapital_standard_sandbox_client_id').value,
23
+ $('payment_yapital_standard_sandbox_secret_key').value
24
+ );
25
+
26
+ function getConnectionName(storageType, connection) {
27
+ return storageType + '_' + connection;
28
+ }
29
+
30
+ function addAllowedStorage(storageType, connection) {
31
+ var storage = getConnectionName(storageType, connection);
32
+
33
+ if (storage != getConnectionName('', '') && !allowedNotifications.include(storage)) {
34
+ allowedNotifications.push(storage);
35
+ }
36
+ }
37
+
38
+ function checkButtonState(event) {
39
+ var element = Event.element(event);
40
+
41
+ var defaultStorage = getConnectionName(
42
+ defaultValues['payment_yapital_standard_sandbox_client_id'],
43
+ defaultValues['payment_yapital_standard_sandbox_secret_key']
44
+ );
45
+
46
+ storage = getConnectionName(
47
+ $('payment_yapital_standard_sandbox_client_id').value,
48
+ $('payment_yapital_standard_sandbox_secret_key').value
49
+ );
50
+
51
+ if (defaultStorage != storage) {
52
+ enableValidateButton();
53
+ } else {
54
+ disableValidateButton();
55
+ }
56
+ }
57
+
58
+ function enableStorageSelection() {
59
+ $('payment_yapital_standard_sandbox_client_id').enable('enabled');
60
+ $('payment_yapital_standard_sandbox_secret_key').enable('enabled');
61
+ }
62
+
63
+ function disableStorageSelection() {
64
+ $('payment_yapital_standard_sandbox_client_id').disable('disabled');
65
+ $('payment_yapital_standard_sandbox_secret_key').disable('disabled');
66
+ }
67
+
68
+ function enableValidateButton() {
69
+ Form.Element.enable('validate_button');
70
+ $('validate_button').removeClassName('disabled');
71
+ }
72
+
73
+ function disableValidateButton() {
74
+ Form.Element.disable('validate_button');
75
+ $('validate_button').addClassName('disabled');
76
+ }
77
+
78
+ Event.observe(window, 'load', function () {
79
+ //disableStorageSelection();
80
+ //disableValidateButton();
81
+ //checkStatus();
82
+ });
83
+ $('payment_yapital_standard_sandbox_client_id').observe('change', checkButtonState);
84
+ $('payment_yapital_standard_sandbox_secret_key').observe('change', checkButtonState);
85
+
86
+ function yapitalCheckStatus() {
87
+
88
+ }
89
+
90
+ function validateSandboxYapital() {
91
+ //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
92
+ //if (advice) {
93
+ // advice.hide();
94
+ //}
95
+ console.log("validateYapital()");
96
+
97
+ params = {
98
+ shop_id : 1,
99
+ client_id :$('payment_yapital_standard_sandbox_client_id').value,
100
+ secret_key:$('payment_yapital_standard_sandbox_secret_key').value
101
+ };
102
+
103
+ $('credentials_sandbox_message_span').addClassName('no-display');
104
+ $('credentials_sandbox_span').removeClassName('no-display');
105
+
106
+ new Ajax.Request('<?php echo $this->getAjaxValidateUpdateUrl() ?>', {
107
+ parameters :params,
108
+ loaderArea :false,
109
+ asynchronous:false,
110
+ onSuccess :function (transport) {
111
+ var response;
112
+
113
+ response = eval('(' + transport.responseText + ')');
114
+ console.log(response);
115
+ if (false == response.has_errors) {
116
+ // no errors: it works!
117
+ disableValidateButton();
118
+ } else {
119
+ // TODO ERROR
120
+ }
121
+
122
+ allowedNotifications.push(getConnectionName(
123
+ $('payment_yapital_standard_sandbox_client_id').value,
124
+ $('payment_yapital_standard_sandbox_secret_key').value
125
+ ));
126
+
127
+ $('credentials_sandbox_span').addClassName('no-display');
128
+ $('credentials_sandbox_message_span').removeClassName('no-display');
129
+ $('credentials_sandbox_message_span').update(response.message);
130
+ },
131
+
132
+ onFailure:function (transport) {
133
+ $('credentials_sandbox_span').addClassName('no-display');
134
+ $('credentials_sandbox_message_span').removeClassName('no-display');
135
+ $('credentials_sandbox_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
136
+ }
137
+
138
+ });
139
+
140
+ //window.setTimeout('yapitalCheckStatus()', 2011);
141
+
142
+ //disableStorageSelection();
143
+ //disableValidateButton();
144
+ enableValidateButton();
145
+ }
146
+ //]]>
147
+ </script>
148
+
149
+ <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="credentials_sandbox_span"><img
150
+ alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
151
+ ?>"/></span><span id="credentials_sandbox_message_span"></span>
152
+ <input type="hidden" id="validation-input" class="required-validation no-display"/>
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/live/secret.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Validate */ ?>
2
+
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ function yapitalGenerateNotificationSecret() {
6
+ var uniq = Math.floor(Math.random() * 0xF + 10).toString(36);
7
+ uniq += Math.floor(Math.random() * 0x100000000).toString(36);
8
+ uniq += Math.floor(Math.random() * 0x1000).toString(36);
9
+ uniq += Math.floor(Math.random() * 0x1000).toString(36);
10
+ uniq += Math.floor(Math.random() * 0x1000).toString(36);
11
+
12
+ return uniq;
13
+ }
14
+
15
+ function yapitalLiveGenerateNotificationSecret() {
16
+ $('payment_yapital_standard_notification_secret').value = yapitalGenerateNotificationSecret();
17
+ }
18
+ //]]>
19
+ </script>
20
+
21
+ <?php echo $this->getButtonHtml() ?>
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/notification.phtml ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Notification */ ?>
2
+
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ /* Validation.add('required-validation', '<?php echo $this->__('Validation is required.') ?>', function(){
6
+ storage = yapitalGetNotificationName(
7
+ $('payment_yapital_standard_notification_secret').value,
8
+ $('payment_yapital_standard_notification_id').value
9
+ );
10
+
11
+ return allowedNotifications.include(storage);
12
+ }); */
13
+
14
+ defaultValues = [];
15
+ defaultValues['payment_yapital_standard_notification_secret'] = $('payment_yapital_standard_notification_secret').value;
16
+ defaultValues['payment_yapital_standard_notification_id'] = $('payment_yapital_standard_notification_id').value;
17
+
18
+ allowedNotifications = [];
19
+ yapitalAddAllowedNotification(
20
+ $('payment_yapital_standard_notification_secret').value,
21
+ $('payment_yapital_standard_notification_id').value
22
+ );
23
+
24
+ function yapitalGetNotificationName(storageType, connection) {
25
+ return storageType + '_' + connection;
26
+ }
27
+
28
+ function yapitalAddAllowedNotification(storageType, connection) {
29
+ var storage = yapitalGetNotificationName(storageType, connection);
30
+
31
+ if (storage != '' && !allowedNotifications.include(storage)) {
32
+ allowedNotifications.push(storage);
33
+ }
34
+ }
35
+
36
+ function yapitalNotificationsCheckButtonState(event) {
37
+ var element = Event.element(event);
38
+
39
+ var defaultStorage = yapitalGetNotificationName(
40
+ defaultValues['payment_yapital_standard_notification_secret'],
41
+ defaultValues['payment_yapital_standard_notification_id']
42
+ );
43
+
44
+ var storage = yapitalGetNotificationName(
45
+ $('payment_yapital_standard_notification_secret').value,
46
+ $('payment_yapital_standard_notification_id').value
47
+ );
48
+
49
+ if (defaultStorage != storage) {
50
+ enableValidateButton();
51
+ } else {
52
+ disableValidateButton();
53
+ }
54
+ }
55
+
56
+ function enableStorageSelection() {
57
+ $('payment_yapital_standard_notification_secret').enable('enabled');
58
+ $('payment_yapital_standard_notification_id').enable('enabled');
59
+ }
60
+
61
+ function disableStorageSelection() {
62
+ $('payment_yapital_standard_notification_secret').disable('disabled');
63
+ $('payment_yapital_standard_notification_id').disable('disabled');
64
+ }
65
+
66
+ function enableValidateButton() {
67
+ Form.Element.enable('validate_button');
68
+ $('validate_button').removeClassName('disabled');
69
+ }
70
+
71
+ function disableValidateButton() {
72
+ Form.Element.disable('validate_button');
73
+ $('validate_button').addClassName('disabled');
74
+ }
75
+
76
+ Event.observe(window, 'load', function () {
77
+ //disableStorageSelection();
78
+ //disableValidateButton();
79
+ //checkStatus();
80
+ });
81
+ $('payment_yapital_standard_notification_secret').observe('change', yapitalNotificationsCheckButtonState);
82
+ $('payment_yapital_standard_notification_id').observe('change', yapitalNotificationsCheckButtonState);
83
+
84
+ function yapitalCheckNotificationStatus() {
85
+
86
+ }
87
+
88
+ function yapitalNotificationRegister() {
89
+ //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
90
+ //if (advice) {
91
+ // advice.hide();
92
+ //}
93
+
94
+ params = {
95
+ store_id :1,
96
+ notification_secret :$('payment_yapital_standard_notification_secret').value,
97
+ notification_id:$('payment_yapital_standard_notification_id').value
98
+ };
99
+
100
+ $('notification_message_span').addClassName('no-display');
101
+ $('notification_span').removeClassName('no-display');
102
+
103
+ new Ajax.Request('<?php echo $this->getAjaxRegisterUrl() ?>', {
104
+ parameters :params,
105
+ loaderArea :false,
106
+ asynchronous:false,
107
+ onSuccess :function (transport) {
108
+ var response;
109
+
110
+ response = eval('(' + transport.responseText + ')');
111
+ console.log(response);
112
+ if (false == response.has_errors) {
113
+ // no errors: it works!
114
+ disableValidateButton();
115
+ } else {
116
+ // TODO ERROR
117
+ }
118
+
119
+ allowedNotifications.push(yapitalGetNotificationName(
120
+ $('payment_yapital_standard_notification_secret').value,
121
+ $('payment_yapital_standard_notification_id').value
122
+ ));
123
+
124
+ $('notification_span').addClassName('no-display');
125
+ $('notification_message_span').removeClassName('no-display');
126
+ $('notification_message_span').update(response.message);
127
+ },
128
+
129
+ onFailure:function (transport) {
130
+ $('validation_span').addClassName('no-display');
131
+ $('validation_message_span').removeClassName('no-display');
132
+ $('validation_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
133
+ }
134
+
135
+ });
136
+
137
+ enableValidateButton();
138
+ }
139
+ //]]>
140
+ </script>
141
+
142
+ <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="notification_span"><img
143
+ alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
144
+ ?>"/></span><span id="notification_message_span"></span>
145
+ <input type="hidden" id="validation-input" class="required-validation no-display"/>
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox.phtml ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Notification */ ?>
2
+
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ /* Validation.add('required-validation', '<?php echo $this->__('Validation is required.') ?>', function(){
6
+ storage = yapitalGetSandboxName(
7
+ $('payment_yapital_standard_sandbox_notification_secret').value,
8
+ $('payment_yapital_standard_sandbox_id').value
9
+ );
10
+
11
+ return allowedSandboxs.include(storage);
12
+ }); */
13
+
14
+ defaultValues = [];
15
+ defaultValues['payment_yapital_standard_sandbox_notification_secret'] = $('payment_yapital_standard_sandbox_notification_secret').value;
16
+ defaultValues['payment_yapital_standard_sandbox_id'] = $('payment_yapital_standard_sandbox_id').value;
17
+
18
+ allowedSandboxs = [];
19
+ yapitalAddAllowedSandbox(
20
+ $('payment_yapital_standard_sandbox_notification_secret').value,
21
+ $('payment_yapital_standard_sandbox_id').value
22
+ );
23
+
24
+ function yapitalGetSandboxName(storageType, connection) {
25
+ return storageType + '_' + connection;
26
+ }
27
+
28
+ function yapitalAddAllowedSandbox(storageType, connection) {
29
+ var storage = yapitalGetSandboxName(storageType, connection);
30
+
31
+ if (storage != '' && !allowedSandboxs.include(storage)) {
32
+ allowedSandboxs.push(storage);
33
+ }
34
+ }
35
+
36
+ function yapitalSandboxsCheckButtonState(event) {
37
+ var element = Event.element(event);
38
+
39
+ var defaultStorage = yapitalGetSandboxName(
40
+ defaultValues['payment_yapital_standard_sandbox_notification_secret'],
41
+ defaultValues['payment_yapital_standard_sandbox_id']
42
+ );
43
+
44
+ storage = yapitalGetSandboxName(
45
+ $('payment_yapital_standard_sandbox_notification_secret').value,
46
+ $('payment_yapital_standard_sandbox_id').value
47
+ );
48
+
49
+ if (defaultStorage != storage) {
50
+ enableValidateButton();
51
+ } else {
52
+ disableValidateButton();
53
+ }
54
+ }
55
+
56
+ function enableStorageSelection() {
57
+ $('payment_yapital_standard_sandbox_notification_secret').enable('enabled');
58
+ $('payment_yapital_standard_sandbox_id').enable('enabled');
59
+ }
60
+
61
+ function disableStorageSelection() {
62
+ $('payment_yapital_standard_sandbox_notification_secret').disable('disabled');
63
+ $('payment_yapital_standard_sandbox_id').disable('disabled');
64
+ }
65
+
66
+ function enableValidateButton() {
67
+ Form.Element.enable('validate_button');
68
+ $('validate_button').removeClassName('disabled');
69
+ }
70
+
71
+ function disableValidateButton() {
72
+ Form.Element.disable('validate_button');
73
+ $('validate_button').addClassName('disabled');
74
+ }
75
+
76
+ Event.observe(window, 'load', function () {
77
+ //disableStorageSelection();
78
+ //disableValidateButton();
79
+ //checkStatus();
80
+ });
81
+ $('payment_yapital_standard_sandbox_notification_secret').observe('change', yapitalSandboxsCheckButtonState);
82
+ $('payment_yapital_standard_sandbox_id').observe('change', yapitalSandboxsCheckButtonState);
83
+
84
+ function yapitalCheckSandboxStatus() {
85
+
86
+ }
87
+
88
+ function yapitalSandboxRegister() {
89
+ //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
90
+ //if (advice) {
91
+ // advice.hide();
92
+ //}
93
+
94
+ params = {
95
+ store_id :1,
96
+ notification_secret :$('payment_yapital_standard_sandbox_notification_secret').value,
97
+ notification_id:$('payment_yapital_standard_sandbox_id').value
98
+ };
99
+
100
+ $('sandbox_message_span').addClassName('no-display');
101
+ $('sandbox_span').removeClassName('no-display');
102
+
103
+ new Ajax.Request('<?php echo $this->getAjaxRegisterUrl() ?>', {
104
+ parameters :params,
105
+ loaderArea :false,
106
+ asynchronous:false,
107
+ onSuccess :function (transport) {
108
+ var response;
109
+
110
+ response = eval('(' + transport.responseText + ')');
111
+ if (false == response.has_errors) {
112
+ // no errors: it works!
113
+ disableValidateButton();
114
+ } else {
115
+ // TODO ERROR
116
+ }
117
+
118
+ allowedSandboxs.push(yapitalGetSandboxName(
119
+ $('payment_yapital_standard_sandbox_notification_secret').value,
120
+ $('payment_yapital_standard_sandbox_id').value
121
+ ));
122
+
123
+ $('sandbox_span').addClassName('no-display');
124
+ $('sandbox_message_span').removeClassName('no-display');
125
+ $('sandbox_message_span').update(response.message);
126
+ },
127
+
128
+ onFailure:function (transport) {
129
+ $('validation_span').addClassName('no-display');
130
+ $('validation_message_span').removeClassName('no-display');
131
+ $('validation_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
132
+ }
133
+
134
+ });
135
+
136
+ enableValidateButton();
137
+ }
138
+ //]]>
139
+ </script>
140
+
141
+ <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="sandbox_span"><img
142
+ alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
143
+ ?>"/></span><span id="sandbox_message_span"></span>
144
+ <input type="hidden" id="validation-input" class="required-validation no-display"/>
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox/notification.phtml ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Notification */ ?>
2
+
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ /* Validation.add('required-validation', '<?php echo $this->__('Validation is required.') ?>', function(){
6
+ storage = yapitalGetNotificationName(
7
+ $('payment_yapital_standard_sandbox_notification_secret').value,
8
+ $('payment_yapital_standard_sandbox_notification_id').value
9
+ );
10
+
11
+ return allowedNotifications.include(storage);
12
+ }); */
13
+
14
+ defaultValues = [];
15
+ defaultValues['payment_yapital_standard_sandbox_notification_secret'] = $('payment_yapital_standard_sandbox_notification_secret').value;
16
+ defaultValues['payment_yapital_standard_sandbox_notification_id'] = $('payment_yapital_standard_sandbox_notification_id').value;
17
+
18
+ allowedSandboxNotifications = [];
19
+ yapitalSandboxAddAllowedNotification(
20
+ $('payment_yapital_standard_sandbox_notification_secret').value,
21
+ $('payment_yapital_standard_sandbox_notification_id').value
22
+ );
23
+
24
+ function yapitalSandboxGetNotificationName(notificationSecret, notificationId) {
25
+ return notificationSecret + '_' + notificationId;
26
+ }
27
+
28
+ function yapitalSandboxAddAllowedNotification(storageType, connection) {
29
+ var storage = yapitalSandboxGetNotificationName(storageType, connection);
30
+
31
+ if (storage != '' && !allowedNotifications.include(storage)) {
32
+ allowedSandboxNotifications.push(storage);
33
+ }
34
+ }
35
+
36
+ function yapitalSandboxNotificationsCheckButtonState(event) {
37
+ var element = Event.element(event);
38
+
39
+ var defaultStorage = yapitalGetSandboxNotificationName(
40
+ defaultValues['payment_yapital_standard_sandbox_notification_secret'],
41
+ defaultValues['payment_yapital_standard_sandbox_notification_id']
42
+ );
43
+
44
+ storage = yapitalGetSandboxNotificationName(
45
+ $('payment_yapital_standard_sandbox_notification_secret').value,
46
+ $('payment_yapital_standard_sandbox_notification_id').value
47
+ );
48
+
49
+ if (defaultStorage != storage) {
50
+ enableValidateButton();
51
+ } else {
52
+ disableValidateButton();
53
+ }
54
+ }
55
+
56
+ function enableStorageSelection() {
57
+ $('payment_yapital_standard_sandbox_notification_secret').enable('enabled');
58
+ $('payment_yapital_standard_sandbox_notification_id').enable('enabled');
59
+ }
60
+
61
+ function disableStorageSelection() {
62
+ $('payment_yapital_standard_sandbox_notification_secret').disable('disabled');
63
+ $('payment_yapital_standard_sandbox_notification_id').disable('disabled');
64
+ }
65
+
66
+ function enableValidateButton() {
67
+ Form.Element.enable('validate_button');
68
+ $('validate_button').removeClassName('disabled');
69
+ }
70
+
71
+ function disableValidateButton() {
72
+ Form.Element.disable('validate_button');
73
+ $('validate_button').addClassName('disabled');
74
+ }
75
+
76
+ Event.observe(window, 'load', function () {
77
+ //disableStorageSelection();
78
+ //disableValidateButton();
79
+ //checkStatus();
80
+ });
81
+ $('payment_yapital_standard_sandbox_notification_secret').observe('change', yapitalSandboxNotificationsCheckButtonState);
82
+ $('payment_yapital_standard_sandbox_notification_id').observe('change', yapitalSandboxNotificationsCheckButtonState);
83
+
84
+ function yapitalCheckSandboxNotificationStatus() {
85
+
86
+ }
87
+
88
+ function yapitalSandboxNotificationRegister() {
89
+ //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
90
+ //if (advice) {
91
+ // advice.hide();
92
+ //}
93
+
94
+ params = {
95
+ store_id :1,
96
+ notification_secret :$('payment_yapital_standard_sandbox_notification_secret').value,
97
+ notification_id:$('payment_yapital_standard_sandbox_notification_id').value
98
+ };
99
+
100
+ $('sandbox_notification_message_span').addClassName('no-display');
101
+ $('sandbox_notification_span').removeClassName('no-display');
102
+
103
+ new Ajax.Request('<?php echo $this->getAjaxRegisterUrl() ?>', {
104
+ parameters :params,
105
+ loaderArea :false,
106
+ asynchronous:false,
107
+ onSuccess :function (transport) {
108
+ var response;
109
+
110
+ response = eval('(' + transport.responseText + ')');
111
+ if (false == response.has_errors) {
112
+ // no errors: it works!
113
+ disableValidateButton();
114
+ } else {
115
+ // TODO ERROR
116
+ }
117
+
118
+ yapitalSandboxAddAllowedNotification(
119
+ $('payment_yapital_standard_sandbox_notification_secret').value,
120
+ $('payment_yapital_standard_sandbox_notification_id').value
121
+ );
122
+
123
+ $('sandbox_notification_span').addClassName('no-display');
124
+ $('sandbox_notification_message_span').removeClassName('no-display');
125
+ $('sandbox_notification_message_span').update(response.message);
126
+ },
127
+
128
+ onFailure:function (transport) {
129
+ $('validation_span').addClassName('no-display');
130
+ $('validation_message_span').removeClassName('no-display');
131
+ $('validation_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
132
+ }
133
+
134
+ });
135
+
136
+ enableValidateButton();
137
+ }
138
+ //]]>
139
+ </script>
140
+
141
+ <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="sandbox_notification_span"><img
142
+ alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
143
+ ?>"/></span><span id="sandbox_notification_message_span"></span>
144
+ <input type="hidden" id="validation-input" class="required-validation no-display"/>
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox/secret.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /** @var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox_Secret */ ?>
2
+
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ function yapitalSandboxGenerateNotificationSecret() {
6
+ $('payment_yapital_standard_sandbox_notification_secret').value = yapitalGenerateNotificationSecret();
7
+ }
8
+ //]]>
9
+ </script>
10
+
11
+ <?php echo $this->getButtonHtml() ?>
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/validate.phtml ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Validate */ ?>
2
+
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ Validation.add('required-validation', '<?php echo $this->__('Validation is required.') ?>', function () {
6
+ var storage = getConnectionName(
7
+ $('payment_yapital_standard_client_id').value,
8
+ $('payment_yapital_standard_secret_key').value
9
+ );
10
+
11
+ return allowedNotifications.include(storage);
12
+ });
13
+
14
+ defaultValues = [];
15
+ defaultValues['payment_yapital_standard_client_id'] = $('payment_yapital_standard_client_id').value;
16
+ defaultValues['system_media_storage_configuration_media_database'] = $('payment_yapital_standard_secret_key').value;
17
+
18
+ allowedNotifications = [];
19
+ addAllowedStorage(
20
+ $('payment_yapital_standard_client_id').value,
21
+ $('payment_yapital_standard_secret_key').value
22
+ );
23
+
24
+ function getConnectionName(storageType, connection) {
25
+ return storageType + '_' + connection;
26
+ }
27
+
28
+ function addAllowedStorage(storageType, connection) {
29
+ var storage = getConnectionName(storageType, connection);
30
+
31
+ if (storage != getConnectionName('', '') && !allowedNotifications.include(storage)) {
32
+ allowedNotifications.push(storage);
33
+ }
34
+ }
35
+
36
+ function checkButtonState(event) {
37
+ var element = Event.element(event);
38
+
39
+ var defaultStorage = getConnectionName(
40
+ defaultValues['payment_yapital_standard_client_id'],
41
+ defaultValues['payment_yapital_standard_secret_key']
42
+ );
43
+
44
+ storage = getConnectionName(
45
+ $('payment_yapital_standard_client_id').value,
46
+ $('payment_yapital_standard_secret_key').value
47
+ );
48
+
49
+ if (defaultStorage != storage) {
50
+ enableValidateButton();
51
+ } else {
52
+ disableValidateButton();
53
+ }
54
+ }
55
+
56
+ function enableStorageSelection() {
57
+ $('payment_yapital_standard_client_id').enable('enabled');
58
+ $('payment_yapital_standard_secret_key').enable('enabled');
59
+ }
60
+
61
+ function disableStorageSelection() {
62
+ $('payment_yapital_standard_client_id').disable('disabled');
63
+ $('payment_yapital_standard_secret_key').disable('disabled');
64
+ }
65
+
66
+ function enableValidateButton() {
67
+ Form.Element.enable('validate_button');
68
+ $('validate_button').removeClassName('disabled');
69
+ }
70
+
71
+ function disableValidateButton() {
72
+ Form.Element.disable('validate_button');
73
+ $('validate_button').addClassName('disabled');
74
+ }
75
+
76
+ Event.observe(window, 'load', function () {
77
+ //disableStorageSelection();
78
+ //disableValidateButton();
79
+ //checkStatus();
80
+ });
81
+ $('payment_yapital_standard_client_id').observe('change', checkButtonState);
82
+ $('payment_yapital_standard_secret_key').observe('change', checkButtonState);
83
+
84
+ function yapitalCheckStatus() {
85
+
86
+ }
87
+
88
+ function validateYapital() {
89
+ //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
90
+ //if (advice) {
91
+ // advice.hide();
92
+ //}
93
+
94
+ params = {
95
+ shop_id : 1,
96
+ client_id :$('payment_yapital_standard_client_id').value,
97
+ secret_key:$('payment_yapital_standard_secret_key').value
98
+ };
99
+
100
+ $('validation_message_span').addClassName('no-display');
101
+ $('validation_span').removeClassName('no-display');
102
+
103
+ new Ajax.Request('<?php echo $this->getAjaxValidateUpdateUrl() ?>', {
104
+ parameters :params,
105
+ loaderArea :false,
106
+ asynchronous:false,
107
+ onSuccess :function (transport) {
108
+ var response;
109
+
110
+ response = eval('(' + transport.responseText + ')');
111
+ if (false == response.has_errors) {
112
+ // no errors: it works!
113
+ disableValidateButton();
114
+ } else {
115
+ // TODO ERROR
116
+ }
117
+
118
+ allowedNotifications.push(getConnectionName(
119
+ $('payment_yapital_standard_client_id').value,
120
+ $('payment_yapital_standard_secret_key').value
121
+ ));
122
+
123
+ $('validation_span').addClassName('no-display');
124
+ $('validation_message_span').removeClassName('no-display');
125
+ $('validation_message_span').update(response.message);
126
+ },
127
+
128
+ onFailure:function (transport) {
129
+ $('validation_span').addClassName('no-display');
130
+ $('validation_message_span').removeClassName('no-display');
131
+ $('validation_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
132
+ }
133
+
134
+ });
135
+
136
+ //window.setTimeout('yapitalCheckStatus()', 2011);
137
+
138
+ //disableStorageSelection();
139
+ //disableValidateButton();
140
+ enableValidateButton();
141
+ }
142
+ //]]>
143
+ </script>
144
+
145
+ <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="validation_span"><img
146
+ alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
147
+ ?>"/></span><span id="validation_message_span"></span>
148
+ <input type="hidden" id="validation-input" class="required-validation no-display"/>
app/design/frontend/base/default/layout/yapital.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+
4
+ <yapital_standard_redirect>
5
+ <reference name="content">
6
+ <block type="yapital/standard_iframe"
7
+ name="yapital.standard.iframe"
8
+ template="yapital/standard/iframe.phtml"
9
+ />
10
+ </reference>
11
+
12
+ <reference name="root">
13
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
14
+ </reference>
15
+
16
+ <reference name="head">
17
+ <action method="addCss"><stylesheet>css/yapital/iframe.css</stylesheet></action>
18
+ </reference>
19
+
20
+ </yapital_standard_redirect>
21
+
22
+ <yapital_standard_error>
23
+ <reference name="root">
24
+ <action method="setTemplate"><template>page/3columns.phtml</template></action>
25
+ </reference>
26
+
27
+ <reference name="content">
28
+ <block type="yapital/base" template="yapital/standard/error.phtml" name="yapital.standard.error" />
29
+ </reference>
30
+ </yapital_standard_error>
31
+
32
+ <yapital_standard_accessdenied>
33
+ <reference name="root">
34
+ <action method="setTemplate"><template>page/3columns.phtml</template></action>
35
+ </reference>
36
+
37
+ <reference name="content">
38
+ <block type="yapital/base" template="yapital/standard/accessdenied.phtml" name="yapital.standard.accessdenied" />
39
+ </reference>
40
+ </yapital_standard_accessdenied>
41
+
42
+ </layout>
app/design/frontend/base/default/template/yapital/.gitignore ADDED
File without changes
app/design/frontend/base/default/template/yapital/standard/accessdenied.phtml ADDED
@@ -0,0 +1 @@
 
1
+ Oh snap! Wasn't able to authorize at the yapital API.
app/design/frontend/base/default/template/yapital/standard/error.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h2><?php echo $this->__('A problem occurred') ?></h2>
2
+
3
+ <?php echo $this->__(
4
+ 'We are sorry!
5
+ It was not possible to receive your payment from yapital.
6
+ Therefor we canceled your order.
7
+ You can try it again or choose another payment method.'
8
+ ) ?>
9
+
10
+ <div class="a-center">
11
+ <a href="<? echo Mage::getUrl('checkout/cart') ?>">
12
+ <?php echo $this->__('Back to cart') ?>
13
+ </a>
14
+ </div>
app/design/frontend/base/default/template/yapital/standard/iframe.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this Codex_Yapital_Block_Standard_Iframe */ ?>
2
+ <div id="yapital-widget-container-id"></div>
3
+ <script src="<?php echo $this->getApiIFrameScript(); ?>"></script>
4
+ <script>
5
+ (function (window) {
6
+ var transactionId = "<?php echo $this->getTransactionId(); ?>";
7
+ window.__yapital_init_widget(transactionId, "<?php echo $this->getApiIFrameScript(); ?>",
8
+ "yapital-widget-container-id");
9
+ })(window);
10
+ </script>
app/etc/modules/Codex_Yapital.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Codex_Yapital>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ <depends>
7
+ <Mage_Checkout />
8
+ <Mage_Payment />
9
+ </depends>
10
+ <version>1.1.0</version>
11
+ </Codex_Yapital>
12
+ </modules>
13
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>yapital</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/apachepl.php">APL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.</summary>
10
+ <description>Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.</description>
11
+ <notes>Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.</notes>
12
+ <authors><author><name>code-x GmbH</name><user>Yapital</user><email>yapital@code-x.de</email></author></authors>
13
+ <date>2013-10-29</date>
14
+ <time>14:06:17</time>
15
+ <contents><target name="magecommunity"><dir name="Codex"><dir name="Yapital"><dir name="Block"><file name="AbstractBlock.php" hash="5c615255446d077cee069bf7d5d21322"/><dir name="Adminhtml"><dir name="Report"><dir name="Yapital"><dir name="Payment"><file name="Grid.php" hash="a0344b462ed361f7d57acfda0ba10798"/></dir><file name="Payment.php" hash="aea486be982bc8741d1eedd221802758"/></dir></dir></dir><file name="Base.php" hash="791be5703ba25b221a7321abec8c0f45"/><dir name="Config"><dir name="Credentials"><file name="Sandbox.php" hash="d59b058fcd135de6048c0a9e3d9fcebb"/></dir><dir name="Notification"><file name="Sandbox.php" hash="112035622ba9f81f4753a0f461bdb01d"/></dir></dir><dir name="Standard"><file name="Iframe.php" hash="93acbf9e7d373bf9f75dfc4c27ff6d6a"/></dir><dir name="System"><dir name="Config"><dir name="Storage"><dir name="Credentials"><dir name="Live"><file name="Secret.php" hash="14684928a2a51942e0aaa02cc55497db"/></dir><file name="Notification.php" hash="bbed86882e6192843acf75247d4cf585"/><dir name="Sandbox"><file name="Secret.php" hash="f80470cf08d702187e453cc1113963b1"/></dir><file name="Sandbox.php" hash="83d525ac976c538243f38c35399f77b5"/><file name="Validate.php" hash="0c20bd7c1db1967bd0a9e3a629713a92"/></dir></dir></dir></dir></dir><file name="ErrorException.php" hash="fe1b4ff685300385200970d7d0f25571"/><file name="Exception.php" hash="b0de3f506d7247d17807f2582cef47a7"/><dir name="Helper"><file name="Data.php" hash="818a367f6504849a355e099597ed6d16"/></dir><dir name="Model"><file name="Abstract.php" hash="7d8d5535aa68914342ac867ee90e44cf"/><dir name="Api"><file name="Abstract.php" hash="de49b71ba967f62427107860b0bd2c25"/><dir name="Basket"><file name="Transaction.php" hash="381eeb3b0adf030adb2458270994e926"/></dir><file name="Notification.php" hash="3fea7c8f75d07ae25824d622fce99e42"/><file name="Restclient.php" hash="f161a48ea789206e000a972e080020f6"/><file name="ReturnBasket.php" hash="64b28c01b7cf3404e633bb78c4207feb"/><file name="Token.php" hash="ffe35d52b03af4913b1978b6d1ea88ae"/></dir><file name="Config.php" hash="dfeb91696cf5897cc8fcf356a2b3b40d"/><dir name="Datatype"><file name="Abstract.php" hash="f6cfcdba68d0680cae215fc396453ddc"/><file name="AbstractSimpleType.php" hash="cb14f8247e7e5c501cad829e566e62e8"/><file name="Airlinedata.php" hash="23fb1b88201c6813b9a9f59ac6da8968"/><file name="Amount.php" hash="70688876d82c81886f707d539c026d9b"/><file name="Basket.php" hash="5b3c687efec18bfe955819b1973591f3"/><file name="Basketstransaction.php" hash="96af52e5b7a8ec7d5f19b8f640109d4a"/><file name="Baskettransactioncreated.php" hash="d0123197d7391957eded7a27a249f9d1"/><file name="Currency.php" hash="bfd417f13b4e591086cdd8344908e30c"/><file name="EventType.php" hash="766ca5f6ff202501a2c91ea7c38b387c"/><file name="Interface.php" hash="ee2a4b504cf88f52dd732b485bb6f200"/><file name="Item.php" hash="9863da0b4b7c8fdb71ef9e40d204b8a6"/><file name="Merchantitem.php" hash="6de991ba501f6c8e0262fc178274e490"/><file name="Notification.php" hash="68403d19e03e029b87ae9f0c222bd9a5"/><file name="Postaladdress.php" hash="fb82d24751a956bac07fe93c541fef50"/><file name="Qrcodebinary.php" hash="d3a11746ea034234feaacf9f9a34c997"/><file name="Returnbasket.php" hash="b94285c70113ce402fc6d8a18fcf942f"/><file name="Shoprestresponse.php" hash="eb24834c14e622c8ac8679a8b14e5b5d"/><file name="Token.php" hash="c88ba481935bace3c72f661fe7ace803"/><file name="Transaction.php" hash="56ab62845ec4fefc29ba89c518af5058"/><file name="Transactionstatus.php" hash="b0bb4364938c6978f29540008b6d4932"/><file name="Yapitalpublicid.php" hash="6484f8852560106eb9237d354ca2f7a6"/></dir><file name="Log.php" hash="c31d1f06231b7397cb39d01cee19d5d2"/><file name="Notification.php" hash="ad25abfed8a840139ff33b534920a617"/><file name="Observer.php" hash="ad02a74d3cc02bdec9b8bc6a58c3615d"/><dir name="Order"><file name="Transaction.php" hash="7408eb705773c2ad499219a4677babf1"/></dir><dir name="Payment"><file name="Standard.php" hash="acfea2ae40055cf56cd736abdd4d252d"/></dir><dir name="Resource"><dir name="Notification"><file name="Collection.php" hash="e1b79fbcec50d81d1c4174c89b8f1148"/></dir><file name="Notification.php" hash="b0068110480422a9e1b6f2449efba433"/><dir name="Order"><dir name="Transaction"><file name="Collection.php" hash="027427bd2322fd73683ea3c60c61ef04"/></dir><file name="Transaction.php" hash="2c0bac5ca37f822da93b49971458f5d0"/></dir><dir name="Report"><dir name="Paymentmethod"><file name="Collection.php" hash="cc5b60ed4de7e958a0fc79707dd36482"/></dir><file name="Paymentmethod.php" hash="456b9e3d6b7d621257e4d51b36d64395"/></dir></dir><dir name="System"><dir name="Config"><dir name="Payment"><dir name="Credentials"><file name="Switch.php" hash="348cda17f3003ea434d27457aadf3064"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Report"><file name="YapitalController.php" hash="683e407a92e7c136cee9ec2380368823"/></dir><dir name="Yapital"><file name="ConfigController.php" hash="f6625e999ff97d6846cfd2e0ace7cf84"/><file name="NotificationController.php" hash="f28571bee8c4503d6328d0b6abb4c6ea"/><file name="SandboxController.php" hash="964c254652930d0e0bfe1fb633f01b82"/></dir></dir><file name="NotificationController.php" hash="e40e6e973be86e5b98c4cb05615ec448"/><file name="StandardController.php" hash="4624e119ecb77c16115190ba4a804056"/></dir><dir name="doc"><file name="phpdoc.xml" hash="2f00609a356a86ae5563d2aab9f18267"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1ff06e4291227e1206db001e2d22d788"/><file name="config.xml" hash="d021ab919b1b24197b52c2fc40e3ccab"/><file name="system.xml" hash="bfb429e766f59c42d09de337a2520661"/></dir><dir name="sql"><dir name="yapital_setup"><file name="mysql4-install-0.1.0.php" hash="4152644ea01d36e2e3e1b57fec1994ef"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="1293127dc8ed191d4d33de7190e872e6"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="b1e1a52496abe325f21bbc3bfce79243"/><file name="mysql4-upgrade-0.3.0-1.0.0.php" hash="6d9e464fbb62007982d3ce4e2d82f8f9"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="45f5bf22bb6ef4d414bcc9a2281300d3"/></dir></dir><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Codex_Yapital.xml" hash="a6a24ae1ce947aa47c778521b1f481a0"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="yapital.xml" hash="63a92065cdcf2ec2afde43ec2a784865"/></dir><dir name="template"><dir name="yapital"><dir><dir name="config"><dir name="credentials"><file name="sandbox.phtml" hash="32632b84161860816dbcfd6e06f09732"/></dir></dir><dir name="system"><dir name="config"><dir name="storage"><dir name="credentials"><dir name="live"><file name="secret.phtml" hash="9b060fe464997596b148cb0e68dc5cad"/></dir><file name="notification.phtml" hash="0f6baf2ffe7abd478ec55c5930e4f001"/><dir name="sandbox"><file name="notification.phtml" hash="8753a4948d1cceb3aae306a26acd20d3"/><file name="secret.phtml" hash="e4182859bdc46c6e235e2f5842be89f9"/></dir><file name="sandbox.phtml" hash="24f0bdfcd8c7784a4e66ecfae1061414"/><file name="validate.phtml" hash="501521604be082fa9c150a23d3e04685"/></dir></dir></dir></dir></dir><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="yapital.xml" hash="e287f912353cc9361531f2970e2b6412"/></dir><dir name="template"><dir name="yapital"><dir><dir name="standard"><file name="accessdenied.phtml" hash="1cc01463abf6c8548295f939ed0aaf47"/><file name="error.phtml" hash="0de94c4b4db0214018c8e3206cb066f3"/><file name="iframe.phtml" hash="a41ce580655291686ae016585d4aa31d"/></dir></dir><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="yapital"><file name="iframe.css" hash="e415f3f5f58ec92b1d8fcc395fc2a717"/><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.3</min><max>5.4.16</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/yapital/.gitignore ADDED
File without changes
skin/frontend/base/default/css/yapital/iframe.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ .yapital-widget-container-id iframe {
2
+ width: 600px !important;
3
+ }