Mage_Centinel - Version 1.6.0.0

Version Notes

1.6.0.0

Download this release

Release Info

Developer Magento Core Team
Extension Mage_Centinel
Version 1.6.0.0
Comparing to
See all releases


Version 1.6.0.0

Files changed (39) hide show
  1. app/code/core/Mage/Centinel/Block/Adminhtml/Validation.php +75 -0
  2. app/code/core/Mage/Centinel/Block/Adminhtml/Validation/Form.php +55 -0
  3. app/code/core/Mage/Centinel/Block/Authentication.php +87 -0
  4. app/code/core/Mage/Centinel/Block/Authentication/Complete.php +48 -0
  5. app/code/core/Mage/Centinel/Block/Authentication/Start.php +48 -0
  6. app/code/core/Mage/Centinel/Block/Logo.php +47 -0
  7. app/code/core/Mage/Centinel/Helper/Data.php +181 -0
  8. app/code/core/Mage/Centinel/Model/Api.php +267 -0
  9. app/code/core/Mage/Centinel/Model/Config.php +150 -0
  10. app/code/core/Mage/Centinel/Model/Observer.php +141 -0
  11. app/code/core/Mage/Centinel/Model/Service.php +398 -0
  12. app/code/core/Mage/Centinel/Model/Session.php +42 -0
  13. app/code/core/Mage/Centinel/Model/State/Jcb.php +164 -0
  14. app/code/core/Mage/Centinel/Model/State/Mastercard.php +156 -0
  15. app/code/core/Mage/Centinel/Model/State/Visa.php +169 -0
  16. app/code/core/Mage/Centinel/Model/StateAbstract.php +169 -0
  17. app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php +120 -0
  18. app/code/core/Mage/Centinel/controllers/IndexController.php +91 -0
  19. app/code/core/Mage/Centinel/etc/config.xml +171 -0
  20. app/code/core/Mage/Centinel/etc/system.xml +96 -0
  21. app/design/adminhtml/default/default/layout/centinel.xml +70 -0
  22. app/design/adminhtml/default/default/template/centinel/authentication/complete.phtml +38 -0
  23. app/design/adminhtml/default/default/template/centinel/authentication/start.phtml +38 -0
  24. app/design/adminhtml/default/default/template/centinel/validation/form.phtml +37 -0
  25. app/design/frontend/base/default/layout/centinel.xml +65 -0
  26. app/design/frontend/base/default/template/centinel/authentication.phtml +56 -0
  27. app/design/frontend/base/default/template/centinel/authentication/complete.phtml +41 -0
  28. app/design/frontend/base/default/template/centinel/authentication/start.phtml +40 -0
  29. app/design/frontend/base/default/template/centinel/logo.phtml +33 -0
  30. app/etc/modules/Mage_Centinel.xml +39 -0
  31. app/locale/en_US/Mage_Centinel.csv +34 -0
  32. js/mage/adminhtml/sales/centinel.js +71 -0
  33. lib/3Dsecure/CentinelClient.php +161 -0
  34. lib/3Dsecure/CentinelErrors.php +20 -0
  35. lib/3Dsecure/XMLParser.php +88 -0
  36. package.xml +18 -0
  37. skin/frontend/base/default/images/centinel/sc_learn_62x34.gif +0 -0
  38. skin/frontend/base/default/images/centinel/v_activate_steps.gif +0 -0
  39. skin/frontend/base/default/images/centinel/vbv_ltbg_71x57.gif +0 -0
