Skip to content

Commit

Permalink
Merge pull request #490 from BoulangerV/MAGE-533-PPE_Error_105
Browse files Browse the repository at this point in the history
MAGE-533: Add Redirect handling for PPE Checkout
  • Loading branch information
jvarelmann authored Apr 4, 2023
2 parents 46427d3 + 757cd23 commit 233fb40
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
53 changes: 53 additions & 0 deletions app/code/community/Payone/Core/Exception/PaypalExpressRedirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
*
* NOTICE OF LICENSE
*
* This source file is subject to the GNU General Public License (GPL 3)
* that is bundled with this package in the file LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer
* versions in the future. If you wish to customize Payone_Core for your
* needs please refer to http://www.payone.de for more information.
*
* @category Payone
* @package Payone_Core_Exception
* @subpackage
* @copyright Copyright (c) 2023 <[email protected]> - www.fatchip.de
* @author FATCHIP GmbH <[email protected]>
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
* @link http://www.fatchip.de
*/

/**
*
* @category Payone
* @package Payone_Core_Exception
* @subpackage
* @copyright Copyright (c) 2023 <[email protected]> - www.fatchip.de
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
* @link http://www.fatchip.de
*/
class Payone_Core_Exception_PaypalExpressRedirect extends Exception
{
/** @var string */
private $redirectUrl = "";

/**
* @return string
*/
public function getRedirectUrl()
{
return $this->redirectUrl;
}

/**
* @param string $redirectUrl
*/
public function setRedirectUrl(string $redirectUrl)
{
$this->redirectUrl = $redirectUrl;
}
}
10 changes: 10 additions & 0 deletions app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ public function handle(Payone_Api_Response_Interface $response)
$sRedirectUrl = Mage::helper('payone_core/url')->getMagentoUrl('payone_core/iframe/show');
}

if ($paymentMethod->getMethodType() == Payone_Core_Model_System_Config_PaymentMethodType::WALLETPAYPALEXPRESS) {
$aUrlDetails = parse_url($sRedirectUrl);
parse_str($aUrlDetails['query'], $aURLParameters);
if ($aURLParameters['useraction'] == 'continue') {
$oEx = new Payone_Core_Exception_PaypalExpressRedirect();
$oEx->setRedirectUrl($sRedirectUrl);
throw $oEx;
}
}

$paymentMethod->setRedirectUrl($sRedirectUrl);

$orderId = $order->getEntityId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ public function placeOrderAction()
catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
catch (Payone_Core_Exception_PaypalExpressRedirect $e) {
// MAGE-533: Renew OrderId after response redirect from PPal Express checkout
$this->_quote->setReservedOrderId('');
$this->_quote->reserveOrderId()->save();
$this->_redirectUrl($e->getRedirectUrl());
return;
}
catch (Exception $e) {
$this->_getSession()->addError($this->__('Unable to place the order.'));
Mage::logException($e);
Expand Down

0 comments on commit 233fb40

Please sign in to comment.