lib/Conekta/Requestor.php
public function request($method, $url, $params = null)
  {
    $jsonParams = json_encode($params);
    $headers = $this->setHeaders();
    $curl = curl_init();
    $method = strtolower($method);
    $opts = array();

    switch ($method) {
      case 'get':
      $opts[CURLOPT_HTTPGET] = 1;
      $url = $this->buildQueryParamsUrl($url, $params);
      break;
      case 'post':
      $opts[CURLOPT_POST] = 1;
      $opts[CURLOPT_POSTFIELDS] = $jsonParams;
      break;
      case 'put':
      $opts[CURLOPT_RETURNTRANSFER] = 1;
      $opts[CURLOPT_CUSTOMREQUEST] = 'PUT';
      $opts[CURLOPT_POSTFIELDS] = $jsonParams;
      break;
      case 'delete':
      $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
      $url = $this->buildSegmentParamsUrl($url, $params);
      break;
      default:
      throw new \Exception('Wrong method');
    }

    $url = $this->apiUrl($url);
    $opts[CURLOPT_URL] = $url;
    $opts[CURLOPT_RETURNTRANSFER] = true;
    $opts[CURLOPT_CONNECTTIMEOUT] = 30;
    $opts[CURLOPT_TIMEOUT] = 80;
    $opts[CURLOPT_RETURNTRANSFER] = true;
    $opts[CURLOPT_HTTPHEADER] = $headers;
    $opts[CURLOPT_SSLVERSION] = 6;
    $opts[CURLOPT_CAINFO] = dirname(__FILE__).'/../ssl_data/ca_bundle.crt';
    curl_setopt_array($curl, $opts);
    $response = curl_exec($curl);
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);

    $jsonResponse = json_decode($response, true);

    if ($responseCode != 200) {
      throw Handler::errorHandler($jsonResponse, $responseCode);
    }

    return $jsonResponse;
  }
public function request($method, $url, $params = null)
  {
    $jsonParams = json_encode($params);
    $headers = $this->setHeaders();
    $curl = curl_init();
    $method = strtolower($method);
    $opts = array();

    switch ($method) {
      case 'get':
      $opts[CURLOPT_HTTPGET] = 1;
      $url = $this->buildQueryParamsUrl($url, $params);
      break;
      case 'post':
      $opts[CURLOPT_POST] = 1;
      $opts[CURLOPT_POSTFIELDS] = $jsonParams;
      break;
      case 'put':
      $opts[CURLOPT_RETURNTRANSFER] = 1;
      $opts[CURLOPT_CUSTOMREQUEST] = 'PUT';
      $opts[CURLOPT_POSTFIELDS] = $jsonParams;
      break;
      case 'delete':
      $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
      $url = $this->buildSegmentParamsUrl($url, $params);
      break;
      default:
      throw new \Exception('Wrong method');
    }

    $url = $this->apiUrl($url);
    $opts[CURLOPT_URL] = $url;
    $opts[CURLOPT_RETURNTRANSFER] = true;
    $opts[CURLOPT_CONNECTTIMEOUT] = 30;
    $opts[CURLOPT_TIMEOUT] = 80;
    $opts[CURLOPT_RETURNTRANSFER] = true;
    $opts[CURLOPT_HTTPHEADER] = $headers;
    $opts[CURLOPT_SSLVERSION] = 6;
    $opts[CURLOPT_CAINFO] = dirname(__FILE__).'/../ssl_data/ca_bundle.crt';
    curl_setopt_array($curl, $opts);
    $response = curl_exec($curl);
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);

    $jsonResponse = json_decode($response, true);

    if ($responseCode != 200) {
      throw Handler::errorHandler($jsonResponse, $responseCode);
    }

    return $jsonResponse;
  }
Function request

Make api call

@param method (string) REST action [DELETE,PUT,POST,GET]
@param url (string) endpoint to concatenate
@param params (array) contains body request
@return (json)