Ensygnia_Onescan - Version 1.0.0

Version Notes

Version 1 of the Ensygnia Onescan extension.

Download this release

Release Info

Developer Ensygnia
Extension Ensygnia_Onescan
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (78) hide show
  1. app/code/local/Ensygnia/Onescan/Block/Abstract.php +28 -0
  2. app/code/local/Ensygnia/Onescan/Block/Adminhtml/System/Config/Cta.php +25 -0
  3. app/code/local/Ensygnia/Onescan/Block/Basket.php +23 -0
  4. app/code/local/Ensygnia/Onescan/Block/Login.php +21 -0
  5. app/code/local/Ensygnia/Onescan/Block/Logo.php +21 -0
  6. app/code/local/Ensygnia/Onescan/Block/Register.php +22 -0
  7. app/code/local/Ensygnia/Onescan/Block/Widget/Basket.php +25 -0
  8. app/code/local/Ensygnia/Onescan/Block/Widget/Login.php +25 -0
  9. app/code/local/Ensygnia/Onescan/Block/Widget/Register.php +25 -0
  10. app/code/local/Ensygnia/Onescan/Helper/Data.php +161 -0
  11. app/code/local/Ensygnia/Onescan/Model/Callback/Abstract.php +39 -0
  12. app/code/local/Ensygnia/Onescan/Model/Callback/Login.php +93 -0
  13. app/code/local/Ensygnia/Onescan/Model/Callback/Purchase.php +388 -0
  14. app/code/local/Ensygnia/Onescan/Model/Callback/Registration.php +132 -0
  15. app/code/local/Ensygnia/Onescan/Model/Config/Abstract.php +35 -0
  16. app/code/local/Ensygnia/Onescan/Model/Config/Login.php +41 -0
  17. app/code/local/Ensygnia/Onescan/Model/Config/Purchase.php +33 -0
  18. app/code/local/Ensygnia/Onescan/Model/Config/Registration.php +41 -0
  19. app/code/local/Ensygnia/Onescan/Model/Logintokens.php +26 -0
  20. app/code/local/Ensygnia/Onescan/Model/Method/Onescan.php +57 -0
  21. app/code/local/Ensygnia/Onescan/Model/Resource/Logintokens.php +25 -0
  22. app/code/local/Ensygnia/Onescan/Model/Resource/Logintokens/Collection.php +25 -0
  23. app/code/local/Ensygnia/Onescan/Model/Resource/Sessiondata.php +25 -0
  24. app/code/local/Ensygnia/Onescan/Model/Resource/Sessiondata/Collection.php +25 -0
  25. app/code/local/Ensygnia/Onescan/Model/Resource/Setup.php +21 -0
  26. app/code/local/Ensygnia/Onescan/Model/Sessiondata.php +26 -0
  27. app/code/local/Ensygnia/Onescan/controllers/CallbackController.php +41 -0
  28. app/code/local/Ensygnia/Onescan/controllers/IndexController.php +173 -0
  29. app/code/local/Ensygnia/Onescan/etc/adminhtml.xml +38 -0
  30. app/code/local/Ensygnia/Onescan/etc/config.xml +118 -0
  31. app/code/local/Ensygnia/Onescan/etc/system.xml +181 -0
  32. app/code/local/Ensygnia/Onescan/etc/widget.xml +31 -0
  33. app/code/local/Ensygnia/Onescan/license.txt +178 -0
  34. app/code/local/Ensygnia/Onescan/sql/onescan_setup/install-1.0.0.php +65 -0
  35. app/design/adminhtml/default/default/template/onescan/system/config/cta.phtml +21 -0
  36. app/design/frontend/base/default/template/onescan/basket.phtml +40 -0
  37. app/design/frontend/base/default/template/onescan/login.phtml +40 -0
  38. app/design/frontend/base/default/template/onescan/logo.phtml +40 -0
  39. app/design/frontend/base/default/template/onescan/register.phtml +40 -0
  40. lib/Onescan/core/onescan-Exceptions.php +28 -0
  41. lib/Onescan/core/onescan-GUID.php +28 -0
  42. lib/Onescan/core/onescan-HMAC.php +26 -0
  43. lib/Onescan/core/onescan-HTTPClient.php +82 -0
  44. lib/Onescan/core/onescan-Login.php +73 -0
  45. lib/Onescan/core/onescan-Message.php +233 -0
  46. lib/Onescan/core/onescan-Onescan.php +81 -0
  47. lib/Onescan/core/onescan-Process.php +195 -0
  48. lib/Onescan/core/onescan-Session.php +35 -0
  49. lib/Onescan/core/onescan-SessionState.php +40 -0
  50. lib/Onescan/core/onescan-Settings.php +51 -0
  51. lib/Onescan/login/LocalDataFactory.php +37 -0
  52. lib/Onescan/login/onescan-LoginProcess.php +217 -0
  53. lib/Onescan/purchase/onescan-AdditionalChargesPayload.php +50 -0
  54. lib/Onescan/purchase/onescan-CardInformation.php +56 -0
  55. lib/Onescan/purchase/onescan-CardType.php +26 -0
  56. lib/Onescan/purchase/onescan-Charge.php +36 -0
  57. lib/Onescan/purchase/onescan-ConfirmPaymentPayload.php +39 -0
  58. lib/Onescan/purchase/onescan-CorePurchaseInfo.php +66 -0
  59. lib/Onescan/purchase/onescan-DeliveryOption.php +56 -0
  60. lib/Onescan/purchase/onescan-OrderAcceptedPayload.php +35 -0
  61. lib/Onescan/purchase/onescan-OrderDeclinedPayload.php +89 -0
  62. lib/Onescan/purchase/onescan-PaymentMethodCharge.php +37 -0
  63. lib/Onescan/purchase/onescan-PaymentMethodInformation.php +37 -0
  64. lib/Onescan/purchase/onescan-PaymentMethodType.php +35 -0
  65. lib/Onescan/purchase/onescan-PaymentOptins.php +37 -0
  66. lib/Onescan/purchase/onescan-PurchaseAction.php +26 -0
  67. lib/Onescan/purchase/onescan-PurchaseCharges.php +56 -0
  68. lib/Onescan/purchase/onescan-PurchaseContextPayload.php +47 -0
  69. lib/Onescan/purchase/onescan-PurchaseInclude.php +34 -0
  70. lib/Onescan/purchase/onescan-PurchasePayload.php +24 -0
  71. lib/Onescan/purchase/onescan-PurchaseProcess.php +260 -0
  72. lib/Onescan/purchase/onescan-PurchaseSettings.php +24 -0
  73. lib/Onescan/purchase/onescan-UserAddress.php +29 -0
  74. package.xml +24 -0
  75. skin/adminhtml/default/default/onescan/css/onescan.css +52 -0
  76. skin/adminhtml/default/default/onescan/images/Thumbs.db +0 -0
  77. skin/adminhtml/default/default/onescan/images/logo-sml.png +0 -0
  78. skin/adminhtml/default/default/onescan/images/logo.png +0 -0
