Version Notes
First stable release.
Download this release
Release Info
Developer | David Danier |
Extension | PaypalUseractionCommit |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Team23/PaypalUseractionCommit/Model/Config.php +32 -0
- app/code/community/Team23/PaypalUseractionCommit/controllers/ExpressController.php +153 -0
- app/code/community/Team23/PaypalUseractionCommit/etc/config.xml +41 -0
- app/etc/modules/Team23_PaypalUseractionCommit.xml +25 -0
- package.xml +18 -0
app/code/community/Team23/PaypalUseractionCommit/Model/Config.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Team23_PaypalUseractionCommit
|
5 |
+
*
|
6 |
+
* @category Team23
|
7 |
+
* @package Team23_PaypalUseractionCommit
|
8 |
+
* @version 1.0.0
|
9 |
+
* @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
|
10 |
+
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class Team23_PaypalUseractionCommit_Model_Config extends Mage_Paypal_Model_Config
|
15 |
+
{
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Get url for dispatching customer to express checkout start
|
19 |
+
*
|
20 |
+
* @param string $token
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getExpressCheckoutStartUrl($token)
|
24 |
+
{
|
25 |
+
return $this->getPaypalUrl(array(
|
26 |
+
'cmd' => '_express-checkout',
|
27 |
+
'useraction' => 'commit',
|
28 |
+
'token' => $token,
|
29 |
+
));
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Team23/PaypalUseractionCommit/controllers/ExpressController.php
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Team23_PaypalUseractionCommit
|
5 |
+
*
|
6 |
+
* @category Team23
|
7 |
+
* @package Team23_PaypalUseractionCommit
|
8 |
+
* @version 1.0.0
|
9 |
+
* @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
|
10 |
+
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
require_once('Mage/Paypal/controllers/ExpressController.php');
|
15 |
+
|
16 |
+
class Team23_PaypalUseractionCommit_ExpressController extends Mage_Paypal_ExpressController
|
17 |
+
{
|
18 |
+
|
19 |
+
/**
|
20 |
+
* PayPal session instance getter
|
21 |
+
*
|
22 |
+
* @return Mage_PayPal_Model_Session
|
23 |
+
*/
|
24 |
+
private function _getSession()
|
25 |
+
{
|
26 |
+
return Mage::getSingleton('paypal/session');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Return checkout session object
|
31 |
+
*
|
32 |
+
* @return Mage_Checkout_Model_Session
|
33 |
+
*/
|
34 |
+
private function _getCheckoutSession()
|
35 |
+
{
|
36 |
+
return Mage::getSingleton('checkout/session');
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return checkout quote object
|
41 |
+
*
|
42 |
+
* @return Mage_Sales_Model_Quote
|
43 |
+
*/
|
44 |
+
private function _getQuote()
|
45 |
+
{
|
46 |
+
if (!$this->_quote) {
|
47 |
+
$this->_quote = $this->_getCheckoutSession()->getQuote();
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this->_quote;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Instantiate quote and checkout
|
55 |
+
*
|
56 |
+
* @throws Mage_Core_Exception
|
57 |
+
*/
|
58 |
+
private function _initCheckout()
|
59 |
+
{
|
60 |
+
/** @var Mage_Sales_Model_Quote $quote */
|
61 |
+
$quote = $this->_getQuote();
|
62 |
+
|
63 |
+
if (!$quote->hasItems() || $quote->getHasError())
|
64 |
+
{
|
65 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
|
66 |
+
Mage::throwException(Mage::helper('paypal')->__('Unable to initialize Express Checkout.'));
|
67 |
+
}
|
68 |
+
|
69 |
+
$this->_checkout = Mage::getSingleton($this->_checkoutType, array(
|
70 |
+
'config' => $this->_config,
|
71 |
+
'quote' => $quote,
|
72 |
+
));
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Return from PayPal and dispatch customer to order review page
|
77 |
+
*/
|
78 |
+
public function returnAction()
|
79 |
+
{
|
80 |
+
try {
|
81 |
+
$this->_initCheckout();
|
82 |
+
|
83 |
+
// Call GetExpressCheckoutDetails
|
84 |
+
$this->_checkout->returnFromPaypal($this->_initToken());
|
85 |
+
|
86 |
+
// COPY OF placeOrderAction, without agreement check
|
87 |
+
$this->_checkout->place($this->_initToken());
|
88 |
+
|
89 |
+
// prepare session to success or cancellation page
|
90 |
+
$session = $this->_getCheckoutSession();
|
91 |
+
|
92 |
+
$session->clearHelperData();
|
93 |
+
|
94 |
+
// "last successful quote"
|
95 |
+
$quoteId = $this->_getQuote()->getId();
|
96 |
+
|
97 |
+
$session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
|
98 |
+
|
99 |
+
// an order may be created
|
100 |
+
$order = $this->_checkout->getOrder();
|
101 |
+
|
102 |
+
if ($order)
|
103 |
+
{
|
104 |
+
$session->setLastOrderId($order->getId())
|
105 |
+
->setLastRealOrderId($order->getIncrementId());
|
106 |
+
|
107 |
+
// as well a billing agreement can be created
|
108 |
+
$agreement = $this->_checkout->getBillingAgreement();
|
109 |
+
|
110 |
+
if ($agreement)
|
111 |
+
$session->setLastBillingAgreementId($agreement->getId());
|
112 |
+
}
|
113 |
+
|
114 |
+
// recurring profiles may be created along with the order or without it
|
115 |
+
$profiles = $this->_checkout->getRecurringPaymentProfiles();
|
116 |
+
|
117 |
+
if ($profiles)
|
118 |
+
{
|
119 |
+
$ids = array();
|
120 |
+
|
121 |
+
foreach($profiles as $profile)
|
122 |
+
$ids[] = $profile->getId();
|
123 |
+
|
124 |
+
$session->setLastRecurringProfileIds($ids);
|
125 |
+
}
|
126 |
+
|
127 |
+
// redirect if PayPal specified some URL (for example, to Giropay bank)
|
128 |
+
$url = $this->_checkout->getRedirectUrl();
|
129 |
+
|
130 |
+
if ($url)
|
131 |
+
{
|
132 |
+
$this->getResponse()->setRedirect($url);
|
133 |
+
|
134 |
+
return;
|
135 |
+
}
|
136 |
+
|
137 |
+
$this->_initToken(false); // no need in token anymore
|
138 |
+
$this->_redirect('checkout/onepage/success');
|
139 |
+
|
140 |
+
return;
|
141 |
+
}
|
142 |
+
catch (Mage_Core_Exception $e) {
|
143 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
144 |
+
}
|
145 |
+
catch (Exception $e) {
|
146 |
+
Mage::getSingleton('checkout/session')->addError($this->__('Unable to process Express Checkout approval.'));
|
147 |
+
Mage::logException($e);
|
148 |
+
}
|
149 |
+
|
150 |
+
$this->_redirect('checkout/cart');
|
151 |
+
}
|
152 |
+
|
153 |
+
}
|
app/code/community/Team23/PaypalUseractionCommit/etc/config.xml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
/**
|
5 |
+
* Team23_PaypalUseractionCommit
|
6 |
+
*
|
7 |
+
* @category Team23
|
8 |
+
* @package Team23_PaypalUseractionCommit
|
9 |
+
* @version 1.0.0
|
10 |
+
* @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
|
11 |
+
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
|
15 |
+
<config>
|
16 |
+
<modules>
|
17 |
+
<Team23_PaypalUseractionCommit>
|
18 |
+
<version>1.0.0</version>
|
19 |
+
</Team23_PaypalUseractionCommit>
|
20 |
+
</modules>
|
21 |
+
<global>
|
22 |
+
<models>
|
23 |
+
<paypal>
|
24 |
+
<rewrite>
|
25 |
+
<config>Team23_PaypalUseractionCommit_Model_Config</config>
|
26 |
+
</rewrite>
|
27 |
+
</paypal>
|
28 |
+
</models>
|
29 |
+
</global>
|
30 |
+
<frontend>
|
31 |
+
<routers>
|
32 |
+
<paypal>
|
33 |
+
<args>
|
34 |
+
<modules>
|
35 |
+
<Team23_PaypalUseractionCommit before="Mage_Paypal">Team23_PaypalUseractionCommit</Team23_PaypalUseractionCommit>
|
36 |
+
</modules>
|
37 |
+
</args>
|
38 |
+
</paypal>
|
39 |
+
</routers>
|
40 |
+
</frontend>
|
41 |
+
</config>
|
app/etc/modules/Team23_PaypalUseractionCommit.xml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
/**
|
5 |
+
* Team23_PaypalUseractionCommit
|
6 |
+
*
|
7 |
+
* @category Team23
|
8 |
+
* @package Team23_PaypalUseractionCommit
|
9 |
+
* @version 1.0.0
|
10 |
+
* @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
|
11 |
+
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
|
15 |
+
<config>
|
16 |
+
<modules>
|
17 |
+
<Team23_PaypalUseractionCommit>
|
18 |
+
<active>true</active>
|
19 |
+
<codePool>community</codePool>
|
20 |
+
<depends>
|
21 |
+
<Mage_Paypal/>
|
22 |
+
</depends>
|
23 |
+
</Team23_PaypalUseractionCommit>
|
24 |
+
</modules>
|
25 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>PaypalUseractionCommit</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/MIT">MIT</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Removes the papyal express order review page.</summary>
|
10 |
+
<description>This extension removes the papyal express order review page.</description>
|
11 |
+
<notes>First stable release.</notes>
|
12 |
+
<authors><author><name>David Danier</name><user>team23</user><email>info@team23.de</email></author></authors>
|
13 |
+
<date>2014-03-27</date>
|
14 |
+
<time>17:15:28</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Team23"><dir name="PaypalUseractionCommit"><dir name="Model"><file name="Config.php" hash="ee269220ac9d06d33c3a16f86613294b"/></dir><dir name="controllers"><file name="ExpressController.php" hash="ab99b6378756b86d4c9d20e5be818949"/></dir><dir name="etc"><file name="config.xml" hash="e8d3ab4610aadf6e8449756b6c9b9af8"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Team23_PaypalUseractionCommit.xml" hash="9ce0b2a8add1103fe9aad0440a679525"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.8.1.0</max></package></required></dependencies>
|
18 |
+
</package>
|