/**
  * @covers            \JohnConde\Authnet\AuthnetJsonRequest::setProcessHandler()
  */
 public function testProcessorIsInstanceOfCurlWrapper()
 {
     $request = new AuthnetJsonRequest(null, null, AuthnetApiFactory::USE_DEVELOPMENT_SERVER);
     $request->setProcessHandler(new CurlWrapper());
     $reflectionOfRequest = new \ReflectionObject($request);
     $processor = $reflectionOfRequest->getProperty('processor');
     $processor->setAccessible(true);
     $this->assertTrue($processor->getValue($request) instanceof \JohnConde\Authnet\CurlWrapper);
 }
Exemplo n.º 2
0
 /**
  * Validates the Authorize.Net credentials and returns a Request object to be used to make an API call
  *
  * @param   string      $login                          Authorize.Net API Login ID
  * @param   string      $transaction_key                Authorize.Net API Transaction Key
  * @param   integer     $server                         ID of which server to use (optional)
  * @return  object      \JohnConde\Authnet\AuthnetJson
  * @throws  \JohnConde\Authnet\AuthnetInvalidCredentialsException
  */
 public static function getJsonApiHandler($login, $transaction_key, $server = self::USE_AKAMAI_SERVER)
 {
     $login = trim($login);
     $transaction_key = trim($transaction_key);
     $api_url = static::getWebServiceURL($server);
     if (empty($login) || empty($transaction_key)) {
         throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.');
     }
     $object = new AuthnetJsonRequest($login, $transaction_key, $api_url);
     $object->setProcessHandler(new CurlWrapper());
     return $object;
 }