app/code/local/Ensygnia/Onescan/Block/Abstract.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Abstract extends Mage_Core_Block_Template {
20
+ public function getOnescanHelper() {
21
+ return Mage::helper('onescan');
22
+ }
23
+
24
+ public function getSession() {
25
+ return Mage::getSingleton('customer/session');
26
+ }
27
+ }
28
+ ?>
app/code/local/Ensygnia/Onescan/Block/Adminhtml/System/Config/Cta.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Adminhtml_System_Config_Cta extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface {
20
+ protected $_template = 'onescan/system/config/cta.phtml';
21
+
22
+ public function render(Varien_Data_Form_Element_Abstract $element) {
23
+ return $this->toHtml();
24
+ }
25
+ }
app/code/local/Ensygnia/Onescan/Block/Basket.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Basket extends Ensygnia_Onescan_Block_Abstract {
20
+ public function hasItems() {
21
+ return Mage::getModel('checkout/session')->getQuote()->hasItems();
22
+ }
23
+ }
app/code/local/Ensygnia/Onescan/Block/Login.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Login extends Ensygnia_Onescan_Block_Abstract {
20
+
21
+ }
app/code/local/Ensygnia/Onescan/Block/Logo.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Logo extends Ensygnia_Onescan_Block_Abstract {
20
+
21
+ }
app/code/local/Ensygnia/Onescan/Block/Register.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Register extends Ensygnia_Onescan_Block_Abstract {
20
+
21
+ }
22
+ ?>
app/code/local/Ensygnia/Onescan/Block/Widget/Basket.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Widget_Basket extends Ensygnia_Onescan_Block_Basket implements Mage_Widget_Block_Interface {
20
+ public function _construct() {
21
+ parent::_construct();
22
+
23
+ $this->setTemplate('onescan/basket.phtml');
24
+ }
25
+ }
app/code/local/Ensygnia/Onescan/Block/Widget/Login.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Widget_Login extends Ensygnia_Onescan_Block_Login implements Mage_Widget_Block_Interface {
20
+ public function _construct() {
21
+ parent::_construct();
22
+
23
+ $this->setTemplate('onescan/login.phtml');
24
+ }
25
+ }
app/code/local/Ensygnia/Onescan/Block/Widget/Register.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Block_Widget_Register extends Ensygnia_Onescan_Block_Register implements Mage_Widget_Block_Interface {
20
+ public function _construct() {
21
+ parent::_construct();
22
+
23
+ $this->setTemplate('onescan/register.phtml');
24
+ }
25
+ }
app/code/local/Ensygnia/Onescan/Helper/Data.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Helper_Data extends Mage_Core_Helper_Abstract {
20
+ const XML_PATH_ONESCAN_GENERAL_ENABLED = 'onescantab/general/enabled';
21
+ const XML_PATH_ONESCAN_GENERAL_SERVER_URL = 'onescantab/general/onescan_serverurl';
22
+ const XML_PATH_ONESCAN_GENERAL_ACCOUNT = 'onescantab/general/onescan_account';
23
+ const XML_PATH_ONESCAN_GENERAL_SECRET = 'onescantab/general/onescan_secret';
24
+ const XML_PATH_DESIGN_HEADER_LOGO_SRC = 'design/header/logo_src';
25
+ const XML_PATH_ONESCAN_GENERAL_LOGIN_SUCCESS_MESSAGE = 'onescantab/general/onescan_login-success-message';
26
+ const XML_PATH_ONESCAN_GENERAL_EMAIL_NOT_CONFIRMED_MESSAGE = 'onescantab/general/onescan_email-not-confirmed-message';
27
+ const XML_PATH_ONESCAN_GENERAL_SKIP_CONFIRMATION = 'onescantab/general/onescan_skip-confirmation';
28
+ const XML_PATH_ONESCAN_GENERAL_REGISTER_SUCCESS_MESSAGE = 'onescantab/general/onescan_register-success-message';
29
+ const XML_PATH_ONESCAN_GENERAL_EMAIL_EXISTS_MESSAGE = 'onescantab/general/onescan_email-exists-message';
30
+ const XML_PATH_ONESCAN_GENERAL_PRODUCT_MOVE_MAIN = 'onescantab/general/product_move_main';
31
+ const XML_PATH_ONESCAN_GENERAL_SHOW_ON_CART_PAGE = 'onescantab/general/show_on_cart_page';
32
+
33
+ protected function _getSetting($path) {
34
+ return Mage::getStoreConfig($path);
35
+ }
36
+
37
+ public function isEnabled() {
38
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_ENABLED);
39
+ }
40
+
41
+ public function getServerUrl() {
42
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_SERVER_URL);
43
+ }
44
+
45
+ public function getAccount() {
46
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_ACCOUNT);
47
+ }
48
+
49
+ public function getSecret() {
50
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_SECRET);
51
+ }
52
+
53
+ public function getLogoSrc() {
54
+ return $this->_getSetting(self::XML_PATH_DESIGN_HEADER_LOGO_SRC);
55
+ }
56
+
57
+ public function getLoginSuccessMessage() {
58
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_LOGIN_SUCCESS_MESSAGE);
59
+ }
60
+
61
+ public function getEmailNotConfirmedMessage() {
62
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_EMAIL_NOT_CONFIRMED_MESSAGE);
63
+ }
64
+
65
+ public function getSkipConfirmation() {
66
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_SKIP_CONFIRMATION);
67
+ }
68
+
69
+ public function getRegisterSuccessMessage() {
70
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_REGISTER_SUCCESS_MESSAGE);
71
+ }
72
+
73
+ public function getEmailExistsMessage() {
74
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_EMAIL_EXISTS_MESSAGE);
75
+ }
76
+
77
+ public function getProductMoveMain() {
78
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_PRODUCT_MOVE_MAIN);
79
+ }
80
+
81
+ public function getShowOnCartPage() {
82
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_SHOW_ON_CART_PAGE);
83
+ }
84
+
85
+ public function getShowOnMiniCart() {
86
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_SHOW_ON_MINI_CART);
87
+ }
88
+
89
+ public function getShowNowAccepting() {
90
+ return $this->_getSetting(self::XML_PATH_ONESCAN_GENERAL_SHOW_NOW_ACCEPTING);
91
+ }
92
+
93
+ public function getLoginCallbackUrl() {
94
+ //str_replace('/OnescanLoginConfig.php','',str_replace('/index.php','',Mage::helper('core/url')->getHomeUrl())) . 'app/code/local/Ensygnia/Onescan/controllers/OnescanLoginCallback.php';
95
+
96
+ return Mage::getUrl('onescan/callback/login');
97
+ }
98
+
99
+ public function getRegistrationCallbackUrl() {
100
+ //str_replace('/OnescanRegistrationConfig.php','', str_replace('/index.php','',Mage::helper('core/url')->getHomeUrl())) . 'app/code/local/Ensygnia/Onescan/controllers/OnescanRegistrationCallback.php'
101
+
102
+ return Mage::getUrl('onescan/callback/registration');
103
+ }
104
+
105
+ public function getPurchaseCallbackUrl() {
106
+ //str_replace('/OnescanPurchaseConfig.php','',str_replace('/index.php','',Mage::helper('core/url')->getHomeUrl())) . 'app/code/local/Ensygnia/Onescan/controllers/OnescanPurchaseCallback.php'
107
+
108
+ return Mage::getUrl('onescan/callback/purchase');
109
+ }
110
+
111
+ public function getLogoSrcUrl() {
112
+ //str_replace('/index.php','',Mage::helper('core/url')->getHomeUrl()) . $this->getHelper()->getLogoSrc();
113
+
114
+ return Mage::getUrl($this->getLogoSrc());
115
+ }
116
+
117
+ public function getLoginSuccessUrl() {
118
+ //str_replace('OnescanLoginCallback.php','index.php',Mage::helper('core/url')->getHomeUrl()) .'onescan/index/loginsuccess';
119
+
120
+ return Mage::getUrl('onescan/index/loginsuccess');
121
+ }
122
+
123
+ public function getLoginFailureUrl() {
124
+ //str_replace('OnescanLoginCallback.php','index.php',Mage::helper('core/url')->getHomeUrl()) . 'onescan/index/loginfailure';
125
+
126
+ return Mage::getUrl('onescan/index/loginfailure');
127
+ }
128
+
129
+ public function getEmailConfirmationUrl($username) {
130
+ //str_replace('OnescanRegistrationCallback.php','index.php', Mage::helper('customer')->getEmailConfirmationUrl($credentials->Username));
131
+
132
+ return Mage::helper('customer')->getEmailConfirmationUrl($username);
133
+ }
134
+
135
+ public function getConfirmationMessage($username) {
136
+ return $this->getHelper()->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', $this->getEmailConfirmationUrl($username));
137
+ }
138
+
139
+ public function getSessionPollUrl() {
140
+ return $this->getServerUrl() . 'CheckOnescanSessionStatus';
141
+ }
142
+
143
+ public function getSessionFromBasketUrl() {
144
+ //Mage::helper('core/url')->getHomeUrl() . 'onescan/index/createsessionfrombasket';
145
+
146
+ return Mage::getUrl('onescan/index/createsessionfrombasket');
147
+ }
148
+
149
+ public function getLoginSessionUrl() {
150
+ //Mage::helper('core/url')->getHomeUrl() . 'onescan/index/createloginsession";
151
+
152
+ return Mage::getUrl('onescan/index/createloginsession');
153
+ }
154
+
155
+ public function getRegistrationSessionUrl() {
156
+ //Mage::helper('core/url')->getHomeUrl() . 'onescan/index/createregistrationsession";
157
+
158
+ return Mage::getUrl('onescan/index/createregistrationsession');
159
+ }
160
+ }
161
+ ?>
app/code/local/Ensygnia/Onescan/Model/Callback/Abstract.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ abstract class Ensygnia_Onescan_Model_Callback_Abstract {
20
+ protected $_config;
21
+
22
+ abstract public function getConfigReference();
23
+
24
+ public function handle() {
25
+ return $this;
26
+ }
27
+
28
+ public function getConfig() {
29
+ if ($this->_config == null) {
30
+ $this->_config = Mage::getModel($this->getConfigReference());
31
+ }
32
+
33
+ return $this->_config;
34
+ }
35
+
36
+ public function getHelper() {
37
+ return Mage::helper('onescan');
38
+ }
39
+ }
app/code/local/Ensygnia/Onescan/Model/Callback/Login.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once(Mage::getBaseDir('lib') . "/Onescan/login/LocalDataFactory.php");
20
+
21
+ class Ensygnia_Onescan_Model_Callback_Login extends Ensygnia_Onescan_Model_Callback_Abstract {
22
+ public function getConfigReference() {
23
+ return 'onescan/config_login';
24
+ }
25
+
26
+ public function handle() {
27
+ $settings = $this->getConfig()->getSettings();
28
+
29
+ $session = Mage::getSingleton('customer/session');
30
+
31
+ $onescanMessage = Onescan::ReadMessage($settings);
32
+
33
+ $loginProcess = new OnescanLoginProcess();
34
+ $credentials = $loginProcess->DecodeLoginCredentials($onescanMessage,$settings, LoginMode::TokenOrCredentials);
35
+
36
+ $sessionState=$loginProcess->SessionState();
37
+ $sessionID = $sessionState->SessionID;
38
+
39
+ $loginResult = new LoginResult();
40
+
41
+ $loginTokens = Mage::getModel('onescan/logintokens')->getCollection();
42
+ $loginTokens->addFieldToFilter('onescantoken', array('like' => $credentials->OnescanUserIdentityToken));
43
+ $loginTokens->load();
44
+ $details=$loginTokens->getData();
45
+ if (empty($details)) {
46
+ //We do not recognise the user token, so we check for username and password
47
+ if ($credentials->Username == null || $credentials->Username == "") {
48
+ $loginResult->NextAction = LoginNextAction::FallbackToUsernamePassword;
49
+ $loginResult->EndProcess = false;
50
+ } else {
51
+ $customer = Mage::getModel('customer/customer');
52
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
53
+ try {
54
+ $customer->authenticate($credentials->Username,$credentials->Password);
55
+ $newToken=Mage::getModel('onescan/logintokens');
56
+ $newToken->setOnescantoken($credentials->OnescanUserIdentityToken);
57
+ $newToken->setMagentouserid($customer->getId());
58
+ $newToken->save();
59
+
60
+ LocalDataFactory::storeObject($sessionID,$customer->getId());
61
+ LocalDataFactory::storeObject($sessionID . '-message',Mage::getStoreConfig('onescantab/general/onescan_login-success-message'));
62
+
63
+ $loginResult->BrowserRedirectURL = Mage::helper('core/url')->getHomeUrl() . 'onescan/index/loginsuccess';
64
+ $loginResult->NextAction = LoginNextAction::LoginSuccessful;
65
+ } catch (Mage_Core_Exception $e) {
66
+ switch ($e->getCode()) {
67
+ case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
68
+ $value = Mage::helper('customer')->getEmailConfirmationUrl($credentials->Username);
69
+ $message = Mage::helper('customer')->__(Mage::getStoreConfig('onescantab/general/onescan_email-not-confirmed-message'), $value);
70
+ break;
71
+ default:
72
+ $message = $e->getMessage();
73
+ }
74
+ LocalDataFactory::storeObject($sessionID . '-message',$message);
75
+ $loginResult->BrowserRedirectURL = Mage::helper('core/url')->getHomeUrl() . 'onescan/index/loginfailure';
76
+ $loginResult->NextAction = LoginNextAction::LoginSuccessful;
77
+ }
78
+ }
79
+ } else {
80
+ //We recognise the user token, so we can log in
81
+ LocalDataFactory::storeObject($sessionID,$details[0]['magentouserid']);
82
+ LocalDataFactory::storeObject($sessionID . '-message',Mage::getStoreConfig('onescantab/general/onescan_login-success-message'));
83
+
84
+ $loginResult->BrowserRedirectURL = Mage::helper('core/url')->getHomeUrl() . 'onescan/index/loginsuccess';
85
+ $loginResult->NextAction = LoginNextAction::LoginSuccessful;
86
+ }
87
+ $responseMessage = $loginProcess->EncodeOutcome($loginResult,$settings);
88
+
89
+ Onescan::SendMessage($responseMessage,$settings);
90
+
91
+ return parent::handle();
92
+ }
93
+ }
app/code/local/Ensygnia/Onescan/Model/Callback/Purchase.php ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once(Mage::getBaseDir('lib') . "/Onescan/login/LocalDataFactory.php");
20
+
21
+ class Ensygnia_Onescan_Model_Callback_Purchase extends Ensygnia_Onescan_Model_Callback_Abstract {
22
+ public function getConfigReference() {
23
+ return 'onescan/config_purchase';
24
+ }
25
+
26
+ public function handle() {
27
+ $settings = $this->getConfig()->getSettings();
28
+ if (isset($_GET['basket'])) {
29
+ $settings->OnescanCallbackURL .= '?basket=' . $_GET['basket'];
30
+ }
31
+
32
+ $onescanMessage = Onescan::ReadMessage($settings);
33
+
34
+ $purchaseProcess = new OnescanPurchaseProcess();
35
+ $nextAction = $purchaseProcess->DecodePurchaseMessage($onescanMessage);
36
+ $sessionState = $purchaseProcess->SessionState();
37
+
38
+ switch ($nextAction)
39
+ {
40
+ case PurchaseAction::StartPayment:
41
+ $purchasePayload = $this->BuildPurchasePayload($sessionState->SessionID);
42
+ $purchaseProcess->ProcessStartPurchase($purchasePayload);
43
+ break;
44
+ case PurchaseAction::AdditionalCharges:
45
+ $purchaseProcess->DecodeAdditionalChargesRequest($onescanMessage);
46
+ $additionalChargesPayload = $this->BuildAdditionalCharges($purchaseProcess);
47
+ $purchaseProcess->ProcessAdditionalCharges($additionalChargesPayload);
48
+ break;
49
+ case PurchaseAction::PaymentConfirmed:
50
+ $purchaseProcess->DecodePaymentConfirmed($onescanMessage);
51
+ $orderAcceptedPayload = $this->BuildOrderAccepted($purchaseProcess);
52
+ $purchaseProcess->ProcessPaymentConfirmed($orderAcceptedPayload);
53
+ break;
54
+ case PurchaseAction::PaymentFailed:
55
+ $purchaseProcess->ProcessPaymentFailed();
56
+ break;
57
+ case PurchaseAction::PaymentCancelled:
58
+ $purchaseProcess->ProcessPaymentCancelled();
59
+ break;
60
+ }
61
+
62
+ $responseMessage = $purchaseProcess->EncodeOutcome();
63
+
64
+ Onescan::SendMessage($responseMessage,$settings);
65
+
66
+ return parent::handle();
67
+ }
68
+
69
+ /// <summary>
70
+ /// Build some extra information about further charges.
71
+ /// </summary>
72
+ public function BuildAdditionalCharges($process) {
73
+ $additionalChargesContext = $process->AdditionalChargesContext;
74
+ $requires=$process->PurchaseInfo->Requires;
75
+ $purchaseCharges = new AdditionalChargesPayload();
76
+
77
+ if ($requires->DeliveryOptions && !empty($additionalChargesContext->DeliveryAddress))
78
+ $this->AddDeliveryCharges($additionalChargesContext->DeliveryAddress,$purchaseCharges,$process);
79
+
80
+ if ($requires->Surcharges && !empty($additionalChargesContext->PaymentMethod))
81
+ $this->AddPaymentMethodCharges($additionalChargesContext->PaymentMethod,$purchaseCharges,$process);
82
+
83
+ return $purchaseCharges;
84
+ }
85
+
86
+ /// <summary>
87
+ /// Add charges for the specified payment method.
88
+ /// </summary>
89
+ public function AddPaymentMethodCharges($paymentMethod,$purchaseCharges,$process) {
90
+ switch ($paymentMethod->PaymentMethodType) {
91
+ case 'CreditCard':
92
+ $this->HandleCreditCardCharges($paymentMethod,$purchaseCharges,$process);
93
+ break;
94
+ case 'OnescanPlay':
95
+ $this->HandlePlayCardCharges($paymentMethod,$purchaseCharges,$process);
96
+ break;
97
+ }
98
+ }
99
+
100
+ /// <summary>
101
+ /// Handle charges for the onescan test card.
102
+ /// </summary>
103
+ public function HandlePlayCardCharges($paymentMethod,$purchaseCharges,$process) {
104
+ $cardDetails = $paymentMethod->CardInformation;
105
+
106
+ $purchaseCharges->PaymentMethodCharge = new PaymentMethodCharge();
107
+ $purchaseCharges->PaymentMethodCharge->Code = "PLAY";
108
+ $purchaseCharges->PaymentMethodCharge->Description = "The onescan play card attracts a £1 surcharge";
109
+ $purchaseCharges->PaymentMethodCharge->Charge = new Charge();
110
+ $purchaseCharges->PaymentMethodCharge->Charge->BaseAmount = 1.00;
111
+ $purchaseCharges->PaymentMethodCharge->Charge->Tax = 0;
112
+ $purchaseCharges->PaymentMethodCharge->Charge->TotalAmount = 1.00;
113
+ }
114
+
115
+ /// <summary>
116
+ /// Handle charges for credit cards
117
+ /// </summary>
118
+ public function HandleCreditCardCharges($paymentMethod,$purchaseCharges,$process) {
119
+ $cardDetails = $paymentMethod->CardInformation;
120
+
121
+ if ($cardDetails->PaymentSystemCode == "VISA") {
122
+
123
+ $surcharge = round($process->PurchaseInfo->PaymentAmount * 0.01, 2);
124
+
125
+ $purchaseCharges->PaymentMethodCharge = new PaymentMethodCharge();
126
+ $purchaseCharges->PaymentMethodCharge->Code = "VISA";
127
+ $purchaseCharges->PaymentMethodCharge->Description = "Paying with a credit card attracts a 1% charge";
128
+ $purchaseCharges->PaymentMethodCharge->Charge = new Charge();
129
+ $purchaseCharges->PaymentMethodCharge->Charge->BaseAmount = $surcharge;
130
+ $purchaseCharges->PaymentMethodCharge->Charge->Tax = 0;
131
+ $purchaseCharges->PaymentMethodCharge->Charge->TotalAmount = $surcharge;
132
+ }
133
+ }
134
+
135
+ /// <summary>
136
+ /// Add delivery charges for the specified address.
137
+ /// </summary>
138
+ public function AddDeliveryCharges($address,$purchaseCharges,$process) {
139
+ $onescanModel=Mage::getModel('onescan/sessiondata');
140
+ $onescanData = $onescanModel->getCollection();
141
+ $onescanData->addFieldToFilter('sessionid', array('like' => $process->SessionState()->SessionID));
142
+ $onescanData->load();
143
+ $sessionData=$onescanData->getData();
144
+ $quoteid=$sessionData[0]['quoteid'];
145
+
146
+ $cart=Mage::getModel('checkout/cart')->getCheckoutSession();
147
+ $cart->setQuoteId($quoteid);
148
+ $quote=$cart->getQuote();
149
+ $quote->getShippingAddress()->setCountryId(Mage::app()->getLocale()->getCountryTranslation(Mage::getStoreConfig('general/country/default')));
150
+ $quote->getShippingAddress()->collectTotals();
151
+ $quote->getShippingAddress()->setCollectShippingRates(true);
152
+ $quote->getShippingAddress()->collectShippingRates();
153
+ $rates = $quote->getShippingAddress()->getShippingRatesCollection();
154
+
155
+ $purchaseCharges->DeliveryOptions = array();
156
+ foreach ($rates as $rate) {
157
+ $option=new DeliveryOption();
158
+ $option->Code = $rate->getCode();
159
+ $option->Description = $rate->getMethodDescription();
160
+ if (count($purchaseCharges->DeliveryOptions)==0) {
161
+ $option->IsDefault = true;
162
+ }
163
+ $option->Label = $rate->getMethodTitle();
164
+ $option->Charge = new Charge();
165
+ $option->Charge->BaseAmount = $rate->getPrice();
166
+ $option->Charge->Tax = 0;
167
+ $option->Charge->TotalAmount = $rate->getPrice();
168
+ $purchaseCharges->DeliveryOptions[]=$option;
169
+ }
170
+
171
+ //Temporary fix: Save first shipping rate found
172
+ //Once we can select shipping rate on device we can save the selected shipping rate.
173
+ $option=$purchaseCharges->DeliveryOptions[0];
174
+ $onescanModel->setId($sessionData[0]['sessiondata_id']);
175
+ $onescanModel->setSessionid($process->SessionState()->SessionID);
176
+ $onescanModel->setQuoteid($quoteid);
177
+ $onescanModel->setCustomerid($sessionData[0]['customerid']);
178
+ $onescanModel->setShippingmethod($option->Code);
179
+ $onescanModel->setShippingrate($option->Charge->TotalAmount);
180
+ $onescanModel->save();
181
+ }
182
+
183
+ public function BuildPurchasePayload($sessionID) {
184
+ $onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
185
+ $onescanData->addFieldToFilter('sessionid', array('like' => $sessionID));
186
+ $onescanData->load();
187
+ $sessionData=$onescanData->getData();
188
+ $quoteid=$sessionData[0]['quoteid'];
189
+
190
+ $cart=Mage::getModel('checkout/cart')->getCheckoutSession();
191
+ $cart->setQuoteId($quoteid);
192
+
193
+ $quote=$cart->getQuote();
194
+ $quote->reserveOrderId();
195
+ $quote->save();
196
+
197
+ $storeid=$quote->getStoreId();
198
+ $totals=$quote->getTotals();
199
+
200
+ $payload = new PurchasePayload();
201
+ $payload->RequiresDeliveryAddress = true;
202
+ $payload->MerchantName = Mage::app()->getStore()->getFrontendName();
203
+ $payload->MerchantTransactionID = GUID();
204
+ $payload->PurchaseDescription = Mage::getStoreConfig('onescantab/general/onescan_basket-name');
205
+
206
+ if(isset($totals['tax']) && $totals['tax']->getValue()) {
207
+ $payload->Tax = $totals['tax']->getValue();
208
+ } else {
209
+ $payload->Tax = 0;
210
+ }
211
+ $payload->ProductAmount = $totals['subtotal']->getValue()-$payload->Tax;
212
+ $payload->PaymentAmount = $totals['grand_total']->getValue();
213
+ $payload->Currency = Mage::app()->getStore($storeid)->getCurrentCurrencyCode();
214
+
215
+ $payload->Requires = new PaymentOptIns();
216
+ $payload->Requires->DeliveryOptions = true;
217
+ $payload->Requires->Surcharges = false;
218
+ $filename = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'frontend/' .
219
+ Mage::getSingleton('core/design_package')->getPackageName() . '/' .
220
+ Mage::getSingleton('core/design_package')->getTheme('frontend') . '/' .
221
+ Mage::getStoreConfig('design/header/logo_src');
222
+ $payload->ImageData = base64_encode(file_get_contents($filename));
223
+
224
+ return $payload;
225
+ }
226
+
227
+ public function BuildOrderAccepted($process) {
228
+ $sessionState=$process->SessionState();
229
+ $sessionID = $sessionState->SessionID;
230
+
231
+ $onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
232
+ $onescanData->addFieldToFilter('sessionid', array('like' => $process->SessionState()->SessionID));
233
+ $onescanData->load();
234
+ $sessionData=$onescanData->getData();
235
+
236
+ $quoteid=$sessionData[0]['quoteid'];
237
+ $customerid=$sessionData[0]['customerid'];
238
+ $shippingMethod=$sessionData[0]['shippingmethod'];
239
+ $shippingRate=$sessionData[0]['shippingrate'];
240
+
241
+ $cart=Mage::getModel('checkout/cart')->getCheckoutSession();
242
+ $cart->setQuoteId($quoteid);
243
+ $totals=$cart->getQuote()->getTotals();
244
+ $quote=$cart->getQuote();
245
+
246
+ //TEMPORARY FIX FOR BLANK FIRST AND LAST NAMES
247
+ if ($process->PaymentConfirmation->FirstName=="") {
248
+ $process->PaymentConfirmation->FirstName="First";
249
+ }
250
+ if ($process->PaymentConfirmation->LastName=="") {
251
+ $process->PaymentConfirmation->LastName="Last";
252
+ }
253
+
254
+ if ($customerid) {
255
+ // We are already logged in:
256
+ $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getWebsite()->getId())->load($customerid);
257
+ $quote->assignCustomer($customer);
258
+ } else {
259
+ $loginTokens = Mage::getModel('onescan/logintokens')->getCollection();
260
+ $loginTokens->addFieldToFilter('onescantoken', array('like' => $process->UserToken));
261
+ $loginTokens->load();
262
+ $details=$loginTokens->getData();
263
+ $customer = Mage::getModel('customer/customer');
264
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
265
+ if (empty($details)) {
266
+ //We do not recognise the user token, so we create an account and log in
267
+ $customer->loadByEmail($process->PaymentConfirmation->UserEmail);
268
+
269
+ if(!$customer->getId()) {
270
+ //New customer registration
271
+ $customer->setEmail($process->PaymentConfirmation->UserEmail);
272
+ $customer->setFirstname($process->PaymentConfirmation->FirstName);
273
+ $customer->setLastname($process->PaymentConfirmation->LastName);
274
+ $customer->setPassword($this->randomPassword());
275
+ try {
276
+ $customer->save();
277
+ if (Mage::getStoreConfig('onescantab/general/onescan_skip-confirmation') || !$customer->isConfirmationRequired()) {
278
+ $customer->setConfirmation(null);
279
+ $customer->save();
280
+ $customer->sendNewAccountEmail(
281
+ 'registered',
282
+ '',
283
+ Mage::app()->getStore()->getId()
284
+ );
285
+ $confirmMessage=false;
286
+ } else {
287
+ $customer->sendNewAccountEmail(
288
+ 'confirmation',
289
+ $session->getBeforeAuthUrl(),
290
+ Mage::app()->getStore()->getId()
291
+ );
292
+ $confirmMessage=true;
293
+ }
294
+
295
+ $newToken=Mage::getModel('onescan/logintokens');
296
+ $newToken->setOnescantoken($process->UserToken);
297
+ $newToken->setMagentouserid($customer->getId());
298
+ $newToken->save();
299
+
300
+ $message=Mage::getStoreConfig('onescantab/general/onescan_register-success-message');
301
+
302
+ if ($confirmMessage) {
303
+ $value=Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
304
+ $message = Mage::helper('customer')->__(Mage::getStoreConfig('onescantab/general/onescan_email-not-confirmed-message'),$value);
305
+ }
306
+
307
+ LocalDataFactory::storeObject($sessionID,$customer->getId());
308
+ LocalDataFactory::storeObject($sessionID . '-message',$message);
309
+ }
310
+ catch (Mage_Core_Exception $e) {
311
+ LocalDataFactory::storeObject($sessionID . '-message',$e->getMessage());
312
+ }
313
+ } else { //Email address recognised so redirect to login page
314
+ LocalDataFactory::storeObject($sessionID . '-message',Mage::getStoreConfig('onescantab/general/onescan_email-exists-message'));
315
+ }
316
+ } else {
317
+ //We recognise the user token, so we can log in
318
+ $customer->load($details[0]['magentouserid']);
319
+ LocalDataFactory::storeObject($sessionID,$details[0]['magentouserid']);
320
+ LocalDataFactory::storeObject($sessionID . '-message',Mage::getStoreConfig('onescantab/general/onescan_login-success-message'));
321
+ }
322
+ $quote->assignCustomer($customer);
323
+ }
324
+
325
+ $country=Mage::app()->getLocale()->getCountryTranslation(Mage::getStoreConfig('general/country/default'));
326
+ $addressData = array(
327
+ 'firstname' => $process->PaymentConfirmation->FirstName,
328
+ 'lastname' => $process->PaymentConfirmation->LastName,
329
+ 'street' => $process->PaymentConfirmation->DeliveryAddress->AddressLine1 . ', ' . $process->PaymentConfirmation->DeliveryAddress->AddressLine2,
330
+ 'city' => $process->PaymentConfirmation->DeliveryAddress->Town,
331
+ 'postcode' => $process->PaymentConfirmation->DeliveryAddress->Postcode,
332
+ 'telephone' => '0',
333
+ 'country_id' => $country,
334
+ 'region_id' => 0,
335
+ );
336
+ $billingAddress = $quote->getBillingAddress()->addData($addressData);
337
+ $shippingAddress = $quote->getShippingAddress()->addData($addressData);
338
+ $shippingAddress->setCollectShippingRates(true)->collectShippingRates()
339
+ ->setShippingMethod($shippingMethod)
340
+ ->setPaymentMethod('onescan');
341
+
342
+ $quote->getPayment()->importData(array('method' => 'onescan'));
343
+
344
+ $quote->collectTotals();
345
+
346
+ //Add postage to quote
347
+ $totals['grand_total']->setValue($totals['grand_total']->getValue()+$shippingRate);
348
+
349
+ $quote->setIsActive(0);
350
+ $quote->save();
351
+
352
+ $service = Mage::getModel('sales/service_quote', $quote);
353
+ $service->submitAll();
354
+ $order = $service->getOrder();
355
+
356
+ if(isset($totals['tax']) && $totals['tax']->getValue()) {
357
+ $order->setTaxAmount($totals['tax']->getValue());
358
+ $order->setBaseTaxAmount($totals['tax']->getValue());
359
+ $order->setGrandTotal($totals['grand_total']->getValue());
360
+ $order->setBaseGrandTotal($totals['grand_total']->getValue());
361
+ }
362
+
363
+ $order->place();
364
+ $order->save();
365
+ $order->sendNewOrderEmail();
366
+
367
+ $quote->setIsActive(false);
368
+ $quote->delete();
369
+
370
+ $orderAccepted = new OrderAcceptedPayload();
371
+ $orderAccepted->ReceiptId = $process->ProcessId();
372
+ $orderAccepted->OrderId = $order->getIncrementId();
373
+ return $orderAccepted;
374
+ }
375
+
376
+ public function randomPassword() {
377
+ $alphabet = "abcdefghijkmnopqrstuwxyzABCDEFGHJKLMNPQRSTUWXYZ23456789";
378
+ $pass='';
379
+
380
+ for ($i = 0; $i < 8; $i++) {
381
+ $n = rand(0, strlen($alphabet)-1);
382
+ $pass .= $alphabet[$n];
383
+ }
384
+
385
+ return $pass;
386
+ }
387
+ }
388
+ ?>
app/code/local/Ensygnia/Onescan/Model/Callback/Registration.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once(Mage::getBaseDir('lib') . "/Onescan/login/LocalDataFactory.php");
20
+
21
+ class Ensygnia_Onescan_Model_Callback_Registration extends Ensygnia_Onescan_Model_Callback_Abstract {
22
+ public function getConfigReference() {
23
+ return 'onescan/config_login';
24
+ }
25
+
26
+ public function handle() {
27
+ $settings = $this->getConfig()->getSettings();
28
+
29
+ $session = Mage::getSingleton('customer/session');
30
+
31
+ $onescanMessage = Onescan::ReadMessage($settings);
32
+
33
+ $loginProcess = new OnescanLoginProcess();
34
+ $credentials = $loginProcess->DecodeLoginCredentials($onescanMessage,$settings);
35
+
36
+ $sessionState=$loginProcess->SessionState();
37
+ $sessionID = $sessionState->SessionID;
38
+
39
+ $loginResult = new LoginResult();
40
+
41
+ $loginTokens = Mage::getModel('onescan/logintokens')->getCollection();
42
+ $loginTokens->addFieldToFilter('onescantoken', array('like' => $credentials->OnescanUserIdentityToken));
43
+ $loginTokens->load();
44
+ $details=$loginTokens->getData();
45
+ if (empty($details)) {
46
+ //We do not recognise the user token, so we create an account and log in
47
+ $customer = Mage::getModel('customer/customer');
48
+
49
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
50
+ $customer->loadByEmail($credentials->Email);
51
+
52
+ if(!$customer->getId()) { //New customer registration
53
+ $customer->setEmail($credentials->Email);
54
+ $customer->setFirstname($credentials->Firstname);
55
+ $customer->setLastname($credentials->Lastname);
56
+ $customer->setPassword($this->randomPassword());
57
+ try {
58
+ $customer->save();
59
+ if (Mage::getStoreConfig('onescantab/general/onescan_skip-confirmation') || !$customer->isConfirmationRequired()) {
60
+ $customer->setConfirmation(null);
61
+ $customer->save();
62
+ $customer->sendNewAccountEmail(
63
+ 'registered',
64
+ '',
65
+ Mage::app()->getStore()->getId()
66
+ );
67
+ $confirmMessage=false;
68
+ } else {
69
+ $customer->sendNewAccountEmail(
70
+ 'confirmation',
71
+ $session->getBeforeAuthUrl(),
72
+ Mage::app()->getStore()->getId()
73
+ );
74
+ $confirmMessage=true;
75
+ }
76
+
77
+ $newToken=Mage::getModel('onescan/logintokens');
78
+ $newToken->setOnescantoken($credentials->OnescanUserIdentityToken);
79
+ $newToken->setMagentouserid($customer->getId());
80
+ $newToken->save();
81
+
82
+ $message=Mage::getStoreConfig('onescantab/general/onescan_register-success-message');
83
+
84
+ if ($confirmMessage) {
85
+ $value=Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
86
+ $message = Mage::helper('customer')->__(Mage::getStoreConfig('onescantab/general/onescan_email-not-confirmed-message'),$value);
87
+ $loginResult->BrowserRedirectURL = Mage::helper('core/url')->getHomeUrl() . 'onescan/index/loginfailure';
88
+ } else {
89
+ $loginResult->BrowserRedirectURL = Mage::helper('core/url')->getHomeUrl() . 'onescan/index/loginsuccess';
90
+ }
91
+
92
+ LocalDataFactory::storeObject($sessionID,$customer->getId());
93
+ LocalDataFactory::storeObject($sessionID . '-message',$message);
94
+ $loginResult->NextAction = LoginNextAction::LoginSuccessful;
95
+ }
96
+ catch (Mage_Core_Exception $e) {
97
+ LocalDataFactory::storeObject($sessionID . '-message',$e->getMessage());
98
+ $loginResult->BrowserRedirectURL = Mage::helper('core/url')->getHomeUrl() . 'onescan/index/loginfailure';
99
+ $loginResult->NextAction = LoginNextAction::LoginSuccessful;
100
+ }
101
+ } else { //Email address recognised so redirect to login page
102
+ LocalDataFactory::storeObject($sessionID . '-message',Mage::getStoreConfig('onescantab/general/onescan_email-exists-message'));
103
+ $loginResult->BrowserRedirectURL = Mage::helper('core/url')->getHomeUrl() . 'onescan/index/loginfailure';
104
+ $loginResult->NextAction = LoginNextAction::LoginSuccessful;
105
+ }
106
+ } else {
107
+ //We recognise the user token, so we can log in
108
+ LocalDataFactory::storeObject($sessionID,$details[0]['magentouserid']);
109
+ LocalDataFactory::storeObject($sessionID . '-message',Mage::getStoreConfig('onescantab/general/onescan_login-success-message'));
110
+
111
+ $loginResult->BrowserRedirectURL = Mage::helper('core/url')->getHomeUrl() . 'onescan/index/loginsuccess';
112
+ $loginResult->NextAction = LoginNextAction::LoginSuccessful;
113
+ }
114
+ $responseMessage = $loginProcess->EncodeOutcome($loginResult,$settings);
115
+
116
+ Onescan::SendMessage($responseMessage,$settings);
117
+
118
+ return parent::handle();
119
+ }
120
+
121
+ public function randomPassword() {
122
+ $alphabet = "abcdefghijkmnopqrstuwxyzABCDEFGHJKLMNPQRSTUWXYZ23456789";
123
+ $pass='';
124
+
125
+ for ($i = 0; $i < 8; $i++) {
126
+ $n = rand(0, strlen($alphabet)-1);
127
+ $pass .= $alphabet[$n];
128
+ }
129
+
130
+ return $pass;
131
+ }
132
+ }
app/code/local/Ensygnia/Onescan/Model/Config/Abstract.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ abstract class Ensygnia_Onescan_Model_Config_Abstract {
20
+ protected $_settings;
21
+
22
+ abstract protected function _loadSettings();
23
+
24
+ public function getSettings() {
25
+ if (empty($_settings)) {
26
+ $this->_loadSettings();
27
+ }
28
+
29
+ return $this->_settings;
30
+ }
31
+
32
+ public function getHelper() {
33
+ return Mage::helper('onescan');
34
+ }
35
+ }
app/code/local/Ensygnia/Onescan/Model/Config/Login.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once(Mage::getBaseDir('lib') . "/Onescan/login/onescan-LoginProcess.php");
20
+
21
+ class Ensygnia_Onescan_Model_Config_Login extends Ensygnia_Onescan_Model_Config_Abstract {
22
+ protected function _loadSettings() {
23
+ $this->_settings = new OnescanLoginSettings();
24
+
25
+ $this->_settings->OnescanServerURL = $this->getHelper()->getServerUrl() . "RequestOneScanSession";
26
+
27
+ $this->_settings->OnescanCallbackURL = $this->getHelper()->getLoginCallbackUrl();
28
+
29
+ $this->_settings->OnescanAccountKey = $this->getHelper()->getAccount();
30
+
31
+ $this->_settings->OnescanSecret = $this->getHelper()->getSecret();
32
+
33
+ $this->_settings->SiteID = Mage::app()->getWebsite()->getId();
34
+
35
+ $this->_settings->FriendlyName = Mage::app()->getStore()->getFrontendName();
36
+
37
+ $this->_settings->SiteLogoURL = $this->getHelper()->getLogoSrcUrl();
38
+
39
+ $this->_settings->LoginMode = LoginMode::TokenOrCredentials;
40
+ }
41
+ }
app/code/local/Ensygnia/Onescan/Model/Config/Purchase.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once(Mage::getBaseDir('lib') . "/Onescan/purchase/onescan-PurchaseInclude.php");
20
+
21
+ class Ensygnia_Onescan_Model_Config_Purchase extends Ensygnia_Onescan_Model_Config_Abstract {
22
+ protected function _loadSettings() {
23
+ $this->_settings = new OnescanPurchaseSettings();
24
+
25
+ $this->_settings->OnescanServerURL = $this->getHelper()->getServerUrl() . "RequestOneScanSession";
26
+
27
+ $this->_settings->OnescanCallbackURL = $this->getHelper()->getPurchaseCallbackUrl();
28
+
29
+ $this->_settings->OnescanAccountKey = $this->getHelper()->getAccount();
30
+
31
+ $this->_settings->OnescanSecret = $this->getHelper()->getSecret();
32
+ }
33
+ }
app/code/local/Ensygnia/Onescan/Model/Config/Registration.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once(Mage::getBaseDir('lib') . "/Onescan/login/onescan-LoginProcess.php");
20
+
21
+ class Ensygnia_Onescan_Model_Config_Registration extends Ensygnia_Onescan_Model_Config_Abstract {
22
+ protected function _loadSettings() {
23
+ $this->_settings = new OnescanLoginSettings();
24
+
25
+ $this->_settings->OnescanServerURL = $this->getHelper()->getServerUrl() . "RequestOneScanSession";
26
+
27
+ $this->_settings->OnescanCallbackURL = $this->getHelper()->getRegistrationCallbackUrl();
28
+
29
+ $this->_settings->OnescanAccountKey = $this->getHelper()->getAccount();
30
+
31
+ $this->_settings->OnescanSecret = $this->getHelper()->getSecret();
32
+
33
+ $this->_settings->SiteID = Mage::app()->getWebsite()->getId();
34
+
35
+ $this->_settings->FriendlyName = Mage::app()->getStore()->getFrontendName();
36
+
37
+ $this->_settings->SiteLogoURL = $this->getHelper()->getLogoSrcUrl();;
38
+
39
+ $this->_settings->LoginMode = LoginMode::Register;
40
+ }
41
+ }
app/code/local/Ensygnia/Onescan/Model/Logintokens.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Model_Logintokens extends Mage_Core_Model_Abstract
20
+ {
21
+ protected function _construct()
22
+ {
23
+ $this->_init('onescan/logintokens');
24
+ }
25
+ }
26
+ ?>
app/code/local/Ensygnia/Onescan/Model/Method/Onescan.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Model_Method_Onescan extends Mage_Payment_Model_Method_Abstract
20
+ {
21
+
22
+ protected $_code = 'onescan';
23
+ //protected $_formBlockType = 'payment/form_checkmo';
24
+ //protected $_infoBlockType = 'payment/info_checkmo';
25
+
26
+ /**
27
+ * Assign data to info model instance
28
+ *
29
+ * @param mixed $data
30
+ * @return Ensygnia_Onescan_Model_Method_Onescan
31
+ */
32
+ public function assignData($data)
33
+ {
34
+ $details = array();
35
+ if ($this->getPayableTo()) {
36
+ $details['payable_to'] = $this->getPayableTo();
37
+ }
38
+ if ($this->getMailingAddress()) {
39
+ $details['mailing_address'] = $this->getMailingAddress();
40
+ }
41
+ if (!empty($details)) {
42
+ $this->getInfoInstance()->setAdditionalData(serialize($details));
43
+ }
44
+ return $this;
45
+ }
46
+
47
+ public function getPayableTo()
48
+ {
49
+ return $this->getConfigData('payable_to');
50
+ }
51
+
52
+ public function getMailingAddress()
53
+ {
54
+ return $this->getConfigData('mailing_address');
55
+ }
56
+
57
+ }
app/code/local/Ensygnia/Onescan/Model/Resource/Logintokens.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Model_Resource_Logintokens extends Mage_Core_Model_Resource_Db_Abstract{
20
+ protected function _construct()
21
+ {
22
+ $this->_init('onescan/logintokens', 'logintoken_id');
23
+ }
24
+ }
25
+ ?>
app/code/local/Ensygnia/Onescan/Model/Resource/Logintokens/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Model_Resource_Logintokens_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
20
+ protected function _construct()
21
+ {
22
+ $this->_init('onescan/logintokens');
23
+ }
24
+ }
25
+ ?>
app/code/local/Ensygnia/Onescan/Model/Resource/Sessiondata.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Model_Resource_Sessiondata extends Mage_Core_Model_Resource_Db_Abstract{
20
+ protected function _construct()
21
+ {
22
+ $this->_init('onescan/sessiondata', 'sessiondata_id');
23
+ }
24
+ }
25
+ ?>
app/code/local/Ensygnia/Onescan/Model/Resource/Sessiondata/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Model_Resource_Sessiondata_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
20
+ protected function _construct()
21
+ {
22
+ $this->_init('onescan/sessiondata');
23
+ }
24
+ }
25
+ ?>
app/code/local/Ensygnia/Onescan/Model/Resource/Setup.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
20
+ }
21
+ ?>
app/code/local/Ensygnia/Onescan/Model/Sessiondata.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_Model_Sessiondata extends Mage_Core_Model_Abstract
20
+ {
21
+ protected function _construct()
22
+ {
23
+ $this->_init('onescan/sessiondata');
24
+ }
25
+ }
26
+ ?>
app/code/local/Ensygnia/Onescan/controllers/CallbackController.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Ensygnia_Onescan_CallbackController extends Mage_Core_Controller_Front_Action {
20
+ public function indexAction() {
21
+ echo 'No route';
22
+ }
23
+
24
+ public function loginAction() {
25
+ $model = Mage::getModel('onescan/callback_login');
26
+
27
+ $model->handle();
28
+ }
29
+
30
+ public function registrationAction() {
31
+ $model = Mage::getModel('onescan/callback_registration');
32
+
33
+ $model->handle();
34
+ }
35
+
36
+ public function purchaseAction() {
37
+ $model = Mage::getModel('onescan/callback_purchase');
38
+
39
+ $model->handle();
40
+ }
41
+ }
app/code/local/Ensygnia/Onescan/controllers/IndexController.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once(Mage::getBaseDir('lib') . "/Onescan/login/LocalDataFactory.php");
20
+
21
+ class Ensygnia_Onescan_IndexController extends Mage_Core_Controller_Front_Action {
22
+ public function createsessionfrombasketAction() {
23
+ $purchaseSettings = Mage::getModel('onescan/config_purchase')->getSettings();
24
+ $sessionvarname='guid';
25
+ if (isset($_GET['basket'])) {
26
+ $sessionvarname.=$_GET['basket'];
27
+ $purchaseSettings->OnescanCallbackURL .= '?basket=' . $_GET['basket'];
28
+ }
29
+
30
+ try {
31
+ $purchaseProcess = new OnescanPurchaseProcess();
32
+ $purchaseSessionID = GUID();
33
+ $_SESSION[$sessionvarname]=$purchaseSessionID;
34
+ $purchaseProcess->CreateSecurityCookie($purchaseSettings, $purchaseSessionID);
35
+ $response = $purchaseProcess->CreateOnescanSessionFromSessionData($purchaseSettings, $purchaseSessionID);
36
+ }
37
+ catch (Exception $e)
38
+ {
39
+ //Error Logging goes here.
40
+ $errorResponse = new OneScanResponseMessage();
41
+ $errorResponse->Success = false;
42
+ $response = json_encode($errorResponse);
43
+ }
44
+
45
+ //Store the current quote ID and customer ID (if logged in) against the session ID
46
+ $onescanData=Mage::getModel('onescan/sessiondata');
47
+ $onescanData->setSessionid($purchaseSessionID);
48
+ $onescanData->setQuoteid(Mage::getModel('checkout/cart')->getQuote()->getId());
49
+ $onescanData->setCustomerid(Mage::getSingleton('customer/session')->getCustomer()->getId());
50
+ $onescanData->save();
51
+
52
+ return $response;
53
+ }
54
+
55
+ public function createregistrationsessionAction() {
56
+ $registrationSettings = Mage::getModel('onescan/config_registration')->getSettings();
57
+
58
+ try {
59
+ $registrationProcess = new OnescanLoginProcess();
60
+ $registrationSessionID = GUID();
61
+ $_SESSION['guid']=$registrationSessionID;
62
+ $registrationProcess->CreateSecurityCookie($registrationSettings,$registrationSessionID);
63
+ $response = $registrationProcess->CreateOnescanSessionFromSessionData($registrationSettings,$registrationSessionID);
64
+ }
65
+ catch (Exception $e)
66
+ {
67
+ //Error Logging goes here.
68
+ $errorResponse = new OneScanResponseMessage();
69
+ $errorResponse->Success = false;
70
+ $response = json_encode($errorResponse);
71
+ }
72
+
73
+ return $response;
74
+ }
75
+
76
+ public function createloginsessionAction() {
77
+ $loginSettings = Mage::getModel('onescan/config_login')->getSettings();
78
+
79
+ try {
80
+ $loginProcess = new OnescanLoginProcess();
81
+ $loginSessionID = GUID();
82
+ $_SESSION['guid']=$loginSessionID;
83
+ $loginProcess->CreateSecurityCookie($loginSettings,$loginSessionID);
84
+ $response = $loginProcess->CreateOnescanSessionFromSessionData($loginSettings,$loginSessionID);
85
+ }
86
+ catch (Exception $e)
87
+ {
88
+ //Error Logging goes here.
89
+ $errorResponse = new OneScanResponseMessage();
90
+ $errorResponse->Success = false;
91
+ $response = json_encode($errorResponse);
92
+ }
93
+
94
+ return $response;
95
+ }
96
+
97
+ public function loginsuccessAction() {
98
+ $sessionvarname='guid';
99
+ if (isset($_GET['basket'])) {
100
+ $sessionvarname.=$_GET['basket'];
101
+ }
102
+ $loginSessionID=$_SESSION[$sessionvarname];
103
+ $customerID = LocalDataFactory::getStoredObject($loginSessionID);
104
+ $message = LocalDataFactory::getStoredObject($loginSessionID . '-message');
105
+ $redirect='customer/account/';
106
+ if ($customerID != null) {
107
+ $customer = Mage::getModel('customer/customer')->load($customerID);
108
+
109
+ if ($customer->getId()==null) {
110
+ //Customer no longer exists!
111
+
112
+ //Delete all login tokens associated with this customer
113
+ $loginTokens = Mage::getModel('onescan/logintokens')->getCollection();
114
+ $loginTokens->addFieldToFilter('magentouserid', array('like' => $customerID));
115
+ $loginTokens->load();
116
+ foreach($loginTokens as $loginToken) {
117
+ $loginToken->delete();
118
+ }
119
+
120
+ $message = Mage::getStoreConfig('onescantab/general/onescan_customer-deleted-message');
121
+ if ($message != '') {
122
+ Mage::getSingleton('core/session')->addError($message);
123
+ }
124
+ $redirect='customer/account/create/';
125
+ } elseif($customer->getConfirmation()!=null) {
126
+ //Customer not confirmed
127
+ $value=Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
128
+ $message = Mage::helper('customer')->__(Mage::getStoreConfig('onescantab/general/onescan_email-not-confirmed-message'),$value);
129
+ if ($message != '') {
130
+ Mage::getSingleton('core/session')->addError($message);
131
+ }
132
+ } else {
133
+ //Customer can be logged in
134
+ Mage::getSingleton('customer/session')->loginById($customerID);
135
+ if ($message != '') {
136
+ Mage::getSingleton('core/session')->addSuccess($message);
137
+ }
138
+ }
139
+ } elseif ($message != '') {
140
+ Mage::getSingleton('core/session')->addError($message);
141
+ }
142
+ LocalDataFactory::removeStoredObject($loginSessionID);
143
+ LocalDataFactory::removeStoredObject($loginSessionID . '-message');
144
+
145
+ session_write_close();
146
+
147
+ $this->_redirect($redirect);
148
+ }
149
+
150
+ public function loginfailureAction() {
151
+ $loginSessionID=$_SESSION['guid'];
152
+ $message = LocalDataFactory::getStoredObject($loginSessionID . '-message');
153
+ LocalDataFactory::removeStoredObject($loginSessionID);
154
+ LocalDataFactory::removeStoredObject($loginSessionID . '-message');
155
+ Mage::getSingleton('core/session')->addError($message);
156
+ session_write_close();
157
+
158
+ $this->_redirect('customer/account/');
159
+ }
160
+
161
+ public function purchasesuccessAction() {
162
+ //Empty Cart
163
+ $cartHelper = Mage::helper('checkout/cart');
164
+ $items = $cartHelper->getCart()->getItems();
165
+ foreach ($items as $item) {
166
+ $cartHelper->getCart()->removeItem($item->getItemId())->save();
167
+ }
168
+
169
+ Mage::getSingleton('core/session')->addSuccess('Thank you for ordering with Onescan.');
170
+ $this->loginsuccessAction();
171
+ }
172
+ }
173
+ ?>
app/code/local/Ensygnia/Onescan/etc/adminhtml.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ Ensygnia Onescan extension
3
+ Copyright (C) 2014 Ensygnia Ltd
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ -->
18
+ <config>
19
+ <acl>
20
+ <resources>
21
+ <admin>
22
+ <children>
23
+ <system>
24
+ <children>
25
+ <config>
26
+ <children>
27
+ <onescantab>
28
+ <title>Onescan</title>
29
+ </onescantab>
30
+ </children>
31
+ </config>
32
+ </children>
33
+ </system>
34
+ </children>
35
+ </admin>
36
+ </resources>
37
+ </acl>
38
+ </config>
app/code/local/Ensygnia/Onescan/etc/config.xml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ Ensygnia Onescan extension
3
+ Copyright (C) 2014 Ensygnia Ltd
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ -->
18
+ <config>
19
+ <modules>
20
+ <Ensygnia_Onescan>
21
+ <version>1.0.0</version>
22
+ </Ensygnia_Onescan>
23
+ </modules>
24
+ <global>
25
+ <helpers>
26
+ <onescan>
27
+ <class>Ensygnia_Onescan_Helper</class>
28
+ </onescan>
29
+ </helpers>
30
+ <blocks>
31
+ <onescan>
32
+ <class>Ensygnia_Onescan_Block</class>
33
+ </onescan>
34
+ </blocks>
35
+ <resources>
36
+ <onescan_setup>
37
+ <setup>
38
+ <module>Ensygnia_Onescan</module>
39
+ <class>Ensygnia_Onescan_Model_Resource_Setup</class>
40
+ </setup>
41
+ </onescan_setup>
42
+ </resources>
43
+ <models>
44
+ <onescan>
45
+ <class>Ensygnia_Onescan_Model</class>
46
+ <resourceModel>onescan_resource</resourceModel>
47
+ </onescan>
48
+ <onescan_resource>
49
+ <class>Ensygnia_Onescan_Model_Resource</class>
50
+ <entities>
51
+ <sessiondata>
52
+ <table>onescan_session_data</table>
53
+ </sessiondata>
54
+ <logintokens>
55
+ <table>onescan_login_tokens</table>
56
+ </logintokens>
57
+ </entities>
58
+ </onescan_resource>
59
+ </models>
60
+ </global>
61
+ <default>
62
+ <onescantab>
63
+ <general>
64
+ <enabled>1</enabled>
65
+ <onescan_account></onescan_account>
66
+ <onescan_secret></onescan_secret>
67
+ <onescan_serverurl>https://liveservice.ensygnia.net/api/PartnerGateway/1/</onescan_serverurl>
68
+ <onescan_register-success-message>You have successfully registered using Onescan. We have sent you an email with your login details should you ever need to log in "manually".</onescan_register-success-message>
69
+ <onescan_skip-confirmation>1</onescan_skip-confirmation>
70
+ <onescan_email-exists-message>Email address already registered, please log in using Onescan.</onescan_email-exists-message>
71
+ <onescan_login-success-message>You have successfully logged in using Onescan.</onescan_login-success-message>
72
+ <onescan_email-not-confirmed-message>This account is not confirmed. &lt;a href="%s"&gt;Click here&lt;/a&gt; to resend confirmation email.</onescan_email-not-confirmed-message>
73
+ <onescan_customer-deleted-message>We cannot find your account on our system. Please use Onescan to create a new account.</onescan_customer-deleted-message>
74
+ <onescan_basket-name>Shopping Basket</onescan_basket-name>
75
+ <show_on_cart_page>1</show_on_cart_page>
76
+ <show_on_mini_cart>1</show_on_mini_cart>
77
+ <show_now_accepting>1</show_now_accepting>
78
+ </general>
79
+ </onescantab>
80
+ <payment>
81
+ <onescan>
82
+ <active>1</active>
83
+ <model>onescan/method_onescan</model>
84
+ <order_status>processing</order_status>
85
+ <title>Onescan</title>
86
+ <allowspecific>0</allowspecific>
87
+ <group>offline</group>
88
+ </onescan>
89
+ </payment>
90
+ </default>
91
+ <frontend>
92
+ <routers>
93
+ <onescan>
94
+ <use>standard</use>
95
+ <args>
96
+ <module>Ensygnia_Onescan</module>
97
+ <frontName>onescan</frontName>
98
+ </args>
99
+ </onescan>
100
+ </routers>
101
+ <layout>
102
+ <updates>
103
+ <emc>
104
+ <file>onescan.xml</file>
105
+ </emc>
106
+ </updates>
107
+ </layout>
108
+ </frontend>
109
+ <adminhtml>
110
+ <layout>
111
+ <updates>
112
+ <onescan>
113
+ <file>onescan.xml</file>
114
+ </onescan>
115
+ </updates>
116
+ </layout>
117
+ </adminhtml>
118
+ </config>
app/code/local/Ensygnia/Onescan/etc/system.xml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ Ensygnia Onescan extension
3
+ Copyright (C) 2014 Ensygnia Ltd
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ -->
18
+ <config>
19
+ <sections>
20
+ <onescantab translate="label" module="adminhtml">
21
+ <label>Onescan</label>
22
+ <class>onescan-section</class>
23
+ <header_css>onescan-header</header_css>
24
+ <tab>sales</tab>
25
+ <sort_order>995</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <groups>
30
+ <cta>
31
+ <frontend_model>onescan/adminhtml_system_config_cta</frontend_model>
32
+ <sort_order>0</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </cta>
37
+ <general translate="label comment">
38
+ <label>General</label>
39
+ <sort_order>50</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <comment><![CDATA[Please enter the Onscan settings supplied by Ensygnia]]></comment>
44
+ <fields>
45
+ <enabled translate="label">
46
+ <label>Enabled</label>
47
+ <comment>Disable Onescan on your system</comment>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ <sort_order>10</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </enabled>
55
+ <onescan_account translate="label comment">
56
+ <label>Onescan Account Key</label>
57
+ <comment>Onescan account key supplied when you created your account with Ensygnia</comment>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>20</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </onescan_account>
64
+ <onescan_secret translate="label comment">
65
+ <label>Onescan Secret</label>
66
+ <comment>Onescan secret supplied when you created your account with Ensygnia</comment>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>30</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ </onescan_secret>
73
+ <onescan_serverurl translate="label comment">
74
+ <label>Onescan Server URL</label>
75
+ <comment>Onescan server URL - do not change unless instructed to do so by Ensygnia</comment>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>40</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ </onescan_serverurl>
82
+ <onescan_register-success-message translate="label comment">
83
+ <label>Register Success Message</label>
84
+ <comment>Message to show after a successful registration</comment>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>50</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ </onescan_register-success-message>
91
+ <onescan_skip-confirmation translate="label comment">
92
+ <label>Skip Confirmation Email</label>
93
+ <comment>Selects whether customers who register with Onescan skip the confirmation email. Has no effect if Require Emails Confirmation in Customer Configuration is set to "No".</comment>
94
+ <frontend_type>select</frontend_type>
95
+ <source_model>adminhtml/system_config_source_yesno</source_model>
96
+ <sort_order>60</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ </onescan_skip-confirmation>
101
+ <onescan_email-exists-message translate="label comment">
102
+ <label>Email Exists Message</label>
103
+ <comment>Error message to show if a user attempts to register with an existing email address</comment>
104
+ <frontend_type>text</frontend_type>
105
+ <sort_order>70</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </onescan_email-exists-message>
110
+ <onescan_login-success-message translate="label comment">
111
+ <label>Login Success Message</label>
112
+ <comment>Message to show after a successful login</comment>
113
+ <frontend_type>text</frontend_type>
114
+ <sort_order>80</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </onescan_login-success-message>
119
+ <onescan_email-not-confirmed-message translate="label comment">
120
+ <label>Email Not Confirmed Message</label>
121
+ <comment>Message to show after a login attempt when email address has not been confirmed (use %s for resend email URL).</comment>
122
+ <frontend_type>text</frontend_type>
123
+ <sort_order>90</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </onescan_email-not-confirmed-message>
128
+ <onescan_customer-deleted-message translate="label comment">
129
+ <label>Customer Deleted Message</label>
130
+ <comment>Message to show after a login attempt when customer no longer exists.</comment>
131
+ <frontend_type>text</frontend_type>
132
+ <sort_order>90</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ </onescan_customer-deleted-message>
137
+ <onescan_basket-name translate="label comment">
138
+ <label>Shopping Basket Name</label>
139
+ <comment>The name of the shopping basket that appears on the Onescanner's device.</comment>
140
+ <frontend_type>text</frontend_type>
141
+ <sort_order>100</sort_order>
142
+ <show_in_default>1</show_in_default>
143
+ <show_in_website>1</show_in_website>
144
+ <show_in_store>1</show_in_store>
145
+ </onescan_basket-name>
146
+ <show_on_cart_page translate="label">
147
+ <label>Show Onescan on cart page</label>
148
+ <comment>Display the Onescan padlock on the cart page.</comment>
149
+ <frontend_type>select</frontend_type>
150
+ <source_model>adminhtml/system_config_source_yesno</source_model>
151
+ <sort_order>110</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>1</show_in_store>
155
+ </show_on_cart_page>
156
+ <show_on_mini_cart translate="label">
157
+ <label>Show Onescan in mini cart</label>
158
+ <comment>Display the Onescan padlock in the mini cart.</comment>
159
+ <frontend_type>select</frontend_type>
160
+ <source_model>adminhtml/system_config_source_yesno</source_model>
161
+ <sort_order>120</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ </show_on_mini_cart>
166
+ <show_now_accepting translate="label">
167
+ <label>Show now accepting Onescan</label>
168
+ <comment>Display the "Now accepting Onescan" block.</comment>
169
+ <frontend_type>select</frontend_type>
170
+ <source_model>adminhtml/system_config_source_yesno</source_model>
171
+ <sort_order>130</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>1</show_in_store>
175
+ </show_now_accepting>
176
+ </fields>
177
+ </general>
178
+ </groups>
179
+ </onescantab>
180
+ </sections>
181
+ </config>
app/code/local/Ensygnia/Onescan/etc/widget.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ Ensygnia Onescan extension
3
+ Copyright (C) 2014 Ensygnia Ltd
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ -->
18
+ <widgets>
19
+ <onescan_basket type="onescan/widget_basket">
20
+ <name>Onescan: Basket</name>
21
+ <description type="desc">Adds a Onescan padlock for the entire shopping basket</description>
22
+ </onescan_basket>
23
+ <onescan_login type="onescan/widget_login">
24
+ <name>Onescan: Login</name>
25
+ <description type="desc">Adds a Onescan padlock for login</description>
26
+ </onescan_login>
27
+ <onescan_register type="onescan/widget_register">
28
+ <name>Onescan: Register</name>
29
+ <description type="desc">Adds a Onescan padlock for registration</description>
30
+ </onescan_register>
31
+ </widgets>
app/code/local/Ensygnia/Onescan/license.txt ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Preamble
2
+
3
+ The GNU General Public License is a free, copyleft license for software and other kinds of works.
4
+
5
+ The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
6
+
7
+ When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
8
+
9
+ To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
10
+
11
+ For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
12
+
13
+ Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
14
+
15
+ For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
16
+
17
+ Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
18
+
19
+ Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
20
+
21
+ The precise terms and conditions for copying, distribution and modification follow.
22
+
23
+ TERMS AND CONDITIONS
24
+
25
+ 0. Definitions.
26
+ �This License� refers to version 3 of the GNU General Public License.
27
+
28
+ �Copyright� also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
29
+
30
+ �The Program� refers to any copyrightable work licensed under this License. Each licensee is addressed as �you�. �Licensees� and �recipients� may be individuals or organizations.
31
+
32
+ To �modify� a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a �modified version� of the earlier work or a work �based on� the earlier work.
33
+
34
+ A �covered work� means either the unmodified Program or a work based on the Program.
35
+
36
+ To �propagate� a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
37
+
38
+ To �convey� a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
39
+
40
+ An interactive user interface displays �Appropriate Legal Notices� to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
41
+
42
+ 1. Source Code.
43
+ The �source code� for a work means the preferred form of the work for making modifications to it. �Object code� means any non-source form of a work.
44
+
45
+ A �Standard Interface� means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
46
+
47
+ The �System Libraries� of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A �Major Component�, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
48
+
49
+ The �Corresponding Source� for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
50
+
51
+ The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
52
+
53
+ The Corresponding Source for a work in source code form is that same work.
54
+
55
+ 2. Basic Permissions.
56
+ All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
57
+
58
+ You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
59
+
60
+ Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
61
+
62
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
63
+ No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
64
+
65
+ When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
66
+
67
+ 4. Conveying Verbatim Copies.
68
+ You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
69
+
70
+ You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
71
+
72
+ 5. Conveying Modified Source Versions.
73
+ You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
74
+
75
+ a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
76
+ b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to �keep intact all notices�.
77
+ c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
78
+ d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
79
+ A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an �aggregate� if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
80
+
81
+ 6. Conveying Non-Source Forms.
82
+ You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
83
+
84
+ a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
85
+ b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
86
+ c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
87
+ d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
88
+ e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
89
+ A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
90
+
91
+ A �User Product� is either (1) a �consumer product�, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, �normally used� refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
92
+
93
+ �Installation Information� for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
94
+
95
+ If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
96
+
97
+ The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
98
+
99
+ Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
100
+
101
+ 7. Additional Terms.
102
+ �Additional permissions� are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
103
+
104
+ When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
105
+
106
+ Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
107
+
108
+ a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
109
+ b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
110
+ c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
111
+ d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
112
+ e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
113
+ f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
114
+ All other non-permissive additional terms are considered �further restrictions� within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
115
+
116
+ If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
117
+
118
+ Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
119
+
120
+ 8. Termination.
121
+ You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
122
+
123
+ However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
124
+
125
+ Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
126
+
127
+ Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
128
+
129
+ 9. Acceptance Not Required for Having Copies.
130
+ You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
131
+
132
+ 10. Automatic Licensing of Downstream Recipients.
133
+ Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
134
+
135
+ An �entity transaction� is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
136
+
137
+ You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
138
+
139
+ 11. Patents.
140
+ A �contributor� is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's �contributor version�.
141
+
142
+ A contributor's �essential patent claims� are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, �control� includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
143
+
144
+ Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
145
+
146
+ In the following three paragraphs, a �patent license� is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To �grant� such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
147
+
148
+ If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. �Knowingly relying� means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
149
+
150
+ If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
151
+
152
+ A patent license is �discriminatory� if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
153
+
154
+ Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
155
+
156
+ 12. No Surrender of Others' Freedom.
157
+ If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
158
+
159
+ 13. Use with the GNU Affero General Public License.
160
+ Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
161
+
162
+ 14. Revised Versions of this License.
163
+ The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
164
+
165
+ Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License �or any later version� applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
166
+
167
+ If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
168
+
169
+ Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
170
+
171
+ 15. Disclaimer of Warranty.
172
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
173
+
174
+ 16. Limitation of Liability.
175
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
176
+
177
+ 17. Interpretation of Sections 15 and 16.
178
+ If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
app/code/local/Ensygnia/Onescan/sql/onescan_setup/install-1.0.0.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ $installer = $this;
20
+ $installer->startSetup();
21
+
22
+ $sessionDataTable = $installer->getConnection()->newTable($installer->getTable('onescan/sessiondata'))
23
+ ->addColumn('sessiondata_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
24
+ 'unsigned' => true,
25
+ 'nullable' => false,
26
+ 'primary' => true,
27
+ 'identity' => true,
28
+ ), 'Session Data ID')
29
+ ->addColumn('sessionid', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
30
+ 'nullable' => false,
31
+ ), 'Session ID')
32
+ ->addColumn('quoteid', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
33
+ 'nullable' => false,
34
+ ), 'Quote ID')
35
+ ->addColumn('customerid', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
36
+ 'nullable' => true,
37
+ ), 'Customer ID')
38
+ ->addColumn('shippingmethod', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
39
+ 'nullable' => true,
40
+ ), 'Shipping Method')
41
+ ->addColumn('shippingrate', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
42
+ 'unsigned' => true,
43
+ 'nullable' => true,
44
+ ), 'Shipping Rate')
45
+ ->setComment('Ensygnia onescan/sessiondata entity table');
46
+ $installer->getConnection()->createTable($sessionDataTable);
47
+
48
+ $LoginTokensTable = $installer->getConnection()->newTable($installer->getTable('onescan/logintokens'))
49
+ ->addColumn('logintoken_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
50
+ 'unsigned' => true,
51
+ 'nullable' => false,
52
+ 'primary' => true,
53
+ 'identity' => true,
54
+ ), 'Login Token ID')
55
+ ->addColumn('onescantoken', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
56
+ 'nullable' => false,
57
+ ), 'Onescan Token')
58
+ ->addColumn('magentouserid', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
59
+ 'nullable' => false,
60
+ ), 'Magento Userid')
61
+ ->setComment('Ensygnia onescan/logintokens entity table');
62
+ $installer->getConnection()->createTable($LoginTokensTable);
63
+
64
+ $installer->endSetup();
65
+ ?>
app/design/adminhtml/default/default/template/onescan/system/config/cta.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ Ensygnia Onescan extension
3
+ Copyright (C) 2014 Ensygnia Ltd
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ -->
18
+ <div class="onescan-notice">
19
+ <h4><?php echo Mage::helper('onescan')->__('Sign up for'); ?> <a href="https://portal.ensygnia.net" target="_blank">Onescan</a> by Ensygnia.</h4>
20
+ <h4><?php echo Mage::helper('onescan')->__('Download the manual from'); ?> <a href="http://www.ensygnia.com/downloads/OnescanPaymentPlugin.pdf" target="_blank">http://www.ensygnia.com/downloads/OnescanPaymentPlugin.pdf</a>.</h4>
21
+ </div>
app/design/frontend/base/default/template/onescan/basket.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ global $basketPadlockCount;
20
+ if (!isset($basketPadlockCount)) {
21
+ $basketPadlockCount=1;
22
+ } else {
23
+ $basketPadlockCount++;
24
+ }
25
+ ?>
26
+ <?php if ($this->getOnescanHelper()->isEnabled()): ?>
27
+ <div class="block block-onescan block-onescan-basket">
28
+ <div class="block-title">
29
+ <strong><span>Pay with Onescan</span></strong>
30
+ </div>
31
+
32
+ <div class="block-content">
33
+ <?php if ($this->hasItems()) { ?>
34
+ <div id="onescanPadlock_basket<?php echo $basketPadlockCount; ?>" class="onescanPadlock_basket onescanpadlock" data-sessionurl="<?php echo $this->getOnescanHelper()->getSessionFromBasketUrl() . '?basket=' . $basketPadlockCount; ?>" data-postconfirm="postConfirm(<?php echo $basketPadlockCount; ?>);" data-postfailed="postFailed();" data-polltarget="<?php echo $this->getOnescanHelper()->getSessionPollUrl(); ?>">
35
+
36
+ </div>
37
+ <?php } ?>
38
+ </div>
39
+ </div>
40
+ <?php endif; ?>
app/design/frontend/base/default/template/onescan/login.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ $ver=Mage::getVersion();
20
+ $verArray=explode('.',$ver);
21
+ if ($verArray[0]>1 || $verArray[1]==9) {
22
+ $verstring='19';
23
+ } else {
24
+ $verstring='pre19';
25
+ }
26
+ ?>
27
+ <?php if ($this->getOnescanHelper()->isEnabled()): ?>
28
+ <?php if (!$this->getSession()->isLoggedIn()): ?>
29
+ <div class="block block-onescan block-onescan-login-<?php echo $verstring; ?>">
30
+ <div class="block-title">
31
+ <strong><span>Onescan Login</span></strong>
32
+ </div>
33
+ <div class="block-content">
34
+ <div id="onescanPadlock_login" class="onescanpadlock" data-sessionurl="<?php echo $this->getOnescanHelper()->getLoginSessionUrl(); ?>" data-polltarget="<?php echo $this->getOnescanHelper()->getSessionPollUrl(); ?>">
35
+
36
+ </div>
37
+ </div>
38
+ </div>
39
+ <?php endif; ?>
40
+ <?php endif; ?>
app/design/frontend/base/default/template/onescan/logo.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ $ver=Mage::getVersion();
20
+ $verArray=explode('.',$ver);
21
+ if ($verArray[0]>1 || $verArray[1]==9) {
22
+ $verstring='19';
23
+ } else {
24
+ $verstring='pre19';
25
+ }
26
+ ?><?php if ($this->getOnescanHelper()->isEnabled()): ?>
27
+ <?php if (!$this->getSession()->isLoggedIn()): ?>
28
+ <div class="block block-onescan block-onescan-logo-<?php echo $verstring; ?>">
29
+ <div class="block-title">
30
+ <strong><span>Now Accepting Onescan</span></strong>
31
+ </div>
32
+ <div class="block-content">
33
+ <p>
34
+ <br />
35
+ <a href="http://www.onescan.me/" target="_blank"><img src="<?php echo $this->getSkinUrl('images/logo.png') ?>" /></a>
36
+ </p>
37
+ </div>
38
+ </div>
39
+ <?php endif; ?>
40
+ <?php endif; ?>
app/design/frontend/base/default/template/onescan/register.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ $ver=Mage::getVersion();
20
+ $verArray=explode('.',$ver);
21
+ if ($verArray[0]>1 || $verArray[1]==9) {
22
+ $verstring='19';
23
+ } else {
24
+ $verstring='pre19';
25
+ }
26
+ ?>
27
+ <?php if ($this->getOnescanHelper()->isEnabled()): ?>
28
+ <?php if (!$this->getSession()->isLoggedIn()): ?>
29
+ <div class="block block-onescan block-onescan-register-<?php echo $verstring; ?>">
30
+ <div class="block-title">
31
+ <strong><span>Onescan Register</span></strong>
32
+ </div>
33
+ <div class="block-content">
34
+ <div id="onescanPadlock_register" class="onescanpadlock" data-sessionurl="<?php echo $this->getOnescanHelper()->getRegistrationSessionUrl(); ?>" data-polltarget="<?php echo $this->getOnescanHelper()->getSessionPollUrl(); ?>">
35
+
36
+ </div>
37
+ </div>
38
+ </div>
39
+ <?php endif; ?>
40
+ <?php endif; ?>
lib/Onescan/core/onescan-Exceptions.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class ArgumentException extends Exception
20
+ {
21
+
22
+ }
23
+
24
+ class ArgumentNullException extends Exception
25
+ {
26
+ }
27
+
28
+ ?>
lib/Onescan/core/onescan-GUID.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ function GUID()
20
+ {
21
+ if (function_exists('com_create_guid') === true)
22
+ {
23
+ return trim(com_create_guid(), '{}');
24
+ }
25
+ return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
26
+ }
27
+
28
+ ?>
lib/Onescan/core/onescan-HMAC.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class HMAC
20
+ {
21
+ public static function Encode($input, $keystring)
22
+ {
23
+ return hash_hmac('sha1',$input,$keystring);
24
+ }
25
+ }
26
+ ?>
lib/Onescan/core/onescan-HTTPClient.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class HTTPClient
20
+ {
21
+ public static $UseAsync = TRUE;
22
+ public static $HTTPTimeout = 10000;
23
+
24
+ public function HTTPClient()
25
+ {
26
+ $this->RequestTimeout = HTTPClient::$HTTPTimeout;
27
+ $this->WasAborted = FALSE;
28
+ }
29
+
30
+ private function MakeRequest($account_key, $hmac, $post, $url, $data, $UseGZip, $contentType = "application/json")
31
+ {
32
+
33
+ $uri = curl_init($url);
34
+ if ($UseGZip)
35
+ curl_setopt($uri,CURLOPT_ENCODING,"gzip");
36
+
37
+ $header = array();
38
+ if ($contentType != NULL)
39
+ $header[] = "content-type: " . $contentType;
40
+
41
+ $header[] = "x-onescan-account: " . $account_key;
42
+ $header[] = "x-onescan-signature: " . $hmac;
43
+
44
+ curl_setopt($uri, CURLOPT_HTTPHEADER, $header);
45
+ curl_setopt($uri,CURLOPT_POST,$post);
46
+
47
+ if ($data != NULL)
48
+ {
49
+ curl_setopt($uri, CURLOPT_POSTFIELDS, $data);
50
+ }
51
+
52
+ try {
53
+ $response = curl_exec($uri);
54
+
55
+ if (curl_errno($uri) != 200) {
56
+ throw new Exception("HTTP Error " . curl_errno($uri) . '. ' . curl_error($uri));
57
+ }
58
+ }
59
+ catch (Exception $e) {
60
+ curl_close($uri);
61
+ throw $e;
62
+ }
63
+
64
+ return $response;
65
+ }
66
+
67
+ public function Post($account_key, $hmac, $url, $data, $UseGZip = false)
68
+ {
69
+ return $this->MakeRequest($account_key, $hmac, TRUE, $url, $data, $UseGZip);
70
+ }
71
+
72
+ public function Get($account_key, $hmac, $url, $UseGZip)
73
+ {
74
+ return $this->MakeRequest($account_key, $hmac, FALSE, $url, "", $UseGZip);
75
+ }
76
+
77
+
78
+ public $RequestTimeout;
79
+ public $WasAborted;
80
+ }
81
+
82
+ ?>
lib/Onescan/core/onescan-Login.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ abstract class LoginMode
20
+ {
21
+ const UsernamePassword=0;
22
+ const UserToken=1;
23
+ const TokenOrCredentials=2;
24
+ const Register=3;
25
+ }
26
+
27
+ class LoginDevicePayload
28
+ {
29
+
30
+ /// <summary>
31
+ /// Used by the device as a key for vaulted passwords.
32
+ /// </summary>
33
+ public $SiteIdentifier;
34
+
35
+ public $SiteLogoUrl;
36
+
37
+ /// <summary>
38
+ /// Tells the device what the friendly name of the site is.
39
+ /// </summary>
40
+ public $FriendlyName;
41
+
42
+ /// <summary>
43
+ /// Set by the partner to indicate what type of login
44
+ /// processes they support.
45
+ /// </summary>
46
+ public $LoginMode;
47
+
48
+ /// <summary>
49
+ /// An array of names of profiles for the data that the partner
50
+ /// wants to access to (e.g. "Basic" for name/email).
51
+ /// </summary>
52
+ public $Profiles=array();
53
+ }
54
+
55
+ class LoginDeviceSubmitPayload
56
+ {
57
+ /// <summary>
58
+ /// The list of profiles that have actually been provided. The user may have rejected
59
+ /// some of the ones requested.
60
+ /// </summary>
61
+ public $Profiles=array();
62
+
63
+ public $Username;
64
+ public $Password;
65
+ public $DefaultPassword;
66
+
67
+ // -- Profile data --
68
+ // this is "basic", we will populate the properties
69
+ public $FirstName;
70
+ public $LastName;
71
+ public $Email;
72
+ }
73
+ ?>
lib/Onescan/core/onescan-Message.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ // -------- Pre-process version ----------
21
+
22
+ define('CONST_SENARIO_LOGIN', 1);
23
+ define('CONST_SENARIO_PAYMENT', 2);
24
+ define('CONST_SENARIO_REGISTRATION', 3);
25
+ define('CONST_SENARIO_ONESCANLOGIN', 4);
26
+
27
+ class OneScanMetadata
28
+ {
29
+ public $EndpointURL;
30
+ public $VisualCodeTTL;
31
+ }
32
+
33
+ class PayloadItem {
34
+
35
+ /// <summary>
36
+ /// The name of this payload item. The names of payloads are entirely defined
37
+ /// by the process that uses the payloads.
38
+ /// </summary>
39
+ public $PayloadName;
40
+
41
+ /// <summary>
42
+ /// The actualy payload, stored as P7 encoded data.
43
+ /// </summary>
44
+ public $JsonPayload;
45
+
46
+ /// <summary>
47
+ /// The time stamp at which this payload item was first added to the
48
+ /// durable version of the process message that contains this payload item.
49
+ /// </summary>
50
+ public $PersistTimeStamp;
51
+
52
+ // -- Pre process version.
53
+ public $payloadType;
54
+ public $Context;
55
+ public $OriginatingParty;
56
+ public $DestinationParty;
57
+
58
+ protected function Duplicate() {
59
+ $payloadItem = new PayloadItem();
60
+ $payloadItem->PayloadName = $PayloadName;
61
+ $payloadItem->JsonPayload = $JsonPayload;
62
+ $payloadItem->PersistTimeStamp = $PersistTimeStamp;
63
+ $payloadItem->payloadType = $payloadType;
64
+ $payloadItem->Context = $Context;
65
+ $payloadItem->OriginatingParty = $OriginatingParty;
66
+ $payloadItem->DestinationParty = $DestinationParty;
67
+ }
68
+ }
69
+
70
+ class OneScanMessage {
71
+ /// <summary>
72
+ /// Get or set the Payloads that are part of this message.
73
+ /// </summary>
74
+ public $Payloads = array();
75
+
76
+ /// <summary>
77
+ /// The version of this message.
78
+ /// </summary>
79
+ public $Version;
80
+
81
+ /// <summary>
82
+ /// The type of process that this message supports (e.g. payments). Process
83
+ /// types are registered late so the full set of possible processes
84
+ /// cannot be defined here. We use a string ID for the type so that it is
85
+ /// a little easier to debug!
86
+ /// </summary>
87
+ public $ProcessType;
88
+
89
+ /// <summary>
90
+ /// The type of message. This essentially represents one "step" in the process
91
+ /// defined by ProcessType.
92
+ /// </summary>
93
+ public $MessageType;
94
+
95
+ /// <summary>
96
+ /// The ID of the process that this message is part of. Logically a single
97
+ /// message is created for a process and we continually enhance that message
98
+ /// with additional payloads.
99
+ /// </summary>
100
+ public $ProcessId;
101
+
102
+ public function CopyFrom($message)
103
+ {
104
+ if (isset($message->Payloads)) {
105
+ $this->Payloads = $message->Payloads;
106
+ } else {
107
+ $this->Payloads = null;
108
+ }
109
+ if (isset($message->Version)) {
110
+ $this->Version = $message->Version;
111
+ } else {
112
+ $this->Version = null;
113
+ }
114
+ if (isset($message->CertificateStore)) {
115
+ $this->CertificateStore = $message->CertificateStore;
116
+ } else {
117
+ $this->CertificateStore = null;
118
+ }
119
+ if (isset($message->ProcessType)) {
120
+ $this->ProcessType = $message->ProcessType;
121
+ } else {
122
+ $this->ProcessType = null;
123
+ }
124
+ if (isset($message->MessageType)) {
125
+ $this->MessageType = $message->MessageType;
126
+ } else {
127
+ $this->MessageType = null;
128
+ }
129
+ if (isset($message->ProcessId)) {
130
+ $this->ProcessId = $message->ProcessId;
131
+ } else {
132
+ $this->ProcessId = null;
133
+ }
134
+ if (isset($message->scenarioID)) {
135
+ $this->scenarioID = $message->scenarioID;
136
+ } else {
137
+ $this->scenarioID = null;
138
+ }
139
+ }
140
+
141
+ public $CertificateStore;
142
+
143
+ /// <summary>
144
+ /// Fetches a particular payload item from the set of payloads, if that item
145
+ /// actually exists. Returns null otherwise.
146
+ /// </summary>
147
+ /// <param name="payloadName"></param>
148
+ /// <returns></returns>
149
+ public function GetPayloadItemByName($payloadName)
150
+ {
151
+ foreach ($this->Payloads as $item)
152
+ {
153
+ if (strcmp($item->PayloadName,$payloadName) == 0)
154
+ {
155
+ return $item;
156
+ }
157
+ }
158
+ return NULL;
159
+ }
160
+
161
+ /// <summary>
162
+ /// Decode the specified payload.
163
+ /// </summary>
164
+ /// <typeparam name="T"></typeparam>
165
+ /// <param name="payloadName"></param>
166
+ /// <returns></returns>
167
+ public function FindPayloadAs( $payloadName ) {
168
+ $payload = $this->GetPayloadItemByName($payloadName);
169
+ if ($payload != NULL)
170
+ return json_decode($payload->JsonPayload);
171
+
172
+ return NULL;
173
+ }
174
+
175
+ /// <summary>
176
+ /// Copy the payloads from this message to the target message, unless the
177
+ /// target already has a payload with that name.
178
+ /// </summary>
179
+ /// <param name="message"></param>
180
+ public function MergePayloads( $message ) {
181
+ foreach ($Payloads as $item => $value) {
182
+ if ($message[$item->PayloadName] == null) {
183
+ $message->AddPayloadItem($item->Duplicate());
184
+ }
185
+ }
186
+ }
187
+
188
+ public function AddNewPayloadItem() {
189
+ $newPayloadItem = new PayloadItem();
190
+ $newPayloadItem->OriginatingParty = "";
191
+ $newPayloadItem->DestinationParty = "";
192
+ $this->Payloads[] = $newPayloadItem;
193
+ return $newPayloadItem;
194
+ }
195
+
196
+ public function AssertPayloadExists() {
197
+ if (($this->Payloads != NULL) && (count($this->Payloads) > 0))
198
+ return TRUE;
199
+ throw new Exception("No payload exists");
200
+ }
201
+
202
+ public function GetPayloadCount() {
203
+ if ($this->Payloads != NULL)
204
+ {
205
+ return count($this->Payloads);
206
+ }
207
+ return 0;
208
+ }
209
+
210
+ public $scenarioID;
211
+
212
+ public function UserTokenPayload()
213
+ {
214
+ return $this->FindPayloadAs(UserTokenPayload::Name);
215
+ }
216
+
217
+ }
218
+
219
+ class OneScanResponseMessage extends OneScanMessage
220
+ {
221
+
222
+ function OneScanResponseMessage() {
223
+ $Success = TRUE;
224
+ }
225
+
226
+ /// <summary>
227
+ /// Did the request succeed?
228
+ /// </summary>
229
+ public $Success;
230
+
231
+ }
232
+
233
+ ?>
lib/Onescan/core/onescan-Onescan.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once("onescan-HMAC.php");
20
+ require_once("onescan-Message.php");
21
+
22
+ class Onescan
23
+ {
24
+ private static function VerifyContentSignature($OnescanMessageAsJson, $settings, $passedHmac)
25
+ {
26
+ $calculatedHmac = Onescan::CalculateHMAC($settings, $OnescanMessageAsJson);
27
+ return ($calculatedHmac == $passedHmac);
28
+ }
29
+
30
+ public static function safe_getallheaders()
31
+ {
32
+ $headers = '';
33
+ foreach ($_SERVER as $name => $value)
34
+ {
35
+ if (strtoupper(substr($name, 0, 5)) == 'HTTP_')
36
+ {
37
+ $headers[str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($name, 5))))] = $value;
38
+ }
39
+ }
40
+ return $headers;
41
+ }
42
+
43
+ public static function ReadMessage($settings)
44
+ {
45
+ $message = NULL;
46
+
47
+ $jsonContent = file_get_contents("php://input");
48
+ $headers=Onescan::safe_getallheaders();
49
+ $hmacOfRequest=$headers["x-onescan-signature"];
50
+ if (Onescan::VerifyContentSignature($jsonContent, $settings, $hmacOfRequest))
51
+ {
52
+ $message = new OnescanMessage();
53
+ $message->CopyFrom( json_decode($jsonContent) );
54
+ }
55
+ return $message;
56
+ }
57
+
58
+ public static function SendMessage($message,$settings)
59
+ {
60
+ $jsonResponse=json_encode($message);
61
+ $hmacOfResponse = Onescan::CalculateHMAC($settings, $jsonResponse);
62
+ header("x-onescan-signature: " . $hmacOfResponse);
63
+ echo $jsonResponse;
64
+ }
65
+
66
+ public static function BuildResponseMessage($requestMessage)
67
+ {
68
+ $responseMessage = new OneScanResponseMessage();
69
+ $responseMessage->ProcessId = $requestMessage->ProcessId;
70
+ $responseMessage->ProcessType = $requestMessage->ProcessType;
71
+ $responseMessage->MessageType = $requestMessage->MessageType;
72
+ return $responseMessage;
73
+ }
74
+
75
+ public static function CalculateHMAC($settings, $content)
76
+ {
77
+ return HMAC::Encode($content, $settings->OnescanSecret);
78
+ }
79
+ }
80
+
81
+ ?>
lib/Onescan/core/onescan-Process.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ require_once("onescan-SessionState.php");
20
+ require_once("onescan-HMAC.php");
21
+ require_once("onescan-HTTPClient.php");
22
+ require_once("onescan-Message.php");
23
+ require_once("onescan-Exceptions.php");
24
+
25
+ /// <summary>
26
+ /// Represents a payload that can be added to each message sent to a partner
27
+ /// to uniquely identify the user. This token is expected to be constant for
28
+ /// a given user and partner pairing.
29
+ /// </summary>
30
+ class UserTokenPayload
31
+ {
32
+ const Name="Onescan.UserToken";
33
+ public $UserToken;
34
+ }
35
+
36
+ class ProcessOutcome
37
+ {
38
+ const Name='Onescan.ProcessOutcome';
39
+ public $RedirectURL;
40
+ public $RedirectAsFormPost;
41
+ public $FormPostData;
42
+ public $UserMessage;
43
+ }
44
+
45
+ class OnescanProcess
46
+ {
47
+ public $UserToken;
48
+
49
+ /// <summary>
50
+ /// Get the token uniquely representing the logged in user.
51
+ /// </summary>
52
+ protected function DecodeUserToken( $requestMessage ) {
53
+ $payload = $requestMessage->FindPayloadAs(UserTokenPayload::Name);
54
+ $this->UserToken = $payload->UserToken;
55
+ }
56
+
57
+ public function BuildSessionStateManager()
58
+ {
59
+ return new SimpleSessionStateManager();
60
+ }
61
+
62
+ /// <summary>
63
+ /// Build the common parts of the message that we will send to Onescan
64
+ /// </summary>
65
+ /// <returns></returns>
66
+ private function BuildBasicMessage($settings, $sessionState)
67
+ {
68
+
69
+ $sessionMessage = new OneScanMessage();
70
+
71
+ $metadataPayload = $sessionMessage->AddNewPayloadItem();
72
+ $metadataPayload->PayloadName = 'onescan.metadata';
73
+ $metadata = new OneScanMetadata();
74
+ $metadata->EndpointURL = $settings->OnescanCallbackURL;
75
+ $metadata->VisualCodeTTL = 500 * 60;
76
+
77
+ $metadataPayload->JsonPayload = json_encode($metadata);
78
+
79
+ // And we add a custom payload to it
80
+ $payloadItem = $sessionMessage->AddNewPayloadItem();
81
+ $payloadItem->PayloadName = 'partnerNamespace.sessionID';
82
+ $payloadItem->JsonPayload = json_encode($sessionState);
83
+
84
+ return $sessionMessage;
85
+ }
86
+
87
+ private function SetSessionState($message,$settings,$sessionState)
88
+ {
89
+ // And we add a custom payload to it
90
+ $payloadItem = $message->AddNewPayloadItem();
91
+ $payloadItem->PayloadName = 'partnerNamespace.sessionID';
92
+ $payloadItem->JsonPayload = json_encode($sessionState);
93
+ }
94
+
95
+ public function UpdateSessionState($message,$settings,$sessionState)
96
+ {
97
+ $this->SetSessionState($message,$settings,$sessionState);
98
+ return;
99
+ // And we add a custom payload to it
100
+ /*string sessionStatePayloadName = settings.PartnerNamespace + ".sessionID";
101
+ PayloadItem payload = message[sessionStatePayloadName];
102
+ if (payload == null)
103
+ throw new ArgumentException("Payload must contain a PayloadName entry", "PayloadItem");
104
+
105
+ try
106
+ {
107
+ payload.JsonPayload = JSonUtils.Serialise(sessionState);
108
+ }
109
+ catch (Exception ex)
110
+ {
111
+ }*/
112
+ }
113
+
114
+ /// <summary>
115
+ /// Build a message that we
116
+ /// </summary>
117
+ public function BuildStaticResponseMessage($settings,$sessionId) {
118
+ $sessionState = $this->BuildOnescanSessionState($sessionId);
119
+ $message = $this->BuildBasicMessage($settings,$sessionState);
120
+ $responseMessage = Onescan::BuildResponseMessage($message);
121
+ $message->MergePayloads($responseMessage);
122
+ return $responseMessage;
123
+ }
124
+
125
+ /// <summary>
126
+ /// Passes the data describing the process we want to initiate
127
+ /// over to onescan and gets back a session object that we can
128
+ /// use to render the QR code
129
+ /// </summary>
130
+ private function InternalCreateOnescanSession($settings,$sessionState)
131
+ {
132
+ // create payload
133
+ // lodge session data
134
+ // perform HMAC signing
135
+ // call OnescanServer and grabresult
136
+ $message = $this->BuildBasicMessage($settings,$sessionState);
137
+ $this->AddProcessPayload($settings,$message);
138
+ $messageAsJson = json_encode($message);
139
+ $hmac = HMAC::Encode($messageAsJson,$settings->OnescanSecret);
140
+
141
+ $client = new HTTPClient();
142
+ $response = $client->Post($settings->OnescanAccountKey, $hmac, $settings->OnescanServerURL, $messageAsJson);
143
+
144
+ $onescanSessionMessage = json_decode($response);
145
+ $jsonPayload = $onescanSessionMessage->Payloads[0]->JsonPayload;
146
+
147
+ return $response;
148
+ }
149
+
150
+ public function AddProcessPayload($settings, $message)
151
+ {
152
+ }
153
+
154
+ public function BuildOnescanSessionState($sessionData)
155
+ {
156
+ $sessionState = new OnescanSessionState();
157
+ $sessionState->SessionID = $sessionData;
158
+ return $sessionState;
159
+ }
160
+
161
+ public function CreateOnescanSessionFromSessionData($settings, $sessionData)
162
+ {
163
+ $sessionState = $this->BuildOnescanSessionState($sessionData);
164
+ return $this->CreateOnescanSessionFromSessionState($settings, $sessionState);
165
+ }
166
+
167
+ public function CreateOnescanSessionFromSessionState($settings, $sessionState)
168
+ {
169
+ return $this->InternalCreateOnescanSession($settings, $sessionState);
170
+ }
171
+
172
+ public function CreateSecurityCookie($settings, $sessionID)
173
+ {
174
+ $settingsAsJson = json_encode($settings);
175
+ $Expires = time()+$settings->SecurityCookieLifetimeSeconds;
176
+ $Secure = $settings->CookieIsSecure;
177
+ setcookie($sessionID, HMAC::Encode($settingsAsJson,$sessionID),$Expires,"/",$_SERVER["SERVER_NAME"],$Secure);
178
+ }
179
+
180
+ public function CheckSecurityCookie($settings,$sessionID)
181
+ {
182
+ $result = false;
183
+ $securityCookie = $_COOKIE[$sessionID];
184
+ if ($securityCookie != null)
185
+ {
186
+ $hmac = HMAC_Encode($settings,$sessionID);
187
+ if ($securityCookie != null)
188
+ {
189
+ $result = $hmac == $securityCookie;
190
+ }
191
+ }
192
+ return $result;
193
+ }
194
+ }
195
+ ?>
lib/Onescan/core/onescan-Session.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class OnescanSession
20
+ {
21
+ public $SessionID;
22
+ public $SignedSessionID;
23
+ public $Status;
24
+ }
25
+
26
+ class RequestQRResponse
27
+ {
28
+ public $Protocol;
29
+ public $Session;
30
+ public $ImageBytes;
31
+ public $QRdata;
32
+ public $ResultCode;
33
+ }
34
+
35
+ ?>
lib/Onescan/core/onescan-SessionState.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class SimpleSessionStateManager
20
+ {
21
+ private $sessionState;
22
+
23
+ public function AsJson()
24
+ {
25
+ return json_encode($sessionState);
26
+ }
27
+
28
+ public function FromJson($value)
29
+ {
30
+ $sessionState = json_decode($value);
31
+ }
32
+
33
+ }
34
+
35
+ class OnescanSessionState
36
+ {
37
+ public $SessionID;
38
+ }
39
+
40
+ ?>
lib/Onescan/core/onescan-Settings.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class OnescanSettings
20
+ {
21
+ /// <summary>
22
+ /// The partner's OnescanAccountKey supplied by Ensygnia
23
+ /// </summary>
24
+ public $OnescanAccountKey;
25
+
26
+ /// <summary>
27
+ /// The partner's OnescanSecret supplied by Ensygnia
28
+ /// </summary>
29
+ public $OnescanSecret;
30
+
31
+ /// <summary>
32
+ /// The partner's callback endpoint used by Onescan to communicate during the process
33
+ /// </summary>
34
+ public $OnescanCallbackURL;
35
+
36
+ /// <summary>
37
+ /// The Ensygnia supplied Onescan server endpoint
38
+ /// </summary>
39
+ public $OnescanServerURL;
40
+
41
+ /// <summary>
42
+ /// Get or set the namespace for all partner payloads.
43
+ /// </summary>
44
+ public $PartnerNamespace = 'partner';
45
+
46
+ public $SecurityCookieLifetimeSeconds = 300;
47
+
48
+ public $CookieIsSecure = true;
49
+
50
+ }
51
+ ?>
lib/Onescan/login/LocalDataFactory.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class LocalDataFactory {
20
+
21
+ public static function removeStoredObject($signature) {
22
+ return (unlink(sys_get_temp_dir() . '/' . $signature));
23
+ }
24
+
25
+ public static function getStoredObject($signature) {
26
+ if ($data = file_get_contents(sys_get_temp_dir() . '/' . $signature)) {
27
+ $obj = @unserialize($data);
28
+ return $obj;
29
+ }
30
+ return false;
31
+ }
32
+
33
+ public static function storeObject($signature, $obj) {
34
+ file_put_contents(sys_get_temp_dir() . '/' . $signature,serialize($obj));
35
+ }
36
+ }
37
+ ?>
lib/Onescan/login/onescan-LoginProcess.php ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ $logindir=dirname(__FILE__);
20
+ $coredir=str_replace("login","core",$logindir);
21
+
22
+ require_once($coredir . "/onescan-Settings.php");
23
+ require_once($coredir . "/onescan-Process.php");
24
+ require_once($coredir . "/onescan-Onescan.php");
25
+ require_once($coredir . "/onescan-GUID.php");
26
+ require_once($coredir . "/onescan-HMAC.php");
27
+ require_once($coredir . "/onescan-Message.php");
28
+ require_once($coredir . "/onescan-Login.php");
29
+
30
+ class OnescanLoginSettings extends OnescanSettings
31
+ {
32
+ /// <summary>
33
+ /// The SiteID supplied by Onescan. This is used in the device vault
34
+ /// </summary>
35
+ public $SiteID;
36
+
37
+ /// <summary>
38
+ /// A friendly name for displaying on the Device login prompt screen
39
+ /// </summary>
40
+ public $FriendlyName;
41
+
42
+ /// <summary>
43
+ /// A url to a publically available logo for the site/company authorising access
44
+ /// </summary>
45
+ public $SiteLogoURL;
46
+
47
+ /// <summary>
48
+ /// What login mode(s) do we wish to support
49
+ /// </summary>
50
+ public $LoginMode;
51
+
52
+ public $Profiles=array();
53
+ }
54
+
55
+ class LoginCredentials
56
+ {
57
+ public $Mode;
58
+ public $Username;
59
+ public $Password;
60
+ public $OnescanUserIdentityToken;
61
+
62
+ public $Profiles=array();
63
+
64
+ // basic profile data
65
+ public $Firstname;
66
+ public $Lastname;
67
+ public $Email;
68
+ }
69
+
70
+ class LoginResult
71
+ {
72
+ public function LoginResult()
73
+ {
74
+ $this->NextAction = LoginNextAction::Unknown;
75
+
76
+ // Default Success out to true, this should be set to fault and a DeviceMessage provided in the case we want to signal failure
77
+ $this->Success = true;
78
+ $this->EndProcess = true;
79
+ }
80
+
81
+ public $Success;
82
+ public $EndProcess;
83
+ public $BrowserRedirectURL;
84
+ public $RedirectAsFormPost;
85
+ public $FormPostData;
86
+ public $DeviceMessage;
87
+ public $NextAction;
88
+ }
89
+
90
+ abstract class LoginNextAction
91
+ {
92
+ const Unknown=0;
93
+ const LoginSuccessful=1;
94
+ const FallbackToUsernamePassword=2;
95
+ const PromptForRetry=3;
96
+ const RequestUserDetails=4;
97
+ const SignalFailure=5;
98
+ }
99
+
100
+ class OnescanLoginProcess extends OnescanProcess
101
+ {
102
+ private $sessionState;
103
+ private $requestMessage;
104
+
105
+ public function AddProcessPayload($settings,$message)
106
+ {
107
+ parent::AddProcessPayload($settings,$message);
108
+
109
+ // Define this process type, we are doing login here
110
+ $message->ProcessType = "login";
111
+
112
+ $payloadItem = $message->AddNewPayloadItem();
113
+ $payloadItem->PayloadName = "Onescan.LoginDevicePayload";
114
+
115
+ $loginSettings = new OnescanLoginSettings;
116
+ $loginSettings = $settings;
117
+
118
+ $siteDetails = new LoginDevicePayload();
119
+ $siteDetails->FriendlyName = $loginSettings->FriendlyName;
120
+ $siteDetails->SiteIdentifier = $loginSettings->SiteID;
121
+ $siteDetails->SiteLogoUrl = $loginSettings->SiteLogoURL;
122
+ $siteDetails->LoginMode = $loginSettings->LoginMode;
123
+ $siteDetails->Profiles = $loginSettings->Profiles != null ? $loginSettings->Profiles : array("basic");
124
+ $payloadItem->JsonPayload = json_encode($siteDetails);
125
+ }
126
+
127
+ public function DecodeLoginCredentials($message,$settings,$defaultMode = LoginMode::UserToken)
128
+ {
129
+ $creds = new LoginCredentials();
130
+ // we arrive here only if there is a valid message
131
+
132
+ $userTokenPayload = $message->UserTokenPayload();
133
+ if (($userTokenPayload != null) && ($userTokenPayload->UserToken != null))
134
+ {
135
+ $creds->OnescanUserIdentityToken = $userTokenPayload->UserToken;
136
+ $creds->Mode = $defaultMode;
137
+ }
138
+
139
+ $userCredentials = $message->FindPayloadAs("Onescan.LoginCredentials");
140
+
141
+ $this->sessionState = $message->FindPayloadAs("partnerNamespace.sessionID");
142
+ if ($userCredentials != null && $this->sessionState != null)
143
+ {
144
+ $creds->Username = $userCredentials->Username;
145
+ $creds->Password = $userCredentials->Password;
146
+ $creds->Mode = LoginMode::UsernamePassword;
147
+
148
+ if ($userCredentials->Profiles != null)
149
+ {
150
+ $creds->Mode = LoginMode::Register;
151
+ $creds->Profiles = $userCredentials->Profiles;
152
+
153
+ $creds->Firstname = $userCredentials->FirstName;
154
+ $creds->Lastname = $userCredentials->LastName;
155
+ $creds->Email = $userCredentials->Email;
156
+ }
157
+ }
158
+
159
+ $this->requestMessage = $message;
160
+ return $creds;
161
+ }
162
+
163
+ private function SetNextAction($responseMessage,$nextAction)
164
+ {
165
+ switch ($nextAction)
166
+ {
167
+ case LoginNextAction::LoginSuccessful:
168
+ $responseMessage->MessageType = "ProcessComplete";
169
+ break;
170
+ case LoginNextAction::FallbackToUsernamePassword:
171
+ $responseMessage->MessageType = "StartLogin"; // as before
172
+ break;
173
+ case LoginNextAction::PromptForRetry:
174
+ $responseMessage->MessageType = "RetryLogin";
175
+ break;
176
+ case LoginNextAction::RequestUserDetails:
177
+ $responseMessage->MessageType = "RegisterUser";
178
+ break;
179
+ case LoginNextAction::SignalFailure:
180
+ $responseMessage->MessageType = "LoginProblem";
181
+ break;
182
+ }
183
+ }
184
+
185
+ public function EncodeOutcome($loginResult,$settings)
186
+ {
187
+ if ($loginResult->NextAction == LoginNextAction::Unknown)
188
+ throw new Exception("Next action is not set");
189
+
190
+ $responseMessage = Onescan::BuildResponseMessage($this->requestMessage);
191
+ $this->UpdateSessionState($responseMessage,$settings,$this->sessionState);
192
+
193
+ $this->SetNextAction($responseMessage,$loginResult->NextAction);
194
+
195
+ $responseMessage->Success = $loginResult->Success;
196
+
197
+ if ($loginResult->EndProcess)
198
+ {
199
+ // finally setup the response payload
200
+ $responsePayload = $responseMessage->AddNewPayloadItem();
201
+ $responsePayload->PayloadName = ProcessOutcome::Name;
202
+ $outcome = new ProcessOutcome();
203
+ $outcome->RedirectURL = $loginResult->BrowserRedirectURL;
204
+ $outcome->UserMessage = $loginResult->DeviceMessage;
205
+ $outcome->RedirectAsFormPost = $loginResult->RedirectAsFormPost;
206
+ $outcome->FormPostData = $loginResult->FormPostData;
207
+ $responsePayload->JsonPayload = json_encode($outcome);
208
+ }
209
+ return $responseMessage;
210
+ }
211
+
212
+ public function SessionState()
213
+ {
214
+ return $this->sessionState;
215
+ }
216
+ }
217
+ ?>
lib/Onescan/purchase/onescan-AdditionalChargesPayload.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// Response from the partner containing the set of delivery options and their costs given
21
+ /// the address that was supplied, and any surcharges for the payment method.
22
+ /// </summary>
23
+ class AdditionalChargesPayload {
24
+ const Name = "Onescan.AdditionalCharges";
25
+
26
+ /// <summary>
27
+ /// The list of delivery options that are available for this order. If the
28
+ /// address has not yet been supplied then this can be an empty list.
29
+ /// </summary>
30
+ public $DeliveryOptions=array();
31
+
32
+ /// <summary>
33
+ /// Flag indicating that no delivery options could be returned for the specified address.
34
+ /// In the case of orders that do not support/require delivery, this should be set to
35
+ /// false.
36
+ /// </summary>
37
+ public $AddressNotSupported;
38
+
39
+ /// <summary>
40
+ /// A string just describing why the address is not supported. For those purchases that do not
41
+ /// require a delivery address, simply leave blank.
42
+ /// </summary>
43
+ public $AddressNotSupportedReason;
44
+
45
+ /// <summary>
46
+ /// Information about any charges.
47
+ /// </summary>
48
+ public $PaymentMethodCharge;
49
+ }
50
+ ?>
lib/Onescan/purchase/onescan-CardInformation.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class CardInformation {
20
+
21
+ /// <summary>
22
+ /// Is this a debit card rather than a credit card?
23
+ /// </summary>
24
+ public $CardType;
25
+
26
+ /// <summary>
27
+ /// Is this a corporate card?
28
+ /// </summary>
29
+ public $Corporate;
30
+
31
+ /// <summary>
32
+ /// The type of the card (e.g. AMEX, VISA). Note that we do not use this currently in the
33
+ /// platform and all we do is pass it through from the SagePay getCardDetails call to the
34
+ /// partner. It could be an enum but since we are just serializing, it will go across the wire
35
+ /// as text anyway. By just keeping it as text, if SagePay add new types then we will just
36
+ /// automatically support them.
37
+ /// </summary>
38
+ public $PaymentSystemCode;
39
+
40
+ /// <summary>
41
+ /// The 2 character ISO code for the country the card was issued in.
42
+ /// </summary>
43
+ public $CountryCode;
44
+
45
+ /// <summary>
46
+ /// The name of the payment system ( e.g. MasterCard)
47
+ /// </summary>
48
+ public $PaymentSystemName;
49
+
50
+ /// <summary>
51
+ /// The issuer of the card.
52
+ /// </summary>
53
+ public $Issuer;
54
+
55
+ }
56
+ ?>
lib/Onescan/purchase/onescan-CardType.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// Is it a debit or credit card?
21
+ /// </summary>
22
+ abstract class CardType {
23
+ const Debit=0;
24
+ const Credit=1;
25
+ }
26
+ ?>
lib/Onescan/purchase/onescan-Charge.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class Charge {
20
+
21
+ /// <summary>
22
+ /// The basic amount
23
+ /// </summary>
24
+ public $BaseAmount;
25
+
26
+ /// <summary>
27
+ /// The tax being charged.
28
+ /// </summary>
29
+ public $Tax;
30
+
31
+ /// <summary>
32
+ /// The total charge that will be applied.
33
+ /// </summary>
34
+ public $TotalAmount;
35
+ }
36
+ ?>
lib/Onescan/purchase/onescan-ConfirmPaymentPayload.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// The confirm payment payload
21
+ /// </summary>
22
+ class ConfirmPaymentPayload {
23
+
24
+ const Name = "Onescan.PurchaseDetails";
25
+
26
+ public $PurchaseInformation;
27
+ public $BuyerAddress;
28
+ public $DeliveryAddress;
29
+ public $UserEmail;
30
+ public $UserMobile;
31
+ public $FirstName;
32
+ public $LastName;
33
+
34
+ public $GatewayTransactionId;
35
+ public $AmountCharged;
36
+ public $DeliveryMethodCode;
37
+ public $SurchargeCode;
38
+ }
39
+ ?>
lib/Onescan/purchase/onescan-CorePurchaseInfo.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class CorePurchaseInfo {
20
+
21
+ const Name = "Onescan.PurchasePayload";
22
+
23
+ public $MerchantName;
24
+
25
+ /// <summary>
26
+ /// A merchant defined transaction ID for their own internal use.
27
+ /// </summary>
28
+ public $MerchantTransactionID;
29
+
30
+ /// <summary>
31
+ /// The subject of the purchase.
32
+ /// </summary>
33
+ public $PurchaseDescription;
34
+
35
+ /// <summary>
36
+ /// The amount of the basic product
37
+ /// </summary>
38
+ public $ProductAmount;
39
+
40
+ /// <summary>
41
+ /// The amount of the tax added to the product.
42
+ /// </summary>
43
+ public $Tax;
44
+
45
+ /// <summary>
46
+ /// The total payment amount to be taken.
47
+ /// </summary>
48
+ public $PaymentAmount;
49
+
50
+ /// <summary>
51
+ /// The currency that the payment is being charged in.
52
+ /// </summary>
53
+ public $Currency;
54
+
55
+ /// <summary>
56
+ /// Indicates whether the order is a physical order that requires
57
+ /// a delivery address in addition to the billing address.
58
+ /// </summary>
59
+ public $RequiresDeliveryAddress;
60
+
61
+ /// <summary>
62
+ /// The set of payment optins that the partner requires.
63
+ /// </summary>
64
+ public $Requires;
65
+ }
66
+ ?>
lib/Onescan/purchase/onescan-DeliveryOption.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class DeliveryOption {
20
+
21
+ /// <summary>
22
+ /// A unique ID set by the partner so when we hand the record back as the selected
23
+ /// payment option they know what to pick.
24
+ /// </summary>
25
+ public $Code;
26
+
27
+ /// <summary>
28
+ /// A short name for the delivery option (e.g. 'free', 'first class').
29
+ /// </summary>
30
+ public $Label;
31
+
32
+ /// <summary>
33
+ /// If required, a longer description for the payment method. We might use the
34
+ /// Label in a drop down, then show the description (e.g. 'First class delivery using
35
+ /// Royal Mail recorded delivery) when we show the details of the delivery method.
36
+ /// </summary>
37
+ public $Description;
38
+
39
+ /// <summary>
40
+ /// An explanation of the terms and conditions. For example, if the type is courier
41
+ /// it might be some text saying it will be any time before noon or whatever.
42
+ /// </summary>
43
+ public $Conditions;
44
+
45
+ /// <summary>
46
+ /// True if we should choose this delivery option as the initial default.
47
+ /// </summary>
48
+ public $IsDefault;
49
+
50
+ /// <summary>
51
+ /// The charge for this delivery option.
52
+ /// </summary>
53
+ public $Charge;
54
+
55
+ }
56
+ ?>
lib/Onescan/purchase/onescan-OrderAcceptedPayload.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ class OrderAcceptedPayload {
21
+ const Name="Onescan.OrderAccepted";
22
+
23
+ /// <summary>
24
+ /// An ID for the receipt.
25
+ /// </summary>
26
+ public $ReceiptId;
27
+
28
+ /// <summary>
29
+ /// A key provided by the partner to provide
30
+ /// some sort of order identifier.
31
+ /// </summary>
32
+ public $OrderId;
33
+ }
34
+
35
+ ?>
lib/Onescan/purchase/onescan-OrderDeclinedPayload.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class OrderDeclinedPayload {
20
+ /* Some standard error codes that the partner can use to indicate
21
+ * particular problems that the device may be able to fix
22
+ */
23
+ public static $Name="Onescan.OrderDeclined";
24
+
25
+ /// <summary>
26
+ /// A general failure.
27
+ /// </summary>
28
+ const GeneralFailure = 0;
29
+
30
+ /// <summary>
31
+ /// The delivery address was not supplied.
32
+ /// </summary>
33
+ const NoDeliveryAddress = 1;
34
+
35
+ /// <summary>
36
+ /// The address cannot be delivered to
37
+ /// </summary>
38
+ const AddressNotCovered = 2;
39
+
40
+ /// <summary>
41
+ /// Insufficient stock levels.
42
+ /// </summary>
43
+ const OutOfStock = 3;
44
+
45
+ /// <summary>
46
+ /// The address was not valid.
47
+ /// </summary>
48
+ const InvalidAddress = 4;
49
+
50
+ /// <summary>
51
+ /// For things like car bookings or tickets we might reserve a ticket
52
+ /// for a short period of time whilst the user enters the details for the
53
+ /// purchase. If we didn't complete in time then it may be that the item
54
+ /// has been released. This means the order didn't really "fail" as such
55
+ /// but that the user still needs to start again.
56
+ /// </summary>
57
+ const ForceRestart = 5;
58
+
59
+ /// <summary>
60
+ /// Set up which of the errors are considered critical failures that mean the
61
+ /// process must be cancelled.
62
+ /// </summary>
63
+ private $criticalFailures = array(OrderDeclinedPayload::GeneralFailure,
64
+ OrderDeclinedPayload::OutOfStock,
65
+ OrderDeclinedPayload::InvalidAddress);
66
+
67
+ /// <summary>
68
+ /// Get or set whether the error from the partner is critical (i.e. cannot
69
+ /// be fixed) or not. If not then the device can re-submit the payload with
70
+ /// appropriate corrections.
71
+ /// </summary>
72
+ public function IsCritical() {
73
+ return in_array($this->ErrorCode,$this->criticalFailures);
74
+ }
75
+
76
+ /// <summary>
77
+ /// An error code indicating what type of failure happened - see the
78
+ /// above error codes.
79
+ /// </summary>
80
+ public $ErrorCode;
81
+
82
+ /// <summary>
83
+ /// Get or set a human readable version of the error so that the user has some
84
+ /// idea what happened.
85
+ /// </summary>
86
+ public $ReasonDescription;
87
+ }
88
+
89
+ ?>
lib/Onescan/purchase/onescan-PaymentMethodCharge.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class PaymentMethodCharge {
20
+
21
+ /// <summary>
22
+ /// A unique id set by the partner so when we hand the record back as the
23
+ /// applied surcharge they have a handle to it.
24
+ /// </summary>
25
+ public $Code;
26
+
27
+ /// <summary>
28
+ /// A description of the charge (e.g. 'Credit cards attract a 2% charge')
29
+ /// </summary>
30
+ public $Description;
31
+
32
+ /// <summary>
33
+ /// The charge itself.
34
+ /// </summary>
35
+ public $Charge;
36
+ }
37
+ ?>
lib/Onescan/purchase/onescan-PaymentMethodInformation.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// Contains information about the type of payment method that the user has
21
+ /// entered. The actual contents of this will vary by the payment field.
22
+ /// </summary>
23
+ class PaymentMethodInformation {
24
+
25
+ /// <summary>
26
+ /// The type of payment method that the user has selected, if any. This indicates if the
27
+ /// payment is a card, PayPal etc.
28
+ /// </summary>
29
+ public $PaymentMethodType;
30
+
31
+ /// <summary>
32
+ /// If the payment type is CreditCard this will be present to provide further information about
33
+ /// the card.
34
+ /// </summary>
35
+ public $CardInformation;
36
+ }
37
+ ?>
lib/Onescan/purchase/onescan-PaymentMethodType.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// The various types of payment method
21
+ /// </summary>
22
+ abstract class PaymentMethodType {
23
+
24
+ const CreditCard = 0;
25
+ const PayPal = 1;
26
+ const DirectDebit = 2;
27
+
28
+ /// <summary>
29
+ /// Essentially a no-operation payment method that allows users to try out a payment scan on
30
+ /// a test site. If they have provided an email then it simulates a full payment process
31
+ /// but obviously doesn't actually take any actual payments.
32
+ /// </summary>
33
+ const OnescanPlay = 3;
34
+ }
35
+ ?>
lib/Onescan/purchase/onescan-PaymentOptins.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// Provides a set of features that the partner can opt in
21
+ /// to.
22
+ /// </summary>
23
+ class PaymentOptIns {
24
+
25
+ /// <summary>
26
+ /// Does the partner want to be called to supply delivery options?
27
+ /// </summary>
28
+ public $DeliveryOptions;
29
+
30
+ /// <summary>
31
+ /// Does the partner want to be called to supply surcharge information
32
+ /// based on the selected payment methods?
33
+ /// </summary>
34
+ public $Surcharges;
35
+
36
+ }
37
+ ?>
lib/Onescan/purchase/onescan-PurchaseAction.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ abstract class PurchaseAction {
20
+ const StartPayment=0;
21
+ const PaymentConfirmed=1;
22
+ const PaymentCancelled=2;
23
+ const PaymentFailed=3;
24
+ const AdditionalCharges=4;
25
+ }
26
+ ?>
lib/Onescan/purchase/onescan-PurchaseCharges.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// Contains calculated information about the costs of the entire transaction, including
21
+ /// P+P, appropriate taxes, payment method surcharges and so on.
22
+ /// </summary>
23
+ class PurchaseCharges {
24
+
25
+ /// <summary>
26
+ /// The total amount of postage.
27
+ /// </summary>
28
+ public $PostageAmount;
29
+
30
+ /// <summary>
31
+ /// The amount of the item(s) costs, excluding taxes
32
+ /// </summary>
33
+ public $BasketAmount;
34
+
35
+ /// <summary>
36
+ /// The amount of tax added to the products in the basket.
37
+ /// </summary>
38
+ public $BasketTax;
39
+
40
+ /// <summary>
41
+ /// The total payment amount taken.
42
+ /// </summary>
43
+ public $PaymentAmount;
44
+
45
+ /// <summary>
46
+ /// The currency that the payment is being charged in. All amounts in
47
+ /// this class will be in this currency.
48
+ /// </summary>
49
+ public $Currency;
50
+
51
+ /// <summary>
52
+ /// Any extra charges for the currently selected payment method
53
+ /// </summary>
54
+ public $Surcharge;
55
+ }
56
+ ?>
lib/Onescan/purchase/onescan-PurchaseContextPayload.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// This is a payload that we can send to the partner whenever we need them to give
21
+ /// some information about possible extra charges that depend upon the current
22
+ /// delivery and payment information provided by the user.
23
+ /// </summary>
24
+ /// <remarks>
25
+ /// If we choose to use a default delivery address and payment method then this payload
26
+ /// could be provided as part of the initial "start purchase" method so that the
27
+ /// partner can provide this information straight away. It can also be passed in as part
28
+ /// of an explicit call when the user changes one of those options.
29
+ /// </remarks>
30
+ class PurchaseContextPayload {
31
+
32
+ /// <summary>
33
+ /// The name of the payload.
34
+ /// </summary>
35
+ const Name = "Onescan.PurchaseContext";
36
+
37
+ /// <summary>
38
+ /// The delivery address that the user has chosen, if any.
39
+ /// </summary>
40
+ public $DeliveryAddress;
41
+
42
+ /// <summary>
43
+ /// The type of payment method that the user has selected, if any.
44
+ /// </summary>
45
+ public $PaymentMethod;
46
+ }
47
+ ?>
lib/Onescan/purchase/onescan-PurchaseInclude.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ $purchasedir=dirname(__FILE__);
20
+ $coredir=str_replace("purchase","core",$purchasedir);
21
+
22
+ require_once($coredir . "/onescan-Onescan.php");
23
+ require_once($coredir . "/onescan-GUID.php");
24
+ require_once($coredir . "/onescan-Settings.php");
25
+ require_once($coredir . "/onescan-Process.php");
26
+
27
+ //Include all php files in the onescan/purchase directory except this one
28
+ $filenames=scandir($purchasedir);
29
+ foreach($filenames as $filename) {
30
+ if(substr(strtolower($filename),-3)=="php" && $filename!=basename(__FILE__)) {
31
+ require_once($purchasedir . "/" . $filename);
32
+ }
33
+ }
34
+ ?>
lib/Onescan/purchase/onescan-PurchasePayload.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class PurchasePayload extends CorePurchaseInfo {
20
+
21
+ public $ImageData;
22
+ public $MerchantLogo;
23
+ }
24
+ ?>
lib/Onescan/purchase/onescan-PurchaseProcess.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class OnescanPurchaseProcess extends OnescanProcess
20
+ {
21
+ /// <summary>
22
+ /// The name of the process.
23
+ /// </summary>
24
+ public static $CONST_PAYMENT_PROCESS_TYPE = "payment";
25
+
26
+ /// <summary>
27
+ /// The current session state.
28
+ /// </summary>
29
+ private $sessionState;
30
+
31
+ /// <summary>
32
+ /// The message from onescan that we are processing.
33
+ /// </summary>
34
+ private $requestMessage;
35
+
36
+ /// <summary>
37
+ /// The message we are building as a response.
38
+ /// </summary>
39
+ private $responseMessage = NULL;
40
+
41
+ /// <summary>
42
+ /// Get or set the additional charges context payload
43
+ /// </summary>
44
+ public $AdditionalChargesContext;
45
+
46
+ /// <summary>
47
+ /// Get or set the purchase info
48
+ /// </summary>
49
+ public $PurchaseInfo;
50
+
51
+ /// <summary>
52
+ /// Get or set the payment confirmation payload.
53
+ /// </summary>
54
+ public $PaymentConfirmation;
55
+
56
+ /// <summary>
57
+ /// Get or set the next action to perform
58
+ /// </summary>
59
+ public $NextAction;
60
+
61
+ /// <summary>
62
+ /// Return the session state.
63
+ /// </summary>
64
+ public function SessionState()
65
+ {
66
+ return $this->sessionState;
67
+ }
68
+
69
+ /// <summary>
70
+ /// Get the process ID
71
+ /// </summary>
72
+ public function ProcessId()
73
+ {
74
+ return $this->requestMessage->ProcessId;
75
+ }
76
+
77
+
78
+ /// <summary>
79
+ /// Add any process specific payload and configuration.
80
+ /// </summary>
81
+ public function AddProcessPayload($settings, $message)
82
+ {
83
+ parent::AddProcessPayload($settings, $message);
84
+
85
+ // Define this process type, we are doing payment here
86
+ $message->ProcessType = "payment";
87
+
88
+ }
89
+
90
+ /// <summary>
91
+ /// Encode the outcome of this process.
92
+ /// </summary>
93
+ public function EncodeOutcome()
94
+ {
95
+ return $this->responseMessage;
96
+ }
97
+
98
+ /// <summary>
99
+ /// From the request message, decode the session state.
100
+ /// </summary>
101
+ protected function DecodeSessionState($requestMessage)
102
+ {
103
+ $this->DecodeUserToken($requestMessage);
104
+ $this->sessionState = $requestMessage->FindPayloadAs("partnerNamespace.sessionID");
105
+ }
106
+
107
+ /// <summary>
108
+ /// Decode the payment confirmed payload.
109
+ /// </summary>
110
+ public function DecodePaymentConfirmed( $requestMessage ) {
111
+ $this->PaymentConfirmation = $requestMessage->FindPayloadAs(ConfirmPaymentPayload::Name);
112
+ }
113
+
114
+ /// <summary>
115
+ /// Decode the purchase message.
116
+ /// </summary>
117
+ public function DecodePurchaseMessage($requestMessage)
118
+ {
119
+ $this->requestMessage = $requestMessage;
120
+ $this->DecodeSessionState($requestMessage);
121
+ switch ($requestMessage->MessageType)
122
+ {
123
+ case "StartPayment":
124
+ $this->NextAction = PurchaseAction::StartPayment;
125
+ break;
126
+
127
+ case "AdditionalCharges" :
128
+ $this->NextAction = PurchaseAction::AdditionalCharges;
129
+ break;
130
+
131
+ case "PaymentConfirmed":
132
+ $this->NextAction = PurchaseAction::PaymentConfirmed;
133
+ break;
134
+
135
+ case "PaymentCancelled":
136
+ $this->NextAction = PurchaseAction::PaymentCancelled;
137
+ break;
138
+
139
+ case "PaymentFailed":
140
+ $this->NextAction = PurchaseAction::PaymentFailed;
141
+ break;
142
+ }
143
+ return $this->NextAction;
144
+ }
145
+
146
+ /// <summary>
147
+ /// Decode the additional charges request.
148
+ /// </summary>
149
+ public function DecodeAdditionalChargesRequest($onescanMessage) {
150
+ $this->AdditionalChargesContext = $onescanMessage->FindPayloadAs(PurchaseContextPayload::Name);
151
+ $this->PurchaseInfo = $onescanMessage->FindPayloadAs(CorePurchaseInfo::Name);
152
+ }
153
+
154
+ /// <summary>
155
+ /// Handle the start purchase step of the process.
156
+ /// </summary>
157
+ public function ProcessStartPurchase($purchaseInfo)
158
+ {
159
+ if ($this->requestMessage->ProcessType != self::$CONST_PAYMENT_PROCESS_TYPE)
160
+ throw new Exception("Unexpected process type");
161
+
162
+ // we are expecting our session payload to be present
163
+ $sessionPayload = $this->requestMessage->FindPayloadAs("partnerNamespace.sessionID");
164
+ if ($sessionPayload==NULL)
165
+ throw new Exception("Missing session payload");
166
+
167
+ $responseMessage = new OneScanMessage();
168
+ $responseMessage->ProcessType = self::$CONST_PAYMENT_PROCESS_TYPE;
169
+ $responseMessage->MessageType = $this->requestMessage->MessageType;
170
+ $responseMessage->ProcessId = $this->requestMessage->ProcessId;
171
+
172
+ // this is the actual information detailing the purchase for this merchant
173
+ $messagePayload = $responseMessage->AddNewPayloadItem();
174
+ $messagePayload->JsonPayload = json_encode($purchaseInfo);
175
+ $messagePayload->PayloadName = CorePurchaseInfo::Name;
176
+
177
+ $this->responseMessage = $responseMessage;
178
+ }
179
+
180
+ /// <summary>
181
+ /// Process the additional charges payload.
182
+ /// </summary>
183
+ public function ProcessAdditionalCharges($additionalChargesPayload) {
184
+ $responseMessage = new OnescanMessage();
185
+ $responseMessage->MessageType = "AdditionalCharges";
186
+ $responseMessage->ProcessId = $this->requestMessage->ProcessId;
187
+ $responseMessage->ProcessType = self::$CONST_PAYMENT_PROCESS_TYPE;
188
+
189
+ $payload = $responseMessage->AddNewPayloadItem();
190
+ $payload->JsonPayload = json_encode($additionalChargesPayload);
191
+ $payload->PayloadName = AdditionalChargesPayload::Name;
192
+
193
+ $this->responseMessage = $responseMessage;
194
+ }
195
+
196
+ /// <summary>
197
+ /// Process the payment confirmed message when we want to accept the order.
198
+ /// </summary>
199
+ public function ProcessPaymentConfirmed($orderAccepted, $outcome = NULL)
200
+ {
201
+ $this->responseMessage = new OneScanMessage();
202
+ $this->responseMessage->ProcessType = self::$CONST_PAYMENT_PROCESS_TYPE;
203
+ $this->responseMessage->MessageType = "OrderAccepted";
204
+ $this->responseMessage->ProcessId = $this->requestMessage->ProcessId;
205
+
206
+ $messagePayload = $this->responseMessage->AddNewPayloadItem();
207
+ $messagePayload->JsonPayload = json_encode($outcome);
208
+ $messagePayload->PayloadName = ProcessOutcome::Name;
209
+
210
+ $confirmPayload = $this->responseMessage->AddNewPayloadItem();
211
+ $confirmPayload->JsonPayload = json_encode($orderAccepted);
212
+ $confirmPayload->PayloadName = OrderAcceptedPayload::Name;
213
+
214
+ $this->InternalAddOutcome($outcome);
215
+
216
+ return $this->responseMessage;
217
+ }
218
+
219
+ /// <summary>
220
+ /// Add the outcome.
221
+ /// </summary>
222
+ private function InternalAddOutcome($outcome)
223
+ {
224
+ $outcome = ($outcome == NULL) ? new ProcessOutcome() : $outcome;
225
+ $messagePayload = $this->responseMessage->AddNewPayloadItem();
226
+ $messagePayload->JsonPayload = json_encode($outcome);
227
+ $messagePayload->PayloadName = ProcessOutcome::Name;
228
+ }
229
+
230
+ /// <summary>
231
+ /// Process the outcome.
232
+ /// </summary>
233
+ private function InternalProcessOutcome($outcome)
234
+ {
235
+ $this->responseMessage = new OneScanMessage();
236
+ $this->responseMessage->ProcessType = self::$CONST_PAYMENT_PROCESS_TYPE;
237
+ $this->responseMessage->MessageType = $this->requestMessage->MessageType;
238
+ $this->responseMessage->ProcessId = $this->requestMessage->ProcessId;
239
+ $this->InternalAddOutcome($outcome);
240
+ }
241
+
242
+ /// <summary>
243
+ /// Process payment cancelled.
244
+ /// </summary>
245
+ public function ProcessPaymentCancelled($outcome = NULL)
246
+ {
247
+ $this->InternalProcessOutcome($outcome);
248
+ }
249
+
250
+ /// <summary>
251
+ /// Process payment failed.
252
+ /// </summary>
253
+ public function ProcessPaymentFailed($outcome = NULL)
254
+ {
255
+ $this->InternalProcessOutcome($outcome);
256
+ }
257
+ }
258
+
259
+
260
+ ?>
lib/Onescan/purchase/onescan-PurchaseSettings.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ /// <summary>
20
+ /// Extension to the basic settings with any additional purchase settings.
21
+ /// </summary>
22
+ class OnescanPurchaseSettings extends OnescanSettings {
23
+ }
24
+ ?>
lib/Onescan/purchase/onescan-UserAddress.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Ensygnia Onescan extension
4
+ Copyright (C) 2014 Ensygnia Ltd
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ class UserAddress {
20
+
21
+ public $AddressId;
22
+ public $AddressLine1;
23
+ public $AddressLine2;
24
+ public $Town;
25
+ public $County;
26
+ public $Postcode;
27
+ public $Country;
28
+ }
29
+ ?>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ensygnia_Onescan</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://www.gnu.org/licenses/gpl.html">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Ensygnia's Onescan payment plugin allows online market shops to accept mobile payments in just one scan. Visitors no longer have to complete long registration forms or jump through security hoops in a long checkout process. Using their mobile phone, all customers have to do is scan our Onescan padlock using our Onescan app at checkout. With one scan of a padlock and in under 10 seconds payment is securely completed.</summary>
10
+ <description>The Onescan payment plugin brings speed and security to the Magento platform, allowing customers to register, login or even purchase, with just one scan from their mobile phone.&#xD;
11
+ &#xD;
12
+ No usernames and passwords to remember, no security checks to pass, or tiresome forms to fill.&#xD;
13
+ &#xD;
14
+ All while improving the security of your site. And the burden of dealing with sensitive financial information is lifted. Payments are confirmed by a tokenised system: at no point do the details need to be shared.&#xD;
15
+ &#xD;
16
+ Thanks to Onescan, mobile phones become a secure proof of identity. Online, all customers have to do to login, register or even purchase an item is complete one simple scan. We take all the hassle out of online shopping and tear down the barriers between you and your customers.</description>
17
+ <notes>Version 1 of the Ensygnia Onescan extension.</notes>
18
+ <authors><author><name>Ensygnia</name><user>MAG002660123</user><email>paul.newson@ensygnia.com</email></author></authors>
19
+ <date>2014-10-31</date>
20
+ <time>12:17:01</time>
21
+ <contents><target name="magelocal"><dir name="Ensygnia"><dir name="Onescan"><dir name="Block"><file name="Abstract.php" hash="4488b86743ac3cd970d52a4dc857c4d6"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Cta.php" hash="433c964de85d708af211461033f7a5fc"/></dir></dir></dir><file name="Basket.php" hash="438f95ad093d4b5cde252eb4a8661035"/><file name="Login.php" hash="099ce7a3c3b483e0e509357949d0056d"/><file name="Logo.php" hash="fd58bed8012207372450577b137781ea"/><file name="Register.php" hash="a3ce5e2b5d4cb627f23a6d52dc3f5db9"/><dir name="Widget"><file name="Basket.php" hash="95fad0d733885b0c4651d7e41bc0039c"/><file name="Login.php" hash="225660cace8fc351da454b49d887e124"/><file name="Register.php" hash="89a1492f818fc787cdde4f1adc29702b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="3fcf293e50ba489a07fadb6454f77c81"/></dir><dir name="Model"><dir name="Callback"><file name="Abstract.php" hash="31b73999f34ffd0f7e539d9ed6499cce"/><file name="Login.php" hash="94f1d610a7c56a95e10694b58e84de31"/><file name="Purchase.php" hash="e055b00e0eb17543700e49e6743a72f6"/><file name="Registration.php" hash="24fed90927c3a6b72c1503c2e94bce67"/></dir><dir name="Config"><file name="Abstract.php" hash="9e407f490c53651e5fe6b19c92cb5c1a"/><file name="Login.php" hash="6fbec423b7b3c6d72fa6e3b519163cd8"/><file name="Purchase.php" hash="0bd21ab4d83b48a31aa9003b473ed6db"/><file name="Registration.php" hash="4c39c0ee7690abc16c0519d3c950c5cb"/></dir><file name="Logintokens.php" hash="1a61be2e17f8ef9562cc205d525a473c"/><dir name="Method"><file name="Onescan.php" hash="1fe0e5435e3e8d5a04782f16df98a33a"/></dir><dir name="Resource"><dir name="Logintokens"><file name="Collection.php" hash="3767dcf1cbe12088186664ef7d1be309"/></dir><file name="Logintokens.php" hash="4f0fd6b83ee508a382a442641a357e31"/><dir name="Sessiondata"><file name="Collection.php" hash="0b62795cd0f7f7b6dba3ecf07599a9f6"/></dir><file name="Sessiondata.php" hash="48c60528f7accbf52da25030a7681fc0"/><file name="Setup.php" hash="e09e39a39405ebd80af368fefa013839"/></dir><file name="Sessiondata.php" hash="f5f6c2f7ea7fc3c6f033d5a5ff3b1666"/></dir><dir name="controllers"><file name="CallbackController.php" hash="dbbaebed3d7f7aa4e1431d22e2f6a541"/><file name="IndexController.php" hash="37d200f846305bed89a853d41e8f2c55"/></dir><dir name="etc"><file name="adminhtml.xml" hash="87b27e9403e9d38cf849a8516d83c7e5"/><file name="config.xml" hash="6d9312cb44b108c4111901140d3d31a9"/><file name="system.xml" hash="55ace4f8c5d677fd6a3531f6ad38d775"/><file name="widget.xml" hash="5c078e20e1698f285b3ad987477a0242"/></dir><file name="license.txt" hash="f075d971a6aa12e3ae52489ef961a7f5"/><dir name="sql"><dir name="onescan_setup"><file name="install-1.0.0.php" hash="5e0c3bc48f935bf61b98bfc245585df8"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="layout" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir name="template"><dir name="onescan"><dir name="system"><dir name="config"><file name="cta.phtml" hash="c99b3ce3333dbff286f2156a031f5401"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><file name="layout" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir name="template"><dir name="onescan"><file name="basket.phtml" hash="c6b51ae4a94fdaef74d8c49ef128ceab"/><file name="login.phtml" hash="06e2ba3a1101b46050a65553cf5b2758"/><file name="logo.phtml" hash="29e5cb387d8e2aaf676040a2c25b9596"/><file name="register.phtml" hash="17749f596a966ec18933d0c779b8b56b"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="."><file name="modules" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target><target name="magelib"><dir name="Onescan"><dir name="core"><file name="onescan-Exceptions.php" hash="1733a8f40cdc6fbb7a2c77890f0fd197"/><file name="onescan-GUID.php" hash="732799426a921038f30f1485f5cd7264"/><file name="onescan-HMAC.php" hash="797d68c8879ee9574dcb06770947d19b"/><file name="onescan-HTTPClient.php" hash="59eee1d07c3796ad24126c0c85b35086"/><file name="onescan-Login.php" hash="deaf58a3c6c9bc30a0acc4f10d64ade0"/><file name="onescan-Message.php" hash="f978243be9032897fcf1a288a23ce837"/><file name="onescan-Onescan.php" hash="93120300b4add29f3cd44709d8cc32d6"/><file name="onescan-Process.php" hash="86d8ccd62a5261d86ae7c35a099b5c1f"/><file name="onescan-Session.php" hash="a365d6c0fc9d41f603e88384b0c15fea"/><file name="onescan-SessionState.php" hash="a0b3b8d6d8d433551340ede175d094cc"/><file name="onescan-Settings.php" hash="2c62dcbb810b2d1d02f5773db9184408"/></dir><dir name="login"><file name="LocalDataFactory.php" hash="a49582171443ca73b292317e2128e9ac"/><file name="onescan-LoginProcess.php" hash="c3552a34b51e879c535d7b67d541e0fd"/></dir><dir name="purchase"><file name="onescan-AdditionalChargesPayload.php" hash="cb1f2d49d560e1b46b866dffda932111"/><file name="onescan-CardInformation.php" hash="6c2fd7227533dfe986d93bd8bfeb4c1e"/><file name="onescan-CardType.php" hash="8e7765420c6a0de517949393b7360818"/><file name="onescan-Charge.php" hash="285cc0b1f0708f3a3dbc503447b7c0bd"/><file name="onescan-ConfirmPaymentPayload.php" hash="7eda3538cd471c41976732d462a2d84e"/><file name="onescan-CorePurchaseInfo.php" hash="08d943667c901189edaf8dc22406b7d8"/><file name="onescan-DeliveryOption.php" hash="8580b35f993b668c153b6488a9572bd4"/><file name="onescan-OrderAcceptedPayload.php" hash="c007ac8a0a78e51f516f9456d47c0129"/><file name="onescan-OrderDeclinedPayload.php" hash="1cfd9499b9cb167435a33766a5822909"/><file name="onescan-PaymentMethodCharge.php" hash="35f576d4ba1965a5ffc1155d28ba2ceb"/><file name="onescan-PaymentMethodInformation.php" hash="9c332bf6aa9395ec484a13a771101f94"/><file name="onescan-PaymentMethodType.php" hash="df5296173d5a34e55a425810072192dd"/><file name="onescan-PaymentOptins.php" hash="da07521ee0d52657a776ea8ecb705ac0"/><file name="onescan-PurchaseAction.php" hash="ca494c86fe5548b93ba2876a4e3b7aad"/><file name="onescan-PurchaseCharges.php" hash="1b67b353045ea1f93a7b18d2c1940b94"/><file name="onescan-PurchaseContextPayload.php" hash="0bdf109a37bd5104660d13ee3ea42d42"/><file name="onescan-PurchaseInclude.php" hash="a52385a7ceb5f056367a40eaff2a2d32"/><file name="onescan-PurchasePayload.php" hash="0970da6cfc0907c268218501d24f08d1"/><file name="onescan-PurchaseProcess.php" hash="1e9046c659315532197c05d8259d6686"/><file name="onescan-PurchaseSettings.php" hash="f3c3d6776d5da8a616eb417a9728fe61"/><file name="onescan-UserAddress.php" hash="4e1ec23d74d6f192a1edb31f3e3c9c8e"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="onescan"><dir name="css"><file name="onescan.css" hash="1f758b313e54a8782fcc96e34423caf5"/></dir><dir name="images"><file name="Thumbs.db" hash="b549b3ffcbba28977308023c089a780a"/><file name="logo-sml.png" hash="af6d80c8d752b68ffff5d2cedd60319f"/><file name="logo.png" hash="ad10933575eaa2f9e379c0aad2ac038e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><file name="css" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="images" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="js" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.2.13</min><max>5.6.1</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.0</min><max>1.9.0.1</max></package></required></dependencies>
24
+ </package>
skin/adminhtml/default/default/onescan/css/onescan.css ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Ensygnia Onescan extension
3
+ Copyright (C) 2014 Ensygnia Ltd
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ ul.tabs a.onescan-section {
19
+ min-height: 39px;
20
+ background: transparent url('../images/logo-sml.png') no-repeat 15px center;
21
+ text-indent: -9999px;
22
+ }
23
+
24
+ ul.tabs a.onescan-section.active {
25
+ background-color: white;
26
+ }
27
+
28
+ ul.tabs a.onescan-section.active:hover {
29
+ background-color: #eee;
30
+ }
31
+
32
+ ul.tabs a.onescan-section.active span {
33
+ background-color: transparent;
34
+ }
35
+
36
+ h3.onescan-header {
37
+ width: 185px;
38
+ height: 70px;
39
+ background: transparent url("../images/logo.png") no-repeat 0 0 ;
40
+ text-indent: -9999px;
41
+ }
42
+
43
+ .onescan-notice {
44
+ background: #EAF0EE;
45
+ border: 1px solid #CCCCCC;
46
+ margin-bottom: 10px;
47
+ padding: 12px;
48
+ }
49
+
50
+ .onescan-notice h4 {
51
+ margin: 0;
52
+ }
skin/adminhtml/default/default/onescan/images/Thumbs.db ADDED
Binary file
skin/adminhtml/default/default/onescan/images/logo-sml.png ADDED
Binary file
skin/adminhtml/default/default/onescan/images/logo.png ADDED
Binary file