title: Prestashop payment module returning 500 server status
body: <p>I'm trying to figure out how to give a good response status to my API shot which was made to the prestashop.
  That's the code of validation.php:</p>
  
  <pre><code>&lt;?php
  
  class InpayValidationModuleFrontController extends ModuleFrontController
  {
      /**
       * @see FrontController::postProcess()
       */
  
      public function postProcess()
      {
  
          if ($_SERVER['REQUEST_METHOD'] == 'POST' &amp;&amp; $_POST['invoiceCode'] &amp;&amp; $_POST['status'] &amp;&amp; $_POST['optData']) {
              $apiHash = $_SERVER['HTTP_API_HASH'];
              $query = http_build_query($_POST);
              $hash = hash_hmac("sha512", $query, $this-&gt;module-&gt;secret_key);
              if ($apiHash == $hash) {
  
                  PrestaShopLogger::addLog(json_encode(_PS_VERSION_), 1);
  
                      parse_str($_POST['optData'], $optData);
                  $id_cart = intval($optData['cartId']);
                  $query = "SELECT * from " . _DB_PREFIX_ . "orders where id_cart='" . $id_cart . "'";
                  //$query = "SELECT * from aps_orders where id_cart='67867'";
                  $row = Db::getInstance()-&gt;getRow($query);
  
                  if ($_POST['status'] == 'confirmed' &amp;&amp; $row['current_state'] != null) {
                      $sql = "UPDATE " . _DB_PREFIX_ . "orders SET current_state='2' WHERE id_cart='" . $id_cart . "'";
                      if(Db::getInstance()-&gt;Execute($sql))
                          Tools::redirect(__FILE__,'payment_confirmation.tpl');
  
                  } else {
                      $cart = new Cart($id_cart);
  
                      if ($cart-&gt;id_customer == 0 || $cart-&gt;id_address_delivery == 0 || $cart-&gt;id_address_invoice == 0 || !$this-&gt;module-&gt;active) {
                          //die('Cannot create order for this cart.');
                          Tools::redirect(__FILE__,'payment_cart_error.tpl');
  
                      }
  
                      $customer = new Customer($cart-&gt;id_customer);
  
                      if (!Validate::isLoadedObject($customer)) {
                          //die('No customer for this order.');
                          Tools::redirect(__FILE__,'payment_customer_error.tpl');
  
                      }
  
                      $currency = new Currency((int)($cart-&gt;id_currency));
                      $paid_amount = $_POST['amount'];
                      $order_amount = $cart-&gt;getOrderTotal(true, Cart::BOTH);
  
  
                      if ($_POST['status'] == 'confirmed') {
                          $paymentId = 2;
                      } elseif ($_POST['status'] == 'received') {
                          $paymentId = 11;
                      }
  
                      $result = $this-&gt;module-&gt;validateOrder(
                          $cart-&gt;id,
                          //Configuration::get('PS_OS_PAYMENT'),
                          $paymentId,
                          $order_amount,
                          $this-&gt;module-&gt;displayName,
                          'Invoice Code: ' . $_POST['invoiceCode'],
                          array(),
                          intval($currency-&gt;id),
                          false,
                          $customer-&gt;secure_key
                      );
                      //die($result);
                      Tools::redirect(__FILE__,'payment_confirmation.tpl');
  
  
                  }
              } else {
                  return null;
              }
  
  
          }
  
      }
  }
  </code></pre>
  
  <p>While I use the <code>die();</code> function the server returns 200 response status which is good... but the die isn't a function for production... When using redirect it gives me 302 and additional status of error. I tried doing hacks like:</p>
  
  <pre><code>header("HTTP/1.1 200 OK");
  </code></pre>
  
  <p>or</p>
  
  <pre><code>return http_response_code(200);
  </code></pre>
  
  <p>But the status is 500. I would appreciate any tip or help how to do that.</p>
  
  <p>Cheers!</p>