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: * PayPalUk Direct Module
29: */
30: class Mage_PaypalUk_Model_Direct extends Mage_Paypal_Model_Direct
31: {
32: protected $_code = Mage_Paypal_Model_Config::METHOD_WPP_PE_DIRECT;
33:
34: /**
35: * Website Payments Pro instance type
36: *
37: * @var string
38: */
39: protected $_proType = 'paypaluk/pro';
40:
41: /**
42: * Return available CC types for gateway based on merchant country
43: *
44: * @return string
45: */
46: public function getAllowedCcTypes()
47: {
48: return $this->_pro->getConfig()->cctypes;
49: }
50:
51: /**
52: * Merchant country limitation for 3d secure feature, rewrite for parent implementation
53: *
54: * @return bool
55: */
56: public function getIsCentinelValidationEnabled()
57: {
58: if (!parent::getIsCentinelValidationEnabled()) {
59: return false;
60: }
61: // available only for US and UK merchants
62: if (in_array($this->_pro->getConfig()->getMerchantCountry(), array('US', 'GB'))) {
63: return true;
64: }
65: return false;
66: }
67:
68: /**
69: * Import direct payment results to payment
70: *
71: * @param Mage_Paypal_Model_Api_Nvp
72: * @param Mage_Sales_Model_Order_Payment
73: */
74: protected function _importResultToPayment($api, $payment)
75: {
76: $payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(0)
77: ->setIsTransactionPending($api->getIsPaymentPending())
78: ->setTransactionAdditionalInfo(Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId())
79: ;
80: $payment->setPreparedMessage(Mage::helper('paypaluk')->__('Payflow PNREF: #%s.', $api->getTransactionId()));
81: $this->_pro->importPaymentInfo($api, $payment);
82: }
83:
84: /**
85: * Format credit card expiration date based on month and year values
86: * Format: mmyy
87: *
88: * @param string|int $month
89: * @param string|int $year
90: * @return string
91: */
92: protected function _getFormattedCcExpirationDate($month, $year)
93: {
94: return sprintf('%02d', $month) . sprintf('%02d', substr($year, -2, 2));
95: }
96: }
97: