Mes_Gateway - Version 1.1.4

Version Notes

Fixed an issue during checkout with Digital Products.
Enhanced fraud protection features.

Download this release

Release Info

Developer mesolutions
Extension Mes_Gateway
Version 1.1.4
Comparing to
See all releases


Code changes from version 1.1.3 to 1.1.4

app/code/community/Mes/Gateway/Block/Form.php CHANGED
@@ -2,10 +2,10 @@
2
  /**
3
  * Merchant e-Solutions Magento Plugin.
4
  * v1.1.0 - March 10th, 2011
5
- *
6
  * Copyright (c) 2010 Merchant e-Solutions
7
  * All rights reserved.
8
- *
9
  * Redistribution and use in source and binary forms, with or without
10
  * modification, are permitted provided that the following conditions are met:
11
  * * Redistributions of source code must retain the above copyright
@@ -31,9 +31,14 @@
31
 
32
  class Mes_Gateway_Block_Form extends Mage_Payment_Block_Form_Cc
33
  {
34
- protected function _construct()
35
- {
36
- parent::_construct();
37
- $this->setTemplate('mes/cc.phtml');
38
- }
 
 
 
 
 
39
  }
2
  /**
3
  * Merchant e-Solutions Magento Plugin.
4
  * v1.1.0 - March 10th, 2011
5
+ *
6
  * Copyright (c) 2010 Merchant e-Solutions
7
  * All rights reserved.
8
+ *
9
  * Redistribution and use in source and binary forms, with or without
10
  * modification, are permitted provided that the following conditions are met:
11
  * * Redistributions of source code must retain the above copyright
31
 
32
  class Mes_Gateway_Block_Form extends Mage_Payment_Block_Form_Cc
33
  {
34
+ protected function _construct()
35
+ {
36
+ parent::_construct();
37
+ $this->setTemplate('mes/cc.phtml');
38
+ }
39
+
40
+ protected function _prepareLayout()
41
+ {
42
+ return parent::_prepareLayout();
43
+ }
44
  }
app/code/community/Mes/Gateway/Model/Paymentmodel.php CHANGED
@@ -39,47 +39,61 @@ class Mes_Gateway_Model_Paymentmodel extends Mage_Payment_Model_Method_Cc {
39
  protected $_canVoid = true;
40
  protected $_canUseInternal = true; ## Creation of a transaction from the admin panel
41
  protected $_canUseCheckout = true;
42
- //protected $_formBlockType = 'gateway/form';
43
 
44
  public function __construct() {
45
  }
46
-
47
-
48
  public function authorize(Varien_Object $payment, $amount) {
49
- //$session = Mage::getSingleton('gateway/session');
50
-
51
  if($this->getConfigData('logging'))
52
  Mage::log("[MeS Gateway Module] ".$this->getConfigData('payment_action')." attempt");
53
 
54
  $order = $payment->getOrder();
55
- $billing = $order->getShippingAddress();
56
  $orderid = $order->getIncrementId();
57
- list($avsstreet) = $order->getBillingAddress()->getStreet();
58
- $shipping = $order->getShippingAddress();
59
 
60
- $requestValues = array( "profile_id" => $this->getConfigData('profile_id'),
61
- "profile_key" => $this->getConfigData('profile_key'),
62
- "card_number" => $payment->getCcNumber(),
63
- "card_exp_date" => str_pad($payment->getCcExpMonth(), 2, "0", STR_PAD_LEFT) . substr($payment->getCcExpYear(), 2, 2),
64
- "cvv2" => $payment->getCcCid(),
65
- "transaction_amount" => number_format($amount, 2, '.', ''),
66
- "cardholder_street_address" => urlencode($avsstreet),
67
- "cardholder_zip" => $order->getBillingAddress()->getPostcode(),
68
- "ship_to_zip" => $shipping->getPostcode(),
69
- "transaction_type" => $this->convertTransactionType($this->getConfigData('payment_action')),
70
- "client_reference_number" => urlencode($this->getClientReferenceNumber($order, $orderid, $this->getConfigData('client_reference_number'))),
71
- "tax_amount" => number_format($order->getTaxAmount(), 2, '.', ''),
72
- "currency_code" => $order->getBaseCurrencyCode(),
73
- "invoice_number" => $orderid
74
- );
 
 
 
 
 
 
 
 
75
 
76
- $response = $this->execute($requestValues);
 
 
77
 
 
 
 
 
 
 
 
 
 
 
78
  $payment->setStatus(self::STATUS_APPROVED);
79
  $payment->setTransactionId($response['transaction_id']);
80
-
81
  $payment->setIsTransactionClosed(0);
82
-
83
  return $this;
84
  }
85
 
@@ -254,7 +268,7 @@ class Mes_Gateway_Model_Paymentmodel extends Mage_Payment_Model_Method_Cc {
254
 
255
  private function getClientReferenceNumber($order, $orderid, $crn) {
256
 
257
- $billing = $order->getShippingAddress();
258
 
259
  ## Default
260
  if(empty($crn)) {
39
  protected $_canVoid = true;
40
  protected $_canUseInternal = true; ## Creation of a transaction from the admin panel
41
  protected $_canUseCheckout = true;
42
+ protected $_formBlockType = 'gateway/form';
43
 
44
  public function __construct() {
45
  }
46
+
 
47
  public function authorize(Varien_Object $payment, $amount) {
 
 
48
  if($this->getConfigData('logging'))
49
  Mage::log("[MeS Gateway Module] ".$this->getConfigData('payment_action')." attempt");
50
 
51
  $order = $payment->getOrder();
 
52
  $orderid = $order->getIncrementId();
53
+ $billing = $order->getBillingAddress();
54
+ $shipping = $order->getShippingAddress(); ## May not be set
55
 
56
+ $requestValues = array(
57
+ "profile_id" => $this->getConfigData('profile_id'),
58
+ "profile_key" => $this->getConfigData('profile_key'),
59
+ "card_number" => preg_replace("/[^0-9]/", "", $payment->getCcNumber()),
60
+ "card_exp_date" => str_pad($payment->getCcExpMonth(), 2, "0", STR_PAD_LEFT) . substr($payment->getCcExpYear(), 2, 2),
61
+ "cvv2" => preg_replace("/[^0-9]/", "", $payment->getCcCid()),
62
+ "transaction_amount" => number_format($amount, 2, '.', ''),
63
+ "transaction_type" => $this->convertTransactionType($this->getConfigData('payment_action')),
64
+ "client_reference_number" => urlencode($this->getClientReferenceNumber($order, $orderid, $this->getConfigData('client_reference_number'))),
65
+ "tax_amount" => number_format($order['tax_amount'], 2, '.', ''),
66
+ "invoice_number" => $orderid,
67
+ "currency_code" => $order['order_currency_code'],
68
+ "account_email" => $order['customer_email'],
69
+ "ip_address" => $order['remote_ip'],
70
+ "digital_goods" => $order['is_virtual'] ? "true" : "false",
71
+ "cardholder_street_address" => $billing['street'],
72
+ "cardholder_zip" => $billing['postcode'],
73
+ "cardholder_first_name" => $billing['firstname'],
74
+ "cardholder_last_name" => $billing['lastname'],
75
+ "cardholder_email" => $billing['email'],
76
+ "cardholder_phone" => preg_replace("/[^0-9]/", "", $billing['telephone']),
77
+ "country_code" => $billing['country_id'],
78
+ );
79
 
80
+ ## Cannot depend on device fingerprint to always be available
81
+ if(isset($_POST['payment']['cc_fingerprint']) && $_POST['payment']['cc_fingerprint'] != "")
82
+ $requestValues['device_id'] = $_POST['payment']['cc_fingerprint'];
83
 
84
+ ## Digital download products have no shipping
85
+ if($shipping) {
86
+ $requestValues['ship_to_first_name'] = $shipping['firstname'];
87
+ $requestValues['ship_to_last_name'] = $shipping['lastname'];
88
+ $requestValues['ship_to_address'] = $shipping['street'];
89
+ $requestValues['ship_to_zip'] = $shipping['postcode'];
90
+ $requestValues['dest_country_code'] = $shipping['country_id'];
91
+ }
92
+
93
+ $response = $this->execute($requestValues);
94
  $payment->setStatus(self::STATUS_APPROVED);
95
  $payment->setTransactionId($response['transaction_id']);
 
96
  $payment->setIsTransactionClosed(0);
 
97
  return $this;
98
  }
99
 
268
 
269
  private function getClientReferenceNumber($order, $orderid, $crn) {
270
 
271
+ $billing = $order->getBillingAddress();
272
 
273
  ## Default
274
  if(empty($crn)) {
app/design/frontend/base/default/template/mes/cc.phtml ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Merchant e-Solutions Magento Plugin.
4
+ * v1.1.0 - March 10th, 2011
5
+ *
6
+ * Copyright (c) 2010 Merchant e-Solutions
7
+ * All rights reserved.
8
+ *
9
+ * Redistribution and use in source and binary forms, with or without
10
+ * modification, are permitted provided that the following conditions are met:
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above copyright
14
+ * notice, this list of conditions and the following disclaimer in the
15
+ * documentation and/or other materials provided with the distribution.
16
+ * * Neither the name of Merchant e-Solutions nor the
17
+ * names of its contributors may be used to endorse or promote products
18
+ * derived from this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
24
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+ ?>
32
+ <?php $_code=$this->getMethodCode() ?>
33
+
34
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
35
+ <li>
36
+ <label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
37
+ <div class="input-box">
38
+ <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
39
+ <option value=""><?php echo $this->__('--Please Select--')?></option>
40
+ <?php $_ccType = $this->getInfoData('cc_type') ?>
41
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
42
+ <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
43
+ <?php endforeach ?>
44
+ </select>
45
+ </div>
46
+ </li>
47
+ <li>
48
+ <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
49
+ <div class="input-box">
50
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" />
51
+ </div>
52
+ </li>
53
+ <li id="<?php echo $_code ?>_cc_type_exp_div">
54
+ <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
55
+ <div class="input-box">
56
+ <div class="v-fix">
57
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
58
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
59
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
60
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
61
+ <?php endforeach ?>
62
+ </select>
63
+ </div>
64
+ <div class="v-fix">
65
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
66
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
67
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
68
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
69
+ <?php endforeach ?>
70
+ </select>
71
+ </div>
72
+ </div>
73
+ </li>
74
+ <?php echo $this->getChildHtml() ?>
75
+ <?php if($this->hasVerification()): ?>
76
+ <li id="<?php echo $_code ?>_cc_type_cvv_div">
77
+ <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
78
+ <div class="input-box">
79
+ <div class="v-fix">
80
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" />
81
+ </div>
82
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
83
+ </div>
84
+ </li>
85
+ <?php endif; ?>
86
+
87
+ <?php if ($this->hasSsCardType()): ?>
88
+ <li id="<?php echo $_code ?>_cc_type_ss_div">
89
+ <ul class="inner-form">
90
+ <li class="form-alt"><label for="<?php echo $_code ?>_cc_issue" class="required"><em>*</em><?php echo $this->__('Switch/Solo/Maestro Only') ?></label></li>
91
+ <li>
92
+ <label for="<?php echo $_code ?>_cc_issue"><?php echo $this->__('Issue Number') ?>:</label>
93
+ <span class="input-box">
94
+ <input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-cc-ukss cvv" id="<?php echo $_code ?>_cc_issue" name="payment[cc_ss_issue]" value="" />
95
+ </span>
96
+ </li>
97
+
98
+ <li>
99
+ <label for="<?php echo $_code ?>_start_month"><?php echo $this->__('Start Date') ?>:</label>
100
+ <div class="input-box">
101
+ <div class="v-fix">
102
+ <select id="<?php echo $_code ?>_start_month" name="payment[cc_ss_start_month]" class="validate-cc-ukss month">
103
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
104
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$this->getInfoData('cc_ss_start_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
105
+ <?php endforeach ?>
106
+ </select>
107
+ </div>
108
+ <div class="v-fix">
109
+ <select id="<?php echo $_code ?>_start_year" name="payment[cc_ss_start_year]" class="validate-cc-ukss year">
110
+ <?php foreach ($this->getSsStartYears() as $k=>$v): ?>
111
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$this->getInfoData('cc_ss_start_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
112
+ <?php endforeach ?>
113
+ </select>
114
+ </div>
115
+ </div>
116
+ </li>
117
+ <li class="adv-container">&nbsp;</li>
118
+ </ul>
119
+
120
+ <script type="text/javascript">
121
+ //<![CDATA[
122
+ var SSChecked<?php echo $_code ?> = function() {
123
+ var elm = $('<?php echo $_code ?>_cc_type');
124
+ if (['SS','SM','SO'].indexOf(elm.value) != -1) {
125
+ $('<?php echo $_code ?>_cc_type_ss_div').show();
126
+ } else {
127
+ $('<?php echo $_code ?>_cc_type_ss_div').hide();
128
+ }
129
+ };
130
+
131
+ Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
132
+ SSChecked<?php echo $_code ?>();
133
+ //]]>
134
+ </script>
135
+ </li>
136
+ <?php endif; ?>
137
+
138
+ <li>
139
+ <div id="BCLDGuidDiv" style="border: 0px; width: 0px; height: 0px;"></div>
140
+ <div id="BCLDflashplayer" style="border: 0px; width: 0px; height: 0px;"></div>
141
+ <input type="hidden" id="<?php echo $_code ?>_cc_fingerprint" name="payment[cc_fingerprint]" value="" />
142
+ </li>
143
+
144
+ </ul>
145
+
146
+ <script type="text/javascript" src="https://ds.bluecava.com/V50/LD/BCLD5.js"></script>
147
+ <script type="text/javascript">
148
+ //<![CDATA[
149
+ if(typeof BCLD != 'undefined') // BlueCava may not have loaded.
150
+ BCLD.getSnapshot(fpOkay, fpError);
151
+
152
+ function fpError(errorMessage) {
153
+ // ... bypass fingerprint onerror
154
+ }
155
+
156
+ function fpOkay(fp, warningMessage) {
157
+ var fingerprintData = document.getElementById('<?php echo $_code ?>_cc_fingerprint');
158
+ fingerprintData.value = fp;
159
+ }
160
+ //]]>
161
+ </script>
162
+
163
+
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mes_Gateway</name>
4
- <version>1.1.3</version>
5
  <stability>stable</stability>
6
  <license>BSD</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This plug-in will allow credit card acceptance through the Merchant e-Solutions Payment Gateway.</summary>
10
  <description>For full setup instructions see resources.merchante-solutions.com.</description>
11
- <notes>Fixed admin order entry</notes>
 
12
  <authors><author><name>Merchant e-Solutions</name><user>mesolutions</user><email>mes_certification@merchante-solutions.com</email></author></authors>
13
- <date>2012-07-02</date>
14
- <time>18:25:17</time>
15
- <contents><target name="magecommunity"><dir name="Mes"><dir name="Gateway"><dir name="Block"><file name="Form.php" hash="8f199dd731d62551808e9104800d1aff"/></dir><dir name="Helper"><file name="Data.php" hash="1a95e5fc5e9fdbd269d9252c1cc943f9"/></dir><dir name="Model"><file name="Paymentmodel.php" hash="b8c1a104242555f3117d40ce507e04e0"/><file name="Session.php" hash="f6ce82220c951243ab7c65f6394c9027"/><dir name="Source"><file name="Cardtypes.php" hash="c86be0ea657658fc49fbda3639a663f0"/><file name="Currencies.php" hash="cde6d43fdd21b96c570fc082c2acaadb"/><file name="Transactiontype.php" hash="de93477fe1e51031399ece2a7fcf45ea"/></dir></dir><dir name="etc"><file name="config.xml" hash="e4131a7e85c3b125a82a5f5cf03dca1b"/><file name="system.xml" hash="1435661a49bd9814464a0e4b3a53e966"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mes_Gateway.xml" hash="3c66636dd94beda5bfb984565b52aca1"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mes_Gateway</name>
4
+ <version>1.1.4</version>
5
  <stability>stable</stability>
6
  <license>BSD</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This plug-in will allow credit card acceptance through the Merchant e-Solutions Payment Gateway.</summary>
10
  <description>For full setup instructions see resources.merchante-solutions.com.</description>
11
+ <notes>Fixed an issue during checkout with Digital Products.&#xD;
12
+ Enhanced fraud protection features.</notes>
13
  <authors><author><name>Merchant e-Solutions</name><user>mesolutions</user><email>mes_certification@merchante-solutions.com</email></author></authors>
14
+ <date>2013-02-20</date>
15
+ <time>20:12:16</time>
16
+ <contents><target name="magecommunity"><dir name="Mes"><dir name="Gateway"><dir name="Block"><file name="Form.php" hash="a6e4232208af5b4b890833fbe265e933"/></dir><dir name="Helper"><file name="Data.php" hash="1a95e5fc5e9fdbd269d9252c1cc943f9"/></dir><dir name="Model"><file name="Paymentmodel.php" hash="3c4359860ac09fd5e8c013990ef9d3f9"/><file name="Session.php" hash="f6ce82220c951243ab7c65f6394c9027"/><dir name="Source"><file name="Cardtypes.php" hash="c86be0ea657658fc49fbda3639a663f0"/><file name="Currencies.php" hash="cde6d43fdd21b96c570fc082c2acaadb"/><file name="Transactiontype.php" hash="de93477fe1e51031399ece2a7fcf45ea"/></dir></dir><dir name="etc"><file name="config.xml" hash="e4131a7e85c3b125a82a5f5cf03dca1b"/><file name="system.xml" hash="1435661a49bd9814464a0e4b3a53e966"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mes_Gateway.xml" hash="3c66636dd94beda5bfb984565b52aca1"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="mes"><file name="cc.phtml" hash="e706324167380abcd6c70f506605946b"/></dir></dir></dir></dir></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>