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;
 }
 /**
  * Tests Services_Paymill_Preauthorizations->delete()
  */
 public function testDelete()
 {
     try {
         $this->_preauthorization->delete();
     } catch (Exception $e) {
         $this->assertInstanceOf('Services_Paymill_Exception', $e);
         $this->assertEquals(404, $e->getCode());
     }
 }
 /**
  * Returns the store of the transaction overview
  */
 public function loadStoreAction()
 {
     $swConfig = Shopware()->Plugins()->Frontend()->PaymPaymentCreditcard()->Config();
     $apiKey = trim($swConfig->get("privateKey"));
     $apiEndpoint = "https://api.paymill.com/v2/";
     $orderId = $this->Request()->getParam("orderId");
     $modelHelper = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_ModelHelper();
     $orderNumber = $modelHelper->getOrderNumberById($orderId);
     $success = true;
     $result = array();
     $preAuthId = $modelHelper->getPaymillPreAuthorization($orderNumber);
     $transactionId = $modelHelper->getPaymillTransactionId($orderNumber);
     $refundId = $modelHelper->getPaymillRefund($orderNumber);
     $cancelled = $modelHelper->getPaymillCancelled($orderNumber);
     if ($preAuthId !== "" && $preAuthId !== null) {
         //List PreAuth
         require_once dirname(dirname(dirname(__FILE__))) . '/lib/Services/Paymill/Preauthorizations.php';
         $preAuthObj = new Services_Paymill_Preauthorizations($apiKey, $apiEndpoint);
         $response = $preAuthObj->getOne($preAuthId);
         $result[] = array('entryDate' => date('d.M.Y H:i:s', $response['created_at']), 'description' => 'PreAuthorization ' . $response['id'], 'amount' => $response['amount'] / 100 . ' ' . $response['currency']);
     }
     if ($transactionId !== "" && $transactionId !== null) {
         //List Transaction
         require_once dirname(dirname(dirname(__FILE__))) . '/lib/Services/Paymill/Transactions.php';
         $transactionObj = new Services_Paymill_Transactions($apiKey, $apiEndpoint);
         $response = $transactionObj->getOne($transactionId);
         $currency = $response['currency'];
         $result[] = array('entryDate' => date('d.M.Y H:i:s', $response['created_at']), 'description' => 'Transaction ' . $response['id'], 'amount' => $response['origin_amount'] / 100 . ' ' . $currency);
     }
     if ($refundId !== "" && $refundId !== null) {
         //List Refund
         require_once dirname(dirname(dirname(__FILE__))) . '/lib/Services/Paymill/Refunds.php';
         $refundObj = new Services_Paymill_Refunds($apiKey, $apiEndpoint);
         $response = $refundObj->getOne($refundId);
         $result[] = array('entryDate' => date('d.M.Y H:i:s', $response['updated_at']), 'description' => 'Refund ' . $response['id'], 'amount' => $response['amount'] / 100 . ' ' . $currency);
     }
     $this->View()->assign(array('success' => $success, 'data' => $result, 'debug' => var_export($refundId, true)));
 }