/** * export global config and payment method configurations * it's just one shop which will be exported, but all payment methods from all shops are included * * @throws Exception */ public function generateConfigExportAction() { //$this->Front()->Plugins()->ViewRenderer()->setNoRender(); $this->moptPayone__sdk__Builder = Shopware()->Plugins()->Frontend()->MoptPaymentPayone()->Application()->PayoneBuilder(); $this->moptPayone__main = Shopware()->Plugins()->Frontend()->MoptPaymentPayone()->Application()->PayoneMain(); $this->moptPayone__helper = $this->moptPayone__main->getHelper(); $this->moptPayone__paymentHelper = $this->moptPayone__main->getPaymentHelper(); $globalPayoneConfig = $this->moptPayone__main->getPayoneConfig(); /** @var $service Payone_Settings_Service_XmlGenerate */ $service = $this->moptPayone__sdk__Builder->buildServiceSettingsXmlGenerate(); $global = new Payone_Settings_Data_ConfigFile_Shop_Global(); $global->setMid($globalPayoneConfig['merchantId']); $global->setAid($globalPayoneConfig['subaccountId']); $global->setPortalid($globalPayoneConfig['portalId']); //@todo check what these parameters should contain $global->setParameterInvoice(array()); $global->setPaymentCreditcard(array()); if ($globalPayoneConfig['authorisationMethod'] == 'preAuthorise' || $globalPayoneConfig['authorisationMethod'] == 'Vorautorisierung') { $global->setRequestType(Payone_Api_Enum_RequestType::PREAUTHORIZATION); } else { $global->setRequestType(Payone_Api_Enum_RequestType::AUTHORIZATION); } $statusMapping = new Payone_Settings_Data_ConfigFile_Global_StatusMapping(); $personStatusMapping = array(); $transactionStatusForwarding = new Payone_Settings_Data_ConfigFile_Misc_TransactionstatusForwarding(); foreach ($globalPayoneConfig as $configKey => $configValue) { if (strpos($configKey, 'state') === 0) { $statusMapping->addStatusMapping($configKey, $configValue); } if (strpos($configKey, 'map') === 0) { $personStatusMapping[$configKey] = $configValue; } if (strpos($configKey, 'trans') === 0) { $transactionStatusForwarding->addTransactionstatusForwarding($configValue); } } $global->setStatusMapping($statusMapping); $shop = new Payone_Settings_Data_ConfigFile_Shop(); $em = Shopware()->Models(); $shopRepository = $em->getRepository('Shopware\\Models\\Shop\\Shop'); $defaultShop = $shopRepository->getActiveDefault(); $shop->setName($defaultShop->getName()); $shop->setCode($this->generateFileHash()); //what is this param used for?, now using for filehash $system = new Payone_Settings_Data_ConfigFile_Shop_System(); $system->setName('shopware'); $system->setEdition(Shopware()->Config()->Version); $system->setModules($this->getModules()); $protect = new Payone_Settings_Data_ConfigFile_Shop_Protect(); $addressCheck = new Payone_Settings_Data_ConfigFile_Protect_Addresscheck(); $addressCheck->setActive($globalPayoneConfig['adresscheckActive']); $addressCheck->setCheckbilling($globalPayoneConfig['adresscheckBillingAdress']); $addressCheck->setCheckshipping($globalPayoneConfig['adresscheckShippingAdress ']); $addressCheck->setMaxOrderTotal($globalPayoneConfig['adresscheckMaxBasket']); $addressCheck->setMinOrderTotal($globalPayoneConfig['adresscheckMinBasket']); $addressCheck->setMode($globalPayoneConfig['adresscheckLiveMode']); $addressCheck->setPersonstatusmapping($personStatusMapping); $consumerscore = new Payone_Settings_Data_ConfigFile_Protect_Consumerscore(); $consumerscore->setActive($globalPayoneConfig['onsumerscoreActive']); $consumerscore->setAddresscheck($globalPayoneConfig['consumerscoreCheckMode']); $consumerscore->setDuetime($globalPayoneConfig['consumerscoreLifetime']); $consumerscore->setMaxOrderTotal($globalPayoneConfig['consumerscoreMaxBasket']); $consumerscore->setMinOrderTotal($globalPayoneConfig['consumerscoreMinBasket']); $consumerscore->setMode($globalPayoneConfig['consumerscoreLiveMode']); //$consumerscore->setRed($globalPayoneConfig['']); //@todo what is this param used for? //$consumerscore->setYellow($globalPayoneConfig['']); //@todo what is this param used for? $paymentMethods = $this->getPaymentMethods($globalPayoneConfig['checkCc']); $clearingTypes = new Payone_Settings_Data_ConfigFile_Shop_ClearingTypes(); $clearingTypes->setClearingtypes($paymentMethods); $misc = new Payone_Settings_Data_ConfigFile_Shop_Misc(); $misc->setShippingcosts($this->getShippingCosts()); $misc->setTransactionstatusforwarding($transactionStatusForwarding); $config = new Payone_Settings_Data_ConfigFile_Root(); $shop->setGlobal($global); $protect->setAddresscheck($addressCheck); $protect->setConsumerscore($consumerscore); $shop->setProtect($protect); $shop->setClearingtypes($clearingTypes); $shop->setMisc($misc); $shop->setSystem($system); $config->setShop($shop); try { $export = '<?xml version="1.0" encoding="UTF-8"?>' . $service->execute($config); // $export = $service->generate($config); $response = array('success' => true, 'moptConfigExport' => $export); } catch (Exception $e) { $response = array('success' => false, 'error_message' => $e->getMessage()); } $this->View()->assign($response); }
/** * @param Payone_Settings_Data_ConfigFile_Shop $shopConfig * @param DOMElement $configXml * @return string */ protected function mapShop(Payone_Settings_Data_ConfigFile_Shop $shopConfig, DOMElement $configXml) { $shopXml = $this->appendElement($configXml, $shopConfig->getKey()); $this->addChild($shopXml, $shopConfig, 'code'); $this->addChild($shopXml, $shopConfig, 'name', true); $shopXml = $this->mapSystem($shopConfig->getSystem(), $shopXml); $shopXml = $this->mapGlobal($shopConfig->getGlobal(), $shopXml); $shopXml = $this->mapClearingtypes($shopConfig->getClearingtypes(), $shopXml); $shopXml = $this->mapProtect($shopConfig->getProtect(), $shopXml); $shopXml = $this->mapMisc($shopConfig->getMisc(), $shopXml); return $shopXml; }