title: PayPal PHP Sandbox Header Auth?
body: <p>I am currently facing some problems during my paypal refund test.</p>
  
  <p>I get the token of the account by making this:</p>
  
  <pre><code> public function __construct(){
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
      curl_setopt($ch, CURLOPT_HEADER, false);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
      curl_setopt($ch, CURLOPT_USERPWD, $this-&gt;clientID.":".$this-&gt;secret);
      curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
  
      $result = curl_exec($ch);
      $json = json_decode($result);
  
      $this-&gt;auth = $json-&gt;access_token;
  
     // echo "Auth?" . $this-&gt;auth;
  
   }
  </code></pre>
  
  <p>And when i try refund a sale, it just returns 1 nomatter what. The transaction ID is correct, but it's like it doesn't set the right headers - can someone help me?</p>
  
  <pre><code> public function RefundSale($transaction_id){
       $url = self::getPath() . "/payments/sale/".$transaction_id."/refund";
       echo "URL:" . $url;
       self::rest($url);
   }
  
   public function rest($url,$data=""){
  
      $ch = curl_init();
  
      if ( !empty($data)): $data=json_encode($data); endif; //Array to json?
  
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_POST, true);
      if ( !empty($data)): curl_setopt($ch, CURLOPT_POSTFIELDS, $data); endif;
       curl_setopt($ch, CURLOPT_USERPWD, $this-&gt;clientID . ":" . $this-&gt;secret);
      $result = curl_exec($ch);
  
      var_dump($result);
   }
  </code></pre>