$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'];
    }
}
$_SESSION['ShippingCalculationMode'] = isset($GECDResult['SHIPPINGCALCULATIONMODE']) ? $GECDResult['SHIPPINGCALCULATIONMODE'] : '';
$_SESSION['InsuranceOptionSelected'] = isset($GECDResult['INSURANCEOPTIONSELECTED']) ? $GECDResult['INSURANCEOPTIONSELECTED'] : '';
$_SESSION['ShippingOptionIsDefault'] = isset($GECDResult['SHIPPINGOPTIONISDEFAULT']) ? $GECDResult['SHIPPINGOPTIONISDEFAULT'] : '';
$_SESSION['ShippingOptionAmount'] = isset($GECDResult['SHIPPINGOPTIONAMOUNT']) ? $GECDResult['SHIPPINGOPTIONAMOUNT'] : '';