title: Woocommerce Gateway Integration Payment Status not updating
body: <p>I have set up a custom Woocommerce off-side payment gateway, the communication from my website to the Gateway works fine. The user gets redirected to the gateway and after the payment he gets returned to the (by Woocommerce) defined return URL.</p>
  
  <p>In the API documentation of the gateway, it says that the payment gateway will add a query string variable to the return url. This variable can have the following values:</p>
  
  <pre><code>response=approved
  response=declined
  response=error
  </code></pre>
  
  <p>In the documentation is this exampple:
  If backURL = <a href="http://www.test.com/return.asp" rel="nofollow">http://www.test.com/return.asp</a>
  Then the response will be <a href="http://www.test.com/return.asp?response=approved" rel="nofollow">http://www.test.com/return.asp?response=approved</a></p>
  
  <p>To process the order I have created the code below (first just for the state of <code>response=approved</code>)
  However, the order status does not get updated, when I test it. I hope somebody can point me in the right direction to find the error.</p>
  
  <p>On top of the gateway I have extended query_vars with:</p>
  
  <pre><code>function add_query_vars_filter( $vars ){
  $vars[] = "response";
  return $vars;
  }
  add_filter( 'query_vars', 'add_query_vars_filter' );    
  </code></pre>
  
  <p>After sending the user to the gateway I have this function to handle and process the query string in the return URL:</p>
  
  <pre><code>function check_example_response(){
  
          global $woocommerce;
  
              $transaction_id = get_query_var( 'response' );
  
              $order          = new WC_Order( $order_id );
  
                  // check if payment was successful
                  if ($transaction_id == 'approved') {
  
                              //Update order status
                              $order-&gt;update_status( 'processing', 'Payment received, your order is currently being processed.' );
  
                              //Add admin order noote
                              $order-&gt;add_order_note('Payment Via Example Gateway&lt;br /&gt;Transaction ID: '.$order);
  
                              //Add customer order note
                              $order-&gt;add_order_note('Payment Received.&lt;br /&gt;Your order is currently being processed.&lt;br /&gt;We will be shipping your order to you soon.&lt;br /&gt;Transaction ID: '.$order, 1);
  
                              $message = 'Thank you for shopping with us.&lt;br /&gt;Your transaction was successful, payment was received.&lt;br /&gt;Your order is currently being processed.';
                              $message_type = 'success';
                          }
  
                          // Reduce stock levels
                          $order-&gt;reduce_order_stock();
  
                          // Empty cart
                          WC()-&gt;cart-&gt;empty_cart();
   }}
  </code></pre>
  
  <p>I have also registered this function with:</p>
  
  <pre><code>add_action( 'woocommerce_api_wc_example', array( $this, 'check_example_response' ) );
  </code></pre>
  
  <p>Wordpress also does not give any hints in DEBUG mode, so I am right now quite frustrated and hope somebody can help me.</p>
  
  <p>Thank you!</p>