【问题标题】:PayPal Billing Plan Key Response ErrorPayPal 计费计划密钥响应错误
【发布时间】:2015-05-23 12:22:49
【问题描述】:
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 ?>



}

谁能帮帮我?

【问题讨论】:

  • 具体说明您的要求
  • 401 Unauthorized...再次检查您的凭据

标签: php wordpress paypal woocommerce paypal-rest-sdk


【解决方案1】:

您没有为通话使用正确的凭据。您正在使用用于经典 API 的 API 用户/密码/签名。您尝试使用的计费计划是 RESTful API 的一部分,这些 API 使用客户端 ID 和客户端密码的标准 oAuth 凭据。可以在 here 找到 REST API 参考,其中包含有关身份验证/标头的信息以及其他有用信息。

【讨论】:

  • 我正在尝试请求标头(即 $headers_array_sub_new = array('clientId'=>'xxxxxxxxxxxxxxxxxxxxxxxxxxx', 'secret'=>'xxxxxxxxxxxxxxxxxxxxxxxxxx','Accept'=>'application/json ');
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-15
  • 2017-10-11
  • 2019-03-11
  • 1970-01-01
  • 2018-12-21
  • 2017-02-07
  • 2017-06-21
相关资源
最近更新 更多