Version Notes
Mage_Payone-3.2.0
Download this release
Release Info
Developer | PAYONE |
Extension | Mage_Payone |
Version | 3.3.3 |
Comparing to | |
See all releases |
Code changes from version 3.3.1 to 3.3.3
- app/code/community/Payone/Core/Block/Payment/Method/Form/Abstract.php +1 -1
- app/code/community/Payone/Core/Block/Payment/Method/Info/Abstract.php +1 -1
- app/code/community/Payone/Core/Block/Paypal/Express/Form.php +37 -0
- app/code/community/Payone/Core/Block/Paypal/Express/Review.php +78 -0
- app/code/community/Payone/Core/Block/Paypal/Express/Review/Billing.php +59 -0
- app/code/community/Payone/Core/Block/Paypal/Express/Review/Details.php +37 -0
- app/code/community/Payone/Core/Block/Paypal/Express/Review/Shipping.php +53 -0
- app/code/community/Payone/Core/Block/Paypal/Express/Shortcut.php +164 -0
- app/code/community/Payone/Core/Model/Config/General.php +21 -0
- app/code/community/Payone/Core/Model/Config/General/PaymentPaypalExpressCheckout.php +77 -0
- app/code/community/Payone/Core/Model/Config/Payment/Method.php +63 -0
- app/code/community/Payone/Core/Model/Config/Payment/Method/Interface.php +30 -0
- app/code/community/Payone/Core/Model/Domain/Config/PaymentMethod.php +3 -1
- app/code/community/Payone/Core/Model/Factory.php +65 -0
- app/code/community/Payone/Core/Model/Handler/Payment/Genericpayment.php +38 -0
- app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Abstract.php +2 -1
- app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php +23 -7
- app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Capture.php +3 -2
- app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Debit.php +2 -1
- app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php +112 -0
- app/code/community/Payone/Core/Model/Service/Payment/Genericpayment.php +72 -0
- app/code/community/Payone/Core/Model/Service/Paypal/Express/Checkout.php +643 -0
- app/code/community/Payone/Core/Model/Session.php +38 -0
- app/code/community/Payone/Core/controllers/Checkout/Onepage/PaymentController.php +3 -3
- app/code/community/Payone/Core/controllers/PexpressController.php +282 -0
- app/code/community/Payone/Core/etc/config.xml +2 -1
- app/code/community/Payone/Core/etc/system.xml +32 -1
- app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.3.2-3.3.3.php +60 -0
- app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.3.2-3.3.3.sql +12 -0
- app/code/community/Payone/Licensemanager/etc/config.xml +12 -0
- app/design/frontend/base/default/layout/payone/core.xml +55 -0
- app/design/frontend/base/default/template/payone/core/paypal/express/shortcut.phtml +38 -0
- app/locale/de_DE/Payone_Core.csv +2 -0
- lib/Payone/Api/Adapter/Http/Abstract.php +9 -1
- lib/Payone/Api/Adapter/Interface.php +0 -10
- lib/Payone/Api/Config.php +4 -8
- lib/Payone/Api/Enum/GenericpaymentAction.php +32 -0
- lib/Payone/Api/Enum/RequestType.php +5 -0
- lib/Payone/Api/Enum/ResponseType.php +1 -0
- lib/Payone/Api/Enum/WalletType.php +77 -36
- lib/Payone/Api/Factory.php +85 -129
- lib/Payone/Api/Mapper/Request/Payment/Genericpayment.php +38 -0
- lib/Payone/Api/Mapper/Response/Genericpayment.php +56 -0
- lib/Payone/Api/Request/Abstract.php +20 -24
- lib/Payone/Api/Request/Authorization/Abstract.php +21 -0
- lib/Payone/Api/Request/Genericpayment.php +229 -0
- lib/Payone/Api/Request/Interface.php +1 -1
- lib/Payone/Api/Request/Parameter/Abstract.php +1 -1
- lib/Payone/Api/Request/Parameter/Paydata/DataItem.php +1 -1
- lib/Payone/Api/Request/Parameter/Paydata/Paydata.php +42 -10
- lib/Payone/Api/Response/Abstract.php +20 -5
- lib/Payone/Api/Response/Genericpayment/Abstract.php +33 -0
- lib/Payone/Api/Response/Genericpayment/Approved.php +88 -0
- lib/Payone/Api/Response/Genericpayment/Ok.php +23 -0
- lib/Payone/Api/Response/Genericpayment/Redirect.php +44 -0
- lib/Payone/Api/Response/Parameter/Abstract.php +81 -0
- lib/Payone/Api/Response/Parameter/Interface.php +38 -0
- lib/Payone/Api/Response/Parameter/Paydata/DataItem.php +75 -0
- lib/Payone/Api/Response/Parameter/Paydata/Paydata.php +128 -0
- lib/Payone/Api/Service/Payment/Genericpayment.php +98 -0
- lib/Payone/Api/Service/Payment/GenericpaymentInterface.php +34 -0
- lib/Payone/Api/Service/ProtocolRequest.php +4 -11
- lib/Payone/Autoload.php +0 -10
- lib/Payone/Builder.php +58 -69
- lib/Payone/ClientApi/Factory.php +0 -9
- lib/Payone/Config/Abstract.php +2 -10
- lib/Payone/Enum/ClearingType.php +0 -9
- lib/Payone/Enum/Mode.php +0 -9
- lib/Payone/Enum/Reminderlevel.php +0 -9
- lib/Payone/Protocol/Factory.php +5 -37
- lib/Payone/Protocol/Filter/Filterable.php +2 -11
- lib/Payone/Protocol/Filter/MaskAllValue.php +18 -0
- lib/Payone/Protocol/Service/ApplyFilters.php +58 -81
- lib/Payone/SessionStatus/Config.php +5 -18
- lib/Payone/SessionStatus/Factory.php +0 -9
- lib/Payone/SessionStatus/Mapper/Request.php +2 -2
- lib/Payone/SessionStatus/Request.php +0 -11
- lib/Payone/SessionStatus/Request/Abstract.php +22 -25
- lib/Payone/SessionStatus/Request/Interface.php +1 -1
- lib/Payone/SessionStatus/Request/Item/Abstract.php +22 -25
- lib/Payone/SessionStatus/Request/Item/Interface.php +1 -1
- lib/Payone/SessionStatus/Response.php +0 -11
- lib/Payone/SessionStatus/Response/Abstract.php +3 -20
- lib/Payone/Settings/Factory.php +0 -9
- lib/Payone/TransactionStatus/Config.php +4 -8
- lib/Payone/TransactionStatus/Factory.php +0 -9
- lib/Payone/TransactionStatus/Request.php +0 -1
- lib/Payone/TransactionStatus/Request/Abstract.php +22 -25
- lib/Payone/TransactionStatus/Response.php +0 -11
- lib/Payone/TransactionStatus/Response/Abstract.php +11 -16
- lib/Payone/TransactionStatus/Response/Interface.php +1 -1
- lib/Payone/TransactionStatus/Service/ProtocolRequest.php +111 -115
- package.xml +2 -2
app/code/community/Payone/Core/Block/Payment/Method/Form/Abstract.php
CHANGED
@@ -281,7 +281,7 @@ class Payone_Core_Block_Payment_Method_Form_Abstract
|
|
281 |
* @param string $text
|
282 |
* @return string
|
283 |
*/
|
284 |
-
public function strToXXX
|
285 |
$result = str_repeat('x', strlen($text) - 8);
|
286 |
$result = substr($text, 0, 4).$result.substr($text, -4);
|
287 |
return $result;
|
281 |
* @param string $text
|
282 |
* @return string
|
283 |
*/
|
284 |
+
public function strToXXX($text) {
|
285 |
$result = str_repeat('x', strlen($text) - 8);
|
286 |
$result = substr($text, 0, 4).$result.substr($text, -4);
|
287 |
return $result;
|
app/code/community/Payone/Core/Block/Payment/Method/Info/Abstract.php
CHANGED
@@ -116,7 +116,7 @@ class Payone_Core_Block_Payment_Method_Info_Abstract
|
|
116 |
* @param string $text
|
117 |
* @return string
|
118 |
*/
|
119 |
-
public function strToXXX
|
120 |
$result = str_repeat('x', strlen($text) - 8);
|
121 |
$result = substr($text, 0, 4).$result.substr($text, -4);
|
122 |
return $result;
|
116 |
* @param string $text
|
117 |
* @return string
|
118 |
*/
|
119 |
+
public function strToXXX($text) {
|
120 |
$result = str_repeat('x', strlen($text) - 8);
|
121 |
$result = substr($text, 0, 4).$result.substr($text, -4);
|
122 |
return $result;
|
app/code/community/Payone/Core/Block/Paypal/Express/Form.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Block
|
17 |
+
* @subpackage Adminhtml
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Block
|
28 |
+
* @subpackage Adminhtml
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Payone_Core_Block_Paypal_Express_Form extends Mage_Paypal_Block_Express_Form
|
35 |
+
{
|
36 |
+
|
37 |
+
}
|
app/code/community/Payone/Core/Block/Paypal/Express/Review.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Block
|
17 |
+
* @subpackage Adminhtml
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Block
|
28 |
+
* @subpackage Adminhtml
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Payone_Core_Block_Paypal_Express_Review extends Mage_Paypal_Block_Express_Review
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Retrieve payment method and assign additional template values
|
38 |
+
*
|
39 |
+
* @return Payone_Core_Block_Paypal_Express_Review
|
40 |
+
*/
|
41 |
+
protected function _beforeToHtml()
|
42 |
+
{
|
43 |
+
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
|
44 |
+
$this->setPaymentMethodTitle($methodInstance->getTitle());
|
45 |
+
$this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
|
46 |
+
$this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
|
47 |
+
|
48 |
+
$this->setShippingRateRequired(true);
|
49 |
+
if ($this->_quote->getIsVirtual()) {
|
50 |
+
$this->setShippingRateRequired(false);
|
51 |
+
} else {
|
52 |
+
// prepare shipping rates
|
53 |
+
$this->_address = $this->_quote->getShippingAddress();
|
54 |
+
$groups = $this->_address->getGroupedAllShippingRates();
|
55 |
+
if ($groups && $this->_address) {
|
56 |
+
$this->setShippingRateGroups($groups);
|
57 |
+
// determine current selected code & name
|
58 |
+
foreach ($groups as $code => $rates) {
|
59 |
+
foreach ($rates as $rate) {
|
60 |
+
if ($this->_address->getShippingMethod() == $rate->getCode()) {
|
61 |
+
$this->_currentShippingRate = $rate;
|
62 |
+
break(2);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
// misc shipping parameters
|
69 |
+
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
|
70 |
+
->setCanEditShippingAddress(false)
|
71 |
+
->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
|
72 |
+
;
|
73 |
+
}
|
74 |
+
|
75 |
+
$this->setEditUrl(null) //$this->getUrl("{$this->_paypalActionPrefix}/express/edit")
|
76 |
+
->setPlaceOrderUrl($this->getUrl("payone_core/pexpress/placeOrder"));
|
77 |
+
}
|
78 |
+
}
|
app/code/community/Payone/Core/Block/Paypal/Express/Review/Billing.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Block
|
17 |
+
* @subpackage Adminhtml
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Block
|
28 |
+
* @subpackage Adminhtml
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Payone_Core_Block_Paypal_Express_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Return Sales Quote Address model
|
38 |
+
*
|
39 |
+
* @return Mage_Sales_Model_Quote_Address
|
40 |
+
*/
|
41 |
+
public function getAddress()
|
42 |
+
{
|
43 |
+
if (is_null($this->_address)) {
|
44 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
|
45 |
+
$this->_address = $this->getQuote()->getBillingAddress();
|
46 |
+
if (!$this->_address->getFirstname()) {
|
47 |
+
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
|
48 |
+
}
|
49 |
+
if (!$this->_address->getLastname()) {
|
50 |
+
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
|
51 |
+
}
|
52 |
+
} else {
|
53 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return $this->_address;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Payone/Core/Block/Paypal/Express/Review/Details.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Block
|
17 |
+
* @subpackage Adminhtml
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Block
|
28 |
+
* @subpackage Adminhtml
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Payone_Core_Block_Paypal_Express_Review_Details extends Mage_Paypal_Block_Express_Review_Details
|
35 |
+
{
|
36 |
+
|
37 |
+
}
|
app/code/community/Payone/Core/Block/Paypal/Express/Review/Shipping.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Block
|
17 |
+
* @subpackage Adminhtml
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Block
|
28 |
+
* @subpackage Adminhtml
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Payone_Core_Block_Paypal_Express_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Return Sales Quote Address model (shipping address)
|
38 |
+
*
|
39 |
+
* @return Mage_Sales_Model_Quote_Address
|
40 |
+
*/
|
41 |
+
public function getAddress()
|
42 |
+
{
|
43 |
+
if (is_null($this->_address)) {
|
44 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
|
45 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
46 |
+
} else {
|
47 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
return $this->_address;
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Payone/Core/Block/Paypal/Express/Shortcut.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Block
|
17 |
+
* @subpackage Adminhtml
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Block
|
28 |
+
* @subpackage Adminhtml
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Payone_Core_Block_Paypal_Express_Shortcut extends Mage_Core_Block_Template
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Position of "OR" label against shortcut
|
38 |
+
*/
|
39 |
+
const POSITION_BEFORE = 'before';
|
40 |
+
const POSITION_AFTER = 'after';
|
41 |
+
|
42 |
+
/** @var Payone_Core_Model_Factory */
|
43 |
+
private $factory = null;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Whether the block should be eventually rendered
|
47 |
+
*
|
48 |
+
* @var bool
|
49 |
+
*/
|
50 |
+
protected $_shouldRender = true;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Payment method code
|
54 |
+
*
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
protected $_paymentMethodCode = Payone_Core_Model_System_Config_PaymentMethodCode::WALLET;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Payment method type for Paypal Express
|
61 |
+
*
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
protected $_paymentMethodType = Payone_Api_Enum_WalletType::PAYPAL_EXPRESS;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Start express action
|
68 |
+
*
|
69 |
+
* @var string
|
70 |
+
*/
|
71 |
+
protected $_startAction = 'payone_core/pexpress/start';
|
72 |
+
|
73 |
+
protected function _beforeToHtml()
|
74 |
+
{
|
75 |
+
$result = parent::_beforeToHtml();
|
76 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
77 |
+
|
78 |
+
// check payment method availability
|
79 |
+
$methodInstance = Mage::helper('payment')->getMethodInstance($this->_paymentMethodCode);
|
80 |
+
if (!$methodInstance || !$methodInstance->isAvailable($quote)) {
|
81 |
+
$this->_shouldRender = false;
|
82 |
+
return $result;
|
83 |
+
}
|
84 |
+
|
85 |
+
// check payment method type availability
|
86 |
+
$configMethod = $methodInstance->getConfigForQuote($quote);
|
87 |
+
$methodTypes = $configMethod->getTypes();
|
88 |
+
if(!in_array($this->_paymentMethodType, $methodTypes)) {
|
89 |
+
$this->_shouldRender = false;
|
90 |
+
return $result;
|
91 |
+
}
|
92 |
+
|
93 |
+
// check visibility button on shopping cart
|
94 |
+
$shortcutOnShoppingCart = $this->getHelperConfig()->getConfigGeneral($quote->getStoreId())->getPaymentPaypalExpressCheckout()->getPaypalExpressCheckoutVisibleOnCart();
|
95 |
+
if(empty($shortcutOnShoppingCart)) {
|
96 |
+
$this->_shouldRender = false;
|
97 |
+
return $result;
|
98 |
+
}
|
99 |
+
|
100 |
+
// set misc data
|
101 |
+
$this->setShortcutHtmlId($this->helper('core')->uniqHash('ppe_shortcut_'))
|
102 |
+
->setCheckoutUrl($this->getUrl($this->_startAction));
|
103 |
+
|
104 |
+
$this->setImageUrl(Mage::getModel('payone_core/service_paypal_express_checkout', array(
|
105 |
+
'quote' => $quote,
|
106 |
+
'config' => $configMethod
|
107 |
+
))->getCheckoutShortcutImageUrl());
|
108 |
+
|
109 |
+
|
110 |
+
return $result;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Render the block if needed
|
115 |
+
*
|
116 |
+
* @return string
|
117 |
+
*/
|
118 |
+
protected function _toHtml()
|
119 |
+
{
|
120 |
+
if (!$this->_shouldRender) {
|
121 |
+
return '';
|
122 |
+
}
|
123 |
+
return parent::_toHtml();
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Check is "OR" label position before shortcut
|
128 |
+
*
|
129 |
+
* @return bool
|
130 |
+
*/
|
131 |
+
public function isOrPositionBefore()
|
132 |
+
{
|
133 |
+
return ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_BEFORE);
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Check is "OR" label position after shortcut
|
138 |
+
*
|
139 |
+
* @return bool
|
140 |
+
*/
|
141 |
+
public function isOrPositionAfter()
|
142 |
+
{
|
143 |
+
return ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_AFTER);
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @return Payone_Core_Helper_Config
|
148 |
+
*/
|
149 |
+
protected function getHelperConfig()
|
150 |
+
{
|
151 |
+
return $this->getFactory()->helperConfig();
|
152 |
+
}
|
153 |
+
/**
|
154 |
+
* @return Payone_Core_Model_Factory
|
155 |
+
*/
|
156 |
+
|
157 |
+
protected function getFactory()
|
158 |
+
{
|
159 |
+
if ($this->factory === null) {
|
160 |
+
$this->factory = new Payone_Core_Model_Factory();
|
161 |
+
}
|
162 |
+
return $this->factory;
|
163 |
+
}
|
164 |
+
}
|
app/code/community/Payone/Core/Model/Config/General.php
CHANGED
@@ -48,6 +48,10 @@ class Payone_Core_Model_Config_General extends Payone_Core_Model_Config_AreaAbst
|
|
48 |
* @var Payone_Core_Model_Config_General_PaymentCreditcard
|
49 |
*/
|
50 |
protected $payment_creditcard;
|
|
|
|
|
|
|
|
|
51 |
|
52 |
/**
|
53 |
* @var Payone_Core_Model_Config_General_ParameterNarrativeText
|
@@ -86,6 +90,7 @@ class Payone_Core_Model_Config_General extends Payone_Core_Model_Config_AreaAbst
|
|
86 |
return $this->parameter_invoice;
|
87 |
}
|
88 |
|
|
|
89 |
/**
|
90 |
* @param Payone_Core_Model_Config_General_PaymentCreditcard $payment_creditcard
|
91 |
*/
|
@@ -102,6 +107,22 @@ class Payone_Core_Model_Config_General extends Payone_Core_Model_Config_AreaAbst
|
|
102 |
return $this->payment_creditcard;
|
103 |
}
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
/**
|
106 |
* @param Payone_Core_Model_Config_General_StatusMapping $status_mapping
|
107 |
*/
|
48 |
* @var Payone_Core_Model_Config_General_PaymentCreditcard
|
49 |
*/
|
50 |
protected $payment_creditcard;
|
51 |
+
/**
|
52 |
+
* @var Payone_Core_Model_Config_General_PaymentPaypalExpressCheckout
|
53 |
+
*/
|
54 |
+
protected $payment_paypal_express_checkout;
|
55 |
|
56 |
/**
|
57 |
* @var Payone_Core_Model_Config_General_ParameterNarrativeText
|
90 |
return $this->parameter_invoice;
|
91 |
}
|
92 |
|
93 |
+
|
94 |
/**
|
95 |
* @param Payone_Core_Model_Config_General_PaymentCreditcard $payment_creditcard
|
96 |
*/
|
107 |
return $this->payment_creditcard;
|
108 |
}
|
109 |
|
110 |
+
/**
|
111 |
+
* @param Payone_Core_Model_Config_General_PaymentPaypalExpressCheckout $payment_paypal_express_checkout
|
112 |
+
*/
|
113 |
+
public function setPaymentPaypalExpressCheckout(Payone_Core_Model_Config_General_PaymentPaypalExpressCheckout $payment_paypal_express_checkout)
|
114 |
+
{
|
115 |
+
$this->payment_paypal_express_checkout = $payment_paypal_express_checkout;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @return Payone_Core_Model_Config_General_PaymentPaypalExpressCheckout
|
120 |
+
*/
|
121 |
+
public function getPaymentPaypalExpressCheckout()
|
122 |
+
{
|
123 |
+
return $this->payment_paypal_express_checkout;
|
124 |
+
}
|
125 |
+
|
126 |
/**
|
127 |
* @param Payone_Core_Model_Config_General_StatusMapping $status_mapping
|
128 |
*/
|
app/code/community/Payone/Core/Model/Config/General/PaymentPaypalExpressCheckout.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Model
|
17 |
+
* @subpackage Config
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Model
|
28 |
+
* @subpackage Config
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
class Payone_Core_Model_Config_General_PaymentPaypalExpressCheckout extends Payone_Core_Model_Config_AreaAbstract
|
34 |
+
{
|
35 |
+
/**
|
36 |
+
* @var int
|
37 |
+
*/
|
38 |
+
protected $paypal_express_checkout_visible_on_cart = 0;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
protected $paypal_express_checkout_image = '';
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param int $paypal_express_checkout_visible_on_cart
|
48 |
+
*/
|
49 |
+
public function setPaypalExpressCheckoutVisibleOnCart($paypal_express_checkout_visible_on_cart)
|
50 |
+
{
|
51 |
+
$this->paypal_express_checkout_visible_on_cart = $paypal_express_checkout_visible_on_cart;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return int
|
56 |
+
*/
|
57 |
+
public function getPaypalExpressCheckoutVisibleOnCart()
|
58 |
+
{
|
59 |
+
return $this->paypal_express_checkout_visible_on_cart;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param string $paypal_express_checkout_image
|
64 |
+
*/
|
65 |
+
public function setPaypalExpressCheckoutImage($paypal_express_checkout_image)
|
66 |
+
{
|
67 |
+
$this->paypal_express_checkout_image = $paypal_express_checkout_image;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function getPaypalExpressCheckoutImage()
|
74 |
+
{
|
75 |
+
return $this->paypal_express_checkout_image;
|
76 |
+
}
|
77 |
+
}
|
app/code/community/Payone/Core/Model/Config/Payment/Method.php
CHANGED
@@ -126,6 +126,21 @@ class Payone_Core_Model_Config_Payment_Method
|
|
126 |
*/
|
127 |
protected $klarna_campaign_code = '';
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
/**
|
130 |
* @var int
|
131 |
*/
|
@@ -493,6 +508,54 @@ class Payone_Core_Model_Config_Payment_Method
|
|
493 |
return $this->klarna_campaign_code;
|
494 |
}
|
495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
/**
|
497 |
* @param int $mid
|
498 |
*/
|
126 |
*/
|
127 |
protected $klarna_campaign_code = '';
|
128 |
|
129 |
+
/**
|
130 |
+
* @var int
|
131 |
+
*/
|
132 |
+
// protected $paypal_express_checkout_visible_on_cart = 0;
|
133 |
+
|
134 |
+
/**
|
135 |
+
* @var int
|
136 |
+
*/
|
137 |
+
// protected $paypal_express_address = 0;
|
138 |
+
|
139 |
+
/**
|
140 |
+
* @var string
|
141 |
+
*/
|
142 |
+
protected $paypal_express_image = '';
|
143 |
+
|
144 |
/**
|
145 |
* @var int
|
146 |
*/
|
508 |
return $this->klarna_campaign_code;
|
509 |
}
|
510 |
|
511 |
+
/**
|
512 |
+
* @param int $paypal_express_checkout_visible_on_cart
|
513 |
+
*/
|
514 |
+
// public function setPaypalExpressCheckoutVisibleOnCart($paypal_express_checkout_visible_on_cart)
|
515 |
+
// {
|
516 |
+
// $this->paypal_express_checkout_visible_on_cart = $paypal_express_checkout_visible_on_cart;
|
517 |
+
// }
|
518 |
+
|
519 |
+
/**
|
520 |
+
* @return int
|
521 |
+
*/
|
522 |
+
// public function getPaypalExpressCheckoutVisibleOnCart()
|
523 |
+
// {
|
524 |
+
// return $this->paypal_express_checkout_visible_on_cart;
|
525 |
+
// }
|
526 |
+
|
527 |
+
/**
|
528 |
+
* @param int $paypal_express_address
|
529 |
+
*/
|
530 |
+
// public function setPaypalExpressAddress($paypal_express_address)
|
531 |
+
// {
|
532 |
+
// $this->paypal_express_address = $paypal_express_address;
|
533 |
+
// }
|
534 |
+
|
535 |
+
/**
|
536 |
+
* @return int
|
537 |
+
*/
|
538 |
+
// public function getPaypalExpressAddress()
|
539 |
+
// {
|
540 |
+
// return $this->paypal_express_address;
|
541 |
+
// }
|
542 |
+
|
543 |
+
/**
|
544 |
+
* @param string $paypal_express_image
|
545 |
+
*/
|
546 |
+
public function setPaypalExpressImage($paypal_express_image)
|
547 |
+
{
|
548 |
+
$this->paypal_express_image = $paypal_express_image;
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* @return string
|
553 |
+
*/
|
554 |
+
public function getPaypalExpressImage()
|
555 |
+
{
|
556 |
+
return $this->paypal_express_image;
|
557 |
+
}
|
558 |
+
|
559 |
/**
|
560 |
* @param int $mid
|
561 |
*/
|
app/code/community/Payone/Core/Model/Config/Payment/Method/Interface.php
CHANGED
@@ -293,6 +293,36 @@ interface Payone_Core_Model_Config_Payment_Method_Interface
|
|
293 |
*/
|
294 |
public function getKlarnaCampaignCode();
|
295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
/**
|
297 |
* @param int $mid
|
298 |
*/
|
293 |
*/
|
294 |
public function getKlarnaCampaignCode();
|
295 |
|
296 |
+
/**
|
297 |
+
* @param int $paypal_express_checkout_visible_on_cart)
|
298 |
+
*/
|
299 |
+
// public function setPaypalExpressCheckoutVisibleOnCart($paypal_express_checkout_visible_on_cart);
|
300 |
+
|
301 |
+
/**
|
302 |
+
* @return int
|
303 |
+
*/
|
304 |
+
// public function getPaypalExpressCheckoutVisibleOnCart();
|
305 |
+
|
306 |
+
/**
|
307 |
+
* @param int $paypal_express_address
|
308 |
+
*/
|
309 |
+
// public function setPaypalExpressAddress($paypal_express_address);
|
310 |
+
|
311 |
+
/**
|
312 |
+
* @return int
|
313 |
+
*/
|
314 |
+
// public function getPaypalExpressAddress();
|
315 |
+
|
316 |
+
/**
|
317 |
+
* @param string $paypal_express_image
|
318 |
+
*/
|
319 |
+
public function setPaypalExpressImage($paypal_express_image);
|
320 |
+
|
321 |
+
/**
|
322 |
+
* @return string
|
323 |
+
*/
|
324 |
+
public function getPaypalExpressImage();
|
325 |
+
|
326 |
/**
|
327 |
* @param int $mid
|
328 |
*/
|
app/code/community/Payone/Core/Model/Domain/Config/PaymentMethod.php
CHANGED
@@ -427,7 +427,9 @@ class Payone_Core_Model_Domain_Config_PaymentMethod
|
|
427 |
$keyPrefix = Payone_Core_Block_Adminhtml_System_Config_Form_Payment_Method::SECTION_PAYONE_PAYMENT . '/';
|
428 |
$keyPrefix .= Payone_Core_Block_Adminhtml_System_Config_Form_Payment_Method::GROUP_TEMPLATE_PREFIX . $methodType . '/';
|
429 |
foreach ($data as $key => $value) {
|
430 |
-
|
|
|
|
|
431 |
}
|
432 |
|
433 |
return $configData;
|
427 |
$keyPrefix = Payone_Core_Block_Adminhtml_System_Config_Form_Payment_Method::SECTION_PAYONE_PAYMENT . '/';
|
428 |
$keyPrefix .= Payone_Core_Block_Adminhtml_System_Config_Form_Payment_Method::GROUP_TEMPLATE_PREFIX . $methodType . '/';
|
429 |
foreach ($data as $key => $value) {
|
430 |
+
if(!is_null($value)) {
|
431 |
+
$configData[$keyPrefix . $key] = $value;
|
432 |
+
}
|
433 |
}
|
434 |
|
435 |
return $configData;
|
app/code/community/Payone/Core/Model/Factory.php
CHANGED
@@ -202,6 +202,21 @@ class Payone_Core_Model_Factory
|
|
202 |
return $mapper;
|
203 |
}
|
204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
/**
|
206 |
* @param Payone_Core_Model_Config_Protect_AddressCheck $configAddresscheck
|
207 |
* @return Payone_Core_Model_Mapper_ApiRequest_Verification_AddressCheck
|
@@ -369,6 +384,24 @@ class Payone_Core_Model_Factory
|
|
369 |
return $service;
|
370 |
}
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
/**
|
373 |
* @return Payone_Core_Model_Service_Management_GetInvoice
|
374 |
*/
|
@@ -548,6 +581,17 @@ class Payone_Core_Model_Factory
|
|
548 |
return $handler;
|
549 |
}
|
550 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
551 |
/**
|
552 |
* @return Payone_Core_Model_Handler_Management_GetInvoice
|
553 |
*/
|
@@ -613,6 +657,14 @@ class Payone_Core_Model_Factory
|
|
613 |
return $request;
|
614 |
}
|
615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
616 |
|
617 |
/**
|
618 |
* @return Payone_Api_Request_AddressCheck
|
@@ -721,6 +773,19 @@ class Payone_Core_Model_Factory
|
|
721 |
return $service;
|
722 |
}
|
723 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
724 |
/**
|
725 |
* @return Payone_ClientApi_Service_GenerateHash
|
726 |
*/
|
202 |
return $mapper;
|
203 |
}
|
204 |
|
205 |
+
/**
|
206 |
+
* @param Payone_Core_Model_Config_Payment_Method_Interface $config
|
207 |
+
* @return Payone_Core_Model_Mapper_ApiRequest_Payment_Genericpayment
|
208 |
+
*/
|
209 |
+
public function getMapperPaymentRequestGenericpayment(Payone_Core_Model_Config_Payment_Method_Interface $config)
|
210 |
+
{
|
211 |
+
/** @var $mapper Payone_Core_Model_Mapper_ApiRequest_Payment_Genericpayment */
|
212 |
+
$mapper = Mage::getModel('payone_core/mapper_apiRequest_payment_genericpayment');
|
213 |
+
$mapper->setConfigPayment($config);
|
214 |
+
$mapper->setFactory($this);
|
215 |
+
$mapper->setIsAdmin($this->getIsAdmin());
|
216 |
+
|
217 |
+
return $mapper;
|
218 |
+
}
|
219 |
+
|
220 |
/**
|
221 |
* @param Payone_Core_Model_Config_Protect_AddressCheck $configAddresscheck
|
222 |
* @return Payone_Core_Model_Mapper_ApiRequest_Verification_AddressCheck
|
384 |
return $service;
|
385 |
}
|
386 |
|
387 |
+
/**
|
388 |
+
* @param Payone_Core_Model_Config_Payment_Method_Interface $config
|
389 |
+
* @return Payone_Core_Model_Service_Payment_Genericpayment
|
390 |
+
*/
|
391 |
+
public function getServicePaymentGenericpayment(Payone_Core_Model_Config_Payment_Method_Interface $config)
|
392 |
+
{
|
393 |
+
$mapper = $this->getMapperPaymentRequestGenericpayment($config);
|
394 |
+
$handler = $this->getHandlerPaymentGenericpayment($config);
|
395 |
+
|
396 |
+
/** @var $service Payone_Core_Model_Service_Payment_Genericpayment */
|
397 |
+
$service = Mage::getModel('payone_core/service_payment_genericpayment');
|
398 |
+
$service->setMapper($mapper);
|
399 |
+
$service->setHandler($handler);
|
400 |
+
$service->setServiceApiPayment($this->getServiceApiPaymentGenericpayment());
|
401 |
+
|
402 |
+
return $service;
|
403 |
+
}
|
404 |
+
|
405 |
/**
|
406 |
* @return Payone_Core_Model_Service_Management_GetInvoice
|
407 |
*/
|
581 |
return $handler;
|
582 |
}
|
583 |
|
584 |
+
/**
|
585 |
+
* @param Payone_Core_Model_Config_Payment_Method_Interface $config
|
586 |
+
* @return Payone_Core_Model_Handler_Payment_Abstract|Payone_Core_Model_Handler_Payment_Genericpayment
|
587 |
+
*/
|
588 |
+
public function getHandlerPaymentGenericpayment(Payone_Core_Model_Config_Payment_Method_Interface $config)
|
589 |
+
{
|
590 |
+
/** @var $handler Payone_Core_Model_Handler_Payment_Genericpayment */
|
591 |
+
$handler = $this->getHandlerPayment('payone_core/handler_payment_genericpayment', $config);
|
592 |
+
return $handler;
|
593 |
+
}
|
594 |
+
|
595 |
/**
|
596 |
* @return Payone_Core_Model_Handler_Management_GetInvoice
|
597 |
*/
|
657 |
return $request;
|
658 |
}
|
659 |
|
660 |
+
/**
|
661 |
+
* @return Payone_Api_Request_Genericpayment
|
662 |
+
*/
|
663 |
+
public function getRequestPaymentGenericpayment()
|
664 |
+
{
|
665 |
+
$request = new Payone_Api_Request_Genericpayment();
|
666 |
+
return $request;
|
667 |
+
}
|
668 |
|
669 |
/**
|
670 |
* @return Payone_Api_Request_AddressCheck
|
773 |
return $service;
|
774 |
}
|
775 |
|
776 |
+
/**
|
777 |
+
* @return Payone_Api_Service_Payment_Genericpayment
|
778 |
+
*/
|
779 |
+
public function getServiceApiPaymentGenericpayment()
|
780 |
+
{
|
781 |
+
$builder = $this->getBuilder();
|
782 |
+
$service = $builder->buildServicePaymentGenericpayment();
|
783 |
+
|
784 |
+
$this->afterBuildServiceApi($service);
|
785 |
+
|
786 |
+
return $service;
|
787 |
+
}
|
788 |
+
|
789 |
/**
|
790 |
* @return Payone_ClientApi_Service_GenerateHash
|
791 |
*/
|
app/code/community/Payone/Core/Model/Handler/Payment/Genericpayment.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Model
|
17 |
+
* @subpackage Handler
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Model
|
28 |
+
* @subpackage Handler
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
class Payone_Core_Model_Handler_Payment_Genericpayment
|
34 |
+
extends Payone_Core_Model_Handler_Payment_Abstract
|
35 |
+
implements Payone_Core_Model_Handler_Payment_Interface
|
36 |
+
{
|
37 |
+
|
38 |
+
}
|
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Abstract.php
CHANGED
@@ -112,7 +112,8 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
|
|
112 |
$params['de'] = $order->getShippingDescription();
|
113 |
$params['no'] = 1;
|
114 |
$params['pr'] = $order->getShippingInclTax();
|
115 |
-
$params['va'] = $this->getShippingTaxRate();
|
|
|
116 |
|
117 |
if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
|
118 |
$params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
|
112 |
$params['de'] = $order->getShippingDescription();
|
113 |
$params['no'] = 1;
|
114 |
$params['pr'] = $order->getShippingInclTax();
|
115 |
+
// $params['va'] = $this->getShippingTaxRate();
|
116 |
+
$params['va'] = round( $this->getShippingTaxRate() * 100 ); // transfer vat in basis point format [#MAGE-186]
|
117 |
|
118 |
if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
|
119 |
$params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
|
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php
CHANGED
@@ -72,6 +72,11 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
|
|
72 |
$request->setInvoicing($invoicing);
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
75 |
$payment = $this->mapPaymentParameters();
|
76 |
|
77 |
// Not every Paymentmethod has an extra Parameter Set
|
@@ -197,9 +202,14 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
|
|
197 |
$personalData->setIp($ip);
|
198 |
}
|
199 |
|
200 |
-
// US
|
201 |
-
if ($billingCountry == 'US' or $billingCountry == 'CA
|
202 |
-
$
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
// Safe Invoice "Klarna" specific personal parameters mapping
|
@@ -338,9 +348,14 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
|
|
338 |
$deliveryData->setShippingCity($address->getCity());
|
339 |
$deliveryData->setShippingCountry($shippingCountry);
|
340 |
|
341 |
-
// US
|
342 |
-
if ($shippingCountry == 'US' or $shippingCountry == 'CA
|
343 |
-
$
|
|
|
|
|
|
|
|
|
|
|
344 |
}
|
345 |
|
346 |
// Safe Invoice type "Klarna"
|
@@ -389,7 +404,8 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
|
|
389 |
$params['pr'] = $itemData->getPriceInclTax();
|
390 |
$params['no'] = $number;
|
391 |
$params['de'] = $itemData->getName();
|
392 |
-
$params['va'] = number_format($itemData->getTaxPercent(), 0, '.', '');
|
|
|
393 |
|
394 |
if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
|
395 |
$params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
|
72 |
$request->setInvoicing($invoicing);
|
73 |
}
|
74 |
|
75 |
+
//Add workorderid when wollet and checkout express
|
76 |
+
if($workOrderId = $payment->getAdditionalInformation(Payone_Core_Model_Service_Paypal_Express_Checkout::PAYONE_EXPRESS_CHECKOUT_WORKORDERID)) {
|
77 |
+
$request->setWorkorderId($workOrderId);
|
78 |
+
}
|
79 |
+
|
80 |
$payment = $this->mapPaymentParameters();
|
81 |
|
82 |
// Not every Paymentmethod has an extra Parameter Set
|
202 |
$personalData->setIp($ip);
|
203 |
}
|
204 |
|
205 |
+
// US, CA, CN, JP, MX, BR, AR, ID, TH, IN always need state and shipping_state paramters
|
206 |
+
if ($billingCountry == 'US' or $billingCountry == 'CA' or $billingCountry == 'CN' or $billingCountry == 'JP' or $billingCountry == 'MX' or
|
207 |
+
$billingCountry == 'BR' or $billingCountry == 'AR' or $billingCountry == 'ID' or $billingCountry == 'TH' or $billingCountry == 'IN') {
|
208 |
+
$regionCode = $billingAddress->getRegionCode();
|
209 |
+
if(empty($regionCode)) {
|
210 |
+
$regionCode = $billingAddress->getRegion();
|
211 |
+
}
|
212 |
+
$personalData->setState($regionCode);
|
213 |
}
|
214 |
|
215 |
// Safe Invoice "Klarna" specific personal parameters mapping
|
348 |
$deliveryData->setShippingCity($address->getCity());
|
349 |
$deliveryData->setShippingCountry($shippingCountry);
|
350 |
|
351 |
+
// US, CA, CN, JP, MX, BR, AR, ID, TH, IN always need shipping_state paramters
|
352 |
+
if ($shippingCountry == 'US' or $shippingCountry == 'CA' or $shippingCountry == 'CN' or $shippingCountry == 'JP' or $shippingCountry == 'MX' or
|
353 |
+
$shippingCountry == 'BR' or $shippingCountry == 'AR' or $shippingCountry == 'ID' or $shippingCountry == 'TH' or $shippingCountry == 'IN') {
|
354 |
+
$regionCode = $address->getRegionCode();
|
355 |
+
if(empty($regionCode)) {
|
356 |
+
$regionCode = $address->getRegion();
|
357 |
+
}
|
358 |
+
$deliveryData->setShippingState($regionCode);
|
359 |
}
|
360 |
|
361 |
// Safe Invoice type "Klarna"
|
404 |
$params['pr'] = $itemData->getPriceInclTax();
|
405 |
$params['no'] = $number;
|
406 |
$params['de'] = $itemData->getName();
|
407 |
+
// $params['va'] = number_format($itemData->getTaxPercent(), 0, '.', '');
|
408 |
+
$params['va'] = round( $itemData->getTaxPercent() * 100 ); // transfer vat in basis point format [#MAGE-186]
|
409 |
|
410 |
if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
|
411 |
$params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
|
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Capture.php
CHANGED
@@ -187,7 +187,8 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
|
|
187 |
}
|
188 |
|
189 |
// We have to load the tax percentage from the order item
|
190 |
-
$params['va'] = number_format($orderItem->getTaxPercent(), 0, '.', '');
|
|
|
191 |
|
192 |
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
|
193 |
$item->init($params);
|
@@ -200,7 +201,7 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Capture
|
|
200 |
}
|
201 |
|
202 |
// Discounts:
|
203 |
-
$discountAmount =
|
204 |
if ($discountAmount > 0) {
|
205 |
$invoicing->addItem($this->mapDiscountAsItem(-1 * $discountAmount));
|
206 |
}
|
187 |
}
|
188 |
|
189 |
// We have to load the tax percentage from the order item
|
190 |
+
// $params['va'] = number_format($orderItem->getTaxPercent(), 0, '.', '');
|
191 |
+
$params['va'] = round( $orderItem->getTaxPercent() * 100 ); // transfer vat in basis point format [#MAGE-186]
|
192 |
|
193 |
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
|
194 |
$item->init($params);
|
201 |
}
|
202 |
|
203 |
// Discounts:
|
204 |
+
$discountAmount = abs($invoice->getDiscountAmount()); // Discount Amount is positive on invoice.
|
205 |
if ($discountAmount > 0) {
|
206 |
$invoicing->addItem($this->mapDiscountAsItem(-1 * $discountAmount));
|
207 |
}
|
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Debit.php
CHANGED
@@ -164,7 +164,8 @@ class Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
|
|
164 |
|
165 |
|
166 |
// We have to load the tax percentage from the order item
|
167 |
-
$params['va'] = number_format($orderItem->getTaxPercent(), 0, '.', '');
|
|
|
168 |
|
169 |
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
|
170 |
$item->init($params);
|
164 |
|
165 |
|
166 |
// We have to load the tax percentage from the order item
|
167 |
+
// $params['va'] = number_format($orderItem->getTaxPercent(), 0, '.', '');
|
168 |
+
$params['va'] = round( $orderItem->getTaxPercent() * 100 ); // transfer vat in basis point format [#MAGE-186]
|
169 |
|
170 |
$item = new Payone_Api_Request_Parameter_Invoicing_Item();
|
171 |
$item->init($params);
|
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Model
|
17 |
+
* @subpackage Mapper
|
18 |
+
* @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
|
19 |
+
* @author Matthias Walter <info@noovias.com>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.noovias.com
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Model
|
28 |
+
* @subpackage Mapper
|
29 |
+
* @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.noovias.com
|
32 |
+
*/
|
33 |
+
class Payone_Core_Model_Mapper_ApiRequest_Payment_Genericpayment
|
34 |
+
extends Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
|
35 |
+
{
|
36 |
+
const EVENT_TYPE = 'genericpayment';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @return Payone_Api_Request_Genericpayment
|
40 |
+
*/
|
41 |
+
public function getRequest()
|
42 |
+
{
|
43 |
+
return $this->getFactory()->getRequestPaymentGenericpayment();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
48 |
+
* @return Payone_Api_Request_Genericpayment
|
49 |
+
*/
|
50 |
+
public function mapFromPayment(Mage_Sales_Model_Order_Payment $payment)
|
51 |
+
{
|
52 |
+
$this->init($payment);
|
53 |
+
|
54 |
+
$request = $this->getRequest();
|
55 |
+
|
56 |
+
$this->mapDefaultParameters($request);
|
57 |
+
|
58 |
+
// $this->mapDefaultDebitParameters($request);
|
59 |
+
// $business = $this->mapBusinessParameters();
|
60 |
+
// $request->setBusiness($business);
|
61 |
+
|
62 |
+
/** Set Invoiceing-Parameter only if enabled in Config */
|
63 |
+
// if ($this->mustTransmitInvoiceData()) {
|
64 |
+
// $invoicing = $this->mapInvoicingParameters();
|
65 |
+
// $request->setInvoicing($invoicing);
|
66 |
+
// }
|
67 |
+
|
68 |
+
$this->dispatchEvent($this->getEventName(), array('request' => $request));
|
69 |
+
$this->dispatchEvent($this->getEventPrefix() . '_all', array('request' => $request));
|
70 |
+
return $request;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param Mage_Sales_Model_Quote $quote
|
75 |
+
*/
|
76 |
+
public function mapExpressCheckoutParameters($quote, $workOrderId = null)
|
77 |
+
{
|
78 |
+
$request = $this->getRequest();
|
79 |
+
$this->mapDefaultParameters($request);
|
80 |
+
$paydata = new Payone_Api_Request_Parameter_Paydata_Paydata();
|
81 |
+
if(null === $workOrderId) {
|
82 |
+
$paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
|
83 |
+
array('key' => 'action', 'data' => Payone_Api_Enum_GenericpaymentAction::PAYPAL_ECS_SET_EXPRESSCHECKOUT)
|
84 |
+
));
|
85 |
+
} else {
|
86 |
+
$paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(
|
87 |
+
array('key' => 'action', 'data' => Payone_Api_Enum_GenericpaymentAction::PAYPAL_ECS_GET_EXPRESSCHECKOUTDETAILS)
|
88 |
+
));
|
89 |
+
$request->setWorkorderId($workOrderId);
|
90 |
+
}
|
91 |
+
$request->setPaydata($paydata);
|
92 |
+
$request->setAid($this->getConfigPayment()->getAid());
|
93 |
+
$request->setClearingtype(Payone_Enum_ClearingType::WALLET);
|
94 |
+
$request->setAmount($quote->getGrandTotal());
|
95 |
+
$request->setCurrency($quote->getQuoteCurrencyCode());
|
96 |
+
$request->setWallet(new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Wallet(array(
|
97 |
+
'wallettype' => Payone_Api_Enum_WalletType::PAYPAL_EXPRESS,
|
98 |
+
'successurl' => Mage::getUrl('*/*/return'),
|
99 |
+
'errorurl' => Mage::getUrl('*/*/error'),
|
100 |
+
'backurl' => Mage::getUrl('*/*/cancel')
|
101 |
+
)));
|
102 |
+
return $request;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @return string
|
107 |
+
*/
|
108 |
+
public function getEventType()
|
109 |
+
{
|
110 |
+
return self::EVENT_TYPE;
|
111 |
+
}
|
112 |
+
}
|
app/code/community/Payone/Core/Model/Service/Payment/Genericpayment.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Model
|
17 |
+
* @subpackage Service
|
18 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
19 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
20 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
21 |
+
* @link http://www.votum.de
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @category Payone
|
27 |
+
* @package Payone_Core_Model
|
28 |
+
* @subpackage Service
|
29 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
30 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
31 |
+
* @link http://www.votum.de
|
32 |
+
*/
|
33 |
+
class Payone_Core_Model_Service_Payment_Genericpayment
|
34 |
+
extends Payone_Core_Model_Service_Payment_Abstract
|
35 |
+
{
|
36 |
+
const EVENT_TYPE = 'genericpayment';
|
37 |
+
|
38 |
+
/** @var Payone_Api_Service_Payment_GenericpaymentInterface */
|
39 |
+
protected $serviceApiPayment = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param Payone_Api_Request_Interface $request
|
43 |
+
* @return mixed
|
44 |
+
*/
|
45 |
+
protected function perform(Payone_Api_Request_Interface $request)
|
46 |
+
{
|
47 |
+
return $this->getServiceApiPayment()->request($request);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @param Payone_Api_Service_Payment_DebitInterface $serviceApiPayment
|
52 |
+
*/
|
53 |
+
public function setServiceApiPayment(Payone_Api_Service_Payment_GenericpaymentInterface $serviceApiPayment)
|
54 |
+
{
|
55 |
+
$this->serviceApiPayment = $serviceApiPayment;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @return Payone_Api_Service_Payment_DebitInterface
|
60 |
+
*/
|
61 |
+
public function getServiceApiPayment()
|
62 |
+
{
|
63 |
+
return $this->serviceApiPayment;
|
64 |
+
}
|
65 |
+
/**
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
public function getEventType()
|
69 |
+
{
|
70 |
+
return self::EVENT_TYPE;
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Payone/Core/Model/Service/Paypal/Express/Checkout.php
ADDED
@@ -0,0 +1,643 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Model
|
17 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
18 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
19 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
20 |
+
* @link http://www.votum.de
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
*
|
25 |
+
* @category Payone
|
26 |
+
* @package Payone_Core_Model
|
27 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
28 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
29 |
+
* @link http://www.votum.de
|
30 |
+
*/
|
31 |
+
|
32 |
+
class Payone_Core_Model_Service_Paypal_Express_Checkout
|
33 |
+
{
|
34 |
+
const PAYONE_EXPRESS_CHECKOUT_WORKORDERID = 'payone_express_checkout_workorderid';
|
35 |
+
const PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN = 'paypal_express_checkout_shipping_overriden';
|
36 |
+
const PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD = 'paypal_express_checkout_shipping_method';
|
37 |
+
const PAYMENT_INFO_TRANSPORT_PAYER_ID = 'paypal_express_checkout_payer_id';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @var Mage_Sales_Model_Quote
|
41 |
+
*/
|
42 |
+
protected $_quote = null;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Payone method config instance
|
46 |
+
* @var Payone_Core_Model_Config_Payment_Method
|
47 |
+
*/
|
48 |
+
protected $_config = null;
|
49 |
+
|
50 |
+
/** @var Payone_Core_Model_Factory */
|
51 |
+
protected $factory = null;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* State helper variables
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
protected $_redirectUrl = '';
|
58 |
+
protected $_workorderid;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Order
|
62 |
+
*
|
63 |
+
* @var Mage_Sales_Model_Order
|
64 |
+
*/
|
65 |
+
protected $_order = null;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Recurring payment profiles
|
69 |
+
*
|
70 |
+
* @var array
|
71 |
+
*/
|
72 |
+
protected $_recurringPaymentProfiles = array();
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Billing agreement that might be created during order placing
|
76 |
+
*
|
77 |
+
* @var Mage_Sales_Model_Billing_Agreement
|
78 |
+
*/
|
79 |
+
protected $_billingAgreement = null;
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Locale codes supported by misc images (marks, shortcuts etc)
|
83 |
+
*
|
84 |
+
* @var array
|
85 |
+
* @link https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration#id089QD0O0TX4__id08AH904I0YK
|
86 |
+
*/
|
87 |
+
protected $_supportedImageLocales = array('de_DE', 'en_AU', 'en_GB', 'en_US', 'es_ES', 'es_XC', 'fr_FR',
|
88 |
+
'fr_XC', 'it_IT', 'ja_JP', 'nl_NL', 'pl_PL', 'zh_CN', 'zh_XC',
|
89 |
+
);
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @var Mage_Customer_Model_Session
|
93 |
+
*/
|
94 |
+
protected $_customerSession;
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Set quote and config instances
|
98 |
+
* @param array $params
|
99 |
+
*/
|
100 |
+
public function __construct($params = array())
|
101 |
+
{
|
102 |
+
if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
|
103 |
+
$this->_quote = $params['quote'];
|
104 |
+
} else {
|
105 |
+
throw new Exception('Quote instance is required.');
|
106 |
+
}
|
107 |
+
|
108 |
+
if (isset($params['config']) && $params['config'] instanceof Payone_Core_Model_Config_Payment_Method) {
|
109 |
+
$this->_config = $params['config'];
|
110 |
+
} else {
|
111 |
+
throw new Exception('Config instance is required.');
|
112 |
+
}
|
113 |
+
$this->_customerSession = Mage::getSingleton('customer/session');
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Checkout with PayPal image URL getter
|
118 |
+
* @return string
|
119 |
+
*/
|
120 |
+
public function getCheckoutShortcutImageUrl()
|
121 |
+
{
|
122 |
+
|
123 |
+
$localUrl = $this->getHelperConfig()->getConfigGeneral($this->_quote->getStoreId())->getPaymentPaypalExpressCheckout()->getPaypalExpressCheckoutImage();
|
124 |
+
if($localUrl) {
|
125 |
+
return Mage::getBaseUrl('media') . 'payone' . DS . $localUrl;
|
126 |
+
}
|
127 |
+
return sprintf('https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif', $this->_getSupportedLocaleCode(Mage::app()->getLocale()->getLocaleCode()));
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Specify quote payment method
|
132 |
+
*
|
133 |
+
* @param array $data
|
134 |
+
* @return array
|
135 |
+
*/
|
136 |
+
public function savePayment($data)
|
137 |
+
{
|
138 |
+
if ($this->_quote->isVirtual()) {
|
139 |
+
$this->_quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
140 |
+
} else {
|
141 |
+
$this->_quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
142 |
+
}
|
143 |
+
|
144 |
+
// shipping totals may be affected by payment method
|
145 |
+
if (!$this->_quote->isVirtual() && $this->_quote->getShippingAddress()) {
|
146 |
+
$this->_quote->getShippingAddress()->setCollectShippingRates(true);
|
147 |
+
}
|
148 |
+
|
149 |
+
// $data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT
|
150 |
+
// | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY
|
151 |
+
// | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY
|
152 |
+
// | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
|
153 |
+
// | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
|
154 |
+
|
155 |
+
$data['checks'] = array();
|
156 |
+
|
157 |
+
$payment = $this->_quote->getPayment();
|
158 |
+
|
159 |
+
$payment->importData($data);
|
160 |
+
|
161 |
+
$this->_quote->save();
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Reserve order ID for specified quote and start checkout on PayPal
|
166 |
+
*
|
167 |
+
* @return mixed
|
168 |
+
*/
|
169 |
+
public function start()
|
170 |
+
{
|
171 |
+
$this->_quote->collectTotals();
|
172 |
+
|
173 |
+
if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
|
174 |
+
Mage::throwException(Mage::helper('payone_core')->__('PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
|
175 |
+
}
|
176 |
+
|
177 |
+
$this->_quote->reserveOrderId()->save();
|
178 |
+
|
179 |
+
$service = $this->getFactory()->getServicePaymentGenericpayment($this->_config);
|
180 |
+
$mapper = $service->getMapper();
|
181 |
+
$request = $mapper->mapExpressCheckoutParameters($this->_quote);
|
182 |
+
$response = $this->getFactory()->getServiceApiPaymentGenericpayment()->request($request);
|
183 |
+
|
184 |
+
if($response instanceof Payone_Api_Response_Genericpayment_Redirect) {
|
185 |
+
$this->_redirectUrl = $response->getRedirecturl();
|
186 |
+
$this->_workorderid = $response->getWorkorderId();
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Request with $workOrderId and saving the address
|
192 |
+
*
|
193 |
+
* @param string $workOrderId
|
194 |
+
*/
|
195 |
+
public function returnFromPaypal($workOrderId)
|
196 |
+
{
|
197 |
+
$service = $this->getFactory()->getServicePaymentGenericpayment($this->_config);
|
198 |
+
$mapper = $service->getMapper();
|
199 |
+
$request = $mapper->mapExpressCheckoutParameters($this->_quote, $workOrderId);
|
200 |
+
|
201 |
+
$response = $this->getFactory()->getServiceApiPaymentGenericpayment()->request($request);
|
202 |
+
|
203 |
+
$this->_ignoreAddressValidation();
|
204 |
+
|
205 |
+
if($response instanceof Payone_Api_Response_Genericpayment_Ok) {
|
206 |
+
// @var Mage_Sales_Model_Quote_Address
|
207 |
+
$billingAddress = $this->_quote->getBillingAddress();
|
208 |
+
// @var Mage_Sales_Model_Quote_Address
|
209 |
+
$shippingAddress = $this->_quote->getShippingAddress();
|
210 |
+
foreach($response->getPayData()->getItems() as $item) {
|
211 |
+
if($item->getKey() == 'email') {
|
212 |
+
$billingAddress->setEmail($item->getData());
|
213 |
+
$shippingAddress->setEmail($item->getData());
|
214 |
+
}
|
215 |
+
if($item->getKey() == 'shipping_zip') {
|
216 |
+
$billingAddress->setPostcode($item->getData());
|
217 |
+
$shippingAddress->setPostcode($item->getData());
|
218 |
+
}
|
219 |
+
if($item->getKey() == 'shipping_country') {
|
220 |
+
$billingAddress->setCountryId($item->getData());
|
221 |
+
$shippingAddress->setCountryId($item->getData());
|
222 |
+
}
|
223 |
+
if($item->getKey() == 'shipping_state' && $item->getData() != 'Empty') {
|
224 |
+
$billingAddress->setRegion($item->getData());
|
225 |
+
$shippingAddress->setRegion($item->getData());
|
226 |
+
}
|
227 |
+
if($item->getKey() == 'shipping_city') {
|
228 |
+
$billingAddress->setCity($item->getData());
|
229 |
+
$shippingAddress->setCity($item->getData());
|
230 |
+
}
|
231 |
+
if($item->getKey() == 'shipping_street') {
|
232 |
+
$billingAddress->setStreet($item->getData());
|
233 |
+
$shippingAddress->setStreet($item->getData());
|
234 |
+
}
|
235 |
+
if($item->getKey() == 'shipping_firstname') {
|
236 |
+
$billingAddress->setFirstname($item->getData());
|
237 |
+
$shippingAddress->setFirstname($item->getData());
|
238 |
+
$this->_quote->setCustomerFirstname($item->getData());
|
239 |
+
}
|
240 |
+
if($item->getKey() == 'shipping_lastname') {
|
241 |
+
$billingAddress->setLastname($item->getData());
|
242 |
+
$shippingAddress->setLastname($item->getData());
|
243 |
+
$this->_quote->setCustomerLastname($item->getData());
|
244 |
+
}
|
245 |
+
}
|
246 |
+
$this->_quote->setBillingAddress($billingAddress);
|
247 |
+
if (!$this->_quote->getIsVirtual()) {
|
248 |
+
$shippingAddress->setCollectShippingRates(true);
|
249 |
+
$shippingAddress->setSameAsBilling(0);
|
250 |
+
$this->_quote->setShippingAddress($shippingAddress);
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
$this->_quote->getPayment()->setAdditionalInformation(self::PAYONE_EXPRESS_CHECKOUT_WORKORDERID, $workOrderId)
|
255 |
+
->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $workOrderId);
|
256 |
+
|
257 |
+
$this->_quote->collectTotals()->save();
|
258 |
+
}
|
259 |
+
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Preparing order review
|
264 |
+
*/
|
265 |
+
public function prepareOrderReview()
|
266 |
+
{
|
267 |
+
$payment = $this->_quote->getPayment();
|
268 |
+
if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) {
|
269 |
+
Mage::throwException(Mage::helper('paypal')->__('Payer is not identified.'));
|
270 |
+
}
|
271 |
+
$this->_quote->setMayEditShippingAddress(
|
272 |
+
1 != $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN)
|
273 |
+
);
|
274 |
+
$this->_quote->setMayEditShippingMethod(
|
275 |
+
'' == $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD)
|
276 |
+
);
|
277 |
+
$this->_ignoreAddressValidation();
|
278 |
+
$this->_quote->collectTotals()->save();
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Place the order and recurring payment profiles when customer returned from paypal
|
283 |
+
* Until this moment all quote data must be valid
|
284 |
+
*
|
285 |
+
* @param string $workOrderId
|
286 |
+
* @param string $shippingMethodCode
|
287 |
+
*/
|
288 |
+
public function place($workOrderId, $shippingMethodCode = null)
|
289 |
+
{
|
290 |
+
if ($shippingMethodCode) {
|
291 |
+
$this->updateShippingMethod($shippingMethodCode);
|
292 |
+
}
|
293 |
+
|
294 |
+
$isNewCustomer = false;
|
295 |
+
switch ($this->getCheckoutMethod()) {
|
296 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST:
|
297 |
+
$this->_prepareGuestQuote();
|
298 |
+
break;
|
299 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER:
|
300 |
+
$this->_prepareNewCustomerQuote();
|
301 |
+
$isNewCustomer = true;
|
302 |
+
break;
|
303 |
+
default:
|
304 |
+
$this->_prepareCustomerQuote();
|
305 |
+
break;
|
306 |
+
}
|
307 |
+
|
308 |
+
$this->_ignoreAddressValidation();
|
309 |
+
$this->_quote->collectTotals();
|
310 |
+
$service = Mage::getModel('sales/service_quote', $this->_quote);
|
311 |
+
$service->submitAll();
|
312 |
+
$this->_quote->save();
|
313 |
+
|
314 |
+
if ($isNewCustomer) {
|
315 |
+
try {
|
316 |
+
$this->_involveNewCustomer();
|
317 |
+
} catch (Exception $e) {
|
318 |
+
Mage::logException($e);
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
$this->_recurringPaymentProfiles = $service->getRecurringPaymentProfiles();
|
323 |
+
|
324 |
+
$order = $service->getOrder();
|
325 |
+
if (!$order) {
|
326 |
+
return;
|
327 |
+
}
|
328 |
+
$this->_billingAgreement = $order->getPayment()->getBillingAgreement();
|
329 |
+
|
330 |
+
switch ($order->getState()) {
|
331 |
+
// even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
|
332 |
+
case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
|
333 |
+
// TODO
|
334 |
+
break;
|
335 |
+
// regular placement, when everything is ok
|
336 |
+
case Mage_Sales_Model_Order::STATE_PROCESSING:
|
337 |
+
case Mage_Sales_Model_Order::STATE_COMPLETE:
|
338 |
+
case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
|
339 |
+
$order->sendNewOrderEmail();
|
340 |
+
break;
|
341 |
+
}
|
342 |
+
$this->_order = $order;
|
343 |
+
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Return order
|
349 |
+
*
|
350 |
+
* @return Mage_Sales_Model_Order
|
351 |
+
*/
|
352 |
+
public function getOrder()
|
353 |
+
{
|
354 |
+
return $this->_order;
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Set shipping method to quote, if needed
|
359 |
+
* @param string $methodCode
|
360 |
+
*/
|
361 |
+
public function updateShippingMethod($methodCode)
|
362 |
+
{
|
363 |
+
if (!$this->_quote->getIsVirtual() && $shippingAddress = $this->_quote->getShippingAddress()) {
|
364 |
+
if ($methodCode != $shippingAddress->getShippingMethod()) {
|
365 |
+
$this->_ignoreAddressValidation();
|
366 |
+
$shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
|
367 |
+
$this->_quote->collectTotals();
|
368 |
+
}
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Make sure addresses will be saved without validation errors
|
374 |
+
*/
|
375 |
+
private function _ignoreAddressValidation()
|
376 |
+
{
|
377 |
+
$this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
|
378 |
+
if (!$this->_quote->getIsVirtual()) {
|
379 |
+
$this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
|
384 |
+
/**
|
385 |
+
* @param Payone_Core_Model_Factory $factory
|
386 |
+
*/
|
387 |
+
public function setFactory(Payone_Core_Model_Factory $factory)
|
388 |
+
{
|
389 |
+
$this->factory = $factory;
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* @return Payone_Core_Model_Factory
|
394 |
+
*/
|
395 |
+
public function getFactory()
|
396 |
+
{
|
397 |
+
if ($this->factory === null) {
|
398 |
+
$this->factory = Mage::getModel('payone_core/factory');
|
399 |
+
}
|
400 |
+
return $this->factory;
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* @return Payone_Core_Helper_Config
|
405 |
+
*/
|
406 |
+
protected function getHelperConfig()
|
407 |
+
{
|
408 |
+
return $this->getFactory()->helperConfig();
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Check whether specified locale code is supported. Fallback to en_US
|
413 |
+
*
|
414 |
+
* @param string $localeCode
|
415 |
+
* @return string
|
416 |
+
*/
|
417 |
+
protected function _getSupportedLocaleCode($localeCode = null)
|
418 |
+
{
|
419 |
+
if (!$localeCode || !in_array($localeCode, $this->_supportedImageLocales)) {
|
420 |
+
return 'en_US';
|
421 |
+
}
|
422 |
+
return $localeCode;
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Determine whether redirect somewhere specifically is required
|
427 |
+
*
|
428 |
+
* @return string
|
429 |
+
*/
|
430 |
+
public function getRedirectUrl()
|
431 |
+
{
|
432 |
+
return $this->_redirectUrl;
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Determine whether redirect somewhere specifically is required
|
437 |
+
*
|
438 |
+
* @return integer
|
439 |
+
*/
|
440 |
+
public function getWorkOrderId()
|
441 |
+
{
|
442 |
+
return $this->_workorderid;
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Get checkout method
|
447 |
+
*
|
448 |
+
* @return string
|
449 |
+
*/
|
450 |
+
public function getCheckoutMethod()
|
451 |
+
{
|
452 |
+
if ($this->getCustomerSession()->isLoggedIn()) {
|
453 |
+
return Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
|
454 |
+
}
|
455 |
+
if (!$this->_quote->getCheckoutMethod()) {
|
456 |
+
if (Mage::helper('checkout')->isAllowedGuestCheckout($this->_quote)) {
|
457 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
|
458 |
+
} else {
|
459 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
|
460 |
+
}
|
461 |
+
}
|
462 |
+
return $this->_quote->getCheckoutMethod();
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
* Get customer session object
|
467 |
+
*
|
468 |
+
* @return Mage_Customer_Model_Session
|
469 |
+
*/
|
470 |
+
public function getCustomerSession()
|
471 |
+
{
|
472 |
+
return $this->_customerSession;
|
473 |
+
}
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Prepare quote for guest checkout order submit
|
477 |
+
*
|
478 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
479 |
+
*/
|
480 |
+
protected function _prepareGuestQuote()
|
481 |
+
{
|
482 |
+
$quote = $this->_quote;
|
483 |
+
$quote->setCustomerId(null)
|
484 |
+
->setCustomerEmail($quote->getBillingAddress()->getEmail())
|
485 |
+
->setCustomerIsGuest(true)
|
486 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
487 |
+
return $this;
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Prepare quote for customer registration and customer order submit
|
492 |
+
* and restore magento customer data from quote
|
493 |
+
*
|
494 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
495 |
+
*/
|
496 |
+
protected function _prepareNewCustomerQuote()
|
497 |
+
{
|
498 |
+
$quote = $this->_quote;
|
499 |
+
$billing = $quote->getBillingAddress();
|
500 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
501 |
+
|
502 |
+
$customerId = $this->_lookupCustomerId();
|
503 |
+
if ($customerId) {
|
504 |
+
$this->getCustomerSession()->loginById($customerId);
|
505 |
+
return $this->_prepareCustomerQuote();
|
506 |
+
}
|
507 |
+
|
508 |
+
$customer = $quote->getCustomer();
|
509 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
510 |
+
$customerBilling = $billing->exportCustomerAddress();
|
511 |
+
$customer->addAddress($customerBilling);
|
512 |
+
$billing->setCustomerAddress($customerBilling);
|
513 |
+
$customerBilling->setIsDefaultBilling(true);
|
514 |
+
if ($shipping && !$shipping->getSameAsBilling()) {
|
515 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
516 |
+
$customer->addAddress($customerShipping);
|
517 |
+
$shipping->setCustomerAddress($customerShipping);
|
518 |
+
$customerShipping->setIsDefaultShipping(true);
|
519 |
+
} elseif ($shipping) {
|
520 |
+
$customerBilling->setIsDefaultShipping(true);
|
521 |
+
}
|
522 |
+
/**
|
523 |
+
* @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender
|
524 |
+
*/
|
525 |
+
if ($quote->getCustomerDob() && !$billing->getCustomerDob()) {
|
526 |
+
$billing->setCustomerDob($quote->getCustomerDob());
|
527 |
+
}
|
528 |
+
|
529 |
+
if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) {
|
530 |
+
$billing->setCustomerTaxvat($quote->getCustomerTaxvat());
|
531 |
+
}
|
532 |
+
|
533 |
+
if ($quote->getCustomerGender() && !$billing->getCustomerGender()) {
|
534 |
+
$billing->setCustomerGender($quote->getCustomerGender());
|
535 |
+
}
|
536 |
+
|
537 |
+
Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
|
538 |
+
$customer->setEmail($quote->getCustomerEmail());
|
539 |
+
$customer->setPrefix($quote->getCustomerPrefix());
|
540 |
+
$customer->setFirstname($quote->getCustomerFirstname());
|
541 |
+
$customer->setMiddlename($quote->getCustomerMiddlename());
|
542 |
+
$customer->setLastname($quote->getCustomerLastname());
|
543 |
+
$customer->setSuffix($quote->getCustomerSuffix());
|
544 |
+
$customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
|
545 |
+
$customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
|
546 |
+
$customer->save();
|
547 |
+
$quote->setCustomer($customer);
|
548 |
+
|
549 |
+
return $this;
|
550 |
+
}
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Prepare quote for customer order submit
|
554 |
+
*
|
555 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
556 |
+
*/
|
557 |
+
protected function _prepareCustomerQuote()
|
558 |
+
{
|
559 |
+
$quote = $this->_quote;
|
560 |
+
$billing = $quote->getBillingAddress();
|
561 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
562 |
+
|
563 |
+
$customer = $this->getCustomerSession()->getCustomer();
|
564 |
+
if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
|
565 |
+
$customerBilling = $billing->exportCustomerAddress();
|
566 |
+
$customer->addAddress($customerBilling);
|
567 |
+
$billing->setCustomerAddress($customerBilling);
|
568 |
+
}
|
569 |
+
if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
|
570 |
+
|| (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
|
571 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
572 |
+
$customer->addAddress($customerShipping);
|
573 |
+
$shipping->setCustomerAddress($customerShipping);
|
574 |
+
}
|
575 |
+
|
576 |
+
if (isset($customerBilling) && !$customer->getDefaultBilling()) {
|
577 |
+
$customerBilling->setIsDefaultBilling(true);
|
578 |
+
}
|
579 |
+
if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) {
|
580 |
+
$customerBilling->setIsDefaultShipping(true);
|
581 |
+
} elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
|
582 |
+
$customerShipping->setIsDefaultShipping(true);
|
583 |
+
}
|
584 |
+
$quote->setCustomer($customer);
|
585 |
+
|
586 |
+
return $this;
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* Checks if customer with email coming from Express checkout exists
|
591 |
+
*
|
592 |
+
* @return int
|
593 |
+
*/
|
594 |
+
protected function _lookupCustomerId()
|
595 |
+
{
|
596 |
+
return Mage::getModel('customer/customer')
|
597 |
+
->setWebsiteId(Mage::app()->getWebsite()->getId())
|
598 |
+
->loadByEmail($this->_quote->getCustomerEmail())
|
599 |
+
->getId();
|
600 |
+
}
|
601 |
+
|
602 |
+
/**
|
603 |
+
* Involve new customer to system
|
604 |
+
*
|
605 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
606 |
+
*/
|
607 |
+
protected function _involveNewCustomer()
|
608 |
+
{
|
609 |
+
$customer = $this->_quote->getCustomer();
|
610 |
+
if ($customer->isConfirmationRequired()) {
|
611 |
+
$customer->sendNewAccountEmail('confirmation');
|
612 |
+
$url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
|
613 |
+
$this->getCustomerSession()->addSuccess(
|
614 |
+
Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
|
615 |
+
);
|
616 |
+
} else {
|
617 |
+
$customer->sendNewAccountEmail();
|
618 |
+
$this->getCustomerSession()->loginById($customer->getId());
|
619 |
+
}
|
620 |
+
return $this;
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Return recurring payment profiles
|
625 |
+
*
|
626 |
+
* @return array
|
627 |
+
*/
|
628 |
+
public function getRecurringPaymentProfiles()
|
629 |
+
{
|
630 |
+
return $this->_recurringPaymentProfiles;
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Get created billing agreement
|
635 |
+
*
|
636 |
+
* @return Mage_Sales_Model_Billing_Agreement|null
|
637 |
+
*/
|
638 |
+
public function getBillingAgreement()
|
639 |
+
{
|
640 |
+
return $this->_billingAgreement;
|
641 |
+
}
|
642 |
+
|
643 |
+
}
|
app/code/community/Payone/Core/Model/Session.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
7 |
+
* that is bundled with this package in the file LICENSE.txt
|
8 |
+
*
|
9 |
+
* DISCLAIMER
|
10 |
+
*
|
11 |
+
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
|
12 |
+
* versions in the future. If you wish to customize Payone_Core for your
|
13 |
+
* needs please refer to http://www.payone.de for more information.
|
14 |
+
*
|
15 |
+
* @category Payone
|
16 |
+
* @package Payone_Core_Model
|
17 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
18 |
+
* @author Edward Mateja <edward.mateja@votum.de>
|
19 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
20 |
+
* @link http://www.votum.de
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
*
|
25 |
+
* @category Payone
|
26 |
+
* @package Payone_Core_Model
|
27 |
+
* @copyright Copyright (c) 2012 <info@votum.de> - www.votum.de
|
28 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
29 |
+
* @link http://www.votum.de
|
30 |
+
*/
|
31 |
+
|
32 |
+
class Payone_Core_Model_Session extends Mage_Core_Model_Session_Abstract
|
33 |
+
{
|
34 |
+
public function __construct()
|
35 |
+
{
|
36 |
+
$this->init('payone');
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Payone/Core/controllers/Checkout/Onepage/PaymentController.php
CHANGED
@@ -106,11 +106,11 @@ class Payone_Core_Checkout_Onepage_PaymentController extends Payone_Core_Control
|
|
106 |
}
|
107 |
|
108 |
// Load transaction status via order id, check for APPOINTED:
|
109 |
-
$txStatus = $this->getFactory()->
|
110 |
$txStatus->load($order->getIncrementId(), 'reference');
|
111 |
|
112 |
-
if (!$txStatus->hasData() or !$txStatus->getId
|
113 |
-
// Wrong or no
|
114 |
$message = $helper->__('Sorry, your payment has not been confirmed by the payment provider.');
|
115 |
$checkoutSession->addError($message);
|
116 |
return false;
|
106 |
}
|
107 |
|
108 |
// Load transaction status via order id, check for APPOINTED:
|
109 |
+
$txStatus = $this->getFactory()->getModelTransaction();
|
110 |
$txStatus->load($order->getIncrementId(), 'reference');
|
111 |
|
112 |
+
if (!$txStatus->hasData() or !$txStatus->getId()) {// or !$txStatus->isAppointed()
|
113 |
+
// Wrong or no transaction for this order, failure.
|
114 |
$message = $helper->__('Sorry, your payment has not been confirmed by the payment provider.');
|
115 |
$checkoutSession->addError($message);
|
116 |
return false;
|
app/code/community/Payone/Core/controllers/PexpressController.php
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|