Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Authorizenet_Block_Directpost_Form
  • Mage_Authorizenet_Block_Directpost_Iframe
  • Mage_Authorizenet_Directpost_PaymentController
  • Mage_Authorizenet_Helper_Data
  • Mage_Authorizenet_Model_Directpost
  • Mage_Authorizenet_Model_Directpost_Observer
  • Mage_Authorizenet_Model_Directpost_Request
  • Mage_Authorizenet_Model_Directpost_Response
  • Mage_Authorizenet_Model_Directpost_Session
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Authorizenet
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Authorize.net DirectPost payment method model.
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Authorizenet
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Authorizenet_Model_Directpost extends Mage_Paygate_Model_Authorizenet
 35: {
 36:     protected $_code  = 'authorizenet_directpost';
 37:     protected $_formBlockType = 'directpost/form';
 38:     protected $_infoBlockType = 'payment/info';
 39: 
 40:     /**
 41:      * Availability options
 42:      */
 43:     protected $_canAuthorize            = true;
 44:     protected $_canCapture              = true;
 45:     protected $_canCapturePartial       = false;
 46:     protected $_canRefund               = true;
 47:     protected $_canRefundInvoicePartial = true;
 48:     protected $_canVoid                 = true;
 49:     protected $_canUseInternal          = true;
 50:     protected $_canUseCheckout          = true;
 51:     protected $_canUseForMultishipping  = false;
 52:     protected $_canSaveCc               = false;
 53:     protected $_isInitializeNeeded      = true;
 54: 
 55:     /**
 56:      * Do not validate payment form using server methods
 57:      *
 58:      * @return  bool
 59:      */
 60:     public function validate()
 61:     {
 62:         return true;
 63:     }
 64: 
 65:     /**
 66:      * Send authorize request to gateway
 67:      *
 68:      * @param  Varien_Object $payment
 69:      * @param  decimal $amount
 70:      * @return Mage_Paygate_Model_Authorizenet
 71:      * @throws Mage_Core_Exception
 72:      */
 73:     public function authorize(Varien_Object $payment, $amount)
 74:     {
 75:         $payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
 76:     }
 77: 
 78:     /**
 79:      * Send capture request to gateway
 80:      *
 81:      * @param Varien_Object $payment
 82:      * @param decimal $amount
 83:      * @return Mage_Authorizenet_Model_Directpost
 84:      * @throws Mage_Core_Exception
 85:      */
 86:     public function capture(Varien_Object $payment, $amount)
 87:     {
 88:         if ($amount <= 0) {
 89:             Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
 90:         }
 91: 
 92:         $payment->setAmount($amount);
 93: 
 94:         if ($payment->getParentTransactionId()) {
 95:             $payment->setAnetTransType(self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE);
 96:             $payment->setXTransId($this->_getRealParentTransactionId($payment));
 97:         } else {
 98:             $payment->setAnetTransType(self::REQUEST_TYPE_AUTH_CAPTURE);
 99:         }
100: 
101:         $request= $this->_buildRequest($payment);
102:         $result = $this->_postRequest($request);
103: 
104:         switch ($result->getResponseCode()) {
105:             case self::RESPONSE_CODE_APPROVED:
106:                 if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_APPROVED) {
107:                     if (!$payment->getParentTransactionId() ||
108:                         $result->getTransactionId() != $payment->getParentTransactionId()) {
109:                         $payment->setTransactionId($result->getTransactionId());
110:                     }
111:                     $payment
112:                         ->setIsTransactionClosed(0)
113:                         ->setTransactionAdditionalInfo($this->_realTransactionIdKey, $result->getTransactionId());
114:                     return $this;
115:                 }
116:                 Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
117:             case self::RESPONSE_CODE_DECLINED:
118:             case self::RESPONSE_CODE_ERROR:
119:                 Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
120:             default:
121:                 Mage::throwException(Mage::helper('paygate')->__('Payment capturing error.'));
122:         }
123:     }
124: 
125:     /**
126:      * Check refund availability
127:      *
128:      * @return bool
129:      */
130:     public function canRefund()
131:     {
132:         return $this->_canRefund;
133:     }
134: 
135:     /**
136:      * Check void availability
137:      *
138:      * @param   Varien_Object $invoicePayment
139:      * @return  bool
140:      */
141:     public function canVoid(Varien_Object $payment)
142:     {
143:         return $this->_canVoid;
144:     }
145: 
146:     /**
147:      * Void the payment through gateway
148:      *
149:      * @param Varien_Object $payment
150:      * @return Mage_Authorizenet_Model_Directpost
151:      * @throws Mage_Core_Exception
152:      */
153:     public function void(Varien_Object $payment)
154:     {
155:         if (!$payment->getParentTransactionId()) {
156:             Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
157:         }
158: 
159:         $payment->setAnetTransType(self::REQUEST_TYPE_VOID);
160:         $payment->setXTransId($this->_getRealParentTransactionId($payment));
161: 
162:         $request = $this->_buildRequest($payment);
163:         $result = $this->_postRequest($request);
164: 
165:         switch ($result->getResponseCode()) {
166:             case self::RESPONSE_CODE_APPROVED:
167:                 if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_APPROVED) {
168:                     if ($result->getTransactionId() != $payment->getParentTransactionId()) {
169:                         $payment->setTransactionId($result->getTransactionId());
170:                     }
171:                     $payment
172:                         ->setIsTransactionClosed(1)
173:                         ->setShouldCloseParentTransaction(1)
174:                         ->setTransactionAdditionalInfo($this->_realTransactionIdKey, $result->getTransactionId());
175:                     return $this;
176:                 }
177:                 Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
178:             case self::RESPONSE_CODE_DECLINED:
179:             case self::RESPONSE_CODE_ERROR:
180:                 Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
181:             default:
182:                 Mage::throwException(Mage::helper('paygate')->__('Payment voiding error.'));
183:         }
184:     }
185: 
186:     /**
187:      * Set capture transaction ID to invoice for informational purposes
188:      * @param Mage_Sales_Model_Order_Invoice $invoice
189:      * @param Mage_Sales_Model_Order_Payment $payment
190:      * @return Mage_Payment_Model_Method_Abstract
191:      */
192:     public function processInvoice($invoice, $payment)
193:     {
194:         return Mage_Payment_Model_Method_Abstract::processInvoice($invoice, $payment);
195:     }
196: 
197:     /**
198:      * Set transaction ID into creditmemo for informational purposes
199:      * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
200:      * @param Mage_Sales_Model_Order_Payment $payment
201:      * @return Mage_Payment_Model_Method_Abstract
202:      */
203:     public function processCreditmemo($creditmemo, $payment)
204:     {
205:         return Mage_Payment_Model_Method_Abstract::processCreditmemo($creditmemo, $payment);
206:     }
207: 
208:     /**
209:      * Refund the amount
210:      * Need to decode Last 4 digits for request.
211:      *
212:      * @param Varien_Object $payment
213:      * @param decimal $amount
214:      * @return Mage_Authorizenet_Model_Directpost
215:      * @throws Mage_Core_Exception
216:      */
217:     public function refund(Varien_Object $payment, $amount)
218:     {
219:         $last4 = $payment->getCcLast4();
220:         $payment->setCcLast4($payment->decrypt($last4));
221:         try {
222:             $this->_refund($payment, $amount);
223:         } catch (Exception $e) {
224:             $payment->setCcLast4($last4);
225:             throw $e;
226:         }
227:         $payment->setCcLast4($last4);
228:         return $this;
229:     }
230: 
231:     /**
232:      * refund the amount with transaction id
233:      *
234:      * @param string $payment Varien_Object object
235:      * @return Mage_Authorizenet_Model_Directpost
236:      * @throws Mage_Core_Exception
237:      */
238:     protected function _refund(Varien_Object $payment, $amount)
239:     {
240:         if ($amount <= 0) {
241:             Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
242:         }
243: 
244:         if (!$payment->getParentTransactionId()) {
245:             Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
246:         }
247: 
248:         $payment->setAnetTransType(self::REQUEST_TYPE_CREDIT);
249:         $payment->setAmount($amount);
250:         $payment->setXTransId($this->_getRealParentTransactionId($payment));
251: 
252:         $request = $this->_buildRequest($payment);
253:         $result = $this->_postRequest($request);
254: 
255:         switch ($result->getResponseCode()) {
256:             case self::RESPONSE_CODE_APPROVED:
257:                 if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_APPROVED) {
258:                     if ($result->getTransactionId() != $payment->getParentTransactionId()) {
259:                         $payment->setTransactionId($result->getTransactionId());
260:                     }
261:                     $shouldCloseCaptureTransaction = $payment->getOrder()->canCreditmemo() ? 0 : 1;
262:                     $payment
263:                          ->setIsTransactionClosed(1)
264:                          ->setShouldCloseParentTransaction($shouldCloseCaptureTransaction)
265:                          ->setTransactionAdditionalInfo($this->_realTransactionIdKey, $result->getTransactionId());
266:                     return $this;
267:                 }
268:                 Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
269:             case self::RESPONSE_CODE_DECLINED:
270:             case self::RESPONSE_CODE_ERROR:
271:                 Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
272:             default:
273:                 Mage::throwException(Mage::helper('paygate')->__('Payment refunding error.'));
274:         }
275:     }
276: 
277:     /**
278:      * Get CGI url
279:      *
280:      * @return string
281:      */
282:     public function getCgiUrl()
283:     {
284:         $uri = $this->getConfigData('cgi_url');
285:         return $uri ? $uri : self::CGI_URL;
286:     }
287: 
288:     /**
289:      * Return URL on which Authorize.net server will return payment result data in hidden request.
290:      *
291:      * @param int $storeId
292:      * @return string
293:      */
294:     public function getRelayUrl($storeId = null)
295:     {
296:         if ($storeId == null && $this->getStore()) {
297:             $storeId = $this->getStore();
298:         }
299:         return Mage::app()->getStore($storeId)
300:             ->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).
301:             'authorizenet/directpost_payment/response';
302:     }
303: 
304:     /**
305:      * Return request model for form data building
306:      *
307:      * @return Mage_Authorizenet_Model_Directpost_Request
308:      */
309:     protected function _getRequestModel()
310:     {
311:         return Mage::getModel('authorizenet/directpost_request');
312:     }
313: 
314:     /**
315:      * Return response.
316:      *
317:      * @return Mage_Authorizenet_Model_Directpost_Response
318:      */
319:     public function getResponse()
320:     {
321:         return Mage::getSingleton('authorizenet/directpost_response');
322:     }
323: 
324:     /**
325:      * Instantiate state and set it to state object
326:      *
327:      * @param string $paymentAction
328:      * @param Varien_Object
329:      */
330:     public function initialize($paymentAction, $stateObject)
331:     {
332:         switch ($paymentAction) {
333:             case self::ACTION_AUTHORIZE:
334:             case self::ACTION_AUTHORIZE_CAPTURE:
335:                 $payment = $this->getInfoInstance();
336:                 $order = $payment->getOrder();
337:                 $order->setCanSendNewEmailFlag(false);
338:                 $payment->authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
339:                 $payment->setAmountAuthorized($order->getTotalDue());
340: 
341:                 $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, 'pending_payment', '', false);
342: 
343:                 $stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
344:                 $stateObject->setStatus('pending_payment');
345:                 $stateObject->setIsNotified(false);
346:                 break;
347:             default:
348:                 break;
349:         }
350:     }
351: 
352:     /**
353:      * Generate request object and fill its fields from Quote or Order object
354:      *
355:      * @param Mage_Core_Model_Abstract $entity Quote or order object.
356:      * @return Mage_Authorizenet_Model_Directpost_Request
357:      */
358:     public function generateRequestFromOrder(Mage_Sales_Model_Order $order)
359:     {
360:         $request = $this->_getRequestModel();
361:         $request->setConstantData($this)
362:             ->setDataFromOrder($order, $this)
363:             ->signRequestData();
364: 
365:         $this->_debug(array('request' => $request->getData()));
366: 
367:         return $request;
368:     }
369: 
370:     /**
371:      * Fill response with data.
372:      *
373:      * @param array $postData
374:      * @return Mage_Authorizenet_Model_Directpost
375:      */
376:     public function setResponseData(array $postData)
377:     {
378:         $this->getResponse()->setData($postData);
379:         return $this;
380:     }
381: 
382:     /**
383:      * Validate response data. Needed in controllers.
384:      *
385:      * @return bool true in case of validation success.
386:      * @throws Mage_Core_Exception in case of validation error
387:      */
388:     public function validateResponse()
389:     {
390:         $response = $this->getResponse();
391:         //md5 check
392:         if (!$this->getConfigData('trans_md5') || !$this->getConfigData('login') ||
393:             !$response->isValidHash($this->getConfigData('trans_md5'), $this->getConfigData('login'))
394:         ) {
395:             Mage::throwException(
396:                 Mage::helper('authorizenet')->__('Response hash validation failed. Transaction declined.')
397:             );
398:         }
399:         return true;
400:     }
401: 
402:     /**
403:      * Operate with order using data from $_POST which came from authorize.net by Relay URL.
404:      *
405:      * @param array $responseData data from Authorize.net from $_POST
406:      * @throws Mage_Core_Exception in case of validation error or order creation error
407:      */
408:     public function process(array $responseData)
409:     {
410:         $debugData = array(
411:             'response' => $responseData
412:         );
413:         $this->_debug($debugData);
414: 
415:         $this->setResponseData($responseData);
416: 
417:         //check MD5 error or others response errors
418:         //throws exception on false.
419:         $this->validateResponse();
420: 
421:         $response = $this->getResponse();
422:         //operate with order
423:         $orderIncrementId = $response->getXInvoiceNum();
424:         $responseText = $this->_wrapGatewayError($response->getXResponseReasonText());
425:         $isError = false;
426:         if ($orderIncrementId) {
427:             /* @var $order Mage_Sales_Model_Order */
428:             $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
429:             if ($order->getId() &&  $order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
430:                 //operate with order
431:                 $this->_authOrder($order);
432:             } else {
433:                 $isError = true;
434:             }
435:         } else {
436:             $isError = true;
437:         }
438: 
439:         if ($isError) {
440:             Mage::throwException(
441:                 ($responseText && !$response->isApproved()) ?
442:                 $responseText :
443:                 Mage::helper('authorizenet')->__('Payment error. Order was not found.')
444:             );
445:         }
446:     }
447: 
448:     /**
449:      * Fill payment with credit card data from response from Authorize.net.
450:      *
451:      * @param Varien_Object $payment
452:      */
453:     protected function _fillPaymentByResponse(Varien_Object $payment)
454:     {
455:         $response = $this->getResponse();
456:         $payment->setTransactionId($response->getXTransId())
457:             ->setParentTransactionId(null)
458:             ->setIsTransactionClosed(0)
459:             ->setTransactionAdditionalInfo($this->_realTransactionIdKey, $response->getXTransId());
460: 
461:         if ($response->getXMethod() == self::REQUEST_METHOD_CC) {
462:             $payment->setCcAvsStatus($response->getXAvsCode())
463:                 ->setCcLast4($payment->encrypt(substr($response->getXAccountNumber(), -4)));
464:         }
465:     }
466: 
467:     /**
468:      * Check response code came from authorize.net.
469:      *
470:      * @return true in case of Approved response
471:      * @throws Mage_Core_Exception in case of Declined or Error response from Authorize.net
472:      */
473:     public function checkResponseCode()
474:     {
475:         switch ($this->getResponse()->getXResponseCode()) {
476:             case self::RESPONSE_CODE_APPROVED:
477:                 return true;
478:             case self::RESPONSE_CODE_DECLINED:
479:             case self::RESPONSE_CODE_ERROR:
480:                 Mage::throwException($this->_wrapGatewayError($this->getResponse()->getXResponseReasonText()));
481:             default:
482:                 Mage::throwException(Mage::helper('authorizenet')->__('Payment authorization error.'));
483:         }
484:     }
485: 
486:     /**
487:      * Check transaction id came from Authorize.net
488:      *
489:      * @return true in case of right transaction id
490:      * @throws Mage_Core_Exception in case of bad transaction id.
491:      */
492:     public function checkTransId()
493:     {
494:         if (!$this->getResponse()->getXTransId()) {
495:             Mage::throwException(
496:                 Mage::helper('authorizenet')->__('Payment authorization error. Transacion id is empty.')
497:             );
498:         }
499:         return true;
500:     }
501: 
502:     /**
503:      * Compare amount with amount from the response from Authorize.net.
504:      *
505:      * @param float $amount
506:      * @return bool
507:      */
508:     protected function _matchAmount($amount)
509:     {
510:          return sprintf('%.2F', $amount) == sprintf('%.2F', $this->getResponse()->getXAmount());
511:     }
512: 
513:     /**
514:      * Operate with order using information from Authorize.net.
515:      * Authorize order or authorize and capture it.
516:      *
517:      * @param Mage_Sales_Model_Order $order
518:      */
519:     protected function _authOrder(Mage_Sales_Model_Order $order)
520:     {
521:         try {
522:             $this->checkResponseCode();
523:             $this->checkTransId();
524:         } catch (Exception $e) {
525:             //decline the order (in case of wrong response code) but don't return money to customer.
526:             $message = $e->getMessage();
527:             $this->_declineOrder($order, $message, false);
528:             throw $e;
529:         }
530: 
531:         $response = $this->getResponse();
532: 
533:         //create transaction. need for void if amount will not match.
534:         $payment = $order->getPayment();
535:         $this->_fillPaymentByResponse($payment);
536: 
537:         $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
538: 
539:         // Set transaction apporval message
540:         $message = Mage::helper('authorizenet')->__(
541:             'Amount of %s approved by payment gateway. Transaction ID: "%s".',
542:             $order->getBaseCurrency()->formatTxt($payment->getBaseAmountAuthorized()),
543:             $response->getXTransId()
544:         );
545: 
546:         $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
547:         $orderStatus = $this->getConfigData('order_status');
548:         if (!$orderStatus || $order->getIsVirtual()) {
549:             $orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
550:         }
551: 
552:         $order->setState($orderState, $orderStatus ? $orderStatus : true, $message, false)
553:             ->save();
554: 
555:         //match amounts. should be equals for authorization.
556:         //decline the order if amount does not match.
557:         if (!$this->_matchAmount($payment->getBaseAmountAuthorized())) {
558:             $message = Mage::helper('authorizenet')->__('Payment error. Paid amount doesn\'t match the order amount.');
559:             $this->_declineOrder($order, $message, true);
560:             Mage::throwException($message);
561:         }
562: 
563:         //capture order using AIM if needed
564:         $this->_captureOrder($order);
565: 
566:         try {
567:             if (!$response->hasOrderSendConfirmation() || $response->getOrderSendConfirmation()) {
568:                 $order->sendNewOrderEmail();
569:             }
570: 
571:             Mage::getModel('sales/quote')
572:                 ->load($order->getQuoteId())
573:                 ->setIsActive(false)
574:                 ->save();
575:         } catch (Exception $e) {} // do not cancel order if we couldn't send email
576:     }
577: 
578:     /**
579:      * Register order cancellation. Return money to customer if needed.
580:      *
581:      * @param Mage_Sales_Model_Order $order
582:      * @param string $message
583:      * @param bool $voidPayment
584:      */
585:     protected function _declineOrder(Mage_Sales_Model_Order $order, $message = '', $voidPayment = true)
586:     {
587:         try {
588:             $response = $this->getResponse();
589:             if ($voidPayment &&
590:                 $response->getXTransId() &&
591:                 strtoupper($response->getXType()) == self::REQUEST_TYPE_AUTH_ONLY
592:             ) {
593:                 $order->getPayment()
594:                     ->setTransactionId(null)
595:                     ->setParentTransactionId($response->getXTransId())
596:                     ->void();
597:             }
598:             $order->registerCancellation($message)
599:                 ->save();
600:         } catch (Exception $e) {
601:             //quiet decline
602:             Mage::logException($e);
603:         }
604:     }
605: 
606:     /**
607:      * Capture order's payment using AIM.
608:      *
609:      * @param Mage_Sales_Model_Order $order
610:      */
611:     protected function _captureOrder(Mage_Sales_Model_Order $order)
612:     {
613:         $payment = $order->getPayment();
614:         if ($payment->getAdditionalInformation('payment_type') == self::ACTION_AUTHORIZE_CAPTURE) {
615:             try {
616:                 $payment->setTransactionId(null)
617:                     ->setParentTransactionId($this->getResponse()->getXTransId())
618:                     ->capture(null);
619: 
620:                 // set status from config for AUTH_AND_CAPTURE orders.
621:                 if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) {
622:                     $orderStatus = $this->getConfigData('order_status');
623:                     if (!$orderStatus || $order->getIsVirtual()) {
624:                         $orderStatus = $order->getConfig()
625:                                 ->getStateDefaultStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
626:                     }
627:                     if ($orderStatus) {
628:                         $order->setStatus($orderStatus);
629:                     }
630:                 }
631: 
632:                 $order->save();
633:             } catch (Exception $e) {
634:                 Mage::logException($e);
635:                 //if we couldn't capture order, just leave it as NEW order.
636:             }
637:         }
638:     }
639: 
640:     /**
641:      * Return additional information`s transaction_id value of parent transaction model
642:      *
643:      * @param Mage_Sales_Model_Order_Payment $payment
644:      * @return string
645:      */
646:     protected function _getRealParentTransactionId($payment)
647:     {
648:         $transaction = $payment->getTransaction($payment->getParentTransactionId());
649:         return $transaction->getAdditionalInformation($this->_realTransactionIdKey);
650:     }
651: }
652: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0