* Here we'll pull out data from the PayPal response.
     * Refer to the PayPal API Reference for all of the variables available
     * in $PayPalResult['variablename']
     *
     * https://developer.paypal.com/docs/classic/api/merchant/GetExpressCheckoutDetails_API_Operation_NVP/
     *
     * Again, Express Checkout allows for parallel payments, so what we're doing here
     * is usually the library to parse out the individual payments using the GetPayments()
     * method so that we can easily access the data.
     *
     * We only have a single payment here, which will be the case with most checkouts,
     * but we will still loop through the $Payments array returned by the library
     * to grab our data accordingly.
     */
    $_SESSION['paypal_payer_id'] = isset($PayPalResult['PAYERID']) ? $PayPalResult['PAYERID'] : '';
    $_SESSION['phone_number'] = isset($PayPalResult['PHONENUM']) ? $PayPalResult['PHONENUM'] : '';
    $_SESSION['email'] = isset($PayPalResult['EMAIL']) ? $PayPalResult['EMAIL'] : '';
    $_SESSION['first_name'] = isset($PayPalResult['FIRSTNAME']) ? $PayPalResult['FIRSTNAME'] : '';
    $_SESSION['last_name'] = isset($PayPalResult['LASTNAME']) ? $PayPalResult['LASTNAME'] : '';
    $payments = $PayPal->GetPayments($PayPalResult);
    /**
     * We do not need our final review page for this Digital Goods
     * checkout because no shipping or any additional amounts are
     * involved.  As such, we'll simply redirect straight to our
     * DoExpressCheckoutPayment.php page to finalize the payment.
     */
    header('Location: DoExpressCheckoutPayment.php');
} else {
    $_SESSION['paypal_errors'] = $PayPalResult['ERRORS'];
    header('Location: /demo/error.php');
}
<?php

require_once '../includes/config.php';
require_once '../autoload.php';
$PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature);
$PayPal = new angelleye\PayPal\PayPal($PayPalConfig);
/*
 * Here we call GetExpressCheckoutDetails to obtain payer information from PayPal
 */
$GECDResult = $PayPal->GetExpressCheckoutDetails($_SESSION['SetExpressCheckoutResult']['TOKEN']);
$GECDResult_Payments = $PayPal->GetPayments($GECDResult);
foreach ($GECDResult_Payments as $Payment) {
    // Gather required data for this payment.
    $_SESSION['ShipToName'] = isset($Payment['SHIPTONAME']) ? $Payment['SHIPTONAME'] : '';
    $_SESSION['ShipToStreet'] = isset($Payment['SHIPTOSTREET']) ? $Payment['SHIPTOSTREET'] : '';
    $_SESSION['ShipToStreet2'] = isset($Payment['SHIPTOSTREET2']) ? $Payment['SHIPTOSTREET2'] : '';
    $_SESSION['ShipToCity'] = isset($Payment['SHIPTOCITY']) ? $Payment['SHIPTOCITY'] : '';
    $_SESSION['ShipToState'] = isset($Payment['SHIPTOSTATE']) ? $Payment['SHIPTOSTATE'] : '';
    if (strlen($_SESSION['ShipToState']) > 2) {
        $_SESSION['ShipToState'] = $PayPal->GetStateCode($_SESSION['ShipToState']);
    }
    $_SESSION['ShipToPostalCode'] = isset($Payment['SHIPTOZIP']) ? $Payment['SHIPTOZIP'] : '';
    $_SESSION['ShipToCountryCode'] = isset($Payment['SHIPTOCOUNTRYCODE']) ? $Payment['SHIPTOCOUNTRYCODE'] : '';
    $_SESSION['ShipToCountryName'] = isset($Payment['SHIPTOCOUNTRYNAME']) ? $Payment['SHIPTOCOUNTRYNAME'] : '';
    $_SESSION['ShipToPhoneNumber'] = isset($Payment['SHIPTOPHONENUM']) ? $Payment['SHIPTOPHONENUM'] : '';
    $_SESSION['ShipToAddressStatus'] = isset($Payment['ADDRESSSTATUS']) ? $Payment['ADDRESSSTATUS'] : '';
    $_SESSION['CustomerNotes'] = isset($Payment['NOTETEXT']) ? $Payment['NOTETEXT'] : '';
    if ($_SESSION['ShipToCountryCode'] != 'US' && $_SESSION['ShipToState'] == '') {
        $_SESSION['ShipToState'] = $_SESSION['ShipToCountryCode'];
    }
}