From d59af08df008200e8baa6c50415ddfeec8659c12 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 17 Dec 2024 20:27:54 +0100 Subject: [PATCH 1/2] add additional save --- src/Model/Order.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index 49a43025a..c9f92bcc2 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -657,12 +657,14 @@ protected function extractTransactionId(PayPalApiOrder $apiOrder): string public function setPayPalTracking(string $trackingCarrier, string $trackingCode): void { - // for backwardscompatibility + // for backwards compatibility $this->assign( [ 'oxtrackcode' => $trackingCode ] ); + $this->save(); + $payPalOrder = $this->getPayPalRepository(); $payPalOrder->setTrackingCode($trackingCode); $payPalOrder->setTrackingCarrier($trackingCarrier); From 9d6e414f5ee58721b0d0e60e47e11c4013000e5c Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 17 Dec 2024 20:28:23 +0100 Subject: [PATCH 2/2] use Request instead of Config --- src/Component/UserComponent.php | 12 ++++++++---- src/Controller/Admin/OrderMain.php | 11 +++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Component/UserComponent.php b/src/Component/UserComponent.php index be458b81b..125549e2a 100644 --- a/src/Component/UserComponent.php +++ b/src/Component/UserComponent.php @@ -7,9 +7,11 @@ namespace OxidSolutionCatalysts\PayPal\Component; +use OxidEsales\Eshop\Core\Exception\UserException; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Application\Model\User; use OxidSolutionCatalysts\PayPal\Core\Utils\PayPalAddressResponseToOxidAddress; +use OxidSolutionCatalysts\PayPalApi\Model\Orders\Order; /** * @mixin \OxidEsales\Eshop\Application\Component\UserComponent @@ -42,7 +44,7 @@ public function login_noredirect() //phpcs:ignore PSR1.Methods.CamelCapsMethodNa return $return; } - public function createPayPalGuestUser(\OxidSolutionCatalysts\PayPalApi\Model\Orders\Order $response): void + public function createPayPalGuestUser(Order $response): void { $this->setParent(oxNew('Register')); @@ -59,9 +61,11 @@ public function createPayPalGuestUser(\OxidSolutionCatalysts\PayPalApi\Model\Ord } /** - * @param \OxidSolutionCatalysts\PayPalApi\Model\Orders\Order $response + * @param Order $response + * @return bool + * @throws UserException */ - public function loginPayPalCustomer(\OxidSolutionCatalysts\PayPalApi\Model\Orders\Order $response): bool + public function loginPayPalCustomer(Order $response): bool { $user = oxNew(User::class); @@ -69,7 +73,7 @@ public function loginPayPalCustomer(\OxidSolutionCatalysts\PayPalApi\Model\Order $loginSuccess = $user->login( $response->payer->email_address, '', - Registry::getConfig()->getRequestParameter('lgn_cook') + Registry::getRequest()->getRequestParameter('lgn_cook') ) ) { $this->setLoginStatus(USER_LOGIN_SUCCESS); diff --git a/src/Controller/Admin/OrderMain.php b/src/Controller/Admin/OrderMain.php index 7c6578f8c..22a0a045b 100644 --- a/src/Controller/Admin/OrderMain.php +++ b/src/Controller/Admin/OrderMain.php @@ -49,12 +49,12 @@ protected function onOrderSend() */ public function save() { - $config = Registry::getConfig(); - if ($config->getRequestParameter("sendorder")) { + $request = Registry::getRequest(); + if ($request->getRequestParameter("sendorder")) { $this->sendOrder(); } - $trackingCarrier = $config->getRequestParameter("paypaltrackingcarrier"); - $trackingCode = $config->getRequestParameter("paypaltrackingcode"); + $trackingCarrier = $request->getRequestParameter("paypaltrackingcarrier"); + $trackingCode = $request->getRequestParameter("paypaltrackingcode"); if ($trackingCarrier && $trackingCode) { $this->getOrder()->setPayPalTracking( $trackingCarrier, @@ -65,6 +65,9 @@ public function save() parent::save(); } + /** + * @throws StandardException + */ public function getPayPalTrackingCode(): string { return $this->getOrder()->getPayPalTrackingCode();