Index: paycom.info
===================================================================
--- paycom.info	(revision 356)
+++ paycom.info	(working copy)
@@ -1,5 +1,5 @@
 name = Paycom
-description = This module is intended to help experienced developers/programmers set up your web site to connect to Epoch�s payment gateway using the new FlexPost� Interface.
+description = This module is intended to help experienced developers/programmers set up your web site to connect to Epoch's payment gateway using the new FlexPost Interface.
 package = "Epoch Payment Gateway"
 core = 6.x
 
Index: paycom.module
===================================================================
--- paycom.module	(revision 356)
+++ paycom.module	(working copy)
@@ -15,40 +15,40 @@
   global $user;
   $items = array();
 
-    $items['admin/settings/paycom'] = array(
+  $items['admin/settings/paycom'] = array(
     'title' => 'Paycom',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('paycom_settings'),
     'access arguments' => array('administer paycom'),
     'type' => MENU_NORMAL_ITEM,
     'description' => 'Configure Paycom payment gateway',
-    );
+  );
 
-    $items['paycom/postback'] = array(
+  $items['paycom/postback'] = array(
     'page callback' => 'paycom_postback',
     'type' => MENU_CALLBACK,
-    );
+  );
 
-    $items['paycom/process'] = array(
+  $items['paycom/process'] = array(
     'page callback' => 'paycom_process_transaction',
     'type' => MENU_CALLBACK,
-    );
+  );
 
-    $items['user/'.$user->uid.'/upgrade'] = array(
+  $items['user/'. $user->uid .'/upgrade'] = array(
     'title' => 'Upgrade Membership',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('paycom_form'),
     'access arguments' => array('access upgrade page'),
     'type' => MENU_LOCAL_TASK,
-    );
+  );
 
-    $items['upgrade'] = array(
+  $items['upgrade'] = array(
     'title' => 'Upgrade Membership',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('paycom_form'),
     'access arguments' => array('access upgrade page'),
     'type' => MENU_CALLBACK,
-    );
+  );
 
   return $items;
 }
@@ -56,10 +56,10 @@
 /**
  * Implementation of hook_help().
  */
