IdentityMind_AntiFraud_Magento - Version 1.0.24

Version Notes

Please contact IdentityMind for updated User Guide and release notes at cs@identitymind.com

Download this release

Release Info

Developer Jose Caldera
Extension IdentityMind_AntiFraud_Magento
Version 1.0.24
Comparing to
See all releases


Version 1.0.24

app/code/local/IdentityMind/IdentityMindEdna/Block/Sales/Order/Payment.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This is an overwrite of core Magento block class: Mage_Adminhtml_Block_Sales_Order_Payment
5
+ * it adds a http link right after the code of Payment Information section
6
+ *
7
+ * @category IdentityMind
8
+ * @package IdentityMind_IdentityMindEdna
9
+ */
10
+ class IdentityMind_IdentityMindEdna_Block_Sales_Order_Payment extends Mage_Adminhtml_Block_Sales_Order_Payment {
11
+
12
+ /**
13
+ * Transforms returned HTML code of Payment Information
14
+ * add a http link to IdentityMind EDNA panel
15
+ *
16
+ * @param string $html
17
+ * @return string
18
+ */
19
+ protected function _afterToHtml($html) {
20
+ $payment = $this->getParentBlock()->getOrder()->getPayment();
21
+ /* @var $payment Mage_Sales_Model_Order_Payment */
22
+
23
+ if ($payment->getAdditionalInformation(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_TRANSACTION_ID_KEY)) {
24
+ $html = $html . '<a href="https://edna.identitymind.com" target="_blank">IdentityMind eDNA Login</a>';
25
+ }
26
+
27
+ return parent::_afterToHtml( $html);
28
+ }
29
+
30
+ }
app/code/local/IdentityMind/IdentityMindEdna/Block/System/Config/Form/Fieldset.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class IdentityMind_IdentityMindEdna_Block_System_Config_Form_Fieldset
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
5
+ {
6
+ public function render(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ return Mage::helper('identitymindedna')->__(Mage::getStoreConfig('identitymind/access/text'));
9
+ }
10
+ }
app/code/local/IdentityMind/IdentityMindEdna/Helper/Data.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * A default module helper
5
+ *
6
+ * @category IdentityMind
7
+ * @package IdentityMind_IdentityMindEdna
8
+ */
9
+ class IdentityMind_IdentityMindEdna_Helper_Data extends Mage_Core_Helper_Abstract {
10
+
11
+ const PAYMENT_TRANSACTION_ID_KEY = 'edna_transaction_id';
12
+ const PAYMENT_FEEDBACK_EVENT_NAME = 'feedback_event_type';
13
+ const PAYMENT_OBJECT_KEY = 'payment_object';
14
+ const PAYMENT_FEEDBACK_SENT_FLAG = 'feedback_sent';
15
+
16
+ const ORDER_STATUS_MANUAL_REVIEW = 'manual_review';
17
+ const ORDER_STATUS_DENIED = 'denied';
18
+ const ORDER_STATUS_REJECTED = 'rejected';
19
+ const ORDER_STATUS_PENDING = 'pending';
20
+ const ORDER_STATUS_ACCEPTED = 'processing';
21
+
22
+ /**
23
+ * Checks if current payment belongs to an order, which was after the Manual Review status
24
+ *
25
+ * @param Mage_Sales_Model_Order_Payment $payment
26
+ * @return boolean
27
+ */
28
+ public function isOrderPaymentAfterManualReview(Mage_Sales_Model_Order_Payment $payment) {
29
+
30
+ $order = $payment->getOrder();
31
+ /* @var $order Mage_Sales_Model_Order */
32
+
33
+ $statusHistoryCollection = $order->getStatusHistoryCollection();
34
+
35
+ foreach ($statusHistoryCollection as $status) {
36
+ if ($status->getStatus() == self::ORDER_STATUS_MANUAL_REVIEW) {
37
+ return true;
38
+ }
39
+ }
40
+
41
+ return false;
42
+ }
43
+ /**
44
+ * Sets IdentityMind transactionID in the additional information array for Payment object
45
+ *
46
+ * @param Mage_Sales_Model_Quote_Payment $payment
47
+ * @param string $transactionId
48
+ */
49
+ public function setOrderPaymentEdnaTransactionId($payment, $transactionId) {
50
+ $payment->setAdditionalInformation(self::PAYMENT_TRANSACTION_ID_KEY, $transactionId);
51
+ }
52
+
53
+ /**
54
+ * Gets IdentityMind transactionID from the current Payment object
55
+ * (returns null if not set)
56
+ *
57
+ * @param Mage_Sales_Model_Order_Payment $payment
58
+ * @return string (null if not set)
59
+ */
60
+ public function getOrderPaymentEdnaTransactionId($payment) {
61
+ return $payment->getAdditionalInformation(self::PAYMENT_TRANSACTION_ID_KEY);
62
+ }
63
+
64
+ }
app/code/local/IdentityMind/IdentityMindEdna/Model/Identitymindapi/Ednarequest.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHP API communication with IdentityMind EDNA API
4
+ *
5
+ * @category IdentityMind
6
+ * @package IdentityMind_IdentityMindEdna
7
+ */
8
+ class IdentityMind_IdentityMindEdna_Model_Identitymindapi_Ednarequest {
9
+
10
+ const BASE_URL_REQUEST = 'https://204.147.180.38/im/transaction'; // staging.identitymind.com (?)
11
+ // const BASE_URL_REQUEST = 'https://edna.identitymind.com/im/transaction';
12
+
13
+ const FEEDBACK_TYPE_ACCEPTED = 'accepted';
14
+ const FEEDBACK_TYPE_REJECTED = 'rejected';
15
+
16
+ /**
17
+ * Sends a request to provided url and with provided request params
18
+ * Returns decoded json object (a PHP stdClass), or null on error
19
+ *
20
+ * @param string $url
21
+ * @param array $ednaRequestArray
22
+ * @return stdClass
23
+ */
24
+ private function getResponse($url, $ednaRequestArray = array()) {
25
+
26
+
27
+ $username = Mage::getStoreConfig('identitymind_edna/api_credentials/user', Mage::app()->getStore());
28
+ $password = Mage::getStoreConfig('identitymind_edna/api_credentials/key', Mage::app()->getStore());
29
+
30
+ $headers = array(
31
+ 'Content-Type: application/json',
32
+ 'Accept: application/json',
33
+ );
34
+
35
+
36
+ Mage::log(print_r(array($url, $ednaRequestArray), true), null, 'feedback.log', true);
37
+
38
+ $process = curl_init();
39
+ curl_setopt($process, CURLOPT_URL, $url);
40
+ curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
41
+ curl_setopt($process, CURLOPT_SSL_VERIFYHOST, false);
42
+ curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
43
+ curl_setopt($process, CURLOPT_HEADER, false);
44
+ curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
45
+ curl_setopt($process, CURLOPT_TIMEOUT, 30);
46
+ curl_setopt($process, CURLOPT_POST, 1);
47
+ curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
48
+ if (!empty($ednaRequestArray)) {
49
+ curl_setopt($process, CURLOPT_POSTFIELDS, json_encode($ednaRequestArray));
50
+ }
51
+ curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
52
+
53
+
54
+ $response = curl_exec($process);
55
+
56
+ Mage::log("getResponse: ".print_r($response, true), null, 'feedback.log', true);
57
+ $responseError = curl_error($process);
58
+
59
+ if ($responseError) {
60
+ Mage::log('eDNA Response Error:' . $responseError, null, 'feedback.log', true);
61
+ return null;
62
+ } else {
63
+ Mage::log('no eDNA Response Error:' . $responseError, null, 'feedback.log', true);
64
+ return json_decode($response);
65
+ }
66
+ }
67
+
68
+ /**
69
+ *
70
+ * @param array $ednaRequestArray
71
+ * @param string $creditCardNumber
72
+ * @return stdClass
73
+ */
74
+ public function getTransactionResponse($ednaRequestArray = array(), $creditCardNumber = '') {
75
+ $ednaRequestArray = Mage::getModel('identitymindedna/identitymindapi_utils_creditcardutils')
76
+ ->addCreditCardData($creditCardNumber, $ednaRequestArray);
77
+
78
+ return $this->getResponse(
79
+ Mage::getStoreConfig('identitymind_edna/api_credentials/endpoint', Mage::app()->getStore()),
80
+ $ednaRequestArray
81
+ );
82
+ }
83
+
84
+ /**
85
+ *
86
+ * @param type $transactionId
87
+ * @param type $feedbackType
88
+ * @param type $ednaRequestArray
89
+ * @return type
90
+ */
91
+ public function getFeedbackResponse($transactionId, $feedbackType, $ednaRequestArray = array()) {
92
+ $feedbackUrl = Mage::getStoreConfig('identitymind_edna/api_credentials/endpoint', Mage::app()->getStore()) . '/'
93
+ . $transactionId . '/' . $feedbackType;
94
+ return $this->getResponse($feedbackUrl, $ednaRequestArray);
95
+ }
96
+
97
+
98
+ public function getPaypalTransactionResponse($ednaRequestArray = array()) {
99
+ return $this->getResponse(
100
+ Mage::getStoreConfig('identitymind_edna/api_credentials/endpoint', Mage::app()->getStore()),
101
+ $ednaRequestArray
102
+ );
103
+ }
104
+ }
app/code/local/IdentityMind/IdentityMindEdna/Model/Identitymindapi/Utils/Creditcardutils.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This class is a 1-1 wrapper of provided IdentityMind JAVA class CreditCardUtils (package: com.identitymind.utils)
5
+ * transfered from JAVA to PHP code
6
+ *
7
+ * @category IdentityMind
8
+ * @package IdentityMind_IdentityMindEdna
9
+ */
10
+ class IdentityMind_IdentityMindEdna_Model_Identitymindapi_Utils_Creditcardutils {
11
+
12
+ private $_salt = '54l73D47';
13
+
14
+ public function addCreditCardData($creditCardNumber, $requestArray = array()) {
15
+ $requestArray['pccn'] = $this->generateFullCardHash($creditCardNumber);
16
+ $requestArray['pcct'] = $this->generateCardToken($creditCardNumber);
17
+ $requestArray['pccp'] = $this->generatePartialCardHash($creditCardNumber);
18
+ return $requestArray;
19
+ }
20
+
21
+ private function generateFullCardHash($creditCardNumber) {
22
+ $creditCardNumber = $this->normalizeCreditCard($creditCardNumber);
23
+ return sha1($this->_salt . $creditCardNumber);
24
+ }
25
+
26
+ private function generateCardToken($creditCardNumber) {
27
+ if (empty($creditCardNumber)) {
28
+ Mage::throwException(Mage::helper('identitymindedna')->__('card number must be provided'));
29
+ }
30
+ $creditCardNumber = $this->normalizeCreditCard($creditCardNumber);
31
+ if (strlen($creditCardNumber) == 15 || strlen($creditCardNumber) == 16) {
32
+ return substr($creditCardNumber, 0, 6) . 'XXXXXX' . substr($creditCardNumber, 12);
33
+ } else {
34
+ Mage::throwException(Mage::helper('identitymindedna')->__('card number did not normalize to a 15 or 16 digit number'));
35
+ }
36
+ }
37
+
38
+ private function generatePartialCardHash($creditCardNumber) {
39
+ $creditCardNumber = $this->normalizeCreditCard($creditCardNumber);
40
+ return $this->generateFullCardHash(substr($creditCardNumber, 0, 11));
41
+ }
42
+
43
+ private function normalizeCreditCard($creditCardNumber) {
44
+ return preg_replace('/[\s\W]+/', "", $creditCardNumber);
45
+ }
46
+ }
app/code/local/IdentityMind/IdentityMindEdna/Model/Observer.php ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The main Observer class, which catches following events:
5
+ * sales_quote_payment_import_data_before
6
+ * sales_order_payment_place_end
7
+ * sales_order_payment_capture
8
+ * sales_order_payment_void
9
+ * sales_order_payment_cancel
10
+ *
11
+ *
12
+ * @category IdentityMind
13
+ * @package IdentityMind_IdentityMindEdna
14
+ */
15
+ class IdentityMind_IdentityMindEdna_Model_Observer {
16
+
17
+ private $_ednaResponse = null;
18
+ private $_afterValidationAction = null;
19
+
20
+ /**
21
+ * Set payment data into registry for further operations (if needed)
22
+ * @param Varien_Event_Observer $observer
23
+ */
24
+ public function verifyCreditCardBefore(Varien_Event_Observer $observer)
25
+ {
26
+ Mage::log("verifyCreditCardBefore", null, 'feedback.log', true);
27
+ $paymentObject = new Varien_Object();
28
+
29
+ $input = $observer->getEvent()->getInput();
30
+
31
+ if (!isset($input['cc_number'])) {
32
+ return $this;
33
+ }
34
+ $paymentObject->setPayment($observer->getEvent()->getPayment());
35
+ $paymentObject->setInput($input);
36
+
37
+ if (!Mage::registry('payment_object')) {
38
+ Mage::register('payment_object', $paymentObject);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * A method to be added for 'sales_quote_payment_import_data_before' event
44
+ * This is a verification of CC data entered by the front-end user (both: admin and regular customer)
45
+ * It prepares and sends a request data to the IdentityMind API server with use of Identitymindapi_Ednarequest model
46
+ *
47
+ * @param Varien_Object $obj
48
+ * @throws Mage_Core_Exception
49
+ * @return IdentityMind_IdentityMindEdna_Model_Observer
50
+ */
51
+ public function verifyCreditCard(Varien_Object $obj)
52
+ {
53
+ Mage::log("verifyCreditCard", null, 'feedback.log', true);
54
+
55
+ if (!(bool)Mage::getStoreConfig('identitymind_edna/general/enabled', Mage::app()->getStore())) {
56
+ return $this;
57
+ }
58
+
59
+ $input = $obj->getInput();
60
+
61
+ $payment = $obj->getPayment();
62
+ /* @var $payment Mage_Sales_Model_Quote_Payment */
63
+ $order = $payment->getOrder();
64
+
65
+ $quote = $payment->getQuote();
66
+ /* @var $quote Mage_Sales_Model_Quote */
67
+ $billingAddress = $quote->getBillingAddress();
68
+ /* @var $billingAddress Mage_Sales_Model_Quote_Address */
69
+
70
+ $shippingAddress = $quote->getShippingAddress();
71
+ /* @var $shippingAddress Mage_Sales_Model_Quote_Address */
72
+
73
+ $ednaRequestArray = array(
74
+ 'bfn' => $billingAddress->getFirstname(),
75
+ 'bln' => $billingAddress->getLastname(),
76
+ 'bsn' => $billingAddress->getStreetFull(),
77
+ 'bc' => $billingAddress->getCity(),
78
+ 'bs' => $billingAddress->getRegionCode(),
79
+ 'bz' => $billingAddress->getPostcode(),
80
+ 'bco' => $billingAddress->getCountry(),
81
+ 'sfn' => $shippingAddress->getFirstname(),
82
+ 'sln' => $shippingAddress->getLastname(),
83
+ 'ssn' => $shippingAddress->getStreetFull(),
84
+ 'sc' => $shippingAddress->getCity(),
85
+ 'ss' => $shippingAddress->getRegionCode(),
86
+ 'sz' => $shippingAddress->getPostcode(),
87
+ 'sco' => $shippingAddress->getCountry(),
88
+ 'ip' => $quote->getRemoteIp(),
89
+ 'blg' => $_SERVER['HTTP_ACCEPT_LANGUAGE'],
90
+ 'tea' => $quote->getCustomerEmail(),
91
+ 'ph' => $billingAddress->getTelephone(),
92
+ 'amt' => $quote->getGrandTotal(),
93
+ 'ccy' => $quote->getQuoteCurrencyCode(),
94
+ );
95
+
96
+ if (!$quote->getCustomerIsGuest()) {
97
+ $customer = $quote->getCustomer();
98
+ /* @var $customer Mage_Customer_Model_Customer */
99
+
100
+ $registeredUserDetailsArray = array(
101
+ 'acd' => $customer->getCreatedAtTimestamp(),
102
+ 'man' => $customer->getLastname().', '.$customer->getFirstname(),
103
+ 'mem' => $customer->getEmail(),
104
+ );
105
+ $ednaRequestArray = array_merge($ednaRequestArray, $registeredUserDetailsArray);
106
+ }
107
+
108
+ $this->_ednaResponse = Mage::getModel('identitymindedna/identitymindapi_ednarequest')
109
+ ->getTransactionResponse($ednaRequestArray, $input['cc_number']);
110
+
111
+ if ( !($this->_ednaResponse instanceof stdClass)) {
112
+ Mage::log('IdentityMind API Response was incorrect (reserved-order-ID: ' . $quote->getReservedOrderId() . ')');
113
+ }
114
+
115
+ if (isset($this->_ednaResponse->transaction_status) && $this->_ednaResponse->transaction_status == 'error') {
116
+ $action = strtoupper(Mage::getStoreConfig('identitymind_edna/configuration/action_on_error', Mage::app()->getStore()));
117
+ $this->_afterValidationAction = str_replace('-', '_', $action);
118
+ } else {
119
+ $this->_afterValidationAction = $this->_ednaResponse->res;
120
+ }
121
+
122
+ if (isset($this->_ednaResponse->tid)) {
123
+ Mage::helper('identitymindedna')->setOrderPaymentEdnaTransactionId($payment,$this->_ednaResponse->tid);
124
+ Mage::register(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_TRANSACTION_ID_KEY, $this->_ednaResponse->tid);
125
+ if (!Mage::registry(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_FEEDBACK_SENT_FLAG)){
126
+ if(!Mage::registry(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_OBJECT_KEY)) {
127
+ Mage::register(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_OBJECT_KEY, $payment);
128
+ }
129
+ $this->sendFeedback();
130
+ }
131
+ }
132
+
133
+
134
+ switch ($this->_afterValidationAction) {
135
+ case 'DENY':
136
+ // $exceptionMessage = isset($this->_ednaResponse->res)?$this->_ednaResponse->res . ': ' . $this->_ednaResponse->frn:'Your Credit Card details were rejected';
137
+ // Mage::throwException($exceptionMessage);
138
+
139
+ // $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, IdentityMind_IdentityMindEdna_Helper_Data::ORDER_STATUS_MANUAL_REVIEW, $exceptionMessage, false);
140
+ case 'MANUAL_REVIEW':
141
+ case 'ACCEPT':
142
+ default:
143
+ return $this;
144
+ }
145
+
146
+ }
147
+
148
+ /**
149
+ * Method added to the 'sales_order_payment_place_end' event
150
+ * event after successful payment place and just before order save
151
+ * it uses a response object returned by IdentityMind EDNA API on CC details validation
152
+ * (returned on the previous step)
153
+ *
154
+ * It is used only for adding the response message to the order comments, and
155
+ * if the response was MANUAL_REVIEW - it puts the order to "OnHold" state with "Manual Review" status
156
+ *
157
+ * @param Varien_Event_Observer $observer
158
+ * @return \IdentityMind_IdentityMindEdna_Model_Observer
159
+ */
160
+ public function applyActionToOrder(Varien_Event_Observer $observer)
161
+ {
162
+ Mage::log("applyActionToOrder", null, 'feedback.log', true);
163
+ if ($paymentObject = Mage::registry('payment_object')) {
164
+ $this->verifyCreditCard($paymentObject);
165
+ }
166
+
167
+ if (!(bool)Mage::getStoreConfig('identitymind_edna/general/enabled', Mage::app()->getStore())) {
168
+ return $this;
169
+ }
170
+
171
+ if ( empty($this->_ednaResponse) || !($this->_ednaResponse instanceof stdClass)) {
172
+ return $this;
173
+ }
174
+
175
+ /* @var $payment Mage_Sales_Model_Order_Payment */
176
+ $payment = $observer->getEvent()->getPayment();
177
+
178
+ /*
179
+ * process further only if the payment uses "Authorize Only" (without capture on order placement)
180
+ * if the payment transaction is captured - it's already paid and there's nothing we can do
181
+ */
182
+ /*if ($payment->getMethodInstance()->getConfigPaymentAction() != Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
183
+ return $this;
184
+ }*/
185
+
186
+ $order = $payment->getOrder();
187
+
188
+ /* @var $order Mage_Sales_Model_Order */
189
+ switch($this->_afterValidationAction) {
190
+ case 'MANUAL_REVIEW':
191
+ $message = '';
192
+ if (isset($this->_ednaResponse->res)) {
193
+ $message = '[IdentityMind eDNA] (transactionID:' . $this->_ednaResponse->tid . ') "'
194
+ . $this->_ednaResponse->res . '" reason: ' . $this->_ednaResponse->frn;
195
+
196
+ if (isset($this->_ednaResponse->ram)) {
197
+ $message .= '; "ram": ' . $this->_ednaResponse->ram;
198
+ }
199
+
200
+ if (isset($this->_ednaResponse->frd)) {
201
+ $message .= '; "frd": ' . $this->_ednaResponse->frd;
202
+ }
203
+ } elseif(isset($this->_ednaResponse->error_message)) {
204
+ $message = '[IdentityMind eDNA] error on request to eDNA: ' . $this->_ednaResponse->error_message;
205
+ }
206
+ $order->setHoldBeforeState($order->getState());
207
+ $order->setHoldBeforeStatus($order->getStatus());
208
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, IdentityMind_IdentityMindEdna_Helper_Data::ORDER_STATUS_MANUAL_REVIEW, $message, false);
209
+
210
+ break;
211
+ case 'ACCEPT':
212
+ $message = '[IdentityMind eDNA] (transactionID:' . $this->_ednaResponse->tid . ') "'
213
+ . $this->_ednaResponse->res . '": ' . $this->_ednaResponse->frn;
214
+ if (isset($this->_ednaResponse->frd)) {
215
+ $message .= '; "frd": ' . $this->_ednaResponse->frd;
216
+ }
217
+ $order->addStatusHistoryComment($message);
218
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, $message, false);
219
+ break;
220
+ case 'DENY':
221
+ $message = '[IdentityMind eDNA] (transactionID:' . $this->_ednaResponse->tid . ') "'
222
+ . $this->_ednaResponse->res . '": ' . $this->_ednaResponse->frn;
223
+ if (isset($this->_ednaResponse->frd)) {
224
+ $message .= '; "frd": ' . $this->_ednaResponse->frd;
225
+ }
226
+ $order->addStatusHistoryComment($message);
227
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, IdentityMind_IdentityMindEdna_Helper_Data::ORDER_STATUS_DENIED, $message, false);
228
+ break;
229
+ case 'REJECT':
230
+ $message = '[IdentityMind eDNA] (transactionID:' . $this->_ednaResponse->tid . ') "'
231
+ . $this->_ednaResponse->res . '": ' . $this->_ednaResponse->frn;
232
+ if (isset($this->_ednaResponse->frd)) {
233
+ $message .= '; "frd": ' . $this->_ednaResponse->frd;
234
+ }
235
+ $order->addStatusHistoryComment($message);
236
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, IdentityMind_IdentityMindEdna_Helper_Data::ORDER_STATUS_REJECTED, $message, false);
237
+ break;
238
+ default:
239
+ return $this;
240
+ }
241
+ return $this;
242
+ }
243
+
244
+ /**
245
+ * Sends a feedback after the payment was: captured, voided or canceled
246
+ * it uses methods from Identitymindapi_Ednarequest model
247
+ *
248
+ * @param Varien_Event_Observer $observer
249
+ * @return \IdentityMind_IdentityMindEdna_Model_Observer
250
+ */
251
+ public function sendFeedback($observer = null)
252
+ {
253
+ Mage::log("sendFeedback", null, 'feedback.log', true);
254
+
255
+ if (!(bool)Mage::getStoreConfig('identitymind_edna/general/enabled')) {
256
+ return $this;
257
+ }
258
+
259
+ $ednaTransactionId = Mage::registry(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_TRANSACTION_ID_KEY);
260
+ $feedbackEventName = Mage::registry(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_FEEDBACK_EVENT_NAME);
261
+ $payment = Mage::registry(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_OBJECT_KEY);
262
+
263
+ if (!$feedbackEventName && $observer) {
264
+ Mage::register(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_FEEDBACK_EVENT_NAME, $observer->getEvent()->getName());
265
+ }
266
+
267
+ if (!$payment && $observer) {
268
+ $payment = $observer->getEvent()->getPayment();
269
+ Mage::register(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_OBJECT_KEY, $payment);
270
+ }
271
+
272
+ if (!$ednaTransactionId ) {
273
+ return $this;
274
+ }
275
+
276
+
277
+
278
+ $feedbackType = null;
279
+
280
+ switch($feedbackEventName) {
281
+ case 'sales_order_payment_capture':
282
+ $feedbackType = IdentityMind_IdentityMindEdna_Model_Identitymindapi_Ednarequest::FEEDBACK_TYPE_ACCEPTED;
283
+ break;
284
+ case 'sales_order_payment_void':
285
+ case 'sales_order_payment_cancel':
286
+ $feedbackType = IdentityMind_IdentityMindEdna_Model_Identitymindapi_Ednarequest::FEEDBACK_TYPE_REJECTED;
287
+ break;
288
+ default:
289
+ return $this;
290
+ }
291
+
292
+ $ednaRequestArray = array(
293
+ 'tid' => $ednaTransactionId
294
+ );
295
+
296
+ $this->_ednaResponse = Mage::getModel('identitymindedna/identitymindapi_ednarequest')
297
+ ->getFeedbackResponse($ednaTransactionId, $feedbackType, $ednaRequestArray);
298
+
299
+ $order = $payment->getOrder();
300
+
301
+ if (!$order) {
302
+ return;
303
+ }
304
+
305
+ /* @var $order Mage_Sales_Model_Order */
306
+
307
+ if ( !($this->_ednaResponse instanceof stdClass)) {
308
+ Mage::log(
309
+ 'IdentityMind API Response was incorrect for Order ID: ' . $order->getId() . ', Order increment-ID: '
310
+ . $order->getIncrementId()
311
+ );
312
+ }
313
+
314
+ if (isset($this->_ednaResponse->transaction_status) && $this->_ednaResponse->transaction_status == 'error') {
315
+ $order->addStatusHistoryComment(
316
+ 'There was an error during IdentityMind eDNA feedback request: '
317
+ . $this->_ednaResponse->error_message
318
+ );
319
+ $this->_ednaResponse = null;
320
+ return $this;
321
+ } elseif(isset($this->_ednaResponse->message)) {
322
+
323
+ Mage::log('[IdentityMind eDNA] Feedback response: ' . $this->_ednaResponse->message, null, 'feedback.log', true);
324
+ $order->addStatusHistoryComment('[IdentityMind eDNA] Feedback response: ' . $this->_ednaResponse->message);
325
+ }
326
+ Mage::log("The End", null, 'feedback.log', true);
327
+ Mage::register(IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_FEEDBACK_SENT_FLAG, true);
328
+ return $this;
329
+ }
330
+
331
+ public function orderPaymentSaveAfter(Varien_Event_Observer $observer)
332
+ {
333
+ Mage::log("orderPaymentSaveAfter", null, 'feedback.log', true);
334
+ $payment = $observer->getEvent()->getPayment();
335
+
336
+ if (Mage::registry('paypal_payment_'.$payment->getId())) {
337
+ return;
338
+ }
339
+
340
+ $info = $payment->getAdditionalInformation();
341
+
342
+ if (!isset($info['paypal_payer_id']) || !isset($info['paypal_payer_email'])) {
343
+ return;
344
+ }
345
+
346
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
347
+
348
+ if (!$quote || !($quote->getId()>0)) {
349
+ return;
350
+ }
351
+
352
+ $billingAddress = $quote->getBillingAddress();
353
+ $shippingAddress = $quote->getShippingAddress();
354
+
355
+ if (!$billingAddress || !$shippingAddress || !$quote->getGrandTotal() || !$quote->getCustomerEmail()) {
356
+ return;
357
+ }
358
+
359
+ $ednaRequestArray = array(
360
+ 'bfn' => $billingAddress->getFirstname(),
361
+ 'bln' => $billingAddress->getLastname(),
362
+ 'bsn' => $billingAddress->getStreetFull(),
363
+ 'bc' => $billingAddress->getCity(),
364
+ 'bs' => $billingAddress->getRegionCode(),
365
+ 'bz' => $billingAddress->getPostcode(),
366
+ 'bco' => $billingAddress->getCountry(),
367
+ 'sfn' => $shippingAddress->getFirstname(),
368
+ 'sln' => $shippingAddress->getLastname(),
369
+ 'ssn' => $shippingAddress->getStreetFull(),
370
+ 'sc' => $shippingAddress->getCity(),
371
+ 'ss' => $shippingAddress->getRegionCode(),
372
+ 'sz' => $shippingAddress->getPostcode(),
373
+ 'sco' => $shippingAddress->getCountry(),
374
+ 'ip' => $quote->getRemoteIp(),
375
+ 'blg' => $_SERVER['HTTP_ACCEPT_LANGUAGE'],
376
+ 'tea' => $quote->getCustomerEmail(),
377
+ 'ph' => $billingAddress->getTelephone(),
378
+ 'amt' => $quote->getGrandTotal(),
379
+ 'ccy' => $quote->getQuoteCurrencyCode(),
380
+ 'pppi'=> $info['paypal_payer_id'],
381
+ 'pppe'=> $info['paypal_payer_email']
382
+ );
383
+
384
+ $ednaResponse = Mage::getModel('identitymindedna/identitymindapi_ednarequest')
385
+ ->getPaypalTransactionResponse($ednaRequestArray);
386
+
387
+ Mage::helper('identitymindedna')->setOrderPaymentEdnaTransactionId($payment,$ednaResponse->tid);
388
+
389
+ Mage::register('paypal_payment_'.$payment->getId(), true);
390
+
391
+ $order = $payment->getOrder();
392
+
393
+
394
+ $order->addStatusHistoryComment(
395
+ "[IdentityMind eDNA] PayPal Transaction: <br />" .
396
+ "Transaction status:".$ednaResponse->res."<br />".
397
+ "Result:".$ednaResponse->transaction_status."<br />"
398
+ );
399
+
400
+ $msg = isset($ednaResponse->res) ? $ednaResponse->res . ': ' . $ednaResponse->frn : 'Your Paypal Account details were rejected';
401
+ echo get_class($order->getPayment());
402
+ switch ($ednaResponse->res) {
403
+ case 'DENY':
404
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, IdentityMind_IdentityMindEdna_Helper_Data::ORDER_STATUS_DENIED, $msg, false);
405
+ // $order->getPayment()->deny();
406
+ break;
407
+ case 'MANUAL_REVIEW':
408
+
409
+ $order->setHoldBeforeState($order->getState());
410
+ $order->setHoldBeforeStatus($order->getStatus());
411
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, IdentityMind_IdentityMindEdna_Helper_Data::ORDER_STATUS_MANUAL_REVIEW, $msg, false);
412
+ break;
413
+ case 'ACCEPT':
414
+ $msg = '[IdentityMind eDNA] (transactionID:' . $ednaResponse->tid . ') "'
415
+ . $ednaResponse->res . '": ' . $ednaResponse->frn;
416
+ if (isset($ednaResponse->frd)) {
417
+ $msg .= '; "frd": ' . $ednaResponse->frd;
418
+ }
419
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, $msg, false);
420
+ // $order->getPayment()->accept();
421
+ break;
422
+ case 'REJECTED':
423
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, IdentityMind_IdentityMindEdna_Helper_Data::ORDER_STATUS_REJECTED, $msg, false);
424
+ break;
425
+ default:
426
+ return $this;
427
+ }
428
+ // $order->save();
429
+
430
+ return;
431
+ }
432
+
433
+ public function paymentReviewCompletedAfter(Varien_Event_Observer $observer)
434
+ {
435
+ $payment = $observer->getEvent()->getPayment();
436
+ $action = $observer->getEvent()->getAction();
437
+
438
+ $event = ($action == 'accept') ? 'sales_order_payment_capture' : 'sales_order_payment_cancel';
439
+
440
+ Mage::log("paymentReviewCompletedAfter; action: ".$action, null, 'feedback.log', true);
441
+
442
+ Mage::register(
443
+ IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_TRANSACTION_ID_KEY,
444
+ $payment->getAdditionalInformation('edna_transaction_id')
445
+ );
446
+
447
+ Mage::register(
448
+ IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_FEEDBACK_EVENT_NAME,
449
+ $event
450
+ );
451
+
452
+ Mage::register(
453
+ IdentityMind_IdentityMindEdna_Helper_Data::PAYMENT_OBJECT_KEY,
454
+ $payment
455
+ );
456
+
457
+ return $this->sendFeedback();
458
+ }
459
+
460
+ };
app/code/local/IdentityMind/IdentityMindEdna/Model/Source/Onerrordropdown.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * A definition of available options for a drop-down admin field
5
+ *
6
+ *
7
+ * @category IdentityMind
8
+ * @package IdentityMind_IdentityMindEdna
9
+ */
10
+ class IdentityMind_IdentityMindEdna_Model_Source_Onerrordropdown {
11
+
12
+ /**
13
+ * Options getter
14
+ *
15
+ * @return array
16
+ */
17
+ public function toOptionArray() {
18
+ return array(
19
+ array('value' => 'accept', 'label' => Mage::helper('identitymindedna')->__('Accept Order')),
20
+ array('value' => 'deny', 'label' => Mage::helper('identitymindedna')->__('Deny Order')),
21
+ array('value' => 'manual-review', 'label' => Mage::helper('identitymindedna')->__('Set Manual Review Status (On Hold state)')),
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Get options in "key-value" format
27
+ *
28
+ * @return array
29
+ */
30
+ public function toArray()
31
+ {
32
+ return array(
33
+ 'accept' => Mage::helper('identitymindedna')->__('Accept Order'),
34
+ 'deny' => Mage::helper('identitymindedna')->__('Deny Order'),
35
+ 'manual-review' => Mage::helper('identitymindedna')->__('Set Manual Review Status (On Hold state)'),
36
+ );
37
+ }
38
+ }
app/code/local/IdentityMind/IdentityMindEdna/controllers/IndexController.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class IdentityMind_IdentityMindEdna_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout()->renderLayout();
8
+ }
9
+
10
+ }
app/code/local/IdentityMind/IdentityMindEdna/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <identitymind_edna translate="title">
12
+ <title>IdentityMind eDNA Configuration</title>
13
+ <sort_order>100</sort_order>
14
+ </identitymind_edna>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/local/IdentityMind/IdentityMindEdna/etc/config.xml ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <IdentityMind_IdentityMindEdna>
5
+ <version>0.1.2</version>
6
+ </IdentityMind_IdentityMindEdna>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <identitymindedna>
11
+ <class>IdentityMind_IdentityMindEdna_Model</class>
12
+ </identitymindedna>
13
+ </models>
14
+ <helpers>
15
+ <identitymindedna>
16
+ <class>IdentityMind_IdentityMindEdna_Helper</class>
17
+ </identitymindedna>
18
+ </helpers>
19
+ <events>
20
+ <sales_quote_payment_import_data_before>
21
+ <observers>
22
+ <identitymind_identitymindedna>
23
+ <class>identitymindedna/observer</class>
24
+ <method>verifyCreditCardBefore</method>
25
+ <type>singleton</type>
26
+ </identitymind_identitymindedna>
27
+ </observers>
28
+ </sales_quote_payment_import_data_before>
29
+ <sales_order_payment_place_end>
30
+ <observers>
31
+ <identitymind_identitymindedna>
32
+ <class>identitymindedna/observer</class>
33
+ <method>applyActionToOrder</method>
34
+ <type>singleton</type>
35
+ </identitymind_identitymindedna>
36
+ </observers>
37
+ </sales_order_payment_place_end>
38
+ <sales_order_payment_capture>
39
+ <observers>
40
+ <identitymind_identitymindedna>
41
+ <class>identitymindedna/observer</class>
42
+ <method>sendFeedback</method>
43
+ <type>singleton</type>
44
+ </identitymind_identitymindedna>
45
+ </observers>
46
+ </sales_order_payment_capture>
47
+ <sales_order_payment_void>
48
+ <observers>
49
+ <identitymind_identitymindedna>
50
+ <class>identitymindedna/observer</class>
51
+ <method>sendFeedback</method>
52
+ <type>singleton</type>
53
+ </identitymind_identitymindedna>
54
+ </observers>
55
+ </sales_order_payment_void>
56
+ <sales_order_payment_cancel>
57
+ <observers>
58
+ <identitymind_identitymindedna>
59
+ <class>identitymindedna/observer</class>
60
+ <method>sendFeedback</method>
61
+ <type>singleton</type>
62
+ </identitymind_identitymindedna>
63
+ </observers>
64
+ </sales_order_payment_cancel>
65
+ <sales_order_payment_save_after>
66
+ <observers>
67
+ <payment_before_save>
68
+ <class>identitymindedna/observer</class>
69
+ <method>orderPaymentSaveAfter</method>
70
+ </payment_before_save>
71
+ </observers>
72
+ </sales_order_payment_save_after>
73
+ <payepalfix_payment_review_completed_after>
74
+ <observers>
75
+ <payepalfix_payment_review>
76
+ <class>identitymindedna/observer</class>
77
+ <method>paymentReviewCompletedAfter</method>
78
+ </payepalfix_payment_review>
79
+ </observers>
80
+ </payepalfix_payment_review_completed_after>
81
+ <!--
82
+ <sales_place_order_after>
83
+ <observers>
84
+ <payment_before_save>
85
+ <class>identitymindedna/observer</class>
86
+ <method>placeOrderAfter</method>
87
+ </payment_before_save>
88
+ </observers>
89
+ </sales_place_order_after>-->
90
+ </events>
91
+ <resources>
92
+ <identitymindedna_setup>
93
+ <setup>
94
+ <module>IdentityMind_IdentityMindEdna</module>
95
+ </setup>
96
+ </identitymindedna_setup>
97
+ <identitymindedna_write>
98
+ <connection>
99
+ <use>core_write</use>
100
+ </connection>
101
+ </identitymindedna_write>
102
+ <identitymindedna_read>
103
+ <connection>
104
+ <use>default_read</use>
105
+ </connection>
106
+ </identitymindedna_read>
107
+ </resources>
108
+ <blocks>
109
+ <identitymind>
110
+ <class>IdentityMind_IdentityMindEdna_Block</class>
111
+ </identitymind>
112
+ <adminhtml>
113
+ <rewrite>
114
+ <sales_order_payment>IdentityMind_IdentityMindEdna_Block_Sales_Order_Payment</sales_order_payment>
115
+ </rewrite>
116
+ </adminhtml>
117
+ </blocks>
118
+
119
+ </global>
120
+ <frontend>
121
+ <routers>
122
+ <identitymindedna>
123
+ <use>standard</use>
124
+ <args>
125
+ <module>IdentityMind_IdentityMindEdna</module>
126
+ <frontName>identitymindedna</frontName>
127
+ </args>
128
+ </identitymindedna>
129
+ <!--<paypal>
130
+ <args>
131
+ <modules>
132
+ <IdentityMind_IdentityMindEdna before="Mage_Paypal">IdentityMind_IdentityMindEdna_Paypal</IdentityMind_IdentityMindEdna>
133
+ </modules>
134
+ </args>
135
+ </paypal>-->
136
+ </routers>
137
+ <layout>
138
+ <updates>
139
+ <identitymindedna module="IdentityMind_IdentityMindEdna">
140
+ <file>identitymindedna.xml</file>
141
+ </identitymindedna>
142
+ </updates>
143
+ </layout>
144
+ </frontend>
145
+ <default>
146
+ <identitymind>
147
+ <access>
148
+ <text>
149
+ <![CDATA[
150
+ <a href='http://www.identitymind.com/im/form.asp?i=4' onclick='window.open(this.href); return false;'>
151
+ Request Credentials</a>
152
+ <br /><br />
153
+ ]]>
154
+ </text>
155
+ </access>
156
+ </identitymind>
157
+ </default>
158
+ </config>
app/code/local/IdentityMind/IdentityMindEdna/etc/system.xml ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <identitymind translate="label">
5
+ <label>IdentityMind Setup</label>
6
+ <sort_order>100</sort_order>
7
+ </identitymind>
8
+ </tabs>
9
+ <sections>
10
+ <identitymind_edna translate="label">
11
+ <label>IdentityMind eDNA</label>
12
+ <tab>identitymind</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <access translate="access">
20
+ <label>access</label>
21
+ <frontend_type>text</frontend_type>
22
+ <frontend_model>identitymind/system_config_form_fieldset</frontend_model>
23
+ <sort_order>10</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>0</show_in_website>
26
+ <show_in_store>0</show_in_store>
27
+ </access>
28
+ <general translate="label">
29
+ <label>IdentityMind eDNA General</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>100</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <fields>
36
+ <enabled translate="label">
37
+ <label>Enabled</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>10</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </enabled>
45
+ </fields>
46
+ </general>
47
+ <api_credentials translate="label">
48
+ <label>IdentityMind eDNA API Credentials</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>110</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <fields>
55
+ <user translate="label">
56
+ <label>API User</label>
57
+ <frontend_type>text</frontend_type>
58
+ <sort_order>10</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </user>
63
+ <key translate="label">
64
+ <label>API Key</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>20</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
+ </key>
71
+ <endpoint translate="label">
72
+ <label>Endpoint</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>30</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
+ </endpoint>
79
+ </fields>
80
+ </api_credentials>
81
+ <configuration translate="label">
82
+ <label>IdentityMind eDNA Configuration</label>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>120</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ <fields>
89
+ <action_on_error translate="label">
90
+ <label>What to do on error response</label>
91
+ <frontend_type>select</frontend_type>
92
+ <source_model>identitymindedna/source_onerrordropdown</source_model>
93
+ <sort_order>10</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ </action_on_error>
98
+ </fields>
99
+ </configuration>
100
+ </groups>
101
+ </identitymind_edna>
102
+ </sections>
103
+ </config>
app/code/local/IdentityMind/IdentityMindEdna/sql/identitymindedna_setup/install-0.1.0.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Adding new "Manual Review" status to "Hold" state
4
+ *
5
+ * @category IdentityMind
6
+ * @package IdentityMind_IdentityMindEdna
7
+ */
8
+
9
+ $installer = $this;
10
+ /* @var $installer Mage_Core_Model_Resource_Setup */
11
+
12
+ $installer->startSetup();
13
+
14
+ $connection = $installer->getConnection();
15
+ /* @var $connection Varien_Db_Adapter_Interface */
16
+
17
+ try {
18
+ $connection->beginTransaction();
19
+ $connection->query(
20
+ $installer->getTable('sales/order_status'), array(
21
+ 'status' => 'manual_review',
22
+ 'label' => 'Manual Review',
23
+ ));
24
+ $connection->insert($installer->getTable('sales/order_status_state'), array(
25
+ 'status' => 'manual_review',
26
+ 'state' => 'holded',
27
+ 'is_default' => '0',
28
+ ));
29
+ $connection->commit();
30
+ } catch(Exception $e) {
31
+ Mage::logException($e);
32
+ $connection->rollback();
33
+ }
34
+
35
+ $installer->endSetup();
app/code/local/IdentityMind/IdentityMindEdna/sql/identitymindedna_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Adding new "Manual Review" status to "Hold" state
4
+ *
5
+ * @category IdentityMind
6
+ * @package IdentityMind_IdentityMindEdna
7
+ */
8
+
9
+ $installer = $this;
10
+ /* @var $installer Mage_Core_Model_Resource_Setup */
11
+
12
+ $installer->startSetup();
13
+
14
+ $connection = $installer->getConnection();
15
+ /* @var $connection Varien_Db_Adapter_Interface */
16
+
17
+ try {
18
+ $connection->beginTransaction();
19
+ $connection->insert($installer->getTable('sales/order_status'), array(
20
+ 'status' => 'denied',
21
+ 'label' => 'Deny',
22
+ ));
23
+ $connection->insert($installer->getTable('sales/order_status_state'), array(
24
+ 'status' => 'denied',
25
+ 'state' => 'holded',
26
+ 'is_default' => '0',
27
+ ));
28
+
29
+ $connection->insert($installer->getTable('sales/order_status'), array(
30
+ 'status' => 'rejected',
31
+ 'label' => 'Rejected',
32
+ ));
33
+ $connection->insert($installer->getTable('sales/order_status_state'), array(
34
+ 'status' => 'rejected',
35
+ 'state' => 'holded',
36
+ 'is_default' => '0',
37
+ ));
38
+ $connection->commit();
39
+ } catch(Exception $e) {
40
+ $connection->rollback();
41
+ Mage::logException($e);
42
+ }
43
+
44
+ $installer->endSetup();
app/code/local/IdentityMind/IdentityMindEdna/sql/identitymindedna_setup/mysql4-upgrade-0.1.1-0.1.2.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+ $installer->run("UPDATE {$this->getTable('sales/order_status')} SET label = 'Accept' WHERE status = 'processing';");
7
+ $installer->run("UPDATE {$this->getTable('sales/order_status')} SET label = 'Payment Review' WHERE status = 'manual_review';");
8
+ $installer->run("UPDATE {$this->getTable('sales/order_status')} SET label = 'Cancelled' WHERE status = 'denied';");
9
+
10
+ $installer->endSetup();
app/etc/modules/IdentityMind_IdentityMindEdna.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <IdentityMind_IdentityMindEdna>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </IdentityMind_IdentityMindEdna>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>IdentityMind_AntiFraud_Magento</name>
4
+ <version>1.0.24</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>IdentityMind Anti Fraud and Risk Management Platform Integration</summary>
10
+ <description>IdentityMind provides anti fraud and risk management services for online merchants. The integration with Magento enables merchants to protect their store in minutes. It integrates the anti fraud evaluation within the Magento order processing. It also gives merchants access to IdentityMind' s analysis interface and fraud rule configuration.</description>
11
+ <notes>Please contact IdentityMind for updated User Guide and release notes at cs@identitymind.com</notes>
12
+ <authors><author><name>Jose Caldera</name><user>josercaldera</user><email>jose@identitymind.com</email></author></authors>
13
+ <date>2012-10-03</date>
14
+ <time>13:50:56</time>
15
+ <contents><target name="magelocal"><dir name="IdentityMind"><dir name="IdentityMindEdna"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="64b3d7c3cbe4944f1ae29de4759f1ee3"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Fieldset.php" hash="2ef6b0e47bda590da77fd6c2bda9852a"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="cac100ebd0155ba7e279dd0020b17ec2"/></dir><dir name="Model"><dir name="Identitymindapi"><file name="Ednarequest.php" hash="eb999c26b363af8e98bcf4770d159559"/><dir name="Utils"><file name="Creditcardutils.php" hash="29e882777047ec135e12b15924276944"/></dir></dir><file name="Observer.php" hash="e919d3b061e9fefd4817383a11925210"/><dir name="Source"><file name="Onerrordropdown.php" hash="c86e83e4ebfaa9ca8050c289bb220ad5"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="b5e47f0d75425ac321d010aa20932313"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6946e168d3c0ca8b1833fd02a32ee86f"/><file name="config.xml" hash="bad254dab8c927866690538e738b59aa"/><file name="system.xml" hash="64fe11e4054eb3dd3bbc440c2fce0e1c"/></dir><dir name="sql"><dir name="identitymindedna_setup"><file name="install-0.1.0.php" hash="6e412a0e3861bae5db8679847038b2b8"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="29d70e6bcf6c5b5fe827a69b316ed1bb"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="ab8b48c0c4bdd8088c909a407c43f8dc"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="IdentityMind_IdentityMindEdna.xml" hash="15e3f9262e345dff79d5042cff43814a"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>