Mage_AmazonPayments_Model_Api_Abstract Class Reference

Inheritance diagram for Mage_AmazonPayments_Model_Api_Abstract:

Varien_Object Mage_AmazonPayments_Model_Api_Asp_Abstract Mage_AmazonPayments_Model_Api_Cba Mage_AmazonPayments_Model_Api_Asp Mage_AmazonPayments_Model_Api_Asp_Fps

List of all members.

Public Member Functions

 setPaymentCode ($paymentCode)
 getPayServiceUrl ()
 getConfigData ($key, $default=false)
 checkSignParams ($params)
 signParams ($params)

Public Attributes

const PAYMENT_TYPE_AUTH = 'Authorization'
const USER_ACTION_COMMIT = 'commit'

Protected Member Functions

 _getSignatureForArray ($array, $secretKey)
 _getSignatureForString ($string, $secretKey)

Protected Attributes

 $paymentCode

Static Protected Attributes

static $HMAC_SHA1_ALGORITHM = 'sha1'


Detailed Description

Definition at line 34 of file Abstract.php.


Member Function Documentation

_getSignatureForArray ( array,
secretKey 
) [protected]

Return signature for array

Parameters:
array $array
string $secretKey
Returns:
array

Definition at line 135 of file Abstract.php.

00136     {
00137         uksort($array, 'strcasecmp');
00138         $tmpString = '';
00139         foreach ($array as $paramName => $paramValue) {
00140            $tmpString = $tmpString . $paramName . $paramValue;
00141         }
00142         return $this->_getSignatureForString($tmpString, $secretKey);
00143     }

_getSignatureForString ( string,
secretKey 
) [protected]

Return signature for string

Parameters:
string $string
string $secretKey
Returns:
string

Definition at line 152 of file Abstract.php.

00153     {
00154         $rawHmac = hash_hmac(self::$HMAC_SHA1_ALGORITHM, $string, $secretKey, true);
00155         return base64_encode($rawHmac);
00156     }

checkSignParams ( params  ) 

Check signed params

Parameters:
array $params
Returns:
bool

Definition at line 103 of file Abstract.php.

00104     {
00105         if (is_array($params) && isset($params[$this->getRequestSignatureParamName()])) {
00106             $paramSignature = $params[$this->getRequestSignatureParamName()];
00107             unset($params[$this->getRequestSignatureParamName()]);
00108             $generateSignature = $this->_getSignatureForArray($params, $this->getSecretKey());
00109             return $paramSignature == $generateSignature;
00110         }
00111 
00112         return false;
00113     }

getConfigData ( key,
default = false 
)

Get value from the payment module config

Parameters:
string $kay
string $default
Returns:
string

Definition at line 85 of file Abstract.php.

00086     {
00087         if (!$this->hasData($key)) {
00088              $value = Mage::getStoreConfig('payment/' . $paymentCode . '/' . $key);
00089              if (is_null($value) || false===$value) {
00090                  $value = $default;
00091              }
00092             $this->setData($key, $value);
00093         }
00094         return $this->getData($key);
00095     }

getPayServiceUrl (  ) 

Return payment url

Returns:
string

Definition at line 70 of file Abstract.php.

00071     {
00072         if ($this->getSandboxFlag()) {
00073             return $this->getData('sandbox_pay_service_url');
00074         }
00075         return $this->getData('pay_service_url');
00076     }

setPaymentCode ( paymentCode  ) 

Set payment module code

Returns:
string

Definition at line 57 of file Abstract.php.

00058     {
00059         if(is_null($this->paymentCode)) {
00060             $this->paymentCode = $paymentCode;
00061             $this->setData(Mage::getStoreConfig('payment/' . $paymentCode));
00062         }
00063     }

signParams ( params  ) 

Add signature param to params array

Parameters:
array $params
Returns:
array

Definition at line 121 of file Abstract.php.

00122     {
00123         $signature = $this->_getSignatureForArray($params, $this->getSecretKey());
00124         $params[$this->getRequestSignatureParamName()] = $signature;
00125         return $params;
00126     }


Member Data Documentation

$HMAC_SHA1_ALGORITHM = 'sha1' [static, protected]

Reimplemented in Mage_AmazonPayments_Model_Api_Cba.

Definition at line 45 of file Abstract.php.

$paymentCode [protected]

Reimplemented in Mage_AmazonPayments_Model_Api_Asp_Abstract.

Definition at line 50 of file Abstract.php.

const PAYMENT_TYPE_AUTH = 'Authorization'

Definition at line 39 of file Abstract.php.

const USER_ACTION_COMMIT = 'commit'

Definition at line 40 of file Abstract.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:30 2009 for Magento by  doxygen 1.5.8