Mage_AmazonPayments_Model_Api_Asp Class Reference

Inheritance diagram for Mage_AmazonPayments_Model_Api_Asp:

Mage_AmazonPayments_Model_Api_Asp_Abstract Mage_AmazonPayments_Model_Api_Abstract Varien_Object

List of all members.

Public Member Functions

 getPayUrl ()
 getPayParams ($referenceId, $amountValue, $currencyCode, $abandonUrl, $returnUrl, $ipnUrl)
 processNotification ($requestParams)
 cancel ($transactionId)
 capture ($transactionId, $amount, $currencyCode)
 refund ($transactionId, $amount, $currencyCode, $referenceId)

Protected Member Functions

 _getFps ()
 _getIpnRequest ()

Protected Attributes

 $_collectShippingAddress = 0
 $_ipnRequest = 'amazonpayments/api_asp_ipn_request'
 $_fpsModel = 'amazonpayments/api_asp_fps'


Detailed Description

Definition at line 34 of file Asp.php.


Member Function Documentation

_getFps (  )  [protected]

Get singleton with AmazonPayments ASP API FPS Model

Returns:
Mage_AmazonPayments_Model_Api_Asp_Fps

Definition at line 56 of file Asp.php.

00057     {
00058         return Mage::getSingleton($this->_fpsModel)->setStoreId($this->getStoreId());
00059     }

_getIpnRequest (  )  [protected]

Get singleton with AmazonPayments ASP IPN notification request Model

Returns:
Mage_AmazonPayments_Model_Api_Asp_Ipn_Request

Definition at line 66 of file Asp.php.

00067     {
00068         return Mage::getSingleton($this->_ipnRequest);
00069     }

cancel ( transactionId  ) 

cancel payment through FPS api

Parameters:
string $transactionId
Returns:
Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract

Definition at line 156 of file Asp.php.

00157     {
00158         $fps = $this->_getFps();
00159 
00160         $request = $fps->getRequest(Mage_AmazonPayments_Model_Api_Asp_Fps::ACTION_CODE_CANCEL)
00161             ->setTransactionId($transactionId)
00162             ->setDescription($this->_getConfig('cancel_description'));
00163             
00164         $response = $fps->process($request);
00165         return $response; 
00166     }

capture ( transactionId,
amount,
currencyCode 
)

capture payment through FPS api

Parameters:
string $transactionId
string $amount
string $currencyCode
Returns:
Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract

Definition at line 176 of file Asp.php.

00177     {
00178         $fps = $this->_getFps();
00179         $amount = $this->_getAmount()
00180             ->setValue($amount)
00181             ->setCurrencyCode($currencyCode);
00182                         
00183         $request = $fps->getRequest(Mage_AmazonPayments_Model_Api_Asp_Fps::ACTION_CODE_SETTLE)
00184             ->setTransactionId($transactionId)
00185             ->setAmount($amount);
00186 
00187         $response = $fps->process($request);
00188         return $response; 
00189     }

getPayParams ( referenceId,
amountValue,
currencyCode,
abandonUrl,
returnUrl,
ipnUrl 
)

Return Amazon Simple Pay payment params

Parameters:
string $referenceId
string $amountValue
string $currencyCode
string $abandonUrl
string $returnUrl
string $ipnUrl
Returns:
array

Definition at line 96 of file Asp.php.

00097     {
00098         $amount = Mage::getSingleton('amazonpayments/api_asp_amount')
00099             ->setValue($amountValue)
00100             ->setCurrencyCode($currencyCode);
00101         
00102         $requestParams = array();
00103         $requestParams['referenceId'] = $referenceId;
00104         $requestParams['amount'] = $amount->toString(); 
00105         $requestParams['description'] = $this->_getConfig('pay_description');
00106 
00107         $requestParams['accessKey'] = $this->_getConfig('access_key');
00108         $requestParams['processImmediate'] = $this->_getConfig('pay_process_immediate');
00109         $requestParams['immediateReturn'] = $this->_getConfig('pay_immediate_return');
00110         $requestParams['collectShippingAddress'] = $this->_collectShippingAddress;
00111         $requestParams['abandonUrl'] = $abandonUrl;
00112         $requestParams['returnUrl'] = $returnUrl;
00113         $requestParams['ipnUrl'] = $ipnUrl;
00114         
00115         $signature = $this->_getSignatureForArray($requestParams, $this->_getConfig('secret_key'));
00116         $requestParams['signature'] = $signature;
00117 
00118         return $requestParams;
00119     }

getPayUrl (  ) 

Return Amazon Simple Pay payment url

Returns:
string

Definition at line 77 of file Asp.php.

00078     {
00079         if ($this->_isSandbox()) {
00080             return $this->_getConfig('pay_service_url_sandbox');
00081         }
00082         return $this->_getConfig('pay_service_url');
00083     } 

processNotification ( requestParams  ) 

process notification request

Parameters:
array $requestParams
Returns:
Mage_AmazonPayments_Model_Api_Asp_Ipn_Request

Definition at line 127 of file Asp.php.

00128     {
00129         $requestSignature = false;
00130         
00131         if (isset($requestParams['signature'])) {
00132             $requestSignature = $requestParams['signature'];
00133             unset($requestParams['signature']);
00134         }
00135         
00136         $originalSignature = $this->_getSignatureForArray($requestParams, $this->_getConfig('secret_key'));
00137         if ($requestSignature != $originalSignature) {
00138             Mage::throwException(Mage::helper('amazonpayments')->__('Request signed an incorrect or missing signature'));
00139         }
00140         
00141         $ipnRequest = $this->_getIpnRequest();
00142         
00143         if(!$ipnRequest->init($requestParams)) {
00144             Mage::throwException(Mage::helper('amazonpayments')->__('Request is not a valid IPN request'));
00145         }
00146         
00147         return $ipnRequest;
00148     }

refund ( transactionId,
amount,
currencyCode,
referenceId 
)

capture payment through FPS api

Parameters:
string $transactionId
string $amount
string $currencyCode
string $referenceId
Returns:
Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract

Definition at line 200 of file Asp.php.

00201     {
00202         $fps = $this->_getFps();
00203 
00204         $amount = $this->_getAmount()
00205             ->setValue($amount)
00206             ->setCurrencyCode($currencyCode);
00207         
00208         $request = $fps->getRequest(Mage_AmazonPayments_Model_Api_Asp_Fps::ACTION_CODE_REFUND)
00209             ->setTransactionId($transactionId)
00210             ->setReferenceId($referenceId)
00211             ->setAmount($amount)
00212             ->setDescription($this->_getConfig('refund_description'));
00213 
00214         $response = $fps->process($request);
00215         return $response; 
00216     }


Member Data Documentation

$_collectShippingAddress = 0 [protected]

collect shipping address to IPN notification request

Definition at line 39 of file Asp.php.

$_fpsModel = 'amazonpayments/api_asp_fps' [protected]

FPS model path

Definition at line 49 of file Asp.php.

$_ipnRequest = 'amazonpayments/api_asp_ipn_request' [protected]

IPN notification request model path

Definition at line 44 of file Asp.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