EPOSTIDENT - Version 13.02.28

Version Notes

Initial release

Download this release

Release Info

Developer Mario Behrendt
Extension EPOSTIDENT
Version 13.02.28
Comparing to
See all releases


Version 13.02.28

Files changed (91) hide show
  1. app/code/community/DeutschePost/Postident/Block/Adminhtml/Customer/Edit/Tab/Verificationdata.php +90 -0
  2. app/code/community/DeutschePost/Postident/Block/Adminhtml/System/Config/Checkconnect/Button.php +47 -0
  3. app/code/community/DeutschePost/Postident/Block/Adminhtml/System/Config/Domainuri/Notice.php +42 -0
  4. app/code/community/DeutschePost/Postident/Block/Adminhtml/System/Config/Gateway/Notice.php +40 -0
  5. app/code/community/DeutschePost/Postident/Block/Checkout/Abstract.php +45 -0
  6. app/code/community/DeutschePost/Postident/Block/Checkout/Address.php +19 -0
  7. app/code/community/DeutschePost/Postident/Block/Checkout/Cart/Link.php +39 -0
  8. app/code/community/DeutschePost/Postident/Block/Checkout/Onepage/Billing.php +32 -0
  9. app/code/community/DeutschePost/Postident/Block/Checkout/Onepage/Shipping.php +32 -0
  10. app/code/community/DeutschePost/Postident/Helper/Client.php +98 -0
  11. app/code/community/DeutschePost/Postident/Helper/Client/Exception.php +21 -0
  12. app/code/community/DeutschePost/Postident/Helper/Data.php +209 -0
  13. app/code/community/DeutschePost/Postident/Model/Client.php +146 -0
  14. app/code/community/DeutschePost/Postident/Model/Client/Exception.php +88 -0
  15. app/code/community/DeutschePost/Postident/Model/Client/Http.php +188 -0
  16. app/code/community/DeutschePost/Postident/Model/Client/Response/Exception.php +76 -0
  17. app/code/community/DeutschePost/Postident/Model/Config.php +198 -0
  18. app/code/community/DeutschePost/Postident/Model/Entity/Attribute/Source/Productminage.php +65 -0
  19. app/code/community/DeutschePost/Postident/Model/IdCard/Abstract.php +46 -0
  20. app/code/community/DeutschePost/Postident/Model/IdCard/IdCard10.php +38 -0
  21. app/code/community/DeutschePost/Postident/Model/IdCard/IdCard120.php +40 -0
  22. app/code/community/DeutschePost/Postident/Model/IdCard/IdCard130.php +38 -0
  23. app/code/community/DeutschePost/Postident/Model/IdCard/IdCard1304.php +24 -0
  24. app/code/community/DeutschePost/Postident/Model/IdCard/IdCard40.php +31 -0
  25. app/code/community/DeutschePost/Postident/Model/Observer.php +182 -0
  26. app/code/community/DeutschePost/Postident/Model/System/Config/Clientid.php +55 -0
  27. app/code/community/DeutschePost/Postident/Model/System/Config/Source/Idcards.php +37 -0
  28. app/code/community/DeutschePost/Postident/Model/System/Config/Source/Verificationtype.php +43 -0
  29. app/code/community/DeutschePost/Postident/Model/Verification.php +271 -0
  30. app/code/community/DeutschePost/Postident/Model/Verification/Exception.php +19 -0
  31. app/code/community/DeutschePost/Postident/Test/Controller/Adminhtml/AbstractControllerTest.php +75 -0
  32. app/code/community/DeutschePost/Postident/Test/Controller/Adminhtml/ConfigControllerTest.php +114 -0
  33. app/code/community/DeutschePost/Postident/Test/Controller/Adminhtml/PermissionDeniedControllerTest.php +59 -0
  34. app/code/community/DeutschePost/Postident/Test/Controller/CartControllerTest.php +203 -0
  35. app/code/community/DeutschePost/Postident/Test/Helper/ClientTest.php +166 -0
  36. app/code/community/DeutschePost/Postident/Test/Helper/ClientTest/expectations/postidentQuoteVerificationData.yaml +3 -0
  37. app/code/community/DeutschePost/Postident/Test/Helper/ClientTest/expectations/redirectLink.yaml +1 -0
  38. app/code/community/DeutschePost/Postident/Test/Helper/DataTest.php +161 -0
  39. app/code/community/DeutschePost/Postident/Test/Helper/DataTest/fixtures/product.yaml +14 -0
  40. app/code/community/DeutschePost/Postident/Test/Helper/DataTest/fixtures/quotes.yaml +80 -0
  41. app/code/community/DeutschePost/Postident/Test/Model/Client/ExceptionTest.php +41 -0
  42. app/code/community/DeutschePost/Postident/Test/Model/Client/HttpTest.php +212 -0
  43. app/code/community/DeutschePost/Postident/Test/Model/Client/Response/ExceptionTest.php +41 -0
  44. app/code/community/DeutschePost/Postident/Test/Model/ClientTest.php +193 -0
  45. app/code/community/DeutschePost/Postident/Test/Model/ConfigTest.php +222 -0
  46. app/code/community/DeutschePost/Postident/Test/Model/IdCard/AbstractTest.php +93 -0
  47. app/code/community/DeutschePost/Postident/Test/Model/ObserverTest.php +177 -0
  48. app/code/community/DeutschePost/Postident/Test/Model/ObserverTest/fixtures/orders.yaml +12 -0
  49. app/code/community/DeutschePost/Postident/Test/Model/ObserverTest/fixtures/quotes.yaml +102 -0
  50. app/code/community/DeutschePost/Postident/Test/Model/System/Config/ClientidTest.php +103 -0
  51. app/code/community/DeutschePost/Postident/Test/Model/System/Config/Source/IdcardsTest.php +44 -0
  52. app/code/community/DeutschePost/Postident/Test/Model/System/Config/Source/VerificationtypeTest.php +44 -0
  53. app/code/community/DeutschePost/Postident/Test/Model/VerificationTest.php +665 -0
  54. app/code/community/DeutschePost/Postident/Test/Model/VerificationTest/expectations/customer.yaml +1 -0
  55. app/code/community/DeutschePost/Postident/Test/Model/VerificationTest/expectations/quotes.yaml +1 -0
  56. app/code/community/DeutschePost/Postident/Test/Model/VerificationTest/fixtures/customer.yaml +14 -0
  57. app/code/community/DeutschePost/Postident/Test/Model/VerificationTest/fixtures/quotes.yaml +9 -0
  58. app/code/community/DeutschePost/Postident/controllers/Adminhtml/ConfigController.php +66 -0
  59. app/code/community/DeutschePost/Postident/controllers/CartController.php +102 -0
  60. app/code/community/DeutschePost/Postident/etc/adminhtml.xml +32 -0
  61. app/code/community/DeutschePost/Postident/etc/config.xml +208 -0
  62. app/code/community/DeutschePost/Postident/etc/system.xml +252 -0
  63. app/code/community/DeutschePost/Postident/sql/postident_setup/mysql4-install-12.11.14.php +69 -0
  64. app/design/adminhtml/default/default/layout/postident.xml +32 -0
  65. app/design/adminhtml/default/default/template/postident/customer/verificationdata.phtml +28 -0
  66. app/design/adminhtml/default/default/template/postident/system/config/domainuri/notice.phtml +12 -0
  67. app/design/adminhtml/default/default/template/postident/system/config/gateway/notice.phtml +5 -0
  68. app/design/adminhtml/default/default/template/postident/validate.phtml +7 -0
  69. app/design/frontend/base/default/layout/postident.xml +100 -0
  70. app/design/frontend/base/default/template/postident/checkout/address.phtml +83 -0
  71. app/design/frontend/base/default/template/postident/checkout/cart/link.phtml +43 -0
  72. app/design/frontend/base/default/template/postident/checkout/onepage/billing.phtml +46 -0
  73. app/design/frontend/base/default/template/postident/checkout/onepage/shipping.phtml +46 -0
  74. app/etc/modules/DeutschePost_Postident.xml +30 -0
  75. app/locale/de_DE/DeutschePost_Postident.csv +93 -0
  76. js/postident/adminhtml/checkconnect.js +23 -0
  77. js/postident/adminhtml/validation.js +11 -0
  78. js/postident/checkout/addressdata.js +218 -0
  79. package.xml +22 -0
  80. skin/frontend/base/default/css/postident.css +70 -0
  81. skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_Mouse-over.png +0 -0
  82. skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_Mouse-over_160.png +0 -0
  83. skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_aktiv.png +0 -0
  84. skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_aktiv_160.png +0 -0
  85. skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_inaktiv.png +0 -0
  86. skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_inaktiv_160.png +0 -0
  87. skin/frontend/base/default/images/postident/identifikation_short/Button_Identifikation_Mouse-over.png +0 -0
  88. skin/frontend/base/default/images/postident/identifikation_short/Button_Identifikation_aktiv.png +0 -0
  89. skin/frontend/base/default/images/postident/identifikation_short/Identifikation_inaktiv.png +0 -0
  90. skin/frontend/base/default/images/postident/produktzeichen/DP_E-POSTIDENT_Produktzeichen.png +0 -0
  91. skin/frontend/base/default/images/postident/produktzeichen/DP_E-POSTIDENT_Produktzeichen_160.png +0 -0
