Skip to content

Commit

Permalink
Merge pull request #303 from OXID-eSales/bugfix/PSPAYPAL-784-error-af…
Browse files Browse the repository at this point in the history
…ter-paypal-express

Bugfix/pspaypal 784 error after paypal express
  • Loading branch information
mariolorenz authored Jun 21, 2024
2 parents bb24c12 + efb82d7 commit 99fbba8
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.3.9] - 2024-06-18

- [0007661](https://bugs.oxid-esales.com/view.php?id=7661): Error in the order process the total value did not match the total of the items and shipping cost of the order

## [1.3.8] - 2024-06-06

- Update Client Version v1.0.10
Expand Down
5 changes: 4 additions & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* See LICENSE file for license details.
*/

use OxidEsales\Eshop\Application\Component\BasketComponent;
use OxidEsales\Eshop\Application\Component\UserComponent;
use OxidEsales\Eshop\Application\Controller\OrderController;
use OxidEsales\Eshop\Application\Controller\PaymentController;
Expand All @@ -20,6 +21,7 @@
use OxidEsales\Eshop\Core\InputValidator;
use OxidEsales\Eshop\Core\ShopControl;
use OxidEsales\Eshop\Core\ViewConfig;
use OxidSolutionCatalysts\PayPal\Component\BasketComponent as PayPalBasketComponent;
use OxidSolutionCatalysts\PayPal\Component\UserComponent as PayPalUserComponent;
use OxidSolutionCatalysts\PayPal\Controller\Admin\PayPalConfigController;
use OxidSolutionCatalysts\PayPal\Controller\Admin\PayPalOrderController;
Expand Down Expand Up @@ -56,7 +58,7 @@
'en' => 'Use of the online payment service from PayPal. Documentation: <a href="https://docs.oxid-esales.com/modules/paypal-checkout/en/latest/" target="_blank">PayPal Checkout</a>'
],
'thumbnail' => 'out/img/paypal.png',
'version' => '1.3.7',
'version' => '1.3.9-rc.1',
'author' => 'OXID eSales AG',
'url' => 'https://www.oxid-esales.com',
'email' => '[email protected]',
Expand All @@ -73,6 +75,7 @@
OrderController::class => PayPalFrontEndOrderController::class,
PaymentController::class => PayPalPaymentController::class,
UserComponent::class => PayPalUserComponent::class,
BasketComponent::class => PayPalBasketComponent::class,
OrderMain::class => PayPalOrderMainController::class,
OrderOverview::class => PayPalOrderOverviewController::class,
State::class => PayPalState::class
Expand Down
63 changes: 63 additions & 0 deletions src/Component/BasketComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

namespace OxidSolutionCatalysts\PayPal\Component;

use OxidEsales\Eshop\Core\Registry;
use OxidSolutionCatalysts\PayPal\Core\PayPalSession;

/**
* @mixin \OxidEsales\Eshop\Application\Component\BasketComponent
*/
class BasketComponent extends BasketComponent_parent
{
/**
* @param $sProductId
* @param $dAmount
* @param $aSel
* @param $aPersParam
* @param $blOverride
* @return mixed
*/
public function changeBasket(
$sProductId = null,
$dAmount = null,
$aSel = null,
$aPersParam = null,
$blOverride = true
) {
$this->resetExpressOrderAndShowError();
return parent::changeBasket($sProductId, $dAmount, $aSel, $aPersParam, $blOverride);
}

/**
* @param $sProductId
* @param $dAmount
* @param $aSel
* @param $aPersParam
* @param $blOverride
* @return mixed
*/
public function toBasket($sProductId = null, $dAmount = null, $aSel = null, $aPersParam = null, $blOverride = false)
{
$this->resetExpressOrderAndShowError();
return parent::toBasket($sProductId, $dAmount, $aSel, $aPersParam, $blOverride);
}

/**
* Resets the session if the user has previously authorized a payment
* with PayPal Express and is now adding or changing an item to the basket.
* @return void
*/
protected function resetExpressOrderAndShowError() {
if (PayPalSession::isPayPalExpressOrderActive()) {
PayPalSession::unsetPayPalOrderId();
Registry::getSession()->getBasket()->setPayment(null);
Registry::getUtilsView()->addErrorToDisplay('OSCPAYPAL_KILL_EXPRESS_SESSION_REASON');
}
}
}
2 changes: 2 additions & 0 deletions src/Controller/ProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OxidSolutionCatalysts\PayPal\Core\Utils\PayPalAddressResponseToOxidAddress;
use OxidSolutionCatalysts\PayPalApi\Model\Orders\Order as PayPalApiOrder;
use OxidSolutionCatalysts\PayPal\Core\PayPalDefinitions;
use stdClass;

