public function preparePayment() {
    if ($this->validate()) {
      $trans = array();

      foreach ($this->fieldsJSON as $fieldName) {
        if (is_array($this->{$fieldName}) || !C2PValidate::isEmpty($this->{$fieldName})) {
          $trans[$fieldName] = $this->{"get" . ucfirst($fieldName)}();
        }
      }

      // Only PHP >= 5.4 has JSON_UNESCAPED_SLASHES option
      $post_data = str_replace('\\/', '/', json_encode($trans));
      $url = $this->url . Connect2PayClient::$API_ROUTES['TRANS_PREPARE'];

      $result = $this->doPost($url, $post_data);

      if ($result != null && is_array($result)) {
        $this->returnCode = $result['code'];
        $this->returnMessage = $result['message'];

        if ($this->returnCode == "200") {
          $this->merchantToken = $result['merchantToken'];
          $this->customerToken = $result['customerToken'];

          return true;
        } else {
          $this->clientErrorMessage = $this->returnMessage;
        }
      }
    }

    return false;
  }