diff --git a/commerce_dps_pxpay.inc b/commerce_dps_pxpay.inc
index deb5a61055f50c36be30c3e6758684785dac9593..ce0906576738270a65311c9388296f2f0d8e5ba8 100644
--- a/commerce_dps_pxpay.inc
+++ b/commerce_dps_pxpay.inc
@@ -151,3 +151,86 @@ function commerce_dps_pxpay_currencies() {
     'FJD' => 'Fiji Dollar',
   );
 }
+
+/**
+ * Create a transaction and associate it with an order.
+ * 
+ * @param  object $order   The order object being processed
+ * @param  array  $payment Payment details from DPS
+ * @param  string $status  The payment status to use for the transaction
+ * 
+ * @return void
+ */
+function commerce_dps_pxpay_order_transaction($order, $payment, $status){
+    // Create a new payment transaction for the order.
+  $transaction = commerce_payment_transaction_new('dps_pxpay', $order->order_id);
+  $transaction->instance_id           = 'dps_pxpay';
+  $transaction->remote_id             = $payment['TxnId'];
+  $transaction->amount                = commerce_currency_decimal_to_amount($payment['AmountSettlement'], $payment['CurrencyInput']);
+  $transaction->currency_code         = $payment['CurrencyInput'];
+  $transaction->payload[REQUEST_TIME] = $payment;
+
+  // Set the transaction's statuses based on the payment_status.
+  $transaction->remote_status = $payment['ResponseText'];
+  $transaction->status        = $status;
+  $transaction->message       = 'Status @status, @statusdetail. Email: @email. Auth Code=@authcode.';
+
+  $transaction->message_variables = array(
+    '@status'       => $payment['Success'],
+    '@statusdetail' => $payment['ResponseText'],
+    '@email'        => $payment['EmailAddress'],
+    '@authcode'     => $payment['AuthCode'],
+  );
+
+  // Save the transaction information.
+  commerce_payment_transaction_save($transaction);
+}
+
+/**
+ * Get all the transaction remote ids for a given order number.
+ * 
+ * @param  int $order_id The order id the check against
+ * 
+ * @return array This array contains all the the remote_ids
+ */
+function commerce_dps_pxpay_get_remote_ids($order_id){
+
+  $transaction_ids = commerce_dps_pxpay_get_transaction_ids($order_id);
+
+  $transactions = commerce_payment_transaction_load_multiple($transaction_ids);
+
+  $remote_ids = array();
+
+  foreach ($transactions as $transaction) {
+    $remote_ids[] = $transaction->remote_id;
+  }
+
+  return $remote_ids;
+}
+
+/**
+ * Get all the transaction ids for a given order number.
+ * 
+ * @param  int $order_id The order id the check against
+ * 
+ * @return array This array contains all the transaction ids for the order
+ */
+function commerce_dps_pxpay_get_transaction_ids($order_id){
+
+  $query = new EntityFieldQuery();
+
+  $query->entityCondition('entity_type', 'commerce_payment_transaction')
+    ->propertyCondition('order_id', $order_id, '=');
+
+  $transactions = $query->execute();
+
+  $transaction_ids = array();
+
+  if (array_key_exists('commerce_payment_transaction', $transactions)){
+    foreach ($transactions['commerce_payment_transaction'] as $transaction) {
+      $transaction_ids[] = $transaction->transaction_id;
+    }
+  }
+
+  return $transaction_ids;
+}
\ No newline at end of file
diff --git a/commerce_dps_pxpay.info b/commerce_dps_pxpay.info
index 7abc804231da3351327d2d657ccb0bd587eeeb7e..68621918b919876b7bbf88dda5249eadd55aaa2d 100644
--- a/commerce_dps_pxpay.info
+++ b/commerce_dps_pxpay.info
@@ -12,6 +12,7 @@ dependencies[] = commerce_payment
 dependencies[] = commerce_order
 dependencies[] = libraries
 
+files[] = commerce_dps_pxpay.install
 files[] = commerce_dps_pxpay.module
 files[] = commerce_dps_pxpay.inc
 
