title: Errors When Making a Stripe Charge using Custom cURL and PHP Code
body: <p>After doing 3 days of solid research and trying my absoloute best to resolve the issue in hand, Ive become to the point of no success and have had to realise maybe this is something i should have not tried to attempt! On Failing with my own personal attempts i have had to turn to you experts in need of some advice and help along my beginner learning stage.</p>
  
  <p>I have tried to use the PHP code supplied by stripe however due to the complex custom form we use in our website and also alot of our website traffic comes internally we need a way to send payments to stripe easiser than integrating a whole new php payment process that can handle the payments from internal clients as well so i thought i knew a little cURL due to using several cURL and PHP API Calls already within the website process.</p>
  
  <p>The cURL i have tried for stripe is as follows:</p>
  
  <hr>
  
  <pre><code>    $headers = array(
      'Authorization: Bearer sk_test_my_test_key_here',
  );
  $ch = curl_init("https://api.stripe.com/v1/charges -H Content-Type=application/x-www-form-urlencoded -u sk_test_my_test_key: -d source[object]=card -d source[number]=4242424242424242 -d source[exp_month]=08 -d source[exp_year]=18 -d source[cvc]=123 -d amount=250 -d currency=gbp -d description=Testing ");
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $response = curl_exec($ch);
  echo $response;
  curl_close($ch);
  </code></pre>
  
  <hr>
  
  <p>{ "error": { "type": "invalid_request_error", "message": "Unrecognized request URL (POST: /v1/charges%20-H%20Content-Type=application/x-www-form-urlencoded%20-u%20sk_test_keyP:%20-d%20source[object]=card%20-d%20source[number]=4242424242424242%20-d%20source[exp_month]=08%20-d%20source[exp_year]=18%20-d%20source[cvc]=123%20-d%20amount=250%20-d%20currency=gbp%20-d%20description=Testing). Please see <a href="https://stripe.com/docs" rel="nofollow">https://stripe.com/docs</a> or we can help at <a href="https://support.stripe.com/" rel="nofollow">https://support.stripe.com/</a>." } }</p>
  
  <hr>
  
  <p>I have tried to read up on the documentation, but nothing explains about the errors i get, I think the biggest part of the problem is im not experienced enough to know exactly what to research and the key-phrases experts like you would know to look up.</p>
  
  <hr>
  
  <p>i have tried with and without the <code>-H Content-Type included</code>and still get the same issue however if i was to copy and paste the curl into the command line and execute it from a command using </p>
  
  <pre><code>curl.exe https://...................
  </code></pre>
  
  <p>then the message is successful and i get the response i want back to say the card has been charged.</p>
  
  <pre><code>also tried  `$string = rawurlencode($data) and then http_build_query` on the $string
  </code></pre>
  
  <p>Here is enough example i have tried:</p>
  
  <pre><code>&lt;?php
  $headers = array(
      'Authorization: Bearer sk_test_removed_for_stackoverflow',
  );
  
  // create curl resource 
  $ch = curl_init(); 
  
  // set url 
  curl_setopt($ch, CURLOPT_URL, "https://api.stripe.com/v1/charges -u sk_test_removed: -d source[object]=card -d source[number]=4242424242424242 -d source[exp_month]=08 -d source[exp_year]=18 -d source[cvc]=123 -d amount=250 -d currency=gbp -d description=Test "); 
  </code></pre>
  
  <p>also tried it like this:</p>
  
  <pre><code>// set url 
  curl_setopt($ch, CURLOPT_URL, "https://api.stripe.com/v1/charges -u sk_test_removed: -d source[object]=$card -d source[number]=$number -d source[exp_month]=$expdate -d source[exp_year]=$expmonth -d source[cvc]=$ccv -d amount=$amount -d currency=gbp -d description=$sale "); 
  
  // set headers
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  
  //return the transfer as a string 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  
  // $output contains the output string 
  $output = curl_exec($ch); 
  print($output);
  
  // close curl resource to free up system resources 
  curl_close($ch);
  ?&gt;
  </code></pre>
  
  <p>I am now honestly at a lost end, I would be extreamly greatfull for anyone to be able to assist me and help me on this issue, After 3 hard painfull days i really don't know what to do.</p>
  
  <p>As a novice learner it is very hard knowing exactly what to search for when doing re-search on the issues. I have spent 3 days on google with 2 warning messages saying they think i was sending automated query's as a result of how many times if done research!! So any advice and help really would go a long way on this.</p>
  
  <p>Thanks All.</p>