diff --git a/README.txt b/README.txt
index 410589a..4fa07db 100644
--- a/README.txt
+++ b/README.txt
@@ -9,9 +9,14 @@ INSTALL
 See the getting started guild on installing drupal modules:
 http://drupal.org/getting-started/install-contrib/modules
 
+Visit admin/store/settings/payment and enable the gateway, click on
+'settings' and then the tab 'SecurePay Gateway'
+
+
 CREDITS
 ~~~~~~~
 Chris Hood - (http://univate.com.au)
+Leigh Morresi - (https://dgtlmoon.com)
 
 LICENSE
 ~~~~~~~
diff --git a/uc_securepayau.info b/uc_securepayau.info
index 62711cf..66b0ac2 100644
--- a/uc_securepayau.info
+++ b/uc_securepayau.info
@@ -3,5 +3,5 @@ description = Process payments using Securepay.com.au XML gateway
 dependencies[] = uc_payment
 dependencies[] = uc_credit
 package = Ubercart - payment
-core = 6.x
-php = 5.0
+core = 7.x
+
diff --git a/uc_securepayau.install b/uc_securepayau.install
index 520b4fb..51d9c85 100644
--- a/uc_securepayau.install
+++ b/uc_securepayau.install
@@ -29,62 +29,3 @@ function uc_securepayau_uninstall() {
   // Delete related variables all at once.
   db_query("DELETE FROM {variable} WHERE name LIKE 'uc_authnet_%%'");
 }
-
-function uc_securepayau_update_1() {
-  // Update variable values to the new names that match the API documentation.
-  variable_set('uc_authnet_api_login_id', variable_get('authnet_aim_login_id', ''));
-  variable_del('authnet_aim_login_id');
-
-  variable_set('uc_authnet_api_transaction_key', variable_get('authnet_aim_transaction_key', ''));
-  variable_del('authnet_aim_transaction_key');
-
-  $mode = variable_get('authnet_aim_transaction_mode', 'live_test');
-  if ($mode == 'production') {
-    $mode = 'live';
-  }
-  elseif ($mode == 'test') {
-    $mode = 'developer_test';
-  }
-  variable_set('uc_authnet_aim_txn_mode', $mode);
-  variable_del('authnet_aim_transaction_mode');
-
-  if (variable_get('authnet_aim_transaction_type', 'capture') == 'capture') {
-    variable_set('uc_authnet_aim_txn_type', 'AUTH_CAPTURE');
-  }
-  else {
-    variable_set('uc_authnet_aim_txn_type', 'AUTH_ONLY');
-  }
-  variable_del('authnet_aim_transaction_type');
-
-  variable_del('authnet_aim_delimiter');
-
-  if (variable_get('authnet_aim_customer_notification', 'FALSE') == 'TRUE') {
-    variable_set('uc_authnet_aim_customer_email', TRUE);
-  }
-  variable_del('authnet_aim_customer_notification');
-
-  variable_del('authnet_aim_merchant_notification');
-
-  return array();
-}
-
-function uc_securepayau_update_2() {
-  // Change the variable used to define the default transaction type.
-  if (variable_get('uc_authnet_aim_txn_type', 'AUTH_CAPTURE') == 'AUTH_CAPTURE') {
-    variable_set('uc_pg_securepayau_cc_txn_type', UC_CREDIT_AUTH_CAPTURE);
-  }
-  else {
-    variable_set('uc_pg_securepayau_cc_txn_type', UC_CREDIT_AUTH_ONLY);
-  }
-
-  variable_del('uc_authnet_aim_txn_type');
-
-  return array();
-}
-
-function uc_securepayau_update_3() {
-  // Update the name of the CIM transaction mode variable.
-  variable_set('uc_authnet_cim_mode', variable_get('uc_authnet_cim_server', 'disabled'));
-  variable_del('uc_authet_cim_server');
-}
-
diff --git a/uc_securepayau.module b/uc_securepayau.module
index fe0fef0..a3833d8 100644
--- a/uc_securepayau.module
+++ b/uc_securepayau.module
@@ -5,6 +5,7 @@
  * Process payments using securepay.com.au
  *
  * Development sponsored by Univate - http://www.univate.com.au
+ * Drupal 7 Development sponsored by DGTLMOON - https://dgtlmoon.com
  */
 
 
@@ -13,45 +14,38 @@
 *********************************************************************/
 
 /**
- * Implementation of hook_payment_gateway().
+ * Implementation of hook_uc_payment_gateway().
  */
-function uc_securepayau_payment_gateway() {
-  $gateways[] = array(
-    'id' => 'securepayau',
-    'title' => t('Securepay.com.au'),
-    'description' => t('Process credit card payments using the credit card gateway at securepay.com.au'),
+function uc_securepayau_uc_payment_gateway() {
+  $gateways['uc_securepayau_gateway'] = array(
+    'title' => t('SecurePay gateway'),
+    'description' => t('Process credit card payments through the SecurePay Gateway.'),
     'settings' => 'uc_securepayau_settings_form',
-    'credit' => 'uc_securepayau_charge',
-    'credit_txn_types' => array(UC_CREDIT_AUTH_CAPTURE, UC_CREDIT_REFERENCE_SET, UC_CREDIT_REFERENCE_TXN, UC_CREDIT_REFERENCE_REMOVE),
+    'credit' => 'uc_payment_method_securepayau_charge',
   );
-
   return $gateways;
 }
 
+
 /**
- * Implements hook_charge()
+ * Callback from hook_uc_payment_gateway::credit
  *
- * Main handler for processing credit card transactions.
+ * @param $op
+ * @param $order
+ * @param null $form
+ * @param null $form_state
+ * @return array result
  */
-function uc_securepayau_charge($order_id, $amount, $data) {
-  // load the order object
+function uc_payment_method_securepayau_charge($order_id, $amount, $data) {
+
   $order = uc_order_load($order_id);
 
-  // Perform the appropriate action based on the transaction type.
-  switch ($data['txn_type']) {
-    // Accommodate all other transaction types.
-    case 'reference_set':
-      break;
-    case 'reference_txn':
-      break;
-    case 'reference_remove':
-      break;
-    case 'auth_capture':
-    default:
-      return _uc_securepayau_charge($order, $amount, $data);
-  }
+  $result = _uc_securepayau_charge($order, $order->order_total, $data);
+
+  return $result;
 }
 
+
 /*********************************************************************
                  DRUPAL CORE HOOKS
 *********************************************************************/
@@ -81,17 +75,12 @@ function uc_securepayau_settings_form() {
     '#title' => t('Mode/Settings'),
     '#description' => t('This allows you to set settings for the securepay account you are accessing.'),
   );
-  $form['settings']['uc_securepayau_currency'] = array(
-    '#type' => 'select',
-    '#title' => 'Currency',
-    '#default_value' => variable_get('uc_securepayau_currency', variable_get('uc_currency_code', 'AUD')),
-    '#options' => array('AUD' => 'AUD', 
-                        'USD' => 'USD'),
-  );
+  
   $account_types = array(
       'live' => t('Live transactions in a live account'),
       'test' => t('Developer test account transactions'),
   );
+
  $form['settings']['uc_securepayau_txn_mode'] = array(
     '#type' => 'select',
     '#title' => t('Live/Test account'),
@@ -145,7 +134,6 @@ function _uc_securepayau_charge($order, $amount, $data) {
           'txnType' => '0',  // 0 = Standard Payment
           'txnSource' => '23',  // 23 = XML
           'amount' => (int)($amount*100), // amount takes a value in cents
-          'currency' => variable_get('uc_securepayau_currency', 'AUD'),
           'purchaseOrderNo' => $order->order_id,
           'CreditCardInfo' => array(
             'cardNumber' => $order->payment_details['cc_number'],
@@ -155,23 +143,29 @@ function _uc_securepayau_charge($order, $amount, $data) {
       ),
     ),
   );
+
+  if(!empty($order->currency)) {
+    $request['Payment']['TxnList count="1"']['Txn ID="1"']['currency'] = $order->currency;
+  }
+  
   if (variable_get('uc_credit_cvv_enabled', FALSE)) {
-    $request['Payment']['TxnList count="1"']['CreditCardInfo']['cvv'] = $order->payment_details['cc_cvv'];
+    $request['Payment']['TxnList count="1"']['Txn ID="1"']['CreditCardInfo']['cvv'] = $order->payment_details['cc_cvv'];
   }
 
   // Request a profile from auth.net.
   $xml = _uc_securepayau_xml_api_wrapper('Payment', _uc_securepayau_array_to_xml($request));
  
   // Parse the response.
-  $response = _uc_securepayau_parse_response(uc_securepayau_xml_api($server, 'payment', $order->order_id, $xml));
+  $trx_response = uc_securepayau_xml_api($server, 'payment', $order->order_id, $xml);
+  $response = _uc_securepayau_parse_response($trx_response);
 
   if ($response['approved'] != 'Yes') {
     // Fail the charge with the reason text in the decline message.
     $result = array(
       'success' => FALSE,
-      'message' => t('Credit card payment declined: @message [@code]', 
-                      array('@message' => $response['responseText'], 
-                            '@code' => $response['responseCode'])),
+      'message' => t('Credit card payment declined: @message [@code]',
+                      array('@message' => $response['statusDescription'] ? $response['statusDescription'] : $response['responseText'],
+                            '@code' => $response['statusCode'] ? $response['statusCode'] : $response['responseCode'])),
       'uid' => $user->uid,
     );
   } 
@@ -183,10 +177,11 @@ function _uc_securepayau_charge($order, $amount, $data) {
       'comment' => $message,
       'message' => $message,
       'data' => array('module' => 'uc_securepayau', 
-                      'txn_type' => $response['RequestType'], 
-                      'action' => $response['actionType'],
-                      'subscription_id' => $response['clientID']),
-      'uid' => $user->uid,
+                      'txn_type' => _uc_securepay_txn_type($response['txnType']),
+                      'txnID' => $response['txnID'],
+                      'settlementDate' => $response['settlementDate']),
+
+      'uid' => $user->uid
     );
 
   }
@@ -213,300 +208,6 @@ function _uc_securepayau_charge($order, $amount, $data) {
 /***********************************************************************/
 
 /**
-* Implementation of hook_recurring_info().
-*/
-function uc_securepayau_recurring_info() {
-  $items['securepayau'] = array(
-    'name' => t('Securepay AU'),
-    'payment method' => 'credit',
-    'module' => 'uc_securepayau',
-    'fee handler' => 'securepayau',
-    'renew callback' => 'uc_securepayau_recurring_renew',
-    'process callback' => 'uc_securepayau_recurring_process',
-    'cancel callback' => 'uc_securepayau_recurring_cancel',
-    'menu' => array(
-      'charge' => UC_RECURRING_MENU_DEFAULT,
-      'edit'   => UC_RECURRING_MENU_DEFAULT,
-      'update' => array(
-        'title' => 'Update Account Details', 
-        'page arguments' => array('uc_securepayau_recurring_user_update_form'),
-        'file' => 'uc_securepayau.pages.inc',
-      ),
-      'cancel' => UC_RECURRING_MENU_DEFAULT,
-    ), // Use the default user operation defined in uc_recurring.
-  );
-  return $items;
-}
-
-/**
- * Implemenation of hook_recurring_renew()
- *
- * Use a triggered reference in securepay to charge to an account.
- */
-function uc_securepayau_recurring_renew($order, $fee) {
-  $server = variable_get('uc_securepayau_txn_mode', 'test');
-  
-  // Help build the request.
-  $request = array(
-    'Periodic' => array(
-      'PeriodicList count="1"' => array(
-        'PeriodicItem ID="1"' => array(
-          'actionType' => 'trigger',
-          'clientID' => $fee->data['subscription_id'], // TODO: need to check this is correct
-          'amount' => (int)($order->order_total*100), // amount takes a value in cents
-        ),
-      ),
-    ),
-  );
-
-  // Request a profile from auth.net.
-  $xml = _uc_securepayau_xml_api_wrapper('Periodic', _uc_securepayau_array_to_xml($request));
-
-  // Parse the response.
-  $response = _uc_securepayau_parse_response(uc_securepayau_xml_api($server, 'periodic', $order->order_id, $xml));
-
-  // TODO: verify payment completed here
-
-  // Error state.
-  if ($response['responseCode'] != '00' && $response['responseCode'] != '08' && $response['responseCode'] != '77') {
-    $result = array(
-      'success' => FALSE,
-      'message' => t('Credit card payment declined: @message [@code]', 
-                      array('@message' => $response['responseText'], 
-                            '@code' => $response['responseCode'])),
-      'uid' => $user->uid,
-    );
-
-    return FALSE;
-  }
-  // Transaction succeeded.
-  else {
-    // Build a message for display and comments in the payments table.
-    $message = t('!amount recurring fee collected for @model. (ID: <a href="!url">!fee</a>)', 
-                  array('!url' => url('admin/store/orders/recurring/view/fee/'. $fee->rfid), 
-                        '!fee' => $fee->rfid, 
-                        '!amount' => uc_currency_format($fee->fee_amount), 
-                        '@model' => $fee->data['subscription_id']));
-    $result = array(
-      'success' => TRUE,
-      'comment' => $message,
-      'message' => $message,
-      'data' => array('module' => 'uc_securepayau', 
-                      'txn_type' => $response['RequestType'], 
-                      'action' => $response['actionType'],
-                      'subscription_id' => $response['clientID']),
-      'uid' => $user->uid,
-    );
-
-    // enter the payment.
-    uc_payment_enter($order->order_id, 'credit', $response['amount']/100, 0, $result['data'], $message);
-
-    uc_order_comment_save($order->order_id, 0, $message);
-
-  }
-
-  // Build an admin order comment.
-  $comment = t('<b>@type</b><br /><b>@status:</b> @message<br />Amount: @amount<br />Credit Card: @cc<br/>Expiry Date: @expiry<br/>Card Type: @cardtype',
-    array('@type' => $response['RequestType'] .' '. $response['actionType'] .' '. $response['clientID'], 
-          '@status' => $result['success'] ? t('ACCEPTED') : t('REJECTED'), 
-          '@message' => $response['responseText'], 
-          '@amount' => uc_currency_format($response['amount']/100),
-          '@cc' => $response['pan'],
-          '@expiry' => $response['expiryDate'],
-          '@cardtype' => $response['cardDescription'],
-         ));
-
-  // Save the comment to the order.
-  uc_order_comment_save($order->order_id, $user->uid, $comment, 'admin');
-
-  return TRUE;
-}
-
-/**
- * Callback for setting up a recurring fee.
- *
- * Create a triggered payment in securepay using an order's data.
- *
- * This is where we will send a message to setup the user CC details in securepay
- *
- * @param $order
- *   The order object containing billing and shipping information.
- * @param $fee
- *   An array of data describing the recurring fee.
- * @return
- *   TRUE or FALSE indicating the success of the request.
- */
-function uc_securepayau_recurring_process($order, &$fee) {
-  $server = variable_get('uc_securepayau_txn_mode', 'test');
-
-  // Get a default SKU if none was supplied.
-  if (empty($fee->model)) {
-    $fee->model = db_result(db_query("SELECT model FROM {uc_products} WHERE nid = %d", $fee->nid));
-  }
-
-  // Add the payment information to the data array based on the payment method.
-  if ($order->payment_method == 'credit') {
-    if (strlen($order->payment_details['cc_exp_month']) < 2) {
-      $order->payment_details['cc_exp_month'] = '0'. $order->payment_details['cc_exp_month'];
-    }
-  }
-
-  // we need a unique subscription_id to store in securepay
-  // using user_id-order_id-<random 5-10 char string>
-  $fee->data['subscription_id'] = $order->uid .'-'. $order->order_id .'-'. _uc_securepayau_rand_text($min = 5, $max = 8);
-
-  // Build the data array for the request.
-  $data = _uc_securepayau_create_account_xml($order, $fee);
-
-  // Build the XML string.
-  $xml = _uc_securepayau_xml_api_wrapper('Periodic', _uc_securepayau_array_to_xml($data));
-  
-  // Send the request off to the server and get the response.
-  // Parse the response into a data array.
-  $response = _uc_securepayau_parse_response(uc_securepayau_xml_api($server, 'periodic', $order->order_id, $xml));
-
-  if ($response['successful'] != 'yes') {
-    uc_order_comment_save($order->order_id, 0, 
-      t('securepay.com.au: Recurring fee setup for @model failed.<br />@error - @text', 
-         array('@model' => $fee->model, 
-               '@error' => $response['responseCode'], 
-               '@text' => $response['responseText'])
-      ), 
-      'admin'
-    );
-    return FALSE;
-  }
-
-  uc_order_comment_save($order->order_id, 0, 
-    t('securepay.com.au: Recurring fee setup for @model.<br />Subscription ID: @subscription_id', 
-       array('@model' => $fee->model, 
-             '@subscription_id' => $response['clientID'])
-    ), 
-    'admin'
-  );
-
-  return TRUE;
-}
-
-/**
- * Updates a subscription; what this actually means is that the detail stored at 
- * securepay are deleted and replaced with values entered by the user
- *
- * @param $subscription_id
- *   The ID of the subscription at securepay.com.au to change
- * @param $updates
- *   An array of data to update using key/value pairs from the XML API 
- * @return
- *   TRUE or FALSE indicating the success of the cancellation.
- */
-function uc_securepayau_recurring_update($order, $fee) {
-  $server = variable_get('uc_securepayau_txn_mode', 'test');
-
-  // TODO: do we care if the delete fails?
-  $delete_data = _uc_securepayau_delete_account_xml($fee->data['subscription_id']);
-  $xml = _uc_securepayau_xml_api_wrapper('Periodic', _uc_securepayau_array_to_xml($delete_data));
-  $response = uc_securepayau_xml_api($server, 'periodic', $order->order_id, $xml);
-
-  // Add the payment information to the data array based on the payment method.
-  if ($order->payment_method == 'credit') {
-    if (strlen($order->payment_details['cc_exp_month']) < 2) {
-      $order->payment_details['cc_exp_month'] = '0'. $order->payment_details['cc_exp_month'];
-    }
-  }
-
-  $create_data = _uc_securepayau_create_account_xml($order, $fee);
-  // Build the XML string.
-  $xml = _uc_securepayau_xml_api_wrapper('Periodic', _uc_securepayau_array_to_xml($create_data));
-
-  // Send the request off to the server and get the response.
-  $response = uc_securepayau_xml_api($server, 'periodic', $order->order_id, $xml);
-
-  // Fail if the response is empty or FALSE.
-  if (!$response) {
-    return FALSE;
-  }
-
-  // Parse the response into a data array.
-  $data = _uc_securepayau_parse_response($response);
-
-  if ($data['successful'] != 'yes') {
-    if (!empty($fee->order_id)) {
-      uc_order_comment_save($fee->order_id, 0, 
-        t('securepay.com.au: Subscription @subscription_id updated failed.<br />@error - @text', 
-           array('@subscription_id' => $fee->data['subscription_id'], 
-                 '@error' => $data['code'], 
-                 '@text' => $data['text'])
-        ), 
-        'admin'
-      );
-    }
-    return FALSE;
-  }
-
-  uc_order_comment_save($fee->order_id, 0, 
-    t('securepay.com.au: Subscription @subscription_id updated.<br/>Credit Card: @cc<br/>Expiry Date: @expiry', 
-       array('@subscription_id' => $fee->data['subscription_id'], 
-             '@cc' => $data['pan'], 
-             '@expiry' => $data['expiryDate'])
-    ),
-    'admin'
-  );
-
-  return TRUE;
-}
-
-/**
- * Cancels an recurring subscription.
- *
- * @param $order_id
- *   The ID of the order the recurring fee was attached to.
- * @param $fee
- *   The data array for the recurring fee being canceled.
- * @return
- *   TRUE or FALSE indicating the success of the cancellation.
- */
-function uc_securepayau_recurring_cancel($fee) {
-  $server = variable_get('uc_securepayau_txn_mode', 'test');
-
-  // Build the data array for the request.
-  $data = _uc_securepayau_delete_account_xml($fee->data['subscription_id']);
-
-  // Build the XML string.
-  $xml = _uc_securepayau_xml_api_wrapper('Periodic', _uc_securepayau_array_to_xml($data));
-
-  // Send the request off to the server and get the response.
-  $response = uc_securepayau_xml_api($server, 'periodic', $fee->order_id, $xml);
-
-  // Fail if the response is empty or FALSE.
-  if (!$response) {
-    return FALSE;
-  }
-
-  // Parse the response into a data array.
-  $data = _uc_securepayau_parse_response($response);
-
-  if ($data['successful'] != 'yes') {
-    if (!empty($fee->order_id)) {
-      uc_order_comment_save($fee->order_id, 0, 
-        t('securepay.com.au: Subscription @subscription_id cancellation failed.<br />
-           @error - @text', 
-           array('@subscription_id' => $subscription_id, 
-                 '@error' => $data['code'], 
-                 '@text' => $data['text'])
-         ), 'admin');
-    }
-    return FALSE;
-  }
-
-  uc_order_comment_save($fee->order_id, 0, 
-    t('securepay.com.au: Subscription @subscription_id cancelled.', 
-       array('@subscription_id' => $subscription_id)
-     ), 'admin');
-
-  return TRUE;
-}
-
-/**
  * Sends an XML API Request to securepay.com.au.
  *
  * @param $server
@@ -533,7 +234,7 @@ function uc_securepayau_xml_api($server, $requesttype, $order_id, $xml) {
   curl_setopt($ch, CURLOPT_HEADER, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
   curl_setopt($ch, CURLOPT_POST, 1);
-  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
   $response = curl_exec($ch);
 
   // Log any errors to the watchdog.
@@ -543,10 +244,10 @@ function uc_securepayau_xml_api($server, $requesttype, $order_id, $xml) {
   }
   curl_close($ch);
 
-  // for debugging purposes log request/reponse strings to order log (just in case we need to check something later)
+  // for debugging purposes log request/response strings to order log (just in case we need to check something later)
   // but we need to cleans the request xml of any sensitive data
-  $xml = ereg_replace("(<cardNumber>)[0-9]*(</cardNumber>)", "\\1****\\2", $xml);
-  $xml = ereg_replace("(<cvv>)[0-9]*(</cvv>)", "\\1***\\2", $xml);
+  $xml = preg_replace("/(<cardNumber>)[0-9]{1,}/i", "\\1****\\2", $xml);
+  $xml = preg_replace("/(<cvv>)[0-9]{1,}/i", "\\1***\\2", $xml);
   $log[] = 'Request: '. htmlspecialchars($xml);
   $log[] = 'Response:'. htmlspecialchars($response);
   if (variable_get('uc_order_logging', TRUE)) {
@@ -555,63 +256,6 @@ function uc_securepayau_xml_api($server, $requesttype, $order_id, $xml) {
   return $response;
 }
 
-/**
- * Creates the structured message with the information needed to created a stored tiggered account
- *
- * @param $order
- *   the order object
- * @param $fee
- *   the recurrning fee object
- * @return
- *   the array structure of the message to send to securepay 
- */
-function _uc_securepayau_create_account_xml($order, $fee) {
-  // Build the data array for the request.
-  $data = array(
-    'Periodic' => array(
-      'PeriodicList count="1"' => array(
-        'PeriodicItem ID="1"' => array(
-          'actionType' => 'add', 
-          'clientID' => $fee->data['subscription_id'],
-          'currency' => variable_get('uc_securepayau_currency', 'AUD'),
-          'CreditCardInfo' => array(
-            'cardNumber' => $order->payment_details['cc_number'],
-            'expiryDate' => $order->payment_details['cc_exp_month'] .'/'. substr($order->payment_details['cc_exp_year'], -2),
-            'recurringFlag' => 'no',
-          ),
-          'amount' => (int)($fee->fee_amount*100), // amount takes a value in cents
-          'periodicType' => '4',
-        ),
-      ),
-    ),
-  );
-  if (variable_get('uc_credit_cvv_enabled', FALSE)) {
-    $data['Periodic']['PeriodicList count="1"']['CreditCardInfo']['cvv'] = $order->payment_details['cc_cvv'];
-  }
-  return $data;
-}
-
-/**
- * Removed an account from securepays tiggered accounts
- *
- * @param $subscription_id
- *   the id of the account to remove
- * @return
- *   the array structure of the message to send to securepay 
- */
-function _uc_securepayau_delete_account_xml($subscription_id) {
-  $data = array(
-    'Periodic' => array(
-      'PeriodicList count="1"' => array(
-        'PeriodicItem ID="1"' => array(
-          'actionType' => 'delete',
-          'clientID' => $subscription_id,
-        ),
-      ),
-    ),
-  );
-  return $data;
-}
 
 /**
  * Wraps XML API request child elements in the request element and includes the
@@ -709,60 +353,60 @@ function _uc_securepayau_parse_response(&$content) {
 
   $data = array(
     // message details
-    'messageID'        => _uc_securepayau_substr_between($content, 'messageID'),
-    'messageTimestamp' => _uc_securepayau_substr_between($content, 'messageTimestamp'),
-    'apiVersion'       => _uc_securepayau_substr_between($content, 'apiVersion'),
+    'messageID'        => _uc_securepayau_xml_value($content, 'messageID'),
+    'messageTimestamp' => _uc_securepayau_xml_value($content, 'messageTimestamp'),
+    'apiVersion'       => _uc_securepayau_xml_value($content, 'apiVersion'),
 
     // request type and merchant details (should be the same as sent)
-    'RequestType'      => _uc_securepayau_substr_between($content, 'RequestType'),
-    'merchantID'       => _uc_securepayau_substr_between($content, 'merchantID'),
+    'RequestType'      => _uc_securepayau_xml_value($content, 'RequestType'),
+    'merchantID'       => _uc_securepayau_xml_value($content, 'merchantID'),
 
     // status Code
-    'statusCode'       => _uc_securepayau_substr_between($content, 'statusCode'),
-    'satusDescription' => _uc_securepayau_substr_between($content, 'statusDescription'),
+    'statusCode'       => _uc_securepayau_xml_value($content, 'statusCode'),
+    'statusDescription'=> _uc_securepayau_xml_value($content, 'statusDescription'),
 
     // standard payment details
-    'txnType'          => _uc_securepayau_substr_between($content, 'txnType'),
-    'txnSource'        => _uc_securepayau_substr_between($content, 'txnSource'),
-    'currency'         => _uc_securepayau_substr_between($content, 'currency'),
-    'amount'           => _uc_securepayau_substr_between($content, 'amount'),
-    'purchaseOrderNo'  => _uc_securepayau_substr_between($content, 'purchaseOrderNo'),
-    'approved'         => _uc_securepayau_substr_between($content, 'approved'),
-    'responseCode'     => _uc_securepayau_substr_between($content, 'responseCode'),
-    'responseText'     => _uc_securepayau_substr_between($content, 'responsetext'),
-    'successful'       => _uc_securepayau_substr_between($content, 'successful'),
-    'settlementDate'   => _uc_securepayau_substr_between($content, 'settlementDate'),
-    'txnID'            => _uc_securepayau_substr_between($content, 'txnID'),
+    'txnType'          => _uc_securepayau_xml_value($content, 'txnType'),
+    'settlementDate'   => _uc_securepayau_xml_value($content, 'settlementDate'),
+    'txnSource'        => _uc_securepayau_xml_value($content, 'txnSource'),
+    'currency'         => _uc_securepayau_xml_value($content, 'currency'),
+    'amount'           => _uc_securepayau_xml_value($content, 'amount'),
+    'purchaseOrderNo'  => _uc_securepayau_xml_value($content, 'purchaseOrderNo'),
+    'approved'         => _uc_securepayau_xml_value($content, 'approved'),
+    'responseCode'     => _uc_securepayau_xml_value($content, 'responseCode'),
+    'responseText'     => _uc_securepayau_xml_value($content, 'responseText'),
+    'successful'       => _uc_securepayau_xml_value($content, 'successful'),
+    'settlementDate'   => _uc_securepayau_xml_value($content, 'settlementDate'),
+    'txnID'            => _uc_securepayau_xml_value($content, 'txnID'),
 
     // payment information
-    'pan'              => _uc_securepayau_substr_between($content, 'pan'),
-    'expiryDate'       => _uc_securepayau_substr_between($content, 'expiryDate'),
-    'cardType'         => _uc_securepayau_substr_between($content, 'cardType'),
-    'cardDescription'  => _uc_securepayau_substr_between($content, 'cardDescription'),
+    'pan'              => _uc_securepayau_xml_value($content, 'pan'),
+    'expiryDate'       => _uc_securepayau_xml_value($content, 'expiryDate'),
+    'cardType'         => _uc_securepayau_xml_value($content, 'cardType'),
+    'cardDescription'  => _uc_securepayau_xml_value($content, 'cardDescription'),
     
     // periodic details
-    'actionType'       => _uc_securepayau_substr_between($content, 'actionType'),
-    'clientID'         => _uc_securepayau_substr_between($content, 'clientID'),
+    'actionType'       => _uc_securepayau_xml_value($content, 'actionType'),
+    'clientID'         => _uc_securepayau_xml_value($content, 'clientID'),
   );
+
   return $data;
 }
 
 /**
  * Helper function for parsing responses; a crude xml parser
+ * many install's dont come with simplexml, so this should be safe enough
  */
-function _uc_securepayau_substr_between($string, $element) {
-  $open = '<'. $element .'>';
-  $close = '</'. $element .'>';
+function _uc_securepayau_xml_value($string, $element) {
 
-  // Fail if we can't find the open or close tag for the element.
-  if (strpos($string, $open) === FALSE || strpos($string, $close) === FALSE) {
-    return FALSE;
-  }
+  $value = false;
+  $element = preg_quote($element);
 
-  $start = strpos($string, $open) + strlen($open);
-  $end = strpos($string, $close);
+  if ($result = preg_match_all("/<$element>(.*)<.$element>/i", $string, $matches)) {
+    $value = $matches[0][1];
+  }
 
-  return substr($string, $start, $end - $start);
+  return $value;
 }
 
 /**
