title: PAYPAL - curl request
body: <p><p>Hi,
  <p>After finally and successfully have gotten an authorization token from <a href="https://api.sandbox.paypal.com/v1/oauth2/token" rel="nofollow">https://api.sandbox.paypal.com/v1/oauth2/token</a>, now I need to construct a payment object.</p>
  
  <p>Paypal suggests the following code:</p>
  
  <pre><code>curl -v https://api.sandbox.paypal.com/v1/payments/payment
  -H "Content-Type:application/json"
  -H "Authorization:Bearer A015Mw6GQ5z3CtAUWFdzTISeW7KJcA4s0dssTXavN.N7djY"
  -d '{
          "transactions": [{
          "amount": {
              "currency":"USD",
              "total":"12"
          },
          "description":"creating a payment"
          }],
          "payer": {
              "payment_method":"paypal"
          },
          "intent":"sale",
          "redirect_urls": {
              "cancel_url":"https://devtools-paypal.com/guide/pay_paypal/curl?cancel=true",
              "return_url":"https://devtools-paypal.com/guide/pay_paypal/curl?success=true"
          }
     }'
  </code></pre>
  
  <p>My PHP code is:</p>
  
  <pre><code>$ch = curl_init();
  $token = "A015Mw6GQ5z3CtAUWFdzTISeW7KJcA4s0dssTXavN.N7djY";
  $data = '{
          "transactions": [{
          "amount": {
              "currency":"USD",
              "total":"12"
          },
          "description":"creating a payment"
          }],
          "payer": {
              "payment_method":"paypal"
          },
          "intent":"sale",
          "redirect_urls": {
              "cancel_url":"http://myurl.com/cancel.php",
              "return_url":"http://myurl.com/return.php"
          }
     }';
  curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
  curl_setopt($ch, CURLOPT_VERBOSE, true);
  curl_setopt($ch, CURLOPT_HEADER, "Content-Type:application/json");
  curl_setopt($ch, CURLOPT_HEADER, "Authorization:Bearer ".$token);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  
  $result = curl_exec($ch);
  $json = json_decode($result, TRUE); // 'true' converts it to an array
  print_r($json);
  curl_close($ch);
  </code></pre>
  
  <p><p>It returns no json data. Am I doing something wrong?
  <p>Thanks</p>