/**
  * PaymentRequest constructor.
  *
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
  * @param \Adyen\Payment\Helper\Data $adyenHelper
  * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
  * @param \Adyen\Payment\Model\RecurringType $recurringType
  * @param array $data
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Model\RecurringType $recurringType, array $data = [])
 {
     $this->_encryptor = $encryptor;
     $this->_adyenHelper = $adyenHelper;
     $this->_adyenLogger = $adyenLogger;
     $this->_recurringType = $recurringType;
     $this->_appState = $context->getAppState();
     // initialize client
     $webserviceUsername = $this->_adyenHelper->getWsUsername();
     $webservicePassword = $this->_adyenHelper->getWsPassword();
     $client = new \Adyen\Client();
     $client->setApplicationName("Magento 2 plugin");
     $client->setUsername($webserviceUsername);
     $client->setPassword($webservicePassword);
     if ($this->_adyenHelper->isDemoMode()) {
         $client->setEnvironment(\Adyen\Environment::TEST);
     } else {
         $client->setEnvironment(\Adyen\Environment::LIVE);
     }
     // assign magento log
     $client->setLogger($adyenLogger);
     $this->_client = $client;
 }
Esempio n. 2
0
 /**
  * @param $requestParams
  * @param $store
  * @return array
  * @throws \Adyen\AdyenException
  */
 protected function _getDirectoryLookupResponse($requestParams, $store)
 {
     $cacheKey = $this->_getCacheKeyForRequest($requestParams, $store);
     // initialize the adyen client
     $client = new \Adyen\Client();
     if ($this->_adyenHelper->isDemoMode()) {
         $client->setEnvironment(\Adyen\Environment::TEST);
     } else {
         $client->setEnvironment(\Adyen\Environment::LIVE);
     }
     // connect to magento log
     $client->setLogger($this->_adyenLogger);
     $hmacKey = $this->_adyenHelper->getHmac();
     // create and add signature
     try {
         $requestParams["merchantSig"] = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $requestParams);
     } catch (\Adyen\AdyenException $e) {
         $this->_adyenLogger->error($e->getMessage());
         // return empty result
         return [];
     }
     // initialize service
     $service = new \Adyen\Service\DirectoryLookup($client);
     try {
         $responseData = $service->directoryLookup($requestParams);
     } catch (\Adyen\AdyenException $e) {
         $this->_adyenLogger->error("The Directory Lookup response is empty check your Adyen configuration in Magento.");
         // return empty result
         return [];
     }
     return $responseData;
 }