PayPal 计费计划密钥响应错误

PayPal Billing Plan Key Response Error

function testing(){  
         $headers_array_sub_new = array("X-PAYPAL-SECURITY-USERID" => 'testing',
        "X-PAYPAL-SECURITY-PASSWORD" => '12345645',
        "X-PAYPAL-SECURITY-SIGNATURE" => 'Ab2145sdfd-IhWqUntNLtS4AWDawDzjOUVWjw6nXIcMtyOrkmDu',
        "X-PAYPAL-APPLICATION-ID" => 'APP-80W284485P519543T',
        "X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
        "X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON",
        "Authorization" =>array('clientId'=>'testing','secret'=>'testing'),
        "Accept" =>'application/json',
             );
  $url = "https://api.sandbox.paypal.com/v1/payments/billing-plans";

       $subscriptionplan = array(

             'name'=>'T shirt Plan',
             'description'=> 'welcome plan',
             'type'=> 'INFINITE' ,
             'payment_definitions'=>array('name'=>'welcome','type'=>'REGULAR','frequency_interval'=>'2','frequency'=>'Month','cycles'=>'10','amount'=>'100'),
             'merchant_preferences'=>''
    );

$pay_result_trial = wp_remote_request($url, array('method' => 'POST', 'timeout' => 20, 'headers' => $headers_array_sub_new, 'body' => $subscriptionplan)); 
//$pay_result_trial2 = wp_remote_request($url2, array('method' => 'POST', 'timeout' => 20, 'headers' => $headers_array_sub1, 'body' =>$subscriptionplan)); 
var_dump($pay_result_trial);

这里是响应错误

array(5) { ["headers"]=> array(7) { ["server"]=> string(17) "Apache-Coyote/1.1" ["proxy_server_info"]=> string(57) "host=slcsbplatformapiserv3002.slc.paypal.com;threadId=322" ["paypal-debug-id"]=> string(13) "c764b1af30167" ["content-type"]=> string(16) "application/json" ["content-length"]=> string(1) "0" ["date"]=> string(29) "Fri, 20 Mar 2015 05:25:30 GMT" ["connection"]=> string(5) "close" } ["body"]=> string(0) "" ["response"]=> array(2) { ["code"]=> int(401) ["message"]=> string(12) "Unauthorized" } ["cookies"]=> array(0) { } ["filename"]=> NULL ?>



}

谁能帮帮我?

您没有使用正确的通话凭据。您正在使用用于经典 API 的 API User/Pwd/Signature。您尝试使用的计费计划是 RESTful API 的一部分,它使用客户端 ID 和客户端密码的标准 oAuth 凭据。可以在 here 找到 REST API 参考,其中包含有关 Authentication/Headers 的信息以及其他有用的信息。