public function testDirectoryLookup()
 {
     $this->_needSkinCode();
     // initialize client
     $client = $this->createClient();
     // initialize service
     $service = new Service\DirectoryLookup($client);
     $sessionValidity = date(DATE_ATOM, mktime(date("H") + 10, date("i"), date("s"), date("m"), date("j"), date("Y")));
     $json = '{
           "paymentAmount": "1000",
           "currencyCode": "EUR",
           "merchantReference": "Get Payment methods",
           "skinCode":  "' . $this->_skinCode . '",
           "merchantAccount": "' . $this->_merchantAccount . '",
           "sessionValidity": "' . $sessionValidity . '",
           "countryCode": "NL",
           "shopperLocale": "nl_NL"
         }';
     // calculate string
     $params = json_decode($json, true);
     // calculate the signature
     $hmacKey = $this->_hmacSignature;
     // add signature in request
     $params["merchantSig"] = Util::calculateSha256Signature($hmacKey, $params);
     // convert the result into an array
     $result = $service->directoryLookup($params);
     // needs to have an array with the result
     $this->assertInternalType('array', $result);
     // needs to have Ideal in result because country is netherlands
     $hasIdeal = false;
     foreach ($result['paymentMethods'] as $paymentMethod) {
         if ($paymentMethod['brandCode'] == 'ideal') {
             $hasIdeal = true;
         }
     }
     $this->assertEquals(true, $hasIdeal);
 }
Exemplo 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;
 }