title: Get and pass the order ID on a custom payment gateway in Woocommerce
body: <p>I am building custom payment gateway which i need to handle the success response through ajax and mapped the transaction id with the order id. I am querying to get the last_order_id. Is this the correct way to get the order id or any issue will be arised if i use this way to get the order id. </p>
  
  <pre><code>&lt;script&gt;
      jQuery.ajax({
          type : "POST",                                          
          url: 'http://example.com/?wc-api=callback',
  // .........
  &lt;/script&gt;
  
  function callback(){
      // handle the response here 
  }
  
  
  function get_last_order_id(){
      global $wpdb;
      $statuses = array_keys(wc_get_order_statuses());
      $statuses = implode( "','", $statuses );
  
      // Getting last Order ID (max value)
      $results = $wpdb-&gt;get_col( "
          SELECT MAX(ID) FROM {$wpdb-&gt;prefix}posts
          WHERE post_type LIKE 'shop_order'
          AND post_status IN ('$statuses')
      " );
      return reset($results);
  }
  </code></pre>