Skip to content

Commit

Permalink
Fixed payment controller access and redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ committed Oct 31, 2024
1 parent a7b2026 commit 87f1481
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions controllers/front/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Ps_CheckoutPaymentModuleFrontController extends AbstractFrontController

public function checkAccess()
{
return $this->context->customer && $this->context->customer->isLogged() && $this->context->cart;
return $this->context->customer && $this->context->cart;
}

public function initContent()
Expand Down Expand Up @@ -89,17 +89,17 @@ public function postProcess()

$payPalOrder = $payPalOrderRepository->getPayPalOrderById($this->paypalOrderId);

if ($payPalOrder->getIdCart() !== $this->context->cart->id) {
$this->redirectToOrderPage();
}

$orders = new PrestaShopCollection(Order::class);
$orders->where('id_cart', '=', $payPalOrder->getIdCart());

if ($orders->count()) {
$this->redirectToOrderHistoryPage();
}

if ($payPalOrder->getIdCart() !== $this->context->cart->id) {
$this->redirectToOrderPage();
}

/** @var GetPayPalOrderForOrderConfirmationQueryResult $payPalOrderQueryResult */
$payPalOrderQueryResult = $commandBus->handle(new GetPayPalOrderForOrderConfirmationQuery($this->paypalOrderId->getValue()));
$payPalOrderFromCache = $payPalOrderQueryResult->getOrderPayPal();
Expand Down
2 changes: 1 addition & 1 deletion src/PayPal/Order/PaypalOrderDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function isTokenSaved()

public function getPaymentTokenIdentifier()
{
if ($this->payPalOrder) {
if ($this->payPalOrder && isset($this->payPalOrder->getPaymentSource()[$this->payPalOrder->getFundingSource()])) {
$paymentSource = $this->payPalOrder->getPaymentSource()[$this->payPalOrder->getFundingSource()];

if ($this->payPalOrder->getFundingSource() === 'card') {
Expand Down

0 comments on commit 87f1481

Please sign in to comment.