private function proceedCapture($preauth_id)
 {
     $result = false;
     $this->init();
     $this->load->model('sale/order');
     $orderId = $this->getPost('orderId', 0);
     $preauth = $this->paymillPreauth->getOne($preauth_id);
     if (is_array($preauth)) {
         $this->paymillProcessor->setAmount($preauth['amount']);
         $this->paymillProcessor->setCurrency($preauth['currency']);
         $this->paymillProcessor->setPreauthId($preauth_id);
         $this->paymillProcessor->setDescription('Capture ' . $preauth_id);
         try {
             $result = $this->paymillProcessor->capture();
             $this->log('Capture resulted in', var_export($result, true));
             $this->log('Capture successfully', $this->paymillProcessor->getTransactionId());
             $this->saveTransactionId($orderId, $this->paymillProcessor->getTransactionId());
             $orderStatusId = $this->db->query('SELECT `order_status_id` FROM `' . DB_PREFIX . 'order_status` WHERE `name`= "Complete"')->row['order_status_id'];
             $this->model_sale_order->addOrderHistory($orderId, array('order_status_id' => $orderStatusId, 'notify' => false, 'comment' => ''));
         } catch (Exception $ex) {
             $result = false;
         }
     }
     return $result;
 }
 public function capturePreauth()
 {
     $transaction = oxNew('paymill_transaction');
     $transaction->load($this->getEditObjectId());
     $params = array();
     $params['amount'] = (int) (int) ($this->_getRefundAmount() * 100);
     $params['currency'] = strtoupper($this->getEditObject()->oxorder__oxcurrency->rawValue);
     $paymentProcessor = new Services_Paymill_PaymentProcessor(trim(oxRegistry::getConfig()->getShopConfVar('PAYMILL_PRIVATEKEY')), paymill_util::API_ENDPOINT, null, $params, $this);
     oxRegistry::getSession()->setVariable('preauth', true);
     $paymentProcessor->setPreauthId($transaction->paymill_transaction__preauth_id->rawValue);
     if (!$paymentProcessor->capture()) {
         oxRegistry::getSession()->setVariable('error', true);
     } else {
         $transaction->assign(array('transaction_id' => $paymentProcessor->getTransactionId()));
         $transaction->save();
         oxRegistry::getSession()->setVariable('success', true);
     }
 }
 public function processInvoice($invoice, $payment)
 {
     $data = $payment->getAdditionalInformation();
     if (array_key_exists('paymillPreauthId', $data) && !empty($data['paymillPreauthId'])) {
         $params = array();
         $params['amount'] = (int) Mage::helper("paymill/paymentHelper")->getAmount($invoice);
         $params['currency'] = Mage::helper("paymill/paymentHelper")->getCurrency($invoice);
         $params['description'] = Mage::helper('paymill/paymentHelper')->getDescription($payment->getOrder());
         $params['source'] = Mage::helper('paymill')->getSourceString();
         $paymentProcessor = new Services_Paymill_PaymentProcessor(Mage::helper('paymill/optionHelper')->getPrivateKey(), Mage::helper('paymill')->getApiUrl(), null, $params, Mage::helper('paymill/loggingHelper'));
         $paymentProcessor->setPreauthId($data['paymillPreauthId']);
         if (!$paymentProcessor->capture()) {
             Mage::throwException(Mage::helper("paymill/paymentHelper")->getErrorMessage($paymentProcessor->getErrorCode()));
         }
         Mage::helper('paymill/loggingHelper')->log("Capture created", var_export($paymentProcessor->getLastResponse(), true));
         $payment->setAdditionalInformation('paymillTransactionId', $paymentProcessor->getTransactionId());
     }
     parent::processInvoice($invoice, $payment);
 }
<?php

require_once 'includes/application_top.php';
require_once DIR_WS_CLASSES . 'order.php';
require_once dirname(__FILE__) . '/../ext/modules/payment/paymill/lib/Services/Paymill/PaymentProcessor.php';
if (isset($_GET['oID']) && !empty($_GET['oID'])) {
    $order = new order($_GET['oID']);
    $transaction = tep_db_fetch_array(tep_db_query("SELECT * FROM pi_paymill_transaction WHERE order_id = '" . $_GET['oID'] . "'"));
    require_once dirname(__FILE__) . '/../includes/modules/payment/' . $transaction['payment_code'] . '.php';
    include dirname(__FILE__) . '/../includes/languages/' . $_SESSION['language'] . '/modules/payment/' . $transaction['payment_code'] . '.php';
    $payment = new $transaction['payment_code']();
    $params = array();
    $params['amount'] = $transaction['amount'];
    $params['currency'] = $order->info['currency'];
    $paymentProcessor = new Services_Paymill_PaymentProcessor($payment->privateKey, $payment->apiUrl, null, $params, $payment);
    $paymentProcessor->setPreauthId($transaction['preauth_id']);
    try {
        $result = $paymentProcessor->capture();
    } catch (Exception $ex) {
    }
    if ($result) {
        $statusArray = tep_db_fetch_array(tep_db_query("select orders_status_id from " . TABLE_ORDERS_STATUS . " where orders_status_name = 'Paymill [Captured]' limit 1"));
        tep_db_query("UPDATE " . TABLE_ORDERS . " SET orders_status='" . $statusArray['orders_status_id'] . "' WHERE orders_id='" . $_GET['oID'] . "'");
        tep_db_query("UPDATE pi_paymill_transaction SET transaction_id = '" . tep_db_prepare_input($paymentProcessor->getTransactionId()) . "' WHERE order_id = " . (int) $_GET['oID']);
        $messageStack->add_session(PAYMILL_CAPTURE_SUCCESS, 'success');
    } else {
        $messageStack->add_session(PAYMILL_CAPTURE_ERROR, 'error');
    }
}
tep_redirect(tep_href_link(FILENAME_ORDERS, 'oID=' . $_GET['oID'] . '&action=edit', true, false));
 /**
  * tests _validateResult for unknown errors
  */
 public function testValidateResultCapture()
 {
     $payment = new Services_Paymill_PaymentProcessor($this->_apiTestKey, $this->_apiUrl, null, null, $this);
     $this->assertFalse($payment->capture());
 }