/**
  * Returns the PayPal public certificate filename.
  *
  * @param string The environment to get the certificate for.
  * @return mixed The path and file of the certificate file, or a PayPal error object on failure.
  */
 function getPayPalCertificateFile($environment)
 {
     $package_root = PayPal::getPackageRoot();
     $cert = $package_root . '/cert/' . strtolower($environment) . '.paypal.com.pem';
     if (@(include "{$package_root}/conf/paypal-sdk.php")) {
         if (isset($__PP_CONFIG['paypal_cert_file']) && !empty($__PP_CONFIG['paypal_cert_file'])) {
             $cert = $__PP_CONFIG['paypal_cert_file'][$environment];
         }
     }
     if (!file_exists($cert)) {
         return PayPal::raiseError("Could not file Paypal public Certificate file '{$cert}'");
     }
     return $cert;
 }
Example #2
0
 /**
  * Get information describing all types provided by the SDK.
  * @static
  */
 function getTypeList()
 {
     $root_dir = PayPal::getPackageRoot();
     $types = "{$root_dir}/Type/*.php";
     $files = glob($types);
     if (count($files) < 2) {
         return PayPal::raiseError("Types not found in package! (Looked for '{$types}')");
     }
     $retval = array();
     foreach ($files as $type_files) {
         $retval[] = basename(substr($type_files, 0, strpos($type_files, '.')));
     }
     return $retval;
 }
Example #3
0
 /**
  * Gets the PEAR Log object to use.
  *
  * @return Log  A Log object, either provided by the user or
  *              created by this function.
  */
 function &getLogger()
 {
     if (!$this->_logger) {
         $file = $this->_logDir . '/' . date('Ymd') . '.PayPal.log';
         if (is_link($file) || file_exists($file) && !is_writable($file)) {
             // Don't overwrite symlinks.
             return PayPal::raiseError('bad logfile');
         }
         $this->_logger =& Log::singleton('file', $file, $this->_profile->getAPIUsername(), array('append' => true));
     }
     return $this->_logger;
 }
Example #4
0
 /**
  * Validates the profile data currently loaded before use.
  *
  * @return mixed true if the data is valid, or a PayPal_Error object on failure.
  */
 function validate()
 {
     // Either certificate or signature or UNI pay is required
     if (empty($this->_subject)) {
         if (empty($this->_username) || empty($this->_password) || empty($this->_certificateFile) && empty($this->_signature) || empty($this->_environment)) {
             return PayPal::raiseError("API Username, Password, Certificate File and Environment must all be set");
         }
         if (!empty($this->_certificateFile) && !file_exists($this->_certificateFile)) {
             return PayPal::raiseError("Could not find certificate file '{$this->_certificateFile}'");
         }
         if (!in_array(strtolower($this->_environment), $this->_validEnvironments, true)) {
             return PayPal::raiseError("Environment '{$this->_environment}' is not a valid environment.");
         }
     }
     return true;
 }
Example #5
0
 /**
  * Set the Merchant private key file
  *
  * @param string The Merchant Private Key File
  * @return mixed True on success, a PayPal error object on faliure
  */
 function setPrivateKeyFile($filename)
 {
     if (!file_exists($filename)) {
         return PayPal::raiseError("The private key '{$filename}' does not exist");
     }
     $this->_privateKeyFile = $filename;
     return true;
 }
Example #6
0
 /**
  * Set the environment associated with this profile.
  *
  * @param string True on success, a Paypal error object on failure
  */
 function setEnvironment($environment)
 {
     $environment = strtolower($environment);
     $envs = $this->getValidEnvironments();
     if (PayPal::isError($envs)) {
         return $envs;
     }
     if (in_array($environment, $envs)) {
         $this->_environment = $environment;
         return true;
     }
     return PayPal::raiseError("Invalid Environment Specified");
 }
Example #7
0
 /**
  * Validates the profile data currently loaded before use.
  *
  * @return mixed true if the data is valid, or a PayPal_Error object on failure.
  */
 function validate()
 {
     // certificate or signature or UNI pay op permissioning is required
     if (empty($this->_subject) && (empty($this->_authSignature) && empty($this->_authToken) && empty($this->_authTimestamp))) {
         if (empty($this->_username) || empty($this->_password) || empty($this->_certificateFile) && empty($this->_signature) || empty($this->_environment)) {
             return PayPal::raiseError("API Username, Password, Certificate File and Environment must all be set or auth token,auth signature and auth timestamp must be set");
         }
         if (!empty($this->_certificateFile) && !file_exists($this->_certificateFile)) {
             return PayPal::raiseError("Could not find certificate file '{$this->_certificateFile}'");
         }
         if (!in_array(strtolower($this->_environment), $this->_validEnvironments, true)) {
             return PayPal::raiseError("Environment '{$this->_environment}' is not a valid environment.");
         }
     }
     return true;
 }
 function &getInstance($params)
 {
     return PayPal::raiseError("Cannot call this method from the base ProfileHandler class");
 }
Example #9
0
 function validateParams()
 {
     if (!isset($this->_params['path'])) {
         return PayPal::raiseError("You must provide the 'path' parameter for this handler");
     }
     if (file_exists($this->_params['path']) && is_dir($this->_params['path'])) {
         return true;
     }
     return false;
 }
Example #10
0
/**
 * Returns an instance of the specified handler for use
 *
 * @internal
 * @param string The name of the handler (i.e. 'File', 'Array)
 * @param array An array of parameters for the specified handler
 * @return object A new instance of the Handler or a PayPal error object on failure
 */
function &_getHandlerInstance($handler_name, $handler_params)
{
    $handler_paths = _getHandlerPaths();
    $handler_classname = "ProfileHandler_{$handler_name}";
    _loadProfileHandlerClasses($handler_paths, $handler_name);
    if (!class_exists($handler_classname)) {
        return PayPal::raiseError("Could not load handler '{$handler_name}'");
    }
    $inst = new $handler_classname($handler_params);
    return $inst;
}