PayPal API - Verify that an account is valid / exists / verified

Jordan picture Jordan · Dec 13, 2013 · Viewed 16.1k times · Source

Has anyone been able to verify the validity of a PayPal account only by the email address?

AdaptiveAccounts GetVerifiedStatus (in PayPal's own words) is only for use by their key strategic customers (see below), and I cannot find any other way to check based on an email address whether an account exists and is verified.

Even doing a valid NAME search with all fields supplied doesn't work, try it for yourself:

https://devtools-paypal.com/apiexplorer/AdaptiveAccounts

I've been using their Adaptive Payments for quite some time and am constantly surprised at how many of our sellers manage to wrongly enter their PayPal account into our site.

It seems PayPal is happy to provide services to take our payments and commissions but not willing to provide a core and very basic function to be able to verify receivers before processing.

PayPal Support response to my query to them:

The only API we have for seeing if a PayPal account is Verified is the GetVerifiedStatus API. The value of NONE for matchCriteria is supported but only for very large strategic partners and/or actual Financial Institutions. Our App Review team has strict requirements for providing access to that value. Unfortunately we don't have any API currently that will simply tell you if the email address is confirmed on an account.

Thank you for your patience.

Hopefully there some sort of hack someone else has managed to work out to perform this function??

Answer

Sunil Sharma picture Sunil Sharma · Jul 27, 2017
<?php
// create a new cURL resource
$ch = curl_init();

$ppUserID = "******************"; //Take it from   sandbox dashboard for test mode or take it from paypal.com account in production mode, help: https://developer.paypal.com/docs/classic/api/apiCredentials/
$ppPass = "*************"; //Take it from sandbox dashboard for test mode or take it from paypal.com account in production mode, help: https://developer.paypal.com/docs/classic/api/apiCredentials/
$ppSign = "********************"; //Take it from sandbox dashboard for test mode or take it from paypal.com account in production mode, help: https://developer.paypal.com/docs/classic/api/apiCredentials/
$ppAppID = "***********"; //if it is sandbox then app id is always: APP-80W284485P519543T
$sandboxEmail = "********************"; //comment this line if you want to use it in production mode.It is just for sandbox mode

$emailAddress = "[email protected]"; //The email address you wana verify

//parameters of requests
$nvpStr = 'emailAddress='.$emailAddress.'&matchCriteria=NONE';

// RequestEnvelope fields
$detailLevel    = urlencode("ReturnAll");
$errorLanguage  = urlencode("en_US");
$nvpreq = "requestEnvelope.errorLanguage=$errorLanguage&requestEnvelope.detailLevel=$detailLevel&";
$nvpreq .= "&$nvpStr";
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

$headerArray = array(
"X-PAYPAL-SECURITY-USERID:$ppUserID",
"X-PAYPAL-SECURITY-PASSWORD:$ppPass",
"X-PAYPAL-SECURITY-SIGNATURE:$ppSign",
"X-PAYPAL-REQUEST-DATA-FORMAT:NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT:JSON",
"X-PAYPAL-APPLICATION-ID:$ppAppID",
"X-PAYPAL-SANDBOX-EMAIL-ADDRESS:$sandboxEmail" //comment this line in production mode. IT IS JUST FOR SANDBOX TEST 
);

$url="https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
$paypalResponse = curl_exec($ch);
//echo $paypalResponse;   //if you want to see whole PayPal response then uncomment it.
curl_close($ch);

echo $data = json_decode($paypalResponse);



?>