/**
  * Constructor method
  *
  * Expects a configuration parameter.
  *
  * @param Enlight_Config $config
  */
 public function __construct($config)
 {
     $wsdl = 'https://ipayment.de/service/3.0/?wsdl';
     if ($config->get('ipaymentSandbox')) {
         $this->accountData = array('accountId' => '99999', 'trxuserId' => '99998', 'trxpassword' => '0', 'adminactionpassword' => '5cfgRT34xsdedtFLdfHxj7tfwx24fe');
     } else {
         $this->accountData = array('accountId' => $config->get('ipaymentAccountId'), 'trxuserId' => $config->get('ipaymentAppId'), 'trxpassword' => $config->get('ipaymentAppPassword'), 'adminactionpassword' => $config->get('ipaymentAdminPassword'));
     }
     parent::__construct($wsdl, array('useragent' => 'Shopware ' . Shopware::VERSION));
 }
 /**
  * @param \Enlight_Controller_Request_Request $request
  * @return bool
  */
 public function isRequestAllowed(\Enlight_Controller_Request_Request $request)
 {
     $clientIp = $request->getClientIp();
     $allowedIp = $this->config->get('AllowIP');
     if (empty($allowedIp)) {
         return true;
     }
     if (empty($clientIp)) {
         return false;
     }
     return strpos($allowedIp, $clientIp) !== false;
 }
 /**
  * Constructor method
  *
  * Expects a configuration parameter.
  *
  * @param Enlight_Config $config
  */
 public function __construct($config)
 {
     if (!empty($config->paypalSandbox)) {
         $url = self::URL_SANDBOX;
     } else {
         $url = self::URL_LIVE;
     }
     $this->apiUsername = $config->get('paypalUsername');
     $this->apiPassword = $config->get('paypalPassword');
     $this->apiSignature = $config->get('paypalSignature');
     $this->apiVersion = $config->get('paypalVersion');
     parent::__construct($url);
     $this->setAdapter(RestClient::createAdapterFromConfig($config));
 }
 /**
  * @param PayPalConfig $config
  * @param CacheManager $cacheManager
  * @param string|bool $certPath path to Bundle of CA Root Certificates (see: https://curl.haxx.se/ca/cacert.pem)
  */
 public function __construct(PayPalConfig $config, CacheManager $cacheManager, $certPath = true)
 {
     $this->cacheManager = $cacheManager;
     $restUser = $config->get('paypalClientId');
     $restPw = $config->get('paypalSecret');
     $sandBoxMode = $config->get('paypalSandbox');
     if ($sandBoxMode) {
         $base_url = self::URL_SANDBOX;
     } else {
         $base_url = self::URL_LIVE;
     }
     $this->restClient = new Client(array('base_url' => $base_url, 'defaults' => array('headers' => array('PayPal-Partner-Attribution-Id' => 'ShopwareAG_Cart_PayPalPlus_1017'), 'verify' => $certPath)));
     $this->setAuth($restUser, $restPw);
 }
Beispiel #5
0
 /**
  * Test case
  */
 public function testConfigFileWrite()
 {
     $adapter = new Enlight_Config_Adapter_DbTable(array('automaticSerialization' => true, 'namePrefix' => 'config_', 'nameColumn' => 'name', 'db' => $this->db));
     $config = new Enlight_Config('test', array('adapter' => $adapter, 'section' => 'test', 'allowModifications' => true));
     $config->set('test', 1)->write();
     $config = new Enlight_Config('test', array('adapter' => $adapter));
     $this->assertEquals(1, $config->get('test'));
 }
