Public Member Functions | |
getConfig ($path) | |
isAvailable ($quote=null) | |
getApi () | |
getNotification () | |
setOrder ($order) | |
getOrder () | |
getOrderPlaceRedirectUrl () | |
getPayRedirectUrl () | |
getPayRedirectParams () | |
processEventRedirect () | |
processEventReturnSuccess () | |
processEventReturnCancel () | |
initialize ($paymentAction, $stateObject) | |
processNotification ($requestParams) | |
capture (Varien_Object $payment, $amount) | |
processInvoice ($invoice, $payment) | |
processCreditmemo ($creditmemo, $payment) | |
cancel (Varien_Object $payment) | |
Protected Member Functions | |
_log ($request, $response= '') | |
_mail ($template, array $variables=array()) | |
Protected Attributes | |
$_isGateway = false | |
$_canAuthorize = false | |
$_canCapture = true | |
$_canCapturePartial = false | |
$_canRefund = true | |
$_canVoid = true | |
$_canUseInternal = false | |
$_canUseCheckout = true | |
$_canUseForMultishipping = false | |
$_isInitializeNeeded = true | |
$_formBlockType = 'amazonpayments/asp_form' | |
$_code = 'amazonpayments_asp' | |
$_order |
Definition at line 34 of file Asp.php.
_log | ( | $ | request, | |
$ | response = '' | |||
) | [protected] |
Add item in to log storage
string | $request | |
string | $response |
Definition at line 139 of file Asp.php.
00140 { 00141 $debug = Mage::getModel('amazonpayments/api_debug') 00142 ->setRequestBody($request) 00143 ->setResponseBody($response) 00144 ->save(); 00145 return $this; 00146 }
Send mail
string | $template | |
array | $variables |
Definition at line 155 of file Asp.php.
00156 { 00157 $mailTemplate = Mage::getModel('core/email_template'); 00158 $mailTemplate->setDesignConfig(array('area' => 'frontend')) 00159 ->sendTransactional( 00160 $this->getConfig($template), 00161 $this->getConfig('email_sender_identity'), 00162 $this->getConfig('report_email'), 00163 null, 00164 $variables 00165 ); 00166 return $this; 00167 }
cancel | ( | Varien_Object $ | payment | ) |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 393 of file Asp.php.
00394 { 00395 if (!is_null($payment->getCcTransId()) && 00396 is_null($payment->getLastTransId())) { 00397 00398 $transactionId = $payment->getCcTransId(); 00399 $response = $this->getApi() 00400 ->setStoreId($payment->getOrder()->getStoreId()) 00401 ->cancel($transactionId); 00402 00403 if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_ERROR) { 00404 Mage::throwException( 00405 Mage::helper('amazonpayments')->__('Order was not cancelled. Amazon Simple Pay service error: [%s] %s', $response->getCode(), $response->getMessage()) 00406 ); 00407 } 00408 00409 if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_CANCELLED) { 00410 $payment->getOrder()->setState( 00411 Mage_Sales_Model_Order::STATE_CANCELED, 00412 true, 00413 Mage::helper('amazonpayments')->__('Payment authorization cancelled with Amazon Simple Pay service.'), 00414 $notified = false 00415 )->save(); 00416 } 00417 } 00418 return $this; 00419 }
capture | ( | Varien_Object $ | payment, | |
$ | amount | |||
) |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 299 of file Asp.php.
00300 { 00301 if (is_null($payment->getCcTransId())) { 00302 Mage::throwException( 00303 Mage::helper('amazonpayments')->__('Order was not captured online. Authorization confirmation is required.') 00304 ); 00305 } 00306 return $this; 00307 }
getApi | ( | ) |
Get singleton with AmazonPayments ASP API Model
Definition at line 89 of file Asp.php.
00090 { 00091 return Mage::getSingleton('amazonpayments/api_asp'); 00092 }
getConfig | ( | $ | path | ) |
Get value from the module config
string | $path |
Definition at line 71 of file Asp.php.
00072 { 00073 return Mage::getStoreConfig('payment/' . $this->_code . '/' . $path); 00074 }
getNotification | ( | ) |
Get singleton with AmazonPayments ASP Notification Model
Definition at line 99 of file Asp.php.
00100 { 00101 return Mage::getSingleton('amazonpayments/payment_asp_notification'); 00102 }
getOrder | ( | ) |
Get model of current order
Definition at line 121 of file Asp.php.
00122 { 00123 if (!$this->_order) { 00124 $paymentInfo = $this->getInfoInstance(); 00125 $this->_order = Mage::getModel('sales/order')->loadByIncrementId( 00126 $paymentInfo->getOrder()->getRealOrderId() 00127 ); 00128 } 00129 return $this->_order; 00130 }
getOrderPlaceRedirectUrl | ( | ) |
rewrited for Mage_Payment_Model_Method_Abstract
Definition at line 172 of file Asp.php.
00173 { 00174 return Mage::getUrl('amazonpayments/asp/pay'); 00175 }
getPayRedirectParams | ( | ) |
Return pay params for current order
Definition at line 192 of file Asp.php.
00193 { 00194 $orderId = $this->getOrder()->getRealOrderId(); 00195 $amount = Mage::app()->getStore()->roundPrice($this->getOrder()->getBaseGrandTotal()); 00196 $currencyCode = $this->getOrder()->getBaseCurrency(); 00197 00198 $urlModel = Mage::getModel('core/url') 00199 ->setUseSession(false); 00200 00201 return $this->getApi()->getPayParams( 00202 $orderId, 00203 $amount, 00204 $currencyCode, 00205 $urlModel->getUrl('amazonpayments/asp/returnCancel'), 00206 $urlModel->getUrl('amazonpayments/asp/returnSuccess'), 00207 $urlModel->getUrl('amazonpayments/asp/notification') 00208 ); 00209 }
getPayRedirectUrl | ( | ) |
initialize | ( | $ | paymentAction, | |
$ | stateObject | |||
) |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 257 of file Asp.php.
00258 { 00259 $state = Mage_Sales_Model_Order::STATE_NEW; 00260 $stateObject->setState($state); 00261 $stateObject->setStatus(Mage::getSingleton('sales/order_config')->getStateDefaultStatus($state)); 00262 $stateObject->setIsNotified(false); 00263 return $this; 00264 }
isAvailable | ( | $ | quote = null |
) |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 79 of file Asp.php.
00080 { 00081 return $this->getConfig('active'); 00082 }
processCreditmemo | ( | $ | creditmemo, | |
$ | payment | |||
) |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 353 of file Asp.php.
00354 { 00355 00356 $transactionId = $creditmemo->getInvoice()->getTransactionId(); 00357 00358 if (!is_null($transactionId) && 00359 is_null($creditmemo->getTransactionId())) { 00360 00361 $amount = Mage::app()->getStore()->roundPrice($creditmemo->getBaseGrandTotal()); 00362 $currencyCode = $payment->getOrder()->getBaseCurrency(); 00363 $referenseID = $creditmemo->getInvoice()->getIncrementId(); 00364 $response = $this->getApi() 00365 ->setStoreId($payment->getOrder()->getStoreId()) 00366 ->refund($transactionId, $amount, $currencyCode, $referenseID); 00367 00368 if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_ERROR) { 00369 Mage::throwException( 00370 Mage::helper('amazonpayments')->__('Invoice was not refunded. Amazon Simple Pay service error: [%s] %s', $response->getCode(), $response->getMessage()) 00371 ); 00372 } 00373 00374 if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_SUCCESS || 00375 $response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_PENDING) { 00376 00377 $creditmemo->setTransactionId($response->getTransactionId()); 00378 $creditmemo->addComment(Mage::helper('amazonpayments')->__('Payment refunded online. Waiting for refund confirmation from Amazon Simple Pay service.')); 00379 $creditmemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_OPEN); 00380 00381 $payment->getOrder()->addStatusToHistory( 00382 $payment->getOrder()->getStatus(), 00383 Mage::helper('amazonpayments')->__('Payment refunded online with Amazon Simple Pay service. Creditmemo was created. Waiting for refund confirmation from Amazon Simple Pay service.') 00384 )->save(); 00385 } 00386 } 00387 return $this; 00388 }
processEventRedirect | ( | ) |
When a customer redirect to Amazon Simple Pay site
Definition at line 216 of file Asp.php.
00217 { 00218 $this->getOrder()->addStatusToHistory( 00219 $this->getOrder()->getStatus(), 00220 Mage::helper('amazonpayments')->__('Customer was redirected to Amazon Simple Pay site') 00221 )->save(); 00222 return $this; 00223 }
processEventReturnCancel | ( | ) |
Customer canceled payment and successfully returned from Amazon Simple Pay site
Definition at line 245 of file Asp.php.
00246 { 00247 $this->getOrder()->addStatusToHistory( 00248 $this->getOrder()->getStatus(), 00249 Mage::helper('amazonpayments')->__('Customer canceled payment and successfully returned from Amazon Simple Pay site') 00250 )->save(); 00251 return $this; 00252 }
processEventReturnSuccess | ( | ) |
When a customer successfully returned from Amazon Simple Pay site
Definition at line 230 of file Asp.php.
00231 { 00232 $this->getOrder()->sendNewOrderEmail(); 00233 $this->getOrder()->addStatusToHistory( 00234 $this->getOrder()->getStatus(), 00235 Mage::helper('amazonpayments')->__('Customer successfully returned from Amazon Simple Pay site') 00236 )->save(); 00237 return $this; 00238 }
processInvoice | ( | $ | invoice, | |
$ | payment | |||
) |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
Definition at line 312 of file Asp.php.
00313 { 00314 if (!is_null($payment->getCcTransId()) && 00315 is_null($payment->getLastTransId()) && 00316 is_null($invoice->getTransactionId())) { 00317 00318 $amount = Mage::app()->getStore()->roundPrice($invoice->getBaseGrandTotal()); 00319 $currencyCode = $payment->getOrder()->getBaseCurrency(); 00320 $transactionId = $payment->getCcTransId(); 00321 $response = $this->getApi() 00322 ->setStoreId($payment->getOrder()->getStoreId()) 00323 ->capture($transactionId, $amount, $currencyCode); 00324 00325 if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_ERROR) { 00326 Mage::throwException( 00327 Mage::helper('amazonpayments')->__('Order was not captured. Amazon Simple Pay service error: [%s] %s', $response->getCode(), $response->getMessage()) 00328 ); 00329 } 00330 00331 if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_SUCCESS || 00332 $response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_PENDING) { 00333 00334 $payment->setForcedState(Mage_Sales_Model_Order_Invoice::STATE_OPEN); 00335 $payment->setLastTransId($response->getTransactionId()); 00336 00337 $invoice->setTransactionId($response->getTransactionId()); 00338 $invoice->addComment(Mage::helper('amazonpayments')->__('Invoice was created (online capture). Waiting for capture confirmation from Amazon Simple Pay service.')); 00339 00340 $payment->getOrder()->addStatusToHistory( 00341 $payment->getOrder()->getStatus(), 00342 Mage::helper('amazonpayments')->__('Payment was captured online with Amazon Simple Pay service. Invoice was created. Waiting for capture confirmation from payment service.') 00343 )->save(); 00344 00345 } 00346 } 00347 return $this; 00348 }
processNotification | ( | $ | requestParams | ) |
process Amazon Simple Pay notification request
array | $requestParams |
Definition at line 272 of file Asp.php.
00273 { 00274 if ($this->getConfig('debug_log')) { 00275 $this->_log('DEBUG ASP notification: ' . print_r($requestParams, 1)); 00276 } 00277 00278 try { 00279 $this->getNotification()->setPayment($this)->process($requestParams); 00280 } catch(Exception $e) { 00281 if ($this->getConfig('error_log')) { 00282 $this->_log('ERROR ASP notification: ' . print_r($requestParams, 1), $e->getMessage()); 00283 } 00284 00285 if ($this->getConfig('report_error_to_email')) { 00286 $variables = array(); 00287 $variables['request'] = print_r($requestParams, 1); 00288 $variables['error'] = $e->getMessage(); 00289 $this->_mail('email_template_notofication_error', $variables); 00290 } 00291 } 00292 00293 return $this; 00294 }
setOrder | ( | $ | order | ) |
Set model of current order
Mage_Sales_Model_Order | $order |
Definition at line 110 of file Asp.php.
$_canAuthorize = false [protected] |
$_canCapture = true [protected] |
$_canCapturePartial = false [protected] |
$_canRefund = true [protected] |
$_canUseCheckout = true [protected] |
$_canUseForMultishipping = false [protected] |
$_canUseInternal = false [protected] |
$_canVoid = true [protected] |
$_code = 'amazonpayments_asp' [protected] |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
$_formBlockType = 'amazonpayments/asp_form' [protected] |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
$_isGateway = false [protected] |
rewrited for Mage_Payment_Model_Method_Abstract
Reimplemented from Mage_Payment_Model_Method_Abstract.
$_isInitializeNeeded = true [protected] |