Php Paypal:无法重新授权授权支付错误:发生内部服务错误

Php Paypal:无法重新授权授权支付错误:发生内部服务错误,php,curl,paypal,payment,payment-method,Php,Curl,Paypal,Payment,Payment Method,贝宝:无法重新授权授权付款 下面是我的代码 $clientId = 'XXXXX'; $secret = 'XXXX'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, true); curl_seto

贝宝:无法重新授权授权付款

下面是我的代码

$clientId = 'XXXXX';
$secret = 'XXXX';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId . ":" . $secret);
$result = curl_exec($ch);

if (empty($result)) {
    die("Error: No response.");
} else {
    $json = json_decode($result);
    //echo "<pre>";
    //print_r($json);
    //exit;
    $token_type = $json->token_type;
    $access_token = $json->access_token;
    $nonce = $json->nonce;

    //echo "Authorization: " . $token_type . " " . $access_token;

    if (!empty($token_type) && !empty($access_token)) {

        // START REAUTHORIZE PAYMENT
        $authorizationId = 'AF998724VR277443T';
        $currency = 'USD';
        $amount = '20.00';
        $data = '{
                    "amount": {
                    "total": "' . $amount . '",                     
                    "currency": "' . $currency . '"

                    }
                };';


        $ch1 = curl_init();
        curl_setopt($ch1, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/authorization/" . $authorizationId . "/reauthorize");
        curl_setopt($ch1, CURLOPT_POST, true);
        curl_setopt($ch1, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch1, CURLOPT_HTTPHEADER, array(
            "Content-Type: application/json",
            "Authorization: " . $token_type . " " . $access_token,
            "Content-length: " . strlen($data))
        );

        $result1 = curl_exec($ch1);
        if (empty($result1)) {
            die("Error: No response.");
        } else {
            $json1 = json_decode($result1);
            echo "<pre>";
            print_r($json1);
            exit;
            //echo $json1->id;
        }
        // END REAUTHORIZE PAYMENT
    }
}

我错过了什么。我在WAMP上运行上述代码

根据贝宝:


三天荣誉期授权到期后,您可以重新授权付款。

看起来授权id已经重新授权,仍在荣誉期内。因此,贝宝不允许重新授权。您可以在荣誉期到期后重试。

添加


HTTPS链接,可能与您的问题有关

授权id已重新授权,且重新授权的id仍在荣誉期内。请与Paypal联系,已重新授权。但是上面的代码仍然存在问题,没有给出resultTry curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);在两个curl_init()中
stdClass Object
(
    [name] => INTERNAL_SERVICE_ERROR
    [message] => An internal service error occurred.
    [information_link] => https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR
    [debug_id] => b220155a9c70e
)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);