app/code/core/Mage/Centinel/Block/Adminhtml/Validation.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml sales order create validation card block
29
+ */
30
+ class Mage_Centinel_Block_Adminhtml_Validation extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract
31
+ {
32
+ /**
33
+ * construct
34
+ */
35
+ public function __construct()
36
+ {
37
+ parent::__construct();
38
+ $this->setId('sales_order_create_validation_card');
39
+ }
40
+
41
+ /**
42
+ * Return text for block`s header
43
+ *
44
+ * @return string
45
+ */
46
+ public function getHeaderText()
47
+ {
48
+ return Mage::helper('centinel')->__('3D Secure Card Validation');
49
+ }
50
+
51
+ /**
52
+ * Return css class name for header block
53
+ *
54
+ * @return string
55
+ */
56
+ public function getHeaderCssClass()
57
+ {
58
+ return 'head-payment-method';
59
+ }
60
+
61
+ /**
62
+ * Prepare html output
63
+ *
64
+ * @return string
65
+ */
66
+ protected function _toHtml()
67
+ {
68
+ $payment = $this->getQuote()->getPayment();
69
+ if (!$payment->getMethod() || !$payment->getMethodInstance() || !$payment->getMethodInstance()->getIsCentinelValidationEnabled()) {
70
+ return '';
71
+ }
72
+ return parent::_toHtml();
73
+ }
74
+ }
75
+
app/code/core/Mage/Centinel/Block/Adminhtml/Validation/Form.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml sales order create validation card block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Centinel
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Centinel_Block_Adminhtml_Validation_Form extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract
36
+ {
37
+ /**
38
+ * Prepare validation and template parameters
39
+ */
40
+ protected function _toHtml()
41
+ {
42
+ $payment = $this->getQuote()->getPayment();
43
+ if ($payment && $method = $payment->getMethodInstance()) {
44
+ if ($method->getIsCentinelValidationEnabled() && $centinel = $method->getCentinelValidator()) {
45
+ $this->setFrameUrl($centinel->getValidatePaymentDataUrl())
46
+ ->setContainerId('centinel_authenticate_iframe')
47
+ ->setMethodCode($method->getCode())
48
+ ;
49
+ return parent::_toHtml();
50
+ }
51
+ }
52
+ return '';
53
+ }
54
+ }
55
+
app/code/core/Mage/Centinel/Block/Authentication.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Centinel validation frame
29
+ */
30
+ class Mage_Centinel_Block_Authentication extends Mage_Core_Block_Template
31
+ {
32
+ /**
33
+ * Strage for identifiers of related blocks
34
+ *
35
+ * @var array
36
+ */
37
+ protected $_relatedBlocks = array();
38
+
39
+ /**
40
+ * Flag - authentication start mode
41
+ * @see self::setAuthenticationStartMode
42
+ *
43
+ * @var bool
44
+ */
45
+ protected $_authenticationStartMode = false;
46
+
47
+ /**
48
+ * Add identifier of related block
49
+ *
50
+ * @param string $blockId
51
+ * @return Mage_Centinel_Block_Authentication
52
+ */
53
+ public function addRelatedBlock($blockId)
54
+ {
55
+ $this->_relatedBlocks[] = $blockId;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Return identifiers of related blocks
61
+ *
62
+ * @return array
63
+ */
64
+ public function getRelatedBlocks()
65
+ {
66
+ return $this->_relatedBlocks;
67
+ }
68
+
69
+ /**
70
+ * Check whether authentication is required and prepare some template data
71
+ *
72
+ * @return string
73
+ */
74
+ protected function _toHtml()
75
+ {
76
+ $method = Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance();
77
+ if ($method->getIsCentinelValidationEnabled()) {
78
+ $centinel = $method->getCentinelValidator();
79
+ if ($centinel && $centinel->shouldAuthenticate()) {
80
+ $this->setAuthenticationStart(true);
81
+ $this->setFrameUrl($centinel->getAuthenticationStartUrl());
82
+ return parent::_toHtml();
83
+ }
84
+ }
85
+ return parent::_toHtml();
86
+ }
87
+ }
app/code/core/Mage/Centinel/Block/Authentication/Complete.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Centinel validation form lookup
30
+ */
31
+ class Mage_Centinel_Block_Authentication_Complete extends Mage_Core_Block_Template
32
+ {
33
+ /**
34
+ * Prepare authentication result params and render
35
+ *
36
+ * @return string
37
+ */
38
+ protected function _toHtml()
39
+ {
40
+ $validator = Mage::registry('current_centinel_validator');
41
+ if ($validator) {
42
+ $this->setIsProcessed(true);
43
+ $this->setIsSuccess($validator->isAuthenticateSuccessful());
44
+ }
45
+ return parent::_toHtml();
46
+ }
47
+ }
48
+
app/code/core/Mage/Centinel/Block/Authentication/Start.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Authentication start/redirect form
30
+ */
31
+ class Mage_Centinel_Block_Authentication_Start extends Mage_Core_Block_Template
32
+ {
33
+ /**
34
+ * Prepare form parameters and render
35
+ *
36
+ * @return string
37
+ */
38
+ protected function _toHtml()
39
+ {
40
+ $validator = Mage::registry('current_centinel_validator');
41
+ if ($validator && $validator->shouldAuthenticate()) {
42
+ $this->addData($validator->getAuthenticateStartData());
43
+ return parent::_toHtml();
44
+ }
45
+ return '';
46
+ }
47
+ }
48
+
app/code/core/Mage/Centinel/Block/Logo.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Centinel payment form logo block
29
+ */
30
+ class Mage_Centinel_Block_Logo extends Mage_Core_Block_Template
31
+ {
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('centinel/logo.phtml');
36
+ }
37
+
38
+ /**
39
+ * Return code of payment method
40
+ *
41
+ * @return string
42
+ */
43
+ public function getCode()
44
+ {
45
+ return $this->getMethod()->getCode();
46
+ }
47
+ }
app/code/core/Mage/Centinel/Helper/Data.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Centinel module base helper
29
+ *
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+ class Mage_Centinel_Helper_Data extends Mage_Core_Helper_Abstract
33
+ {
34
+ /**
35
+ * Return label for cmpi field
36
+ *
37
+ * @param string $fieldName
38
+ * @return string
39
+ */
40
+ public function getCmpiLabel($fieldName)
41
+ {
42
+ switch ($fieldName) {
43
+ case Mage_Centinel_Model_Service::CMPI_PARES:
44
+ return $this->__('3D Secure Verification Result');
45
+ case Mage_Centinel_Model_Service::CMPI_ENROLLED:
46
+ return $this->__('3D Secure Cardholder Validation');
47
+ case Mage_Centinel_Model_Service::CMPI_ECI:
48
+ return $this->__('3D Secure Electronic Commerce Indicator');
49
+ case Mage_Centinel_Model_Service::CMPI_CAVV:
50
+ return $this->__('3D Secure CAVV');
51
+ case Mage_Centinel_Model_Service::CMPI_XID:
52
+ return $this->__('3D Secure XID');
53
+ }
54
+ return '';
55
+ }
56
+
57
+ /**
58
+ * Return value for cmpi field
59
+ *
60
+ * @param string $fieldName
61
+ * @param string $value
62
+ * @return string
63
+ */
64
+ public function getCmpiValue($fieldName, $value)
65
+ {
66
+ switch ($fieldName) {
67
+ case Mage_Centinel_Model_Service::CMPI_PARES:
68
+ return $this->_getCmpiParesValue($value);
69
+ case Mage_Centinel_Model_Service::CMPI_ENROLLED:
70
+ return $this->_getCmpiEnrolledValue($value);
71
+ case Mage_Centinel_Model_Service::CMPI_ECI:
72
+ return $this->_getCmpiEciValue($value);
73
+ case Mage_Centinel_Model_Service::CMPI_CAVV: // break intentionally omitted
74
+ case Mage_Centinel_Model_Service::CMPI_XID:
75
+ return $value;
76
+ }
77
+ return '';
78
+ }
79
+
80
+ /**
81
+ * Return text value for cmpi eci flag field
82
+ *
83
+ * @param string $value
84
+ * @return string
85
+ */
86
+ private function _getCmpiEciValue($value)
87
+ {
88
+ switch ($value) {
89
+ case '01':
90
+ case '07':
91
+ return $this->__('Merchant Liability');
92
+ case '02':
93
+ case '05':
94
+ case '06':
95
+ return $this->__('Card Issuer Liability');
96
+ default:
97
+ return $value;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Return text value for cmpi enrolled field
103
+ *
104
+ * @param string $value
105
+ * @return string
106
+ */
107
+ private function _getCmpiEnrolledValue($value)
108
+ {
109
+ switch ($value) {
110
+ case 'Y':
111
+ return $this->__('Enrolled');
112
+ case 'U':
113
+ return $this->__('Enrolled but Authentication Unavailable');
114
+ case 'N': // break intentionally omitted
115
+ default:
116
+ return $this->__('Not Enrolled');
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Return text value for cmpi pares field
122
+ *
123
+ * @param string $value
124
+ * @return string
125
+ */
126
+ private function _getCmpiParesValue($value)
127
+ {
128
+ switch ($value) {
129
+ case 'Y':
130
+ return $this->__('Successful');
131
+ case 'N':
132
+ return $this->__('Failed');
133
+ case 'U':
134
+ return $this->__('Unable to complete');
135
+ case 'A':
136
+ return $this->__('Successful attempt');
137
+ default:
138
+ return $value;
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Return centinel block for payment form with logos
144
+ *
145
+ * @param Mage_Payment_Model_Method_Abstract $method
146
+ * @return Mage_Centinel_Block_Logo
147
+ */
148
+ public function getMethodFormBlock($method)
149
+ {
150
+ $blockType = 'centinel/logo';
151
+ if ($this->getLayout()) {
152
+ $block = $this->getLayout()->createBlock($blockType);
153
+ }
154
+ else {
155
+ $className = Mage::getConfig()->getBlockClassName($blockType);
156
+ $block = new $className;
157
+ }
158
+ $block->setMethod($method);
159
+ return $block;
160
+ }
161
+
162
+ /**
163
+ * Return url of page about visa verification
164
+ *
165
+ * @return string
166
+ */
167
+ public function getVisaLearnMorePageUrl()
168
+ {
169
+ return 'https://usa.visa.com/personal/security/vbv/index.html?ep=v_sym_verifiedbyvisa';
170
+ }
171
+
172
+ /**
173
+ * Return url of page about mastercard verification
174
+ *
175
+ * @return string
176
+ */
177
+ public function getMastercardLearnMorePageUrl()
178
+ {
179
+ return 'http://www.mastercardbusiness.com/mcbiz/index.jsp?template=/orphans&amp;content=securecodepopup';
180
+ }
181
+ }
app/code/core/Mage/Centinel/Model/Api.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * 3D Secure Validation Library for Payment
29
+ */
30
+ include_once '3Dsecure/CentinelClient.php';
31
+
32
+ /**
33
+ * 3D Secure Validation Api
34
+ */
35
+ class Mage_Centinel_Model_Api extends Varien_Object
36
+ {
37
+ /**
38
+ * Fields that should be replaced in debug with '***'
39
+ *
40
+ * @var array
41
+ */
42
+ protected $_debugReplacePrivateDataKeys = array('TransactionPwd', 'CardNumber', 'CardExpMonth', 'CardExpYear');
43
+
44
+ protected static $_iso4217Currencies = array(
45
+ 'AED' => '784', 'AFN' => '971',
46
+ 'ALL' => '008', 'AMD' => '051', 'ANG' => '532', 'AOA' => '973', 'ARS' => '032', 'AUD' => '036', 'AWG' => '533',
47
+ 'AZN' => '944', 'BAM' => '977', 'BBD' => '052', 'BDT' => '050', 'BGN' => '975', 'BHD' => '048', 'BIF' => '108',
48
+ 'BMD' => '060', 'BND' => '096', 'BOB' => '068', 'BOV' => '984', 'BRL' => '986', 'BSD' => '044', 'BTN' => '064',
49
+ 'BWP' => '072', 'BYR' => '974', 'BZD' => '084', 'CAD' => '124', 'CDF' => '976', 'CHE' => '947', 'CHF' => '756',
50
+ 'CHW' => '948', 'CLF' => '990', 'CLP' => '152', 'CNY' => '156', 'COP' => '170', 'COU' => '970', 'CRC' => '188',
51
+ 'CUC' => '931', 'CUP' => '192', 'CVE' => '132', 'CZK' => '203', 'DJF' => '262', 'DKK' => '208', 'DOP' => '214',
52
+ 'DZD' => '012', 'EEK' => '233', 'EGP' => '818', 'ERN' => '232', 'ETB' => '230', 'EUR' => '978', 'FJD' => '242',
53
+ 'FKP' => '238', 'GBP' => '826', 'GEL' => '981', 'GHS' => '936', 'GIP' => '292', 'GMD' => '270', 'GNF' => '324',
54
+ 'GTQ' => '320', 'GYD' => '328', 'HKD' => '344', 'HNL' => '340', 'HRK' => '191', 'HTG' => '332', 'HUF' => '348',
55
+ 'IDR' => '360', 'ILS' => '376', 'INR' => '356', 'IQD' => '368', 'IRR' => '364', 'ISK' => '352', 'JMD' => '388',
56
+ 'JOD' => '400', 'JPY' => '392', 'KES' => '404', 'KGS' => '417', 'KHR' => '116', 'KMF' => '174', 'KPW' => '408',
57
+ 'KRW' => '410', 'KWD' => '414', 'KYD' => '136', 'KZT' => '398', 'LAK' => '418', 'LBP' => '422', 'LKR' => '144',
58
+ 'LRD' => '430', 'LSL' => '426', 'LTL' => '440', 'LVL' => '428', 'LYD' => '434', 'MAD' => '504', 'MDL' => '498',
59
+ 'MGA' => '969', 'MKD' => '807', 'MMK' => '104', 'MNT' => '496', 'MOP' => '446', 'MRO' => '478', 'MUR' => '480',
60
+ 'MVR' => '462', 'MWK' => '454', 'MXN' => '484', 'MXV' => '979', 'MYR' => '458', 'MZN' => '943', 'NAD' => '516',
61
+ 'NGN' => '566', 'NIO' => '558', 'NOK' => '578', 'NPR' => '524', 'NZD' => '554', 'OMR' => '512', 'PAB' => '590',
62
+ 'PEN' => '604', 'PGK' => '598', 'PHP' => '608', 'PKR' => '586', 'PLN' => '985', 'PYG' => '600', 'QAR' => '634',
63
+ 'RON' => '946', 'RSD' => '941', 'RUB' => '643', 'RWF' => '646', 'SAR' => '682', 'SBD' => '090', 'SCR' => '690',
64
+ 'SDG' => '938', 'SEK' => '752', 'SGD' => '702', 'SHP' => '654', 'SLL' => '694', 'SOS' => '706', 'SRD' => '968',
65
+ 'STD' => '678', 'SYP' => '760', 'SZL' => '748', 'THB' => '764', 'TJS' => '972', 'TMT' => '934', 'TND' => '788',
66
+ 'TOP' => '776', 'TRY' => '949', 'TTD' => '780', 'TWD' => '901', 'TZS' => '834', 'UAH' => '980', 'UGX' => '800',
67
+ 'USD' => '840', 'USN' => '997', 'USS' => '998', 'UYU' => '858', 'UZS' => '860', 'VEF' => '937', 'VND' => '704',
68
+ 'VUV' => '548', 'WST' => '882', 'XAF' => '950', 'XAG' => '961', 'XAU' => '959', 'XBA' => '955', 'XBB' => '956',
69
+ 'XBC' => '957', 'XBD' => '958', 'XCD' => '951', 'XDR' => '960', 'XOF' => '952', 'XPD' => '964', 'XPF' => '953',
70
+ 'XPT' => '962', 'XTS' => '963', 'XXX' => '999', 'YER' => '886', 'ZAR' => '710', 'ZMK' => '894', 'ZWL' => '932',
71
+ );
72
+
73
+ /**
74
+ * Centinel validation client
75
+ *
76
+ * @var CentinelClient
77
+ */
78
+ protected $_clientInstance = null;
79
+
80
+ /**
81
+ * Return Centinel thin client object
82
+ *
83
+ * @return CentinelClient
84
+ */
85
+ protected function _getClientInstance()
86
+ {
87
+ if (empty($this->_clientInstance)) {
88
+ $this->_clientInstance = new CentinelClient();
89
+ }
90
+ return $this->_clientInstance;
91
+ }
92
+
93
+ /**
94
+ * Return Centinel Api version
95
+ *
96
+ * @return string
97
+ */
98
+ protected function _getVersion()
99
+ {
100
+ return '1.7';
101
+ }
102
+
103
+ /**
104
+ * Return transaction type. according centinel documetation it should be "C"
105
+ *
106
+ * @return "C"
107
+ */
108
+ protected function _getTransactionType()
109
+ {
110
+ return 'C';
111
+ }
112
+
113
+ /**
114
+ * Return Timeout Connect
115
+ *
116
+ * @return int
117
+ */
118
+ protected function _getTimeoutConnect()
119
+ {
120
+ return 100;
121
+ }
122
+
123
+ /**
124
+ * Return Timeout Read
125
+ *
126
+ * @return int
127
+ */
128
+ protected function _getTimeoutRead()
129
+ {
130
+ return 100;
131
+ }
132
+
133
+ /**
134
+ * Call centinel api methods by given method name and data
135
+ *
136
+ * @param $method string
137
+ * @param $data array
138
+ *
139
+ * @return CentinelClient
140
+ */
141
+ protected function _call($method, $data)
142
+ {
143
+ $client = $this->_getClientInstance();
144
+ $request = array_merge(array(
145
+ 'MsgType' => $method,
146
+ 'Version' => $this->_getVersion(),
147
+ 'ProcessorId' => $this->getProcessorId(),
148
+ 'MerchantId' => $this->getMerchantId(),
149
+ 'TransactionPwd' => $this->getTransactionPwd(),
150
+ 'TransactionType' => $this->_getTransactionType(),
151
+ ), $data);
152
+
153
+ $debugData = array('request' => $request);
154
+
155
+ try {
156
+ foreach($request as $key => $val) {
157
+ $client->add($key, $val);
158
+ }
159
+ $client->sendHttp($this->_getApiEndpointUrl(), $this->_getTimeoutConnect(), $this->_getTimeoutRead());
160
+ } catch (Exception $e) {
161
+ $debugData['response'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
162
+ $this->_debug($debugData);
163
+ throw $e;
164
+ }
165
+
166
+ $debugData['response'] = $client->response;
167
+ $this->_debug($debugData);
168
+
169
+ return $client;
170
+ }
171
+
172
+ /**
173
+ * Getter for API call URL
174
+ *
175
+ * @return string
176
+ * @throws Exception
177
+ */
178
+ protected function _getApiEndpointUrl()
179
+ {
180
+ if ($this->getIsTestMode()) {
181
+ return 'https://centineltest.cardinalcommerce.com/maps/txns.asp';
182
+ }
183
+ $url = $this->getApiEndpointUrl();
184
+ if (!$url) {
185
+ throw new Exception('Centinel API endpoint URL is not configured properly.');
186
+ }
187
+ return $url;
188
+ }
189
+
190
+ /**
191
+ * Call centinel api lookup method
192
+ *
193
+ * @return Mage_Centinel_Model_Api
194
+ */
195
+ public function callLookup($data)
196
+ {
197
+ $result = new Varien_Object();
198
+
199
+ $month = strlen($data->getCardExpMonth()) == 1 ? '0' . $data->getCardExpMonth() : $data->getCardExpMonth();
200
+ $currencyCode = $data->getCurrencyCode();
201
+ $currencyNumber = isset(self::$_iso4217Currencies[$currencyCode]) ? self::$_iso4217Currencies[$currencyCode] : '';
202
+ if (!$currencyNumber) {
203
+ return $result->setErrorNo(1)->setErrorDesc(
204
+ Mage::helper('payment')->__('Unsupported currency code: %s.', $currencyCode)
205
+ );
206
+ }
207
+
208
+ $clientResponse = $this->_call('cmpi_lookup', array(
209
+ 'Amount' => round($data->getAmount() * 100),
210
+ 'CurrencyCode' => $currencyNumber,
211
+ 'CardNumber' => $data->getCardNumber(),
212
+ 'CardExpMonth'=> $month,
213
+ 'CardExpYear' => $data->getCardExpYear(),
214
+ 'OrderNumber' => $data->getOrderNumber()
215
+ ));
216
+
217
+ $result->setErrorNo($clientResponse->getValue('ErrorNo'));
218
+ $result->setErrorDesc($clientResponse->getValue('ErrorDesc'));
219
+ $result->setTransactionId($clientResponse->getValue('TransactionId'));
220
+ $result->setEnrolled($clientResponse->getValue('Enrolled'));
221
+ $result->setAcsUrl($clientResponse->getValue('ACSUrl'));
222
+ $result->setPayload($clientResponse->getValue('Payload'));
223
+ $result->setEciFlag($clientResponse->getValue('EciFlag'));
224
+
225
+ return $result;
226
+ }
227
+
228
+ /**
229
+ * Call centinel api authentication method
230
+ *
231
+ * @return Mage_Centinel_Model_Api
232
+ */
233
+ public function callAuthentication($data)
234
+ {
235
+ $result = new Varien_Object();
236
+
237
+ $clientResponse = $this->_call('cmpi_authenticate', array(
238
+ 'TransactionId' => $data->getTransactionId(),
239
+ 'PAResPayload' => $data->getPaResPayload(),
240
+ ));
241
+
242
+ $result->setErrorNo($clientResponse->getValue('ErrorNo'));
243
+ $result->setErrorDesc($clientResponse->getValue('ErrorDesc'));
244
+ $result->setPaResStatus($clientResponse->getValue('PAResStatus'));
245
+ $result->setSignatureVerification($clientResponse->getValue('SignatureVerification'));
246
+ $result->setCavv($clientResponse->getValue('Cavv'));
247
+ $result->setEciFlag($clientResponse->getValue('EciFlag'));
248
+ $result->setXid($clientResponse->getValue('Xid'));
249
+
250
+ return $result;
251
+ }
252
+
253
+ /**
254
+ * Log debug data to file
255
+ *
256
+ * @param mixed $debugData
257
+ */
258
+ protected function _debug($debugData)
259
+ {
260
+ if ($this->getDebugFlag()) {
261
+ Mage::getModel('core/log_adapter', 'card_validation_3d_secure.log')
262
+ ->setFilterDataKeys($this->_debugReplacePrivateDataKeys)
263
+ ->log($debugData);
264
+ }
265
+ }
266
+ }
267
+
app/code/core/Mage/Centinel/Model/Config.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Config centinel model
29
+ */
30
+ class Mage_Centinel_Model_Config
31
+ {
32
+ /**
33
+ * Store id or store model
34
+ *
35
+ * @var int|Mage_Core_Model_Store
36
+ */
37
+ protected $_store = false;
38
+
39
+ /**
40
+ * Path of centinel config
41
+ *
42
+ * @var string
43
+ */
44
+ protected $_serviceConfigPath = 'payment_services/centinel';
45
+
46
+ /**
47
+ * Path of cards config
48
+ *
49
+ * @var string
50
+ */
51
+ protected $_cardTypesConfigPath = 'global/payment/cc/types';
52
+
53
+ /**
54
+ * Set store to congif model
55
+ *
56
+ * @param int|Mage_Core_Model_Store $store
57
+ * @return Mage_Centinel_Model_Config
58
+ */
59
+ public function setStore($store)
60
+ {
61
+ $this->_store = $store;
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Return store
67
+ *
68
+ * @return int|Mage_Core_Model_Store
69
+ */
70
+ public function getStore()
71
+ {
72
+ return $this->_store;
73
+ }
74
+
75
+ /**
76
+ * Return validation state class for card with type $cardType
77
+ *
78
+ * @param string $cardType
79
+ * @return string
80
+ */
81
+ public function getStateModelClass($cardType)
82
+ {
83
+ $node = Mage::getConfig()->getNode($this->_cardTypesConfigPath . '/' . $cardType . '/validator/centinel/state');
84
+ if (!$node) {
85
+ return false;
86
+ }
87
+ return $node->asArray();
88
+ }
89
+
90
+ /**
91
+ * Return centinel processorId
92
+ *
93
+ * @return string
94
+ */
95
+ public function getProcessorId()
96
+ {
97
+ return $this->_getServiceConfigValue('processor_id');
98
+ }
99
+
100
+ /**
101
+ * Return centinel merchantId
102
+ *
103
+ * @return string
104
+ */
105
+ public function getMerchantId()
106
+ {
107
+ return $this->_getServiceConfigValue('merchant_id');
108
+ }
109
+
110
+ /**
111
+ * Return centinel transactionPwd
112
+ *
113
+ * @return string
114
+ */
115
+ public function getTransactionPwd()
116
+ {
117
+ return Mage::helper('core')->decrypt($this->_getServiceConfigValue('password'));
118
+ }
119
+
120
+ /**
121
+ * Return flag - is centinel mode test
122
+ *
123
+ * @return bool
124
+ */
125
+ public function getIsTestMode()
126
+ {
127
+ return (bool)(int)$this->_getServiceConfigValue('test_mode');
128
+ }
129
+
130
+ /**
131
+ * Return value of node of centinel config section
132
+ *
133
+ * @param string $key
134
+ * @return string
135
+ */
136
+ private function _getServiceConfigValue($key)
137
+ {
138
+ return Mage::getStoreConfig($this->_serviceConfigPath . '/' . $key, $this->getStore());
139
+ }
140
+
141
+ /**
142
+ * Define if debugging is enabled
143
+ *
144
+ * @return bool
145
+ */
146
+ public function getDebugFlag()
147
+ {
148
+ return $this->_getServiceConfigValue('debug');
149
+ }
150
+ }
app/code/core/Mage/Centinel/Model/Observer.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * 3D Secure Validation Model
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Centinel
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Centinel_Model_Observer extends Varien_Object
36
+ {
37
+ /**
38
+ * Set cmpi data to payment
39
+ *
40
+ * @param Varien_Object $observer
41
+ * @return Mage_Centinel_Model_Observer
42
+ */
43
+ public function salesEventConvertQuoteToOrder($observer)
44
+ {
45
+ $payment = $observer->getEvent()->getQuote()->getPayment();
46
+
47
+ if ($payment->getMethodInstance()->getIsCentinelValidationEnabled()) {
48
+ $to = array($payment, 'setAdditionalInformation');
49
+ $payment->getMethodInstance()->getCentinelValidator()->exportCmpiData($to);
50
+ }
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * Add cmpi data to info block
56
+ *
57
+ * @param Varien_Object $observer
58
+ * @return Mage_Centinel_Model_Observer
59
+ */
60
+ public function paymentInfoBlockPrepareSpecificInformation($observer)
61
+ {
62
+ if ($observer->getEvent()->getBlock()->getIsSecureMode()) {
63
+ return;
64
+ }
65
+
66
+ $payment = $observer->getEvent()->getPayment();
67
+ $transport = $observer->getEvent()->getTransport();
68
+ $helper = Mage::helper('centinel');
69
+
70
+ $info = array(
71
+ Mage_Centinel_Model_Service::CMPI_PARES,
72
+ Mage_Centinel_Model_Service::CMPI_ENROLLED,
73
+ Mage_Centinel_Model_Service::CMPI_ECI,
74
+ Mage_Centinel_Model_Service::CMPI_CAVV,
75
+ Mage_Centinel_Model_Service::CMPI_XID
76
+ );
77
+ foreach ($info as $key) {
78
+ if ($value = $payment->getAdditionalInformation($key)) {
79
+ $transport->setData($helper->getCmpiLabel($key), $helper->getCmpiValue($key, $value));
80
+ }
81
+ }
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * Add centinel logo block into payment form
87
+ *
88
+ * @param Varien_Object $observer
89
+ * @return Mage_Centinel_Model_Observer
90
+ */
91
+ public function paymentFormBlockToHtmlBefore($observer)
92
+ {
93
+ $paymentFormBlock = $observer->getEvent()->getBlock();
94
+ $method = $paymentFormBlock->getMethod();
95
+
96
+ if ($method && $method->getIsCentinelValidationEnabled()) {
97
+ $paymentFormBlock->setChild(
98
+ 'payment.method.' . $method->getCode() . 'centinel.logo',
99
+ Mage::helper('centinel')->getMethodFormBlock($method)
100
+ );
101
+ }
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Reset validation data
107
+ *
108
+ * @param Varien_Object $observer
109
+ * @return Mage_Centinel_Model_Observer
110
+ */
111
+ public function checkoutSubmitAllAfter($observer)
112
+ {
113
+ $method = false;
114
+
115
+ if ($order = $observer->getEvent()->getOrder()) {
116
+ $method = $order->getPayment()->getMethodInstance();
117
+ } elseif ($orders = $observer->getEvent()->getOrders()) {
118
+ if ($order = array_shift($orders)) {
119
+ $method = $order->getPayment()->getMethodInstance();
120
+ }
121
+ }
122
+
123
+ if ($method && $method->getIsCentinelValidationEnabled()) {
124
+ $method->getCentinelValidator()->reset();
125
+ }
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ * Reset validation data
131
+ * @deprecated back compatibility alias for checkoutSubmitAllAfter
132
+ *
133
+ * @param Varien_Object $observer
134
+ * @return Mage_Centinel_Model_Observer
135
+ */
136
+ public function salesOrderPaymentPlaceEnd($observer)
137
+ {
138
+ $this->checkoutSubmitAllAfter($observer);
139
+ return $this;
140
+ }
141
+ }
app/code/core/Mage/Centinel/Model/Service.php ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Centinel
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * 3D Secure Validation Model
29
+ */
30
+ class Mage_Centinel_Model_Service extends Varien_Object
31
+ {
32
+ /**
33
+ * Cmpi public keys
34
+ */
35
+ const CMPI_PARES = 'centinel_authstatus';
36
+ const CMPI_ENROLLED = 'centinel_mpivendor';
37
+ const CMPI_CAVV = 'centinel_cavv';
38
+ const CMPI_ECI = 'centinel_eci';
39
+ const CMPI_XID = 'centinel_xid';
40
+
41
+ /**
42
+ * State cmpi results to public map
43
+ *
44
+ * @var array
45
+ */
46
+ protected $_cmpiMap = array(
47
+ 'lookup_enrolled' => self::CMPI_ENROLLED,
48
+ 'lookup_eci_flag' => self::CMPI_ECI,
49
+ 'authenticate_pa_res_status' => self::CMPI_PARES,
50
+ 'authenticate_cavv' => self::CMPI_CAVV,
51
+ 'authenticate_eci_flag' => self::CMPI_ECI,
52
+ 'authenticate_xid' => self::CMPI_XID,
53
+ );
54
+
55
+ /**
56
+ * Validation api model
57
+ *
58
+ * @var Mage_Centinel_Model_Api
59
+ */
60
+ protected $_api;
61
+
62
+ /**
63
+ * Validation state model
64
+ *
65
+ * @var Mage_Centinel_Model_StateAbstract
66