EWPProfile Class Reference

Inheritance diagram for EWPProfile:

Inheritance graph
[legend]
Collaboration diagram for EWPProfile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EWPProfile ($id, &$handler)
 validate ()
 getCertificateId ()
 setCertificateId ($filename)
 getCertificateFile ()
 setCertificateFile ($filename)
 getButtonImage ()
 setButtonImage ($url)
 getUrl ()
 setUrl ($url)
 setPrivateKeyFile ($filename)
 getPrivateKeyFile ()
 setPrivateKeyPassword ($password)
 getPrivateKeyPassword ()
 _getSerializeList ()
 getInstance ($id, &$handler)
 _load ()
 getID ()
 loadEnvironments ()
 save ()
 setEnvironment ($environment)
 getEnvironment ()
 getValidEnvironments ()

Public Attributes

 $_privateKeyFile
 $_privateKeyPassword
 $_buttonImageURL
 $_buttonURL
 $_certificateId
 $_certificateFile
 $_environment
 $_validEnvironments = array()
 $_handler
 $_handler_id

Detailed Description

Definition at line 20 of file EWP.php.


Constructor & Destructor Documentation

EWPProfile::EWPProfile id,
&$  handler
 

Class constructor

Parameters:
ProfileHandler &$handler A handler where the profile should be stored.

Definition at line 69 of file EWP.php.

00070     {
00071         parent::Profile($id, $handler);
00072     }


Member Function Documentation

EWPProfile::_getSerializeList  ) 
 

Returns an array of member variables names which should be included when storing the profile.

Returns:
array An array of member variable names which should be included protected

Reimplemented from Profile.

Definition at line 238 of file EWP.php.

00239     {
00240         return array('environment', 'certificateId', 'certificateFile', 'privateKeyFile', 'buttonImageURL', 'buttonURL');
00241     }

Profile::_load  )  [inherited]
 

Loads the profile data from the defined handler.

Returns:
mixed true on success or a PayPal_Error object on failure private

Definition at line 67 of file Profile.php.

References $value, Profile::_getSerializeList(), PEAR::isError(), Profile::loadEnvironments(), and Services_PayPal::raiseError().

00068     {
00069         $loaded_data = $this->_handler->loadProfile($this->_handler_id);
00070         $expected_keys = $this->_getSerializeList();
00071 
00072         if (!is_a($this->_handler, 'ProfileHandler_Array')) {
00073             $expected_keys[] = 'classname';
00074         }
00075 
00076         if (Services_PayPal::isError($loaded_data)) {
00077             foreach ($expected_keys as $key) {
00078                 $ikey = "_$key";
00079                 $this->$ikey = null;
00080             }
00081 
00082             return Services_PayPal::raiseError("Could not load data for non-existant profile '{$this->_handler_id}'");
00083         }
00084 
00085         $expected_keys = array_flip($expected_keys);
00086         foreach ($loaded_data as $key => $value) {
00087             $ikey = "_$key";
00088             $this->$ikey = $value;
00089             unset($expected_keys[$key]);
00090         }
00091 
00092         if (!empty($expected_keys)) {
00093             $key_list = implode(', ', array_flip($expected_keys));
00094             return Services_PayPal::raiseError("The following values were expected but not found in the profile data: $key_list");
00095         }
00096 
00097         return $this->loadEnvironments();
00098     }

EWPProfile::getButtonImage  ) 
 

Returns the URL where the button image is

Returns:
string The URL to the button image

Definition at line 149 of file EWP.php.

00150     {
00151         return $this->_buttonImageURL;
00152     }

EWPProfile::getCertificateFile  ) 
 

Get the merchant certificate file associated with the profile

Returns:
string The certificate file associated with the profile

Definition at line 125 of file EWP.php.

00126     {
00127         return $this->_certificateFile;
00128     }

EWPProfile::getCertificateId  ) 
 

Get the merchant certificate id associated with the profile

Returns:
string The certificate id associated with the profile

Definition at line 105 of file EWP.php.

00106     {
00107         return $this->_certificateId;
00108     }

Profile::getEnvironment  )  [inherited]
 

Get the environment associated with the profile.

Returns:
string The environment associated with the profile.

Definition at line 198 of file Profile.php.

00199     {
00200         return strtolower($this->_environment);
00201     }

Profile::getID  )  [inherited]
 

Definition at line 100 of file Profile.php.

00101     {
00102         return $this->_handler_id;
00103     }

EWPProfile::getInstance id,
&$  handler
 

