PaypalUseractionCommit - Version 1.0.1

Version Notes

Added possibility to disable extension in Magento backend.

Download this release

Release Info

Developer David Danier
Extension PaypalUseractionCommit
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/Team23/PaypalUseractionCommit/Helper/Data.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Team23_PaypalUseractionCommit
5
+ *
6
+ * @category Team23
7
+ * @package Team23_PaypalUseractionCommit
8
+ * @version 1.0.1
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_Helper_Data extends Mage_Core_Helper_Abstract
15
+ {
16
+
17
+ /**
18
+ * Check if module is active
19
+ *
20
+ * @return bool
21
+ */
22
+ public function isActive()
23
+ {
24
+ return $this->isModuleEnabled();
25
+ }
26
+
27
+ }
app/code/community/Team23/PaypalUseractionCommit/Model/Config.php CHANGED
@@ -5,7 +5,7 @@
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
  */
@@ -22,11 +22,18 @@ class Team23_PaypalUseractionCommit_Model_Config extends Mage_Paypal_Model_Confi
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
  }
5
  *
6
  * @category Team23
7
  * @package Team23_PaypalUseractionCommit
8
+ * @version 1.0.1
9
  * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
10
  * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11
  */
22
  */
23
  public function getExpressCheckoutStartUrl($token)
24
  {
25
+ if (Mage::helper('Team23_PaypalUseractionCommit')->isActive())
26
+ {
27
+ return $this->getPaypalUrl(array(
28
+ 'cmd' => '_express-checkout',
29
+ 'useraction' => 'commit',
30
+ 'token' => $token,
31
+ ));
32
+ }
33
+ else
34
+ {
35
+ return parent::getExpressCheckoutStartUrl($token);
36
+ }
37
  }
38
 
39
  }
app/code/community/Team23/PaypalUseractionCommit/controllers/ExpressController.php CHANGED
@@ -5,7 +5,7 @@
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
  */
@@ -77,77 +77,84 @@ class Team23_PaypalUseractionCommit_ExpressController extends Mage_Paypal_Expres
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
  }
5
  *
6
  * @category Team23
7
  * @package Team23_PaypalUseractionCommit
8
+ * @version 1.0.1
9
  * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
10
  * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11
  */
77
  */
78
  public function returnAction()
79
  {
80
+ if (Mage::helper('Team23_PaypalUseractionCommit')->isActive())
81
+ {
82
+ try {
83
+ $this->_initCheckout();
84
 
85
+ // Call GetExpressCheckoutDetails
86
+ $this->_checkout->returnFromPaypal($this->_initToken());
87
 
88
+ // COPY OF placeOrderAction, without agreement check
89
+ $this->_checkout->place($this->_initToken());
90
 
91
+ // prepare session to success or cancellation page
92
+ $session = $this->_getCheckoutSession();
93
 
94
+ $session->clearHelperData();
95
 
96
+ // "last successful quote"
97
+ $quoteId = $this->_getQuote()->getId();
98
 
99
+ $session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
100
 
101
+ // an order may be created
102
+ $order = $this->_checkout->getOrder();
103
 
104
+ if ($order)
105
+ {
106
+ $session->setLastOrderId($order->getId())
107
+ ->setLastRealOrderId($order->getIncrementId());
108
 
109
+ // as well a billing agreement can be created
110
+ $agreement = $this->_checkout->getBillingAgreement();
111
 
112
+ if ($agreement)
113
+ $session->setLastBillingAgreementId($agreement->getId());
114
+ }
115
 
116
+ // recurring profiles may be created along with the order or without it
117
+ $profiles = $this->_checkout->getRecurringPaymentProfiles();
118
 
119
+ if ($profiles)
120
+ {
121
+ $ids = array();
122
 
123
+ foreach($profiles as $profile)
124
+ $ids[] = $profile->getId();
125
 
126
+ $session->setLastRecurringProfileIds($ids);
127
+ }
128
 
129
+ // redirect if PayPal specified some URL (for example, to Giropay bank)
130
+ $url = $this->_checkout->getRedirectUrl();
131
 
132
+ if ($url)
133
+ {
134
+ $this->getResponse()->setRedirect($url);
135
+
136
+ return;
137
+ }
138
+
139
+ $this->_initToken(false); // no need in token anymore
140
+ $this->_redirect('checkout/onepage/success');
141
 
142
  return;
143
  }
144
+ catch (Mage_Core_Exception $e) {
145
+ Mage::getSingleton('checkout/session')->addError($e->getMessage());
146
+ }
147
+ catch (Exception $e) {
148
+ Mage::getSingleton('checkout/session')->addError($this->__('Unable to process Express Checkout approval.'));
149
+ Mage::logException($e);
150
+ }
151
 
152
+ $this->_redirect('checkout/cart');
 
 
 
 
 
 
153
  }
154
+ else
155
+ {
156
+ parent::returnAction();
157
  }
 
 
158
  }
159
 
160
  }
app/code/community/Team23/PaypalUseractionCommit/etc/adminhtml.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Team23_PaypalUseractionCommit
6
+ *
7
+ * @category Team23
8
+ * @package Team23_PaypalUseractionCommit
9
+ * @version 1.0.1
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
+ <acl>
17
+ <resources>
18
+ <admin>
19
+ <children>
20
+ <system>
21
+ <children>
22
+ <config>
23
+ <children>
24
+ <useractioncommit>
25
+ <title>PayPal Useractioncommit</title>
26
+ </useractioncommit>
27
+ </children>
28
+ </config>
29
+ </children>
30
+ </system>
31
+ </children>
32
+ </admin>
33
+ </resources>
34
+ </acl>
35
+ </config>
app/code/community/Team23/PaypalUseractionCommit/etc/config.xml CHANGED
@@ -6,7 +6,7 @@
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
  */