Beispiel #6
0
 /**
  * Constructor method
  *
  * @param $name
  * @param Enlight_Config|null $info
  */
 public function __construct($name, $info = null)
 {
     $this->info = new Enlight_Config($this->getInfo(), true);
     if ($info instanceof Enlight_Config) {
         $info->setAllowModifications(true);
         $updateVersion = null;
         $updateSource = null;
         if ($info->get('version') < $this->info->get('version')) {
             $updateVersion = $this->info->get('version');
             $updateSource = $this->info->get('source');
         }
         $this->info->merge($info);
         if ($updateVersion !== null) {
             $this->info->set('updateVersion', $updateVersion);
             $this->info->set('updateSource', $updateSource);
         }
     }
     $this->info->set('capabilities', $this->getCapabilities());
     parent::__construct($name);
 }
 /**
  * @param Enlight_Config $config
  * @see https://github.com/paypal/sdk-core-php
  * @return Zend_Http_Client_Adapter_Curl|Zend_Http_Client_Adapter_Socket
  */
 public static function createAdapterFromConfig($config)
 {
     $curl = $config->get('paypalCurl', true);
     $sslVersion = $config->get('paypalSslVersion', 0);
     $timeout = $config->get('paypalTimeout') ?: 60;
     $userAgent = 'Shopware/' . Shopware::VERSION;
     if ($curl && extension_loaded('curl')) {
         $adapter = new Zend_Http_Client_Adapter_Curl();
         $adapter->setConfig(array('useragent' => $userAgent, 'timeout' => $timeout));
         if (!empty($config->paypalSandbox)) {
             $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
             $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, false);
         }
         $adapter->setCurlOption(CURLOPT_TIMEOUT, $timeout);
         $adapter->setCurlOption(CURLOPT_SSLVERSION, $sslVersion);
         //$adapter->setCurlOption(CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
         //$adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
         //$adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, 2);
     } else {
         $adapter = new Zend_Http_Client_Adapter_Socket();
         $adapter->setConfig(array('useragent' => $userAgent, 'timeout' => $timeout, 'ssltransport' => $sslVersion > 3 || $sslVersion == 1 ? 'tls' : 'ssl'));
     }
     return $adapter;
 }
 /**
  * @return array
  */
 protected function getProfileData()
 {
     $template = $this->bootstrap->get('template');
     $router = $this->bootstrap->get('router');
     $shop = $this->bootstrap->get('shop');
     $localeCode = $this->paypalBootstrap->getLocaleCode(true);
     $profileName = "{$shop->getHost()}{$shop->getBasePath()}[{$shop->getId()}]";
     $shopName = $this->bootstrap->get('config')->get('shopName');
     $shopName = $this->config->get('paypalBrandName', $shopName);
     $logoImage = $this->config->get('paypalLogoImage');
     $logoImage = 'string:{link file=' . var_export($logoImage, true) . ' fullPath}';
     $logoImage = $template->fetch($logoImage);
     $notifyUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'notify', 'forceSecure' => true));
     return array('name' => $profileName, 'presentation' => array('brand_name' => $shopName, 'logo_image' => $logoImage, 'locale_code' => $localeCode), 'input_fields' => array('allow_note' => true, 'no_shipping' => 0, 'address_override' => 1), 'flow_config' => array('bank_txn_pending_url' => $notifyUrl));
 }
Beispiel #9
0
 public function testAutoNumArray()
 {
     $config = new Enlight_Config(array(), true);
     $config[0] = 'test1';
     $config[] = 'test2';
     $this->assertEquals('test1', $config->get(0));
     $this->assertEquals('test2', $config->get(1));
 }
Beispiel #10
0
 /**
  * Saves the data changes in the data store.
  *
  * @param      Enlight_Config $config
  * @param      array          $fields
  * @param      bool           $update
  * @return     Enlight_Config_Adapter_DbTable
  */
 public function write(Enlight_Config $config, $fields = null, $update = true)
 {
     $name = $this->_namePrefix . $config->getName() . $this->_nameSuffix;
     $section = $config->getSection();
     $dbTable = new Enlight_Components_Table(array('name' => $name, 'db' => $this->_db));
     $db = $dbTable->getAdapter();
     if ($fields === null) {
         $fields = $config->getDirtyFields();
     }
     if (empty($fields)) {
         return $this;
     }
     $updateData = array();
     $insertData = array();
     if ($this->_updatedColumn !== null) {
         $updateData[$this->_updatedColumn] = new Zend_Date();
         $insertData[$this->_updatedColumn] = new Zend_Date();
     }
     if ($this->_createdColumn !== null) {
         $insertData[$this->_createdColumn] = new Zend_Date();
     }
     $where = array();
     if ($section !== null) {
         if (is_array($this->_sectionColumn)) {
             foreach ($this->_sectionColumn as $key => $sectionColumn) {
                 if (isset($section[$key])) {
                     $where[] = $db->quoteInto($sectionColumn . '=?', $section[$key]);
                     $insertData[$sectionColumn] = $section[$key];
                 }
             }
         } else {
             $where[] = $db->quoteInto($this->_sectionColumn . '=?', $section);
             $insertData[$this->_sectionColumn] = $section;
         }
     }
     foreach ((array) $fields as $field) {
         $fieldWhere = $where;
         $fieldWhere[] = $db->quoteInto($this->_nameColumn . '=?', $field);
         $row = $dbTable->fetchRow($fieldWhere);
         if ($row !== null) {
             if ($update) {
                 $data = $updateData;
                 if ($this->_automaticSerialization) {
                     $data[$this->_valueColumn] = serialize($config->get($field));
                 } else {
                     $data[$this->_valueColumn] = $config->get($field);
                 }
                 $dbTable->update($data, $fieldWhere);
             }
         } else {
             $data = $insertData;
             $data[$this->_nameColumn] = $field;
             if ($this->_automaticSerialization) {
                 $data[$this->_valueColumn] = serialize($config->get($field));
             } else {
                 $data[$this->_valueColumn] = $config->get($field);
             }
             $dbTable->insert($data);
         }
     }
     $config->setDirtyFields(array_diff($config->getDirtyFields(), $fields));
     return $this;
 }
