这是我的php代码,请从这里找到error.code referencehttps://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/future_payments_server.md
$acces_token="A103.LhXuh7MZlAXK-4Vw6jJn9Q7m__ncsJHMDkkpUouekljaXxoNoCGNVkQanDcp9Jyt.9s7Yk5J9UoulgI3aGZNgZp3pwPy";
$Metadata_id="28c5sss8d309db24639bb1b76ca2419a850";
$data=array(
"intent"=>"authorize",
"payer"=>array(
"payment_method"=>"paypal"
),
"transactions"=>array(
array( "amount"=>array(
"currency"=>"USD",
"total"=>"1.88"
),
"description"=>"future of sauces")
));
$data_string = json_encode($data);
$ch = curl_init( "https://api.sandbox.paypal.com/v1/payments/payment" );
curl_setopt_array( $ch, array(
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'PayPal-Client-Metadata-Id: ' . $Metadata_id,
'Authorization: Bearer ' . $acces_token
),
CURLOPT_POSTFIELDS => $data_string
)
);
$result = curl_exec( $ch );
$information = curl_getinfo($ch);
curl_close($ch);
print_r($information);die;
响应是
{"name":"PERMISSION_DENIED","message":"No permission for the requested operation","information_link":"https://developer.paypal.com/docs/api/#PERMISSION_DENIED","debug_id":"4fb7372e76089"}
我相信您需要为您的应用程序启用权限才能使用未来的付款。要检查您的权限,请执行以下操作:
- 转到 http://developer.paypal.com/并登录
- 去 https://developer.paypal.com/developer/accountStatus 那里,你可以看到你有什么许可证。
您还可以在此处获取有关应用上线的一些信息:https://developer.paypal.com/docs/classic/lifecycle/goingLive/
Array ( [url] => https://api.sandbox.paypal.com/v1/payments/payment [content_type] => application/json [http_code] => 403 [header_size] => 591 [request_size] => 518 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 1.439073 [namelookup_time] => 0.178351 [connect_time] => 0.447411 [pretransfer_time] => 1.024267 [size_upload] => 153 [size_download] => 187 [speed_download] => 129 [speed_upload] => 106 [download_content_length] => 187 [upload_content_length] => 153 [starttransfer_time] => 1.438986 [redirect_time] => 0 [redirect_url] => [primary_ip] => 173.0.82.78 [certinfo] => Array ( ) [primary_port] => 443 [local_ip] => 115.112.59.164 [local_port] => 60697 [request_header] => POST /v1/payments/payment HTTP/1.1 User-Agent: User-Agent: curl/7.39.0 Host: api.sandbox.paypal.com Authorization: Bearer A103.RRu4uS7eBHp_c9ULBbKVfd6cRo6vn9p4Qw6Y5gP-DgduoyqFvUF_HY2Y0xHCeTYw.EVQISeVeN40Sa_SM9uwz4dx4EW0 PayPal-Client-Metadata-Id:d35d336b453d44a8bff1315077eb5c10 Accept: application/json Content-Type: application/json Content-Length: 153 )