验证Paypal真实账户

时间:2015-09-21 06:37:17

标签: php paypal

我正在使用以下代码验证电子邮件地址:

$url = trim("https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus");         

$API_UserName = ""; 
$API_Password = ""; 
$API_Signature = "";
$API_AppID = "";                                       
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";

//Create request payload 
$bodyparams = array (   "requestEnvelope.errorLanguage" => "en_US",
                        "emailAddress" => $email, // email to be validate
                        "matchCriteria" => "NONE"
                    );

// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));

//create request and add headers
$params = array("http" => array( 
                            "method" => "POST",
                            "content" => $body_data,
                            "header" => "X-PAYPAL-SECURITY-USERID:     " . $API_UserName . "\r\n" .
                                        "X-PAYPAL-SECURITY-SIGNATURE:  " . $API_Signature . "\r\n" .
                                        "X-PAYPAL-SECURITY-PASSWORD:   " . $API_Password . "\r\n" .
                                        "X-PAYPAL-APPLICATION-ID:      " . $API_AppID . "\r\n" .
                                        "X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
                                        "X-PAYPAL-RESPONSE-DATA-FORMAT:" . $API_ResponseFormat . "\r\n" 
                   ));


$ctx = stream_context_create($params);  //create stream context
$fp = @fopen($url, "r", false, $ctx);   //open the stream and send request
$response = stream_get_contents($fp);   //get response

//check to see if stream is open
if ($response === false) 
{
throw new Exception("php error message = " . "$php_errormsg");
}

fclose($fp);    //close the stream

$keyArray = explode("&", $response);

foreach ($keyArray as $rVal)
{
list($qKey, $qVal) = explode ("=", $rVal);
    $kArray[$qKey] = $qVal;
}

if( $kArray["responseEnvelope.ack"] == "Success") 
{
    // do nothing
}
else 
{
    // error 
}

但是此代码适用于沙盒帐户。我对paypal帐户进行了哪些更改。 任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:3)

https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus 这是沙盒链接将其更改为真实帐户链接。多数民众赞成。

答案 1 :(得分:2)

三件事

P.S您的帐户应为商家/首要已验证帐户