我正在努力集成 PayPal 的 AdaptivePayment API,但每次调用时,我都会收到从 CURL 调用返回的错误“内部服务器错误。请检查服务器日志以获取详细信息”。我相信我拥有所有必需的 header 。其他人遇到过这个问题吗?我的代码如下:
$appID = "APP-80W284485P519543T";
$username = "***********";
$password = "***********";
$signature = "**********";
$endpoint = "https://svcs.sandbox.paypal.com/AdaptivePayments/";
$headers = array(
"X-PAYPAL-SECURITY-USERID: " . $username,
"X-PAYPAL-SECURITY-PASSWORD: ". $password,
"X-PAYPAL-SECURITY-SIGNATURE: ". $signature,
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-APPLICATION-ID: ". $appID
);
$packet = array(
"actionType" => "PAY",
"currencyCode" => "USD",
"cancelUrl" => "cancel.html",
"returnUrl" => "success.html",
"receiverList" => array(
"receiver" => array(
array(
"amount" => "1.00",
"email" => "example@gmail.com",
"primary" => true
),
array(
"amount" => "0.50",
"email" => "example2@gmail.com",
"primary" => false
)
)
),
"requestEnvelope" => array(
"errorLanguage" => "en_US"
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint."PAY");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//turning off the server and peer verification(TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($packet));
$response = curl_exec($ch);
if (curl_errno($ch))
{
// moving to display page to display curl errors
echo curl_errno($ch);
echo curl_error($ch);
//Execute the Error handling module to display errors.
}
else
{
echo "RESPONSE";
header('Content-Type: application/json');
echo $response;
curl_close($ch);
}
最佳答案
您的端点 URL 错误,应该是:
$endpoint = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay";
关于php - 什么会导致 PayPal Adaptive Payments API 返回 "internal server error. please check the server logs for details"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34399492/