dqknycyt92288 2019-05-15 06:26
浏览 322

PayPal支付沙箱正在授予AUTHORIZATION_ERROR

I am using PayPal payouts sandbox 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. 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.

Also, I try it with another account's credentials then it gives INSUFFICIENT_FUNDS error.

So can anyone please tell how to add balance to my PayPal account?

  • 写回答

4条回答 默认 最新

  • dongwen7813 2019-05-15 06:28
    关注

    Follow these steps to add money in your sandbox account

    1. Login to your Paypal sandbox using your sandbox account.
    2. Click My Account –> Add Money
    3. Click the type of account
    4. Enter the amount
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法