From 9b9fe8fdc222a14095422c2dab8313b1d0d3f933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Gust?= Date: Tue, 18 Jun 2024 17:12:11 +0200 Subject: [PATCH 1/8] PSPAYPAL-789 fix basket empty after paypal express come back --- src/Controller/ProxyController.php | 5 +++++ views/tpl/shared/paymentbuttons.tpl | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Controller/ProxyController.php b/src/Controller/ProxyController.php index ee8de6d1..83740a41 100644 --- a/src/Controller/ProxyController.php +++ b/src/Controller/ProxyController.php @@ -100,6 +100,8 @@ public function approveOrder() $userRepository = $this->getServiceFromContainer(UserRepository::class); $paypalEmail = (string) $response->payer->email_address; + $basket = Registry::getSession()->getBasket(); + $nonGuestAccountDetected = false; if ($userRepository->userAccountExists($paypalEmail)) { //got a non-guest account, so either we log in or redirect customer to login step @@ -110,6 +112,8 @@ public function approveOrder() $userComponent = oxNew(UserComponent::class); $userComponent->createPayPalGuestUser($response); } + + Registry::getSession()->setBasket($basket); } if ($user = $this->getUser()) { @@ -146,6 +150,7 @@ public function approveOrder() PayPalSession::unsetPayPalOrderId(); Registry::getSession()->getBasket()->setPayment(null); } + $response->sessionId = Registry::getSession()->getId(); $this->outputJson($response); } diff --git a/views/tpl/shared/paymentbuttons.tpl b/views/tpl/shared/paymentbuttons.tpl index d30d1540..bb4f840e 100644 --- a/views/tpl/shared/paymentbuttons.tpl +++ b/views/tpl/shared/paymentbuttons.tpl @@ -40,7 +40,11 @@ if (data.status == "ERROR") { location.reload(); } else if (data.id && data.status == "APPROVED") { - location.replace('[{$sSelfLink|cat:"cl=order"}]'); + if (data.sessionId) { + location.replace('/?cl=order&force_sid=' + data.sessionId); + } else { + location.replace('[{$sSelfLink|cat:"cl=order"}]'); + } } }) }, @@ -91,7 +95,11 @@ if (data.status == "ERROR") { location.reload(); } else if (data.id && data.status == "APPROVED") { - location.replace('[{$sSelfLink|cat:"cl=order"}]'); + if (data.sessionId) { + location.replace('/?cl=order&force_sid=' + data.sessionId); + } else { + location.replace('[{$sSelfLink|cat:"cl=order"}]'); + } } }) }, From ec228588c5ef11e60c3df6f6357bdd31cf80ef12 Mon Sep 17 00:00:00 2001 From: Danny Date: Thu, 6 Jun 2024 13:32:53 +0200 Subject: [PATCH 2/8] PSPAYPAL-758: takeover from oxid6 --- metadata.php | 3 ++ src/Component/BasketComponent.php | 63 +++++++++++++++++++++++++++ translations/de/oscpaypal_de_lang.php | 3 +- translations/en/oscpaypal_en_lang.php | 3 +- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 src/Component/BasketComponent.php diff --git a/metadata.php b/metadata.php index b4464581..ed9253b6 100644 --- a/metadata.php +++ b/metadata.php @@ -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; @@ -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; @@ -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 diff --git a/src/Component/BasketComponent.php b/src/Component/BasketComponent.php new file mode 100644 index 00000000..d63dd8d0 --- /dev/null +++ b/src/Component/BasketComponent.php @@ -0,0 +1,63 @@ +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'); + } + } +} diff --git a/translations/de/oscpaypal_de_lang.php b/translations/de/oscpaypal_de_lang.php index 0029ac91..d98149d7 100644 --- a/translations/de/oscpaypal_de_lang.php +++ b/translations/de/oscpaypal_de_lang.php @@ -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.', ]; diff --git a/translations/en/oscpaypal_en_lang.php b/translations/en/oscpaypal_en_lang.php index a2615c22..4ab54c58 100644 --- a/translations/en/oscpaypal_en_lang.php +++ b/translations/en/oscpaypal_en_lang.php @@ -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.', ]; From 4a3d33419e01e169207f146e35dd5fb8faf7dec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Gust?= Date: Tue, 18 Jun 2024 17:27:13 +0200 Subject: [PATCH 3/8] PSPAYPAL-784 fix basket not possible to checkout after paypal express come back --- CHANGELOG.md | 4 ++++ metadata.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 402ee0e9..c787007c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/metadata.php b/metadata.php index ed9253b6..4c500ad9 100644 --- a/metadata.php +++ b/metadata.php @@ -58,7 +58,7 @@ 'en' => 'Use of the online payment service from PayPal. Documentation: PayPal Checkout' ], 'thumbnail' => 'out/img/paypal.png', - 'version' => '1.3.7', + 'version' => '1.3.9', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From f90a7a845e358efcb1d23e2031d39a1e0e38b04a Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 20 Jun 2024 15:32:00 +0200 Subject: [PATCH 4/8] WIP seperate NewOrderCtrlUrl --- src/Controller/ProxyController.php | 24 +++++++++++++++++++++++- views/tpl/shared/paymentbuttons.tpl | 16 ++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/Controller/ProxyController.php b/src/Controller/ProxyController.php index 83740a41..6c08a895 100644 --- a/src/Controller/ProxyController.php +++ b/src/Controller/ProxyController.php @@ -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. @@ -150,7 +151,9 @@ public function approveOrder() PayPalSession::unsetPayPalOrderId(); Registry::getSession()->getBasket()->setPayment(null); } - $response->sessionId = Registry::getSession()->getId(); + + //$response->newUrl = $this->getNewOrderCtrlUrl(); + //$response->sessionId = Registry::getSession()->getId(); $this->outputJson($response); } @@ -278,4 +281,23 @@ protected function getRequestedPayPalPaymentId($defaultPayPalPaymentId = PayPalD $paymentId : $defaultPayPalPaymentId; } + + /* + * build a new order-controller-Link if session id is changed + */ + protected function getNewOrderCtrlUrl(): string + { + $sNewOrderUrl = Registry::getConfig()->getShopSecureHomeURL() . 'cl=order'; + $sNewOrderUrl = Registry::getUtilsUrl()->cleanUrl( + $sNewOrderUrl, + ['force_sid'] + ); + $sNewOrderUrl .= '&force_sid=' . Registry::getSession()->getId(); + $sNewOrderUrl = str_replace( + '&', + '&', + $sNewOrderUrl + ); + return $sNewOrderUrl; + } } diff --git a/views/tpl/shared/paymentbuttons.tpl b/views/tpl/shared/paymentbuttons.tpl index bb4f840e..08f8e9da 100644 --- a/views/tpl/shared/paymentbuttons.tpl +++ b/views/tpl/shared/paymentbuttons.tpl @@ -37,11 +37,11 @@ }).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") { - if (data.sessionId) { - location.replace('/?cl=order&force_sid=' + data.sessionId); + } else if (data.id && data.status === "APPROVED") { + if (data.newUrl) { + location.replace(data.newUrl); } else { location.replace('[{$sSelfLink|cat:"cl=order"}]'); } @@ -92,11 +92,11 @@ }).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") { - if (data.sessionId) { - location.replace('/?cl=order&force_sid=' + data.sessionId); + } else if (data.id && data.status === "APPROVED") { + if (data.newUrl) { + location.replace(data.newUrl); } else { location.replace('[{$sSelfLink|cat:"cl=order"}]'); } From 32471dc4e6c936280756dfe93acf18f67bcbdf9e Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 21 Jun 2024 09:36:37 +0200 Subject: [PATCH 5/8] revert Basket-Move --- src/Controller/ProxyController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/ProxyController.php b/src/Controller/ProxyController.php index 6c08a895..ad711c38 100644 --- a/src/Controller/ProxyController.php +++ b/src/Controller/ProxyController.php @@ -101,7 +101,7 @@ public function approveOrder() $userRepository = $this->getServiceFromContainer(UserRepository::class); $paypalEmail = (string) $response->payer->email_address; - $basket = Registry::getSession()->getBasket(); + //$basket = Registry::getSession()->getBasket(); $nonGuestAccountDetected = false; if ($userRepository->userAccountExists($paypalEmail)) { @@ -114,7 +114,7 @@ public function approveOrder() $userComponent->createPayPalGuestUser($response); } - Registry::getSession()->setBasket($basket); + //Registry::getSession()->setBasket($basket); } if ($user = $this->getUser()) { From 8fef62e68762aa1df91e3064bd9e2d0ba66641ab Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 21 Jun 2024 09:37:43 +0200 Subject: [PATCH 6/8] revert all uneccessay stuff --- src/Controller/ProxyController.php | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/Controller/ProxyController.php b/src/Controller/ProxyController.php index ad711c38..78d88686 100644 --- a/src/Controller/ProxyController.php +++ b/src/Controller/ProxyController.php @@ -101,8 +101,6 @@ public function approveOrder() $userRepository = $this->getServiceFromContainer(UserRepository::class); $paypalEmail = (string) $response->payer->email_address; - //$basket = Registry::getSession()->getBasket(); - $nonGuestAccountDetected = false; if ($userRepository->userAccountExists($paypalEmail)) { //got a non-guest account, so either we log in or redirect customer to login step @@ -113,8 +111,6 @@ public function approveOrder() $userComponent = oxNew(UserComponent::class); $userComponent->createPayPalGuestUser($response); } - - //Registry::getSession()->setBasket($basket); } if ($user = $this->getUser()) { @@ -152,8 +148,6 @@ public function approveOrder() Registry::getSession()->getBasket()->setPayment(null); } - //$response->newUrl = $this->getNewOrderCtrlUrl(); - //$response->sessionId = Registry::getSession()->getId(); $this->outputJson($response); } @@ -281,23 +275,4 @@ protected function getRequestedPayPalPaymentId($defaultPayPalPaymentId = PayPalD $paymentId : $defaultPayPalPaymentId; } - - /* - * build a new order-controller-Link if session id is changed - */ - protected function getNewOrderCtrlUrl(): string - { - $sNewOrderUrl = Registry::getConfig()->getShopSecureHomeURL() . 'cl=order'; - $sNewOrderUrl = Registry::getUtilsUrl()->cleanUrl( - $sNewOrderUrl, - ['force_sid'] - ); - $sNewOrderUrl .= '&force_sid=' . Registry::getSession()->getId(); - $sNewOrderUrl = str_replace( - '&', - '&', - $sNewOrderUrl - ); - return $sNewOrderUrl; - } } From fbc312224010bba6d049b3c86c29e506b5b10861 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 21 Jun 2024 09:37:55 +0200 Subject: [PATCH 7/8] revert all uneccessay stuff --- views/tpl/shared/paymentbuttons.tpl | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/views/tpl/shared/paymentbuttons.tpl b/views/tpl/shared/paymentbuttons.tpl index 08f8e9da..2e7b62a8 100644 --- a/views/tpl/shared/paymentbuttons.tpl +++ b/views/tpl/shared/paymentbuttons.tpl @@ -7,9 +7,9 @@ [{/if}] [{assign var="sToken" value=$oViewConf->getSessionChallengeToken()}] [{assign var="sSelfLink" value=$oViewConf->getSslSelfLink()|replace:"&":"&"}] - [{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) { @@ -40,11 +40,7 @@ if (data.status === "ERROR") { location.reload(); } else if (data.id && data.status === "APPROVED") { - if (data.newUrl) { - location.replace(data.newUrl); - } else { - location.replace('[{$sSelfLink|cat:"cl=order"}]'); - } + location.replace('[{$sSelfLink|cat:"cl=order"}]'); } }) }, @@ -95,11 +91,7 @@ if (data.status === "ERROR") { location.reload(); } else if (data.id && data.status === "APPROVED") { - if (data.newUrl) { - location.replace(data.newUrl); - } else { - location.replace('[{$sSelfLink|cat:"cl=order"}]'); - } + location.replace('[{$sSelfLink|cat:"cl=order"}]'); } }) }, From efb82d78dd99f14da28d2b866abbe3850ff73eb5 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 21 Jun 2024 09:39:17 +0200 Subject: [PATCH 8/8] change Version-Number for RC-Check --- metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.php b/metadata.php index 4c500ad9..d875fe6d 100644 --- a/metadata.php +++ b/metadata.php @@ -58,7 +58,7 @@ 'en' => 'Use of the online payment service from PayPal. Documentation: PayPal Checkout' ], 'thumbnail' => 'out/img/paypal.png', - 'version' => '1.3.9', + 'version' => '1.3.9-rc.1', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com',