public function moptPayoneCaptureOrderAction() { $request = $this->Request(); try { $orderId = $request->getParam('id'); if (!($order = Shopware()->Models()->getRepository('Shopware\\Models\\Order\\Order')->find($orderId))) { $message = Shopware()->Snippets()->getNamespace('backend/MoptPaymentPayone/errorMessages')->get('orderNotFound', 'Bestellung nicht gefunden', true); throw new Exception($message); } if (!$this->moptPayone_isOrderCapturable($order)) { $errorMessage = Shopware()->Snippets()->getNamespace('backend/MoptPaymentPayone/errorMessages')->get('captureNotPossibleGeneral', 'Capture nicht möglich.', true); throw new Exception($errorMessage); } $payment = $order->getPayment(); $paymentName = $payment->getName(); if ($request->getParam('includeShipment') === 'true') { $includeShipment = true; } else { $includeShipment = false; } $config = Mopt_PayoneMain::getInstance()->getPayoneConfig($payment->getId()); //positions ? $positionIds = $request->get('positionIds') ? json_decode($request->get('positionIds')) : array(); //covert finalize param $finalize = $request->get('finalize') == "true" ? true : false; //fetch params $params = $this->moptPayone__main->getParamBuilder()->buildOrderCapture($order, $positionIds, $finalize, $includeShipment); if ($config['submitBasket'] || $this->moptPayone__main->getPaymentHelper()->isPayoneBillsafe($paymentName)) { $invoicing = $this->moptPayone__main->getParamBuilder()->getInvoicingFromOrder($order, $positionIds, $finalize, false, $includeShipment); } //call capture service $response = $this->moptPayone_callCaptureService($params, $invoicing); if ($response->getStatus() == Payone_Api_Enum_ResponseType::APPROVED) { //increase sequence $this->moptPayoneUpdateSequenceNumber($order, true); //mark / fill positions as captured $this->moptPayoneMarkPositionsAsCaptured($order, $positionIds, $includeShipment); //extract and save clearing data $clearingData = $this->moptPayone__paymentHelper->extractClearingDataFromResponse($response); if ($clearingData) { $this->moptPayoneSaveClearingData($order, $clearingData); } $response = array('success' => true); } else { $errorMessage = Shopware()->Snippets()->getNamespace('backend/MoptPaymentPayone/errorMessages')->get('captureNotPossibleNow', 'Capture (zur Zeit) nicht möglich.', true); $response = array('success' => false, 'error_message' => $errorMessage); } } catch (Exception $e) { $response = array('success' => false, 'error_message' => $e->getMessage()); } $this->View()->assign($response); }
/** * returns auth-parameters for API-calls * * @param string $paymentId * @return array */ protected function getAuthParameters($paymentId = 0) { $this->payoneConfig = Mopt_PayoneMain::getInstance()->getPayoneConfig($paymentId); $authParameters = array(); $authParameters['mid'] = $this->payoneConfig['merchantId']; $authParameters['portalid'] = $this->payoneConfig['portalId']; $authParameters['key'] = $this->payoneConfig['apiKey']; $authParameters['aid'] = $this->payoneConfig['subaccountId']; $authParameters['solution_name'] = 'mediaopt'; $authParameters['solution_version'] = Shopware()->Plugins()->Frontend()->MoptPaymentPayone()->getVersion(); $authParameters['integrator_name'] = 'shopware'; $authParameters['integrator_version'] = Shopware()->Config()->Version; if ($this->payoneConfig['liveMode'] == 1) { $authParameters['mode'] = Payone_Enum_Mode::LIVE; } else { $authParameters['mode'] = Payone_Enum_Mode::TEST; } $authParameters['encoding'] = 'UTF-8'; // optional param default is: ISO-8859-1 return $authParameters; }
/** * Creates and returns the payone builder for an event. * * @param \Enlight_Event_EventArgs $args * @return \Shopware_Components_Payone_Builder */ public function onInitResourcePayoneMain(\Enlight_Event_EventArgs $args) { $moptPayoneMain = Mopt_PayoneMain::getInstance(); return $moptPayoneMain; }