580001无效请求:{0} PayPal(PHP)

时间:2013-11-27 20:20:18

标签: php android curl paypal app-id

我正在从此页面发送用户ID和密码:https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-api-signature

AppId是我在Android应用中用来创建付款的ID:https://apps.paypal.com/user/my-account/applications

我正在使用以下功能:

function verify_paypal($payKey, $appID)
{
  global $payPalUser_Id, $payPalPassword, $payPalSig;
$headerArray = array(
'X-PAYPAL-SECURITY-USERID:'.$payPalUser_Id,
'X-PAYPAL-SECURITY-PASSWORD:'.$payPalPassword,
'X-PAYPAL-SECURITY-SIGNATURE:'.$payPalSig,
'X-PAYPAL-REQUEST-DATA-FORMAT:JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT:XML',
'X-PAYPAL-APPLICATION-ID:'.$appID
);

$url="https://svcs.paypal.com/AdaptivePayments/PaymentDetails?payKey={$payKey}&requestEnvelope.errorLanguage=en_US";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
$adaptiveResponse = curl_exec($ch);
curl_close($ch);
return $adaptiveResponse;
}

但它给出了这个错误:

<?xml version='1.0' encoding='UTF-8'?>
<ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap">
<responseEnvelope>
<timestamp>2013-11-27T14:58:07.463-08:00</timestamp>
<ack>Failure</ack>
<correlationId>d97c635f935b3</correlationId>
<build>7935900</build>
</responseEnvelope>
<error>
<errorId>580001</errorId>
<domain>PLATFORM</domain>
<subdomain>Application</subdomain>
<severity>Error</severity>
<category>Application</category>
<message>Invalid request: {0}</message>
</error>
</ns3:FaultMessage>

1 个答案:

答案 0 :(得分:5)

REQUEST-DATA-FORMAT应为NV:

$headerArray = array(
'X-PAYPAL-SECURITY-USERID:'.$payPalUser_Id,
'X-PAYPAL-SECURITY-PASSWORD:'.$payPalPassword,
'X-PAYPAL-SECURITY-SIGNATURE:'.$payPalSig,
'X-PAYPAL-REQUEST-DATA-FORMAT:NV',
'X-PAYPAL-RESPONSE-DATA-FORMAT:JSON',
'X-PAYPAL-APPLICATION-ID:'.$appID
);