Factory for creating instances of the EWPProfile. Used when providing an existing Profile ID to load from

Parameters:
string The Profile ID of this instance
object A valid Profile Handler instance
Returns:
object A new instance of EWPProfile for the given ID or a PayPal error object on failure

Reimplemented from Profile.

Definition at line 251 of file EWP.php.

References $result, and PEAR::isError().

00252     {
00253         $classname = __CLASS__;
00254         $inst = new $classname($id, $handler);
00255         $result = $inst->_load();
00256 
00257         if (Services_PayPal::isError($result)) {
00258             return $result;
00259         }
00260 
00261         return $inst;
00262     }

EWPProfile::getPrivateKeyFile  ) 
 

Get the merchant private key file associated with the profile

Returns:
string The merchant private key file associated with the profile

Definition at line 206 of file EWP.php.

00207     {
00208         return $this->_privateKeyFile;
00209     }

EWPProfile::getPrivateKeyPassword  ) 
 

Get the merchant private key password

Returns:
string The private key password.

Definition at line 226 of file EWP.php.

00227     {
00228         return $this->_privateKeyPassword;
00229     }

EWPProfile::getUrl  ) 
 

Returns the URL where the button will post to

Returns:
string The URL where the button will post to

Definition at line 169 of file EWP.php.

00170     {
00171         return $this->_buttonURL;
00172     }

Profile::getValidEnvironments  )  [inherited]
 

Returns an array of valid Environments

Returns:
array An array of valid environment names

Definition at line 208 of file Profile.php.

References PEAR::isError(), and Profile::loadEnvironments().

Referenced by Profile::setEnvironment().

00209     {
00210         if (empty($this->_validEnvironments)) {
00211             $res = $this->loadEnvironments();
00212             if (Services_PayPal::isError($res)) {
00213                 return $res;
00214             }
00215         }
00216 
00217         return $this->_validEnvironments;
00218     }

Profile::loadEnvironments  )  [inherited]
 

Loads the environment names from the endpoint map.

Returns:
mixed True on success or a PayPal error object on failure

Definition at line 115 of file Profile.php.

References Services_PayPal::getEndpoints(), Services_PayPal::getWSDLVersion(), PEAR::isError(), and Services_PayPal::raiseError().

Referenced by Profile::_load(), and Profile::getValidEnvironments().

00116     {
00117         $version = Services_PayPal::getWSDLVersion();
00118         $endpoints = Services_PayPal::getEndpoints();
00119         if (Services_PayPal::isError($endpoints)) {
00120             return $endpoints;
00121         }
00122 
00123         foreach ($endpoints as $range) {
00124             if ($version >= $range['min'] &&
00125                 $version <= $range['max']) {
00126                 foreach (array_keys($range['environments']) as $environment) {
00127                     $this->_validEnvironments[] = strtolower($environment);
00128                 }
00129                 return true;
00130             }
00131         }
00132 
00133         return Services_PayPal::raiseError("Could not find any endpoint mappings for WSDL version '$version'");
00134     }

Profile::save  )  [inherited]
 

Saves the profile data to the defined handler.

Returns:
mixed true on success or a PayPal_Error object on failure

Definition at line 142 of file Profile.php.

References $data, $value, $values, and Profile::_getSerializeList().

00143     {
00144         $values = $this->_getSerializeList();
00145         foreach ($values as $value) {
00146             $ivalue = "_$value";
00147             if (isset($this->$ivalue)) {
00148                 $data[$value] = $this->$ivalue;
00149             } else {
00150                 $data[$value] = null;
00151             }
00152         }
00153 
00154         $data['classname'] = get_class($this);
00155 
00156         return $this->_handler->saveProfile($data, $this->_handler_id);
00157     }

EWPProfile::setButtonImage url  ) 
 

Set the URL where the button image is

Parameters:
string The URL to the button image

Definition at line 159 of file EWP.php.

00160     {
00161         $this->_buttonImageURL = $url;
00162     }

EWPProfile::setCertificateFile filename  ) 
 

Set the merchant certificate file associated with the profile

Parameters:
string The certificate file associated with the profile

Definition at line 135 of file EWP.php.

References $filename, and Services_PayPal::raiseError().

00136     {
00137         if (!file_exists($filename)) {
00138             return Services_PayPal::raiseError("The private key '$filename' does not exist");
00139         }
00140 
00141         $this->_certificateFile = $filename;
00142     }

EWPProfile::setCertificateId filename  ) 
 

