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_PaypalUk_Block_Express_Form
  • Mage_PaypalUk_Block_Express_Shortcut
  • Mage_PaypalUk_ExpressController
  • Mage_PaypalUk_Helper_Data
  • Mage_PaypalUk_Model_Api_Nvp
  • Mage_PaypalUk_Model_Direct
  • Mage_PaypalUk_Model_Express
  • Mage_PaypalUk_Model_Express_Checkout
  • Mage_PaypalUk_Model_Pro
  • Mage_PaypalUk_Model_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_PaypalUk
 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:  * PayPal Website Payments Pro (Payflow Edition) implementation for payment method instances
 29:  * This model was created because right now PayPal Direct and PayPal Express payment
 30:  * (Payflow Edition) methods cannot have same abstract
 31:  */
 32: class Mage_PaypalUk_Model_Pro extends Mage_Paypal_Model_Pro
 33: {
 34:     /**
 35:      * Api model type
 36:      *
 37:      * @var string
 38:      */
 39:     protected $_apiType = 'paypaluk/api_nvp';
 40: 
 41:     /**
 42:      * Config model type
 43:      *
 44:      * @var string
 45:      */
 46:     protected $_configType = 'paypal/config';
 47: 
 48:     /**
 49:      * Payflow trx_id key in transaction info
 50:      *
 51:      * @var string
 52:      */
 53:     const TRANSPORT_PAYFLOW_TXN_ID = 'payflow_trxid';
 54: 
 55:     /**
 56:      * Refund a capture transaction
 57:      *
 58:      * @param Varien_Object $payment
 59:      * @param float $amount
 60:      */
 61:     public function refund(Varien_Object $payment, $amount)
 62:     {
 63:         if ($captureTxnId = $this->_getParentTransactionId($payment)) {
 64:             $api = $this->getApi();
 65:             $api->setAuthorizationId($captureTxnId);
 66:         }
 67:         parent::refund($payment, $amount);
 68:     }
 69: 
 70:     /**
 71:      * Is capture request needed on this transaction
 72:      *
 73:      * @return true
 74:      */
 75:     protected function _isCaptureNeeded()
 76:     {
 77:         return true;
 78:     }
 79: 
 80:     /**
 81:      * Get payflow transaction id from parent transaction
 82:      *
 83:      * @param Varien_Object $payment
 84:      * @return string
 85:      */
 86:     protected function _getParentTransactionId(Varien_Object $payment)
 87:     {
 88:         if ($payment->getParentTransactionId()) {
 89:             return $payment->getTransaction($payment->getParentTransactionId())
 90:                 ->getAdditionalInformation(Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID);
 91:         }
 92:         return $payment->getParentTransactionId();
 93:     }
 94: 
 95:     /**
 96:      * Import capture results to payment
 97:      *
 98:      * @param Mage_Paypal_Model_Api_Nvp
 99:      * @param Mage_Sales_Model_Order_Payment
100:      */
101:     protected function _importCaptureResultToPayment($api, $payment)
102:     {
103:         $payment->setTransactionId($api->getPaypalTransactionId())
104:             ->setIsTransactionClosed(false)
105:             ->setTransactionAdditionalInfo(
106:                 Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID,
107:                 $api->getTransactionId()
108:         );
109:         $payment->setPreparedMessage(
110:             Mage::helper('paypaluk')->__('Payflow PNREF: #%s.', $api->getTransactionId())
111:         );
112:         Mage::getModel('paypal/info')->importToPayment($api, $payment);
113:     }
114: 
115:     /**
116:      * Fetch transaction details info method does not exists in PaypalUK
117:      *
118:      * @param Mage_Payment_Model_Info $payment
119:      * @param string $transactionId
120:      * @throws Mage_Core_Exception
121:      * @return void
122:      */
123:     public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
124:     {
125:         Mage::throwException(
126:             Mage::helper('paypaluk')->__('Fetch transaction details method does not exists in PaypalUK')
127:         );
128:     }
129: 
130:     /**
131:      * Import refund results to payment
132:      *
133:      * @param Mage_Paypal_Model_Api_Nvp
134:      * @param Mage_Sales_Model_Order_Payment
135:      * @param bool $canRefundMore
136:      */
137:     protected function _importRefundResultToPayment($api, $payment, $canRefundMore)
138:     {
139:         $payment->setTransactionId($api->getPaypalTransactionId())
140:             ->setIsTransactionClosed(1) // refund initiated by merchant
141:             ->setShouldCloseParentTransaction(!$canRefundMore)
142:             ->setTransactionAdditionalInfo(
143:                 Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID,
144:                 $api->getTransactionId()
145:         );
146:         $payment->setPreparedMessage(
147:             Mage::helper('paypaluk')->__('Payflow PNREF: #%s.', $api->getTransactionId())
148:         );
149:         Mage::getModel('paypal/info')->importToPayment($api, $payment);
150:     }
151: }
152: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0