/**
* Server side interface for PayPal smart buttons.
Expand Down Expand Up @@ -146,6 +147,7 @@ public function approveOrder()
PayPalSession::unsetPayPalOrderId();
Registry::getSession()->getBasket()->setPayment(null);
}

$this->outputJson($response);
}

Expand Down
3 changes: 2 additions & 1 deletion translations/de/oscpaypal_de_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
'OSC_PAYPAL_ORDER_EXECUTION_IN_PROGRESS' => 'Ihre Bestellung wird geprüft, das kann bis zu 60 Sekunden dauern. Bitte kurz warten und dann erneut auf "zahlungspflichtig bestellen" klicken.',
'OSC_PAYPAL_LOG_IN_TO_CONTINUE' => 'Bitte loggen Sie sich ein, um die Bestellung abzuschliessen.',
'OSC_PAYPAL_3DSECURITY_ERROR' => 'Die Sicherheitsüberprüfung ist fehlgeschlagen, bitte erneut versuchen.',
'OSC_PAYPAL_ORDEREXECUTION_ERROR' => 'Der Bezahlvorgang wurde abgebrochen.'
'OSC_PAYPAL_ORDEREXECUTION_ERROR' => 'Der Bezahlvorgang wurde abgebrochen.',
'OSCPAYPAL_KILL_EXPRESS_SESSION_REASON' => 'Der Warenkorb wurde geändert. Aus diesem Grund wurde der aktive PayPal-Zahlvorgang automatisch abgebrochen. Bitte starten Sie die Zahlung mit PayPal erneut. Es wurde noch kein Geld von PayPal eingezogen.',
];
3 changes: 2 additions & 1 deletion translations/en/oscpaypal_en_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
'OSC_PAYPAL_LOG_IN_TO_CONTINUE' => 'Please log in to continue checking out.',

'OSC_PAYPAL_3DSECURITY_ERROR' => 'Security check failed, please retry.',
'OSC_PAYPAL_ORDEREXECUTION_ERROR' => 'Payment process could not be completed.'
'OSC_PAYPAL_ORDEREXECUTION_ERROR' => 'Payment process could not be completed.',
'OSCPAYPAL_KILL_EXPRESS_SESSION_REASON' => 'The shopping cart has been changed. For this reason, the active PayPal payment process was automatically canceled. Please restart the payment with PayPal. No money has been collected from PayPal yet.',
];
12 changes: 6 additions & 6 deletions views/tpl/shared/paymentbuttons.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
[{/if}]
[{assign var="sToken" value=$oViewConf->getSessionChallengeToken()}]
[{assign var="sSelfLink" value=$oViewConf->getSslSelfLink()|replace:"&amp;":"&"}]
[{if $buttonId == "oscpaypal_sepa" || $buttonId == "oscpaypal_cc_alternative"}]
[{if $buttonId === "oscpaypal_sepa" || $buttonId === "oscpaypal_cc_alternative"}]
FUNDING_SOURCES = [
paypal.FUNDING.[{if $buttonId == "oscpaypal_sepa"}]SEPA[{elseif $buttonId == "oscpaypal_cc_alternative"}]CARD[{/if}]
paypal.FUNDING.[{if $buttonId === "oscpaypal_sepa"}]SEPA[{elseif $buttonId === "oscpaypal_cc_alternative"}]CARD[{/if}]
];
// Loop over each funding source/payment method
FUNDING_SOURCES.forEach(function (fundingSource) {
Expand Down Expand Up @@ -37,9 +37,9 @@
}).then(function (res) {
return res.json();
}).then(function (data) {
if (data.status == "ERROR") {
if (data.status === "ERROR") {
location.reload();
} else if (data.id && data.status == "APPROVED") {
} else if (data.id && data.status === "APPROVED") {
location.replace('[{$sSelfLink|cat:"cl=order"}]');
}
})
Expand Down Expand Up @@ -88,9 +88,9 @@
}).then(function (res) {
return res.json();
}).then(function (data) {
if (data.status == "ERROR") {
if (data.status === "ERROR") {
location.reload();
} else if (data.id && data.status == "APPROVED") {
} else if (data.id && data.status === "APPROVED") {
location.replace('[{$sSelfLink|cat:"cl=order"}]');
}
})
Expand Down

0 comments on commit 99fbba8

Please sign in to comment.