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_XmlConnect
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 Mobile Embedded Payments Checkout Module
29: *
30: * @category Mage
31: * @package Mage_XmlConnect
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_XmlConnect_Model_Payment_Method_Paypal_Mep extends Mage_Paypal_Model_Express
35: {
36: /**
37: * Store MEP payment method code
38: */
39: const MEP_METHOD_CODE = 'paypal_mep';
40:
41: /**
42: * Payment method code
43: *
44: * @var string
45: */
46: protected $_code = self::MEP_METHOD_CODE;
47:
48: protected $_canUseInternal = false;
49: protected $_canUseForMultishipping = false;
50: protected $_isInitializeNeeded = false;
51: protected $_canUseCheckout = false;
52: protected $_canManageRecurringProfiles = false;
53:
54: /**
55: * Get config payment action url
56: * Used to universalize payment actions when processing payment place
57: *
58: * @return string
59: */
60: public function getConfigPaymentAction()
61: {
62: return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
63: }
64:
65: /**
66: * Check whether payment method can be used
67: *
68: * @param Mage_Sales_Model_Quote $quote
69: * @return bool
70: */
71: public function isAvailable($quote = null)
72: {
73: $storeId = false;
74: $model = Mage::registry('current_app');
75:
76: if (($model instanceof Mage_XmlConnect_Model_Application)) {
77: $storeId = $model->getStoreId();
78: }
79:
80: if (!$storeId) {
81: $storeId = $quote ? $quote->getStoreId() : Mage::app()->getStore()->getId();
82: }
83:
84: return (bool) Mage::getModel('paypal/config')->setStoreId($storeId)
85: ->isMethodAvailable(Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS);
86: }
87:
88: /**
89: * Capture payment
90: *
91: * @param Varien_Object $payment
92: * @param float $amount
93: * @return Mage_Payment_Model_Abstract
94: */
95: public function capture(Varien_Object $payment, $amount)
96: {
97: $transactionId = $payment->getAdditionalInformation(
98: Mage_XmlConnect_Model_Paypal_Mep_Checkout::PAYMENT_INFO_TRANSACTION_ID
99: );
100: $payment->setTransactionId($transactionId);
101: return $this;
102: }
103:
104: /**
105: * Return title of the PayPal Mobile Embedded Payment method
106: *
107: * @return string
108: */
109: public function getTitle()
110: {
111: return Mage::helper('xmlconnect')->__('PayPal MEP');
112: }
113: }
114: