public function getEC() { $this->set_credentials(); //Here we call GetExpressCheckoutDetails to obtain payer information from PayPal $PayPalConfig = array('Sandbox' => $this->payment_mode, 'APIUsername' => trim($this->api_username), 'APIPassword' => trim($this->api_password), 'APISignature' => trim($this->api_signature), 'APIVersion' => '97.0', 'APISubject' => '', 'PrintHeaders' => false, 'LogResults' => false, 'LogPath' => ''); $PayPal = new angelleye\PayPal\PayPal($PayPalConfig); $GECDResult = $PayPal->GetExpressCheckoutDetails($this->_token); return $GECDResult; }
* Include our config file and the PayPal library. */ require_once '../../includes/config.php'; require_once '../../vendor/angelleye/paypal-php-library/autoload.php'; /** * Setup configuration for the PayPal library using vars from the config file. * Then load the PayPal object into $PayPal */ $PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature, 'PrintHeaders' => $print_headers, 'LogResults' => $log_results, 'LogPath' => $log_path); $PayPal = new angelleye\PayPal\PayPal($PayPalConfig); /** * Now we pass the PayPal token that we saved to a session variable * in the SetExpressCheckout.php file into the GetExpressCheckoutDetails * request. */ $PayPalResult = $PayPal->GetExpressCheckoutDetails($_SESSION['paypal_token']); /** * Now we'll check for any errors returned by PayPal, and if we get an error, * we'll save the error details to a session and redirect the user to an * error page to display it accordingly. * * If the call is successful, we'll save some data we might want to use * later into session variables. */ if ($PayPal->APICallSuccessful($PayPalResult['ACK'])) { /** * 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/
<?php // Include required library files. require_once '../includes/config.php'; require_once '../autoload.php'; // Create PayPal object. $PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature, 'PrintHeaders' => $print_headers, 'LogResults' => $log_results, 'LogPath' => $log_path); $PayPal = new angelleye\PayPal\PayPal($PayPalConfig); // Pass data into class for processing with PayPal and load the response array into $PayPalResult $Token = ''; $PayPalResult = $PayPal->GetExpressCheckoutDetails($Token); $PhoneNumber = $PayPalResult['PHONENUM']; // Write the contents of the response array to the screen for demo purposes. echo '<pre />'; print_r($PayPalResult);
<?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']; } }