diff --git a/commerce_authnet.module b/commerce_authnet.module
index 2246c2d..2d855d5 100644
--- a/commerce_authnet.module
+++ b/commerce_authnet.module
@@ -1441,3 +1441,59 @@ function commerce_authnet_cvv_response($code) {
 
   return '-';
 }
+
+/*
+ * Capture callback for payment capture rule action
+ *
+ * @param $order object
+ *    The order being charged
+ * @param $amount float
+ *    The amount to be captured
+ *
+ * @return
+ *   TRUE if the capture was succesful, FALSE otherwise
+ *
+ */
+function commerce_authnet_aim_capture($transaction, $amount) {
+  $payment_method = commerce_payment_method_instance_load($transaction->instance_id);
+  // Build a name-value pair array for this transaction.
+  $nvp = array(
+    'x_type' => 'PRIOR_AUTH_CAPTURE',
+    'x_trans_id' => $transaction->remote_id,
+    'x_amount' => $amount,
+  );
+
+  // Submit the request to Authorize.Net.
+  $response = commerce_authnet_aim_request($payment_method, $nvp);
+
+  // Update and save the transaction based on the response.
+  $transaction->payload[REQUEST_TIME] = $response;
+
+  // If we didn't get an approval response code...
+  if ($response[0] != '1') {
+    // Display an error message but leave the transaction pending.
+    //watchdog('commerce_authnet', t('Prior authorization capture failed, so the transaction will remain in a pending status.'), 'error');
+    watchdog('commerce_authnet', check_plain($response[3]), 'error');
+
+    $return = FALSE;
+  }
+  else {
+    watchdog('commerce_authnet', t('Prior authorization captured successfully.'));
+
+    // Update the transaction amount to the actual capture amount.
+    $transaction->amount = commerce_currency_decimal_to_amount($amount, $transaction->currency_code);
+
+    // Set the remote and local status accordingly.
+    $transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
+    $transaction->remote_status = $response[11];
+
+    // Append a capture indication to the result message.
+    $transaction->message .= '<br />' . t('Captured: @date', array('@date' => format_date(REQUEST_TIME, 'short')));
+
+    $return = TRUE;
+  }
+
+  commerce_payment_transaction_save($transaction);
+
+  return $return;
+}
diff --git a/includes/commerce_authnet.admin.inc b/includes/commerce_authnet.admin.inc
index 9d66b1a..fc416e4 100644
--- a/includes/commerce_authnet.admin.inc
+++ b/includes/commerce_authnet.admin.inc
@@ -86,40 +86,7 @@ function commerce_authnet_aim_capture_form_submit($form, &$form_state) {
   $transaction = $form_state['transaction'];
   $amount = $form_state['values']['amount'];
 
-  // Build a name-value pair array for this transaction.
-  $nvp = array(
-    'x_type' => 'PRIOR_AUTH_CAPTURE',
-    'x_trans_id' => $transaction->remote_id,
-    'x_amount' => $amount,
-  );
-
-  // Submit the request to Authorize.Net.
-  $response = commerce_authnet_aim_request($form_state['payment_method'], $nvp);
-
-  // Update and save the transaction based on the response.
-  $transaction->payload[REQUEST_TIME] = $response;
-
-  // If we didn't get an approval response code...
-  if ($response[0] != '1') {
-    // Display an error message but leave the transaction pending.
-    drupal_set_message(t('Prior authorization capture failed, so the transaction will remain in a pending status.'), 'error');
-    drupal_set_message(check_plain($response[3]), 'error');
-  }
-  else {
-    drupal_set_message(t('Prior authorization captured successfully.'));
-
-    // Update the transaction amount to the actual capture amount.
-    $transaction->amount = commerce_currency_decimal_to_amount($amount, $transaction->currency_code);
-
-    // Set the remote and local status accordingly.
-    $transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
-    $transaction->remote_status = $response[11];
-
-    // Append a capture indication to the result message.
-    $transaction->message .= '<br />' . t('Captured: @date', array('@date' => format_date(REQUEST_TIME, 'short')));
-  }
-
-  commerce_payment_transaction_save($transaction);
+  commerce_authnet_aim_capture($transaction, $amount);
 
   $form_state['redirect'] = 'admin/commerce/orders/' . $form_state['order']->order_id . '/payment';
 }