Beispiel #11
0
 /**
  * Constructor method
  * 
  * Expects a configuration parameter.
  *
  * @param Enlight_Config $config
  */
 public function __construct($config)
 {
     if(!empty($config->paypalSandbox)) {
         $url = self::URL_SANDBOX;
     } else {
         $url = self::URL_LIVE;
     }
     $this->apiUsername = $config->get('paypalUsername');
     $this->apiPassword = $config->get('paypalPassword');
     $this->apiSignature = $config->get('paypalSignature');
     $this->apiVersion = $config->get('paypalVersion');
     parent::__construct($url, array(
         'useragent' => 'Shopware/' . Shopware()->Config()->Version,
         'timeout' => 5,
     ));
     if (extension_loaded('curl')) {
         $adapter = new Zend_Http_Client_Adapter_Curl();
         $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
         $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, false);
         $this->setAdapter($adapter);
     }
 }
Beispiel #12
0
 /**
  * Saves the data changes in the data store.
  *
  * @param      Enlight_Config $config
  * @param      array          $fields
  * @param      bool           $update If false, existing rows are not updated
  * @param      bool           $force If true, existing dirty columns are updated
  * @param      bool           $allowReset If true, updating existing columns with existing value will reset dirty flag
  * @return     Enlight_Config_Adapter_DbTable
  */
 public function write(Enlight_Config $config, $fields = null, $update = true, $force = false, $allowReset = false)
 {
     if (!$this->_allowWrites) {
         return $this;
     }
     $name = $this->_namePrefix . $config->getName() . $this->_nameSuffix;
     $section = $config->getSection();
     if (is_string($section)) {
         $section = explode($config->getSectionSeparator(), $config->getSection());
     }
     $dbTable = $this->getTable($this->_namespaceColumn === null ? $name : null);
     $db = $dbTable->getAdapter();
     if ($fields === null) {
         $fields = $config->getDirtyFields();
     }
     if (empty($fields)) {
         return $this;
     }
     $where = array();
     $updateData = array();
     $insertData = array();
     if ($this->_namespaceColumn !== null) {
         $insertData[$this->_namespaceColumn] = $name;
         $where[] = $db->quoteInto($this->_namespaceColumn . '=?', $name);
     }
     if ($this->_updatedColumn !== null) {
         $updateData[$this->_updatedColumn] = new Zend_Date();
         $insertData[$this->_updatedColumn] = new Zend_Date();
     }
     if ($this->_createdColumn !== null) {
         $insertData[$this->_createdColumn] = new Zend_Date();
     }
     if ($section !== null) {
         if (is_array($this->_sectionColumn)) {
             foreach ($this->_sectionColumn as $key => $sectionColumn) {
                 if (isset($section[$key])) {
                     $where[] = $db->quoteInto($sectionColumn . '=?', $section[$key]);
                     $insertData[$sectionColumn] = $section[$key];
                 }
             }
         } else {
             $where[] = $db->quoteInto($this->_sectionColumn . '=?', $section);
             $insertData[$this->_sectionColumn] = $section;
         }
     }
     foreach ((array) $fields as $field) {
         $fieldWhere = $where;
         $fieldWhere[] = $db->quoteInto($this->_nameColumn . '=?', $field);
         $row = $dbTable->fetchRow($fieldWhere);
         if ($row !== null) {
             if ($update) {
                 $data = $updateData;
                 $newValue = $config->get($field);
                 if ($this->_automaticSerialization) {
                     $newValue = serialize($newValue);
                 }
                 if (!$force && $row[$this->_dirtyColumn] == 1 && ($row[$this->_valueColumn] != $newValue || !$allowReset)) {
                     continue;
                 }
                 if ($allowReset && $row[$this->_valueColumn] == $newValue) {
                     $data[$this->_dirtyColumn] = 0;
                 } else {
                     $data[$this->_valueColumn] = $newValue;
                 }
                 $dbTable->update($data, $fieldWhere);
             }
         } else {
             $data = $insertData;
             $data[$this->_nameColumn] = $field;
             $data[$this->_dirtyColumn] = 0;
             if ($this->_automaticSerialization) {
                 $data[$this->_valueColumn] = serialize($config->get($field));
             } else {
                 $data[$this->_valueColumn] = $config->get($field);
             }
             $dbTable->insert($data);
         }
     }
     $config->setDirtyFields(array_diff($config->getDirtyFields(), $fields));
     return $this;
 }
 public function testClientAction()
 {
     $this->get('paypalClient');
     $config = $this->Request()->getParams();
     $config = new \Enlight_Config($config, true);
     // Test timeout
     $timeout = ($config->get('paypalTimeout') ?: 20) * 0.25;
     $config->set('paypalTimeout', $timeout);
     /** @var Zend_Http_Client|Client|RestClient $client */
     $client = null;
     try {
         $client = new Client($config, true);
         $data = $client->getBalance();
         for ($i = 0; isset($data['L_AMT' . $i]); $i++) {
             unset($data['L_AMT' . $i], $data['L_CURRENCYCODE' . $i]);
         }
         unset($data['VERSION']);
         if (isset($data['L_ERRORCODE0'])) {
             $data['code'] = $data['L_ERRORCODE0'];
             $data['message'] = $this->formatErrorMessage($data);
             unset($data['L_ERRORCODE0'], $data['L_SHORTMESSAGE0'], $data['L_LONGMESSAGE0'], $data['L_SEVERITYCODE0']);
         }
         if ($config->get('paypalClientId', false) && $data['ACK'] == 'Success') {
             $client = new RestClient($config);
             $data = $client->setAuthToken();
             $data = array('ACK' => 'Success') + $data;
             if (isset($data['access_token'])) {
                 $data['access_token'] = preg_replace('/[A-Z]/', '#', $data['access_token']);
             }
             unset($data['expires_in']);
         }
     } catch (Exception $e) {
         $data = array('code' => $e->getCode(), 'message' => $e->getMessage());
     }
     $data['shopware_version'] = Shopware::VERSION;
     $data['php_version'] = phpversion();
     if ($config->get('paypalCurl', true) && function_exists('curl_version')) {
         $curlVersion = curl_version();
         $data['curl_version'] = $curlVersion['version'];
         $data['system_host'] = $curlVersion['host'];
         $data['ssl_version'] = $curlVersion['ssl_version'];
         $data['libz_version'] = $curlVersion['libz_version'];
     }
     $this->View()->assign($data);
 }
Beispiel #14
0
 /**
  * Returnswhether or not $updatePluginInfo contains a newer version than $currentPluginInfo
  *
  * @param \Enlight_Config $currentPluginInfo
  * @param \Enlight_Config $updatePluginInfo
  *
  * @return bool
  */
 public function hasInfoNewerVersion(Enlight_Config $updatePluginInfo, Enlight_Config $currentPluginInfo)
 {
     $currentVersion = $currentPluginInfo->get('version');
     $updateVersion = $updatePluginInfo->get('version');
     if (empty($updateVersion)) {
         return false;
     }
     // Exception for Pre-Installed Plugins
     if ($currentVersion == "1" && $updateVersion == "1.0.0") {
         return false;
     }
     return version_compare($updateVersion, $currentVersion, '>');
 }