@@ -15,7 +15,7 @@
15
  <config>
16
  <modules>
17
  <Team23_PaypalUseractionCommit>
18
- <version>1.0.0</version>
19
  </Team23_PaypalUseractionCommit>
20
  </modules>
21
  <global>
@@ -26,6 +26,12 @@
26
  </rewrite>
27
  </paypal>
28
  </models>
 
 
 
 
 
 
29
  </global>
30
  <frontend>
31
  <routers>
@@ -38,4 +44,11 @@
38
  </paypal>
39
  </routers>
40
  </frontend>
 
 
 
 
 
 
 
41
  </config>
6
  *
7
  * @category Team23
8
  * @package Team23_PaypalUseractionCommit
9
+ * @version 1.0.1
10
  * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
11
  * @license http://opensource.org/licenses/MIT The MIT License (MIT)
12
  */
15
  <config>
16
  <modules>
17
  <Team23_PaypalUseractionCommit>
18
+ <version>1.0.1</version>
19
  </Team23_PaypalUseractionCommit>
20
  </modules>
21
  <global>
26
  </rewrite>
27
  </paypal>
28
  </models>
29
+
30
+ <helpers>
31
+ <Team23_PaypalUseractionCommit>
32
+ <class>Team23_PaypalUseractionCommit_Helper</class>
33
+ </Team23_PaypalUseractionCommit>
34
+ </helpers>
35
  </global>
36
  <frontend>
37
  <routers>
44
  </paypal>
45
  </routers>
46
  </frontend>
47
+ <default>
48
+ <payment>
49
+ <useractioncommit>
50
+ <active>1</active>
51
+ </useractioncommit>
52
+ </payment>
53
+ </default>
54
  </config>
app/code/community/Team23/PaypalUseractionCommit/etc/system.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Team23_PaypalUseractionCommit
6
+ *
7
+ * @category Team23
8
+ * @package Team23_PaypalUseractionCommit
9
+ * @version 1.0.1
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
+ <sections>
17
+ <payment>
18
+ <groups>
19
+ <useractioncommit translate="label" module="Team23_PaypalUseractionCommit">
20
+ <label>PayPal Useractioncommit</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>20</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <active translate="label">
28
+ <label>Disable PayPal Express order review page</label>
29
+ <comment>Disables also agreements! If these are required for your shop, you have to integrate them before the customer gets redirected to PayPal!</comment>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>10</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </active>
37
+ </fields>
38
+ </useractioncommit>
39
+ </groups>
40
+ </payment>
41
+ </sections>
42
+ </config>
app/etc/modules/Team23_PaypalUseractionCommit.xml CHANGED
@@ -6,7 +6,7 @@
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
  */
6
  *
7
  * @category Team23
8
  * @package Team23_PaypalUseractionCommit
9
+ * @version 1.0.1
10
  * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
11
  * @license http://opensource.org/licenses/MIT The MIT License (MIT)
12
  */
package.xml CHANGED
@@ -1,18 +1,26 @@
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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>PaypalUseractionCommit</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/MIT">MITL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>This extension removes the order review page from PayPal Express and redirects directly to order success page.</summary>
10
+ <description>When ordering using PayPal Express in Magento, it takes the customer to PayPal, PayPal already displays a confirmation, the customer confirms, and get redirected to another confirmation page (/paypal/express/review). This is an extra step that is unnecessary for user experience.&#xD;
11
+ &#xD;
12
+ This extension removes the PayPal Express review page (/paypal/express/review) by adding "useraction =&gt; commit" to PayPal URL. Your customer will directly redirected to your success page after paying on PayPal. On PayPal side, the button now displays "Pay" instead of "Continue".&#xD;
13
+ &#xD;
14
+ This extension extends the PayPal module from Magento.&#xD;
15
+ &#xD;
16
+ Caution: The extension disables the agreements. If these are required for your shop, you have to integrate them before the customer gets redirected to PayPal!&#xD;
17
+ &#xD;
18
+ This module is licensed under the MIT license.</description>
19
+ <notes>Added possibility to disable extension in Magento backend.</notes>
20
+ <authors><author><name>David Danier</name><user>team23</user><email>info@team23.de</email></author><author><name>Marc Rochow</name><user>team23</user><email>info@team23.de</email></author></authors>
21
+ <date>2014-04-08</date>
22
+ <time>09:42:11</time>
23
+ <contents><target name="magecommunity"><dir name="Team23"><dir name="PaypalUseractionCommit"><dir name="Helper"><file name="Data.php" hash="d1ae11ffc3a8bc20f97024c4b8768ad4"/></dir><dir name="Model"><file name="Config.php" hash="24eee20224e2f4a31d4d09c7078edf3d"/></dir><dir name="controllers"><file name="ExpressController.php" hash="98fcb267177c56a1dbe292cb8b4e75c8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="7cdf7e7ec0a4b59279c372913b43a658"/><file name="config.xml" hash="34b73b415bda7b0a7e86505c27192f16"/><file name="system.xml" hash="c178dba0acbaf65dd3cbf0d52fe203ba"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Team23_PaypalUseractionCommit.xml" hash="b85d9fc3d3821d583670ee14aa59eb8c"/></dir></target></contents>
24
  <compatible/>
25
+ <dependencies><required><php><min>5.2.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>
26
  </package>