php - Validate Paypal Live Account -
i validating email address using following code :
$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 validate "matchcriteria" => "none" ); // convert payload array url encoded query string $body_data = http_build_query($bodyparams, "", chr(38)); //create request , 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 stream , send request $response = stream_get_contents($fp); //get response //check see if stream open if ($response === false) { throw new exception("php error message = " . "$php_errormsg"); } fclose($fp); //close stream $keyarray = explode("&", $response); foreach ($keyarray $rval) { list($qkey, $qval) = explode ("=", $rval); $karray[$qkey] = $qval; } if( $karray["responseenvelope.ack"] == "success") { // nothing } else { // error }
however code works sandbox account. changes make validate paypal account. appreciated.
three things
getverifiedstatus
api requires adaptive payment application approved "getverifiedstatus" feature enabled.- you need submit application(with
getverifiedstatus
checkbox enabled, application approved @ www.paypal-apps.com app-id - change endpoint https://svcs.paypal.com/adaptiveaccounts/getverifiedstatus
p.s
account should business/premier verified account
Comments
Post a Comment