PayPal\Service\PayPalAPIInterfaceServiceService::GetAuthDetails PHP Method

GetAuthDetails() public method

Service Call: GetAuthDetails
public GetAuthDetails ( GetAuthDetailsReq $getAuthDetailsReq, mixed $apiCredential = null ) : GetAuthDetailsResponseType
$getAuthDetailsReq PayPal\PayPalAPI\GetAuthDetailsReq
$apiCredential mixed - Optional API credential - can either be a username configured in sdk_config.ini or a ICredential object created dynamically
return PayPal\PayPalAPI\GetAuthDetailsResponseType
    public function GetAuthDetails($getAuthDetailsReq, $apiCredential = null)
    {
        $apiContext = new PPApiContext($this->config);
        $handlers = array(new PPMerchantServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION));
        $this->setStandardParams($getAuthDetailsReq->GetAuthDetailsRequest);
        $ret = new GetAuthDetailsResponseType();
        $resp = $this->call('PayPalAPIAA', 'GetAuthDetails', $getAuthDetailsReq, $apiContext, $handlers);
        $ret->init(PPUtils::xmlToArray($resp));
        return $ret;
    }

Usage Example

Example #1
0
use PayPal\Service\PayPalAPIInterfaceServiceService;
require_once '../PPBootStrap.php';
/*
 *  If a token from the SetAuthFlowParam call is specified on input, the GetAuthDetails call can return a customer's Payer ID, PayPal email address, first name, and last name. 
 */
$reqType = new GetAuthDetailsRequestType($_REQUEST['token']);
$req = new GetAuthDetailsReq();
$req->GetAuthDetailsRequest = $reqType;
$logger->info("created GetAuthDetailsRequest Object");
/*
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $getAuthDetailsResponse = $paypalService->GetAuthDetails($req);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($getAuthDetailsResponse)) {
    echo "<pre>";
    print_r($getAuthDetailsResponse);
    echo "</pre>";
    if ($getAuthDetailsResponse->Ack == 'Success') {
        $payPalURL = 'https://www.sandbox.paypal.com/webscr&cmd=_account-authenticate-logout&token=' . $token;
        echo "<a href={$payPalURL}><b>* Redirect to paypal to logout</b></a><br>";
    }
}
/*
 * Note that the GetAuthDetails call is used after you have specified a set of customer data in the SetAuthFlowParam call (in the example above, the customer name and email address), and the customer has logged into PayPal and then was redirected back to your site