diff --git a/commerce_migs_merchant.module b/commerce_migs_merchant.module
index 309de34..c6a8847 100644
--- a/commerce_migs_merchant.module
+++ b/commerce_migs_merchant.module
@@ -52,6 +52,7 @@ function commerce_migs_merchant_settings_form($settings = NULL) {
   $settings = (array) $settings + array(
     'commerce_migs_mid' => '',
     'commerce_migs_access_code' => '',
+    'commerce_migs_secure_code' => '',
     'commerce_migs_version' => '1',
     'commerce_migs_locale' => 'en',
     'commerce_migs_method_title' => 'Credit card',
@@ -75,11 +76,18 @@ function commerce_migs_merchant_settings_form($settings = NULL) {
     '#default_value' => $settings['commerce_migs_access_code'],
     '#size' => 16,
   );
-
+  $form['commerce_migs_secure_code'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Secure code'),
+    '#description' => t('The secure code is provided to you when you registered
+      your merchant profile.'),
+    '#default_value' => $settings['commerce_migs_secure_code'],
+    '#size' => 16,
+  );
   $form['commerce_migs_version'] = array(
     '#type' => 'textfield',
     '#title' => t('Version number'),
-    '#description' => t('The version number of the API being used. 
+    '#description' => t('The version number of the API being used.
       Currently developed for version 1. Most likely do not change this.'),
     '#default_value' => $settings['commerce_migs_version'],
     '#size' => 5,
@@ -120,19 +128,19 @@ function commerce_migs_merchant_settings_form($settings = NULL) {
 
 /**
  * Payment method callback: checkout form.
- * 
- * @param array $payment_method 
+ *
+ * @param array $payment_method
  *   The payment method.
- * 
- * @param array $pane_values 
+ *
+ * @param array $pane_values
  *   Values from the pane.
- * 
+ *
  * @param array $checkout_pane
  *   The checkout pane.
- * 
- * @param object $order 
+ *
+ * @param object $order
  *   The order.
- * 
+ *
  * @return array
  *   Drupal FAPI form array.
  */
@@ -148,20 +156,20 @@ function commerce_migs_merchant_submit_form($payment_method, $pane_values, $chec
 
 /**
  * Payment method callback: checkout form validation.
- * 
- * @param array $payment_method 
+ *
+ * @param array $payment_method
  *   The payment method.
- * 
- * @param array $pane_form 
+ *
+ * @param array $pane_form
  *   Pane form information. Includes this and other active payment methods.
- * 
- * @param array $pane_values 
+ *
+ * @param array $pane_values
  *   Values from the pane.
- * 
- * @param object $order 
+ *
+ * @param object $order
  *   The order.
- * 
- * @param array $form_parents 
+ *
+ * @param array $form_parents
  *   Parent form info.
  */
 function commerce_migs_merchant_submit_form_validate($payment_method, $pane_form, $pane_values, $order, $form_parents = array()) {
@@ -182,22 +190,22 @@ function commerce_migs_merchant_submit_form_validate($payment_method, $pane_form
 
 /**
  * Payment method callback: checkout form submission.
- * 
- * @param array $payment_method 
+ *
+ * @param array $payment_method
  *   The payment method.
- * 
- * @param array $pane_form 
+ *
+ * @param array $pane_form
  *   Pane form information. Includes this and other active payment methods.
- * 
- * @param array $pane_values 
+ *
+ * @param array $pane_values
  *   Values from the pane.
- * 
- * @param object $order 
+ *
+ * @param object $order
  *   The order.
- * 
+ *
  * @param array $charge
  *   The amount charged (commerce currency array).
- * 
+ *
  * @return bool
  *   FALSE if the transaction fails.
  */
@@ -226,7 +234,9 @@ function commerce_migs_merchant_submit_form_submit($payment_method, $pane_form,
     'vpc_CardSecurityCode' => $pane_values['credit_card']['code'],
     'vpc_CardExp' => substr((string) $pane_values['credit_card']['exp_year'], 2) .
       $pane_values['credit_card']['exp_month'],
+      'vpc_SecureHashType' => 'SHA256',
   );
+  $message_args['vpc_SecureHash'] = commerce_migs_secure_hash($secret, $message_args);
 
   $message = drupal_http_build_query($message_args);
 
@@ -251,7 +261,7 @@ function commerce_migs_merchant_submit_form_submit($payment_method, $pane_form,
           WATCHDOG_ERROR);
       drupal_set_message(
           t(
-              'ERROR. There has been any error with your order. 
+              'ERROR. There has been any error with your order.
                 Please contact the website administrator for more information.'
           ), 'error');
       return;
@@ -306,7 +316,7 @@ function commerce_migs_merchant_submit_form_submit($payment_method, $pane_form,
     // Add one to the Transaction Ref# incase the order needs to be resubmitted.
     $tx_ref++;
 
-    drupal_set_message(t('ERROR. There has been any error with your order. 
+    drupal_set_message(t('ERROR. There has been any error with your order.
       Please contact the website administrator for more information.'), 'error');
 
     $result = array(
@@ -383,6 +393,7 @@ function commerce_migs_merchant_request($payment_method, $message, $order) {
   );
 
   $response = drupal_http_request($url, $options);
+
   if (isset($response->data)) {
     return $response->data;
   }
@@ -481,3 +492,29 @@ function commerce_migs_merchant_form_alter(&$form, &$form_state, $form_id) {
     }
   }
 }
+
+
+ /**
+  * Generate secure hash from url params
+  *
+  *
+  * @param  array $params
+  * @return string
+  */
+ function commerce_migs_secure_hash($secret, array $params)
+ { $secureHash = '';
+  // Sorting params first based on the keys
+     ksort($params);
+   foreach ($params as $key => $value)
+     {
+      // Check if key equals to vpc_SecureHash or vpc_SecureHashType to discard it
+      if(in_array($key, array('vpc_SecureHash', 'vpc_SecureHashType'))) continue;
+       // If key either starts with vpc_ or user_
+         if(substr( $key, 0, 4 ) === "vpc_" || substr($key, 0, 5) === "user_") {
+           $secureHash .= $key."=".$value."&";
+         }
+     }
+     // Remove the last `&` character from string
+    $secureHash = rtrim($secureHash, "&");
+   return strtoupper(hash_hmac('sha256', $secureHash, pack('H*', $secret)));
+}
