简体   繁体   English

PayPal支付沙箱正在授予AUTHORIZATION_ERROR

[英]PayPal payouts sandbox is giving AUTHORIZATION_ERROR

I am using PayPal payouts sandbox API. 我正在使用PayPal支付沙盒API。 In my sandbox app, payouts are enabled. 在我的沙盒应用中,付款已启用。 But when I hit the API endpoint then it gives AUTHORIZATION_ERROR although my client_id & client_secret are correct. 但是当我点击API端点时它会给出AUTHORIZATION_ERROR尽管我的client_idclient_secret是正确的。 Following is the code sample: 以下是代码示例:

function get_paypal_auth_token($client_id, $client_secret) {
    $curl = curl_init();

    curl_setopt($curl, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($curl, CURLOPT_USERPWD, $client_id.":".$client_secret);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
    $result = curl_exec($curl);
    curl_close($curl);
    return json_decode($result);
}

function create_paypal_payment($data) {
    $client_id = "XXXXXX";
    $client_secret = "XXXXXXXSECRET";
    $auth_data = get_paypal_auth_token($client_id, $client_secret);
    $url = "https://api.sandbox.paypal.com/v1/payments/payouts";
    $data_json = json_encode($data);
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer '.$auth_data->access_token));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data_json);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $resp = curl_exec($curl);
    curl_close($curl);
    return json_decode($resp);
}

The expected result of this API should be kind of related to payouts. 此API的预期结果应与付款相关。

Also, I try it with another account's credentials then it gives INSUFFICIENT_FUNDS error. 此外,我尝试使用其他帐户的凭据,然后它给出了INSUFFICIENT_FUNDS错误。

So can anyone please tell how to add balance to my PayPal account? 那么有人可以告诉我如何为我的PayPal帐户添加余额吗?

Follow these steps to add money in your sandbox account 请按照以下步骤在sandbox account添加资金

  1. Login to your Paypal sandbox using your sandbox account. 使用您的沙箱帐户登录您的Paypal沙箱。
  2. Click My Account –> Add Money 单击我的帐户 - >添加资金
  3. Click the type of account 单击帐户类型
  4. Enter the amount 输入金额

Do you get this error only sometimes? 你有时会得到这个错误吗? I think their sandbox is experiencing issues, as my system also gets this error about 50% of the time since a couple of days ago. 我认为他们的沙箱遇到了问题,因为我的系统在几天前的大约50%的时间内也会出现此错误。 You can try sending a direct request to their servers to confirm this. 您可以尝试向其服务器发送直接请求以进行确认。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM