Exemplo n.º 1
0
 /**
  * Generates an XML string from a Root config object, including all settings (global, shop, payment, protect)
  *
  * @api
  *
  * @param Payone_Settings_Data_ConfigFile_Root $config
  * @return mixed @see SimpleXMLElement::asXml()
  */
 public function execute(Payone_Settings_Data_ConfigFile_Root $config)
 {
     // Recursively add the arrays to a SimpleXMLElement, forming a tree:
     $arrayData = $config->toArray();
     $xml = $this->simpleXmlFromNestedArray(self::TAG_CONFIG_ROOT, $arrayData);
     return $xml->asXML();
 }
Exemplo n.º 2
0
 /**
  * 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);
 }