Set the merchant certificate id associated with the profile

Parameters:
string The certificate id associated with the profile

Definition at line 115 of file EWP.php.

References $filename.

00116     {
00117         $this->_certificateId = $filename;
00118     }

Profile::setEnvironment environment  )  [inherited]
 

Set the environment associated with this profile.

Parameters:
string True on success, a Paypal error object on failure

Definition at line 176 of file Profile.php.

References Profile::getValidEnvironments(), PEAR::isError(), and Services_PayPal::raiseError().

00177     {
00178         $environment = strtolower($environment);
00179 
00180         $envs = $this->getValidEnvironments();
00181         if (Services_PayPal::isError($envs)) {
00182             return $envs;
00183         }
00184 
00185         if (in_array($environment, $envs)) {
00186             $this->_environment = $environment;
00187             return true;
00188         }
00189 
00190         return Services_PayPal::raiseError("Invalid Environment Specified");
00191     }

EWPProfile::setPrivateKeyFile filename  ) 
 

Set the Merchant private key file

Parameters:
string The Merchant Private Key File
Returns:
mixed True on success, a PayPal error object on faliure

Definition at line 190 of file EWP.php.

References $filename, and Services_PayPal::raiseError().

00191     {
00192         if (!file_exists($filename)) {
00193             return Services_PayPal::raiseError("The private key '$filename' does not exist");
00194         }
00195 
00196         $this->_privateKeyFile = $filename;
00197 
00198         return true;
00199     }

EWPProfile::setPrivateKeyPassword password  ) 
 

Set the merchant private key password

Parameters:
string The private key password

Definition at line 216 of file EWP.php.

References $password.

00217     {
00218         $this->_privateKeyPassword = $password;
00219     }

EWPProfile::setUrl url  ) 
 

Sets the URL where the button will post to

Parameters:
string The URL where the button should post to

Definition at line 179 of file EWP.php.

00180     {
00181         $this->_buttonURL = $url;
00182     }

EWPProfile::validate  ) 
 

Validates the profile data currently loaded before use.

Returns:
mixed true if the data is valid, or a PayPal_Error object on failure.

Definition at line 79 of file EWP.php.

References Services_PayPal::raiseError().

00080     {
00081         if (empty($this->_certificateFile)) {
00082             return Services_PayPal::raiseError("Certificate File must be set!");
00083         }
00084         if (empty($this->_certificateId)) {
00085             return Services_PayPal::raiseError("Certificate ID must be set.");
00086         }
00087         if (empty($this->_environment)) {
00088             return Services_PayPal::raiseError("Environment must be set.");
00089         }
00090         if (!file_exists($this->_certificateFile)) {
00091             return Services_PayPal::raiseError("Could not find certificate file '{$this->_certificateFile}'");
00092         }
00093         if (!in_array(strtolower($this->_environment), $this->_validEnvironments, true)) {
00094             return Services_PayPal::raiseError("Environment '{$this->_environment}' is not a valid environment.");
00095         }
00096 
00097         return true;
00098     }


Member Data Documentation

EWPProfile::$_buttonImageURL
 

The URL to the button image

private

Definition at line 41 of file EWP.php.

EWPProfile::$_buttonURL
 

The URL the button posts to

private

Definition at line 48 of file EWP.php.

EWPProfile::$_certificateFile
 

The location of the .pem certificate file.

private

Definition at line 62 of file EWP.php.

EWPProfile::$_certificateId
 

The PayPal-assigned id of the certificate.

private

Definition at line 55 of file EWP.php.

Profile::$_environment [inherited]
 

Which environment should API calls be made against?

See also:
$_validEnvironments
protected

Definition at line 29 of file Profile.php.

Profile::$_handler [inherited]
 

The ProfileHandler instance associated with this Profile.

protected

Definition at line 44 of file Profile.php.

Profile::$_handler_id [inherited]
 

Definition at line 45 of file Profile.php.

EWPProfile::$_privateKeyFile
 

The private Key file

private

Definition at line 27 of file EWP.php.

EWPProfile::$_privateKeyPassword
 

The password on the private key.

private

Definition at line 34 of file EWP.php.

Profile::$_validEnvironments = array() [inherited]
 

The list of valid environments that API calls can be executed against.

protected

Definition at line 37 of file Profile.php.


The documentation for this class was generated from the following file:
Generated on Fri Mar 17 14:54:02 2006 for CRE Loaded 6.2 Pro by  doxygen 1.4.4