我已经在我的应用中启用了未来付款权限,并使用开发人员控制面板。但是还没有生效,请查找错误。http://developer.paypal.com/并登录https://developer.paypal.com/developer/accountStatus,您可以查看您拥有的许可证。
$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();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
$headers = array(
'Content-Type: application/json',
'PayPal-Client-Metadata-Id: d6743cbb53ea4470a53bfe458f0cb885',
'Authorization: Bearer A103.B7d5318JDS6NA1zGh02avjCx16oxnBPadUat5z9SlGVGEiOhoAeMuqyz0anGSICS.FAkzECypTS1IXfemHcpVa5yyrGu',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, 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":"5b39efd4cf370"}Array
(
[url] => https://api.sandbox.paypal.com/v1/payments/payment
[content_type] => application/json
[http_code] => 403
[header_size] => 592