Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pspaypal 840 tracking code #374

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Component/UserComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'));

Expand All @@ -59,17 +61,19 @@ 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);

if (
$loginSuccess = $user->login(
$response->payer->email_address,
'',
Registry::getConfig()->getRequestParameter('lgn_cook')
Registry::getRequest()->getRequestParameter('lgn_cook')
)
) {
$this->setLoginStatus(USER_LOGIN_SUCCESS);
Expand Down
11 changes: 7 additions & 4 deletions src/Controller/Admin/OrderMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -65,6 +65,9 @@ public function save()
parent::save();
}

/**
* @throws StandardException
*/
public function getPayPalTrackingCode(): string
{
return $this->getOrder()->getPayPalTrackingCode();
Expand Down
4 changes: 3 additions & 1 deletion src/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading