Is a valid paypal email address or not (PHP)

后端 未结 3 1802
滥情空心
滥情空心 2020-12-15 02:00

I am using paypal adaptive payments and i need to verify email address from paypal api given by the store/seller, so that the payment can be directly given to store by custo

3条回答
  •  借酒劲吻你
    2020-12-15 02:42

    Yes PayPal supports this feature via the use of "GetVerifiedStatus" API where you have to input the email address , first name and the last name as the required parameter and it will return the response like below :

    Response:
    responseEnvelope.timestamp: 2014-10-01T01%3A17%3A10.081-07%3A00
    responseEnvelope.ack: Success
    responseEnvelope.correlationId: ce5a28138ca78
    responseEnvelope.build: 13068405
    accountStatus: VERIFIED
    userInfo.emailAddress: XXXXXXX
    userInfo.accountType: BUSINESS
    userInfo.accountId: XXXXXXXX
    userInfo.name.salutation: 
    userInfo.name.firstName: Eshan+Business+Test
    userInfo.name.middleName: 
    userInfo.name.lastName: Account
    userInfo.name.suffix: 
    userInfo.businessName: Eshan+New+Business+Name
    

    You can use the below php code for this :

     "en_US",
                            "emailAddress" =>"put email address to check ",
                            "firstName" =>"XXXXX",
                            "lastName" =>"XXXXXX",
                            "matchCriteria" => "NAME"
                        );
    
    // convert payload array into url encoded query string
    $body_data = http_build_query($bodyparams, "", chr(38));
    
    try
    {
        //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
    
        //parse the ap key from the response
    
        $keyArray = explode("&", $response);
    
        foreach ($keyArray as $rVal)
        {
            list($qKey, $qVal) = explode ("=", $rVal);
                $kArray[$qKey] = $qVal;
        }
    
    //print the request to screen for testing purposes
    echo "Header info:" . "
    "; print_r($params['http']['header']); echo "

    " . "Request Info:" . "
    "; print_r(urldecode($params['http']['content'])); echo "

    " . "Response:" . "
    "; //print the response to screen for testing purposes If ( $kArray["responseEnvelope.ack"] == "Success") { foreach ($kArray as $key =>$value) { echo $key . ": " .$value . "
    "; } } else { foreach ($kArray as $key =>$value) { echo $key . ": " .$value . "
    "; } } } catch(Exception $e) { echo "Message: ||" .$e->getMessage()."||"; } echo "
    "; ?>

提交回复
热议问题