diff --git a/commerce_dps_pxpay.install b/commerce_dps_pxpay.install
new file mode 100644
index 0000000000000000000000000000000000000000..ce011fbd84c84dd67203aeb02e5237c4bbd1f5f1
--- /dev/null
+++ b/commerce_dps_pxpay.install
@@ -0,0 +1,13 @@
++<?php
+
+/**
+ * @file
+ * Install, update, and uninstall functions for the commerce_dps module.
+ */
+
+/**
+ * Ensure that commerce_dps is menu is rebuilt after upgrading ie clean menu cache.
+ */
+function commerce_dps_pxpay_update_7100() {
+  menu_rebuild();
+}
\ No newline at end of file
diff --git a/commerce_dps_pxpay.module b/commerce_dps_pxpay.module
index aeee8e90dd243c186c9e83585eee2db0559dd426..e09211df4a0d81300ce78188d62ee4e383072909 100644
--- a/commerce_dps_pxpay.module
+++ b/commerce_dps_pxpay.module
@@ -13,18 +13,150 @@ define('COMMERCE_DPS_PXPAY_CANCEL_RETURN_URL', 'cart');
 define('COMMERCE_DPS_PXPAY_REFPREFIX', 'Website Order');
 
 /**
+ * Implements hook_menu().
+ */
+function commerce_dps_pxpay_menu() {
+  // Define an always accessible path to receive FPRN (Fail-proof Result Notification).
+  $items['commerce_dps_pxpay_pxpay/fprn'] = array(
+    'page callback' => 'commerce_dps_pxpay_process_fprn',
+    'page arguments' => array(),
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+
+  return $items;
+}
+
+/**
+ * Processes an normal payment or FPRN.
+ * 
+ * @return void
+ */
+function commerce_dps_pxpay_process_fprn() {
+  module_load_include('inc', 'commerce_dps_pxpay', 'commerce_dps_pxpay');
+  
+  $order = commerce_order_load(arg(2));
+  
+  if(!$order) {
+    return drupal_not_found();
+  }
+
+  $payment_method = $order->data['payment_method'];
+  $payment_data = commerce_payment_method_instance_load($payment_method);
+
+  $transaction = array(
+    'server'  => COMMERCE_DPS_PXPAY_SERVER,
+    'user_id' => $payment_data['settings']['commerce_dps_pxpay_userid'],
+    'key'     => $payment_data['settings']['commerce_dps_pxpay_key'],
+    'log'     => $payment_data['settings']['commerce_dps_pxpay_log_transactions'],
+  );
+
+  // Make sure result is set from DPS
+  if (isset($_GET['result'])) {
+    $transaction['result'] = $_GET['result'];
+  }
+  else {
+    watchdog('commerce_dps_pxpay', 'Transaction result data not found.', array(), WATCHDOG_ERROR);
+    if (preg_match('/(\?|\&)result=/', $_SERVER['REQUEST_URI'])) {
+
+      watchdog(
+        'commerce_dps_pxpay', 
+        'Please see !link for how to configure your webserver to accept DPS return requests.', 
+        array('!link' => l('drupal.org #1799294', 'https://drupal.org/node/1799294')), 
+        WATCHDOG_WARNING
+      );
+
+      drupal_set_message('Server configuration prevented DPS transaction completion. Please advise site administrator to check Drupal logs for details.', 'error');
+      drupal_goto($settings['commerce_dps_pxpay_cancel_return_url']);
+    }
+    return;
+  }
+
+  // Get DPS payment information
+  $response = commerce_dps_pxpay_process_response($transaction);
+  // Proccess the order payment
+  commerce_dps_pxpay_fprn_process($order, $response, $payment_data['settings']);
+}
+
+/**
+ * Payment method callback: process an payment once it's been validated.
+ * 
+ * @param  object $order    The order object being processed
+ * @param  array  $payment  Payment details from DPS
+ * @param  string $settings User defined settings
+ * 
+ * @return void
+ */
+function commerce_dps_pxpay_fprn_process($order, &$payment, $settings) {
+  // Do not perform any processing on transactions here that do not have a transaction ID.
+  if (empty($payment['TxnId'])) {
+    return FALSE;
+  }
+
+  // Exit when we don't get a payment status we recognize.
+  if (!$payment['Success']) {
+
+    // Only add the transaction if we do not have the TxnId stored. 
+    $remote_ids = commerce_dps_pxpay_get_remote_ids($order->order_id);
+
+    if (!in_array($payment['TxnId'], $remote_ids)) {
+      // Write transaction information if payment failed.
+      commerce_dps_pxpay_order_transaction($order, $payment, COMMERCE_PAYMENT_STATUS_FAILURE);
+      watchdog('commerce_dps_pxpay', 'DPS PxPay transaction failed validation. Cart order ID: @cart_order', array('@cart_order' => $order->order->order_number), WATCHDOG_NOTICE);
+      drupal_set_message(t('The transaction failed validation. Please contact us for assistance. Reference Order Id: @orderid', array('@orderid' => $order->order_number)));
+    } 
+
+    drupal_goto($settings['commerce_dps_pxpay_cancel_return_url']);
+  }
+
+  // Local validation.
+  $merchant_reference = $settings['commerce_dps_pxpay_refprefix'] . " #" . $order->order_number;
+
+  if ($merchant_reference != $payment['MerchantReference'] || $order->mail != $payment['EmailAddress']) {
+   
+    watchdog('commerce_dps_pxpay', 'DPS PxPay details do not match order details! Cart order ID: @cart_order', array('@cart_order' => $order->order_number), WATCHDOG_NOTICE);
+
+    drupal_set_message(
+      t('The details of your DPS PxPay payment do not match your order. Please contact us for assistance. Reference Order Id: @orderid', array('@orderid' => $order->order_number))
+    );
+    
+    // Write transaction information if payment details do not match order.
+    commerce_dps_pxpay_order_transaction($order, $payment, COMMERCE_PAYMENT_STATUS_FAILURE);
+    drupal_goto($settings['commerce_dps_pxpay_cancel_return_url']);
+  }
+
+  
+  $remote_ids = commerce_dps_pxpay_get_remote_ids($order->order_id);
+
+  // Only add the transaction if we do not have the TxnId stored. 
+  if (!in_array($payment['TxnId'], $remote_ids)) {
+
+    watchdog('commerce_dps_pxpay', 'DPS PxPay transaction succeeded. Cart order ID: @cart_order', array('@cart_order' => $order->order_number), WATCHDOG_NOTICE);
+
+    drupal_set_message(t('Transaction succeeded. Reference Order Id: @orderid', array('@orderid' => $order->order_number)));
+    
+    // Write transaction information when payment was successful.
+    commerce_dps_pxpay_order_transaction($order, $payment, COMMERCE_PAYMENT_STATUS_SUCCESS);
+    commerce_payment_redirect_pane_next_page($order);
+
+  }
+
+  drupal_goto('checkout/' . $order->order_number. '/complete' );
+}
+
+/**
  * Implements hook_commerce_payment_method_info().
  */
 function commerce_dps_pxpay_commerce_payment_method_info() {
   return array(
     'commerce_dps_pxpay' => array(
-      'title' => t('Commerce Payment Express (PxPay)'),
-      'short_title' => t('DPS'),
+      'title'         => t('Commerce Payment Express (PxPay)'),
+      'short_title'   => t('DPS'),
       'display_title' => t('Credit card'),
-      'description' => t('Provides integration with the DPS PxPay payment gateway.'),
-      'terminal' => FALSE,
-      'offsite' => TRUE,
-      'active' => TRUE,
+      'description'   => t('Provides integration with the DPS PxPay payment gateway.'),
+      'terminal'      => FALSE,
+      'offsite'       => TRUE,
+      'active'        => TRUE,
     ),
   );
 }
@@ -43,9 +175,9 @@ function commerce_dps_pxpay_redirect_form($form, &$form_state, $order, $payment_
 
   $settings = array(
     // Return to the previous page when payment is canceled.
-    'cancel_return' => url('checkout/' . $order->order_id . '/payment/back/' . $order->data['payment_redirect_key'], array('absolute' => TRUE)),
+    'cancel_return'  => url('checkout/' . $order->order_id . '/payment/back/' . $order->data['payment_redirect_key'], array('absolute' => TRUE)),
     // Return to the payment redirect page for processing successful payments.
-    'return' => url('checkout/' . $order->order_id . '/payment/return/' . $order->data['payment_redirect_key'], array('absolute' => TRUE)),
+    'return'         => url('commerce_dps_pxpay_pxpay/fprn/' . $order->order_id . '/payment/return/' . $order->data['payment_redirect_key'], array('absolute' => TRUE)),
     // Specify the current payment method instance ID in the notify_url.
     'payment_method' => $payment_method['instance_id'],
   );
@@ -61,72 +193,72 @@ function commerce_dps_pxpay_settings_form($settings = NULL) {
   $form = array();
 
   $settings = (array) $settings + array(
-    'commerce_dps_pxpay_userid' => COMMERCE_DPS_PXPAY_USERID,
-    'commerce_dps_pxpay_key' => COMMERCE_DPS_PXPAY_KEY,
-    'commerce_dps_pxpay_server' => COMMERCE_DPS_PXPAY_SERVER,
-    'commerce_dps_pxpay_currency' => COMMERCE_DPS_PXPAY_CURRENCY,
+    'commerce_dps_pxpay_userid'            => COMMERCE_DPS_PXPAY_USERID,
+    'commerce_dps_pxpay_key'               => COMMERCE_DPS_PXPAY_KEY,
+    'commerce_dps_pxpay_server'            => COMMERCE_DPS_PXPAY_SERVER,
+    'commerce_dps_pxpay_currency'          => COMMERCE_DPS_PXPAY_CURRENCY,
     'commerce_dps_pxpay_cancel_return_url' => COMMERCE_DPS_PXPAY_CANCEL_RETURN_URL,
-    'commerce_dps_pxpay_refprefix' => COMMERCE_DPS_PXPAY_REFPREFIX,
-    'commerce_dps_pxpay_log_transactions' => 0,
+    'commerce_dps_pxpay_refprefix'         => COMMERCE_DPS_PXPAY_REFPREFIX,
+    'commerce_dps_pxpay_log_transactions'  => 0,
   );
 
   $form['commerce_dps_pxpay_userid'] = array(
-    '#type' => 'textfield',
-    '#title' => t('PxPay User Id'),
-    '#description' => t('PxPay User Id that was issued by Payment Express.'),
+    '#type'          => 'textfield',
+    '#title'         => t('PxPay User Id'),
+    '#description'   => t('PxPay User Id that was issued by Payment Express.'),
     '#default_value' => $settings['commerce_dps_pxpay_userid'],
-    '#required' => TRUE,
+    '#required'      => TRUE,
   );
 
   $form['commerce_dps_pxpay_key'] = array(
-    '#type' => 'textfield',
-    '#title' => t('PxPay key'),
-    '#description' => t('PxPay Key that was issued by Payment Express.'),
+    '#type'          => 'textfield',
+    '#title'         => t('PxPay key'),
+    '#description'   => t('PxPay Key that was issued by Payment Express.'),
     '#default_value' => $settings['commerce_dps_pxpay_key'],
-    '#required' => TRUE,
+    '#required'      => TRUE,
   );
 
   $form['commerce_dps_pxpay_server'] = array(
-    '#type' => 'value',
+    '#type'  => 'value',
     '#title' => t('PxPay server'),
     '#value' => $settings['commerce_dps_pxpay_server'],
   );
   
   $form['commerce_dps_pxpay_log_transactions'] = array(
-    '#type' => 'select',
-    '#title' => t('Record transaction information to Drupal logs.'),
+    '#type'        => 'select',
+    '#title'       => t('Record transaction information to Drupal logs.'),
     '#description' => t('Record communication with DPS server to Drupal logs. For development only.'),
-    '#options' => array(
+    '#options'     => array(
       0 => ('Disabled (production)'),
       1 => ('Enabled (development)'),
     ),
     '#default_value' => $settings['commerce_dps_pxpay_log_transactions'],
-    '#required' => TRUE,
+    '#required'      => TRUE,
   );
 
   $form['commerce_dps_pxpay_currency'] = array(
-    '#type' => 'select',
-    '#title' => t('Currency code'),
-    '#description' => t('Transactions can only be processed in one of the listed currencies.'),
-    '#options' => commerce_dps_pxpay_currencies(),
+    '#type'          => 'select',
+    '#title'         => t('Currency code'),
+    '#description'   => t('Transactions can only be processed in one of the listed currencies.'),
+    '#options'       => commerce_dps_pxpay_currencies(),
     '#default_value' => $settings['commerce_dps_pxpay_currency'],
   );
 
   $form['commerce_dps_pxpay_cancel_return_url'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Cancel return URL'),
-    '#description' => t('Specify the path customers who cancel their DPS PxPay payment will be directed to when they return to your site.'),
+    '#type'          => 'textfield',
+    '#title'         => t('Cancel return URL'),
+    '#description'   => t('Specify the path customers who cancel their DPS PxPay payment will be directed to when they return to your site.'),
     '#default_value' => $settings['commerce_dps_pxpay_cancel_return_url'],
-    '#size' => 32,
-    '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
+    '#size'          => 32,
+    '#field_prefix'  => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
   );
 
   $form['commerce_dps_pxpay_refprefix'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Merchant Reference Prefix'),
-    '#description' => t('Added before order number sent to DPS, ie Website Order #1234'),
+    '#type'          => 'textfield',
+    '#title'         => t('Merchant Reference Prefix'),
+    '#description'   => t('Added before order number sent to DPS, ie Website Order #1234'),
     '#default_value' => $settings['commerce_dps_pxpay_refprefix'],
-    '#required' => TRUE,
+    '#required'      => TRUE,
   );
 
   return $form;
@@ -139,9 +271,9 @@ function commerce_dps_pxpay_submit_form($payment_method, $pane_values, $checkout
   $form['commerce_dps_pxpay_logo'] = array(
     '#markup' => l(
       theme_image(array(
-          'path' => drupal_get_path('module', 'commerce_dps_pxpay') . '/images/dps_paymentexpress_small.png',
-          'alt' => t('DPS - Payment Gateway by Payment Express.'),
-          'title' => t('DPS - Payment Gateway by Payment Express.'),
+          'path'       => drupal_get_path('module', 'commerce_dps_pxpay') . '/images/dps_paymentexpress_small.png',
+          'alt'        => t('DPS - Payment Gateway by Payment Express.'),
+          'title'      => t('DPS - Payment Gateway by Payment Express.'),
           'attributes' => array('style' => 'float: left; margin: 1em 1em 1em 1.5em;'),
         )),
       'http://www.paymentexpress.com',
@@ -158,19 +290,24 @@ function commerce_dps_pxpay_submit_form($payment_method, $pane_values, $checkout
 function commerce_dps_pxpay_order_form($form, &$form_state, $order, $settings) {
   module_load_include('inc', 'commerce_dps_pxpay', 'commerce_dps_pxpay');
 
-  $transaction = array(
-    'user_id' => $settings['commerce_dps_pxpay_userid'],
-    'server' => $settings['commerce_dps_pxpay_server'],
-    'key' => $settings['commerce_dps_pxpay_key'],
-    'amount' => $order->commerce_order_total['und'][0]['amount'] / 100,
-    'type' => 'Purchase',
-    'txn_id' => substr(uniqid($order->order_number . '-'), 0, 16),
-    'reference' => $settings['commerce_dps_pxpay_refprefix'] . " #" . $order->order_number,
-    'currency' => 'NZD',
+  $wrapper = entity_metadata_wrapper('commerce_order', $order);
+  $currency_code = $wrapper->commerce_order_total->currency_code->value();
+  $amount = $wrapper->commerce_order_total->amount->value();
+  $amount = commerce_currency_amount_to_decimal($amount, $currency_code);
+
+   $transaction = array(
+    'user_id'     => $settings['commerce_dps_pxpay_userid'],
+    'server'      => $settings['commerce_dps_pxpay_server'],
+    'key'         => $settings['commerce_dps_pxpay_key'],
+    'amount'      => $amount,
+    'type'        => 'Purchase',
+    'txn_id'      => uniqid($order->order_number),
+    'reference'   => $settings['commerce_dps_pxpay_refprefix'] . " #" . $order->order_number,
+    'currency'    => $currency_code,
     'url_success' => $settings['return'],
-    'url_failure' => $settings['cancel_return'],
-    'email' => $order->mail,
-    'log' => $settings['commerce_dps_pxpay_log_transactions'],
+    'url_failure' => $settings['return'],
+    'email'       => $order->mail,
+    'log'         => $settings['commerce_dps_pxpay_log_transactions'],
   );
 
   if ($url = commerce_dps_pxpay_generate_request($transaction)) {
@@ -179,111 +316,4 @@ function commerce_dps_pxpay_order_form($form, &$form_state, $order, $settings) {
   else {
     watchdog('commerce_dps_pxpay', 'Unable to generate DPS request with settings: @settings', array('@settings' => print_r($settings, 1)), WATCHDOG_DEBUG);
   }
-}
-
-/**
- * Implements hook_redirect_form_validate().
- */
-function commerce_dps_pxpay_redirect_form_validate($order, $payment_method) {
-  module_load_include('inc', 'commerce_dps_pxpay', 'commerce_dps_pxpay');
-  $settings = $payment_method['settings'];
-
-  $transaction = array(
-    'server' => $settings['commerce_dps_pxpay_server'],
-    'user_id' => $settings['commerce_dps_pxpay_userid'],
-    'key' => $settings['commerce_dps_pxpay_key'],
-    'log' => $settings['commerce_dps_pxpay_log_transactions'],
-  );
-  if (isset($_GET['result'])) {
-    $transaction['result'] = $_GET['result'];
-  }
-  else {
-    watchdog('commerce_dps_pxpay', 'Transaction result data not found.', array(), WATCHDOG_ERROR);
-    if (preg_match('/(\?|\&)result=/', $_SERVER['REQUEST_URI'])) {
-      watchdog('commerce_dps_pxpay', 'Please see !link for how to configure your webserver to accept DPS return requests.', array('!link' => l('drupal.org #1799294', 'https://drupal.org/node/1799294')), WATCHDOG_WARNING);
-      drupal_set_message('Server configuration prevented DPS transaction completion. Please advise site administrator to check Drupal logs for details.', 'error');
-      drupal_goto($settings['commerce_dps_pxpay_cancel_return_url']);
-    }
-    return;
-  }
-
-  $tokens->data['payment_details'] = array();
-
-  $response = commerce_dps_pxpay_process_response($transaction);
-
-  // DPS validation.
-  if ($response['Success'] != "1") {
-    // Not a success.
-    commerce_dps_pxpay_form_transaction($payment_method, $order, $tokens, COMMERCE_PAYMENT_STATUS_FAILURE);
-    watchdog('commerce_dps_pxpay', 'DPS PxPay transaction failed validation. Cart order ID: @cart_order', array('@cart_order' => $order->order->order_number), WATCHDOG_NOTICE);
-
-    drupal_set_message(t('The transaction failed validation. Please contact us for assistance. Reference Order Id: @orderid', array('@orderid' => $order->order_number)));
-    drupal_goto($settings['commerce_dps_pxpay_cancel_return_url']);
-  }
-
-  foreach ($response as $k => $v) {
-    $tokens->data['payment_details']['pxpay_' . $k] = $v;
-  }
-
-  // Local validation.
-  $merchant_reference = $settings['commerce_dps_pxpay_refprefix'] . " #" . $order->order_number;
-  if ($merchant_reference != $response['MerchantReference'] || $order->mail != $response['EmailAddress']) {
-    if ($merchant_reference != $payment['MerchantReference']) {
-      $mismatch_info = t('Mismatch: Merchant reference should be %order_ref but was returned as %payment_ref from DPS.',
-                         array('%order_ref' => $merchant_reference, '%payment_ref' => $payment['MerchantReference']));
-    }
-    if ($order->mail != $payment['EmailAddress']) {
-      $mismatch_info = t('Mismatch: Email address should be %order_email but was returned as %payment_email from DPS.',
-                         array('%order_email' => $order->mail, '%payment_email' => $payment['EmailAddress']));
-    }
-    watchdog('commerce_dps_pxpay',
-      'DPS PxPay details for order @cart_order do not match order details! !info',
-      array('@cart_order' => $order->order_number, '!info' => $mismatch_info),
-      WATCHDOG_NOTICE,
-      l('Order #' . $order->order_number, 'admin/commerce/orders/' . $order->order_number));
-    // watchdog('commerce_dps_pxpay', '<pre>!response</pre>', array('!response' => print_r($response,1)), WATCHDOG_DEBUG);
-    drupal_set_message(
-      t('The details of your DPS PxPay payment do not match your order. Please contact us for assistance. Reference Order Id: @orderid',
-        array('@orderid' => $order->order_number)),
-      'error');
-
-    commerce_dps_pxpay_form_transaction($payment_method, $order, $tokens, COMMERCE_PAYMENT_STATUS_FAILURE);
-    drupal_goto($settings['commerce_dps_pxpay_cancel_return_url']);
-  }
-
-  watchdog('commerce_dps_pxpay', 'DPS PxPay transaction succeeded. Cart order ID: @cart_order', array('@cart_order' => $order->order_number), WATCHDOG_NOTICE);
-
-  drupal_set_message(t('Transaction succeeded. Reference Order Id: @orderid', array('@orderid' => $order->order_number)));
-  // Success.
-  commerce_dps_pxpay_form_transaction($payment_method, $order, $tokens, COMMERCE_PAYMENT_STATUS_SUCCESS);
-  return TRUE;
-}
-
-/**
- * Create a transaction and associate it with an order.
- *
- * Set a status for the payment - one of COMMERCE_PAYMENT_STATUS_SUCCESS,
- * COMMERCE_PAYMENT_STATUS_PENDING, or COMMERCE_PAYMENT_STATUS_FAILURE.
- *
- * @TODO move to .inc ?
- */
-function commerce_dps_pxpay_form_transaction($payment_method, $order, $tokens, $transaction_status) {
-  $settings = $payment_method['settings'];
-
-  $transaction = commerce_payment_transaction_new('commerce_dps_pxpay', $order->order_id);
-  $transaction->instance_id = $payment_method['instance_id'];
-  $transaction->amount = $tokens->data['payment_details']['pxpay_AmountSettlement'] * 100;
-  $transaction->currency_code = $settings['commerce_dps_pxpay_currency'];
-  $transaction->remote_id = $tokens->data['payment_details']['pxpay_DpsTxnRef'];
-
-  $transaction->status = $transaction_status;
-  $transaction->message = 'Status @status, @statusdetail. Email: @email. Auth Code=@authcode.';
-  $transaction->message_variables = array(
-    '@status' => $tokens->data['payment_details']['pxpay_Success'],
-    '@statusdetail' => $tokens->data['payment_details']['pxpay_ResponseText'],
-    '@email' => $tokens->data['payment_details']['pxpay_EmailAddress'],
-    '@authcode' => $tokens->data['payment_details']['pxpay_AuthCode'],
-  );
-
-  commerce_payment_transaction_save($transaction);
-}
+}
\ No newline at end of file
