2017-04-24 85 views
1

寶:無法重新授權認可的付款貝寶:無法重新授權認可的付款錯誤:發生內部服務錯誤

下面是我的代碼

$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 
    } 
} 

它給下面的錯誤

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 
) 

https://developer.paypal.com/docs/api/payments/#authorization_reauthorize

我失蹤了。我在WAMP上面運行代碼。

由於百付寶:

三天的榮譽授權期限到期後,可以重新授權支付。

回答

0

它看起來像授權ID已經重新授權,仍然在榮譽期內。因此PayPal不允許重新授權。榮譽期滿後,您可以再試一次。

+0

3天的榮譽時期已經過期與它沒有重新授權 –

+0

授權標識已經重新授權和重新授權ID還在裏面的榮譽期。 –

+0

如何檢查授權ID是否已被重新授權? –

0

添加

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

HTTPS鏈接,可能與您的問題

+0

的上述代碼問題沒有。它仍然給人同樣的錯誤:( –

+0

嘗試 curl_setopt($ CH,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ CH,CURLOPT_SSL_VERIFYHOST,假); 在兩個curl_init() –

+0

嘗試同樣的錯誤@Anyone_ph –