app/code/community/DeutschePost/Postident/Block/Adminhtml/Customer/Edit/Tab/Verificationdata.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Adminhtml_Customer_Edit_Tab_Verificationdata
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+
18
+ */
19
+ class DeutschePost_Postident_Block_Adminhtml_Customer_Edit_Tab_Verificationdata
20
+ extends Mage_Adminhtml_Block_Template
21
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
22
+ {
23
+
24
+ public function __construct()
25
+ {
26
+ parent::__construct();
27
+ $this->setTemplate('postident/customer/verificationdata.phtml');
28
+ }
29
+
30
+ /**
31
+ * Return Tab label
32
+ *
33
+ * @return string
34
+ */
35
+ public function getTabLabel()
36
+ {
37
+ return Mage::helper('postident')->__('E-POSTIDENT Data');
38
+ }
39
+
40
+ /**
41
+ * Return Tab label
42
+ *
43
+ * @return string
44
+ */
45
+ public function getTabTitle()
46
+ {
47
+ return Mage::helper('postident')->__('Verificationdata');
48
+ }
49
+
50
+ /**
51
+ * Can show tab in tabs
52
+ *
53
+ * @return boolean
54
+ */
55
+ public function canShowTab()
56
+ {
57
+ $customer = Mage::registry('current_customer');
58
+ return (bool)$customer->getId();
59
+ }
60
+
61
+ /**
62
+ * Tab is hidden
63
+ *
64
+ * @return boolean
65
+ */
66
+ public function isHidden()
67
+ {
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * Defines after which tab, this tab should be rendered
73
+ *
74
+ * @return string
75
+ */
76
+ public function getAfter()
77
+ {
78
+ return 'orders';
79
+ }
80
+
81
+ /**
82
+ * Get unserialized postident verification data
83
+ *
84
+ * @return array
85
+ */
86
+ public function getPostidentVerificationData()
87
+ {
88
+ return unserialize(Mage::registry('current_customer')->getPostidentVerificationData());
89
+ }
90
+ }
app/code/community/DeutschePost/Postident/Block/Adminhtml/System/Config/Checkconnect/Button.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Adminhtml_System_Config_Checkconnect_Button
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ class DeutschePost_Postident_Block_Adminhtml_System_Config_Checkconnect_Button
20
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
21
+ {
22
+
23
+ /**
24
+ * add button block to the rendered html
25
+ *
26
+ * @param Varien_Data_Form_Element_Abstract $element
27
+ * @return string
28
+ */
29
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
30
+ {
31
+ $this->setElement($element);
32
+ $url = Mage::helper('adminhtml')->getUrl(
33
+ 'postident/adminhtml_config/checkConnect',
34
+ array('domainUri' => Mage::helper('postident')->getDomainUri())
35
+ );
36
+ $url = rtrim($url,'/');
37
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
38
+ ->setType('button')
39
+ ->setClass('scalable')
40
+ ->setLabel('Check Connect')
41
+ ->setOnClick("sentCheckConnectRequest('{$url}')")
42
+ ->toHtml();
43
+
44
+ return $html;
45
+ }
46
+ }
47
+ ?>
app/code/community/DeutschePost/Postident/Block/Adminhtml/System/Config/Domainuri/Notice.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Adminhtml_System_Config_Domainuri_Notice
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Block_Adminhtml_System_Config_Domainuri_Notice extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
19
+ {
20
+ /**
21
+ * Custom template
22
+ *
23
+ * @var string
24
+ */
25
+ protected $_template = 'postident/system/config/domainuri/notice.phtml';
26
+
27
+ /**
28
+ * Render fieldset html
29
+ *
30
+ * @param Varien_Data_Form_Element_Abstract $fieldset
31
+ * @return string
32
+ */
33
+ public function render(Varien_Data_Form_Element_Abstract $fieldset)
34
+ {
35
+ $originalData = $fieldset->getOriginalData();
36
+ $this->addData(array(
37
+ 'fieldset_label' => $fieldset->getLegend(),
38
+ 'fieldset_help_url' => isset($originalData['help_url']) ?
39
+ $originalData['help_url'] : ''));
40
+ return $this->toHtml();
41
+ }
42
+ }
app/code/community/DeutschePost/Postident/Block/Adminhtml/System/Config/Gateway/Notice.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Adminhtml_System_Config_Gateway_Notice
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Block_Adminhtml_System_Config_Gateway_Notice extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
19
+ {
20
+ /**
21
+ * Custom template
22
+ *
23
+ * @var string
24
+ */
25
+ protected $_template = 'postident/system/config/gateway/notice.phtml';
26
+
27
+ /**
28
+ * Render fieldset html
29
+ *
30
+ * @param Varien_Data_Form_Element_Abstract $fieldset
31
+ * @return string
32
+ */
33
+ public function render(Varien_Data_Form_Element_Abstract $fieldset)
34
+ {
35
+ $originalData = $fieldset->getOriginalData();
36
+ $this->addData(array(
37
+ 'fieldset_label' => $fieldset->getLegend()));
38
+ return $this->toHtml();
39
+ }
40
+ }
app/code/community/DeutschePost/Postident/Block/Checkout/Abstract.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Checkout_Abstract
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Block_Checkout_Abstract extends Mage_Core_Block_Template
19
+ {
20
+ /**
21
+ * get postident data from quote or customer
22
+ *
23
+ *
24
+ * @return array
25
+ */
26
+ public function getPostidentData()
27
+ {
28
+ $postidentData = Mage::getModel('postident/verification')->getPostidentVerificationData();
29
+ $dateString = $postidentData['identData']['dateofbirth'];
30
+ $postidentData['identData']['dateofbirth'] = strtok($dateString," ");
31
+ unset($postidentData['identData']['verification_date']);
32
+ return $postidentData['identData'];
33
+ }
34
+
35
+ /**
36
+ * get postident data from quote or customer
37
+ * and return it as Json
38
+ *
39
+ * @return string
40
+ */
41
+ public function getPostidentDataAsJson()
42
+ {
43
+ return Mage::helper('core')->jsonEncode($this->getPostidentData());
44
+ }
45
+ }
app/code/community/DeutschePost/Postident/Block/Checkout/Address.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Checkout_Address
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Block_Checkout_Address extends DeutschePost_Postident_Block_Checkout_Abstract
19
+ { }
app/code/community/DeutschePost/Postident/Block/Checkout/Cart/Link.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Checkout_Cart_Link
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Block_Checkout_Cart_Link extends Mage_Core_Block_Template
19
+ {
20
+ /**
21
+ * gets the redirect link from model and passing it to template
22
+ *
23
+ * @return string
24
+ */
25
+ public function getPostidentLink()
26
+ {
27
+ return Mage::helper('postident/client')->buildRedirectLink();
28
+ }
29
+
30
+ /**
31
+ * gets the selected id_card from condig model and passing it to template
32
+ *
33
+ * @return string
34
+ */
35
+ public function getIdCard()
36
+ {
37
+ return Mage::getModel('postident/config')->getSelectedIdCard();
38
+ }
39
+ }
app/code/community/DeutschePost/Postident/Block/Checkout/Onepage/Billing.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Checkout_Onepage_Billing
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Block_Checkout_Onepage_Billing
19
+ extends DeutschePost_Postident_Block_Checkout_Abstract
20
+ {
21
+
22
+ /**
23
+ * Internal constructor, that is called from real constructor.
24
+ *
25
+ * @return void
26
+ */
27
+ protected function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->setTemplate('postident/checkout/onepage/billing.phtml');
31
+ }
32
+ }
app/code/community/DeutschePost/Postident/Block/Checkout/Onepage/Shipping.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Block_Checkout_Onepage_Shipping
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Block_Checkout_Onepage_Shipping
19
+ extends DeutschePost_Postident_Block_Checkout_Abstract
20
+ {
21
+
22
+ /**
23
+ * Internal constructor, that is called from real constructor.
24
+ *
25
+ * @return void
26
+ */
27
+ protected function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->setTemplate('postident/checkout/onepage/shipping.phtml');
31
+ }
32
+ }
app/code/community/DeutschePost/Postident/Helper/Client.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category DeutschePost Postident
5
+ * @package DeutschePost_Postident
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
8
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+
12
+ /**
13
+ * DeutschePost_Postident_Helper_Client
14
+ * @author André Herrn <andre.herrn@netresearch.de>
15
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
16
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+
19
+ */
20
+ class DeutschePost_Postident_Helper_Client extends Mage_Core_Helper_Abstract
21
+ {
22
+ /**
23
+ * Validate the redirect response from E-POSTIDENT
24
+ *
25
+ * Check if "code" and "state" - parameters were correctly set
26
+ *
27
+ * @param array $response
28
+ *
29
+ * @return void
30
+ */
31
+ public function validateRedirectResponse($response)
32
+ {
33
+ Mage::helper('postident')->logWebserviceResponse(
34
+ 'Postident-Redirect-Response',
35
+ $response);
36
+
37
+ if (is_null($response)
38
+ || false === array_key_exists('code', $response)
39
+ || false === array_key_exists('state', $response)
40
+ || (true === array_key_exists('state', $response) && true === is_null($response['state']))
41
+ || (true === array_key_exists('code', $response) && true === is_null($response['code'])))
42
+ {
43
+ throw new DeutschePost_Postident_Helper_Client_Exception(
44
+ "Response is Null or parameter 'code' or 'state' doesn't exist");
45
+ }
46
+
47
+ if ((int) $response['state'] != (int) Mage::helper('postident')->getQuote()->getId())
48
+ {
49
+ throw new DeutschePost_Postident_Helper_Client_Exception(sprintf(
50
+ "Response-Quote_Id = %s doesn't match Shop-Quote_Id = %s from session.",
51
+ $response['state'],
52
+ Mage::helper('postident')->getQuote()->getId()
53
+ ));
54
+ }
55
+ }
56
+
57
+ /**
58
+ * build the redirect link
59
+ *
60
+ * @return string
61
+ */
62
+ public function buildRedirectLink()
63
+ {
64
+ $helper = Mage::helper('postident/data');
65
+ $redirect = Mage::getModel('postident/config')->getPostidentUrl();
66
+ $urlParams = array(
67
+ 'client_id' => Mage::getModel('postident/config')->getClientId(),
68
+ 'redirect_uri' => Mage::getUrl('postident/cart/back/', array('_secure' => true, '_nosid' => true)),
69
+ 'scope' => Mage::getModel('postident/config')->getSelectedIdCard(),
70
+ 'reason' => urlencode($helper->__('Your online purchase at %s.', $helper->getStoreName())),
71
+ 'response_type' => 'code',
72
+ 'state' => $helper->getQuote()->getId()
73
+ );
74
+ //Log
75
+ $helper->logWebserviceRequest(
76
+ "E-POSTIDENT-Request Link generation",
77
+ $redirect,
78
+ http_build_query($urlParams)
79
+ );
80
+ return $redirect . '?' . http_build_query($urlParams);
81
+ }
82
+
83
+ /**
84
+ * add verificatrion data to identdata xml
85
+ * transform to array and save it on quote
86
+ *
87
+ * @param SimpleXMLObject $identDataXml
88
+ * @return void
89
+ */
90
+ public function saveIdentDataToQuote($identDataXml)
91
+ {
92
+ $identDataXml->addChild('verification_date',
93
+ Mage::getModel('core/date')->date("Y-m-d H:i:s")
94
+ );
95
+ $identDataArray = json_decode(json_encode($identDataXml), 1);
96
+ Mage::getModel('postident/verification')->setPostidentVerificationDataToQuote($identDataArray);
97
+ }
98
+ }
app/code/community/DeutschePost/Postident/Helper/Client/Exception.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Helper_Client_Exception
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Helper_Client_Exception extends Exception
19
+ {
20
+
21
+ }
app/code/community/DeutschePost/Postident/Helper/Data.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+ /**
4
+ * @category DeutschePost Postident
5
+ * @package DeutschePost_Postident
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
8
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+
12
+ /**
13
+ * DeutschePost_Postident_Helper_Data
14
+ * @author André Herrn <andre.herrn@netresearch.de>
15
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
16
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+
19
+ */
20
+ class DeutschePost_Postident_Helper_Data extends Mage_Core_Helper_Abstract
21
+ {
22
+
23
+ /**
24
+ * log to a separate log file
25
+ *
26
+ * @param string $message
27
+ * @param int $level
28
+ * @param bool $force
29
+ * @return DeutschePost_Postident_Helper_Data
30
+ */
31
+ public function log($message, $level = null, $force = false)
32
+ {
33
+ if ($force || Mage::getModel('postident/config')->isLoggingEnabled()) {
34
+ Mage::log($message, $level, 'postident.log', $force);
35
+ }
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * log Webservice-Request
41
+ *
42
+ * @param string request-Call Title $callTitle
43
+ * @param string webservice-url $webserviceUrl
44
+ * @param array request-Values $request
45
+ *
46
+ * @return DeutschePost_Postident_Helper_Data
47
+ */
48
+ public function logWebserviceRequest($callTitle, $webserviceUrl, $request)
49
+ {
50
+ $message = sprintf(
51
+ "\n=====================\nRequest Call: %s\nWebservice-Gateway: %s\nRequest: %s\n=====================", $callTitle, $webserviceUrl, Zend_Json::encode($request)
52
+ );
53
+ return $this->log($message);
54
+ }
55
+
56
+ /**
57
+ * log Webservice-Response
58
+ *
59
+ * @param string request-Call Title $callTitle
60
+ * @param string webservice-url $webserviceUrl
61
+ * @param array response-Values $response
62
+ *
63
+ * @return DeutschePost_Postident_Helper_Data
64
+ */
65
+ public function logWebserviceResponse($callTitle, $response)
66
+ {
67
+ $message = sprintf(
68
+ "\n=====================\nResponse: %s\nResponse: %s\n=====================", $callTitle, Zend_Json::encode($response)
69
+ );
70
+ return $this->log($message);
71
+ }
72
+
73
+ /**
74
+ * returns the base url for the current store
75
+ *
76
+ * @return string
77
+ */
78
+ public function getDomainUri()
79
+ {
80
+ $params = Mage::app()->getRequest()->getParams();
81
+ $currentStoreId = 0;
82
+ if (array_key_exists('store', $params) && false != $this->getStoreIdByCode($params['store'])) {
83
+ $currentStoreId = $this->getStoreIdByCode($params['store']);
84
+ }
85
+
86
+ $baseUrl = Mage::app()->getStore($currentStoreId)->getBaseUrl(
87
+ Mage_Core_Model_Store::URL_TYPE_WEB, true
88
+ );
89
+ $baseUrl = rtrim($baseUrl, "/");
90
+ return str_replace(
91
+ array("https://", "http://"), "", $baseUrl
92
+ );
93
+
94
+ return $baseUrl;
95
+ }
96
+
97
+ /**
98
+ * get the name of the current store
99
+ *
100
+ * @return string
101
+ */
102
+ public function getStoreName()
103
+ {
104
+ return Mage::app()->getStore()->getName();
105
+ }
106
+
107
+ /**
108
+ * returns the Id for the store via its store code
109
+ *
110
+ * @param type string $storeCode
111
+ * @return string or Boolean
112
+ */
113
+ protected function getStoreIdByCode($storeCode)
114
+ {
115
+ $stores = array_keys(Mage::app()->getStores());
116
+ foreach ($stores as $id) {
117
+ $store = Mage::app()->getStore($id);
118
+ if ($store->getCode() == $storeCode) {
119
+ return $store->getId();
120
+ }
121
+ }
122
+ return false;
123
+ }
124
+
125
+ /**
126
+ * Get current page code
127
+ *
128
+ * Returns f.e. "checkout-cart-index"
129
+ *
130
+ * @return string | boolean
131
+ */
132
+ public function getPageCode()
133
+ {
134
+ $action = Mage::app()->getFrontController()->getAction();
135
+ $page_code = '';
136
+ if ($action) {
137
+ $page_code = $action->getFullActionName('-');
138
+ }
139
+ return $page_code;
140
+ }
141
+
142
+ /**
143
+ * Get current quote
144
+ *
145
+ * @return Mage_Sales_Model_Quote
146
+ */
147
+ public function getQuote()
148
+ {
149
+ return Mage::getSingleton('checkout/session')->getQuote();
150
+ }
151
+
152
+ /**
153
+ *
154
+ * @return Mage_Customer_Model_Customer
155
+ */
156
+ public function getCustomer()
157
+ {
158
+ return Mage::helper('customer')->getCustomer();
159
+ }
160
+
161
+ /**
162
+ * saves the identdata from the quote on the customer
163
+ *
164
+ * @param Mage_Customer_Model_Customer $customer
165
+ * @param Mage_Sales_Quote $quote
166
+ *
167
+ * @return Mage_Customer_Model_Customer
168
+ */
169
+
170
+ public function saveIdentDataToCustomer($customer = null, $quote = null)
171
+ {
172
+ if (is_null($quote) || (false === $quote instanceof Mage_Sales_Model_Quote)) {
173
+ $quote = $this->getQuote();
174
+ }
175
+
176
+ if (is_null($customer)) {
177
+ $customer = $this->getCustomer();
178
+ }
179
+
180
+ $oldCustomerVerficationData = $customer->getPostidentVerificationData();
181
+ $customer->setPostidentVerificationData($quote->getPostidentVerificationData());
182
+ $customer->save();
183
+ $this->log(
184
+ $this->__("Changed customer <%s|%s> postidentData from '%s' to '%s'",
185
+ $customer->getId(),
186
+ $customer->getEmail(),
187
+ $oldCustomerVerficationData,
188
+ $customer->getPostidentVerificationData())
189
+ );
190
+
191
+ return $customer;
192
+ }
193
+
194
+ /**
195
+ * check cart items and return highest min age
196
+ *
197
+ * @return int
198
+ */
199
+ public function checkCart()
200
+ {
201
+ $quoteItems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
202
+ $productMinAge = array(0);
203
+ foreach ($quoteItems as $item) {
204
+ $product = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
205
+ $productMinAge[] = $product->getEpostidentMinage();
206
+ }
207
+ return max($productMinAge);
208
+ }
209
+ }
app/code/community/DeutschePost/Postident/Model/Client.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_Client
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_Client
19
+ {
20
+
21
+
22
+ /**
23
+ * Get HTTP-Client
24
+ *
25
+ * @return DeutschePost_Postident_Model_Client_Http
26
+ */
27
+ public function getHttpClient()
28
+ {
29
+ return Mage::getModel('postident/client_http');
30
+ }
31
+
32
+ /**
33
+ * Get the data helper
34
+ *
35
+ * @return DeutschePost_Postident_Helper_Data
36
+ */
37
+ protected function getHelper()
38
+ {
39
+ return Mage::helper("postident");
40
+ }
41
+
42
+ /**
43
+ * send check request with the needed data
44
+ *
45
+ * @param string $clientId
46
+ * @param string $domain
47
+ *
48
+ * @return Zend_Http_Response
49
+ * @throws DeutschePost_Postident_Model_Client_Exception
50
+ */
51
+ public function sendCheckConnectRequest($clientId, $domain, $checkConnectUrl = null)
52
+ {
53
+ $helper = $this->getHelper();
54
+ $config = Mage::getModel('postident/config');
55
+
56
+ $checkConnectData = array(
57
+ 'clientId' => $clientId,
58
+ 'domainUri' => $domain
59
+ );
60
+
61
+ if (null == $checkConnectUrl) {
62
+ $checkConnectUrl = $config->getCheckConnectUrl();
63
+ }
64
+
65
+ try {
66
+ $httpClient = $this->getHttpClient();
67
+ $httpClient->requestCheckConnect(
68
+ $checkConnectUrl, $checkConnectData
69
+ );
70
+ return $httpClient->parseCheckConnectJsonResponse($httpClient->getLastResponse()->getBody());
71
+ } catch (Zend_Http_Client_Adapter_Exception $e) {
72
+ //throw DeutschePost_Postident_Model_Client_Exception
73
+ DeutschePost_Postident_Model_Client_Exception::connectError($e->getMessage());
74
+ }
75
+ }
76
+
77
+ /**
78
+ * request the access token with the unaltered response code
79
+ *
80
+ * @param string $accessToken
81
+ * @return void
82
+ * @throws DeutschePost_Postident_Model_Client_Exception
83
+ */
84
+ public function sendAccessTicketRequest($accessToken)
85
+ {
86
+ $helper = $this->getHelper();
87
+ $gatewayUrl = Mage::getModel('postident/config')->getAccessTicketUrl();
88
+
89
+ $accessTicketRequestData = array(
90
+ 'code' => $accessToken,
91
+ 'client_id' => Mage::getModel('postident/config')->getClientId(),
92
+ 'client_secret' => Mage::getModel('postident/config')->getClientSecret(),
93
+ 'redirect_uri' => Mage::getUrl('postident/cart/back/', array('_secure' => true, '_nosid' => true)),
94
+ 'grant_type' => 'authorization_code'
95
+ );
96
+
97
+ try {
98
+ $httpClient = $this->getHttpClient();
99
+ $httpClient->requestAccessTicket(
100
+ $gatewayUrl,
101
+ $accessTicketRequestData
102
+ );
103
+ $accessToken = $httpClient->getLastResponse()->getBody();
104
+
105
+ //Log
106
+ Mage::helper("postident/data")->logWebserviceResponse(
107
+ "Access Ticket",
108
+ $accessToken
109
+ );
110
+
111
+ return $accessToken;
112
+ } catch (Zend_Http_Client_Adapter_Exception $e) {
113
+ //throw DeutschePost_Postident_Model_Client_Exception
114
+ DeutschePost_Postident_Model_Client_Exception::accessTicketError($e->getMessage());
115
+ }
116
+ }
117
+
118
+ /**
119
+ * request the ident data with the provided access token
120
+ *
121
+ * @param array $accessToken
122
+ * @return string
123
+ * @throws DeutschePost_Postident_Model_Client_Exception
124
+ */
125
+ public function sendIdentDataRequest($accessToken)
126
+ {
127
+ $helper = $this->getHelper();
128
+ $gatewayUrl = Mage::getModel('postident/config')->getIdentDataUrl();
129
+ $accessToken = array(
130
+ 'Authorization' => $accessToken
131
+ );
132
+
133
+ try {
134
+ $httpClient = $this->getHttpClient();
135
+ $httpClient->requestIdentData(
136
+ $gatewayUrl,
137
+ $accessToken
138
+ );
139
+ return $httpClient->validateIdentDataXmlResponse($httpClient->getLastResponse()->getBody());
140
+ } catch (Zend_Http_Client_Adapter_Exception $e) {
141
+ //throw DeutschePost_Postident_Model_Client_Exception
142
+ DeutschePost_Postident_Model_Client_Exception::identDataError($e->getMessage());
143
+ }
144
+ }
145
+
146
+ }
app/code/community/DeutschePost/Postident/Model/Client/Exception.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_Client_Exception
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_Client_Exception extends Zend_Http_Client_Adapter_Exception
19
+ {
20
+ /**
21
+ * Basic method to throw client exceptions
22
+ *
23
+ * @param string $message
24
+ *
25
+ * @throws DeutschePost_Postident_Model_Client_Exception
26
+ */
27
+ public static function clientError($message)
28
+ {
29
+ $helper = Mage::helper("postident/data");
30
+ $helper->log($message);
31
+
32
+ //throw DeutschePost_Postident_Model_Client_Exception
33
+ throw new self(
34
+ $helper->__(
35
+ 'Client-Exception: s%',
36
+ $message
37
+ )
38
+ );
39
+ }
40
+
41
+ /**
42
+ * Build check connect error message
43
+ *
44
+ * @param string $message
45
+ *
46
+ * @return void
47
+ */
48
+ public static function connectError($message)
49
+ {
50
+ self::clientError(sprintf(
51
+ 'Unable to connect to E-POSTIDENT Webservice. Http-Client Error-Message: %s',
52
+ $message
53
+ )
54
+ );
55
+ }
56
+
57
+ /**
58
+ * Build check access ticket error message
59
+ *
60
+ * @param string $message
61
+ *
62
+ * @return void
63
+ */
64
+ public static function accessTicketError($message)
65
+ {
66
+ self::clientError(sprintf(
67
+ 'Error during Access-Ticket-Request.Http-Client Error-Message: %s',
68
+ $message
69
+ )
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Build identData error message
75
+ *
76
+ * @param string $message
77
+ *
78
+ * @return void
79
+ */
80
+ public static function identDataError($message)
81
+ {
82
+ self::clientError(sprintf(
83
+ 'Error while requesting ident data. Http-Client Error-Message: %s',
84
+ $message
85
+ )
86
+ );
87
+ }
88
+ }
app/code/community/DeutschePost/Postident/Model/Client/Http.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_Client_Http
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_Client_Http extends Zend_Http_Client
19
+ {
20
+
21
+ /**
22
+ *
23
+ * neccessary override because Mage::getModel passes unwanted params to the client
24
+ *
25
+ * @override
26
+ */
27
+ public function __construct()
28
+ {
29
+ parent::__construct(null, null);
30
+ }
31
+
32
+ /**
33
+ *
34
+ * Request Check Connect
35
+ *
36
+ * @param string $checkConnectUrl
37
+ * @param array $checkConnectData
38
+ *
39
+ * @return DeutschePost_Postident_Model_Client_Http
40
+ */
41
+ public function requestCheckConnect($checkConnectUrl, $checkConnectData)
42
+ {
43
+ $this->setMethod(Zend_Http_Client::GET);
44
+
45
+ $this->setUri($checkConnectUrl);
46
+ $this->setParameterGet($checkConnectData);
47
+
48
+ //Log
49
+ Mage::helper("postident/data")->logWebserviceRequest(
50
+ "CheckConnect",
51
+ $checkConnectUrl,
52
+ $checkConnectData
53
+ );
54
+
55
+ parent::request();
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ *
61
+ * Process Check Connect JSON Response
62
+ *
63
+ * @param string $bodyText
64
+ *
65
+ * @return array
66
+ * @throws DeutschePost_Postident_Model_Client_Response_Exception
67
+ */
68
+ public function parseCheckConnectJsonResponse($bodyText)
69
+ {
70
+ $helper = Mage::helper("postident");
71
+ $response = Zend_Json::decode($bodyText);
72
+
73
+ //Log
74
+ Mage::helper("postident/data")->logWebserviceResponse("CheckConnect", $response);
75
+
76
+ //Check if JSON-Data exists
77
+ if (false === isset($response["status"]) || false === isset($response["message"])) {
78
+ DeutschePost_Postident_Model_Client_Response_Exception::checkConnectError('Unable to parse JSON E-POSTIDENT response');
79
+ }
80
+
81
+ //Case success
82
+ if ('200' == $response["status"]) {
83
+ return $response;
84
+ }
85
+
86
+ /*
87
+ * Error cases start here
88
+ *
89
+ * Check Response Codes
90
+ */
91
+ $errorMessage = "";
92
+ switch ($response["status"]) {
93
+ case '404':
94
+ $errorMessage = "The Client-ID doens't exist";
95
+ break;
96
+
97
+ case '403':
98
+ $errorMessage = "The Client-ID exists but was not activated yet";
99
+ break;
100
+
101
+ case '400':
102
+ $errorMessage = "The Client-ID exists but the Domain-URI doesn't match to it";
103
+ break;
104
+
105
+ default:
106
+ $errorMessage = "Unknown Check-Connect-Response-Code";
107
+ break;
108
+ }
109
+ //throw DeutschePost_Postident_Model_Client_Response_Exception
110
+ DeutschePost_Postident_Model_Client_Response_Exception::checkConnectError($errorMessage);
111
+ }
112
+
113
+ /**
114
+ * Request access ticket
115
+ *
116
+ * @param string $authorization_code
117
+ * @param string $gateway
118
+ * @return DeutschePost_Postident_Model_Client_Http
119
+ */
120
+ public function requestAccessTicket($gatewayUrl, $accessTicketRequestData)
121
+ {
122
+ $this->setMethod(Zend_Http_Client::POST);
123
+ $this->setEncType('application/x-www-form-urlencoded');
124
+ $this->setUri($gatewayUrl);
125
+ $this->setParameterPost($accessTicketRequestData);
126
+
127
+ //Log
128
+ Mage::helper("postident/data")->logWebserviceRequest(
129
+ "Access Ticket",
130
+ $gatewayUrl,
131
+ $accessTicketRequestData
132
+ );
133
+ parent::request();
134
+ return $this;
135
+ }
136
+
137
+ /**
138
+ * Request identity data
139
+ *
140
+ * @param string $accessToken
141
+ * @param string $gatewayUrl
142
+ * @return DeutschePost_Postident_Model_Client_Http
143
+ */
144
+ public function requestIdentData($gatewayUrl, $accessToken)
145
+ {
146
+ $this->setMethod(Zend_Http_Client::GET);
147
+ $this->setUri($gatewayUrl);
148
+ $this->setHeaders($accessToken);
149
+
150
+ //Log
151
+ Mage::helper("postident/data")->logWebserviceRequest(
152
+ "IdentData",
153
+ $gatewayUrl,
154
+ $accessToken
155
+ );
156
+ parent::request();
157
+ return $this;
158
+ }
159
+
160
+ /**
161
+ * check if node givenname exists and returns simpleXml object
162
+ *
163
+ * @param xml $bodyText
164
+ * @return SimpleXMLElement
165
+ * @throws DeutschePost_Postident_Model_Client_Response_Exception
166
+ */
167
+ public function validateIdentDataXmlResponse($bodyText)
168
+ {
169
+ //Log
170
+ Mage::helper("postident/data")->logWebserviceResponse(
171
+ "IdentData",
172
+ $bodyText
173
+ );
174
+
175
+ try {
176
+ $simpleXMLResponse = simplexml_load_string($bodyText);
177
+ if (isset($simpleXMLResponse->givenname)) {
178
+ return $simpleXMLResponse;
179
+ } else {
180
+ //throw DeutschePost_Postident_Model_Client_Response_Exception
181
+ DeutschePost_Postident_Model_Client_Response_Exception::throwValidateXMlResponseError('XML Validation failed.');
182
+ }
183
+ } catch (Exception $e) {
184
+ //throw DeutschePost_Postident_Model_Client_Response_Exception
185
+ DeutschePost_Postident_Model_Client_Response_Exception::throwValidateXMlResponseError($e->getMessage());
186
+ }
187
+ }
188
+ }
app/code/community/DeutschePost/Postident/Model/Client/Response/Exception.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_Client_Response_Exception
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_Client_Response_Exception extends Exception
19
+ {
20
+ /**
21
+ * Basic method to throw client response exceptions
22
+ *
23
+ * @param string $message
24
+ *
25
+ * @throws DeutschePost_Postident_Model_Client_Response_Exception
26
+ */
27
+ public static function responseError($message)
28
+ {
29
+ $helper = Mage::helper("postident/data");
30
+ $helper->log($message);
31
+
32
+ //throw DeutschePost_Postident_Model_Client_Response_Exception
33
+ throw new self(
34
+ $helper->__(
35
+ 'Client-Response Error: %s',
36
+ $message
37
+ )
38
+ );
39
+ }
40
+
41
+ /**
42
+ * Build check connect error message
43
+ *
44
+ * @param string $message
45
+ *
46
+ * @return void
47
+ */
48
+ public static function checkConnectError($message)
49
+ {
50
+ self::responseError($message);
51
+ }
52
+
53
+ /**
54
+ * Build check access ticket error message
55
+ *
56
+ * @param string $message
57
+ *
58
+ * @return void
59
+ */
60
+ public static function accessTicketError($message)
61
+ {
62
+ self::responseError($message);
63
+ }
64
+
65
+ /**
66
+ * Build throwValidateXMlResponse error message
67
+ *
68
+ * @param string $message
69
+ *
70
+ * @return void
71
+ */
72
+ public static function throwValidateXMlResponseError($message)
73
+ {
74
+ self::responseError($message);
75
+ }
76
+ }
app/code/community/DeutschePost/Postident/Model/Config.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_Config
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_Config
19
+ {
20
+ /* ID-Card for Testmode */
21
+ const ID_CARD_TEST = 1304;
22
+
23
+ /**
24
+ * Is module enabled?
25
+ *
26
+ * @return boolean
27
+ */
28
+ public function isEnabled()
29
+ {
30
+ return (1 == Mage::getStoreConfig('postident/general/active'));
31
+ }
32
+
33
+ /**
34
+ * if logging is enabled
35
+ *
36
+ * @return boolean
37
+ */
38
+ public function isLoggingEnabled()
39
+ {
40
+ return (1 == Mage::getStoreConfig('postident/general/logging_enabled'));
41
+ }
42
+
43
+ /**
44
+ * get client-id from store config
45
+ *
46
+ * @return string
47
+ */
48
+ public function getClientId()
49
+ {
50
+ return Mage::getStoreConfig('postident/master_data/client_id');
51
+ }
52
+
53
+ /**
54
+ * get client secret from store config
55
+ *
56
+ * @return string
57
+ */
58
+ public function getClientSecret()
59
+ {
60
+ return Mage::getStoreConfig('postident/master_data/client_secret');
61
+ }
62
+
63
+ /**
64
+ * Get all ID-Cards
65
+ *
66
+ * @return array
67
+ */
68
+ public function getAllIdcards()
69
+ {
70
+ return Mage::getStoreConfig('postident/idcards');
71
+ }
72
+
73
+ /**
74
+ * get the selected ID-Card
75
+ *
76
+ * @return string
77
+ */
78
+ public function getSelectedIdCard()
79
+ {
80
+ if ($this->isTestMode() === true) {
81
+ return DeutschePost_Postident_Model_Config::ID_CARD_TEST;
82
+ }
83
+ return Mage::getStoreConfig('postident/idcard/number');
84
+ }
85
+
86
+ /**
87
+ * get the check connect url that is set in config.xml
88
+ *
89
+ * @return string
90
+ */
91
+ public function getCheckConnectUrl()
92
+ {
93
+ return Mage::getStoreConfig('postident/gateway_urls/check_connect_url');
94
+ }
95
+
96
+ /**
97
+ * check if testmode is enabled
98
+ *
99
+ * @return int
100
+ */
101
+ public function isTestMode()
102
+ {
103
+ return (1 == Mage::getStoreConfig('postident/idcard/testmode'));
104
+ }
105
+
106
+ /**
107
+ * get the Age thats set in modul config
108
+ *
109
+ * @return int
110
+ */
111
+ public function getAgeVerification()
112
+ {
113
+ return (int) Mage::getStoreConfig('postident/verification_criteria/age_verification');
114
+ }
115
+
116
+ /**
117
+ * get the E_POSTIDENT url that is set in config.xml
118
+ *
119
+ * @return string
120
+ */
121
+ public function getPostidentUrl()
122
+ {
123
+ return Mage::getStoreConfig('postident/gateway_urls/postident_url');
124
+ }
125
+
126
+ /**
127
+ * Get an instance of an ID-Card
128
+ *
129
+ * @param int $idCardNumber
130
+ *
131
+ * @return instanceOf DeutschePost_Postident_Model_IdCard_Abstract
132
+ */
133
+ public function getIdCardInstance($idCardNumber)
134
+ {
135
+ return Mage::getModel("postident/idCard_idCard".$idCardNumber);
136
+ }
137
+
138
+ /**
139
+ * Get the instance of the selected ID-Card
140
+ *
141
+ * @return instanceOf DeutschePost_Postident_Model_IdCard_Abstract
142
+ */
143
+ public function getSelectedIdCardInstance()
144
+ {
145
+ return $this->getIdCardInstance($this->getSelectedIdCard());
146
+ }
147
+
148
+ /**
149
+ * get the access ticket url from config
150
+ *
151
+ * @return string
152
+ */
153
+ public function getAccessTicketUrl()
154
+ {
155
+ return Mage::getStoreConfig('postident/gateway_urls/access_ticket_url');
156
+ }
157
+
158
+ /**
159
+ * get the identdata url from config
160
+ *
161
+ * @return string
162
+ */
163
+ public function getIdentDataUrl()
164
+ {
165
+ return Mage::getStoreConfig('postident/gateway_urls/identdata_url');
166
+ }
167
+
168
+ /**
169
+ * get checkout_verification value from config
170
+ *
171
+ * @return bool
172
+ */
173
+ public function verifyForEveryCheckout()
174
+ {
175
+ return (1 == Mage::getStoreConfig('postident/verification_criteria/checkout_verification'));
176
+ }
177
+
178
+ /**
179
+ * get verification_type value from config
180
+ *
181
+ * @return string
182
+ */
183
+ public function getVerificationType()
184
+ {
185
+ return Mage::getStoreConfig('postident/verification_criteria/verification_type');
186
+ }
187
+
188
+ /**
189
+ * get address data value from config
190
+ *
191
+ * @return bool
192
+ */
193
+ public function getAddressDataUsage()
194
+ {
195
+ return (1 == Mage::getStoreConfig('postident/checkout/use_address_data'));
196
+ }
197
+
198
+ }
app/code/community/DeutschePost/Postident/Model/Entity/Attribute/Source/Productminage.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ /**
11
+ * DeutschePost_Postident_Model_Entity_Attribute_Source_Productminage
12
+ * @author André Herrn <andre.herrn@netresearch.de>
13
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
14
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class DeutschePost_Postident_Model_Entity_Attribute_Source_Productminage
19
+ extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
20
+ {
21
+ const USE_DEFAULT = 0;
22
+
23
+ /**
24
+ * Retrieve all options array
25
+ *
26
+ * @return array
27
+ */
28
+ public function getAllOptions()
29
+ {
30
+ if (is_null($this->_options)) {
31
+ $this->_options = array(
32
+ array(
33
+ 'label' => Mage::helper('postident')->__('No age restriction'),
34
+ 'value' => self::USE_DEFAULT,
35
+ ),
36
+ array(
37
+ 'label' => Mage::helper('postident')->__('16 years'),
38
+ 'value' => 16,
39
+ ),
40
+ array(
41
+ 'label' => Mage::helper('postident')->__('18 years'),
42
+ 'value' => 18,
43
+ ),
44
+ );
45
+ }
46
+ return $this->_options;
47
+ }
48
+
49
+ /**
50
+ * Bugfix for Magento 1.3 - do not return the option array entry, only the label.
51
+ *
52
+ * @param mixed $value
53
+ * @return string
54
+ */
55
+ public function getOptionText($value)
56
+ {
57
+ $option = parent::getOptionText($value);
58
+ if (is_array($option) && isset($option['label']))
59
+ {
60
+ $option = $option['label'];
61
+ }
62
+ return $option;
63
+ }
64
+
65
+ }
app/code/community/DeutschePost/Postident/Model/IdCard/Abstract.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_IdCard_Abstract
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_IdCard_Abstract extends Varien_Object
19
+ {
20
+ /**
21
+ * Checks if ID-Card has Age-Check-Verification
22
+ */
23
+ public function allowAgeCheck()
24
+ {
25
+ return $this->allowAgeCheck;
26
+ }
27
+
28
+ /**
29
+ * checks if the age is above or the same as the age setup in the store config
30
+ *
31
+ * @param string $verificationResponse
32
+ * @return boolean
33
+ */
34
+ public function checkAgeByBirthdate($dateOfBirth, $currentDate = null)
35
+ {
36
+ if (is_null($currentDate)) {
37
+ $currentDate = Mage::getModel('core/date')->date("Y/m/d");
38
+ }
39
+
40
+ if (($currentDate - $dateOfBirth)
41
+ >= Mage::getModel('postident/verification')->getMinAge())
42
+ return true;
43
+ else
44
+ return false;
45
+ }
46
+ }
app/code/community/DeutschePost/Postident/Model/IdCard/IdCard10.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_IdCard_IdCard10
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_IdCard_IdCard10 extends DeutschePost_Postident_Model_IdCard_Abstract
19
+ {
20
+ /**
21
+ * @var boolean
22
+ */
23
+ public $allowAgeCheck = true;
24
+
25
+ /**
26
+ * checks if the age is above or the same as the age setup in the store config
27
+ *
28
+ * @param array $verificationResponse
29
+ * @return boolean
30
+ */
31
+ public function checkAge($verificationResponse)
32
+ {
33
+ if (true === is_array($verificationResponse)
34
+ && true === array_key_exists('dateofbirth', $verificationResponse)) {
35
+ return $this->checkAgeByBirthdate($verificationResponse["dateofbirth"]);
36
+ }
37
+ }
38
+ }
app/code/community/DeutschePost/Postident/Model/IdCard/IdCard120.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_IdCard_IdCard120
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_IdCard_IdCard120 extends DeutschePost_Postident_Model_IdCard_Abstract
19
+ {
20
+ const IDCARD_VALUE = '120';
21
+
22
+ /**
23
+ * @var boolean
24
+ */
25
+ public $allowAgeCheck = true;
26
+
27
+ /**
28
+ * checks if the age is above or the same as the age setup in the store config
29
+ *
30
+ * @param array $verificationResponse
31
+ * @return boolean
32
+ */
33
+ public function checkAge($verificationResponse)
34
+ {
35
+ if (true === is_array($verificationResponse)
36
+ && true === array_key_exists('dateofbirth', $verificationResponse)) {
37
+ return $this->checkAgeByBirthdate($verificationResponse["dateofbirth"]);
38
+ }
39
+ }
40
+ }
app/code/community/DeutschePost/Postident/Model/IdCard/IdCard130.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_IdCard_IdCard130
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_IdCard_IdCard130 extends DeutschePost_Postident_Model_IdCard_Abstract
19
+ {
20
+ /**
21
+ * @var boolean
22
+ */
23
+ public $allowAgeCheck = true;
24
+
25
+ /**
26
+ * checks if the age is above or the same as the age setup in the store config
27
+ *
28
+ * @param array $verificationResponse
29
+ * @return boolean
30
+ */
31
+ public function checkAge($verificationResponse)
32
+ {
33
+ if (true === is_array($verificationResponse)
34
+ && true === array_key_exists('dateofbirth', $verificationResponse)) {
35
+ return $this->checkAgeByBirthdate($verificationResponse["dateofbirth"]);
36
+ }
37
+ }
38
+ }
app/code/community/DeutschePost/Postident/Model/IdCard/IdCard1304.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_IdCard_IdCard1304
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_IdCard_IdCard1304 extends DeutschePost_Postident_Model_IdCard_Abstract
19
+ {
20
+ /**
21
+ * @var boolean
22
+ */
23
+ public $allowAgeCheck = true;
24
+ }
app/code/community/DeutschePost/Postident/Model/IdCard/IdCard40.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_IdCard_IdCard40
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_IdCard_IdCard40 extends DeutschePost_Postident_Model_IdCard_Abstract
19
+ {
20
+ /**
21
+ * IMPORTANT: This is a DUMMY-ID-Card which could not be selected in the configuration
22
+ *
23
+ * It is just existing for UnitTesting
24
+ *
25
+ */
26
+
27
+ /**
28
+ * @var boolean
29
+ */
30
+ public $allowAgeCheck = false;
31
+ }
app/code/community/DeutschePost/Postident/Model/Observer.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_Observer
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_Observer
19
+ {
20
+
21
+ /**
22
+ * Check if customer is authorized to enter the checkout
23
+ *
24
+ * If customer is not identified -> redirect to cart with notice
25
+ *
26
+ * @param Varien_Event_Observer $observer
27
+ *
28
+ * @return void
29
+ */
30
+ public function checkIsVerified(Varien_Event_Observer $observer)
31
+ {
32
+ if (!Mage::getModel('postident/config')->isEnabled()) {
33
+ return;
34
+ }
35
+
36
+ /* @var $controller Mage_Checkout_CartController */
37
+ $controller = $observer->getControllerAction();
38
+ if (($controller->getRequest()->getControllerName() == 'onepage' && $controller->getRequest()->getActionName() != 'success') && false === Mage::getModel('postident/verification')->userIsVerified()
39
+ ) {
40
+ //Set quote to hasErrors -> this causes a redirect to cart in all cases
41
+ $controller->getOnepage()->getQuote()->setHasError(true);
42
+
43
+ //Add notice message, that the user has to be verified before he is allowed to enter the checkout
44
+ Mage::getSingleton("core/session")->addNotice(
45
+ Mage::helper("postident")->__("An identification by E-POSTIDENT is necessary to enter the checkout.")
46
+ );
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Add a layout handle on "checkout_cart_index"-page
52
+ *
53
+ * IF veritifaction doesn't exist for the customer
54
+ * AND verification is required
55
+ * THEN add the layout handle
56
+ *
57
+ * @param Varien_Event_Observer $observer
58
+ *
59
+ * @return void
60
+ */
61
+ public function addLayoutHandle(Varien_Event_Observer $observer)
62
+ {
63
+ /* @var $update Mage_Core_Model_Layout_Update */
64
+ $update = $observer->getEvent()->getLayout()->getUpdate();
65
+ $userIsVerified = Mage::getModel("postident/verification")->userIsVerified();
66
+
67
+ //New handle for all store parts
68
+ if (true === $this->getConfig()->isEnabled() && false === $userIsVerified) {
69
+ $update->addHandle('postident_verification_required');
70
+ }
71
+
72
+ //New handle for shoppinh_cart
73
+ if (true === $this->getConfig()->isEnabled() && "checkout-cart-index" == $this->getHelper()->getPageCode() && false === $userIsVerified) {
74
+ $update->addHandle('postident_checkout_cart_verification_required');
75
+ }
76
+ }
77
+
78
+
79
+ /**
80
+ * Save ident data from quote to customer after placing an order
81
+ *
82
+ * @param Varien_Event_Observer $observer
83
+ * @return void
84
+ */
85
+ public function saveIdentDataForNewCustomer(Varien_Event_Observer $observer)
86
+ {
87
+ if (!Mage::getModel('postident/config')->isEnabled()) {
88
+ return;
89
+ }
90
+
91
+ $quote = $observer->getEvent()->getOrder()->getQuote();
92
+ $customer = $observer->getEvent()->getOrder()->getCustomer();
93
+ $checkoutMethod = $quote->getCheckoutMethod();
94
+
95
+ if (!is_null($quote)
96
+ && !is_null($quote->getPostidentVerificationData())
97
+ && $checkoutMethod != Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST
98
+ ) {
99
+ $customer = Mage::Helper('postident/data')->saveIdentDataToCustomer($customer, $quote);
100
+
101
+ //This updates the customer object in the session - ensures that it has the postident data
102
+ Mage::getSingleton('customer/session')->setCustomer($customer);
103
+ }
104
+ }
105
+
106
+
107
+ /**
108
+ * add address template to billing step
109
+ *
110
+ * @param $observer
111
+ * @return void
112
+ */
113
+ public function appendAddressDataToBillingStep($observer)
114
+ {
115
+ if( false === Mage::getModel('postident/config')->isEnabled()
116
+ || false === Mage::getModel('postident/config')->getAddressDataUsage()) {
117
+ return;
118
+ }
119
+
120
+ if ($observer->getBlock() instanceof Mage_Checkout_Block_Onepage_Billing
121
+ && false == $observer->getBlock() instanceof Mage_Paypal_Block_Express_Review_Billing
122
+ ) {
123
+ $transport = $observer->getTransport();
124
+ $block = $observer->getBlock();
125
+ $layout = $block->getLayout();
126
+ $html = $transport->getHtml();
127
+ $addAddressTemplateHtml = $layout->createBlock(
128
+ 'postident/checkout_onepage_billing', 'postident_onepage_billing')
129
+ ->renderView();
130
+ $html = $html . $addAddressTemplateHtml;
131
+ $transport->setHtml($html);
132
+ }
133
+ }
134
+
135
+ /**
136
+ * add address template to shipping step
137
+ *
138
+ * @param $observer
139
+ * @return void
140
+ */
141
+ public function appendAddressDataToShippingStep($observer)
142
+ {
143
+ if( false === Mage::getModel('postident/config')->isEnabled()
144
+ || false === Mage::getModel('postident/config')->getAddressDataUsage()) {
145
+ return;
146
+ }
147
+
148
+ if ($observer->getBlock() instanceof Mage_Checkout_Block_Onepage_Shipping
149
+ && false == $observer->getBlock() instanceof Mage_Paypal_Block_Express_Review_Shipping
150
+ ) {
151
+ $transport = $observer->getTransport();
152
+ $block = $observer->getBlock();
153
+ $layout = $block->getLayout();
154
+ $html = $transport->getHtml();
155
+ $addAddressTemplateHtml = $layout->createBlock(
156
+ 'postident/checkout_onepage_shipping', 'postident_onepage_billing')
157
+ ->renderView();
158
+ $html = $html . $addAddressTemplateHtml;
159
+ $transport->setHtml($html);
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Get Postident Helper
165
+ *
166
+ * @return DeutschePost_Postident_Helper_Data
167
+ */
168
+ public function getHelper()
169
+ {
170
+ return Mage::helper("postident");
171
+ }
172
+
173
+ /**
174
+ * Get Postident Config Model
175
+ *
176
+ * @return DeutschePost_Postident_Model_Config
177
+ */
178
+ public function getConfig()
179
+ {
180
+ return Mage::getModel("postident/config");
181
+ }
182
+ }
app/code/community/DeutschePost/Postident/Model/System/Config/Clientid.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_System_Config_Clientid
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_System_Config_Clientid extends Mage_Core_Model_Config_Data
19
+ {
20
+ /**
21
+ * Check if Client-ID and Domain-URI are valid
22
+ *
23
+ * @return void
24
+ */
25
+ public function _afterSave()
26
+ {
27
+ $params = Mage::app()->getRequest()->getParams();
28
+ $checkConnectUrl = null;
29
+ if (true === isset($params["groups"]["gateway_urls"]["fields"]["check_connect_url"]["value"])) {
30
+ $checkConnectUrl = $params["groups"]["gateway_urls"]["fields"]["check_connect_url"]["value"];
31
+ }
32
+
33
+ try {
34
+ Mage::getModel("postident/client")->sendCheckConnectRequest(
35
+ $this->getValue(),
36
+ Mage::helper("postident")->getDomainUri(),
37
+ $checkConnectUrl //Get current POST-Check Connect Url
38
+ );
39
+
40
+ Mage::getSingleton('adminhtml/session')->addSuccess(
41
+ Mage::helper("postident")->__("Client-ID and Domain-URI successfully validated by Check-Connect.")
42
+ );
43
+
44
+ parent::_beforeSave();
45
+ } catch (DeutschePost_Postident_Model_Client_Exception $e) {
46
+ Mage::getSingleton('adminhtml/session')->addError(
47
+ $e->getMessage()
48
+ );
49
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $e) {
50
+ Mage::getSingleton('adminhtml/session')->addError(
51
+ $e->getMessage()
52
+ );
53
+ }
54
+ }
55
+ }
app/code/community/DeutschePost/Postident/Model/System/Config/Source/Idcards.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_System_Config_Source_Idcards
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+
18
+ */
19
+ class DeutschePost_Postident_Model_System_Config_Source_Idcards
20
+ {
21
+ /**
22
+ * Get all possible ID-Cards
23
+ *
24
+ * @return array $idcards
25
+ */
26
+ public function toOptionArray()
27
+ {
28
+ $idcards = array();
29
+ foreach (Mage::getModel("postident/config")->getAllIdcards() as $idcard):
30
+ $idcards[$idcard["code"]] = array(
31
+ 'label' => $idcard["title"],
32
+ 'value' => $idcard["code"]
33
+ );
34
+ endforeach;
35
+ return $idcards;
36
+ }
37
+ }
app/code/community/DeutschePost/Postident/Model/System/Config/Source/Verificationtype.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_System_Config_Source_Verificationtype
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ class DeutschePost_Postident_Model_System_Config_Source_Verificationtype
20
+ {
21
+
22
+ const GLOBAL_VALUE = 'global';
23
+ const PRODUCT_SPECIFIC = 'product_specific';
24
+ const BOTH_VALUES = 'both';
25
+ /**
26
+ * values for type of verification
27
+ *
28
+ * @return array $options
29
+ */
30
+ public function toOptionArray()
31
+ {
32
+ $options = array(
33
+ array('value' => self::GLOBAL_VALUE,
34
+ 'label' => Mage::helper('postident/data')->__('global')),
35
+ array('value' => self::PRODUCT_SPECIFIC,
36
+ 'label' => Mage::helper('postident/data')->__('product specific')),
37
+ array('value' => self::BOTH_VALUES,
38
+ 'label' => Mage::helper('postident/data')->__('both')),
39
+
40
+ );
41
+ return $options;
42
+ }
43
+ }
app/code/community/DeutschePost/Postident/Model/Verification.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_Verification
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_Verification
19
+ {
20
+ /*
21
+ * var Mage_Sales_Model_Quote
22
+ */
23
+ protected $quote = null;
24
+
25
+ /**
26
+ * Key for Postident Response-Data in $quote->getAdditionalData()
27
+ * => $quote->getAdditionalData()["postident"]["identData"]
28
+ *
29
+ * var string
30
+ */
31
+ protected $postIdentResponseKey = 'identData';
32
+
33
+ /**
34
+ * Check if a the user is verified
35
+ *
36
+ * @return boolean
37
+ */
38
+ public function userIsVerified()
39
+ {
40
+ $userIsVerified = false;
41
+
42
+ try {
43
+ //Check if verfification is required
44
+ if (false === $this->isVerificationRequired()) {
45
+ return true;
46
+ }
47
+
48
+ //Start to run different verification checks (currently only for min age)
49
+ //Check user for age verification
50
+ if (true === $this->ageCheckIsRequired() && true === $this->verifiyUserByAge()) {
51
+ $userIsVerified = true;
52
+ }
53
+
54
+ Mage::dispatchEvent('postident_user_verification_check', array(
55
+ 'quote' => $this->getQuote(),
56
+ 'userIsVerified' => $userIsVerified
57
+ )
58
+ );
59
+ } catch (Exception $e) {
60
+ Mage::helper("postident/data")->log(
61
+ sprintf("Error in userIsVerified()-check for quote %s with message '%s'", $this->getQuote()->getId(), $e->getMessage()
62
+ )
63
+ );
64
+ }
65
+
66
+ return $userIsVerified;
67
+ }
68
+
69
+ /**
70
+ * Check if a verification is necessary with the current setup
71
+ *
72
+ * @return boolean
73
+ */
74
+ public function isVerificationRequired()
75
+ {
76
+ $config = Mage::getModel("postident/config");
77
+ //Verification is not required if module is disabled
78
+ if (false === $config->isEnabled()) {
79
+ return false;
80
+ }
81
+
82
+ //Currently we allow only a verification by age
83
+ if (true === $this->ageCheckIsRequired()) {
84
+ return true;
85
+ } else {
86
+ return false;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Check if age verification is required and available for the ID-Card
92
+ *
93
+ * @return boolean
94
+ */
95
+ public function ageCheckIsRequired()
96
+ {
97
+ $config = Mage::getModel("postident/config");
98
+ if ($this->getMinAge() > 0 && true === $config->getSelectedIdCardInstance()->allowAgeCheck()) {
99
+ return true;
100
+ }
101
+ return false;
102
+ }
103
+
104
+ /**
105
+ * Check user/quote session for min age
106
+ *
107
+ * @return boolean
108
+ */
109
+ public function verifiyUserByAge()
110
+ {
111
+ $idCard = Mage::getModel("postident/config")->getSelectedIdCardInstance();
112
+ $verificationData = $this->getPostidentVerificationData();
113
+ if (false === is_array($verificationData) || false === array_key_exists($this->postIdentResponseKey, $verificationData)) {
114
+ //User has no valid verification result yet
115
+ return false;
116
+ } else {
117
+ //User has a valid verification result - run age check
118
+ $ageCheck = $idCard->checkAge($verificationData[$this->postIdentResponseKey]);
119
+ Mage::helper("postident/data")->log(
120
+ sprintf("Age check for quote %s passed with result '%s'", $this->getQuote()->getId(), var_export($ageCheck, true))
121
+ );
122
+ return $ageCheck;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * returns the min age based on verification type
128
+ *
129
+ * @return int
130
+ */
131
+ public function getMinAge()
132
+ {
133
+ $minAge = 0;
134
+
135
+ switch (Mage::getModel("postident/config")->getVerificationType()) {
136
+ case DeutschePost_Postident_Model_System_Config_Source_Verificationtype::GLOBAL_VALUE:
137
+ $minAge = Mage::getModel("postident/config")->getAgeVerification();
138
+ break;
139
+ case DeutschePost_Postident_Model_System_Config_Source_Verificationtype::PRODUCT_SPECIFIC:
140
+ $minAge = Mage::helper('postident/data')->checkCart();
141
+ break;
142
+ case DeutschePost_Postident_Model_System_Config_Source_Verificationtype::BOTH_VALUES:
143
+ $minAge = max(
144
+ Mage::getModel("postident/config")->getAgeVerification(),
145
+ Mage::helper('postident/data')->checkCart()
146
+ );
147
+ break;
148
+ }
149
+ return $minAge;
150
+ }
151
+
152
+ /**
153
+ * gets postident data from either quote or customer and returns it
154
+ *
155
+ * @return string
156
+ */
157
+ public function getPostidentVerificationData()
158
+ {
159
+ if (true === is_array($this->getPostidentVerificationDataFromQuote()))
160
+ {
161
+ return $this->getPostidentVerificationDataFromQuote();
162
+ }
163
+
164
+ if (false === Mage::getModel('postident/config')->verifyForEveryCheckout()
165
+ && true === is_array($this->getPostidentVerificationDataFromCustomer()))
166
+ {
167
+ return $this->getPostidentVerificationDataFromCustomer();
168
+ }
169
+
170
+ return null;
171
+ }
172
+
173
+ /**
174
+ * gets the postident data from customer and returns it
175
+ *
176
+ * @return null
177
+ */
178
+ public function getPostidentVerificationDataFromCustomer()
179
+ {
180
+ $customer = $this->getCustomer();
181
+ if (false === is_null($customer)) {
182
+ return unserialize($customer->getPostidentVerificationData());
183
+ }
184
+ return null;
185
+ }
186
+
187
+ /**
188
+ * gets the postident data from quote and returns it
189
+ *
190
+ * @return null
191
+ */
192
+ public function getPostidentVerificationDataFromQuote()
193
+ {
194
+ $quote = $this->getQuote();
195
+ if (false === is_null($quote)) {
196
+ Mage::log('data =' . unserialize($quote->getPostidentVerificationData()));
197
+ return unserialize($quote->getPostidentVerificationData());
198
+ }
199
+ return null;
200
+ }
201
+
202
+ /**
203
+ * saves the permited postident data on the quote
204
+ *
205
+ * @param array $postidentData
206
+ * @return null
207
+ */
208
+ public function setPostidentVerificationDataToQuote(array $postidentData)
209
+ {
210
+ $quote = $this->getQuote();
211
+ if (false === is_null($quote)) {
212
+ Mage::dispatchEvent('postident_data_to_quote_save_before', array(
213
+ 'quote' => $quote,
214
+ 'postidentData' => $postidentData
215
+ )
216
+ );
217
+
218
+ $quote->setPostidentVerificationData(serialize(array($this->postIdentResponseKey => $postidentData)));
219
+ $quote->save();
220
+
221
+ Mage::dispatchEvent('postident_data_to_quote_save_after', array(
222
+ 'quote' => $quote,
223
+ 'postidentData' => $postidentData
224
+ )
225
+ );
226
+ Mage::helper('postident')->log(
227
+ sprintf('Quote (%s): Saved identdata %s', $quote->getId(), Zend_Json::encode($postidentData))
228
+ );
229
+ return null;
230
+ } else {
231
+ Mage::throwException(
232
+ sprintf(
233
+ "PostidentVerificationData '%s'could not be saved because quote is empty", Zend_Json::encode($postidentData)
234
+ )
235
+ );
236
+ }
237
+ }
238
+
239
+ /**
240
+ * gets the quote from session
241
+ *
242
+ * @return Mage_Sales_Model_Quote
243
+ */
244
+ public function getQuote()
245
+ {
246
+ if (true === is_null($this->quote)) {
247
+ $this->quote = Mage::getSingleton('checkout/cart')->getQuote();
248
+ }
249
+ return $this->quote;
250
+ }
251
+
252
+ /**
253
+ * sets quote
254
+ *
255
+ * @param Mage_Sales_Model_Quote $quote
256
+ */
257
+ public function setQuote(Mage_Sales_Model_Quote $quote)
258
+ {
259
+ $this->quote = $quote;
260
+ }
261
+
262
+ /**
263
+ * gets the customer from session
264
+ *
265
+ * @return Mage_Customer_Model_Customer
266
+ */
267
+ public function getCustomer()
268
+ {
269
+ return Mage::getSingleton('customer/session')->getCustomer();
270
+ }
271
+ }
app/code/community/DeutschePost/Postident/Model/Verification/Exception.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_Verification_Exception
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Model_Verification_Exception extends Exception
19
+ { }
app/code/community/DeutschePost/Postident/Test/Controller/Adminhtml/AbstractControllerTest.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Controller_Adminhtml_AbstractControllerTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ abstract class DeutschePost_Postident_Test_Controller_Adminhtml_AbstractControllerTest
19
+ extends EcomDev_PHPUnit_Test_Case_Controller
20
+ {
21
+ const FAKE_USER_ID = 999999999;
22
+
23
+ protected function _fakeLogin()
24
+ {
25
+ $this->_workaroundAdminMenuIssue();
26
+ $this->_registerUserMock();
27
+ $this->_allowGlobalAccess();
28
+ Mage::getSingleton('adminhtml/url')->turnOffSecretKey();
29
+ $session = Mage::getSingleton('admin/session');
30
+
31
+ // segmentation fault when trying to delete old session id:
32
+ // Mage_Core_Model_Session_Abstract_Varien::regenerateSessionId()
33
+ // workaround: use <session_save><![CDATA[db]]></session_save>
34
+ Mage::getConfig()->setNode(Mage_Core_Model_Session::XML_NODE_SESSION_SAVE, 'db');
35
+
36
+ $user = $session->login('fakeuser', 'fakeuser_pass');
37
+ }
38
+
39
+ /**
40
+ * _workaroundAdminMenuIssue
41
+ *
42
+ * @see https://github.com/IvanChepurnyi/EcomDev_PHPUnit/issues/26
43
+ * @return void
44
+ */
45
+ protected function _workaroundAdminMenuIssue()
46
+ {
47
+ $menuBlock = $this->getBlockMock('adminhtml/page_menu', array('_toHtml'));
48
+ $menuBlock->expects($this->any())
49
+ ->method('_toHtml')
50
+ ->will($this->returnCallback(array($this, 'getAdminhtmlPageMenuTemplate')));
51
+ $this->replaceByMock('block', 'adminhtml/page_menu', $menuBlock);
52
+ }
53
+
54
+ /**
55
+ * Creates a mock object for admin/user Magento Model
56
+ *
57
+ * @return My_Module_Test_Controller_Adminhtml_Controller
58
+ */
59
+ protected function _registerUserMock()
60
+ {
61
+ $user = $this->getModelMock('admin/user');
62
+ $user->expects($this->any())->method('getId')->will($this->returnValue(self::FAKE_USER_ID));
63
+ $this->replaceByMock('model', 'admin/user', $user);
64
+ return $this;
65
+ }
66
+
67
+ protected function _allowGlobalAccess()
68
+ {
69
+ $session = $this->getModelMock('admin/session', array('isAllowed', 'renewSession'));
70
+ $session->expects($this->any())
71
+ ->method('isAllowed')
72
+ ->will($this->returnValue(true));
73
+ $this->replaceByMock('singleton', 'admin/session', $session);
74
+ }
75
+ }
app/code/community/DeutschePost/Postident/Test/Controller/Adminhtml/ConfigControllerTest.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Controller_Adminhtml_ConfigControllerTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Controller_Adminhtml_ConfigControllerTest
19
+ extends DeutschePost_Postident_Test_Controller_Adminhtml_AbstractControllerTest
20
+ {
21
+ public function setUp()
22
+ {
23
+ $this->reset();
24
+ $this->_fakeLogin();
25
+ parent::setUp();
26
+ }
27
+
28
+ /**
29
+ * Logged in to Magento with fake user to test an adminhtml controllers
30
+ */
31
+ /**
32
+ * Test whether fake user successfully logged in
33
+ */
34
+ public function testLoggedIn()
35
+ {
36
+ $this->assertTrue(Mage::getSingleton('admin/session')->isLoggedIn());
37
+ }
38
+
39
+ /**
40
+ * Test whether logged user is fake
41
+ */
42
+ public function testLoggedUserIsFakeUser()
43
+ {
44
+ $this->assertEquals(Mage::getSingleton('admin/session')->getUser()->getId(), self::FAKE_USER_ID);
45
+ }
46
+
47
+ /**
48
+ * Test check connect button controller
49
+ */
50
+ public function testCheckConnectActionSuccess()
51
+ {
52
+ $checkConnectResponse = array("status" => "200", "message" => "toll");
53
+
54
+ $clientMock = $this->getModelMock('postident/client', array('sendCheckConnectRequest'));
55
+ $clientMock->expects($this->once())
56
+ ->method('sendCheckConnectRequest')
57
+ ->will($this->returnValue($checkConnectResponse)); //sendCheckConnectRequest returns an array with status and message
58
+
59
+ $this->replaceByMock('model', 'postident/client', $clientMock);
60
+ $this->dispatch('postident/adminhtml_config/checkConnect');
61
+ $this->assertRequestRoute('postident/adminhtml_config/checkConnect');
62
+
63
+ $this->assertEquals(
64
+ $this->getResponse()->getOutputBody(),
65
+ Zend_Json::encode(
66
+ array('message' => Mage::helper('postident')->__("Check Connect Test successful."))
67
+ )
68
+ );
69
+ }
70
+
71
+ /**
72
+ * Test check connect button controller
73
+ */
74
+ public function testCheckConnectActionWithClientException()
75
+ {
76
+ $clientMock = $this->getModelMock('postident/client', array('sendCheckConnectRequest'));
77
+ $clientMock->expects($this->once())
78
+ ->method('sendCheckConnectRequest')
79
+ ->will($this->throwException(new DeutschePost_Postident_Model_Client_Exception)); //sendCheckConnectRequest returns an array with status and message
80
+
81
+ $this->replaceByMock('model', 'postident/client', $clientMock);
82
+ $this->dispatch('postident/adminhtml_config/checkConnect');
83
+ $this->assertRequestRoute('postident/adminhtml_config/checkConnect');
84
+
85
+ $this->assertNotEquals(
86
+ $this->getResponse()->getOutputBody(),
87
+ Zend_Json::encode(
88
+ array('message' => Mage::helper('postident')->__("Check Connect Test successful."))
89
+ )
90
+ );
91
+ }
92
+
93
+ /**
94
+ * Test check connect button controller
95
+ */
96
+ public function testCheckConnectActionWithClientResponseException()
97
+ {
98
+ $clientMock = $this->getModelMock('postident/client', array('sendCheckConnectRequest'));
99
+ $clientMock->expects($this->once())
100
+ ->method('sendCheckConnectRequest')
101
+ ->will($this->throwException(new DeutschePost_Postident_Model_Client_Response_Exception)); //sendCheckConnectRequest returns an array with status and message
102
+
103
+ $this->replaceByMock('model', 'postident/client', $clientMock);
104
+ $this->dispatch('postident/adminhtml_config/checkConnect');
105
+ $this->assertRequestRoute('postident/adminhtml_config/checkConnect');
106
+
107
+ $this->assertNotEquals(
108
+ $this->getResponse()->getOutputBody(),
109
+ Zend_Json::encode(
110
+ array('message' => Mage::helper('postident')->__("Check Connect Test successful."))
111
+ )
112
+ );
113
+ }
114
+ }
app/code/community/DeutschePost/Postident/Test/Controller/Adminhtml/PermissionDeniedControllerTest.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Controller_Adminhtml_ConfigControllerTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Controller_Adminhtml_PermissionDeniedControllerTest
19
+ extends DeutschePost_Postident_Test_Controller_Adminhtml_AbstractControllerTest
20
+ {
21
+ public function setUp()
22
+ {
23
+ $this->reset();
24
+ $this->_fakeLogin();
25
+ parent::setUp();
26
+ }
27
+
28
+ protected function _allowGlobalAccess()
29
+ {
30
+ $session = $this->getModelMock('admin/session', array('isAllowed', 'renewSession'));
31
+ $session->expects($this->any())
32
+ ->method('isAllowed')
33
+ ->will($this->returnCallback(array($this, 'fakePermission')));
34
+ /*
35
+ * uncommented:
36
+ * ->will($this->returnValue(true));
37
+ *
38
+ * This is the difference to original
39
+ * DeutschePost_Postident_Test_Controller_Adminhtml_AbstractControllerTest::_allowGlobalAccess
40
+ */
41
+ //
42
+ $this->replaceByMock('singleton', 'admin/session', $session);
43
+ }
44
+
45
+ public static function fakePermission($path)
46
+ {
47
+ return 'system/config/postident' === $path;
48
+ }
49
+
50
+ public function testCheckSectionAllowed()
51
+ {
52
+ $this->dispatch('postident/adminhtml_config/checkConnect');
53
+ //Todo
54
+ $this->markTestIncomplete('Todo');
55
+ //Currently no redirect is detected
56
+ //$this->assertRedirect();
57
+ //Mage::getSingleton('adminhtml/session')->getMessages(true);
58
+ }
59
+ }
app/code/community/DeutschePost/Postident/Test/Controller/CartControllerTest.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /**
2
+ * @category DeutschePost Postident
3
+ * @package DeutschePost_Postident
4
+ * @author André Herrn <andre.herrn@netresearch.de>
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ /**
11
+ * DeutschePost_Postident_Test_Controller_CartControllerTest
12
+ * @author André Herrn <andre.herrn@netresearch.de>
13
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
14
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class DeutschePost_Postident_Test_Controller_CartControllerTest
18
+ extends EcomDev_PHPUnit_Test_Case_Controller
19
+ {
20
+ public function testBackAction()
21
+ {
22
+ $clientHelperMock = $this->getHelperMock('postident/client', array(
23
+ 'validateRedirectResponse',
24
+ 'saveIdentDataToQuote'
25
+ ));
26
+ $clientHelperMock->expects($this->any())
27
+ ->method('validateRedirectResponse')
28
+ ->will($this->returnValue(null));
29
+
30
+ $clientHelperMock->expects($this->once())
31
+ ->method('saveIdentDataToQuote')
32
+ ->will($this->returnValue(null));
33
+
34
+ $this->replaceByMock('helper', 'postident/client', $clientHelperMock);
35
+
36
+ $clientModelMock = $this->getModelMock('postident/client', array(
37
+ 'sendAccessTicketRequest',
38
+ 'sendIdentDataRequest'
39
+ ));
40
+ $clientModelMock->expects($this->any())
41
+ ->method('sendAccessTicketRequest')
42
+ ->will($this->returnValue(null));
43
+
44
+ $clientModelMock->expects($this->any())
45
+ ->method('sendIdentDataRequest')
46
+ ->will($this->returnValue(null));
47
+
48
+ $this->replaceByMock('model', 'postident/client', $clientModelMock);
49
+
50
+ $verificationMock = $this->getModelMock('postident/verification', array('userIsVerified'));
51
+ $verificationMock->expects($this->any())
52
+ ->method('userIsVerified')
53
+ ->will($this->returnValue(true));
54
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
55
+
56
+ $this->dispatch('postident/cart/back/code/foo');
57
+ $this->assertRequestRoute('postident/cart/back');
58
+ $this->assertRedirectTo('checkout/onepage', array('_store' => ''));
59
+
60
+ $messages = Mage::getSingleton('core/session')->getMessages(true);
61
+ $success = $messages->getItemsByType(Mage_Core_Model_Message::SUCCESS);
62
+ $notice = $messages->getItemsByType(Mage_Core_Model_Message::NOTICE);
63
+ $error = $messages->getItemsByType(Mage_Core_Model_Message::ERROR);
64
+
65
+ $this->assertEquals(0, count($notice));
66
+ $this->assertEquals(0, count($error));
67
+ $this->assertEquals(1, count($success));
68
+ $this->reset();
69
+ }
70
+
71
+ public function testBackActionWithHelperClientException()
72
+ {
73
+ Mage::getSingleton('core/session')->getMessages(true);
74
+ $this->reset();
75
+ $helperMock = $this->getHelperMock('postident/client', array(
76
+ 'validateRedirectResponse'
77
+ ));
78
+ $helperMock->expects($this->any())
79
+ ->method('validateRedirectResponse')
80
+ ->will($this->throwException(new DeutschePost_Postident_Helper_Client_Exception));
81
+ $this->replaceByMock('helper', 'postident/client', $helperMock);
82
+ $this->dispatch('postident/cart/back/code/foo');
83
+ $this->assertRequestRoute('postident/cart/back');
84
+ $this->assertRedirectTo('checkout/cart', array('_store' => ''));
85
+
86
+ $messages = Mage::getSingleton('core/session')->getMessages(true);
87
+ $success = $messages->getItemsByType(Mage_Core_Model_Message::SUCCESS);
88
+ $notice = $messages->getItemsByType(Mage_Core_Model_Message::NOTICE);
89
+ $error = $messages->getItemsByType(Mage_Core_Model_Message::ERROR);
90
+
91
+ $this->assertEquals(0, count($notice));
92
+ $this->assertEquals(1, count($error));
93
+ $this->assertEquals(0, count($success));
94
+ $this->reset();
95
+
96
+ }
97
+
98
+ public function testBackActionWithModelClientException()
99
+ {
100
+ $helperMock = $this->getHelperMock('postident/client', array(
101
+ 'validateRedirectResponse',
102
+ ));
103
+ $helperMock->expects($this->any())
104
+ ->method('validateRedirectResponse')
105
+ ->will($this->throwException(new DeutschePost_Postident_Model_Client_Exception));
106
+
107
+ $this->replaceByMock('helper', 'postident/client', $helperMock);
108
+ $this->dispatch('postident/cart/back/code/foo');
109
+ $this->assertRequestRoute('postident/cart/back');
110
+ $this->assertRedirectTo('checkout/cart', array('_store' => ''));
111
+
112
+ $messages = Mage::getSingleton('core/session')->getMessages(true);
113
+ $success = $messages->getItemsByType(Mage_Core_Model_Message::SUCCESS);
114
+ $notice = $messages->getItemsByType(Mage_Core_Model_Message::NOTICE);
115
+ $error = $messages->getItemsByType(Mage_Core_Model_Message::ERROR);
116
+
117
+ $this->assertEquals(0, count($notice));
118
+ $this->assertEquals(1, count($error));
119
+ $this->assertEquals(0, count($success));
120
+ $this->reset();
121
+ }
122
+
123
+ public function testBackActionWithStandartException()
124
+ {
125
+ $helperMock = $this->getHelperMock('postident/client', array(
126
+ 'validateRedirectResponse'
127
+ ));
128
+ $helperMock->expects($this->any())
129
+ ->method('validateRedirectResponse')
130
+ ->will($this->throwException(new Exception));
131
+ $this->replaceByMock('helper', 'postident/client', $helperMock);
132
+ $this->dispatch('postident/cart/back/code/foo');
133
+ $this->assertRequestRoute('postident/cart/back');
134
+ $this->assertRedirectTo('checkout/cart', array('_store' => ''));
135
+
136
+ $messages = Mage::getSingleton('core/session')->getMessages(true);
137
+ $success = $messages->getItemsByType(Mage_Core_Model_Message::SUCCESS);
138
+ $notice = $messages->getItemsByType(Mage_Core_Model_Message::NOTICE);
139
+ $error = $messages->getItemsByType(Mage_Core_Model_Message::ERROR);
140
+
141
+ $this->assertEquals(0, count($notice));
142
+ $this->assertEquals(1, count($error));
143
+ $this->assertEquals(0, count($success));
144
+ $this->reset();
145
+ }
146
+
147
+
148
+ public function testBackActionFailedBecauseOfVerification()
149
+ {
150
+ $clientHelperMock = $this->getHelperMock('postident/client', array(
151
+ 'validateRedirectResponse',
152
+ 'saveIdentDataToQuote'
153
+ ));
154
+ $clientHelperMock->expects($this->any())
155
+ ->method('validateRedirectResponse')
156
+ ->will($this->returnValue(null));
157
+
158
+ $clientHelperMock->expects($this->once())
159
+ ->method('saveIdentDataToQuote')
160
+ ->will($this->returnValue(null));
161
+
162
+ $this->replaceByMock('helper', 'postident/client', $clientHelperMock);
163
+
164
+ $clientModelMock = $this->getModelMock('postident/client', array(
165
+ 'sendAccessTicketRequest',
166
+ 'sendIdentDataRequest'
167
+ ));
168
+ $clientModelMock->expects($this->any())
169
+ ->method('sendAccessTicketRequest')
170
+ ->will($this->returnValue(null));
171
+
172
+ $clientModelMock->expects($this->any())
173
+ ->method('sendIdentDataRequest')
174
+ ->will($this->returnValue(null));
175
+ $this->replaceByMock('model', 'postident/client', $clientModelMock);
176
+
177
+ $verificationMock = $this->getModelMock('postident/verification', array('userIsVerified'));
178
+ $verificationMock->expects($this->any())
179
+ ->method('userIsVerified')
180
+ ->will($this->returnValue(false));
181
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
182
+
183
+ $this->dispatch('postident/cart/back/code/foo');
184
+ $this->assertRequestRoute('postident/cart/back');
185
+ $this->assertRedirectTo('checkout/cart', array('_store' => ''));
186
+
187
+ $messages = Mage::getSingleton('core/session')->getMessages(true);
188
+ $success = $messages->getItemsByType(Mage_Core_Model_Message::SUCCESS);
189
+ $notice = $messages->getItemsByType(Mage_Core_Model_Message::NOTICE);
190
+ $error = $messages->getItemsByType(Mage_Core_Model_Message::ERROR);
191
+
192
+ $this->assertEquals(0, count($notice));
193
+ $this->assertEquals(1, count($error));
194
+ $this->assertEquals(0, count($success));
195
+
196
+ $this->assertEquals(
197
+ Mage::helper('postident')->__('The identification was passed succesfully but the verification to enter the checkout failed.'),
198
+ $error[0]->getCode()
199
+ );
200
+
201
+ $this->reset();
202
+ }
203
+ }
app/code/community/DeutschePost/Postident/Test/Helper/ClientTest.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Helper_Client
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Helper_ClientTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+
21
+
22
+ /**
23
+ * @var Mage_Core_Model_Store
24
+ */
25
+ protected $store;
26
+
27
+ /**
28
+ * @var DeutschePost_Postident_Model_Config
29
+ */
30
+ protected $config;
31
+
32
+ public function setUp()
33
+ {
34
+ $this->store = Mage::app()->getStore(0)->load(0);
35
+ $this->config = Mage::getModel('postident/config');
36
+ parent::setup();
37
+ }
38
+
39
+ public function testValidateRedirectResponseNull()
40
+
41
+ {
42
+ $response = array();
43
+ $helper = Mage::helper('postident/client');
44
+ $this->setExpectedException('DeutschePost_Postident_Helper_Client_Exception');
45
+ $helper->validateRedirectResponse($response);
46
+
47
+ }
48
+
49
+ public function testValidateRedirectResponseParameterStateMissing()
50
+ {
51
+ $response = array(
52
+ 'code' => 'test'
53
+ );
54
+ $helper = Mage::helper('postident/client');
55
+ $this->setExpectedException('DeutschePost_Postident_Helper_Client_Exception');
56
+ $helper->validateRedirectResponse($response);
57
+
58
+ }
59
+
60
+ public function testValidateRedirectResponseParameterCodeMissing()
61
+ {
62
+ $response = array(
63
+ 'state' => 'testState'
64
+ );
65
+ $helper = Mage::helper('postident/client');
66
+ $this->setExpectedException('DeutschePost_Postident_Helper_Client_Exception');
67
+ $helper->validateRedirectResponse($response);
68
+
69
+ }
70
+
71
+
72
+ public function testValidateRedirectResponseQuoteIdFailure()
73
+ {
74
+ $response = array(
75
+ 'code' => 'test',
76
+ 'state' => '12'
77
+ );
78
+ $helperMock = $this->getHelperMock('postident/data', array(
79
+ 'getQuote'
80
+ ));
81
+ $quote = Mage::getModel('sales/quote');
82
+ $quote->setId('5');
83
+ $helperMock->expects($this->any())
84
+ ->method('getQuote')
85
+ ->will($this->returnValue($quote));
86
+ $helper = Mage::helper('postident/client');
87
+ $this->setExpectedException('DeutschePost_Postident_Helper_Client_Exception');
88
+ $helper->validateRedirectResponse($response);
89
+
90
+
91
+ }
92
+
93
+ /**
94
+ * @test
95
+ * @loadExpectation redirectLink.yaml
96
+ */
97
+ public function testBuildRedirectLink()
98
+ {
99
+
100
+ $quote = Mage::getModel('sales/quote');
101
+ $quote->setId(9);
102
+
103
+ $helperMock = $this->getHelperMock('postident/data', array(
104
+ 'getQuote',
105
+ ));
106
+ $helperMock->expects($this->once())
107
+ ->method('getQuote')
108
+ ->will($this->returnValue($quote));
109
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
110
+
111
+ $configModelMock = $this->getModelMock('postident/config', array(
112
+ 'getPostidentUrl',
113
+ 'getClientId',
114
+ 'getSelectedIdCard'
115
+ ));
116
+ $configModelMock->expects($this->once())
117
+ ->method('getPostidentUrl')
118
+ ->will($this->returnValue('https://ident.epost-gka.de/oauth2/login'));
119
+ $configModelMock->expects($this->once())
120
+ ->method('getClientId')
121
+ ->will($this->returnValue('05337686-ff03-4c9c-aff9-6a3823e0faf0'));
122
+ $configModelMock->expects($this->once())
123
+ ->method('getSelectedIdCard')
124
+ ->will($this->returnValue('10'));
125
+ $this->replaceByMock('model', 'postident/config', $configModelMock);
126
+
127
+ $this->store->resetConfig();
128
+ $this->store->setConfig('web/secure/base_url', 'https://example.com/');
129
+ $this->store->setConfig('web/unsecure/base_url', 'https://example.com/');
130
+ Mage::app()->getStore()->setName('English');
131
+ $redirectLink = $this->_getExpectations()->getLink();
132
+ $this->assertEquals($redirectLink, Mage::helper('postident/client')->buildRedirectLink());
133
+ $this->store->resetConfig();
134
+
135
+ }
136
+
137
+ /**
138
+ * @test
139
+ * @loadExpectation postidentQuoteVerificationData.yaml
140
+ */
141
+ public function testSaveIdentDataToQuote()
142
+ {
143
+ $simpleXML = simplexml_load_string($this->_getExpectations()->getXml());
144
+
145
+ //Mock Date
146
+ $dateMock = $this->getModelMock('core/date', array(
147
+ 'date'
148
+ ));
149
+ $dateMock->expects($this->any())
150
+ ->method('date')
151
+ ->will($this->returnValue($this->_getExpectations()->getDate()));
152
+ $this->replaceByMock('model', 'core/date', $dateMock);
153
+
154
+ //Mock verification
155
+ $verificationMock = $this->getModelMock('postident/verification', array(
156
+ 'setPostidentVerificationDataToQuote'
157
+ ));
158
+
159
+ $verificationMock->expects($this->any())
160
+ ->method('setPostidentVerificationDataToQuote')
161
+ ->with($this->equalTo(unserialize($this->_getExpectations()->getIdentdata())));
162
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
163
+
164
+ Mage::helper('postident/client')->saveIdentDataToQuote($simpleXML);
165
+ }
166
+ }
app/code/community/DeutschePost/Postident/Test/Helper/ClientTest/expectations/postidentQuoteVerificationData.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ xml: <?xml version="1.0" encoding="UTF-8"?><identdata> <givenname>Anton</givenname><familyname>A-netresearchdemo02</familyname><dateofbirth>1992-11-19 00:00:00.0</dateofbirth><street>Moltkestraße</street><housenumber>14</housenumber><zipcode>53173</zipcode><city>Bonn</city><country>DE</country><epostaddress>anton.a-netresearchdemo02@epost-gka.de</epostaddress></identdata>
2
+ date: 2012-12-12 07:45:13
3
+ identdata: a:10:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo02";s:11:"dateofbirth";s:21:"1992-11-19 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo02@epost-gka.de";s:17:"verification_date";s:19:"2012-12-12 07:45:13";}
app/code/community/DeutschePost/Postident/Test/Helper/ClientTest/expectations/redirectLink.yaml ADDED
@@ -0,0 +1 @@
 
1
+ link: https://ident.epost-gka.de/oauth2/login?client_id=05337686-ff03-4c9c-aff9-6a3823e0faf0&redirect_uri=https%3A%2F%2Fexample.com%2Findex.php%2Fpostident%2Fcart%2Fback%2F&scope=10&reason=Your%2Bonline%2Bpurchase%2Bat%2BEnglish.&response_type=code&state=9
app/code/community/DeutschePost/Postident/Test/Helper/DataTest.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Helper_DataTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Helper_DataTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ protected $helper;
21
+ protected $config;
22
+
23
+ public function setUp()
24
+ {
25
+
26
+ $this->helper = Mage::helper('postident');
27
+ $this->config = Mage::getModel('postident/config');
28
+ parent::setUp();
29
+ }
30
+
31
+ public function testLog()
32
+ {
33
+ $this->assertTrue(true);
34
+ }
35
+
36
+ public function testGetDomainUri()
37
+ {
38
+ $store = Mage::app()->getStore(1)->load(1);
39
+ $params = array('store' => 'default');
40
+ Mage::app()->getRequest()->setParams($params);
41
+ $helperMock = $this->getHelperMock('postident/data');
42
+ $helperMock->expects($this->any())
43
+ ->method('getStoreIdByCode')
44
+ ->with($this->equalTo('default'))
45
+ ->will($this->returnValue(1));
46
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
47
+ $store->resetConfig();
48
+ $store->setConfig('web/secure/base_url','https://www.test.de/' );
49
+ $this->assertEquals('www.test.de', $this->helper->getDomainUri());
50
+ }
51
+
52
+ /**
53
+ * test set save identData to customer
54
+ *
55
+ * @test
56
+ * @loadFixture quotes
57
+ * @loadExpectation quotes
58
+ */
59
+ public function testSaveIdentDataToCustomer()
60
+ {
61
+
62
+ // no verification data on customer
63
+ $customer = Mage::getModel('customer/customer')->load(1);
64
+ $this->assertEquals(null, $customer->getPostidentVerificationData());
65
+
66
+ // verification data on quote
67
+ $quote = Mage::getModel('sales/quote')->load(2);
68
+ $helperMock = $this->getHelperMock('postident/data', array(
69
+ 'getQuote',
70
+ 'getCustomer'
71
+ )
72
+ );
73
+ $helperMock->expects($this->any())
74
+ ->method('getQuote')
75
+ ->will($this->returnValue($quote));
76
+
77
+ $helperMock->expects($this->any())
78
+ ->method('getCustomer')
79
+ ->will($this->returnValue($customer));
80
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
81
+
82
+ /**
83
+ * No matter if parameters are null or not, the result
84
+ * allways should be the same !
85
+ *
86
+ *
87
+ */
88
+
89
+ //test if customer and quote is given as parameter
90
+ Mage::helper('postident/data')->saveIdentDataToCustomer($customer, $quote);
91
+ $this->assertEquals(
92
+ $quote->getPostidentVerificationData(),
93
+ Mage::getModel('customer/customer')->load(1)->getPostidentVerificationData()
94
+ );
95
+ //test if only customer is given as parameter
96
+ Mage::helper('postident/data')->saveIdentDataToCustomer($customer, null);
97
+ $this->assertEquals(
98
+ $quote->getPostidentVerificationData(),
99
+ Mage::getModel('customer/customer')->load(1)->getPostidentVerificationData()
100
+ );
101
+
102
+ //test if only quote is given as parameter
103
+ Mage::helper('postident/data')->saveIdentDataToCustomer(null, $quote);
104
+ $this->assertEquals(
105
+ $quote->getPostidentVerificationData(),
106
+ Mage::getModel('customer/customer')->load(1)->getPostidentVerificationData()
107
+ );
108
+
109
+ //test if nothing is given as parameter
110
+ Mage::helper('postident/data')->saveIdentDataToCustomer(null, null);
111
+ $this->assertEquals(
112
+ $quote->getPostidentVerificationData(),
113
+ Mage::getModel('customer/customer')->load(1)->getPostidentVerificationData()
114
+ );
115
+ }
116
+
117
+ /**
118
+ * test check cart for min age items
119
+ *
120
+ * @test
121
+ * @loadFixture quotes
122
+ */
123
+ public function testCheckCart()
124
+ {
125
+
126
+
127
+ $customerSession = $this->getModelMock('customer/session', array('getQuote', 'start', 'renewSession', 'init'));
128
+ $this->replaceByMock('model', 'customer/session', $customerSession);
129
+
130
+ $itemsCollection = array();
131
+ $product = new Varien_Object();
132
+ $product->setId(1);
133
+ $item = new Varien_Object();
134
+ $item->setProduct($product);
135
+ $item->setId(1);
136
+ $itemsCollection[] = $item;
137
+ $item = new Varien_Object();
138
+ $product->setId(2);
139
+ $item->setProduct($product);
140
+ $item->setId(2);
141
+ $itemsCollection[] = $item;
142
+ $item = new Varien_Object();
143
+ $product->setId(3);
144
+ $item->setProduct($product);
145
+ $item->setId(3);
146
+ $itemsCollection[] = $item;
147
+ $quoteMock = $this->getModelMock('sales/quote', array('getAllItems'));
148
+ $quoteMock->expects($this->any())
149
+ ->method('getAllItems')
150
+ ->will($this->returnValue($itemsCollection));
151
+ $this->replaceByMock('model', 'sales/quote', $quoteMock);
152
+ $quote = Mage::getModel('sales/quote')->load(2);
153
+ $checkoutSession = $this->getModelMock('checkout/session', array('getQuote', 'start', 'renewSession', 'init'));
154
+ $checkoutSession->expects($this->any())
155
+ ->method('getQuote')
156
+ ->will($this->returnValue($quote));
157
+ $this->replaceByMock('model', 'checkout/session', $checkoutSession);
158
+
159
+ $this->assertEquals(21, Mage::helper('postident/data')->checkCart());
160
+ }
161
+ }
app/code/community/DeutschePost/Postident/Test/Helper/DataTest/fixtures/product.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ eav:
2
+ customer:
3
+ - entity_id: 1
4
+ attribute_set_id: 0 # Fix issue with customer entity load
5
+ website_id: 1
6
+ store_id: 1
7
+ created_in: Default Store
8
+ group_id: 1
9
+ firstname: John
10
+ lastname: Doe11
11
+ email: <a href="mailto:john@doe.com">john@doe.com</a>
12
+ postident_verification_data: a:1:{s:9:"identData";a:9:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo03";s:11:"dateofbirth";s:21:"1992-11-20 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo03@epost-gka.de";}}
13
+
14
+
app/code/community/DeutschePost/Postident/Test/Helper/DataTest/fixtures/quotes.yaml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ eav:
2
+ customer:
3
+ - entity_id: 1
4
+ attribute_set_id: 0 # Fix issue with customer entity load
5
+ website_id: 1
6
+ store_id: 1
7
+ created_in: Default Store
8
+ group_id: 1
9
+ firstname: John
10
+ lastname: Doe11
11
+ email: <a href="mailto:john@doe.com">john@doe.com</a>
12
+ postident_verification_data:
13
+
14
+ - entity_id: 2
15
+ attribute_set_id: 0 # Fix issue with customer entity load
16
+ website_id: 1
17
+ store_id: 1
18
+ created_in: Default Store
19
+ group_id: 1
20
+ firstname: Hans
21
+ lastname: Müller
22
+ email: <a href="mailto:hans@müller.com">hans@müller.com</a>
23
+ postident_verification_data: a:1:{s:9:"identData";a:9:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo03";s:11:"dateofbirth";s:21:"1992-11-20 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo03@epost-gka.de";}}
24
+
25
+
26
+ catalog_product:
27
+ - entity_id: 1
28
+ epostident_minage: 18
29
+ website_id: 1
30
+ store_id: 1
31
+
32
+ - entity_id: 2
33
+ epostident_minage: 0
34
+ website_id: 1
35
+ store_id: 1
36
+
37
+ - entity_id: 3
38
+ epostident_minage: 21
39
+ website_id: 1
40
+ store_id: 1
41
+
42
+
43
+ tables:
44
+ sales/quote:
45
+ - id: 1
46
+ entity_id: 1
47
+ items_count: 0
48
+ postident_verification_data:
49
+
50
+ - entity_id: 2
51
+ items_count: 3
52
+ postident_verification_data: a:1:{s:9:"identData";a:9:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo03";s:11:"dateofbirth";s:21:"1992-11-20 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo03@epost-gka.de";}}
53
+
54
+
55
+
56
+ sales/quote_item:
57
+ - item_id: 1
58
+ quote_id: 2
59
+ store_id: 1
60
+ website_id: 1
61
+ product_id: 1
62
+ parent_item_id: 1
63
+
64
+
65
+ - item_id: 2
66
+ quote_id: 2
67
+ product_id: 2
68
+ store_id: 1
69
+ website_id: 1
70
+ parent_item_id: 2
71
+
72
+ - item_id: 3
73
+ quote_id: 2
74
+ product_id: 3
75
+ store_id: 1
76
+ website_id: 1
77
+ parent_item_id: 2
78
+
79
+
80
+
app/code/community/DeutschePost/Postident/Test/Model/Client/ExceptionTest.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_Client_ExceptionTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_Client_ExceptionTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+
21
+ public function testclientError()
22
+ {
23
+ $clientException = new DeutschePost_Postident_Model_Client_Exception();
24
+ $helperMock = $this->getHelperMock('postident/data', array(
25
+ 'log',
26
+ '__'
27
+ ));
28
+ $helperMock
29
+ ->expects($this->once())
30
+ ->method('log')
31
+ ->will($this->returnValue(null));
32
+ $helperMock->expects($this->any())
33
+ ->method('__')
34
+ ->will($this->returnValue(null));
35
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
36
+ $this->setExpectedException(
37
+ 'DeutschePost_Postident_Model_Client_Exception');
38
+ $clientException->clientError('Error');
39
+
40
+ }
41
+ }
app/code/community/DeutschePost/Postident/Test/Model/Client/HttpTest.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_Client_HttpTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_Client_HttpTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ /**
21
+ * @var DeutschePost_Postident_Model_Client_Http
22
+ */
23
+ protected $httpClient;
24
+
25
+ /**
26
+ * @var DeutschePost_Postident_Model_Client_Http
27
+ */
28
+ protected $mockHttpClient;
29
+
30
+ public function setUp()
31
+ {
32
+ $this->httpClient = Mage::getModel('postident/client_http');
33
+
34
+ /* mock http client */
35
+ $this->mockHttpClient = $this->getMock(
36
+ 'DeutschePost_Postident_Model_Client_Http'
37
+ );
38
+ }
39
+
40
+ public function testRequestCheckConnect()
41
+ {
42
+ $clientId = "9cd4cf22-e6cb-4496-b9ca-d9c0de606526";
43
+ $domainUri = "ahe-ce-1510.magento.nrdev.de";
44
+ $gatewayUrl = "https://ident.epost-gka.de/oauth2/clientverification";
45
+
46
+ $mockHttpClient = $this->mockHttpClient;
47
+ $mockHttpClient->expects($this->any())
48
+ ->method('request')
49
+ ->will($this->returnValue($mockHttpClient));
50
+ $this->replaceByMock('model', 'postident/client_http', $mockHttpClient);
51
+
52
+ $response = $this->httpClient->requestCheckConnect($gatewayUrl, array("clientId" => $clientId, "domainUri" => $domainUri));
53
+ $this->assertTrue("DeutschePost_Postident_Model_Client_Http" == get_class($response));
54
+ $this->assertEquals("https://ident.epost-gka.de:443/oauth2/clientverification", $response->getUri(true));
55
+ }
56
+
57
+ public function testParseCheckConnectJsonResponse()
58
+ {
59
+ $response = array("status" => 200, "message" => "clientId and domainUri matched");
60
+
61
+ $httpClient = Mage::getModel('postident/client_http');
62
+
63
+ try {
64
+ $bodyText = '{"status":200,"message":"clientId and domainUri matched"}';
65
+ $this->assertEquals($response, $this->httpClient->parseCheckConnectJsonResponse($bodyText));
66
+ } catch (Exception $e) {
67
+ $this->fail("Unexpected Exception '{$e->getMessage()}' in success case");
68
+ }
69
+
70
+ try {
71
+ $httpClient = Mage::getModel('postident/client_http');
72
+ $bodyText = '{"wrong_key":404}';
73
+ $this->httpClient->parseCheckConnectJsonResponse($bodyText);
74
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $expected) {
75
+ $this->assertEquals("Client-Response Error: Unable to parse JSON E-POSTIDENT response", $expected->getMessage());
76
+ }
77
+
78
+ try {
79
+ $httpClient = Mage::getModel('postident/client_http');
80
+ $bodyText = '';
81
+ $this->httpClient->parseCheckConnectJsonResponse($bodyText);
82
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $expected) {
83
+ $this->assertEquals('Client-Response Error: Unable to parse JSON E-POSTIDENT response', $expected->getMessage());
84
+ }
85
+
86
+ try {
87
+ $httpClient = Mage::getModel('postident/client_http');
88
+ $bodyText = '{"status":404,"message":"clientId mismatched"}';
89
+ $this->httpClient->parseCheckConnectJsonResponse($bodyText);
90
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $expected) {
91
+ $this->assertEquals("Client-Response Error: The Client-ID doens't exist", $expected->getMessage());
92
+ }
93
+
94
+ try {
95
+ $httpClient = Mage::getModel('postident/client_http');
96
+ $bodyText = '{"status":403,"message":"clientservice activation state is false"}';
97
+ $this->httpClient->parseCheckConnectJsonResponse($bodyText);
98
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $expected) {
99
+ $this->assertEquals("Client-Response Error: The Client-ID exists but was not activated yet", $expected->getMessage());
100
+ }
101
+
102
+ try {
103
+ $httpClient = Mage::getModel('postident/client_http');
104
+ $bodyText = '{"status":400,"message":"clientId matched but domainUri mismatched"}';
105
+ $this->httpClient->parseCheckConnectJsonResponse($bodyText);
106
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $expected) {
107
+ $this->assertEquals("Client-Response Error: The Client-ID exists but the Domain-URI doesn't match to it", $expected->getMessage());
108
+ }
109
+
110
+ try {
111
+ $httpClient = Mage::getModel('postident/client_http');
112
+ $bodyText = '{"status":999,"message":"The end is near"}';
113
+ $this->httpClient->parseCheckConnectJsonResponse($bodyText);
114
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $expected) {
115
+ $this->assertEquals('Client-Response Error: Unknown Check-Connect-Response-Code', $expected->getMessage());
116
+ }
117
+ }
118
+
119
+ public function testRequestAccessTicket()
120
+ {
121
+ $accessTokenRequestData = array(
122
+ 'clientId' => "05337686-ff03-4c9c-aff9-6a3823e0faf0",
123
+ 'domainUri' => "ser-dhlpi.magento.nrdev.de ",
124
+ 'clientSecret' => "sebastian80165",
125
+ 'code' => "code12345"
126
+ );
127
+ $gatewayUrl = "https://ident.epost-gka.de/oauth2/token";
128
+
129
+ $mockHttpClient = $this->mockHttpClient;
130
+ $mockHttpClient->expects($this->any())
131
+ ->method('request')
132
+ ->will($this->returnValue($mockHttpClient));
133
+ $this->replaceByMock('model', 'postident/client_http', $mockHttpClient);
134
+
135
+ $response = $this->httpClient->requestAccessTicket($gatewayUrl, $accessTokenRequestData);
136
+ $this->assertTrue("DeutschePost_Postident_Model_Client_Http" == get_class($response));
137
+ $this->assertEquals("https://ident.epost-gka.de:443/oauth2/token", $response->getUri(true));
138
+ }
139
+
140
+ public function testRequestIdentData()
141
+ {
142
+ $helperMock = $this->getHelperMock('postident/data', array(
143
+ 'logWebserviceRequest',
144
+ '__'
145
+ ));
146
+ $helperMock
147
+ ->expects($this->any())
148
+ ->method('logWebserviceRequest')
149
+ ->will($this->returnValue(null));
150
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
151
+
152
+ $accessTokenData = array(
153
+ 'code' => "code12345"
154
+ );
155
+ $gatewayUrl = "https://ident.epost-gka.de/oauth2/identdata";
156
+
157
+ $mockHttpClient = $this->mockHttpClient;
158
+ $mockHttpClient->expects($this->any())
159
+ ->method('request')
160
+ ->will($this->returnValue($mockHttpClient));
161
+ $this->replaceByMock('model', 'postident/client_http', $mockHttpClient);
162
+
163
+ $response = $this->httpClient->requestIdentData($gatewayUrl, $accessTokenData);
164
+ $this->assertTrue("DeutschePost_Postident_Model_Client_Http" == get_class($response));
165
+ $this->assertEquals("https://ident.epost-gka.de:443/oauth2/identdata", $response->getUri(true));
166
+ }
167
+
168
+ public function testValidateIdentDataXmlResponse()
169
+ {
170
+
171
+ $helperMock = $this->getHelperMock('postident/data', array(
172
+ 'logWebserviceResponse',
173
+ '__'
174
+ ));
175
+ $helperMock
176
+ ->expects($this->any())
177
+ ->method('logWebserviceResponse')
178
+ ->will($this->returnValue(null));
179
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
180
+
181
+ $bodyText = '<?xml version="1.0" encoding="UTF-8"?>
182
+ <identdata>
183
+ <givenname>Anton</givenname>
184
+ <familyname>A-netresearchdemo02</familyname>
185
+ <dateofbirth>1992-11-19 00:00:00.0</dateofbirth>
186
+ <street>Moltkestraße</street>
187
+ <housenumber>14</housenumber>
188
+ <zipcode>53173</zipcode>
189
+ <city>Bonn</city>
190
+ <country>DE</country>
191
+ <epostaddress>anton.a-netresearchdemo02@epost-gka.de</epostaddress>
192
+ </identdata>';
193
+
194
+ $simpleXML = simplexml_load_string($bodyText);
195
+ $this->assertEquals($simpleXML,$this->httpClient->validateIdentDataXmlResponse($bodyText));
196
+ $this->assertNotEquals('foo',$this->httpClient->validateIdentDataXmlResponse($bodyText));
197
+
198
+ //Error case
199
+ $this->setUp();
200
+
201
+ $bodyText = '<?xml version="1.0" encoding="UTF-8"?>
202
+ <identdata>
203
+ <givenname>Anton</givenname>
204
+ <familyname>A-netresearchdemo02</familyname>
205
+ <dateofbirth>1992-11-19 00:00:00.0</dateofbirth>
206
+ <street>Moltkestraße</street>
207
+ <housenumber>14';
208
+
209
+ $this->setExpectedException('DeutschePost_Postident_Model_Client_Response_Exception');
210
+ $this->httpClient->validateIdentDataXmlResponse($bodyText);
211
+ }
212
+ }
app/code/community/DeutschePost/Postident/Test/Model/Client/Response/ExceptionTest.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_Client_Response_ExceptionTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_Client_Response_ExceptionTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ public function testCheckConnectError()
21
+ {
22
+ $clientResponseException = new DeutschePost_Postident_Model_Client_Response_Exception();
23
+ $helperMock = $this->getHelperMock('postident/data', array(
24
+ 'log',
25
+ '__'
26
+ ));
27
+ $helperMock
28
+ ->expects($this->once())
29
+ ->method('log')
30
+ ->will($this->returnValue(null));
31
+
32
+ $helperMock->expects($this->once())
33
+ ->method('__')
34
+ ->will($this->returnValue(null));
35
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
36
+ $this->setExpectedException(
37
+ 'DeutschePost_Postident_Model_Client_Response_Exception'
38
+ );
39
+ $clientResponseException->checkConnectError("dummy message");
40
+ }
41
+ }
app/code/community/DeutschePost/Postident/Test/Model/ClientTest.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_ClientTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_ClientTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ /**
21
+ * @var Mage_Core_Model_Store
22
+ */
23
+ protected $store;
24
+
25
+ /**
26
+ * @var DeutschePost_Postident_Model_Config
27
+ */
28
+ protected $config;
29
+
30
+ /**
31
+ * @var DeutschePost_Postident_Model_Client
32
+ */
33
+ protected $client;
34
+
35
+ /**
36
+ * @var DeutschePost_Postident_Model_Client_Http
37
+ */
38
+ protected $mockHttpClient;
39
+
40
+ public function setUp()
41
+ {
42
+ $this->store = Mage::app()->getStore(0)->load(0);
43
+ $this->config = Mage::getModel('postident/config');
44
+ $this->client = Mage::getModel('postident/client');
45
+
46
+ /* mock http client */
47
+ $this->mockHttpClient = $this->getMock(
48
+ 'DeutschePost_Postident_Model_Client_Http'
49
+ );
50
+
51
+ parent::setUp();
52
+ }
53
+
54
+ public function testGetHttpClient()
55
+ {
56
+ $this->assertEquals(
57
+ "DeutschePost_Postident_Model_Client_Http",
58
+ get_class($this->client->getHttpClient())
59
+ );
60
+ }
61
+
62
+ public function testSendCheckConnectRequest()
63
+ {
64
+ $clientId = "9cd4cf22-e6cb-4496-b9ca-d9c0de606526";
65
+ $domainUri = "ahe-ce-1510.magento.nrdev.de";
66
+ $gatewayUrl = "https://ident.epost-gka.de/oauth2/clientverification";
67
+
68
+ $httpClient = $this->mockHttpClient;
69
+ $httpClient->expects($this->any())
70
+ ->method('requestCheckConnect')
71
+ ->with($this->equalTo($gatewayUrl), $this->equalTo(array("clientId" => $clientId, "domainUri" => $domainUri)))
72
+ ->will($this->returnValue($httpClient));
73
+ $this->replaceByMock('model', 'postident/client_http', $httpClient);
74
+
75
+ $httpClient = $this->mockHttpClient;
76
+ $httpClient->expects($this->any())
77
+ ->method('request')
78
+ ->will($this->returnValue($httpClient));
79
+ $this->replaceByMock('model', 'postident/client_http', $httpClient);
80
+
81
+ //Success case
82
+ try {
83
+ $response = array("status" => "200", "message" => "clientId and domainUri matched");
84
+
85
+ $httpClient = $this->mockHttpClient;
86
+ $httpClient->expects($this->any())
87
+ ->method('parseCheckConnectJsonResponse')
88
+ ->with($this->equalTo('{"status":200,"message":"clientId and domainUri matched"}'))
89
+ ->will($this->returnValue($response));
90
+ $this->replaceByMock('model', 'postident/client_http', $httpClient);
91
+ } catch (DeutschePost_Postident_Model_Client_Exception $e) {
92
+ $this->fail('DeutschePost_Postident_Model_Client_Exception exception in success case');
93
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $e) {
94
+ $this->fail('DeutschePost_Postident_Model_Client_Response_Exception exception in success case');
95
+ }
96
+
97
+ //Error case
98
+ $this->setUp();
99
+ $response = array("status" => "403", "message" => "clientservice activation state is false");
100
+
101
+ $httpClient = $this->mockHttpClient;
102
+ $httpClient->expects($this->any())
103
+ ->method('requestCheckConnect')
104
+ ->will($this->throwException(new DeutschePost_Postident_Model_Client_Exception()));
105
+ $this->replaceByMock('model', 'postident/client_http', $httpClient);
106
+ $this->setExpectedException('DeutschePost_Postident_Model_Client_Exception');
107
+ $this->client->sendCheckConnectRequest($clientId, $domainUri, $gatewayUrl);
108
+ }
109
+
110
+
111
+ public function testSendAccessTicketRequest()
112
+ {
113
+ $this->store->resetConfig();
114
+ $this->store->setConfig('web/secure/base_url', 'https://example.com/');
115
+ $this->store->setConfig('web/unsecure/base_url', 'https://example.com/');
116
+ $this->store->setConfig('postident/master_data/client_id', '123456');
117
+ $this->store->setConfig('postident/master_data/client_secret', 'pass');
118
+
119
+ $reponseObject = new Varien_Object();
120
+ $reponseObject->setBody('foo');
121
+
122
+ $gatewayUrl = 'https://ident.epost.de/oauth2/token';
123
+
124
+ $accessTicketRequestData = array(
125
+ 'code' => '4711',
126
+ 'client_id' => '123456',
127
+ 'client_secret' => 'pass',
128
+ 'redirect_uri' => 'https://example.com/index.php/postident/cart/back/',
129
+ 'grant_type' => 'authorization_code'
130
+ );
131
+
132
+
133
+ $httpClient = $this->mockHttpClient;
134
+ $httpClient->expects($this->any())
135
+ ->method('requestAccessTicket')
136
+ ->with($this->equalTo($gatewayUrl), $this->equalTo($accessTicketRequestData))
137
+ ->will($this->returnValue($httpClient));
138
+
139
+ $httpClient->expects($this->any())
140
+ ->method('getLastResponse')
141
+ ->will($this->returnValue($reponseObject));
142
+ $this->replaceByMock('model', 'postident/client_http', $httpClient);
143
+ $this->assertEquals('foo', Mage::getModel('postident/client')->sendAccessTicketRequest('4711'));
144
+ $this->assertNotEquals('bar', Mage::getModel('postident/client')->sendAccessTicketRequest('4711'));
145
+
146
+
147
+ //Error case
148
+ $this->setUp();
149
+ $httpClient = $this->mockHttpClient;
150
+ $httpClient->expects($this->once())
151
+ ->method('requestAccessTicket')
152
+ ->will($this->throwException(new DeutschePost_Postident_Model_Client_Exception()));
153
+ $this->replaceByMock('model', 'postident/client_http', $httpClient);
154
+ $this->setExpectedException('DeutschePost_Postident_Model_Client_Exception');
155
+ $this->client->sendAccessTicketRequest('foo');
156
+
157
+ }
158
+
159
+ public function testSendIdentDataRequest()
160
+ {
161
+ $reponseObject = new Varien_Object();
162
+ $reponseObject->setBody('foo');
163
+
164
+ $httpClient = $this->mockHttpClient;
165
+ $httpClient->expects($this->once())
166
+ ->method('requestIdentData')
167
+ ->will($this->returnValue($httpClient));
168
+
169
+ $httpClient->expects($this->once())
170
+ ->method('getLastResponse')
171
+ ->will($this->returnValue($reponseObject));
172
+
173
+ $httpClient->expects($this->once())
174
+ ->method('validateIdentDataXmlResponse')
175
+ ->will($this->returnValue('foo'));
176
+ $this->replaceByMock('model', 'postident/client_http', $httpClient);
177
+
178
+ $bodyResult = Mage::getModel('postident/client')->sendIdentDataRequest('4711');
179
+ $this->assertEquals('foo', $bodyResult);
180
+ $this->assertNotEquals('bar', $bodyResult);
181
+
182
+ //Error case
183
+ $this->setUp();
184
+ $httpClient = $this->mockHttpClient;
185
+ $httpClient->expects($this->once())
186
+ ->method('requestIdentData')
187
+ ->will($this->throwException(new DeutschePost_Postident_Model_Client_Exception()));
188
+ $this->replaceByMock('model', 'postident/client_http', $httpClient);
189
+ $this->setExpectedException('DeutschePost_Postident_Model_Client_Exception');
190
+ $this->client->sendIdentDataRequest('foo');
191
+ }
192
+
193
+ }
app/code/community/DeutschePost/Postident/Test/Model/ConfigTest.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_ConfigTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_ConfigTest extends EcomDev_PHPUnit_Test_Case_Controller
19
+ {
20
+ /**
21
+ * @var Mage_Core_Model_Store
22
+ */
23
+ protected $store;
24
+
25
+ /**
26
+ * @var DeutschePost_Postident_Model_Config
27
+ */
28
+ protected $config;
29
+
30
+ public function setUp()
31
+ {
32
+ $this->store = Mage::app()->getStore(0)->load(0);
33
+ $this->config = Mage::getModel('postident/config');
34
+ }
35
+
36
+ public function testType()
37
+ {
38
+ $this->assertInstanceOf(
39
+ 'DeutschePost_Postident_Model_Config', Mage::getModel('postident/config')
40
+ );
41
+ }
42
+
43
+ public function testIsEnabled()
44
+ {
45
+ $path = 'postident/general/active';
46
+ $this->store->resetConfig();
47
+ $this->store->setConfig($path, 1);
48
+ $this->assertTrue($this->config->isEnabled());
49
+ $this->store->resetConfig();
50
+ $this->store->setConfig($path, 0);
51
+ $this->assertFalse($this->config->isEnabled());
52
+ }
53
+
54
+ public function testIsLoggingEnabled()
55
+ {
56
+ $path = 'postident/general/logging_enabled';
57
+ $this->store->resetConfig();
58
+ $this->store->setConfig($path, 1);
59
+ $this->assertTrue($this->config->isLoggingEnabled());
60
+ $this->store->resetConfig();
61
+ $this->store->setConfig($path, 0);
62
+ $this->assertFalse($this->config->isLoggingEnabled());
63
+ }
64
+
65
+
66
+ public function testGetClientId()
67
+ {
68
+ $path = 'postident/master_data/client_id';
69
+ $this->store->resetConfig();
70
+ $this->store->setConfig($path, 'foo');
71
+ $this->assertEquals('foo', $this->config->getClientId());
72
+ $this->store->resetConfig();
73
+ $this->store->setConfig($path, 0);
74
+ $this->assertNotEquals('foo', $this->config->getClientId());
75
+ }
76
+
77
+ public function testGetClientSecret()
78
+ {
79
+ $path = 'postident/master_data/client_secret';
80
+ $this->store->resetConfig();
81
+ $this->store->setConfig($path, 'foo');
82
+ $this->assertEquals('foo', $this->config->getClientSecret());
83
+ $this->store->resetConfig();
84
+ $this->store->setConfig($path, 0);
85
+ $this->assertNotEquals('foo', $this->config->getClientSecret());
86
+ }
87
+
88
+ public function testGetAllIdcards()
89
+ {
90
+ $allIdCards = $this->config->getAllIdcards();
91
+ $this->assertTrue(is_array($allIdCards));
92
+ $this->assertGreaterThanOrEqual(3, count($allIdCards)); //We start with 3 id-cards: 10,120,130
93
+ $allIdCards = array_shift($allIdCards);
94
+ $this->assertArrayHasKey('code', $allIdCards);
95
+ $this->assertArrayHasKey('title', $allIdCards);
96
+
97
+ }
98
+
99
+ public function testgetSelectedIdCard()
100
+ {
101
+ $path ='postident/idcard/testmode';
102
+ $this->store->resetConfig();
103
+ $this->store->setConfig($path, 1);
104
+ $this->assertEquals(1304, $this->config->getSelectedIdCard());
105
+ $this->store->resetConfig();
106
+ $this->store->setConfig($path, 0);
107
+ $this->assertNotEquals(1304, $this->config->getSelectedIdCard());
108
+
109
+ $path ='postident/idcard/number';
110
+ $this->store->setConfig($path, 120);
111
+ $this->assertEquals(120, $this->config->getSelectedIdCard());
112
+ }
113
+
114
+ public function testIsTestMode()
115
+ {
116
+ $path ='postident/idcard/testmode';
117
+ $this->store->resetConfig();
118
+ $this->store->setConfig($path, 1);
119
+ $this->assertEquals(true, $this->config->isTestMode());
120
+ $this->store->resetConfig();
121
+ $this->store->setConfig($path, 0);
122
+ $this->assertEquals(false ,$this->config->isTestMode());
123
+ }
124
+
125
+ public function testGetAgeVerification()
126
+ {
127
+ $path ='postident/verification_criteria/age_verification';
128
+ $this->store->resetConfig();
129
+ $this->store->setConfig($path, 15);
130
+ $this->assertEquals(15, $this->config->getAgeVerification());
131
+ $this->store->resetConfig();
132
+ $this->store->setConfig($path, 23);
133
+ $this->assertNotEquals('foo' ,$this->config->getAgeVerification());
134
+ }
135
+
136
+ public function testGetPostidentUrl()
137
+ {
138
+ $path = 'postident/gateway_urls/postident_url';
139
+ $this->store->resetConfig();
140
+ $this->store->setConfig($path, 'www.test.de');
141
+ $this->assertEquals('www.test.de', $this->config->getPostidentUrl());
142
+ $this->store->resetConfig();
143
+ $this->store->setConfig($path, 'foo');
144
+ $this->assertNotEquals('www.test.de',$this->config->getPostidentUrl());
145
+ }
146
+
147
+
148
+ public function testGetIdCardInstance()
149
+ {
150
+ //Take ID Card 10 as example
151
+ $idCardInstance = $this->config->getIdCardInstance(10);
152
+ $this->assertTrue($idCardInstance instanceOf DeutschePost_Postident_Model_IdCard_Abstract);
153
+ }
154
+
155
+ public function testGetSelectedIdCardInstance()
156
+ {
157
+ $pathSelectedIdCard ='postident/idcard/number';
158
+ $pathTestMode ='postident/idcard/testmode';
159
+ $this->store->resetConfig();
160
+ $this->store->setConfig($pathSelectedIdCard, 10);
161
+ $this->store->setConfig($pathTestMode, 0);
162
+ $this->assertTrue($this->config->getSelectedIdCardInstance() instanceOf DeutschePost_Postident_Model_IdCard_IdCard10);
163
+
164
+ $this->store->resetConfig();
165
+ $this->store->setConfig($pathSelectedIdCard, 120);
166
+ $this->store->setConfig($pathTestMode, 0);
167
+ $this->assertTrue($this->config->getSelectedIdCardInstance() instanceOf DeutschePost_Postident_Model_IdCard_IdCard120);
168
+
169
+ $this->store->resetConfig();
170
+ $this->store->setConfig($pathTestMode, 1);
171
+ $this->assertTrue($this->config->getSelectedIdCardInstance() instanceOf DeutschePost_Postident_Model_IdCard_IdCard1304);
172
+ }
173
+
174
+ public function testGetIdentDataUrl()
175
+ {
176
+ $path = 'postident/gateway_urls/identdata_url';
177
+ $this->store->resetConfig();
178
+ $this->store->setConfig($path, 'www.test.de');
179
+ $this->assertEquals('www.test.de', $this->config->getIdentDataUrl());
180
+ $this->store->resetConfig();
181
+ $this->store->setConfig($path, 'foo');
182
+ $this->assertNotEquals('www.test.de',$this->config->getIdentDataUrl());
183
+ }
184
+
185
+ public function testGetVerificationType()
186
+ {
187
+ $path = 'postident/verification_criteria/verification_type';
188
+
189
+ //Assert Default
190
+ $this->assertEquals(DeutschePost_Postident_Model_System_Config_Source_Verificationtype::GLOBAL_VALUE, $this->config->getVerificationType());
191
+
192
+ $this->store->resetConfig();
193
+ $this->store->setConfig($path, DeutschePost_Postident_Model_System_Config_Source_Verificationtype::PRODUCT_SPECIFIC);
194
+ $this->assertEquals(DeutschePost_Postident_Model_System_Config_Source_Verificationtype::PRODUCT_SPECIFIC, $this->config->getVerificationType());
195
+
196
+ $this->store->resetConfig();
197
+ $this->store->setConfig($path, DeutschePost_Postident_Model_System_Config_Source_Verificationtype::BOTH_VALUES);
198
+ $this->assertEquals(DeutschePost_Postident_Model_System_Config_Source_Verificationtype::BOTH_VALUES ,$this->config->getVerificationType());
199
+ }
200
+
201
+ public function testGetAddressDataUsage()
202
+ {
203
+ $path = 'postident/checkout/use_address_data';
204
+ $this->store->resetConfig();
205
+ $this->store->setConfig($path, true);
206
+ $this->assertEquals(true, $this->config->getAddressDataUsage());
207
+ $this->store->resetConfig();
208
+ $this->store->setConfig($path, false);
209
+ $this->assertEquals(false,$this->config->getAddressDataUsage());
210
+ }
211
+
212
+ public function testVerifyForEveryCheckout()
213
+ {
214
+ $path ='postident/verification_criteria/checkout_verification';
215
+ $this->store->resetConfig();
216
+ $this->store->setConfig($path, 1);
217
+ $this->assertEquals(true, $this->config->verifyForEveryCheckout());
218
+ $this->store->resetConfig();
219
+ $this->store->setConfig($path, 0);
220
+ $this->assertEquals(false ,$this->config->verifyForEveryCheckout());
221
+ }
222
+ }
app/code/community/DeutschePost/Postident/Test/Model/IdCard/AbstractTest.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Model_IdCard_Abstract
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_IdCard_AbstractTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ /**
21
+ * @var Mage_Core_Model_Store
22
+ */
23
+ protected $store;
24
+
25
+ /**
26
+ * @var DeutschePost_Postident_Model_Config
27
+ */
28
+ protected $config;
29
+
30
+ public function setUp()
31
+ {
32
+ $this->store = Mage::app()->getStore(0)->load(0);
33
+ $this->config = Mage::getModel('postident/config');
34
+ }
35
+
36
+ /**
37
+ * Check if all ID-Cards have a correct class
38
+ */
39
+ public function testCheckAllIdCardClasses()
40
+ {
41
+ foreach ($this->config->getAllIdcards() as $idCardConfig) {
42
+ $idCardInstance = $this->config->getIdCardInstance($idCardConfig["code"]);
43
+ $this->assertTrue("object" == gettype($idCardInstance));
44
+ $this->assertTrue($idCardInstance instanceOf DeutschePost_Postident_Model_IdCard_Abstract);
45
+ }
46
+ }
47
+
48
+ public function testAllowAgeCheck()
49
+ {
50
+ /*
51
+ * Currently all selectable ID-Cards support AgeCheck
52
+ */
53
+ foreach ($this->config->getAllIdcards() as $idCardConfig) {
54
+ $idCardInstance = $this->config->getIdCardInstance($idCardConfig["code"]);
55
+ $this->assertTrue($idCardInstance->allowAgeCheck());
56
+ }
57
+
58
+ $idCardInstance = $this->config->getIdCardInstance(40);
59
+ $this->assertFalse($idCardInstance->allowAgeCheck());
60
+ }
61
+
62
+ /**
63
+ * test if CheckAge returns true and false correctly based on dateofbirth
64
+ */
65
+ public function testcheckAgeByBirthdate()
66
+ {
67
+ $verificationModelMock = $this->getModelMock('postident/config', array(
68
+ 'getMinAge'
69
+ ));
70
+ $verificationModelMock->expects($this->any())
71
+ ->method('getMinAge')
72
+ ->will($this->returnValue(18));
73
+ $this->replaceByMock('model', 'postident/verification', $verificationModelMock);
74
+ $this->assertTrue(Mage::getModel('postident/IdCard_Abstract')->checkAgeByBirthdate(
75
+ '1980-05-10 00:00:00.0',
76
+ '2010-05-10 00:00:00.0'
77
+ ));
78
+ $this->assertFalse(Mage::getModel('postident/IdCard_Abstract')->checkAgeByBirthdate(
79
+ '1998-05-10 00:00:00.0',
80
+ '1999-05-10 00:00:00.0'
81
+ ));
82
+ //assertion for 17y and 3xx days
83
+ $this->assertFalse(Mage::getModel('postident/IdCard_Abstract')->checkAgeByBirthdate(
84
+ '1980-01-01 00:00:00.0',
85
+ '1997-12-31 00:00:00.0'
86
+ ));
87
+ //assertion for 18y and 1 day
88
+ $this->assertTrue(Mage::getModel('postident/IdCard_Abstract')->checkAgeByBirthdate(
89
+ '1980-01-01 00:00:00.0',
90
+ '1998-01-02 00:00:00.0'
91
+ ));
92
+ }
93
+ }
app/code/community/DeutschePost/Postident/Test/Model/ObserverTest.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_ObserverTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+
21
+ public function setUp()
22
+ {
23
+ $this->app()->getFrontController()->getRequest()->setBaseUrl('http://example.org');
24
+ parent::setUp();
25
+ }
26
+
27
+ /**
28
+ * Set order to event object
29
+ *
30
+ * @param Mage_Sales_Model_Order $order
31
+ * @return Varien_Event_Observer
32
+ */
33
+ protected function prepareObserver(Mage_Sales_Model_Order $order)
34
+ {
35
+ $observer = new Varien_Event_Observer;
36
+ $event = new Varien_Event();
37
+ $event->setData('order', $order);
38
+ $observer->setData('event', $event);
39
+ return $observer;
40
+
41
+ }
42
+
43
+ /**
44
+ * test save identData to new customer
45
+ *
46
+ * @test
47
+ * @loadFixture quotes
48
+ */
49
+ public function testSaveIdentDataForNewCustomer()
50
+ {
51
+ $order = Mage::getModel('sales/order')->load(1);
52
+ $customer = Mage::getModel('customer/customer')->load(1);
53
+ $order->setCustomer($customer);
54
+ $observer = $this->prepareObserver($order);
55
+ $quote = Mage::getModel('sales/quote')->load(1);
56
+ $order->setQuote($quote);
57
+
58
+ $configMock = $this->getModelMock('postident/config', array(
59
+ 'isEnabled'
60
+ )
61
+ );
62
+ $configMock->expects($this->once())
63
+ ->method('isEnabled')
64
+ ->will($this->returnValue(true));
65
+ $this->replaceByMock('model', 'postident/config', $configMock);
66
+
67
+ $helperMock = $this->getHelperMock('postident/data', array(
68
+ 'saveIdentDataToCustomer'
69
+ )
70
+ );
71
+ $helperMock->expects($this->once())
72
+ ->method('saveIdentDataToCustomer')
73
+ ->with($customer,$quote)
74
+ ->will($this->returnValue($customer));
75
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
76
+
77
+ $sessionMock = $this->getModelMock('customer/session', array(
78
+ 'setCustomer', 'renewSession', 'init', 'start'
79
+ )
80
+ );
81
+ $sessionMock->expects($this->once())
82
+ ->method('setCustomer')
83
+ ->will($this->returnValue(''));
84
+ $this->replaceByMock('model', 'customer/session', $sessionMock);
85
+ Mage::getModel('postident/observer')->saveIdentDataForNewCustomer($observer);
86
+
87
+ }
88
+
89
+ /**
90
+ * test save identData to new customer
91
+ *
92
+ * @test
93
+ * @loadFixture quotes
94
+ */
95
+ public function TestSaveIdentDataForNewCustomerWithNoDataOnQuote()
96
+ {
97
+ $order = Mage::getModel('sales/order')->load(2);
98
+ $customer = Mage::getModel('customer/customer')->load(1);
99
+ $order->setCustomer($customer);
100
+ $observer = $this->prepareObserver($order);
101
+ $quote = Mage::getModel('sales/quote')->load(2);
102
+ $order->setQuote($quote);
103
+ $configMock = $this->getModelMock('postident/config', array(
104
+ 'isEnabled'
105
+ )
106
+ );
107
+ $configMock->expects($this->once())
108
+ ->method('isEnabled')
109
+ ->will($this->returnValue(true));
110
+ $this->replaceByMock('model', 'postident/config', $configMock);
111
+
112
+ $helperMock = $this->getHelperMock('postident/data', array(
113
+ 'saveIdentDataToCustomer'
114
+ )
115
+ );
116
+
117
+ $helperMock->expects($this->never())
118
+ ->method('saveIdentDataToCustomer')
119
+ ->will($this->returnValue(''));
120
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
121
+
122
+ $sessionMock = $this->getModelMock('customer/session', array(
123
+ 'setCustomer', 'init', 'renewSession', 'start'
124
+ )
125
+ );
126
+ $sessionMock->expects($this->never())
127
+ ->method('setCustomer')
128
+ ->will($this->returnValue(''));
129
+ $this->replaceByMock('model', 'customer/session', $sessionMock);
130
+ Mage::getModel('postident/observer')->saveIdentDataForNewCustomer($observer);
131
+
132
+ }
133
+
134
+ /**
135
+ * test save identData to new customer
136
+ *
137
+ * @test
138
+ * @loadFixture quotes
139
+ */
140
+ public function testSaveIdentDataWithCheckoutAsGuest()
141
+ {
142
+ $order = Mage::getModel('sales/order')->load(3);
143
+ $customer = Mage::getModel('customer/customer')->load(1);
144
+ $order->setCustomer($customer);
145
+ $observer = $this->prepareObserver($order);
146
+ $quote = Mage::getModel('sales/quote')->load(3);
147
+ $order->setQuote($quote);
148
+ $configMock = $this->getModelMock('postident/config', array(
149
+ 'isEnabled'
150
+ )
151
+ );
152
+ $configMock->expects($this->once())
153
+ ->method('isEnabled')
154
+ ->will($this->returnValue(true));
155
+ $this->replaceByMock('model', 'postident/config', $configMock);
156
+
157
+ $helperMock = $this->getHelperMock('postident/data', array(
158
+ 'saveIdentDataToCustomer'
159
+ )
160
+ );
161
+
162
+ $helperMock->expects($this->never())
163
+ ->method('saveIdentDataToCustomer')
164
+ ->will($this->returnValue(''));
165
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
166
+
167
+ $sessionMock = $this->getModelMock('customer/session', array(
168
+ 'setCustomer', 'init', 'renewSession', 'start'
169
+ )
170
+ );
171
+ $sessionMock->expects($this->never())
172
+ ->method('setCustomer')
173
+ ->will($this->returnValue(''));
174
+ $this->replaceByMock('model', 'customer/session', $sessionMock);
175
+ Mage::getModel('postident/observer')->saveIdentDataForNewCustomer($observer);
176
+ }
177
+ }
app/code/community/DeutschePost/Postident/Test/Model/ObserverTest/fixtures/orders.yaml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+
4
+ - entity_id: 1
5
+ increment_id: 100000055
6
+ shipping_address_id: 42
7
+ base_grand_total: 119.00
8
+ grand_total: 119.00
9
+ currency: 'EUR'
10
+ customer_gender: 1
11
+ shipping_method: 'flatrate_flatrate'
12
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
app/code/community/DeutschePost/Postident/Test/Model/ObserverTest/fixtures/quotes.yaml ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ eav:
2
+ customer:
3
+ - entity_id: 1
4
+ attribute_set_id: 0 # Fix issue with customer entity load
5
+ website_id: 1
6
+ store_id: 1
7
+ created_in: Default Store
8
+ group_id: 1
9
+ firstname: John
10
+ lastname: Doe11
11
+ email: <a href="mailto:john@doe.com">john@doe.com</a>
12
+ postident_verification_data:
13
+
14
+ - entity_id: 2
15
+ attribute_set_id: 0 # Fix issue with customer entity load
16
+ website_id: 1
17
+ store_id: 1
18
+ created_in: Default Store
19
+ group_id: 1
20
+ firstname: Hans
21
+ lastname: Müller
22
+ email: <a href="mailto:hans@müller.com">hans@müller.com</a>
23
+ postident_verification_data: a:1:{s:9:"identData";a:9:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo03";s:11:"dateofbirth";s:21:"1992-11-20 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo03@epost-gka.de";}}
24
+
25
+
26
+ catalog_product:
27
+ - entity_id: 1
28
+ epostident_minage: 18
29
+
30
+ - entity_id: 2
31
+ epostident_minage: 0
32
+
33
+
34
+ tables:
35
+ sales/order:
36
+
37
+ - entity_id: 1
38
+ increment_id: 100000055
39
+ quote_id: 1
40
+ shipping_address_id: 42
41
+ base_grand_total: 119.00
42
+ grand_total: 119.00
43
+ currency: 'EUR'
44
+ customer_gender: 1
45
+ shipping_method: 'flatrate_flatrate'
46
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
47
+
48
+ - entity_id: 2
49
+ increment_id: 100000055
50
+ quote_id: 2
51
+ shipping_address_id: 42
52
+ base_grand_total: 119.00
53
+ grand_total: 119.00
54
+ currency: 'EUR'
55
+ customer_gender: 1
56
+ shipping_method: 'flatrate_flatrate'
57
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
58
+
59
+ - entity_id: 3
60
+ increment_id: 100000055
61
+ quote_id: 3
62
+ shipping_address_id: 42
63
+ base_grand_total: 119.00
64
+ grand_total: 119.00
65
+ currency: 'EUR'
66
+ customer_gender: 1
67
+ shipping_method: 'flatrate_flatrate'
68
+ customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
69
+
70
+ sales/quote:
71
+ - entity_id: 1
72
+ items_count: 0
73
+ order_id: 1
74
+ postident_verification_data: foo
75
+ checkout_method: 'register'
76
+
77
+ - entity_id: 2
78
+ items_count: 2
79
+ checkout_method: 'register'
80
+
81
+ - entity_id: 3
82
+ items_count: 2
83
+ postident_verification_data: foo
84
+ checkout_method: 'guest'
85
+
86
+
87
+ sales/quote_item:
88
+ - item_id: 1
89
+ quote_id: 2
90
+ store_id: 1
91
+ product_id: 1
92
+ parent_item_id: 1
93
+
94
+
95
+ - item_id: 2
96
+ quote_id: 2
97
+ product_id: 2
98
+ store_id: 1
99
+ parent_item_id: 2
100
+
101
+
102
+
app/code/community/DeutschePost/Postident/Test/Model/System/Config/ClientidTest.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost_Postident
4
+ * @package DeutschePost_Postident
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_System_Config_ClientidTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_System_Config_ClientidTest extends EcomDev_PHPUnit_Test_Case_Config
19
+ {
20
+ /**
21
+ * @var Netresearch_Hermes_Model_Config
22
+ */
23
+ protected $systemConfigClientid;
24
+
25
+ public function setUp()
26
+ {
27
+ $sessionMock = $this->getModelMock('adminhtml/session', array(
28
+ 'setCustomer', 'renewSession', 'init', 'start'
29
+ )
30
+ );
31
+ $this->replaceByMock('model', 'adminhtml/session', $sessionMock);
32
+ $this->systemConfigClientid = new DeutschePost_Postident_Model_System_Config_Clientid();
33
+ }
34
+
35
+ public function testAfterSaveSuccess()
36
+ {
37
+ //Expect no errors
38
+ $clientMock = $this->getModelMock('postident/client', array(
39
+ 'sendCheckConnectRequest'
40
+ ));
41
+ $clientMock
42
+ ->expects($this->once())
43
+ ->method('sendCheckConnectRequest')
44
+ ->with(null, Mage::helper("postident")->getDomainUri(), $this->equalTo(null))
45
+ ->will($this->returnValue(null));
46
+ $this->replaceByMock('model', 'postident/client', $clientMock);
47
+ $this->systemConfigClientid->_afterSave();
48
+
49
+ $messages = Mage::getSingleton('adminhtml/session')->getMessages(true);
50
+ $success = $messages->getItemsByType(Mage_Core_Model_Message::SUCCESS);
51
+ $error = $messages->getItemsByType(Mage_Core_Model_Message::ERROR);
52
+
53
+ $this->assertEquals(0, count($error));
54
+ $this->assertEquals(1, count($success));
55
+
56
+ $this->assertEquals(
57
+ 'success: ' . Mage::helper('postident')->__('Client-ID and Domain-URI successfully validated by Check-Connect.'),
58
+ current($success)->toString()
59
+ );
60
+ }
61
+
62
+ public function testAfterSaveWithClientException()
63
+ {
64
+ $clientMock = $this->getModelMock('postident/client', array(
65
+ 'sendCheckConnectRequest'
66
+ ));
67
+
68
+ $clientMock
69
+ ->expects($this->once())
70
+ ->method('sendCheckConnectRequest')
71
+ ->will($this->throwException(new DeutschePost_Postident_Model_Client_Exception));
72
+ $this->replaceByMock('model', 'postident/client', $clientMock);
73
+ $this->systemConfigClientid->_afterSave();
74
+
75
+ $messages = Mage::getSingleton('adminhtml/session')->getMessages(true);
76
+ $success = $messages->getItemsByType(Mage_Core_Model_Message::SUCCESS);
77
+ $error = $messages->getItemsByType(Mage_Core_Model_Message::ERROR);
78
+
79
+ $this->assertEquals(1, count($error));
80
+ $this->assertEquals(0, count($success));
81
+ }
82
+
83
+ public function testAfterSaveWithClientResponseException()
84
+ {
85
+ $clientMock = $this->getModelMock('postident/client', array(
86
+ 'sendCheckConnectRequest'
87
+ ));
88
+
89
+ $clientMock
90
+ ->expects($this->once())
91
+ ->method('sendCheckConnectRequest')
92
+ ->will($this->throwException(new DeutschePost_Postident_Model_Client_Response_Exception));
93
+ $this->replaceByMock('model', 'postident/client', $clientMock);
94
+ $this->systemConfigClientid->_afterSave();
95
+
96
+ $messages = Mage::getSingleton('adminhtml/session')->getMessages(true);
97
+ $success = $messages->getItemsByType(Mage_Core_Model_Message::SUCCESS);
98
+ $error = $messages->getItemsByType(Mage_Core_Model_Message::ERROR);
99
+
100
+ $this->assertEquals(1, count($error));
101
+ $this->assertEquals(0, count($success));
102
+ }
103
+ }
app/code/community/DeutschePost/Postident/Test/Model/System/Config/Source/IdcardsTest.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_System_Config_Source_IdcardsTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_System_Config_Source_IdcardsTest extends EcomDev_PHPUnit_Test_Case_Config
19
+ {
20
+ public function testSourceClassExists()
21
+ {
22
+ $this->assertTrue(class_exists('DeutschePost_Postident_Model_System_Config_Source_Idcards'));
23
+ return new DeutschePost_Postident_Model_System_Config_Source_Idcards();
24
+ }
25
+
26
+ /**
27
+ * @depends testSourceClassExists
28
+ */
29
+ public function testToOptionArray(DeutschePost_Postident_Model_System_Config_Source_Idcards $sourceIdcards)
30
+ {
31
+ $this->assertTrue(method_exists($sourceIdcards, "toOptionArray"));
32
+ $this->assertTrue(is_array($sourceIdcards->toOptionArray()));
33
+
34
+ $options = $sourceIdcards->toOptionArray();
35
+ $this->assertNotEmpty($options);
36
+ $this->assertTrue(
37
+ count($options) > 0,
38
+ sprintf(
39
+ "Available ID-Cards calculated (%s) num is not bigger 0",
40
+ count($options)
41
+ )
42
+ );
43
+ }
44
+ }
app/code/community/DeutschePost/Postident/Test/Model/System/Config/Source/VerificationtypeTest.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_System_Config_Source_VerificationtypeTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_System_Config_Source_VerificationtypeTest extends EcomDev_PHPUnit_Test_Case_Config
19
+ {
20
+ public function testSourceClassExists()
21
+ {
22
+ $this->assertTrue(class_exists('DeutschePost_Postident_Model_System_Config_Source_Verificationtype'));
23
+ return new DeutschePost_Postident_Model_System_Config_Source_Verificationtype();
24
+ }
25
+
26
+ /**
27
+ * @depends testSourceClassExists
28
+ */
29
+ public function testToOptionArray(DeutschePost_Postident_Model_System_Config_Source_Verificationtype $sourceVerificationtype)
30
+ {
31
+ $this->assertTrue(method_exists($sourceVerificationtype, "toOptionArray"));
32
+ $this->assertTrue(is_array($sourceVerificationtype->toOptionArray()));
33
+
34
+ $options = $sourceVerificationtype->toOptionArray();
35
+ $this->assertNotEmpty($options);
36
+ $this->assertTrue(
37
+ count($options) > 0,
38
+ sprintf(
39
+ "Available verification types calculated (%s) num is not bigger 0",
40
+ count($options)
41
+ )
42
+ );
43
+ }
44
+ }
app/code/community/DeutschePost/Postident/Test/Model/VerificationTest.php ADDED
@@ -0,0 +1,665 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Test_Model_VerificationTest
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Test_Model_VerificationTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ /**
21
+ * @var Mage_Core_Model_Store
22
+ */
23
+ protected $store;
24
+
25
+ /**
26
+ * @var Mage_Postident_Model_Verification
27
+ */
28
+ protected $verification = null;
29
+
30
+ public function setUp()
31
+ {
32
+ $sessionMock = $this->getModelMock('customer/session', array(
33
+ 'init', 'renewSession', 'start'
34
+ )
35
+ );
36
+ $this->replaceByMock('model', 'customer/session', $sessionMock);
37
+
38
+ $sessionMock = $this->getModelMock('checkout/session', array(
39
+ 'init', 'renewSession', 'start'
40
+ )
41
+ );
42
+ $this->replaceByMock('model', 'checkout/session', $sessionMock);
43
+ $this->store = Mage::app()->getStore(0)->load(0);
44
+ $this->verification = Mage::getModel('postident/verification');
45
+ parent::setup();
46
+ }
47
+
48
+ public function testSetQuote()
49
+ {
50
+ $this->setUp();
51
+ $quote = Mage::getModel('sales/quote');
52
+ $quote->setId(1);
53
+ $this->assertEquals(null, $this->verification->getQuote()->getId());
54
+ $this->verification->setQuote($quote);
55
+ $this->assertEquals(1, $this->verification->getQuote()->getId());
56
+ }
57
+
58
+ public function testGetQuote()
59
+ {
60
+ $this->setUp();
61
+ $this->assertNotNull($this->verification->getQuote());
62
+ $this->assertTrue($this->verification->getQuote() instanceof Mage_Sales_Model_Quote);
63
+ }
64
+
65
+ public function testGetCustomer()
66
+ {
67
+ $this->setUp();
68
+ $this->assertNotNull($this->verification->getCustomer());
69
+ $this->assertTrue($this->verification->getCustomer() instanceof Mage_Customer_Model_Customer);
70
+ }
71
+
72
+ public function testAgeCheckIsRequired()
73
+ {
74
+ $this->setUp();
75
+
76
+ //Successful test - Min age is set and a id card with age check was selected
77
+ $this->store->resetConfig();
78
+ $this->store->setConfig("postident/idcard/number", 10);
79
+ $this->store->setConfig("postident/idcard/testmode", 0);
80
+
81
+ $verificationMock = $this->getModelMock('postident/verification', array(
82
+ 'getMinAge'
83
+ )
84
+ );
85
+ $verificationMock->expects($this->any())
86
+ ->method('getMinAge')
87
+ ->will($this->returnValue(18));
88
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
89
+ $this->assertTrue(Mage::getModel('postident/verification')->ageCheckIsRequired());
90
+
91
+ //Failed test - Min age is not set or 0 and a id card with age check was selected
92
+ $this->store->resetConfig();
93
+ $this->store->setConfig("postident/idcard/number", 10);
94
+ $this->store->setConfig("postident/idcard/testmode", 0);
95
+ $verificationMock = $this->getModelMock('postident/verification', array(
96
+ 'getMinAge'
97
+ )
98
+ );
99
+ $verificationMock->expects($this->any())
100
+ ->method('getMinAge')
101
+ ->will($this->returnValue(0));
102
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
103
+ $this->assertFalse(Mage::getModel('postident/verification')->ageCheckIsRequired());
104
+
105
+ //Failed test - Min age is not set or 0 and a id card with age check was selected
106
+ $this->store->resetConfig();
107
+ $this->store->setConfig("postident/idcard/number", 10);
108
+ $this->store->setConfig("postident/idcard/testmode", 0);
109
+ $this->assertFalse(Mage::getModel('postident/verification')->ageCheckIsRequired());
110
+
111
+ //Failed test - Min age is set and a id card without age check was selected
112
+ $this->store->resetConfig();
113
+ $this->store->setConfig("postident/idcard/number", 40);
114
+ $this->store->setConfig("postident/idcard/testmode", 0);
115
+ $verificationMock = $this->getModelMock('postident/verification', array(
116
+ 'getMinAge'
117
+ )
118
+ );
119
+ $verificationMock->expects($this->any())
120
+ ->method('getMinAge')
121
+ ->will($this->returnValue(18));
122
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
123
+ $this->assertFalse(Mage::getModel('postident/verification')->ageCheckIsRequired());
124
+
125
+ //Failed test - Min age is not set and a id card without age check was selected
126
+ $this->store->resetConfig();
127
+ $this->store->setConfig("postident/idcard/number", 40);
128
+ $this->store->setConfig("postident/idcard/testmode", 0);
129
+ $this->store->setConfig("postident/verification_criteria/age_verification", 0);
130
+ $this->assertFalse(Mage::getModel('postident/verification')->ageCheckIsRequired());
131
+ }
132
+
133
+ public function testIsVerificationRequired()
134
+ {
135
+ $this->setUp();
136
+
137
+ //Test for verification required
138
+ $this->store->resetConfig();
139
+ $this->store->setConfig("postident/general/active", 1);
140
+ $verificationMock = $this->getModelMock('postident/verification', array('ageCheckIsRequired'));
141
+ $verificationMock->expects($this->once())
142
+ ->method('ageCheckIsRequired')
143
+ ->will($this->returnValue(true));
144
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
145
+ $this->assertTrue(Mage::getModel('postident/verification')->isVerificationRequired());
146
+
147
+ //Verification not required
148
+ $this->store->resetConfig();
149
+ $this->store->setConfig("postident/general/active", 0);
150
+ $this->assertFalse(Mage::getModel('postident/verification')->isVerificationRequired());
151
+
152
+ //Verification not required
153
+ $this->store->resetConfig();
154
+ $this->store->setConfig("postident/general/active", 1);
155
+ $verificationMock = $this->getModelMock('postident/verification', array('ageCheckIsRequired'));
156
+ $verificationMock->expects($this->once())
157
+ ->method('ageCheckIsRequired')
158
+ ->will($this->returnValue(false));
159
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
160
+ $this->assertFalse(Mage::getModel('postident/verification')->isVerificationRequired());
161
+ }
162
+
163
+ public function testVerifiyUserByAgeSuccess()
164
+ {
165
+ $this->setUp();
166
+ $postIdentData = array(
167
+ 'identData' => array(
168
+ 'givenname' => 'anton',
169
+ 'dateofbirth' => '1980-05-10'
170
+ ),
171
+ 'verificationDate' => Mage::getModel('core/date')->date("Y-m-d H:i:s")
172
+ );
173
+
174
+
175
+ $this->store->resetConfig();
176
+ $this->store->setConfig("postident/idcard/number", 10);
177
+ $this->store->setConfig("postident/idcard/testmode", 0);
178
+
179
+ $helperMock = $this->getHelperMock('postident/data', array('log'));
180
+ $helperMock->expects($this->once())
181
+ ->method('log')
182
+ ->will($this->returnValue(null));
183
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
184
+
185
+ $verificationMock = $this->getModelMock('postident/verification', array('getPostidentVerificationData'));
186
+ $verificationMock->expects($this->once())
187
+ ->method('getPostidentVerificationData')
188
+ ->will($this->returnValue($postIdentData));
189
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
190
+
191
+ $idCardMock = $this->getModelMock('postident/idCard_idCard10', array('checkAge'));
192
+ $idCardMock->expects($this->once())
193
+ ->method('checkAge')
194
+ ->with($this->equalTo($postIdentData["identData"]))
195
+ ->will($this->returnValue(true));
196
+ $this->replaceByMock('model', 'postident/idCard_idCard10', $idCardMock);
197
+
198
+ $this->assertTrue(Mage::getModel('postident/verification')->verifiyUserByAge());
199
+ }
200
+
201
+ public function testVerifiyUserBecauseOfMissingPostidentData()
202
+ {
203
+ $this->setUp();
204
+
205
+ $this->store->resetConfig();
206
+ $this->store->setConfig("postident/idcard/number", 10);
207
+ $this->store->setConfig("postident/idcard/testmode", 0);
208
+
209
+ $helperMock = $this->getHelperMock('postident/data', array('log'));
210
+ $helperMock->expects($this->never())
211
+ ->method('log')
212
+ ->will($this->returnValue(null));
213
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
214
+
215
+ $verificationMock = $this->getModelMock('postident/verification', array('getPostidentVerificationDataFromQuote'));
216
+ $verificationMock->expects($this->any())
217
+ ->method('getPostidentVerificationDataFromQuote')
218
+ ->will($this->returnValue(null));
219
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
220
+
221
+ $idCardMock = $this->getModelMock('postident/idCard_idCard10', array('checkAge'));
222
+ $idCardMock->expects($this->never())
223
+ ->method('checkAge')
224
+ ->will($this->returnValue(true));
225
+ $this->replaceByMock('model', 'postident/idCard_idCard10', $idCardMock);
226
+
227
+ $this->assertFalse(Mage::getModel('postident/verification')->verifiyUserByAge());
228
+ }
229
+
230
+ public function testVerifiyUserBecauseOfFailedAgeCheck()
231
+ {
232
+ $this->setUp();
233
+
234
+ $this->store->resetConfig();
235
+ $this->store->setConfig("postident/idcard/number", 10);
236
+ $this->store->setConfig("postident/idcard/testmode", 0);
237
+
238
+ $helperMock = $this->getHelperMock('postident/data', array('log'));
239
+ $helperMock->expects($this->once())
240
+ ->method('log')
241
+ ->will($this->returnValue(null));
242
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
243
+
244
+ $verificationMock = $this->getModelMock('postident/verification', array('getPostidentVerificationData'));
245
+ $verificationMock->expects($this->once())
246
+ ->method('getPostidentVerificationData')
247
+ ->will($this->returnValue(array("identData" => array())));
248
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
249
+
250
+ $idCardMock = $this->getModelMock('postident/idCard_idCard10', array('checkAge'));
251
+ $idCardMock->expects($this->once())
252
+ ->method('checkAge')
253
+ ->will($this->returnValue(false));
254
+ $this->replaceByMock('model', 'postident/idCard_idCard10', $idCardMock);
255
+
256
+ $this->assertFalse(Mage::getModel('postident/verification')->verifiyUserByAge());
257
+ }
258
+
259
+ public function testUserIsVerifiedSuccess()
260
+ {
261
+ $verificationMock = $this->getModelMock('postident/verification',
262
+ array('isVerificationRequired', 'ageCheckIsRequired', 'verifiyUserByAge')
263
+ );
264
+
265
+ //Test success because of verification is not required
266
+ $verificationMock->expects($this->once())
267
+ ->method('isVerificationRequired')
268
+ ->will($this->returnValue(false));
269
+
270
+ $verificationMock->expects($this->never())
271
+ ->method('ageCheckIsRequired')
272
+ ->will($this->returnValue(array()));
273
+
274
+ $verificationMock->expects($this->never())
275
+ ->method('verifiyUserByAge')
276
+ ->will($this->returnValue(array()));
277
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
278
+ $this->assertTrue(Mage::getModel('postident/verification')->userIsVerified());
279
+
280
+ //Test success because of verification is required and the user has a valid age verification
281
+ $verificationMock = $this->getModelMock('postident/verification',
282
+ array('isVerificationRequired', 'ageCheckIsRequired', 'verifiyUserByAge')
283
+ );
284
+ $verificationMock->expects($this->once())
285
+ ->method('isVerificationRequired')
286
+ ->will($this->returnValue(true));
287
+
288
+ $verificationMock->expects($this->once())
289
+ ->method('ageCheckIsRequired')
290
+ ->will($this->returnValue(true));
291
+
292
+ $verificationMock->expects($this->once())
293
+ ->method('verifiyUserByAge')
294
+ ->will($this->returnValue(true));
295
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
296
+ $this->assertTrue(Mage::getModel('postident/verification')->userIsVerified());
297
+ }
298
+
299
+ public function testUserIsVerifiedFailure()
300
+ {
301
+ $verificationMock = $this->getModelMock('postident/verification',
302
+ array('isVerificationRequired', 'ageCheckIsRequired', 'verifiyUserByAge')
303
+ );
304
+
305
+ //Test failed because of verification is required and the user has no valid age verification
306
+ $verificationMock = $this->getModelMock('postident/verification',
307
+ array('isVerificationRequired', 'ageCheckIsRequired', 'verifiyUserByAge')
308
+ );
309
+ $verificationMock->expects($this->once())
310
+ ->method('isVerificationRequired')
311
+ ->will($this->returnValue(true));
312
+
313
+ $verificationMock->expects($this->once())
314
+ ->method('ageCheckIsRequired')
315
+ ->will($this->returnValue(true));
316
+
317
+ $verificationMock->expects($this->once())
318
+ ->method('verifiyUserByAge')
319
+ ->will($this->returnValue(false));
320
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
321
+ $this->assertFalse(Mage::getModel('postident/verification')->userIsVerified());
322
+ }
323
+
324
+ public function testUserIsVerifiedException()
325
+ {
326
+ $verificationMock = $this->getModelMock('postident/verification',
327
+ array('isVerificationRequired', 'ageCheckIsRequired', 'verifiyUserByAge')
328
+ );
329
+
330
+ //Test failed because of verification is required and the user has no valid age verification
331
+ $verificationMock = $this->getModelMock('postident/verification',
332
+ array('isVerificationRequired', 'ageCheckIsRequired', 'verifiyUserByAge')
333
+ );
334
+ $verificationMock->expects($this->once())
335
+ ->method('isVerificationRequired')
336
+ ->will($this->throwException(new Exception));
337
+
338
+ $verificationMock->expects($this->never())
339
+ ->method('ageCheckIsRequired')
340
+ ->will($this->returnValue(true));
341
+
342
+ $verificationMock->expects($this->never())
343
+ ->method('verifiyUserByAge')
344
+ ->will($this->returnValue(false));
345
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
346
+
347
+ $helperMock = $this->getHelperMock('postident/data', array('log'));
348
+ $helperMock->expects($this->once())
349
+ ->method('log')
350
+ ->will($this->returnValue(null));
351
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
352
+
353
+ $this->assertFalse(Mage::getModel('postident/verification')->userIsVerified());
354
+ }
355
+
356
+
357
+ /**
358
+ * test get postientdata from quote
359
+ *
360
+ * @test
361
+ * @loadFixture quotes.yaml
362
+ * @loadExpectation quotes.yaml
363
+ */
364
+ public function testGetPostidentVerificationDataFromQuote()
365
+ {
366
+ $quote = Mage::getModel('sales/quote')->load(1);
367
+ $testVerificationData = unserialize($this->_getExpectations()->getVerificationdata());
368
+
369
+ $verificationMock = $this->getModelMock('postident/verification', array('getQuote'));
370
+ $verificationMock->expects($this->any())
371
+ ->method('getQuote')
372
+ ->will($this->returnValue($quote));
373
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
374
+
375
+ $this->assertTrue(is_array($testVerificationData));
376
+ $this->assertEquals(
377
+ $testVerificationData,
378
+ Mage::getModel('postident/verification')->getPostidentVerificationDataFromQuote()
379
+ );
380
+ $this->assertNotEquals(
381
+ 'foo',
382
+ Mage::getModel('postident/verification')->getPostidentVerificationDataFromQuote()
383
+ );
384
+ }
385
+
386
+ /**
387
+ * test get postientdata from customer
388
+ *
389
+ * @test
390
+ * @loadFixture customer.yaml
391
+ * @loadExpectation customer.yaml
392
+ */
393
+ public function testGetPostidentVerificationDataFromCustomer()
394
+ {
395
+ $customer = Mage::getModel('customer/customer')->load(1);
396
+ $testVerificationData = unserialize($this->_getExpectations()->getVerificationdata());
397
+
398
+ $verificationMock = $this->getModelMock('postident/verification', array('getCustomer'));
399
+ $verificationMock->expects($this->any())
400
+ ->method('getCustomer')
401
+ ->will($this->returnValue($customer));
402
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
403
+ $this->assertTrue(is_array($testVerificationData));
404
+ $this->assertEquals(
405
+ $testVerificationData,
406
+ Mage::getModel('postident/verification')->getPostidentVerificationDataFromCustomer()
407
+ );
408
+ $this->assertNotEquals(
409
+ 'foo',
410
+ Mage::getModel('postident/verification')->getPostidentVerificationDataFromCustomer()
411
+ );
412
+ }
413
+ /**
414
+ * test set postientdata on quote
415
+ *
416
+ * @test
417
+ * @loadFixture quotes.yaml
418
+ * @loadExpectation quotes.yaml
419
+ */
420
+ public function testSetPostidentVerificationDataToQuote()
421
+ {
422
+ $quoteMock = $this->getModelMock('sales/quote', array('_beforeSave'));
423
+ $this->replaceByMock('model', 'sales/quote', $quoteMock);
424
+ $quote = Mage::getModel('sales/quote')->load(2);
425
+ $testVerificationData = unserialize($this->_getExpectations()->getVerificationdata());
426
+
427
+ $verificationMock = $this->getModelMock('postident/verification', array('getQuote'));
428
+ $verificationMock->expects($this->any())
429
+ ->method('getQuote')
430
+ ->will($this->returnValue($quote));
431
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
432
+
433
+ //Test if verification data is empty before
434
+ $this->assertFalse(is_array(unserialize($quote->getPostidentVerificationData())));
435
+
436
+ $customerSessionMock = $this->getModelMock('core/session', array('renewSession', 'init', 'start'));
437
+ $this->replaceByMock('model', 'core/session', $customerSessionMock);
438
+
439
+ //Test if expected $testVerificationData was saved correctly to quote
440
+ Mage::getModel('postident/verification')->setPostidentVerificationDataToQuote($testVerificationData["identData"]);
441
+ $this->assertEquals(
442
+ $testVerificationData,
443
+ unserialize($quote->getPostidentVerificationData())
444
+ );
445
+ $quote = Mage::getModel('sales/quote')->load(2);
446
+
447
+ $this->assertTrue(is_array(unserialize($quote->getPostidentVerificationData())));
448
+
449
+
450
+ //Check case if quote is null
451
+ $verificationMock = $this->getModelMock('postident/verification', array('getQuote'));
452
+ $verificationMock->expects($this->any())
453
+ ->method('getQuote')
454
+ ->will($this->returnValue(null));
455
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
456
+ $this->setExpectedException('Mage_Core_Exception');
457
+ Mage::getModel('postident/verification')->setPostidentVerificationDataToQuote($testVerificationData["identData"]);
458
+ }
459
+
460
+ public function testGetPostidentVerificationDataTakeFromQuote()
461
+ {
462
+ $this->setUp();
463
+ $postIdentDataFromQuote = array(
464
+ 'identData' => array(
465
+ 'givenname' => 'anton',
466
+ 'dateofbirth' => '1980-05-10'
467
+ ),
468
+ 'verificationDate' => Mage::getModel('core/date')->date("Y-m-d H:i:s")
469
+ );
470
+ $postIdentDataFromCustomer = array(
471
+ 'identData' => array(
472
+ 'givenname' => 'falk',
473
+ 'dateofbirth' => '1970-01-10'
474
+ ),
475
+ 'verificationDate' => Mage::getModel('core/date')->date("Y-m-d H:i:s")
476
+ );
477
+
478
+ //Test => Take verficiation data from quote
479
+ $verificationMock = $this->getModelMock('postident/verification',
480
+ array('getPostidentVerificationDataFromQuote', 'getPostidentVerificationDataFromCustomer')
481
+ );
482
+ $verificationMock->expects($this->any())
483
+ ->method('getPostidentVerificationDataFromQuote')
484
+ ->will($this->returnValue($postIdentDataFromQuote));
485
+ $verificationMock->expects($this->any())
486
+ ->method('getPostidentVerificationDataFromCustomer')
487
+ ->will($this->returnValue($postIdentDataFromCustomer));
488
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
489
+ $this->assertEquals($postIdentDataFromQuote, Mage::getModel('postident/verification')->getPostidentVerificationData());
490
+ }
491
+
492
+ public function testGetPostidentVerificationDataTakeFromCustomer()
493
+ {
494
+ $this->setUp();
495
+ $postIdentDataFromQuote = array(
496
+ 'identData' => array(
497
+ 'givenname' => 'anton',
498
+ 'dateofbirth' => '1980-05-10'
499
+ ),
500
+ 'verificationDate' => Mage::getModel('core/date')->date("Y-m-d H:i:s")
501
+ );
502
+ $postIdentDataFromCustomer = array(
503
+ 'identData' => array(
504
+ 'givenname' => 'falk',
505
+ 'dateofbirth' => '1970-01-10'
506
+ ),
507
+ 'verificationDate' => Mage::getModel('core/date')->date("Y-m-d H:i:s")
508
+ );
509
+
510
+ //Test => Take verficiation data from customer
511
+ $this->store->resetConfig();
512
+ $this->store->setConfig("postident/verification_criteria/checkout_verification", 0);
513
+
514
+ $verificationMock = $this->getModelMock('postident/verification', array(
515
+ 'getPostidentVerificationDataFromQuote',
516
+ 'getPostidentVerificationDataFromCustomer')
517
+ );
518
+ $verificationMock->expects($this->any())
519
+ ->method('getPostidentVerificationDataFromQuote')
520
+ ->will($this->returnValue(null));
521
+ $verificationMock->expects($this->any())
522
+ ->method('getPostidentVerificationDataFromCustomer')
523
+ ->will($this->returnValue($postIdentDataFromCustomer));
524
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
525
+ $this->assertEquals($postIdentDataFromCustomer, Mage::getModel('postident/verification')->getPostidentVerificationData());
526
+ }
527
+
528
+ public function testGetPostidentVerificationDataTakeFromQuoteIfCustomerHasData()
529
+ {
530
+ $this->setUp();
531
+ $postIdentDataFromQuote = array(
532
+ 'identData' => array(
533
+ 'givenname' => 'anton',
534
+ 'dateofbirth' => '1980-05-10'
535
+ ),
536
+ 'verificationDate' => Mage::getModel('core/date')->date("Y-m-d H:i:s")
537
+ );
538
+ $postIdentDataFromCustomer = array(
539
+ 'identData' => array(
540
+ 'givenname' => 'falk',
541
+ 'dateofbirth' => '1970-01-10'
542
+ ),
543
+ 'verificationDate' => Mage::getModel('core/date')->date("Y-m-d H:i:s")
544
+ );
545
+
546
+ //Test => Take verficiation data from quote if quote and customer both have verification data
547
+ $this->store->resetConfig();
548
+ $this->store->setConfig("postident/verification_criteria/checkout_verification", 0);
549
+
550
+ $verificationMock = $this->getModelMock('postident/verification', array(
551
+ 'getPostidentVerificationDataFromQuote',
552
+ 'getPostidentVerificationDataFromCustomer')
553
+ );
554
+ $verificationMock->expects($this->any())
555
+ ->method('getPostidentVerificationDataFromQuote')
556
+ ->will($this->returnValue($postIdentDataFromQuote));
557
+ $verificationMock->expects($this->any($postIdentDataFromQuote))
558
+ ->method('getPostidentVerificationDataFromCustomer')
559
+ ->will($this->returnValue($postIdentDataFromCustomer));
560
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
561
+ $this->assertEquals($postIdentDataFromQuote, Mage::getModel('postident/verification')->getPostidentVerificationData());
562
+
563
+ }
564
+
565
+ public function testGetPostidentVerificationDataWithNoData()
566
+ {
567
+ //Test => Take no verficiation data because verification should be checked for every checkout
568
+ $this->store->resetConfig();
569
+ $this->store->setConfig("postident/verification_criteria/checkout_verification", 1);
570
+
571
+ $verificationMock = $this->getModelMock('postident/verification',
572
+ array('getPostidentVerificationDataFromQuote', 'getPostidentVerificationDataFromCustomer')
573
+ );
574
+ $verificationMock->expects($this->any())
575
+ ->method('getPostidentVerificationDataFromQuote')
576
+ ->will($this->returnValue(null));
577
+ $verificationMock->expects($this->any())
578
+ ->method('getPostidentVerificationDataFromCustomer')
579
+ ->will($this->returnValue(''));
580
+ $this->replaceByMock('model', 'postident/verification', $verificationMock);
581
+ $this->assertEquals(null, Mage::getModel('postident/verification')->getPostidentVerificationData());
582
+ }
583
+
584
+ /**
585
+ * test case for min age only set global
586
+ */
587
+ public function testGetMinAgeWithGlobalMinAgeSet()
588
+ {
589
+ $configMock = $this->getModelMock('postident/verification', array(
590
+ 'getVerificationType',
591
+ 'getAgeVerification'
592
+ )
593
+ );
594
+ $configMock->expects($this->any())
595
+ ->method('getVerificationType')
596
+ ->will($this->returnValue(DeutschePost_Postident_Model_System_Config_Source_Verificationtype::GLOBAL_VALUE));
597
+ $configMock->expects($this->any())
598
+ ->method('getAgeVerification')
599
+ ->will($this->returnValue(18));
600
+ $this->replaceByMock('model', 'postident/config', $configMock);
601
+
602
+ //test if no global and no product min age are set
603
+ $this->assertEquals(18, Mage::getModel('postident/verification')->getMinAge());
604
+ }
605
+
606
+ /**
607
+ * test case for min age only set on product
608
+ */
609
+ public function testGetMinAgeWithProductMinAgeSet()
610
+ {
611
+ $configMock = $this->getModelMock('postident/verification', array(
612
+ 'getVerificationType',
613
+ )
614
+ );
615
+ $configMock->expects($this->any())
616
+ ->method('getVerificationType')
617
+ ->will($this->returnValue(DeutschePost_Postident_Model_System_Config_Source_Verificationtype::PRODUCT_SPECIFIC));
618
+ $this->replaceByMock('model', 'postident/config', $configMock);
619
+
620
+ $helperMock = $this->getHelperMock('postident/data', array(
621
+ 'checkCart',
622
+ )
623
+ );
624
+
625
+ $helperMock->expects($this->any())
626
+ ->method('checkCart')
627
+ ->will($this->returnValue(18));
628
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
629
+ //test if no global and no product min age are set
630
+ $this->assertEquals(18, Mage::getModel('postident/verification')->getMinAge());
631
+ $this->assertNotEquals(0, Mage::getModel('postident/verification')->getMinAge());
632
+
633
+ }
634
+ /**
635
+ * test case for min age on product AND global
636
+ */
637
+ public function testGetMinAgeWithBothMinAgeSet()
638
+ {
639
+ $configMock = $this->getModelMock('postident/verification', array(
640
+ 'getVerificationType',
641
+ 'getAgeVerification'
642
+ )
643
+ );
644
+ $configMock->expects($this->any())
645
+ ->method('getVerificationType')
646
+ ->will($this->returnValue(DeutschePost_Postident_Model_System_Config_Source_Verificationtype::BOTH_VALUES));
647
+ //return 18 for global min age
648
+ $configMock->expects($this->any())
649
+ ->method('getAgeVerification')
650
+ ->will($this->returnValue(18));
651
+ $this->replaceByMock('model', 'postident/config', $configMock);
652
+
653
+ $helperMock = $this->getHelperMock('postident/data', array(
654
+ 'checkCart',
655
+ )
656
+ );
657
+ //return 21 for global min age
658
+ $helperMock->expects($this->any())
659
+ ->method('checkCart')
660
+ ->will($this->returnValue(21));
661
+ $this->replaceByMock('helper', 'postident/data', $helperMock);
662
+ $this->assertEquals(21, Mage::getModel('postident/verification')->getMinAge());
663
+ $this->assertNotEquals(18, Mage::getModel('postident/verification')->getMinAge());
664
+ }
665
+ }
app/code/community/DeutschePost/Postident/Test/Model/VerificationTest/expectations/customer.yaml ADDED
@@ -0,0 +1 @@
 
1
+ verificationdata: a:1:{s:9:"identData";a:9:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo03";s:11:"dateofbirth";s:21:"1992-11-20 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo03@epost-gka.de";}}
app/code/community/DeutschePost/Postident/Test/Model/VerificationTest/expectations/quotes.yaml ADDED
@@ -0,0 +1 @@
 
1
+ verificationdata: a:1:{s:9:"identData";a:9:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo03";s:11:"dateofbirth";s:21:"1992-11-20 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo03@epost-gka.de";}}
app/code/community/DeutschePost/Postident/Test/Model/VerificationTest/fixtures/customer.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ eav:
2
+ customer:
3
+ - entity_id: 1
4
+ attribute_set_id: 0 # Fix issue with customer entity load
5
+ website_id: 1
6
+ store_id: 1
7
+ created_in: Default Store
8
+ group_id: 1
9
+ firstname: John
10
+ lastname: Doe11
11
+ email: <a href="mailto:john@doe.com">john@doe.com</a>
12
+ postident_verification_data: a:1:{s:9:"identData";a:9:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo03";s:11:"dateofbirth";s:21:"1992-11-20 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo03@epost-gka.de";}}
13
+
14
+
app/code/community/DeutschePost/Postident/Test/Model/VerificationTest/fixtures/quotes.yaml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/quote:
3
+ - entity_id: 1
4
+ postident_verification_data: a:1:{s:9:"identData";a:9:{s:9:"givenname";s:5:"Anton";s:10:"familyname";s:19:"A-netresearchdemo03";s:11:"dateofbirth";s:21:"1992-11-20 00:00:00.0";s:6:"street";s:13:"Moltkestraße";s:11:"housenumber";s:2:"14";s:7:"zipcode";s:5:"53173";s:4:"city";s:4:"Bonn";s:7:"country";s:2:"DE";s:12:"epostaddress";s:38:"anton.a-netresearchdemo03@epost-gka.de";}}
5
+
6
+ - entity_id: 2
7
+ postident_verification_data:
8
+
9
+
app/code/community/DeutschePost/Postident/controllers/Adminhtml/ConfigController.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Controllers_Adminhtml_ConfigController
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Action
19
+ {
20
+
21
+ /**
22
+ * check if the current user is allowed to execute controller action
23
+ *
24
+ * @return string
25
+ */
26
+ protected function _isAllowed()
27
+ {
28
+ return Mage::getSingleton('admin/session')
29
+ ->isAllowed('system/config/postident');
30
+ }
31
+
32
+ /**
33
+ * check if the current user is allowed to see this section
34
+ *
35
+ * @param string
36
+ */
37
+ protected function _checkSectionAllowed($section)
38
+ {
39
+ if (false == Mage::getSingleton('admin/session')
40
+ ->isAllowed('system/config/postident/' . $section)) {
41
+ $this->forward('denied');
42
+ }
43
+ }
44
+
45
+ /**
46
+ * calls the sendCheckConnectRequest Method with clientId and doaminUri
47
+ * and returns the response as JSON
48
+ */
49
+ public function checkConnectAction()
50
+ {
51
+ try {
52
+ Mage::getModel("postident/client")->sendCheckConnectRequest(
53
+ $this->getRequest()->getParam('clientId'), $this->getRequest()->getParam('domainUri')
54
+ );
55
+ $result = array(
56
+ 'message' => Mage::helper('postident')->__("Check Connect Test successful."));
57
+ } catch (DeutschePost_Postident_Model_Client_Exception $e) {
58
+ $result = array('message' => $e->getMessage());
59
+ } catch (DeutschePost_Postident_Model_Client_Response_Exception $e) {
60
+ $result = array('message' => $e->getMessage());
61
+ }
62
+ $this->getResponse()->setBody(
63
+ Zend_Json::encode($result)
64
+ );
65
+ }
66
+ }
app/code/community/DeutschePost/Postident/controllers/CartController.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+
11
+ /**
12
+ * DeutschePost_Postident_Controllers_CartController
13
+ * @author André Herrn <andre.herrn@netresearch.de>
14
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
15
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ class DeutschePost_Postident_CartController extends Mage_Core_Controller_Front_Action
19
+ {
20
+
21
+ /**
22
+ * handles the redirect to the shop after a E-POSTIDENT Request
23
+ *
24
+ * @return void
25
+ */
26
+ public function backAction()
27
+ {
28
+ try {
29
+ $postidentClient = Mage::getModel('postident/client');
30
+
31
+ //Code for Parsing the redirect response
32
+ $responseParams = $this->getRequest()->getParams();
33
+ $clientHelper = Mage::helper('postident/client');
34
+ $clientHelper->validateRedirectResponse($responseParams);
35
+
36
+ //Request access ticket
37
+ $accessToken = $postidentClient->sendAccessTicketRequest($responseParams['code']);
38
+
39
+ //Request identification data
40
+ $identData = $postidentClient->sendIdentDataRequest($accessToken);
41
+
42
+ //Save identification data to quote
43
+ Mage::helper('postident/client')->saveIdentDataToQuote($identData);
44
+
45
+ //if customer is logged in save idenData from quote on customer
46
+
47
+ if (true === Mage::helper('customer')->isLoggedIn()) {
48
+ Mage::helper('postident/data')->saveIdentDataToCustomer();
49
+ }
50
+
51
+ //Check if the user passed the verification requirements
52
+ if (true === Mage::getModel("postident/verification")->userIsVerified()) {
53
+ //Success message, that the identification was passed successfully
54
+ Mage::getSingleton('core/session')->addSuccess(
55
+ Mage::helper('postident')->__('Your data was verified successfully'));
56
+ } else {
57
+ //Identification passed successfully but the verification (by different criteria like age) failed
58
+ throw new DeutschePost_Postident_Model_Verification_Exception(
59
+ "Identification passed successfully but verification failed"
60
+ );
61
+ }
62
+
63
+ //Redirect in Checkout mit success
64
+ $this->_redirect('checkout/onepage/');
65
+
66
+ } catch (DeutschePost_Postident_Helper_Client_Exception $e) {
67
+ $this->handleVerificationError($e, Mage::helper('postident')->__('The identification failed. Please try again.'));
68
+ } catch (DeutschePost_Postident_Model_Client_Exception $e) {
69
+ $this->handleVerificationError($e, Mage::helper('postident')->__('The identification failed. Please try again.'));
70
+ } catch (DeutschePost_Postident_Model_Verification_Exception $e) {
71
+ $this->handleVerificationError(
72
+ $e,
73
+ Mage::helper('postident')->__('The identification was passed succesfully but the verification to enter the checkout failed.')
74
+ );
75
+ } catch (Exception $e) {
76
+ $this->handleVerificationError($e, Mage::helper('postident')->__('A system-error occured. Please try again.'));
77
+ }
78
+ }
79
+
80
+ /**
81
+ *
82
+ * handle the occurence of a verification error
83
+ * and log the error and redirects the customer to cart
84
+ *
85
+ * @param mixed $exception
86
+ * @param string $frontendMessage
87
+ *
88
+ * @return void
89
+ */
90
+ protected function handleVerificationError($exception, $frontendMessage)
91
+ {
92
+ Mage::helper('postident')->log(sprintf('Catched %s with message: %s',
93
+ get_class($exception),
94
+ $exception->getMessage()
95
+ ));
96
+ Mage::getSingleton('core/session')->addError($frontendMessage);
97
+ $this->_redirect('checkout/cart');
98
+ }
99
+ }
100
+
101
+
102
+
app/code/community/DeutschePost/Postident/etc/adminhtml.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Config
5
+ * @package DeutschePost_Postident
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
8
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+ <config>
13
+ <acl>
14
+ <resources>
15
+ <admin>
16
+ <children>
17
+ <system>
18
+ <children>
19
+ <config>
20
+ <children>
21
+ <postident translate="title" module="postident">
22
+ <title>E-POSTIDENT</title>
23
+ </postident>
24
+ </children>
25
+ </config>
26
+ </children>
27
+ </system>
28
+ </children>
29
+ </admin>
30
+ </resources>
31
+ </acl>
32
+ </config>
app/code/community/DeutschePost/Postident/etc/config.xml ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Config
5
+ * @package DeutschePost_Postident
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
8
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <DeutschePost_Postident>
15
+ <version>13.02.28</version>
16
+ </DeutschePost_Postident>
17
+ </modules>
18
+ <global>
19
+ <helpers>
20
+ <postident>
21
+ <class>DeutschePost_Postident_Helper</class>
22
+ </postident>
23
+ </helpers>
24
+ <models>
25
+ <postident>
26
+ <class>DeutschePost_Postident_Model</class>
27
+ <resourceModel>postident_mysql4</resourceModel>
28
+ </postident>
29
+ </models>
30
+ <blocks>
31
+ <postident>
32
+ <class>DeutschePost_Postident_Block</class>
33
+ </postident>
34
+ </blocks>
35
+ <resources>
36
+ <postident_setup>
37
+ <setup>
38
+ <module>DeutschePost_Postident</module>
39
+ </setup>
40
+ <connection>
41
+ <use>default_setup</use>
42
+ </connection>
43
+ </postident_setup>
44
+ <postident_write>
45
+ <connection>
46
+ <use>default_write</use>
47
+ </connection>
48
+ </postident_write>
49
+ <postident_read>
50
+ <connection>
51
+ <use>default_read</use>
52
+ </connection>
53
+ </postident_read>
54
+ </resources>
55
+ </global>
56
+ <admin>
57
+ <routers>
58
+ <postident>
59
+ <use>admin</use>
60
+ <args>
61
+ <module>DeutschePost_Postident</module>
62
+ <frontName>postident</frontName>
63
+ </args>
64
+ </postident>
65
+ </routers>
66
+ </admin>
67
+ <adminhtml>
68
+ <translate>
69
+ <modules>
70
+ <DeutschePost_Postident>
71
+ <files>
72
+ <default>DeutschePost_Postident.csv</default>
73
+ </files>
74
+ </DeutschePost_Postident>
75
+ </modules>
76
+ </translate>
77
+ <layout>
78
+ <updates>
79
+ <postident>
80
+ <file>postident.xml</file>
81
+ </postident>
82
+ </updates>
83
+ </layout>
84
+ </adminhtml>
85
+ <frontend>
86
+ <routers>
87
+ <postident>
88
+ <use>standard</use>
89
+ <args>
90
+ <module>DeutschePost_Postident</module>
91
+ <frontName>postident</frontName>
92
+ </args>
93
+ </postident>
94
+ </routers>
95
+ <translate>
96
+ <modules>
97
+ <DeutschePost_Postident>
98
+ <files>
99
+ <default>DeutschePost_Postident.csv</default>
100
+ </files>
101
+ </DeutschePost_Postident>
102
+ </modules>
103
+ </translate>
104
+ <events>
105
+ <!-- Add a custom html template to shipping and billing step -->
106
+ <core_block_abstract_to_html_after>
107
+ <observers>
108
+ <append_address_data_to_billing_step>
109
+ <class>postident/observer</class>
110
+ <method>appendAddressDataToBillingStep</method>
111
+ </append_address_data_to_billing_step>
112
+ <append_address_data_to_shipping_step>
113
+ <class>postident/observer</class>
114
+ <method>appendAddressDataToShippingStep</method>
115
+ </append_address_data_to_shipping_step>
116
+ </observers>
117
+ </core_block_abstract_to_html_after>
118
+
119
+ <!-- Add a custom layout handle in case that a verification is needed -->
120
+ <controller_action_layout_load_before>
121
+ <observers>
122
+ <postident_observer_add_layout_handle>
123
+ <type>singleton</type>
124
+ <class>postident/observer</class>
125
+ <method>addLayoutHandle</method>
126
+ </postident_observer_add_layout_handle>
127
+ </observers>
128
+ </controller_action_layout_load_before>
129
+
130
+ <!-- Check if user is allowed to access checkout -->
131
+ <controller_action_predispatch_checkout>
132
+ <observers>
133
+ <postident_observer_checkIsVerified>
134
+ <type>singleton</type>
135
+ <class>postident/observer</class>
136
+ <method>checkIsVerified</method>
137
+ </postident_observer_checkIsVerified>
138
+ </observers>
139
+ </controller_action_predispatch_checkout>
140
+ <!-- Save ident data for new customers -->
141
+ <sales_order_place_after>
142
+ <observers>
143
+ <postident_observer_saveIdentDataForNewCustomer>
144
+ <type>singleton</type>
145
+ <class>postident/observer</class>
146
+ <method>saveIdentDataForNewCustomer</method>
147
+ </postident_observer_saveIdentDataForNewCustomer>
148
+ </observers>
149
+ </sales_order_place_after>
150
+ </events>
151
+ <layout>
152
+ <updates>
153
+ <postident>
154
+ <file>postident.xml</file>
155
+ </postident>
156
+ </updates>
157
+ </layout>
158
+ </frontend>
159
+ <default>
160
+ <postident>
161
+ <general>
162
+ <active>0</active>
163
+ </general>
164
+ <idcard>
165
+ <testmode>0</testmode>
166
+ </idcard>
167
+ <idcards>
168
+ <idcard_120>
169
+ <code>120</code>
170
+ <title>Altersprüfung</title>
171
+ </idcard_120>
172
+ <idcard_10>
173
+ <code>10</code>
174
+ <title>Identitätsprüfung Basis</title>
175
+ </idcard_10>
176
+ <idcard_130>
177
+ <code>130</code>
178
+ <title>Identitätsprüfung Premium</title>
179
+ </idcard_130>
180
+ </idcards>
181
+ <design>
182
+ <cart_link_top>0</cart_link_top>
183
+ <cart_link_bottom>1</cart_link_bottom>
184
+ </design>
185
+ <gateway_urls>
186
+ <check_connect_url>https://ident.epost.de/oauth2/clientverification</check_connect_url>
187
+ <postident_url>https://ident.epost.de/oauth2/login</postident_url>
188
+ <access_ticket_url>https://ident.epost.de/oauth2/token</access_ticket_url>
189
+ <identdata_url>https://ident.epost.de/oauth2/identdata</identdata_url>
190
+ </gateway_urls>
191
+ <verification_criteria>
192
+ <age_verification>0</age_verification>
193
+ <checkout_verification>0</checkout_verification>
194
+ <verification_type>global</verification_type>
195
+ </verification_criteria>
196
+ <checkout>
197
+ <use_address_data>1</use_address_data>
198
+ </checkout>
199
+ </postident>
200
+ </default>
201
+ <phpunit>
202
+ <suite>
203
+ <modules>
204
+ <DeutschePost_Postident/>
205
+ </modules>
206
+ </suite>
207
+ </phpunit>
208
+ </config>
app/code/community/DeutschePost/Postident/etc/system.xml ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Config
5
+ * @package DeutschePost_Postident
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
8
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+ <config>
13
+ <sections>
14
+ <postident translate="label" module="postident">
15
+ <label>E-POSTIDENT</label>
16
+ <tab>sales</tab>
17
+ <sort_order>325</sort_order>
18
+ <frontend_type>text</frontend_type>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ <groups>
23
+ <general translate="label comment" module="postident">
24
+ <label>Basic configuration</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>10</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <fields>
31
+ <active translate="label comment" module="postident">
32
+ <label>Enabled</label>
33
+ <frontend_type>select</frontend_type>
34
+ <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ <sort_order>100</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </active>
40
+ <logging_enabled translate="label comment">
41
+ <label>Logging enabled</label>
42
+ <comment><![CDATA[Please ensure that the Magento-Log is activated.]]></comment>
43
+ <frontend_type>select</frontend_type>
44
+ <source_model>adminhtml/system_config_source_yesno</source_model>
45
+ <sort_order>200</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>0</show_in_website>
48
+ <show_in_store>0</show_in_store>
49
+ </logging_enabled>
50
+ </fields>
51
+ </general>
52
+ <master_data translate="label comment" module="postident">
53
+ <label>master data</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>20</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ <fields>
60
+ <client_id translate="label comment" module="postident">
61
+ <label>Client ID</label>
62
+ <comment><![CDATA[The Client-ID must be in the following format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is a character from 0-9 a-f A-F and y either 8,9,A or B.]]></comment>
63
+ <frontend_type>Text</frontend_type>
64
+ <backend_model>postident/system_config_clientid</backend_model>
65
+ <validate>required-entry validate-clientid</validate>
66
+ <sort_order>100</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </client_id>
71
+ <check_connect_button translate="label comment">
72
+ <frontend_model>postident/adminhtml_system_config_checkconnect_button</frontend_model>
73
+ <frontend_type>button</frontend_type>
74
+ <sort_order>200</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </check_connect_button>
79
+ <client_secret translate="label comment">
80
+ <label>ClientSecret</label>
81
+ <frontend_type>password</frontend_type>
82
+ <validate>required-entry validate-clientsecret validate-length maximum-length-20 minimum-length-10</validate>
83
+ <sort_order>300</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </client_secret>
88
+ <domain_uri_notice translate="label">
89
+ <label>Contact to Service-Center</label>
90
+ <frontend_type>text</frontend_type>
91
+ <frontend_model>postident/adminhtml_system_config_domainuri_notice</frontend_model>
92
+ <sort_order>1</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </domain_uri_notice>
97
+ </fields>
98
+ </master_data>
99
+ <idcard translate="label comment" module="postident">
100
+ <label>ID-Cards</label>
101
+ <frontend_type>text</frontend_type>
102
+ <sort_order>30</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ <fields>
107
+ <number translate="label comment" module="postident">
108
+ <label>ID-Card Name</label>
109
+ <comment><![CDATA[Please select the ID-Card which you want to use for the customer identification. More detailed informations about all possible ID-Cards can be found here: <a href="http://www.netresearch.de/fileadmin/user_upload/partner-deutschepost/epostident/downloads/ID-Card_und_PreisA1_4bersicht_E-POSTIDENT.pdf">E_PSOTIDENT price-list</a>]]></comment>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>postident/system_config_source_idcards</source_model>
112
+ <validate>required-entry</validate>
113
+ <sort_order>10</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </number>
118
+ <testmode translate="label comment" module="postident">
119
+ <label>Testmode</label>
120
+ <comment><![CDATA[If test mode is activated, a charge free Test ID-Card will be used. This ID Card returns the values:<br />- first name<br />- last name<br />- date of birth<br />- E-Postbrief address<br />- mobile number]]></comment>
121
+ <frontend_type>select</frontend_type>
122
+ <source_model>adminhtml/system_config_source_yesno</source_model>
123
+ <sort_order>20</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
+ </testmode>
128
+ </fields>
129
+ </idcard>
130
+ <gateway_urls translate="label comment" module="postident">
131
+ <label>Gateway URLs</label>
132
+ <frontend_type>text</frontend_type>
133
+ <sort_order>40</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>0</show_in_website>
136
+ <show_in_store>0</show_in_store>
137
+ <fields>
138
+ <gateway_notice translate="label">
139
+ <label>Gateway Notes</label>
140
+ <frontend_type>text</frontend_type>
141
+ <frontend_model>postident/adminhtml_system_config_gateway_notice</frontend_model>
142
+ <sort_order>1</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ </gateway_notice>
147
+ <check_connect_url translate="label comment">
148
+ <label>Check Connect URL</label>
149
+ <frontend_type>Text</frontend_type>
150
+ <comment><![CDATA[Gateway URL for the Check Connect Service]]></comment>
151
+ <validate>required-entry validate-url</validate>
152
+ <sort_order>10</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>0</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ </check_connect_url>
157
+ <postident_url translate="label comment">
158
+ <label>E-POSTIDENT URL</label>
159
+ <frontend_type>Text</frontend_type>
160
+ <comment><![CDATA[Gateway URL for the E-POSTIDENT-Verification Request]]></comment>
161
+ <validate>required-entry validate-url</validate>
162
+ <sort_order>20</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>0</show_in_website>
165
+ <show_in_store>0</show_in_store>
166
+ </postident_url>
167
+ <access_ticket_url translate="label comment">
168
+ <label>Access-Token URL</label>
169
+ <frontend_type>Text</frontend_type>
170
+ <comment><![CDATA[The Gateway URL for E-POSTIDENT-Verification Access-Ticket-Request.]]></comment>
171
+ <validate>required-entry validate-url</validate>
172
+ <sort_order>30</sort_order>
173
+ <show_in_default>1</show_in_default>
174
+ <show_in_website>0</show_in_website>
175
+ <show_in_store>0</show_in_store>
176
+ </access_ticket_url>
177
+ <identdata_url>
178
+ <label>Identdata URL</label>
179
+ <frontend_type>Text</frontend_type>
180
+ <comment><![CDATA[The Gateway URL for E_POSTIDENT-Verification Identity-Request.]]></comment>
181
+ <validate>required-entry validate-url</validate>
182
+ <sort_order>40</sort_order>
183
+ <show_in_default>1</show_in_default>
184
+ <show_in_website>0</show_in_website>
185
+ <show_in_store>0</show_in_store>
186
+ </identdata_url>
187
+ </fields>
188
+ </gateway_urls>
189
+ <verification_criteria translate="label comment" module="postident">
190
+ <label>Verification Criteria</label>
191
+ <frontend_type>text</frontend_type>
192
+ <sort_order>50</sort_order>
193
+ <show_in_default>1</show_in_default>
194
+ <show_in_website>1</show_in_website>
195
+ <show_in_store>1</show_in_store>
196
+ <fields>
197
+ <age_verification translate="label comment">
198
+ <label>Minimum age (in years)</label>
199
+ <frontend_type>Text</frontend_type>
200
+ <comment><![CDATA[Leave field empty or enter "0" if there should be no age verification. The minimum age, if filled, is used as criteria to enter the checkout and finish the order.]]></comment>
201
+ <validate>validate-number</validate>
202
+ <sort_order>10</sort_order>
203
+ <show_in_default>1</show_in_default>
204
+ <show_in_website>1</show_in_website>
205
+ <show_in_store>1</show_in_store>
206
+ </age_verification>
207
+ <checkout_verification translate="label comment">
208
+ <label>Verification on every Checkout</label>
209
+ <frontend_type>select</frontend_type>
210
+ <source_model>adminhtml/system_config_source_yesno</source_model>
211
+ <comment><![CDATA[Enable, if a new verification is needed for every checkout.]]></comment>
212
+ <sort_order>20</sort_order>
213
+ <show_in_default>1</show_in_default>
214
+ <show_in_website>1</show_in_website>
215
+ <show_in_store>1</show_in_store>
216
+ </checkout_verification>
217
+ <verification_type translate="label comment">
218
+ <label>Verification type</label>
219
+ <frontend_type>select</frontend_type>
220
+ <source_model>DeutschePost_Postident_Model_System_Config_Source_Verificationtype</source_model>
221
+ <comment><![CDATA[Here you can select which type of age verification is used.]]></comment>
222
+ <sort_order>5</sort_order>
223
+ <show_in_default>1</show_in_default>
224
+ <show_in_website>1</show_in_website>
225
+ <show_in_store>1</show_in_store>
226
+ </verification_type>
227
+ </fields>
228
+ </verification_criteria>
229
+ <checkout translate="label comment" module="postident">
230
+ <label>Checkout</label>
231
+ <frontend_type>text</frontend_type>
232
+ <sort_order>100</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>1</show_in_store>
236
+ <fields>
237
+ <use_address_data translate="label comment">
238
+ <label>Address data usage</label>
239
+ <frontend_type>select</frontend_type>
240
+ <source_model>adminhtml/system_config_source_yesno</source_model>
241
+ <comment><![CDATA[If activated, the customer can use his verified address data to populate registration and shipping form.]]></comment>
242
+ <sort_order>100</sort_order>
243
+ <show_in_default>1</show_in_default>
244
+ <show_in_website>1</show_in_website>
245
+ <show_in_store>1</show_in_store>
246
+ </use_address_data>
247
+ </fields>
248
+ </checkout>
249
+ </groups>
250
+ </postident>
251
+ </sections>
252
+ </config>
app/code/community/DeutschePost/Postident/sql/postident_setup/mysql4-install-12.11.14.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ /**
11
+ * DeutschePost_Postident_Sql_Postident_Setup
12
+ * @author André Herrn <andre.herrn@netresearch.de>
13
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
14
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ $installer = $this;
18
+ $installer->startSetup();
19
+
20
+ // add additional data to quote table
21
+ $installer->getConnection()
22
+ ->addColumn(
23
+ $installer->getTable('sales_flat_quote'),
24
+ 'postident_verification_data',
25
+ 'text NULL DEFAULT NULL'
26
+ );
27
+
28
+ //Add new product attribute epostident_minage for minimum age
29
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
30
+ $setup->addAttribute('catalog_product', 'epostident_minage', array(
31
+ 'group' => 'General',
32
+ 'label' => 'E-POSTIDENT Minimum age',
33
+ 'type' => 'int',
34
+ 'input' => 'text',
35
+ 'source' => '',
36
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
37
+ 'required' => false,
38
+ 'default' => DeutschePost_Postident_Model_Entity_Attribute_Source_Productminage::USE_DEFAULT,
39
+ 'user_defined' => 0,
40
+ 'apply_to' => array(),
41
+ 'used_in_product_listing' => 1,
42
+ 'is_configurable' => 0,
43
+ 'filterable_in_search' => 0,
44
+ 'used_for_price_rules' => 0,
45
+ ));
46
+
47
+ // add additional data to customer table
48
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
49
+
50
+ $entityTypeId = $setup->getEntityTypeId('customer');
51
+ $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
52
+ $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
53
+
54
+ $setup->addAttribute('customer', 'postident_verification_data', array(
55
+ 'type' => 'text',
56
+ 'label' => 'postident verification data',
57
+ 'required' => false,
58
+ 'note' => 'JSON Postident Verification Data',
59
+ ));
60
+
61
+ $setup->addAttributeToGroup(
62
+ $entityTypeId,
63
+ $attributeSetId,
64
+ $attributeGroupId,
65
+ 'postident_verification_data',
66
+ '999' //sort_order
67
+ );
68
+
69
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/postident.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Layout
5
+ * @package DeutschePost_Postident
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
8
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+ <layout>
13
+ <adminhtml_system_config_edit>
14
+ <reference name="head">
15
+ <action method="addJs"><script>postident/adminhtml/validation.js</script></action>
16
+ <action method="addJs"><script>postident/adminhtml/checkconnect.js</script></action>
17
+ </reference>
18
+ <reference name="content">
19
+ <block name="postident_validate" type="adminhtml/template" template="postident/validate.phtml" />
20
+ </reference>
21
+ </adminhtml_system_config_edit>
22
+
23
+ <adminhtml_customer_edit>
24
+ <reference name="customer_edit_tabs">
25
+ <action method="addTab">
26
+ <name>customer_edit_tab_postident_verificationdata</name>
27
+ <block>postident/adminhtml_customer_edit_tab_verificationdata</block>
28
+ </action>
29
+ </reference>
30
+ </adminhtml_customer_edit>
31
+
32
+ </layout>
app/design/adminhtml/default/default/template/postident/customer/verificationdata.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $identData = $this->getPostidentVerificationData();
3
+ ?>
4
+ <div id="customer_info_tabs_customer_edit_tab_view_content">
5
+ <div class="entry-edit">
6
+ <div class="entry-edit-head">
7
+ <h4 class="icon-head head-customer-view">
8
+ <?php echo $this->__('E-POSTIDENT verification data') ?>
9
+ </h4>
10
+ </div>
11
+ <fieldset>
12
+ <?php if (is_array($identData) && array_key_exists('identData', $identData)): ?>
13
+ <table id="box-left" cellspacing="15">
14
+ <tbody>
15
+ <?php foreach ($identData['identData'] as $key => $value): ?>
16
+ <tr>
17
+ <td><strong><?php echo $this->__($this->escapeHtml($key)) . ":"; ?></strong></td>
18
+ <td><?php echo $this->escapeHtml($value); ?></td>
19
+ </tr>
20
+ <?php endforeach; ?>
21
+ </tbody>
22
+ </table>
23
+ <?php else: ?>
24
+ <p> <?php echo $this->__('For this customer verification data doesnt exist.') ?> </p>
25
+ <?php endif; ?>
26
+ </fieldset>
27
+ </div>
28
+ </div>
app/design/adminhtml/default/default/template/postident/system/config/domainuri/notice.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ var domainUri = "<?php Mage::helper('postident')->getDomainUri(); ?>";
3
+ </script>
4
+ <div class="switcher">
5
+ <h3><?php print Mage::helper('postident')->__('Domain-URI') ?></h3>
6
+ <p><?php print Mage::helper('postident')->__('Actual Store-Domain-URI:') ?> <b> <?php print Mage::helper('postident')->getDomainUri(); ?> </b> </p>
7
+ <p>
8
+ <?php print Mage::helper('postident')->__('Please check that the actual Store-Domain-URI is entered in the E-POSTIDENT self administration portal and is set to active.') ?> <br>
9
+ <?php print Mage::helper('postident')->__('Please enter all domains of your stores in which E-POSTIDENT should be used also in the E-POSTIDENT self administration portal.') ?> <br>
10
+ <?php print Mage::helper('postident')->__('The Domain associated parameters Client-ID, Client Secret and Alias need to be entered here.') ?> <br>
11
+ </p>
12
+ </div>
app/design/adminhtml/default/default/template/postident/system/config/gateway/notice.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <div class="switcher">
2
+ <p>
3
+ <?php print Mage::helper('postident')->__('This are service links provided by Deutsche Post AG. Please only change them, if they tould you so.For Test-Mode use ident.epost-gka.de insteat of ident.epost.de.') ?> <br>
4
+ </p>
5
+ </div>
app/design/adminhtml/default/default/template/postident/validate.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ Translator.add('Only charakters a-z, A-Z, 0-9 are allowed.', '<?php echo Mage::helper('postident')->__('Only charakters a-z, A-Z, 0-9 are allowed.') ?>');
3
+ Translator.add('Please Enter a valid Client-ID.', '<?php echo Mage::helper('postident')->__('Please Enter a valid Client-ID.') ?>');
4
+ Translator.add('Check Connect Error: Message not found.', '<?php echo Mage::helper('postident')->__('Check Connect Error: Message not found.') ?>');
5
+ Translator.add('Check Connect Error: Response is no JSON format.', '<?php echo Mage::helper('postident')->__('Check Connect Error: Response is no JSON format.') ?>');
6
+ Translator.add('Check Connect request failed.', '<?php echo Mage::helper('postident')->__('Check Connect request failed.') ?>');
7
+ </script>
app/design/frontend/base/default/layout/postident.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Layout
5
+ * @package DeutschePost_Postident
6
+ * @author André Herrn <andre.herrn@netresearch.de>
7
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
8
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+ <layout version="0.1.0">
13
+ <!--
14
+ Custom Update Handle
15
+
16
+ IF veritifaction doesn't exist for the customer
17
+ AND verification is required
18
+ THEN remove checkout buttons
19
+ -->
20
+
21
+ <!-- All Shop areas -->
22
+ <postident_verification_required>
23
+ <reference name="top.links">
24
+ <!-- Remove cart and checkout link - unfortunately only both of them can be deleted together -->
25
+ <remove name="checkout_cart_link" />
26
+
27
+ <!-- Welcome back cart link - Add cart link after it was removed -->
28
+ <block type="checkout/links" name="checkout_cart_link_custom">
29
+ <action method="addCartLink"></action>
30
+ </block>
31
+ </reference>
32
+ </postident_verification_required>
33
+
34
+ <!-- Checkout cart area -->
35
+ <postident_checkout_cart_verification_required>
36
+ <reference name="checkout.cart">
37
+ <!-- Remove "Checkout"/"Zur Kasse"-Buttons -->
38
+ <remove name="checkout.cart.methods.onepage" />
39
+
40
+ <!-- Remove Multishipping Bottom Block -->
41
+ <remove name="checkout.cart.methods.multishipping" />
42
+
43
+ <!-- Remove Paypal UK Express Bottom Block -->
44
+ <remove name="checkout.cart.methods.paypaluk_express.bottom" />
45
+
46
+ <!-- Remove Paypal Express Bottom Block -->
47
+ <remove name="checkout.cart.methods.paypal_express.bottom" />
48
+
49
+ <!-- Remove Googlecheckout Bottom Block -->
50
+ <remove name="checkout.cart.methods.googlecheckout.bottom" />
51
+
52
+ <!-- Remove Paypal UK Express Top Block -->
53
+ <remove name="checkout.cart.methods.paypaluk_express.top" />
54
+
55
+ <!-- Remove Paypal Express Top Block -->
56
+ <remove name="checkout.cart.methods.paypal_express.top" />
57
+
58
+ <!-- Remove Googlecheckout Top Block -->
59
+ <remove name="checkout.cart.methods.googlecheckout.top" />
60
+ </reference>
61
+
62
+ <!-- Add PostIdent Info Block -->
63
+ <reference name="checkout.cart.methods">
64
+ <block
65
+ type="postident/checkout_cart_link"
66
+ name="checkout.cart.methods.postident_link.bottom"
67
+ before="-">
68
+ <action method="setTemplate">
69
+ <template>postident/checkout/cart/link.phtml</template>
70
+ </action>
71
+ </block>
72
+ </reference>
73
+
74
+ <!-- Add postident.css -->
75
+ <reference name="head">
76
+ <action method="addCss"><stylesheet>css/postident.css</stylesheet></action>
77
+ </reference>
78
+ </postident_checkout_cart_verification_required>
79
+
80
+ <!-- onepage checkout area -->
81
+ <checkout_onepage_index>
82
+ <reference name="head">
83
+ <action method="addCss" ifconfig="postident/checkout/use_address_data"><stylesheet>css/postident.css</stylesheet></action>
84
+ </reference>
85
+
86
+ <!-- Add address.phtml to checkout -->
87
+ <reference name="content">
88
+ <block type="postident/checkout_address" name="postident_address_data" as="postident_address_data">
89
+ <action method="setTemplate" ifconfig="postident/checkout/use_address_data">
90
+ <template>postident/checkout/address.phtml</template>
91
+ </action>
92
+ </block>
93
+ </reference>
94
+
95
+ <!-- Add addressdata.js to checkout -->
96
+ <reference name="head">
97
+ <action method="addJs" ifconfig="postident/checkout/use_address_data"><script>postident/checkout/addressdata.js</script></action>
98
+ </reference>
99
+ </checkout_onepage_index>
100
+ </layout>
app/design/frontend/base/default/template/postident/checkout/address.phtml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ ?>
11
+
12
+ <script type="text/javascript">
13
+ //<![CDATA[
14
+ //Initialize Postident Class with JSON Identification data
15
+ var postidentAddressData = new PostidentAddressData('<?php echo $this->getPostidentDataAsJson() ?>');
16
+
17
+ //If Dom is loaded -> Set event listeners to billing address and shipping address form
18
+ document.observe("dom:loaded", function() {
19
+
20
+
21
+ /*
22
+ * early return if there is no postident data
23
+ * so we wont show the button in the checkout
24
+ */
25
+ if (false === postidentAddressData.hasPostidentData()) {
26
+ return;
27
+ }
28
+
29
+ /*
30
+ * Move the postident button and hover window to the new address node
31
+ * After it will be visible only if "New address" was selected in the address selector
32
+ */
33
+ movePostidentButtonToAddressEnd("billing");
34
+ movePostidentButtonToAddressEnd("shipping");
35
+ setEventToButton('billing');
36
+ setEventToButton('shipping');
37
+
38
+ });
39
+
40
+ //Add Javascript-Translations for Prefix Field
41
+ Translator.add('mr', '<?php echo Mage::helper('postident')->__('mr') ?>');
42
+ Translator.add('mrs', '<?php echo Mage::helper('postident')->__('mrs') ?>');
43
+
44
+ function setEventToButton(addressType)
45
+ {
46
+ //If form fields are empty - automatically replace address fields with Postident Data
47
+ if (true === postidentAddressData.checkFormFieldsEmpty(addressType)) {
48
+ postidentAddressData.updateFormData(addressType);
49
+ }
50
+
51
+ //Show/Hide Hover-Window with Postident address data
52
+ Event.observe($('postidentinfo_sign_' + addressType), 'mouseover', function(event) {
53
+ $('postidentinfo_content_' + addressType).style.display = 'block';
54
+ })
55
+ Event.observe($('postidentinfo_sign_' + addressType), 'mouseout', function(event) {
56
+ $('postidentinfo_content_' + addressType).style.display = 'none';
57
+ })
58
+ }
59
+
60
+
61
+ function movePostidentButtonToAddressEnd(addressType) {
62
+ //Postident Node to replace
63
+ var postidentNode = $('postident_' + addressType + '_adressdata');
64
+
65
+ //New address form node
66
+ var newAddressNode = $(addressType + '-new-address-form');
67
+
68
+ //Check if both nodes exist
69
+ if (null === postidentNode || null === newAddressNode) {
70
+ return;
71
+ }
72
+
73
+ //Add postident node at the end of the new address area
74
+ newAddressNode.insertBefore(postidentNode, newAddressNode.lastChild);
75
+
76
+ //Enable visibility of postident node
77
+ if (false === postidentAddressData.checkFormFieldsEmpty(addressType)
78
+ && false === postidentAddressData.checkFormFieldsAreSame(addressType)) {
79
+ postidentNode.show();
80
+ }
81
+ }
82
+ //]]>
83
+ </script>
app/design/frontend/base/default/template/postident/checkout/cart/link.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ ?>
11
+ <?php
12
+ /**
13
+ * @see DeutschePost_Postident_Block_Checkout_Cart_Link
14
+ */
15
+ ?>
16
+ <?php
17
+ $helper = Mage::helper("postident");
18
+ $buttonText = $helper->__('Identify now');
19
+ ?>
20
+
21
+ <div class="postident_verification">
22
+ <p class="verification_text">
23
+ <!-- Age verification -->
24
+ <?php if ($this->getIdCard() == DeutschePost_Postident_Model_IdCard_IdCard120::IDCARD_VALUE): ?>
25
+ <?php echo $helper->__("You have age-restricted products in your shopping cart. For child-protection reasons, we ask for an age verification by") ?>
26
+ <?php $buttonText = $helper->__('Verify age now') ?>
27
+ <!-- Identification -->
28
+ <?php else: ?>
29
+ <?php echo $helper->__("For safety reasons we ask for an online identification by") ?>
30
+ <?php endif; ?>
31
+ </p>
32
+ <img
33
+ src="<?php echo $this->getSkinUrl('images/postident/produktzeichen/DP_E-POSTIDENT_Produktzeichen_160.png'); ?>"
34
+ title="<?php echo $helper->__("E-POSTIDENT Logo"); ?>"
35
+ class="epostident_logo" />
36
+ <button class="button btn-proceed-checkout btn-checkout"
37
+ onclick="window.location = '<?php echo $this->getPostidentLink() ?>';"
38
+ title="<?php echo $buttonText ?>" type="button">
39
+ <span>
40
+ <span><?php echo $buttonText ?></span>
41
+ </span>
42
+ </button>
43
+ </div>
app/design/frontend/base/default/template/postident/checkout/onepage/billing.phtml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ ?>
11
+
12
+ <?php $identData = $this->getPostidentData() ?>
13
+
14
+ <div id="postident_billing_adressdata" class="postident_adressdata" style="display:none">
15
+ <div class="field">
16
+ <button
17
+ class="button"
18
+ id="billing-use-postidentdata-button"
19
+ title="<?php echo $this->__('Prefill form fields with verified E-POSTIDENT data'); ?>"
20
+ onclick="postidentAddressData.updateFormData('billing');return false;">
21
+ <span>
22
+ <span><?php echo $this->__('Use E-POSTIDENT data'); ?></span>
23
+ </span>
24
+ </button>
25
+ <div class="postidentinfo">
26
+ <span id="postidentinfo_sign_billing">?<span>
27
+ <div class="postidentinfo_content" id="postidentinfo_content_billing">
28
+ <p><?php echo $this->__('This is your verified data.') ?>
29
+ <img id="postidentlogo" src="<?php echo $this->getSkinUrl('images/postident/produktzeichen/DP_E-POSTIDENT_Produktzeichen_160'); ?>" alt="produktzeichen" />
30
+ </p>
31
+ <?php if (is_array($identData)): ?>
32
+ <table class="identdatatable">
33
+ <tbody>
34
+ <?php foreach ($identData as $key => $value): ?>
35
+ <tr>
36
+ <td><strong><?php echo $this->__($this->escapeHtml($key)) . ":"; ?></strong></td>
37
+ <td><?php echo $this->__($this->escapeHtml($value)); ?></td>
38
+ </tr>
39
+ <?php endforeach; ?>
40
+ </tbody>
41
+ </table>
42
+ <?php endif; ?>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ </div>
app/design/frontend/base/default/template/postident/checkout/onepage/shipping.phtml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category DeutschePost Postident
4
+ * @package DeutschePost_Postident
5
+ * @author André Herrn <andre.herrn@netresearch.de>
6
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
7
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ ?>
11
+
12
+ <?php $identData = $this->getPostidentData() ?>
13
+
14
+ <div id="postident_shipping_adressdata" class="postident_adressdata" style="display:none">
15
+ <div class="field">
16
+ <button
17
+ class="button"
18
+ id="shipping-use-postidentdata-button"
19
+ title="<?php echo $this->__('Prefill form fields with verified E-POSTIDENT data'); ?>"
20
+ onclick="postidentAddressData.updateFormData('shipping');return false;">
21
+ <span>
22
+ <span><?php echo $this->__('Use E-POSTIDENT data'); ?></span>
23
+ </span>
24
+ </button>
25
+ <div class="postidentinfo">
26
+ <span id="postidentinfo_sign_shipping">?<span>
27
+ <div class="postidentinfo_content" id="postidentinfo_content_shipping">
28
+ <p><?php echo $this->__('This is your verified data.') ?>
29
+ <img id="postidentlogo" src="<?php echo $this->getSkinUrl('images/postident/produktzeichen/DP_E-POSTIDENT_Produktzeichen_160'); ?>" alt="produktzeichen" />
30
+ </p>
31
+ <?php if (is_array($identData)): ?>
32
+ <table class="identdatatable">
33
+ <tbody>
34
+ <?php foreach ($identData as $key => $value): ?>
35
+ <tr>
36
+ <td><strong><?php echo $this->__($this->escapeHtml($key)) . ":"; ?></strong></td>
37
+ <td><?php echo $this->__($this->escapeHtml($value)); ?></td>
38
+ </tr>
39
+ <?php endforeach; ?>
40
+ </tbody>
41
+ </table>
42
+ <?php endif; ?>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ </div>
app/etc/modules/DeutschePost_Postident.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Magento
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * If you did not receive a copy of the license and are unable to
14
+ * obtain it through the world-wide-web, please send an email
15
+ * to license@magentocommerce.com so we can send you a copy immediately.
16
+ *
17
+ * @category Magento Module
18
+ * @package DeutschePost_Postident
19
+ * @copyright Copyright (c) 2010 Netresearch GmbH & Co. KG (http://www.netresearch.de)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <DeutschePost_Postident>
26
+ <active>true</active>
27
+ <codePool>community</codePool>
28
+ </DeutschePost_Postident>
29
+ </modules>
30
+ </config>
app/locale/de_DE/DeutschePost_Postident.csv ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Enabled","Aktiviert"
2
+ "Yes","Ja"
3
+ "ID-Card Name","ID-Card Name"
4
+ "Please select the ID-Card which you want to use for the customer identification. More detailed informations about all possible ID-Cards can be found here: <a href=""http://www.netresearch.de/fileadmin/user_upload/partner-deutschepost/epostident/downloads/ID-Card_und_PreisA1_4bersicht_E-POSTIDENT.pdf"">E_PSOTIDENT price-list</a>","Bitte wählen Sie die ID-Card, welche für die Kundenidentifikation verwendet werden soll. Ausführliche Informationen zum Thema ID-Cards finden Sie auf der Webseite: <a href=""http://www.netresearch.de/fileadmin/user_upload/partner-deutschepost/epostident/downloads/ID-Card_und_PreisA1_4bersicht_E-POSTIDENT.pdf"">E-POSTIDENT Preisliste</a>"
5
+ "Logging enabled","Logging aktiviert"
6
+ "Please ensure that the Magento-Log is activated.","Bitte stellen Sie sicher das der Magento-Log aktiviert ist"
7
+ "Basic configuration","Basis-Konfiguration"
8
+ "master data","Stammdaten"
9
+ "Actual Store-Domain-URI:","Aktuelle Shop-Domain-URI:"
10
+ "Only charakters a-z, A-Z, 0-9 are allowed.","Es sind nur die Zeichen a-z, A-Z, 0-9 erlaubt."
11
+ "This is a required field.","Dies ist ein Pflichtfeld."
12
+ "Please Enter a valid Client-ID.","Bitte geben Sie eine gültige Client-ID ein."
13
+ "Text length does not satisfy specified text range.","Die Länge der Eingabe muss zwischen 10 und 20 Zeichen liegen."
14
+ "Please ensure that the Magento-Log is activated.","Bitte stellen Sie sicher das der Magento-Log aktiviert ist"
15
+ "The Client-ID must be in the following format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is a character from 0-9 a-f A-F and y either 8,9,A or B.","Die Client-ID muss folgendes Format besitzen:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx an den Positionen mit x können Zeichen von 0-9 a-f und A-F vorkommen, an den Stellen mit y nur die Zeichen 8,9,A,B."
16
+ "Please check that the actual Store-Domain-URI is entered in the E-POSTIDENT self administration portal and is set to active.","Bitte prüfen Sie, dass die aktuelle Store-Domain-URI im E-POSTIDENT Selbstadministrationsportal eingetragen und aktiv ist."
17
+ "Please enter all domains of your stores in which E-POSTIDENT should be used also in the E-POSTIDENT self administration portal.","Bitte tragen Sie alle Domains Ihrer Shops, in denen E-POSTIDENT verwendet werden soll, auch im E-POSTIDENT - Selbstverwaltungsportal ein."
18
+ "Please enter a valid URL. Protocol is required (http://, https:// or ftp://)","Bitte geben Sie eine gültige URL ein. Protokoll ist erforderlich (http://, https:// or ftp://)"
19
+ "The Domain associated parameters Client-ID, Client Secret and Alias need to be entered here.","Die zur Domain gehörenden Parameter Client-ID, Client Secret und Alias sind ebenfalls hier zu hinterlegen."
20
+ "This are service links provided by Deutsche Post AG. Please only change them, if they tould you so.For Test-Mode use ident.epost-gka.de insteat of ident.epost.de.","Dies sind vorgegebene Service-Links der Deutschen Post AG. Bitte nur bei expliziter Aufforderung durch die Deutsche Post AG ändern. Benutzen Sie für den Test-Modus ident.epost-gka.de anstelle von ident.epost.de."
21
+ "The Client-ID doens't exist","Die Client-ID existiert nicht"
22
+ "Error during Check-Connect-Validation: '%s'.","Fehler bei der Check-Connect-Überprüfung: '%s'."
23
+ "The Client-ID exists but was not activated yet","Die angegebene Client-ID existiert, wurde aber nicht aktiviert"
24
+ "The Client-ID exists but the Domain-URI doesn't match to it","Die Client-ID existiert, aber die Domain-URI passt nicht zur Client-ID"
25
+ "Client-ID and Domain-URI successfully validated by Check-Connect.","Die Client-ID und Domain-URI wurden erfolgreich per Check-Connect validiert."
26
+ "Unknown Check-Connect-Response-Code","Unbekannter Check-Connect-Response-Code"
27
+ "Check Connect request failed.","Check-Connect-Request fehlgeschlagen."
28
+ "Check Connect Error: Message not found.","Check-Connect-Fehler: Nachricht nicht gefunden."
29
+ "Check Connect Error: Response is no JSON format.","Check-Connect-Fehler: Response ist nicht im JSON-Format."
30
+ "Check Connect Test successful.","Check-Connect-Test erfolgreich."
31
+ "Unable to connect to E-POSTIDENT Webservice: Name or service not known","Verbindung zu E-POSTIDENT konnte nicht hergestellt werden: Name und Service unbekannt"
32
+ "Testmode","Testmodus"
33
+ "If test mode is activated, a charge free Test ID-Card will be used. This ID Card returns the values:<br />- first name<br />- last name<br />- date of birth<br />- E-Postbrief address<br />- mobile number","Bei aktiviertem Testmodus wird eine kostenlose Test-ID-Card verwendet. Diese ID-Card liefert folgende Werte:<br />- Vorname<br />- Nachname<br />- Geburtsdatum<br />- E-POSTBRIEF Adresse<br />- Mobilfunknummer"
34
+ "Identify yourself now","Jetzt identifizieren"
35
+ "For safety reasons we ask for an online identification by","Aus Sicherheitsgründen bitten wir um eine Online Identifikation per"
36
+ "Identify now","Jetzt Identifizieren"
37
+ "Verification Criteria","Verifikationskriterien"
38
+ "Minimum age (in years)","Mindestalter (in Jahren)"
39
+ "Leave field empty or enter ""0"" if there should be no age verification. The minimum age, if filled, is used as criteria to enter the checkout and finish the order.","Feld leer lassen bzw. 0 eintragen, sofern keine Altersverifikation durchgeführt werden soll. Das Mindestalter, sofern ausgefüllt, gilt als Kriterium für alle Käufe um den Checkout betreten und die Bestellung abschließen zu können."
40
+ "ID-Cards","ID-Cards"
41
+ "ID-Card Name","ID-Card Name"
42
+ "Gateway URLs","Schnittstellen-URLs"
43
+ "Identify now","Jetzt identifizieren"
44
+ "Access-Token URL","Access-Ticket URL"
45
+ "Your online purchase at %s."," Ihr Onlineeinkauf bei %s."
46
+ "Gateway URL for the E-POSTIDENT-Verification Request","Schnittstellen-URL für die Verifizierung und Weiterleitung der Kunden zu E-POSTIDENT"
47
+ "An identification by E-POSTIDENT is necessary to enter the checkout.","Eine Identifizierung per E-POSTIDENT ist nötig, um den Checkout zu betreten."
48
+ "Your data was verified successfully","Ihre Daten wurden erfolgreich verifiziert"
49
+ "The identification failed. Please try again.","Die Identifizierung ist fehlgeschlagen. Bitte versuchen Sie es noch einmal."
50
+ "A system-error occured. Please try again.","Ein Systemfehler ist aufgetreten. Bitte versuchen Sie es noch einmal."
51
+ "Gateway URL for the Check Connect Service","Schnittstellen-URL für den Check Connect - Service"
52
+ "The Gateway URL for E-POSTIDENT-Verification Access-Ticket-Request.","Die Schnittstellen-URL die für die Verifizierung benutzt wird."
53
+ "The Gateway URL for E_POSTIDENT-Verification Identity-Request.","Die Schnittstellen-URL für das Abrufen der Identitätsdaten."
54
+ "Identdata URL","Identitätsdaten URL"
55
+ "The identification was passed succesfully but the verification to enter the checkout failed.","Die Identifizierung konnte erfolgreich durchgeführt werden. Die Verifizierung Ihrer Daten zum Betreten des Checkouts schlug jedoch fehl."
56
+ "Verification on every Checkout","Bei jedem Checkout verifizieren"
57
+ "Enable, if a new verification is needed for every checkout.","Hier können Sie aktivieren, dass für jeden Checkout eine erneute Verifizierung durchgeführt wird."
58
+ "E-POSTIDENT Data","E-POSTIDENT Daten"
59
+ "E-POSTIDENT verification data","E-POSTIDENT Verifizierungsdaten"
60
+ "givenname","Vorname"
61
+ "familyname","Familenname"
62
+ "dateofbirth","Geburtsdatum"
63
+ "street","Straße"
64
+ "housenumber","Hausnummer"
65
+ "zipcode","Postleitzahl"
66
+ "city","Stadt"
67
+ "country","Land"
68
+ "epostaddress","E-POST Email-Adresse"
69
+ "verification_date","Datum der Verifizierung"
70
+ "For this customer verification data doesnt exist.","Für diesen Kunden existieren keine verifizierten Daten."
71
+ "Verification type","Art der Verifikation"
72
+ "global","Global"
73
+ "product specific","Produktspezifisch"
74
+ "both","Beides"
75
+ "Here you can select which type of age verification is used.","Hier können Sie auswählen welche Art der Altersverifikation verwendet werden soll."
76
+ "Verify age now","Jetzt Alter prüfen"
77
+ "You have age-restricted products in your shopping cart. For child-protection reasons, we ask for an age verification by","Sie haben in Ihrem Warenkorb alters-beschränkte Inhalte. Aus Jugendschutzgründen bitten wir um eine Altersprüfung per"
78
+ "E-POSTIDENT min age","E-POSTIDENT Mindestalter"
79
+ "16 years","16 Jahre"
80
+ "18 years","18 Jahre"
81
+ "No age restriction","Keine Altersbeschränkung"
82
+ "address data","Adressdaten"
83
+ "Address data usage","Adressdaten übernehmen"
84
+ "If activated, the customer can use his verified address data to populate registration and shipping form.","Wenn Sie diese Option aktivieren, hat der Kunde die Möglichkeit, die Rechnungs- und Lieferadresse mit seinen verifizierten E-POSTIDENT Daten vorausfüllen zu lassen."
85
+ "mr","Herr"
86
+ "mrs","Frau"
87
+ "salutation","Anrede"
88
+ "nationality","Nationalität"
89
+ "addressaddon","Adresszusatz"
90
+ "Use E-POSTIDENT data","E-POSTIDENT-Adresse übernehmen"
91
+ "Prefill form fields with verified E-POSTIDENT data","Die Formularfelder werden mit verifizierten E-POSTIDENT-Daten vorausgefüllt"
92
+ "This is your verified data.","Dies sind Ihre verifizierten Daten."
93
+ "E-POSTIDENT Minimum age","E-POSTIDENT Mindestalter"
js/postident/adminhtml/checkconnect.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function sentCheckConnectRequest(url)
2
+ {
3
+ url = url + '/clientId/' + $('postident_master_data_client_id').value + domainUri;
4
+ request = new Ajax.Request(url, {
5
+ onSuccess: function(transport) {
6
+ if (transport.responseText.isJSON()) {
7
+ var response = transport.responseText.evalJSON();
8
+ if ('undefined' != typeof(response.message)) {
9
+ alert(response.message);
10
+ } else {
11
+ alert(Translator.translate("Check Connect Error: Message not found."));
12
+ }
13
+
14
+ } else {
15
+ alert(Translator.translate("Check Connect Error: Response is no JSON format."));
16
+ }
17
+ },
18
+ onFailure: function()
19
+ {
20
+ alert(Translator.translate("Check Connect request failed."));
21
+ }
22
+ });
23
+ }
js/postident/adminhtml/validation.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ Validation.add('validate-clientsecret', 'Only charakters a-z, A-Z, 0-9 are allowed.',
2
+ function(v) {
3
+ return /^[a-zA-Z0-9]+$/.test(v);
4
+ }
5
+ );
6
+
7
+ Validation.add('validate-clientid', 'Please Enter a valid Client-ID.',
8
+ function(v) {
9
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(v);
10
+ }
11
+ );
js/postident/checkout/addressdata.js ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @category DeutschePost Postident
3
+ * @package DeutschePost_Postident
4
+ * @author André Herrn <andre.herrn@netresearch.de>
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ var PostidentAddressData = Class.create();
10
+ PostidentAddressData.prototype = {
11
+ initialize: function(postident_address_data) {
12
+ this.postidentData = postident_address_data.evalJSON();
13
+ // check if givenname exist in JSON object, log Error if not
14
+ if (!this.postidentData.hasOwnProperty('givenname')) {
15
+ console.log("Error parsing postidentData JSON object, key 'givenname' doesn't exists");
16
+ }
17
+
18
+ /*
19
+ * map magento_form_keys to postident_data_keys
20
+ *
21
+ * magento_form_key : postident_data_key
22
+ */
23
+ this.mappedAddressArray = {
24
+ 'firstname': 'givenname',
25
+ 'lastname': 'familyname',
26
+ 'city': 'city',
27
+ 'postcode': 'zipcode',
28
+ 'country_id': 'nationality'
29
+ };
30
+ },
31
+ updateFormData: function(addressType) {
32
+
33
+ if (false === this.hasPostidentData()) {
34
+ return false;
35
+ }
36
+
37
+ this.updateBirthDateFormFields(addressType);
38
+ this.updatePrefixFormField(addressType);
39
+ this.updateStreetFormField(addressType);
40
+ for (var magentoAddressKey in this.mappedAddressArray) {
41
+ var postidentKey = this.mappedAddressArray[magentoAddressKey];
42
+ if (true === this.postidentData.hasOwnProperty(postidentKey)
43
+ && this.postidentData[postidentKey] !== null) {
44
+
45
+ if ($(addressType + ":" + magentoAddressKey) !== null) {
46
+ $(addressType + ":" + magentoAddressKey).value = this.postidentData[postidentKey];
47
+ }
48
+ }
49
+ else {
50
+ continue;
51
+ }
52
+ }
53
+ if (addressType === 'billing') {
54
+ billingRegionUpdater.update();
55
+ }
56
+ if (addressType === 'shipping') {
57
+ shippingRegionUpdater.update();
58
+ }
59
+ },
60
+ updatePrefixFormField: function(addressType) {
61
+
62
+ if ($(addressType + ":" + 'prefix') !== null) {
63
+ $(addressType + ":" + 'prefix').value = this.getPrefix();
64
+ }
65
+ },
66
+ updateStreetFormField: function(addressType) {
67
+
68
+ if ($(addressType + ":" + 'street1') !== null) {
69
+ $(addressType + ":" + 'street1').value = this.getStreetWithHouseNumber();
70
+ }
71
+
72
+ if (typeof(this.postidentData['addressaddon']) !== "undefined") {
73
+ $(addressType + ":" + 'street2').value = this.postidentData['addressaddon'];
74
+ }
75
+
76
+ },
77
+ updateBirthDateFormFields: function(addressType) {
78
+
79
+ if ($(addressType + ":" + 'day') !== null
80
+ && $(addressType + ":" + 'month') !== null
81
+ && $(addressType + ":" + 'year') !== null) {
82
+
83
+ var date = this.getBirthdayDateObject();
84
+ $(addressType + ":" + 'day').value = date.getDate();
85
+ $(addressType + ":" + 'month').value = date.getMonth() + 1;
86
+ $(addressType + ":" + 'year').value = date.getFullYear().toString();
87
+
88
+ }
89
+ },
90
+ checkFormFieldsEmpty: function(addressType) {
91
+
92
+ if (false === this.hasPostidentData()) {
93
+ return false;
94
+ }
95
+
96
+ //iterate over mapping array which covers the usual field names
97
+ for (var magentoAddressKey in this.mappedAddressArray) {
98
+
99
+ if (null === $(addressType + ":" + magentoAddressKey)
100
+ || "country_id" === magentoAddressKey) {
101
+ continue;
102
+ }
103
+
104
+ if (false === $(addressType + ":" + magentoAddressKey).value.empty()) {
105
+ return false;
106
+ }
107
+ }
108
+
109
+ //for street1 form field
110
+ if (null !== $(addressType + ":" + 'street1') && false === $(addressType + ":" + 'street1').value.empty()) {
111
+ return false;
112
+ }
113
+
114
+ //for birthdate form fields
115
+ if (null !== $(addressType + ":" + 'day') && false === $(addressType + ":" + 'day').value.empty()) {
116
+ return false;
117
+ }
118
+ if (null !== $(addressType + ":" + 'month') && false === $(addressType + ":" + 'month').value.empty()) {
119
+ return false;
120
+ }
121
+ if (null !== $(addressType + ":" + 'year') && false === $(addressType + ":" + 'year').value.empty()) {
122
+ return false;
123
+ }
124
+ // for prefix form field
125
+ //Excluded prefix field - returns false in case of predefined prefix option
126
+ /*
127
+ if (null !== $(addressType + ":" + 'prefix') && false === $(addressType + ":" + 'prefix').value.empty()) {
128
+ return false;
129
+ }
130
+ */
131
+ return true;
132
+ },
133
+ checkFormFieldsAreSame: function(addressType) {
134
+
135
+ if (false === this.hasPostidentData()) {
136
+ return false;
137
+ }
138
+
139
+ //iterate over mapping array which covers the usual field names
140
+ for (var magentoAddressKey in this.mappedAddressArray) {
141
+ var postidentKey = this.mappedAddressArray[magentoAddressKey];
142
+
143
+ if (null === $(addressType + ":" + magentoAddressKey)) {
144
+ continue;
145
+ }
146
+
147
+ if (this.postidentData[postidentKey] !== $(addressType + ":" + magentoAddressKey).value) {
148
+ return false;
149
+ }
150
+ }
151
+
152
+ if (null !== $(addressType + ":" + 'street1')
153
+ && this.getStreetWithHouseNumber() !== $(addressType + ":" + 'street1').value){
154
+ return false;
155
+ }
156
+
157
+ //for birthdate form fields
158
+ if (null !== $(addressType + ":" + 'day')
159
+ && this.getBirthdayDateObject().getDate().toString() !== $(addressType + ":" + 'day').value) {
160
+ return false;
161
+ }
162
+
163
+ // add 1 since getMonth() returns months from 0 - 11
164
+ var month = this.getBirthdayDateObject().getMonth() + 1;
165
+ if (null !== $(addressType + ":" + 'month')
166
+ && month.toString() !== $(addressType + ":" + 'month').value) {
167
+ return false;
168
+ }
169
+
170
+ if (null !== $(addressType + ":" + 'year')
171
+ && this.getBirthdayDateObject().getFullYear().toString() !== $(addressType + ":" + 'year').value) {
172
+ return false;
173
+ }
174
+
175
+ // for prefix form field
176
+ if (null !== $(addressType + ":" + 'prefix')
177
+ && this.getPrefix() !== $(addressType + ":" + 'prefix').value) {
178
+ return false;
179
+ }
180
+
181
+ return true;
182
+ },
183
+ getBirthdayDateObject: function() {
184
+
185
+ if (typeof(this.postidentData['dateofbirth']) !== "undefined") {
186
+ var a = this.postidentData['dateofbirth'].split(" ");
187
+ var d = a[0].split("-");
188
+
189
+ return new Date(d[0], (d[1] - 1), d[2]);
190
+ }
191
+ },
192
+ getPrefix: function() {
193
+
194
+ if (typeof(this.postidentData['salutation']) !== "undefined") {
195
+ return Translator.translate(this.postidentData['salutation']);
196
+ }
197
+ },
198
+ getStreetWithHouseNumber: function() {
199
+ var street = '';
200
+ if (typeof(this.postidentData['street']) !== "undefined"
201
+ && typeof(this.postidentData['housenumber']) !== "undefined") {
202
+ street = this.postidentData['street'] + " " + this.postidentData['housenumber'];
203
+ }
204
+ return street;
205
+
206
+ },
207
+ hasPostidentData: function() {
208
+
209
+ if (typeof(this.postidentData) !== "undefined"
210
+ && this.postidentData.hasOwnProperty('givenname')) {
211
+ return true;
212
+ } else {
213
+ if (window['console'] !== 'undefined')
214
+ console.log("Error: postidentData is undefined or corrupted since givenname is missing");
215
+ return false;
216
+ }
217
+ }
218
+ };
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>EPOSTIDENT</name>
4
+ <version>13.02.28</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Deutsche Post &#x2013; E-POSTIDENT&#xD;
10
+ Online age verification, identification and automatic handover of address data</summary>
11
+ <description>Mit E-POSTIDENT bietet die Deutsche Post eine Online L&#xF6;sung zur Alterspr&#xFC;fung und Identifizierung Ihrer Nutzer im Internet an. Dar&#xFC;ber hinaus k&#xF6;nnen Sie den Checkout Prozess f&#xFC;r Ihre Kunden verk&#xFC;rzen. &#xD;
12
+ Denn im Rahmen der Identifizierung entf&#xE4;llt f&#xFC;r Ihre Neukunden die Eingabe der Adressdaten. &#xD;
13
+ Diese werden Ihnen im Rahmen von E-POSTIDENT &#xFC;bermittelt und automatisch in die daf&#xFC;r vorgesehenen &#xD;
14
+ Adressfelder vorgeschrieben. </description>
15
+ <notes>Initial release</notes>
16
+ <authors><author><name>Netresearch App Factory AG</name><user>Netresearch</user><email>magento@netresearch.de</email></author></authors>
17
+ <date>2013-02-28</date>
18
+ <time>13:51:18</time>
19
+ <contents><target name="magecommunity"><dir name="DeutschePost"><dir name="Postident"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Tab"><file name="Verificationdata.php" hash="d2fd92d0669ea7a1b6335bc9a2cac9a2"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Checkconnect"><file name="Button.php" hash="0b4127ad7906bc8628e757dd2765974a"/></dir><dir name="Domainuri"><file name="Notice.php" hash="7cde00cd8abded6eac65ec7b916294e1"/></dir><dir name="Gateway"><file name="Notice.php" hash="16f375bce90bad7fcc0731ad47b47d24"/></dir></dir></dir></dir><dir name="Checkout"><file name="Abstract.php" hash="abf574013c7763c2b87881d51bcbd75f"/><file name="Address.php" hash="1ced8d9595dec1c7635d1a1c70a50675"/><dir name="Cart"><file name="Link.php" hash="b0509cb621c018c485c4e9fb483c5ea1"/></dir><dir name="Onepage"><file name="Billing.php" hash="41f465eb493583f71812285a61f4bb56"/><file name="Shipping.php" hash="748657057a8b53d914bb8130a2a51c41"/></dir></dir></dir><dir name="Helper"><dir name="Client"><file name="Exception.php" hash="83dde28135944bda3323a22e43094bf0"/></dir><file name="Client.php" hash="103228beb7d5ff09408e4f79ae430e98"/><file name="Data.php" hash="a5633a14d11658b172bb4bf8a7ebe321"/></dir><dir name="Model"><dir name="Client"><file name="Exception.php" hash="fb3a98b83d2f3bf5246a1ddeda78cfc3"/><file name="Http.php" hash="042ecb00eee63ea46dcc215dfb1e513b"/><dir name="Response"><file name="Exception.php" hash="7dc6c05a706f2be13e19e3142e8961e8"/></dir></dir><file name="Client.php" hash="e0d2c1250822ac1874c2d763039c0534"/><file name="Config.php" hash="ebed14f4276aa6f2b2d50bb41b1745af"/><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Productminage.php" hash="0e51a92075e97cfff46732cc907a8602"/></dir></dir></dir><dir name="IdCard"><file name="Abstract.php" hash="af3686a4b8d0d5db860135111eb2f5d3"/><file name="IdCard10.php" hash="ded3e18ef803defde68a1706ffa93c81"/><file name="IdCard120.php" hash="462299b07c7d9c0466fb476b2fb6fc64"/><file name="IdCard130.php" hash="65de23c354f5f0a9a90ca8c460b414e5"/><file name="IdCard1304.php" hash="c5b84ae58cfba4285095fd65f02012c3"/><file name="IdCard40.php" hash="30b32c0aa1bcb3dd5825dba339ee8cc5"/></dir><file name="Observer.php" hash="315631a365ac642879596d9bc85ac8cd"/><dir name="System"><dir name="Config"><file name="Clientid.php" hash="ca502177ec3fbe2183aa3d87c952afae"/><dir name="Source"><file name="Idcards.php" hash="a8b3ef486c461e6c52fa78d79fd051b3"/><file name="Verificationtype.php" hash="64b21b7846c2e710407a7a629988eb7f"/></dir></dir></dir><dir name="Verification"><file name="Exception.php" hash="353203ec2324cc6d4f610666a72cd53e"/></dir><file name="Verification.php" hash="6dc7d6e30bd45b94d6e3d043824d906d"/></dir><dir name="Test"><dir name="Controller"><dir name="Adminhtml"><file name="AbstractControllerTest.php" hash="e506249ea5acfd1da8abbfd7491380f5"/><file name="ConfigControllerTest.php" hash="0fc2468f34f5953cfdc409a937d4a5e5"/><file name="PermissionDeniedControllerTest.php" hash="1899cc16bb646eb823ed0321e0e1e9b9"/></dir><file name="CartControllerTest.php" hash="0f11a7819eab984faf53bbe8de5a80a1"/></dir><dir name="Helper"><dir name="ClientTest"><dir name="expectations"><file name="postidentQuoteVerificationData.yaml" hash="b08758b6ad1d054fd2983e0f78c7c3ee"/><file name="redirectLink.yaml" hash="c29472e6585b5c86078c3e86b07ef815"/></dir></dir><file name="ClientTest.php" hash="ef013d8acc89a59c11ea51692b125255"/><dir name="DataTest"><dir name="fixtures"><file name="product.yaml" hash="52ded9090849d852ed28d31c5403841d"/><file name="quotes.yaml" hash="47d24876481dfcf893f8607d3c34d90c"/></dir></dir><file name="DataTest.php" hash="89462ff7c9689be3c231d0228bf52224"/></dir><dir name="Model"><dir name="Client"><file name="ExceptionTest.php" hash="f0a00a06c00e02786e9c456b5101968d"/><file name="HttpTest.php" hash="bc8daf47af4f565c0c55d9273ee49992"/><dir name="Response"><file name="ExceptionTest.php" hash="c687bcec03f441d8db427a336e7d6ecb"/></dir></dir><file name="ClientTest.php" hash="4c39e4b89724c5724ca26dd6e111c8e9"/><file name="ConfigTest.php" hash="b8a5211e4f840ba921e3802b3eb7a14f"/><dir name="IdCard"><file name="AbstractTest.php" hash="03203ff8184e419a8047c4f061ef6509"/></dir><dir name="ObserverTest"><dir name="fixtures"><file name="orders.yaml" hash="1280132f3c4cd6879c2f79170f7099e4"/><file name="quotes.yaml" hash="01ed3237ba6a074c78ce1098b1c731f6"/></dir></dir><file name="ObserverTest.php" hash="6e45e95fdd16229ff161bc83b0545810"/><dir name="System"><dir name="Config"><file name="ClientidTest.php" hash="241463b42e655c0702efd728ecf32a5b"/><dir name="Source"><file name="IdcardsTest.php" hash="2b35b6b1cade76e3d9840d24ebaadf58"/><file name="VerificationtypeTest.php" hash="c977147d3e1764e1f2ed468f409e0f78"/></dir></dir></dir><dir name="VerificationTest"><dir name="expectations"><file name="customer.yaml" hash="1bf18c086cbf567c8aaf541f5c53daa9"/><file name="quotes.yaml" hash="1bf18c086cbf567c8aaf541f5c53daa9"/></dir><dir name="fixtures"><file name="customer.yaml" hash="52ded9090849d852ed28d31c5403841d"/><file name="quotes.yaml" hash="0a375eacecf6725414277cda7b369fcc"/></dir></dir><file name="VerificationTest.php" hash="2be773a0a942079acaceabadb8eddcae"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigController.php" hash="16800b237511ba82033d3a3bc947553b"/></dir><file name="CartController.php" hash="91c6884cfaf52b50b22c53ecc482ce60"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e1f404fe20b02a9d5537e9a742c43583"/><file name="config.xml" hash="30b010f692c017700e64bdfb25dbcc27"/><file name="system.xml" hash="f37439bb1f2a78f15660cc465ee88621"/></dir><dir name="sql"><dir name="postident_setup"><file name="mysql4-install-12.11.14.php" hash="0498d81686a41d60803e222cfb0f7976"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="postident"><dir name="checkout"><file name="address.phtml" hash="0a9e27de32986ec5e6c098857d6e3831"/><dir name="cart"><file name="link.phtml" hash="1166ae2e511c2f616c14ea4383b6a878"/></dir><dir name="onepage"><file name="billing.phtml" hash="34e3997b0802f1f054e60ddb89843730"/><file name="shipping.phtml" hash="7412295e6a9c27b08a485cefbaadc284"/></dir></dir></dir></dir><dir name="layout"><file name="postident.xml" hash="31b3fd98e34ddb07a67bc20cb7d8232b"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="postident"><dir name="customer"><file name="verificationdata.phtml" hash="0f0f648f8d27fe6b66f2ca71c8e59f5f"/></dir><dir name="system"><dir name="config"><dir name="domainuri"><file name="notice.phtml" hash="2821ca11d0a05d3d50639fa2eb4ac471"/></dir><dir name="gateway"><file name="notice.phtml" hash="668c856d818208e5a101e1efbc65378e"/></dir></dir></dir><file name="validate.phtml" hash="91d2f45bc08ebe1870918c8c298586c0"/></dir></dir><dir name="layout"><file name="postident.xml" hash="bcd79e7b689905f3a9a58e9d0a200a2e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DeutschePost_Postident.xml" hash="02a996cd6319dd5f9becc8f73f370af0"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="DeutschePost_Postident.csv" hash="89e2d2cad54bdff3fdeb01b73ba08432"/></dir><dir name="en_US"><file name="DeutschePost_Postident.csv" hash=""/></dir></target><target name="mage"><dir name="js"><dir name="postident"><dir name="adminhtml"><file name="checkconnect.js" hash="7d3847024b4722a72f5b84ee13294ce7"/><file name="validation.js" hash="f19ba8e2c130ea5382cd4e8370cbb193"/></dir><dir name="checkout"><file name="addressdata.js" hash="23427cdd2022d2528b849967d4de5cf3"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="postident"><dir name="identifikation"><file name="Button_Identifikation_Mouse-over.png" hash="cef9c838e24eafed41e9b7ec4749c47e"/><file name="Button_Identifikation_Mouse-over_160.png" hash="0f097dee9f17cad4b8cdebfdf2dd6660"/><file name="Button_Identifikation_aktiv.png" hash="3c4bfb18380b5271d2c8bdfe69c884b3"/><file name="Button_Identifikation_aktiv_160.png" hash="8025b76b0de444d1f3d5df5d8f42f9eb"/><file name="Button_Identifikation_inaktiv.png" hash="ea702eb864936ed3f002d3777ff680b5"/><file name="Button_Identifikation_inaktiv_160.png" hash="db2343c7399d4d56f0b9ca564b3c801e"/></dir><dir name="identifikation_short"><file name="Button_Identifikation_Mouse-over.png" hash="c1bf54c78a506c39b50cbc0fd4634d78"/><file name="Button_Identifikation_aktiv.png" hash="66862f110c255bbfda6ec90a6c66f39f"/><file name="Identifikation_inaktiv.png" hash="34acbb919dba2d49b0594cba70d6e77f"/></dir><dir name="produktzeichen"><file name="DP_E-POSTIDENT_Produktzeichen.png" hash="1d6fd03782114e1725928043d85f432d"/><file name="DP_E-POSTIDENT_Produktzeichen_160.png" hash="cc18262b0d60f74a41a5dc2a9e9cc19d"/></dir></dir></dir><dir name="css"><file name="postident.css" hash="5b9f6ecd9f433bf1e21a60763d1e0e8f"/></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>
skin/frontend/base/default/css/postident.css ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @category postident.css
3
+ * @package DeutschePost_Postident
4
+ * @author André Herrn <andre.herrn@netresearch.de>
5
+ * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
6
+ * @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ .postident_adressdata {
11
+ margin: 10px 10px 10px 0;
12
+ }
13
+
14
+ .postident_verification {
15
+ border: 1px solid #BEBCB7;
16
+ background-color: #FFFFFF;
17
+ padding: 5px;
18
+ }
19
+
20
+ .postident_verification .epostident_logo {
21
+
22
+ width: 150px;
23
+ height: 60px;
24
+ float: left;
25
+ margin: 20px 0px 40px 5px;
26
+ }
27
+
28
+ .postident_verification .verification_link {
29
+ background: url('../images/postident/identifikation/Button_Identifikation_inaktiv_160.png') no-repeat;
30
+ display: block;
31
+ float: right;
32
+ height: 50px;
33
+ margin-top: 10px;
34
+ width: 160px;
35
+ }
36
+
37
+ .verification_text {
38
+ text-align: left;
39
+ }
40
+
41
+ .postidentinfo {
42
+ position:absolute;
43
+ display: inline-block;
44
+ padding:5px;
45
+ font-family:Arial;
46
+ font-weight:bold;
47
+ line-height: 15px;
48
+ z-index:2;
49
+ cursor: pointer;
50
+ }
51
+ .postidentinfo_content {
52
+ display:none;
53
+ background-color: #F2F2F2;
54
+ border:solid 1px black;
55
+ padding:10px;
56
+ width: 400px;
57
+ font-size: 12px;
58
+ }
59
+
60
+ #postidentinfo_sign {
61
+ font-size: 15px;
62
+ }
63
+
64
+ #postidentlogo {
65
+ float:right;
66
+ }
67
+
68
+ .identdatatable td {
69
+ padding:0 10px 0 0;
70
+ }
skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_Mouse-over.png ADDED
Binary file
skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_Mouse-over_160.png ADDED
Binary file
skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_aktiv.png ADDED
Binary file
skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_aktiv_160.png ADDED
Binary file
skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_inaktiv.png ADDED
Binary file
skin/frontend/base/default/images/postident/identifikation/Button_Identifikation_inaktiv_160.png ADDED
Binary file
skin/frontend/base/default/images/postident/identifikation_short/Button_Identifikation_Mouse-over.png ADDED
Binary file
skin/frontend/base/default/images/postident/identifikation_short/Button_Identifikation_aktiv.png ADDED
Binary file
skin/frontend/base/default/images/postident/identifikation_short/Identifikation_inaktiv.png ADDED
Binary file
skin/frontend/base/default/images/postident/produktzeichen/DP_E-POSTIDENT_Produktzeichen.png ADDED
Binary file
skin/frontend/base/default/images/postident/produktzeichen/DP_E-POSTIDENT_Produktzeichen_160.png ADDED
Binary file