-function paycom_help($path, $arg ) {
-    switch ($section) {
-        case 'admin/paycom':
-            return t("This module is intended to help experienced you to set up your web site to connect to Epoch payment gateway using the new FlexPost Interface.<br/>You need to have an account with Paycom in order to use this module. Click <a href=\"http://epoch.com\">here</a> for more information.");
+function paycom_help($path, $arg) {
+  switch ($section) {
+    case 'admin/paycom':
+      return t('This module is intended to help experienced you to set up your web site to connect to Epoch payment gateway using the new FlexPost Interface.<br/>You need to have an account with Paycom in order to use this module. Click <a href="http://epoch.com">here</a> for more information.');
   }
 }
 
@@ -69,91 +69,92 @@
 function paycom_settings() {
 
   $form['paycom'] = array(
-  '#type' => 'fieldset',
-  '#title' => t('Paycom settings'),
-  '#description' => t('The customer will have this role as long as their Paycom account is in good standing.'),
+    '#type' => 'fieldset',
+    '#title' => t('Paycom settings'),
+    '#description' => t('The customer will have this role as long as their Paycom account is in good standing.'),
   );
 
   $form['paycom']['paycom_role'] = array(
-  '#type' => 'select',
-  '#title' => t('Role assigned at purchase'),
-  '#default_value' => variable_get('paycom_role', ''),
-  '#options' => user_roles(1),
-  '#description' => t('The customer will have this role as long as their Paycom account is in good standing.'),
+    '#type' => 'select',
+    '#title' => t('Role assigned at purchase'),
+    '#default_value' => variable_get('paycom_role', ''),
+    '#options' => user_roles(1),
+    '#description' => t('The customer will have this role as long as their Paycom account is in good standing.'),
   );
 
   $form['paycom']['paycom_co_code'] = array(
-  '#type' => 'textfield',
-  '#title' => t('Company Code'),
-  '#default_value' => variable_get('paycom_co_code', ''),
-  '#size' => 10,
-  '#maxlength' => 20,
-  '#description' => t("Three character,unmodifiable alphanumeric company code assigned by Epoch"),
-  '#required' => TRUE,
+    '#type' => 'textfield',
+    '#title' => t('Company Code'),
+    '#default_value' => variable_get('paycom_co_code', ''),
+    '#size' => 10,
+    '#maxlength' => 20,
+    '#description' => t('Three character,unmodifiable alphanumeric company code assigned by Epoch'),
+    '#required' => TRUE,
   );
 
   $form['paycom']['paycom_reseller'] = array(
-  '#type' => 'textfield',
-  '#title' => t('Reseller code'),
-  '#default_value' => variable_get('paycom_reseller', 'a'),
-  '#size' => 10,
-  '#maxlength' => 10,
-  '#description' => t("Maximum length 10 characters.  To enable EzTrack logic to determine the affiliate (reseller) code, set the reseller parameter to 'eztrack'."),
+    '#type' => 'textfield',
+    '#title' => t('Reseller code'),
+    '#default_value' => variable_get('paycom_reseller', 'a'),
+    '#size' => 10,
+    '#maxlength' => 10,
+    '#description' => t("Maximum length 10 characters. To enable EzTrack logic to determine the affiliate (reseller) code, set the reseller parameter to 'eztrack'."),
   );
 
   $form['paycom']['paycom_ach'] = array(
-  '#type' => 'checkbox',
-  '#title' => t('ACH'),
-  '#default_value' => variable_get('paycom_ach', ''),
-  '#description' => t('If this field is passed in it will enable online check (ACH) processing.  Online check processing is only valid for US.'),
+    '#type' => 'checkbox',
+    '#title' => t('ACH'),
+    '#default_value' => variable_get('paycom_ach', ''),
+    '#description' => t('If this field is passed in it will enable online check (ACH) processing.  Online check processing is only valid for US.'),
   );
 
   $form['paycom']['paycom_processing_url'] = array(
-  '#type' => 'textfield',
-  '#title' => t('Paycom processing URL'),
-  '#default_value' => variable_get('paycom_processing_url', 'https://wnu.com/secure/fpost.cgi'),
-  '#size' => 70,
-  '#maxlength' => 180,
-  '#description' => t('URL of the secure payment processing page.'),
+    '#type' => 'textfield',
+    '#title' => t('Paycom processing URL'),
+    '#default_value' => variable_get('paycom_processing_url', 'https://wnu.com/secure/fpost.cgi'),
+    '#size' => 70,
+    '#maxlength' => 180,
+    '#description' => t('URL of the secure payment processing page.'),
   );
 
   $form['paycom']['paycom_handle_response'] = array(
-  '#type' => 'checkbox',
-  '#title' => t('Handle Response'),
-  '#default_value' => variable_get('paycom_handle_response', ''),
-  '#description' => t('This field will keep the customer on the FlexPost response page if the transaction is approved.'),
+    '#type' => 'checkbox',
+    '#title' => t('Handle Response'),
+    '#default_value' => variable_get('paycom_handle_response', ''),
+    '#description' => t('This field will keep the customer on the FlexPost response page if the transaction is approved.'),
   );
 
   $form['paycom']['paycom_response_post'] = array(
-  '#type' => 'checkbox',
-  '#title' => t('Response Post'),
-  '#default_value' => variable_get('paycom_response_post', ''),
-  '#description' => t('If this field is passed in it will enable sending a data post back to the client.'),
+    '#type' => 'checkbox',
+    '#title' => t('Response Post'),
+    '#default_value' => variable_get('paycom_response_post', ''),
+    '#description' => t('If this field is passed in it will enable sending a data post back to the client.'),
   );
 
   $form['product'] = array(
-  '#type' => 'fieldset',
-  '#title' => t('Product settings'),
-  '#description' => t('Product id and details of the product.'),
+    '#type' => 'fieldset',
+    '#title' => t('Product settings'),
+    '#description' => t('Product id and details of the product.'),
   );
   $form['product']['product_packages'] = array(
-  '#type' => 'textfield',
-  '#title' => t('Product Ids ,Price and Duration'),
-  '#default_value' => variable_get('product_packages', ''),
-  '#size' => 100,
-  '#maxlength' => 180,
-  '#description' => t("Please enter product id,Price and the duration for a product, each set should separatd by comma.<br/> Eg: if <b>sfheu32m1ciBYrJ</b> and <b>24$</b> for <b>30</b> days you should enter <b>sfheu32m1ciBYrJ:24:30</b> (each separated by \":\")  ."),
+    '#type' => 'textfield',
+    '#title' => t('Product Ids ,Price and Duration'),
+    '#default_value' => variable_get('product_packages', ''),
+    '#size' => 100,
+    '#maxlength' => 180,
+    '#description' => t('Please enter product id,Price and the duration for a product, each set should separatd by comma.<br/> Eg: if <b>sfheu32m1ciBYrJ</b> and <b>24$</b> for <b>30</b> days you should enter <b>sfheu32m1ciBYrJ:24:30</b> (each separated by ":")  .'),
   );
 
   $form['message'] = array(
-  '#type' => 'fieldset',
-  '#title' => t('Message settings'),
+    '#type' => 'fieldset',
+    '#title' => t('Message settings'),
   );
+
   $form['message']['message_content'] = array(
-  '#type' => 'textarea',
-  '#title' => t('Message to member'),
-  '#default_value' => variable_get('message_content', ''),
-  '#description' => t("Please enter message that should be displayed at the upgrade page."),
+    '#type' => 'textarea',
+    '#title' => t('Message to member'),
+    '#default_value' => variable_get('message_content', ''),
+    '#description' => t('Please enter message that should be displayed at the upgrade page.'),
   );
   return system_settings_form($form);
 }
@@ -165,152 +166,140 @@
   return array('administer paycom', 'access upgrade page');
 }
 
-
-function paycom_form_bkp() {
-  global $user;
-
-
-
-
-
-  //return $output;
-}
-
-
 /**
  * Implementation of hook_form().
  */
 function paycom_form() {
   global $user;
-  //print_r($user);
+
   $form['#action'] = variable_get('paycom_processing_url', '');
+
   //user details ----------------------------
   $form['user'] = array(
-  '#type' => 'fieldset',
-  '#title' => t('User Details'),
-  '#description' => t('Check your register informations.'),
+    '#type' => 'fieldset',
+    '#title' => t('User Details'),
+    '#description' => t('Check your register informations.'),
   );
   $form['user']['name'] = array(
-  '#value' => t("<b>User Name</b> : $user->name"),
+    '#value' => t("<b>User Name</b> : $user->name"),
   );
   $form['user']['email'] = array(
-  '#value' => t("<br/><b>Email</b> : $user->mail"),
+    '#value' => t("<br/><b>Email</b> : $user->mail"),
   );
   $accounts = $user->roles;
-  //$sf=',';
+
   foreach ($accounts as $value) {
     $account .= "$value,";
-    //$sf = ",";
   }
   $form['user']['account'] = array(
-  '#value' => t("<br/><b>Account Type</b> : $account"),
+    '#value' => t("<br/><b>Account Type</b> : $account"),
   );
-  $status = ($user->status == 1)? "Active":"Not Active";
+  $status = ($user->status == 1) ? 'Active' : 'Not Active';
   $form['user']['type'] = array(
-  '#value' => t("<br/><b>Status</b> : $status"),
+    '#value' => t("<br/><b>Status</b> : $status"),
   );
 
   //message details ----------------------------
   $form['msg'] = array(
-  '#type' => 'fieldset',
-  '#title' => t('Message to Member'),
+    '#type' => 'fieldset',
+    '#title' => t('Message to Member'),
   );
   $form['msg']['name'] = array(
-  '#value' => variable_get('message_content', ''),
+    '#value' => variable_get('message_content', ''),
   );
   //hidden fields	------------------------------
   $form['co_code'] = array(
-  '#type' => 'hidden',
-  '#value' => urlencode(variable_get('paycom_co_code', '')),
+    '#type' => 'hidden',
+    '#value' => urlencode(variable_get('paycom_co_code', '')),
   );
 
   $form['product_id'] = array(
-  '#type' => 'hidden',
-  '#value' => urlencode($pid),
+    '#type' => 'hidden',
+    '#value' => urlencode($pid),
   );
 
   $form['reseller'] = array(
-  '#type' => 'hidden',
-  '#value' => urlencode(variable_get('paycom_reseller', 'a')),
+    '#type' => 'hidden',
+    '#value' => urlencode(variable_get('paycom_reseller', 'a')),
   );
 
   $form['email'] = array(
-  '#type' => 'hidden',
-  '#value' => $user->mail,
+    '#type' => 'hidden',
+    '#value' => $user->mail,
   );
 
   $form['username'] = array(
-  '#type' => 'hidden',
-  '#value' => $user->name,
+    '#type' => 'hidden',
+    '#value' => $user->name,
   );
 
   $form['no_userpass'] = array(
-  '#type' => 'hidden',
-  '#value' => TRUE,
+    '#type' => 'hidden',
+    '#value' => TRUE,
   );
 
   if (variable_get('paycom_ach', 'false')) {
     $form['ach_form'] = array(
-    '#type' => 'hidden',
-    '#value' => variable_get('paycom_ach', ''),
+      '#type' => 'hidden',
+      '#value' => variable_get('paycom_ach', ''),
     );
   }
 
   if (variable_get('paycom_handle_response', 'false')) {
     $form['handle_response'] = array(
-    '#type' => 'hidden',
-    '#value' => variable_get('paycom_handle_response', ''),
+      '#type' => 'hidden',
+      '#value' => variable_get('paycom_handle_response', ''),
     );
   }
 
   if (variable_get('paycom_response_post', 'false')) {
     $form['response_post'] = array(
-    '#type' => 'hidden',
-    '#value' => variable_get('paycom_response_post', ''),
+      '#type' => 'hidden',
+      '#value' => variable_get('paycom_response_post', ''),
     );
   }
   //payment products--------------------------------------
   $form['product'] = array(
-  '#type' => 'fieldset',
-  '#title' => t('Pricing Options'),
-  '#description' => t('IMPORTANT: After your signup is completed, please wait minimum 1 minute before trying to log in with your new password. The system needs this time to update all files.'),
+    '#type' => 'fieldset',
+    '#title' => t('Pricing Options'),
+    '#description' => t('IMPORTANT: After your signup is completed, please wait minimum 1 minute before trying to log in with your new password. The system needs this time to update all files.'),
   );
   $products = variable_get('product_packages', '');
-  $product_array = explode(",", $products);
+  $product_array = explode(',', $products);
   $product_list = array();
 
-  for ($i=0;$i<sizeof($product_array);$i++) {
+  for ($i=0; $i<sizeof($product_array); $i++) {
     $product_buff = explode(":", $product_array[$i]);
-    if ($product_buff[2]==30) {
-        $moths =1;
+    if ($product_buff[2] == 30) {
+      $moths =1;
     }
-    else if ($product_buff[2]==60) {
-        $moths =2;
+    elseif ($product_buff[2] == 60) {
+      $moths =2;
     }
-    else if ($product_buff[2]==90) {
-        $moths =3;
+    elseif ($product_buff[2] == 90) {
+      $moths =3;
     }
     $product_list[$product_buff[0]] = "Recurring: $$product_buff[1] for every $moths month(s)";
   }
-  //print_r($product_list);
+
   $form['product']['pi_code'] = array(
-  '#type' => 'select',
-  '#title' => t('Pricing options'),
-  '#options' => $product_list,
-  '#description' => t('Select a payment package to be a member and get access to all material.'),
+    '#type' => 'select',
+    '#title' => t('Pricing options'),
+    '#options' => $product_list,
+    '#description' => t('Select a payment package to be a member and get access to all material.'),
   );
 
 
   $form['submit'] = array(
-  '#type' => 'submit',
-  '#value' => t('Secure Signup by credit card'),
+    '#type' => 'submit',
+    '#value' => t('Secure Signup by credit card'),
   );
 
   return $form;
 }
 
 /**
- * handle the paycompost back call().
+ * Handle the paycompost back call().
  */
 function paycom_postback() {
   /*
@@ -332,45 +321,44 @@
   $product_id = $_POST['pi_code'];
   $new_ans = $member_id_split[0];
   $new_ans_buffer = str_split($new_ans);// split all elements
-  if ($new_ans_buffer[0] == "Y") {
+  if ($new_ans_buffer[0] == 'Y') {
     if ($username = $_POST['username']) {
-        // change the days by the product id
-        $days =0;
-        $products = variable_get('product_packages', '');
-        $product_array = explode(",", $products);
-        $product_list = array();
-        for ($i=0;$i<sizeof($product_array);$i++) {
-            $product_buff = explode(":", $product_array[$i]);
-            $product_list[$product_buff[0]] = "$product_buff[2]";
-        }
-        $days = $product_list[$product_id];
-        $rid = variable_get('paycom_role', '');
+      // change the days by the product id
+      $days = 0;
+      $products = variable_get('product_packages', '');
+      $product_array = explode(",", $products);
+      $product_list = array();
+      for ($i=0; $i<sizeof($product_array); $i++) {
+        $product_buff = explode(":", $product_array[$i]);
+        $product_list[$product_buff[0]] = "$product_buff[2]";
+      }
+      $days = $product_list[$product_id];
+      $rid = variable_get('paycom_role', '');
 
-        if ($member = db_fetch_object(db_query("SELECT * FROM {users} WHERE name = '%s'", $username))) {
-            $values = array('userid' => $member->uid, 'count' => $days, 'unit' => 'D');
-            db_query('INSERT INTO {paycom} (uid, product_id) VALUES (%d, %d )', $member->uid, $product_id);
-            //_upgrade_membership_to_premium($values,0);				// Add the entry to the users_roles table
-            db_query("DELETE FROM {users_roles} WHERE uid = %d and rid=%d", $data['userid'], $role_id);
-            // Add the entry to the users_roles table
-            if (!db_fetch_object(db_query("SELECT * FROM {users_roles} WHERE uid = %d AND rid=%d", $data['userid'], $role_id))) {
-                if (db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $data['userid'], $role_id)) {
-                    watchdog('Upgrade Member', 'Upgraded user(%user) to an VIP Member.', array('%user' => l($data['userid'], "user/".$data['userid'])));
-                }
-            }
-            watchdog('paycom', 'Upgraded %user to an Upgraded Membership as the result of a successful Paycom Transaction', array('%user' => l($member->name, "user/".$member->uid)));
-            //drupal_set_message("Script was not able to update any records as the email", 'error');
+      if ($member = db_fetch_object(db_query("SELECT * FROM {users} WHERE name = '%s'", $username))) {
+        $values = array('userid' => $member->uid, 'count' => $days, 'unit' => 'D');
+        db_query('INSERT INTO {paycom} (uid, product_id) VALUES (%d, %d )', $member->uid, $product_id);
+        //_upgrade_membership_to_premium($values,0);				// Add the entry to the users_roles table
+        db_query('DELETE FROM {users_roles} WHERE uid = %d and rid = %d', $data['userid'], $role_id);
+        // Add the entry to the users_roles table
+        if (!db_fetch_object(db_query('SELECT * FROM {users_roles} WHERE uid = %d AND rid = %d', $data['userid'], $role_id))) {
+          if (db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $data['userid'], $role_id)) {
+            watchdog('Upgrade Member', 'Upgraded user(%user) to an VIP Member.', array('%user' => l($data['userid'], "user/" . $data['userid'])));
+          }
         }
-        else {
-            watchdog('paycom', 'Script was not able to update any records as the username, %name, was not found in the database.', array('%name' => $username), WATCHDOG_ERROR);
-            //drupal_set_message("Upgraded Membership was success as the result of a successful Paycom Transaction", 'error');
-        }
-
+        watchdog('paycom', 'Upgraded %user to an Upgraded Membership as the result of a successful Paycom Transaction', array('%user' => l($member->name, "user/" . $member->uid)));
+        //drupal_set_message("Script was not able to update any records as the email", 'error');
       }
-      //watchdog('paycom', t('Script was not able to update any records as the email, %email, was not found in the URL.', array('%email' => $email)), WATCHDOG_ERROR);
-      //drupal_set_message("Script was not able to update any records as the email", 'error');
+      else {
+        watchdog('paycom', 'Script was not able to update any records as the username, %name, was not found in the database.', array('%name' => $username), WATCHDOG_ERROR);
+        //drupal_set_message("Upgraded Membership was success as the result of a successful Paycom Transaction", 'error');
+      }
 
+    }
+    //watchdog('paycom', t('Script was not able to update any records as the email, %email, was not found in the URL.', array('%email' => $email)), WATCHDOG_ERROR);
+    //drupal_set_message("Script was not able to update any records as the email", 'error');
   }
-  else if ($new_ans_buffer[0] == "N") {
+  elseif ($new_ans_buffer[0] == 'N') {
     // to show error messages
     $error_code = substr($new_ans, 1);
     $error_msg = _show_paycom_errors($error_code);
@@ -385,105 +373,105 @@
   */
   //$output .= "";
   //print theme('page', $output);
-
 }
+
 // if the transaction is denied show the error message
 function _show_paycom_errors($errcode) {
   $errcode = trim($errcode);
   switch ($errcode) {
     case 'MYVSNOTACCEPTED':
-    $msg = 'VISA not accepted : Epoch';
-    break;
+      $msg = 'VISA not accepted : Epoch';
+      break;
     case 'DECLINEDCVV2':
-    $msg = 'Invalid CVV2:Bank';
-    break;
+      $msg = 'Invalid CVV2:Bank';
+      break;
     case 'CALLCENTER':
-    $msg = 'Bank Denial';
-    break;
+      $msg = 'Bank Denial';
+      break;
     case 'DECLINED':
-    $msg = 'Bank Denial';
-    break;
+      $msg = 'Bank Denial';
+      break;
     case 'DECLINEDINSFUNDS':
-    $msg = 'Bank Denial';
-    break;
+      $msg = 'Bank Denial';
+      break;
     case 'EXPIRED':
-    $msg = 'Bank Denial';
-    break;
+      $msg = 'Bank Denial';
+      break;
     case 'INVPIN':
-    $msg = 'Bank Denial';
-    break;
+      $msg = 'Bank Denial';
+      break;
     case 'MYINVSTARTDATE':
-    $msg = 'Invalid start date:Bank';
-    break;
+      $msg = 'Invalid start date:Bank';
+      break;
     case 'MYAMNOTACCEPTED':
-    $msg = 'AMEX not accepted:Epoth';
-    break;
+      $msg = 'AMEX not accepted:Epoth';
+      break;
     case 'MYCNOTFND':
-    $msg = 'Country not found:Epoth';
-    break;
+      $msg = 'Country not found:Epoth';
+      break;
     case 'MYSYSERR':
-    $msg = 'System error; need to resubmit:Epoth';
-    break;
+      $msg = 'System error; need to resubmit:Epoth';
+      break;
     case 'MYSWNOTACCEPTED':
-    $msg = 'Maestro/Switch/Solo notaccepted:Epoth';
-    break;
+      $msg = 'Maestro/Switch/Solo notaccepted:Epoth';
+      break;
     case 'MYMCNOTACCEPTED':
-    $msg = 'MC not accepted';
-    break;
+      $msg = 'MC not accepted';
+      break;
     case 'MYINVCARDNUM':
-    $msg = 'Invalid card number';
-    break;
+      $msg = 'Invalid card number';
+      break;
     case 'MYINVISSUENUM':
-    $msg = 'Invalid issue number';
-    break;
+      $msg = 'Invalid issue number';
+      break;
     case 'MYINVDATE':
-    $msg = 'Invalid start date';
-    break;
+      $msg = 'Invalid start date';
+      break;
     case 'MYMISSINGDATA':
-    $msg = 'Missing info';
-    break;
+      $msg = 'Missing info';
+      break;
     case 'MYDNVEL':
-    $msg = 'Too many denial attempts';
-    break;
+      $msg = 'Too many denial attempts';
+      break;
     case 'INVDATA':
-    $msg = 'Bank Denial';
-    break;
+      $msg = 'Bank Denial';
+      break;
     case 'MYINVTRANS':
-    $msg = 'Bank Denial';
-    break;
+      $msg = 'Bank Denial';
+      break;
     case 'MYCOMPVEL':
-    $msg = 'Customer has exceeded spending limits set by the company';
-    break;
+      $msg = 'Customer has exceeded spending limits set by the company';
+      break;
     case 'MYDENIED':
-    $msg = '';
-    break;
+      $msg = '';
+      break;
     case 'MYBLOCKEDZIP':
-    $msg = 'Blocked Zip';
-    break;
+      $msg = 'Blocked Zip';
+      break;
     case 'MYCEH':
-    $msg = 'Customer already has a membership to the site.';
-    break;
+      $msg = 'Customer already has a membership to the site.';
+      break;
     case 'MYRETRY':
-    $msg = 'System problems';
-    break;
+      $msg = 'System problems';
+      break;
     case 'MYDUPLICATE':
-    $msg = 'Duplicate membership to the same product.';
-    break;
+      $msg = 'Duplicate membership to the same product.';
+      break;
     case 'MYINVINFO':
-    $msg = 'Invalid info; needs to resubmit';
-    break;
+      $msg = 'Invalid info; needs to resubmit';
+      break;
     case 'MYNEGDB':
-    $msg = 'Customer is in the negative database.';
-    break;
+      $msg = 'Customer is in the negative database.';
+      break;
     case 'MYNOCARDACCEPTED':
-    $msg = 'None of the card types are accepted';
-    break;
+      $msg = 'None of the card types are accepted';
+      break;
     case 'MYVELDUP':
-    $msg = 'Product Velocity exceeded';
-    break;
+      $msg = 'Product Velocity exceeded';
+      break;
     case 'MYDNFRD':
-    $msg = 'Too many denial attempts';
-    break;
+      $msg = 'Too many denial attempts';
+      break;
   }
   return $msg;
 }
@@ -499,40 +487,39 @@
   _paycom_check_cancellations($last_ran);
 
   variable_set('paycom_last_cron', time());
-
 }
 
-
 // process transaction
 function paycom_process_transaction() {
   if ($email = $_POST['email']) {
     $rid = variable_get('paycom_role', '');
     if ($member = db_fetch_object(db_query("SELECT * FROM {users} WHERE email = '%s'", $email))) {
-        // Make sure there is not a duplicate entry in the users_roles table
-        db_query("DELETE FROM {users_roles} WHERE uid = %d AND rid = %d", $member->uid, $rid);
-        // Add the entry to the users_roles table
-        if (db_query("INSERT INTO {users_roles} ('uid', 'rid') VALUES (%d, %d)", $member->uid, $rid)) {
-            watchdog('paycom', 'Upgraded %user to an Upgraded Membership as the result of a successful Paycom Transaction', array('%user' => l($member->name, "user/".$member->uid)));
-        }
+      // Make sure there is not a duplicate entry in the users_roles table
+      db_query('DELETE FROM {users_roles} WHERE uid = %d AND rid = %d', $member->uid, $rid);
+      // Add the entry to the users_roles table
+      if (db_query("INSERT INTO {users_roles} ('uid', 'rid') VALUES (%d, %d)", $member->uid, $rid)) {
+        watchdog('paycom', 'Upgraded %user to an Upgraded Membership as the result of a successful Paycom Transaction', array('%user' => l($member->name, "user/" . $member->uid)));
+      }
     }
     watchdog('paycom', 'Script was not able to update any records as the email, %email, was not found in the database.', array('%email' => $email), WATCHDOG_ERROR);
   }
 }
+
 /**
  * check for the expired accounts.
  */
 function _paycom_check_cancellations($last_ran) {
 
-  $sql = db_query("SELECT * FROM {MemberCancelStats} WHERE mcs_canceldate > %d", $last_ran);
+  $sql = db_query('SELECT * FROM {paycom_MemberCancelStats} WHERE mcs_canceldate > %d', $last_ran);
   while ($result = db_fetch_object($sql)) {
     if ($sql_user = db_fetch_object(db_query("SELECT * FROM {users} WHERE mail = '%s'", $result->mcs_email))) {
-        if (db_query("DELETE FROM {users_roles} WHERE uid = %d AND rid = %d", $sql_user->uid, variable_get('paycom_role', ''))) {
-            // to delete from the paycom table
-            db_query("DELETE FROM {paycom} WHERE uid = %d" , $sql_user->uid);
-            //to delete from the premium users modules
-            db_query("DELETE FROM {premium_user} WHERE uid = %d", $sql_user->uid);
-            watchdog('paycom', '%user lost their Upgraded Membership role due to a Paycom cancellation.', array('%user' => l($sql_user->name, "user/{$sql_user->uid}/edit")));
-        }
+      if (db_query('DELETE FROM {users_roles} WHERE uid = %d AND rid = %d', $sql_user->uid, variable_get('paycom_role', ''))) {
+        // to delete from the paycom table
+        db_query('DELETE FROM {paycom} WHERE uid = %d', $sql_user->uid);
+        // to delete from the premium users modules
+        db_query('DELETE FROM {premium_user} WHERE uid = %d', $sql_user->uid);
+        watchdog('paycom', '%user lost their Upgraded Membership role due to a Paycom cancellation.', array('%user' => l($sql_user->name, "user/{$sql_user->uid}/edit")));
+      }
     }
   }
 }
@@ -540,245 +527,245 @@
 
 function paycom_country_conversion($country) {
   $list = array(
-  "Andorra" => "ad",
-  "United Arab Emirates" => "ae",
-  "Afghanistan"=>"af",
-  "Antigua and Barbuda"=>"ag",
-  "Anguilla"=>"ai",
-  "Albania"=>"al",
-  "Armenia"=>"am",
-  "Netherlands Antilles"=>"an",
-  "Angola"=>"ao",
-  "Antarctica"=>"aq",
-  "Argentina"=>"ar",
-  "American Samoa"=>"as",
-  "Austria"=>"at",
-  "Australia"=>"au",
-  "Aruba"=>"aw",
-  "Aland Islands"=>"ax",
-  "Azerbaijan"=>"az",
-  "Bosnia and Herzegovina"=>"ba",
-  "Barbados"=>"bb",
-  "Bangladesh"=>"bd",
-  "Belgium"=>"be",
-  "Burkina Faso"=>"bf",
-  "Bulgaria"=>"bg",
-  "Bahrain"=>"bh",
-  "Burundi"=>"bi",
-  "Benin"=>"bj",
-  "Bermuda"=>"bm",
-  "Brunei Darussalam"=>"bn",
-  "Bolivia"=>"bo",
-  "Brazil"=>"br",
-  "Bahamas"=>"bs",
-  "Bhutan"=>"bt",
-  "Bouvet Island"=>"bv",
-  "Botswana"=>"bw",
-  "Belarus"=>"by",
-  "Belize"=>"bz",
-  "Canada"=>"ca",
-  "Cocos (Keeling) Islands"=>"cc",
-  "Democratic Republic of the Congo (formerly Zaire)"=>"cd",
-  "Central African Republic"=>"cf",
-  "Congo (Republic of the Congo)"=>"cg",
-  "Switzerland (Confoederatio Helvetica)"=>"ch",
-  "Cote d\&#039;Ivoire (Ivory Coast)"=>"ci",
-  "Cook Islands"=>"ck",
-  "Chile"=>"cl",
-  "Cameroon"=>"cm",
-  "China"=>"cn",
-  "Colombia"=>"co",
-  "Costa Rica"=>"cr",
-  "Serbia and Montenegro"=>"cs",
-  "Cuba"=>"cu",
-  "Cape Verde"=>"cv",
-  "Christmas Island"=>"cx",
-  "Cyprus"=>"cy",
-  "Czech Republic"=>"cz",
-  "Germany (Deutschland)"=>"de",
-  "Djibouti"=>"dj",
-  "Denmark"=>"dk",
-  "Dominica"=>"dm",
-  "Dominican Republic"=>"do",
-  "Algeria"=>"dz",
-  "Ecuador"=>"ec",
-  "Estonia"=>"ee",
-  "Egypt"=>"eg",
-  "Western Sahara (formerly Spanish Sahara)"=>"eh",
-  "Eritrea"=>"er",
-  "Spain (Espana)"=>"es",
-  "Ethiopia"=>"et",
-  "Finland"=>"fi",
-  "Fiji"=>"fj",
-  "Falkland Islands"=>"fk",
-  "Federated States of Micronesia"=>"fm",
-  "Faroe Islands"=>"fo",
-  "France"=>"fr",
-  "Gabon"=>"ga",
-  "Ghana"=>"gd",
-  "Georgia"=>"ge",
-  "French Guiana"=>"gf",
-  "Gibraltar"=>"gi",
-  "Greenland"=>"gl",
-  "Gambia"=>"gm",
-  "Guinea"=>"gn",
-  "Guadeloupe"=>"gp",
-  "Equatorial Guinea"=>"gq",
-  "Greece"=>"gr",
-  "South Georgia and the South Sandwich Islands"=>"gs",
-  "Guatemala"=>"gt",
-  "Guam"=>"gu",
-  "Guinea-Bissau"=>"gw",
-  "Guyana"=>"gy",
-  "Hong Kong"=>"hk",
-  "Heard Island and McDonald Islands"=>"hm",
-  "Honduras"=>"hn",
-  "Croatia (Hrvatska)"=>"hr",
-  "Haiti"=>"ht",
-  "Hungary"=>"hu",
-  "Indonesia"=>"id",
-  "Ireland"=>"ie",
-  "Israel"=>"il",
-  "India"=>"in",
-  "British Indian Ocean Territory (including Diego Garcia)"=>"io",
-  "Iraq"=>"iq",
-  "Iran"=>"ir",
-  "Iceland"=>"is",
-  "Italy"=>"it",
-  "Jamaica"=>"jm",
-  "Jordan"=>"jo",
-  "Japan"=>"jp",
-  "Kenya"=>"ke",
-  "Kyrgyzstan"=>"kg",
-  "Cambodia"=>"kh",
-  "Kiribati"=>"ki",
-  "Comoros"=>"km",
-  "Saint Kitts and Nevis"=>"kn",
-  "North Korea"=>"kp",
-  "South Korea"=>"kr",
-  "Kuwait"=>"kw",
-  "Cayman Islands"=>"ky",
-  "Kazakhstan"=>"kz",
-  "Laos"=>"la",
-  "Lebanon"=>"lb",
-  "Saint Lucia"=>"lc",
-  "Liechtenstein"=>"li",
-  "Sri Lanka"=>"lk",
-  "Liberia"=>"lr",
-  "Lesotho"=>"ls",
-  "Lithuania"=>"lt",
-  "Luxembourg"=>"lu",
-  "Latvia"=>"lv",
-  "Libya"=>"ly",
-  "Morocco"=>"ma",
-  "Monaco"=>"mc",
-  "Moldova"=>"md",
-  "Madagascar"=>"mg",
-  "Marshall Islands"=>"mh",
-  "Former Yugoslav Republic of Macedonia"=>"mk",
-  "Mali"=>"ml",
-  "Myanmar (Burma)"=>"mm",
-  "Mongolia"=>"mn",
-  "Macao (Macau)"=>"mo",
-  "Northern Mariana Islands"=>"mp",
-  "Martinique"=>"mq",
-  "Mauritania"=>"mr",
-  "Montserrat"=>"ms",
-  "Malta"=>"mt",
-  "Mauritius"=>"mu",
-  "Maldives"=>"mv",
-  "Malawi"=>"mw",
-  "Mexico"=>"mx",
-  "Malaysia"=>"my",
-  "Mozambique"=>"mz",
-  "Namibia"=>"na",
-  "New Caledonia"=>"nc",
-  "Niger"=>"ne",
-  "Norfolk Island"=>"nf",
-  "Nigeria"=>"ng",
-  "Nicaragua"=>"ni",
-  "Netherlands"=>"nl",
-  "Norway"=>"no",
-  "Nepal"=>"np",
-  "Nauru"=>"nr",
-  "Niue"=>"nu",
-  "New Zealand"=>"nz",
-  "Oman"=>"om",
-  "Panama"=>"pa",
-  "Peru"=>"pe",
-  "French Polynesia"=>"pf",
-  "Papua New Guinea"=>"pg",
-  "Philippines"=>"ph",
-  "Pakistan"=>"pk",
-  "Poland"=>"pl",
-  "Saint-Pierre and Miquelon"=>"pm",
-  "Pitcairn Islands"=>"pn",
-  "Puerto Rico"=>"pr",
-  "Palestinian Territories (West Bank and Gaza Strip)"=>"ps",
-  "Portugal"=>"pt",
-  "Palau"=>"pw",
-  "Paraguay"=>"py",
-  "Qatar"=>"qa",
-  "Reunion"=>"re",
-  "Romania"=>"ro",
-  "Russia"=>"ru",
-  "Rwanda"=>"rw",
-  "Saudi Arabia"=>"sa",
-  "Solomon Islands"=>"sb",
-  "Seychelles"=>"sc",
-  "Sudan"=>"sd",
-  "Sweden"=>"se",
-  "Singapore"=>"sg",
-  "Saint Helena"=>"sh",
-  "Slovenia"=>"si",
-  "Svalbard and Jan Mayen Islands"=>"sj",
-  "Slovakia"=>"sk",
-  "Sierra Leone"=>"sl",
-  "San Marino"=>"sm",
-  "Senegal"=>"sn",
-  "Somalia"=>"so",
-  "Suriname"=>"sr",
-  "Sao Tome and Principe"=>"st",
-  "El Salvador"=>"sv",
-  "Syria"=>"sy",
-  "Swaziland"=>"sz",
-  "Turks and Caicos Islands"=>"tc",
-  "Chad (Tchad)"=>"td",
-  "French Southern Territories"=>"tf",
-  "Togo"=>"tg",
-  "Thailand"=>"th",
-  "Tajikistan"=>"tj",
-  "Tokelau"=>"tk",
-  "Timor-Leste (East Timor)"=>"tl",
-  "Turkmenistan"=>"tm",
-  "Tunisia"=>"tn",
-  "Tonga"=>"to",
-  "Turkey"=>"tr",
-  "Trinidad and Tobago"=>"tt",
-  "Tuvalu"=>"tv",
-  "Taiwan"=>"tw",
-  "Tanzania"=>"tz",
-  "Ukraine"=>"ua",
-  "Uganda"=>"ug",
-  "United Kingdom"=>"uk",
-  "United States Minor Outlying Islands"=>"um",
-  "United States"=>"us",
-  "Uruguay"=>"uy",
-  "Uzbekistan"=>"uz",
-  "Vatican City"=>"va",
-  "Saint Vincent and the Grenadines"=>"vc",
-  "Venezuela"=>"ve",
-  "British Virgin Islands"=>"vg",
-  "U.S. Virgin Islands"=>"vi",
-  "Vietnam"=>"vn",
-  "Vanuatu"=>"vu",
-  "Wallis and Futuna"=>"wf",
-  "Samoa"=>"ws",
-  "Yemen"=>"ye",
-  "Mayotte"=>"yt",
-  "South Africa"=>"za",
-  "Zambia"=>"zm",
-  "Zimbabwe"=>"zw"
+    'Andorra' => 'ad',
+    'United Arab Emirates' => 'ae',
+    'Afghanistan' => 'af',
+    'Antigua and Barbuda' => 'ag',
+    'Anguilla' => 'ai',
+    'Albania' => 'al',
+    'Armenia' => 'am',
+    'Netherlands Antilles' => 'an',
+    'Angola' => 'ao',
+    'Antarctica' => 'aq',
+    'Argentina' => 'ar',
+    'American Samoa' => 'as',
+    'Austria' => 'at',
+    'Australia' => 'au',
+    'Aruba' => 'aw',
+    'Aland Islands' => 'ax',
+    'Azerbaijan' => 'az',
+    'Bosnia and Herzegovina' => 'ba',
+    'Barbados' => 'bb',
+    'Bangladesh' => 'bd',
+    'Belgium' => 'be',
+    'Burkina Faso' => 'bf',
+    'Bulgaria' => 'bg',
+    'Bahrain' => 'bh',
+    'Burundi' => 'bi',
+    'Benin' => 'bj',
+    'Bermuda' => 'bm',
+    'Brunei Darussalam' => 'bn',
+    'Bolivia' => 'bo',
+    'Brazil' => 'br',
+    'Bahamas' => 'bs',
+    'Bhutan' => 'bt',
+    'Bouvet Island' => 'bv',
+    'Botswana' => 'bw',
+    'Belarus' => 'by',
+    'Belize' => 'bz',
+    'Canada' => 'ca',
+    'Cocos (Keeling) Islands' => 'cc',
+    'Democratic Republic of the Congo (formerly Zaire)' => 'cd',
+    'Central African Republic' => 'cf',
+    'Congo (Republic of the Congo)' => 'cg',
+    'Switzerland (Confoederatio Helvetica)' => 'ch',
+    'Cote d\&#039;Ivoire (Ivory Coast)' => 'ci',
+    'Cook Islands' => 'ck',
+    'Chile' => 'cl',
+    'Cameroon' => 'cm',
+    'China' => 'cn',
+    'Colombia' => 'co',
+    'Costa Rica' => 'cr',
+    'Serbia and Montenegro' => 'cs',
+    'Cuba' => 'cu',
+    'Cape Verde' => 'cv',
+    'Christmas Island' => 'cx',
+    'Cyprus' => 'cy',
+    'Czech Republic' => 'cz',
+    'Germany (Deutschland)' => 'de',
+    'Djibouti' => 'dj',
+    'Denmark' => 'dk',
+    'Dominica' => 'dm',
+    'Dominican Republic' => 'do',
+    'Algeria' => 'dz',
+    'Ecuador' => 'ec',
+    'Estonia' => 'ee',
+    'Egypt' => 'eg',
+    'Western Sahara (formerly Spanish Sahara)' => 'eh',
+    'Eritrea' => 'er',
+    'Spain (Espana)' => 'es',
+    'Ethiopia' => 'et',
+    'Finland' => 'fi',
+    'Fiji' => 'fj',
+    'Falkland Islands' => 'fk',
+    'Federated States of Micronesia' => 'fm',
+    'Faroe Islands' => 'fo',
+    'France' => 'fr',
+    'Gabon' => 'ga',
+    'Ghana' => 'gd',
+    'Georgia' => 'ge',
+    'French Guiana' => 'gf',
+    'Gibraltar' => 'gi',
+    'Greenland' => 'gl',
+    'Gambia' => 'gm',
+    'Guinea' => 'gn',
+    'Guadeloupe' => 'gp',
+    'Equatorial Guinea' => 'gq',
+    'Greece' => 'gr',
+    'South Georgia and the South Sandwich Islands' => 'gs',
+    'Guatemala' => 'gt',
+    'Guam' => 'gu',
+    'Guinea-Bissau' => 'gw',
+    'Guyana' => 'gy',
+    'Hong Kong' => 'hk',
+    'Heard Island and McDonald Islands' => 'hm',
+    'Honduras' => 'hn',
+    'Croatia (Hrvatska)' => 'hr',
+    'Haiti' => 'ht',
+    'Hungary' => 'hu',
+    'Indonesia' => 'id',
+    'Ireland' => 'ie',
+    'Israel' => 'il',
+    'India' => 'in',
+    'British Indian Ocean Territory (including Diego Garcia)' => 'io',
+    'Iraq' => 'iq',
+    'Iran' => 'ir',
+    'Iceland' => 'is',
+    'Italy' => 'it',
+    'Jamaica' => 'jm',
+    'Jordan' => 'jo',
+    'Japan' => 'jp',
+    'Kenya' => 'ke',
+    'Kyrgyzstan' => 'kg',
+    'Cambodia' => 'kh',
+    'Kiribati' => 'ki',
+    'Comoros' => 'km',
+    'Saint Kitts and Nevis' => 'kn',
+    'North Korea' => 'kp',
+    'South Korea' => 'kr',
+    'Kuwait' => 'kw',
+    'Cayman Islands' => 'ky',
+    'Kazakhstan' => 'kz',
+    'Laos' => 'la',
+    'Lebanon' => 'lb',
+    'Saint Lucia' => 'lc',
+    'Liechtenstein' => 'li',
+    'Sri Lanka' => 'lk',
+    'Liberia' => 'lr',
+    'Lesotho' => 'ls',
+    'Lithuania' => 'lt',
+    'Luxembourg' => 'lu',
+    'Latvia' => 'lv',
+    'Libya' => 'ly',
+    'Morocco' => 'ma',
+    'Monaco' => 'mc',
+    'Moldova' => 'md',
+    'Madagascar' => 'mg',
+    'Marshall Islands' => 'mh',
+    'Former Yugoslav Republic of Macedonia' => 'mk',
+    'Mali' => 'ml',
+    'Myanmar (Burma)' => 'mm',
+    'Mongolia' => 'mn',
+    'Macao (Macau)' => 'mo',
+    'Northern Mariana Islands' => 'mp',
+    'Martinique' => 'mq',
+    'Mauritania' => 'mr',
+    'Montserrat' => 'ms',
+    'Malta' => 'mt',
+    'Mauritius' => 'mu',
+    'Maldives' => 'mv',
+    'Malawi' => 'mw',
+    'Mexico' => 'mx',
+    'Malaysia' => 'my',
+    'Mozambique' => 'mz',
+    'Namibia' => 'na',
+    'New Caledonia' => 'nc',
+    'Niger' => 'ne',
+    'Norfolk Island' => 'nf',
+    'Nigeria' => 'ng',
+    'Nicaragua' => 'ni',
+    'Netherlands' => 'nl',
+    'Norway' => 'no',
+    'Nepal' => 'np',
+    'Nauru' => 'nr',
+    'Niue' => 'nu',
+    'New Zealand' => 'nz',
+    'Oman' => 'om',
+    'Panama' => 'pa',
+    'Peru' => 'pe',
+    'French Polynesia' => 'pf',
+    'Papua New Guinea' => 'pg',
+    'Philippines' => 'ph',
+    'Pakistan' => 'pk',
+    'Poland' => 'pl',
+    'Saint-Pierre and Miquelon' => 'pm',
+    'Pitcairn Islands' => 'pn',
+    'Puerto Rico' => 'pr',
+    'Palestinian Territories (West Bank and Gaza Strip)' => 'ps',
+    'Portugal' => 'pt',
+    'Palau' => 'pw',
+    'Paraguay' => 'py',
+    'Qatar' => 'qa',
+    'Reunion' => 're',
+    'Romania' => 'ro',
+    'Russia' => 'ru',
+    'Rwanda' => 'rw',
+    'Saudi Arabia' => 'sa',
+    'Solomon Islands' => 'sb',
+    'Seychelles' => 'sc',
+    'Sudan' => 'sd',
+    'Sweden' => 'se',
+    'Singapore' => 'sg',
+    'Saint Helena' => 'sh',
+    'Slovenia' => 'si',
+    'Svalbard and Jan Mayen Islands' => 'sj',
+    'Slovakia' => 'sk',
+    'Sierra Leone' => 'sl',
+    'San Marino' => 'sm',
+    'Senegal' => 'sn',
+    'Somalia' => 'so',
+    'Suriname' => 'sr',
+    'Sao Tome and Principe' => 'st',
+    'El Salvador' => 'sv',
+    'Syria' => 'sy',
+    'Swaziland' => 'sz',
+    'Turks and Caicos Islands' => 'tc',
+    'Chad (Tchad)' => 'td',
+    'French Southern Territories' => 'tf',
+    'Togo' => 'tg',
+    'Thailand' => 'th',
+    'Tajikistan' => 'tj',
+    'Tokelau' => 'tk',
+    'Timor-Leste (East Timor)' => 'tl',
+    'Turkmenistan' => 'tm',
+    'Tunisia' => 'tn',
+    'Tonga' => 'to',
+    'Turkey' => 'tr',
+    'Trinidad and Tobago' => 'tt',
+    'Tuvalu' => 'tv',
+    'Taiwan' => 'tw',
+    'Tanzania' => 'tz',
+    'Ukraine' => 'ua',
+    'Uganda' => 'ug',
+    'United Kingdom' => 'uk',
+    'United States Minor Outlying Islands' => 'um',
+    'United States' => 'us',
+    'Uruguay' => 'uy',
+    'Uzbekistan' => 'uz',
+    'Vatican City' => 'va',
+    'Saint Vincent and the Grenadines' => 'vc',
+    'Venezuela' => 've',
+    'British Virgin Islands' => 'vg',
+    'U.S. Virgin Islands' => 'vi',
+    'Vietnam' => 'vn',
+    'Vanuatu' => 'vu',
+    'Wallis and Futuna' => 'wf',
+    'Samoa' => 'ws',
+    'Yemen' => 'ye',
+    'Mayotte' => 'yt',
+    'South Africa' => 'za',
+    'Zambia' => 'zm',
+    'Zimbabwe' => 'zw',
   );
 
   return $list[$country];
