paypal php credit card payment returns 401 -


i'm trying make credit card payment via paypal rest api services, can grab access token, every time try make credit card payment 401.

my sample works perfect on .net not on php. please advice

$json = '{"intent":"sale","redirect_urls":{"return_url":"","cancel_url":""},"payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4417119669820331","type":"visa","expire_month":11,"expire_year":2018,"cvv2":"874","first_name":"betsy","last_name":"buyer","billing_address":{"line1":"111 first street","city":"saratoga","state":"ca","postal_code":"95070","country_code":"us"}}}]},"transactions":[{"amount":{"total":"200","currency":"usd"},"description":"credit card payment - $200"}]}';  $url = "https://api.sandbox.paypal.com/v1/payments/payment"; $accesstoken = getaccesstoken(); echo "bearer ".$accesstoken; echo "<br><br>"; $headers = array("authorization" => "bearer ".$accesstoken, "content-type" => "text/json", "content-length" =>strlen($json));  $handle = curl_init($url);   curl_setopt($handle,curlopt_httpheader,$headers);    curl_setopt($handle, curlopt_post, true); curl_setopt($handle, curlopt_postfields, $json); curl_setopt($handle, curlopt_returntransfer, 1);  curl_setopt($handle, curlopt_ssl_verifypeer, false); $response   = curl_exec($handle); $info = curl_getinfo($handle); $error= curl_error ( $handle ); curl_close($handle);  var_dump($info); echo "<br><br>"; var_dump($error); echo "<br><br>"; var_dump($response); 

full sample here https://dl.dropboxusercontent.com/u/3517813/index.php

i able process changing $headers line to:

$headers = array("content-type: application/json", "authorization: bearer " . $accesstoken);


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -